diff src/protocol.c @ 282:baa6408d1bbc noffle

[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting, check the article for those headers that are specified in section 5 of the IETF draft and ensure they only occur once. * src/post.c: Clean up a conditional.
author bears
date Mon, 06 Jan 2003 18:16:18 +0000
parents 3477050e8d10
children 01755687c565
line wrap: on
line diff
--- a/src/protocol.c	Fri Dec 27 21:48:25 2002 +0000
+++ b/src/protocol.c	Mon Jan 06 18:16:18 2003 +0000
@@ -1,7 +1,7 @@
 /*
   protocol.c
 
-  $Id: protocol.c 403 2002-11-10 11:32:17Z bears $
+  $Id: protocol.c 414 2003-01-06 18:16:18Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -180,12 +180,16 @@
 }
 
 Bool
-Prt_getField( Str resultField, Str resultValue, const char* line )
+Prt_getField( Str resultField, Str resultValue,
+	      Bool* isContinuation, const char* line )
 {
     char *dst;
     const char *p;
     Str lineLower, t;
+
+    ASSERT( isContinuation );
     
+    *isContinuation = FALSE;
     Utl_cpyStr( lineLower, line );
     Utl_toLower( lineLower );
     p = Utl_stripWhiteSpace( lineLower );
@@ -204,14 +208,23 @@
             p = Utl_stripWhiteSpace( t );
             strcpy( resultValue, p );
             return TRUE;
-        }
+        } else
+	    return FALSE;	/* Not a header line */
     }
-    else        /* continued header.  */
+    else
     {
-            strcpy( resultValue, lineLower ); /* include starting whitespace */
-            return TRUE;
+	/*
+	 * If the line starts with white space, it can be a header
+	 * continuation.
+	 */
+	if( ! isspace( *line ) )
+	    return FALSE;
+	
+	Utl_cpyStr( resultValue, line );
+	*isContinuation = TRUE;
+        return TRUE;
     }
-    return FALSE;
+    /* NOTREACHED */
 }
 
 Bool
@@ -221,6 +234,7 @@
     char *dst;
     Str line, whichLower, field;
     int len;
+    Bool continuation;
     
     Utl_cpyStr( whichLower, which );
     Utl_toLower( whichLower );
@@ -242,7 +256,7 @@
         p = Utl_stripWhiteSpace( line );
         if ( *p == '\0' )
             break;
-        if ( Prt_getField( field, result, line )
+        if ( Prt_getField( field, result, &continuation, line )
              && strcmp( field, whichLower ) == 0 )
             return TRUE;
     }