diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-06-15 14:22:17 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-06-15 14:22:17 +0200 |
commit | 79e826a028f4b4c62c0c16e20af1fb13a9636324 (patch) | |
tree | 5ddc446344fd7659ae847efc00f7ff70a8e3764a | |
parent | 5a5c926ec0dffa4b28895929c092089c2a9b9d9f (diff) |
Converted irc->status to binary flags. (This also fixes auto-save-on-quit
that broke because of USTATUS_SHUTDOWN. :-( )
-rw-r--r-- | bitlbee.c | 2 | ||||
-rw-r--r-- | ipc.c | 10 | ||||
-rw-r--r-- | irc.c | 10 | ||||
-rw-r--r-- | irc.h | 8 | ||||
-rw-r--r-- | irc_commands.c | 6 | ||||
-rw-r--r-- | root_commands.c | 6 | ||||
-rw-r--r-- | storage_text.c | 4 |
7 files changed, 23 insertions, 23 deletions
@@ -235,7 +235,7 @@ gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condi irc->sendbuffer = NULL; irc->w_watch_source_id = 0; - if( irc->status == USTATUS_SHUTDOWN ) + if( irc->status & USTATUS_SHUTDOWN ) irc_free( irc ); return( FALSE ); @@ -114,7 +114,7 @@ static void ipc_child_cmd_die( irc_t *irc, char **cmd ) static void ipc_child_cmd_wallops( irc_t *irc, char **cmd ) { - if( irc->status < USTATUS_LOGGED_IN ) + if( ! irc->status & USTATUS_LOGGED_IN ) return; if( strchr( irc->umode, 'w' ) ) @@ -123,7 +123,7 @@ static void ipc_child_cmd_wallops( irc_t *irc, char **cmd ) static void ipc_child_cmd_lilo( irc_t *irc, char **cmd ) { - if( irc->status < USTATUS_LOGGED_IN ) + if( ! irc->status & USTATUS_LOGGED_IN ) return; if( strchr( irc->umode, 's' ) ) @@ -132,7 +132,7 @@ static void ipc_child_cmd_lilo( irc_t *irc, char **cmd ) static void ipc_child_cmd_opermsg( irc_t *irc, char **cmd ) { - if( irc->status < USTATUS_LOGGED_IN ) + if( ! irc->status & USTATUS_LOGGED_IN ) return; if( strchr( irc->umode, 'o' ) ) @@ -153,7 +153,7 @@ static void ipc_child_cmd_rehash( irc_t *irc, char **cmd ) static void ipc_child_cmd_kill( irc_t *irc, char **cmd ) { - if( irc->status < USTATUS_LOGGED_IN ) + if( ! irc->status & USTATUS_LOGGED_IN ) return; if( nick_cmp( cmd[1], irc->nick ) != 0 ) @@ -165,7 +165,7 @@ static void ipc_child_cmd_kill( irc_t *irc, char **cmd ) static void ipc_child_cmd_hello( irc_t *irc, char **cmd ) { - if( irc->status < USTATUS_LOGGED_IN ) + if( ! irc->status & USTATUS_LOGGED_IN ) ipc_to_master_str( "HELLO\r\n" ); else ipc_to_master_str( "HELLO %s %s :%s\r\n", irc->host, irc->nick, irc->realname ); @@ -178,7 +178,7 @@ void irc_abort( irc_t *irc, int immed, char *format, ... ) irc->nick ? irc->nick : "(NONE)", irc->host, "No reason given" ); } - irc->status = USTATUS_SHUTDOWN; + irc->status |= USTATUS_SHUTDOWN; if( irc->sendbuffer && !immed ) { /* We won't read from this socket anymore. Instead, we'll connect a timer @@ -212,7 +212,7 @@ void irc_free(irc_t * irc) log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); - if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) + if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) if( storage_save( irc, TRUE ) != STORAGE_OK ) irc_usermsg( irc, "Error while saving settings!" ); @@ -700,7 +700,7 @@ int irc_check_login( irc_t *irc ) { if( irc->user && irc->nick ) { - if( global.conf->authmode == AUTHMODE_CLOSED && irc->status < USTATUS_AUTHORIZED ) + if( global.conf->authmode == AUTHMODE_CLOSED && ! irc->status & USTATUS_AUTHORIZED ) { irc_reply( irc, 464, ":This server is password-protected." ); return 0; @@ -757,7 +757,7 @@ void irc_login( irc_t *irc ) if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname ); - irc->status = USTATUS_LOGGED_IN; + irc->status |= USTATUS_LOGGED_IN; } void irc_motd( irc_t *irc ) @@ -1180,7 +1180,7 @@ static gboolean irc_userping( gpointer _irc ) irc_t *irc = _irc; int rv = 0; - if( irc->status < USTATUS_LOGGED_IN ) + if( ! irc->status & USTATUS_LOGGED_IN ) { if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) ) rv = gettime() - irc->last_pong; @@ -41,10 +41,10 @@ typedef enum { USTATUS_OFFLINE = 0, - USTATUS_AUTHORIZED, - USTATUS_LOGGED_IN, - USTATUS_IDENTIFIED, - USTATUS_SHUTDOWN = -1 + USTATUS_AUTHORIZED = 1, + USTATUS_LOGGED_IN = 2, + USTATUS_IDENTIFIED = 4, + USTATUS_SHUTDOWN = 8 } irc_status_t; typedef struct channel diff --git a/irc_commands.c b/irc_commands.c index dc59f7ee..519070db 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -31,7 +31,7 @@ static void irc_cmd_pass( irc_t *irc, char **cmd ) { if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 ) { - irc->status = USTATUS_AUTHORIZED; + irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); } else @@ -609,11 +609,11 @@ void irc_exec( irc_t *irc, char *cmd[] ) /* There should be no typo in the next line: */ for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --; - if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >= USTATUS_LOGGED_IN ) + if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN ) { irc_reply( irc, 462, ":Only allowed before logging in" ); } - else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN ) + else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && ! irc->status & USTATUS_LOGGED_IN ) { irc_reply( irc, 451, ":Register first" ); } diff --git a/root_commands.c b/root_commands.c index 0e12e9ab..d8611347 100644 --- a/root_commands.c +++ b/root_commands.c @@ -162,7 +162,7 @@ static void cmd_register( irc_t *irc, char **cmd ) break; case STORAGE_OK: - irc->status = USTATUS_IDENTIFIED; + irc->status |= USTATUS_IDENTIFIED; irc_umode_set( irc, "+R", 1 ); break; @@ -186,7 +186,7 @@ static void cmd_drop( irc_t *irc, char **cmd ) break; case STORAGE_OK: irc_setpass( irc, NULL ); - irc->status = USTATUS_LOGGED_IN; + irc->status &= ~USTATUS_IDENTIFIED; irc_umode_set( irc, "-R", 1 ); irc_usermsg( irc, "Account `%s' removed", irc->nick ); break; @@ -200,7 +200,7 @@ static void cmd_account( irc_t *irc, char **cmd ) { account_t *a; - if( global.conf->authmode == AUTHMODE_REGISTERED && irc->status < USTATUS_IDENTIFIED ) + if( global.conf->authmode == AUTHMODE_REGISTERED && ! irc->status & USTATUS_IDENTIFIED ) { irc_usermsg( irc, "This server only accepts registered users" ); return; diff --git a/storage_text.c b/storage_text.c index f807cb3e..506c9f03 100644 --- a/storage_text.c +++ b/storage_text.c @@ -70,7 +70,7 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i FILE *fp; user_t *ru = user_find( irc, ROOT_NICK ); - if( irc->status >= USTATUS_IDENTIFIED ) + if( irc->status & USTATUS_IDENTIFIED ) return( 1 ); g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".accounts" ); @@ -87,7 +87,7 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i /* Do this now. If the user runs with AuthMode = Registered, the account command will not work otherwise. */ - irc->status = USTATUS_IDENTIFIED; + irc->status |= USTATUS_IDENTIFIED; while( fscanf( fp, "%511[^\n]s", s ) > 0 ) { |