X-Git-Url: https://git.kengrimes.com/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fbin%2Ftools%2Fapc.c;h=2307ccc3f73b9dfa1916a2e7c20a9628a402170c;hp=a22975d6d55d8fc1f659ca3819ea40e35fb0a192;hb=301cac5f6e2edcecf2e1bd89aee5182130a213fc;hpb=c0288501d87f8aaacba73daee346e5adf71a9bd2 diff --git a/src/bin/tools/apc.c b/src/bin/tools/apc.c index a22975d..2307ccc 100644 --- a/src/bin/tools/apc.c +++ b/src/bin/tools/apc.c @@ -14,20 +14,27 @@ /* Standard */ #include //print #include //errors -#include //strnlen +#include //strndupa /* Posix */ #include //exit #include //getopt +/* Internal */ +#include //bison const char* cargs['Z'] = {0}; int main(int, char*[]); extern //bison -void yyparse(void); +int yyparse(void); extern //lexer.c int lexer_init(void); +extern //apc/parser.tab.c +YYSTYPE yylval; +extern //lexer.c +int lexer(void); + /* Main entry from terminal parses the command line and kicks off recursive scanning */ @@ -35,18 +42,24 @@ int main ( int argc, char* argv[] ) -#define S(S)#S //stringifier +#define $($)#$ //stringifier #define MAXSTR 255 -#define MAXERR "-%c allows at most " S(MAXSTR) " input characters\n", opt -#define USAGE "Usage: %s [-r root]\n", argv[0] +#define MAXERR "-%c allows at most " $(MAXSTR) " input characters\n", opt +#define OPTS "d:o:h-" +#define USAGE "Usage %s [-d dir_root][-o output_file][-h]\n", argv[0] +#define USAGE_LONG \ + "\tOptions:\n" \ + "\t\t-d\tRoot directory to parse from \t[./]\n" \ + "\t\t-o\tOutput filename \t\t[a.asspak]\n" \ + "\t\t-h\tPrint this help\n" #define DONE -1 { int opt; getopt: - switch (opt = getopt(argc, argv, "r:o:")) + switch (opt = getopt(argc, argv, OPTS)) { case DONE: break; - case 'r' : + case 'd' : case 'o' : if (strnlen(optarg, MAXSTR) != MAXSTR) { cargs[opt] = optarg; @@ -56,6 +69,10 @@ int main default : fprintf(stderr, USAGE); exit(EXIT_FAILURE); + case 'h' : + printf(USAGE); + printf(USAGE_LONG); + exit(EXIT_SUCCESS); } if (lexer_init()) { perror("lexer");