]>
diplodocus.org Git - nmh/blob - uip/mhparam.c
1 /* mhparam.c -- print mh_profile values
3 * Originally contributed by
4 * Jeffrey C Honig <Jeffrey_C_Honig@cornell.edu>
6 * This code is Copyright (c) 2002, by the authors of nmh. See the
7 * COPYRIGHT file in the root directory of the nmh distribution for
8 * complete copyright information.
12 #include "sbr/context_find.h"
13 #include "sbr/ambigsw.h"
14 #include "sbr/print_version.h"
15 #include "sbr/print_help.h"
16 #include "sbr/error.h"
21 #define MHPARAM_SWITCHES \
22 X("components", 0, COMPSW) \
23 X("nocomponents", 0, NCOMPSW) \
25 X("version", 0, VERSIONSW) \
26 X("help", 0, HELPSW) \
27 X("debug", 5, DEBUGSW) \
29 #define X(sw, minchars, id) id,
30 DEFINE_SWITCH_ENUM(MHPARAM
);
33 #define X(sw, minchars, id) { sw, minchars, id },
34 DEFINE_SWITCH_ARRAY(MHPARAM
, switches
);
37 extern char *mhbindir
;
38 extern char *mhlibexecdir
;
39 extern char *mhetcdir
;
40 extern char *mhdocdir
;
42 static char *sbackup
= BACKUP_PREFIX
;
44 static char *datalocking
= "fcntl";
45 static char *localmbox
= "";
46 static bool localmbox_primed
;
48 extern char *spoollocking
;
64 static char *mimetypeproc
=
71 static char *mimeencodingproc
=
72 #ifdef MIMEENCODINGPROC
97 static struct proc procs
[] = {
98 { "context", &context
},
99 { "mh-sequences", &mh_seq
},
100 { "buildmimeproc", &buildmimeproc
},
101 { "fileproc", &fileproc
},
102 { "foldprot", &foldprot
},
103 { "formatproc", &formatproc
},
104 { "incproc", &incproc
},
106 { "mailproc", &mailproc
},
107 { "mhlproc", &mhlproc
},
108 { "mimetypeproc", &mimetypeproc
},
109 { "mimeencodingproc", &mimeencodingproc
},
110 { "moreproc", &moreproc
},
111 { "msgprot", &msgprot
},
112 { "packproc", &packproc
},
113 { "postproc", &postproc
},
114 { "rmmproc", &rmmproc
},
115 { "sendproc", &sendproc
},
116 { "showmimeproc", &showmimeproc
},
117 { "showproc", &showproc
},
118 { "version", &version_num
},
119 { "whatnowproc", &whatnowproc
},
120 { "whomproc", &whomproc
},
121 { "bindir", &mhbindir
},
122 { "libexecdir", &mhlibexecdir
},
123 { "etcdir", &mhetcdir
},
124 { "docdir", &mhdocdir
},
125 { "localmbox", &localmbox
},
126 { "sbackup", &sbackup
},
127 { "datalocking", &datalocking
},
128 { "spoollocking", &spoollocking
},
140 static char *p_find(char *) PURE
;
144 main(int argc
, char **argv
)
151 char *cp
, buf
[BUFSIZ
], **argp
;
152 char **arguments
, *comps
[MAXARGS
];
154 if (nmh_init(argv
[0], true, false)) { return 1; }
156 arguments
= getarguments (invo_name
, argc
, argv
, 1);
159 while ((cp
= *argp
++)) {
161 switch (smatch (++cp
, switches
)) {
163 ambigsw (cp
, switches
);
166 die("-%s unknown", cp
);
169 snprintf (buf
, sizeof(buf
), "%s [profile-components] [switches]",
171 print_help (buf
, switches
, 1);
174 print_version(invo_name
);
194 if (strcmp("localmbox", cp
) == 0 && ! localmbox_primed
) {
195 localmbox
= getlocalmbox();
196 localmbox_primed
= true;
205 inform("profile-components ignored with -all");
208 inform("-%scomponents ignored with -all",
209 components
? "" : "no");
211 /* Print all entries in context/profile list. That does not
212 include entries in mts.conf, such as spoollocking. */
213 for (np
= m_defs
; np
; np
= np
->n_next
)
214 printf("%s: %s\n", np
->n_name
, np
->n_field
);
221 /* In case datalocking was set in profile. */
222 if ((cp
= context_find("datalocking"))) { datalocking
= cp
; }
224 /* In case spoollocking was set in mts.conf. */
227 /* Also set localmbox here */
228 if (! localmbox_primed
) {
229 localmbox
= getlocalmbox();
230 localmbox_primed
= true;
234 * Print the current value of everything in
235 * procs array. This will show their current
236 * value (as determined after context is read).
238 for (ps
= procs
; ps
->p_name
; ps
++)
239 printf ("%s: %s\n", ps
->p_name
, FENDNULL(*ps
->p_field
));
246 components
= compp
> 1;
248 for (i
= 0; i
< compp
; i
++) {
251 if (! strcmp ("spoollocking", comps
[i
])) {
252 /* In case spoollocking was set in mts.conf. */
256 value
= context_find (comps
[i
]);
258 value
= p_find (comps
[i
]);
261 printf("%s: ", comps
[i
]);
278 for (ps
= procs
; ps
->p_name
; ps
++)
279 if (!strcasecmp (ps
->p_name
, str
))