Changeset 2601
- Timestamp:
- Jul 29, 2008, 1:01:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/genethumb/genethumb.c
r2264 r2601 21 21 #endif 22 22 23 #define DEFAULT_WIDTH 120 24 #define DEFAULT_HEIGHT 90 25 23 26 #define MOREINFO "Try `%s --help' for more information.\n" 27 28 static void usage(void); 24 29 25 30 int main(int argc, char *argv[]) … … 28 33 pipi_image_t *src, *dst; 29 34 30 int i, w = 0, h = 0, bpp = 24;35 int i, w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT, bpp = 24; 31 36 32 37 for(;;) … … 35 40 static struct myoption long_options[] = 36 41 { 42 { "bpp", 1, NULL, 'b' }, 37 43 { "geometry", 1, NULL, 'g' }, 38 { "bpp", 1, NULL, 'b' }, 44 { "help", 0, NULL, 'h' }, 45 { NULL, 0, NULL, 0 }, 39 46 }; 40 int c = mygetopt(argc, argv, " g:b:", long_options, &option_index);47 int c = mygetopt(argc, argv, "b:g:h", long_options, &option_index); 41 48 42 49 if(c == -1) … … 58 65 h = atoi(strchr(myoptarg, 'x') + 1); 59 66 break; 67 case 'h': 68 usage(); 69 return EXIT_SUCCESS; 60 70 default: 61 71 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); … … 97 107 } 98 108 109 static void usage(void) 110 { 111 printf("Usage: genethumb [-b bpp] [-g geometry] SOURCE DESTINATION\n"); 112 printf(" genethumb -h | --help\n"); 113 printf("Create an image thumbnail.\n"); 114 printf("\n"); 115 printf("Mandatory arguments to long options are mandatory for short options too.\n"); 116 printf(" -b, --bpp <bits> bits per pixel (32 or 16)\n"); 117 printf(" -g, --geometry <geometry> target geometry (default %ix%i)\n", 118 DEFAULT_WIDTH, DEFAULT_HEIGHT); 119 printf(" -h, --help display this help and exit\n"); 120 printf("\n"); 121 printf("Written by Sam Hocevar. Report bugs to <sam@zoy.org>.\n"); 122 } 123
Note: See TracChangeset
for help on using the changeset viewer.