]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/conf/mhconfig.c
1 /* mhconfig.c - configure MH */
2 /* cc [-DSYS5] mhconfig.c -o mhconfig */
4 static char ident
[] = "@(#)$Id: mhconfig.c,v 2.73 1996/02/08 19:07:47 jromine Exp $";
14 #define rindex strrchr
17 static void insopt(), mkopts();
19 extern char *strcpy(), *malloc(), *index(), *rindex();
21 extern char *sprintf(); /* rely on stdio.h to declare this */
24 #define BANNER "This is %s, for generic UNIX (MH.6 configuration program)\n\n"
27 #define SED "config.sed"
28 #define SEDOC "doc/config.sed"
29 #define MAKE "../%s/Makefile"
31 #define WARNING "This file is automatically generated. Do not edit!"
32 #define MHRELEASE "6.8.4" /* for version: "Maj.min.pat" */
33 #define MHCENTERFOOT "MH.6.8" /* for nroff page footers */
34 #define MHLEFTFOOT "[mh.6]" /* [mh.6] MH.6.6 page# */
35 #define MHSLIBVER "3.2" /* SunOS4 shared library version */
39 #define NULLCP ((char *) 0)
41 #define SVAL(s) (s ? s : "")
51 static int filesP
= 1;
55 static char *myname
= "mhconfig";
56 static char *config
= NULL
;
57 static char *myopts
= NULL
;
59 static char *binpath
= "/usr/local";
60 static char *bbhome
= "/usr/spool/bboards";
61 static char *bboards
= "off";
62 static char *bbdelivery
= "off";
63 static char *ccoptions
= NULL
;
64 static char *chownpath
= "/etc/chown";
65 static char *compiler
= "/bin/cc";
66 static char *copy
= "cp";
67 static char *curses
= "-lcurses -ltermlib";
68 static char *debug
= "off";
69 static char *editor
= "prompter";
70 static char *etcpath
= "/usr/local/lib/mh";
71 static char *ldoptions
= NULL
;
72 static char *ldoptlibs
= NULL
;
73 static char *lex
= "lex -nt";
74 static char *ln
= "ln";
75 static char *mailgroup
= "off";
76 static char *mailpath
= "/usr/spool/mail";
77 static char *maildir
= NULL
;
78 static char *mailfile
= NULL
;
79 static char *mancat
= "man";
80 static char *mandir
= "/usr/man";
81 static char *manuals
= "standard";
82 static char *mf
= "off";
83 static char *mts
= "sendmail";
84 static char *poppath
= "/usr/etc";
85 static char *removeit
= "mv -f";
86 static char *regtest
= "off";
87 static char *oldload
= "off";
88 static char *options
= NULL
;
89 static char *pop
= "off";
90 static char *ranlib
= "on";
91 static char *sharedlib
= "off";
92 static char *signl
= "int";
93 static char *slibdir
= "/usr/local/lib";
94 static char *slflags
= "-pic";
95 static char *sprntf
= NULL
;
104 static int mtsnum
= unknown
;
106 static struct mtsopt
{
115 "mmdf", "MMDFMTS MMDFI", mmdf
, NOFLAGS
,
116 "mmdf/smtp", "SENDMTS SMTP", mmdf
, DOSMTP
,
117 "mmdf2", "MMDFMTS MMDFII", mmdf2
, NOFLAGS
,
118 "mmdf2/smtp", "SENDMTS MMDFII SMTP", mmdf2
, DOSMTP
,
119 "mh", "MHMTS", mh
, NOFLAGS
,
120 "sendmail", "SENDMTS", sendmail
, NOMF
,
121 "sendmail/smtp", "SENDMTS SMTP", sendmail
, NOMF
,
122 "zmailer", "ZMAILER SENDMTS", sendmail
, NOMF
,
123 "zmailer/smtp", "ZMAILER SENDMTS SMTP", sendmail
, NOMF
,
124 NULL
, NULL
, unknown
, NOFLAGS
127 /* other options which cause sed BEGIN/END configuration changes */
133 "APOP", 0, /* authenticated pop */
134 "BSD43", 0, /* sgid ttys */
135 "BSD44", 0, /* manual headings */
136 "KPOP", 0, /* KERBEROS pop */
138 "MIME", 0, /* multi-media extensions */
139 "MPOP", 0, /* mobile pop */
140 "MSGID", 0, /* slocal dup surpression */
141 "NORUSERPASS", 0, /* no ruserpass(3) */
142 "TMA", 0, /* trusted mail */
161 "bin", &binpath
, BD_NIL
,
162 "bbhome", &bbhome
, BD_NIL
,
163 "bboards", &bboards
, BD_NIL
,
164 "bbdelivery", &bbdelivery
, BD_NIL
,
165 "ccoptions", &ccoptions
, BD_ADD
,
166 "chown", &chownpath
, BD_NIL
,
167 "cc", &compiler
, BD_NIL
,
169 "curses", &curses
, BD_NIL
,
170 "debug", &debug
, BD_NIL
,
171 "editor", &editor
, BD_NIL
,
172 "etc", &etcpath
, BD_NIL
,
173 "ldoptions", &ldoptions
, BD_ADD
,
174 "ldoptlibs", &ldoptlibs
, BD_ADD
,
177 "mail", &mailpath
, BD_NIL
,
178 "mailgroup", &mailgroup
, BD_NIL
,
179 "mandir", &mandir
, BD_NIL
,
180 "manuals", &manuals
, BD_NIL
,
183 "oldload", &oldload
, BD_NIL
,
184 "options", &options
, BD_ADD
,
186 "popdir", &poppath
, BD_NIL
,
187 "ranlib", &ranlib
, BD_NIL
,
188 "remove", &removeit
, BD_NIL
,
189 "regtest", ®test
, BD_NIL
,
190 "sharedlib", &sharedlib
, BD_NIL
,
191 "signal", &signl
, BD_NIL
,
192 "slflags", &slflags
, BD_NIL
,
193 "slibdir", &slibdir
, BD_NIL
,
194 "sprintf", &sprntf
, BD_NIL
,
201 "../support/bboards/bboards.daily",
202 "../support/bboards/bboards.weekly",
203 "../support/bboards/crontab",
204 "../support/bboards/MakeBBoards",
205 "../config/config.c",
206 "../zotnet/mts/mts.c",
207 "../zotnet/mts/mtstailor",
208 "../support/general/MailAliases",
209 "../mts/sendmail/bboardsMH.m4",
210 "../mts/sendmail/popMH.m4",
218 "makefiles/MH-Makefile", ".",
219 "makefiles/config","config",
220 "makefiles/dist","dist",
221 "makefiles/doc","doc",
222 "makefiles/mtsM","mts",
223 "makefiles/mts/mh","mts/mh",
224 "makefiles/mts/mmdf","mts/mmdf",
225 "makefiles/mts/sendmail","mts/sendmail",
226 "makefiles/papers","papers",
227 "makefiles/sbr","sbr",
228 "makefiles/supportM","support",
229 "makefiles/support/bboards","support/bboards",
230 "makefiles/support/general","support/general",
231 "makefiles/support/pop","support/pop",
232 "makefiles/uip","uip",
233 "makefiles/zotnetM","zotnet",
234 "makefiles/zotnet/bboards","zotnet/bboards",
235 "makefiles/zotnet/mf","zotnet/mf",
236 "makefiles/zotnet/mts","zotnet/mts",
237 "makefiles/zotnet/tws","zotnet/tws",
242 static do_sed(), do_sedfile(), do_files(), do_doc(), do_make();
243 static shell(), arginit(), add_option(), trim();
245 static char *stradd (), *strdup (), *tail ();
253 main (argc
, argv
, envp
)
270 printf ("Don't forget to edit \"config/mtstailor\"\n");
273 printf ("Don't forget to run \"make clean\" in the top directory before compiling\n");
283 do_sedfile (SEDOC
, smtp
);
286 static do_alldoc (fp
)
289 fprintf (fp
, "%s\n%s\n%s\n%s\n", /* turn @BEGIN: XX into #ifdef XX */
290 "s!^@BEGIN: \\(.*\\)$!.br\\", /* for MH wizard manual set */
295 fprintf (fp
, "%s\n%s\n%s\n%s\n",
296 "s!^@END: \\(.*\\)$!.br\\",
298 "#endif /* \\1\\ */",
305 static do_sedfile (sed
, flag
)
313 if ((fp
= fopen (sed
, "w")) == NULL
)
314 adios (sed
, "unable to write");
315 printf ("generating %s\n", sed
);
318 printf ("...using special all-doc format.\n");
319 printf ("Be sure to reconfigure before compiling.\n");
320 do_alldoc(fp
); /* hack up doc/config.sed */
323 fprintf (fp
, "s%%@(MHCONFIGFILE)%%%s%%g\n", SVAL(config
));
324 fprintf (fp
, "s%%@(MHWARNING)%%%s%%g\n", WARNING
);
325 fprintf (fp
, "s%%@(MHRELEASE)%%%s%%g\n", MHRELEASE
);
326 fprintf (fp
, "s%%@(MHCENTERFOOT)%%%s%%g\n", MHCENTERFOOT
);
327 fprintf (fp
, "s%%@(MHLEFTFOOT)%%%s%%g\n", MHLEFTFOOT
);
328 fprintf (fp
, "s%%@(MHBINPATH)%%%s%%g\n", SVAL (binpath
));
329 fprintf (fp
, "s%%@(MHETCPATH)%%%s%%g\n", SVAL (etcpath
));
330 fprintf (fp
, "s%%@(MHPOPDPATH)%%%s%%g\n", SVAL (poppath
));
331 fprintf (fp
, "s%%@(MHCHOWNPATH)%%%s%%g\n", SVAL (chownpath
));
332 fprintf (fp
, "s%%@(MHDROPATH)%%%s%%g\n", SVAL (maildir
));
333 fprintf (fp
, "s%%@(MHDROPFIL)%%%s%%g\n", SVAL (mailfile
));
335 fprintf (fp
, "s%%@(MHDROPLOC)%%%s/$USER%%g\n", SVAL (maildir
));
337 fprintf (fp
, "s%%@(MHDROPLOC)%%$HOME/%s%%g\n", SVAL (mailfile
));
338 fprintf (fp
, "s%%@(MHDROPHAK)%%%s%%g\n",/* HACK */
339 maildir
? maildir
: "/usr/spool/mail");
341 fprintf (fp
, "s%%@(MHMANDIR)%%%s%%g\n", mandir
);
342 fprintf (fp
, "s%%@(MHCATMAN)%%%s%%g\n",
343 strcmp(mancat
, "cat") == 0 ? "| nroff -man" : "");
344 if (strcmp (manuals
, "standard") == 0 || strcmp (manuals
, "gen") == 0)
345 for (i
= 1; i
<= 8; i
++) {
346 fprintf (fp
, "s%%@(MHMANDIR%d)%%%s%d%%g\n", i
, mancat
, i
);
347 fprintf (fp
, "s%%@(MHMANEXT%d)%%%d%%g\n", i
, i
);
350 for (i
= 1; i
<= 8; i
++) {
351 fprintf (fp
, "s%%@(MHMANDIR%d)%%%s%c%%g\n", i
, mancat
,
352 strcmp (manuals
, "new") == 0 ? 'n'
353 : strcmp (manuals
, "old") == 0 ? 'o'
354 : strcmp (manuals
, "bsd44") == 0 ? i
+ '0'
356 fprintf (fp
, "s%%@(MHMANEXT%d)%%%c%%g\n", i
,
357 strcmp (manuals
, "new") == 0 ? 'n'
358 : strcmp (manuals
, "old") == 0 ? 'o'
359 : strcmp (manuals
, "bsd44") == 0 ? '0'
365 if (strcmp (regtest
, "on") == 0)
366 fprintf (fp
, "s%%@(MHHOSTVER)%%%s%%g\n", "-n");
368 fprintf (fp
, "s%%@(MHHOSTVER)%%%s%%g\n", "");
370 if (strcmp (manuals
, "gen") == 0 || strcmp (manuals
, "none") == 0)
371 fprintf (fp
, "s%%@(MHMANGEN)%%%s%%g\n", "#"); /* comment char */
373 fprintf (fp
, "s%%@(MHMANGEN)%%%s%%g\n", "");
375 fprintf (fp
, "s%%@(MHEDITOR)%%%s%%g\n", SVAL (editor
));
376 fprintf (fp
, "s%%@(MHCONFIG)%%%s%%g\n", SVAL (myopts
));
377 fprintf (fp
, "s%%@(MHCOMPILER)%%%s%%g\n", SVAL (compiler
));
378 fprintf (fp
, "s%%@(CP)%%%s%%g\n", SVAL (copy
));
379 fprintf (fp
, "s%%@(LN)%%%s%%g\n", SVAL (ln
));
380 fprintf (fp
, "s%%@(LEX)%%%s%%g\n", SVAL (lex
));
382 fprintf (fp
, "s%%@(MHOPTIONS)%%%s %s%%g\n",
383 SVAL (options
), SVAL (ccoptions
));
385 fprintf (fp
, "s%%@(MHOPTIONS)%%%s %s%%g\n",
386 SVAL (options
), "-O");
387 fprintf (fp
, "s%%@(LDOPTIONS)%%%s%%g\n", SVAL (ldoptions
));
388 fprintf (fp
, "s%%@(LDOPTLIB)%%%s%%g\n", SVAL (ldoptlibs
));
389 fprintf (fp
, "s%%@(LDCURSES)%%%s%%g\n", SVAL (curses
));
391 if (strcmp (bboards
, "off") == 0)
392 fprintf (fp
, "/^@BEGIN: BBOARDS$/,/^@END: BBOARDS$/d\n");
394 fprintf (fp
, "/^@BEGIN: BBOARDS$/d\n/^@END: BBOARDS$/d\n");
395 fprintf (fp
, "s%%@(BBHOME)%%%s%%g\n", SVAL (bbhome
));
396 if (strcmp (bbdelivery
, "off") == 0)
397 fprintf (fp
, "/^@BEGIN: BBSERVER$/,/^@END: BBSERVER$/d\n");
399 fprintf (fp
, "/^@BEGIN: BBSERVER$/d\n/^@END: BBSERVER$/d\n");
401 if (strcmp (debug
, "on") == 0) {
402 fprintf (fp
, "/^@BEGIN: DEBUG$/d\n/^@END: DEBUG$/d\n");
403 fprintf (fp
, "/^@BEGIN: OPTIM$/,/^@END: OPTIM$/d\n");
406 fprintf (fp
, "/^@BEGIN: DEBUG$/,/^@END: DEBUG$/d\n");
407 fprintf (fp
, "/^@BEGIN: OPTIM$/d\n/^@END: OPTIM$/d\n");
410 if (strcmp (mailgroup
, "off")) { /* for SYS5 sgid-inc */
411 fprintf (fp
, "/^@BEGIN: MAILGROUP$/d\n/^@END: MAILGROUP$/d\n");
412 fprintf (fp
, "s%%@(MAILGROUP)%%%s%%g\n", SVAL (mailgroup
));
415 fprintf (fp
, "/^@BEGIN: MAILGROUP$/,/^@END: MAILGROUP$/d\n");
417 if (strcmp (oldload
, "on") == 0)
418 fprintf (fp
, "/^@BEGIN: OLDLOAD$/d\n/^@END: OLDLOAD$/d\n");
420 fprintf (fp
, "/^@BEGIN: OLDLOAD$/,/^@END: OLDLOAD$/d\n");
421 if (strcmp (oldload
, "off") == 0)
422 fprintf (fp
, "/^@BEGIN: NEWLOAD$/d\n/^@END: NEWLOAD$/d\n");
424 fprintf (fp
, "/^@BEGIN: NEWLOAD$/,/^@END: NEWLOAD$/d\n");
428 if (strcmp (ranlib
, "on") == 0) {
429 fprintf (fp
, "/^@BEGIN: RANLIB$/d\n/^@END: RANLIB$/d\n");
430 fprintf (fp
, "/^@BEGIN: LORDER$/,/^@END: LORDER$/d\n");
433 fprintf (fp
, "/^@BEGIN: LORDER$/d\n/^@END: LORDER$/d\n");
434 fprintf (fp
, "/^@BEGIN: RANLIB$/,/^@END: RANLIB$/d\n");
437 if (strcmp (sharedlib
, "off")) { /* if not off */
438 fprintf (fp
, "/^@BEGIN: SHAREDLIB$/d\n/^@END: SHAREDLIB$/d\n");
439 fprintf (fp
, "/^@BEGIN: STDLIB$/,/^@END: STDLIB$/d\n");
440 fprintf (fp
, "s%%@(SLIBDIR)%%%s%%g\n", slibdir
);
441 fprintf (fp
, "s%%@(SLIBVER)%%%s%%g\n", MHSLIBVER
);
442 fprintf (fp
, "s%%@(SLFLAGS)%%%s%%g\n", SVAL(slflags
));
443 if (strcmp (sharedlib
, "secure") == 0)
444 fprintf (fp
, "s%%@(SLDFLAG)%%-L%s%%g\n",slibdir
);
446 fprintf (fp
, "s%%@(SLDFLAG)%%%%g\n");
449 fprintf (fp
, "/^@BEGIN: STDLIB$/d\n/^@END: STDLIB$/d\n");
450 fprintf (fp
, "/^@BEGIN: SHAREDLIB$/,/^@END: SHAREDLIB$/d\n");
452 if (strcmp (sharedlib
, "sun4") == 0 || strcmp (sharedlib
, "on") == 0)
453 fprintf (fp
, "/^@BEGIN: SUN4SHLIB$/d\n/^@END: SUN4SHLIB$/d\n");
455 fprintf (fp
, "/^@BEGIN: SUN4SHLIB$/,/^@END: SUN4SHLIB$/d\n");
456 if (strcmp (sharedlib
, "sys5") == 0)
457 fprintf (fp
, "/^@BEGIN: SYS5SHLIB$/d\n/^@END: SYS5SHLIB$/d\n");
459 fprintf (fp
, "/^@BEGIN: SYS5SHLIB$/,/^@END: SYS5SHLIB$/d\n");
463 if (flag
|| ((mtsnum
== mmdf
|| mtsnum
== mmdf2
) && !smtp
)) {
464 fprintf (fp
, "/^@BEGIN: MMDFMTS$/d\n/^@END: MMDFMTS$/d\n");
466 fprintf (fp
, "/^@BEGIN: MMDFIMTS$/d\n/^@END: MMDFIMTS$/d\n");
468 fprintf (fp
, "/^@BEGIN: MMDFIMTS$/,/^@END: MMDFIMTS$/d\n");
470 fprintf (fp
, "/^@BEGIN: MMDFIIMTS$/d\n/^@END: MMDFIIMTS$/d\n");
472 fprintf (fp
, "/^@BEGIN: MMDFIIMTS$/,/^@END: MMDFIIMTS$/d\n");
475 fprintf (fp
, "/^@BEGIN: MMDFMTS$/,/^@END: MMDFMTS$/d\n");
476 fprintf (fp
, "/^@BEGIN: MMDFIMTS$/,/^@END: MMDFIMTS$/d\n");
477 fprintf (fp
, "/^@BEGIN: MMDFIIMTS$/,/^@END: MMDFIIMTS$/d\n");
481 fprintf (fp
, "/^@BEGIN: MHMTS$/d\n/^@END: MHMTS$/d\n");
483 fprintf (fp
, "/^@BEGIN: MHMTS$/,/^@END: MHMTS$/d\n");
485 if (!flag
&& (mtsnum
== sendmail
|| smtp
))
486 fprintf (fp
, "/^@BEGIN: SENDMTS$/d\n/^@END: SENDMTS$/d\n");
488 fprintf (fp
, "/^@BEGIN: SENDMTS$/,/^@END: SENDMTS$/d\n");
494 fprintf (fp
, "/^@BEGIN: SENDMTSHACK$/d\n/^@END: SENDMTSHACK$/d\n");
498 fprintf (fp
, "/^@BEGIN: SENDMTSHACK$/,/^@END: SENDMTSHACK$/d\n");
504 /* special hack for support/pop/popser.c */
505 fprintf (fp
, "s%%@(POPUUMBOX)%%%s%%g\n",
506 mtsnum
== sendmail
? "-DPOPUUMBOX" : "");
509 fprintf (fp
, "/^@BEGIN: SMTP$/d\n/^@END: SMTP$/d\n");
511 fprintf (fp
, "/^@BEGIN: SMTP$/,/^@END: SMTP$/d\n");
513 if (strcmp (pop
, "on") == 0)
514 fprintf (fp
, "/^@BEGIN: POP$/d\n/^@END: POP$/d\n");
516 fprintf (fp
, "/^@BEGIN: POP$/,/^@END: POP$/d\n");
518 if (strcmp (bboards
, "pop") == 0)
519 fprintf (fp
, "/^@BEGIN: BPOP$/d\n/^@END: BPOP$/d\n");
521 fprintf (fp
, "/^@BEGIN: BPOP$/,/^@END: BPOP$/d\n");
523 if (strcmp (bboards
, "nntp") == 0)
524 fprintf (fp
, "/^@BEGIN: NNTP$/d\n/^@END: NNTP$/d\n");
526 fprintf (fp
, "/^@BEGIN: NNTP$/,/^@END: NNTP$/d\n");
528 if (strcmp (mf
, "on") == 0)
529 fprintf (fp
, "/^@BEGIN: MF$/d\n/^@END: MF$/d\n");
531 fprintf (fp
, "/^@BEGIN: MF$/,/^@END: MF$/d\n");
533 fprintf (fp
, "s%%@(MHREMOVE)%%%s%%g\n", SVAL (removeit
));
535 for (op
= copts
; op
->c_name
; op
++) {
536 fprintf (fp
, op
->c_value
? "/^@BEGIN: %s$/d\n/^@END: %s$/d\n" :
537 "/^@BEGIN: %s$/,/^@END: %s$/d\n",
538 op
->c_name
, op
->c_name
);
549 for (pp
= files
; *pp
; pp
++)
550 shell ("rm -f %s; sed -f %s < config/%s > %s",
551 *pp
, SED
, tail (*pp
), *pp
);
564 for (pp
= makefiles
; pp
-> infile
; pp
++) {
565 (void) sprintf (buffer
, MAKE
, pp
-> outfile
);
566 shell ("rm -f %s; sed -f %s < %s > %s",
567 buffer
, SED
, pp
-> infile
, buffer
);
575 static shell (fmt
, a
, b
, c
, d
)
584 (void) sprintf (buffer
, fmt
, a
, b
, c
, d
);
585 printf ("%s\n", buffer
);
586 (void) fflush (stdout
);
589 adios (NULLCP
, "failed");
605 myname
= tail (*vec
);
606 printf (BANNER
, myname
);
607 (void) fflush (stdout
);
609 for (vec
++; *vec
; vec
++) {
610 if (strcmp (*vec
, "-D") == 0) {
611 sedP
= 1; filesP
= makeP
= 0; docP
= 2;
614 if (strcmp (*vec
, "-s") == 0) {
618 if (strcmp (*vec
, "-f") == 0) {
622 if (strcmp (*vec
, "-d") == 0) {
626 if (strcmp (*vec
, "-m") == 0) {
630 if (strcmp (*vec
, "-help") == 0) {
631 printf ("usage: %s [opt] file\n", myname
);
632 printf ("%s\n%s\n%s\n%s\n",
633 " -s\tno sed files", " -f\tno config files",
634 " -d\tno doc files", " -m\tno makefiles");
639 if ((config
= *vec
) == NULL
|| vec
[1] != NULL
) /* no arg or too many */
640 adios (NULLCP
, "usage: %s file", myname
);
644 if ((fp
= fopen (config
, "r")) == NULL
)
645 adios (config
, "unable to read");
647 while (fgets (buffer
, sizeof buffer
, fp
)) {
648 if (ap
= index (buffer
, '\n'))
651 ap
= &buffer
[strlen (buffer
) - 1];
657 for (cp
= buffer
; isspace (*cp
); cp
++)
659 if (*cp
== '\0' || *cp
== '#')
661 for (ap
= cp
; *ap
; ap
++)
662 if (isspace (*ap
) || *ap
== ':') {
664 while (isspace (*ap
))
668 for (bp
= binds
; bp
-> keyword
; bp
++)
669 if (strcmp (bp
-> keyword
, cp
) == 0)
671 if (bp
-> keyword
== NULL
)
672 adios (NULLCP
, "unknown option %s in %s", cp
, config
);
674 if (*(bp
-> value
) == NULL
|| !(bp
-> flags
& BD_ADD
))
675 *(bp
-> value
) = strdup (ap
);
677 *(bp
-> value
) = stradd (ap
, stradd (" ", *(bp
-> value
)));
685 adios (NULLCP
, "bin must be specified in %s", config
);
688 if (strcmp (bboards
, "on") && strcmp (bboards
, "off") &&
689 strcmp (bboards
, "pop") && strcmp (bboards
, "nntp"))
690 adios (NULLCP
, "bboards should be %s not %s",
691 "either \"on\", \"off\", \"pop\" or \"nntp\"", bboards
);
692 if (strcmp (bboards
, "off") == 0 && strcmp (bbdelivery
, "off"))
694 "you cannot have \"bbdelivery\" \"%s\" with \"bboards\" \"%s\"",
695 bbdelivery
, bboards
);
697 adios (NULLCP
, "bbhome must be specified in %s", config
);
700 if (strcmp (debug
, "on") && strcmp (debug
, "off"))
701 adios (NULLCP
, "debug should be either \"on\" or \"off\", not %s",
705 adios (NULLCP
, "etc must be specified in %s", config
);
708 if (strcmp (mailgroup
, "off")) /* if not "off" */
709 add_option ("MAILGROUP");
710 if (mailpath
== NULL
)
711 adios (NULLCP
, "mail must be specified in %s", config
);
713 if (*mailpath
== '/')
718 if (cp
= index (manuals
, '/')) { /* "standard/cat" */
721 if (strcmp (mancat
, "cat"))
722 adios (NULLCP
,"invalid manuals setting: %s/%s",manuals
, mancat
);
724 if (strcmp (manuals
, "standard")
725 && strcmp (manuals
, "bsd44")
726 && strcmp (manuals
, "local")
727 && strcmp (manuals
, "new")
728 && strcmp (manuals
, "old")
729 && strcmp (manuals
, "gen")
730 && strcmp (manuals
, "none"))
731 adios (NULLCP
,"invalid manuals setting: %s",manuals
);
734 adios (NULLCP
, "mts must be specified in %s", config
);
735 for (i
= 0; mtsopts
[i
].mtskey
; i
++)
736 if (strcmp (mts
, mtsopts
[i
].mtskey
) == 0)
738 if ((mtsnum
= mtsopts
[i
].code
) == unknown
)
739 adios (NULLCP
, "invalid mts setting: %s", mts
);
740 add_option (mtsopts
[i
].optval
);
741 smtp
= mtsopts
[i
].mtsflags
& DOSMTP
;
742 if (mtsopts
[i
].mtsflags
& NOMF
)
743 mf
= "off"; /* hack... */
745 if (strcmp (pop
, "on") && strcmp (pop
, "off"))
746 adios (NULLCP
, "pop should be either \"on\" or \"off\", not %s", pop
);
747 if (strcmp (pop
, "on") == 0)
750 if (strcmp (bboards
, "pop") == 0) {
752 if (strcmp (pop
, "on"))
753 adios (NULLCP
, "bboards \"pop\" requires pop \"on\"");
755 else if (strcmp (bboards
, "nntp") == 0) {
756 add_option ("BPOP");/* used by msh.c & bbc.c, but see also pshsbr.c */
760 "bboards \"nntp\" is incompatible with \"options MPOP\"");
763 if (strcmp (mf
, "on") && strcmp (mf
, "off"))
764 adios (NULLCP
, "mf should be either \"on\" or \"off\", not %s", mf
);
765 if (strcmp (mf
, "on") == 0)
768 if (sprntf
&& strcmp (sprntf
, "char *")) {/* this defaults to "char *" */
769 if (strcmp (sprntf
, "int"))
771 "sprintf should be either \"int\" or \"char *\", not %s",
773 add_option ("SPRINTFTYPE=int");
776 if (strcmp (sharedlib
, "on") && strcmp (sharedlib
, "off")
777 && strcmp (sharedlib
, "sun4") && strcmp (sharedlib
, "sys5")
778 && strcmp (sharedlib
, "secure"))
780 "sharedlib should be either \"sun4\", \"sys5\", or \"off\", not %s",
783 (void) sprintf(buffer
, "TYPESIG=%s", signl
);
786 /* loop over options string and add -D ccoptions */
790 for (ap
= cp
; *ap
; ap
++)
794 for (ap
= cp
; dp
= index (ap
, ' '); ap
= dp
) {
797 (void) sprintf (buffer
, "%s-D%s", options
? " " : "", ap
);
799 options
= stradd (ap
, options
);
800 while (isspace (*dp
))
805 (void) sprintf (buffer
, "%s-D%s", options
? " " : "", ap
);
807 options
= stradd (ap
, options
);
812 if (strcmp (bboards
, "nntp") == 0 && mpop
)
814 "bboards \"nntp\" is incompatible with \"options MPOP\"");
819 static add_option (s
)
822 options
= options
? stradd (s
, stradd (" ", options
)) : strdup (s
);
827 myopts
= strdup ("char *options[] = {");
838 static int nameoutput
= 0;
839 static int linepos
= 0;
840 static int outputlinelen
= 72;
842 for (op
= copts
; op
->c_name
; op
++)
843 if (!strncmp (op
->c_name
,s
,strlen(op
->c_name
))) {
848 if (strcmp (s
, "MPOP") == 0)
850 if (smtp
&& strcmp (s
, "BERK") == 0) {
851 fprintf (stderr
, "\"options BERK\" overriding smtp suffix...\n");
855 printf ("%s: ", bp
= "options");
856 linepos
+= (nameoutput
= strlen (bp
) + 2);
859 if (linepos
!= nameoutput
)
860 if (len
+ linepos
+ 3 > outputlinelen
)
861 printf ("\n%*s", linepos
= nameoutput
, "");
863 printf (" "), linepos
++;
866 (void) fflush (stdout
);
872 *bp
++ = QUOTE
, *bp
++ = QUOTE
;
875 (void) strcpy (bp
, "\", ");
882 (void) fflush (stdout
);
884 myopts
= stradd ("NULL};", myopts
);
894 if (s
== NULL
|| (p
= rindex (s
, '/')) == NULL
)
901 static char *tail (s
)
906 if (p
= rindex (s
, '/'))
908 return ((p
== NULL
|| *p
== '\0') ? s
: p
);
913 static char *stradd (s1
, s2
)
919 if (s1
== NULL
|| *s1
== '\0')
923 if ((p
= malloc ((unsigned) (strlen (s1
) + strlen (s2
) + 2))) == NULL
)
924 adios (NULLCP
, "insufficient memory");
926 (void) sprintf (p
, "%s%s", s2
, s1
);
933 static char *strdup (s
)
938 if ((p
= malloc ((unsigned) (strlen (s
) + 1))) == NULL
)
939 adios (NULLCP
, "insufficient memory");
941 (void) strcpy (p
, s
);
948 /* these used to be for SYS5 machines, but now this is compiled
949 * with -DSYS5 which redefines the SYS5 str[r]chr names to [r]index.
951 static char *index (s
, c
)
965 static char *rindex (s
, c
)
985 adios (what
, fmt
, a
, b
, c
)
992 (void) fflush (stdout
);
994 fprintf (stderr
, "%s: ", myname
);
995 fprintf (stderr
, fmt
, a
, b
, c
);
997 (void) fputc (' ', stderr
);
1001 (void) fputc ('\n', stderr
);
1006 /* quick and dirty ordering of options for readability */
1013 static struct opt
*optp
= (struct opt
*)NULL
;
1017 char *s
; /* string for sorting */
1021 *lp
= (struct opt
*)NULL
;
1023 if ((np
= (struct opt
*) malloc ((unsigned) sizeof (struct opt
))) ==
1025 adios (NULL
, "unable to malloc opt");
1026 np
-> s
= strdup(s
);
1027 np
-> n
= (struct opt
*)NULL
;
1029 for (p
= optp
; p
; lp
= p
, p
= p
-> n
) {
1030 if (strcmp (p
->s
, s
) > 0)
1046 for (p
= optp
; p
; p
= p
-> n
)
1047 myopts
= stradd (p
->s
, myopts
);