Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
statusMessageReporting.h File Reference
#include <stdio.h>
#include <stdarg.h>
Include dependency graph for statusMessageReporting.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  statusMessageReport
 
struct  statusMessageReporting
 

Macros

#define smr_unknownID   0
 
#define smr_tooManyIDs   1
 
#define smr_invalidID   2
 
#define smr_errnoID   3
 
#define smr_smrID   4
 
#define smr_maximumNumberOfRegisteredLibraries   128
 
#define smr_maximumFileNameSize   1024
 
#define smr_codeNULL   0
 
#define smr_codeFileIO   -1
 
#define smr_codeMemoryAllocating   -2
 
#define smr_malloc2(smr, size, zero, forItem)   smr_malloc( smr, size, zero, forItem, __FILE__, __LINE__, __func__ )
 
#define smr_realloc2(smr, old, size, forItem)   smr_realloc( smr, old, size, forItem, __FILE__, __LINE__, __func__ )
 
#define smr_allocateCopyString2(smr, s, forItem)   smr_allocateCopyString( smr, s, forItem, __FILE__, __LINE__, __func__ )
 
#define smr_allocateCopyStringN2(smr, s, n, forItem)   smr_allocateCopyStringN( smr, s, n, forItem, __FILE__, __LINE__, __func__ )
 
#define smr_setReportInfo2(smr, libraryID, code, fmt,...)   smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
 
#define smr_setReportInfo2p(smr, libraryID, code, fmt)   smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )
 
#define smr_vsetReportInfo2(smr, libraryID, code, fmt, args)   smr_vsetReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
 
#define smr_setReportWarning2(smr, libraryID, code, fmt,...)   smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
 
#define smr_setReportWarning2p(smr, libraryID, code, fmt)   smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )
 
#define smr_vsetReportWarning2(smr, libraryID, code, fmt, args)   smr_vsetReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
 
#define smr_setReportError2(smr, libraryID, code, fmt,...)   smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
 
#define smr_setReportError2p(smr, libraryID, code, fmt)   smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )
 
#define smr_vsetReportError2(smr, libraryID, code, fmt, args)   smr_vsetReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
 
#define smr_setReportInfo3(smr, userInterface, libraryID, code, fmt,...)   smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
 
#define smr_setReportInfo3p(smr, userInterface, libraryID, code, fmt)   smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )
 
#define smr_vsetReportInfo3(smr, userInterface, libraryID, code, fmt, args)   smr_vsetReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
 
#define smr_setReportWarning3(smr, userInterface, libraryID, code, fmt,...)   smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
 
#define smr_setReportWarning3p(smr, userInterface, libraryID, code, fmt)   smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )
 
#define smr_vsetReportWarning3(smr, userInterface, libraryID, code, fmt, args)   smr_vsetReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
 
#define smr_setReportError3(smr, userInterface, libraryID, code, fmt,...)   smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
 
#define smr_setReportError3p(smr, userInterface, libraryID, code, fmt)   smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )
 
#define smr_vsetReportError3(smr, userInterface, libraryID, code, fmt, args)   smr_vsetReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
 

Typedefs

typedef char *(* smr_userInterface )(void *userData)
 
typedef struct statusMessageReport statusMessageReport
 
typedef struct
statusMessageReporting 
statusMessageReporting
 

Enumerations

enum  smr_status { smr_status_Ok = 0, smr_status_Info, smr_status_Warning, smr_status_Error }
 

Functions

int smr_setup (void)
 
int smr_cleanup (void)
 
int smr_registerLibrary (char const *libraryName)
 
int smr_numberOfRegisteredLibraries (void)
 
char const * smr_getRegisteredLibrariesName (int ID)
 
statusMessageReportingsmr_new (statusMessageReporting *smr, enum smr_status verbosity, int append)
 
int smr_initialize (statusMessageReporting *smr, enum smr_status verbosity, int append)
 
void smr_release (statusMessageReporting *smr)
 
voidsmr_free (statusMessageReporting **smr)
 
statusMessageReportingsmr_clone (statusMessageReporting *smr)
 
int smr_setReportInfo (statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
 
int smr_vsetReportInfo (statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args)
 
int smr_setReportWarning (statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
 
int smr_vsetReportWarning (statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args)
 
int smr_setReportError (statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
 
int smr_vsetReportError (statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args)
 
enum smr_status smr_highestStatus (statusMessageReporting *smr)
 
int smr_isOk (statusMessageReporting *smr)
 
int smr_isInfo (statusMessageReporting *smr)
 
int smr_isWarning (statusMessageReporting *smr)
 
int smr_isError (statusMessageReporting *smr)
 
int smr_isWarningOrError (statusMessageReporting *smr)
 
int smr_isReportOk (statusMessageReport *report)
 
int smr_isReportInfo (statusMessageReport *report)
 
int smr_isReportWarning (statusMessageReport *report)
 
int smr_isReportError (statusMessageReport *report)
 
int smr_isReportWarningOrError (statusMessageReport *report)
 
int smr_numberOfReports (statusMessageReporting *smr)
 
statusMessageReportsmr_firstReport (statusMessageReporting *smr)
 
statusMessageReportsmr_nextReport (statusMessageReport *report)
 
enum smr_status smr_getVerbosity (statusMessageReporting *smr)
 
int smr_getAppend (statusMessageReporting *smr)
 
int smr_getLibraryID (statusMessageReport *report)
 
int smr_getCode (statusMessageReport *report)
 
int smr_getLine (statusMessageReport *report)
 
char const * smr_getFile (statusMessageReport *report)
 
char const * smr_getFunction (statusMessageReport *report)
 
char const * smr_getMessage (statusMessageReport *report)
 
char * smr_copyMessage (statusMessageReport *report)
 
char * smr_copyFullMessage (statusMessageReport *report)
 
void smr_print (statusMessageReporting *smr, int clear)
 
void smr_write (statusMessageReporting *smr, FILE *f, int clear)
 
void smr_reportPrint (statusMessageReport *report)
 
void smr_reportWrite (statusMessageReport *report, FILE *f)
 
char const * smr_statusToString (enum smr_status status)
 
char * smr_allocateFormatMessage (char const *fmt,...)
 
char * smr_vallocateFormatMessage (char const *fmt, va_list *args)
 
voidsmr_malloc (statusMessageReporting *smr, size_t size, int zero, char const *forItem, char const *file, int line, char const *function)
 
voidsmr_realloc (statusMessageReporting *smr, void *pOld, size_t size, char const *forItem, char const *file, int line, char const *function)
 
voidsmr_freeMemory (void **p)
 
char * smr_allocateCopyString (statusMessageReporting *smr, char const *s, char const *forItem, char const *file, int line, char const *function)
 
char * smr_allocateCopyStringN (statusMessageReporting *smr, char const *s, size_t n, char const *forItem, char const *file, int line, char const *function)
 

Macro Definition Documentation

#define smr_allocateCopyString2 (   smr,
  s,
  forItem 
)    smr_allocateCopyString( smr, s, forItem, __FILE__, __LINE__, __func__ )

Definition at line 113 of file statusMessageReporting.h.

#define smr_allocateCopyStringN2 (   smr,
  s,
  n,
  forItem 
)    smr_allocateCopyStringN( smr, s, n, forItem, __FILE__, __LINE__, __func__ )

Definition at line 114 of file statusMessageReporting.h.

#define smr_codeFileIO   -1

Definition at line 25 of file statusMessageReporting.h.

#define smr_codeMemoryAllocating   -2

Definition at line 26 of file statusMessageReporting.h.

#define smr_codeNULL   0

Definition at line 24 of file statusMessageReporting.h.

#define smr_errnoID   3

Definition at line 19 of file statusMessageReporting.h.

#define smr_invalidID   2

Definition at line 18 of file statusMessageReporting.h.

#define smr_malloc2 (   smr,
  size,
  zero,
  forItem 
)    smr_malloc( smr, size, zero, forItem, __FILE__, __LINE__, __func__ )

Definition at line 111 of file statusMessageReporting.h.

#define smr_maximumFileNameSize   1024

Definition at line 23 of file statusMessageReporting.h.

#define smr_maximumNumberOfRegisteredLibraries   128

Definition at line 22 of file statusMessageReporting.h.

#define smr_realloc2 (   smr,
  old,
  size,
  forItem 
)    smr_realloc( smr, old, size, forItem, __FILE__, __LINE__, __func__ )

Definition at line 112 of file statusMessageReporting.h.

#define smr_setReportError2 (   smr,
  libraryID,
  code,
  fmt,
  ... 
)    smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )

Definition at line 122 of file statusMessageReporting.h.

#define smr_setReportError2p (   smr,
  libraryID,
  code,
  fmt 
)    smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )

Definition at line 123 of file statusMessageReporting.h.

#define smr_setReportError3 (   smr,
  userInterface,
  libraryID,
  code,
  fmt,
  ... 
)    smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )

Definition at line 132 of file statusMessageReporting.h.

#define smr_setReportError3p (   smr,
  userInterface,
  libraryID,
  code,
  fmt 
)    smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )

Definition at line 133 of file statusMessageReporting.h.

#define smr_setReportInfo2 (   smr,
  libraryID,
  code,
  fmt,
  ... 
)    smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )

Definition at line 116 of file statusMessageReporting.h.

#define smr_setReportInfo2p (   smr,
  libraryID,
  code,
  fmt 
)    smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )

Definition at line 117 of file statusMessageReporting.h.

#define smr_setReportInfo3 (   smr,
  userInterface,
  libraryID,
  code,
  fmt,
  ... 
)    smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )

Definition at line 126 of file statusMessageReporting.h.

#define smr_setReportInfo3p (   smr,
  userInterface,
  libraryID,
  code,
  fmt 
)    smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )

Definition at line 127 of file statusMessageReporting.h.

#define smr_setReportWarning2 (   smr,
  libraryID,
  code,
  fmt,
  ... 
)    smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )

Definition at line 119 of file statusMessageReporting.h.

#define smr_setReportWarning2p (   smr,
  libraryID,
  code,
  fmt 
)    smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )

Definition at line 120 of file statusMessageReporting.h.

#define smr_setReportWarning3 (   smr,
  userInterface,
  libraryID,
  code,
  fmt,
  ... 
)    smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )

Definition at line 129 of file statusMessageReporting.h.

#define smr_setReportWarning3p (   smr,
  userInterface,
  libraryID,
  code,
  fmt 
)    smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )

Definition at line 130 of file statusMessageReporting.h.

#define smr_smrID   4

Definition at line 20 of file statusMessageReporting.h.

#define smr_tooManyIDs   1

Definition at line 17 of file statusMessageReporting.h.

#define smr_unknownID   0

Definition at line 16 of file statusMessageReporting.h.

#define smr_vsetReportError2 (   smr,
  libraryID,
  code,
  fmt,
  args 
)    smr_vsetReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )

Definition at line 124 of file statusMessageReporting.h.

#define smr_vsetReportError3 (   smr,
  userInterface,
  libraryID,
  code,
  fmt,
  args 
)    smr_vsetReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )

Definition at line 134 of file statusMessageReporting.h.

#define smr_vsetReportInfo2 (   smr,
  libraryID,
  code,
  fmt,
  args 
)    smr_vsetReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )

Definition at line 118 of file statusMessageReporting.h.

#define smr_vsetReportInfo3 (   smr,
  userInterface,
  libraryID,
  code,
  fmt,
  args 
)    smr_vsetReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )

Definition at line 128 of file statusMessageReporting.h.

#define smr_vsetReportWarning2 (   smr,
  libraryID,
  code,
  fmt,
  args 
)    smr_vsetReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )

Definition at line 121 of file statusMessageReporting.h.

#define smr_vsetReportWarning3 (   smr,
  userInterface,
  libraryID,
  code,
  fmt,
  args 
)    smr_vsetReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )

Definition at line 131 of file statusMessageReporting.h.

Typedef Documentation

typedef char*(* smr_userInterface)(void *userData)

Definition at line 28 of file statusMessageReporting.h.

Enumeration Type Documentation

enum smr_status
Enumerator
smr_status_Ok 
smr_status_Info 
smr_status_Warning 
smr_status_Error 

Definition at line 27 of file statusMessageReporting.h.

Function Documentation

char* smr_allocateCopyString ( statusMessageReporting smr,
char const *  s,
char const *  forItem,
char const *  file,
int  line,
char const *  function 
)

Definition at line 652 of file statusMessageReporting.cc.

652  {
653 /*
654 * User must free returned string.
655 */
656  char *c = strdup( s );
657 
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 );
660  return( c );
661 }
const XML_Char * s
Definition: expat.h:262
int smr_setReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
#define smr_smrID
tuple c
Definition: test.py:13

Here is the call graph for this function:

Here is the caller graph for this function:

char* smr_allocateCopyStringN ( statusMessageReporting smr,
char const *  s,
size_t  n,
char const *  forItem,
char const *  file,
int  line,
char const *  function 
)

Definition at line 665 of file statusMessageReporting.cc.

665  {
666 /*
667 * User must free returned string.
668 */
669  size_t l = strlen( s );
670  char *c;
671 
672  if( l > n ) l = n;
673  if( ( c = (char *) smr_malloc( smr, l + 1, 0, forItem, file, line, function ) ) != NULL ) {
674  strncpy( c, s, n );
675  c[l] = 0;
676  }
677 /*
678  c = strndup( s, l ); # Not standard on enough systems.
679  if( c != NULL ) {
680  c[l] = 0; }
681  else {
682  smr_setReportError( smr, NULL, file, line, function, smr_smrID, -1, " smr_allocateCopyStringN: strndup failed for strlen( s ) = %z for variable %s",
683  strlen( s ), forItem );
684  }
685 */
686  return( c );
687 }
const XML_Char * s
Definition: expat.h:262
const G4int n
void * smr_malloc(statusMessageReporting *smr, size_t size, int zero, char const *forItem, char const *file, int line, char const *function)
tuple c
Definition: test.py:13

Here is the call graph for this function:

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

Definition at line 568 of file statusMessageReporting.cc.

568  {
569 
570  char *s;
571  va_list args;
572 
573  va_start( args, fmt );
574  s = smr_vallocateFormatMessage( fmt, &args );
575  va_end( args );
576  return( s );
577 }
const XML_Char * s
Definition: expat.h:262
char * smr_vallocateFormatMessage(char const *fmt, va_list *args)

Here is the call graph for this function:

Here is the caller graph for this function:

int smr_cleanup ( void  )

Definition at line 64 of file statusMessageReporting.cc.

64  {
65 
66  int i;
67 
68  if( smrIsSetup == 0 ) return( 0 );
69  for( i = smr_smrID + 1; i < numberOfRegisteredLibraries; ++i ) smr_freeMemory( (void **) &(registeredLibraries[i]) );
70  numberOfRegisteredLibraries = 0;
71  smrIsSetup = 0;
72 
73  return( 0 );
74 }
static char * registeredLibraries[smr_maximumNumberOfRegisteredLibraries]
void * smr_freeMemory(void **p)
static int numberOfRegisteredLibraries
static int smrIsSetup
#define smr_smrID

Here is the call graph for this function:

Definition at line 131 of file statusMessageReporting.cc.

131  {
132 
133  if( smr == NULL ) return( NULL );
134  return( smr_new( NULL, smr->verbosity, smr->append ) );
135 }
statusMessageReporting * smr_new(statusMessageReporting *smr, enum smr_status verbosity, int append)

Here is the call graph for this function:

char* smr_copyFullMessage ( statusMessageReport report)

Definition at line 514 of file statusMessageReporting.cc.

514  {
515 
516  if( report == NULL ) return( NULL );
517  if( report->status == smr_status_Ok ) return( NULL );
518  return( smr_allocateFormatMessage( "%s\nAt line %d of %s in function %s", report->message, report->line, report->fileName, report->function ) );
519 }
char * smr_allocateFormatMessage(char const *fmt,...)
char fileName[smr_maximumFileNameSize+1]
char function[smr_maximumFileNameSize+1]

Here is the call graph for this function:

char* smr_copyMessage ( statusMessageReport report)

Definition at line 505 of file statusMessageReporting.cc.

505  {
506 
507  if( report == NULL ) return( NULL );
508  if( report->status == smr_status_Ok ) return( NULL );
509  return( smr_allocateFormatMessage( report->message ) );
510 }
char * smr_allocateFormatMessage(char const *fmt,...)

Here is the call graph for this function:

statusMessageReport* smr_firstReport ( statusMessageReporting smr)

Definition at line 424 of file statusMessageReporting.cc.

424  {
425 
426  if( smr == NULL ) return( NULL );
427  if( smr->report.status == smr_status_Ok ) return( NULL );
428  return( &(smr->report) );
429 }
statusMessageReport report

Here is the caller graph for this function:

void* smr_free ( statusMessageReporting **  smr)

Definition at line 154 of file statusMessageReporting.cc.

154  {
155 
156  if( smr == NULL ) return( NULL );
157  if( *smr != NULL ) {
158  smr_release( *smr );
159  smr_freeMemory( (void **) smr );
160  }
161  return( *smr );
162 }
void smr_release(statusMessageReporting *smr)
void * smr_freeMemory(void **p)

Here is the call graph for this function:

void* smr_freeMemory ( void **  p)

Definition at line 640 of file statusMessageReporting.cc.

640  {
641 
642  if( p == NULL ) return( NULL );
643  if( *p != NULL ) {
644  free( *p );
645  *p = NULL;
646  }
647  return( *p );
648 }
const char * p
Definition: xmltok.h:285
int smr_getAppend ( statusMessageReporting smr)

Definition at line 449 of file statusMessageReporting.cc.

449  {
450 
451  if( smr == NULL ) return( 0 );
452  return( smr->append );
453 }
int smr_getCode ( statusMessageReport report)

Definition at line 465 of file statusMessageReporting.cc.

465  {
466 
467  if( report == NULL ) return( -1 );
468  return( report->code );
469 }
char const* smr_getFile ( statusMessageReport report)

Definition at line 481 of file statusMessageReporting.cc.

481  {
482 
483  if( report == NULL ) return( NULL );
484  return( report->fileName );
485 }
char fileName[smr_maximumFileNameSize+1]
char const* smr_getFunction ( statusMessageReport report)

Definition at line 489 of file statusMessageReporting.cc.

489  {
490 
491  if( report == NULL ) return( NULL );
492  return( report->function );
493 }
char function[smr_maximumFileNameSize+1]
int smr_getLibraryID ( statusMessageReport report)

Definition at line 457 of file statusMessageReporting.cc.

457  {
458 
459  if( report == NULL ) return( 0 );
460  return( report->libraryID );
461 }
int smr_getLine ( statusMessageReport report)

Definition at line 473 of file statusMessageReporting.cc.

473  {
474 
475  if( report == NULL ) return( -1 );
476  return( report->line );
477 }
char const* smr_getMessage ( statusMessageReport report)

Definition at line 497 of file statusMessageReporting.cc.

497  {
498 
499  if( report == NULL ) return( NULL );
500  return( report->message );
501 }
char const* smr_getRegisteredLibrariesName ( int  ID)

Definition at line 101 of file statusMessageReporting.cc.

101  {
102 
103  if( ( ID < 0 ) || ( ID >= smr_maximumNumberOfRegisteredLibraries ) ) return( NULL );
104  return( registeredLibraries[ID] );
105 }
static char * registeredLibraries[smr_maximumNumberOfRegisteredLibraries]
#define smr_maximumNumberOfRegisteredLibraries
enum smr_status smr_getVerbosity ( statusMessageReporting smr)

Definition at line 441 of file statusMessageReporting.cc.

441  {
442 
443  if( smr == NULL ) return( smr_status_Ok );
444  return( smr->verbosity );
445 }
enum smr_status smr_highestStatus ( statusMessageReporting smr)

Definition at line 322 of file statusMessageReporting.cc.

322  {
323 
324  enum smr_status status = smr_status_Ok;
325  statusMessageReport *report;
326 
327  if( smr == NULL ) return( smr_status_Ok );
328  for( report = smr_firstReport( smr ); report != NULL; report = smr_nextReport( report ) ) if( report->status > status ) status = report->status;
329  return( status );
330 }
statusMessageReport * smr_firstReport(statusMessageReporting *smr)
statusMessageReport * smr_nextReport(statusMessageReport *report)

Here is the call graph for this function:

Here is the caller graph for this function:

int smr_initialize ( statusMessageReporting smr,
enum smr_status  verbosity,
int  append 
)

Definition at line 120 of file statusMessageReporting.cc.

120  {
121 
122  if( smr == NULL ) return( 0 );
123  smr->verbosity = verbosity;
124  smr->append = append;
125  smr_reportInitialize( &(smr->report) );
126  return( 0 );
127 }
statusMessageReport report
static int smr_reportInitialize(statusMessageReport *report)

Here is the call graph for this function:

Here is the caller graph for this function:

int smr_isError ( statusMessageReporting smr)

Definition at line 355 of file statusMessageReporting.cc.

355  {
356 
357  return( smr_highestStatus( smr ) == smr_status_Error );
358 }
enum smr_status smr_highestStatus(statusMessageReporting *smr)

Here is the call graph for this function:

int smr_isInfo ( statusMessageReporting smr)

Definition at line 341 of file statusMessageReporting.cc.

341  {
342 
343  return( smr_highestStatus( smr ) == smr_status_Info );
344 }
enum smr_status smr_highestStatus(statusMessageReporting *smr)

Here is the call graph for this function:

int smr_isOk ( statusMessageReporting smr)

Definition at line 334 of file statusMessageReporting.cc.

334  {
335 
336  return( smr_highestStatus( smr ) == smr_status_Ok );
337 }
enum smr_status smr_highestStatus(statusMessageReporting *smr)

Here is the call graph for this function:

Here is the caller graph for this function:

int smr_isReportError ( statusMessageReport report)

Definition at line 395 of file statusMessageReporting.cc.

395  {
396 
397  if( report == NULL ) return( 0 );
398  return( report->status == smr_status_Error );
399 }
int smr_isReportInfo ( statusMessageReport report)

Definition at line 379 of file statusMessageReporting.cc.

379  {
380 
381  if( report == NULL ) return( 0 );
382  return( report->status == smr_status_Info );
383 }
int smr_isReportOk ( statusMessageReport report)

Definition at line 371 of file statusMessageReporting.cc.

371  {
372 
373  if( report == NULL ) return( 0 );
374  return( report->status == smr_status_Ok );
375 }
int smr_isReportWarning ( statusMessageReport report)

Definition at line 387 of file statusMessageReporting.cc.

387  {
388 
389  if( report == NULL ) return( 0 );
390  return( report->status == smr_status_Warning );
391 }
int smr_isReportWarningOrError ( statusMessageReport report)

Definition at line 403 of file statusMessageReporting.cc.

403  {
404 
405  if( report == NULL ) return( 0 );
406  return( ( report->status == smr_status_Warning ) || ( report->status == smr_status_Error ) );
407 }
int smr_isWarning ( statusMessageReporting smr)

Definition at line 348 of file statusMessageReporting.cc.

348  {
349 
350  return( smr_highestStatus( smr ) == smr_status_Warning );
351 }
enum smr_status smr_highestStatus(statusMessageReporting *smr)

Here is the call graph for this function:

int smr_isWarningOrError ( statusMessageReporting smr)

Definition at line 362 of file statusMessageReporting.cc.

362  {
363 
364  enum smr_status status = smr_highestStatus( smr );
365 
366  return( ( status == smr_status_Warning ) || ( status == smr_status_Error ) );
367 }
enum smr_status smr_highestStatus(statusMessageReporting *smr)

Here is the call graph for this function:

void* smr_malloc ( statusMessageReporting smr,
size_t  size,
int  zero,
char const *  forItem,
char const *  file,
int  line,
char const *  function 
)

Definition at line 611 of file statusMessageReporting.cc.

611  {
612 
613  void *p = smr_realloc( smr, NULL, size, forItem, file, line, function );
614  size_t i;
615  char *c;
616  long long *l;
617 
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;
621  }
622 
623  return( p );
624 }
const char * p
Definition: xmltok.h:285
tuple c
Definition: test.py:13
void * smr_realloc(statusMessageReporting *smr, void *pOld, size_t size, char const *forItem, char const *file, int line, char const *function)

Here is the call graph for this function:

Here is the caller graph for this function:

statusMessageReporting* smr_new ( statusMessageReporting smr,
enum smr_status  verbosity,
int  append 
)

Definition at line 109 of file statusMessageReporting.cc.

109  {
110 
111  statusMessageReporting *new_SMR;
112 
113  if( ( new_SMR = (statusMessageReporting *) smr_malloc2( smr, sizeof( statusMessageReporting ), 0, "new_SMR" ) ) == NULL ) return( NULL );
114  smr_initialize( new_SMR, verbosity, append );
115  return( new_SMR );
116 }
#define smr_malloc2(smr, size, zero, forItem)
int smr_initialize(statusMessageReporting *smr, enum smr_status verbosity, int append)

Here is the call graph for this function:

Here is the caller graph for this function:

statusMessageReport* smr_nextReport ( statusMessageReport report)

Definition at line 433 of file statusMessageReporting.cc.

433  {
434 
435  if( report == NULL ) return( NULL );
436  return( report->next );
437 }
struct statusMessageReport * next

Here is the caller graph for this function:

int smr_numberOfRegisteredLibraries ( void  )

Definition at line 94 of file statusMessageReporting.cc.

94  {
95 
97 }
static int numberOfRegisteredLibraries
int smr_numberOfReports ( statusMessageReporting smr)

Definition at line 411 of file statusMessageReporting.cc.

411  {
412 
413  int n = 0;
414  statusMessageReport *report;
415 
416  if( smr == NULL ) return( 0 );
417  if( smr->report.status == smr_status_Ok ) return( 0 );
418  for( report = smr_firstReport( smr ); report != NULL; report = smr_nextReport( report ) ) ++n;
419  return( n );
420 }
statusMessageReport * smr_firstReport(statusMessageReporting *smr)
statusMessageReport report
const G4int n
statusMessageReport * smr_nextReport(statusMessageReport *report)

Here is the call graph for this function:

void smr_print ( statusMessageReporting smr,
int  clear 
)

Definition at line 523 of file statusMessageReporting.cc.

523  {
524 
525  smr_write( smr, stdout, clear );
526 }
void smr_write(statusMessageReporting *smr, FILE *f, int clear)

Here is the call graph for this function:

Here is the caller graph for this function:

void* smr_realloc ( statusMessageReporting smr,
void pOld,
size_t  size,
char const *  forItem,
char const *  file,
int  line,
char const *  function 
)

Definition at line 628 of file statusMessageReporting.cc.

628  {
629 
630  void *p = realloc( pOld, size );
631 
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 );
634  }
635  return( p );
636 }
const char * p
Definition: xmltok.h:285
int smr_setReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
#define smr_smrID

Here is the call graph for this function:

Here is the caller graph for this function:

int smr_registerLibrary ( char const *  libraryName)

Definition at line 78 of file statusMessageReporting.cc.

78  {
79 
80  int i;
81 
82  if( smrIsSetup == 0 ) return( -1 );
84  for( i = 0; i < numberOfRegisteredLibraries; ++i ) { /* Check if name is already registered. */
85  if( strcmp( libraryName, registeredLibraries[i] ) == 0 ) return( i );
86  }
87  if( ( registeredLibraries[numberOfRegisteredLibraries] = strdup( libraryName ) ) == NULL ) return( -2 );
89  return( numberOfRegisteredLibraries - 1 );
90 }
static char * registeredLibraries[smr_maximumNumberOfRegisteredLibraries]
#define smr_tooManyIDs
static int numberOfRegisteredLibraries
static int smrIsSetup
#define smr_maximumNumberOfRegisteredLibraries
void smr_release ( statusMessageReporting smr)

Definition at line 139 of file statusMessageReporting.cc.

139  {
140 
141  statusMessageReport *current, *next, *first = smr_firstReport( smr );
142 
143  if( smr == NULL ) return;
144  for( current = first; current != NULL; current = next ) {
145  next = smr_nextReport( current );
146  smr_reportRelease( current );
147  if( current != first ) smr_freeMemory( (void **) &current );
148  }
149  smr_initialize( smr, smr->verbosity, smr->append );
150 }
statusMessageReport * smr_firstReport(statusMessageReporting *smr)
void * smr_freeMemory(void **p)
int smr_initialize(statusMessageReporting *smr, enum smr_status verbosity, int append)
statusMessageReport * smr_nextReport(statusMessageReport *report)
static void smr_reportRelease(statusMessageReport *report)

Here is the call graph for this function:

Here is the caller graph for this function:

void smr_reportPrint ( statusMessageReport report)

Definition at line 541 of file statusMessageReporting.cc.

541  {
542 
543  smr_reportWrite( report, stderr );
544 }
void smr_reportWrite(statusMessageReport *report, FILE *f)

Here is the call graph for this function:

void smr_reportWrite ( statusMessageReport report,
FILE *  f 
)

Definition at line 548 of file statusMessageReporting.cc.

548  {
549 
550  if( report->message != NULL ) fprintf( f, "%s\nAt line %d of %s in function %s\n", report->message, report->line, report->fileName, report->function );
551 }
char fileName[smr_maximumFileNameSize+1]
char function[smr_maximumFileNameSize+1]

Here is the caller graph for this function:

int smr_setReportError ( statusMessageReporting smr,
void userInterface,
char const *  file,
int  line,
char const *  function,
int  libraryID,
int  code,
char const *  fmt,
  ... 
)

Definition at line 302 of file statusMessageReporting.cc.

302  {
303 
304  int status;
305  va_list args;
306 
307  va_start( args, fmt );
308  status = smr_setReport( smr, userInterface, file, line, function, libraryID, code, smr_status_Error, fmt, &args );
309  va_end( args );
310  return( status );
311 }
static int smr_setReport(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, enum smr_status status, char const *fmt, va_list *args)
Definition: inftrees.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

int smr_setReportInfo ( statusMessageReporting smr,
void userInterface,
char const *  file,
int  line,
char const *  function,
int  libraryID,
int  code,
char const *  fmt,
  ... 
)

Definition at line 262 of file statusMessageReporting.cc.

262  {
263 
264  int status;
265  va_list args;
266 
267  va_start( args, fmt );
268  status = smr_setReport( smr, userInterface, file, line, function, libraryID, code, smr_status_Info, fmt, &args );
269  va_end( args );
270  return( status );
271 }
static int smr_setReport(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, enum smr_status status, char const *fmt, va_list *args)
Definition: inftrees.h:24

Here is the call graph for this function:

int smr_setReportWarning ( statusMessageReporting smr,
void userInterface,
char const *  file,
int  line,
char const *  function,
int  libraryID,
int  code,
char const *  fmt,
  ... 
)

Definition at line 282 of file statusMessageReporting.cc.

282  {
283 
284  int status;
285  va_list args;
286 
287  va_start( args, fmt );
288  status = smr_setReport( smr, userInterface, file, line, function, libraryID, code, smr_status_Warning, fmt, &args );
289  va_end( args );
290  return( status );
291 }
static int smr_setReport(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, enum smr_status status, char const *fmt, va_list *args)
Definition: inftrees.h:24

Here is the call graph for this function:

int smr_setup ( void  )

Definition at line 42 of file statusMessageReporting.cc.

42  {
43 
44  int i;
45 
46  if( smrIsSetup ) return( 0 );
47  smrIsSetup = 1;
48  for( i = 0; i < smr_maximumNumberOfRegisteredLibraries; ++i ) registeredLibraries[i] = NULL;
59  return( 1 );
60 }
static char * registeredLibraries[smr_maximumNumberOfRegisteredLibraries]
#define smr_tooManyIDs
static char unknownLibrary[]
#define smr_errnoID
#define smr_invalidID
static char tooManyLibrary[]
static char smrLibrary[]
static char invalidLibrary[]
#define smr_unknownID
static char errnoLibrary[]
static int numberOfRegisteredLibraries
static int smrIsSetup
#define smr_smrID
#define smr_maximumNumberOfRegisteredLibraries
char const* smr_statusToString ( enum smr_status  status)

Definition at line 555 of file statusMessageReporting.cc.

555  {
556 
557  switch( status ) {
558  case smr_status_Ok : return( statusStringOk );
559  case smr_status_Info : return( statusStringInfo );
560  case smr_status_Warning : return( statusStringWarning );
561  case smr_status_Error : return( statusStringError );
562  }
563  return( statusStringInvalid );
564 }
static char statusStringWarning[]
static char statusStringError[]
static char statusStringInvalid[]
static char statusStringInfo[]
static char statusStringOk[]
char* smr_vallocateFormatMessage ( char const *  fmt,
va_list *  args 
)

Definition at line 581 of file statusMessageReporting.cc.

581  {
582 
583  int n, size = SMR_InitialMessageSize;
584  char buffer[SMR_InitialMessageSize], *message = buffer;
585  va_list args_;
586 
587  while( 1 ) {
588  va_copy( args_, *args );
589  n = vsnprintf( message, size, fmt, args_ );
590  va_end( args_ );
591  if( ( n > -1 ) && ( n < size ) ) break;
592  if( n > -1 ) { /* glibc 2.1 */
593  size = n + 3; }
594  else { /* glibc 2.0 */
595  size += SMR_IncrementMessageSize;
596  }
597  if( message == buffer ) message = NULL;
598  if( ( message = (char *) realloc( message, size ) ) == NULL ) return( NULL );
599  } // Loop checking, 11.06.2015, T. Koi
600  if( message == buffer ) {
601  if( ( message = (char *) malloc( n + 1 ) ) == NULL ) return( NULL );
602  strcpy( message, buffer ); }
603  else {
604  if( ( message = (char *) realloc( message, n + 1 ) ) == NULL ) return( NULL );
605  }
606  return( message );
607 }
#define SMR_IncrementMessageSize
#define buffer
Definition: xmlparse.cc:628
#define SMR_InitialMessageSize
const G4int n

Here is the caller graph for this function:

int smr_vsetReportError ( statusMessageReporting smr,
void userInterface,
char const *  file,
int  line,
char const *  function,
int  libraryID,
int  code,
char const *  fmt,
va_list *  args 
)

Definition at line 315 of file statusMessageReporting.cc.

315  {
316 
317  return( smr_setReport( smr, userInterface, file, line, function, libraryID, code, smr_status_Error, fmt, args ) );
318 }
static int smr_setReport(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, enum smr_status status, char const *fmt, va_list *args)
Definition: inftrees.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

int smr_vsetReportInfo ( statusMessageReporting smr,
void userInterface,
char const *  file,
int  line,
char const *  function,
int  libraryID,
int  code,
char const *  fmt,
va_list *  args 
)

Definition at line 275 of file statusMessageReporting.cc.

275  {
276 
277  return( smr_setReport( smr, userInterface, file, line, function, libraryID, code, smr_status_Info, fmt, args ) );
278 }
static int smr_setReport(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, enum smr_status status, char const *fmt, va_list *args)
Definition: inftrees.h:24

Here is the call graph for this function:

int smr_vsetReportWarning ( statusMessageReporting smr,
void userInterface,
char const *  file,
int  line,
char const *  function,
int  libraryID,
int  code,
char const *  fmt,
va_list *  args 
)

Definition at line 295 of file statusMessageReporting.cc.

295  {
296 
297  return( smr_setReport( smr, userInterface, file, line, function, libraryID, code, smr_status_Warning, fmt, args ) );
298 }
static int smr_setReport(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, enum smr_status status, char const *fmt, va_list *args)
Definition: inftrees.h:24

Here is the call graph for this function:

void smr_write ( statusMessageReporting smr,
FILE *  f,
int  clear 
)

Definition at line 530 of file statusMessageReporting.cc.

530  {
531 
532  statusMessageReport *report;
533 
534  if( smr == NULL ) return;
535  for( report = smr_firstReport( smr ); report != NULL; report = smr_nextReport( report ) ) smr_reportWrite( report, f );
536  if( clear ) smr_release( smr );
537 }
void smr_release(statusMessageReporting *smr)
statusMessageReport * smr_firstReport(statusMessageReporting *smr)
statusMessageReport * smr_nextReport(statusMessageReport *report)
void smr_reportWrite(statusMessageReport *report, FILE *f)

Here is the call graph for this function:

Here is the caller graph for this function: