Annotation of 43BSDReno/contrib/mh/conf/mhconfig.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char rcsid[] =
                      3:     "@(#) $Header: mhconfig.c,v 1.7 89/12/15 23:34:02 leres Exp $ (LBL)";
                      4: #endif
                      5: /* mhconfig.c - configure MH */
                      6: 
                      7: #include <sys/param.h>
                      8: #if defined(BSD4_4)
                      9: #define BSD44
                     10: #endif
                     11: #include "../h/strings.h"
                     12: #include <ctype.h>
                     13: #include <stdio.h>
                     14: 
                     15: 
                     16: #define        BANNER  "This is %s, for generic UNIX (MH.6 configuration program)\n\n"
                     17: 
                     18: 
                     19: #define        SED             "config.sed"
                     20: #define        SEDOC           "doc/config.sed"
                     21: #define        MFIL(f)         "makefiles/f", "f"
                     22: #define        MMFIL(f,g)      "makefiles/f", "g"
                     23: #define        MAKE            "../%s/Makefile"
                     24: 
                     25: #define        WARNING "This file is automatically generated.  Do not edit!"
                     26: 
                     27: #define        NOTOK   (-1)
                     28: 
                     29: #define        NULLCP  ((char *) 0)
                     30: 
                     31: #define        SVAL(s) (s ? s : "")
                     32: 
                     33: #define        QUOTE   '\\'
                     34: 
                     35: /*  */
                     36: 
                     37: static int   smtp = 0;
                     38: 
                     39: static int   sedP = 1;
                     40: static int   filesP = 1;
                     41: static int   docP = 1;
                     42: static int   makeP = 1;
                     43: 
                     44: static char *myname = "mhconfig";
                     45: 
                     46: static char *myopts = NULL;
                     47: 
                     48: static char *binpath = "/usr/local";
                     49: static char *bbhome = "/usr/spool/bboards";
                     50: static char *bboards = "off";
                     51: static char *cc = "cc";
                     52: static char *ccoptions = NULL;
                     53: #if defined(BSD44)
                     54: static char *chownpath = "/usr/sbin/chown";
                     55: #else
                     56: static char *chownpath = "/etc/chown";
                     57: #endif
                     58: static char *curses = "-lcurses -ltermlib";
                     59: static char *debug = "off";
                     60: static char *editor = "prompter";
                     61: static char *etcpath = "/usr/local/lib/mh";
                     62: static char *ldoptions = NULL;
                     63: static char *ldoptlibs = NULL;
                     64: #if defined(BSD44)
                     65: static char *mailpath = "/var/mail";
                     66: #else
                     67: static char *mailpath = "/usr/spool/mail";
                     68: #endif
                     69: static char *maildir = NULL;
                     70: static char *mailfile = NULL;
                     71: #if defined(BSD44)
                     72: static char *mandir = "/usr/man";
                     73: #else
                     74: static char *mandir = "/usr/share/man";
                     75: #endif
                     76: static char *manuals = "standard";
                     77: static char *mf = "off";
                     78: static char *mts = "sendmail";
                     79: static char *remove = "mv -f";
                     80: static char *oldload = "off";
                     81: static char *options = NULL;
                     82: static char *pop = "off";
                     83: static char *popbboards = "off";
                     84: static char *ranlib = "on";
                     85: static char *flex = "off";
                     86: static char *tma = "off";
                     87: 
                     88: #define        unknown         0
                     89: #define        mmdf            1
                     90: #define        mmdf2           2
                     91: #define        mh              3
                     92: #define        sendmail        4
                     93: static int mtsnum = unknown;
                     94: 
                     95: static struct mtsopt {
                     96:     char  *mtskey;
                     97:     char  *optval;
                     98:     int           code;
                     99:     int    mtsflags;
                    100: #define        NOFLAGS 0x00
                    101: #define        DOSMTP  0x01
                    102: #define        NOMF    0x02
                    103: } mtsopts[] = {
                    104:     "mmdf", "MMDFMTS MMDFI", mmdf, NOFLAGS,
                    105:     "mmdf/smtp", "SENDMTS SMTP", mmdf, DOSMTP,
                    106:     "mmdf2", "MMDFMTS MMDFII", mmdf2, NOFLAGS,
                    107:     "mmdf2/smtp", "SENDMTS MMDFII SMTP", mmdf2, DOSMTP,
                    108:     "mh", "MHMTS", mh, NOFLAGS,
                    109:     "sendmail", "SENDMTS", sendmail, NOMF,
                    110:     "sendmail/smtp", "SENDMTS SMTP", sendmail, NOMF,
                    111:     NULL, NULL, unknown, NOFLAGS
                    112: };
                    113: 
                    114: static struct bind {
                    115:     char   *keyword;
                    116: 
                    117:     char  **value;
                    118: 
                    119:     int     flags;
                    120: #define        BD_NIL  0x00
                    121: #define        BD_ADD  0x01
                    122: }                   binds[] = {
                    123:                         "bin", &binpath, BD_NIL,
                    124:                         "bbhome", &bbhome, BD_NIL,
                    125:                         "bboards", &bboards, BD_NIL,
                    126:                        "cc", &cc, BD_NIL,
                    127:                        "ccoptions", &ccoptions, BD_ADD,
                    128:                        "chown", &chownpath, BD_NIL,
                    129:                        "curses", &curses, BD_NIL,
                    130:                        "debug", &debug, BD_NIL,
                    131:                        "editor", &editor, BD_NIL,
                    132:                         "etc", &etcpath, BD_NIL,
                    133:                        "ldoptions", &ldoptions, BD_ADD,
                    134:                        "ldoptlibs", &ldoptlibs, BD_ADD,
                    135:                         "mail", &mailpath, BD_NIL,
                    136:                         "mandir", &mandir, BD_NIL,
                    137:                         "manuals", &manuals, BD_NIL,
                    138:                        "mf", &mf, BD_NIL,
                    139:                         "mts", &mts, BD_NIL,
                    140:                        "oldload", &oldload, BD_NIL,
                    141:                         "options", &options, BD_ADD,
                    142:                         "pop", &pop, BD_NIL,
                    143:                         "popbboards", &popbboards, BD_NIL,
                    144:                        "ranlib", &ranlib, BD_NIL,
                    145:                        "flex", &flex, BD_NIL,
                    146:                        "remove", &remove, BD_NIL,
                    147:                        "tma", &tma, BD_NIL,
                    148:                         NULL
                    149: };
                    150: 
                    151: 
                    152: char   *files[] = {
                    153:     "../support/bboards/bboards.daily",
                    154:     "../support/bboards/bboards.weekly",
                    155:     "../support/bboards/crontab",
                    156:     "../support/bboards/MakeBBoards",
                    157:     "../config/config.c",
                    158:     "../zotnet/mts/mts.c",
                    159:     "../zotnet/mts/mtstailor",
                    160:     "../support/general/MailAliases",
                    161:     "../mts/sendmail/bboardsMH.m4",
                    162:     "../mts/sendmail/popMH.m4",
                    163:     NULL
                    164: };
                    165: 
                    166: static struct pair {
                    167:     char   *infile;
                    168:     char   *outfile;
                    169: }                  makefiles[] = {
                    170:                        MFIL (config),
                    171:                        MFIL (dist),
                    172:                        MFIL (doc),
                    173:                        MMFIL (mtsM,mts),
                    174:                            MFIL (mts/mh),
                    175:                            MFIL (mts/mmdf),
                    176:                            MFIL (mts/sendmail),
                    177:                        MFIL (papers),
                    178:                        MFIL (sbr),
                    179:                        MMFIL (supportM,support),
                    180:                            MFIL (support/bboards),
                    181:                            MFIL (support/general),
                    182:                            MFIL (support/pop),
                    183:                        MFIL (uip),
                    184:                        MMFIL (zotnetM,zotnet),
                    185:                            MFIL (zotnet/bboards),
                    186:                            MFIL (zotnet/mf),
                    187:                            MFIL (zotnet/mts),
                    188:                            MFIL (zotnet/tws),
                    189:                        NULL
                    190: };
                    191: 
                    192: 
                    193: char   *stradd (), *strdup (), *tail ();
                    194: 
                    195: long    time ();
                    196: 
                    197: /*  */
                    198: 
                    199: /* ARGSUSED */
                    200: 
                    201: main (argc, argv, envp)
                    202: int     argc;
                    203: char  **argv,
                    204:       **envp;
                    205: {
                    206:     arginit (argc, argv);
                    207: 
                    208:     if (sedP)
                    209:        do_sed ();
                    210:     if (filesP)
                    211:        do_files ();
                    212:     if (docP)
                    213:        do_doc ();
                    214:     if (makeP)
                    215:        do_make ();
                    216: 
                    217:     if (filesP || makeP)
                    218:        printf ("Don't forget to run \"make clean\" before proceeding\n");
                    219: 
                    220:     exit (0);
                    221: }
                    222: 
                    223: /*  */
                    224: 
                    225: static  do_sed () {
                    226:     do_sedfile (SED, 0);
                    227:     do_sedfile (SEDOC, smtp);
                    228: }
                    229: 
                    230: 
                    231: static do_sedfile (sed, flag)
                    232: char   *sed;
                    233: int    flag;
                    234: {
                    235:     int     i;
                    236:     FILE * fp;
                    237: 
                    238:     if ((fp = fopen (sed, "w")) == NULL)
                    239:        adios (sed, "unable to write");
                    240:     printf ("generating %s\n", sed);
                    241: 
                    242:     fprintf (fp, "s%%@(MHWARNING)%%%s%%g\n", WARNING);
                    243:     fprintf (fp, "s%%@(MHBINPATH)%%%s%%g\n", SVAL (binpath));
                    244:     fprintf (fp, "s%%@(MHETCPATH)%%%s%%g\n", SVAL (etcpath));
                    245:     fprintf (fp, "s%%@(MHCHOWNPATH)%%%s%%g\n", SVAL (chownpath));
                    246:     fprintf (fp, "s%%@(MHDROPATH)%%%s%%g\n", SVAL (maildir));
                    247:     fprintf (fp, "s%%@(MHDROPFIL)%%%s%%g\n", SVAL (mailfile));
                    248:     if (maildir)
                    249:        fprintf (fp, "s%%@(MHDROPLOC)%%%s/$USER%%g\n", SVAL (maildir));
                    250:     else
                    251:        fprintf (fp, "s%%@(MHDROPLOC)%%$HOME/%s%%g\n", SVAL (mailfile));
                    252:     fprintf (fp, "s%%@(MHDROPHAK)%%%s%%g\n",/* HACK */
                    253:        maildir ? maildir : "/usr/spool/mail");
                    254: 
                    255:     fprintf (fp, "s%%@(MHMANDIR)%%%s%%g\n", mandir);
                    256:     if (strcmp (manuals, "standard") == 0 || strcmp (manuals, "gen") == 0)
                    257:        for (i = 1; i <= 8; i++) {
                    258:            fprintf (fp, "s%%@(MHMANDIR%d)%%man%d%%g\n", i, i);
                    259:            fprintf (fp, "s%%@(MHMANEXT%d)%%%d%%g\n", i, i);
                    260:        }
                    261:     else
                    262:        for (i = 1; i <= 8; i++) {
                    263:            fprintf (fp, "s%%@(MHMANDIR%d)%%man%c%%g\n", i,
                    264:                    strcmp (manuals, "new") == 0 ? 'n'
                    265:                    : strcmp (manuals, "old") == 0 ? 'o'
                    266:                    : 'l');
                    267:            fprintf (fp, "s%%@(MHMANEXT%d)%%%c%%g\n", i,
                    268:                    strcmp (manuals, "new") == 0 ? 'n'
                    269:                    : strcmp (manuals, "old") == 0 ? 'o'
                    270:                    : 'l');
                    271:        }
                    272:     if (strcmp (manuals, "gen") == 0)
                    273:        fprintf (fp, "s%%@(MHMANGEN)%%%s%%g\n", "#"); /* comment char */
                    274:     else
                    275:        fprintf (fp, "s%%@(MHMANGEN)%%%s%%g\n", "");
                    276: 
                    277:     fprintf (fp, "s%%@(MHEDITOR)%%%s%%g\n", SVAL (editor));
                    278:     fprintf (fp, "s%%@(MHCONFIG)%%%s%%g\n", SVAL (myopts));
                    279:     fprintf (fp, "s%%@(CC)%%%s%%g\n", SVAL (cc));
                    280:     if (ccoptions)
                    281:        fprintf (fp, "s%%@(MHOPTIONS)%%%s %s%%g\n",
                    282:                SVAL (options), SVAL (ccoptions));
                    283:     else
                    284:        fprintf (fp, "s%%@(MHOPTIONS)%%%s%%g\n", SVAL (options));
                    285:     fprintf (fp, "s%%@(LDOPTIONS)%%%s%%g\n", SVAL (ldoptions));
                    286:     fprintf (fp, "s%%@(LDOPTLIB)%%%s%%g\n", SVAL (ldoptlibs));
                    287:     fprintf (fp, "s%%@(LDCURSES)%%%s%%g\n", SVAL (curses));
                    288: 
                    289:     if (strcmp (bboards, "on") == 0)
                    290:        fprintf (fp, "/^@BEGIN: BBOARDS$/d\n/^@END: BBOARDS$/d\n");
                    291:     else
                    292:        fprintf (fp, "/^@BEGIN: BBOARDS$/,/^@END: BBOARDS$/d\n");
                    293:     fprintf (fp, "s%%@(BBHOME)%%%s%%g\n", SVAL (bbhome));
                    294: 
                    295:     if (strcmp (debug, "on") == 0) {
                    296:        fprintf (fp, "/^@BEGIN: DEBUG$/d\n/^@END: DEBUG$/d\n");
                    297:        fprintf (fp, "/^@BEGIN: OPTIM$/,/^@END: OPTIM$/d\n");
                    298:     }
                    299:     else {
                    300:        fprintf (fp, "/^@BEGIN: DEBUG$/,/^@END: DEBUG$/d\n");
                    301:        fprintf (fp, "/^@BEGIN: OPTIM$/d\n/^@END: OPTIM$/d\n");
                    302:     }
                    303: 
                    304:     if (strcmp (oldload, "on") == 0) {
                    305:        fprintf (fp, "/^@BEGIN: OLDLOAD$/d\n/^@END: OLDLOAD$/d\n");
                    306:        fprintf (fp, "/^@BEGIN: NEWLOAD$/,/^@END: NEWLOAD$/d\n");
                    307:     }
                    308:     else {
                    309:        fprintf (fp, "/^@BEGIN: NEWLOAD$/d\n/^@END: NEWLOAD$/d\n");
                    310:        fprintf (fp, "/^@BEGIN: OLDLOAD$/,/^@END: OLDLOAD$/d\n");
                    311:     }
                    312: 
                    313:     if (strcmp (ranlib, "on") == 0) {
                    314:        fprintf (fp, "/^@BEGIN: RANLIB$/d\n/^@END: RANLIB$/d\n");
                    315:        fprintf (fp, "/^@BEGIN: LORDER$/,/^@END: LORDER$/d\n");
                    316:     }
                    317:     else {
                    318:        fprintf (fp, "/^@BEGIN: LORDER$/d\n/^@END: LORDER$/d\n");
                    319:        fprintf (fp, "/^@BEGIN: RANLIB$/,/^@END: RANLIB$/d\n");
                    320:     }
                    321: 
                    322:     if (strcmp (flex, "on") == 0) {
                    323:        fprintf (fp, "/^@BEGIN: FLEX$/d\n/^@END: FLEX$/d\n");
                    324:        fprintf (fp, "/^@BEGIN: LEX$/,/^@END: LEX$/d\n");
                    325:     }
                    326:     else {
                    327:        fprintf (fp, "/^@BEGIN: LEX$/d\n/^@END: LEX$/d\n");
                    328:        fprintf (fp, "/^@BEGIN: FLEX$/,/^@END: FLEX$/d\n");
                    329:     }
                    330: 
                    331:     if (strcmp (tma, "on") == 0)
                    332:        fprintf (fp, "/^@BEGIN: TMA$/d\n/^@END: TMA$/d\n");
                    333:     else
                    334:        fprintf (fp, "/^@BEGIN: TMA$/,/^@END: TMA$/d\n");
                    335:     if (flag || ((mtsnum == mmdf || mtsnum == mmdf2) && !smtp)) {
                    336:        fprintf (fp, "/^@BEGIN: MMDFMTS$/d\n/^@END: MMDFMTS$/d\n");
                    337:        if (mtsnum == mmdf)
                    338:            fprintf (fp, "/^@BEGIN: MMDFIMTS$/d\n/^@END: MMDFIMTS$/d\n");
                    339:        else
                    340:            fprintf (fp, "/^@BEGIN: MMDFIMTS$/,/^@END: MMDFIMTS$/d\n");
                    341:        if (mtsnum == mmdf2)
                    342:            fprintf (fp, "/^@BEGIN: MMDFIIMTS$/d\n/^@END: MMDFIIMTS$/d\n");
                    343:        else
                    344:            fprintf (fp, "/^@BEGIN: MMDFIIMTS$/,/^@END: MMDFIIMTS$/d\n");
                    345:     }
                    346:     else {
                    347:        fprintf (fp, "/^@BEGIN: MMDFMTS$/,/^@END: MMDFMTS$/d\n");
                    348:        fprintf (fp, "/^@BEGIN: MMDFIMTS$/,/^@END: MMDFIMTS$/d\n");
                    349:        fprintf (fp, "/^@BEGIN: MMDFIIMTS$/,/^@END: MMDFIIMTS$/d\n");
                    350:     }
                    351: 
                    352:     if (mtsnum == mh)
                    353:        fprintf (fp, "/^@BEGIN: MHMTS$/d\n/^@END: MHMTS$/d\n");
                    354:     else
                    355:        fprintf (fp, "/^@BEGIN: MHMTS$/,/^@END: MHMTS$/d\n");
                    356: 
                    357:     if (!flag && (mtsnum == sendmail || smtp))
                    358:        fprintf (fp, "/^@BEGIN: SENDMTS$/d\n/^@END: SENDMTS$/d\n");
                    359:     else
                    360:        fprintf (fp, "/^@BEGIN: SENDMTS$/,/^@END: SENDMTS$/d\n");
                    361: 
                    362:     switch (mtsnum) {
                    363:        case mh:
                    364:        case sendmail:
                    365:        case mmdf:
                    366:            fprintf (fp, "/^@BEGIN: SENDMTSHACK$/d\n/^@END: SENDMTSHACK$/d\n");
                    367:            break;
                    368: 
                    369:        default:
                    370:            fprintf (fp, "/^@BEGIN: SENDMTSHACK$/,/^@END: SENDMTSHACK$/d\n");
                    371:            break;
                    372:     }
                    373: 
                    374:     if (smtp)
                    375:        fprintf (fp, "/^@BEGIN: SMTP$/d\n/^@END: SMTP$/d\n");
                    376:     else
                    377:        fprintf (fp, "/^@BEGIN: SMTP$/,/^@END: SMTP$/d\n");
                    378: 
                    379:     if (strcmp (pop, "on") == 0)
                    380:        fprintf (fp, "/^@BEGIN: POP$/d\n/^@END: POP$/d\n");
                    381:     else
                    382:        fprintf (fp, "/^@BEGIN: POP$/,/^@END: POP$/d\n");
                    383: 
                    384:     if (strcmp (popbboards, "on") == 0)
                    385:        fprintf (fp, "/^@BEGIN: BPOP$/d\n/^@END: BPOP$/d\n");
                    386:     else
                    387:        fprintf (fp, "/^@BEGIN: BPOP$/,/^@END: BPOP$/d\n");
                    388: 
                    389:     if (strcmp (mf, "on") == 0)
                    390:        fprintf (fp, "/^@BEGIN: MF$/d\n/^@END: MF$/d\n");
                    391:     else
                    392:        fprintf (fp, "/^@BEGIN: MF$/,/^@END: MF$/d\n");
                    393: 
                    394:     fprintf (fp, "s%%@(MHREMOVE)%%%s%%g\n", SVAL (remove));
                    395: 
                    396:     (void) fclose (fp);
                    397: }
                    398: 
                    399: /*  */
                    400: 
                    401: static  do_files () {
                    402:     char  **pp;
                    403: 
                    404:     for (pp = files; *pp; pp++)
                    405:        shell ("rm -f %s; sed -f %s < config/%s > %s",
                    406:                *pp, SED, tail (*pp), *pp);
                    407: }
                    408: 
                    409: 
                    410: static  do_doc () {
                    411:     shell ("mhdoc");
                    412: }
                    413: 
                    414: 
                    415: static  do_make () {
                    416:     char    buffer[BUFSIZ];
                    417:     struct pair *pp;
                    418: 
                    419:     for (pp = makefiles; pp -> infile; pp++) {
                    420:        (void) sprintf (buffer, MAKE, pp -> outfile);
                    421:        shell ("rm -f %s; sed -f %s < %s > %s",
                    422:                buffer, SED, pp -> infile, buffer);
                    423:     }
                    424: }
                    425: 
                    426: /*  */
                    427: 
                    428: /* VARARGS */
                    429: 
                    430: static  shell (fmt, a, b, c, d)
                    431: char   *fmt,
                    432:        *a,
                    433:        *b,
                    434:        *c,
                    435:        *d;
                    436: {
                    437:     int s;
                    438:     char    buffer[BUFSIZ];
                    439: 
                    440:     (void) sprintf (buffer, fmt, a, b, c, d);
                    441:     printf ("%s\n", buffer);
                    442:     (void) fflush (stdout);
                    443: 
                    444:     s = system (buffer);
                    445:     if (s == 256) {
                    446:        printf ("(Not found, let's see if it's in \".\")\n");
                    447:        buffer[0] = '.';
                    448:        buffer[1] = '/';
                    449:        (void) sprintf (&buffer[2], fmt, a, b, c, d);
                    450:        printf ("%s\n", buffer);
                    451:        (void) fflush (stdout);
                    452:        s = system (buffer);
                    453:     }
                    454:     if (s)
                    455:        adios (NULLCP, "failed");
                    456: }
                    457: 
                    458: /*  */
                    459: 
                    460: static  arginit (n, vec)
                    461: int n;
                    462: char  **vec;
                    463: {
                    464:     int            i;
                    465:     char   *ap,
                    466:            *cp,
                    467:            *dp,
                    468:            *config,
                    469:             buffer[BUFSIZ];
                    470:     struct bind *bp;
                    471:     FILE * fp;
                    472: 
                    473:     myname = tail (*vec);
                    474:     printf (BANNER, myname);
                    475:     (void) fflush (stdout);
                    476: 
                    477:     vec++;
                    478:     for (n--; n > 0; n--) {
                    479:        if (strcmp (*vec, "-s") == 0) {
                    480:            sedP = !sedP;
                    481:            vec++;
                    482:            continue;
                    483:        }
                    484:        if (strcmp (*vec, "-f") == 0) {
                    485:            filesP = !filesP;
                    486:            vec++;
                    487:            continue;
                    488:        }
                    489:        if (strcmp (*vec, "-d") == 0) {
                    490:            docP = !docP;
                    491:            vec++;
                    492:            continue;
                    493:        }
                    494:        if (strcmp (*vec, "-m") == 0) {
                    495:            makeP = !makeP;
                    496:            vec++;
                    497:            continue;
                    498:        }
                    499:        break;
                    500:     }
                    501:     if ((config = *vec++) == NULL || *vec != NULL)
                    502:        adios (NULLCP, "usage: %s file", myname);
                    503: 
                    504:     if ((fp = fopen (config, "r")) == NULL)
                    505:        adios (config, "unable to read");
                    506: 
                    507:     while (fgets (buffer, sizeof buffer, fp)) {
                    508:        if (ap = index (buffer, '\n'))
                    509:            *ap-- = NULL;
                    510:        else
                    511:            ap = &buffer[strlen (buffer) - 1];
                    512:        while (ap >= buffer)
                    513:            if (isspace (*ap))
                    514:                *ap = NULL;
                    515:            else
                    516:                break;
                    517:        for (cp = buffer; isspace (*cp); cp++)
                    518:            continue;
                    519:        if (*cp == NULL || *cp == '#')
                    520:            continue;
                    521:        for (ap = cp; *ap; ap++)
                    522:            if (isspace (*ap)) {
                    523:                *ap++ = NULL;
                    524:                while (isspace (*ap))
                    525:                    ap++;
                    526:                break;
                    527:            }
                    528:        for (bp = binds; bp -> keyword; bp++)
                    529:            if (strcmp (bp -> keyword, cp) == 0)
                    530:                break;
                    531:        if (bp -> keyword == NULL)
                    532:            adios (NULLCP, "unknown option %s in %s", cp, config);
                    533:        else
                    534:            if (*(bp -> value) == NULL || !(bp -> flags & BD_ADD))
                    535:                *(bp -> value) = strdup (ap);
                    536:            else
                    537:                *(bp -> value) = stradd (ap, stradd (" ", *(bp -> value)));
                    538:     }
                    539: 
                    540:     (void) fclose (fp);
                    541: 
                    542: /*  */
                    543: 
                    544:     if (binpath == NULL)
                    545:        adios (NULLCP, "bin must be specified in %s", config);
                    546:     trim (binpath);
                    547: 
                    548:     if (strcmp (bboards, "on") && strcmp (bboards, "off"))
                    549:        adios (NULLCP, "bboards should be either \"on\" or \"off\", not %s",
                    550:                bboards);
                    551:     if (bbhome == NULL)
                    552:        adios (NULLCP, "bbhome must be specified in %s", config);
                    553:     trim (bbhome);
                    554: 
                    555:     if (strcmp (debug, "on") && strcmp (debug, "off"))
                    556:        adios (NULLCP, "debug should be either \"on\" or \"off\", not %s",
                    557:                debug);
                    558: 
                    559:     if (etcpath == NULL)
                    560:        adios (NULLCP, "etc must be specified in %s", config);
                    561:     trim (etcpath);
                    562: 
                    563:     if (mailpath == NULL)
                    564:        adios (NULLCP, "mail must be specified in %s", config);
                    565:     trim (mailpath);
                    566:     if (*mailpath == '/')
                    567:        maildir = mailpath;
                    568:     else
                    569:        mailfile = mailpath;
                    570: 
                    571:     if (strcmp (manuals, "standard")
                    572:            && strcmp (manuals, "local")
                    573:            && strcmp (manuals, "new")
                    574:            && strcmp (manuals, "old")
                    575:            && strcmp (manuals, "gen")
                    576:            && strcmp (manuals, "none"))
                    577:        adios (NULLCP,"invalid manuals setting: %s",manuals);
                    578: 
                    579:     if (mts == NULL)
                    580:        adios (NULLCP, "mts must be specified in %s", config);
                    581:     for (i = 0; mtsopts[i].mtskey; i++)
                    582:        if (strcmp (mts, mtsopts[i].mtskey) == 0)
                    583:            break;
                    584:     if ((mtsnum = mtsopts[i].code) == unknown)
                    585:        adios (NULLCP, "invalid mts setting: %s", mts);
                    586:     add_option (mtsopts[i].optval);
                    587:     smtp = mtsopts[i].mtsflags & DOSMTP;
                    588:     if (mtsopts[i].mtsflags & NOMF)
                    589:        mf = "off";             /* hack... */
                    590: 
                    591:     if (strcmp (pop, "on") && strcmp (pop, "off"))
                    592:        adios (NULLCP, "pop should be either \"on\" or \"off\", not %s", pop);
                    593:     if (strcmp (pop, "on") == 0)
                    594:        add_option ("POP");
                    595: 
                    596:     if (strcmp (popbboards, "on") && strcmp (popbboards, "off"))
                    597:        adios (NULLCP, "popbboards should be either \"on\" or \"off\", not %s",
                    598:                popbboards);
                    599:     if (strcmp (popbboards, "on") == 0) {
                    600:        add_option ("BPOP");
                    601:        if (strcmp (bboards, "on") || strcmp (pop, "on"))
                    602:            adios (NULLCP,
                    603:                    "popbboards \"on\" requires both bboards and pop \"on\"");
                    604:     }
                    605: 
                    606:     if (strcmp (mf, "on") && strcmp (mf, "off"))
                    607:        adios (NULLCP, "mf should be either \"on\" or \"off\", not %s", mf);
                    608:     if (strcmp (mf, "on") == 0)
                    609:        add_option ("MF");
                    610: 
                    611:     if (strcmp (tma, "on") && strcmp (tma, "off"))
                    612:        adios (NULLCP, "tma should be either \"on\" or \"off\", not %s", tma);
                    613:     if (strcmp (tma, "on") == 0)
                    614:        add_option ("TMA");
                    615: 
                    616:     begin_myopt ();
                    617:     if (cp = options) {
                    618:        for (ap = cp; *ap; ap++)
                    619:            if (isspace (*ap))
                    620:                *ap = ' ';
                    621:        options = NULL;
                    622:        for (ap = cp; dp = index (ap, ' '); ap = dp) {
                    623:            *dp++ = NULL;
                    624:            add_myopt (ap);
                    625:            (void) sprintf (buffer, "%s-D%s", options ? " " : "", ap);
                    626:            ap = buffer;
                    627:            options = stradd (ap, options);
                    628:            while (isspace (*dp))
                    629:                dp++;
                    630:        }
                    631:        if (*ap) {
                    632:            add_myopt (ap);
                    633:            (void) sprintf (buffer, "%s-D%s", options ? " " : "", ap);
                    634:            ap = buffer;
                    635:            options = stradd (ap, options);
                    636:        }
                    637:        free (cp);
                    638:     }
                    639:     end_myopt ();
                    640: }
                    641: 
                    642: /*  */
                    643: 
                    644: static  add_option (s)
                    645: char   *s;
                    646: {
                    647:     options = options ? stradd (s, stradd (" ", options)) : strdup (s);
                    648: }
                    649: 
                    650: 
                    651: begin_myopt () {
                    652:     myopts = strdup ("char *options[] = {");
                    653: }
                    654: 
                    655: 
                    656: add_myopt (s)
                    657: char   *s;
                    658: {
                    659:     int     len;
                    660:     char   *bp,
                    661:             buffer[BUFSIZ];
                    662:     static int  nameoutput = 0;
                    663:     static int  linepos = 0;
                    664:     static int  outputlinelen = 72;
                    665: 
                    666:     if (!nameoutput) {
                    667:        printf ("%s: ", bp = "options");
                    668:        linepos += (nameoutput = strlen (bp) + 2);
                    669:     }
                    670:     len = strlen (s);
                    671:     if (linepos != nameoutput)
                    672:        if (len + linepos + 3 > outputlinelen)
                    673:            printf ("\n%*s", linepos = nameoutput, "");
                    674:        else
                    675:            printf (" "), linepos++;
                    676:     printf ("[%s]", s);
                    677:     linepos += len + 2;
                    678:     (void) fflush (stdout);
                    679: 
                    680:     bp = buffer;
                    681:     *bp++ = '"';
                    682:     while (*s) {
                    683:        if (*s == '"')
                    684:            *bp++ = QUOTE, *bp++ = QUOTE;
                    685:        *bp++ = *s++;
                    686:     }
                    687:     (void) strcpy (bp, "\", ");
                    688:     myopts = stradd (buffer, myopts);
                    689: }
                    690: 
                    691: 
                    692: end_myopt () {
                    693:     printf ("\n");
                    694:     (void) fflush (stdout);
                    695: 
                    696:     myopts = stradd ("NULL};", myopts);
                    697: }
                    698: 
                    699: /*  */
                    700: 
                    701: static  trim (s)
                    702: char   *s;
                    703: {
                    704:     char   *p;
                    705: 
                    706:     if (s == NULL || (p = rindex (s, '/')) == NULL)
                    707:        return;
                    708:     if (*++p == NULL)
                    709:        *--p = NULL;
                    710: }
                    711: 
                    712: 
                    713: static char *tail (s)
                    714: char   *s;
                    715: {
                    716:     char   *p;
                    717: 
                    718:     if (p = rindex (s, '/'))
                    719:        p++;
                    720:     return ((p == NULL || *p == NULL) ? s : p);
                    721: }
                    722: 
                    723: /*  */
                    724: 
                    725: static char *stradd (s1, s2)
                    726: char   *s1,
                    727:        *s2;
                    728: {
                    729:     char   *p;
                    730: 
                    731:     if (s1 == NULL || *s1 == NULL)
                    732:        return s2;
                    733:     if (s2 == NULL)
                    734:        return strdup (s1);
                    735:     if ((p = malloc ((unsigned) (strlen (s1) + strlen (s2) + 2))) == NULL)
                    736:        adios (NULLCP, "insufficient memory");
                    737: 
                    738:     (void) sprintf (p, "%s%s", s2, s1);
                    739:     if (s2)
                    740:        free (s2);
                    741:     return p;
                    742: }
                    743: 
                    744: 
                    745: static char *strdup (s)
                    746: char   *s;
                    747: {
                    748:     char   *p;
                    749: 
                    750:     if ((p = malloc ((unsigned) (strlen (s) + 1))) == NULL)
                    751:        adios (NULLCP, "insufficient memory");
                    752: 
                    753:     (void) strcpy (p, s);
                    754:     return p;
                    755: }
                    756: 
                    757: /*  */
                    758: 
                    759: static char *index (s, c)
                    760: char   *s,
                    761:         c;
                    762: {
                    763:     char    i;
                    764: 
                    765:     while (i = *s++)
                    766:        if (i == c)
                    767:            return (s - 1);
                    768: 
                    769:     return NULL;
                    770: }
                    771: 
                    772: 
                    773: static char *rindex (s, c)
                    774: char   *s,
                    775:         c;
                    776: {
                    777:     char    i,
                    778:            *t;
                    779: 
                    780:     t = NULL;
                    781:     while (i = *s++)
                    782:        if (i == c)
                    783:            t = s - 1;
                    784: 
                    785:     return t;
                    786: }
                    787: 
                    788: /*  */
                    789: 
                    790: /* VARARGS */
                    791: 
                    792: adios (what, fmt, a, b, c)
                    793: char   *what,
                    794:        *fmt,
                    795:        *a,
                    796:        *b,
                    797:        *c;
                    798: {
                    799:     (void) fflush (stdout);
                    800: 
                    801:     fprintf (stderr, "%s: ", myname);
                    802:     fprintf (stderr, fmt, a, b, c);
                    803:     if (what) {
                    804:        (void) fputc (' ', stderr);
                    805:        perror (what);
                    806:     }
                    807:     else
                    808:        (void) fputc ('\n', stderr);
                    809: 
                    810:     exit (1);
                    811: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.