# HG changeset patch # User enz # Date 976448090 0 # Node ID 976ff791c7eca965e8445eb94b8a7eb558638f50 # Parent a7882c8e180cf75cf9fe10b325846dc2df1064f9 [svn] Extract common code from putCmd and putCmdNoFlush, reset client.lastStat when sending new command. diff -r a7882c8e180c -r 976ff791c7ec src/client.c --- 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 );