]>
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 *mhlibdir
;
33 extern char *mhetcdir
;
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 { "mshproc", &mshproc
},
99 { "packproc", &packproc
},
100 { "postproc", &postproc
},
101 { "rmmproc", &rmmproc
},
102 { "sendproc", &sendproc
},
103 { "showmimeproc", &showmimeproc
},
104 { "showproc", &showproc
},
105 { "version", &version_num
},
106 { "vmhproc", &vmhproc
},
107 { "whatnowproc", &whatnowproc
},
108 { "whomproc", &whomproc
},
109 { "etcdir", &mhetcdir
},
110 { "libdir", &mhlibdir
},
111 { "localmbox", &localmbox
},
112 { "sbackup", &sbackup
},
113 { "datalocking", &datalocking
},
114 { "spoollocking", &spoollocking
},
125 static char *p_find(char *);
129 main(int argc
, char **argv
)
131 int i
, compp
= 0, missed
= 0;
132 int all
= 0, debug
= 0;
134 char *cp
, buf
[BUFSIZ
], **argp
;
135 char **arguments
, *comps
[MAXARGS
];
137 if (nmh_init(argv
[0], 1)) { return 1; }
139 arguments
= getarguments (invo_name
, argc
, argv
, 1);
142 while ((cp
= *argp
++)) {
144 switch (smatch (++cp
, switches
)) {
146 ambigsw (cp
, switches
);
149 adios (NULL
, "-%s unknown", cp
);
152 snprintf (buf
, sizeof(buf
), "%s [profile-components] [switches]",
154 print_help (buf
, switches
, 1);
157 print_version(invo_name
);
177 if (strcmp("localmbox", cp
) == 0 && ! localmbox_primed
) {
178 localmbox
= getlocalmbox();
179 localmbox_primed
= 1;
188 advise(NULL
, "profile-components ignored with -all");
191 advise(NULL
, "-%scomponents ignored with -all",
192 components
? "" : "no");
194 /* print all entries in context/profile list */
195 for (np
= m_defs
; np
; np
= np
->n_next
)
196 printf("%s: %s\n", np
->n_name
, np
->n_field
);
201 /* Need to see if datalocking was set in profile. */
202 if ((cp
= context_find("datalocking"))) { datalocking
= cp
; }
204 /* Also set localmbox here */
205 if (! localmbox_primed
) {
206 localmbox
= getlocalmbox();
207 localmbox_primed
= 1;
211 * Print the current value of everything in
212 * procs array. This will show their current
213 * value (as determined after context is read).
215 for (ps
= procs
; ps
->p_name
; ps
++)
216 printf ("%s: %s\n", ps
->p_name
, *ps
->p_field
? *ps
->p_field
: "");
220 components
= compp
> 1;
222 for (i
= 0; i
< compp
; i
++) {
223 register char *value
;
225 value
= context_find (comps
[i
]);
227 value
= p_find (comps
[i
]);
230 printf("%s: ", comps
[i
]);
232 printf("%s\n", value
);
248 for (ps
= procs
; ps
->p_name
; ps
++)
249 if (!strcasecmp (ps
->p_name
, str
? str
: ""))
250 return (*ps
->p_field
);