--- lmtp2nntp_config.c 2002/01/17 17:01:55 1.9
+++ lmtp2nntp_config.c 2002/01/21 16:21:16 1.10
@@ -113,39 +113,39 @@
{
switch (type) {
case VAL_TYPE_VAL:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_VAL, desc=<%20s>, data@%.8lx INTERNAL\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_VAL, desc=<%20s>, data@%.8lx INTERNAL\n",
(char *)ctx, name, desc, (long)data);
break;
case VAL_TYPE_PTR:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_PTR, desc=<%20s>, data@%.8lx=%.8lx\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_PTR, desc=<%20s>, data@%.8lx=%.8lx\n",
(char *)ctx, name, desc, (long)data, *(long *)data);
break;
case VAL_TYPE_CHAR:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_CHAR, desc=<%20s>, data@%.8lx='%c'\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_CHAR, desc=<%20s>, data@%.8lx='%c'\n",
(char *)ctx, name, desc, (long)data, *(char *)data);
break;
case VAL_TYPE_SHORT:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_SHORT, desc=<%20s>, data@%.8lx=%8d\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_SHORT, desc=<%20s>, data@%.8lx=%8d\n",
(char *)ctx, name, desc, (long)data, *(short *)data);
break;
case VAL_TYPE_INT:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_INT, desc=<%20s>, data@%.8lx=%8d\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_INT, desc=<%20s>, data@%.8lx=%8d\n",
(char *)ctx, name, desc, (long)data, *(int *)data);
break;
case VAL_TYPE_LONG:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_LONG, desc=<%20s>, data@%.8lx=%8ld\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_LONG, desc=<%20s>, data@%.8lx=%8ld\n",
(char *)ctx, name, desc, (long)data, *(long *)data);
break;
case VAL_TYPE_FLOAT:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_FLOAT, desc=<%20s>, data@%.8lx=%8f\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_FLOAT, desc=<%20s>, data@%.8lx=%8f\n",
(char *)ctx, name, desc, (long)data, *(float *)data);
break;
case VAL_TYPE_DOUBLE:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, VAL_TYPE_DOUBLE, desc=<%20s>, data@%.8lx=%8f\n",
+ printf("DEBUG: <%10s>, name=<%10s>, VAL_TYPE_DOUBLE, desc=<%20s>, data@%.8lx=%8f\n",
(char *)ctx, name, desc, (long)data, *(double *)data);
break;
default:
- fprintf(stderr, "DEBUG: <%10s>, name=<%10s>, type = %.8lx, desc=<%20s>, data@%.8lx\n",
+ printf("DEBUG: <%10s>, name=<%10s>, type = %.8lx, desc=<%20s>, data@%.8lx\n",
(char *)ctx, name, (long)type, desc, (long)data);
}
@@ -160,164 +160,10 @@
void dotconftest(int argc, char **argv) /*FIXME*/
{
- popt_context poptCon; /* context for parsing command-line options */
- lmtp2nntp_config_t *ctx;
- char *cpBuf;
- struct popt_option poptTable[] = {
- { "childsmax", 'C', POPT_ARG_STRING, NULL, 'C', "foo", "childsmax" },
- { "daemonize", 'D', POPT_ARG_NONE, NULL, 'D', "foo", NULL },
- { "kill", 'K', POPT_ARG_NONE, NULL, 'K', "foo", NULL },
- { "pidfile", 'P', POPT_ARG_STRING, NULL, 'P', "foo", "pidfile" },
- { "veryverbose", 'V', POPT_ARG_NONE, NULL, 'V', "foo", NULL },
- { "acl", 'a', POPT_ARG_STRING, NULL, 'a', "foo", "addr[/mask]" },
- { "bind", 'b', POPT_ARG_STRING, NULL, 'b', "foo", "addr[:port]|-|path[:perms]" },
- { "client", 'c', POPT_ARG_STRING, NULL, 'c', "foo", "addr[:port]" },
- { "destination", 'd', POPT_ARG_STRING, NULL, 'd', "foo", "addr[:port]" },
- { "groupmode", 'g', POPT_ARG_STRING, NULL, 'g', "foo", "groupmode" },
- { "headervalue", 'h', POPT_ARG_STRING, NULL, 'h', "foo", "header: value" },
- { "include", 'i', POPT_ARG_STRING, NULL, 'i', "foo", "configfile" },
- { "size", 's', POPT_ARG_STRING, NULL, 's', "foo", "bytes" },
- { "timeout", 't', POPT_ARG_STRING, NULL, 't', "foo", "name=sec" },
- { "mailfrom", 'm', POPT_ARG_STRING, NULL, 'm', "foo", "regex" },
- { "nodename", 'n', POPT_ARG_STRING, NULL, 'n', "foo", "nodename" },
- { "operationmode", 'o', POPT_ARG_STRING, NULL, 'o', "foo", "post|feed" },
- { "l2spec", 'l', POPT_ARG_STRING, NULL, 'l', "foo", "spec" },
- { "uid", 'u', POPT_ARG_STRING, NULL, 'u', "foo", "number|name" },
- { "restrictheader", 'r', POPT_ARG_STRING, NULL, 'r', "foo", "regex" },
- { "newsgroup", NUL, POPT_ARG_STRING
- |POPT_ARGFLAG_DOC_HIDDEN, NULL, 1, NULL, NULL },
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
- };
ctx = malloc(sizeof(lmtp2nntp_config_t));
ctx->option_childsmax = 10;
- {
- int testint = 10;
- int testintout = 100;
- int testint2 = 20;
- int testintout2 = 200;
- val_rc_t rc;
- val_t *v, *v2, *v3;
-
- if ((rc = val_create(&v)) != VAL_OK)
- die("val_create");
-
- printf("DEBUG: testint = %d, testintout = %d\n", testint, testintout);
-
- if ((rc = val_reg(v, "foo", VAL_TYPE_INT, "foo variable", (void *)&testint)) != VAL_OK)
- die("val_reg");
-
- testint++;
- if ((rc = val_get(v, "foo", &testintout)) != VAL_OK)
- die("val_get");
- printf("DEBUG: testint = %d, testintout = %d\n", testint, testintout);
-
- if ((rc = val_set(v, "foo", 2)) != VAL_OK)
- die("val_set");
- if ((rc = val_get(v, "foo", &testintout)) != VAL_OK)
- die("val_get");
- printf("DEBUG: testint = %d, testintout = %d\n", testint, testintout);
-
- if ((rc = val_create(&v2)) != VAL_OK)
- die("val_create 2");
-
- if ((rc = val_reg(v, "bar", VAL_TYPE_VAL, "bar variable", (void *)&v2)) != VAL_OK)
- die("val_reg 2");
- val_reg(v, "bar", VAL_TYPE_VAL, "bar variable", NULL);
- val_set(v, "bar", v2);
- if ((rc = val_get(v, "bar", &v3)) != VAL_OK)
- die("val_get v3");
-
- if ((rc = val_reg(v2, "quux", VAL_TYPE_INT, "quux variable", (void *)&testint2)) != VAL_OK)
- die("val_reg 2b");
-
- testint2++;
- if ((rc = val_get(v2, "quux", &testintout2)) != VAL_OK)
- die("val_get 2c");
- printf("DEBUG: testint2 = %d, testintout2 = %d\n", testint2, testintout2);
- if ((rc = val_get(v, "bar.quux", &testintout2)) != VAL_OK) {
- fprintf(stderr, "rc=%d\n", rc);
- die("val_get 2d");
- }
- printf("DEBUG: testint2 = %d, testintout2 = %d\n", testint2, testintout2);
-
- printf("DEBUG: testint at address %lx\n", (long)&testint);
- printf("DEBUG: testintout at address %lx\n", (long)&testintout);
- printf("DEBUG: testint2 at address %lx\n", (long)&testint2);
- printf("DEBUG: testint2out at address %lx\n", (long)&testintout2);
-
- if ((rc = val_reg(v, "bar.ptr", VAL_TYPE_PTR, "bar ptr (&testint)", NULL)) != VAL_OK)
- die("val_ret for bar.ptr using inline data");
- if ((rc = val_set(v, "bar.ptr", &testint)) != VAL_OK)
- die("val_set for bar.ptr using inline data");
- if ((rc = val_reg(v, "bar.char", VAL_TYPE_CHAR, "bar character (!)", NULL)) != VAL_OK)
- die("val_ret for bar.char using inline data");
- if ((rc = val_set(v, "bar.char", '!')) != VAL_OK)
- die("val_set for bar.char using inline data");
- if ((rc = val_reg(v, "bar.short", VAL_TYPE_SHORT, "bar short (555)", NULL)) != VAL_OK)
- die("val_ret for bar.short using inline data");
- if ((rc = val_set(v, "bar.short", 555)) != VAL_OK)
- die("val_set for bar.short using inline data");
- if ((rc = val_reg(v, "bar.int", VAL_TYPE_INT, "bar integer (76543)", NULL)) != VAL_OK)
- die("val_ret for bar.int using inline data");
- if ((rc = val_set(v, "bar.int", 76543)) != VAL_OK)
- die("val_set for bar.int using inline data");
- if ((rc = val_reg(v, "bar.long", VAL_TYPE_LONG, "bar long (2097152)", NULL)) != VAL_OK)
- die("val_ret for bar.long using inline data");
- if ((rc = val_set(v, "bar.long", 2097152)) != VAL_OK)
- die("val_set for bar.long using inline data");
- if ((rc = val_reg(v, "bar.float", VAL_TYPE_FLOAT, "bar float (1.955830)", NULL)) != VAL_OK)
- die("val_ret for bar.float using inline data");
- if ((rc = val_set(v, "bar.float", 1.95583)) != VAL_OK)
- die("val_set for bar.float using inline data");
- if ((rc = val_reg(v, "bar.double", VAL_TYPE_DOUBLE, "bar double (3.1415+)", NULL)) != VAL_OK)
- die("val_ret for bar.double using inline data");
- if ((rc = val_set(v, "bar.double", 3.14159265358979)) != VAL_OK)
- die("val_set for bar.double using inline data");
-
- OK val_apply(v, "", 9, dumper, "v" );
- OK val_apply(v2, "", 9, dumper, "v2");
- OK val_apply(v, "", 0, dumper, "v" );
- OK val_apply(v, "bar", 1, dumper, "v" );
- OK val_apply(v2, "", 0, dumper, "v" );
- OK val_apply(v, "", 1, dumper, "v" );
- OK val_apply(v, "foo", 0, dumper, "v" );
- OK val_apply(v2, "char", 2, dumper, "v" );
- OK val_apply(v, "bar.char", 2, dumper, "v" );
-
- if ((rc = val_destroy(v2)) != VAL_OK)
- die("val_destroy 2");
-
- if ((rc = val_destroy(v)) != VAL_OK)
- die("val_destroy");
-
- return;
- }
-
- {
- char c;
- char *cp;
-
- poptCon = popt_getcontext(NULL, argc, (const char **)argv, poptTable, 0);
- popt_setotheroptionhelp(poptCon, "[OPTIONS]* [newsgroup ...]");
- printf("DEBUG: argc=%d\n", argc);
- if (argc < 2) {
- popt_printusage(poptCon, stderr, 0);
- exit(1);
- }
- while ((c = popt_getnextopt(poptCon)) >= 0) {
- printf("DEBUG: popt_getnextopt returned %d='%c'\n", (int)c, c);
- }
- while ((cp = popt_getarg(poptCon)) != NULL) {
- printf("DEBUG: popt_getarg returned \"%s\"\n", cp);
- }
-
- printf("DEBUG: popt_getnextopt ended with \"%s\"(%d)\n", popt_strerror((int)c), (int)c);
- popt_freecontext(poptCon);
- return;
- }
/* Braindump
@@ -418,16 +264,6 @@
}
#endif
-typedef enum {
- OPT_FLAG,
- OPT_SINGLE,
- OPT_MULTI
-} optiontype_t;
-
-typedef void (*optionloop_cb_t)(void);
-
-struct optionconfig_s;
-typedef struct optionconfig_s optionconfig_t;
struct optionconfig_s {
optionconfig_t *next; /* cleanup chain for destroy */
/**/
@@ -449,23 +285,142 @@
} data;
};
-static void stdsyntax(void)
+lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionconfig_t **ocp);
+lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionconfig_t **ocp)
{
- return;
+ lmtp2nntp_option_rc_t rc = VAL_OK;
+
+ if (o == NULL || ocp == NULL)
+ return OPTION_ERR_ARG;
+
+ *ocp = o->first;
+ while (*ocp != NULL && (*ocp)->number != number)
+ *ocp = (*ocp)->next;
+
+ return rc;
+}
+
+
+lmtp2nntp_option_rc_t option_register(lmtp2nntp_option_t *o, char *longname, char shortname, optiontype_t type, optionloop_cb_t *cb, char *cbctx, char *descrip, char *argdescrip)
+{
+ lmtp2nntp_option_rc_t rc = VAL_OK;
+ optionconfig_t *oc;
+
+ printf("DEBUG: enter option_register(%.8lx, \"%s\", '%c', %d, %.8lx, %.8lx, \"%s\", \"%s\")\n", (long)o, longname, shortname, type, (long)cb, (long)cbctx, descrip, argdescrip);
+
+ if (o == NULL || longname == NULL)
+ return OPTION_ERR_ARG;
+
+ /* create a optionconfig_t structure */
+ if ((oc = (optionconfig_t *)malloc(sizeof(optionconfig_t))) == NULL)
+ return OPTION_ERR_MEM;
+ printf("DEBUG: optionconfig_t structure malloc'ed\n");
+ oc->next = NULL;
+ oc->longname = strdup(longname);
+ oc->shortname = shortname;
+ oc->descrip = descrip == NULL ? NULL : strdup(descrip);
+ oc->argdescrip = argdescrip == NULL ? NULL : strdup(argdescrip);
+ oc->type = type;
+ oc->cb = cb;
+ oc->cbctx = cbctx;
+ oc->pass1default = NULL; /*FIXME*/
+ oc->val = o->vo;
+ oc->number = o->pi; /*FIXME + 1; 0 is a reserved val in popt, so offset 1 */
+ if ( ( oc->longname == NULL)
+ || (descrip != NULL && oc->descrip == NULL)
+ || (argdescrip != NULL && oc->argdescrip == NULL)
+ )
+ CU(OPTION_ERR_MEM);
+
+ printf("DEBUG: optionconfig_t structure created\n");
+
+ /* feed lib_val */
+ (void)/*FIXME rc*/val_reg(oc->val, oc->longname,
+ type == OPT_FLAG ? VAL_TYPE_INT : VAL_TYPE_PTR,
+ oc->descrip, NULL);
+
+ printf("DEBUG: val_reg'ed\n");
+
+ /* feed lib_popt */
+ printf("DEBUG: o->pi=%d, o->pn=%d\n", o->pi, o->pn);
+ if (o->pi >= (o->pn-2)) { /* correction by two here, in malloc and realloc is for AUTOHELP and TABLEEND */
+ if (o->pt == NULL) {
+ printf("DEBUG: malloc\n");
+ o->pt = (struct popt_option *)malloc( (1 + 2) * sizeof(struct popt_option)); /*FIXME out of mem*/
+ o->pn = 1;
+ }
+ else {
+ printf("DEBUG: realloc\n");
+ o->pt = (struct popt_option *)realloc(o->pt, (o->pn * 2 + 2) * sizeof(struct popt_option)); /*FIXME out of mem*/
+ o->pn = o->pn * 2;
+ }
+ }
+ o->pt[o->pi].longName = oc->longname;
+ o->pt[o->pi].shortName = oc->shortname;
+ o->pt[o->pi].argInfo = oc->type == OPT_FLAG ? POPT_ARG_NONE : POPT_ARG_STRING;
+ o->pt[o->pi].arg = NULL;
+ o->pt[o->pi].val = oc->number;
+ o->pt[o->pi].descrip = oc->descrip;
+ o->pt[o->pi].argDescrip = oc->argdescrip;
+
+ /* append POPT_AUTOHELP */
+ o->pt[o->pi+1].longName = NULL;
+ o->pt[o->pi+1].shortName = '\0';
+ o->pt[o->pi+1].argInfo = POPT_ARG_INCLUDE_TABLE;
+ o->pt[o->pi+1].arg = popt_helpoptions;
+ o->pt[o->pi+1].val = 0;
+ o->pt[o->pi+1].descrip = "Help options:";
+ o->pt[o->pi+1].argDescrip = NULL;
+
+ /* append POPT_TABLEEND */
+ o->pt[o->pi+2].longName = NULL;
+ o->pt[o->pi+2].shortName = '\0';
+ o->pt[o->pi+2].argInfo = 0;
+ o->pt[o->pi+2].arg = 0;
+ o->pt[o->pi+2].val = 0;
+ o->pt[o->pi+2].descrip = NULL;
+ o->pt[o->pi+2].argDescrip = NULL;
+ o->pi++;
+ printf("DEBUG: popt'ed\n");
+
+ /* link in this new optionconfig_t structure */
+ if (o->first == NULL) {
+ o->first = oc;
+ o->last = oc;
+ }
+ else {
+ o->last->next = oc;
+ o->last = oc;
+ }
+ printf("DEBUG: linked\n");
+
+ return rc;
+
+ CUS:
+ if (oc != NULL) {
+ if (oc->argdescrip != NULL) free(oc->argdescrip);
+ if (oc->descrip != NULL) free(oc->descrip);
+ if (oc->longname != NULL) free(oc->longname);
+ free(oc);
+ }
+ return rc;
}
-static void includeit(void)
+static void stdsyntax(optionconfig_t *oc, char *arg, char *cbctx)
{
+ printf("DEBUG: enter stdsyntax %.8lx, \"%s\", \"%s\"\n", (long)oc, arg, cbctx);
return;
}
-static void option_register(lmtp2nntp_option_t *o, char *longname, char shortname, optiontype_t type, optionloop_cb_t cb, char *cbctx, char *descrip, char *argdescrip)
+static void includeit(optionconfig_t *oc, char *arg, char *cbctx)
{
return;
}
lmtp2nntp_option_rc_t option_create(lmtp2nntp_option_t **op)
{
+ printf("DEBUG: enter option_create(%.8lx)\n", (long)op);
+
if (op == NULL)
return OPTION_ERR_ARG;
@@ -503,7 +458,13 @@
(*op)->newsgroup.as = 0;
(*op)->newsgroup.az = NULL;
/**/
+ (*op)->first = NULL;
+ (*op)->last = NULL;
(*op)->vo = NULL;
+ (*op)->pn = 0;
+ (*op)->pi = 0;
+ (*op)->pt = NULL;
+
if (val_create(&((*op)->vo)) != VAL_OK) {
free(*op);
return OPTION_ERR_VAL;
@@ -513,36 +474,69 @@
lmtp2nntp_option_rc_t option_parse(lmtp2nntp_option_t *o, int argc, char **argv)
{
+ printf("DEBUG: enter option_parse(%.8lx, %d, %.8lx)\n", (long)o, argc, (long)argv);
+
if (o == NULL)
return OPTION_ERR_ARG;
- option_register(o, "childsmax", 'C', OPT_SINGLE, stdsyntax, "[0-9]{,5}", "foo", "childsmax" );
- option_register(o, "daemonize", 'D', OPT_FLAG, NULL, NULL, "foo", NULL );
- option_register(o, "kill", 'K', OPT_FLAG, NULL, NULL, "foo", NULL );
- option_register(o, "pidfile", 'P', OPT_SINGLE, stdsyntax, ".{,255}", "foo", "pidfile" );
- option_register(o, "veryverbose", 'V', OPT_FLAG, NULL, NULL, "foo", NULL );
- option_register(o, "acl", 'a', OPT_MULTI, stdsyntax, "[0-9.](/[0-9]2)?", "foo", "addr[/mask]" );
- option_register(o, "bind", 'b', OPT_SINGLE, stdsyntax, ".*", "foo", "addr[:port]|-|path[:perms]" );
- option_register(o, "client", 'c', OPT_SINGLE, stdsyntax, ".*", "foo", "addr[:port]" );
- option_register(o, "destination", 'd', OPT_MULTI, stdsyntax, ".*", "foo", "addr[:port]" );
- option_register(o, "groupmode", 'g', OPT_SINGLE, stdsyntax, ".*", "foo", "groupmode" );
- option_register(o, "headervalue", 'h', OPT_MULTI, stdsyntax, ".*", "foo", "header: value" );
- option_register(o, "include", 'i', OPT_MULTI, includeit, ".*", "foo", "configfile" );
- option_register(o, "size", 's', OPT_SINGLE, stdsyntax, ".*", "foo", "bytes" );
- option_register(o, "timeoutlmtpaccept", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" );
- option_register(o, "timeoutlmtpread", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" );
- option_register(o, "timeoutlmtpwrite", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" );
- option_register(o, "timeoutnntpconnect", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" );
- option_register(o, "timeoutnntpread", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" );
- option_register(o, "timeoutnntpwrite", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" );
- option_register(o, "mailfrom", 'm', OPT_SINGLE, stdsyntax, ".*", "foo", "regex" );
- option_register(o, "nodename", 'n', OPT_SINGLE, stdsyntax, ".*", "foo", "nodename" );
- option_register(o, "operationmode", 'o', OPT_SINGLE, stdsyntax, ".*", "foo", "post|feed" );
- option_register(o, "l2spec", 'l', OPT_SINGLE, stdsyntax, ".*", "foo", "spec" );
- option_register(o, "uid", 'u', OPT_SINGLE, stdsyntax, ".*", "foo", "number|name" );
- option_register(o, "restrictheader", 'r', OPT_MULTI, stdsyntax, ".*", "foo", "regex" );
- option_register(o, "newsgroup", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "newsgroup");
+ (void)option_register(o, "childsmax", 'C', OPT_SINGLE, &stdsyntax, "[0-9]{,5}", "foo", "childsmax" );
+ (void)option_register(o, "daemonize", 'D', OPT_FLAG, NULL, NULL, "foo", NULL );
+ (void)option_register(o, "kill", 'K', OPT_FLAG, NULL, NULL, "foo", NULL );
+ (void)option_register(o, "pidfile", 'P', OPT_SINGLE, &stdsyntax, ".{,255}", "foo", "pidfile" );
+ (void)option_register(o, "veryverbose", 'V', OPT_FLAG, NULL, NULL, "foo", NULL );
+ (void)option_register(o, "acl", 'a', OPT_MULTI, &stdsyntax, "[0-9.](/[0-9]2)?", "foo", "addr[/mask]" );
+ (void)option_register(o, "bind", 'b', OPT_SINGLE, &stdsyntax, ".*", "foo", "addr[:port]|-|path[:perms]" );
+ (void)option_register(o, "client", 'c', OPT_SINGLE, &stdsyntax, ".*", "foo", "addr[:port]" );
+ (void)option_register(o, "destination", 'd', OPT_MULTI, &stdsyntax, ".*", "foo", "addr[:port]" );
+ (void)option_register(o, "groupmode", 'g', OPT_SINGLE, &stdsyntax, ".*", "foo", "groupmode" );
+ (void)option_register(o, "headervalue", 'h', OPT_MULTI, &stdsyntax, ".*", "foo", "header: value" );
+ (void)option_register(o, "include", 'i', OPT_MULTI, &includeit, ".*", "foo", "configfile" );
+ (void)option_register(o, "size", 's', OPT_SINGLE, &stdsyntax, ".*", "foo", "bytes" );
+ (void)option_register(o, "timeoutlmtpaccept", NUL, OPT_MULTI, &stdsyntax, ".*", "foo", "sec" );
+ (void)option_register(o, "timeoutlmtpread", NUL, OPT_MULTI, &stdsyntax, ".*", "foo", "sec" );
+ (void)option_register(o, "timeoutlmtpwrite", NUL, OPT_MULTI, &stdsyntax, ".*", "foo", "sec" );
+ (void)option_register(o, "timeoutnntpconnect", NUL, OPT_MULTI, &stdsyntax, ".*", "foo", "sec" );
+ (void)option_register(o, "timeoutnntpread", NUL, OPT_MULTI, &stdsyntax, ".*", "foo", "sec" );
+ (void)option_register(o, "timeoutnntpwrite", NUL, OPT_MULTI, &stdsyntax, ".*", "foo", "sec" );
+ (void)option_register(o, "mailfrom", 'm', OPT_SINGLE, &stdsyntax, ".*", "foo", "regex" );
+ (void)option_register(o, "nodename", 'n', OPT_SINGLE, &stdsyntax, ".*", "foo", "nodename" );
+ (void)option_register(o, "operationmode", 'o', OPT_SINGLE, &stdsyntax, ".*", "foo", "post|feed" );
+ (void)option_register(o, "l2spec", 'l', OPT_SINGLE, &stdsyntax, ".*", "foo", "spec" );
+ (void)option_register(o, "uid", 'u', OPT_SINGLE, &stdsyntax, ".*", "foo", "number|name" );
+ (void)option_register(o, "restrictheader", 'r', OPT_MULTI, &stdsyntax, ".*", "foo", "regex" );
+ (void)option_register(o, "newsgroup", NUL, OPT_MULTI, &stdsyntax, ".*", "foo", "newsgroup");
+
+
+ {
+ int i;
+ char *cp;
+ optionconfig_t *ocp;
+ popt_context poptCon; /* context for parsing command-line options */
+ poptCon = popt_getcontext(NULL, argc, (const char **)argv, o->pt, 0);
+ popt_setotheroptionhelp(poptCon, "[OPTIONS]* [newsgroup ...]");
+ printf("DEBUG: argc=%d\n", argc);
+ if (argc < 2) {
+ popt_printusage(poptCon, stderr, 0);
+ exit(1);
+ }
+ while ((i = popt_getnextopt(poptCon)) >= 0) {
+ (void)option_find(o, i, &ocp);
+ if (ocp->type == OPT_FLAG)
+ ocp->cb(ocp, "ohne", ocp->cbctx);
+ else
+ ocp->cb(ocp, cp = popt_getoptarg(poptCon), ocp->cbctx);
+ printf("DEBUG: popt_getnextopt returned %d \"%s\", \"%s\"\n", i, o->pt[i].longName, ocp->longname);
+ printf("DEBUG: popt_getoptarg returned \"%s\"\n", cp);
+ }
+ printf("DEBUG: current popt error is \"%s\"(%d)\n", popt_strerror(i), i);
+ printf("DEBUG: ----\n");
+ while ((cp = (char *)popt_getarg(poptCon)) != NULL) {
+ printf("DEBUG: popt_getarg returned \"%s\"\n", cp);
+ }
+ printf("DEBUG: current popt error is \"%s\"(%d)\n", popt_strerror(i), i);
+ popt_freecontext(poptCon);
+ }
return OPTION_OK;
}
|