Changeset 89db90e for storage_xml.c
- Timestamp:
- 2015-03-12T09:10:16Z (9 years ago)
- Children:
- fc650a8
- Parents:
- 0e4c3dd (diff), 3bb333c (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
storage_xml.c
r0e4c3dd r89db90e 103 103 if (protocol) { 104 104 prpl = find_protocol(protocol); 105 if (!prpl) { 106 irc_rootmsg(xd->irc, "Error loading user config: Protocol not found: `%s'", protocol); 107 return XT_ABORT; 108 } 105 109 local = protocol_account_islocal(protocol); 106 110 } … … 197 201 fn = g_strconcat(global.conf->configdir, xd->given_nick, ".xml", NULL); 198 202 if ((fd = open(fn, O_RDONLY)) < 0) { 199 ret = STORAGE_NO_SUCH_USER; 203 if (errno == ENOENT) { 204 ret = STORAGE_NO_SUCH_USER; 205 } else { 206 irc_rootmsg(irc, "Error loading user config: %s", g_strerror(errno)); 207 } 200 208 goto error; 201 209 } … … 259 267 260 268 261 static gboolean xml_generate_nick(gpointer key, gpointer value, gpointer data);262 269 static void xml_generate_settings(struct xt_node *cur, set_t **head); 263 270 … … 292 299 293 300 for (acc = irc->b->accounts; acc; acc = acc->next) { 301 GHashTableIter iter; 302 gpointer key, value; 294 303 unsigned char *pass_cr; 295 304 char *pass_b64; … … 312 321 g_free(pass_b64); 313 322 314 /* This probably looks pretty strange. g_hash_table_foreach 315 is quite a PITA already (but it can't get much better in 316 C without using #define, I'm afraid), and it 317 doesn't seem to be possible to abort the foreach on write 318 errors, so instead let's use the _find function and 319 return TRUE on write errors. Which means, if we found 320 something, there was an error. :-) */ 321 g_hash_table_find(acc->nicks, xml_generate_nick, cur); 323 g_hash_table_iter_init(&iter, acc->nicks); 324 while (g_hash_table_iter_next(&iter, &key, &value)) { 325 struct xt_node *node = xt_new_node("buddy", NULL, NULL); 326 xt_add_attr(node, "handle", key); 327 xt_add_attr(node, "nick", value); 328 xt_add_child(cur, node); 329 } 322 330 323 331 xml_generate_settings(cur, &acc->set); … … 343 351 344 352 return root; 345 }346 347 static gboolean xml_generate_nick(gpointer key, gpointer value, gpointer data)348 {349 struct xt_node *node = xt_new_node("buddy", NULL, NULL);350 351 xt_add_attr(node, "handle", key);352 xt_add_attr(node, "nick", value);353 xt_add_child((struct xt_node *) data, node);354 355 return FALSE;356 353 } 357 354 … … 388 385 strcat(path, ".XXXXXX"); 389 386 if ((fd = mkstemp(path)) < 0) { 390 irc_rootmsg(irc, "Error while opening configuration file."); 391 return STORAGE_OTHER_ERROR; 387 goto error; 392 388 } 393 389 … … 411 407 412 408 error: 413 irc_rootmsg(irc, "Write error . Disk full?");409 irc_rootmsg(irc, "Write error: %s", g_strerror(errno)); 414 410 ret = STORAGE_OTHER_ERROR; 415 411
Note: See TracChangeset
for help on using the changeset viewer.