diff --git a/tunsafe_types.h b/tunsafe_types.h index 7bdc600..d4dc203 100644 --- a/tunsafe_types.h +++ b/tunsafe_types.h @@ -7,7 +7,6 @@ #include "build_config.h" #include "tunsafe_config.h" - typedef uint8_t byte; typedef uint8_t uint8; typedef uint16_t uint16; @@ -17,8 +16,7 @@ typedef int64_t int64; typedef int8_t int8; typedef int16_t int16; typedef int32_t int32; - -typedef unsigned int in_addr_t; +typedef unsigned int uint; #define CTASTR2(pre,post) pre ## post #define CTASTR(pre,post) CTASTR2(pre,post) diff --git a/tunsafe_win32.cpp b/tunsafe_win32.cpp index 583c9ae..7d37292 100644 --- a/tunsafe_win32.cpp +++ b/tunsafe_win32.cpp @@ -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); return buf; } diff --git a/util.cpp b/util.cpp index 6921c64..11add66 100644 --- a/util.cpp +++ b/util.cpp @@ -100,8 +100,8 @@ static const unsigned char d[] = { 66,66,66,66,66,66 }; -bool base64_decode(uint8 *in, size_t inLen, uint8 *out, size_t *outLen) { - uint8 *end = in + inLen; +bool base64_decode(const uint8 *in, size_t inLen, uint8 *out, size_t *outLen) { + const uint8 *end = in + inLen; uint8 iter = 0; uint32_t buf = 0; size_t len = 0; @@ -168,10 +168,6 @@ int RunCommand(const char *fmt, ...) { tmp += buf; } else if (c == '%') { 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) { ZERO: diff --git a/util.h b/util.h index 95efef9..3d1ffd3 100644 --- a/util.h +++ b/util.h @@ -4,7 +4,7 @@ #include "tunsafe_types.h" 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); int RunCommand(const char *fmt, ...);