Index: ossp-pkg/lmtp2nntp/example.conf RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/example.conf,v rcsdiff -q -kk '-r1.9' '-r1.10' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/example.conf,v' 2>/dev/null --- example.conf 2002/01/31 10:40:07 1.9 +++ example.conf 2002/01/31 13:44:05 1.10 @@ -22,7 +22,7 @@ ### GATEWAY ### client 127.0.0.1:45678 #see -c aka --client -destination news.example.com #see -d aka --destination +destination 127.0.0.1:nntp #see -d aka --destination groupmode envelope #see -g aka --groupmode headervalue X-gateway "lmtp2nntp gateway" #see -h aka --headervalue #include "sampleconfig.two" # -i aka --include Index: ossp-pkg/lmtp2nntp/fixme.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v' 2>/dev/null --- fixme.h 2002/01/31 10:40:07 1.5 +++ fixme.h 2002/01/31 13:44:05 1.6 @@ -19,8 +19,8 @@ typedef struct nntp_st nntp_t; #include "lmtp2nntp_nntp.h" struct ns { - char *h; /* host */ - char *p; /* port */ + /*FIXME obsolete char *h; * host */ + /*FIXME obsolete char *p; * port */ sa_addr_t *saa; /* socket address abstraction */ sa_t *sa; /* socket abstraction */ nntp_t *nntp; @@ -90,8 +90,13 @@ sa_t *saIO; int fdIOi; int fdIOo; + int nsc; struct ns ns[MAXNEWSSERVICES]; + /*FIXME replaced by following */ + int nns; /* number of ns structures found at pns */ + struct ns *pns; /* pointer to an array of ns structures */ + char *azGroupargs; size_t asGroupargs; struct session session; Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v rcsdiff -q -kk '-r1.21' '-r1.22' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null --- lmtp2nntp_config.c 2002/01/31 10:40:07 1.21 +++ lmtp2nntp_config.c 2002/01/31 13:44:05 1.22 @@ -381,6 +381,48 @@ catch (ex) rethrow; + /* --destination MULTI */ + try { + char *cp; + int i; + + if ( (val_get(ctx->val, "option.destination", &ov) != VAL_OK) + || ((ov->ndata >= 1) && (ov->data.m == NULL)) + ) throw(0,0,0); + log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata); + for (i = 0; i < ov->ndata; i++) + log2(ctx, TRACE, "--destination[%d] = \"%s\"", i, (ov->data.m)[i]); + + if ((ctx->pacl = (struct acl *)malloc(ov->ndata * sizeof(struct acl))) == NULL) throw(0,0,0); + for (i = 0; i < ov->ndata; i++) { + cp = (ov->data.m)[i]; + log2(ctx, DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp); + if (strrchr(cp, ':') == NULL) + cp = str_concat(cp, ":nntp", NULL); //FIXME is this a config var/val? + else + cp = str_concat(cp, NULL); /* prepare for free() */ + log1(ctx, DEBUG, "cp = \"%s\"", cp); + if ((rc = sa_addr_create(&ctx->ns[i].saa)) != SA_OK) { + log1(ctx, ERROR, "option --destination, create address (internal) failed with \"%s\"", + sa_error(rc)); + throw(0,0,0); + } + if ((rc = sa_addr_u2a(ctx->ns[i].saa, "inet://%s", cp)) != SA_OK) { + log2(ctx, ERROR, "option --destination, parsing host address (%s) failed with \"%s\"", + cp /*FIXME again, option vs. config */, sa_error(rc)); + throw(0,0,0); + } + if ((rc = sa_create(&ctx->ns[i].sa)) != SA_OK) { + log2(ctx, ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\"", + cp /*FIXME again, option vs. config */, sa_error(rc)); + throw(0,0,0); + } + free(cp); + } + ctx->nns = i; + } + catch (ex) + rethrow; CUS: return; } Index: ossp-pkg/lmtp2nntp/lmtp2nntp_main.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v rcsdiff -q -kk '-r1.16' '-r1.17' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v' 2>/dev/null --- lmtp2nntp_main.c 2002/01/31 10:42:01 1.16 +++ lmtp2nntp_main.c 2002/01/31 13:44:05 1.17 @@ -368,12 +368,8 @@ int bOk; int i; /* general purpose scratch int, index ... */ char *cp; /* general purpose character pointer */ - char *azHosts; - size_t asHosts; char *azTimeout; size_t asTimeout; - char *cpHost; - char *cpPort; pid_t pid; FILE *fd; char *cpName; @@ -431,16 +427,8 @@ ctx->saServerbind = NULL; ctx->saaClientbind = NULL; ctx->saClientbind = NULL; - ctx->nsc = 0; - for (i=0; i < MAXNEWSSERVICES; i++) { - ctx->ns[i].h = NULL; - ctx->ns[i].p = NULL; - ctx->ns[i].saa = NULL; - ctx->ns[i].sa = NULL; - ctx->ns[i].nntp = NULL; - ctx->ns[i].rc = LMTP_ERR_UNKNOWN; - ctx->ns[i].l2 = NULL; - } + ctx->nns = 0; + ctx->pns = NULL; ctx->nacl = 0; ctx->pacl = NULL; ctx->azGroupargs = NULL; @@ -476,44 +464,6 @@ /* read in the arguments */ while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:h:l:m:n:o:r:s:t:u:v")) != -1) { switch (i) { - case 'd': /*POD [B<-d> I[I<:port>][,I[I<:port>], ...]] */ - if (argz_create_sep(optarg, ',', &azHosts, &asHosts) != 0) - CU(ERR_EXECUTION); - cp = NULL; - while ((cp = argz_next(azHosts, asHosts, cp)) != NULL) { - if (ctx->nsc >= MAXNEWSSERVICES) { - fprintf(stderr, "%s:Error: Too many services (%d) using option -d\n", ctx->progname, ctx->nsc); - CU(ERR_EXECUTION); - } - cpHost = strdup(cp); - if ((cpPort = strrchr(cpHost, ':')) != NULL) { - *cpPort++ = NUL; - cpPort = strdup(cpPort); - } - else - cpPort = strdup("nntp"); - ctx->ns[ctx->nsc].h = cpHost; - ctx->ns[ctx->nsc].p = cpPort; - if ((rc = sa_addr_create(&ctx->ns[ctx->nsc].saa)) != SA_OK) { - fprintf(stderr, "%s:Error: Creating address failed for -d option (%d)\n", - ctx->progname, rc); - } - if ((rc = sa_addr_u2a(ctx->ns[ctx->nsc].saa, "inet://%s:%s", - ctx->ns[ctx->nsc].h, ctx->ns[ctx->nsc].p)) != SA_OK) { - fprintf(stderr, "%s:Error: Parsing host address failed for \"%s:%s\" (%d)\n", - ctx->progname, ctx->ns[ctx->nsc].h, ctx->ns[ctx->nsc].p, rc); - CU(ERR_EXECUTION); - } - if ((rc = sa_create(&ctx->ns[ctx->nsc].sa)) != SA_OK) { - fprintf(stderr, "%s:Error: Creating TCP socket failed for \"%s:%s\": %s\n", - ctx->progname, ctx->ns[ctx->nsc].h, ctx->ns[ctx->nsc].p, strerror(errno)); - CU(ERR_EXECUTION); - } - ctx->ns[ctx->nsc].nntp = NULL; - ctx->nsc++; - } - free(azHosts); - break; case 'g': /*POD [B<-g> I] */ if (strcasecmp(optarg, "arg") == 0) ctx->option_groupmode = GROUPMODE_ARG; @@ -1105,7 +1055,7 @@ do { log1(ctx, DEBUG, "trying ns[%d]", i); bOk = TRUE; - log2(ctx, TRACE, "try %s:%s", ctx->ns[i].h, ctx->ns[i].p); + log1(ctx, TRACE, "try ${option.destination}[${i}]", i); //FIXME ctx->ns[i].l2 = ctx->l2; @@ -1126,8 +1076,7 @@ log0(ctx, DEBUG, "connect"); if (sa_connect(ctx->ns[i].sa, ctx->ns[i].saa) != SA_OK) { bOk = FALSE; - log2(ctx, WARNING, "connect to %s:%s failed, %m", - ctx->ns[i].h, ctx->ns[i].p); + log1(ctx, WARNING, "connect to ${option.destination}[${i}] failed, %m", i); //FIXME } } @@ -1151,11 +1100,11 @@ } if (bOk) { - log2(ctx, INFO, "NNTP session to %s:%s successfully established", ctx->ns[i].h, ctx->ns[i].p); + log1(ctx, INFO, "NNTP session to ${option.destination}[${i}] successfully established", i); //FIXME i++; } else { - log2(ctx, WARNING, "NNTP session establishment to %s:%s failed", ctx->ns[i].h, ctx->ns[i].p); + log1(ctx, WARNING, "NNTP session establishment to ${option.destination}[${i}] failed", i); //FIXME log1(ctx, DEBUG, "removing ns[%d] from list", i); lmtp_gfs_ns(&ctx->ns[i]); if (i < --ctx->nsc) { @@ -1218,14 +1167,6 @@ sa_addr_destroy(ns->saa); ns->saa = NULL; } - if (ns->p != NULL) { - free(ns->p); - ns->p = NULL; - } - if (ns->h != NULL) { - free(ns->h); - ns->h = NULL; - } } static void lmtp_gfs_lhlo(lmtp2nntp_t *ctx) @@ -1937,10 +1878,11 @@ for (i = 0; i < ctx->nsc; i++) { if (ctx->ns[i].rc != NNTP_OK) { str_format(errorstring, sizeof(errorstring), - "%s:%s returned %s\n" - "%s:%s lastresp \"%s\"", - ctx->ns[i].h, ctx->ns[i].p, nntp_error(ctx->ns[i].rc), - ctx->ns[i].h, ctx->ns[i].p, nntp_lastresp(ctx->ns[i].nntp)); + "${option.destination}[${i}] returned %s\n" /*FIXME*/ + "${option.destination}[${i}] lastresp \"%s\"", /*FIXME*/ + i, + nntp_error(ctx->ns[i].rc), + nntp_lastresp(ctx->ns[i].nntp)); argz_add(&azErr, &asErr, errorstring); } }