OSSP CVS Repository

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

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");

CVSTrac 2.0.1