#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "statusMessageReporting.h"
Go to the source code of this file.
Functions | |
int | smr_initialize (statusMessageReporting *smr) |
int | smr_release (statusMessageReporting *smr) |
int | smr_setMessageInfo (statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...) |
int | smr_vsetMessageInfo (statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, va_list *args) |
int | smr_setMessageError (statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...) |
int | smr_vsetMessageError (statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, va_list *args) |
char * | smr_allocateFormatMessage (const char *fmt,...) |
char * | smr_vallocateFormatMessage (const char *fmt, va_list *args) |
int | smr_isOk (statusMessageReporting *smr) |
int | smr_isInfo (statusMessageReporting *smr) |
int | smr_isError (statusMessageReporting *smr) |
int | smr_isFatal (statusMessageReporting *smr) |
const char * | smr_getMessage (statusMessageReporting *smr) |
char * | smr_getFullMessage (statusMessageReporting *smr) |
void | smr_print (statusMessageReporting *smr, FILE *f, int clear) |
char* smr_allocateFormatMessage | ( | const char * | fmt, | |
... | ||||
) |
Definition at line 121 of file statusMessageReporting.cc.
References smr_vallocateFormatMessage().
00121 { 00122 00123 char *s; 00124 va_list args; 00125 00126 va_start( args, fmt ); 00127 s = smr_vallocateFormatMessage( fmt, &args ); 00128 va_end( args ); 00129 return( s ); 00130 }
char* smr_getFullMessage | ( | statusMessageReporting * | smr | ) |
Definition at line 247 of file statusMessageReporting.cc.
00247 { 00248 00249 return( smr_getFullMessage2( "%s\nAt line %d of %s", smr->message, smr->line, smr->packageName ) ); 00250 }
const char* smr_getMessage | ( | statusMessageReporting * | smr | ) |
int smr_initialize | ( | statusMessageReporting * | smr | ) |
Definition at line 57 of file statusMessageReporting.cc.
Referenced by G4GIDI_target::init(), and smr_release().
00057 { 00058 00059 smr->status = smr_status_Ok; 00060 smr->packageName[0] = 0; 00061 smr->line= -1; 00062 smr->code = 0; 00063 smr->message = NULL; 00064 return( 0 ); 00065 }
int smr_isError | ( | statusMessageReporting * | smr | ) |
Definition at line 224 of file statusMessageReporting.cc.
00224 { 00225 00226 if( smr == NULL ) return( 1 ); 00227 return( ( smr->status == smr_status_Error ) || ( smr->status == smr_status_Fatal ) ); 00228 }
int smr_isFatal | ( | statusMessageReporting * | smr | ) |
Definition at line 232 of file statusMessageReporting.cc.
00232 { 00233 00234 if( smr == NULL ) return( 1 ); 00235 return( smr->status == smr_status_Fatal ); 00236 }
int smr_isInfo | ( | statusMessageReporting * | smr | ) |
Definition at line 216 of file statusMessageReporting.cc.
00216 { 00217 00218 if( smr == NULL ) return( 1 ); 00219 return( smr->status == smr_status_Info ); 00220 }
int smr_isOk | ( | statusMessageReporting * | smr | ) |
Definition at line 208 of file statusMessageReporting.cc.
Referenced by G4GIDI_target::init(), tpia_angularEnergy_SampleEp(), tpia_channel_getFromElement(), tpia_decayChannel_sampleProductsAtE(), tpia_frame_setFromString(), tpia_map_findTarget(), tpia_map_readFile(), tpia_misc_pointerToAttributeIfAllOk(), tpia_miscNameToZAm(), tpia_particle_getInternalID(), tpia_product_getFromElement(), tpia_target_getEnergyGridAtTIndex(), tpia_target_getTotalCrossSectionAtTIndex(), tpia_target_heated_read(), tpia_target_read(), xData_parseEndOfXML(), xData_parseInitialize(), xData_parseReadFile(), and xData_parseString().
00208 { 00209 00210 if( smr == NULL ) return( 1 ); 00211 return( smr->status == smr_status_Ok ); 00212 }
void smr_print | ( | statusMessageReporting * | smr, | |
FILE * | f, | |||
int | clear | |||
) |
Definition at line 267 of file statusMessageReporting.cc.
References smr_release().
Referenced by G4GIDI_target::init().
00267 { 00268 00269 if( smr->message != NULL ) fprintf( f, "%s\nAt line %d of %s\n", smr->message, smr->line, smr->packageName ); 00270 if( clear ) smr_release( smr ); 00271 }
int smr_release | ( | statusMessageReporting * | smr | ) |
Definition at line 69 of file statusMessageReporting.cc.
References smr_initialize().
Referenced by smr_print(), G4GIDI_map::~G4GIDI_map(), and G4GIDI_target::~G4GIDI_target().
00069 { 00070 00071 if( smr->message != NULL ) { 00072 if( smr->message != smr_mallocFailed ) free( smr->message ); 00073 } 00074 return( smr_initialize( smr ) ); 00075 }
int smr_setMessageError | ( | statusMessageReporting * | smr, | |
void * | userInterface, | |||
const char * | file, | |||
int | line, | |||
int | code, | |||
const char * | fmt, | |||
... | ||||
) |
Definition at line 100 of file statusMessageReporting.cc.
Referenced by getRowStartEndAtIndex(), tpia_decayChannel_sampleProductsAtE(), tpia_depot_addTargetFromMap(), tpia_frame_getColumn(), tpia_frame_setColumn(), tpia_frame_setFromString(), tpia_frame_toString(), tpia_map_readFile(), tpia_misc_pointerToAttributeIfAllOk(), tpia_misc_setMessageError_Element(), tpia_miscNameToZAm(), tpia_particleMass_AMU(), tpia_target_getHeatedTargetAtIndex_ReadIfNeeded(), tpia_target_getHeatedTargetAtTIndex(), tpia_target_getTotalCrossSectionAtTIndex(), tpia_target_heated_getChannelAtIndex_smr(), tpia_target_read(), tpia_target_readHeatedTarget(), xData_1d_x_copyData(), xData_convertAttributeTo_xData_Int(), xData_convertAttributeToDouble(), xData_getCommonData(), xData_getOneElementByTagName(), xData_is_xDataType(), xData_parseEndOfXML(), xData_parseInitialize(), xData_parseReadFile(), xData_realloc(), xData_setMessageError_ReturnInt(), xData_stringTo_double(), xData_stringTo_xData_Int(), xData_xDataTypeConvertAttributes(), and xDataMisc_getAbsPath().
00100 { 00101 00102 int status; 00103 va_list args; 00104 00105 va_start( args, fmt ); 00106 status = smr_setMessage( smr, userInterface, file, line, code, smr_status_Error, fmt, &args ); 00107 va_end( args ); 00108 return( status ); 00109 }
int smr_setMessageInfo | ( | statusMessageReporting * | smr, | |
void * | userInterface, | |||
const char * | file, | |||
int | line, | |||
int | code, | |||
const char * | fmt, | |||
... | ||||
) |
Definition at line 79 of file statusMessageReporting.cc.
Referenced by tpia_map_findTarget(), and tpia_map_toXMLString().
00079 { 00080 00081 int status; 00082 va_list args; 00083 00084 va_start( args, fmt ); 00085 status = smr_setMessage( smr, userInterface, file, line, code, smr_status_Info, fmt, &args ); 00086 va_end( args ); 00087 return( status ); 00088 }
char* smr_vallocateFormatMessage | ( | const char * | fmt, | |
va_list * | args | |||
) |
Definition at line 134 of file statusMessageReporting.cc.
References CLHEP::detail::n.
Referenced by smr_allocateFormatMessage(), and tpia_misc_setMessageError_Element().
00134 { 00135 00136 int n, size = 128; 00137 char *message = NULL; 00138 va_list args_; 00139 00140 while( 1 ) { 00141 if( ( message = (char *) realloc( message, size ) ) == NULL ) return( NULL ); 00142 //TK110426 00143 #if defined WIN32 00144 args_ = *args; 00145 #elif defined __IBMCPP__ 00146 va_copy( args_, *args ); 00147 #else 00148 __va_copy( args_, *args ); 00149 #endif 00150 n = vsnprintf( message, size, fmt, args_ ); 00151 va_end( args_ ); 00152 if( ( n > -1 ) && ( n < size ) ) break; 00153 if( n > -1 ) { /* glibc 2.1 */ 00154 size = n + 3; } 00155 else { /* glibc 2.0 */ 00156 size += 128; 00157 } 00158 } 00159 return( message ); 00160 }
int smr_vsetMessageError | ( | statusMessageReporting * | smr, | |
void * | userInterface, | |||
const char * | file, | |||
int | line, | |||
int | code, | |||
const char * | fmt, | |||
va_list * | args | |||
) |
Definition at line 113 of file statusMessageReporting.cc.
Referenced by tpia_misc_setMessageError_Element().
00113 { 00114 00115 int status = smr_setMessage( smr, userInterface, file, line, code, smr_status_Error, fmt, args ); 00116 return( status ); 00117 }
int smr_vsetMessageInfo | ( | statusMessageReporting * | smr, | |
void * | userInterface, | |||
const char * | file, | |||
int | line, | |||
int | code, | |||
const char * | fmt, | |||
va_list * | args | |||
) |
Definition at line 92 of file statusMessageReporting.cc.
00092 { 00093 00094 int status = smr_setMessage( smr, userInterface, file, line, code, smr_status_Info, fmt, args ); 00095 return( status ); 00096 }