]>
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 *mhlibexecdir
;
34 extern char *mhetcdir
;
35 extern char *mhdocdir
;
37 static char *sbackup
= BACKUP_PREFIX
;
39 static char *datalocking
= "fcntl";
40 static char *localmbox
= "";
41 static int localmbox_primed
= 0;
43 extern char *spoollocking
;
59 static char *mimetypeproc
=
66 static char *mimeencodingproc
=
67 #ifdef MIMEENCODINGPROC
85 static struct proc procs
[] = {
86 { "context", &context
},
87 { "mh-sequences", &mh_seq
},
88 { "buildmimeproc", &buildmimeproc
},
89 { "fileproc", &fileproc
},
90 { "foldprot", &foldprot
},
91 { "formatproc", &formatproc
},
92 { "incproc", &incproc
},
94 { "mailproc", &mailproc
},
95 { "mhlproc", &mhlproc
},
96 { "mimetypeproc", &mimetypeproc
},
97 { "mimeencodingproc", &mimeencodingproc
},
98 { "moreproc", &moreproc
},
99 { "msgprot", &msgprot
},
100 { "packproc", &packproc
},
101 { "postproc", &postproc
},
102 { "rmmproc", &rmmproc
},
103 { "sendproc", &sendproc
},
104 { "showmimeproc", &showmimeproc
},
105 { "showproc", &showproc
},
106 { "version", &version_num
},
107 { "whatnowproc", &whatnowproc
},
108 { "whomproc", &whomproc
},
109 { "bindir", &mhbindir
},
110 { "libexecdir", &mhlibexecdir
},
111 { "libdir", &mhlibexecdir
},
112 { "etcdir", &mhetcdir
},
113 { "docdir", &mhdocdir
},
114 { "localmbox", &localmbox
},
115 { "sbackup", &sbackup
},
116 { "datalocking", &datalocking
},
117 { "spoollocking", &spoollocking
},
128 static char *p_find(char *);
132 main(int argc
, char **argv
)
134 int i
, compp
= 0, missed
= 0;
135 int all
= 0, debug
= 0;
137 char *cp
, buf
[BUFSIZ
], **argp
;
138 char **arguments
, *comps
[MAXARGS
];
140 if (nmh_init(argv
[0], 1)) { return 1; }
142 arguments
= getarguments (invo_name
, argc
, argv
, 1);
145 while ((cp
= *argp
++)) {
147 switch (smatch (++cp
, switches
)) {
149 ambigsw (cp
, switches
);
152 adios (NULL
, "-%s unknown", cp
);
155 snprintf (buf
, sizeof(buf
), "%s [profile-components] [switches]",
157 print_help (buf
, switches
, 1);
160 print_version(invo_name
);
180 if (strcmp("localmbox", cp
) == 0 && ! localmbox_primed
) {
181 localmbox
= getlocalmbox();
182 localmbox_primed
= 1;
191 advise(NULL
, "profile-components ignored with -all");
194 advise(NULL
, "-%scomponents ignored with -all",
195 components
? "" : "no");
197 /* Print all entries in context/profile list. That does not
198 include entries in mts.conf, such as spoollocking. */
199 for (np
= m_defs
; np
; np
= np
->n_next
)
200 printf("%s: %s\n", np
->n_name
, np
->n_field
);
205 /* In case datalocking was set in profile. */
206 if ((cp
= context_find("datalocking"))) { datalocking
= cp
; }
208 /* In case spoollocking was set in mts.conf. */
211 /* Also set localmbox here */
212 if (! localmbox_primed
) {
213 localmbox
= getlocalmbox();
214 localmbox_primed
= 1;
218 * Print the current value of everything in
219 * procs array. This will show their current
220 * value (as determined after context is read).
222 for (ps
= procs
; ps
->p_name
; ps
++)
223 printf ("%s: %s\n", ps
->p_name
, *ps
->p_field
? *ps
->p_field
: "");
227 components
= compp
> 1;
229 for (i
= 0; i
< compp
; i
++) {
230 register char *value
;
232 if (! strcmp ("spoollocking", comps
[i
])) {
233 /* In case spoollocking was set in mts.conf. */
237 value
= context_find (comps
[i
]);
239 value
= p_find (comps
[i
]);
242 printf("%s: ", comps
[i
]);
244 printf("%s\n", value
);
260 for (ps
= procs
; ps
->p_name
; ps
++)
261 if (!strcasecmp (ps
->p_name
, str
? str
: ""))
262 return (*ps
->p_field
);