Changeset 84e9cea
- Timestamp:
- 2006-06-20T21:36:53Z (18 years ago)
- Branches:
- master
- Children:
- 2befb95
- Parents:
- d028a77
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
storage_xml.c
rd028a77 r84e9cea 35 35 } xml_pass_st; 36 36 37 /* This isn't very clean, probably making a separate error class + code for 38 BitlBee would be a better solution. But this will work for now... */ 37 39 #define XML_PASS_ERRORMSG "Wrong username or password" 38 40 … … 194 196 { 195 197 struct xml_parsedata *xd = data; 196 // irc_t *irc = xd->irc;197 198 198 199 if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting ) … … 215 216 { 216 217 /* Let's not parse anything else if we only have to check 217 the password. */ 218 the password, or if we didn't get the chance to check it 219 yet. */ 218 220 } 219 221 else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && … … 243 245 } 244 246 245 static storage_status_t xml_load ( const char *my_nick, const char *password, irc_t *irc)247 static storage_status_t xml_load_real( const char *my_nick, const char *password, irc_t *irc, xml_pass_st action ) 246 248 { 247 249 GMarkupParseContext *ctx; … … 251 253 int fd, st; 252 254 253 if( irc ->status & USTATUS_IDENTIFIED )255 if( irc && irc->status & USTATUS_IDENTIFIED ) 254 256 return( 1 ); 255 257 … … 258 260 xd->given_nick = g_strdup( my_nick ); 259 261 xd->given_pass = g_strdup( password ); 262 xd->pass_st = action; 260 263 nick_lc( xd->given_nick ); 261 264 … … 283 286 else 284 287 { 285 if( gerr )288 if( gerr && irc ) 286 289 irc_usermsg( irc, "Error from XML-parser: %s", gerr->message ); 287 290 … … 294 297 close( fd ); 295 298 299 if( action == XML_PASS_CHECK_ONLY ) 300 return STORAGE_OK; 301 296 302 irc->status |= USTATUS_IDENTIFIED; 297 303 … … 304 310 305 311 return STORAGE_OK; 312 } 313 314 static storage_status_t xml_load( const char *my_nick, const char *password, irc_t *irc ) 315 { 316 return xml_load_real( my_nick, password, irc, XML_PASS_UNKNOWN ); 317 } 318 319 static storage_status_t xml_check_pass( const char *my_nick, const char *password ) 320 { 321 /* This is a little bit risky because we have to pass NULL for the 322 irc_t argument. This *should* be fine, if I didn't miss anything... */ 323 return xml_load_real( my_nick, password, NULL, XML_PASS_CHECK_ONLY ); 306 324 } 307 325 … … 396 414 } 397 415 416 static storage_status_t xml_remove( const char *nick, const char *password ) 417 { 418 char s[512]; 419 storage_status_t status; 420 421 status = xml_check_pass( nick, password ); 422 if( status != STORAGE_OK ) 423 return status; 424 425 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, nick, ".xml" ); 426 if( unlink( s ) == -1 ) 427 return STORAGE_OTHER_ERROR; 428 429 return STORAGE_OK; 430 } 431 398 432 storage_t storage_xml = { 399 433 .name = "xml", 400 434 .init = xml_init, 401 //.check_pass = xml_check_pass,402 //.remove = xml_remove,435 .check_pass = xml_check_pass, 436 .remove = xml_remove, 403 437 .load = xml_load, 404 438 .save = xml_save
Note: See TracChangeset
for help on using the changeset viewer.