[Bug 681] Handlers filenames and syntax versions

Kevin P. Fleming kpfleming at linuxfromscratch.org
Tue Sep 30 10:45:21 PDT 2003


Here's a compile&run-tested simple example to show how it would really 
be done (the array initialization did not work as I originally posted):

#include <stdlib.h>

struct foo {
   char *name;
   char **parameters;
};

char *foo1params[] = {"param1", "param2", NULL};
char *foo2params[] = {"foo2", "foo22", NULL};

struct foo foos[] = {
   { .name = "foo1",
     .parameters = foo1params
   },
   { .name = "foo2",
     .parameters = foo2params
   },
   { .name = NULL
   }
};

int main() {
   struct foo *s;
   char **c;

   for (s = foos; s->name != NULL; s++)
     {
       printf("name: %s\n", s->name);
       for (c = s->parameters; *c != NULL; c++) {
	printf("\tparam: %s\n", *c);
       }
     }

   return 0;
}





More information about the alfs-log mailing list