INN commit: trunk/innd (art.c innd.h)

INN Commit Russ_Allbery at isc.org
Thu Sep 4 20:36:12 UTC 2008


    Date: Thursday, September 4, 2008 @ 13:36:11
  Author: iulius
Revision: 8002

Correctly count :bytes (without the first character of dot-stuffed lines).
Also save the right :lines value in the overview database.

Modified:
  trunk/innd/art.c
  trunk/innd/innd.h

--------+
 art.c  |   21 ++++++++++++++-------
 innd.h |    1 +
 2 files changed, 15 insertions(+), 7 deletions(-)

Modified: art.c
===================================================================
--- art.c	2008-09-04 18:56:22 UTC (rev 8001)
+++ art.c	2008-09-04 20:36:11 UTC (rev 8002)
@@ -588,14 +588,12 @@
     }
     data->BytesValue += iov[i].iov_len;
   }
-  /* Subtract the trailing 3 octets ".\r\n".  Note that we count
-   * a CRLF pair as two octets.  We also count the empty line
-   * between headers and body.
-   * FIXME:  We should also remove for each dot-stuffed lines.
+  /* Subtract the trailing 3 octets ".\r\n" and the "." characters
+   * used for dot-stuffing.  Note that we count a CRLF pair as
+   * two octets.  We also count the empty line between headers and body.
    * It is how the count of Bytes: should be done according to
-   * RFC 3977.  However, should we parse the whole body here
-   * only for that? */
-  data->BytesValue -= 3;
+   * RFC 3977. */
+  data->BytesValue -= 3 + data->DotStuffedLines;
   /* Figure out how much space we'll need and get it. */
   snprintf(data->Bytes, sizeof(data->Bytes), "Bytes: %ld\r\n",
            data->BytesValue);
@@ -792,6 +790,7 @@
     hc->Length = 0;
   }
   data->Lines = data->HeaderLines = data->CRwithoutLF = data->LFwithoutCR = 0;
+  data->DotStuffedLines = 0;
   data->CurHeader = data->LastCRLF = data->Body = cp->Start;
   data->BytesHeader = NULL;
   data->Feedsite = "?";
@@ -964,6 +963,9 @@
         } else if (bp->data[i + 1] == '\n') {
             i++;
             data->Lines++;
+            /* Check whether the new line begins with a dot. */
+            if (bp->data[i + 1] == '.')
+                data->DotStuffedLines++;
         } else {
             data->LFwithoutCR++;
         }
@@ -1828,6 +1830,11 @@
 	  len = data->XrefLength - 2;
 	}
 	break;
+      case HDR__LINES:
+        p = NULL;
+        xasprintf(&p, "%d\r\n", data->Lines);
+        len = strlen(p) - 2;
+        break;
       default:
 	p = HDR(j);
 	len = HDR_LEN(j);

Modified: innd.h
===================================================================
--- innd.h	2008-09-04 18:56:22 UTC (rev 8001)
+++ innd.h	2008-09-04 20:36:11 UTC (rev 8002)
@@ -245,6 +245,7 @@
   struct buffer	  Overview;		/* buffer for overview data */
   int		  CRwithoutLF;		/* counter for '\r' without '\n' */
   int		  LFwithoutCR;		/* counter for '\n' without '\r' */
+  int             DotStuffedLines;      /* counter for lines beginning with '.' */
   size_t	  CurHeader;		/* where current header starts.
 					   this is used for folded header
 					   it indicates offset from bp->Data */



More information about the inn-committers mailing list