⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mhconfig.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
    if (strcmp (bboards, "nntp") == 0)	fprintf (fp, "/^@BEGIN: NNTP$/d\n/^@END: NNTP$/d\n");    else	fprintf (fp, "/^@BEGIN: NNTP$/,/^@END: NNTP$/d\n");    if (strcmp (mf, "on") == 0)	fprintf (fp, "/^@BEGIN: MF$/d\n/^@END: MF$/d\n");    else	fprintf (fp, "/^@BEGIN: MF$/,/^@END: MF$/d\n");    fprintf (fp, "s%%@(MHREMOVE)%%%s%%g\n", SVAL (removeit));    (void) fclose (fp);}/*  */static  do_files () {    char  **pp;    for (pp = files; *pp; pp++)	shell ("rm -f %s; sed -f %s < config/%s > %s",		*pp, SED, tail (*pp), *pp);}static  do_doc () {    shell ("./mhdoc");}static  do_make () {    char    buffer[BUFSIZ];    struct pair *pp;    for (pp = makefiles; pp -> infile; pp++) {	(void) sprintf (buffer, MAKE, pp -> outfile);	shell ("rm -f %s; sed -f %s < %s > %s",		buffer, SED, pp -> infile, buffer);    }}/*  *//* VARARGS */static  shell (fmt, a, b, c, d)char   *fmt,       *a,       *b,       *c,       *d;{    char    buffer[BUFSIZ];    (void) sprintf (buffer, fmt, a, b, c, d);    printf ("%s\n", buffer);    (void) fflush (stdout);    if (system (buffer))	adios (NULLCP, "failed");}/*  */static  arginit (vec)char  **vec;{    int	    i;    char   *ap,           *cp,           *dp,           *config,            buffer[BUFSIZ];    struct bind *bp;    FILE * fp;    myname = tail (*vec);    printf (BANNER, myname);    (void) fflush (stdout);        for (vec++; *vec; vec++) {	if (strcmp (*vec, "-D") == 0) {	    sedP = 1; filesP = makeP = 0; docP = 2;	    continue;	}	if (strcmp (*vec, "-s") == 0) {	    sedP = !sedP;	    continue;	}	if (strcmp (*vec, "-f") == 0) {	    filesP = !filesP;	    continue;	}	if (strcmp (*vec, "-d") == 0) {	    docP = !docP;	    continue;	}	if (strcmp (*vec, "-m") == 0) {	    makeP = !makeP;	    continue;	}	if (strcmp (*vec, "-help") == 0) {	    printf ("usage: %s [opt] file\n", myname);	    printf ("%s\n%s\n%s\n%s\n",		" -s\tno sed files", " -f\tno config files",		" -d\tno doc files", " -m\tno makefiles");	    exit (0);	}	break;    }    if ((config = *vec++) == NULL || *vec != NULL)	adios (NULLCP, "usage: %s file", myname);    if ((fp = fopen (config, "r")) == NULL)	adios (config, "unable to read");    while (fgets (buffer, sizeof buffer, fp)) {	if (ap = index (buffer, '\n'))	    *ap-- = NULL;	else	    ap = &buffer[strlen (buffer) - 1];	while (ap >= buffer)	    if (isspace (*ap))		*ap = NULL;	    else		break;	for (cp = buffer; isspace (*cp); cp++)	    continue;	if (*cp == NULL || *cp == '#')	    continue;	for (ap = cp; *ap; ap++)	    if (isspace (*ap)) {		*ap++ = NULL;		while (isspace (*ap))		    ap++;		break;	    }	for (bp = binds; bp -> keyword; bp++)	    if (strcmp (bp -> keyword, cp) == 0)		break;	if (bp -> keyword == NULL)	    adios (NULLCP, "unknown option %s in %s", cp, config);	else	    if (*(bp -> value) == NULL || !(bp -> flags & BD_ADD))		*(bp -> value) = strdup (ap);	    else		*(bp -> value) = stradd (ap, stradd (" ", *(bp -> value)));    }    (void) fclose (fp);/*  */    if (binpath == NULL)	adios (NULLCP, "bin must be specified in %s", config);    trim (binpath);    if (strcmp (bboards, "on") && strcmp (bboards, "off") &&        strcmp (bboards, "pop") && strcmp (bboards, "nntp"))	adios (NULLCP, "bboards should be %s not %s",		"either \"on\", \"off\", \"pop\" or \"nntp\"", bboards);    if (strcmp (bboards, "off") == 0 && strcmp (bbdelivery, "off"))	adios (NULLCP, 	    "you cannot have \"bbdelivery\" \"%s\" with \"bboards\" \"%s\"",	    bbdelivery, bboards);    if (bbhome == NULL)	adios (NULLCP, "bbhome must be specified in %s", config);    trim (bbhome);    if (strcmp (debug, "on") && strcmp (debug, "off"))	adios (NULLCP, "debug should be either \"on\" or \"off\", not %s",		debug);    if (etcpath == NULL)	adios (NULLCP, "etc must be specified in %s", config);    trim (etcpath);    if (mailpath == NULL)	adios (NULLCP, "mail must be specified in %s", config);    trim (mailpath);    if (*mailpath == '/')	maildir = mailpath;    else	mailfile = mailpath;    if (strcmp (manuals, "standard")	    && strcmp (manuals, "local")	    && strcmp (manuals, "new")	    && strcmp (manuals, "old")	    && strcmp (manuals, "gen")	    && strcmp (manuals, "none"))	adios (NULLCP,"invalid manuals setting: %s",manuals);    if (mts == NULL)	adios (NULLCP, "mts must be specified in %s", config);    for (i = 0; mtsopts[i].mtskey; i++)	if (strcmp (mts, mtsopts[i].mtskey) == 0)	    break;    if ((mtsnum = mtsopts[i].code) == unknown)	adios (NULLCP, "invalid mts setting: %s", mts);    add_option (mtsopts[i].optval);    smtp = mtsopts[i].mtsflags & DOSMTP;    if (mtsopts[i].mtsflags & NOMF)	mf = "off";		/* hack... */    if (strcmp (pop, "on") && strcmp (pop, "off"))	adios (NULLCP, "pop should be either \"on\" or \"off\", not %s", pop);    if (strcmp (pop, "on") == 0)	add_option ("POP");    if (strcmp (x400, "on") && strcmp (x400, "off"))	adios (NULLCP, "x400 should be either \"on\" or \"off\", not %s", x400);    if (strcmp (x400, "on") == 0)	add_option ("X400");    if (strcmp (bboards, "pop") == 0) {	add_option ("BPOP");	if (strcmp (pop, "on"))	    adios (NULLCP, "bboards \"pop\" requires pop \"on\"");    }    else if (strcmp (bboards, "nntp") == 0) {	add_option ("BPOP");/* used by msh.c & bbc.c, but see also pshsbr.c */	add_option ("NNTP");    }    if (strcmp (mf, "on") && strcmp (mf, "off"))	adios (NULLCP, "mf should be either \"on\" or \"off\", not %s", mf);    if (strcmp (mf, "on") == 0)	add_option ("MF");    if (sprntf && strcmp (sprntf, "char *")) {/* this defaults to "char *" */	if (strcmp (sprntf, "int"))	    adios (NULLCP,		    "sprintf should be either \"int\" or \"char *\", not %s",		    sprntf);	add_option ("SPRINTFTYPE=int");    }    if (strcmp (sharedlib, "on") && strcmp (sharedlib, "off"))	adios (NULLCP, "sharedlib should be either \"on\" or \"off\", not %s",		sharedlib);    if (strcmp (tma, "on") && strcmp (tma, "off"))	adios (NULLCP, "tma should be either \"on\" or \"off\", not %s", tma);    if (strcmp (tma, "on") == 0)	add_option ("TMA");    begin_myopt ();    if (cp = options) {	for (ap = cp; *ap; ap++)	    if (isspace (*ap))		*ap = ' ';	options = NULL;	for (ap = cp; dp = index (ap, ' '); ap = dp) {	    *dp++ = NULL;	    add_myopt (ap);	    (void) sprintf (buffer, "%s-D%s", options ? " " : "", ap);	    ap = buffer;	    options = stradd (ap, options);	    while (isspace (*dp))		dp++;	}	if (*ap) {	    add_myopt (ap);	    (void) sprintf (buffer, "%s-D%s", options ? " " : "", ap);	    ap = buffer;	    options = stradd (ap, options);	}	free (cp);    }    end_myopt ();}/*  */static  add_option (s)char   *s;{    options = options ? stradd (s, stradd (" ", options)) : strdup (s);}begin_myopt () {    myopts = strdup ("char *options[] = {");}add_myopt (s)char   *s;{    int     len;    char   *bp,            buffer[BUFSIZ];    static int  nameoutput = 0;    static int  linepos = 0;    static int  outputlinelen = 72;    if (smtp && strcmp (s, "BERK") == 0) {	fprintf (stderr, "\"options BERK\" overriding smtp suffix...\n");	smtp = 0;    }    if (strcmp (s, "UCI") == 0) uci = 1;    if (strcmp (s, "BSD43") == 0) bsd43 = 1;    if (!nameoutput) {	printf ("%s: ", bp = "options");	linepos += (nameoutput = strlen (bp) + 2);    }    len = strlen (s);    if (linepos != nameoutput)	if (len + linepos + 3 > outputlinelen)	    printf ("\n%*s", linepos = nameoutput, "");	else	    printf (" "), linepos++;    printf ("[%s]", s);    linepos += len + 2;    (void) fflush (stdout);    bp = buffer;    *bp++ = '"';    while (*s) {	if (*s == '"')	    *bp++ = QUOTE, *bp++ = QUOTE;	*bp++ = *s++;    }    (void) strcpy (bp, "\", ");    myopts = stradd (buffer, myopts);}end_myopt () {    printf ("\n");    (void) fflush (stdout);    myopts = stradd ("NULL};", myopts);}/*  */static  trim (s)char   *s;{    char   *p;    if (s == NULL || (p = rindex (s, '/')) == NULL)	return;    if (*++p == NULL)	*--p = NULL;}static char *tail (s)char   *s;{    char   *p;    if (p = rindex (s, '/'))	p++;    return ((p == NULL || *p == NULL) ? s : p);}/*  */static char *stradd (s1, s2)char   *s1,       *s2;{    char   *p;    if (s1 == NULL || *s1 == NULL)	return s2;    if (s2 == NULL)	return strdup (s1);    if ((p = malloc ((unsigned) (strlen (s1) + strlen (s2) + 2))) == NULL)	adios (NULLCP, "insufficient memory");    (void) sprintf (p, "%s%s", s2, s1);    if (s2)	free (s2);    return p;}static char *strdup (s)char   *s;{    char   *p;    if ((p = malloc ((unsigned) (strlen (s) + 1))) == NULL)	adios (NULLCP, "insufficient memory");    (void) strcpy (p, s);    return p;}/*  */#ifdef	notdef/* these used to be for SYS5 machines, but now this is compiled * with -DSYS5 which redefines the SYS5 str[r]chr names to [r]index. */static char *index (s, c)char   *s,        c;{    char    i;    while (i = *s++)	if (i == c)	    return (s - 1);    return NULL;}static char *rindex (s, c)char   *s,        c;{    char    i,           *t;    t = NULL;    while (i = *s++)	if (i == c)	    t = s - 1;    return t;}#endif	notdef/*  *//* VARARGS */adios (what, fmt, a, b, c)char   *what,       *fmt,       *a,       *b,       *c;{    (void) fflush (stdout);    fprintf (stderr, "%s: ", myname);    fprintf (stderr, fmt, a, b, c);    if (what) {	(void) fputc (' ', stderr);	perror (what);    }    else	(void) fputc ('\n', stderr);    exit (1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -