OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.85 -> 1.86

--- lmtp2nntp_config.c   2003/01/30 14:37:01     1.85
+++ lmtp2nntp_config.c   2003/01/30 15:19:55     1.86
@@ -107,67 +107,68 @@
     "0-9"         /* namechars     */
 };
 
-void config_context(lmtp2nntp_t *ctx)
+lmtp2nntp_config_rc_t config_context(lmtp2nntp_t *ctx)
 {
+    lmtp2nntp_config_rc_t rc = CONFIG_OK;
     ex_t ex;
     optionval_t *ov;
-    int rc;
+    sa_rc_t sa_rc;
 
     /* create L2 environment */
     if (l2_env_create(&ctx->l2_env) != L2_OK) {
         fprintf(stderr, "%s:Error: failed to create L2 environment\n", ctx->progname);
-        CU(ERR_EXECUTION);
+        CU(CONFIG_ERR_LOG);
     }
     if (l2_env_levels(ctx->l2_env, L2_LEVEL_ALL, L2_LEVEL_NONE) != L2_OK) {
         fprintf(stderr, "%s:Error: logging failed to set global logging level defaults\n", ctx->progname);
-        CU(ERR_EXECUTION);
+        CU(CONFIG_ERR_LOG);
     }
     if (l2_env_formatter(ctx->l2_env, 'P', formatter_prefix, &ctx->ctx) != L2_OK) {
         fprintf(stderr, "%s:Error: logging failed to register prefix formatter\n", ctx->progname);
-        CU(ERR_EXECUTION);
+        CU(CONFIG_ERR_LOG);
     }
     if (l2_env_formatter(ctx->l2_env, 'D', l2_util_fmt_dump, NULL) != L2_OK) {
         fprintf(stderr, "%s:Error: logging failed to register dump formatter\n", ctx->progname);
-        CU(ERR_EXECUTION);
+        CU(CONFIG_ERR_LOG);
     }
     if (l2_env_formatter(ctx->l2_env, 'S', l2_util_fmt_string, NULL) != L2_OK) {
         fprintf(stderr, "%s:Error: logging failed to register string formatter\n", ctx->progname);
-        CU(ERR_EXECUTION);
+        CU(CONFIG_ERR_LOG);
     }
     if (l2_env_formatter(ctx->l2_env, 'm', l2_util_fmt_errno, NULL) != L2_OK) {
         fprintf(stderr, "%s:Error: logging failed to register errno formatter\n", ctx->progname);
-        CU(ERR_EXECUTION);
+        CU(CONFIG_ERR_LOG);
     }
     if (val_get(ctx->val, "option.l2spec", &ov) != VAL_OK) {
         fprintf(stderr, "%s:Error: (internal) config did not register 'l2spec' option\n", ctx->progname);
-        CU(ERR_EXECUTION);
+        CU(CONFIG_ERR_LOG);
     }
     if (ov->data.s != NULL) {
         l2_channel_t *ch;
 
         if (l2_env_handler(ctx->l2_env, &l2_handler_var) != L2_OK) {
             fprintf(stderr, "%s:Error: logging failed to register \"%s\" handler \n", ctx->progname, l2_handler_var.name);
-            CU(ERR_EXECUTION);
+            CU(CONFIG_ERR_LOG);
         }
-        if ((rc = l2_channel_create(&ctx->l2, ctx->l2_env, l2_handler_var.name)) != L2_OK) {
+        if ((l2_channel_create(&ctx->l2, ctx->l2_env, l2_handler_var.name)) != L2_OK) {
             fprintf(stderr, "%s:Error: logging failed to create \"%s\" channel\n", ctx->progname, l2_handler_var.name);
-            CU(ERR_EXECUTION);
+            CU(CONFIG_ERR_LOG);
         }
-        if ((rc = l2_channel_configure(ctx->l2, "", ctx->config_varctx)) != L2_OK) {
+        if ((l2_channel_configure(ctx->l2, "", ctx->config_varctx)) != L2_OK) {
             fprintf(stderr, "%s:Error: logging failed to configure \"%s\" channel\n", ctx->progname, l2_handler_var.name);
-            CU(ERR_EXECUTION);
+            CU(CONFIG_ERR_LOG);
         }
-        if ((rc = l2_spec(&ch, ctx->l2_env, ov->data.s)) != L2_OK) {
+        if ((l2_spec(&ch, ctx->l2_env, ov->data.s)) != L2_OK) {
             fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname);
-            CU(ERR_EXECUTION);
+            CU(CONFIG_ERR_LOG);
         }
         if (l2_channel_link(ctx->l2, L2_LINK_CHILD, ch, NULL) != L2_OK) {
             fprintf(stderr, "%s:Error: logging failed to link child channel\n", ctx->progname);
-            CU(ERR_EXECUTION);
+            CU(CONFIG_ERR_LOG);
         }
         if (l2_channel_open(ctx->l2) != L2_OK) {
             fprintf(stderr, "%s:Error: logging failed to open channel stream\n", ctx->progname);
-            CU(ERR_EXECUTION);
+            CU(CONFIG_ERR_LOG);
         }
     }
     /* from this point on logging is up and running and fprintf(stderr, ...)
@@ -187,7 +188,7 @@
 
         if (ov->data.f == 1) {
             fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu);
-            exit(0); /* FIXME */
+            CU(CONFIG_OK_DRY);
         }
     }
     catch (ex)
@@ -306,12 +307,12 @@
                     cp = "-1";
                 ctx->pacl[i].prefixlen = atoi(cp);
                 logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx->pacl[%d].prefixlen = %d", i, ctx->pacl[i].prefixlen);
-                if ((rc = sa_addr_create(&(ctx->pacl[i].saa))) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create address (internal) failed with \"%s\"", sa_error(rc));
+                if ((sa_rc = sa_addr_create(&(ctx->pacl[i].saa))) != SA_OK) {
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                     }
-                if ((rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc));
+                if ((sa_rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
                     throw(0,0,0);
                     }
             }
@@ -324,12 +325,12 @@
             ctx->pacl[i].acl = "0.0.0.0";
             ctx->pacl[i].not = FALSE;
             ctx->pacl[i].prefixlen = 0;
-            if ((rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv4 pass-through address (internal) failed with \"%s\"", sa_error(rc));
+            if ((sa_rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) {
+                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv4 pass-through address (internal) failed with \"%s\"", sa_error(sa_rc));
                 throw(0,0,0);
             }
-            if ((rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv4 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc));
+            if ((sa_rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
+                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv4 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
                 throw(0,0,0);
             }
             i++;
@@ -342,12 +343,12 @@
             ctx->pacl[i].acl = "[::]";
             ctx->pacl[i].not = FALSE;
             ctx->pacl[i].prefixlen = 0;
-            if ((rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv6 pass-through address (internal) failed with \"%s\"", sa_error(rc));
+            if ((sa_rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) {
+                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv6 pass-through address (internal) failed with \"%s\"", sa_error(sa_rc));
                 throw(0,0,0);
             }
-            if ((rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv6 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(rc));
+            if ((sa_rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
+                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv6 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
                 throw(0,0,0);
             }
             i++;
@@ -369,12 +370,12 @@
         if (ov->ndata == 1) {
             /* dash means stdio */
             if (strcmp(ov->data.s, "-") != 0) {
-                if ((rc = sa_create(&ctx->saServerbind)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, creating TCP socket (internal) failed with \"%s\"", sa_error(rc));
+                if ((sa_rc = sa_create(&ctx->saServerbind)) != SA_OK) {
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, creating TCP socket (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                 }
-                if ((rc = sa_addr_create(&ctx->saaServerbind)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, create address (internal) failed with \"%s\"", sa_error(rc));
+                if ((sa_rc = sa_addr_create(&ctx->saaServerbind)) != SA_OK) {
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                 }
             /* slash means UNIX socket */
@@ -408,12 +409,12 @@
                             throw(0,0,0);
                         }
                     }
-                    if ((rc = sa_addr_u2a(ctx->saaServerbind, "unix:%s", cpPath)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing UNIX socket (%s) failed with \"%s\"", cpPath, sa_error(rc));
+                    if ((sa_rc = sa_addr_u2a(ctx->saaServerbind, "unix:%s", cpPath)) != SA_OK) {
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing UNIX socket (%s) failed with \"%s\"", cpPath, sa_error(sa_rc));
                         throw(0,0,0);
                     }
-                    if ((rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", cpPath, sa_error(rc));
+                    if ((sa_rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) {
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", cpPath, sa_error(sa_rc));
                         throw(0,0,0);
                     }
                     if (nPerm != -1) {
@@ -432,18 +433,18 @@
                 }
             /* otherwise assume INET socket */
                 else {
-                    if ((rc = sa_addr_u2a(ctx->saaServerbind, "inet://%s", ov->data.s)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(rc));
+                    if ((sa_rc = sa_addr_u2a(ctx->saaServerbind, "inet://%s", ov->data.s)) != SA_OK) {
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
                         throw(0,0,0);
                     }
-                    if ((rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", ov->data.s, sa_error(rc));
+                    if ((sa_rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) {
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
                         throw(0,0,0);
                     }
                 }
             /* for either sockets */
-                if ((rc = sa_listen(ctx->saServerbind, -1)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, listen (%s) failed with \"%s\"", ov->data.s, sa_error(rc));
+                if ((sa_rc = sa_listen(ctx->saServerbind, -1)) != SA_OK) {
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, listen (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
                         throw(0,0,0);
                 }
             }
@@ -462,14 +463,14 @@
         logbook(ctx->l2, L2_LEVEL_TRACE, "--client = \"%s\"", ov->data.s);
 
         if (ov->ndata == 1) {
-            if ((rc = sa_addr_create(&ctx->saaClientbind)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, create address (internal) failed with \"%s\"", sa_error(rc));
+            if ((sa_rc = sa_addr_create(&ctx->saaClientbind)) != SA_OK) {
+                logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                 throw(0,0,0);
             }
-            if ((rc = sa_addr_u2a(ctx->saaClientbind, 
+            if ((sa_rc = sa_addr_u2a(ctx->saaClientbind, 
                                   (strchr(ov->data.s, ':') == NULL) ?  "inet://%s:0" : "inet://%s", 
                                   ov->data.s)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(rc));
+                logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
                 throw(0,0,0);
             }
         }
@@ -499,16 +500,16 @@
                     cp = str_concat(cp, ":nntp", NULL); /* http://www.iana.org/assignments/port-numbers (and names) */
                 else
                     cp = str_concat(cp, NULL); /* prepare for free() */
-                if ((rc = sa_addr_create(&ctx->pns[i].saa)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, create address (internal) failed with \"%s\"", sa_error(rc));
+                if ((sa_rc = sa_addr_create(&ctx->pns[i].saa)) != SA_OK) {
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                 }
-                if ((rc = sa_addr_u2a(ctx->pns[i].saa, "inet://%s", cp)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, parsing host address (%s) failed with \"%s\"", cp, sa_error(rc));
+                if ((sa_rc = sa_addr_u2a(ctx->pns[i].saa, "inet://%s", cp)) != SA_OK) {
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, parsing host address (%s) failed with \"%s\"", cp, sa_error(sa_rc));
                     throw(0,0,0);
                 }
-                if ((rc = sa_create(&ctx->pns[i].sa)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\"", cp, sa_error(rc));
+                if ((sa_rc = sa_create(&ctx->pns[i].sa)) != SA_OK) {
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\"", cp, sa_error(sa_rc));
                     throw(0,0,0);
                 }
                 ctx->pns[i].nntp = NULL;
@@ -1129,12 +1130,13 @@
                     }
                 }
             }
-        exit(0); /* FIXME */
+        CU(CONFIG_OK_DRY);
         }
     }
     catch (ex)
         rethrow;
-CUS:
-    return;
+    CU(CONFIG_OK);
+    CUS:
+    return rc;
 }
 

CVSTrac 2.0.1