00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __msgprinter_h__
00034 #define __msgprinter_h__
00035
00068 #include <stdarg.h>
00069 #include <stdio.h>
00070
00076 typedef enum _rdd_message_t {
00077 RDD_MSG_INFO = 0x1,
00078 RDD_MSG_ERROR = 0x2,
00079 RDD_MSG_DEBUG = 0x4,
00080 RDD_MSG_WARN = 0x8
00081 } rdd_message_t;
00082
00091 typedef enum _rdd_mp_flags_t {
00092 RDD_MP_RECURSE = 0x1,
00093 RDD_MP_READONLY = 0x2
00094 } rdd_mp_flags_t;
00095
00096 struct _RDD_MSGPRINTER;
00097
00098 typedef void (*rdd_mp_print_fun)(struct _RDD_MSGPRINTER *printer,
00099 rdd_message_t type, int errcode, const char *msg);
00100 typedef int (*rdd_mp_close_fun)(struct _RDD_MSGPRINTER *printer,
00101 unsigned flags);
00102
00107 typedef struct _RDD_MSGPRINTER_OPS {
00108 rdd_mp_print_fun print;
00109 rdd_mp_close_fun close;
00110 } RDD_MSGPRINTER_OPS;
00111
00116 typedef struct _RDD_MSGPRINTER {
00117 char printbuf[1024];
00118 RDD_MSGPRINTER_OPS *ops;
00119 void *state;
00120 uint32_t mask;
00121 } RDD_MSGPRINTER;
00122
00137 int rdd_mp_open_printer(RDD_MSGPRINTER **printer, RDD_MSGPRINTER_OPS *ops,
00138 unsigned statesize);
00139
00140
00141
00142
00146 int rdd_mp_open_bcastprinter(RDD_MSGPRINTER **printer,
00147 unsigned nprinter, RDD_MSGPRINTER **printers);
00148
00152 int rdd_mp_open_stdio_printer(RDD_MSGPRINTER **printer, FILE *stream);
00153
00158 int rdd_mp_open_log_printer(RDD_MSGPRINTER **printer, RDD_MSGPRINTER *next);
00159
00163 int rdd_mp_open_file_printer(RDD_MSGPRINTER **printer, const char *path, const int force_overwrite);
00164
00167 int rdd_mp_close(RDD_MSGPRINTER *printer, unsigned flags);
00168
00171 uint32_t rdd_mp_get_mask(RDD_MSGPRINTER *printer);
00172
00175 void rdd_mp_set_mask(RDD_MSGPRINTER *printer, uint32_t mask);
00176
00179 void rdd_mp_print(RDD_MSGPRINTER *printer,
00180 rdd_message_t type, int errcode, const char *fmt, ...);
00181
00184 void rdd_mp_vmessage(RDD_MSGPRINTER *printer,
00185 rdd_message_t type, const char *fmt, va_list ap);
00186
00189 void rdd_mp_message(RDD_MSGPRINTER *printer,
00190 rdd_message_t type, const char *fmt, ...);
00191
00198 void rdd_mp_unixmsg(RDD_MSGPRINTER *printer,
00199 rdd_message_t type, int unix_errno, const char *fmt, ...);
00200
00207 void rdd_mp_vrddmsg(RDD_MSGPRINTER *printer,
00208 rdd_message_t type, int rdd_errno, const char *fmt, va_list ap);
00209
00216 void rdd_mp_rddmsg(RDD_MSGPRINTER *printer,
00217 rdd_message_t type, int rdd_errno, const char *fmt, ...);
00218
00219 #endif