2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
5 #pragma ident "%Z%%M% %I% %E% SMI"
12 * Copyright 1987, 1988 by MIT Student Information Processing Board
14 * For copyright information, see copyright.h.
17 #include "copyright.h"
19 #include <sys/param.h>
20 #include <sys/types.h>
23 #include "ss_internal.h"
25 static const char copyright
[] =
26 "Copyright 1987 by MIT Student Information Processing Board";
28 extern pointer
malloc (unsigned);
29 extern char *last_token
;
30 extern FILE *output_file
;
32 extern FILE *yyin
, *yyout
;
41 char c_file
[MAXPATHLEN
];
46 fputs("Usage: ", stderr
);
47 fputs(argv
[0], stderr
);
48 fputs("cmdtbl.ct\n", stderr
);
52 path
= malloc(strlen(argv
[1])+4); /* extra space to add ".ct" */
53 strcpy(path
, argv
[1]);
54 p
= strrchr(path
, '/');
55 if (p
== (char *)NULL
)
60 if (p
== (char *)NULL
|| strcmp(p
, ".ct"))
62 yyin
= fopen(path
, "rF");
68 p
= strrchr(path
, '.');
70 q
= rindex(path
, '/');
71 strncpy(c_file
, (q
) ? q
+ 1 : path
, sizeof(c_file
) - 1);
72 c_file
[sizeof(c_file
) - 1] = '\0';
73 strncat(c_file
, ".c", sizeof(c_file
) - 1 - strlen(c_file
));
76 output_file
= fopen(c_file
, "w+F");
82 fputs("/* ", output_file
);
83 fputs(c_file
, output_file
);
84 fputs(" - automatically generated from ", output_file
);
85 fputs(path
, output_file
);
86 fputs(" */\n", output_file
);
87 fputs("#include <ss/ss.h>\n\n", output_file
);
88 fputs("#ifndef __STDC__\n#define const\n#endif\n\n", output_file
);
91 /* put file descriptors back where they belong */
92 fclose(yyin
); /* bye bye input file */
93 fclose(output_file
); /* bye bye output file */
103 fprintf(stderr
, "\nLast token was '%s'\n", last_token
);
105 fprintf(stderr
, "\nLine %d; last token was '%s'\n",
106 yylineno
, last_token
);