Call spost directly, not via postproc. Remove the postproc profile entry.
[mmh] / uip / mhparam.c
1 /*
2 ** mhparam.c -- print mh_profile values
3 **
4 ** Originally contributed by
5 ** Jeffrey C Honig <Jeffrey_C_Honig@cornell.edu>
6 **
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.
10 */
11
12 #include <h/mh.h>
13
14 static struct swit switches[] = {
15 #define COMPSW  0
16         { "components", 0 },
17 #define NCOMPSW  1
18         { "nocomponents", 0 },
19 #define ALLSW  2
20         { "all", 0 },
21 #define VERSIONSW 3
22         { "version", 0 },
23 #define HELPSW  4
24         { "help", 0 },
25 #define DEBUGSW   5
26         { "debug", -5 },
27         { NULL, 0 }
28 };
29
30 struct proc {
31         char *p_name;
32         char **p_field;
33 };
34
35 static struct proc procs [] = {
36         { "attachment-header",  &attach_hdr },
37         { "context",       &context },
38         { "mh-sequences",  &mh_seq },
39         { "editor",        &defaulteditor },
40         { "fileproc",      &fileproc },
41         { "foldprot",      &foldprot },
42         { "listproc",      &listproc },
43         { "mimetypequeryproc", &mimetypequeryproc },
44         { "msgprot",       &msgprot },
45         { "pager",         &defaultpager },
46         { "rmmproc",       &rmmproc },
47         { "sendmail",      &sendmail },
48         { "sendproc",      &sendproc },
49         { "version",       &version_num },
50         { "whatnowproc",   &whatnowproc },
51         { "etcdir",        &mhetcdir },
52         { "backup-prefix", &backup_prefix },
53         { "altmsg-link",   &altmsglink },
54         { "draft-folder",  &draftfolder },
55         { NULL,            NULL },
56 };
57
58
59 /*
60 ** static prototypes
61 */
62 static char *p_find(char *);
63
64
65 int
66 main(int argc, char **argv)
67 {
68         int i, compp = 0, missed = 0;
69         int all = 0, debug = 0;
70         int components = -1;
71         char *cp, buf[BUFSIZ], **argp;
72         char **arguments, *comps[MAXARGS];
73
74         invo_name = mhbasename(argv[0]);
75
76         /* read user profile/context */
77         context_read();
78
79         arguments = getarguments(invo_name, argc, argv, 1);
80         argp = arguments;
81
82         while ((cp = *argp++)) {
83                 if (*cp == '-') {
84                         switch (smatch(++cp, switches)) {
85                         case AMBIGSW:
86                                 ambigsw(cp, switches);
87                                 done(1);
88                         case UNKWNSW:
89                                 adios(NULL, "-%s unknown", cp);
90
91                         case HELPSW:
92                                 snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
93                                 print_help(buf, switches, 1);
94                                 done(1);
95                         case VERSIONSW:
96                                 print_version(invo_name);
97                                 done(1);
98
99                         case COMPSW:
100                                 components = 1;
101                                 break;
102                         case NCOMPSW:
103                                 components = 0;
104                                 break;
105
106                         case ALLSW:
107                                 all = 1;
108                                 break;
109
110                         case DEBUGSW:
111                                 debug = 1;
112                                 break;
113                         }
114                 } else {
115                         comps[compp++] = cp;
116                 }
117         }
118
119         if (all) {
120                 struct node *np;
121
122                 if (compp)
123                         advise(NULL, "profile-components ignored with -all");
124
125                 if (components >= 0)
126                         advise(NULL, "-%scomponents ignored with -all",
127                                         components ? "" : "no");
128
129                 /* print all entries in context/profile list */
130                 for (np = m_defs; np; np = np->n_next)
131                         printf("%s: %s\n", np->n_name, np->n_field);
132
133         } else if (debug) {
134                 struct proc *ps;
135
136                 /*
137                 ** Print the current value of everything in
138                 ** procs array.  This will show their current
139                 ** value (as determined after context is read).
140                 */
141                 for (ps = procs; ps->p_name; ps++)
142                         printf("%s: %s\n", ps->p_name,
143                                         *ps->p_field ? *ps->p_field : "");
144
145         } else {
146                 if (components < 0)
147                         components = compp > 1;
148
149                 for (i = 0; i < compp; i++)  {
150                         register char *value;
151
152                         value = context_find(comps[i]);
153                         if (!value)
154                                 value = p_find(comps[i]);
155                         if (value) {
156                                 if (components)
157                                         printf("%s: ", comps[i]);
158
159                                 printf("%s\n", value);
160                         } else
161                                 missed++;
162                 }
163         }
164
165         done(missed);
166         return 1;
167 }
168
169
170 static char *
171 p_find(char *str)
172 {
173         struct proc *ps;
174
175         for (ps = procs; ps->p_name; ps++)
176                 if (!mh_strcasecmp(ps->p_name, str))
177                         return (*ps->p_field);
178
179         return NULL;
180 }