Many Visual C++ compile warnings and errors fixed.

This commit is contained in:
Jan Vidar Krey 2011-01-02 02:39:25 +01:00
parent adb6641a17
commit 9b57279628
20 changed files with 163 additions and 115 deletions

View File

@ -600,7 +600,7 @@ int adc_msg_has_named_argument(struct adc_message* cmd, const char prefix_[2])
while (start) while (start)
{ {
count++; count++;
if ((&start[0] - &cmd->cache[0]) < 1+cmd->length) if ((size_t) (&start[0] - &cmd->cache[0]) < 1+cmd->length)
start = memmem(&start[1], (&cmd->cache[cmd->length] - &start[0]), prefix, 3); start = memmem(&start[1], (&cmd->cache[cmd->length] - &start[0]), prefix, 3);
else else
start = NULL; start = NULL;
@ -881,8 +881,8 @@ char* adc_msg_unescape(const char* string)
char* adc_msg_escape(const char* string) char* adc_msg_escape(const char* string)
{ {
char* str = hub_malloc(adc_msg_escape_length(string)+1); char* str = hub_malloc(adc_msg_escape_length(string)+1);
int n = 0; size_t n = 0;
int i = 0; size_t i = 0;
for (i = 0; i < strlen(string); i++) for (i = 0; i < strlen(string); i++)
{ {
switch (string[i]) { switch (string[i]) {

View File

@ -119,6 +119,8 @@ void sid_pool_destroy(struct sid_pool* pool)
sid_t sid_alloc(struct sid_pool* pool, struct hub_user* user) sid_t sid_alloc(struct sid_pool* pool, struct hub_user* user)
{ {
sid_t n;
if (pool->count >= (pool->max - pool->min)) if (pool->count >= (pool->max - pool->min))
{ {
#ifdef DEBUG_SID #ifdef DEBUG_SID
@ -127,7 +129,8 @@ sid_t sid_alloc(struct sid_pool* pool, struct hub_user* user)
return 0; return 0;
} }
sid_t n = (++pool->count); n = ++pool->count;
for (; (pool->map[n % pool->max]); n++) ; for (; (pool->map[n % pool->max]); n++) ;
#ifdef DEBUG_SID #ifdef DEBUG_SID

View File

@ -45,7 +45,69 @@ struct commands_handler
const char* description; const char* description;
}; };
static struct commands_handler command_handlers[]; #define FORWARD_DECL_CMD(X) static int X(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
FORWARD_DECL_CMD(command_ban);
FORWARD_DECL_CMD(command_broadcast);
FORWARD_DECL_CMD(command_crash);
FORWARD_DECL_CMD(command_getip);
FORWARD_DECL_CMD(command_help);
FORWARD_DECL_CMD(command_history);
FORWARD_DECL_CMD(command_kick);
FORWARD_DECL_CMD(command_log);
FORWARD_DECL_CMD(command_motd);
FORWARD_DECL_CMD(command_mute);
FORWARD_DECL_CMD(command_myip);
FORWARD_DECL_CMD(command_register);
FORWARD_DECL_CMD(command_reload);
FORWARD_DECL_CMD(command_rules);
FORWARD_DECL_CMD(command_password);
FORWARD_DECL_CMD(command_shutdown);
FORWARD_DECL_CMD(command_stats);
FORWARD_DECL_CMD(command_unban);
FORWARD_DECL_CMD(command_uptime);
FORWARD_DECL_CMD(command_useradd);
FORWARD_DECL_CMD(command_userdel);
FORWARD_DECL_CMD(command_userinfo);
FORWARD_DECL_CMD(command_usermod);
FORWARD_DECL_CMD(command_userpass);
FORWARD_DECL_CMD(command_version);
FORWARD_DECL_CMD(command_whoip);
#undef FORWARD_DECL_CMD
static struct commands_handler command_handlers[] = {
{ "ban", 3, "n", auth_cred_operator, command_ban, "Ban a user" },
{ "broadcast", 9, "m", auth_cred_operator, command_broadcast,"Send a message to all users" },
#ifdef CRASH_DEBUG
{ "crash", 5, 0, auth_cred_admin, command_crash, "Crash the hub (DEBUG)." },
#endif
{ "getip", 5, "n", auth_cred_operator, command_getip, "Show IP address for a user" },
{ "help", 4, "?c",auth_cred_guest, command_help, "Show this help message." },
{ "history", 7, "?N",auth_cred_guest, command_history, "Show the last chat messages." },
{ "kick", 4, "n", auth_cred_operator, command_kick, "Kick a user" },
{ "log", 3, 0, auth_cred_operator, command_log, "Display log" },
{ "motd", 4, 0, auth_cred_guest, command_motd, "Show the message of the day" },
{ "mute", 4, "n", auth_cred_operator, command_mute, "Mute user" },
{ "myip", 4, 0, auth_cred_guest, command_myip, "Show your own IP." },
{ "register", 8, "p", auth_cred_guest, command_register, "Register your username." },
{ "reload", 6, 0, auth_cred_admin, command_reload, "Reload configuration files." },
{ "rules", 5, 0, auth_cred_guest, command_rules, "Show the hub rules" },
{ "password", 8, "p", auth_cred_user, command_password, "Change your own password." },
{ "shutdown", 8, 0, auth_cred_admin, command_shutdown, "Shutdown hub." },
{ "stats", 5, 0, auth_cred_super, command_stats, "Show hub statistics." },
{ "unban", 5, "n", auth_cred_operator, command_unban, "Lift ban on a user" },
{ "unmute", 6, "n", auth_cred_operator, command_mute, "Unmute user" },
{ "uptime", 6, 0, auth_cred_guest, command_uptime, "Display hub uptime info." },
{ "useradd", 7, "np",auth_cred_operator, command_useradd, "Register a new user." },
{ "userdel", 7, "n", auth_cred_operator, command_userdel, "Delete a registered user." },
{ "userinfo", 8, "n", auth_cred_operator, command_userinfo, "Show registered user info." },
{ "usermod", 7, "nC",auth_cred_admin, command_usermod, "Modify user credentials." },
{ "userpass", 8, "np",auth_cred_operator, command_userpass, "Change password for a user." },
{ "version", 7, 0, auth_cred_guest, command_version, "Show hub version info." },
{ "whoip", 5, "a", auth_cred_operator, command_whoip, "Show users matching IP range" },
{ 0, 0, 0, auth_cred_none, command_help, "" }
};
static void command_destroy(struct hub_command* cmd) static void command_destroy(struct hub_command* cmd)
{ {
@ -219,8 +281,8 @@ static int command_help(struct hub_info* hub, struct hub_user* user, struct hub_
{ {
size_t n; size_t n;
char msg[MAX_HELP_MSG]; char msg[MAX_HELP_MSG];
msg[0] = 0;
char* command = list_get_first(cmd->args); char* command = list_get_first(cmd->args);
msg[0] = 0;
if (!command) if (!command)
{ {
@ -495,11 +557,12 @@ static int command_broadcast(struct hub_info* hub, struct hub_user* user, struct
char from_sid[5]; char from_sid[5];
char buffer[128]; char buffer[128];
size_t recipients = 0; size_t recipients = 0;
struct hub_user* target;
memcpy(from_sid, sid_to_string(user->id.sid), sizeof(from_sid)); memcpy(from_sid, sid_to_string(user->id.sid), sizeof(from_sid));
memcpy(pm_flag + 2, from_sid, sizeof(from_sid)); memcpy(pm_flag + 2, from_sid, sizeof(from_sid));
struct hub_user* target = (struct hub_user*) list_get_first(hub->users->list); target = (struct hub_user*) list_get_first(hub->users->list);
while (target) while (target)
{ {
if (target != user) if (target != user)
@ -835,36 +898,3 @@ int command_dipatcher(struct hub_info* hub, struct hub_user* user, const char* m
return 0; return 0;
} }
static struct commands_handler command_handlers[] = {
{ "ban", 3, "n", auth_cred_operator, command_ban, "Ban a user" },
{ "broadcast", 9, "m", auth_cred_operator, command_broadcast,"Send a message to all users" },
#ifdef CRASH_DEBUG
{ "crash", 5, 0, auth_cred_admin, command_crash, "Crash the hub (DEBUG)." },
#endif
{ "getip", 5, "n", auth_cred_operator, command_getip, "Show IP address for a user" },
{ "help", 4, "?c",auth_cred_guest, command_help, "Show this help message." },
{ "history", 7, "?N",auth_cred_guest, command_history, "Show the last chat messages." },
{ "kick", 4, "n", auth_cred_operator, command_kick, "Kick a user" },
{ "log", 3, 0, auth_cred_operator, command_log, "Display log" },
{ "motd", 4, 0, auth_cred_guest, command_motd, "Show the message of the day" },
{ "mute", 4, "n", auth_cred_operator, command_mute, "Mute user" },
{ "myip", 4, 0, auth_cred_guest, command_myip, "Show your own IP." },
{ "register", 8, "p", auth_cred_guest, command_register, "Register your username." },
{ "reload", 6, 0, auth_cred_admin, command_reload, "Reload configuration files." },
{ "rules", 5, 0, auth_cred_guest, command_rules, "Show the hub rules" },
{ "password", 8, "p", auth_cred_user, command_password, "Change your own password." },
{ "shutdown", 8, 0, auth_cred_admin, command_shutdown, "Shutdown hub." },
{ "stats", 5, 0, auth_cred_super, command_stats, "Show hub statistics." },
{ "unban", 5, "n", auth_cred_operator, command_unban, "Lift ban on a user" },
{ "unmute", 6, "n", auth_cred_operator, command_mute, "Unmute user" },
{ "uptime", 6, 0, auth_cred_guest, command_uptime, "Display hub uptime info." },
{ "useradd", 7, "np",auth_cred_operator, command_useradd, "Register a new user." },
{ "userdel", 7, "n", auth_cred_operator, command_userdel, "Delete a registered user." },
{ "userinfo", 8, "n", auth_cred_operator, command_userinfo, "Show registered user info." },
{ "usermod", 7, "nC",auth_cred_admin, command_usermod, "Modify user credentials." },
{ "userpass", 8, "np",auth_cred_operator, command_userpass, "Change password for a user." },
{ "version", 7, 0, auth_cred_guest, command_version, "Show hub version info." },
{ "whoip", 5, "a", auth_cred_operator, command_whoip, "Show users matching IP range" },
{ 0, 0, 0, auth_cred_none, command_help, "" }
};

View File

@ -396,6 +396,7 @@ void hub_send_hubinfo(struct hub_info* hub, struct hub_user* u)
{ {
struct adc_message* info = adc_msg_copy(hub->command_info); struct adc_message* info = adc_msg_copy(hub->command_info);
int value = 0; int value = 0;
uint64_t size = 0;
if (user_flag_get(u, feature_ping)) if (user_flag_get(u, feature_ping))
{ {
@ -409,13 +410,13 @@ void hub_send_hubinfo(struct hub_info* hub, struct hub_user* u)
adc_msg_add_named_argument(info, "UC", uhub_itoa(hub_get_user_count(hub))); adc_msg_add_named_argument(info, "UC", uhub_itoa(hub_get_user_count(hub)));
adc_msg_add_named_argument(info, "MC", uhub_itoa(hub_get_max_user_count(hub))); adc_msg_add_named_argument(info, "MC", uhub_itoa(hub_get_max_user_count(hub)));
adc_msg_add_named_argument(info, "SS", uhub_ulltoa(hub_get_shared_size(hub))); adc_msg_add_named_argument(info, "SS", uhub_ulltoa(hub_get_shared_size(hub)));
adc_msg_add_named_argument(info, "SF", uhub_itoa(hub_get_shared_files(hub))); adc_msg_add_named_argument(info, "SF", uhub_ulltoa(hub_get_shared_files(hub)));
/* Maximum/minimum share size */ /* Maximum/minimum share size */
value = hub_get_max_share(hub); size = hub_get_max_share(hub);
if (value) adc_msg_add_named_argument(info, "XS", uhub_itoa(value)); if (size) adc_msg_add_named_argument(info, "XS", uhub_ulltoa(size));
value = hub_get_min_share(hub); size = hub_get_min_share(hub);
if (value) adc_msg_add_named_argument(info, "MS", uhub_itoa(value)); if (size) adc_msg_add_named_argument(info, "MS", uhub_ulltoa(size));
/* Maximum/minimum upload slots allowed per user */ /* Maximum/minimum upload slots allowed per user */
value = hub_get_max_slots(hub); value = hub_get_max_slots(hub);
@ -972,7 +973,7 @@ void hub_free_variables(struct hub_info* hub)
/** /**
* @return 1 if nickname is in use, or 0 if not used. * @return 1 if nickname is in use, or 0 if not used.
*/ */
static inline int is_nick_in_use(struct hub_info* hub, const char* nick) static int is_nick_in_use(struct hub_info* hub, const char* nick)
{ {
struct hub_user* lookup = uman_get_user_by_nick(hub, nick); struct hub_user* lookup = uman_get_user_by_nick(hub, nick);
if (lookup) if (lookup)
@ -986,7 +987,7 @@ static inline int is_nick_in_use(struct hub_info* hub, const char* nick)
/** /**
* @return 1 if CID is in use, or 0 if not used. * @return 1 if CID is in use, or 0 if not used.
*/ */
static inline int is_cid_in_use(struct hub_info* hub, const char* cid) static int is_cid_in_use(struct hub_info* hub, const char* cid)
{ {
struct hub_user* lookup = uman_get_user_by_cid(hub, cid); struct hub_user* lookup = uman_get_user_by_cid(hub, cid);
if (lookup) if (lookup)

View File

@ -429,7 +429,7 @@ static int check_limits(struct hub_info* hub, struct hub_user* user, struct adc_
arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_SHARED_FILES); arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_SHARED_FILES);
if (arg) if (arg)
{ {
ssize_t shared_files = atoll(arg); int shared_files = atoi(arg);
if (shared_files < 0) if (shared_files < 0)
shared_files = 0; shared_files = 0;
@ -446,7 +446,7 @@ static int check_limits(struct hub_info* hub, struct hub_user* user, struct adc_
arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_NORMAL); arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_NORMAL);
if (arg) if (arg)
{ {
ssize_t num = atoll(arg); int num = atoi(arg);
if (num < 0) num = 0; if (num < 0) num = 0;
user->limits.hub_count_user = num; user->limits.hub_count_user = num;
hub_free(arg); hub_free(arg);
@ -456,7 +456,7 @@ static int check_limits(struct hub_info* hub, struct hub_user* user, struct adc_
arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_REGISTER); arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_REGISTER);
if (arg) if (arg)
{ {
ssize_t num = atoll(arg); int num = atoi(arg);
if (num < 0) num = 0; if (num < 0) num = 0;
user->limits.hub_count_registered = num; user->limits.hub_count_registered = num;
hub_free(arg); hub_free(arg);
@ -466,7 +466,7 @@ static int check_limits(struct hub_info* hub, struct hub_user* user, struct adc_
arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_OPERATOR); arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_OPERATOR);
if (arg) if (arg)
{ {
ssize_t num = atoll(arg); int num = atoi(arg);
if (num < 0) num = 0; if (num < 0) num = 0;
user->limits.hub_count_operator = num; user->limits.hub_count_operator = num;
hub_free(arg); hub_free(arg);
@ -476,7 +476,7 @@ static int check_limits(struct hub_info* hub, struct hub_user* user, struct adc_
arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_UPLOAD_SLOTS); arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_UPLOAD_SLOTS);
if (arg) if (arg)
{ {
ssize_t num = atoll(arg); int num = atoi(arg);
if (num < 0) num = 0; if (num < 0) num = 0;
user->limits.upload_slots = num; user->limits.upload_slots = num;
hub_free(arg); hub_free(arg);
@ -591,7 +591,7 @@ static int check_is_hub_full(struct hub_info* hub, struct hub_user* user)
* If hub is full, don't let users in, but we still want to allow * If hub is full, don't let users in, but we still want to allow
* operators and admins to enter the hub. * operators and admins to enter the hub.
*/ */
if (hub->config->max_users && hub->users->count >= hub->config->max_users && !user_is_protected(user)) if (hub->config->max_users && hub->users->count >= (size_t) hub->config->max_users && !user_is_protected(user))
{ {
return 1; return 1;
} }

View File

@ -231,6 +231,7 @@ void print_usage(char* program)
void parse_command_line(int argc, char** argv) void parse_command_line(int argc, char** argv)
{ {
#ifdef HAVE_GETOPT
int opt; int opt;
while ((opt = getopt(argc, argv, "vqfc:l:hu:g:VCsSLp:")) != -1) while ((opt = getopt(argc, argv, "vqfc:l:hu:g:VCsSLp:")) != -1)
{ {
@ -301,6 +302,7 @@ void parse_command_line(int argc, char** argv)
break; break;
} }
} }
#endif /* HAVE_GETOPT */
if (arg_config == NULL) if (arg_config == NULL)
{ {

View File

@ -88,7 +88,7 @@ int handle_net_read(struct hub_user* user)
if (lastPos || remaining) if (lastPos || remaining)
{ {
if (remaining < g_hub->config->max_recv_buffer) if (remaining < (size_t) g_hub->config->max_recv_buffer)
{ {
hub_recvq_set(q, lastPos ? lastPos : buf, remaining); hub_recvq_set(q, lastPos ? lastPos : buf, remaining);
} }

View File

@ -37,31 +37,37 @@
} }
#define PLUGIN_INVOKE_STATUS_1(HUB, FUNCNAME, ARG1) \ #define PLUGIN_INVOKE_STATUS_1(HUB, FUNCNAME, ARG1) \
do { \
plugin_st status = st_default; \ plugin_st status = st_default; \
INVOKE(HUB, FUNCNAME, { \ INVOKE(HUB, FUNCNAME, { \
status = plugin->funcs.FUNCNAME(plugin, ARG1); \ status = plugin->funcs.FUNCNAME(plugin, ARG1); \
if (status != st_default) \ if (status != st_default) \
break; \ break; \
}); \ }); \
return status return status; \
} while(0)
#define PLUGIN_INVOKE_STATUS_2(HUB, FUNCNAME, ARG1, ARG2) \ #define PLUGIN_INVOKE_STATUS_2(HUB, FUNCNAME, ARG1, ARG2) \
do { \
plugin_st status = st_default; \ plugin_st status = st_default; \
INVOKE(HUB, FUNCNAME, { \ INVOKE(HUB, FUNCNAME, { \
status = plugin->funcs.FUNCNAME(plugin, ARG1, ARG2); \ status = plugin->funcs.FUNCNAME(plugin, ARG1, ARG2); \
if (status != st_default) \ if (status != st_default) \
break; \ break; \
}); \ }); \
return status return status; \
} while(0)
#define PLUGIN_INVOKE_STATUS_3(HUB, FUNCNAME, ARG1, ARG2, ARG3) \ #define PLUGIN_INVOKE_STATUS_3(HUB, FUNCNAME, ARG1, ARG2, ARG3) \
do { \
plugin_st status = st_default; \ plugin_st status = st_default; \
INVOKE(HUB, FUNCNAME, { \ INVOKE(HUB, FUNCNAME, { \
status = plugin->funcs.FUNCNAME(plugin, ARG1, ARG2, ARG3); \ status = plugin->funcs.FUNCNAME(plugin, ARG1, ARG2, ARG3); \
if (status != st_default) \ if (status != st_default) \
break; \ break; \
}); \ }); \
return status return status; \
} while(0)
#define PLUGIN_INVOKE_1(HUB, FUNCNAME, ARG1) INVOKE(HUB, FUNCNAME, { plugin->funcs.FUNCNAME(plugin, ARG1); }) #define PLUGIN_INVOKE_1(HUB, FUNCNAME, ARG1) INVOKE(HUB, FUNCNAME, { plugin->funcs.FUNCNAME(plugin, ARG1); })
#define PLUGIN_INVOKE_2(HUB, FUNCNAME, ARG1, ARG2) INVOKE(HUB, FUNCNAME, { plugin->funcs.FUNCNAME(plugin, ARG1, ARG2); }) #define PLUGIN_INVOKE_2(HUB, FUNCNAME, ARG1, ARG2) INVOKE(HUB, FUNCNAME, { plugin->funcs.FUNCNAME(plugin, ARG1, ARG2); })

View File

@ -123,6 +123,7 @@ void plugin_unload(struct plugin_handle* plugin)
static int plugin_parse_line(char* line, int line_count, void* ptr_data) static int plugin_parse_line(char* line, int line_count, void* ptr_data)
{ {
struct uhub_plugins* handle = (struct uhub_plugins*) ptr_data; struct uhub_plugins* handle = (struct uhub_plugins*) ptr_data;
struct plugin_handle* plugin;
struct cfg_tokens* tokens = cfg_tokenize(line); struct cfg_tokens* tokens = cfg_tokenize(line);
char *directive, *soname, *params; char *directive, *soname, *params;
@ -148,7 +149,7 @@ static int plugin_parse_line(char* line, int line_count, void* ptr_data)
params = ""; params = "";
LOG_TRACE("Load plugin: \"%s\", params=\"%s\"", soname, params); LOG_TRACE("Load plugin: \"%s\", params=\"%s\"", soname, params);
struct plugin_handle* plugin = plugin_load(soname, params); plugin = plugin_load(soname, params);
if (plugin) if (plugin)
{ {
list_append(handle->loaded, plugin); list_append(handle->loaded, plugin);

View File

@ -57,7 +57,7 @@ int route_message(struct hub_info* hub, struct hub_user* u, struct adc_message*
return 0; return 0;
} }
static inline size_t get_max_send_queue(struct hub_info* hub) static size_t get_max_send_queue(struct hub_info* hub)
{ {
/* TODO: More dynamic send queue limit, for instance: /* TODO: More dynamic send queue limit, for instance:
* return MAX(hub->config->max_send_buffer, (hub->config->max_recv_buffer * hub_get_user_count(hub))); * return MAX(hub->config->max_send_buffer, (hub->config->max_recv_buffer * hub_get_user_count(hub)));
@ -65,7 +65,7 @@ static inline size_t get_max_send_queue(struct hub_info* hub)
return hub->config->max_send_buffer; return hub->config->max_send_buffer;
} }
static inline size_t get_max_send_queue_soft(struct hub_info* hub) static size_t get_max_send_queue_soft(struct hub_info* hub)
{ {
return hub->config->max_send_buffer_soft; return hub->config->max_send_buffer_soft;
} }
@ -75,7 +75,7 @@ static inline size_t get_max_send_queue_soft(struct hub_info* hub)
* -1 if send queue is overflowed * -1 if send queue is overflowed
* 0 if soft send queue is overflowed (not implemented at the moment) * 0 if soft send queue is overflowed (not implemented at the moment)
*/ */
static inline int check_send_queue(struct hub_info* hub, struct hub_user* user, struct adc_message* msg) static int check_send_queue(struct hub_info* hub, struct hub_user* user, struct adc_message* msg)
{ {
if (user_flag_get(user, flag_user_list)) if (user_flag_get(user, flag_user_list))
return 1; return 1;

View File

@ -38,7 +38,7 @@ typedef void (*net_con_backend_init)(struct net_backend*, struct net_connection*
typedef void (*net_con_backend_add)(struct net_backend*, struct net_connection*, int mask); typedef void (*net_con_backend_add)(struct net_backend*, struct net_connection*, int mask);
typedef void (*net_con_backend_mod)(struct net_backend*, struct net_connection*, int mask); typedef void (*net_con_backend_mod)(struct net_backend*, struct net_connection*, int mask);
typedef void (*net_con_backend_del)(struct net_backend*,struct net_connection*); typedef void (*net_con_backend_del)(struct net_backend*,struct net_connection*);
typedef const char* (*net_con_backend_name)(void); typedef const char* (*net_con_backend_name)();
struct net_backend_handler struct net_backend_handler
{ {

View File

@ -34,12 +34,14 @@ static struct net_statistics stats_total;
int net_initialize() int net_initialize()
{ {
#ifdef WINSOCK
struct WSAData wsa;
#endif
if (!net_initialized) if (!net_initialized)
{ {
LOG_TRACE("Initializing network monitor."); LOG_TRACE("Initializing network monitor.");
#ifdef WINSOCK #ifdef WINSOCK
struct WSAData wsa;
if (WSAStartup(MAKEWORD(2, 2), &wsa) != NO_ERROR) if (WSAStartup(MAKEWORD(2, 2), &wsa) != NO_ERROR)
{ {
LOG_ERROR("Unable to initialize winsock."); LOG_ERROR("Unable to initialize winsock.");
@ -528,7 +530,7 @@ const char* net_address_to_string(int af, const void* src, char* dst, socklen_t
return NULL; return NULL;
} }
if (WSAAddressToString(addr, size, NULL, dst, &len) == 0) if (WSAAddressToStringA(addr, size, NULL, dst, &len) == 0)
{ {
return dst; return dst;
} }

View File

@ -255,7 +255,7 @@ extern int net_stats_timeout();
extern void net_stats_get(struct net_statistics** intermediate, struct net_statistics** total); extern void net_stats_get(struct net_statistics** intermediate, struct net_statistics** total);
#if defined(WINSOCK) && !defined(__CYGWIN__) #if defined(WINSOCK) && !defined(__CYGWIN__) && !defined(_MSC_VER)
#define EWOULDBLOCK WSAEWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS #define EINPROGRESS WSAEINPROGRESS

View File

@ -48,7 +48,8 @@ const char* net_backend_name_select()
int net_backend_poll_select(struct net_backend* data, int ms) int net_backend_poll_select(struct net_backend* data, int ms)
{ {
int found, res, n; int res;
size_t n, found;
struct timeval tval; struct timeval tval;
struct net_backend_select* backend = (struct net_backend_select*) data; struct net_backend_select* backend = (struct net_backend_select*) data;

View File

@ -54,7 +54,7 @@ void timeout_queue_shutdown(struct timeout_queue* t)
size_t timeout_queue_process(struct timeout_queue* t, time_t now) size_t timeout_queue_process(struct timeout_queue* t, time_t now)
{ {
size_t pos = t->last; size_t pos = (size_t) t->last;
size_t events = 0; size_t events = 0;
struct timeout_evt* evt = 0; struct timeout_evt* evt = 0;
t->last = now; t->last = now;

View File

@ -22,24 +22,6 @@
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#if USE_REGPARM && __GNUC__ >= 3
#define REGPRM1 __attribute__((regparm(1)))
#define REGPRM2 __attribute__((regparm(2)))
#define REGPRM3 __attribute__((regparm(3)))
#else
#define REGPRM1
#define REGPRM2
#define REGPRM3
#endif
#ifndef FORCEINLINE
#if __GNUC__ < 3
#define FORCEINLINE inline
#else
#define FORCEINLINE inline __attribute__((always_inline))
#endif
#endif
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
@ -48,7 +30,7 @@
#define BSD_LIKE #define BSD_LIKE
#endif #endif
#if defined(__CYGWIN__) || defined(__MINGW32__) #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER)
#ifndef WINSOCK #ifndef WINSOCK
#define WINSOCK #define WINSOCK
#endif #endif
@ -72,7 +54,6 @@
#include <fcntl.h> #include <fcntl.h>
#ifndef __sun__ #ifndef __sun__
#include <getopt.h>
#include <stdint.h> #include <stdint.h>
#endif #endif
@ -82,14 +63,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#if !defined(WIN32) #if !defined(WIN32)
#include <unistd.h>
#include <grp.h> #include <grp.h>
#include <pwd.h> #include <pwd.h>
#include <sys/resource.h> #include <sys/resource.h>
#define HAVE_STRNDUP #define HAVE_STRNDUP
#define HAVE_DLOPEN #define HAVE_DLOPEN
#define HAVE_GETOPT
#define HAVE_SSIZE_T
#include <dlfcn.h> #include <dlfcn.h>
#ifndef __HAIKU__ #ifndef __HAIKU__
#define HAVE_MEMMEM #define HAVE_MEMMEM
@ -134,6 +117,9 @@
#undef HAVE_MEMMEM #undef HAVE_MEMMEM
#endif #endif
#ifdef HAVE_GETOPT
#include <getopt.h>
#endif
/* /*
* Detect operating system info. * Detect operating system info.
@ -243,4 +229,23 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif #endif
#ifndef HAVE_SSIZE_T
typedef int ssize_t;
#define HAVE_SSIZE_T
#endif
#ifdef _MSC_VER
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif
#ifdef _MSC_VER
#define strdup _strdup
#define snprintf _snprintf
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define atoll _atoi64
#endif
#endif /* HAVE_UHUB_SYSTEM_H */ #endif /* HAVE_UHUB_SYSTEM_H */

View File

@ -25,6 +25,8 @@
/* #define MEMORY_DEBUG */ /* #define MEMORY_DEBUG */
/* #define DEBUG_SENDQ 1 */ /* #define DEBUG_SENDQ 1 */
#define PLUGIN_SUPPORT
#include "system.h" #include "system.h"
#ifndef WIN32 #ifndef WIN32

View File

@ -29,15 +29,15 @@ struct cfg_tokens
struct cfg_tokens* cfg_tokenize(const char* line) struct cfg_tokens* cfg_tokenize(const char* line)
{ {
struct cfg_tokens* tokens = hub_malloc_zero(sizeof(struct cfg_tokens)); struct cfg_tokens* tokens = (struct cfg_tokens*) hub_malloc_zero(sizeof(struct cfg_tokens));
tokens->list = list_create(); char* buffer = (char*) hub_malloc_zero(strlen(line));
char* buffer = hub_malloc_zero(strlen(line));
char* out = buffer; char* out = buffer;
const char* p = line; const char* p = line;
int backslash = 0; int backslash = 0;
char quote = 0; char quote = 0;
size_t token_count = 0; size_t token_count = 0;
size_t token_size = 0; size_t token_size = 0;
tokens->list = list_create();
for (; *p; p++) for (; *p; p++)
{ {

View File

@ -21,7 +21,7 @@
int ip_is_valid_ipv4(const char* address) int ip_is_valid_ipv4(const char* address)
{ {
int i = 0; /* address index */ size_t i = 0; /* address index */
int o = 0; /* octet number */ int o = 0; /* octet number */
int n = 0; /* numbers after each dot */ int n = 0; /* numbers after each dot */
int d = 0; /* dots */ int d = 0; /* dots */

View File

@ -53,11 +53,6 @@ extern const char* uhub_ulltoa(uint64_t val);
extern int uhub_atoi(const char* value); extern int uhub_atoi(const char* value);
#ifdef NEED_ATOLL
extern int atoll(const char* value);
#endif
#ifndef HAVE_STRNDUP #ifndef HAVE_STRNDUP
extern char* strndup(const char* string, size_t n); extern char* strndup(const char* string, size_t n);
#endif #endif