Changeset 1114
- Timestamp:
- Sep 27, 2006, 12:54:15 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/main.c
r1110 r1114 33 33 #include "filters.h" 34 34 35 static void version(void); 36 #if defined(HAVE_GETOPT_H) 37 static void usage(void); 38 #endif 39 35 40 int main(int argc, char *argv[]) 36 41 { … … 45 50 char const *export = "utf8"; 46 51 char const *font = "mono9"; 47 unsigned flag_gay = 0; 48 unsigned flag_metal = 0; 52 unsigned int flag_gay = 0; 53 unsigned int flag_metal = 0; 54 unsigned int term_width = 80; 55 int infocode = -1; 49 56 50 57 #if defined(HAVE_GETOPT_H) … … 58 65 /* Long option, needs arg, flag, short option */ 59 66 { "font", 1, NULL, 'f' }, 67 { "width", 1, NULL, 'w' }, 60 68 { "gay", 0, NULL, 'g' }, 61 69 { "metal", 0, NULL, 'm' }, 62 70 { "irc", 0, NULL, 'i' }, 63 71 { "help", 0, NULL, 'h' }, 72 { "infocode", 1, NULL, 'I' }, 64 73 { "version", 0, NULL, 'v' }, 65 74 { NULL, 0, NULL, 0 } 66 75 }; 67 76 68 int c = getopt_long(argc, argv, "f:gmihv", long_options, &option_index); 77 int c = getopt_long(argc, argv, "f:w:gmihI:v", 78 long_options, &option_index); 69 79 # else 70 80 # define MOREINFO "Try `%s -h' for more information.\n" 71 int c = getopt(argc, argv, "f: gmihv");81 int c = getopt(argc, argv, "f:w:gmihI:v"); 72 82 # endif 73 83 if(c == -1) … … 77 87 { 78 88 case 'h': /* --help */ 79 printf("Usage: %s [ -f:gmihv ] [ message ]\n", argv[0]); 80 # ifdef HAVE_GETOPT_LONG 81 printf(" -f, --font <fontfile>\n"); 82 printf(" select the font\n"); 83 printf(" -g, --gay add a rainbow effect to the text\n"); 84 printf(" -m, --metal add a metal effect to the text\n"); 85 printf(" -i, --irc output IRC colour codes\n"); 86 printf(" -h, --help display this help and exit\n"); 87 printf(" -v, --version output version information and exit\n"); 88 # else 89 printf(" -f <fontfile>\n"); 90 printf(" select the font\n"); 91 printf(" -g add a rainbow effect to the text\n"); 92 printf(" -m add a metal effect to the text\n"); 93 printf(" -i output IRC colour codes\n"); 94 printf(" -h display this help and exit\n"); 95 printf(" -v output version information and exit\n"); 96 # endif 97 return 0; 89 usage(); 90 return 0; 91 case 'I': /* --infocode */ 92 infocode = atoi(optarg); 93 break; 98 94 case 'v': /* --version */ 99 printf("TOIlet Copyright 2006 Sam Hocevar %s\n", VERSION); 100 printf("Internet: <sam@zoy.org> Version: 0, date: 21 Sep 2006\n"); 101 printf("\n"); 95 version(); 102 96 return 0; 103 97 case 'f': /* --font */ … … 109 103 case 'm': /* --metal */ 110 104 flag_metal = 1; 105 break; 106 case 'w': /* --width */ 107 term_width = atoi(optarg); 111 108 break; 112 109 case 'i': /* --irc */ … … 127 124 #endif 128 125 126 switch(infocode) 127 { 128 case -1: 129 break; 130 case 0: 131 version(); 132 return 0; 133 case 1: 134 printf("20201\n"); 135 return 0; 136 case 2: 137 printf("/usr/share/figlet\n"); 138 return 0; 139 case 3: 140 printf("mono9\n"); 141 return 0; 142 case 4: 143 printf("%u\n", term_width); 144 return 0; 145 default: 146 return 0; 147 } 148 129 149 if(optind >= argc) 130 150 { … … 187 207 } 188 208 209 static void version(void) 210 { 211 printf("TOIlet Copyright 2006 Sam Hocevar %s\n", VERSION); 212 printf("Internet: <sam@zoy.org> Version: 0, date: 21 Sep 2006\n"); 213 printf("\n"); 214 } 215 216 #if defined(HAVE_GETOPT_H) 217 static void usage(void) 218 { 219 printf("Usage: toilet [ -gmihv ] [ message ]\n"); 220 printf(" [ -f fontfile ] [ -w outputwidth ]\n"); 221 printf(" [ -I infocode ]\n"); 222 # ifdef HAVE_GETOPT_LONG 223 printf(" -f, --font <fontfile> select the font\n"); 224 printf(" -w, --width <width> set output width\n"); 225 printf(" -g, --gay add a rainbow effect to the text\n"); 226 printf(" -m, --metal add a metal effect to the text\n"); 227 printf(" -i, --irc output IRC colour codes\n"); 228 printf(" -h, --help display this help and exit\n"); 229 printf(" -I, --infocode print FIGlet-compatible infocode\n"); 230 printf(" -v, --version output version information and exit\n"); 231 # else 232 printf(" -f <fontfile> select the font\n"); 233 printf(" -w <width> set output width\n"); 234 printf(" -g add a rainbow effect to the text\n"); 235 printf(" -m add a metal effect to the text\n"); 236 printf(" -i output IRC colour codes\n"); 237 printf(" -h display this help and exit\n"); 238 printf(" -I print FIGlet-compatible infocode\n"); 239 printf(" -v output version information and exit\n"); 240 # endif 241 } 242 #endif 243
Note: See TracChangeset
for help on using the changeset viewer.