12 #if defined __cplusplus
17 #define SMR_InitialMessageSize 1024
18 #define SMR_IncrementMessageSize 1024
21 static char smr_mallocFailed[] =
"statusMessageReporting could not allocate memory for message";
37 enum smr_status status,
char const *fmt, va_list *args );
70 numberOfRegisteredLibraries = 0;
87 if( (
registeredLibraries[numberOfRegisteredLibraries] = strdup( libraryName ) ) == NULL )
return( -2 );
89 return( numberOfRegisteredLibraries - 1 );
122 if( smr == NULL )
return( 0 );
133 if( smr == NULL )
return( NULL );
143 if( smr == NULL )
return;
144 for( current = first; current != NULL; current = next ) {
156 if( smr == NULL )
return( NULL );
194 if( report->
message != NULL ) {
203 enum smr_status status,
char const *fmt, va_list *args ) {
208 if( smr == NULL )
return( 0 );
209 if( (
int) status < (
int) smr->
verbosity )
return( 0 );
214 next->
next = report; }
216 if( status <= smr->report.
status )
return( 0 );
231 if( userInterface != NULL ) {
232 if( ( userMsg = (*(
smr_userInterface *) userInterface)( (
void *) userInterface ) ) != NULL ) {
233 int userSize = (
int) strlen( userMsg );
238 strcat( report->
message, userMsg );
249 vfprintf( stderr, fmt, *args );
251 fprintf( stderr,
"\nAt line %d of %s in function %s\n", line, file,
function );
252 if( report != NULL ) {
267 va_start( args, fmt );
287 va_start( args, fmt );
307 va_start( args, fmt );
373 if( report == NULL )
return( 0 );
381 if( report == NULL )
return( 0 );
389 if( report == NULL )
return( 0 );
397 if( report == NULL )
return( 0 );
405 if( report == NULL )
return( 0 );
416 if( smr == NULL )
return( 0 );
426 if( smr == NULL )
return( NULL );
435 if( report == NULL )
return( NULL );
436 return( report->
next );
451 if( smr == NULL )
return( 0 );
459 if( report == NULL )
return( 0 );
467 if( report == NULL )
return( -1 );
468 return( report->
code );
475 if( report == NULL )
return( -1 );
476 return( report->
line );
483 if( report == NULL )
return( NULL );
491 if( report == NULL )
return( NULL );
499 if( report == NULL )
return( NULL );
507 if( report == NULL )
return( NULL );
516 if( report == NULL )
return( NULL );
534 if( smr == NULL )
return;
573 va_start( args, fmt );
588 va_copy( args_, *args );
589 n = vsnprintf( message, size, fmt, args_ );
591 if( ( n > -1 ) && ( n < size ) )
break;
597 if( message == buffer ) message = NULL;
598 if( ( message = (
char *) realloc( message, size ) ) == NULL )
return( NULL );
600 if( message == buffer ) {
601 if( ( message = (
char *) malloc( n + 1 ) ) == NULL )
return( NULL );
602 strcpy( message, buffer ); }
604 if( ( message = (
char *) realloc( message, n + 1 ) ) == NULL )
return( NULL );
613 void *
p =
smr_realloc( smr, NULL, size, forItem, file, line,
function );
618 if( ( p != NULL ) && zero ) {
619 for( i = 0, l = (
long long *) p; i < size /
sizeof(
long long ); i++, l++ ) *l = 0;
620 for( i *=
sizeof(
long long ), c = (
char *) l; i < size; i++, c++ ) *c = 0;
630 void *
p = realloc( pOld, size );
632 if( ( p == NULL ) && ( smr != NULL ) ) {
633 smr_setReportError( smr, NULL, file, line,
function,
smr_smrID, -1,
" smr_realloc: failed to realloc size = %z for variable %s\n", size, forItem );
642 if( p == NULL )
return( NULL );
656 char *
c = strdup( s );
658 if( c == NULL )
smr_setReportError( smr, NULL, file, line,
function,
smr_smrID, -1,
" smr_allocateCopyString: strdup failed for strlen( s ) = %z for variable %s",
659 strlen( s ), forItem );
669 size_t l = strlen( s );
673 if( ( c = (
char *)
smr_malloc( smr, l + 1, 0, forItem, file, line,
function ) ) != NULL ) {
689 #if defined __cplusplus