OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp_main.c versions 1.16 and 1.17
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.16 -> 1.17

--- 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<addr>[I<:port>][,I<addr>[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<groupmode>] */
                 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);
             }
         }

CVSTrac 2.0.1