- if( (optcode > -1) && (optcode != '?') )
- t->parse(optcode, (char **)opts, inv, &t->tflags, r->entry, &t->t);
+ opts = malloc(len * sizeof(*opts));
+ opts[0] = "x";
+
+ while( (s = (char *)va_arg(ap, char *)) != NULL )
+ {
+ opts = realloc(opts, ++len * sizeof(*opts));
+ opts[len-1] = s;
+ }
+
+ va_end(ap);
+
+ if( len > 1 )
+ {
+ optind = 0;
+
+ while( (optc = getopt_long(len, opts, "", t->extra_opts, NULL)) > -1 )
+ {
+ if( (optc == '?') && (optarg[0] == '!') && (optarg[1] == '\0') )
+ {
+ inv = 1;
+ continue;
+ }
+
+ t->parse(optc, opts, inv, &t->tflags, r->entry, &t->t);
+ }
+ }
+
+ free(opts);