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 },
39 ** This list should contain all values of h/mh.h and config/config.c
40 ** TODO: Add the constants Nbby, MAXARGS, NUMATTRS, NAMESZ
42 static struct proc procs [] = {
43 { "#--Version--", &empty },
44 { "version", &version_num },
45 { "version-str", &version_str },
47 { "#--Path-and-File-Names--", &empty },
48 { "mypath", &mypath },
49 { "mmhdir", &mmhdir },
50 { "mmhpath", &mmhpath },
51 { "profile", &profile },
52 { "defpath", &defpath },
53 { "context", &context },
54 { "ctxpath", &ctxpath },
55 { "mhetcdir", &mhetcdir },
56 { "mailspool", &mailspool },
57 { "mailstore", &mailstore },
58 { "mh-sequences", &mh_seq },
60 { "#--Default-Programs--", &empty },
61 { "editor", &defaulteditor },
62 { "pager", &defaultpager },
63 { "sendmail", &sendmail },
64 { "listproc", &listproc },
65 { "whatnowproc", &whatnowproc },
66 { "mimetypequeryproc", &mimetypequeryproc },
68 { "#--Mail-Folder-Names--", &empty },
69 { "inbox", &defaultfolder },
70 { "draftfolder", &draftfolder },
71 { "trashfolder", &trashfolder },
73 { "#--Profile-and-Context-Component-Names--", &empty },
74 { "curfolder-component", &curfolder },
75 { "inbox-component", &inbox },
76 { "mimetypequery-component", &mimetypequery },
77 { "nmhstorage-component", &nmhstorage },
78 { "nsequence-component", &nsequence },
79 { "psequence-component", &psequence },
80 { "usequence-component", &usequence },
82 { "#--Mmh-specific-Mail-Header-Names--", &empty },
83 { "attachment-header", &attach_hdr },
84 { "enc-header", &enc_hdr },
85 { "sign-header", &sign_hdr },
87 { "#--File-Permissions--", &empty },
88 { "foldprot", &foldprot },
89 { "msgprot", &msgprot },
91 { "#--Template-File-Names--", &empty },
92 { "components", &components },
93 { "digestcomps", &digestcomps },
94 { "distcomps", &distcomps },
95 { "forwcomps", &forwcomps },
96 { "rcvdistcomps", &rcvdistcomps },
97 { "replcomps", &replcomps },
98 { "replgroupcomps", &replgroupcomps },
99 { "mhlformat", &mhlformat },
100 { "mhlreply", &mhlreply },
102 { "#--Default-Sequence-Names--", &empty },
103 { "seq-all", &seq_all },
104 { "seq-beyond", &seq_beyond },
105 { "seq-cur", &seq_cur },
106 { "seq-first", &seq_first },
107 { "seq-last", &seq_last },
108 { "seq-next", &seq_next },
109 { "previous-sequence", &seq_prev },
110 { "unseen-sequence", &seq_unseen },
111 { "sequence-negation", &seq_neg },
120 static char *p_find(char *);
124 main(int argc, char **argv)
126 int i, compp = 0, missed = 0;
127 int all = 0, debug = 0;
129 char *cp, buf[BUFSIZ], **argp;
130 char **arguments, *comps[MAXARGS];
132 invo_name = mhbasename(argv[0]);
136 arguments = getarguments(invo_name, argc, argv, 1);
139 while ((cp = *argp++)) {
141 switch (smatch(++cp, switches)) {
143 ambigsw(cp, switches);
146 adios(EX_USAGE, NULL, "-%s unknown", cp);
149 snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
150 print_help(buf, switches, 1);
151 exit(argc == 2 ? EX_OK : EX_USAGE);
153 print_version(invo_name);
154 exit(argc == 2 ? EX_OK : EX_USAGE);
180 advise(NULL, "profile-components ignored with -all");
183 advise(NULL, "-%scomponents ignored with -all",
184 components ? "" : "no");
186 /* print all entries in context/profile list */
187 for (np = m_defs; np; np = np->n_next)
188 printf("%s: %s\n", np->n_name, np->n_field);
194 ** Print the current value of everything in
195 ** procs array. This will show their current
196 ** value (as determined after context is read).
198 for (ps = procs; ps->p_name; ps++)
199 printf("%s: %s\n", ps->p_name,
200 *ps->p_field ? *ps->p_field : "");
204 components = compp > 1;
206 for (i = 0; i < compp; i++) {
209 value = context_find(comps[i]);
211 value = p_find(comps[i]);
214 printf("%s: ", comps[i]);
216 printf("%s\n", value);
231 for (ps = procs; ps->p_name; ps++)
232 if (!mh_strcasecmp(ps->p_name, str))
233 return (*ps->p_field);