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 { "usequence-component", &usequence },
83 { "#--Mmh-specific-Mail-Header-Names--", &empty },
84 { "attachment-header", &attach_hdr },
85 { "enc-header", &enc_hdr },
86 { "sign-header", &sign_hdr },
88 { "#--File-Permissions--", &empty },
89 { "foldprot", &foldprot },
90 { "msgprot", &msgprot },
92 { "#--Template-File-Names--", &empty },
93 { "components", &components },
94 { "digestcomps", &digestcomps },
95 { "distcomps", &distcomps },
96 { "forwcomps", &forwcomps },
97 { "rcvdistcomps", &rcvdistcomps },
98 { "replcomps", &replcomps },
99 { "replgroupcomps", &replgroupcomps },
100 { "mhlformat", &mhlformat },
101 { "mhlreply", &mhlreply },
102 { "scanformat", &scanformat },
104 { "#--Default-Sequence-Names--", &empty },
105 { "seq-all", &seq_all },
106 { "seq-beyond", &seq_beyond },
107 { "seq-cur", &seq_cur },
108 { "seq-first", &seq_first },
109 { "seq-last", &seq_last },
110 { "seq-next", &seq_next },
111 { "unseen-sequence", &seq_unseen },
112 { "sequence-negation", &seq_neg },
121 static char *p_find(char *);
125 main(int argc, char **argv)
127 int i, compp = 0, missed = 0;
128 int all = 0, debug = 0;
130 char *cp, buf[BUFSIZ], **argp;
131 char **arguments, *comps[MAXARGS];
133 invo_name = mhbasename(argv[0]);
137 arguments = getarguments(invo_name, argc, argv, 1);
140 while ((cp = *argp++)) {
142 switch (smatch(++cp, switches)) {
144 ambigsw(cp, switches);
147 adios(EX_USAGE, NULL, "-%s unknown", cp);
150 snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
151 print_help(buf, switches, 1);
152 exit(argc == 2 ? EX_OK : EX_USAGE);
154 print_version(invo_name);
155 exit(argc == 2 ? EX_OK : EX_USAGE);
181 advise(NULL, "profile-components ignored with -all");
184 advise(NULL, "-%scomponents ignored with -all",
185 components ? "" : "no");
187 /* print all entries in context/profile list */
188 for (np = m_defs; np; np = np->n_next)
189 printf("%s: %s\n", np->n_name, np->n_field);
195 ** Print the current value of everything in
196 ** procs array. This will show their current
197 ** value (as determined after context is read).
199 for (ps = procs; ps->p_name; ps++)
200 printf("%s: %s\n", ps->p_name,
201 *ps->p_field ? *ps->p_field : "");
205 components = compp > 1;
207 for (i = 0; i < compp; i++) {
210 value = context_find(comps[i]);
212 value = p_find(comps[i]);
215 printf("%s: ", comps[i]);
217 printf("%s\n", value);
232 for (ps = procs; ps->p_name; ps++)
233 if (!mh_strcasecmp(ps->p_name, str))
234 return (*ps->p_field);