2 ** mhparam.c -- print mh_profile values
4 ** Originally contributed by
5 ** Jeffrey C Honig <Jeffrey_C_Honig@cornell.edu>
7 ** This code is Copyright (c) 2002, by the authors of nmh. See the
8 ** COPYRIGHT file in the root directory of the nmh distribution for
9 ** complete copyright information.
15 static struct swit switches[] = {
19 { "nocomponents", 2 },
31 char *version=VERSION;
41 ** This list should contain all values of h/mh.h and config/config.c
42 ** TODO: Add the constants Nbby, MAXARGS, NUMATTRS, NAMESZ
44 static struct proc procs [] = {
45 { "#--Version--", &empty },
46 { "version", &version },
47 { "lib-version", &lib_version },
49 { "#--Path-and-File-Names--", &empty },
50 { "mypath", &mypath },
51 { "mmhdir", &mmhdir },
52 { "mmhpath", &mmhpath },
53 { "profile", &profile },
54 { "defpath", &defpath },
55 { "context", &context },
56 { "ctxpath", &ctxpath },
57 { "mhetcdir", &mhetcdir },
58 { "mailspool", &mailspool },
59 { "mailstore", &mailstore },
60 { "mh-sequences", &mh_seq },
62 { "#--Default-Programs--", &empty },
63 { "editor", &defaulteditor },
64 { "pager", &defaultpager },
65 { "sendmail", &sendmail },
66 { "listproc", &listproc },
67 { "whatnowproc", &whatnowproc },
68 { "mimetypequeryproc", &mimetypequeryproc },
70 { "#--Mail-Folder-Names--", &empty },
71 { "inbox", &defaultfolder },
72 { "draftfolder", &draftfolder },
73 { "trashfolder", &trashfolder },
75 { "#--Profile-and-Context-Component-Names--", &empty },
76 { "curfolder-component", &curfolder },
77 { "inbox-component", &inbox },
78 { "mimetypequery-component", &mimetypequery },
79 { "nmhstorage-component", &nmhstorage },
80 { "nsequence-component", &nsequence },
81 { "psequence-component", &psequence },
82 { "usequence-component", &usequence },
84 { "#--Mmh-specific-Mail-Header-Names--", &empty },
85 { "attachment-header", &attach_hdr },
86 { "enc-header", &enc_hdr },
87 { "sign-header", &sign_hdr },
89 { "#--File-Permissions--", &empty },
90 { "foldprot", &foldprot },
91 { "msgprot", &msgprot },
93 { "#--Template-File-Names--", &empty },
94 { "components", &components },
95 { "digestcomps", &digestcomps },
96 { "distcomps", &distcomps },
97 { "forwcomps", &forwcomps },
98 { "rcvdistcomps", &rcvdistcomps },
99 { "replcomps", &replcomps },
100 { "replgroupcomps", &replgroupcomps },
101 { "mhlformat", &mhlformat },
102 { "mhlreply", &mhlreply },
103 { "scanformat", &scanformat },
105 { "#--Default-Sequence-Names--", &empty },
106 { "seq-all", &seq_all },
107 { "seq-beyond", &seq_beyond },
108 { "seq-cur", &seq_cur },
109 { "seq-first", &seq_first },
110 { "seq-last", &seq_last },
111 { "seq-next", &seq_next },
112 { "previous-sequence", &seq_prev },
113 { "unseen-sequence", &seq_unseen },
114 { "sequence-negation", &seq_neg },
123 static char *p_find(char *);
127 main(int argc, char **argv)
129 int i, compp = 0, missed = 0;
130 int all = 0, debug = 0;
132 char *cp, buf[BUFSIZ], **argp;
133 char **arguments, *comps[MAXARGS];
135 invo_name = mhbasename(argv[0]);
139 arguments = getarguments(invo_name, argc, argv, 1);
142 while ((cp = *argp++)) {
144 switch (smatch(++cp, switches)) {
146 ambigsw(cp, switches);
149 adios(EX_USAGE, NULL, "-%s unknown", cp);
152 snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
153 print_help(buf, switches, 1);
154 exit(argc == 2 ? EX_OK : EX_USAGE);
156 print_version(invo_name);
157 exit(argc == 2 ? EX_OK : EX_USAGE);
183 advise(NULL, "profile-components ignored with -all");
186 advise(NULL, "-%scomponents ignored with -all",
187 components ? "" : "no");
189 /* print all entries in context/profile list */
190 for (np = m_defs; np; np = np->n_next)
191 printf("%s: %s\n", np->n_name, np->n_field);
197 ** Print the current value of everything in
198 ** procs array. This will show their current
199 ** value (as determined after context is read).
201 for (ps = procs; ps->p_name; ps++)
202 printf("%s: %s\n", ps->p_name,
203 *ps->p_field ? *ps->p_field : "");
207 components = compp > 1;
209 for (i = 0; i < compp; i++) {
212 value = context_find(comps[i]);
214 value = p_find(comps[i]);
217 printf("%s: ", comps[i]);
219 printf("%s\n", value);
234 for (ps = procs; ps->p_name; ps++)
235 if (!mh_strcasecmp(ps->p_name, str))
236 return (*ps->p_field);