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

@@ -45,7 +45,69 @@ struct commands_handler
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)
{
@@ -219,8 +281,8 @@ static int command_help(struct hub_info* hub, struct hub_user* user, struct hub_
{
size_t n;
char msg[MAX_HELP_MSG];
msg[0] = 0;
char* command = list_get_first(cmd->args);
msg[0] = 0;
if (!command)
{
@@ -495,11 +557,12 @@ static int command_broadcast(struct hub_info* hub, struct hub_user* user, struct
char from_sid[5];
char buffer[128];
size_t recipients = 0;
struct hub_user* target;
memcpy(from_sid, sid_to_string(user->id.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)
{
if (target != user)
@@ -835,36 +898,3 @@ int command_dipatcher(struct hub_info* hub, struct hub_user* user, const char* m
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);
int value = 0;
uint64_t size = 0;
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, "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, "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 */
value = hub_get_max_share(hub);
if (value) adc_msg_add_named_argument(info, "XS", uhub_itoa(value));
value = hub_get_min_share(hub);
if (value) adc_msg_add_named_argument(info, "MS", uhub_itoa(value));
size = hub_get_max_share(hub);
if (size) adc_msg_add_named_argument(info, "XS", uhub_ulltoa(size));
size = hub_get_min_share(hub);
if (size) adc_msg_add_named_argument(info, "MS", uhub_ulltoa(size));
/* Maximum/minimum upload slots allowed per user */
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.
*/
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);
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.
*/
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);
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);
if (arg)
{
ssize_t shared_files = atoll(arg);
int shared_files = atoi(arg);
if (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);
if (arg)
{
ssize_t num = atoll(arg);
int num = atoi(arg);
if (num < 0) num = 0;
user->limits.hub_count_user = num;
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);
if (arg)
{
ssize_t num = atoll(arg);
int num = atoi(arg);
if (num < 0) num = 0;
user->limits.hub_count_registered = num;
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);
if (arg)
{
ssize_t num = atoll(arg);
int num = atoi(arg);
if (num < 0) num = 0;
user->limits.hub_count_operator = num;
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);
if (arg)
{
ssize_t num = atoll(arg);
int num = atoi(arg);
if (num < 0) num = 0;
user->limits.upload_slots = num;
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
* 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;
}

View File

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

View File

@@ -88,7 +88,7 @@ int handle_net_read(struct hub_user* user)
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);
}

View File

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

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)
{
struct uhub_plugins* handle = (struct uhub_plugins*) ptr_data;
struct plugin_handle* plugin;
struct cfg_tokens* tokens = cfg_tokenize(line);
char *directive, *soname, *params;
@@ -148,7 +149,7 @@ static int plugin_parse_line(char* line, int line_count, void* ptr_data)
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)
{
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;
}
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:
* 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;
}
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;
}
@@ -75,7 +75,7 @@ static inline size_t get_max_send_queue_soft(struct hub_info* hub)
* -1 if send queue is overflowed
* 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))
return 1;