comparison src/post.c @ 93:eb522db0d032 noffle

[svn] Renamed date format and enforce correct date format on post
author bears
date Fri, 19 May 2000 16:14:41 +0100
parents 1fcdced0246e
children af51bf245bc3
comparison
equal deleted inserted replaced
92:160a0af71cf8 93:eb522db0d032
1 /* 1 /*
2 post.c 2 post.c
3 3
4 $Id: post.c 100 2000-05-18 12:17:23Z bears $ 4 $Id: post.c 112 2000-05-19 15:14:41Z 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
160 getArticleText( const char *p ) 160 getArticleText( const char *p )
161 { 161 {
162 DynStr * s; 162 DynStr * s;
163 Str line, field, value; 163 Str line, field, value;
164 Bool replyToFound; 164 Bool replyToFound;
165 time_t t;
165 166
166 s = new_DynStr( 10000 ); 167 s = new_DynStr( 10000 );
167 article.text = s; 168 article.text = s;
168 169
169 memset( &article.over, 0, sizeof( article.over ) ); 170 memset( &article.over, 0, sizeof( article.over ) );
184 { 185 {
185 Utl_cpyStr( article.over.from, value ); 186 Utl_cpyStr( article.over.from, value );
186 DynStr_appLn( s, line ); 187 DynStr_appLn( s, line );
187 } 188 }
188 else if ( strcmp ( field, "date" ) == 0 ) 189 else if ( strcmp ( field, "date" ) == 0 )
189 {
190 Utl_cpyStr( article.over.date, value ); 190 Utl_cpyStr( article.over.date, value );
191 DynStr_appLn( s, line );
192 }
193 else if ( strcmp ( field, "references" ) == 0 ) 191 else if ( strcmp ( field, "references" ) == 0 )
194 { 192 {
195 Utl_cpyStr( article.over.ref, value ); 193 Utl_cpyStr( article.over.ref, value );
196 DynStr_appLn( s, line ); 194 DynStr_appLn( s, line );
197 } 195 }
237 if ( article.newsgroups == NULL || Itl_count( article.newsgroups) == 0 ) 235 if ( article.newsgroups == NULL || Itl_count( article.newsgroups) == 0 )
238 { 236 {
239 Log_err( "Posted message has no valid Newsgroups field" ); 237 Log_err( "Posted message has no valid Newsgroups field" );
240 return FALSE; 238 return FALSE;
241 } 239 }
240
241 /* Ensure correctly formatted date */
242 t = Utl_parseNewsDate( article.over.date );
243 if ( t == (time_t) -1 )
244 {
245 time( &t );
246 Utl_newsDate( t, article.over.date );
247 DynStr_app( s, "Date: " );
248 DynStr_appLn( s, article.over.date );
249 }
250 else
251 DynStr_appLn( s, article.over.date );
252
253 /* Ensure Message ID is present and valid */
242 if ( Cfg_replaceMsgId() ) 254 if ( Cfg_replaceMsgId() )
243 { 255 {
244 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" ); 256 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" );
245 Log_dbg( "Replacing Message-ID with '%s'", article.over.msgId ); 257 Log_dbg( "Replacing Message-ID with '%s'", article.over.msgId );
246 } 258 }
254 Log_ntc( "Replacing invalid Message-ID '%s'", article.over.msgId ); 266 Log_ntc( "Replacing invalid Message-ID '%s'", article.over.msgId );
255 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" ); 267 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" );
256 } 268 }
257 DynStr_app( s, "Message-ID: " ); 269 DynStr_app( s, "Message-ID: " );
258 DynStr_appLn( s, article.over.msgId ); 270 DynStr_appLn( s, article.over.msgId );
271
272 /* Ensure Reply-To header */
259 if ( ! replyToFound ) 273 if ( ! replyToFound )
260 { 274 {
261 Log_dbg( "Adding Reply-To field to posted message." ); 275 Log_dbg( "Adding Reply-To field to posted message." );
262 DynStr_app( s, "Reply-To: " ); 276 DynStr_app( s, "Reply-To: " );
263 DynStr_appLn( s, article.over.from ); 277 DynStr_appLn( s, article.over.from );
264 } 278 }
265 if ( article.over.date[ 0 ] == '\0' ) 279
266 { 280 /* OK, header ready to roll. Something to accompany it? */
267 time_t t;
268
269 time( &t );
270 Utl_rfc822Date( t, article.over.date );
271 DynStr_app( s, "Date: " );
272 DynStr_appLn( s, article.over.date );
273 }
274 if ( p == NULL || p[ 0 ] == '\0' ) 281 if ( p == NULL || p[ 0 ] == '\0' )
275 { 282 {
276 Log_err( "Posted message has no body" ); 283 Log_err( "Posted message has no body" );
277 return FALSE; 284 return FALSE;
278 } 285 }