Changeset eabe6d4


Ignore:
Timestamp:
2015-01-16T19:50:24Z (5 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
885d294
Parents:
6b13103
Message:

cmd_otr_keygen: improve argument parsing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r6b13103 reabe6d4  
    11171117void cmd_otr_keygen(irc_t *irc, char **args)
    11181118{
    1119         int i, n;
    11201119        account_t *a;
    11211120       
    1122         n = atoi(args[1]);
    1123         if(n<0 || (!n && strcmp(args[1], "0"))) {
    1124                 irc_rootmsg(irc, "%s: invalid account number", args[1]);
     1121        if ((a = account_get(irc->b, args[1])) == NULL) {
     1122                irc_rootmsg(irc, "Could not find account `%s'.", args[1]);
    11251123                return;
    11261124        }
    11271125       
    1128         a = irc->b->accounts;
    1129         for(i=0; i<n && a; i++, a=a->next);
    1130         if(!a) {
    1131                 irc_rootmsg(irc, "%s: no such account", args[1]);
     1126        if(keygen_in_progress(irc, a->user, a->prpl->name)) {
     1127                irc_rootmsg(irc, "keygen for account `%s' already in progress", a->tag);
    11321128                return;
    11331129        }
    11341130       
    1135         if(keygen_in_progress(irc, a->user, a->prpl->name)) {
    1136                 irc_rootmsg(irc, "keygen for account %d already in progress", n);
    1137                 return;
    1138         }
    1139        
    11401131        if(otrl_privkey_find(irc->otr->us, a->user, a->prpl->name)) {
    1141                 char *s = g_strdup_printf("account %d already has a key, replace it?", n);
     1132                char *s = g_strdup_printf("account `%s' already has a key, replace it?", a->tag);
    11421133                query_add(irc, NULL, s, yes_keygen, NULL, NULL, a);
    11431134                g_free(s);
Note: See TracChangeset for help on using the changeset viewer.