Annotation of researchv9/sys.vax/conf/src/config/main.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * main.c      1.4     81/03/09
        !             3:  * Config
        !             4:  *     Do system configuration for VAX/UNIX
        !             5:  *             1) Build system data structures
        !             6:  *             2) Build makefile
        !             7:  *             3) Create header files for devices
        !             8:  *     Michael Toy -- Berkeley -- 1981
        !             9:  */
        !            10: 
        !            11: #include <stdio.h>
        !            12: #include <ctype.h>
        !            13: #include "y.tab.h"
        !            14: #include "config.h"
        !            15: 
        !            16: main(argc, argv)
        !            17: int argc;
        !            18: char **argv;
        !            19: {
        !            20: 
        !            21:     if (argc > 1) {
        !            22:        if (chdir("..") < 0) {
        !            23:            perror("..");
        !            24:            exit(1);
        !            25:        }
        !            26:        if (chdir(argv[1]) < 0) {
        !            27:            perror(argv[1]);
        !            28:            exit(1);
        !            29:        }
        !            30:     }
        !            31:     if (freopen(LOCAL("conf"), "r", stdin) == NULL)
        !            32:     {
        !            33:        perror(LOCAL("conf"));
        !            34:        exit(2);
        !            35:     }
        !            36:     dtab = NULL;
        !            37:     if (yyparse())
        !            38:        exit(3);
        !            39:     ioconf();                  /* Print ioconf.c */
        !            40:     ubglue();                  /* Create ubglue.s */
        !            41:     makefile();                        /* build Makefile */
        !            42:     headers();                 /* make a lot of .h files */
        !            43:     conf();                    /* Create conf.c */
        !            44:     execlp("mk", "mk", "depend", NULL);
        !            45:     perror("make");
        !            46:     exit(1);
        !            47: }
        !            48: 
        !            49: /*
        !            50:  * get_word
        !            51:  *     returns EOF on end of file
        !            52:  *     NULL on end of line
        !            53:  *     pointer to the word otherwise
        !            54:  */
        !            55: 
        !            56: char *get_word(fp)
        !            57: register FILE *fp;
        !            58: {
        !            59:     static char line[80];
        !            60:     register int ch;
        !            61:     register char *cp;
        !            62: 
        !            63:     while((ch = getc(fp)) != EOF)
        !            64:        if (ch != ' ' && ch != '\t')
        !            65:            break;
        !            66:     if (ch == EOF)
        !            67:        return WEOF;
        !            68:     if (ch == '\n')
        !            69:        return NULL;
        !            70:     cp = line;
        !            71:     *cp++ = ch;
        !            72:     while((ch = getc(fp)) != EOF)
        !            73:     {
        !            74:        if (isspace(ch))
        !            75:            break;
        !            76:        *cp++ = ch;
        !            77:     }
        !            78:     *cp = '\0';
        !            79:     if (ch == EOF)
        !            80:        return WEOF;
        !            81:     ungetc(ch, fp);
        !            82:     return line;
        !            83: }
        !            84: 
        !            85: /*
        !            86:  * change a pathname to point to where
        !            87:  * our global data files live
        !            88:  */
        !            89: 
        !            90: char *
        !            91: gpath(file)
        !            92: char *file;
        !            93: {
        !            94:     register char *cp;
        !            95: 
        !            96:     if ((cp = malloc(strlen(file)+8+1)) == NULL) {
        !            97:        fprintf(stderr, "out of memory\n");
        !            98:        exit(1);
        !            99:     }
        !           100:     strcpy(cp, "../conf/");
        !           101:     strcat(cp, file);
        !           102:     return cp;
        !           103: }

unix.superglobalmegacorp.com

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