OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.31 -> 1.32

--- lmtp2nntp.c  2001/08/28 11:31:22     1.31
+++ lmtp2nntp.c  2001/08/28 13:12:58     1.32
@@ -124,24 +124,33 @@
  */
 static void usage(char *command)
 {
+    /*  use
+     *  perl <lmtp2nntp.c -e 'while (<>) { if(m/\/\*POD (.*) .*\*\//) { $_=$1; s/.<(.*?)>/$1/g ; print "$_ " };}'
+     *  to pull the USAGE string out of this source
+     */
     fprintf(stderr, 
-            "USAGE: %s [-p protocol] [-l logtarget] "
-            "[-h host[:port]] [-m mode] [-t] [-v] newsgroup [newsgroup ...]\n",
+            "USAGE: %s "
+            "lmtp2nntp [-d deliverymode] [-g groupmode] [-h host[:port]] "
+            "[-t tracefile] [-v] [-V] newsgroup [newsgroup ...]"
+            "\n",
             command);
     return;
 }
 
 int main(int argc, char **argv)
 {
-    int rc = 0;
-    lmtp_t *lmtp;
-    lmtp_io_t lmtp_io;
+    int          rc = 0;
+    lmtp_t      *lmtp;
+    lmtp_io_t    lmtp_io;
     lmtp2nntp_t *ctx;
-    int i;             /* general purpose scratch int, index ... */
-    char *progname;
-    char *cpHost;
-    char *cpPort;
-    sa_t *sa;
+    int          i;             /* general purpose scratch int, index ... */
+    char        *cp;            /* general purpose character pointer */
+    char        *progname;
+    char        *azHosts;
+    size_t       asHosts;
+    char        *cpHost;
+    char        *cpPort;
+    sa_t        *sa;
 
     progname = argv[0];
 
@@ -187,10 +196,17 @@
     }
 #endif
 
+    /*POD B<lmtp2nntp> */
+
+    /*  use
+     *  perl <lmtp2nntp.c -e 'while (<>) { if(m/\/\*POD (.*) .*\*\//) { $_=$1; s/.<(.*?)>/$1/g ; print "$_\n" };}'
+     *  to pull the POD SYNOPSIS header directly out of this source
+     */
+
     /* read in the arguments */
     while ((i = getopt(argc, argv, "d:g:h:t:vV")) != -1) {
         switch (i) {
-            case 'd': /* -d deliverymode */
+            case 'd': /*POD [B<-d> I<deliverymode>] */
                 if      (strcasecmp(optarg, "post") == 0)
                     ctx->option_deliverymode = DELIVERYMODE_POST;
                 else if (strcasecmp(optarg, "feed") == 0)
@@ -230,7 +246,7 @@
                         }
                     }
                 break;
-            case 'g': /* -g groupmode */
+            case 'g': /*POD [B<-g> I<groupmode>] */
                 if      (strcasecmp(optarg, "arg") == 0)
                     ctx->option_groupmode = GROUPMODE_ARG;
                 else if (strcasecmp(optarg, "envelope") == 0)
@@ -242,55 +258,61 @@
                     exit(ERR_EXECUTION);
                 }
                 break;
-            case 'h': /* -h host */
-                if (ctx->nsc >= MAXNEWSSERVICES) {
-                    fprintf(stderr, "%s:Error: Too many services (%d) using option -h\n", progname, ctx->nsc);
+            case 'h': /*POD [B<-h> I<host>[I<:port>]] */
+                if (argz_create_sep(optarg, ',', &azHosts, &asHosts) != 0)
                     exit(ERR_EXECUTION);
-                }
+                cp = NULL;
+                while ((cp = argz_next(azHosts, asHosts, cp)) != NULL) {
+                    if (ctx->nsc >= MAXNEWSSERVICES) {
+                        fprintf(stderr, "%s:Error: Too many services (%d) using option -h\n", progname, ctx->nsc);
+                        exit(ERR_EXECUTION);
+                    }
 
-                /* parse host[:port] string into host and port */
-                cpHost = strdup(optarg);
-                if ((cpPort = strrchr(cpHost, ':')) != NULL) {
-                    *cpPort++ = NUL;
-                    cpPort = strdup(cpPort);
-                }
-                else 
-                    cpPort = strdup("nntp");
-                ctx->ns[ctx->nsc].h = cpHost;
-                ctx->ns[ctx->nsc].p = cpPort;
-
-                if ((sa = sa_create(SA_IP, "tcp",
-                                    ctx->ns[ctx->nsc].h,
-                                    ctx->ns[ctx->nsc].p)) == NULL) {
-                    fprintf(stderr, "%s:Error: creating TCP socket address failed for \"%s:%s\": %s\n", 
-                            progname, 
-                            ctx->ns[ctx->nsc].h, 
-                            ctx->ns[ctx->nsc].p, 
-                            strerror(errno));
-                    exit(ERR_EXECUTION);
-                }
-                ctx->ns[ctx->nsc].sa = sa;
-                if ((ctx->ns[ctx->nsc].s =
-                     socket(sa->sa_buf->sa_family, SOCK_STREAM, sa->sa_proto)) == -1) {
-                    fprintf(stderr, "%s:Error: Creating TCP socket failed for \"%s:%s\": %s\n", 
-                            progname, 
-                            ctx->ns[ctx->nsc].h, 
-                            ctx->ns[ctx->nsc].p, 
-                            strerror(errno));
-                    exit(ERR_EXECUTION);
+                    /* parse host[:port] string into host and port */
+                    cpHost = strdup(cp);
+                    if ((cpPort = strrchr(cpHost, ':')) != NULL) {
+                        *cpPort++ = NUL;
+                        cpPort = strdup(cpPort);
+                    }
+                    else 
+                        cpPort = strdup("nntp");
+                    ctx->ns[ctx->nsc].h = cpHost;
+                    ctx->ns[ctx->nsc].p = cpPort;
+
+                    if ((sa = sa_create(SA_IP, "tcp",
+                                        ctx->ns[ctx->nsc].h,
+                                        ctx->ns[ctx->nsc].p)) == NULL) {
+                        fprintf(stderr, "%s:Error: creating TCP socket address failed for \"%s:%s\": %s\n", 
+                                progname, 
+                                ctx->ns[ctx->nsc].h, 
+                                ctx->ns[ctx->nsc].p, 
+                                strerror(errno));
+                        exit(ERR_EXECUTION);
+                    }
+                    ctx->ns[ctx->nsc].sa = sa;
+                    if ((ctx->ns[ctx->nsc].s =
+                         socket(sa->sa_buf->sa_family, SOCK_STREAM, sa->sa_proto)) == -1) {
+                        fprintf(stderr, "%s:Error: Creating TCP socket failed for \"%s:%s\": %s\n", 
+                                progname, 
+                                ctx->ns[ctx->nsc].h, 
+                                ctx->ns[ctx->nsc].p, 
+                                strerror(errno));
+                        exit(ERR_EXECUTION);
+                    }
+                    ctx->ns[ctx->nsc].nntp = NULL;
+                    ctx->nsc++;
                 }
-                ctx->ns[ctx->nsc].nntp = NULL;
-                ctx->nsc++;
+                free(azHosts);
                 break;
-            case 't': /* -t (tracing) */
+            case 't': /*POD [B<-t> I<tracefile>] */
                 ctx->option_tracing = TRUE;
                 trace_read (-1, optarg, 0);
                 trace_write(-1, optarg, 0);
                 break;
-            case 'v': /* -v (verbose) */
+            case 'v': /*POD [B<-v>] (verbose)*/
                 ctx->option_verbose = TRUE;
                 break;
-            case 'V': /* -V (version) */
+            case 'V': /*POD [B<-V>] (version)*/
                 fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu);
                 exit(0);
                 break;
@@ -300,7 +322,7 @@
                 exit(ERR_EXECUTION);
         }
     }
-    /* remaining arguments are Groupargs */
+    /*POD I<newsgroup> [I<newsgroup> ...] */
     for (i = optind; i < argc; i++) {
         argz_add(&ctx->azGroupargs, &ctx->asGroupargs, argv[i]);
     }

CVSTrac 2.0.1