OSSP CVS Repository

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

Check-in Number: 1720
Date: 2002-Jan-30 17:41:02 (local)
2002-Jan-30 16:41:02 (UTC)
User:thl
Branch:
Comment: flush. first options moved. introduced exception handling.
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/example.conf      1.6 -> 1.7     6 inserted, 3 deleted
ossp-pkg/lmtp2nntp/fixme.h      1.1 -> 1.2     5 inserted, 2 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.17 -> 1.18     192 inserted, 10 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_global.h      1.3 -> 1.4     3 inserted, 11 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.11 -> 1.12     0 inserted, 157 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_option.c      1.3 -> 1.4     23 inserted, 21 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_option.h      1.2 -> 1.3     1 inserted, 3 deleted

ossp-pkg/lmtp2nntp/example.conf 1.6 -> 1.7

--- example.conf 2002/01/23 15:55:21     1.6
+++ example.conf 2002/01/30 16:41:02     1.7
@@ -28,9 +28,12 @@
 #include         "sampleconfig.two"             #    -i aka --include
                                                 #    -l is obsolete since v1.2, see l2spec
 
-l2spec          prefix(prefix="%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: ",timezone=local) \
-                   -> buffer(size=65536) \
-                   -> file(path=%s,append=1,perm=%d) \
+l2spec          ' \
+                debug: prefix(prefix="%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: ",timezone=local) \
+                -> file(path="2log",append=0,perm=432) \
+                '
+               #    -> file(path="2log",append=0,perm=0666) FIXME l2 should support octal notation
+               #'  #-> buffer(size=65536) \     #add this after prefix for log buffering
                                                 #    -l aka --l2spec
 
 mailfrom        "any.*@example\.org"            #see -m aka --mailfrom


ossp-pkg/lmtp2nntp/fixme.h 1.1 -> 1.2

--- fixme.h      2002/01/24 12:07:13     1.1
+++ fixme.h      2002/01/30 16:41:02     1.2
@@ -36,7 +36,7 @@
     l2_context_t    ctx;
     val_t          *val;
     char           *progname;
-    char           *option_logfile;
+    /*FIXME obsolete char           *option_logfile; */
     int             option_groupmode;
     int             option_operationmode;
     char           *option_operationmodefakestatus;
@@ -52,7 +52,7 @@
     int             option_timeout_nntp_write;
     char           *option_mailfrom;
     char           *option_restrictheader;
-    unsigned int    option_levelmask;
+    /*FIXME obsolete unsigned int    option_levelmask; */
     char           *option_pidfile;
     int             option_killflag;
     uid_t           option_uid;
@@ -83,4 +83,7 @@
     struct utsname  uname;
 } lmtp2nntp_t;
 
+#define ERR_EXECUTION 1
+#define ERR_DELIVERY -2
+
 #endif /* __FIXME_H__ */


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.17 -> 1.18

--- lmtp2nntp_config.c   2002/01/30 14:22:23     1.17
+++ lmtp2nntp_config.c   2002/01/30 16:41:02     1.18
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/stat.h>
+#include <errno.h>
 
 /* third party (included) */
 #include "lmtp2nntp_argz.h"
@@ -36,6 +37,7 @@
 #include "str.h"
 #include "val.h"
 #include "popt.h"
+#include "l2.h"
 
 /* library version check (compile-time) */
 #define STR_VERSION_HEX_REQ 0x009206
@@ -75,20 +77,200 @@
 #define NUL '\0'
 #endif
 
+static l2_result_t 
+formatter_prefix(l2_context_t *_ctx, const char id, const char *param,
+          char *bufptr, size_t bufsize, size_t *buflen, va_list *ap)
+{
+    lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx->vp;
+            
+    if ((ctx->msg != NULL) && (ctx->msg->cpFid != NULL)) {
+        sprintf(bufptr, "%s: ", ctx->msg->cpFid);
+        *buflen = strlen(bufptr);
+    }
+    else
+        *buflen = 0;
+    return L2_OK;
+}
+
+static l2_result_t 
+formatter_errno(l2_context_t *_ctx, const char id, const char *param,
+          char *bufptr, size_t bufsize, size_t *buflen, va_list *ap)
+{
+    sprintf(bufptr, "(%d) %s", errno, strerror(errno));
+    *buflen = strlen(bufptr);
+    return L2_OK;
+}
+
 void config_context(lmtp2nntp_t *ctx)
 {
+    ex_t ex;
     optionval_t *ov;
-    char *cp;
+    //char *cp;
+    int 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);
+    }
+    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);
+    }
+    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);
+    }
+    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);
+    }
+    if (l2_env_formatter(ctx->l2_env, 'm', formatter_errno, NULL) != L2_OK) {
+        fprintf(stderr, "%s:Error: logging failed to register errno formatter\n", ctx->progname);
+        CU(ERR_EXECUTION);
+    }
+    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);
+    }
+    if (ov->data.s != NULL) {
+        if ((rc = l2_spec(&ctx->l2, ctx->l2_env, ov->data.s)) != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname);
+            CU(ERR_EXECUTION);
+        }
+        if (l2_channel_levels(ctx->l2, L2_LEVEL_ALL, L2_LEVEL_NONE) != L2_OK) { /* FIXME should this globalmask and flushmask be user-configurable? */
+            fprintf(stderr, "%s:Error: logging failed to set global logging level\n", ctx->progname);
+            CU(ERR_EXECUTION);
+        }
+        if (l2_channel_open(ctx->l2) != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to open channel stream\n", ctx->progname);
+            CU(ERR_EXECUTION);
+        }
+    }
+    /* from this point on logging is up and running and fprintf(stderr, ...)
+     * should not be used in the remainder of the program flow.
+     */
+    log1(ctx, NOTICE, "startup, version %s", lmtp2nntp_version.v_gnu);
+
+    /* --childsmax SINGLE */
+    try {
+        if (   (val_get(ctx->val, "option.childsmax", &ov) != VAL_OK)
+            || (ov->ndata != 1)
+            || (ov->data.s == NULL)
+              ) throw(0,0,0);
+        log1(ctx, TRACE, "--childsmax = \"%s\"", ov->data.s);
+        if ((ctx->option_childsmax = atoi(ov->data.s)) <= 0) {
+            log1(ctx, ERROR, "number (%d) out of range for option --childsmax\n", ctx->option_childsmax);
+            throw(0,0,0);
+        }
+    }
+    catch (ex) {
+        log1(ctx, ERROR, "caught class  %s\n", ex.ex_class  == NULL ? "N/A" : (char *)ex.ex_class );
+        log1(ctx, ERROR, "caught object %s\n", ex.ex_object == NULL ? "N/A" : (char *)ex.ex_object);
+        log1(ctx, ERROR, "caught value  %s\n", ex.ex_value  == NULL ? "N/A" : (char *)ex.ex_value );
+        rethrow;
+    }
+
+    /* --daemonize FLAG */
+    try {
+        if (   (val_get(ctx->val, "option.daemonize", &ov) != VAL_OK)
+            || (ov->ndata != 1)
+            || (ov->data.f != 1)
+              ) throw(0,0,0);
+        log1(ctx, TRACE, "--daemonize = %d", ov->data.f);
+        ctx->option_daemon = TRUE;
+    }
+    catch (ex)
+        rethrow;
 
-    printf("DEBUG: Hello, World!\n");
-    //case 'C': /*POD [B<-C> I<childsmax>] */
-    if (val_get(ctx->val, "option.childsmax", &ov) != VAL_OK)
-        fprintf(stderr, "%s:Error: (internal) config did not register 'childsmax' option\n", ctx->progname);
-    printf("DEBUG: option_childsmax %d = \"%s\"\n", ov->ndata, ov->data.s);
-    ctx->option_childsmax = atoi(ov->data.s);
-    if (ctx->option_childsmax <= 0) {
-        fprintf(stderr, "%s:Error: Invalid number (%d) to option -C\n", ctx->progname, ctx->option_childsmax);
-        return; //FIXME CU(ERR_EXECUTION);
+    /* --kill FLAG */
+    try {
+        if (   (val_get(ctx->val, "option.kill", &ov) != VAL_OK)
+            || (ov->ndata != 1)
+            || (ov->data.f != 1)
+              ) throw(0,0,0);
+        log1(ctx, TRACE, "--kill = %d", ov->data.f);
+        ctx->option_killflag = TRUE;
     }
+    catch (ex)
+        rethrow;
+
+    /* --pidfile SINGLE */
+    try {
+        if (   (val_get(ctx->val, "option.pidfile", &ov) != VAL_OK)
+            || (ov->ndata != 1)
+            || (ov->data.s == NULL)
+              ) throw(0,0,0);
+        log1(ctx, TRACE, "--pidfile = \"%s\"", ov->data.s);
+        ctx->option_pidfile = ov->data.s;
+    }
+    catch (ex)
+        rethrow;
+
+    /* --acl MULTI */
+    try {
+        int i;
+        char *cp;
+        struct acl *acl;
+
+        if (   (val_get(ctx->val, "option.acl", &ov) != VAL_OK)
+            || ((ov->ndata >= 1) && (ov->data.m == NULL))
+              ) throw(0,0,0);
+        for (i = 0; i < ov->ndata; i++)
+            log2(ctx, TRACE, "--acl[%d] = \"%s\"", i, (ov->data.m)[i]);
+        log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata);
+        if ((acl = (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);
+            //ctx->option_acl[ctx->option_aclc].acl = strdup(cp);
+        }
+
+    }
+    catch (ex)
+        rethrow;
+#if 0
+
+                if (argz_create_sep(optarg, ',', &azACL, &asACL) != 0)
+                    CU(ERR_EXECUTION);
+                cp = NULL;
+                while ((cp = argz_next(azACL, asACL, cp)) != NULL) {
+                    if (ctx->option_aclc >= MAXACLS) {
+                        fprintf(stderr, "%s:Error: Too many ACL (%d) using option -a\n", ctx->progname, ctx->option_aclc);
+                        CU(ERR_EXECUTION);
+                    }
+
+
+
+                    ctx->option_acl[ctx->option_aclc].acl = strdup(cp);
+                    if (cp[0] == '!') {
+                        ctx->option_acl[ctx->option_aclc].not = TRUE;
+                        cpAddr = strdup(cp+1);
+                    }
+                    else {
+                        cpAddr = strdup(cp);
+                    }
+                    if ((cpPrefixLen = strrchr(cpAddr, '/')) != NULL)
+                        *cpPrefixLen++ = NUL;
+                    else
+                        cpPrefixLen = "-1";
+                    ctx->option_acl[ctx->option_aclc].prefixlen = atoi(cpPrefixLen);
+                    if ((rc = sa_addr_create(&ctx->option_acl[ctx->option_aclc].saa)) != SA_OK) {
+                        fprintf(stderr, "%s:Error: Creating address failed for -a option (%d)\n", 
+                                ctx->progname, rc);
+                    }
+                    if ((rc = sa_addr_u2a(ctx->option_acl[ctx->option_aclc].saa, "inet://%s:0", cpAddr)) != SA_OK) {
+                        fprintf(stderr, "%s:Error: Parsing host address failed for \"%s:0\" (%d)\n", 
+                                ctx->progname, cpAddr, rc);
+                        CU(ERR_EXECUTION);
+                    }
+                    ctx->option_aclc++;
+                    free(cpAddr);
+                }
+                free(azACL);
+#endif
+
+
+CUS:
     return;
 }


ossp-pkg/lmtp2nntp/lmtp2nntp_global.h 1.3 -> 1.4

--- lmtp2nntp_global.h   2002/01/17 17:01:55     1.3
+++ lmtp2nntp_global.h   2002/01/30 16:41:02     1.4
@@ -34,17 +34,6 @@
 #include "dmalloc.h"
 #endif
 
-#define log0(ctx,level,msg) \
-    l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg)
-#define log1(ctx,level,msg,a1) \
-    l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1)
-#define log2(ctx,level,msg,a1,a2) \
-    l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1, a2)
-#define log3(ctx,level,msg,a1,a2,a3) \
-    l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1, a2, a3)
-#define log4(ctx,level,msg,a1,a2,a3,a4) \
-    l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1, a2, a3, a4)
-
 #define STMT(stuff) do { stuff } while (0)
 #define CU(returncode) STMT( rc = returncode; goto CUS; )
 #define VCU STMT( goto CUS; )
@@ -54,4 +43,7 @@
     char   *az;
 } argz_t;
 
+#define __EX_NS_USE_CXX__
+#include <ex.h>
+
 #endif /* __LMTP2NNTP_H__ */


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.11 -> 1.12

--- lmtp2nntp_main.c     2002/01/30 14:22:23     1.11
+++ lmtp2nntp_main.c     2002/01/30 16:41:02     1.12
@@ -98,9 +98,6 @@
 #define NUL '\0'
 #endif
 
-#define ERR_EXECUTION 1
-#define ERR_DELIVERY -2
-
 #define STDSTRLEN 512
 
 static lmtp_rc_t lmtp_cb_lhlo(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
@@ -321,30 +318,6 @@
     return rc;
 }
 
-static l2_result_t 
-formatter_prefix(l2_context_t *_ctx, const char id, const char *param,
-          char *bufptr, size_t bufsize, size_t *buflen, va_list *ap)
-{
-    lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx->vp;
-            
-    if ((ctx->msg != NULL) && (ctx->msg->cpFid != NULL)) {
-        sprintf(bufptr, "%s: ", ctx->msg->cpFid);
-        *buflen = strlen(bufptr);
-    }
-    else
-        *buflen = 0;
-    return L2_OK;
-}
-
-static l2_result_t 
-formatter_errno(l2_context_t *_ctx, const char id, const char *param,
-          char *bufptr, size_t bufsize, size_t *buflen, va_list *ap)
-{
-    sprintf(bufptr, "(%d) %s", errno, strerror(errno));
-    *buflen = strlen(bufptr);
-    return L2_OK;
-}
-
 static void catchsignal(int sig, ...)
 {
     va_list ap;
@@ -435,7 +408,6 @@
     ctx->val = NULL;
     ctx->progname = NULL;
     ctx->option_childsmax = 10;
-    ctx->option_logfile = NULL;
     ctx->option_groupmode = GROUPMODE_ARG;
     ctx->option_operationmode = OPERATIONMODE_FAKE;
     ctx->option_operationmodefakestatus = "553";   /* Requested action not taken: mailbox name not allowed */
@@ -451,7 +423,6 @@
     ctx->option_timeout_nntp_write = 60;
     ctx->option_mailfrom = NULL;
     ctx->option_restrictheader = NULL;
-    ctx->option_levelmask = L2_LEVEL_NONE;
     ctx->option_pidfile = NULL;
     ctx->option_killflag = FALSE;
     ctx->option_uid = getuid();
@@ -516,54 +487,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>] */
-                ctx->option_daemon = TRUE;
-                break;
-            case 'K': /*POD [B<-K>] */
-                ctx->option_killflag = TRUE;
-                break;
-            case 'P': /*POD [B<-P> I<pidfile>] */
-                ctx->option_pidfile = strdup(optarg);
-                break;
-            case 'V': /*POD [B<-V>] */
-                ctx->option_veryverbose = TRUE;
-                break;
-            case 'a': /*POD [B<-a> I<addr>/I<mask>[,I<addr>/I<mask>[,...]] */
-                if (argz_create_sep(optarg, ',', &azACL, &asACL) != 0)
-                    CU(ERR_EXECUTION);
-                cp = NULL;
-                while ((cp = argz_next(azACL, asACL, cp)) != NULL) {
-                    if (ctx->option_aclc >= MAXACLS) {
-                        fprintf(stderr, "%s:Error: Too many ACL (%d) using option -a\n", ctx->progname, ctx->option_aclc);
-                        CU(ERR_EXECUTION);
-                    }
-                    ctx->option_acl[ctx->option_aclc].acl = strdup(cp);
-                    if (cp[0] == '!') {
-                        ctx->option_acl[ctx->option_aclc].not = TRUE;
-                        cpAddr = strdup(cp+1);
-                    }
-                    else {
-                        cpAddr = strdup(cp);
-                    }
-                    if ((cpPrefixLen = strrchr(cpAddr, '/')) != NULL)
-                        *cpPrefixLen++ = NUL;
-                    else
-                        cpPrefixLen = "-1";
-                    ctx->option_acl[ctx->option_aclc].prefixlen = atoi(cpPrefixLen);
-                    if ((rc = sa_addr_create(&ctx->option_acl[ctx->option_aclc].saa)) != SA_OK) {
-                        fprintf(stderr, "%s:Error: Creating address failed for -a option (%d)\n", 
-                                ctx->progname, rc);
-                    }
-                    if ((rc = sa_addr_u2a(ctx->option_acl[ctx->option_aclc].saa, "inet://%s:0", cpAddr)) != SA_OK) {
-                        fprintf(stderr, "%s:Error: Parsing host address failed for \"%s:0\" (%d)\n", 
-                                ctx->progname, cpAddr, rc);
-                        CU(ERR_EXECUTION);
-                    }
-                    ctx->option_aclc++;
-                    free(cpAddr);
-                }
-                free(azACL);
-                break;
             case 'b': /*POD [B<-b> I<addr>[I<:port>]|C<->|I<path>[:perms]] */
                 if (strcmp(optarg, "-") != 0) {
                     if ((rc = sa_create(&ctx->saAltio)) != SA_OK) {
@@ -737,25 +660,6 @@
                 free(cpHeadervalue);
                 free(cpHeadername);
                 break;
-            case 'l': /*POD [B<-l> I<level>[:I<logfile>]] */
-                if ((cp = strrchr(optarg, ':')) != NULL) {
-                    *cp++ = NUL;
-                    if (*cp == NUL) {
-                        fprintf(stderr, "%s:Error: empty logfile to option -l\n", ctx->progname);
-                        CU(ERR_EXECUTION);
-                    }
-                    else
-                        ctx->option_logfile = strdup(cp);
-                }
-                else
-                    ctx->option_logfile = strdup("logfile");
-
-                if (l2_util_s2l(optarg, strlen(optarg), ',', &ctx->option_levelmask) != L2_OK) {
-                    fprintf(stderr, "%s:Error: invalid level \"%s\" to option -l\n", ctx->progname, optarg);
-                    CU(ERR_EXECUTION);
-                }
-                ctx->option_levelmask = L2_LEVEL_UPTO(ctx->option_levelmask);
-                break;
             case 'm': /*POD [B<-m> I<mailfrom>] */
                 ctx->option_mailfrom = strdup(optarg);
                 /* protect ourselfs from the substitution of backreferences.
@@ -975,65 +879,6 @@
         }
     }
 
-    /* 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);
-    }
-
-    /* register custom L2 formatters */
-    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);
-    }
-    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);
-    }
-    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);
-    }
-    if (l2_env_formatter(ctx->l2_env, 'm', formatter_errno, NULL) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to register errno formatter\n", ctx->progname);
-        CU(ERR_EXECUTION);
-    }
-
-    /* create channel stream */
-    if (ctx->option_levelmask != L2_LEVEL_NONE && ctx->option_logfile != NULL) {
-        if (ctx->option_veryverbose)
-            rc = l2_spec(&ctx->l2, ctx->l2_env, 
-                         "prefix(prefix=\"%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: \",timezone=local)"
-                         "  -> buffer(size=65536)"
-                         "  -> file(path=%s,append=1,perm=%d)",
-                         ctx->option_logfile, 0644);
-        else
-            rc = l2_spec(&ctx->l2, ctx->l2_env, 
-                         "prefix(prefix=\"%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: \",timezone=local)"
-                         "  -> file(path=%s,append=1,perm=%d)",
-                         ctx->option_logfile, 0644);
-        if (rc != L2_OK) {
-            fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname);
-            CU(ERR_EXECUTION);
-        }
-        if (l2_channel_levels(ctx->l2, ctx->option_levelmask, L2_LEVEL_NONE) != L2_OK) {
-            fprintf(stderr, "%s:Error: logging failed to set global logging level\n", ctx->progname);
-            CU(ERR_EXECUTION);
-        }
-        if (l2_channel_open(ctx->l2) != L2_OK) {
-            fprintf(stderr, "%s:Error: logging failed to open channel stream\n", ctx->progname);
-            CU(ERR_EXECUTION);
-        }
-    }
-
-    /* from this point on logging is up and running and fprintf(stderr, ...)
-     * should not be used in the remainder of the code
-     */
-
-    log1(ctx, NOTICE, "startup, version %s", lmtp2nntp_version.v_gnu);
-    if (ctx->option_veryverbose)
-        log0(ctx, NOTICE, "logging very verbose (unbuffered)");
-
     if ((ctx->option_pidfile != NULL) && ctx->option_killflag) {
         if ((fd = fopen(ctx->option_pidfile, "r")) == NULL)
             log1(ctx, ERROR, "cannot open pidfile \"%s\" for reading %m", ctx->option_pidfile);
@@ -1267,8 +1112,6 @@
         free(ctx->azHeaderValuePairs);
     if (ctx->option_pidfile != NULL)
         free(ctx->option_pidfile);
-    if (ctx->option_logfile != NULL)
-        free(ctx->option_logfile);
     if (ctx->progname != NULL)
         free(ctx->progname);
     if (ctx->azGroupargs != NULL)


ossp-pkg/lmtp2nntp/lmtp2nntp_option.c 1.3 -> 1.4

--- lmtp2nntp_option.c   2002/01/30 14:22:23     1.3
+++ lmtp2nntp_option.c   2002/01/30 16:41:02     1.4
@@ -73,12 +73,7 @@
 #define NUL '\0'
 #endif
 
-static void die(char *msg)
-{
-    printf("ERROR: %s\n", msg);
-    exit(-1);
-}
-
+#if 0
 static val_rc_t dumper(void *ctx, const char *name, int type, const char *desc, void *data)
 {
     optionval_t *oc;
@@ -98,7 +93,6 @@
         case OPT_MULTI:
             printf("DEBUG: <%5s>, name=<%20s>, OPT_MULTI,  desc=<%20s>, data@%.8lx->[%d]%.8lx\n",  (char *)ctx, name, desc, (long)oc, oc->ndata, (long)oc->data.m);
             for (i = 0; i < oc->ndata; i++) {
-#if 0
                 {
                     int j;
                     printf("DEBUG: ");
@@ -107,7 +101,6 @@
                     for (j=0; j<8; j++) printf("%c", isprint(oc->data.m[i][j]) ? oc->data.m[i][j] : '.');
                     printf(" ");
                 }
-#endif
                 printf("DEBUG: [%3d] %.8lx \"%s\"\n", i, (long)oc->data.m[i], oc->data.m[i]);
             }
             break;
@@ -116,7 +109,8 @@
     }
     return VAL_OK;
 }
-//lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionval_t **ocp);
+#endif
+
 static lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionval_t **ocp)
 {
     lmtp2nntp_option_rc_t rc = VAL_OK;
@@ -466,7 +460,7 @@
 static lmtp2nntp_option_rc_t includeit(optionval_t *oc, char *arg, char *cbctx)
 {
     lmtp2nntp_option_t *o;
-    char *cpBuf = NULL;
+    volatile char *cpBuf = NULL;
     int argc = 0;
     char **argv = NULL;
 
@@ -480,15 +474,23 @@
     {
         const char *filename = arg;
         struct stat sb;
-        int fd;
+        volatile int fd = -1;
+        ex_t ex;
 
-        if (stat(filename, &sb) == -1) die("stat");
-        if ((cpBuf = (char *)malloc((size_t)sb.st_size + 1)) == NULL) die("malloc");
-        if ((fd = open(filename, O_RDONLY)) == -1) die("open");
-        if (read(fd, (void *)cpBuf, (size_t)sb.st_size) != (ssize_t)sb.st_size) die("read");
-        cpBuf[(int)sb.st_size] = '\0';
-        if (close(fd) == -1)
-            die("close");
+        try {
+            if (stat(filename, &sb) == -1) throw(0, 0, "stat");
+            if ((cpBuf = (char *)malloc((size_t)sb.st_size + 1)) == NULL) throw(0, 0, "malloc");
+            if ((fd = open(filename, O_RDONLY)) == -1) throw(0, 0, "open");
+            if (read(fd, (void *)cpBuf, (size_t)sb.st_size) != (ssize_t)sb.st_size) throw(0, 0, "read");
+            cpBuf[(int)sb.st_size] = '\0';
+        }
+        cleanup {
+            if (fd != -1) close(fd);
+        }
+        catch (ex) {
+            fprintf(stderr, "ERROR: caught %s\n", ex.ex_value == NULL ? "N/A" : (char *)ex.ex_value);
+            rethrow;
+        }
     }
     //printf("DEBUG: *** 2 *** file as it was just read in ***\n%s***\n", cpBuf);
 
@@ -504,8 +506,8 @@
         char p;     /* previous character */
         int eof;    /* flag signaling end of file detected */
 
-        cpI = cpBuf;
-        cpO = cpBuf;
+        cpI = (char *)cpBuf;
+        cpO = (char *)cpBuf;
         eof = FALSE;
         pline = 1;
         p = NUL;
@@ -621,7 +623,7 @@
     (void)option_register(o, "mailfrom",           'm', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo20", "regex" );
     (void)option_register(o, "nodename",           'n', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo21", "nodename" );
     (void)option_register(o, "operationmode",      'o', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo22", "post|feed" );
-    (void)option_register(o, "l2spec",             'l', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo23", "spec" );
+    (void)option_register(o, "l2spec",             'l', OPT_SINGLE, &stdsyntax, "m/.*/",     "L2 channel tree textual specification", "l2spec" );
     (void)option_register(o, "uid",                'u', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo24", "number|name" );
     (void)option_register(o, "restrictheader",     'r', OPT_MULTI,  &stdsyntax, "m/.*/",     "foo25", "regex" );
     (void)option_register(o, "newsgroup",          NUL, OPT_MULTI,  &stdsyntax, "m/.*/",     "foo26", "newsgroup");


ossp-pkg/lmtp2nntp/lmtp2nntp_option.h 1.2 -> 1.3

--- lmtp2nntp_option.h   2002/01/24 16:25:54     1.2
+++ lmtp2nntp_option.h   2002/01/30 16:41:02     1.3
@@ -96,11 +96,9 @@
     val_t              *val;            /* val we are registered under */
                     /**/
     int                 number;         /* number of this option for popt */
-    struct {                             /* option data as read from configuration */
+    union {                             /* option data as read from configuration */
         int f;                          /* OPT_FLAG */
-        void *foo1, *foo2, *foo3, *foo4, *foo5, *foo6, *foo7, *foo8, *foo9; 
         char *s;                        /* OPT_SINGLE */
-        void *bar1, *bar2, *bar3, *bar4, *bar5, *bar6, *bar7, *bar8, *bar9; 
         char **m;                       /* OPT_MULTI */
     } data;
     int ndata;

CVSTrac 2.0.1