References and wrapped headers
Russ Allbery
rra at stanford.edu
Tue Dec 24 06:17:23 UTC 2002
Russ Allbery <rra at Stanford.EDU> writes:
> If not, this has been there since April of 2001. It looks like the goal
> was to allow \r by itself as a line terminator. Hm. Aren't we
> guaranteed that all articles returned by the storage manager are in wire
> format? If so, there shouldn't be any need to consider line endings
> other than \r\n, right?
I've now written wire-format-only implementations of HeaderFindMem and
FindEndOfHeader (wire_findheader and wire_endheader) and have put them
along with tests into CURRENT. I'm now committing the following change,
which should fix makehistory.
The way that we're writing overview information at the moment is a
complete disaster. Gah.
Index: makehistory.c
===================================================================
RCS file: /dist1/cvs/isc/inn/inn/expire/makehistory.c,v
retrieving revision 1.102
diff -u -p -r1.102 makehistory.c
--- makehistory.c 2002/12/23 05:42:30 1.102
+++ makehistory.c 2002/12/24 06:16:44
@@ -15,6 +15,7 @@
#include "inn/innconf.h"
#include "inn/messages.h"
#include "inn/qio.h"
+#include "inn/wire.h"
#include "libinn.h"
#include "macros.h"
#include "ov.h"
@@ -526,19 +527,18 @@ DoArt(ARTHANDLE *art)
}
}
for (fp = ARTfields, i = 0; i < ARTfieldsize; i++, fp++) {
- if ((fp->Header = HeaderFindMem(art->data, art->len, fp->Headername, fp->HeadernameLength)) != (char *)NULL) {
+ fp->Header = wire_findheader(art->data, art->len, fp->Headername);
+ if (fp->Header != NULL) {
fp->HasHeader = TRUE;
- for (p = fp->Header, p1 = (char *)NULL; p < art->data + art->len; p++) {
- if (p1 != (char *)NULL && (*p1 == '\r' || *p1 == '\n') &&
- !ISWHITE(*p))
- break;
- p1 = p;
- }
- if (p >= art->data + art->len) {
- /* not found for this header */
+ p = wire_endheader(fp->Header, art->data + art->len - 1);
+ if (p == NULL)
continue;
- }
- fp->HeaderLength = p1 - fp->Header;
+
+ /* The true length of the header is p - fp->Header + 1, but p
+ points to the \n at the end of the header, so subtract 2 to
+ peel off the \r\n (we're guaranteed we're dealing with
+ wire-format articles. */
+ fp->HeaderLength = p - fp->Header - 1;
} else if (RetrMode == RETR_ALL && strcmp(fp->Headername, "Bytes") == 0)
{
snprintf(bytes, sizeof(bytes), "%d", art->len);
@@ -549,19 +549,13 @@ DoArt(ARTHANDLE *art)
}
if (Missfieldsize > 0) {
for (fp = Missfields, i = 0; i < Missfieldsize; i++, fp++) {
- if ((fp->Header = HeaderFindMem(art->data, art->len, fp->Headername, fp->HeadernameLength)) != (char *)NULL) {
+ fp->Header = wire_findheader(art->data, art->len, fp->Headername);
+ if (fp->Header != NULL) {
fp->HasHeader = TRUE;
- for (p = fp->Header, p1 = (char *)NULL; p < art->data + art->len; p++) {
- if (p1 != (char *)NULL && (*p1 == '\r' || *p1 == '\n') &&
- !ISWHITE(*p))
- break;
- p1 = p;
- }
- if (p >= art->data + art->len) {
- /* not found for this header */
- continue;
- }
- fp->HeaderLength = p1 - fp->Header;
+ p = wire_endheader(fp->Header, art->data + art->len - 1);
+ if (p == NULL)
+ continue;
+ fp->HeaderLength = p - fp->Header - 1;
}
}
}
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
Please send questions to the list rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
More information about the inn-workers
mailing list