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.
14 static struct swit switches[] = {
18 { "nocomponents", 0 },
35 static struct proc procs [] = {
36 { "attachment-header", &attach_hdr },
37 { "context", &context },
38 { "mh-sequences", &mh_seq },
39 { "editor", &defaulteditor },
40 { "foldprot", &foldprot },
41 { "listproc", &listproc },
42 { "mimetypequeryproc", &mimetypequeryproc },
43 { "msgprot", &msgprot },
44 { "pager", &defaultpager },
45 { "sendmail", &sendmail },
46 { "version", &version_num },
47 { "whatnowproc", &whatnowproc },
48 { "etcdir", &mhetcdir },
49 { "backup-prefix", &backup_prefix },
50 { "altmsg-link", &altmsglink },
51 { "draft-folder", &draftfolder },
52 { "trash-folder", &trashfolder },
60 static char *p_find(char *);
64 main(int argc, char **argv)
66 int i, compp = 0, missed = 0;
67 int all = 0, debug = 0;
69 char *cp, buf[BUFSIZ], **argp;
70 char **arguments, *comps[MAXARGS];
72 invo_name = mhbasename(argv[0]);
74 /* read user profile/context */
77 arguments = getarguments(invo_name, argc, argv, 1);
80 while ((cp = *argp++)) {
82 switch (smatch(++cp, switches)) {
84 ambigsw(cp, switches);
87 adios(NULL, "-%s unknown", cp);
90 snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
91 print_help(buf, switches, 1);
94 print_version(invo_name);
121 advise(NULL, "profile-components ignored with -all");
124 advise(NULL, "-%scomponents ignored with -all",
125 components ? "" : "no");
127 /* print all entries in context/profile list */
128 for (np = m_defs; np; np = np->n_next)
129 printf("%s: %s\n", np->n_name, np->n_field);
135 ** Print the current value of everything in
136 ** procs array. This will show their current
137 ** value (as determined after context is read).
139 for (ps = procs; ps->p_name; ps++)
140 printf("%s: %s\n", ps->p_name,
141 *ps->p_field ? *ps->p_field : "");
145 components = compp > 1;
147 for (i = 0; i < compp; i++) {
148 register char *value;
150 value = context_find(comps[i]);
152 value = p_find(comps[i]);
155 printf("%s: ", comps[i]);
157 printf("%s\n", value);
173 for (ps = procs; ps->p_name; ps++)
174 if (!mh_strcasecmp(ps->p_name, str))
175 return (*ps->p_field);