]>
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
84 static struct proc procs
[] = {
85 { "context", &context
},
86 { "mh-sequences", &mh_seq
},
87 { "buildmimeproc", &buildmimeproc
},
88 { "fileproc", &fileproc
},
89 { "foldprot", &foldprot
},
90 { "formatproc", &formatproc
},
91 { "incproc", &incproc
},
93 { "mailproc", &mailproc
},
94 { "mhlproc", &mhlproc
},
95 { "mimetypeproc", &mimetypeproc
},
96 { "mimeencodingproc", &mimeencodingproc
},
97 { "moreproc", &moreproc
},
98 { "msgprot", &msgprot
},
99 { "packproc", &packproc
},
100 { "postproc", &postproc
},
101 { "rmmproc", &rmmproc
},
102 { "sendproc", &sendproc
},
103 { "showmimeproc", &showmimeproc
},
104 { "showproc", &showproc
},
105 { "version", &version_num
},
106 { "whatnowproc", &whatnowproc
},
107 { "whomproc", &whomproc
},
108 { "bindir", &mhbindir
},
109 { "etcdir", &mhetcdir
},
110 { "libdir", &mhlibexecdir
},
111 { "libexecdir", &mhlibexecdir
},
112 { "localmbox", &localmbox
},
113 { "sbackup", &sbackup
},
114 { "datalocking", &datalocking
},
115 { "spoollocking", &spoollocking
},
126 static char *p_find(char *);
130 main(int argc
, char **argv
)
132 int i
, compp
= 0, missed
= 0;
133 int all
= 0, debug
= 0;
135 char *cp
, buf
[BUFSIZ
], **argp
;
136 char **arguments
, *comps
[MAXARGS
];
138 if (nmh_init(argv
[0], 1)) { return 1; }
140 arguments
= getarguments (invo_name
, argc
, argv
, 1);
143 while ((cp
= *argp
++)) {
145 switch (smatch (++cp
, switches
)) {
147 ambigsw (cp
, switches
);
150 adios (NULL
, "-%s unknown", cp
);
153 snprintf (buf
, sizeof(buf
), "%s [profile-components] [switches]",
155 print_help (buf
, switches
, 1);
158 print_version(invo_name
);
178 if (strcmp("localmbox", cp
) == 0 && ! localmbox_primed
) {
179 localmbox
= getlocalmbox();
180 localmbox_primed
= 1;
189 advise(NULL
, "profile-components ignored with -all");
192 advise(NULL
, "-%scomponents ignored with -all",
193 components
? "" : "no");
195 /* Print all entries in context/profile list. That does not
196 include entries in mts.conf, such as spoollocking. */
197 for (np
= m_defs
; np
; np
= np
->n_next
)
198 printf("%s: %s\n", np
->n_name
, np
->n_field
);
203 /* In case datalocking was set in profile. */
204 if ((cp
= context_find("datalocking"))) { datalocking
= cp
; }
206 /* In case spoollocking was set in mts.conf. */
209 /* Also set localmbox here */
210 if (! localmbox_primed
) {
211 localmbox
= getlocalmbox();
212 localmbox_primed
= 1;
216 * Print the current value of everything in
217 * procs array. This will show their current
218 * value (as determined after context is read).
220 for (ps
= procs
; ps
->p_name
; ps
++)
221 printf ("%s: %s\n", ps
->p_name
, *ps
->p_field
? *ps
->p_field
: "");
225 components
= compp
> 1;
227 for (i
= 0; i
< compp
; i
++) {
228 register char *value
;
230 if (! strcmp ("spoollocking", comps
[i
])) {
231 /* In case spoollocking was set in mts.conf. */
235 value
= context_find (comps
[i
]);
237 value
= p_find (comps
[i
]);
240 printf("%s: ", comps
[i
]);
242 printf("%s\n", value
);
258 for (ps
= procs
; ps
->p_name
; ps
++)
259 if (!strcasecmp (ps
->p_name
, str
? str
: ""))
260 return (*ps
->p_field
);