]>
diplodocus.org Git - nmh/blob - uip/mhparam.c
3 * mhparam.c -- print mh_profile values
5 * Originally contributed by
6 * Jeffrey C Honig <Jeffrey_C_Honig@cornell.edu>
8 * This code is Copyright (c) 2002, by the authors of nmh. See the
9 * COPYRIGHT file in the root directory of the nmh distribution for
10 * complete copyright information.
16 #define MHPARAM_SWITCHES \
17 X("components", 0, COMPSW) \
18 X("nocomponents", 0, NCOMPSW) \
20 X("version", 0, VERSIONSW) \
21 X("help", 0, HELPSW) \
22 X("debug", 5, DEBUGSW) \
24 #define X(sw, minchars, id) id,
25 DEFINE_SWITCH_ENUM(MHPARAM
);
28 #define X(sw, minchars, id) { sw, minchars, id },
29 DEFINE_SWITCH_ARRAY(MHPARAM
, switches
);
32 extern char *mhbindir
;
33 extern char *mhetcdir
;
34 extern char *mhlibexecdir
;
36 static char *sbackup
= BACKUP_PREFIX
;
38 static char *datalocking
= "fcntl";
39 static char *localmbox
= "";
40 static int localmbox_primed
= 0;
42 extern char *spoollocking
;
58 static char *mimetypeproc
=
65 static char *mimeencodingproc
=
66 #ifdef MIMEENCODINGPROC
91 static struct proc procs
[] = {
92 { "context", &context
},
93 { "mh-sequences", &mh_seq
},
94 { "buildmimeproc", &buildmimeproc
},
95 { "fileproc", &fileproc
},
96 { "foldprot", &foldprot
},
97 { "formatproc", &formatproc
},
98 { "incproc", &incproc
},
100 { "mailproc", &mailproc
},
101 { "mhlproc", &mhlproc
},
102 { "mimetypeproc", &mimetypeproc
},
103 { "mimeencodingproc", &mimeencodingproc
},
104 { "moreproc", &moreproc
},
105 { "msgprot", &msgprot
},
106 { "packproc", &packproc
},
107 { "postproc", &postproc
},
108 { "rmmproc", &rmmproc
},
109 { "sendproc", &sendproc
},
110 { "showmimeproc", &showmimeproc
},
111 { "showproc", &showproc
},
112 { "version", &version_num
},
113 { "whatnowproc", &whatnowproc
},
114 { "whomproc", &whomproc
},
115 { "bindir", &mhbindir
},
116 { "etcdir", &mhetcdir
},
117 { "libdir", &mhlibexecdir
},
118 { "libexecdir", &mhlibexecdir
},
119 { "localmbox", &localmbox
},
120 { "sbackup", &sbackup
},
121 { "datalocking", &datalocking
},
122 { "spoollocking", &spoollocking
},
134 static char *p_find(char *);
138 main(int argc
, char **argv
)
140 int i
, compp
= 0, missed
= 0;
141 int all
= 0, debug
= 0;
143 char *cp
, buf
[BUFSIZ
], **argp
;
144 char **arguments
, *comps
[MAXARGS
];
146 if (nmh_init(argv
[0], 1)) { return 1; }
148 arguments
= getarguments (invo_name
, argc
, argv
, 1);
151 while ((cp
= *argp
++)) {
153 switch (smatch (++cp
, switches
)) {
155 ambigsw (cp
, switches
);
158 adios (NULL
, "-%s unknown", cp
);
161 snprintf (buf
, sizeof(buf
), "%s [profile-components] [switches]",
163 print_help (buf
, switches
, 1);
166 print_version(invo_name
);
186 if (strcmp("localmbox", cp
) == 0 && ! localmbox_primed
) {
187 localmbox
= getlocalmbox();
188 localmbox_primed
= 1;
197 advise(NULL
, "profile-components ignored with -all");
200 advise(NULL
, "-%scomponents ignored with -all",
201 components
? "" : "no");
203 /* Print all entries in context/profile list. That does not
204 include entries in mts.conf, such as spoollocking. */
205 for (np
= m_defs
; np
; np
= np
->n_next
)
206 printf("%s: %s\n", np
->n_name
, np
->n_field
);
211 /* In case datalocking was set in profile. */
212 if ((cp
= context_find("datalocking"))) { datalocking
= cp
; }
214 /* In case spoollocking was set in mts.conf. */
217 /* Also set localmbox here */
218 if (! localmbox_primed
) {
219 localmbox
= getlocalmbox();
220 localmbox_primed
= 1;
224 * Print the current value of everything in
225 * procs array. This will show their current
226 * value (as determined after context is read).
228 for (ps
= procs
; ps
->p_name
; ps
++)
229 printf ("%s: %s\n", ps
->p_name
, *ps
->p_field
? *ps
->p_field
: "");
233 components
= compp
> 1;
235 for (i
= 0; i
< compp
; i
++) {
236 register char *value
;
238 if (! strcmp ("spoollocking", comps
[i
])) {
239 /* In case spoollocking was set in mts.conf. */
243 value
= context_find (comps
[i
]);
245 value
= p_find (comps
[i
]);
248 printf("%s: ", comps
[i
]);
250 printf("%s\n", value
);
266 for (ps
= procs
; ps
->p_name
; ps
++)
267 if (!strcasecmp (ps
->p_name
, str
? str
: ""))
268 return (*ps
->p_field
);