Fix uip/whom.c for C89 compatibility
[mmh] / uip / mhparam.c
index d456454..2c61e60 100644 (file)
 */
 
 #include <h/mh.h>
+#include <sysexits.h>
 
 static struct swit switches[] = {
 #define COMPSW  0
        { "components", 0 },
 #define NCOMPSW  1
-       { "nocomponents", 0 },
+       { "nocomponents", 2 },
 #define ALLSW  2
        { "all", 0 },
 #define VERSIONSW 3
-       { "version", 0 },
+       { "Version", 0 },
 #define HELPSW  4
        { "help", 0 },
 #define DEBUGSW   5
@@ -27,31 +28,91 @@ static struct swit switches[] = {
        { NULL, 0 }
 };
 
+char *version=VERSION;
+
 struct proc {
        char *p_name;
        char **p_field;
 };
 
+char *empty = "";
+
+/*
+** This list should contain all values of h/mh.h and config/config.c
+** TODO: Add the constants Nbby, MAXARGS, NUMATTRS, NAMESZ
+*/
 static struct proc procs [] = {
-       { "attachment-header",  &attach_hdr },
-       { "context",       &context },
-       { "mh-sequences",  &mh_seq },
+       { "#--Version--", &empty },
+       { "version",          &version },
+       { "lib-version",      &lib_version },
+
+       { "#--Path-and-File-Names--", &empty },
+       { "mypath",          &mypath },
+       { "mmhdir",          &mmhdir },
+       { "mmhpath",         &mmhpath },
+       { "profile",         &profile },
+       { "defpath",         &defpath },
+       { "context",         &context },
+       { "ctxpath",         &ctxpath },
+       { "mhetcdir",        &mhetcdir },
+       { "mailspool",       &mailspool },
+       { "mailstore",       &mailstore },
+       { "mh-sequences",    &mh_seq },
+
+       { "#--Default-Programs--", &empty },
        { "editor",        &defaulteditor },
-       { "fileproc",      &fileproc },
-       { "foldprot",      &foldprot },
-       { "listproc",      &listproc },
-       { "mimetypequeryproc", &mimetypequeryproc },
-       { "msgprot",       &msgprot },
        { "pager",         &defaultpager },
-       { "rmmproc",       &rmmproc },
        { "sendmail",      &sendmail },
-       { "sendproc",      &sendproc },
-       { "version",       &version_num },
+       { "listproc",      &listproc },
        { "whatnowproc",   &whatnowproc },
-       { "etcdir",        &mhetcdir },
-       { "backup-prefix", &backup_prefix },
-       { "altmsg-link",   &altmsglink },
-       { "draft-folder",  &draftfolder },
+       { "mimetypequeryproc", &mimetypequeryproc },
+
+       { "#--Mail-Folder-Names--", &empty },
+       { "inbox",          &defaultfolder },
+       { "draftfolder",    &draftfolder },
+       { "trashfolder",    &trashfolder },
+
+       { "#--Profile-and-Context-Component-Names--", &empty },
+       { "curfolder-component",         &curfolder },
+       { "inbox-component",             &inbox },
+       { "mimetypequery-component",     &mimetypequery },
+       { "nmhstorage-component",        &nmhstorage },
+       { "nsequence-component",         &nsequence },
+       { "psequence-component",         &psequence },
+       { "usequence-component",         &usequence },
+
+       { "#--Mmh-specific-Mail-Header-Names--", &empty },
+       { "attachment-header", &attach_hdr },
+       { "enc-header",        &enc_hdr },
+       { "sign-header",       &sign_hdr },
+
+       { "#--File-Permissions--", &empty },
+       { "foldprot",      &foldprot },
+       { "msgprot",       &msgprot },
+
+       { "#--Template-File-Names--", &empty },
+       { "components",        &components },
+       { "digestcomps",       &digestcomps },
+       { "distcomps",         &distcomps },
+       { "forwcomps",         &forwcomps },
+       { "rcvdistcomps",      &rcvdistcomps },
+       { "replcomps",         &replcomps },
+       { "replgroupcomps",    &replgroupcomps },
+       { "mhlformat",         &mhlformat },
+       { "mhlreply",          &mhlreply },
+       { "scanformat",        &scanformat },
+
+       { "#--Default-Sequence-Names--", &empty },
+       { "seq-all",           &seq_all },
+       { "seq-beyond",        &seq_beyond },
+       { "seq-cur",           &seq_cur },
+       { "seq-first",         &seq_first },
+       { "seq-last",          &seq_last },
+       { "seq-next",          &seq_next },
+       { "previous-sequence", &seq_prev },
+       { "unseen-sequence",   &seq_unseen },
+       { "sequence-negation", &seq_neg },
+
        { NULL,            NULL },
 };
 
@@ -73,7 +134,6 @@ main(int argc, char **argv)
 
        invo_name = mhbasename(argv[0]);
 
-       /* read user profile/context */
        context_read();
 
        arguments = getarguments(invo_name, argc, argv, 1);
@@ -84,17 +144,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(EX_USAGE);
                        case UNKWNSW:
-                               adios(NULL, "-%s unknown", cp);
+                               adios(EX_USAGE, NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(argc == 2 ? EX_OK : EX_USAGE);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(argc == 2 ? EX_OK : EX_USAGE);
 
                        case COMPSW:
                                components = 1;
@@ -147,7 +207,7 @@ main(int argc, char **argv)
                        components = compp > 1;
 
                for (i = 0; i < compp; i++)  {
-                       register char *value;
+                       char *value;
 
                        value = context_find(comps[i]);
                        if (!value)
@@ -162,8 +222,7 @@ main(int argc, char **argv)
                }
        }
 
-       done(missed);
-       return 1;
+       return missed;
 }