/** prints an error message, acting like the vprintf() command using the static message handler */ void SCIPmessageVPrintError( const char* formatstr, /**< format string like in printf() function */ va_list ap /**< variable argument list */ ) { char msg[SCIP_MAXSTRLEN]; int n; va_list aq; va_copy(aq, ap); n = vsnprintf(msg, SCIP_MAXSTRLEN, formatstr, ap); if( n < 0 ) msg[SCIP_MAXSTRLEN-1] = '\0'; else if( n >= SCIP_MAXSTRLEN ) { char* bigmsg; #ifndef NDEBUG int m; #endif if( BMSallocMemorySize(&bigmsg, n+1) == NULL ) { va_end(aq); return; } #ifndef NDEBUG m = vsnprintf(bigmsg, (size_t) n+1, formatstr, aq); #else vsnprintf(bigmsg, (size_t) n+1, formatstr, aq); #endif assert(m == n); va_end(aq); messagePrintError(bigmsg); BMSfreeMemory(&bigmsg); return; } messagePrintError(msg); va_end(aq); }
/** prints a error message, acting like the printf() command */ void SCIPmessagePrintError( const char* formatstr, /**< format string like in printf() function */ ... /**< format arguments line in printf() function */ ) { char msg[SCIP_MAXSTRLEN]; int n; va_list ap; va_start(ap, formatstr); /*lint !e826*/ n = vsnprintf(msg, SCIP_MAXSTRLEN, formatstr, ap); if( n < 0 ) msg[SCIP_MAXSTRLEN-1] = '\0'; else if( n >= SCIP_MAXSTRLEN ) { char* bigmsg; #ifndef NDEBUG int m; #endif if( BMSallocMemorySize(&bigmsg, n+1) == NULL ) { va_end(ap); return; } #ifndef NDEBUG m = vsnprintf(bigmsg, (size_t) n+1, formatstr, ap); #else vsnprintf(bigmsg, (size_t) n+1, formatstr, ap); #endif assert(m == n); va_end(ap); messagePrintError(bigmsg, n); BMSfreeMemory(&bigmsg); return; } messagePrintError(msg, SCIP_MAXSTRLEN); va_end(ap); }
/** prints the header with source file location for an error message using the static message handler */ void SCIPmessagePrintErrorHeader( const char* sourcefile, /**< name of the source file that called the function */ int sourceline /**< line in the source file where the function was called */ ) { char msg[SCIP_MAXSTRLEN]; /* safe string printing - do not use SCIPsnprintf() since message.c should be independent */ (void) snprintf(msg, SCIP_MAXSTRLEN, "[%s:%d] ERROR: ", sourcefile, sourceline); msg[SCIP_MAXSTRLEN-1] = '\0'; messagePrintError(msg); }