]>
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 *mhetcdir
;
33 extern char *mhlibexecdir
;
35 static char *sbackup
= BACKUP_PREFIX
;
37 static char *datalocking
= "fcntl";
38 static char *localmbox
= "";
39 static int localmbox_primed
= 0;
41 extern char *spoollocking
;
57 static char *mimetypeproc
=
64 static char *mimeencodingproc
=
65 #ifdef MIMEENCODINGPROC
83 static struct proc procs
[] = {
84 { "context", &context
},
85 { "mh-sequences", &mh_seq
},
86 { "buildmimeproc", &buildmimeproc
},
87 { "fileproc", &fileproc
},
88 { "foldprot", &foldprot
},
89 { "formatproc", &formatproc
},
90 { "incproc", &incproc
},
92 { "mailproc", &mailproc
},
93 { "mhlproc", &mhlproc
},
94 { "mimetypeproc", &mimetypeproc
},
95 { "mimeencodingproc", &mimeencodingproc
},
96 { "moreproc", &moreproc
},
97 { "msgprot", &msgprot
},
98 { "packproc", &packproc
},
99 { "postproc", &postproc
},
100 { "rmmproc", &rmmproc
},
101 { "sendproc", &sendproc
},
102 { "showmimeproc", &showmimeproc
},
103 { "showproc", &showproc
},
104 { "version", &version_num
},
105 { "whatnowproc", &whatnowproc
},
106 { "whomproc", &whomproc
},
107 { "etcdir", &mhetcdir
},
108 { "libdir", &mhlibexecdir
},
109 { "libexecdir", &mhlibexecdir
},
110 { "localmbox", &localmbox
},
111 { "sbackup", &sbackup
},
112 { "datalocking", &datalocking
},
113 { "spoollocking", &spoollocking
},
124 static char *p_find(char *);
128 main(int argc
, char **argv
)
130 int i
, compp
= 0, missed
= 0;
131 int all
= 0, debug
= 0;
133 char *cp
, buf
[BUFSIZ
], **argp
;
134 char **arguments
, *comps
[MAXARGS
];
136 if (nmh_init(argv
[0], 1)) { return 1; }
138 arguments
= getarguments (invo_name
, argc
, argv
, 1);
141 while ((cp
= *argp
++)) {
143 switch (smatch (++cp
, switches
)) {
145 ambigsw (cp
, switches
);
148 adios (NULL
, "-%s unknown", cp
);
151 snprintf (buf
, sizeof(buf
), "%s [profile-components] [switches]",
153 print_help (buf
, switches
, 1);
156 print_version(invo_name
);
176 if (strcmp("localmbox", cp
) == 0 && ! localmbox_primed
) {
177 localmbox
= getlocalmbox();
178 localmbox_primed
= 1;
187 advise(NULL
, "profile-components ignored with -all");
190 advise(NULL
, "-%scomponents ignored with -all",
191 components
? "" : "no");
193 /* Print all entries in context/profile list. That does not
194 include entries in mts.conf, such as spoollocking. */
195 for (np
= m_defs
; np
; np
= np
->n_next
)
196 printf("%s: %s\n", np
->n_name
, np
->n_field
);
201 /* In case datalocking was set in profile. */
202 if ((cp
= context_find("datalocking"))) { datalocking
= cp
; }
204 /* In case spoollocking was set in mts.conf. */
207 /* Also set localmbox here */
208 if (! localmbox_primed
) {
209 localmbox
= getlocalmbox();
210 localmbox_primed
= 1;
214 * Print the current value of everything in
215 * procs array. This will show their current
216 * value (as determined after context is read).
218 for (ps
= procs
; ps
->p_name
; ps
++)
219 printf ("%s: %s\n", ps
->p_name
, *ps
->p_field
? *ps
->p_field
: "");
223 components
= compp
> 1;
225 for (i
= 0; i
< compp
; i
++) {
226 register char *value
;
228 if (! strcmp ("spoollocking", comps
[i
])) {
229 /* In case spoollocking was set in mts.conf. */
233 value
= context_find (comps
[i
]);
235 value
= p_find (comps
[i
]);
238 printf("%s: ", comps
[i
]);
240 printf("%s\n", value
);
256 for (ps
= procs
; ps
->p_name
; ps
++)
257 if (!strcasecmp (ps
->p_name
, str
? str
: ""))
258 return (*ps
->p_field
);