/* NOTE: The full size of the buffer is expected as nSize. [vszakats] */ int hb_vsnprintf( char * buffer, size_t nSize, const char * format, va_list arglist ) { int result; #if defined( __DJGPP__ ) && ( __DJGPP__ < 2 || ( __DJGPP__ == 2 && __DJGPP_MINOR__ <= 3 ) ) /* Use vsprintf() for DJGPP <= 2.03. This is a temporary hack, should implement a C99 snprintf() ourselves. */ result = vsprintf( buffer, format, arglist ); #define _HB_SNPRINTF_ADD_EOS #elif defined( _MSC_VER ) && _MSC_VER >= 1400 result = _vsnprintf_s( buffer, nSize, _TRUNCATE, format, arglist ); #elif ( defined( _MSC_VER ) || defined( __DMC__ ) ) && ! defined( __XCC__ ) result = _vsnprintf( buffer, nSize, format, arglist ); #define _HB_SNPRINTF_ADD_EOS #elif defined( __WATCOMC__ ) && __WATCOMC__ < 1200 result = _vbprintf( buffer, nSize, format, arglist ); #else result = vsnprintf( buffer, nSize, format, arglist ); #endif #ifdef _HB_SNPRINTF_ADD_EOS if( buffer && nSize ) buffer[ nSize - 1 ] = '\0'; #endif return result; }
void Test__vbprintf( char *buf, char *format, ... ) { va_list args; int status; va_start( args, format ); status = _vbprintf( buf, 80, format, args ); /* print some stuff */ VERIFY( status <= 80 ); va_end( args ); }
void Message( char *buff, ... ) { va_list arglist; char msg[ 512 ]; IDEMsgInfo msg_info; if( Options.quiet ) return; va_start( arglist, buff ); _vbprintf( msg, 512, buff, arglist ); if( ideCb ) { IdeMsgInit( &msg_info, IDEMSGSEV_NOTE_MSG, msg ); ideCb->PrintWithInfo( ideHdl, &msg_info ); } va_end( arglist ); }
void FatalError( int str, ... ) { va_list arglist; char buff[ MAX_ERROR_SIZE ]; char msg[ 512 ]; IDEMsgInfo msg_info; va_start( arglist, str ); MsgGet( str, buff ); _vbprintf( msg, 512, buff, arglist ); if( ideCb ) { IdeMsgInit( &msg_info, IDEMSGSEV_ERROR, msg ); ideCb->PrintWithInfo( ideHdl, &msg_info ); } va_end( arglist ); longjmp( Env, 1 ); }
void Warning( int str, ... ) { va_list arglist; char buff[ MAX_ERROR_SIZE ]; char msg[ 512 ]; IDEMsgInfo msg_info; if( Options.quiet ) return; MsgGet( str, buff ); va_start( arglist, str ); _vbprintf( msg, 512, buff, arglist ); if( ideCb ) { IdeMsgInit( &msg_info, IDEMSGSEV_WARNING, msg ); ideCb->PrintWithInfo( ideHdl, &msg_info ); } va_end( arglist ); }
void WEXPORT WString::concatf( const char* parms... ) { char* buffer; va_list args; int bufsize = DEF_BUFFER; buffer = MALLOC( bufsize ); if( buffer != NULL ) { va_start( args, parms ); while( _vbprintf( buffer, bufsize, parms, args ) == bufsize - 1) { bufsize *= 2; FREE( buffer ); buffer = MALLOC( bufsize ); if( buffer == NULL ) return; va_start( args, parms ); } concat( buffer ); FREE( buffer ); } }