OSSP CVS Repository

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

Check-in Number: 611
Date: 2001-Aug-07 11:21:49 (local)
2001-Aug-07 09:21:49 (UTC)
User:thl
Branch:
Comment: replaced newsservicecount and newsservice by nsc and ns
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.9 -> 1.10     43 inserted, 36 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.9 -> 1.10

--- lmtp2nntp.c  2001/08/07 09:05:55     1.9
+++ lmtp2nntp.c  2001/08/07 09:21:49     1.10
@@ -70,7 +70,7 @@
 };
 static void resetmessage(struct message *message);
 
-struct newsservice {
+struct ns {
     char *h;        /* host */
     char *p;        /* port */
     sa_t *sa;
@@ -82,10 +82,12 @@
     int     option_verbose;
     int     option_tracing;
     int     option_groupmode;
-    int     newsservicecount;
-    struct  newsservice newsservice[MAXNEWSSERVICES];
-    char   *azArggroups;
-    size_t  asArggroups;
+    int     nsc;
+    struct  ns ns[MAXNEWSSERVICES];
+    char   *azGroups;
+    size_t  asGroups;
+    char   *azGroupfilters;
+    size_t  asGroupfilters;
     struct  session session;
     struct  message message;
 } lmtp2nntp_t;
@@ -167,14 +169,16 @@
     ctx->option_verbose = FALSE;
     ctx->option_tracing = FALSE;
     ctx->option_groupmode = GROUPMODE_ARG;
-    ctx->newsservicecount = 0;
+    ctx->nsc = 0;
     for (i=0; i < MAXNEWSSERVICES; i++) {
-        ctx->newsservice[i].h = "";
-        ctx->newsservice[i].s = -1;
-        ctx->newsservice[i].nntp = NULL;
+        ctx->ns[i].h = "";
+        ctx->ns[i].s = -1;
+        ctx->ns[i].nntp = NULL;
     }
-    ctx->azArggroups = NULL;
-    ctx->asArggroups = 0;
+    ctx->azGroups = NULL;
+    ctx->asGroups = 0;
+    ctx->azGroupfilters = NULL;
+    ctx->asGroupfilters = 0;
     resetsession(&ctx->session);
     resetmessage(&ctx->message);
 
@@ -207,8 +211,8 @@
                 }
                 break;
             case 'h': /* -h host */
-                if (ctx->newsservicecount >= MAXNEWSSERVICES) {
-                    fprintf(stderr, "%s:Error: Too many services (%d) using option -h\n", progname, ctx->newsservicecount);
+                if (ctx->nsc >= MAXNEWSSERVICES) {
+                    fprintf(stderr, "%s:Error: Too many services (%d) using option -h\n", progname, ctx->nsc);
                     exit(ERR_EXECUTION);
                 }
 
@@ -220,32 +224,32 @@
                 }
                 else 
                     cpPort = strdup("nntp");
-                ctx->newsservice[ctx->newsservicecount].h = cpHost;
-                ctx->newsservice[ctx->newsservicecount].p = cpPort;
+                ctx->ns[ctx->nsc].h = cpHost;
+                ctx->ns[ctx->nsc].p = cpPort;
 
                 if ((sa = sa_create(SA_IP, "tcp",
-                                    ctx->newsservice[ctx->newsservicecount].h,
-                                    ctx->newsservice[ctx->newsservicecount].p)) == NULL) {
+                                    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->newsservice[ctx->newsservicecount].h, 
-                            ctx->newsservice[ctx->newsservicecount].p, 
+                            ctx->ns[ctx->nsc].h, 
+                            ctx->ns[ctx->nsc].p, 
                             strerror(errno));
                     exit(ERR_EXECUTION);
                 }
-                if ((ctx->newsservice[ctx->newsservicecount].s =
+                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->newsservice[ctx->newsservicecount].h, 
-                            ctx->newsservice[ctx->newsservicecount].p, 
+                            ctx->ns[ctx->nsc].h, 
+                            ctx->ns[ctx->nsc].p, 
                             strerror(errno));
                     exit(ERR_EXECUTION);
                 }
-                ctx->newsservice[ctx->newsservicecount].sa = sa;
+                ctx->ns[ctx->nsc].sa = sa;
                 //FIXME sa_destroy(sa);
-                ctx->newsservice[ctx->newsservicecount].nntp = NULL;
-                ctx->newsservicecount++;
+                ctx->ns[ctx->nsc].nntp = NULL;
+                ctx->nsc++;
                 break;
             case 't': // -t (tracing)
                 ctx->option_tracing = TRUE;
@@ -259,9 +263,12 @@
                 exit(ERR_EXECUTION);
         }
     }
-    /* remaining arguments are groups */
+    /* remaining arguments are groups or group filters */
     for (i = optind; i < argc; i++)
-        argz_add(&ctx->azArggroups, &ctx->asArggroups, argv[i]);
+        if (ctx->option_groupmode == GROUPMODE_ENVELOPE)
+            argz_add(&ctx->azGroupfilters, &ctx->asGroupfilters, argv[i]);
+        else
+            argz_add(&ctx->azGroups, &ctx->asGroups, argv[i]);
 
     /* initialize LMTP context */
     lmtp_io.read  = trace_read;
@@ -366,7 +373,7 @@
         return LMTP_OK;
     }
 
-    if (ctx->newsservicecount == 0) {
+    if (ctx->nsc == 0) {
         res.statuscode = "501";
         res.dsncode    = "5.0.0";
         res.statusmsg  = "No valid NNTP Services specified.";
@@ -377,28 +384,28 @@
     i = 0;
     do {
         bOk = TRUE;
-        if (connect(ctx->newsservice[i].s, ctx->newsservice[i].sa->sa_buf, ctx->newsservice[i].sa->sa_len) < 0) {
+        if (connect(ctx->ns[i].s, ctx->ns[i].sa->sa_buf, ctx->ns[i].sa->sa_len) < 0) {
             fprintf(stderr, "DEBUG: connect failed: %s\n", strerror(errno));
             bOk = FALSE;
         }
-        if (bOk && ((ctx->newsservice[i].nntp = nntp_create(ctx->newsservice[i].s, ctx->newsservice[i].s, NULL)) == NULL)) {
+        if (bOk && ((ctx->ns[i].nntp = nntp_create(ctx->ns[i].s, ctx->ns[i].s, NULL)) == NULL)) {
             fprintf(stderr, "DEBUG: nntp_create failed: %s\n", strerror(errno));
             bOk = FALSE;
         }
-        if (bOk && ((rc = nntp_init(ctx->newsservice[i].nntp)) != NNTP_OK)) {
-            fprintf(stderr, "DEBUG: nntp_init failed: %s\n", nntp_error(ctx->newsservice[i].nntp, rc));
+        if (bOk && ((rc = nntp_init(ctx->ns[i].nntp)) != NNTP_OK)) {
+            fprintf(stderr, "DEBUG: nntp_init failed: %s\n", nntp_error(ctx->ns[i].nntp, rc));
             bOk = FALSE;
         }
         if (bOk)
             i++;
         else {
-            if (i < --ctx->newsservicecount) {
-                memcpy(&ctx->newsservice[i], &ctx->newsservice[i+1], (ctx->newsservicecount - i ) * sizeof(struct newsservice));
+            if (i < --ctx->nsc) {
+                memcpy(&ctx->ns[i], &ctx->ns[i+1], (ctx->nsc - i ) * sizeof(struct ns));
             }
         }
-    } while (i < ctx->newsservicecount);
+    } while (i < ctx->nsc);
 
-    if (ctx->newsservicecount == 0) {
+    if (ctx->nsc == 0) {
         res.statuscode = "501";
         res.dsncode    = "5.0.0";
         res.statusmsg  = "No connection to any NNTP Service."; //FIXME add error strings from above DEBUGs

CVSTrac 2.0.1