static void cmd_drop(irc_t *irc, char **cmd) { storage_status_t status; status = auth_check_pass(irc, irc->user->nick, cmd[1]); if (status == STORAGE_OK) { status = storage_remove(irc->user->nick); } switch (status) { case STORAGE_NO_SUCH_USER: irc_rootmsg(irc, "That account does not exist"); break; case STORAGE_INVALID_PASSWORD: irc_rootmsg(irc, "Password invalid"); break; case STORAGE_OK: irc_setpass(irc, NULL); irc->status &= ~USTATUS_IDENTIFIED; irc_umode_set(irc, "-R", 1); irc_rootmsg(irc, "Account `%s' removed", irc->user->nick); break; default: irc_rootmsg(irc, "Error: `%d'", status); break; } }
storage_status_t storage_rename (const char *onick, const char *nnick, const char *password) { storage_status_t status; GList *gl = global.storage; storage_t *primary_storage = gl->data; irc_t *irc; /* First, try to rename in the current write backend, assuming onick * is stored there */ status = primary_storage->rename(onick, nnick, password); if (status != STORAGE_NO_SUCH_USER) return status; /* Try to load from a migration backend and save to the current backend. * Explicitly remove the account from the migration backend as otherwise * it'd still be usable under the old name */ irc = g_new0(irc_t, 1); status = storage_load(onick, password, irc); if (status != STORAGE_OK) { irc_free(irc); return status; } g_free(irc->nick); irc->nick = g_strdup(nnick); status = storage_save(irc, FALSE); if (status != STORAGE_OK) { irc_free(irc); return status; } irc_free(irc); storage_remove(onick, password); return STORAGE_OK; }