Clean up white space.

This commit is contained in:
Jan Vidar Krey
2013-03-22 20:00:40 +01:00
parent 5835a06676
commit f25015927a
34 changed files with 232 additions and 232 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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 */
};

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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])

View File

@@ -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);

View File

@@ -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++);
}

View File

@@ -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
*/

View File

@@ -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 ?