date and time created 81/02/24 15:51:22 by toy
authorMichael Toy <toy@ucbvax.Berkeley.EDU>
Wed, 25 Feb 1981 07:51:22 +0000 (23:51 -0800)
committerMichael Toy <toy@ucbvax.Berkeley.EDU>
Wed, 25 Feb 1981 07:51:22 +0000 (23:51 -0800)
SCCS-vsn: usr.sbin/config/main.c 1.1

usr/src/usr.sbin/config/main.c [new file with mode: 0644]

diff --git a/usr/src/usr.sbin/config/main.c b/usr/src/usr.sbin/config/main.c
new file mode 100644 (file)
index 0000000..3c1358a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * main.c      1.1     81/02/24
+ * Config
+ *     Do system configuration for VAX/UNIX
+ *             1) Build system data structures
+ *             2) Build makefile
+ *             3) Create header files for devices
+ *     Michael Toy -- Berkeley -- 1981
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#include "y.tab.h"
+#include "config.h"
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+    if (argc != 2)
+    {
+       fprintf(stderr, "usage: config <sysname>\n");
+       exit(1);
+    }
+    if (freopen(argv[1], "r", stdin) == NULL)
+    {
+       perror(argv[1]);
+       exit(2);
+    }
+    dtab = NULL;
+    if (yyparse())
+       exit(3);
+    else
+    {
+       ioconf();                       /* Print ioconf.c */
+       ubglue();                       /* Create ubglue.s */
+       makefile();                     /* build Makefile */
+       headers();                      /* make a lot of .h files */
+    }
+}
+
+/*
+ * get_word
+ *     returns EOF on end of file
+ *     NULL on end of line
+ *     pointer to the word otherwise
+ */
+
+char *get_word(fp)
+register FILE *fp;
+{
+    static char line[80];
+    register int ch;
+    register char *cp;
+
+    while((ch = getc(fp)) != EOF)
+       if (ch != ' ' && ch != '\t')
+           break;
+    if (ch == EOF)
+       return EOF;
+    if (ch == '\n')
+       return NULL;
+    cp = line;
+    *cp++ = ch;
+    while((ch = getc(fp)) != EOF)
+    {
+       if (isspace(ch))
+           break;
+       *cp++ = ch;
+    }
+    *cp = '\0';
+    if (ch == EOF)
+       return EOF;
+    ungetc(ch, fp);
+    return line;
+}