edt_error.h

Go to the documentation of this file.
00001 
00008 #ifndef _edt_msg_H
00009 #define _edt_msg_H
00010 
00011 #include "edt_utils.h"
00012 #include <stdarg.h>
00013 
00014 #ifdef __cplusplus
00015 
00016 extern "C" {
00017 
00018 #endif
00019 
00020 
00083 typedef int (*EdtMsgFunction)(void *target, int level, const char *message);
00084 
00091 typedef struct _edt_msg_handler {
00092 
00093   EdtMsgFunction func; 
00094   int level;
00096   FILE * file; 
00099   unsigned char own_file; 
00100   void * target;
00101 
00102 } EdtMsgHandler;
00103 
00104 
00105 
00106 /* default initialization - uses stdout and stderr */
00107 
00108 EDTAPI void edt_msg_init(EdtMsgHandler *msg_p);
00109 
00110 EDTAPI void edt_msg_init_names(EdtMsgHandler *msg_p, char *file, int level);
00111 
00112 EDTAPI void edt_msg_init_files(EdtMsgHandler *msg_p, FILE *file, int level);
00113 
00114 EDTAPI void edt_msg_close(EdtMsgHandler *msg_p);
00115 
00116 EDTAPI void edt_msg_set_level(EdtMsgHandler *msg_p, int newlevel);
00117 
00118 EDTAPI int edt_msg_get_level(EdtMsgHandler *msg_p);
00119 
00120 EDTAPI void edt_msg_add_level(EdtMsgHandler *msg_p, int level);
00121 
00122 EDTAPI void edt_msg_set_function(EdtMsgHandler *msg_p, EdtMsgFunction f);
00123 
00124 EDTAPI void edt_msg_set_file(EdtMsgHandler *msg_p, FILE *f);
00125 
00126 EDTAPI void edt_msg_set_target(EdtMsgHandler *msg_p, void *t);
00127 
00128 /* Sets the file to that named in the argument f */
00129 EDTAPI void edt_msg_set_name(EdtMsgHandler *msg_p, const char *f);
00130 
00131 EDTAPI int edt_msg(int level, const char *format, ...);
00132 EDTAPI int edt_msg_output(EdtMsgHandler *msg_p, int level, const char *format, ...);
00133 
00134 EDTAPI int edt_msg_perror(int level, const char *msg);
00135 EDTAPI int edt_msg_output_perror(EdtMsgHandler *msg_p, int level, const char *message);
00136 EDTAPI int edt_msg_printf_perror(int level, const char *format, ...);
00137 EDTAPI int edt_msg_output_printf_perror(EdtMsgHandler *msg_p,  int level, const char *format, ...);
00138 
00139 
00140 EDTAPI EdtMsgHandler *edt_msg_default_handle(void);
00141 EDTAPI int edt_msg_default_level(void);
00142 EDTAPI char *edt_msg_last_error(void); /* returns pointer to most recent 
00143                                       msg string */
00144 
00145 EDTAPI void edt_set_verbosity(int verbose); /* simple verbose level setting */
00146 EDTAPI int edt_get_verbosity(void); /* return simple verbose level setting */
00147 
00148 
00149 EDTAPI int lvl_printf(int delta, char *format, ...);
00150 
00151 /*
00152  * predefined message flags. EDTAPP_MSG are for general purpose application
00153  * use EDTLIB_MSG are for libedt messages. PDVLIB are for libpdv messages.
00154  * Application programmers can define other flags in the 0x1000 to
00155  * 0x1000000 range
00156  */
00157 
00159 #define EDTAPP_MSG_FATAL        0x1
00160 
00162 #define EDTAPP_MSG_WARNING      0x2
00163 
00165 #define EDTAPP_MSG_INFO_1       0x4
00166 
00168 #define EDTAPP_MSG_INFO_2       0x8
00169 
00170 
00172 #define EDTLIB_MSG_FATAL        0x10
00173 
00174 #define EDTLIB_MSG_WARNING      0x20
00175 
00177 #define EDTLIB_MSG_INFO_1       0x40
00178 
00180 #define EDTLIB_MSG_INFO_2       0x80
00181 
00182 
00183 
00185 #define PDVLIB_MSG_FATAL        0x100 
00186 
00188 #define PDVLIB_MSG_WARNING      0x200
00189 
00191 #define PDVLIB_MSG_INFO_1       0x400
00192 
00194 #define PDVLIB_MSG_INFO_2       0x800
00195 
00196 #define EDT_MSG_ALWAYS      0x80000000
00197 
00198 
00199 #define EDT_MSG_FATAL \
00200         EDTAPP_MSG_FATAL | EDTLIB_MSG_FATAL | PDVLIB_MSG_FATAL
00201 
00202 #define EDT_MSG_WARNING \
00203         EDTAPP_MSG_WARNING | EDTLIB_MSG_WARNING | PDVLIB_MSG_WARNING
00204 
00205 #define EDT_MSG_INFO_1 \
00206         EDTAPP_MSG_INFO_1 | EDTLIB_MSG_INFO_1 | PDVLIB_MSG_INFO_1
00207 
00208 #define EDT_MSG_INFO_2 \
00209         EDTAPP_MSG_INFO_2 | EDTLIB_MSG_INFO_2 | PDVLIB_MSG_INFO_2
00210 
00211 
00212 #define edt_msg_add_default_level(addlevel) \
00213     edt_msg_set_level(edt_msg_default_handle(), edt_msg_default_level() | addlevel)
00214 
00215  /* end group msg */
00217 
00218 #ifdef __cplusplus
00219 }
00220 #endif
00221 
00222 typedef enum EdtReturn {
00223 
00224 RET_SUCCESS = 0,
00225 ERROR_GENERIC = -1,
00226 ERROR_BADCHANNEL = -2,
00227 ERROR_CONNECTION = -3,
00228 ERROR_BADPARAM = -4,
00229 ERROR_BADPATH = -5,
00230 ERROR_BADDEVICE = -6,
00231 ERROR_PERMISSION = -7,
00232 ERROR_NOCODE = -8,
00233 ERROR_UNDEFINED = -9,
00234 ERROR_NULL_POINTER = -10,
00235 ERROR_NO_FILE = -11,
00236 ERROR_RESPONSE = -12
00237 
00238 } EdtReturn;
00239 
00240 #endif

Generated on 19 Jun 2015 by  doxygen 1.4.7