Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
statusMessageReporting.h File Reference
#include <stdio.h>
#include <stdarg.h>

Go to the source code of this file.

Data Structures

struct  statusMessageReporting
 

Macros

#define smr_maximumPackageNameSize   256
 

Typedefs

typedef int(* smr_userInterface )(void *userData, char **smr)
 
typedef struct
statusMessageReporting 
statusMessageReporting
 

Enumerations

enum  smr_status { smr_status_Ok, smr_status_Info, smr_status_Error, smr_status_Fatal }
 

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)
 

Macro Definition Documentation

#define smr_maximumPackageNameSize   256

Definition at line 47 of file statusMessageReporting.h.

Typedef Documentation

typedef int(* smr_userInterface)(void *userData, char **smr)

Definition at line 49 of file statusMessageReporting.h.

Enumeration Type Documentation

enum smr_status
Enumerator
smr_status_Ok 
smr_status_Info 
smr_status_Error 
smr_status_Fatal 

Definition at line 48 of file statusMessageReporting.h.

Function Documentation

char* smr_allocateFormatMessage ( const char *  fmt,
  ... 
)

Definition at line 121 of file statusMessageReporting.cc.

References smr_vallocateFormatMessage().

121  {
122 
123  char *s;
124  va_list args;
125 
126  va_start( args, fmt );
127  s = smr_vallocateFormatMessage( fmt, &args );
128  va_end( args );
129  return( s );
130 }
const XML_Char * s
char * smr_vallocateFormatMessage(const char *fmt, va_list *args)
char* smr_getFullMessage ( statusMessageReporting smr)

Definition at line 247 of file statusMessageReporting.cc.

References statusMessageReporting::line, statusMessageReporting::message, and statusMessageReporting::packageName.

247  {
248 
249  return( smr_getFullMessage2( "%s\nAt line %d of %s", smr->message, smr->line, smr->packageName ) );
250 }
char packageName[smr_maximumPackageNameSize]
const char* smr_getMessage ( statusMessageReporting smr)

Definition at line 240 of file statusMessageReporting.cc.

References statusMessageReporting::message.

240  {
241 
242  return( smr->message );
243 }
int smr_initialize ( statusMessageReporting smr)
int smr_isError ( statusMessageReporting smr)

Definition at line 224 of file statusMessageReporting.cc.

References smr_status_Error, smr_status_Fatal, and statusMessageReporting::status.

224  {
225 
226  if( smr == NULL ) return( 1 );
227  return( ( smr->status == smr_status_Error ) || ( smr->status == smr_status_Fatal ) );
228 }
int smr_isFatal ( statusMessageReporting smr)

Definition at line 232 of file statusMessageReporting.cc.

References smr_status_Fatal, and statusMessageReporting::status.

232  {
233 
234  if( smr == NULL ) return( 1 );
235  return( smr->status == smr_status_Fatal );
236 }
int smr_isInfo ( statusMessageReporting smr)

Definition at line 216 of file statusMessageReporting.cc.

References smr_status_Info, and statusMessageReporting::status.

216  {
217 
218  if( smr == NULL ) return( 1 );
219  return( smr->status == smr_status_Info );
220 }
int smr_isOk ( statusMessageReporting smr)
void smr_print ( statusMessageReporting smr,
FILE *  f,
int  clear 
)

Definition at line 267 of file statusMessageReporting.cc.

References statusMessageReporting::line, statusMessageReporting::message, statusMessageReporting::packageName, and smr_release().

Referenced by G4GIDI_map::G4GIDI_map(), and G4GIDI_target::init().

267  {
268 
269  if( smr->message != NULL ) fprintf( f, "%s\nAt line %d of %s\n", smr->message, smr->line, smr->packageName );
270  if( clear ) smr_release( smr );
271 }
char packageName[smr_maximumPackageNameSize]
int smr_release(statusMessageReporting *smr)
int smr_release ( statusMessageReporting smr)

Definition at line 69 of file statusMessageReporting.cc.

References free(), statusMessageReporting::message, and smr_initialize().

Referenced by smr_print(), G4GIDI_map::~G4GIDI_map(), and G4GIDI_target::~G4GIDI_target().

69  {
70 
71  if( smr->message != NULL ) {
72  if( smr->message != smr_mallocFailed ) free( smr->message );
73  }
74  return( smr_initialize( smr ) );
75 }
void free(void *__ptr)
Definition: hjmalloc.cc:140
int smr_initialize(statusMessageReporting *smr)
int smr_setMessageError ( statusMessageReporting smr,
void userInterface,
const char *  file,
int  line,
int  code,
const char *  fmt,
  ... 
)
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.

References smr_status_Info, and status.

Referenced by tpia_map_findTarget(), and tpia_map_toXMLString().

79  {
80 
81  int status;
82  va_list args;
83 
84  va_start( args, fmt );
85  status = smr_setMessage( smr, userInterface, file, line, code, smr_status_Info, fmt, &args );
86  va_end( args );
87  return( status );
88 }
int status
Definition: tracer.cxx:24
Definition: inftrees.h:24
char* smr_vallocateFormatMessage ( const char *  fmt,
va_list *  args 
)

Definition at line 134 of file statusMessageReporting.cc.

References n, and realloc().

Referenced by smr_allocateFormatMessage(), and tpia_misc_setMessageError_Element().

134  {
135 
136  int n, size = 128;
137  char *message = NULL;
138  va_list args_;
139 
140  while( 1 ) {
141  if( ( message = (char *) realloc( message, size ) ) == NULL ) return( NULL );
142  //TK110426
143 #if defined WIN32
144  args_ = *args;
145 #elif defined __IBMCPP__
146  va_copy( args_, *args );
147 #else
148  __va_copy( args_, *args );
149 #endif
150  n = vsnprintf( message, size, fmt, args_ );
151  va_end( args_ );
152  if( ( n > -1 ) && ( n < size ) ) break;
153  if( n > -1 ) { /* glibc 2.1 */
154  size = n + 3; }
155  else { /* glibc 2.0 */
156  size += 128;
157  }
158  }
159  return( message );
160 }
const G4int n
void * realloc(void *__ptr, size_t __size)
Definition: hjmalloc.cc:103
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.

References smr_status_Error, and status.

Referenced by tpia_misc_setMessageError_Element().

113  {
114 
115  int status = smr_setMessage( smr, userInterface, file, line, code, smr_status_Error, fmt, args );
116  return( status );
117 }
int status
Definition: tracer.cxx:24
Definition: inftrees.h:24
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.

References smr_status_Info, and status.

92  {
93 
94  int status = smr_setMessage( smr, userInterface, file, line, code, smr_status_Info, fmt, args );
95  return( status );
96 }
int status
Definition: tracer.cxx:24
Definition: inftrees.h:24