Remove in_addr_t type

This commit is contained in:
Ludvig Strigeus 2018-12-10 23:13:54 +01:00
parent aec9415e44
commit 583b01847d
4 changed files with 5 additions and 11 deletions

View file

@ -7,7 +7,6 @@
#include "build_config.h" #include "build_config.h"
#include "tunsafe_config.h" #include "tunsafe_config.h"
typedef uint8_t byte; typedef uint8_t byte;
typedef uint8_t uint8; typedef uint8_t uint8;
typedef uint16_t uint16; typedef uint16_t uint16;
@ -17,8 +16,7 @@ typedef int64_t int64;
typedef int8_t int8; typedef int8_t int8;
typedef int16_t int16; typedef int16_t int16;
typedef int32_t int32; typedef int32_t int32;
typedef unsigned int uint;
typedef unsigned int in_addr_t;
#define CTASTR2(pre,post) pre ## post #define CTASTR2(pre,post) pre ## post
#define CTASTR(pre,post) CTASTR2(pre,post) #define CTASTR(pre,post) CTASTR2(pre,post)

View file

@ -123,7 +123,7 @@ void StopTunsafeBackend(UpdateIconWhy why) {
} }
} }
const char *print_ip(char buf[kSizeOfAddress], in_addr_t ip) { const char *print_ip(char buf[kSizeOfAddress], uint32 ip) {
snprintf(buf, kSizeOfAddress, "%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, (ip >> 0) & 0xff); snprintf(buf, kSizeOfAddress, "%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, (ip >> 0) & 0xff);
return buf; return buf;
} }

View file

@ -100,8 +100,8 @@ static const unsigned char d[] = {
66,66,66,66,66,66 66,66,66,66,66,66
}; };
bool base64_decode(uint8 *in, size_t inLen, uint8 *out, size_t *outLen) { bool base64_decode(const uint8 *in, size_t inLen, uint8 *out, size_t *outLen) {
uint8 *end = in + inLen; const uint8 *end = in + inLen;
uint8 iter = 0; uint8 iter = 0;
uint32_t buf = 0; uint32_t buf = 0;
size_t len = 0; size_t len = 0;
@ -168,10 +168,6 @@ int RunCommand(const char *fmt, ...) {
tmp += buf; tmp += buf;
} else if (c == '%') { } else if (c == '%') {
tmp += '%'; tmp += '%';
} else if (c == 'A') {
struct in_addr in;
in.s_addr = htonl(va_arg(va, in_addr_t));
tmp += inet_ntoa(in);
} }
} else if (c == ' ' || c == 0) { } else if (c == ' ' || c == 0) {
ZERO: ZERO:

2
util.h
View file

@ -4,7 +4,7 @@
#include "tunsafe_types.h" #include "tunsafe_types.h"
char *base64_encode(const uint8 *input, size_t length, char *output, size_t output_size, size_t *actual_size); char *base64_encode(const uint8 *input, size_t length, char *output, size_t output_size, size_t *actual_size);
bool base64_decode(uint8 *in, size_t inLen, uint8 *out, size_t *outLen); bool base64_decode(const uint8 *in, size_t inLen, uint8 *out, size_t *outLen);
bool IsOnlyZeros(const uint8 *data, size_t data_size); bool IsOnlyZeros(const uint8 *data, size_t data_size);
int RunCommand(const char *fmt, ...); int RunCommand(const char *fmt, ...);