OSSP CVS Repository

ossp - Check-in [1738]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1738
Date: 2002-Jan-31 11:40:07 (local)
2002-Jan-31 10:40:07 (UTC)
User:thl
Branch:
Comment: moved --client option
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/example.conf      1.8 -> 1.9     1 inserted, 1 deleted
ossp-pkg/lmtp2nntp/fixme.h      1.4 -> 1.5     6 inserted, 2 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.20 -> 1.21     22 inserted, 0 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.14 -> 1.15     10 inserted, 34 deleted

ossp-pkg/lmtp2nntp/example.conf 1.8 -> 1.9

--- example.conf 2002/01/31 09:03:58     1.8
+++ example.conf 2002/01/31 10:40:07     1.9
@@ -21,7 +21,7 @@
 
         ### GATEWAY ###
 
-client          127.0.0.2                       #see -c aka --client
+client          127.0.0.1:45678                 #see -c aka --client
 destination     news.example.com                #see -d aka --destination
 groupmode       envelope                        #see -g aka --groupmode
 headervalue     X-gateway "lmtp2nntp gateway"   #see -h aka --headervalue


ossp-pkg/lmtp2nntp/fixme.h 1.4 -> 1.5

--- fixme.h      2002/01/31 10:14:54     1.4
+++ fixme.h      2002/01/31 10:40:07     1.5
@@ -77,10 +77,14 @@
     sa_addr_t      *saaServerbind;
     sa_t           *saServerbind;
 
-    char           *cpBindh;
-    char           *cpBindp;
+    /*FIXME obsolete char           *cpBindh; */
+    /*FIXME obsolete char           *cpBindp; */
+    /*
     sa_addr_t      *saaBind;
     sa_t           *saBind;
+    FIXME replaced by following */
+    sa_addr_t      *saaClientbind;
+    sa_t           *saClientbind;
 
     sa_addr_t      *saaIO;
     sa_t           *saIO;


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.20 -> 1.21

--- lmtp2nntp_config.c   2002/01/31 10:14:54     1.20
+++ lmtp2nntp_config.c   2002/01/31 10:40:07     1.21
@@ -359,6 +359,28 @@
     catch (ex)
         rethrow;
 
+    /* --client SINGLE */
+    try {
+        if (   (val_get(ctx->val, "option.client", &ov) != VAL_OK)
+            || (ov->ndata != 1)
+            || (ov->data.s == NULL)
+              ) throw(0,0,0);
+        log1(ctx, TRACE, "--client = \"%s\"", ov->data.s);
+
+        if ((rc = sa_addr_create(&ctx->saaClientbind)) != SA_OK) {
+            log1(ctx, ERROR, "option --client, create address (internal) failed with \"%s\"",
+                 sa_error(rc));
+            throw(0,0,0);
+        }
+        if ((rc = sa_addr_u2a(ctx->saaClientbind, "inet://%s", ov->data.s)) != SA_OK) {
+            log2(ctx, ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"",
+                 ov->data.s, sa_error(rc));
+            throw(0,0,0);
+        }
+    }
+    catch (ex)
+        rethrow;
+
 CUS:
     return;
 }


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.14 -> 1.15

--- lmtp2nntp_main.c     2002/01/31 10:14:54     1.14
+++ lmtp2nntp_main.c     2002/01/31 10:40:07     1.15
@@ -433,10 +433,8 @@
     ctx->l2 = NULL;
     ctx->saaServerbind = NULL;
     ctx->saServerbind = NULL;
-    ctx->cpBindh = NULL;
-    ctx->cpBindp = NULL;
-    ctx->saaBind = NULL;
-    ctx->saBind = NULL;
+    ctx->saaClientbind = NULL;
+    ctx->saClientbind = NULL;
     ctx->nsc = 0;
     for (i=0; i < MAXNEWSSERVICES; i++) {
         ctx->ns[i].h = NULL;
@@ -482,24 +480,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 'c': /*POD [B<-c> I<addr>[I<:port>]] */
-                ctx->cpBindh = strdup(optarg);
-                if ((ctx->cpBindp = strrchr(ctx->cpBindh, ':')) != NULL) {
-                    *ctx->cpBindp++ = NUL;
-                    ctx->cpBindp = strdup(ctx->cpBindp);
-                }
-                else 
-                    ctx->cpBindp = strdup("0");
-                if ((rc = sa_addr_create(&ctx->saaBind)) != SA_OK) {
-                    fprintf(stderr, "%s:Error: Creating address failed for -c option (%d)\n", 
-                            ctx->progname, rc);
-                }
-                if ((rc = sa_addr_u2a(ctx->saaBind, "inet://%s:%s", ctx->cpBindh, ctx->cpBindp)) != SA_OK) {
-                    fprintf(stderr, "%s:Error: Parsing bind address failed for \"%s:%s\" (%d)\n", 
-                            ctx->progname, ctx->cpBindh, ctx->cpBindp, rc);
-                    CU(ERR_EXECUTION);
-                }
-                break;
             case 'd': /*POD [B<-d> I<addr>[I<:port>][,I<addr>[I<:port>], ...]] */
                 if (argz_create_sep(optarg, ',', &azHosts, &asHosts) != 0)
                     CU(ERR_EXECUTION);
@@ -1133,11 +1113,11 @@
 
         ctx->ns[i].l2 = ctx->l2;
 
-        if (bOk && (ctx->saaBind != NULL)) {
-            log2(ctx, DEBUG, "bind local socket to %s:%s", ctx->cpBindh, ctx->cpBindp);
-            if (sa_bind(ctx->ns[i].sa, ctx->saaBind) != SA_OK) {
+        if (bOk && (ctx->saaClientbind != NULL)) {
+            log0(ctx, DEBUG, "bind local socket to ${option.clientbind}"); //FIXME
+            if (sa_bind(ctx->ns[i].sa, ctx->saaClientbind) != SA_OK) {
                 bOk = FALSE;
-                log2(ctx, ERROR, "binding NNTP client to local address %s:%s failed, %m", ctx->cpBindh, ctx->cpBindp);
+                log0(ctx, ERROR, "binding NNTP client to local address ${option.clientbind} failed, %m"); //FIXME
             }
         }
 
@@ -1263,14 +1243,10 @@
 
     if (ctx->option_mailfrom != NULL)
         free(ctx->option_mailfrom);
-    if (ctx->cpBindh != NULL)
-        free(ctx->cpBindh);
-    if (ctx->cpBindp != NULL)
-        free(ctx->cpBindp);
-    if (ctx->saBind != NULL)
-        sa_destroy(ctx->saBind);
-    if (ctx->saaBind != NULL)
-        sa_addr_destroy(ctx->saaBind);
+    if (ctx->saClientbind != NULL)
+        sa_destroy(ctx->saClientbind);
+    if (ctx->saaClientbind != NULL)
+        sa_addr_destroy(ctx->saaClientbind);
 }
 
 static int helo_rfc0821domain(char *msg, char **domain)

CVSTrac 2.0.1