Changeset 89db90e for storage_xml.c


Ignore:
Timestamp:
2015-03-12T09:10:16Z (9 years ago)
Author:
dequis <dx@…>
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.
Message:

Merge branch 'develop' into feat/hip-cat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage_xml.c

    r0e4c3dd r89db90e  
    103103        if (protocol) {
    104104                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                }
    105109                local = protocol_account_islocal(protocol);
    106110        }
     
    197201        fn = g_strconcat(global.conf->configdir, xd->given_nick, ".xml", NULL);
    198202        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                }
    200208                goto error;
    201209        }
     
    259267
    260268
    261 static gboolean xml_generate_nick(gpointer key, gpointer value, gpointer data);
    262269static void xml_generate_settings(struct xt_node *cur, set_t **head);
    263270
     
    292299
    293300        for (acc = irc->b->accounts; acc; acc = acc->next) {
     301                GHashTableIter iter;
     302                gpointer key, value;
    294303                unsigned char *pass_cr;
    295304                char *pass_b64;
     
    312321                g_free(pass_b64);
    313322
    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                }
    322330
    323331                xml_generate_settings(cur, &acc->set);
     
    343351
    344352        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;
    356353}
    357354
     
    388385        strcat(path, ".XXXXXX");
    389386        if ((fd = mkstemp(path)) < 0) {
    390                 irc_rootmsg(irc, "Error while opening configuration file.");
    391                 return STORAGE_OTHER_ERROR;
     387                goto error;
    392388        }
    393389
     
    411407
    412408error:
    413         irc_rootmsg(irc, "Write error. Disk full?");
     409        irc_rootmsg(irc, "Write error: %s", g_strerror(errno));
    414410        ret = STORAGE_OTHER_ERROR;
    415411
Note: See TracChangeset for help on using the changeset viewer.