OSSP CVS Repository

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

Check-in Number: 1748
Date: 2002-Jan-31 16:03:23 (local)
2002-Jan-31 15:03:23 (UTC)
User:thl
Branch:
Comment: moved --operationmode option
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/fixme.h      1.7 -> 1.8     6 inserted, 0 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.27 -> 1.28     51 inserted, 0 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.21 -> 1.22     0 inserted, 46 deleted

ossp-pkg/lmtp2nntp/fixme.h 1.7 -> 1.8

--- fixme.h      2002/01/31 13:54:21     1.7
+++ fixme.h      2002/01/31 15:03:23     1.8
@@ -113,4 +113,10 @@
     GROUPMODE_HEADER
 };
 
+enum {
+    OPERATIONMODE_FAKE,
+    OPERATIONMODE_POST,
+    OPERATIONMODE_FEED
+};
+
 #endif /* __FIXME_H__ */


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.27 -> 1.28

--- lmtp2nntp_config.c   2002/01/31 14:47:13     1.27
+++ lmtp2nntp_config.c   2002/01/31 15:03:23     1.28
@@ -513,6 +513,57 @@
     }
     catch (ex)
         rethrow;
+
+    /* --operationmode SINGLE */
+    try {
+        char *cp;
+
+        if (   (val_get(ctx->val, "option.operationmode", &ov) != VAL_OK)
+            || (ov->ndata != 1)
+            || (ov->data.s == NULL)
+              ) throw(0,0,0);
+        log1(ctx, TRACE, "--operationmode = \"%s\"", ov->data.s);
+
+        cp = strdup(ov->data.s);
+        if      (strcasecmp(cp, "post") == 0)
+            ctx->option_operationmode = OPERATIONMODE_POST;
+        else if (strcasecmp(cp, "feed") == 0)
+            ctx->option_operationmode = OPERATIONMODE_FEED;
+        else {
+            if (strlen(cp) != 9) {
+                log1(ctx, ERROR, "option --operationmode, invalid length (%s)", cp);
+                throw(0,0,0);
+            }
+            if (cp[3] != '/') {
+                log1(ctx, ERROR, "option --operationmode, missing slash (%s)", cp);
+                throw(0,0,0);
+            }
+            cp[3] = NUL;
+            ctx->option_operationmodefakestatus = &cp[0];
+            ctx->option_operationmodefakedsn    = &cp[4];
+            if (   strlen(ctx->option_operationmodefakestatus) != 3
+                || !isdigit((int)ctx->option_operationmodefakestatus[0])
+                || !isdigit((int)ctx->option_operationmodefakestatus[1])
+                || !isdigit((int)ctx->option_operationmodefakestatus[2])
+                  ) {
+                log1(ctx, ERROR, "option --operationmode, invalid status code (%s)", cp);
+                throw(0,0,0);
+            }
+            if (   (strlen(ctx->option_operationmodefakedsn) != 5)
+                || !isdigit((int)ctx->option_operationmodefakedsn[0])
+                || (ctx->option_operationmodefakedsn[1] != '.')
+                || !isdigit((int)ctx->option_operationmodefakedsn[2])
+                || (ctx->option_operationmodefakedsn[3] != '.')
+                || !isdigit((int)ctx->option_operationmodefakedsn[4])
+                || (ctx->option_operationmodefakedsn[0] != ctx->option_operationmodefakestatus[0])
+                  ) {
+                log1(ctx, ERROR, "option --operationmode, invalid dsn code (%s)", cp);
+                throw(0,0,0);
+            }
+        }
+    }
+    catch (ex)
+        rethrow;
 CUS:
     return;
 }


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.21 -> 1.22

--- lmtp2nntp_main.c     2002/01/31 14:47:13     1.21
+++ lmtp2nntp_main.c     2002/01/31 15:03:23     1.22
@@ -189,12 +189,6 @@
 static void lmtp_gfs_rset(lmtp2nntp_t *);
 static void lmtp_gfs_quit(lmtp2nntp_t *);
 
-enum {
-    OPERATIONMODE_FAKE,
-    OPERATIONMODE_POST,
-    OPERATIONMODE_FEED
-};
-
 /*
  * print usage information
  */
@@ -456,46 +450,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 'o': /*POD [B<-o> I<operationmode>] */
-                if      (strcasecmp(optarg, "post") == 0)
-                    ctx->option_operationmode = OPERATIONMODE_POST;
-                else if (strcasecmp(optarg, "feed") == 0)
-                    ctx->option_operationmode = OPERATIONMODE_FEED;
-                else {
-                    if (strlen(optarg) != 9) {
-                        fprintf(stderr, "%s:Error: Invalid format or length \"%s\" to option -o\n", ctx->progname, optarg);
-                        CU(ERR_EXECUTION);
-                    }
-
-                    if (optarg[3] != '/') {
-                        fprintf(stderr, "%s:Error: Invalid format or missing slash \"%s\" to option -o\n", ctx->progname, optarg);
-                        CU(ERR_EXECUTION);
-                    }
-
-                    optarg[3] = NUL;
-                    ctx->option_operationmodefakestatus = &optarg[0];
-                    ctx->option_operationmodefakedsn    = &optarg[4];
-
-                    if (   strlen(ctx->option_operationmodefakestatus) != 3
-                        || !isdigit((int)ctx->option_operationmodefakestatus[0])
-                        || !isdigit((int)ctx->option_operationmodefakestatus[1])
-                        || !isdigit((int)ctx->option_operationmodefakestatus[2])) {
-                            fprintf(stderr, "%s:Error: Invalid status in format \"%s\" to option -o\n", ctx->progname, optarg);
-                            CU(ERR_EXECUTION);
-                        }
-
-                    if (   (strlen(ctx->option_operationmodefakedsn) != 5)
-                        || !isdigit((int)ctx->option_operationmodefakedsn[0])
-                        || (ctx->option_operationmodefakedsn[1] != '.')
-                        || !isdigit((int)ctx->option_operationmodefakedsn[2])
-                        || (ctx->option_operationmodefakedsn[3] != '.')
-                        || !isdigit((int)ctx->option_operationmodefakedsn[4])
-                        || (ctx->option_operationmodefakedsn[0] != ctx->option_operationmodefakestatus[0])) {
-                            fprintf(stderr, "%s:Error: Invalid dsn in format \"%s\" to option -o\n", ctx->progname, optarg);
-                            CU(ERR_EXECUTION);
-                        }
-                    }
-                break;
             case 'r': /*POD [B<-r> I<restrictheader>] */
                 ctx->option_restrictheader = strdup(optarg);
                 /* protect ourselfs from the substitution of backreferences.

CVSTrac 2.0.1