X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fmhparam.c;h=2c61e608076236bb2042a0b4d414215412dc7686;hp=19f418e918a12399736c1a6e274b167086df4c13;hb=6e9577f324bef90765a5edc02044eb111ec48072;hpb=5dd6771b28c257af405d7248639ed0e3bcdce38b diff --git a/uip/mhparam.c b/uip/mhparam.c index 19f418e..2c61e60 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -1,197 +1,239 @@ - /* - * mhparam.c -- print mh_profile values - * - * Originally contributed by - * Jeffrey C Honig - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ +** mhparam.c -- print mh_profile values +** +** Originally contributed by +** Jeffrey C Honig +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include - -extern char *mhlibdir; -extern char *mhetcdir; - -char *sbackup = BACKUP_PREFIX; -char *slink = LINK; +#include static struct swit switches[] = { -#define COMPSW 0 - { "components", 0 }, -#define NCOMPSW 1 - { "nocomponents", 0 }, -#define ALLSW 2 - { "all", 0 }, +#define COMPSW 0 + { "components", 0 }, +#define NCOMPSW 1 + { "nocomponents", 2 }, +#define ALLSW 2 + { "all", 0 }, #define VERSIONSW 3 - { "version", 0 }, -#define HELPSW 4 - { "help", 0 }, + { "Version", 0 }, +#define HELPSW 4 + { "help", 0 }, #define DEBUGSW 5 - { "debug", -5 }, - { NULL, 0 } + { "debug", -5 }, + { NULL, 0 } }; +char *version=VERSION; + struct proc { - char *p_name; - char **p_field; + 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 [] = { - { "context", &context }, - { "mh-sequences", &mh_seq }, - { "buildmimeproc", &buildmimeproc }, - { "faceproc", &faceproc }, - { "fileproc", &fileproc }, - { "foldprot", &foldprot }, - { "incproc", &incproc }, - { "installproc", &installproc }, - { "lproc", &lproc }, - { "mailproc", &mailproc }, - { "mhlproc", &mhlproc }, - { "moreproc", &moreproc }, - { "msgprot", &msgprot }, - { "mshproc", &mshproc }, - { "packproc", &packproc }, - { "postproc", &postproc }, - { "rmfproc", &rmfproc }, - { "rmmproc", &rmmproc }, - { "sendproc", &sendproc }, - { "showmimeproc", &showmimeproc }, - { "showproc", &showproc }, - { "version", &version_num }, - { "vmhproc", &vmhproc }, - { "whatnowproc", &whatnowproc }, - { "whomproc", &whomproc }, - { "etcdir", &mhetcdir }, - { "libdir", &mhlibdir }, - { "sbackup", &sbackup }, - { "link", &slink }, - { NULL, NULL }, + { "#--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 }, + { "pager", &defaultpager }, + { "sendmail", &sendmail }, + { "listproc", &listproc }, + { "whatnowproc", &whatnowproc }, + { "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 }, }; /* - * static prototypes - */ +** static prototypes +*/ static char *p_find(char *); int main(int argc, char **argv) { - int i, compp = 0, missed = 0; - int all = 0, debug = 0; - int components = -1; - char *cp, buf[BUFSIZ], **argp; - char **arguments, *comps[MAXARGS]; - - invo_name = r1bindex (argv[0], '/'); - - /* read user profile/context */ - context_read(); - - arguments = getarguments (invo_name, argc, argv, 1); - argp = arguments; - - while ((cp = *argp++)) { - if (*cp == '-') { - switch (smatch (++cp, switches)) { - case AMBIGSW: - ambigsw (cp, switches); - done (1); - case UNKWNSW: - adios (NULL, "-%s unknown", cp); - - case HELPSW: - snprintf (buf, sizeof(buf), "%s [profile-components] [switches]", - invo_name); - print_help (buf, switches, 1); - done (1); - case VERSIONSW: - print_version(invo_name); - done (1); - - case COMPSW: - components = 1; - break; - case NCOMPSW: - components = 0; - break; - - case ALLSW: - all = 1; - break; - - case DEBUGSW: - debug = 1; - break; - } - } else { - comps[compp++] = cp; + int i, compp = 0, missed = 0; + int all = 0, debug = 0; + int components = -1; + char *cp, buf[BUFSIZ], **argp; + char **arguments, *comps[MAXARGS]; + + invo_name = mhbasename(argv[0]); + + context_read(); + + arguments = getarguments(invo_name, argc, argv, 1); + argp = arguments; + + while ((cp = *argp++)) { + if (*cp == '-') { + switch (smatch(++cp, switches)) { + case AMBIGSW: + ambigsw(cp, switches); + exit(EX_USAGE); + case UNKWNSW: + adios(EX_USAGE, NULL, "-%s unknown", cp); + + case HELPSW: + snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name); + print_help(buf, switches, 1); + exit(argc == 2 ? EX_OK : EX_USAGE); + case VERSIONSW: + print_version(invo_name); + exit(argc == 2 ? EX_OK : EX_USAGE); + + case COMPSW: + components = 1; + break; + case NCOMPSW: + components = 0; + break; + + case ALLSW: + all = 1; + break; + + case DEBUGSW: + debug = 1; + break; + } + } else { + comps[compp++] = cp; + } } - } - - if (all) { - struct node *np; - if (compp) - advise(NULL, "profile-components ignored with -all"); + if (all) { + struct node *np; - if (components >= 0) - advise(NULL, "-%scomponents ignored with -all", - components ? "" : "no"); + if (compp) + advise(NULL, "profile-components ignored with -all"); - /* print all entries in context/profile list */ - for (np = m_defs; np; np = np->n_next) - printf("%s: %s\n", np->n_name, np->n_field); + if (components >= 0) + advise(NULL, "-%scomponents ignored with -all", + components ? "" : "no"); - } if (debug) { - struct proc *ps; - - /* - * Print the current value of everything in - * procs array. This will show their current - * value (as determined after context is read). - */ - for (ps = procs; ps->p_name; ps++) - printf ("%s: %s\n", ps->p_name, *ps->p_field ? *ps->p_field : ""); - - } else { - if (components < 0) - components = compp > 1; + /* print all entries in context/profile list */ + for (np = m_defs; np; np = np->n_next) + printf("%s: %s\n", np->n_name, np->n_field); - for (i = 0; i < compp; i++) { - register char *value; + } else if (debug) { + struct proc *ps; - value = context_find (comps[i]); - if (!value) - value = p_find (comps[i]); - if (value) { - if (components) - printf("%s: ", comps[i]); + /* + ** Print the current value of everything in + ** procs array. This will show their current + ** value (as determined after context is read). + */ + for (ps = procs; ps->p_name; ps++) + printf("%s: %s\n", ps->p_name, + *ps->p_field ? *ps->p_field : ""); - printf("%s\n", value); - } else - missed++; + } else { + if (components < 0) + components = compp > 1; + + for (i = 0; i < compp; i++) { + char *value; + + value = context_find(comps[i]); + if (!value) + value = p_find(comps[i]); + if (value) { + if (components) + printf("%s: ", comps[i]); + + printf("%s\n", value); + } else + missed++; + } } - } - - done (missed); - return 1; + + return missed; } static char * p_find(char *str) { - struct proc *ps; + struct proc *ps; - for (ps = procs; ps->p_name; ps++) - if (!mh_strcasecmp (ps->p_name, str)) - return (*ps->p_field); + for (ps = procs; ps->p_name; ps++) + if (!mh_strcasecmp(ps->p_name, str)) + return (*ps->p_field); - return NULL; + return NULL; }