annotate conf/mhconfig.c @ 7:c20e4181370f

utf-8 input assumption in case of base64/utf-8
author kono
date Sun, 04 Dec 2005 02:30:39 +0900
parents bce86c4163a3
children 441a2190cfae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1 /* mhconfig.c - configure MH */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
2 /* cc [-DSYS5] mhconfig.c -o mhconfig */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
3 #ifndef lint
bce86c4163a3 Initial revision
kono
parents:
diff changeset
4 static char ident[] = "@(#)$Id$";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
5 #endif /* lint */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
6
bce86c4163a3 Initial revision
kono
parents:
diff changeset
7 #include <ctype.h>
bce86c4163a3 Initial revision
kono
parents:
diff changeset
8 #include <stdio.h>
bce86c4163a3 Initial revision
kono
parents:
diff changeset
9 #ifdef hpux
bce86c4163a3 Initial revision
kono
parents:
diff changeset
10 #define SYS5
bce86c4163a3 Initial revision
kono
parents:
diff changeset
11 #endif
bce86c4163a3 Initial revision
kono
parents:
diff changeset
12 #ifdef SYS5
bce86c4163a3 Initial revision
kono
parents:
diff changeset
13 #define index strchr
bce86c4163a3 Initial revision
kono
parents:
diff changeset
14 #define rindex strrchr
bce86c4163a3 Initial revision
kono
parents:
diff changeset
15 #endif /* SYS5 */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
16
bce86c4163a3 Initial revision
kono
parents:
diff changeset
17 static void insopt(), mkopts();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
18
bce86c4163a3 Initial revision
kono
parents:
diff changeset
19 extern char *strcpy(), *malloc(), *index(), *rindex();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
20 #ifdef notdef
bce86c4163a3 Initial revision
kono
parents:
diff changeset
21 extern char *sprintf(); /* rely on stdio.h to declare this */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
22 #endif
bce86c4163a3 Initial revision
kono
parents:
diff changeset
23
bce86c4163a3 Initial revision
kono
parents:
diff changeset
24 #define BANNER "This is %s, for generic UNIX (MH.6 configuration program)\n\n"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
25
bce86c4163a3 Initial revision
kono
parents:
diff changeset
26
bce86c4163a3 Initial revision
kono
parents:
diff changeset
27 #define SED "config.sed"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
28 #define SED2 "config2.sed"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
29 #define SEDOC "doc/config.sed"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
30 #define SEDOC2 "doc/config2.sed"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
31 #define MAKE "../%s/Makefile"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
32
bce86c4163a3 Initial revision
kono
parents:
diff changeset
33 #define WARNING "This file is automatically generated. Do not edit!"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
34 #define MHRELEASE "6.8.4" /* for version: "Maj.min.pat" */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
35 #define MHCENTERFOOT "MH.6.8" /* for nroff page footers */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
36 #define MHLEFTFOOT "[mh.6]" /* [mh.6] MH.6.6 page# */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
37
bce86c4163a3 Initial revision
kono
parents:
diff changeset
38 #ifdef MHSLIB_NOMINVER
bce86c4163a3 Initial revision
kono
parents:
diff changeset
39 #define MHSLIBVER "3" /* Shared library version (no minor version) */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
40 #else /* MHSLIB_NOMINVER */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
41 #define MHSLIBVER "3.2" /* Shared library version */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
42 #endif /* MHSLIB_NOMINVER */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
43
bce86c4163a3 Initial revision
kono
parents:
diff changeset
44 #define NOTOK (-1)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
45
bce86c4163a3 Initial revision
kono
parents:
diff changeset
46 #define NULLCP ((char *) 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
47
bce86c4163a3 Initial revision
kono
parents:
diff changeset
48 #define SVAL(s) (s ? s : "")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
49
bce86c4163a3 Initial revision
kono
parents:
diff changeset
50 #define QUOTE '\\'
bce86c4163a3 Initial revision
kono
parents:
diff changeset
51
bce86c4163a3 Initial revision
kono
parents:
diff changeset
52 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
53
bce86c4163a3 Initial revision
kono
parents:
diff changeset
54 static int smtp = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
55 static int mpop = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
56 static int nntp = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
57 static int gzipman = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
58
bce86c4163a3 Initial revision
kono
parents:
diff changeset
59 static int sedP = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
60 static int filesP = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
61 static int docP = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
62 static int makeP = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
63
bce86c4163a3 Initial revision
kono
parents:
diff changeset
64 static char *myname = "mhconfig";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
65 static char *config = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
66 static char *myopts = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
67
bce86c4163a3 Initial revision
kono
parents:
diff changeset
68 static char *binpath = "/usr/local";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
69 static char *bbhome = "/usr/spool/bboards";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
70 static char *bboards = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
71 static char *bbdelivery = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
72 static char *ccoptions = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
73 static char *chownpath = "/etc/chown";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
74 static char *sendmailpath = "/usr/lib/sendmail";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
75 static char *compiler = "/bin/cc";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
76 static char *cpp = "/lib/ccp";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
77 static char *copy = "cp";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
78 static char *curses = "-lcurses -ltermlib";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
79 static char *debug = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
80 static char *editor = "prompter";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
81 static char *etcpath = "/usr/local/lib/mh";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
82 static char *ldoptions = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
83 static char *ldoptlibs = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
84 /* jp2c+ */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
85 static int norespost = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
86 static char *ldoptlibs_post = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
87 /* jp2c+ */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
88 static char *lex = "lex -nt";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
89 static char *ln = "ln";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
90 static char *mailgroup = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
91 static char *mailpath = "/usr/spool/mail";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
92 static char *maildir = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
93 static char *mailfile = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
94 static char *mancat = "man";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
95 static char *mandir = "/usr/man";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
96 static char *jmandir = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
97 static char *manuals = "standard";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
98 static char *mf = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
99 static char *mts = "sendmail";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
100 static char *poppath = "/usr/etc";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
101 static char *removeit = "mv -f";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
102 static char *regtest = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
103 static char *oldload = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
104 static char *options = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
105 static char *pop = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
106 static char *ranlib = "on";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
107 static char *sharedlib = "off";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
108 static char *signl = "int";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
109 static char *slibdir = "/usr/local/lib";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
110 static char *slflags = "-pic";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
111 static char *sprntf = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
112
bce86c4163a3 Initial revision
kono
parents:
diff changeset
113 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
114
bce86c4163a3 Initial revision
kono
parents:
diff changeset
115 #define unknown 0
bce86c4163a3 Initial revision
kono
parents:
diff changeset
116 #define mmdf 1
bce86c4163a3 Initial revision
kono
parents:
diff changeset
117 #define mmdf2 2
bce86c4163a3 Initial revision
kono
parents:
diff changeset
118 #define mh 3
bce86c4163a3 Initial revision
kono
parents:
diff changeset
119 #define sendmail 4
bce86c4163a3 Initial revision
kono
parents:
diff changeset
120 static int mtsnum = unknown;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
121
bce86c4163a3 Initial revision
kono
parents:
diff changeset
122 static struct mtsopt {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
123 char *mtskey;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
124 char *optval;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
125 int code;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
126 int mtsflags;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
127 #define NOFLAGS 0x00
bce86c4163a3 Initial revision
kono
parents:
diff changeset
128 #define DOSMTP 0x01
bce86c4163a3 Initial revision
kono
parents:
diff changeset
129 #define NOMF 0x02
bce86c4163a3 Initial revision
kono
parents:
diff changeset
130 } mtsopts[] = {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
131 "mmdf", "MMDFMTS MMDFI", mmdf, NOFLAGS,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
132 "mmdf/smtp", "SENDMTS SMTP", mmdf, DOSMTP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
133 "mmdf2", "MMDFMTS MMDFII", mmdf2, NOFLAGS,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
134 "mmdf2/smtp", "SENDMTS MMDFII SMTP", mmdf2, DOSMTP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
135 "mh", "MHMTS", mh, NOFLAGS,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
136 "sendmail", "SENDMTS", sendmail, NOMF,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
137 "sendmail/smtp", "SENDMTS SMTP", sendmail, NOMF,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
138 "zmailer", "ZMAILER SENDMTS", sendmail, NOMF,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
139 "zmailer/smtp", "ZMAILER SENDMTS SMTP", sendmail, NOMF,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
140 NULL, NULL, unknown, NOFLAGS
bce86c4163a3 Initial revision
kono
parents:
diff changeset
141 };
bce86c4163a3 Initial revision
kono
parents:
diff changeset
142
bce86c4163a3 Initial revision
kono
parents:
diff changeset
143 /* other options which cause sed BEGIN/END configuration changes */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
144
bce86c4163a3 Initial revision
kono
parents:
diff changeset
145 static struct copt {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
146 char *c_name;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
147 int c_value;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
148 } copts[] = {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
149 "APOP", 0, /* authenticated pop */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
150 "BSD43", 0, /* sgid ttys */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
151 "BSD44", 0, /* manual headings */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
152 "KPOP", 0, /* KERBEROS pop */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
153 "HESIOD", 0,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
154 /* NOTE: MIME_HEADERS must locate befer MIME */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
155 "MIME_HEADERS", 0, /* RFC-2047 headers */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
156 "MIME", 0, /* multi-media extensions */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
157 "MPOP", 0, /* mobile pop */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
158 "MSGID", 0, /* slocal dup surpression */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
159 "NORUSERPASS", 0, /* no ruserpass(3) */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
160 "TMA", 0, /* trusted mail */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
161 "TTYD", 0,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
162 "UCI", 0,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
163 "RPOP", 0,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
164 "READLINE", 0, /* use GNU readline() */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
165 "JAPAN", 0, /* Japanization patch */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
166 "MH_PLUS", 0, /* MH-plus patch */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
167 NULL, 0
bce86c4163a3 Initial revision
kono
parents:
diff changeset
168 };
bce86c4163a3 Initial revision
kono
parents:
diff changeset
169
bce86c4163a3 Initial revision
kono
parents:
diff changeset
170
bce86c4163a3 Initial revision
kono
parents:
diff changeset
171
bce86c4163a3 Initial revision
kono
parents:
diff changeset
172 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
173
bce86c4163a3 Initial revision
kono
parents:
diff changeset
174 static struct bind {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
175 char *keyword;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
176
bce86c4163a3 Initial revision
kono
parents:
diff changeset
177 char **value;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
178
bce86c4163a3 Initial revision
kono
parents:
diff changeset
179 int flags;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
180 #define BD_NIL 0x00
bce86c4163a3 Initial revision
kono
parents:
diff changeset
181 #define BD_ADD 0x01
bce86c4163a3 Initial revision
kono
parents:
diff changeset
182 } binds[] = {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
183 "bin", &binpath, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
184 "bbhome", &bbhome, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
185 "bboards", &bboards, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
186 "bbdelivery", &bbdelivery, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
187 "ccoptions", &ccoptions, BD_ADD,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
188 "chown", &chownpath, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
189 "cc", &compiler, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
190 "cpp", &cpp, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
191 "cp", &copy, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
192 "curses", &curses, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
193 "debug", &debug, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
194 "editor", &editor, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
195 "etc", &etcpath, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
196 "ldoptions", &ldoptions, BD_ADD,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
197 "ldoptlibs", &ldoptlibs, BD_ADD,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
198 "ldoptlibs_post", &ldoptlibs_post, BD_ADD,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
199 "lex", &lex, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
200 "ln", &ln, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
201 "mail", &mailpath, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
202 "mailgroup", &mailgroup, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
203 "mandir", &mandir, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
204 "jmandir", &jmandir, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
205 "manuals", &manuals, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
206 "mf", &mf, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
207 "mts", &mts, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
208 "oldload", &oldload, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
209 "options", &options, BD_ADD,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
210 "pop", &pop, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
211 "popdir", &poppath, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
212 "ranlib", &ranlib, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
213 "remove", &removeit, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
214 "regtest", &regtest, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
215 "sendmail", &sendmailpath, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
216 "sharedlib", &sharedlib, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
217 "signal", &signl, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
218 "slflags", &slflags, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
219 "slibdir", &slibdir, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
220 "sprintf", &sprntf, BD_NIL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
221 NULL
bce86c4163a3 Initial revision
kono
parents:
diff changeset
222 };
bce86c4163a3 Initial revision
kono
parents:
diff changeset
223
bce86c4163a3 Initial revision
kono
parents:
diff changeset
224 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
225
bce86c4163a3 Initial revision
kono
parents:
diff changeset
226 char *files[] = {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
227 "../support/bboards/bboards.daily",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
228 "../support/bboards/bboards.weekly",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
229 "../support/bboards/crontab",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
230 "../support/bboards/MakeBBoards",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
231 "../config/config.c",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
232 "../zotnet/mts/mts.c",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
233 "../zotnet/mts/mtstailor",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
234 "../support/general/MailAliases",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
235 "../mts/sendmail/bboardsMH.m4",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
236 "../mts/sendmail/popMH.m4",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
237 NULL
bce86c4163a3 Initial revision
kono
parents:
diff changeset
238 };
bce86c4163a3 Initial revision
kono
parents:
diff changeset
239
bce86c4163a3 Initial revision
kono
parents:
diff changeset
240 static struct pair {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
241 char *infile;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
242 char *outfile;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
243 } makefiles[] = {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
244 "makefiles/MH-Makefile", ".",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
245 "makefiles/config","config",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
246 "makefiles/dist","dist",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
247 "makefiles/doc","doc",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
248 "makefiles/mtsM","mts",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
249 "makefiles/mts/mh","mts/mh",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
250 "makefiles/mts/mmdf","mts/mmdf",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
251 "makefiles/mts/sendmail","mts/sendmail",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
252 "makefiles/papers","papers",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
253 "makefiles/sbr","sbr",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
254 "makefiles/supportM","support",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
255 "makefiles/support/bboards","support/bboards",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
256 "makefiles/support/general","support/general",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
257 "makefiles/support/pop","support/pop",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
258 "makefiles/uip","uip",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
259 "makefiles/zotnetM","zotnet",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
260 "makefiles/zotnet/bboards","zotnet/bboards",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
261 "makefiles/zotnet/mf","zotnet/mf",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
262 "makefiles/zotnet/mts","zotnet/mts",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
263 "makefiles/zotnet/tws","zotnet/tws",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
264 NULL
bce86c4163a3 Initial revision
kono
parents:
diff changeset
265 };
bce86c4163a3 Initial revision
kono
parents:
diff changeset
266
bce86c4163a3 Initial revision
kono
parents:
diff changeset
267
bce86c4163a3 Initial revision
kono
parents:
diff changeset
268 static do_sed(), do_sedfile(), do_files(), do_doc(), do_make();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
269 static shell(), arginit(), add_option(), trim();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
270
bce86c4163a3 Initial revision
kono
parents:
diff changeset
271 static char *stradd (), *strdup (), *tail ();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
272
bce86c4163a3 Initial revision
kono
parents:
diff changeset
273 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
274
bce86c4163a3 Initial revision
kono
parents:
diff changeset
275 /* ARGSUSED */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
276
bce86c4163a3 Initial revision
kono
parents:
diff changeset
277 main (argc, argv, envp)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
278 int argc;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
279 char **argv,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
280 **envp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
281 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
282 arginit (argv);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
283
bce86c4163a3 Initial revision
kono
parents:
diff changeset
284 if (sedP)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
285 do_sed ();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
286 if (filesP)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
287 do_files ();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
288 if (docP)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
289 do_doc ();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
290 if (makeP)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
291 do_make ();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
292
bce86c4163a3 Initial revision
kono
parents:
diff changeset
293 #ifdef notdef
bce86c4163a3 Initial revision
kono
parents:
diff changeset
294 printf ("Don't forget to edit \"config/mtstailor\"\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
295 #endif
bce86c4163a3 Initial revision
kono
parents:
diff changeset
296 if (filesP || makeP)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
297 printf ("Don't forget to run \"make clean\" in the top directory before compiling\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
298
bce86c4163a3 Initial revision
kono
parents:
diff changeset
299 exit (0);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
300 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
301
bce86c4163a3 Initial revision
kono
parents:
diff changeset
302 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
303
bce86c4163a3 Initial revision
kono
parents:
diff changeset
304 static do_sed () {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
305 if (docP != 2)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
306 do_sedfile (SED, SED2, 0);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
307 do_sedfile (SEDOC, SEDOC2, smtp);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
308 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
309
bce86c4163a3 Initial revision
kono
parents:
diff changeset
310 static do_alldoc (fp)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
311 FILE *fp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
312 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
313 fprintf (fp, "%s\n%s\n%s\n%s\n", /* turn @BEGIN: XX into #ifdef XX */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
314 "s!^@BEGIN: \\(.*\\)$!.br\\", /* for MH wizard manual set */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
315 ".ti 0i\\",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
316 "#ifdef \\1\\",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
317 ".br!"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
318 );
bce86c4163a3 Initial revision
kono
parents:
diff changeset
319 fprintf (fp, "%s\n%s\n%s\n%s\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
320 "s!^@END: \\(.*\\)$!.br\\",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
321 ".ti 0i\\",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
322 "#endif /* \\1\\ */",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
323 ".br!"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
324 );
bce86c4163a3 Initial revision
kono
parents:
diff changeset
325 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
326
bce86c4163a3 Initial revision
kono
parents:
diff changeset
327 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
328
bce86c4163a3 Initial revision
kono
parents:
diff changeset
329 static do_sedfile (sed, sed2, flag)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
330 char *sed, *sed2;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
331 int flag;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
332 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
333 int i;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
334 FILE * fp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
335 struct copt *op;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
336
bce86c4163a3 Initial revision
kono
parents:
diff changeset
337 if ((fp = fopen (sed, "w")) == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
338 adios (sed, "unable to write");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
339 printf ("generating %s\n", sed);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
340
bce86c4163a3 Initial revision
kono
parents:
diff changeset
341 if (docP == 2) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
342 printf ("...using special all-doc format.\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
343 printf ("Be sure to reconfigure before compiling.\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
344 do_alldoc(fp); /* hack up doc/config.sed */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
345 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
346
bce86c4163a3 Initial revision
kono
parents:
diff changeset
347 fprintf (fp, "s%%@(MHCONFIGFILE)%%%s%%g\n", SVAL(config));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
348 fprintf (fp, "s%%@(MHWARNING)%%%s%%g\n", WARNING);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
349 fprintf (fp, "s%%@(MHRELEASE)%%%s%%g\n", MHRELEASE);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
350 fprintf (fp, "s%%@(MHCENTERFOOT)%%%s%%g\n", MHCENTERFOOT);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
351 fprintf (fp, "s%%@(MHLEFTFOOT)%%%s%%g\n", MHLEFTFOOT);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
352 fprintf (fp, "s%%@(MHBINPATH)%%%s%%g\n", SVAL (binpath));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
353 fprintf (fp, "s%%@(MHETCPATH)%%%s%%g\n", SVAL (etcpath));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
354 fprintf (fp, "s%%@(MHPOPDPATH)%%%s%%g\n", SVAL (poppath));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
355 fprintf (fp, "s%%@(MHCHOWNPATH)%%%s%%g\n", SVAL (chownpath));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
356 fprintf (fp, "s%%@(MHSENDMAILPATH)%%%s%%g\n", SVAL (sendmailpath));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
357 fprintf (fp, "s%%@(MHDROPATH)%%%s%%g\n", SVAL (maildir));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
358 fprintf (fp, "s%%@(MHDROPFIL)%%%s%%g\n", SVAL (mailfile));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
359 if (maildir)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
360 fprintf (fp, "s%%@(MHDROPLOC)%%%s/$USER%%g\n", SVAL (maildir));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
361 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
362 fprintf (fp, "s%%@(MHDROPLOC)%%$HOME/%s%%g\n", SVAL (mailfile));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
363 fprintf (fp, "s%%@(MHDROPHAK)%%%s%%g\n",/* HACK */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
364 maildir ? maildir : "/usr/spool/mail");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
365
bce86c4163a3 Initial revision
kono
parents:
diff changeset
366 fprintf (fp, "s%%@(MHMANDIR)%%%s%%g\n", mandir);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
367 if (jmandir && *jmandir) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
368 fprintf (fp, "s%%@(MHJMANDIR)%%%s%%g\n", jmandir);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
369 fprintf (fp, "/^@BEGIN: JMANUAL$/d\n/^@END: JMANUAL$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
370 } else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
371 fprintf (fp, "/^@BEGIN: JMANUAL$/,/^@END: JMANUAL$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
372 fprintf (fp, "s%%@(MHCATMAN)%%%s%%g\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
373 strcmp(mancat, "cat") == 0 ? "| nroff -man"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
374 : gzipman ? "| gzip -9n" : "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
375 if (strcmp (manuals, "standard") == 0 || strcmp (manuals, "gen") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
376 for (i = 1; i <= 8; i++) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
377 fprintf (fp, "s%%@(MHMANDIR%d)%%%s%d%%g\n", i, mancat, i);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
378 fprintf (fp, "s%%@(MHMANEXT%d)%%%d%s%%g\n", i, i,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
379 gzipman ? ".gz" : "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
380 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
381 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
382 for (i = 1; i <= 8; i++) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
383 fprintf (fp, "s%%@(MHMANDIR%d)%%%s%c%%g\n", i, mancat,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
384 strcmp (manuals, "new") == 0 ? 'n'
bce86c4163a3 Initial revision
kono
parents:
diff changeset
385 : strcmp (manuals, "old") == 0 ? 'o'
bce86c4163a3 Initial revision
kono
parents:
diff changeset
386 : strcmp (manuals, "bsd44") == 0 ? i + '0'
bce86c4163a3 Initial revision
kono
parents:
diff changeset
387 : 'l');
bce86c4163a3 Initial revision
kono
parents:
diff changeset
388 fprintf (fp, "s%%@(MHMANEXT%d)%%%c%s%%g\n", i,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
389 strcmp (manuals, "new") == 0 ? 'n'
bce86c4163a3 Initial revision
kono
parents:
diff changeset
390 : strcmp (manuals, "old") == 0 ? 'o'
bce86c4163a3 Initial revision
kono
parents:
diff changeset
391 : strcmp (manuals, "bsd44") == 0 ? '0'
bce86c4163a3 Initial revision
kono
parents:
diff changeset
392 : 'l', gzipman ? ".gz" : "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
393 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
394
bce86c4163a3 Initial revision
kono
parents:
diff changeset
395 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
396
bce86c4163a3 Initial revision
kono
parents:
diff changeset
397 if (strcmp (regtest, "on") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
398 fprintf (fp, "s%%@(MHHOSTVER)%%%s%%g\n", "-n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
399 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
400 fprintf (fp, "s%%@(MHHOSTVER)%%%s%%g\n", "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
401
bce86c4163a3 Initial revision
kono
parents:
diff changeset
402 if (strcmp (manuals, "gen") == 0 || strcmp (manuals, "none") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
403 fprintf (fp, "s%%@(MHMANGEN)%%%s%%g\n", "#"); /* comment char */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
404 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
405 fprintf (fp, "s%%@(MHMANGEN)%%%s%%g\n", "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
406
bce86c4163a3 Initial revision
kono
parents:
diff changeset
407 fprintf (fp, "s%%@(MHEDITOR)%%%s%%g\n", SVAL (editor));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
408 fprintf (fp, "s%%@(MHCONFIG)%%%s%%g\n", SVAL (myopts));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
409 fprintf (fp, "s%%@(MHCOMPILER)%%%s%%g\n", SVAL (compiler));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
410 fprintf (fp, "s%%@(MHCPP)%%%s%%g\n", SVAL (cpp));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
411 fprintf (fp, "s%%@(CP)%%%s%%g\n", SVAL (copy));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
412 fprintf (fp, "s%%@(LN)%%%s%%g\n", SVAL (ln));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
413 fprintf (fp, "s%%@(LEX)%%%s%%g\n", SVAL (lex));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
414 if (ccoptions)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
415 fprintf (fp, "s%%@(MHOPTIONS)%%%s %s%%g\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
416 SVAL (options), SVAL (ccoptions));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
417 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
418 fprintf (fp, "s%%@(MHOPTIONS)%%%s %s%%g\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
419 SVAL (options), "-O");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
420 fprintf (fp, "s%%@(LDOPTIONS)%%%s%%g\n", SVAL (ldoptions));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
421 fprintf (fp, "s%%@(LDOPTLIB)%%%s%%g\n", SVAL (ldoptlibs));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
422 fprintf (fp, "s%%@(LDOPTLIB_POST)%%%s%%g\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
423 SVAL (norespost ? ldoptlibs_post : ldoptlibs));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
424 fprintf (fp, "s%%@(LDCURSES)%%%s%%g\n", SVAL (curses));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
425
bce86c4163a3 Initial revision
kono
parents:
diff changeset
426 if (strcmp (bboards, "off") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
427 fprintf (fp, "/^@BEGIN: BBOARDS$/,/^@END: BBOARDS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
428 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
429 fprintf (fp, "/^@BEGIN: BBOARDS$/d\n/^@END: BBOARDS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
430 fprintf (fp, "s%%@(BBHOME)%%%s%%g\n", SVAL (bbhome));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
431 if (strcmp (bbdelivery, "off") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
432 fprintf (fp, "/^@BEGIN: BBSERVER$/,/^@END: BBSERVER$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
433 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
434 fprintf (fp, "/^@BEGIN: BBSERVER$/d\n/^@END: BBSERVER$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
435
bce86c4163a3 Initial revision
kono
parents:
diff changeset
436 if (strcmp (debug, "on") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
437 fprintf (fp, "/^@BEGIN: DEBUG$/d\n/^@END: DEBUG$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
438 fprintf (fp, "/^@BEGIN: OPTIM$/,/^@END: OPTIM$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
439 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
440 else {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
441 fprintf (fp, "/^@BEGIN: DEBUG$/,/^@END: DEBUG$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
442 fprintf (fp, "/^@BEGIN: OPTIM$/d\n/^@END: OPTIM$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
443 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
444
bce86c4163a3 Initial revision
kono
parents:
diff changeset
445 if (strcmp (mailgroup, "off")) { /* for SYS5 sgid-inc */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
446 fprintf (fp, "/^@BEGIN: MAILGROUP$/d\n/^@END: MAILGROUP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
447 fprintf (fp, "s%%@(MAILGROUP)%%%s%%g\n", SVAL (mailgroup));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
448 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
449 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
450 fprintf (fp, "/^@BEGIN: MAILGROUP$/,/^@END: MAILGROUP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
451
bce86c4163a3 Initial revision
kono
parents:
diff changeset
452 if (strcmp (oldload, "on") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
453 fprintf (fp, "/^@BEGIN: OLDLOAD$/d\n/^@END: OLDLOAD$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
454 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
455 fprintf (fp, "/^@BEGIN: OLDLOAD$/,/^@END: OLDLOAD$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
456 if (strcmp (oldload, "off") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
457 fprintf (fp, "/^@BEGIN: NEWLOAD$/d\n/^@END: NEWLOAD$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
458 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
459 fprintf (fp, "/^@BEGIN: NEWLOAD$/,/^@END: NEWLOAD$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
460
bce86c4163a3 Initial revision
kono
parents:
diff changeset
461 (void) fclose (fp);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
462
bce86c4163a3 Initial revision
kono
parents:
diff changeset
463 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
464
bce86c4163a3 Initial revision
kono
parents:
diff changeset
465 /* We have to divide a script because some OS have a poor "sed". :-< */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
466 if ((fp = fopen (sed2, "w")) == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
467 adios (sed2, "unable to write");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
468 printf ("generating %s\n", sed2);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
469
bce86c4163a3 Initial revision
kono
parents:
diff changeset
470 if (strcmp (ranlib, "on") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
471 fprintf (fp, "/^@BEGIN: RANLIB$/d\n/^@END: RANLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
472 fprintf (fp, "/^@BEGIN: LORDER$/,/^@END: LORDER$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
473 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
474 else {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
475 fprintf (fp, "/^@BEGIN: LORDER$/d\n/^@END: LORDER$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
476 fprintf (fp, "/^@BEGIN: RANLIB$/,/^@END: RANLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
477 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
478
bce86c4163a3 Initial revision
kono
parents:
diff changeset
479 if (strcmp (sharedlib, "off")) { /* if not off */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
480 fprintf (fp, "/^@BEGIN: SHAREDLIB$/d\n/^@END: SHAREDLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
481 fprintf (fp, "/^@BEGIN: STDLIB$/,/^@END: STDLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
482 fprintf (fp, "s%%@(SLIBDIR)%%%s%%g\n", slibdir);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
483 fprintf (fp, "s%%@(SLIBVER)%%%s%%g\n", MHSLIBVER);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
484 fprintf (fp, "s%%@(SLFLAGS)%%%s%%g\n", SVAL(slflags));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
485 if (strcmp (sharedlib, "secure") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
486 fprintf (fp, "s%%@(SLDFLAG)%%-L%s%%g\n",slibdir);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
487 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
488 fprintf (fp, "s%%@(SLDFLAG)%%%%g\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
489 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
490 else {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
491 fprintf (fp, "/^@BEGIN: STDLIB$/d\n/^@END: STDLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
492 fprintf (fp, "/^@BEGIN: SHAREDLIB$/,/^@END: SHAREDLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
493 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
494 if (strcmp (sharedlib, "sun4") == 0 || strcmp (sharedlib, "on") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
495 fprintf (fp, "/^@BEGIN: SUN4SHLIB$/d\n/^@END: SUN4SHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
496 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
497 fprintf (fp, "/^@BEGIN: SUN4SHLIB$/,/^@END: SUN4SHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
498 if (strcmp (sharedlib, "sys5") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
499 fprintf (fp, "/^@BEGIN: SYS5SHLIB$/d\n/^@END: SYS5SHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
500 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
501 fprintf (fp, "/^@BEGIN: SYS5SHLIB$/,/^@END: SYS5SHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
502 if (strcmp (sharedlib, "fbsd") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
503 fprintf (fp, "/^@BEGIN: FBSDSHLIB$/d\n/^@END: FBSDSHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
504 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
505 fprintf (fp, "/^@BEGIN: FBSDSHLIB$/,/^@END: FBSDSHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
506 if (strcmp (sharedlib, "gnuelf") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
507 fprintf (fp, "/^@BEGIN: GELFSHLIB$/d\n/^@END: GELFSHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
508 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
509 fprintf (fp, "/^@BEGIN: GELFSHLIB$/,/^@END: GELFSHLIB$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
510
bce86c4163a3 Initial revision
kono
parents:
diff changeset
511 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
512
bce86c4163a3 Initial revision
kono
parents:
diff changeset
513 if (flag || ((mtsnum == mmdf || mtsnum == mmdf2) && !smtp)) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
514 fprintf (fp, "/^@BEGIN: MMDFMTS$/d\n/^@END: MMDFMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
515 if (mtsnum == mmdf)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
516 fprintf (fp, "/^@BEGIN: MMDFIMTS$/d\n/^@END: MMDFIMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
517 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
518 fprintf (fp, "/^@BEGIN: MMDFIMTS$/,/^@END: MMDFIMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
519 if (mtsnum == mmdf2)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
520 fprintf (fp, "/^@BEGIN: MMDFIIMTS$/d\n/^@END: MMDFIIMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
521 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
522 fprintf (fp, "/^@BEGIN: MMDFIIMTS$/,/^@END: MMDFIIMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
523 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
524 else {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
525 fprintf (fp, "/^@BEGIN: MMDFMTS$/,/^@END: MMDFMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
526 fprintf (fp, "/^@BEGIN: MMDFIMTS$/,/^@END: MMDFIMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
527 fprintf (fp, "/^@BEGIN: MMDFIIMTS$/,/^@END: MMDFIIMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
528 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
529
bce86c4163a3 Initial revision
kono
parents:
diff changeset
530 if (mtsnum == mh)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
531 fprintf (fp, "/^@BEGIN: MHMTS$/d\n/^@END: MHMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
532 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
533 fprintf (fp, "/^@BEGIN: MHMTS$/,/^@END: MHMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
534
bce86c4163a3 Initial revision
kono
parents:
diff changeset
535 if (!flag && (mtsnum == sendmail || smtp))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
536 fprintf (fp, "/^@BEGIN: SENDMTS$/d\n/^@END: SENDMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
537 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
538 fprintf (fp, "/^@BEGIN: SENDMTS$/,/^@END: SENDMTS$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
539
bce86c4163a3 Initial revision
kono
parents:
diff changeset
540 switch (mtsnum) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
541 case mh:
bce86c4163a3 Initial revision
kono
parents:
diff changeset
542 case sendmail:
bce86c4163a3 Initial revision
kono
parents:
diff changeset
543 case mmdf:
bce86c4163a3 Initial revision
kono
parents:
diff changeset
544 fprintf (fp, "/^@BEGIN: SENDMTSHACK$/d\n/^@END: SENDMTSHACK$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
545 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
546
bce86c4163a3 Initial revision
kono
parents:
diff changeset
547 default:
bce86c4163a3 Initial revision
kono
parents:
diff changeset
548 fprintf (fp, "/^@BEGIN: SENDMTSHACK$/,/^@END: SENDMTSHACK$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
549 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
550 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
551
bce86c4163a3 Initial revision
kono
parents:
diff changeset
552 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
553
bce86c4163a3 Initial revision
kono
parents:
diff changeset
554 /* special hack for support/pop/popser.c */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
555 fprintf (fp, "s%%@(POPUUMBOX)%%%s%%g\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
556 mtsnum == sendmail ? "-DPOPUUMBOX" : "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
557
bce86c4163a3 Initial revision
kono
parents:
diff changeset
558 if (smtp)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
559 fprintf (fp, "/^@BEGIN: SMTP$/d\n/^@END: SMTP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
560 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
561 fprintf (fp, "/^@BEGIN: SMTP$/,/^@END: SMTP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
562
bce86c4163a3 Initial revision
kono
parents:
diff changeset
563 if (strcmp (pop, "on") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
564 fprintf (fp, "/^@BEGIN: POP$/d\n/^@END: POP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
565 fprintf (fp, "/^@BEGIN: POPSERVER$/d\n/^@END: POPSERVER$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
566 } else if (strcmp (pop, "client") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
567 fprintf (fp, "/^@BEGIN: POP$/d\n/^@END: POP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
568 fprintf (fp, "/^@BEGIN: POPSERVER$/,/^@END: POPSERVER$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
569 } else {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
570 fprintf (fp, "/^@BEGIN: POP$/,/^@END: POP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
571 fprintf (fp, "/^@BEGIN: POPSERVER$/,/^@END: POPSERVER$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
572 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
573
bce86c4163a3 Initial revision
kono
parents:
diff changeset
574 if (strcmp (bboards, "pop") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
575 fprintf (fp, "/^@BEGIN: BPOP$/d\n/^@END: BPOP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
576 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
577 fprintf (fp, "/^@BEGIN: BPOP$/,/^@END: BPOP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
578
bce86c4163a3 Initial revision
kono
parents:
diff changeset
579 if (strcmp (bboards, "nntp") == 0 || nntp)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
580 fprintf (fp, "/^@BEGIN: NNTP$/d\n/^@END: NNTP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
581 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
582 fprintf (fp, "/^@BEGIN: NNTP$/,/^@END: NNTP$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
583
bce86c4163a3 Initial revision
kono
parents:
diff changeset
584 if (strcmp (mf, "on") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
585 fprintf (fp, "/^@BEGIN: MF$/d\n/^@END: MF$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
586 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
587 fprintf (fp, "/^@BEGIN: MF$/,/^@END: MF$/d\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
588
bce86c4163a3 Initial revision
kono
parents:
diff changeset
589 fprintf (fp, "s%%@(MHREMOVE)%%%s%%g\n", SVAL (removeit));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
590
bce86c4163a3 Initial revision
kono
parents:
diff changeset
591 for (op = copts; op->c_name; op++) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
592 fprintf (fp, op->c_value ? "/^@BEGIN: %s$/d\n/^@END: %s$/d\n" :
bce86c4163a3 Initial revision
kono
parents:
diff changeset
593 "/^@BEGIN: %s$/,/^@END: %s$/d\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
594 op->c_name, op->c_name);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
595 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
596
bce86c4163a3 Initial revision
kono
parents:
diff changeset
597 (void) fclose (fp);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
598 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
599
bce86c4163a3 Initial revision
kono
parents:
diff changeset
600 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
601
bce86c4163a3 Initial revision
kono
parents:
diff changeset
602 static do_files () {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
603 char **pp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
604
bce86c4163a3 Initial revision
kono
parents:
diff changeset
605 for (pp = files; *pp; pp++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
606 shell ("rm -f %s; sed -f %s < config/%s | sed -f %s > %s",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
607 *pp, SED, tail (*pp), SED2, *pp);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
608 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
609
bce86c4163a3 Initial revision
kono
parents:
diff changeset
610
bce86c4163a3 Initial revision
kono
parents:
diff changeset
611 static do_doc () {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
612 shell ("./mhdoc");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
613 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
614
bce86c4163a3 Initial revision
kono
parents:
diff changeset
615
bce86c4163a3 Initial revision
kono
parents:
diff changeset
616 static do_make () {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
617 char buffer[BUFSIZ];
bce86c4163a3 Initial revision
kono
parents:
diff changeset
618 struct pair *pp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
619
bce86c4163a3 Initial revision
kono
parents:
diff changeset
620 for (pp = makefiles; pp -> infile; pp++) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
621 (void) sprintf (buffer, MAKE, pp -> outfile);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
622 shell ("rm -f %s; sed -f %s < %s | sed -f %s > %s",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
623 buffer, SED, pp -> infile, SED2, buffer);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
624 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
625 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
626
bce86c4163a3 Initial revision
kono
parents:
diff changeset
627 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
628
bce86c4163a3 Initial revision
kono
parents:
diff changeset
629 /* VARARGS */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
630
bce86c4163a3 Initial revision
kono
parents:
diff changeset
631 static shell (fmt, a, b, c, d, e)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
632 char *fmt,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
633 *a,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
634 *b,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
635 *c,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
636 *d,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
637 *e;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
638 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
639 char buffer[BUFSIZ];
bce86c4163a3 Initial revision
kono
parents:
diff changeset
640
bce86c4163a3 Initial revision
kono
parents:
diff changeset
641 (void) sprintf (buffer, fmt, a, b, c, d, e);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
642 printf ("%s\n", buffer);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
643 (void) fflush (stdout);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
644
bce86c4163a3 Initial revision
kono
parents:
diff changeset
645 if (system (buffer))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
646 adios (NULLCP, "failed");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
647 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
648
bce86c4163a3 Initial revision
kono
parents:
diff changeset
649 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
650
bce86c4163a3 Initial revision
kono
parents:
diff changeset
651 static arginit (vec)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
652 char **vec;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
653 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
654 int i;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
655 char *ap,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
656 *cp,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
657 *dp,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
658 buffer[BUFSIZ];
bce86c4163a3 Initial revision
kono
parents:
diff changeset
659 struct bind *bp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
660 FILE * fp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
661
bce86c4163a3 Initial revision
kono
parents:
diff changeset
662 myname = tail (*vec);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
663 printf (BANNER, myname);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
664 (void) fflush (stdout);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
665
bce86c4163a3 Initial revision
kono
parents:
diff changeset
666 for (vec++; *vec; vec++) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
667 if (strcmp (*vec, "-D") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
668 sedP = 1; filesP = makeP = 0; docP = 2;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
669 continue;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
670 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
671 if (strcmp (*vec, "-s") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
672 sedP = !sedP;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
673 continue;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
674 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
675 if (strcmp (*vec, "-f") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
676 filesP = !filesP;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
677 continue;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
678 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
679 if (strcmp (*vec, "-d") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
680 docP = !docP;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
681 continue;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
682 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
683 if (strcmp (*vec, "-m") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
684 makeP = !makeP;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
685 continue;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
686 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
687 if (strcmp (*vec, "-help") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
688 printf ("usage: %s [opt] file\n", myname);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
689 printf ("%s\n%s\n%s\n%s\n",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
690 " -s\tno sed files", " -f\tno config files",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
691 " -d\tno doc files", " -m\tno makefiles");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
692 exit (0);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
693 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
694 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
695 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
696 if ((config = *vec) == NULL || vec[1] != NULL) /* no arg or too many */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
697 adios (NULLCP, "usage: %s file", myname);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
698
bce86c4163a3 Initial revision
kono
parents:
diff changeset
699 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
700
bce86c4163a3 Initial revision
kono
parents:
diff changeset
701 if ((fp = fopen (config, "r")) == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
702 adios (config, "unable to read");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
703
bce86c4163a3 Initial revision
kono
parents:
diff changeset
704 while (fgets (buffer, sizeof buffer, fp)) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
705 if (ap = index (buffer, '\n'))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
706 *ap-- = '\0';
bce86c4163a3 Initial revision
kono
parents:
diff changeset
707 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
708 ap = &buffer[strlen (buffer) - 1];
bce86c4163a3 Initial revision
kono
parents:
diff changeset
709 while (ap >= buffer)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
710 if (isspace (*ap))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
711 *ap = '\0';
bce86c4163a3 Initial revision
kono
parents:
diff changeset
712 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
713 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
714 for (cp = buffer; isspace (*cp); cp++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
715 continue;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
716 if (*cp == '\0' || *cp == '#')
bce86c4163a3 Initial revision
kono
parents:
diff changeset
717 continue;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
718 for (ap = cp; *ap; ap++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
719 if (isspace (*ap) || *ap == ':') {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
720 *ap++ = '\0';
bce86c4163a3 Initial revision
kono
parents:
diff changeset
721 while (isspace (*ap))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
722 ap++;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
723 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
724 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
725 for (bp = binds; bp -> keyword; bp++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
726 if (strcmp (bp -> keyword, cp) == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
727 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
728 if (bp -> keyword == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
729 adios (NULLCP, "unknown option %s in %s", cp, config);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
730 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
731 if (*(bp -> value) == NULL || !(bp -> flags & BD_ADD))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
732 *(bp -> value) = strdup (ap);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
733 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
734 *(bp -> value) = stradd (ap, stradd (" ", *(bp -> value)));
bce86c4163a3 Initial revision
kono
parents:
diff changeset
735 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
736
bce86c4163a3 Initial revision
kono
parents:
diff changeset
737 (void) fclose (fp);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
738
bce86c4163a3 Initial revision
kono
parents:
diff changeset
739 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
740
bce86c4163a3 Initial revision
kono
parents:
diff changeset
741 if (binpath == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
742 adios (NULLCP, "bin must be specified in %s", config);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
743 trim (binpath);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
744
bce86c4163a3 Initial revision
kono
parents:
diff changeset
745 if (strcmp (bboards, "on") && strcmp (bboards, "off") &&
bce86c4163a3 Initial revision
kono
parents:
diff changeset
746 strcmp (bboards, "pop") && strcmp (bboards, "nntp"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
747 adios (NULLCP, "bboards should be %s not %s",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
748 "either \"on\", \"off\", \"pop\" or \"nntp\"", bboards);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
749 if (strcmp (bboards, "off") == 0 && strcmp (bbdelivery, "off"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
750 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
751 "you cannot have \"bbdelivery\" \"%s\" with \"bboards\" \"%s\"",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
752 bbdelivery, bboards);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
753 if (bbhome == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
754 adios (NULLCP, "bbhome must be specified in %s", config);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
755 trim (bbhome);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
756
bce86c4163a3 Initial revision
kono
parents:
diff changeset
757 if (strcmp (debug, "on") && strcmp (debug, "off"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
758 adios (NULLCP, "debug should be either \"on\" or \"off\", not %s",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
759 debug);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
760
bce86c4163a3 Initial revision
kono
parents:
diff changeset
761 if (etcpath == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
762 adios (NULLCP, "etc must be specified in %s", config);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
763 trim (etcpath);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
764
bce86c4163a3 Initial revision
kono
parents:
diff changeset
765 if (strcmp (mailgroup, "off")) /* if not "off" */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
766 add_option ("MAILGROUP");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
767 if (mailpath == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
768 adios (NULLCP, "mail must be specified in %s", config);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
769 trim (mailpath);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
770 if (*mailpath == '/')
bce86c4163a3 Initial revision
kono
parents:
diff changeset
771 maildir = mailpath;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
772 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
773 mailfile = mailpath;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
774
bce86c4163a3 Initial revision
kono
parents:
diff changeset
775 if (cp = index (manuals, '/')) { /* "standard/cat" */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
776 *cp++ = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
777 mancat = cp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
778 if (strcmp (mancat, "gzip") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
779 mancat = "man";
bce86c4163a3 Initial revision
kono
parents:
diff changeset
780 gzipman = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
781 } else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
782 if (strcmp (mancat, "cat"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
783 adios (NULLCP,"invalid manuals setting: %s/%s",manuals, mancat);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
784 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
785 if (strcmp (manuals, "standard")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
786 && strcmp (manuals, "bsd44")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
787 && strcmp (manuals, "local")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
788 && strcmp (manuals, "new")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
789 && strcmp (manuals, "old")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
790 && strcmp (manuals, "gen")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
791 && strcmp (manuals, "none"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
792 adios (NULLCP,"invalid manuals setting: %s",manuals);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
793
bce86c4163a3 Initial revision
kono
parents:
diff changeset
794 if (mts == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
795 adios (NULLCP, "mts must be specified in %s", config);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
796 for (i = 0; mtsopts[i].mtskey; i++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
797 if (strcmp (mts, mtsopts[i].mtskey) == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
798 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
799 if ((mtsnum = mtsopts[i].code) == unknown)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
800 adios (NULLCP, "invalid mts setting: %s", mts);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
801 add_option (mtsopts[i].optval);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
802 smtp = mtsopts[i].mtsflags & DOSMTP;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
803 if (mtsopts[i].mtsflags & NOMF)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
804 mf = "off"; /* hack... */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
805
bce86c4163a3 Initial revision
kono
parents:
diff changeset
806 if (strcmp (pop, "on") && strcmp (pop, "client") && strcmp (pop, "off"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
807 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
808 "pop should be either \"on\", \"client\" or \"off\", not %s",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
809 pop);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
810 if (strcmp (pop, "off"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
811 add_option ("POP");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
812
bce86c4163a3 Initial revision
kono
parents:
diff changeset
813 if (strcmp (bboards, "pop") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
814 add_option ("BPOP");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
815 if (strcmp (pop, "off") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
816 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
817 "bboards \"pop\" requires pop \"on\" or \"client\"");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
818 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
819 else if (strcmp (bboards, "nntp") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
820 add_option ("BPOP");/* used by msh.c & bbc.c, but see also pshsbr.c */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
821 add_option ("NNTP");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
822 if (mpop)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
823 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
824 "bboards \"nntp\" is incompatible with \"options MPOP\"");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
825 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
826
bce86c4163a3 Initial revision
kono
parents:
diff changeset
827 if (strcmp (mf, "on") && strcmp (mf, "off"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
828 adios (NULLCP, "mf should be either \"on\" or \"off\", not %s", mf);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
829 if (strcmp (mf, "on") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
830 add_option ("MF");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
831
bce86c4163a3 Initial revision
kono
parents:
diff changeset
832 if (sprntf && strcmp (sprntf, "char *")) {/* this defaults to "char *" */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
833 if (strcmp (sprntf, "int"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
834 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
835 "sprintf should be either \"int\" or \"char *\", not %s",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
836 sprntf);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
837 add_option ("SPRINTFTYPE=int");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
838 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
839
bce86c4163a3 Initial revision
kono
parents:
diff changeset
840 if (strcmp (sharedlib, "on") && strcmp (sharedlib, "off")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
841 && strcmp (sharedlib, "sun4") && strcmp (sharedlib, "sys5")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
842 && strcmp (sharedlib, "fbsd") && strcmp (sharedlib, "gnuelf")
bce86c4163a3 Initial revision
kono
parents:
diff changeset
843 && strcmp (sharedlib, "secure"))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
844 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
845 "sharedlib should be either \"sun4\", \"sys5\", \"fbsd\", \"gnuelf\" or \"off\", not %s",
bce86c4163a3 Initial revision
kono
parents:
diff changeset
846 sharedlib);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
847
bce86c4163a3 Initial revision
kono
parents:
diff changeset
848 (void) sprintf(buffer, "TYPESIG=%s", signl);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
849 add_option (buffer);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
850
bce86c4163a3 Initial revision
kono
parents:
diff changeset
851 /* loop over options string and add -D ccoptions */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
852
bce86c4163a3 Initial revision
kono
parents:
diff changeset
853 begin_myopt ();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
854 if (cp = options) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
855 for (ap = cp; *ap; ap++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
856 if (isspace (*ap))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
857 *ap = ' ';
bce86c4163a3 Initial revision
kono
parents:
diff changeset
858 options = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
859 for (ap = cp; dp = index (ap, ' '); ap = dp) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
860 *dp++ = '\0';
bce86c4163a3 Initial revision
kono
parents:
diff changeset
861 add_myopt (ap);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
862 (void) sprintf (buffer, "%s-D%s", options ? " " : "", ap);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
863 ap = buffer;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
864 options = stradd (ap, options);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
865 while (isspace (*dp))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
866 dp++;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
867 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
868 if (*ap) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
869 add_myopt (ap);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
870 (void) sprintf (buffer, "%s-D%s", options ? " " : "", ap);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
871 ap = buffer;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
872 options = stradd (ap, options);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
873 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
874 free (cp);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
875 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
876 end_myopt ();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
877 if (strcmp (bboards, "nntp") == 0 && mpop)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
878 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
879 "bboards \"nntp\" is incompatible with \"options MPOP\"");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
880 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
881
bce86c4163a3 Initial revision
kono
parents:
diff changeset
882 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
883
bce86c4163a3 Initial revision
kono
parents:
diff changeset
884 static add_option (s)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
885 char *s;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
886 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
887 options = options ? stradd (s, stradd (" ", options)) : strdup (s);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
888 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
889
bce86c4163a3 Initial revision
kono
parents:
diff changeset
890
bce86c4163a3 Initial revision
kono
parents:
diff changeset
891 begin_myopt () {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
892 myopts = strdup ("char *options[] = {");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
893 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
894
bce86c4163a3 Initial revision
kono
parents:
diff changeset
895
bce86c4163a3 Initial revision
kono
parents:
diff changeset
896 add_myopt (s)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
897 char *s;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
898 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
899 int len;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
900 char *bp,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
901 buffer[BUFSIZ];
bce86c4163a3 Initial revision
kono
parents:
diff changeset
902 struct copt *op;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
903 static int nameoutput = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
904 static int linepos = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
905 static int outputlinelen = 72;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
906
bce86c4163a3 Initial revision
kono
parents:
diff changeset
907 for (op = copts; op->c_name; op++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
908 if (!strncmp (op->c_name,s,strlen(op->c_name))) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
909 op->c_value = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
910 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
911 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
912
bce86c4163a3 Initial revision
kono
parents:
diff changeset
913 if (strcmp (s, "NNTP") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
914 nntp = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
915 if (strcmp (s, "MPOP") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
916 mpop = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
917 if (nntp)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
918 adios (NULLCP,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
919 "\"options MPOP\" is incompatible with \"options NNTP\"");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
920 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
921 if (strcmp (s, "NORESPOST") == 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
922 norespost = 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
923 if (smtp && strcmp (s, "BERK") == 0) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
924 fprintf (stderr, "\"options BERK\" overriding smtp suffix...\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
925 smtp = 0;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
926 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
927 if (!nameoutput) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
928 printf ("%s: ", bp = "options");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
929 linepos += (nameoutput = strlen (bp) + 2);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
930 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
931 len = strlen (s);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
932 if (linepos != nameoutput)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
933 if (len + linepos + 3 > outputlinelen)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
934 printf ("\n%*s", linepos = nameoutput, "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
935 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
936 printf (" "), linepos++;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
937 printf ("[%s]", s);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
938 linepos += len + 2;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
939 (void) fflush (stdout);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
940
bce86c4163a3 Initial revision
kono
parents:
diff changeset
941 bp = buffer;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
942 *bp++ = '"';
bce86c4163a3 Initial revision
kono
parents:
diff changeset
943 while (*s) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
944 if (*s == '"')
bce86c4163a3 Initial revision
kono
parents:
diff changeset
945 *bp++ = QUOTE, *bp++ = QUOTE;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
946 *bp++ = *s++;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
947 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
948 (void) strcpy (bp, "\", ");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
949 insopt (buffer);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
950 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
951
bce86c4163a3 Initial revision
kono
parents:
diff changeset
952
bce86c4163a3 Initial revision
kono
parents:
diff changeset
953 end_myopt () {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
954 printf ("\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
955 (void) fflush (stdout);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
956 mkopts();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
957 myopts = stradd ("NULL};", myopts);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
958 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
959
bce86c4163a3 Initial revision
kono
parents:
diff changeset
960 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
961
bce86c4163a3 Initial revision
kono
parents:
diff changeset
962 static trim (s)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
963 char *s;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
964 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
965 char *p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
966
bce86c4163a3 Initial revision
kono
parents:
diff changeset
967 if (s == NULL || (p = rindex (s, '/')) == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
968 return;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
969 if (*++p == '\0')
bce86c4163a3 Initial revision
kono
parents:
diff changeset
970 *--p = '\0';
bce86c4163a3 Initial revision
kono
parents:
diff changeset
971 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
972
bce86c4163a3 Initial revision
kono
parents:
diff changeset
973
bce86c4163a3 Initial revision
kono
parents:
diff changeset
974 static char *tail (s)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
975 char *s;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
976 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
977 char *p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
978
bce86c4163a3 Initial revision
kono
parents:
diff changeset
979 if (p = rindex (s, '/'))
bce86c4163a3 Initial revision
kono
parents:
diff changeset
980 p++;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
981 return ((p == NULL || *p == '\0') ? s : p);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
982 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
983
bce86c4163a3 Initial revision
kono
parents:
diff changeset
984 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
985
bce86c4163a3 Initial revision
kono
parents:
diff changeset
986 static char *stradd (s1, s2)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
987 char *s1,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
988 *s2;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
989 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
990 char *p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
991
bce86c4163a3 Initial revision
kono
parents:
diff changeset
992 if (s1 == NULL || *s1 == '\0')
bce86c4163a3 Initial revision
kono
parents:
diff changeset
993 return s2;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
994 if (s2 == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
995 return strdup (s1);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
996 if ((p = malloc ((unsigned) (strlen (s1) + strlen (s2) + 2))) == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
997 adios (NULLCP, "insufficient memory");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
998
bce86c4163a3 Initial revision
kono
parents:
diff changeset
999 (void) sprintf (p, "%s%s", s2, s1);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1000 if (s2)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1001 free (s2);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1002 return p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1003 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1004
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1005
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1006 static char *strdup (s)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1007 char *s;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1008 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1009 char *p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1010
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1011 if ((p = malloc ((unsigned) (strlen (s) + 1))) == NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1012 adios (NULLCP, "insufficient memory");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1013
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1014 (void) strcpy (p, s);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1015 return p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1016 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1017
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1018 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1019
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1020 #ifdef notdef
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1021 /* these used to be for SYS5 machines, but now this is compiled
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1022 * with -DSYS5 which redefines the SYS5 str[r]chr names to [r]index.
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1023 */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1024 static char *index (s, c)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1025 char *s,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1026 c;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1027 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1028 char i;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1029
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1030 while (i = *s++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1031 if (i == c)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1032 return (s - 1);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1033
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1034 return NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1035 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1036
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1037
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1038 static char *rindex (s, c)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1039 char *s,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1040 c;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1041 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1042 char i,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1043 *t;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1044
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1045 t = NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1046 while (i = *s++)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1047 if (i == c)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1048 t = s - 1;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1049
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1050 return t;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1051 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1052 #endif /* notdef */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1053
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1054 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1055
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1056 /* VARARGS */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1057
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1058 adios (what, fmt, a, b, c)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1059 char *what,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1060 *fmt,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1061 *a,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1062 *b,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1063 *c;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1064 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1065 (void) fflush (stdout);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1066
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1067 fprintf (stderr, "%s: ", myname);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1068 fprintf (stderr, fmt, a, b, c);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1069 if (what) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1070 (void) fputc (' ', stderr);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1071 perror (what);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1072 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1073 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1074 (void) fputc ('\n', stderr);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1075
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1076 exit (1);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1077 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1078
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1079 /* quick and dirty ordering of options for readability */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1080
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1081 struct opt {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1082 char *s;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1083 struct opt *n;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1084 };
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1085
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1086 static struct opt *optp = (struct opt *)NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1087
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1088 static void
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1089 insopt(s)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1090 char *s; /* string for sorting */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1091 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1092 struct opt *p,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1093 *np,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1094 *lp = (struct opt *)NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1095
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1096 if ((np = (struct opt *) malloc ((unsigned) sizeof (struct opt))) ==
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1097 (struct opt *)NULL)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1098 adios (NULL, "unable to malloc opt");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1099 np -> s = strdup(s);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1100 np -> n = (struct opt *)NULL;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1101
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1102 for (p = optp; p; lp = p, p = p -> n) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1103 if (strcmp (p->s, s) > 0)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1104 break;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1105 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1106 if (p)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1107 np -> n = p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1108 if (lp)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1109 lp -> n = np;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1110 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1111 optp = np;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1112 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1113
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1114 static void
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1115 mkopts()
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1116 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1117 struct opt *p;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1118
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1119 for (p = optp; p; p = p -> n)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1120 myopts = stradd (p->s, myopts);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1121 }