we can list all the garbage...

This commit is contained in:
tth 2021-05-29 09:33:38 +02:00
parent 865cc60ccf
commit 17955bd303

View File

@ -49,8 +49,6 @@ Type *type;
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name); fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
#endif #endif
// #define TEST(str) ( ! strcmp(name, str) )
for (type = types; type->code; type++) { for (type = types; type->code; type++) {
if (!strcmp(name, type->name)) { if (!strcmp(name, type->name)) {
return type->code; return type->code;
@ -60,6 +58,16 @@ for (type = types; type->code; type++) {
return -1; return -1;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void list_types(void)
{
Type *type;
for (type = types; type->code; type++) {
puts(type->name);
}
exit(0);
}
/* --------------------------------------------------------------------- */
static void help(int lj) static void help(int lj)
{ {
int foo, cc; int foo, cc;
@ -67,6 +75,7 @@ int foo, cc;
puts("Usage:\tmkfimg [options] quux.fimg width height"); puts("Usage:\tmkfimg [options] quux.fimg width height");
puts("\t-k N.N\tgive a float parameter"); puts("\t-k N.N\tgive a float parameter");
puts("\t-L\tlist howto's");
fputs("\t-t bla\thowto make the pic :\n\t\t| ", stdout); fputs("\t-t bla\thowto make the pic :\n\t\t| ", stdout);
for (foo=cc=0; types[foo].code; foo++) { for (foo=cc=0; types[foo].code; foo++) {
@ -95,12 +104,13 @@ char *tname = "wtf?";
FloatImg fimg; FloatImg fimg;
while ((opt = getopt(argc, argv, "hk:t:v")) != -1) { while ((opt = getopt(argc, argv, "hk:Lt:v")) != -1) {
switch(opt) { switch(opt) {
case 'h': help(0); break; case 'h': help(0); break;
case 'k': fvalue = atof(optarg); break; case 'k': fvalue = atof(optarg); break;
case 't': type = get_type_by_name(tname=optarg); case 't': type = get_type_by_name(tname=optarg);
break; break;
case 'L': list_types(); break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
} }
} }