Mercurial > noffle
comparison src/post.c @ 223:ffb1848a39db noffle
[svn] * src/util.c: Improve (correct) error detection when updating
timestamp file.
* src/content.h, src/content.c: Return Boolean success/fail from
Cont_write. Also ensure cont.first isn't polluted in the event
of a failed update.
* src/client.c,src/control.c,src/fetch.c,src/noffle.c,src/post.c,
src/pseudo.c: If Cont_write fails, don't do actions that need it to
have worked. Typically, don't update first and last article numbers
in group database.
* src/server.c: If groupinfo.lastupdate is unreadable or corrupt,
spot this and report it and give an explicit error when processing
NNTP NEWGROUPS command.
| author | bears |
|---|---|
| date | Sun, 09 Dec 2001 12:31:57 +0000 |
| parents | bf290632d29e |
| children | fbff73fe5b40 |
comparison
equal
deleted
inserted
replaced
| 222:bf290632d29e | 223:ffb1848a39db |
|---|---|
| 1 /* | 1 /* |
| 2 post.c | 2 post.c |
| 3 | 3 |
| 4 $Id: post.c 341 2001-12-09 11:32:31Z bears $ | 4 $Id: post.c 342 2001-12-09 12:31:57Z 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 |
| 95 Log_dbg( LOG_DBG_POST, "Adding '%s' to Xref of '%s'", grp, msgId ); | 95 Log_dbg( LOG_DBG_POST, "Adding '%s' to Xref of '%s'", grp, msgId ); |
| 96 snprintf( t, MAXCHAR, "%s %s:%i", xref, grp, Ov_numb( over ) ); | 96 snprintf( t, MAXCHAR, "%s %s:%i", xref, grp, Ov_numb( over ) ); |
| 97 Db_setXref( msgId, t ); | 97 Db_setXref( msgId, t ); |
| 98 } | 98 } |
| 99 | 99 |
| 100 Cont_write(); | 100 if ( Cont_write() ) |
| 101 Grp_setFirstLast( Cont_grp(), Cont_first(), Cont_last() ); | 101 { |
| 102 Grp_setLastPostTime( Cont_grp() ); | 102 Grp_setFirstLast( Cont_grp(), Cont_first(), Cont_last() ); |
| 103 return TRUE; | 103 Grp_setLastPostTime( Cont_grp() ); |
| 104 return TRUE; | |
| 105 } | |
| 106 else | |
| 107 return FALSE; | |
| 104 } | 108 } |
| 105 | 109 |
| 106 static Bool | 110 static Bool |
| 107 checkPostableNewsgroup( void ) | 111 checkPostableNewsgroup( void ) |
| 108 { | 112 { |
| 177 int sigLines; | 181 int sigLines; |
| 178 | 182 |
| 179 s = new_DynStr( 10000 ); | 183 s = new_DynStr( 10000 ); |
| 180 article.text = s; | 184 article.text = s; |
| 181 | 185 |
| 182 memset( &article.over, 0, sizeof( article.over ) ); | |
| 183 replyToFound = pathFound = orgFound = FALSE; | 186 replyToFound = pathFound = orgFound = FALSE; |
| 184 | 187 |
| 185 /* Grab header lines first, getting overview info as we go. */ | 188 /* Grab header lines first, getting overview info as we go. */ |
| 186 while ( ( p = Utl_getHeaderLn( line, p ) ) != NULL | 189 while ( ( p = Utl_getHeaderLn( line, p ) ) != NULL |
| 187 && line[ 0 ] != '\0' | 190 && line[ 0 ] != '\0' |
| 537 } | 540 } |
| 538 | 541 |
| 539 return postExternal() && err; | 542 return postExternal() && err; |
| 540 } | 543 } |
| 541 | 544 |
| 545 | |
| 546 static void | |
| 547 clearArticleInfo( void ) | |
| 548 { | |
| 549 article.text = NULL; | |
| 550 article.newsgroups = NULL; | |
| 551 article.control = NULL; | |
| 552 article.approved = FALSE; | |
| 553 article.posted = FALSE; | |
| 554 article.flags = 0; | |
| 555 memset( &article.over, 0, sizeof( article.over ) ); | |
| 556 } | |
| 557 | |
| 542 /* Register an article for posting. */ | 558 /* Register an article for posting. */ |
| 543 Bool | 559 Bool |
| 544 Post_open( const char * text, unsigned flags ) | 560 Post_open( const char * text, unsigned flags ) |
| 545 { | 561 { |
| 546 if ( article.text != NULL ) | 562 if ( article.text != NULL ) |
| 547 { | 563 { |
| 548 Log_err( "Busy article in Post_open." ); | 564 Log_err( "Busy article in Post_open." ); |
| 549 return FALSE; | 565 return FALSE; |
| 550 } | 566 } |
| 551 | 567 |
| 568 clearArticleInfo(); | |
| 569 | |
| 552 article.flags = flags; | 570 article.flags = flags; |
| 553 | |
| 554 if ( ! getArticleText( text ) ) | 571 if ( ! getArticleText( text ) ) |
| 555 return FALSE; | 572 return FALSE; |
| 556 | 573 |
| 557 if ( Db_contains( article.over.msgId ) ) | 574 if ( Db_contains( article.over.msgId ) ) |
| 558 { | 575 { |
| 599 if ( article.control != NULL ) | 616 if ( article.control != NULL ) |
| 600 { | 617 { |
| 601 del_Itl( article.control ); | 618 del_Itl( article.control ); |
| 602 article.control = NULL; | 619 article.control = NULL; |
| 603 } | 620 } |
| 604 article.approved = FALSE; | 621 } |
| 605 article.posted = FALSE; | 622 |
| 606 } | 623 |
| 607 | |
| 608 |
