43 #if defined __cplusplus
48 static const char smr_mallocFailed[] =
"statusMessageReporting could not allocate memory for message";
53 static char *smr_getFullMessage2(
char const *fmt, ... );
84 va_start( args, fmt );
85 status = smr_setMessage( smr, userInterface, file, line, code,
smr_status_Info, fmt, &args );
105 va_start( args, fmt );
106 status = smr_setMessage( smr, userInterface, file, line, code,
smr_status_Error, fmt, &args );
126 va_start( args, fmt );
137 char *message = NULL;
141 if( ( message = (
char *)
realloc( message, size ) ) == NULL )
return( NULL );
145 #elif defined __IBMCPP__
146 va_copy( args_, *args );
148 __va_copy( args_, *args );
150 n = vsnprintf( message, size, fmt, args_ );
152 if( ( n > -1 ) && ( n < size ) )
break;
167 char *userMsg = NULL;
170 if( smr == NULL )
return( 0 );
179 if( userInterface != NULL ) {
180 if( ( userSize = (*(
smr_userInterface *) userInterface)( (
void *) userInterface, NULL ) ) > 0 ) {
182 if( (smr->
message = (
char*)
realloc(smr->
message, strlen( smr->
message ) + userSize + 2)) == NULL )
return( smr_setAllocationFailure( smr, fmt, args ) );
184 userSize = (*(
smr_userInterface *) userInterface)( (
void *) userInterface, &userMsg );
185 if( userSize < 0 )
return( smr_setAllocationFailure( smr, fmt, args ) );
187 strcat( smr->
message, userMsg );
199 vfprintf( stderr, fmt, *args );
200 fprintf( stderr,
"\nAt line %d of %s\n", smr->
line, smr->
packageName );
202 smr->
message = (
char *) smr_mallocFailed;
210 if( smr == NULL )
return( 1 );
218 if( smr == NULL )
return( 1 );
226 if( smr == NULL )
return( 1 );
234 if( smr == NULL )
return( 1 );
254 static char *smr_getFullMessage2(
char const *fmt, ... ) {
259 va_start( args, fmt );
273 #if defined __cplusplus
void smr_print(statusMessageReporting *smr, FILE *f, int clear)
int smr_release(statusMessageReporting *smr)
char * smr_getFullMessage(statusMessageReporting *smr)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
char * smr_vallocateFormatMessage(const char *fmt, va_list *args)
int smr_isInfo(statusMessageReporting *smr)
#define smr_maximumPackageNameSize
int smr_vsetMessageInfo(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, va_list *args)
int smr_isFatal(statusMessageReporting *smr)
int smr_isOk(statusMessageReporting *smr)
char packageName[smr_maximumPackageNameSize]
int smr_setMessageInfo(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
int smr_initialize(statusMessageReporting *smr)
int smr_vsetMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, va_list *args)
const char * smr_getMessage(statusMessageReporting *smr)
int smr_isError(statusMessageReporting *smr)
void * realloc(void *__ptr, size_t __size)
int(* smr_userInterface)(void *userData, char **smr)
char * smr_allocateFormatMessage(const char *fmt,...)