]>
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/smatch.h"
13 #include "sbr/context_find.h"
14 #include "sbr/ambigsw.h"
15 #include "sbr/print_version.h"
16 #include "sbr/print_help.h"
17 #include "sbr/error.h"
22 #define MHPARAM_SWITCHES \
23 X("components", 0, COMPSW) \
24 X("nocomponents", 0, NCOMPSW) \
26 X("version", 0, VERSIONSW) \
27 X("help", 0, HELPSW) \
28 X("debug", 5, DEBUGSW) \
30 #define X(sw, minchars, id) id,
31 DEFINE_SWITCH_ENUM(MHPARAM
);
34 #define X(sw, minchars, id) { sw, minchars, id },
35 DEFINE_SWITCH_ARRAY(MHPARAM
, switches
);
38 extern char *mhbindir
;
39 extern char *mhlibexecdir
;
40 extern char *mhetcdir
;
41 extern char *mhdocdir
;
43 static char *sbackup
= BACKUP_PREFIX
;
45 static char *datalocking
= "fcntl";
46 static char *localmbox
= "";
47 static bool localmbox_primed
;
49 extern char *spoollocking
;
65 static char *mimetypeproc
=
72 static char *mimeencodingproc
=
73 #ifdef MIMEENCODINGPROC
98 static struct proc procs
[] = {
99 { "context", &context
},
100 { "mh-sequences", &mh_seq
},
101 { "buildmimeproc", &buildmimeproc
},
102 { "fileproc", &fileproc
},
103 { "foldprot", &foldprot
},
104 { "formatproc", &formatproc
},
105 { "incproc", &incproc
},
107 { "mailproc", &mailproc
},
108 { "mhlproc", &mhlproc
},
109 { "mimetypeproc", &mimetypeproc
},
110 { "mimeencodingproc", &mimeencodingproc
},
111 { "moreproc", &moreproc
},
112 { "msgprot", &msgprot
},
113 { "packproc", &packproc
},
114 { "postproc", &postproc
},
115 { "rmmproc", &rmmproc
},
116 { "sendproc", &sendproc
},
117 { "showmimeproc", &showmimeproc
},
118 { "showproc", &showproc
},
119 { "version", &version_num
},
120 { "whatnowproc", &whatnowproc
},
121 { "whomproc", &whomproc
},
122 { "bindir", &mhbindir
},
123 { "libexecdir", &mhlibexecdir
},
124 { "etcdir", &mhetcdir
},
125 { "docdir", &mhdocdir
},
126 { "localmbox", &localmbox
},
127 { "sbackup", &sbackup
},
128 { "datalocking", &datalocking
},
129 { "spoollocking", &spoollocking
},
141 static char *p_find(char *) PURE
;
145 main(int argc
, char **argv
)
152 char *cp
, buf
[BUFSIZ
], **argp
;
153 char **arguments
, *comps
[MAXARGS
];
155 if (nmh_init(argv
[0], true, false)) { return 1; }
157 arguments
= getarguments (invo_name
, argc
, argv
, 1);
160 while ((cp
= *argp
++)) {
162 switch (smatch (++cp
, switches
)) {
164 ambigsw (cp
, switches
);
167 die("-%s unknown", cp
);
170 snprintf (buf
, sizeof(buf
), "%s [profile-components] [switches]",
172 print_help (buf
, switches
, 1);
175 print_version(invo_name
);
195 if (strcmp("localmbox", cp
) == 0 && ! localmbox_primed
) {
196 localmbox
= getlocalmbox();
197 localmbox_primed
= true;
206 inform("profile-components ignored with -all");
209 inform("-%scomponents ignored with -all",
210 components
? "" : "no");
212 /* Print all entries in context/profile list. That does not
213 include entries in mts.conf, such as spoollocking. */
214 for (np
= m_defs
; np
; np
= np
->n_next
)
215 printf("%s: %s\n", np
->n_name
, np
->n_field
);
222 /* In case datalocking was set in profile. */
223 if ((cp
= context_find("datalocking"))) { datalocking
= cp
; }
225 /* In case spoollocking was set in mts.conf. */
228 /* Also set localmbox here */
229 if (! localmbox_primed
) {
230 localmbox
= getlocalmbox();
231 localmbox_primed
= true;
235 * Print the current value of everything in
236 * procs array. This will show their current
237 * value (as determined after context is read).
239 for (ps
= procs
; ps
->p_name
; ps
++)
240 printf ("%s: %s\n", ps
->p_name
, FENDNULL(*ps
->p_field
));
247 components
= compp
> 1;
249 for (i
= 0; i
< compp
; i
++) {
252 if (! strcmp ("spoollocking", comps
[i
])) {
253 /* In case spoollocking was set in mts.conf. */
257 value
= context_find (comps
[i
]);
259 value
= p_find (comps
[i
]);
262 printf("%s: ", comps
[i
]);
279 for (ps
= procs
; ps
->p_name
; ps
++)
280 if (!strcasecmp (ps
->p_name
, str
))