INN commit: branches/2.5 (4 files)

INN Commit rra at isc.org
Thu Aug 5 19:53:32 UTC 2010


    Date: Thursday, August 5, 2010 @ 12:53:32
  Author: iulius
Revision: 9099

Use a constant (ARTNUMPRINTSIZE) for the length of a water mark.
It will be of help if we ever switch from 32-bit to 64-bit
article numbers.

Modified:
  branches/2.5/backends/actsync.c
  branches/2.5/include/inn/options.h
  branches/2.5/innd/art.c
  branches/2.5/nnrpd/list.c

-----------------------+
 backends/actsync.c    |   21 ++++++++++-----------
 include/inn/options.h |    3 +++
 innd/art.c            |    4 ++--
 nnrpd/list.c          |    3 ++-
 4 files changed, 17 insertions(+), 14 deletions(-)

Modified: backends/actsync.c
===================================================================
--- backends/actsync.c	2010-08-05 19:51:24 UTC (rev 9098)
+++ backends/actsync.c	2010-08-05 19:53:32 UTC (rev 9099)
@@ -226,7 +226,6 @@
 
 #define DEF_HI   "0000000000"	/* default hi string value for new groups */
 #define DEF_LOW  "0000000001"	/* default low string value for new groups */
-#define WATER_LEN 10		/* string length of hi/low water mark */
 
 #define DEF_NAME "actsync"	/* default name to use for ctlinnd newgroup */
 
@@ -962,10 +961,10 @@
 	/*
 	 * check for excessive hi water length
 	 */
-	if (i > WATER_LEN) {
+	if (i > ARTNUMPRINTSIZE) {
 	    if (!QUIET(hostid))
                 warn("line %d <%s> from %s hi water len: %d < %d",
-                     cnt + 1, cur->name, cur->hi, i, WATER_LEN);
+                     cnt + 1, cur->name, cur->hi, i, ARTNUMPRINTSIZE);
 	    cur->ignore |= ERROR_FORMAT;
 	    continue;
 	}
@@ -973,9 +972,9 @@
 	/*
 	 * if the hi water length is too small, malloc and resize
 	 */
-	if (i != WATER_LEN) {
-            p = xmalloc(WATER_LEN + 1);
-	    memcpy(p, cur->hi, ((i > WATER_LEN) ? WATER_LEN : i)+1);
+	if (i != ARTNUMPRINTSIZE) {
+            p = xmalloc(ARTNUMPRINTSIZE + 1);
+	    memcpy(p, cur->hi, ((i > ARTNUMPRINTSIZE) ? ARTNUMPRINTSIZE : i)+1);
 	}
 
 	/* 
@@ -994,10 +993,10 @@
 	/*
 	 * check for excessive low water length
 	 */
-	if (i > WATER_LEN) {
+	if (i > ARTNUMPRINTSIZE) {
 	    if (!QUIET(hostid))
                 warn("line %d <%s> from %s low water len: %d < %d",
-		     cnt + 1, cur->name, cur->hi, i, WATER_LEN);
+		     cnt + 1, cur->name, cur->hi, i, ARTNUMPRINTSIZE);
 	    cur->ignore |= ERROR_FORMAT;
 	    continue;
 	}
@@ -1005,9 +1004,9 @@
 	/*
 	 * if the low water length is too small, malloc and resize
 	 */
-	if (i != WATER_LEN) {
-            p = xmalloc(WATER_LEN + 1);
-	    memcpy(p, cur->low, ((i > WATER_LEN) ? WATER_LEN : i)+1);
+	if (i != ARTNUMPRINTSIZE) {
+            p = xmalloc(ARTNUMPRINTSIZE + 1);
+	    memcpy(p, cur->low, ((i > ARTNUMPRINTSIZE) ? ARTNUMPRINTSIZE : i)+1);
 	}
 
 	/* check for a bad group type */

Modified: include/inn/options.h
===================================================================
--- include/inn/options.h	2010-08-05 19:51:24 UTC (rev 9098)
+++ include/inn/options.h	2010-08-05 19:53:32 UTC (rev 9099)
@@ -110,6 +110,9 @@
 /* The maximum length of a single header or body line, including CRLF. */
 #define MAXARTLINELENGTH        1000
 
+/* String length of high/low watermark.  Currently for 32-bit article numbers. */
+#define ARTNUMPRINTSIZE         10
+
 /* The size of a small buffer. */
 #define SMBUF                   256
 

Modified: innd/art.c
===================================================================
--- innd/art.c	2010-08-05 19:51:24 UTC (rev 9098)
+++ innd/art.c	2010-08-05 19:53:32 UTC (rev 9099)
@@ -1447,13 +1447,13 @@
     ngp->Filenum = ngp->Last;
     /*  len  ' ' "news_groupname"  ':' "#" "\r\n"
         plus an extra 2 bytes for "\r\n" in case of a continuation line. */
-    if (len + 1 + ngp->NameLength + 1 + 10 + 2 + 2 > data->XrefBufLength) {
+    if (len + 1 + ngp->NameLength + 1 + ARTNUMPRINTSIZE + 2 + 2 > data->XrefBufLength) {
       data->XrefBufLength += MED_BUFFER;
       data->Xref = xrealloc(data->Xref, data->XrefBufLength);
       p = data->Xref + len;
     }
     /* Trailing CRLF is counted in the maximum length. */
-    if (linelen + 1 + ngp->NameLength + 1 + 10 + 2 > MAXARTLINELENGTH) {
+    if (linelen + 1 + ngp->NameLength + 1 + ARTNUMPRINTSIZE + 2 > MAXARTLINELENGTH) {
       /* Line exceeded. */
       sprintf(p, "\r\n %s:%lu", ngp->Name, ngp->Filenum);
       buflen = strlen(p);

Modified: nnrpd/list.c
===================================================================
--- nnrpd/list.c	2010-08-05 19:51:24 UTC (rev 9098)
+++ nnrpd/list.c	2010-08-05 19:53:32 UTC (rev 9099)
@@ -160,7 +160,8 @@
         if (count == 0)
             lo = hi + 1;
         Reply("%d %s\r\n", NNTP_OK_LIST, INFOactive.Format);
-        Printf("%s %010u %010u %c\r\n", group, hi, lo, flag);
+        Printf("%s %0*u %0*u %c\r\n", group, ARTNUMPRINTSIZE, hi,
+               ARTNUMPRINTSIZE, lo, flag);
         Printf(".\r\n");
         return true;
     }




More information about the inn-committers mailing list