# HG changeset patch # User Mahlon E. Smith # Date 1317225856 25200 # Node ID bdf20e6eefd778bd1728f568881be4c5c15b242f # Parent 8d0f25ef038ec0a91f3afcfa1a34b17f4a8074b0 Ansi-fy getopt function and variable declarations. diff -r 8d0f25ef038e -r bdf20e6eefd7 main.c --- a/main.c Wed Sep 28 09:04:16 2011 -0700 +++ b/main.c Wed Sep 28 09:04:16 2011 -0700 @@ -54,9 +54,11 @@ /* get_opt vars */ int opt = 0; - opterr = 0; + extern char *optarg; + extern int opterr, optind, optopt; /* parse options */ + opterr = 0; while ( (opt = getopt( argc, argv, "d:f:hv" )) != -1 ) { switch ( opt ) { diff -r 8d0f25ef038e -r bdf20e6eefd7 parser.c --- a/parser.c Wed Sep 28 09:04:16 2011 -0700 +++ b/parser.c Wed Sep 28 09:04:16 2011 -0700 @@ -1,5 +1,5 @@ -/* #line 1 "parser.rl" */ +#line 1 "parser.rl" /* vim: set noet nosta sw=4 ts=4 ft=ragel : */ /* Copyright (c) 2011, Mahlon E. Smith @@ -60,10 +60,10 @@ #include "volta.h" -/* #line 80 "parser.rl" */ +#line 80 "parser.rl" -/* #line 67 "parser.c" */ +#line 67 "parser.c" static const int redirector_start = 1; static const int redirector_first_final = 13; static const int redirector_error = 0; @@ -71,7 +71,7 @@ static const int redirector_en_main = 1; -/* #line 82 "parser.rl" */ +#line 82 "parser.rl" /* %%{ @@ -133,14 +133,14 @@ /* enter state machine */ -/* #line 137 "parser.c" */ +#line 137 "parser.c" { cs = redirector_start; } -/* #line 143 "parser.rl" */ +#line 143 "parser.rl" -/* #line 144 "parser.c" */ +#line 144 "parser.c" { if ( p == pe ) goto _test_eof; @@ -203,7 +203,7 @@ goto tr7; goto st0; tr7: -/* #line 68 "parser.rl" */ +#line 68 "parser.rl" { printf( "I saw: %s", p+1 ); } @@ -212,7 +212,7 @@ if ( ++p == pe ) goto _test_eof7; case 7: -/* #line 216 "parser.c" */ +#line 216 "parser.c" switch( (*p) ) { case 10: goto st13; case 43: goto st8; @@ -314,7 +314,7 @@ _out: {} } -/* #line 144 "parser.rl" */ +#line 144 "parser.rl" /* reset the request */ /* c_request = reset_request; */ diff -r 8d0f25ef038e -r bdf20e6eefd7 volta.h --- a/volta.h Wed Sep 28 09:04:16 2011 -0700 +++ b/volta.h Wed Sep 28 09:04:16 2011 -0700 @@ -85,6 +85,7 @@ * Function prototypes * */ +int getopt( int, char * const [], const char *); void usage( char *prg ); void debug( int level, char *file, int line, const char *fmt, ... );