comparison uip/mhparam.c @ 0:bce86c4163a3

Initial revision
author kono
date Mon, 18 Apr 2005 23:46:02 +0900
parents
children 441a2190cfae
comparison
equal deleted inserted replaced
-1:000000000000 0:bce86c4163a3
1 /* mhparam.c - print mh_profile values */
2 #ifndef lint
3 static char ident[] = "@(#)$Id$";
4 #endif /* lint */
5 /* contributed by Jeffrey C Honig <Jeffrey_C_Honig@cornell.edu> */
6
7 #include "../h/mh.h"
8 #include <stdio.h>
9
10 extern char *mhlibdir; /* NB: this will change soon */
11 char *sbackup = SBACKUP;
12 char *slink = LINK;
13
14 /* */
15
16 static struct swit switches[] = {
17 #define COMPSW 0
18 "components", 0,
19 #define NCOMPSW 1
20 "nocomponents", 0,
21 #define ALLSW 2
22 "all", 0,
23 #define HELPSW 3
24 "help", 4,
25
26 NULL, 0
27 };
28
29 static char *p_find();
30
31 /* */
32
33 /* ARGSUSED */
34
35 main(argc, argv)
36 int argc;
37 char *argv[];
38 {
39 int i,
40 all = 0,
41 compp = 0,
42 components = -1,
43 missed = 0;
44 char *cp,
45 buf[100],
46 **ap,
47 **argp,
48 *arguments[MAXARGS],
49 *comps[MAXARGS];
50
51 #ifdef JAPAN
52 ml_init();
53 #endif /* JAPAN */
54 invo_name = r1bindex (argv[0], '/');
55 if ((cp = m_find (invo_name)) != NULL) {
56 ap = brkstring (cp = getcpy (cp), " ", "\n");
57 ap = copyip (ap, arguments);
58 }
59 else
60 ap = arguments;
61 (void) copyip (argv + 1, ap);
62 argp = arguments;
63
64 /* */
65
66 while (cp = *argp++) {
67 if (*cp == '-')
68 switch (smatch (++cp, switches)) {
69 case AMBIGSW:
70 ambigsw (cp, switches);
71 done (1);
72 case UNKWNSW:
73 adios (NULLCP, "-%s unknown", cp);
74 case HELPSW:
75 (void) sprintf (buf, "%s [profile-components] [switches]",
76 invo_name);
77 help (buf, switches);
78 done (1);
79
80 case COMPSW:
81 components = 1;
82 break;
83 case NCOMPSW:
84 components = 0;
85 break;
86
87 case ALLSW:
88 all = 1;
89 break;
90
91 }
92 else
93 comps[compp++] = cp;
94 }
95
96 /* */
97
98 if (all) {
99 register struct node *np;
100
101 if (compp)
102 advise(NULLCP, "profile-components ignored with -all");
103
104 if (components >= 0)
105 advise(NULLCP, "-%scomponents ignored with -all",
106 components ? "" : "no");
107
108 m_getdefs ();
109 for (np = m_defs; np; np = np -> n_next) {
110 #ifdef JAPAN
111 printf("%s:\t", np -> n_name);
112 (void) ml_conv(np -> n_field);
113 ml_fputs(np -> n_field, stdout);
114 fputs("\n", stdout);
115 #else /* JAPAN */
116 printf("%s:\t%s\n", np -> n_name, np -> n_field);
117 #endif /* JAPAN */
118 }
119 } else {
120 if (components < 0)
121 components = compp > 1;
122
123 for (i = 0; i < compp; i++) {
124 register char *value = m_find(comps[i]);
125
126 if (!value)
127 value = p_find(comps[i]);
128
129 if (value) {
130 if (components)
131 printf("%s:\t", comps[i]);
132
133 #ifdef JAPAN
134 (void) ml_conv(value);
135 ml_fputs(value, stdout);
136 fputs("\n", stdout);
137 #else /* JAPAN */
138 printf("%s\n", value);
139 #endif /* JAPAN */
140 } else
141 missed++;
142 }
143 }
144
145 done (missed);
146 }
147
148 static struct procs {
149 char *p_name;
150 char **p_field;
151 } procs [] = {
152 { "context", &context },
153 { "faceproc", &faceproc },
154 { "fileproc", &fileproc },
155 { "foldprot", &foldprot },
156 { "incproc", &incproc },
157 { "installproc", &installproc },
158 { "lproc", &lproc },
159 { "mailproc", &mailproc },
160 { "mhlproc", &mhlproc },
161 { "moreproc", &moreproc },
162 { "msgprot", &msgprot },
163 { "mshproc", &mshproc },
164 { "packproc", &packproc },
165 { "postproc", &postproc },
166 { "rmfproc", &rmfproc },
167 { "rmmproc", &rmmproc },
168 { "sendproc", &sendproc },
169 { "showproc", &showproc },
170 { "slocalproc", &slocalproc },
171 { "version", &version },
172 { "vmhproc", &vmhproc },
173 { "whatnowproc", &whatnowproc },
174 { "whomproc", &whomproc },
175 { "libdir", &mhlibdir },
176 { "sbackup", &sbackup },
177 { "link", &slink },
178
179 { NULL, NULL },
180 };
181
182 static char *p_find(str)
183 register char *str;
184 {
185 register struct procs *ps;
186
187 for (ps = procs; ps->p_name; ps++)
188 if (uleq (ps -> p_name, str))
189 #ifdef JAPAN
190 return getcpy(*ps -> p_field);
191 #else
192 return (*ps -> p_field);
193 #endif
194
195 return NULL;
196 }