4 * Header: mk_cmds.c,v 1.6 89/01/25 07:47:26 raeburn Exp
6 * Copyright 1987, 1988 by MIT Student Information Processing Board
8 * For copyright information, see copyright.h.
11 #include "copyright.h"
13 #include <sys/param.h>
16 #include "ss_internal.h"
18 static const char copyright[] =
19 "Copyright 1987 by MIT Student Information Processing Board";
21 extern pointer malloc PROTOTYPE((unsigned));
22 extern char *last_token;
23 extern FILE *output_file;
25 extern FILE *yyin, *yyout;
31 fprintf(stderr, "usage: mk_cmds cmdtbl.ct\n");
40 char c_file[MAXPATHLEN];
47 path = malloc(strlen(argv[1])+4); /* extra space to add ".ct" */
48 strcpy(path, argv[1]);
49 p = rindex(path, '/');
50 if (p == (char *)NULL)
55 if (p == (char *)NULL || strcmp(p, ".ct"))
57 yyin = fopen(path, "r");
63 p = rindex(path, '.');
69 output_file = fopen(c_file, "w+");
75 fputs("/* ", output_file);
76 fputs(c_file, output_file);
77 fputs(" - automatically generated from ", output_file);
78 fputs(path, output_file);
79 fputs(" */\n", output_file);
80 fputs("#include <ss/ss.h>\n\n", output_file);
81 fputs("#ifndef __STDC__\n#define const\n#endif\n\n", output_file);
84 /* put file descriptors back where they belong */
85 fclose(yyin); /* bye bye input file */
86 fclose(output_file); /* bye bye output file */
96 fprintf(stderr, "\nLine %d; last token was '%s'\n",
97 yylineno, last_token);