Browse Source

* Improve genethumb --help message.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2601 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
5e97ce5d43
1 changed files with 28 additions and 3 deletions
  1. +28
    -3
      genethumb/genethumb.c

+ 28
- 3
genethumb/genethumb.c View File

@@ -20,24 +20,31 @@
# define myoption option
#endif

#define DEFAULT_WIDTH 120
#define DEFAULT_HEIGHT 90

#define MOREINFO "Try `%s --help' for more information.\n"

static void usage(void);

int main(int argc, char *argv[])
{
char *srcname = NULL, *dstname = NULL;
pipi_image_t *src, *dst;

int i, w = 0, h = 0, bpp = 24;
int i, w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT, bpp = 24;

for(;;)
{
int option_index = 0;
static struct myoption long_options[] =
{
{ "geometry", 1, NULL, 'g' },
{ "bpp", 1, NULL, 'b' },
{ "geometry", 1, NULL, 'g' },
{ "help", 0, NULL, 'h' },
{ NULL, 0, NULL, 0 },
};
int c = mygetopt(argc, argv, "g:b:", long_options, &option_index);
int c = mygetopt(argc, argv, "b:g:h", long_options, &option_index);

if(c == -1)
break;
@@ -57,6 +64,9 @@ int main(int argc, char *argv[])
if(strchr(myoptarg, 'x'))
h = atoi(strchr(myoptarg, 'x') + 1);
break;
case 'h':
usage();
return EXIT_SUCCESS;
default:
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
printf(MOREINFO, argv[0]);
@@ -96,3 +106,18 @@ int main(int argc, char *argv[])
return 0;
}

static void usage(void)
{
printf("Usage: genethumb [-b bpp] [-g geometry] SOURCE DESTINATION\n");
printf(" genethumb -h | --help\n");
printf("Create an image thumbnail.\n");
printf("\n");
printf("Mandatory arguments to long options are mandatory for short options too.\n");
printf(" -b, --bpp <bits> bits per pixel (32 or 16)\n");
printf(" -g, --geometry <geometry> target geometry (default %ix%i)\n",
DEFAULT_WIDTH, DEFAULT_HEIGHT);
printf(" -h, --help display this help and exit\n");
printf("\n");
printf("Written by Sam Hocevar. Report bugs to <sam@zoy.org>.\n");
}


Loading…
Cancel
Save