diff --git a/src/adc/message.c b/src/adc/message.c index 56a4332..f6eed08 100644 --- a/src/adc/message.c +++ b/src/adc/message.c @@ -168,24 +168,24 @@ int adc_msg_get_arg_offset(struct adc_message* msg) { if (!msg || !msg->cache) return -1; - + switch (msg->cache[0]) { /* These *SHOULD* never be seen on a hub */ case 'U': case 'C': return 4; /* Actually: 4 + strlen(cid). */ - + case 'I': case 'H': return 4; - + case 'B': return 9; - + case 'F': return (10 + (list_size(msg->feature_cast_include)*5) + (list_size(msg->feature_cast_exclude)*5)); - + case 'D': case 'E': return 14; @@ -200,10 +200,10 @@ int adc_msg_is_empty(struct adc_message* msg) if (offset == -1) return -1; - + if ((msg->length - 1) == (size_t) offset) return 1; - + return 0; } @@ -307,17 +307,17 @@ struct adc_message* adc_msg_copy(const struct adc_message* cmd) struct adc_message* adc_msg_parse_verify(struct hub_user* u, const char* line, size_t length) { struct adc_message* command = adc_msg_parse(line, length); - + if (!command) return 0; - + if (command->source && (!u || command->source != u->id.sid)) { LOG_DEBUG("Command does not match user's SID (command->source=%d, user->id.sid=%d)", command->source, (u ? u->id.sid : 0)); adc_msg_free(command); return 0; } - + return command; } @@ -331,7 +331,7 @@ struct adc_message* adc_msg_parse(const char* line, size_t length) int ok = 1; int need_terminate = 0; struct linked_list* feature_cast_list; - + if (command == NULL) return NULL; /* OOM */ @@ -595,14 +595,14 @@ int adc_msg_remove_named_argument(struct adc_message* cmd, const char prefix_[2] int found = 0; int arg_offset = adc_msg_get_arg_offset(cmd); size_t temp_len = 0; - + adc_msg_unterminate(cmd); - + start = memmem(&cmd->cache[arg_offset], (cmd->length - arg_offset), prefix, 3); while (start) { endInfo = &cmd->cache[cmd->length]; - + if (&start[0] < &endInfo[0]) { end = memchr(&start[1], ' ', &endInfo[0]-&start[1]); @@ -611,13 +611,13 @@ int adc_msg_remove_named_argument(struct adc_message* cmd, const char prefix_[2] { end = NULL; } - + if (end) { - + temp_len = &end[0] - &start[0]; // strlen(start); endlen = strlen(end); - + memmove(start, end, endlen); start[endlen] = '\0'; found++; @@ -632,9 +632,9 @@ int adc_msg_remove_named_argument(struct adc_message* cmd, const char prefix_[2] } start = memmem(&cmd->cache[arg_offset], (cmd->length - arg_offset), prefix, 3); } - + adc_msg_terminate(cmd); - + return found; } @@ -683,7 +683,7 @@ char* adc_msg_get_named_argument(struct adc_message* cmd, const char prefix_[2]) length = &end[0] - &start[0]; argument = hub_strndup(start, length); - + if (length > 0 && argument[length-1] == '\n') { argument[length-1] = 0; diff --git a/src/adc/message.h b/src/adc/message.h index 31b4e7f..1fc8de3 100644 --- a/src/adc/message.h +++ b/src/adc/message.h @@ -229,7 +229,7 @@ void adc_msg_unterminate(struct adc_message* cmd); /** * @return the offset for the first command argument in msg->cache. * or -1 if the command is not understood. - * NOTE: for 'U' and 'C' commands (normally not seen by hubs), + * NOTE: for 'U' and 'C' commands (normally not seen by hubs), * this returns 4. Should be 4 + lengthOf(cid). */ int adc_msg_get_arg_offset(struct adc_message* msg); diff --git a/src/adc/sid.c b/src/adc/sid.c index f334516..88c74d9 100644 --- a/src/adc/sid.c +++ b/src/adc/sid.c @@ -47,7 +47,7 @@ sid_t string_to_sid(const char* sid) sid_t nsid = 0; sid_t n, x; sid_t factors[] = { 32768, 1024, 32, 1}; - + if (!sid || strlen(sid) != 4) return 0; for (n = 0; n < 4; n++) { diff --git a/src/core/auth.c b/src/core/auth.c index 305b82f..a9485f2 100644 --- a/src/core/auth.c +++ b/src/core/auth.c @@ -26,20 +26,20 @@ static int check_cmd_bool(const char* cmd, struct linked_list* list, char* line, int line_count) { char* data; - + if (!strncmp(line, cmd, strlen(cmd))) { data = &line[strlen(cmd)]; data[0] = '\0'; data++; - + data = strip_white_space(data); if (!*data) { LOG_FATAL("ACL parse error on line %d", line_count); return -1; } - + list_append(list, hub_strdup(data)); LOG_DEBUG("ACL: Deny access for: '%s' (%s)", data, cmd); return 1; @@ -190,18 +190,18 @@ int acl_initialize(struct hub_config* config, struct acl_handle* handle) { int ret; memset(handle, 0, sizeof(struct acl_handle)); - + handle->users = list_create(); handle->users_denied = list_create(); handle->users_banned = list_create(); handle->cids = list_create(); handle->networks = list_create(); handle->nat_override = list_create(); - + if (!handle->users || !handle->cids || !handle->networks || !handle->users_denied || !handle->users_banned || !handle->nat_override) { LOG_FATAL("acl_initialize: Out of memory"); - + list_destroy(handle->users); list_destroy(handle->users_denied); list_destroy(handle->users_banned); @@ -210,11 +210,11 @@ int acl_initialize(struct hub_config* config, struct acl_handle* handle) list_destroy(handle->nat_override); return -1; } - + if (config) { if (!*config->file_acl) return 0; - + ret = file_read_lines(config->file_acl, handle, &acl_parse_line); if (ret == -1) return -1; @@ -249,26 +249,26 @@ int acl_shutdown(struct acl_handle* handle) list_clear(handle->users, &acl_free_access_info); list_destroy(handle->users); } - + if (handle->users_denied) { list_clear(handle->users_denied, &hub_free); list_destroy(handle->users_denied); } - + if (handle->users_banned) { list_clear(handle->users_banned, &hub_free); list_destroy(handle->users_banned); } - - + + if (handle->cids) { list_clear(handle->cids, &hub_free); list_destroy(handle->cids); } - + if (handle->networks) { list_clear(handle->networks, &acl_free_ip_info); @@ -468,10 +468,10 @@ int acl_password_verify(struct hub_info* hub, struct hub_user* user, const char* base32_decode(challenge, (unsigned char*) raw_challenge, MAX_CID_LEN); password_len = strlen(access->password); - + memcpy(&buf[0], access->password, password_len); memcpy(&buf[password_len], raw_challenge, TIGERSIZE); - + tiger((uint64_t*) buf, TIGERSIZE+password_len, (uint64_t*) tiger_res); base32_encode((unsigned char*) tiger_res, TIGERSIZE, password_calc); password_calc[MAX_CID_LEN] = 0; diff --git a/src/core/config.c b/src/core/config.c index 21ad102..b094d74 100644 --- a/src/core/config.c +++ b/src/core/config.c @@ -76,7 +76,7 @@ static int config_parse_line(char* line, int line_count, void* ptr_data) struct hub_config* config = (struct hub_config*) ptr_data; strip_off_ini_line_comments(line, line_count); - + if (!*line) return 0; LOG_DUMP("config_parse_line(): '%s'", line); diff --git a/src/core/eventqueue.c b/src/core/eventqueue.c index d49d4f0..b5efe36 100644 --- a/src/core/eventqueue.c +++ b/src/core/eventqueue.c @@ -32,20 +32,20 @@ int event_queue_initialize(struct event_queue** queue, event_queue_callback call *queue = (struct event_queue*) hub_malloc_zero(sizeof(struct event_queue)); if (!(*queue)) return -1; - + (*queue)->q1 = list_create(); (*queue)->q2 = list_create(); - + if (!(*queue)->q1 || !(*queue)->q2) { list_destroy((*queue)->q1); list_destroy((*queue)->q2); return -1; } - + (*queue)->callback = callback; (*queue)->callback_data = ptr; - + return 0; } @@ -73,7 +73,7 @@ int event_queue_process(struct event_queue* queue) struct event_data* data; if (queue->locked) return 0; - + /* lock primary queue, and handle the primary queue messages. */ queue->locked = 1; @@ -84,10 +84,10 @@ int event_queue_process(struct event_queue* queue) #endif queue->callback(queue->callback_data, data); }); - + list_clear(queue->q1, event_queue_cleanup_callback); uhub_assert(list_size(queue->q1) == 0); - + /* unlock queue */ queue->locked = 0; @@ -106,18 +106,18 @@ void event_queue_post(struct event_queue* queue, struct event_data* message) { struct linked_list* q = (!queue->locked) ? queue->q1 : queue->q2; struct event_data* data; - + data = (struct event_data*) hub_malloc(sizeof(struct event_data)); if (data) { data->id = message->id; data->ptr = message->ptr; data->flags = message->flags; - + #ifdef EQ_DEBUG eq_debug("POST", data); #endif - + list_append(q, data); } else diff --git a/src/core/hub.h b/src/core/hub.h index cf1cd4b..0a92578 100644 --- a/src/core/hub.h +++ b/src/core/hub.h @@ -55,7 +55,7 @@ enum status_message status_msg_proto_no_common_hash = -50, /* No common hash algorithms */ status_msg_proto_obsolete_adc0 = -51, /* Client is using an obsolete protocol version */ - + }; diff --git a/src/core/inf.c b/src/core/inf.c index 704abdc..41eeff6 100644 --- a/src/core/inf.c +++ b/src/core/inf.c @@ -109,14 +109,14 @@ static int check_cid(struct hub_info* hub, struct hub_user* user, struct adc_mes hub_free(pid); return status_msg_inf_error_cid_invalid; } - + if (strlen(pid) != MAX_CID_LEN) { hub_free(cid); hub_free(pid); return status_msg_inf_error_pid_invalid; } - + for (pos = 0; pos < MAX_CID_LEN; pos++) { if (!is_valid_base32_char(cid[pos])) @@ -133,18 +133,18 @@ static int check_cid(struct hub_info* hub, struct hub_user* user, struct adc_mes return status_msg_inf_error_pid_invalid; } } - + if (!check_hash_tiger(cid, pid)) { hub_free(cid); hub_free(pid); return status_msg_inf_error_cid_invalid; } - + /* Set the cid in the user object */ memcpy(user->id.cid, cid, MAX_CID_LEN); user->id.cid[MAX_CID_LEN] = 0; - + hub_free(cid); hub_free(pid); return 0; @@ -154,7 +154,7 @@ static int check_cid(struct hub_info* hub, struct hub_user* user, struct adc_mes static int check_required_login_flags(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd) { int num = 0; - + num = adc_msg_has_named_argument(cmd, ADC_INF_FLAG_CLIENT_ID); if (num != 1) { @@ -162,7 +162,7 @@ static int check_required_login_flags(struct hub_info* hub, struct hub_user* use return status_msg_inf_error_cid_missing; return status_msg_inf_error_cid_invalid; } - + num = adc_msg_has_named_argument(cmd, ADC_INF_FLAG_PRIVATE_ID); if (num != 1) { @@ -190,7 +190,7 @@ static int check_required_login_flags(struct hub_info* hub, struct hub_user* use static int check_network(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd) { const char* address = user_get_address(user); - + /* Check for NAT override address */ if (acl_is_ip_nat_override(hub->acl, address)) { @@ -236,12 +236,12 @@ static int nick_length_ok(const char* nick) { return nick_invalid_short; } - + if (length > MAX_NICK_LEN) { return nick_invalid_long; } - + return nick_ok; } @@ -249,16 +249,16 @@ static int nick_length_ok(const char* nick) static int nick_bad_characters(const char* nick) { const char* tmp; - + /* Nick must not start with a space */ if (nick[0] == ' ') return nick_invalid_spaces; - + /* Check for ASCII values below 32 */ for (tmp = nick; *tmp; tmp++) if ((*tmp < 32) && (*tmp > 0)) return nick_invalid_bad_ascii; - + return nick_ok; } @@ -286,7 +286,7 @@ static int check_nick(struct hub_info* hub, struct hub_user* user, struct adc_me nick = adc_msg_unescape(tmp); free(tmp); tmp = 0; if (!nick) return 0; - + status = nick_length_ok(nick); if (status != nick_ok) { @@ -295,7 +295,7 @@ static int check_nick(struct hub_info* hub, struct hub_user* user, struct adc_me return status_msg_inf_error_nick_short; return status_msg_inf_error_nick_long; } - + status = nick_bad_characters(nick); if (status != nick_ok) { @@ -304,20 +304,20 @@ static int check_nick(struct hub_info* hub, struct hub_user* user, struct adc_me return status_msg_inf_error_nick_spaces; return status_msg_inf_error_nick_bad_chars; } - + status = nick_is_utf8(nick); if (status != nick_ok) { hub_free(nick); return status_msg_inf_error_nick_not_utf8; } - + if (user_is_connecting(user)) { memcpy(user->id.nick, nick, strlen(nick)); user->id.nick[strlen(nick)] = 0; } - + hub_free(nick); return 0; } @@ -327,12 +327,12 @@ static int check_logged_in(struct hub_info* hub, struct hub_user* user, struct a { struct hub_user* lookup1 = uman_get_user_by_nick(hub->users, user->id.nick); struct hub_user* lookup2 = uman_get_user_by_cid(hub->users, user->id.cid); - + if (lookup1 == user) { return 0; } - + if (lookup1 || lookup2) { if (lookup1 == lookup2) @@ -368,7 +368,7 @@ static int check_user_agent(struct hub_info* hub, struct hub_user* user, struct { char* ua_encoded = 0; char* ua = 0; - + /* Get client user agent version */ ua_encoded = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_USER_AGENT); if (ua_encoded) @@ -391,7 +391,7 @@ static int check_acl(struct hub_info* hub, struct hub_user* user, struct adc_mes { return status_msg_ban_permanently; } - + if (acl_is_user_banned(hub->acl, user->id.nick)) { return status_msg_ban_permanently; @@ -401,7 +401,7 @@ static int check_acl(struct hub_info* hub, struct hub_user* user, struct adc_mes { return status_msg_inf_error_nick_restricted; } - + return 0; } @@ -470,7 +470,7 @@ static int check_limits(struct hub_info* hub, struct hub_user* user, struct adc_ hub_free(arg); arg = 0; } - + arg = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_UPLOAD_SLOTS); if (arg) { @@ -534,7 +534,7 @@ static int set_credentials(struct hub_info* hub, struct hub_user* user, struct a { int ret = 0; struct auth_info* info = acl_get_access_info(hub, user->id.nick); - + if (info) { user->credentials = info->credentials; @@ -550,11 +550,11 @@ static int set_credentials(struct hub_info* hub, struct hub_user* user, struct a { case auth_cred_none: break; - + case auth_cred_bot: adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_BOT); break; - + case auth_cred_guest: /* Nothing to be added to the info message */ break; @@ -566,7 +566,7 @@ static int set_credentials(struct hub_info* hub, struct hub_user* user, struct a case auth_cred_operator: adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_OPERATOR); break; - + case auth_cred_super: adc_msg_add_argument(cmd, ADC_INF_FLAG_CLIENT_TYPE ADC_CLIENT_TYPE_SUPER_USER); break; @@ -578,7 +578,7 @@ static int set_credentials(struct hub_info* hub, struct hub_user* user, struct a case auth_cred_link: break; } - + return ret; } @@ -611,10 +611,10 @@ static int hub_handle_info_common(struct hub_user* user, struct adc_message* cmd { /* Remove server restricted flags */ remove_server_restricted_flags(cmd); - + /* Update/set the feature cast flags. */ set_feature_cast_supports(user, cmd); - + return 0; } @@ -635,7 +635,7 @@ static int hub_handle_info_low_bandwidth(struct hub_info* hub, struct hub_user* adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_DESCRIPTION); adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_EMAIL); } - + return 0; } @@ -680,20 +680,20 @@ int hub_handle_info_login(struct hub_info* hub, struct hub_user* user, struct ad { return status_msg_hub_full; } - + if (check_registered_users_only(hub, user)) { return status_msg_hub_registered_users_only; } - + INF_CHECK(check_limits, hub, user, cmd); - + /* strip off stuff if low_bandwidth_mode is enabled */ hub_handle_info_low_bandwidth(hub, user, cmd); - + /* Set initial user info */ user_set_info(user, cmd); - + return code; } diff --git a/src/core/ioqueue.c b/src/core/ioqueue.c index 52b5252..7362cdc 100644 --- a/src/core/ioqueue.c +++ b/src/core/ioqueue.c @@ -72,7 +72,7 @@ size_t ioq_recv_set(struct ioq_recv* q, void* buf, size_t bufsize) q->buf = 0; q->size = 0; } - + if (!bufsize) { return 0; diff --git a/src/core/main.c b/src/core/main.c index ac2d2a8..42dea69 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -87,7 +87,7 @@ void setup_signal_handlers(struct hub_info* hub) act.sa_mask = sig_set; act.sa_flags = SA_ONSTACK | SA_RESTART; act.sa_handler = hub_handle_signal; - + for (i = 0; signals[i]; i++) { if (sigaction(signals[i], &act, 0) != 0) @@ -124,7 +124,7 @@ int main_loop() hub_log_initialize(arg_log, arg_log_syslog); hub_set_log_verbosity(arg_verbose); } - + if (read_config(arg_config, &configuration, !arg_have_config) == -1) return -1; @@ -150,7 +150,7 @@ int main_loop() #if !defined(WIN32) setup_signal_handlers(hub); #ifdef SYSTEMD - /* Notify the service manager that this daemon has + /* Notify the service manager that this daemon has * been successfully initalized and shall enter the * main loop. */ @@ -174,7 +174,7 @@ int main_loop() #if !defined(WIN32) shutdown_signal_handlers(hub); #endif - + if (hub) { hub_shutdown_service(hub); @@ -288,7 +288,7 @@ void parse_command_line(int argc, char** argv) arg_dump_config = 1; arg_check_config = 1; break; - + case 'S': arg_dump_config = 2; arg_check_config = 1; @@ -297,7 +297,7 @@ void parse_command_line(int argc, char** argv) case 'l': arg_log = optarg; break; - + case 'L': arg_log_syslog = 1; break; diff --git a/src/core/plugincallback.c b/src/core/plugincallback.c index 19135d0..dca49be 100644 --- a/src/core/plugincallback.c +++ b/src/core/plugincallback.c @@ -153,7 +153,7 @@ static void cbfunc_set_hub_name(struct plugin_handle* plugin, const char* str) char* new_str = adc_msg_escape(str ? str : hub->config->hub_name); adc_msg_replace_named_argument(hub->command_info, ADC_INF_FLAG_NICK, new_str); - + // Broadcast hub name command = adc_msg_construct(ADC_CMD_IINF, (strlen(new_str) + 8)); adc_msg_add_named_argument(command, ADC_INF_FLAG_NICK, new_str); @@ -170,7 +170,7 @@ static void cbfunc_set_hub_description(struct plugin_handle* plugin, const char* char* new_str = adc_msg_escape(str ? str : hub->config->hub_description); adc_msg_replace_named_argument(hub->command_info, ADC_INF_FLAG_DESCRIPTION, new_str); - + // Broadcast hub description command = adc_msg_construct(ADC_CMD_IINF, (strlen(new_str) + 8)); adc_msg_add_named_argument(command, ADC_INF_FLAG_DESCRIPTION, new_str); diff --git a/src/core/probe.c b/src/core/probe.c index c217d34..0bdad62 100644 --- a/src/core/probe.c +++ b/src/core/probe.c @@ -73,7 +73,7 @@ static void probe_net_event(struct net_connection* con, int events, void *arg) } #ifdef SSL_SUPPORT else if (bytes >= 11 && - probe_recvbuf[0] == 22 && + probe_recvbuf[0] == 22 && probe_recvbuf[1] == 3 && /* protocol major version */ probe_recvbuf[5] == 1 && /* message type */ probe_recvbuf[9] == probe_recvbuf[1]) diff --git a/src/core/route.c b/src/core/route.c index e202f6a..75510c7 100644 --- a/src/core/route.c +++ b/src/core/route.c @@ -28,7 +28,7 @@ int route_message(struct hub_info* hub, struct hub_user* u, struct adc_message* case 'B': /* Broadcast to all logged in clients */ route_to_all(hub, msg); break; - + case 'D': target = uman_get_user_by_sid(hub->users, msg->target); if (target) @@ -36,7 +36,7 @@ int route_message(struct hub_info* hub, struct hub_user* u, struct adc_message* route_to_user(hub, target, msg); } break; - + case 'E': target = uman_get_user_by_sid(hub->users, msg->target); if (target) @@ -45,11 +45,11 @@ int route_message(struct hub_info* hub, struct hub_user* u, struct adc_message* route_to_user(hub, u, msg); } break; - + case 'F': route_to_subscribers(hub, msg); - break; - + break; + default: /* Ignore the message */ break; @@ -152,7 +152,7 @@ int route_to_subscribers(struct hub_info* hub, struct adc_message* command) /* i { int do_send; char* tmp; - + struct hub_user* user; LIST_FOREACH(struct hub_user*, user, hub->users->list, { @@ -168,10 +168,10 @@ int route_to_subscribers(struct hub_info* hub, struct adc_message* command) /* i break; } }); - + if (!do_send) continue; - + LIST_FOREACH(char*, tmp, command->feature_cast_exclude, { if (user_have_feature_cast_support(user, tmp)) @@ -180,12 +180,12 @@ int route_to_subscribers(struct hub_info* hub, struct adc_message* command) /* i break; } }); - + if (do_send) route_to_user(hub, user, command); } }); - + return 0; } @@ -200,7 +200,7 @@ int route_info_message(struct hub_info* hub, struct hub_user* u) struct adc_message* cmd = adc_msg_copy(u->info); const char* address = user_get_address(u); struct hub_user* user = 0; - + adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR); adc_msg_add_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR, address); diff --git a/src/core/user.c b/src/core/user.c index 7bddb9b..a6365f4 100644 --- a/src/core/user.c +++ b/src/core/user.c @@ -38,7 +38,7 @@ static const char* user_log_str(struct hub_user* user) struct hub_user* user_create(struct hub_info* hub, struct net_connection* con, struct ip_addr_encap* addr) { struct hub_user* user = NULL; - + LOG_TRACE("user_create(), hub=%p, con[sd=%d]", hub, net_con_get_sd(con)); user = (struct hub_user*) hub_malloc_zero(sizeof(struct hub_user)); @@ -90,7 +90,7 @@ void user_set_state(struct hub_user* user, enum user_state state) { return; } - + user->state = state; } @@ -135,7 +135,7 @@ void user_update_info(struct hub_user* u, struct adc_message* cmd) prefix[1] = argument[1]; adc_msg_replace_named_argument(cmd_new, prefix, argument+2); } - + hub_free(argument); argument = adc_msg_get_argument(cmd, n++); } diff --git a/src/core/user.h b/src/core/user.h index 4af9382..45d4caa 100644 --- a/src/core/user.h +++ b/src/core/user.h @@ -51,7 +51,7 @@ enum user_flags flag_muted = 0x00800000, /** User is muted (cannot chat) */ flag_ignore = 0x01000000, /** Ignore further reads */ flag_maxbuf = 0x02000000, /** Hit max buf read, ignore msg */ - flag_choke = 0x04000000, /** Choked: Cannot send, waiting for write event */ + flag_choke = 0x04000000, /** Choked: Cannot send, waiting for write event */ flag_want_read = 0x08000000, /** Need to read (SSL) */ flag_want_write = 0x10000000, /** Need to write (SSL) */ flag_user_list = 0x20000000, /** Send queue bypass (when receiving the send queue) */ @@ -150,7 +150,7 @@ extern void user_destroy(struct hub_user* user); * This associates a INF message to the user. * If the user already has a INF message associated, then this is * released before setting the new one. - * + * * @param info new inf message (can be NULL) */ extern void user_set_info(struct hub_user* user, struct adc_message* info); @@ -244,7 +244,7 @@ extern int user_flag_get(struct hub_user* user, enum user_flags flag); * Check if a user supports 'feature' for feature casting (basis for 'Fxxx' messages) * The feature cast is specified as the 'SU' argument to the user's * INF-message. - * + * * @param feature a feature to lookup (example: 'TCP4' or 'UDP4') * @return 1 if 'feature' supported, or 0 otherwise */ diff --git a/src/core/usermanager.h b/src/core/usermanager.h index 28d9e12..cb313b6 100644 --- a/src/core/usermanager.h +++ b/src/core/usermanager.h @@ -77,7 +77,7 @@ extern sid_t uman_get_free_sid(struct hub_user_manager* users, struct hub_user* * * NOTE: This function will only search connected users, which means * that SIDs assigned to users who are not yet completely logged in, - * or are in the process of being disconnected will result in this + * or are in the process of being disconnected will result in this * function returning NULL even though the sid is not freely available. * * FIXME: Is that really safe / sensible ? diff --git a/src/network/ipcalc.c b/src/network/ipcalc.c index 388bc52..7766f9c 100644 --- a/src/network/ipcalc.c +++ b/src/network/ipcalc.c @@ -25,10 +25,10 @@ int ip_is_valid_ipv4(const char* address) int o = 0; /* octet number */ int n = 0; /* numbers after each dot */ int d = 0; /* dots */ - + if (!address || strlen(address) > 15 || strlen(address) < 7) return 0; - + for (; i < strlen(address); i++) { if (is_num(address[i])) @@ -49,9 +49,9 @@ int ip_is_valid_ipv4(const char* address) return 0; } } - + if (n == 0 || n > 3 || o > 255 || d != 3) return 0; - + return 1; } @@ -107,9 +107,9 @@ int ip_convert_address(const char* text_address, int port, struct sockaddr* addr struct sockaddr_in addr4; size_t sockaddr_size; const char* taddr = 0; - + int ipv6sup = net_is_ipv6_supported(); - + if (strcmp(text_address, "any") == 0) { if (ipv6sup) @@ -136,8 +136,8 @@ int ip_convert_address(const char* text_address, int port, struct sockaddr* addr { taddr = text_address; } - - + + if (ip_is_valid_ipv6(taddr) && ipv6sup) { sockaddr_size = sizeof(struct sockaddr_in6); @@ -152,7 +152,7 @@ int ip_convert_address(const char* text_address, int port, struct sockaddr* addr memcpy(addr, &addr6, sockaddr_size); *addr_len = sockaddr_size; - + } else if (ip_is_valid_ipv4(taddr)) { @@ -185,28 +185,28 @@ int ip_mask_create_left(int af, int bits, struct ip_addr_encap* result) memset(result, 0, sizeof(struct ip_addr_encap)); result->af = af; - + if (bits < 0) bits = 0; - + if (af == AF_INET) { if (bits > 32) bits = 32; mask = (0xffffffff << (32 - bits)); if (bits == 0) mask = 0; - + result->internal_ip_data.in.s_addr = (((uint8_t*) &mask)[0] << 24) | (((uint8_t*) &mask)[1] << 16) | (((uint8_t*) &mask)[2] << 8) | (((uint8_t*) &mask)[3] << 0); } else if (af == AF_INET6) { if (bits > 128) bits = 128; - + fill = (128-bits) / 8; remain_bits = (128-bits) % 8; mask = (0xff << (8 - remain_bits)); for (n = 0; n < fill; n++) ((uint8_t*) &result->internal_ip_data.in6)[n] = (uint8_t) 0xff; - + if (fill < 16) ((uint8_t*) &result->internal_ip_data.in6)[fill] = (uint8_t) mask; } @@ -233,32 +233,32 @@ int ip_mask_create_right(int af, int bits, struct ip_addr_encap* result) memset(result, 0, sizeof(struct ip_addr_encap)); result->af = af; - + if (bits < 0) bits = 0; - + if (af == AF_INET) { if (bits > 32) bits = 32; mask = (0xffffffff >> (32-bits)); if (bits == 0) mask = 0; result->internal_ip_data.in.s_addr = (((uint8_t*) &mask)[0] << 24) | (((uint8_t*) &mask)[1] << 16) | (((uint8_t*) &mask)[2] << 8) | (((uint8_t*) &mask)[3] << 0); - + } else if (af == AF_INET6) { if (bits > 128) bits = 128; - + fill = (128-bits) / 8; remain_bits = (128-bits) % 8; mask8 = (0xff >> (8 - remain_bits)); start = 16-fill; - + for (n = 0; n < start; n++) ((uint8_t*) &result->internal_ip_data.in6)[n] = (uint8_t) 0x00; - + for (n = start; n < 16; n++) ((uint8_t*) &result->internal_ip_data.in6)[n] = (uint8_t) 0xff; - + if (start > 0) ((uint8_t*) &result->internal_ip_data.in6)[start-1] = (uint8_t) mask8; } @@ -266,13 +266,13 @@ int ip_mask_create_right(int af, int bits, struct ip_addr_encap* result) { return -1; } - + #ifdef IP_CALC_DEBUG char* r_str = hub_strdup(ip_convert_to_string(result)); LOG_DUMP("Created right mask: %s", r_str); hub_free(r_str); #endif - + return 0; } @@ -281,7 +281,7 @@ void ip_mask_apply_AND(struct ip_addr_encap* addr, struct ip_addr_encap* mask, s { memset(result, 0, sizeof(struct ip_addr_encap)); result->af = addr->af; - + if (addr->af == AF_INET) { result->internal_ip_data.in.s_addr = addr->internal_ip_data.in.s_addr & mask->internal_ip_data.in.s_addr; @@ -294,19 +294,19 @@ void ip_mask_apply_AND(struct ip_addr_encap* addr, struct ip_addr_encap* mask, s for (n = 0; n < 4; n++) { offset = n * 4; - + A = (((uint8_t*) &addr->internal_ip_data.in6)[offset+0] << 24) | (((uint8_t*) &addr->internal_ip_data.in6)[offset+1] << 16) | (((uint8_t*) &addr->internal_ip_data.in6)[offset+2] << 8) | (((uint8_t*) &addr->internal_ip_data.in6)[offset+3] << 0); - + B = (((uint8_t*) &mask->internal_ip_data.in6)[offset+0] << 24) | (((uint8_t*) &mask->internal_ip_data.in6)[offset+1] << 16) | (((uint8_t*) &mask->internal_ip_data.in6)[offset+2] << 8) | (((uint8_t*) &mask->internal_ip_data.in6)[offset+3] << 0); - + C = A & B; - + D = (((uint8_t*) &C)[0] << 24) | (((uint8_t*) &C)[1] << 16) | (((uint8_t*) &C)[2] << 8) | @@ -321,7 +321,7 @@ void ip_mask_apply_OR(struct ip_addr_encap* addr, struct ip_addr_encap* mask, st { memset(result, 0, sizeof(struct ip_addr_encap)); result->af = addr->af; - + if (addr->af == AF_INET) { result->internal_ip_data.in.s_addr = addr->internal_ip_data.in.s_addr | mask->internal_ip_data.in.s_addr; @@ -334,19 +334,19 @@ void ip_mask_apply_OR(struct ip_addr_encap* addr, struct ip_addr_encap* mask, st for (n = 0; n < 4; n++) { offset = n * 4; - + A = (((uint8_t*) &addr->internal_ip_data.in6)[offset+0] << 24) | (((uint8_t*) &addr->internal_ip_data.in6)[offset+1] << 16) | (((uint8_t*) &addr->internal_ip_data.in6)[offset+2] << 8) | (((uint8_t*) &addr->internal_ip_data.in6)[offset+3] << 0); - + B = (((uint8_t*) &mask->internal_ip_data.in6)[offset+0] << 24) | (((uint8_t*) &mask->internal_ip_data.in6)[offset+1] << 16) | (((uint8_t*) &mask->internal_ip_data.in6)[offset+2] << 8) | (((uint8_t*) &mask->internal_ip_data.in6)[offset+3] << 0); - + C = A | B; - + D = (((uint8_t*) &C)[0] << 24) | (((uint8_t*) &C)[1] << 16) | (((uint8_t*) &C)[2] << 8) | @@ -368,7 +368,7 @@ int ip_compare(struct ip_addr_encap* a, struct ip_addr_encap* b) (((uint8_t*) &a->internal_ip_data.in.s_addr)[1] << 16) | (((uint8_t*) &a->internal_ip_data.in.s_addr)[2] << 8) | (((uint8_t*) &a->internal_ip_data.in.s_addr)[3] << 0); - + B = (((uint8_t*) &b->internal_ip_data.in.s_addr)[0] << 24) | (((uint8_t*) &b->internal_ip_data.in.s_addr)[1] << 16) | (((uint8_t*) &b->internal_ip_data.in.s_addr)[2] << 8) | @@ -386,19 +386,19 @@ int ip_compare(struct ip_addr_encap* a, struct ip_addr_encap* b) (((uint8_t*) &a->internal_ip_data.in6)[offset+1] << 16) | (((uint8_t*) &a->internal_ip_data.in6)[offset+2] << 8) | (((uint8_t*) &a->internal_ip_data.in6)[offset+3] << 0); - + B = (((uint8_t*) &b->internal_ip_data.in6)[offset+0] << 24) | (((uint8_t*) &b->internal_ip_data.in6)[offset+1] << 16) | (((uint8_t*) &b->internal_ip_data.in6)[offset+2] << 8) | (((uint8_t*) &b->internal_ip_data.in6)[offset+3] << 0); - + if (A == B) continue; - + return A - B; } return 0; } - + #ifdef IP_CALC_DEBUG char* a_str = hub_strdup(ip_convert_to_string(a)); char* b_str = hub_strdup(ip_convert_to_string(b)); @@ -406,7 +406,7 @@ int ip_compare(struct ip_addr_encap* a, struct ip_addr_encap* b) hub_free(a_str); hub_free(b_str); #endif - + return ret; } diff --git a/src/network/ipcalc.h b/src/network/ipcalc.h index e6a10e2..6cd86bc 100644 --- a/src/network/ipcalc.h +++ b/src/network/ipcalc.h @@ -18,7 +18,7 @@ */ /* - * This file is used for fiddling with IP-addresses, + * This file is used for fiddling with IP-addresses, * primarily used for IP-banning in uhub. */ diff --git a/src/network/network.c b/src/network/network.c index 327fe89..de765c0 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -449,7 +449,7 @@ int net_is_ipv6_supported() is_ipv6_supported = 0; return 0; } - + net_error_out(ret, "net_is_ipv6_supported"); } else @@ -508,7 +508,7 @@ const char* net_address_to_string(int af, const void* src, char* dst, socklen_t size_t size; LPSOCKADDR addr; DWORD len = cnt; - + switch (af) { case AF_INET: @@ -531,7 +531,7 @@ const char* net_address_to_string(int af, const void* src, char* dst, socklen_t default: return NULL; } - + if (WSAAddressToStringA(addr, size, NULL, dst, &len) == 0) { return dst; @@ -602,15 +602,15 @@ const char* net_get_peer_address(int fd) struct sockaddr_in* name4; struct sockaddr* name; socklen_t namelen; - + memset(address, 0, INET6_ADDRSTRLEN); namelen = sizeof(struct sockaddr_storage); memset(&storage, 0, namelen); - + name6 = (struct sockaddr_in6*) &storage; name4 = (struct sockaddr_in*) &storage; name = (struct sockaddr*) &storage; - + if (getpeername(fd, (struct sockaddr*) name, &namelen) != -1) { int af = storage.ss_family; diff --git a/src/network/openssl.c b/src/network/openssl.c index 671d37f..4edccd8 100644 --- a/src/network/openssl.c +++ b/src/network/openssl.c @@ -73,7 +73,7 @@ int net_ssl_library_shutdown() ERR_free_strings(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); - + // sk_SSL_COMP_free(SSL_COMP_get_compression_methods()); return 1; } diff --git a/src/network/timeout.c b/src/network/timeout.c index 1efc6f5..118fa2a 100644 --- a/src/network/timeout.c +++ b/src/network/timeout.c @@ -89,9 +89,9 @@ void timeout_queue_insert(struct timeout_queue* t, struct timeout_evt* evt, size size_t pos = ((t->last + seconds) % t->max); evt->timestamp = t->last + seconds; evt->next = 0; - + first = t->events[pos]; - + if (first) { uhub_assert(first->timestamp == evt->timestamp); diff --git a/src/plugins/mod_auth_sqlite.c b/src/plugins/mod_auth_sqlite.c index ab36674..71d6a32 100644 --- a/src/plugins/mod_auth_sqlite.c +++ b/src/plugins/mod_auth_sqlite.c @@ -199,7 +199,7 @@ static plugin_st get_user(struct plugin_handle* plugin, const char* nickname, st sqlite3_free(errMsg); return st_default; } - + if (result.found) return st_allow; return st_default; @@ -222,7 +222,7 @@ static plugin_st register_user(struct plugin_handle* plugin, struct auth_info* u return st_deny; } return st_allow; - + } static plugin_st update_user(struct plugin_handle* plugin, struct auth_info* user) @@ -243,7 +243,7 @@ static plugin_st update_user(struct plugin_handle* plugin, struct auth_info* use return st_deny; } return st_allow; - + } static plugin_st delete_user(struct plugin_handle* plugin, struct auth_info* user) diff --git a/src/plugins/mod_chat_history.c b/src/plugins/mod_chat_history.c index 833a33a..a330270 100644 --- a/src/plugins/mod_chat_history.c +++ b/src/plugins/mod_chat_history.c @@ -135,7 +135,7 @@ static int command_history(struct plugin_handle* plugin, struct plugin_user* use maxlines = arg->data.integer; else maxlines = data->history_default; - + buf = cbuf_create(MAX_HISTORY_SIZE); cbuf_append_format(buf, "*** %s: Chat History:\n", cmd->prefix); get_messages(data, maxlines, buf); diff --git a/src/tools/adcclient.c b/src/tools/adcclient.c index 292cbf2..79755f4 100644 --- a/src/tools/adcclient.c +++ b/src/tools/adcclient.c @@ -366,7 +366,7 @@ static int ADC_client_on_recv_line(struct ADC_client* client, const char* line, } */ break; - + default: break; } diff --git a/src/tools/adcrush.c b/src/tools/adcrush.c index fdc72ad..9837e21 100644 --- a/src/tools/adcrush.c +++ b/src/tools/adcrush.c @@ -77,7 +77,7 @@ const char* chat_messages[MAX_CHAT_MSGS] = { "can anyone help me, pls?", "wtf?", "bullshit", - "resistance is futile.", + "resistance is futile.", "You crossed the line first, sir. You squeezed them, you hammered them to the point of desperation. And in their desperation they turned to a man they didn't fully understand.", "beam me up, scotty", "morning", @@ -87,10 +87,10 @@ const char* chat_messages[MAX_CHAT_MSGS] = { "*punt*", "*nudge*", "that's ok", - "...anyway", + "...anyway", "hola", "hey", - "hi", + "hi", "nevermind", "i think so", "dunno", @@ -173,7 +173,7 @@ static void perf_chat(struct ADC_client* client, int priv) else cmd = adc_msg_construct_source(ADC_CMD_BMSG, ADC_client_get_sid(client), strlen(msg)); hub_free(msg); - + ADC_client_send(client, cmd); } @@ -294,7 +294,7 @@ static void perf_normal_action(struct ADC_client* client) bot_output(client, LVL_VERBOSE, "timeout -> chat"); if (user->logged_in) perf_chat(client, 0); - + } break; @@ -486,7 +486,7 @@ int parse_address(const char* arg) { if (!arg || strlen(arg) < 9) return 0; - + if (strncmp(arg, "adc://", 6) && strncmp(arg, "adcs://", 7)) return 0; @@ -537,7 +537,7 @@ int main(int argc, char** argv) { parse_command_line(argc, argv); - + net_initialize(); net_stats_get(&stats_intermediate, &stats_total); diff --git a/src/tools/admin.c b/src/tools/admin.c index 6941513..1b2cac8 100644 --- a/src/tools/admin.c +++ b/src/tools/admin.c @@ -132,7 +132,7 @@ static int handle(struct ADC_client* client, enum ADC_client_callback_type type, break; case ADC_CLIENT_USER_JOIN: - + user_add(data->user); break; diff --git a/src/tools/uhub-passwd.c b/src/tools/uhub-passwd.c index 09b0aaa..64f60c8 100644 --- a/src/tools/uhub-passwd.c +++ b/src/tools/uhub-passwd.c @@ -319,7 +319,7 @@ static int pass(size_t argc, const char** argv) fprintf(stderr, "Unable to change password for user \"%s\"\n", argv[0]); return 1; } - + return 0; } diff --git a/src/util/credentials.c b/src/util/credentials.c index 46ce076..28a1abc 100644 --- a/src/util/credentials.c +++ b/src/util/credentials.c @@ -71,7 +71,7 @@ const char* auth_cred_to_string(enum auth_credentials cred) case auth_cred_link: return "link"; case auth_cred_admin: return "admin"; } - + return ""; }; diff --git a/src/util/floodctl.h b/src/util/floodctl.h index 4fea4a4..cb58e12 100644 --- a/src/util/floodctl.h +++ b/src/util/floodctl.h @@ -36,7 +36,7 @@ void flood_control_reset(struct flood_control*); * @param max_count Max count for flood control * @param window Time window for max_count to appear. * @param now The current time. - * + * * @return 0 if flood no flood detected. * 1 if flood detected. */ diff --git a/src/util/list.c b/src/util/list.c index 515ce22..91483a2 100644 --- a/src/util/list.c +++ b/src/util/list.c @@ -65,7 +65,7 @@ void list_append(struct linked_list* list, void* data_ptr) return; } new_node->ptr = data_ptr; - + if (list->last) { list->last->next = new_node; @@ -123,10 +123,10 @@ void list_remove(struct linked_list* list, void* data_ptr) { if (node->next) node->next->prev = node->prev; - + if (node->prev) node->prev->next = node->next; - + if (node == list->last) list->last = node->prev; @@ -194,7 +194,7 @@ void* list_get_first(struct linked_list* list) list->iterator = list->first; if (list->iterator == NULL) return NULL; - + return list->iterator->ptr; } @@ -203,7 +203,7 @@ struct node* list_get_first_node(struct linked_list* list) list->iterator = list->first; if (list->iterator == NULL) return NULL; - + return list->iterator; } @@ -212,7 +212,7 @@ void* list_get_last(struct linked_list* list) list->iterator = list->last; if (list->iterator == NULL) return NULL; - + return list->iterator->ptr; } @@ -221,9 +221,9 @@ struct node* list_get_last_node(struct linked_list* list) list->iterator = list->last; if (list->iterator == NULL) return NULL; - + return list->iterator; - + } void* list_get_next(struct linked_list* list) @@ -232,7 +232,7 @@ void* list_get_next(struct linked_list* list) list->iterator = list->first; else list->iterator = list->iterator->next; - + if (list->iterator == NULL) return NULL; @@ -244,9 +244,9 @@ void* list_get_prev(struct linked_list* list) { if (list->iterator == NULL) return NULL; - + list->iterator = list->iterator->prev; - + if (list->iterator == NULL) return NULL; diff --git a/src/util/log.c b/src/util/log.c index 2d97528..a5b8213 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -86,7 +86,7 @@ void hub_log_initialize(const char* file, int syslog) return; } #endif - + #ifndef WIN32 if (syslog) { @@ -97,13 +97,13 @@ void hub_log_initialize(const char* file, int syslog) } #endif - + if (!file) { logfile = stderr; return; } - + logfile = fopen(file, "a"); if (!logfile) { @@ -137,7 +137,7 @@ void hub_log_shutdown() netdump = NULL; } #endif - + #ifndef WIN32 if (use_syslog) { @@ -186,7 +186,7 @@ void hub_log(int log_verbosity, const char *format, ...) return; } #endif - + if (log_verbosity < verbosity) { t = time(NULL); @@ -195,7 +195,7 @@ void hub_log(int log_verbosity, const char *format, ...) va_start(args, format); vsnprintf(logmsg, 1024, format, args); va_end(args); - + if (logfile) { fprintf(logfile, "%s %6s: %s\n", timestamp, prefixes[log_verbosity], logmsg); @@ -211,14 +211,14 @@ void hub_log(int log_verbosity, const char *format, ...) if (use_syslog) { int level = 0; - + if (verbosity < log_info) return; - + va_start(args, format); vsnprintf(logmsg, 1024, format, args); va_end(args); - + switch (log_verbosity) { case log_fatal: level = LOG_CRIT; break; @@ -232,15 +232,15 @@ void hub_log(int log_verbosity, const char *format, ...) #endif case log_info: level = LOG_INFO; break; case log_debug: level = LOG_DEBUG; break; - + default: level = 0; break; } - + if (level == 0) return; - + #ifdef SYSTEMD sd_journal_print(level, "%s", logmsg); @@ -250,5 +250,5 @@ void hub_log(int log_verbosity, const char *format, ...) #endif } #endif - + } diff --git a/src/util/memory.c b/src/util/memory.c index e980e87..a38f9e9 100644 --- a/src/util/memory.c +++ b/src/util/memory.c @@ -48,7 +48,7 @@ void internal_debug_print_leaks() size_t leak = 0; size_t count = 0; LOG_MEMORY("--- exit (allocs: %d, size: " PRINTF_SIZE_T ") ---", hub_alloc_count, hub_alloc_size); - + for (; n < UHUB_MAX_ALLOCS; n++) { if (hub_allocs[n].ptr) @@ -58,7 +58,7 @@ void internal_debug_print_leaks() LOG_MEMORY("leak %p size: " PRINTF_SIZE_T " (bt: %p %p)", hub_allocs[n].ptr, hub_allocs[n].size, hub_allocs[n].stack1, hub_allocs[n].stack2); } } - + LOG_MEMORY("--- done (allocs: %d, size: " PRINTF_SIZE_T ", peak: %d/" PRINTF_SIZE_T ", oom: " PRINTF_SIZE_T ") ---", count, leak, hub_alloc_peak_count, hub_alloc_peak_size, hub_alloc_oom); } #endif /* REALTIME_MALLOC_TRACKING */ @@ -67,9 +67,9 @@ void* internal_debug_mem_malloc(size_t size, const char* where) { size_t n = 0; char* ptr = malloc(size); - + #ifdef REALTIME_MALLOC_TRACKING - + /* Make sure the malloc info struct is initialized */ if (!hub_alloc_count) { @@ -81,17 +81,17 @@ void* internal_debug_mem_malloc(size_t size, const char* where) hub_allocs[n].stack1 = 0; hub_allocs[n].stack2 = 0; } - + atexit(&internal_debug_print_leaks); } - + if (ptr) { if (malloc_slot != -1) n = (size_t) malloc_slot; else n = 0; - + for (; n < UHUB_MAX_ALLOCS; n++) { if (!hub_allocs[n].ptr) @@ -100,13 +100,13 @@ void* internal_debug_mem_malloc(size_t size, const char* where) hub_allocs[n].size = size; hub_allocs[n].stack1 = __builtin_return_address(1); hub_allocs[n].stack2 = __builtin_return_address(2); - + hub_alloc_size += size; hub_alloc_count++; - + hub_alloc_peak_count = MAX(hub_alloc_count, hub_alloc_peak_count); hub_alloc_peak_size = MAX(hub_alloc_size, hub_alloc_peak_size); - + LOG_MEMORY("%s %p (%d bytes) (bt: %p %p) {allocs: %d, size: " PRINTF_SIZE_T "}", where, ptr, (int) size, hub_allocs[n].stack1, hub_allocs[n].stack2, hub_alloc_count, hub_alloc_size); break; } @@ -147,7 +147,7 @@ void internal_debug_mem_free(void* ptr) return; } } - + malloc_slot = -1; abort(); LOG_MEMORY("free %p *** NOT ALLOCATED *** (bt: %p %p)", ptr, stack1, stack2); diff --git a/src/util/misc.c b/src/util/misc.c index 3a7851c..a6bfedd 100644 --- a/src/util/misc.c +++ b/src/util/misc.c @@ -37,7 +37,7 @@ static int is_printable(unsigned char c) { if (c >= 32) return 1; - + if (c == '\t' || c == '\r' || c == '\n') return 1; return 0; @@ -59,7 +59,7 @@ char* strip_white_space(char* string) /* Strip appending whitespace */ pos = &string[strlen(string)-1]; while (&string[0] < &pos[0] && is_white_space(pos[0])) { pos[0] = 0; pos--; } - + return string; } @@ -68,9 +68,9 @@ static int is_valid_utf8_str(const char* string, size_t length) int expect = 0; char div = 0; size_t pos = 0; - + if (length == 0) return 1; - + for (pos = 0; pos < length; pos++) { if (expect) @@ -243,7 +243,7 @@ int file_read_lines(const char* file, void* data, file_line_handler_t handler) LOG_ERROR("Unable to open file %s: %s", file, strerror(errno)); return -2; } - + ret = read(fd, buf, MAX_RECV_BUF-1); close(fd); @@ -274,12 +274,12 @@ int uhub_atoi(const char* value) { int val = 0; int i = 0; for (; i < len; i++) - if (value[i] > '9' || value[i] < '0') + if (value[i] > '9' || value[i] < '0') offset++; - - for (i = offset; i< len; i++) + + for (i = offset; i< len; i++) val = val*10 + (value[i] - '0'); - + return value[0] == '-' ? -val : val; } @@ -360,7 +360,7 @@ void* memmem(const void *haystack, size_t haystacklen, const void *needle, size_ char* c_buf = (char*) haystack; char* c_pat = (char*) needle; char* ptr = memchr(c_buf, c_pat[0], haystacklen); - + while (ptr && ((size_t) (&ptr[0] - &c_buf[0]) < haystacklen)) { if (!memcmp(ptr, c_pat, needlelen)) @@ -382,7 +382,7 @@ int split_string(const char* string, const char* split, struct linked_list* list for (;;) { tmp1 = strstr(string, split); - + if (tmp1) tmp2 = hub_strndup(string, tmp1 - string); else tmp2 = hub_strdup(string); diff --git a/src/util/tiger.c b/src/util/tiger.c index ee1e288..4481ed9 100644 --- a/src/util/tiger.c +++ b/src/util/tiger.c @@ -57,7 +57,7 @@ void tiger_compress(uint64_t* str, uint64_t state[3]) { a = state[0]; b = state[1]; c = state[2]; - + x0 = str[0]; x1 = str[1]; x2 = str[2]; @@ -70,7 +70,7 @@ void tiger_compress(uint64_t* str, uint64_t state[3]) { aa = a; bb = b; cc = c; - + PASS(a, b, c, 5); x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5ULL; @@ -91,7 +91,7 @@ void tiger_compress(uint64_t* str, uint64_t state[3]) { x7 -= x6 ^ 0x0123456789ABCDEFULL; PASS(c, a, b, 7); - + x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5ULL; x1 ^= x0; x2 += x1; @@ -130,9 +130,9 @@ void tiger_compress(uint64_t* str, uint64_t state[3]) { x5 ^= x4; x6 += x5; x7 -= x6 ^ 0x0123456789ABCDEFULL; - + PASS(a, b, c, 9); - + swap = a; a = c; c = b; @@ -143,7 +143,7 @@ void tiger_compress(uint64_t* str, uint64_t state[3]) { a ^= aa; b -= bb; c += cc; - + state[0] = a; state[1] = b; state[2] = c; @@ -207,7 +207,7 @@ void tiger(uint64_t* str, uint64_t length, uint64_t res[3]) { } for (; j < 56; j++) temp[j] = 0; - + ((uint64_t*) (&(temp[56])))[0] = ((uint64_t) length) << 3; tiger_compress(((uint64_t*) temp), res);