Changeset 392 for pwntcha/trunk/src/main.c
- Timestamp:
- Jan 4, 2005, 12:26:29 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pwntcha/trunk/src/main.c
r391 r392 14 14 #include <string.h> 15 15 #include <getopt.h> 16 #include <stdarg.h> 16 17 17 18 #include "config.h" … … 24 25 #endif 25 26 27 /* Used for the debug messages */ 28 char *argv0 = NULL; 29 int debug = 1; 30 26 31 int main(int argc, char *argv[]) 27 32 { 28 33 char *mode = "auto"; 34 35 argv0 = argv[0]; 29 36 30 37 int c; … … 40 47 { "mode", 1, 0, 'm' }, 41 48 { "help", 0, 0, 'h' }, 49 { "quiet", 0, 0, 'q' }, 42 50 { "version", 0, 0, 'v' }, 43 51 { 0, 0, 0, 0 } 44 52 }; 45 53 46 c = getopt_long(argc, argv, "hm: v", long_options, &option_index);54 c = getopt_long(argc, argv, "hm:qv", long_options, &option_index); 47 55 #else 48 c = getopt(argc, argv, "hm: v");56 c = getopt(argc, argv, "hm:qv"); 49 57 #endif 50 58 if(c == -1) … … 57 65 #ifdef HAVE_GETOPT_LONG 58 66 printf(" -m, --mode force operating mode\n"); 67 printf(" -q, --quiet do not print information messages\n"); 59 68 printf(" -h, --help display this help and exit\n"); 60 69 printf(" -v, --version output version information and exit\n"); 61 70 #else 62 71 printf(" -m force operating mode\n"); 72 printf(" -q do not print information messages\n"); 63 73 printf(" -h display this help and exit\n"); 64 74 printf(" -v output version information and exit\n"); … … 67 77 case 'm': /* --mode */ 68 78 mode = optarg; 79 break; 80 case 'q': /* --quiet */ 81 debug = 0; 69 82 break; 70 83 case 'v': /* --version */ … … 101 114 if(!img) 102 115 { 103 fprintf(stderr, "%s: cannot load %s\n", argv[0], input);116 dprintf("cannot load %s\n", input); 104 117 printf("\n"); 105 118 continue; … … 115 128 { 116 129 if(img->width == 320 && img->height == 50) 130 { 131 dprintf("autodetecting phpBB captcha\n"); 117 132 result = decode_phpbb(img); 133 } 118 134 else if(img->height == 69) 135 { 136 dprintf("autodetecting slashdot captcha\n"); 119 137 result = decode_slashdot(img); 138 } 120 139 else 121 140 { 122 fprintf(stderr, "%s: could not guess captcha type\n", argv[0]);141 dprintf("could not guess captcha type\n"); 123 142 printf("\n"); 124 143 image_free(img); … … 131 150 if(!result) 132 151 { 133 fprintf(stderr, "%s: sorry, decoding failed\n", argv[0]);152 dprintf("sorry, decoding failed\n"); 134 153 printf("\n"); 135 154 continue; … … 143 162 } 144 163 164 void dprintf(const char *fmt, ...) 165 { 166 va_list args; 167 168 if(!debug) 169 return; 170 171 va_start(args, fmt); 172 fprintf(stderr, "%s: ", argv0); 173 vfprintf(stderr, fmt, args); 174 va_end(args); 175 } 176
Note: See TracChangeset
for help on using the changeset viewer.