Mercurial > noffle
changeset 157:976ff791c7ec noffle
[svn] Extract common code from putCmd and putCmdNoFlush,
reset client.lastStat when sending new command.
author | enz |
---|---|
date | Sun, 10 Dec 2000 11:34:50 +0000 |
parents | a7882c8e180c |
children | 497586db7e55 |
files | src/client.c |
diffstat | 1 files changed, 21 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/client.c Sun Dec 10 11:34:20 2000 +0000 +++ b/src/client.c Sun Dec 10 11:34:50 2000 +0000 @@ -1,7 +1,7 @@ /* client.c - $Id: client.c 217 2000-09-23 10:40:35Z enz $ + $Id: client.c 240 2000-12-10 11:34:50Z enz $ */ #if HAVE_CONFIG_H @@ -121,21 +121,15 @@ } static Bool -putCmd( const char *fmt, ... ) +putCmdLn( const char *line ) { Bool err; unsigned int n; - Str line; - va_list ap; - va_start( ap, fmt ); - vsnprintf( line, MAXCHAR, fmt, ap ); - va_end( ap ); strcpy( client.lastCmd, line ); + strcpy( client.lastStat, "[no status available]" ); Log_dbg( "[S] %s", line ); n = fprintf( client.out, "%s\r\n", line ); - fflush( client.out ); - Log_dbg( "[S FLUSH]" ); err = ( n != strlen( line ) + 2 ); if ( err ) logBreakDown();; @@ -143,23 +137,31 @@ } static Bool -putCmdNoFlush( const char *fmt, ... ) +putCmd( const char *fmt, ... ) { - Bool err; - unsigned int n; Str line; va_list ap; va_start( ap, fmt ); vsnprintf( line, MAXCHAR, fmt, ap ); va_end( ap ); - strcpy( client.lastCmd, line ); - Log_dbg( "[S] %s", line ); - n = fprintf( client.out, "%s\r\n", line ); - err = ( n != strlen( line ) + 2 ); - if ( err ) - logBreakDown();; - return ! err; + if ( ! putCmdLn( line ) ) + return FALSE; + fflush( client.out ); + Log_dbg( "[S FLUSH]" ); + return TRUE; +} + +static Bool +putCmdNoFlush( const char *fmt, ... ) +{ + Str line; + va_list ap; + + va_start( ap, fmt ); + vsnprintf( line, MAXCHAR, fmt, ap ); + va_end( ap ); + return putCmdLn( line ); } static int getStat( void );