This commit is contained in:
tth 2021-05-12 16:45:30 +02:00
parent 5b934abd0a
commit 92b7eb478c
1 changed files with 12 additions and 6 deletions

View File

@ -21,7 +21,7 @@ int verbosity;
#define T_VDEG_A 5
#define T_TPAT0 6
#define T_MIRCOL1 7
#define T_BLOUP 8
typedef struct {
int code;
char *name;
@ -36,10 +36,11 @@ Type types[] = {
{ T_VDEG_A, "vdeg" },
{ T_TPAT0, "tpat0" },
{ T_MIRCOL1, "mircol1" },
{ T_BLOUP, "bloup" },
{ 0, NULL }
};
static int get_type(char *name)
static int get_type_by_name(char *name)
{
Type *type;
@ -65,10 +66,13 @@ int foo, cc;
puts("Usage:\tmkfimg [options] quux.fimg width height");
puts("\t-k N.N\tgive a float parameter");
fputs("\t-t bla\thowto make the pic :\n\t\t", stdout);
for (foo=0; types[foo].code; foo++) {
printf("%s ", types[foo].name);
fputs("\t-t bla\thowto make the pic :\n\t\t| ", stdout);
for (foo=cc=0; types[foo].code; foo++) {
cc += printf("%s ", types[foo].name);
if (cc>42) { cc=0; printf("\n\t\t| "); }
}
puts("\n\t-v\tincrease verbosity");
if (verbosity) {
@ -94,7 +98,8 @@ while ((opt = getopt(argc, argv, "hk:t:v")) != -1) {
switch(opt) {
case 'h': help(0); break;
case 'k': fvalue = atof(optarg); break;
case 't': type = get_type(tname=optarg); break;
case 't': type = get_type_by_name(tname=optarg);
break;
case 'v': verbosity++; break;
}
}
@ -154,6 +159,7 @@ switch(type) {
case T_VDEG_A: fimg_vdeg_a(&fimg, 1.0); break;
case T_TPAT0: fimg_test_pattern(&fimg, 0, fvalue); break;
case T_MIRCOL1: fimg_mircol_1(&fimg, fvalue); break;
case T_BLOUP: fimg_draw_something(&fimg); break;
case -1: exit(1);
}