X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fnew.c;h=04fb949b614c538d0c677c0f633139f11f991535;hb=62b0c6727235a0bc560179dbf6b13d252716c02c;hp=2ac56d63c648608e37a270867068a4a876be03fc;hpb=c2360569e1d8d3678e294eb7c1354cb8bf7501c1;p=mmh diff --git a/uip/new.c b/uip/new.c index 2ac56d6..04fb949 100644 --- a/uip/new.c +++ b/uip/new.c @@ -22,13 +22,13 @@ static struct swit switches[] = { #define MODESW 0 - { "mode", 1 }, + { "mode", 0 }, #define FOLDERSSW 1 - { "folders", 1 }, + { "folders", 0 }, #define VERSIONSW 2 - { "version", 1 }, + { "Version", 0 }, #define HELPSW 3 - { "help", 1 }, + { "help", 0 }, { NULL, 0 } }; @@ -308,10 +308,14 @@ join_sequences(char *sequences[]) static struct node * doit(char *cur, char *folders, char *sequences[]) { - struct node *first, *cur_node, *node, *last, *prev; + struct node *first, *cur_node, *node, *last = NULL, *prev; size_t folder_len; int count, total = 0; - char *command = NULL, *sequences_s = NULL; + char *sequences_s = NULL; + int argc = 0; + char *argv[MAXARGS]; + char **seqp; + char buf[BUFSIZ]; if (cur == NULL || cur[0] == '\0') { cur = "inbox"; @@ -383,14 +387,15 @@ doit(char *cur, char *folders, char *sequences[]) } fflush(stdout); - /* - ** TODO: Split enough of scan.c out so that we can - ** call it here. - */ - command = concat("scan +", node->n_name, " ", - sequences_s, (void *)NULL); - system(command); - free(command); + argc = 0; + argv[argc++] = "scan"; + snprintf(buf, sizeof buf, "+%s", node->n_name); + argv[argc++] = buf; + for (seqp=sequences; *seqp; seqp++) { + argv[argc++] = *seqp; + } + argv[argc] = (char *)NULL; + execprog(*argv, argv); } else { if (node->n_field == NULL) { continue; @@ -432,9 +437,10 @@ main(int argc, char **argv) char *unseen; struct node *folder; -#ifdef LOCALE + sequences[0] = NULL; + sequences[1] = NULL; + setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ @@ -451,7 +457,7 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@ -460,10 +466,10 @@ main(int argc, char **argv) "%s [switches] [sequences]", invo_name); print_help(help, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case FOLDERSSW: if (!(folders = *argp++) || *folders == '-') @@ -481,6 +487,7 @@ main(int argc, char **argv) /* have a sequence argument */ if (!seq_in_list(cp, sequences)) { sequences[i++] = cp; + sequences[i] = NULL; } } @@ -519,7 +526,7 @@ main(int argc, char **argv) folder = doit(context_find(curfolder), folders, sequences); if (folder == NULL) { - done(0); + exit(0); return 1; } @@ -543,6 +550,5 @@ main(int argc, char **argv) context_save(); - done(0); - return 1; + return 0; }