Changeset 5898ef8
- Timestamp:
- 2006-06-15T12:46:31Z (18 years ago)
- Branches:
- master
- Children:
- 10efa91
- Parents:
- c121f89 (diff), 79e826a (diff), 3af70b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
rc121f89 r5898ef8 228 228 irc->w_watch_source_id = 0; 229 229 230 if( irc->status ==USTATUS_SHUTDOWN )230 if( irc->status & USTATUS_SHUTDOWN ) 231 231 irc_free( irc ); 232 232 -
ipc.c
rc121f89 r5898ef8 115 115 static void ipc_child_cmd_wallops( irc_t *irc, char **cmd ) 116 116 { 117 if( irc->status < USTATUS_LOGGED_IN)117 if( !( irc->status & USTATUS_LOGGED_IN ) ) 118 118 return; 119 119 … … 124 124 static void ipc_child_cmd_lilo( irc_t *irc, char **cmd ) 125 125 { 126 if( irc->status < USTATUS_LOGGED_IN)126 if( !( irc->status & USTATUS_LOGGED_IN ) ) 127 127 return; 128 128 … … 133 133 static void ipc_child_cmd_opermsg( irc_t *irc, char **cmd ) 134 134 { 135 if( irc->status < USTATUS_LOGGED_IN)135 if( !( irc->status & USTATUS_LOGGED_IN ) ) 136 136 return; 137 137 … … 154 154 static void ipc_child_cmd_kill( irc_t *irc, char **cmd ) 155 155 { 156 if( irc->status < USTATUS_LOGGED_IN)156 if( !( irc->status & USTATUS_LOGGED_IN ) ) 157 157 return; 158 158 … … 166 166 static void ipc_child_cmd_hello( irc_t *irc, char **cmd ) 167 167 { 168 if( irc->status < USTATUS_LOGGED_IN)168 if( !( irc->status & USTATUS_LOGGED_IN ) ) 169 169 ipc_to_master_str( "HELLO\r\n" ); 170 170 else -
irc.c
rc121f89 r5898ef8 177 177 } 178 178 179 irc->status = USTATUS_SHUTDOWN;179 irc->status |= USTATUS_SHUTDOWN; 180 180 if( irc->sendbuffer && !immed ) 181 181 { … … 211 211 log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); 212 212 213 if( irc->status >=USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )213 if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) 214 214 if( storage_save( irc, TRUE ) != STORAGE_OK ) 215 215 irc_usermsg( irc, "Error while saving settings!" ); … … 577 577 578 578 /* Don't try to write anything new anymore when shutting down. */ 579 if( irc->status ==USTATUS_SHUTDOWN )579 if( irc->status & USTATUS_SHUTDOWN ) 580 580 return; 581 581 … … 707 707 if( irc->user && irc->nick ) 708 708 { 709 if( global.conf->authmode == AUTHMODE_CLOSED && irc->status < USTATUS_AUTHORIZED)709 if( global.conf->authmode == AUTHMODE_CLOSED && !( irc->status & USTATUS_AUTHORIZED ) ) 710 710 { 711 711 irc_reply( irc, 464, ":This server is password-protected." ); … … 764 764 ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname ); 765 765 766 irc->status = USTATUS_LOGGED_IN;766 irc->status |= USTATUS_LOGGED_IN; 767 767 } 768 768 … … 1187 1187 int rv = 0; 1188 1188 1189 if( irc->status < USTATUS_LOGGED_IN)1189 if( !( irc->status & USTATUS_LOGGED_IN ) ) 1190 1190 { 1191 1191 if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) ) -
irc.h
rc121f89 r5898ef8 42 42 { 43 43 USTATUS_OFFLINE = 0, 44 USTATUS_AUTHORIZED ,45 USTATUS_LOGGED_IN ,46 USTATUS_IDENTIFIED ,47 USTATUS_SHUTDOWN = -144 USTATUS_AUTHORIZED = 1, 45 USTATUS_LOGGED_IN = 2, 46 USTATUS_IDENTIFIED = 4, 47 USTATUS_SHUTDOWN = 8 48 48 } irc_status_t; 49 49 -
irc_commands.c
rc121f89 r5898ef8 32 32 if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 ) 33 33 { 34 irc->status = USTATUS_AUTHORIZED;34 irc->status |= USTATUS_AUTHORIZED; 35 35 irc_check_login( irc ); 36 36 } … … 610 610 for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --; 611 611 612 if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >=USTATUS_LOGGED_IN )612 if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN ) 613 613 { 614 614 irc_reply( irc, 462, ":Only allowed before logging in" ); 615 615 } 616 else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN)616 else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && !( irc->status & USTATUS_LOGGED_IN ) ) 617 617 { 618 618 irc_reply( irc, 451, ":Register first" ); -
protocols/msn/msn.c
rc121f89 r5898ef8 64 64 GSList *l; 65 65 66 if( md->fd >= 0 ) 67 closesocket( md->fd ); 68 69 if( md->handler ) 70 { 71 if( md->handler->rxq ) g_free( md->handler->rxq ); 72 if( md->handler->cmd_text ) g_free( md->handler->cmd_text ); 73 g_free( md->handler ); 74 } 75 76 while( md->switchboards ) 77 msn_sb_destroy( md->switchboards->data ); 78 79 if( md->msgq ) 80 { 81 struct msn_message *m; 82 83 for( l = md->msgq; l; l = l->next ) 84 { 85 m = l->data; 86 87 serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); 88 g_free( m->who ); 89 g_free( m->text ); 90 g_free( m ); 91 } 92 g_slist_free( md->msgq ); 66 if( md ) 67 { 68 if( md->fd >= 0 ) 69 closesocket( md->fd ); 70 71 if( md->handler ) 72 { 73 if( md->handler->rxq ) g_free( md->handler->rxq ); 74 if( md->handler->cmd_text ) g_free( md->handler->cmd_text ); 75 g_free( md->handler ); 76 } 77 78 while( md->switchboards ) 79 msn_sb_destroy( md->switchboards->data ); 80 81 if( md->msgq ) 82 { 83 struct msn_message *m; 84 85 for( l = md->msgq; l; l = l->next ) 86 { 87 m = l->data; 88 89 serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); 90 g_free( m->who ); 91 g_free( m->text ); 92 g_free( m ); 93 } 94 g_slist_free( md->msgq ); 95 } 96 97 g_free( md ); 93 98 } 94 99 … … 100 105 g_free( l->data ); 101 106 g_slist_free( gc->deny ); 102 103 g_free( md );104 107 105 108 msn_connections = g_slist_remove( msn_connections, gc ); -
root_commands.c
rc121f89 r5898ef8 164 164 165 165 case STORAGE_OK: 166 irc->status = USTATUS_IDENTIFIED;166 irc->status |= USTATUS_IDENTIFIED; 167 167 irc_umode_set( irc, "+R", 1 ); 168 168 break; … … 188 188 case STORAGE_OK: 189 189 irc_setpass( irc, NULL ); 190 irc->status = USTATUS_LOGGED_IN;190 irc->status &= ~USTATUS_IDENTIFIED; 191 191 irc_umode_set( irc, "-R", 1 ); 192 192 irc_usermsg( irc, "Account `%s' removed", irc->nick ); … … 202 202 account_t *a; 203 203 204 if( global.conf->authmode == AUTHMODE_REGISTERED && irc->status < USTATUS_IDENTIFIED)204 if( global.conf->authmode == AUTHMODE_REGISTERED && !( irc->status & USTATUS_IDENTIFIED ) ) 205 205 { 206 206 irc_usermsg( irc, "This server only accepts registered users" ); -
storage_text.c
rc121f89 r5898ef8 71 71 user_t *ru = user_find( irc, ROOT_NICK ); 72 72 73 if( irc->status >=USTATUS_IDENTIFIED )73 if( irc->status & USTATUS_IDENTIFIED ) 74 74 return( 1 ); 75 75 … … 88 88 /* Do this now. If the user runs with AuthMode = Registered, the 89 89 account command will not work otherwise. */ 90 irc->status = USTATUS_IDENTIFIED;90 irc->status |= USTATUS_IDENTIFIED; 91 91 92 92 while( fscanf( fp, "%511[^\n]s", s ) > 0 ) -
storage_xml.c
rc121f89 r5898ef8 169 169 static void xml_end_element( GMarkupParseContext *ctx, const gchar *element_name, gpointer data, GError **error ) 170 170 { 171 struct xml_parsedata *xd = data; 172 // irc_t *irc = xd->irc; 173 174 if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting ) 175 { 176 g_free( xd->current_setting ); 177 xd->current_setting = NULL; 178 } 179 else if( g_strcasecmp( element_name, "account" ) == 0 ) 180 { 181 xd->current_account = NULL; 182 } 171 183 } 172 184 … … 188 200 xd->current_setting = NULL; 189 201 } 190 }191 192 static void xml_error( GMarkupParseContext *ctx, GError *error, gpointer data )193 {194 202 } 195 203 … … 200 208 xml_text, 201 209 NULL, 202 xml_error210 NULL 203 211 }; 204 212 … … 219 227 int fd, st; 220 228 221 if( irc->status >=USTATUS_IDENTIFIED )229 if( irc->status & USTATUS_IDENTIFIED ) 222 230 return( 1 ); 223 231 … … 244 252 { 245 253 g_markup_parse_context_free( ctx ); 254 close( fd ); 246 255 247 /* TODO: Display useful error msg */ 248 256 /* Slightly dirty... */ 249 257 if( gerr && strcmp( gerr->message, XML_PASS_ERRORMSG ) == 0 ) 250 258 return STORAGE_INVALID_PASSWORD; 251 259 else 260 { 261 if( gerr ) 262 irc_usermsg( irc, "Error from XML-parser: %s", gerr->message ); 263 252 264 return STORAGE_OTHER_ERROR; 265 } 253 266 } 254 267 } 255 268 256 269 g_markup_parse_context_free( ctx ); 257 258 irc->status = USTATUS_IDENTIFIED; 270 close( fd ); 271 272 irc->status |= USTATUS_IDENTIFIED; 259 273 260 274 if( set_getint( irc, "auto_connect" ) ) … … 268 282 } 269 283 284 static int xml_printf( int fd, char *fmt, ... ) 285 { 286 va_list params; 287 char *out; 288 int len; 289 290 va_start( params, fmt ); 291 out = g_markup_vprintf_escaped( fmt, params ); 292 va_end( params ); 293 294 len = strlen( out ); 295 len -= write( fd, out, len ); 296 g_free( out ); 297 298 return len == 0; 299 } 300 270 301 static storage_status_t xml_save( irc_t *irc, int overwrite ) 271 302 { 272 /* if (!overwrite) { 273 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 274 if (access( path, F_OK ) != -1) 275 return STORAGE_ALREADY_EXISTS; 276 277 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 278 if (access( path, F_OK ) != -1) 279 return STORAGE_ALREADY_EXISTS; 280 } 281 */ 303 char path[512], *path2; 304 set_t *set; 305 nick_t *nick; 306 account_t *acc; 307 int fd; 308 309 g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, irc->nick, ".xml" ); 310 311 if( !overwrite && access( path, F_OK ) != -1 ) 312 return STORAGE_ALREADY_EXISTS; 313 314 strcat( path, "~" ); 315 if( ( fd = open( path, O_WRONLY | O_CREAT, 0600 ) ) < 0 ) 316 { 317 irc_usermsg( irc, "Error while opening configuration file." ); 318 return STORAGE_OTHER_ERROR; 319 } 320 321 if( !xml_printf( fd, "<user nick=\"%s\" password=\"%s\">\n", irc->nick, irc->password ) ) 322 goto write_error; 323 324 for( set = irc->set; set; set = set->next ) 325 if( set->value && set->def ) 326 if( !xml_printf( fd, "\t<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) 327 goto write_error; 328 329 for( acc = irc->accounts; acc; acc = acc->next ) 330 { 331 if( !xml_printf( fd, "\t<account protocol=\"%s\" handle=\"%s\" password=\"%s\" autoconnect=\"%s\"", acc->prpl->name, acc->user, acc->pass, "yes" ) ) 332 goto write_error; 333 if( acc->server && acc->server[0] && !xml_printf( fd, " server=\"%s\"", acc->server ) ) 334 goto write_error; 335 if( !xml_printf( fd, ">\n" ) ) 336 goto write_error; 337 338 for( nick = irc->nicks; nick; nick = nick->next ) 339 if( nick->proto == acc->prpl ) 340 if( !xml_printf( fd, "\t\t<buddy handle=\"%s\" nick=\"%s\" />\n", nick->handle, nick->nick ) ) 341 goto write_error; 342 343 if( !xml_printf( fd, "\t</account>\n" ) ) 344 goto write_error; 345 } 346 347 if( !xml_printf( fd, "</user>\n" ) ) 348 goto write_error; 349 350 close( fd ); 351 352 path2 = g_strndup( path, strlen( path ) - 1 ); 353 if( rename( path, path2 ) != 0 ) 354 { 355 irc_usermsg( irc, "Error while renaming temporary configuration file." ); 356 357 g_free( path2 ); 358 unlink( path ); 359 360 return STORAGE_OTHER_ERROR; 361 } 362 363 g_free( path2 ); 364 282 365 return STORAGE_OK; 366 367 write_error: 368 irc_usermsg( irc, "Write error. Disk full?" ); 369 close( fd ); 370 371 return STORAGE_OTHER_ERROR; 283 372 } 284 373
Note: See TracChangeset
for help on using the changeset viewer.