Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:33

0001 #ifndef statusMessageReporting_h_included
0002 #define statusMessageReporting_h_included
0003 
0004 #include <stdio.h>
0005 #include <stdarg.h>
0006 
0007 #ifdef WIN32
0008 #define __func__ __FUNCTION__
0009 #endif
0010 
0011 #if defined __cplusplus
0012     extern "C" {
0013     namespace GIDI {
0014 #endif
0015 
0016 #define smr_unknownID 0
0017 #define smr_tooManyIDs 1
0018 #define smr_invalidID 2
0019 #define smr_errnoID 3
0020 #define smr_smrID 4
0021 
0022 #define smr_maximumNumberOfRegisteredLibraries 128
0023 #define smr_maximumFileNameSize 1024
0024 #define smr_codeNULL 0
0025 #define smr_codeFileIO -1
0026 #define smr_codeMemoryAllocating -2
0027 enum smr_status { smr_status_Ok = 0, smr_status_Info, smr_status_Warning, smr_status_Error };
0028 typedef char *(*smr_userInterface)( void *userData );
0029 
0030 typedef struct statusMessageReport {
0031     struct statusMessageReport *next;
0032     enum smr_status status;
0033     int libraryID;
0034     int code;
0035     int line;
0036     char fileName[smr_maximumFileNameSize+1];           /* Do not free this. */
0037     char function[smr_maximumFileNameSize+1];           /* Do not free this. */
0038     char *message;                                      /* User must free this when done. Should use smr_release. */
0039 } statusMessageReport;
0040 
0041 typedef struct statusMessageReporting {
0042     enum smr_status verbosity;
0043     int append;                                         /* If 0, only one report allowed, else add to next list. */
0044     statusMessageReport report;
0045 } statusMessageReporting;
0046 
0047 int smr_setup( void );
0048 int smr_cleanup( void );
0049 
0050 int smr_registerLibrary( char const *libraryName );
0051 int smr_numberOfRegisteredLibraries( void );
0052 char const *smr_getRegisteredLibrariesName( int ID );
0053 
0054 statusMessageReporting *smr_new( statusMessageReporting *smr, enum smr_status verbosity, int append );
0055 int smr_initialize( statusMessageReporting *smr, enum smr_status verbosity, int append );
0056 void smr_release( statusMessageReporting *smr );
0057 void *smr_free( statusMessageReporting **smr );
0058 statusMessageReporting *smr_clone( statusMessageReporting *smr );
0059 
0060 int smr_setReportInfo(  statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... );
0061 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 );
0062 int smr_setReportWarning(  statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... );
0063 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 );
0064 int smr_setReportError(  statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... );
0065 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 );
0066 
0067 enum smr_status smr_highestStatus( statusMessageReporting *smr );
0068 int smr_isOk( statusMessageReporting *smr );
0069 int smr_isInfo( statusMessageReporting *smr );
0070 int smr_isWarning( statusMessageReporting *smr );
0071 int smr_isError( statusMessageReporting *smr );
0072 int smr_isWarningOrError( statusMessageReporting *smr );
0073 
0074 int smr_isReportOk( statusMessageReport *report );
0075 int smr_isReportInfo( statusMessageReport *report );
0076 int smr_isReportWarning( statusMessageReport *report );
0077 int smr_isReportError( statusMessageReport *report );
0078 int smr_isReportWarningOrError( statusMessageReport *report );
0079 
0080 int smr_numberOfReports( statusMessageReporting *smr );
0081 statusMessageReport *smr_firstReport( statusMessageReporting *smr );
0082 statusMessageReport *smr_nextReport( statusMessageReport *report );
0083 
0084 enum smr_status smr_getVerbosity( statusMessageReporting *smr );
0085 int smr_getAppend( statusMessageReporting *smr );
0086 
0087 int smr_getLibraryID( statusMessageReport *report );
0088 int smr_getCode( statusMessageReport *report );
0089 int smr_getLine( statusMessageReport *report );
0090 char const *smr_getFile( statusMessageReport *report );
0091 char const *smr_getFunction( statusMessageReport *report );
0092 char const *smr_getMessage( statusMessageReport *report );
0093 char *smr_copyMessage( statusMessageReport *report );
0094 char *smr_copyFullMessage( statusMessageReport *report );
0095 void smr_print( statusMessageReporting *smr, int clear );
0096 void smr_write( statusMessageReporting *smr, FILE *f, int clear );
0097 void smr_reportPrint( statusMessageReport *report );
0098 void smr_reportWrite( statusMessageReport *report, FILE *f );
0099 
0100 char const *smr_statusToString( enum smr_status status );
0101 
0102 char *smr_allocateFormatMessage( char const *fmt, ... );
0103 char *smr_vallocateFormatMessage( char const *fmt, va_list *args );
0104 
0105 void *smr_malloc( statusMessageReporting *smr, size_t size, int zero, char const *forItem, char const *file, int line, char const *function );
0106 void *smr_realloc( statusMessageReporting *smr, void *pOld, size_t size, char const *forItem, char const *file, int line, char const *function );
0107 void *smr_freeMemory( void **p );
0108 char *smr_allocateCopyString( statusMessageReporting *smr, char const *s, char const *forItem, char const *file, int line, char const *function );
0109 char *smr_allocateCopyStringN( statusMessageReporting *smr, char const *s, size_t n, char const *forItem, char const *file, int line, char const *function );
0110 
0111 #define smr_malloc2( smr, size, zero, forItem ) smr_malloc( smr, size, zero, forItem, __FILE__, __LINE__, __func__ )
0112 #define smr_realloc2( smr, old, size, forItem ) smr_realloc( smr, old, size, forItem, __FILE__, __LINE__, __func__ )
0113 #define smr_allocateCopyString2( smr, s, forItem ) smr_allocateCopyString( smr, s, forItem, __FILE__, __LINE__, __func__ )
0114 #define smr_allocateCopyStringN2( smr, s, n, forItem ) smr_allocateCopyStringN( smr, s, n, forItem, __FILE__, __LINE__, __func__ )
0115 
0116 #define smr_setReportInfo2( smr, libraryID, code, fmt, ... ) smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
0117 #define smr_setReportInfo2p( smr, libraryID, code, fmt ) smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )
0118 #define smr_vsetReportInfo2( smr, libraryID, code, fmt, args ) smr_vsetReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
0119 #define smr_setReportWarning2( smr, libraryID, code, fmt, ... ) smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
0120 #define smr_setReportWarning2p( smr, libraryID, code, fmt ) smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )
0121 #define smr_vsetReportWarning2( smr, libraryID, code, fmt, args ) smr_vsetReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
0122 #define smr_setReportError2( smr, libraryID, code, fmt, ... ) smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
0123 #define smr_setReportError2p( smr, libraryID, code, fmt ) smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt )
0124 #define smr_vsetReportError2( smr, libraryID, code, fmt, args ) smr_vsetReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
0125 
0126 #define smr_setReportInfo3( smr, userInterface, libraryID, code, fmt, ... ) smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
0127 #define smr_setReportInfo3p( smr, userInterface, libraryID, code, fmt ) smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )
0128 #define smr_vsetReportInfo3( smr, userInterface, libraryID, code, fmt, args ) smr_vsetReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
0129 #define smr_setReportWarning3( smr, userInterface, libraryID, code, fmt, ... ) smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
0130 #define smr_setReportWarning3p( smr, userInterface, libraryID, code, fmt ) smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )
0131 #define smr_vsetReportWarning3( smr, userInterface, libraryID, code, fmt, args ) smr_vsetReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
0132 #define smr_setReportError3( smr, userInterface, libraryID, code, fmt, ... ) smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ )
0133 #define smr_setReportError3p( smr, userInterface, libraryID, code, fmt ) smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt )
0134 #define smr_vsetReportError3( smr, userInterface, libraryID, code, fmt, args ) smr_vsetReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args )
0135 
0136 #if defined __cplusplus
0137     }
0138     }
0139 #endif
0140 
0141 #endif              /* End of statusMessageReporting_h_included. */