Mercurial > noffle
changeset 79:28aeb0b93509 noffle
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
author | enz |
---|---|
date | Sun, 14 May 2000 08:12:23 +0100 |
parents | 8f99308edea0 |
children | 63d7b9549732 |
files | src/fetch.c |
diffstat | 1 files changed, 41 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fetch.c Sun May 14 08:11:28 2000 +0100 +++ b/src/fetch.c Sun May 14 08:12:23 2000 +0100 @@ -1,7 +1,7 @@ /* fetch.c - $Id: fetch.c 67 2000-05-12 17:19:38Z enz $ + $Id: fetch.c 85 2000-05-14 07:12:23Z enz $ */ #if HAVE_CONFIG_H @@ -178,15 +178,50 @@ del_DynStr( list ); } +static void +returnArticleToSender( const char *sender, const char *reason, + const char *article ) +{ + int ret; + Str cmd; + FILE *f; + sig_t lastHandler; + + Log_err( "Return article to '%s' by mail", sender ); + snprintf( cmd, MAXCHAR, "mail -s '[ NOFFLE: Posting failed ]' '%s'", + sender ); + lastHandler = signal( SIGPIPE, SIG_IGN ); + f = popen( cmd, "w" ); + if ( f == NULL ) + Log_err( "Invocation of '%s' failed (%s)", cmd, strerror( errno ) ); + else + { + fprintf( f, + "\t[ NOFFLE: POSTING OF ARTICLE FAILED ]\n" + "\n" + "\t[ The posting of your article failed. ]\n" + "\t[ Reason of failure at remote server: ]\n" + "\n" + "\t[ %s ]\n" + "\n" + "\t[ Full article text has been appended. ]\n" + "\n" + "%s" + ".\n", + reason, article ); + ret = pclose( f ); + if ( ret != EXIT_SUCCESS ) + Log_err( "'%s' exit value %d", cmd, ret ); + signal( SIGPIPE, lastHandler ); + } +} + void Fetch_postArts( void ) { DynStr *s; - Str msgId, cmd, errStr, sender; - int ret; + Str msgId, errStr, sender; const char *txt; - FILE *f; - sig_t lastHandler; s = new_DynStr( 10000 ); if ( Out_first( fetch.serv, msgId, s ) ) @@ -207,37 +242,7 @@ Log_err( "Article %s has no From/Sender/X-Sender field", msgId ); else - { - Log_ntc( "Return article to '%s' by mail", sender ); - snprintf( cmd, MAXCHAR, - "mail -s '[ NOFFLE: Posting failed ]' '%s'", - sender ); - lastHandler = signal( SIGPIPE, SIG_IGN ); - f = popen( cmd, "w" ); - if ( f == NULL ) - Log_err( "Invocation of '%s' failed (%s)", cmd, - strerror( errno ) ); - else - { - fprintf( f, - "\t[ NOFFLE: POSTING OF ARTICLE FAILED ]\n" - "\n" - "\t[ The posting of your article failed. ]\n" - "\t[ Reason of failure at remote server: ]\n" - "\n" - "\t[ %s ]\n" - "\n" - "\t[ Full article text has been appended. ]\n" - "\n" - "%s" - ".\n", - errStr, txt ); - ret = pclose( f ); - if ( ret != EXIT_SUCCESS ) - Log_err( "'%s' exit value %d", cmd, ret ); - signal( SIGPIPE, lastHandler ); - } - } + returnArticleToSender( sender, errStr, txt ); } } while ( Out_next( msgId, s ) );