Commit | Line | Data |
---|---|---|
ca5d0476 MT |
1 | /* |
2 | * main.c 1.1 81/02/24 | |
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 | if (argc != 2) | |
21 | { | |
22 | fprintf(stderr, "usage: config <sysname>\n"); | |
23 | exit(1); | |
24 | } | |
25 | if (freopen(argv[1], "r", stdin) == NULL) | |
26 | { | |
27 | perror(argv[1]); | |
28 | exit(2); | |
29 | } | |
30 | dtab = NULL; | |
31 | if (yyparse()) | |
32 | exit(3); | |
33 | else | |
34 | { | |
35 | ioconf(); /* Print ioconf.c */ | |
36 | ubglue(); /* Create ubglue.s */ | |
37 | makefile(); /* build Makefile */ | |
38 | headers(); /* make a lot of .h files */ | |
39 | } | |
40 | } | |
41 | ||
42 | /* | |
43 | * get_word | |
44 | * returns EOF on end of file | |
45 | * NULL on end of line | |
46 | * pointer to the word otherwise | |
47 | */ | |
48 | ||
49 | char *get_word(fp) | |
50 | register FILE *fp; | |
51 | { | |
52 | static char line[80]; | |
53 | register int ch; | |
54 | register char *cp; | |
55 | ||
56 | while((ch = getc(fp)) != EOF) | |
57 | if (ch != ' ' && ch != '\t') | |
58 | break; | |
59 | if (ch == EOF) | |
60 | return EOF; | |
61 | if (ch == '\n') | |
62 | return NULL; | |
63 | cp = line; | |
64 | *cp++ = ch; | |
65 | while((ch = getc(fp)) != EOF) | |
66 | { | |
67 | if (isspace(ch)) | |
68 | break; | |
69 | *cp++ = ch; | |
70 | } | |
71 | *cp = '\0'; | |
72 | if (ch == EOF) | |
73 | return EOF; | |
74 | ungetc(ch, fp); | |
75 | return line; | |
76 | } |