diff options
author | axel <axel@liljencrantz.se> | 2006-02-23 01:41:52 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-02-23 01:41:52 +1000 |
commit | ca04fc745d5212ec2d5bf70271fd5aa8dc2320e6 (patch) | |
tree | 6936241f8b07dc11be9807aec22fbeff0428b328 /main.c | |
parent | 3afead182710c7e45981707d22bebb8a1518f047 (diff) |
Add some input validation code to various functions
darcs-hash:20060222154152-ac50b-608032284165f099beecd1cd4f7c6bb2b45df432.gz
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -123,6 +123,10 @@ int main( int argc, char **argv ) } , { + "debug-level", required_argument, 0, 'd' + } + , + { "interactive", no_argument, 0, 'i' } , @@ -152,14 +156,14 @@ int main( int argc, char **argv ) int opt = getopt_long( argc, argv, - "hilvc:p:", + "hilvc:p:d:", long_options, &opt_index ); #else int opt = getopt( argc, argv, - "hilvc:p:" ); + "hilvc:p:d:" ); #endif if( opt == -1 ) break; @@ -174,6 +178,22 @@ int main( int argc, char **argv ) is_interactive_session = 0; break; + case 'd': + { + char *end; + int tmp = strtol(optarg, &end, 10); + if( tmp >= 0 && tmp <=10 && !*end ) + { + debug_level=tmp; + } + else + { + debug( 0, _(L"Invalid value '%s' for debug level switch"), optarg ); + exit(1); + } + break; + } + case 'h': cmd = "help"; break; @@ -233,7 +253,7 @@ int main( int argc, char **argv ) wchar_t *cmd_wcs = str2wcs( cmd ); res = eval( cmd_wcs, 0, TOP ); free(cmd_wcs); - reader_exit(0); + reader_exit(0); } else { |