Annotation of researchv9/sys/conf/src/config/main.c, revision 1.1.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:     if (machine != MACHINE_VAX && machine != MACHINE_SUN2 &&
                     40:        machine != MACHINE_SUN3)
                     41:     {
                     42:                printf("Specify machine type, e.g. ``machine vax''\n");
                     43:                exit(1);
                     44:     }
                     45:     ioconf();                  /* Print ioconf.c */
                     46:     ubglue();                  /* Create ubglue.s */
                     47:     makefile();                        /* build Makefile */
                     48:     headers();                 /* make a lot of .h files */
                     49:     conf();                    /* Create conf.c */
                     50:     execlp("mk", "mk", "depend", NULL);
                     51:     perror("make");
                     52:     exit(1);
                     53: }
                     54: 
                     55: /*
                     56:  * get_word
                     57:  *     returns EOF on end of file
                     58:  *     NULL on end of line
                     59:  *     pointer to the word otherwise
                     60:  */
                     61: 
                     62: char *get_word(fp)
                     63: register FILE *fp;
                     64: {
                     65:     static char line[80];
                     66:     register int ch;
                     67:     register char *cp;
                     68: 
                     69:     while((ch = getc(fp)) != EOF)
                     70:        if (ch != ' ' && ch != '\t')
                     71:            break;
                     72:     if (ch == EOF)
                     73:        return WEOF;
                     74:     if (ch == '\n')
                     75:        return NULL;
                     76:     cp = line;
                     77:     *cp++ = ch;
                     78:     while((ch = getc(fp)) != EOF)
                     79:     {
                     80:        if (isspace(ch))
                     81:            break;
                     82:        *cp++ = ch;
                     83:     }
                     84:     *cp = '\0';
                     85:     if (ch == EOF)
                     86:        return WEOF;
                     87:     ungetc(ch, fp);
                     88:     return line;
                     89: }
                     90: 
                     91: /*
                     92:  * change a pathname to point to where
                     93:  * our global data files live
                     94:  */
                     95: 
                     96: char *
                     97: gpath(file)
                     98: char *file;
                     99: {
                    100:     register char *cp;
                    101: 
                    102:     if ((cp = malloc(strlen(file)+8+1)) == NULL) {
                    103:        fprintf(stderr, "out of memory\n");
                    104:        exit(1);
                    105:     }
                    106:     strcpy(cp, "../conf/");
                    107:     strcat(cp, file);
                    108:     return cp;
                    109: }

unix.superglobalmegacorp.com

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