From 12988477f9ca9eac43763471a3df3c01823e203d Mon Sep 17 00:00:00 2001 From: Markus Grüneis Date: Sun, 30 May 2010 19:00:53 +0000 Subject: replaced own u_int types with types from stdint.h --- src/anylike.c | 4 ++-- src/datatypes.h | 13 ++----------- src/log.c | 6 +++--- src/log.h | 4 ++-- src/options.c | 10 +++++----- src/options.h | 4 ++-- src/sig_handler.c | 2 +- tools/bin2c.lua | 4 ++-- 8 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/anylike.c b/src/anylike.c index dca1c54..88edee3 100644 --- a/src/anylike.c +++ b/src/anylike.c @@ -91,8 +91,8 @@ void cleanup_crypt() #endif } -extern const u_int8_t anylike_lua_bytecode[]; -extern const u_int32_t anylike_lua_bytecode_len; +extern const uint8_t anylike_lua_bytecode[]; +extern const uint32_t anylike_lua_bytecode_len; #define LUA_MAIN_LOOP_FUNC "main_loop" diff --git a/src/datatypes.h b/src/datatypes.h index 051d62e..09ae988 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -34,18 +34,9 @@ #include -typedef uint8_t u_int8_t; -typedef uint16_t u_int16_t; -typedef uint32_t u_int32_t; -typedef uint64_t u_int64_t; -/* typedef int8_t int8_t; */ -/* typedef int16_t int16_t; */ -/* typedef int32_t int32_t; */ -/* typedef int64_t int64_t; */ - struct buffer_struct { - u_int32_t length_; - u_int8_t* buf_; + uint32_t length_; + uint8_t* buf_; }; typedef struct buffer_struct buffer_t; diff --git a/src/log.c b/src/log.c index 7031069..c52c5dc 100644 --- a/src/log.c +++ b/src/log.c @@ -234,7 +234,7 @@ void log_printf(log_prio_t prio, const char* fmt, ...) log_targets_log(&stdlog.targets_, prio, msg); } -void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len) +void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len) { if(stdlog.max_prio_ < prio) return; @@ -245,11 +245,11 @@ void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len) snprintf(msg, MSG_LENGTH_MAX, "(NULL)"); } else { - u_int32_t i; + uint32_t i; int offset = snprintf(msg, MSG_LENGTH_MAX, "dump(%d): ", len); if(offset < 0) return; - u_int8_t* ptr = &msg[offset]; + uint8_t* ptr = &msg[offset]; for(i=0; i < len; i++) { if(((i+1)*3) >= (MSG_LENGTH_MAX - offset)) diff --git a/src/log.h b/src/log.h index 0f05c08..6eef9e7 100644 --- a/src/log.h +++ b/src/log.h @@ -32,7 +32,7 @@ #ifndef UANYTUN_log_h_INCLUDED #define UANYTUN_log_h_INCLUDED -#define MSG_LENGTH_MAX 150 +#define MSG_LENGTH_MAX 1024 enum log_prio_enum { ERROR = 1, WARNING = 2, NOTICE = 3, INFO = 4, DEBUG = 5 }; @@ -85,6 +85,6 @@ void log_close(); void update_max_prio(); int log_add_target(const char* conf); void log_printf(log_prio_t prio, const char* fmt, ...); -void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len); +void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len); #endif diff --git a/src/options.c b/src/options.c index 88d359f..c595d99 100644 --- a/src/options.c +++ b/src/options.c @@ -126,7 +126,7 @@ int options_parse_hex_string(const char* hex, buffer_t* buffer) if(!hex || !buffer) return -1; - u_int32_t hex_len = strlen(hex); + uint32_t hex_len = strlen(hex); if(hex_len%2) return 1; @@ -143,9 +143,9 @@ int options_parse_hex_string(const char* hex, buffer_t* buffer) const char* ptr = hex; int i; for(i=0;ilength_;++i) { - u_int32_t tmp; + uint32_t tmp; sscanf(ptr, "%2X", &tmp); - buffer->buf_[i] = (u_int8_t)tmp; + buffer->buf_[i] = (uint8_t)tmp; ptr += 2; } @@ -235,14 +235,14 @@ void options_lua_push_string(lua_State* L, const int tidx, const char* key, cons lua_settable(L, tidx); } -void options_lua_push_int(lua_State* L, const int tidx, const char* key, const u_int32_t value) +void options_lua_push_int(lua_State* L, const int tidx, const char* key, const uint32_t value) { lua_pushstring(L, key); lua_pushinteger(L, value); lua_settable(L, tidx); } -void options_lua_push_boolean(lua_State* L, const int tidx, const char* key, const u_int32_t value) +void options_lua_push_boolean(lua_State* L, const int tidx, const char* key, const uint32_t value) { lua_pushstring(L, key); lua_pushboolean(L, value); diff --git a/src/options.h b/src/options.h index ef2daf3..70eee99 100644 --- a/src/options.h +++ b/src/options.h @@ -55,8 +55,8 @@ int options_parse(options_t* opt, int argc, char* argv[]); void options_parse_post(options_t* opt); void options_default(options_t* opt); void options_lua_push_string(lua_State* L, const int tidx, const char* key, const char* value); -void options_lua_push_int(lua_State* L, const int tidx, const char* key, const u_int32_t value); -void options_lua_push_boolean(lua_State* L, const int tidx, const char* key, const u_int32_t value); +void options_lua_push_int(lua_State* L, const int tidx, const char* key, const uint32_t value); +void options_lua_push_boolean(lua_State* L, const int tidx, const char* key, const uint32_t value); void options_lua_push_string_list(lua_State* L, const int tidx, string_list_t* lst); void options_lua_push(options_t* opt, lua_State* L); void options_clear(options_t* opt); diff --git a/src/sig_handler.c b/src/sig_handler.c index 843ab9b..91a2f13 100644 --- a/src/sig_handler.c +++ b/src/sig_handler.c @@ -169,7 +169,7 @@ static SOCKET server_sock; static DWORD WINAPI signal_connect_thread(void* p) { - u_int16_t port = *((u_int16_t*)p); + uint16_t port = *((uint16_t*)p); SOCKET client; client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); diff --git a/tools/bin2c.lua b/tools/bin2c.lua index c473832..8a61549 100644 --- a/tools/bin2c.lua +++ b/tools/bin2c.lua @@ -54,9 +54,9 @@ io.write([=[ #include "datatypes.h" -const u_int8_t ]=] , c_var_name, [=[[]={ +const uint8_t ]=] , c_var_name, [=[[]={ ]=], dump(content), [=[ }; -const u_int32_t ]=] , c_var_name, [=[_len = sizeof(]=] , c_var_name, [=[); +const uint32_t ]=] , c_var_name, [=[_len = sizeof(]=] , c_var_name, [=[); ]=]) -- cgit v1.2.3