Mercurial > noffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 281:5eece4dfd945 | 282:baa6408d1bbc |
|---|---|
| 1 /* | 1 /* |
| 2 protocol.c | 2 protocol.c |
| 3 | 3 |
| 4 $Id: protocol.c 403 2002-11-10 11:32:17Z bears $ | 4 $Id: protocol.c 414 2003-01-06 18:16:18Z bears $ |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
| 8 #include <config.h> | 8 #include <config.h> |
| 9 #endif | 9 #endif |
| 178 } | 178 } |
| 179 return TRUE; | 179 return TRUE; |
| 180 } | 180 } |
| 181 | 181 |
| 182 Bool | 182 Bool |
| 183 Prt_getField( Str resultField, Str resultValue, const char* line ) | 183 Prt_getField( Str resultField, Str resultValue, |
| 184 Bool* isContinuation, const char* line ) | |
| 184 { | 185 { |
| 185 char *dst; | 186 char *dst; |
| 186 const char *p; | 187 const char *p; |
| 187 Str lineLower, t; | 188 Str lineLower, t; |
| 189 | |
| 190 ASSERT( isContinuation ); | |
| 188 | 191 |
| 192 *isContinuation = FALSE; | |
| 189 Utl_cpyStr( lineLower, line ); | 193 Utl_cpyStr( lineLower, line ); |
| 190 Utl_toLower( lineLower ); | 194 Utl_toLower( lineLower ); |
| 191 p = Utl_stripWhiteSpace( lineLower ); | 195 p = Utl_stripWhiteSpace( lineLower ); |
| 192 if ( p == lineLower ) | 196 if ( p == lineLower ) |
| 193 { | 197 { |
| 202 ++p; | 206 ++p; |
| 203 strcpy( t, line + ( p - lineLower ) ); | 207 strcpy( t, line + ( p - lineLower ) ); |
| 204 p = Utl_stripWhiteSpace( t ); | 208 p = Utl_stripWhiteSpace( t ); |
| 205 strcpy( resultValue, p ); | 209 strcpy( resultValue, p ); |
| 206 return TRUE; | 210 return TRUE; |
| 207 } | 211 } else |
| 208 } | 212 return FALSE; /* Not a header line */ |
| 209 else /* continued header. */ | 213 } |
| 210 { | 214 else |
| 211 strcpy( resultValue, lineLower ); /* include starting whitespace */ | 215 { |
| 212 return TRUE; | 216 /* |
| 213 } | 217 * If the line starts with white space, it can be a header |
| 214 return FALSE; | 218 * continuation. |
| 219 */ | |
| 220 if( ! isspace( *line ) ) | |
| 221 return FALSE; | |
| 222 | |
| 223 Utl_cpyStr( resultValue, line ); | |
| 224 *isContinuation = TRUE; | |
| 225 return TRUE; | |
| 226 } | |
| 227 /* NOTREACHED */ | |
| 215 } | 228 } |
| 216 | 229 |
| 217 Bool | 230 Bool |
| 218 Prt_searchHeader( const char *artTxt, const char *which, Str result ) | 231 Prt_searchHeader( const char *artTxt, const char *which, Str result ) |
| 219 { | 232 { |
| 220 const char *src, *p; | 233 const char *src, *p; |
| 221 char *dst; | 234 char *dst; |
| 222 Str line, whichLower, field; | 235 Str line, whichLower, field; |
| 223 int len; | 236 int len; |
| 237 Bool continuation; | |
| 224 | 238 |
| 225 Utl_cpyStr( whichLower, which ); | 239 Utl_cpyStr( whichLower, which ); |
| 226 Utl_toLower( whichLower ); | 240 Utl_toLower( whichLower ); |
| 227 src = artTxt; | 241 src = artTxt; |
| 228 while ( TRUE ) | 242 while ( TRUE ) |
| 240 ++src; | 254 ++src; |
| 241 *dst = '\0'; | 255 *dst = '\0'; |
| 242 p = Utl_stripWhiteSpace( line ); | 256 p = Utl_stripWhiteSpace( line ); |
| 243 if ( *p == '\0' ) | 257 if ( *p == '\0' ) |
| 244 break; | 258 break; |
| 245 if ( Prt_getField( field, result, line ) | 259 if ( Prt_getField( field, result, &continuation, line ) |
| 246 && strcmp( field, whichLower ) == 0 ) | 260 && strcmp( field, whichLower ) == 0 ) |
| 247 return TRUE; | 261 return TRUE; |
| 248 } | 262 } |
| 249 return FALSE; | 263 return FALSE; |
| 250 } | 264 } |
