X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fmark.c;h=57a6553090183c278093682d978170526ca8c47c;hp=5fd27f665632e4367b6bb8e0ce75c6415a424948;hb=2abb9a7cfb0930e27062088734d306e7d78e4cc2;hpb=d39e2c447b0d163a5a63f480b23d06edb7a73aa0 diff --git a/uip/mark.c b/uip/mark.c index 5fd27f6..57a6553 100644 --- a/uip/mark.c +++ b/uip/mark.c @@ -10,6 +10,8 @@ #include #include +#include +#include static struct swit switches[] = { #define ADDSW 0 @@ -23,13 +25,13 @@ static struct swit switches[] = { #define PUBLSW 4 { "public", 0 }, #define NPUBLSW 5 - { "nopublic", 0 }, + { "nopublic", 2 }, #define ZEROSW 6 { "zero", 0 }, #define NZEROSW 7 - { "nozero", 0 }, + { "nozero", 2 }, #define VERSIONSW 8 - { "version", 0 }, + { "Version", 0 }, #define HELPSW 9 { "help", 0 }, #define DEBUGSW 10 @@ -48,17 +50,15 @@ int main(int argc, char **argv) { int addsw = 0, deletesw = 0, debugsw = 0; - int listsw = 0, publicsw = -1, zerosw = 0; - int seqp = 0, msgnum; + int listsw = 0, publicsw = -1, zerosw = 0, msgnum; + unsigned int seqp = 0; char *cp, *maildir, *folder = NULL, buf[BUFSIZ]; char **argp, **arguments; char *seqs[NUMATTRS + 1]; struct msgs_array msgs = { 0, 0, NULL }; struct msgs *mp; -#ifdef LOCALE setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ @@ -75,17 +75,18 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + /*sysexits.h EX_USAGE*/ + exit(1); case UNKWNSW: adios(NULL, "-%s unknown\n", cp); case HELPSW: snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help(buf, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case ADDSW: addsw++; @@ -152,7 +153,7 @@ main(int argc, char **argv) } if (!msgs.size) - app_msgarg(&msgs, listsw ? "all" :"cur"); + app_msgarg(&msgs, listsw ? seq_all : seq_cur); if (!folder) folder = getcurfol(); maildir = toabsdir(folder); @@ -173,9 +174,12 @@ main(int argc, char **argv) adios(NULL, "no messages in %s", folder); /* parse all the message ranges/sequences and set SELECTED */ - for (msgnum = 0; msgnum < msgs.size; msgnum++) - if (!m_convert(mp, msgs.msgs[msgnum])) - done(1); + for (msgnum = 0; msgnum < msgs.size; msgnum++) { + if (!m_convert(mp, msgs.msgs[msgnum])) { + /*sysexits.h EX_USAGE*/ + exit(1); + } + } if (publicsw == 1 && is_readonly(mp)) adios(NULL, "folder %s is read-only, so -public not allowed", @@ -192,16 +196,20 @@ main(int argc, char **argv) /* Adding messages to sequences */ if (addsw) { - for (seqp = 0; seqs[seqp]; seqp++) - if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw)) - done(1); + for (seqp = 0; seqs[seqp]; seqp++) { + if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw)) { + /*TODO find best exitcode*/ + exit(1); + } + } } /* Deleting messages from sequences */ if (deletesw) { for (seqp = 0; seqs[seqp]; seqp++) if (!seq_delsel(mp, seqs[seqp], publicsw, zerosw)) - done(1); + /*TODO find best exitcode*/ + exit(1); } /* Listing messages in sequences */ @@ -221,11 +229,10 @@ main(int argc, char **argv) } seq_save(mp); /* synchronize message sequences */ - context_replace(pfolder, folder); /* update current folder */ + context_replace(curfolder, folder); /* update current folder */ context_save(); /* save the context file */ folder_free(mp); /* free folder/message structure */ - done(0); - return 1; + return 0; }