Fix some formatting.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 30 Aug 2007 14:27:26 +0000 (16:27 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 30 Aug 2007 14:27:26 +0000 (16:27 +0200)
22 files changed:
mods/auto_away.c
mods/listener.c
mods/log_custom.c
mods/log_irssi.c
src/admin.c
src/cache.c
src/client.c
src/ctcp.c
src/help.c
src/hooks.c
src/isupport.c
src/line.c
src/main.c
src/motd.c
src/network.c
src/nickserv.c
src/plugins.c
src/redirect.c
src/repl.c
src/settings.c
src/state.c
testsuite/torture.c

index 1b4fed00354dc0a596b9368e52d0a9a1a3100109..6a2e2ed28dc1027fcabef058b3963ae571a8e476 100644 (file)
@@ -37,7 +37,7 @@ static gboolean check_time(gpointer user_data)
 {
        struct auto_away_data *d = user_data;
 
-       if(time(NULL) - d->last_message > d->max_idle_time && !d->is_away) { 
+       if (time(NULL) - d->last_message > d->max_idle_time && !d->is_away) { 
                GList *sl;
                d->is_away = TRUE;
                for (sl = d->global->networks; sl; sl = sl->next) {
index 0a7110cf9b405504191be6b7d5f7b41145d7be16..c9676c98430e426e73b0003f5b1dfe019347e0ed 100644 (file)
@@ -57,11 +57,11 @@ static gboolean handle_client_receive(GIOChannel *c, GIOCondition condition, gpo
                        continue;
                }
 
-               if(!listener->password) {
+               if (!listener->password) {
                        log_network(LOG_WARNING, listener->network, "No password set, allowing client _without_ authentication!");
                }
 
-               if(!g_strcasecmp(l->args[0], "PASS")) {
+               if (!g_strcasecmp(l->args[0], "PASS")) {
                        char *desc;
                        if (listener->password && strcmp(l->args[1], listener->password)) {
                                log_network(LOG_WARNING, listener->network, "User tried to log in with incorrect password!");
index e2597753b66ffc932676cd291ebe843606e57393..3477a6aa2a73aeda2d776290f3889b93238658c4 100644 (file)
@@ -518,7 +518,7 @@ static gboolean log_custom_data(struct network *network, const struct line *l,
        } else if (!g_strcasecmp(l->args[0], "PRIVMSG")) {
                if (l->args[2][0] == '\001') { 
                        l->args[2][strlen(l->args[2])-1] = '\0';
-                       if(!g_ascii_strncasecmp(l->args[2], "\001ACTION ", 8)) { 
+                       if (!g_ascii_strncasecmp(l->args[2], "\001ACTION ", 8)) { 
                                l->args[2]+=8;
                                file_write_target(data, network, "action", l);
                                l->args[2]-=8;
@@ -550,14 +550,14 @@ static gboolean log_custom_data(struct network *network, const struct line *l,
                        while (cont) {
                                n = strchr(p, ',');
 
-                               if(!n) cont = 0;
+                               if (!n) cont = 0;
                                else *n = '\0';
 
                                file_write_channel_only(data, network, "kick", l);
 
                                p = n+1;
                                _nick = strchr(_nick, ',');
-                               if(!_nick)break;
+                               if (!_nick)break;
                                _nick++;
                        }
                        
index 9ca0d0d50c723de302ce35b9210f12eede1a9362..16764f6cc2ae2ff38d4d1baaff4c86cf5b89d990 100644 (file)
@@ -50,17 +50,18 @@ static FILE *find_add_channel_file(struct network *s, const char *name)
        g_free(lowercase);
 
        f = g_hash_table_lookup(files, hash_name);
-       if(!f) {
+       if (!f) {
                char *cn; 
                const char *server_name;
 
                server_name = s->info.name;
 
-               if(strchr(server_name, '/'))server_name = strrchr(server_name, '/');
+               if (strchr(server_name, '/') != NULL) 
+                       server_name = strrchr(server_name, '/');
 
                n = g_strdup_printf("%s/%s", logfile, server_name);
                /* Check if directory needs to be created */
-               if(!g_file_test(n, G_FILE_TEST_IS_DIR) && g_mkdir(n, 0700) == -1) {
+               if (!g_file_test(n, G_FILE_TEST_IS_DIR) && g_mkdir(n, 0700) == -1) {
                        log_network(LOG_ERROR, s, "Couldn't create directory %s for logging!", n);
                        g_free(hash_name);
                        g_free(n);
@@ -74,7 +75,7 @@ static FILE *find_add_channel_file(struct network *s, const char *name)
                n = g_strdup_printf("%s/%s/%s", logfile, server_name, cn);
                g_free(cn);
                f = fopen(n, "a+");
-               if(!f) {
+               if (!f) {
                        log_network(LOG_ERROR, s, "Couldn't open file %s for logging!", n);
                        g_free(n);
                        return NULL;
@@ -134,16 +135,16 @@ static gboolean log_data(struct network *n, const struct line *l,
                if (user) user++;
        }
 
-       if(dir == FROM_SERVER && !g_strcasecmp(l->args[0], "JOIN")) {
+       if (dir == FROM_SERVER && !g_strcasecmp(l->args[0], "JOIN")) {
                target_printf(n, l->args[1], "%02d:%02d -!- %s [%s] has joined %s\n", t->tm_hour, t->tm_min, nick, user, l->args[1]);
-       } else if(dir == FROM_SERVER && !g_strcasecmp(l->args[0], "PART")) {
+       } else if (dir == FROM_SERVER && !g_strcasecmp(l->args[0], "PART")) {
                target_printf(n, l->args[1], "%02d:%02d -!- %s [%s] has left %s [%s]\n", t->tm_hour, t->tm_min, nick, user, l->args[1], l->args[2]?l->args[2]:"");
-       } else if(!g_strcasecmp(l->args[0], "PRIVMSG") && l->argc > 2) {
+       } else if (!g_strcasecmp(l->args[0], "PRIVMSG") && l->argc > 2) {
                dest = l->args[1];
                if (!irccmp(&n->state->info, dest, n->state->me.nick)) dest = nick;
                if (l->args[2][0] == '\001') { 
                        l->args[2][strlen(l->args[2])-1] = '\0';
-                       if(!g_ascii_strncasecmp(l->args[2], "\001ACTION ", 8)) { 
+                       if (!g_ascii_strncasecmp(l->args[2], "\001ACTION ", 8)) { 
                                target_printf(n, dest, "%02d:%02d  * %s %s\n", t->tm_hour, t->tm_min, nick, l->args[2]+8);
                        }
                        l->args[2][strlen(l->args[2])] = '\001';
@@ -151,10 +152,10 @@ static gboolean log_data(struct network *n, const struct line *l,
                } else {
                        target_printf(n, dest, "%02d:%02d < %s> %s\n", t->tm_hour, t->tm_min, nick, l->args[2]);
                }
-       } else if(!g_strcasecmp(l->args[0], "MODE") && l->args[1] && 
+       } else if (!g_strcasecmp(l->args[0], "MODE") && l->args[1] && 
                          is_channelname(l->args[1], &n->state->info) && dir == FROM_SERVER) {
                target_printf(n, l->args[1], "%02d:%02d -!- mode/%s [%s %s] by %s\n", t->tm_hour, t->tm_min, l->args[1], l->args[2], l->args[3], nick);
-       } else if(!g_strcasecmp(l->args[0], "QUIT")) {
+       } else if (!g_strcasecmp(l->args[0], "QUIT")) {
                /* Loop thru the channels this user is on */
                GList *gl;
                struct network_nick *nn = find_network_nick(n->state, nick);
@@ -164,8 +165,8 @@ static gboolean log_data(struct network *n, const struct line *l,
                                target_printf(n, cn->channel->name, "%02d:%02d -!- %s [%s] has quit [%s]\n", t->tm_hour, t->tm_min, nick, user, l->args[1]?l->args[1]:"");
                        }
                }
-       } else if(!g_strcasecmp(l->args[0], "KICK") && l->args[1] && l->args[2] && dir == FROM_SERVER) {
-               if(!strchr(l->args[1], ',')) {
+       } else if (!g_strcasecmp(l->args[0], "KICK") && l->args[1] && l->args[2] && dir == FROM_SERVER) {
+               if (!strchr(l->args[1], ',')) {
                        target_printf(n, l->args[1], "%02d:%02d -!- %s has been kicked by %s [%s]\n", t->tm_hour, t->tm_min, l->args[2], nick, l->args[3]?l->args[3]:"");
                } else { 
                        char *channels = g_strdup(l->args[1]);
@@ -178,22 +179,22 @@ static gboolean log_data(struct network *n, const struct line *l,
                        while(cont) {
                                nx = strchr(p, ',');
 
-                               if(!nx) cont = 0;
+                               if (!nx) cont = 0;
                                else *nx = '\0';
 
                                target_printf(n, p, "%02d:%02d -!- %s has been kicked by %s [%s]\n", t->tm_hour, t->tm_min, _nick, nick, l->args[3]?l->args[3]:"");
 
                                p = nx+1;
                                _nick = strchr(_nick, ',');
-                               if(!_nick)break;
+                               if (!_nick)break;
                                _nick++;
                        }
                        
                        g_free(channels);
                        g_free(nicks);
                }
-       } else if(!g_strcasecmp(l->args[0], "TOPIC") && dir == FROM_SERVER && l->args[1]) {
-               if(l->args[2])target_printf(n, l->args[1], "%02d:%02d -!- %s has changed the topic to %s\n", t->tm_hour, t->tm_min, nick, l->args[2]);
+       } else if (!g_strcasecmp(l->args[0], "TOPIC") && dir == FROM_SERVER && l->args[1]) {
+               if (l->args[2])target_printf(n, l->args[1], "%02d:%02d -!- %s has changed the topic to %s\n", t->tm_hour, t->tm_min, nick, l->args[2]);
                else target_printf(n, l->args[1], "%02d:%02d -!- %s has removed the topic\n", t->tm_hour, t->tm_min, nick);
        } else if (!g_strcasecmp(l->args[0], "NICK") && 
                           dir == FROM_SERVER && l->args[1]) {
@@ -222,7 +223,7 @@ static void load_config(struct global *global)
                return;
        }
 
-       if(!g_key_file_has_key(kf, "log-irssi", "logfile", NULL)) {
+       if (!g_key_file_has_key(kf, "log-irssi", "logfile", NULL)) {
                logfile = g_build_filename(global->config->config_dir, "log_irssi", NULL);
        } else {
                logfile = g_key_file_get_string(kf, "log-irssi", "logfile", NULL);
index 52bad88e200272650f666a8871f7dc6f36b2ad6a..c976d35228756b1edcda326ca88133cd3503d98c 100644 (file)
@@ -157,7 +157,7 @@ static void add_server (admin_handle h, char **args, void *userdata)
        struct tcp_server_config *s;
        char *t;
 
-       if(!args[1] || !args[2]) {
+       if (!args[1] || !args[2]) {
                admin_out(h, "Not enough parameters");
                return;
        }
@@ -194,7 +194,7 @@ static void add_server (admin_handle h, char **args, void *userdata)
 static void com_connect_network (admin_handle h, char **args, void *userdata)
 {
        struct network *s;
-       if(!args[1]) {
+       if (!args[1]) {
                 admin_out(h, "No network specified");
                 return;
        }
@@ -234,7 +234,7 @@ static void com_disconnect_network (admin_handle h, char **args, void *userdata)
 
        if (args[1] != NULL) {
                n = find_network(admin_get_global(h), args[1]);
-               if(!n) {
+               if (!n) {
                        admin_out(h, "Can't find active network with that name");
                        return;
                }
@@ -254,14 +254,14 @@ static void com_next_server (admin_handle h, char **args, void *userdata)
        const char *name;
 
 
-       if(args[1] != NULL) {
+       if (args[1] != NULL) {
                name = args[1];
                n = find_network(admin_get_global(h), args[1]);
        } else {
                n = admin_get_network(h);
                name = n->info.name;
        }
-       if(!n) {
+       if (!n) {
                admin_out(h, "%s: Not connected", name);
        } else {
                admin_out(h, "%s: Reconnecting", name);
@@ -321,7 +321,7 @@ static void dump_joined_channels(admin_handle h, char **args, void *userdata)
 
        if (args[1] != NULL) {
                n = find_network(admin_get_global(h), args[1]);
-               if(n == NULL) {
+               if (n == NULL) {
                        admin_out(h, "Can't find network '%s'", args[1]);
                        return;
                }
@@ -465,7 +465,7 @@ gboolean process_cmd(admin_handle h, const char *cmd)
        /* Ok, arguments are processed now. Execute the corresponding command */
        for (gl = admin_commands; gl; gl = gl->next) {
                struct admin_command *cmd = (struct admin_command *)gl->data;
-               if(!g_strcasecmp(cmd->name, args[0])) {
+               if (!g_strcasecmp(cmd->name, args[0])) {
                        cmd->handler(h, args, cmd->userdata);
                        g_strfreev(args);
                        return TRUE;
index e9d5004133e7424584b0139c984ef1d9e762c02e..5bd379ad9fa311e2ea97357655f6506fa2b0f862 100644 (file)
@@ -142,7 +142,7 @@ static gboolean client_try_cache_topic(struct client *c, struct line *l)
        ch = find_channel(c->network->state, l->args[1]);
        if (!ch) return FALSE;
 
-       if(ch->topic) {
+       if (ch->topic) {
                client_send_response(c, RPL_TOPIC, ch->name, ch->topic, NULL);
        } else {
                client_send_response(c, RPL_NOTOPIC, ch->name, "No topic set", NULL);
index a61cfd15f795970e0c46379c564031003daff973..cf2a315f671c84641b1f22548d1b69fb52a414ce 100644 (file)
@@ -96,23 +96,23 @@ static gboolean process_from_client(struct client *c, struct line *l)
 
        g_assert(l->args[0] != NULL);
 
-       if(!g_strcasecmp(l->args[0], "QUIT")) {
+       if (!g_strcasecmp(l->args[0], "QUIT")) {
                disconnect_client(c, "Client exiting");
                return FALSE;
-       } else if(!g_strcasecmp(l->args[0], "PING")) {
+       } else if (!g_strcasecmp(l->args[0], "PING")) {
                client_send_args(c, "PONG", c->network->info.name, l->args[1], NULL);
-       } else if(!g_strcasecmp(l->args[0], "PONG")) {
+       } else if (!g_strcasecmp(l->args[0], "PONG")) {
                if (l->argc < 2) {
                        client_send_response(c, ERR_NEEDMOREPARAMS, l->args[0], 
                                                                 "Not enough parameters", NULL);
                        return TRUE;
                }
                c->last_pong = time(NULL);
-       } else if(!g_strcasecmp(l->args[0], "USER") ||
+       } else if (!g_strcasecmp(l->args[0], "USER") ||
                          !g_strcasecmp(l->args[0], "PASS")) {
                client_send_response(c, ERR_ALREADYREGISTERED,  
                                                 "Please register only once per session", NULL);
-       } else if(!g_strcasecmp(l->args[0], "CTRLPROXY")) {
+       } else if (!g_strcasecmp(l->args[0], "CTRLPROXY")) {
                admin_process_command(c, l, 1);
        } else if (!c->network->global->config->admin_noprivmsg && 
                           !g_strcasecmp(l->args[0], "PRIVMSG") && 
@@ -126,13 +126,13 @@ static gboolean process_from_client(struct client *c, struct line *l)
                        l->args[2][0] == '\001') {
                ctcp_process_client_reply(c, l);
        } else if (!g_strcasecmp(l->args[0], "")) {
-       } else if(c->network->connection.state == NETWORK_CONNECTION_STATE_MOTD_RECVD) {
+       } else if (c->network->connection.state == NETWORK_CONNECTION_STATE_MOTD_RECVD) {
                if (c->network->config->disable_cache || !client_try_cache(c, l)) {
                        /* Perhaps check for validity of input here ? It could save us some bandwidth 
                         * to the server, though very unlikely to occur often */
                        network_send_line(c->network, c, l, FALSE);
                }
-       } else if(c->network->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
+       } else if (c->network->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
                char *msg;
                if (c->network->connection.data.tcp.last_disconnect_reason == NULL)
                        msg = g_strdup("Currently not connected to server...");
@@ -329,7 +329,7 @@ void send_motd(struct client *c)
 
        lines = get_motd_lines(c);
 
-       if(!lines) {
+       if (!lines) {
                client_send_response(c, ERR_NOMOTD, "No MOTD file", NULL);
                return;
        }
@@ -460,7 +460,7 @@ static gboolean welcome_client(struct client *client)
                }
        }
 
-       if(!new_client_hook_execute(client)) {
+       if (!new_client_hook_execute(client)) {
                disconnect_client(client, "Refused by client connect hook");
                return FALSE;
        }
@@ -517,7 +517,7 @@ static gboolean handle_pending_client_receive(GIOChannel *c,
                                }
 
                                client->nick = g_strdup(l->args[1]); /* Save nick */
-                       } else if(!g_strcasecmp(l->args[0], "USER")) {
+                       } else if (!g_strcasecmp(l->args[0], "USER")) {
 
                                if (l->argc < 5) {
                                        client_send_response(client, ERR_NEEDMOREPARAMS, 
@@ -535,9 +535,9 @@ static gboolean handle_pending_client_receive(GIOChannel *c,
                                g_free(client->fullname);
                                client->fullname = g_strdup(l->args[4]);
 
-                       } else if(!g_strcasecmp(l->args[0], "PASS")) {
+                       } else if (!g_strcasecmp(l->args[0], "PASS")) {
                                /* Silently drop... */
-                       } else if(!g_strcasecmp(l->args[0], "CONNECT")) {
+                       } else if (!g_strcasecmp(l->args[0], "CONNECT")) {
                                if (l->argc < 2) {
                                        client_send_response(client, ERR_NEEDMOREPARAMS,
                                                                         l->args[0], "Not enough parameters", NULL);
index 709fb0ff82a2f83a7b2f7f22ba7b67637423c7ad..3f122227f78385cf7ebc7e08e330d01d3cf7acea 100644 (file)
@@ -110,7 +110,7 @@ static void handle_time(struct ctcp_handle *h, char **args)
        time_t ti = time(NULL);
        char *t, *msg = g_strdup(ctime(&ti));
        t = strchr(msg, '\n');
-       if(t)*t = '\0';
+       if (t)*t = '\0';
        ctcp_reply(h, "TIME", msg, NULL);
        g_free(msg);
 }
@@ -283,7 +283,7 @@ gboolean ctcp_process_network_request (struct network *n, struct line *l)
 
        data = g_strdup(l->args[2]+1);
        t = strchr(data, '\001');
-       if(!t) { 
+       if (!t) { 
                g_free(data); 
                log_network(LOG_WARNING, n, "Malformed CTCP request from %s!", h.nick);
                g_free(h.nick);
index 4d902c0a0aeb07344c756e303c5964fffc1dcc03..85a0e48e9cc0874c90d84539e597a111ca3ea9e1 100644 (file)
@@ -90,7 +90,7 @@ help_t *help_load_file( const char *helpfile )
                data = g_mapped_file_get_contents(h->file);
        }
        
-       if( h->file == NULL ) {
+       if (h->file == NULL) {
                log_global(LOG_WARNING, "Unable to open help file `%s': %s", helpfile, 
                                  error->message);
                help_free( h );
index 05920aba63725173068b65b5f45c577c6bcd45a1..5815090f1e2f44b154eb4fadcd3af8837ee834d0 100644 (file)
@@ -61,7 +61,7 @@ static GList *del_filter_ex(GList *list, const char *name)
        {
                struct filter_data *d = (struct filter_data *)gl->data;
 
-               if(!g_strcasecmp(d->name, name)) 
+               if (!g_strcasecmp(d->name, name)) 
                {
                        g_free(d->name);
                        g_free(d);
@@ -78,7 +78,7 @@ static gboolean filter_class_execute(GList *gl, struct network *s, enum data_dir
        while(gl) {
                struct filter_data *d = (struct filter_data *)gl->data;
                
-               if(!d->function(s, l, dir, d->userdata)) {
+               if (!d->function(s, l, dir, d->userdata)) {
                        return FALSE;
                }
 
@@ -130,7 +130,7 @@ gboolean run_client_filter(struct client *c, const struct line *l, enum data_dir
        {
                struct client_filter_data *d = (struct client_filter_data *)gl->data;
                
-               if(!d->function(c, l, dir, d->userdata)) {
+               if (!d->function(c, l, dir, d->userdata)) {
                        return FALSE;
                }
        }
@@ -175,7 +175,7 @@ void del_new_client_hook(const char *name)
        for (l = new_client_hooks; l; l = l->next)
        {
                struct new_client_hook_data *d = (struct new_client_hook_data *)l->data;
-               if(!strcmp(d->name, name)) {
+               if (!strcmp(d->name, name)) {
                        g_free(d->name);
                        g_free(d);
                        new_client_hooks = g_list_remove(new_client_hooks, d);
@@ -192,7 +192,7 @@ gboolean new_client_hook_execute(struct client *c)
        {
                struct new_client_hook_data *d = (struct new_client_hook_data *)l->data;
        
-               if(!d->hook(c, d->userdata)) {
+               if (!d->hook(c, d->userdata)) {
                        g_debug(("New client hook '%s' refused new client"), d->name);
                        return FALSE;
                }
@@ -218,7 +218,7 @@ void del_lose_client_hook(const char *name)
        for (l = lose_client_hooks; l; l = l->next)
        {
                struct lose_client_hook_data *d = (struct lose_client_hook_data *)l->data;
-               if(!strcmp(d->name, name)) {
+               if (!strcmp(d->name, name)) {
                        g_free(d->name);
                        lose_client_hooks = g_list_remove(lose_client_hooks, d);
                        g_free(d);
@@ -263,7 +263,7 @@ void del_server_connected_hook(const char *name)
        for (l = server_connected_hooks; l; l = l->next) 
        {
                struct server_connected_hook_data *d = (struct server_connected_hook_data *)l->data;
-               if(!strcmp(d->name, name)) {
+               if (!strcmp(d->name, name)) {
                        g_free(d->name);
                        g_free(d);
                        server_connected_hooks = g_list_remove(server_connected_hooks, d);
@@ -308,7 +308,7 @@ void del_server_disconnected_hook(const char *name)
        for (l = server_disconnected_hooks; l; l = l->next) 
        {
                struct server_disconnected_hook_data *d = (struct server_disconnected_hook_data *)l->data;
-               if(!strcmp(d->name, name)) {
+               if (!strcmp(d->name, name)) {
                        g_free(d->name);
                        g_free(d);
                        server_disconnected_hooks = g_list_remove(server_disconnected_hooks, d);
index 04f8758f176965716a9482ee34f4c5c35102e0e2..777cbcde89a904fc1d0062c5784cca725941de57 100644 (file)
@@ -264,12 +264,12 @@ void network_info_parse(struct network_info *info, const char *parameter)
                val = g_strdup(sep+1);
        }
        
-       if(!g_strcasecmp(key, "CASEMAPPING")) {
-               if(!g_strcasecmp(val, "rfc1459")) {
+       if (!g_strcasecmp(key, "CASEMAPPING")) {
+               if (!g_strcasecmp(val, "rfc1459")) {
                        info->casemapping = CASEMAP_RFC1459;
-               } else if(!g_strcasecmp(val, "strict-rfc1459")) {
+               } else if (!g_strcasecmp(val, "strict-rfc1459")) {
                        info->casemapping = CASEMAP_STRICT_RFC1459;
-               } else if(!g_strcasecmp(val, "ascii")) {
+               } else if (!g_strcasecmp(val, "ascii")) {
                        info->casemapping = CASEMAP_ASCII;
                } else {
                        info->casemapping = CASEMAP_UNKNOWN;
@@ -472,7 +472,7 @@ gboolean is_prefix(char p, const struct network_info *n)
        pref_end = strchr(n->prefix, ')');
        if (!pref_end)pref_end = n->prefix; else pref_end++;
 
-       if(strchr(pref_end, p)) return TRUE;
+       if (strchr(pref_end, p)) return TRUE;
        return FALSE;
 }
 
@@ -494,7 +494,7 @@ char get_prefix_by_mode(char mode, const struct network_info *n)
        prefix = n->prefix;
        
        pref_end = strchr(prefix, ')');
-       if(prefix[0] != '(' || !pref_end) {
+       if (prefix[0] != '(' || !pref_end) {
                log_global(LOG_WARNING, "Malformed PREFIX data `%s'", prefix);
                return ' ';
        }
@@ -502,7 +502,7 @@ char get_prefix_by_mode(char mode, const struct network_info *n)
        prefix++;
 
        for(i = 0; pref_end[i]; i++) {
-               if(prefix[i] == mode) return pref_end[i];
+               if (prefix[i] == mode) return pref_end[i];
        }
        return ' ';
 }
index fd5890d9eb94376580410cb5f78ca3f06f0504b4..0a76070b1cc7383d40be1474710516beefd01303 100644 (file)
@@ -81,16 +81,16 @@ struct line * irc_parse_line(const char *d)
        l->has_endcolon = WITHOUT_COLON;
        p = data;
 
-       if(p[0] == ':') {
+       if (p[0] == ':') {
                p = strchr(data, ' ');
-               if(!p){ g_free(data); g_free(l); return NULL; }
+               if (!p){ g_free(data); g_free(l); return NULL; }
                *p = '\0';
                l->origin = g_strdup(data+1);
                for(; *(p+1) == ' '; p++);
                p++;
        }
 
-       for(i = 0; p[i]; i++) if(p[i] == ' ')estimate++;
+       for(i = 0; p[i]; i++) if (p[i] == ' ')estimate++;
 
        l->args = g_new(char *, estimate+2);
 
@@ -169,14 +169,14 @@ static int requires_colon(const struct line *l)
 
        g_assert(l);
 
-       if(l->has_endcolon == WITH_COLON) return 1;
-       else if(l->has_endcolon == WITHOUT_COLON) return 0;
+       if (l->has_endcolon == WITH_COLON) return 1;
+       else if (l->has_endcolon == WITHOUT_COLON) return 0;
 
        g_assert(l->args[0]);
 
        c = atoi(l->args[0]);
-       if(!g_strcasecmp(l->args[0], "MODE"))return 0;
-       if(!g_strcasecmp(l->args[0], "NICK"))return 0;
+       if (!g_strcasecmp(l->args[0], "MODE"))return 0;
+       if (!g_strcasecmp(l->args[0], "NICK"))return 0;
 
        switch(c) {
        case RPL_CHANNELMODEIS:
@@ -218,20 +218,20 @@ char *irc_line_string(const struct line *l)
        g_assert(l);
 
        /* Silently ignore empty messages */
-       if(l->argc == 0) return g_strdup("");
+       if (l->argc == 0) return g_strdup("");
 
-       if(l->origin)len+=strlen(l->origin);
+       if (l->origin)len+=strlen(l->origin);
        for(i = 0; l->args[i]; i++) len+=strlen(l->args[i])+2;
        ret = g_malloc(len+20);
        strcpy(ret, "");
        
-       if(l->origin) sprintf(ret, ":%s ", l->origin);
+       if (l->origin) sprintf(ret, ":%s ", l->origin);
 
        for(i = 0; i < l->argc; i++) {
-               if(i == l->argc-1 && requires_colon(l) && i != 0)
+               if (i == l->argc-1 && requires_colon(l) && i != 0)
                        strcat(ret, ":");
                strcat(ret, l->args[i]);
-               if(i != l->argc-1)strcat(ret, " ");
+               if (i != l->argc-1)strcat(ret, " ");
        }
 
        return ret;
@@ -242,8 +242,8 @@ void free_line(struct line *l) {
        if (l == NULL)
                return;
 
-       if(l->origin)g_free(l->origin);
-       if(l->args) {
+       if (l->origin)g_free(l->origin);
+       if (l->args) {
                for(i = 0; l->args[i]; i++)g_free(l->args[i]);
                g_free(l->args);
        }
@@ -261,7 +261,7 @@ char *line_get_nick(const struct line *l)
 
        nick = g_strdup(l->origin);
        t = strchr(nick, '!');
-       if(t == NULL) 
+       if (t == NULL) 
                return nick;
 
        *t = '\0';
@@ -318,7 +318,7 @@ struct line *linedup(const struct line *l)
 
        ret = g_memdup(l, sizeof(struct line));
 
-       if(l->origin)ret->origin = g_strdup(l->origin);
+       if (l->origin)ret->origin = g_strdup(l->origin);
        ret->args = g_new(char *, ret->argc+MAX_LINE_ARGS);
        for(i = 0; l->args[i]; i++) {
                ret->args[i] = g_strdup(l->args[i]);
index d63f6d9022c9dc08924df452fe274cd2683e252f..81cbe750f0cdef4ac162e99d135340cf04319946 100644 (file)
@@ -105,7 +105,7 @@ static void signal_quit(int sig)
 {
        static int state = 0;
        log_global(LOG_WARNING, "Received signal %d, quitting...", sig);
-       if(state == 1) { 
+       if (state == 1) { 
                signal(SIGINT, SIG_IGN); 
                exit(0);
        }
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
        pc = g_option_context_new("");
        g_option_context_add_main_entries(pc, options, NULL);
 
-       if(!g_option_context_parse(pc, &argc, &argv, NULL))
+       if (!g_option_context_parse(pc, &argc, &argv, NULL))
                return 1;
 
        if (version) {
@@ -217,7 +217,7 @@ int main(int argc, char **argv)
        if (config_dir == NULL) 
                config_dir = g_build_filename(g_get_home_dir(), ".ctrlproxy", NULL);
 
-       if(isdaemon && !logfile) {
+       if (isdaemon && !logfile) {
                logfile = g_build_filename(config_dir, "log", NULL);
        }
 
@@ -232,12 +232,12 @@ int main(int argc, char **argv)
 
        log_global(LOG_INFO, "CtrlProxy %s starting", VERSION);
 
-       if(gethostname(my_hostname, MAXHOSTNAMELEN) != 0) {
+       if (gethostname(my_hostname, MAXHOSTNAMELEN) != 0) {
                log_global(LOG_WARNING, "Can't figure out hostname of local host!");
                return 1;
        }
 
-       if(isdaemon) {
+       if (isdaemon) {
 #ifdef HAVE_DAEMON 
 #ifdef SIGTTOU
                signal(SIGTTOU, SIG_IGN);
@@ -274,7 +274,7 @@ int main(int argc, char **argv)
        if (!g_file_test(tmp, G_FILE_TEST_EXISTS)) {
                char *rcfile = g_build_filename(g_get_home_dir(), ".ctrlproxyrc", NULL);
                
-               if(g_file_test(rcfile, G_FILE_TEST_EXISTS)) {
+               if (g_file_test(rcfile, G_FILE_TEST_EXISTS)) {
                        log_global(LOG_INFO, "Pre-3.0 style .ctrlproxyrc found");
                        log_global(LOG_INFO, "Run ctrlproxy-upgrade to update configuration");
                        return 1;
index 048426d572cc6b871b524cef97762b765402ced6..2fa79ac3ecaff7347f58b986dd4df2836e10de79 100644 (file)
@@ -37,7 +37,7 @@ char ** get_motd_lines(struct client *c)
                return NULL;
 
        fd = g_io_channel_new_file(c->network->global->config->motd_file, "r", &error);
-       if(!fd) {
+       if (!fd) {
                log_global(LOG_ERROR, "Can't open '%s'", c->network->global->config->motd_file);
                return NULL;
        }
index df4faf2071fb85ccae9f5d53c3d1c763612743e2..0bb33eec0f94ccaeeff781af6feb16a54b9c8199 100644 (file)
@@ -62,7 +62,7 @@ static void server_send_login (struct network *s)
        s->linestack = new_linestack(s);
        g_assert(s->linestack != NULL);
 
-       if(s->config->type == NETWORK_TCP && 
+       if (s->config->type == NETWORK_TCP && 
           s->connection.data.tcp.current_server->password) { 
                network_send_args(s, "PASS", 
                                        s->connection.data.tcp.current_server->password, NULL);
@@ -183,7 +183,7 @@ static gboolean process_from_server(struct network *n, struct line *l)
        log_network_line(n, l, TRUE);
 
        /* Silently drop empty messages, as allowed by RFC */
-       if(l->argc == 0) {
+       if (l->argc == 0) {
                return TRUE;
        }
 
@@ -203,20 +203,20 @@ static gboolean process_from_server(struct network *n, struct line *l)
 
        g_assert(l->args[0]);
 
-       if(!g_strcasecmp(l->args[0], "PING")){
+       if (!g_strcasecmp(l->args[0], "PING")){
                network_send_args(n, "PONG", l->args[1], NULL);
                return TRUE;
-       } else if(!g_strcasecmp(l->args[0], "PONG")){
+       } else if (!g_strcasecmp(l->args[0], "PONG")){
                return TRUE;
-       } else if(!g_strcasecmp(l->args[0], "ERROR")) {
+       } else if (!g_strcasecmp(l->args[0], "ERROR")) {
                log_network(LOG_ERROR, n, "error: %s", l->args[1]);
-       } else if(!g_strcasecmp(l->args[0], "433") && 
+       } else if (!g_strcasecmp(l->args[0], "433") && 
                          n->connection.state == NETWORK_CONNECTION_STATE_LOGIN_SENT){
                char *tmp = g_strdup_printf("%s_", l->args[2]);
                network_send_args(n, "NICK", tmp, NULL);
                log_network(LOG_WARNING, n, "%s was already in use, trying %s", l->args[2], tmp);
                g_free(tmp);
-       } else if(atoi(l->args[0]) == RPL_ENDOFMOTD ||
+       } else if (atoi(l->args[0]) == RPL_ENDOFMOTD ||
                          atoi(l->args[0]) == ERR_NOMOTD) {
                GList *gl;
                n->connection.state = NETWORK_CONNECTION_STATE_MOTD_RECVD;
@@ -246,13 +246,13 @@ static gboolean process_from_server(struct network *n, struct line *l)
                {
                        struct channel_config *c = gl->data;
 
-                       if(c->autojoin) {
+                       if (c->autojoin) {
                                network_send_args(n, "JOIN", c->name, c->key, NULL);
                        } 
                }
        } 
 
-       if( n->connection.state == NETWORK_CONNECTION_STATE_MOTD_RECVD) {
+       if ( n->connection.state == NETWORK_CONNECTION_STATE_MOTD_RECVD) {
                gboolean linestack_store = TRUE;
                if (atoi(l->args[0])) {
                        linestack_store &= (!redirect_response(n, l));
@@ -772,7 +772,7 @@ static gboolean connect_current_tcp_server(struct network *s)
 #endif
        }
 
-       if(!ioc) {
+       if (!ioc) {
                log_network(LOG_ERROR, s, "Couldn't connect via server %s:%s", cs->host, cs->port);
                return FALSE;
        }
@@ -854,13 +854,13 @@ static gboolean close_server(struct network *n)
 {
        g_assert(n);
 
-       if(n->connection.state == NETWORK_CONNECTION_STATE_RECONNECT_PENDING) {
+       if (n->connection.state == NETWORK_CONNECTION_STATE_RECONNECT_PENDING) {
                g_source_remove(n->reconnect_id);
                n->reconnect_id = 0;
                n->connection.state = NETWORK_CONNECTION_STATE_NOT_CONNECTED;
        }
 
-       if(n->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
+       if (n->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
                return FALSE;
        } 
 
@@ -939,8 +939,8 @@ void clients_send(GList *clients, struct line *l,
 
        for (g = clients; g; g = g->next) {
                struct client *c = (struct client *)g->data;
-               if(c != exception) {
-                       if(run_client_filter(c, l, FROM_SERVER)) { 
+               if (c != exception) {
+                       if (run_client_filter(c, l, FROM_SERVER)) { 
                                client_send_line(c, l);
                        }
                }
@@ -952,7 +952,7 @@ static pid_t piped_child(char* const command[], int *f_in)
        pid_t pid;
        int sock[2];
 
-       if(socketpair(PF_UNIX, SOCK_STREAM, AF_LOCAL, sock) == -1) {
+       if (socketpair(PF_UNIX, SOCK_STREAM, AF_LOCAL, sock) == -1) {
                log_global(LOG_ERROR, "socketpair: %s", strerror(errno));
                return -1;
        }
@@ -1212,7 +1212,7 @@ void unload_network(struct network *s)
 gboolean disconnect_network(struct network *s)
 {
        g_assert(s);
-       if(s->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
+       if (s->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
                return FALSE;
        }
        log_network(LOG_INFO, s, "Disconnecting");
@@ -1237,7 +1237,7 @@ gboolean verify_client(const struct network *s, const struct client *c)
        
        for (gl = s->clients; gl; gl = gl->next) {
                struct client *nc = (struct client *)gl->data;
-               if(c == nc) return 1;
+               if (c == nc) return 1;
        }
 
        return 0;
index 1744ffb3f1c68d21919a8173ef43a53e7585220e..459ecc05b893ef4301ce0f66bc51677b069fd2fd 100644 (file)
@@ -77,14 +77,14 @@ static gboolean log_data(struct network *n, const struct line *l, enum data_dire
        static char *nickattempt = NULL;
 
        /* User has changed his/her nick. Check whether this nick needs to be identified */
-       if(dir == FROM_SERVER && !g_strcasecmp(l->args[0], "NICK") &&
+       if (dir == FROM_SERVER && !g_strcasecmp(l->args[0], "NICK") &&
           nickattempt && !g_strcasecmp(nickattempt, l->args[1])) {
                nickserv_identify_me(n, l->args[1]);
        }
 
        /* Keep track of the last nick that the user tried to take */
-       if(dir == TO_SERVER && !g_strcasecmp(l->args[0], "NICK")) {
-               if(nickattempt) g_free(nickattempt);
+       if (dir == TO_SERVER && !g_strcasecmp(l->args[0], "NICK")) {
+               if (nickattempt) g_free(nickattempt);
                nickattempt = g_strdup(l->args[1]);
        }
 
@@ -126,9 +126,9 @@ static gboolean log_data(struct network *n, const struct line *l, enum data_dire
        }
 
        /* If we receive a nick-already-in-use message, ghost the current user */
-       if(dir == FROM_SERVER && atol(l->args[0]) == ERR_NICKNAMEINUSE) {
+       if (dir == FROM_SERVER && atol(l->args[0]) == ERR_NICKNAMEINUSE) {
                const char *pass = nickserv_find_nick(n, nickattempt);
-               if(nickattempt && pass) {
+               if (nickattempt && pass) {
                        const char *nickserv_n = nickserv_nick(n);
                        char *raw;
                        
index 813f5b72a3a4f145dd74bec31bef4c05ca352da3..e4e26d256f3eb0d64a97de714ed2a6621e5dbc04 100644 (file)
@@ -31,7 +31,7 @@ gboolean plugin_loaded(const char *name)
        GList *gl;
        for (gl = plugins; gl; gl = gl->next) {
                struct plugin *p = (struct plugin *)gl->data;
-               if(p && p->ops && p->ops->name && !strcmp(p->ops->name, name)) 
+               if (p && p->ops && p->ops->name && !strcmp(p->ops->name, name)) 
                        return TRUE;
        }
        return FALSE;
@@ -47,19 +47,19 @@ struct plugin *load_plugin(const char *modulesdir, const char *name)
        /* Try to load from .so file */
        if (!ops) {
 
-               if(g_file_test(name, G_FILE_TEST_EXISTS))path_name = g_strdup(name);
+               if (g_file_test(name, G_FILE_TEST_EXISTS))path_name = g_strdup(name);
                else path_name = g_module_build_path(modulesdir, name);
        
                m = g_module_open(path_name, 0);
 
-               if(!m) {
+               if (!m) {
                        log_global(LOG_ERROR, "Unable to open module %s(%s), ignoring", path_name, g_module_error());
                        g_free(path_name);
                        g_free(p);
                        return NULL;
                }
 
-               if(!g_module_symbol(m, "plugin", (gpointer)&ops)) {
+               if (!g_module_symbol(m, "plugin", (gpointer)&ops)) {
                        log_global(LOG_ERROR, "%s: No valid plugin information found", 
                                strchr(path_name, '/')?(strrchr(path_name, '/')+1):"error"
                                           );
@@ -69,7 +69,7 @@ struct plugin *load_plugin(const char *modulesdir, const char *name)
                }
        }
 
-       if(plugin_loaded(ops->name)) {
+       if (plugin_loaded(ops->name)) {
                log_global(LOG_WARNING, "%s: Plugin already loaded", ops->name);
                g_free(path_name);
                g_free(p);
@@ -81,7 +81,7 @@ struct plugin *load_plugin(const char *modulesdir, const char *name)
        p->module = m;
        p->ops = ops;
 
-       if(!p->ops->init()) {
+       if (!p->ops->init()) {
                log_global( LOG_ERROR, "%s: Error during initialization.", p->ops->name);
                g_free(p);
                return NULL;
@@ -96,7 +96,7 @@ gboolean init_plugins(const char *plugin_dir)
 {
        gboolean ret = TRUE;
 
-       if(!g_module_supported()) {
+       if (!g_module_supported()) {
                log_global(LOG_WARNING, "DSO's not supported on this platform. Not loading any plugins");
        } else {
                const char *name;
index d499b34b3daf5e501bf1f58a0182bd36d54699be..13fc95395ece10474969941c161404ff4bfd04c9 100644 (file)
@@ -528,7 +528,7 @@ static int is_reply(const int *replies, int r)
        g_assert(replies != NULL);
 
        for(i = 0; i < 20 && replies[i]; i++) {
-               if(replies[i] == r) return 1;
+               if (replies[i] == r) return 1;
        }
        return 0;
 }
@@ -537,7 +537,7 @@ static struct query *find_query(char *name)
 {
        int i;
        for(i = 0; queries[i].name; i++) {
-               if(!g_strcasecmp(queries[i].name, name)) return &queries[i];
+               if (!g_strcasecmp(queries[i].name, name)) return &queries[i];
        }
 
        return NULL;
@@ -563,7 +563,7 @@ gboolean redirect_response(struct network *network, struct line *l)
 
        /* Find a request that this response is a reply to */
        for (s = stack; s; s = s->next) {
-               if(s->network == network && 
+               if (s->network == network && 
                   (is_reply(s->query->replies, n) || 
                        is_reply(s->query->errors, n) ||
                        is_reply(s->query->end_replies, n))) {
index 0bd4286cf1304f6562c879e58bf01dd1d91e8987..08247e01f2fb61e592d05cc0807725471e60e514 100644 (file)
@@ -42,7 +42,7 @@ char *mode2string(char modes[255])
        int pos = 0;
        ret[0] = '\0';
        for(i = 0; i < 255; i++) {
-               if(modes[i]) { ret[pos] = (char)i; pos++; }
+               if (modes[i]) { ret[pos] = (char)i; pos++; }
        }
        ret[pos] = '\0';
 
@@ -82,7 +82,7 @@ static void client_send_channel_state(struct client *c,
                char mode[2] = { ch->mode, 0 };
                char *tmp;
                n = (struct channel_nick *)nl->data;
-               if(n->mode && n->mode != ' ') {
+               if (n->mode && n->mode != ' ') {
                        tmp = g_strdup_printf("%c%s", n->mode, n->global_nick->nick);
                } else  { 
                        tmp = g_strdup(n->global_nick->nick);
index afde8f04f8ea958993ac1c98c0a59a02bfda0f05..08ba845f9a74fb928145f4be0ce88c77f7c89d48 100644 (file)
@@ -507,7 +507,7 @@ struct ctrlproxy_config *load_configuration(const char *dir)
     else 
            cfg->client_charset = NULL;
 
-       if(!g_file_test(cfg->motd_file, G_FILE_TEST_EXISTS))
+       if (!g_file_test(cfg->motd_file, G_FILE_TEST_EXISTS))
                log_global(LOG_ERROR, "Can't open MOTD file '%s' for reading", cfg->motd_file);
 
     if (g_key_file_has_key(kf, "admin", "without_privmsg", NULL))
index e0533027ac288de76f6c40efb3ae49a3daf07c7e..e6b0051904cbaff6488bf47e632277da7edd8c18 100644 (file)
@@ -194,7 +194,7 @@ struct channel_state *find_channel(struct network_state *st, const char *name)
        for (cl = st->channels; cl; cl = cl->next) {
                struct channel_state *c = (struct channel_state *)cl->data;
 
-               if(!irccmp(&st->info, c->name, name)) 
+               if (!irccmp(&st->info, c->name, name)) 
                        return c;
        }
        return NULL;
@@ -207,7 +207,7 @@ struct channel_state *find_add_channel(struct network_state *st, char *name)
        g_assert(name);
        
        c = find_channel(st, name);
-       if(c)
+       if (c)
                return c;
        c = g_new0(struct channel_state ,1);
        c->network = st;
@@ -238,7 +238,7 @@ struct channel_nick *find_channel_nick(struct channel_state *c,
 
        for (l = c->nicks; l; l = l->next) {
                struct channel_nick *n = (struct channel_nick *)l->data;
-               if(!irccmp(&c->network->info, n->global_nick->nick, realname))
+               if (!irccmp(&c->network->info, n->global_nick->nick, realname))
                        return n;
        }
 
@@ -262,7 +262,7 @@ struct channel_nick *find_channel_nick_hostmask(struct channel_state *c,
        g_assert(c->network);
        for (l = c->nicks; l; l = l->next) {
                struct channel_nick *n = (struct channel_nick *)l->data;
-               if(!irccmp(&c->network->info, n->global_nick->hostmask, hm))
+               if (!irccmp(&c->network->info, n->global_nick->hostmask, hm))
                        return n;
        }
 
@@ -289,7 +289,7 @@ struct network_nick *find_network_nick(struct network_state *n,
 
        for (gl = n->nicks; gl; gl = gl->next) {
                struct network_nick *ndd = (struct network_nick*)gl->data;
-               if(!irccmp(&n->info, ndd->nick, name)) {
+               if (!irccmp(&n->info, ndd->nick, name)) {
                        return ndd;
                }
        }
@@ -517,7 +517,7 @@ static void handle_333(struct network_state *s, struct line *l)
 {
        struct channel_state *c = find_channel(s, l->args[2]);
 
-       if(!c) {
+       if (!c) {
                log_network_state(LOG_WARNING, s, 
                                "Can't set topic last set time for unknown channel '%s'!", 
                                l->args[2]);
@@ -778,7 +778,7 @@ static void handle_mode(struct network_state *s, struct line *l)
                                case 'l':
                                        c->modes[(unsigned char)'l'] = t;
                                    if (t) {
-                                               if(!l->args[++arg]) {
+                                               if (!l->args[++arg]) {
                                                        log_network_state(LOG_WARNING, s, "Mode +l requires argument, but no argument found");
                                                        break;
                                                }
@@ -790,7 +790,7 @@ static void handle_mode(struct network_state *s, struct line *l)
                                case 'k':
                                        c->modes[(unsigned char)'k'] = t;
                                        if (t) {
-                                               if(!l->args[++arg]) {
+                                               if (!l->args[++arg]) {
                                                        log_network_state(LOG_WARNING, s, "Mode k requires argument, but no argument found");
                                                        break;
                                                }
@@ -805,11 +805,11 @@ static void handle_mode(struct network_state *s, struct line *l)
                                        break;
                                default:
                                          p = get_prefix_by_mode(l->args[2][i], &s->info);
-                                         if(p == ' ') {
+                                         if (p == ' ') {
                                                  c->modes[(unsigned char)l->args[2][i]] = t;
                                          } else {
                                                        n = find_channel_nick(c, l->args[++arg]);
-                                                       if(!n) {
+                                                       if (!n) {
                                                                log_network_state(LOG_WARNING, s, "Can't set mode %c%c on nick %s on channel %s, because nick does not exist!", t == ADD?'+':'-', l->args[2][i], l->args[arg], l->args[1]);
                                                                break;
                                                        }
index 1428246bf58d6813a0bd1246040a28863ea9393c..534ee74a83bdd11c2044a214d1b1aebc1ca60021 100644 (file)
@@ -122,7 +122,7 @@ int main (int argc, char **argv)
        pc = g_option_context_new("");
        g_option_context_add_main_entries(pc, options, NULL);
 
-       if(!g_option_context_parse(pc, &argc, &argv, NULL))
+       if (!g_option_context_parse(pc, &argc, &argv, NULL))
                return 1;
 
        g_option_context_free(pc);