frobnicate parameters handling

This commit is contained in:
tTh 2023-04-28 00:02:04 +02:00
parent 85f1867424
commit 895e61cbb6

View File

@ -73,13 +73,13 @@ return 0; /* allway success ? */
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* EXPERIMENTAL GRUIK-CODE !!! */ /* EXPERIMENTAL GRUIK-CODE !!! */
int load_and_printf_evblob(char *filename, int mode) int load_and_printf_evblob(char *filename, char *outmode)
{ {
EdgesAndVertices eav; EdgesAndVertices eav;
int foo; int foo, mode;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, filename, mode); fprintf(stderr, ">>> %s ( '%s' %s )\n", __func__, filename, outmode);
#endif #endif
memset(&eav, 0, sizeof(EdgesAndVertices)); memset(&eav, 0, sizeof(EdgesAndVertices));
@ -98,13 +98,17 @@ if (verbosity > 1) {
eav.Elist->fidx); eav.Elist->fidx);
} }
mode = 666;
if (! strcasecmp("edges", outmode)) { mode = 0; }
else if (! strcasecmp("vertices", outmode)) { mode = 1; }
switch (mode) { switch (mode) {
case 0: case 0:
printf_the_edges(&eav); break; printf_the_edges(&eav); break;
case 1: case 1:
printf_the_vertices(&eav); break; printf_the_vertices(&eav); break;
default: default:
fprintf(stderr, "no way to do %d\n", mode); fprintf(stderr, "no way to do '%s'\n", outmode);
exit(1); exit(1);
break; break;
} }
@ -124,7 +128,7 @@ exit(0);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int opt, foo; int opt, foo;
int outmode = 0; char *outmode = "vertices";
fprintf(stderr, "### Export EVblob (%s %s)\n", __DATE__, __TIME__); fprintf(stderr, "### Export EVblob (%s %s)\n", __DATE__, __TIME__);
@ -137,11 +141,8 @@ while ((opt = getopt(argc, argv, "ht:v")) != -1) {
case 'v': case 'v':
verbosity++; break; verbosity++; break;
case 't': case 't':
// fprintf(stderr, "t -> %s\n", optarg); fprintf(stderr, "type -> '%s'\n", optarg);
switch(optarg[0]) { outmode = optarg;
case 'e': outmode=0; break;
case 'v': outmode=1; break;
}
break; break;
default: default:
exit(1); exit(1);