This commit was generated by cvs2svn to compensate for changes in r2,
[ircu2.10.12-pk.git] / include / s_debug.h
1 #ifndef S_DEBUG_H
2 #define S_DEBUG_H
3
4 #include <stdarg.h>
5 #ifdef MSGLOG_ENABLED
6 #include "struct.h"             /* Needed for HOSTLEN */
7 #endif
8
9 #ifdef DEBUGMODE
10
11 /*=============================================================================
12  * Macro's
13  */
14
15 #define Debug(x) debug x
16 #define LOGFILE LPATH
17
18 /*
19  * defined debugging levels
20  */
21 #define DEBUG_FATAL  0
22 #define DEBUG_ERROR  1          /* report_error() and other
23                                    errors that are found */
24 #define DEBUG_NOTICE 3
25 #define DEBUG_DNS    4          /* used by all DNS related routines - a *lot* */
26 #define DEBUG_INFO   5          /* general usful info */
27 #define DEBUG_NUM    6          /* numerics */
28 #define DEBUG_SEND   7          /* everything that is sent out */
29 #define DEBUG_DEBUG  8          /* anything to do with debugging,
30                                    ie unimportant :) */
31 #define DEBUG_MALLOC 9          /* malloc/free calls */
32 #define DEBUG_LIST  10          /* debug list use */
33
34 /*=============================================================================
35  * proto types
36  */
37
38 extern void vdebug(int level, const char *form, va_list vl);
39 extern void debug(int level, const char *form, ...)
40     __attribute__ ((format(printf, 2, 3)));
41 extern void send_usage(aClient *cptr, char *nick);
42
43 #else /* !DEBUGMODE */
44
45 #define Debug(x)
46 #define LOGFILE "/dev/null"
47
48 #endif /* !DEBUGMODE */
49
50 extern void count_memory(aClient *cptr, char *nick);
51 extern char serveropts[];
52
53 /*=============================================================================
54  * Message logging service
55  */
56
57 /*
58  * Message levels: these are inclusive, i.e. a message that is LEVEL_MAP
59  * affects also clients and channels and is propagated and needs a query of
60  * some status, and therefore belongs to all the classes, in the same way
61  * _every_ message is parsed so belongs to LEVEL_PARSED
62  */
63
64 /* Messages that affect servers' map */
65 #define LEVEL_MAP       6
66
67 /* Messages that affect clients existance */
68 #define LEVEL_CLIENT    5
69
70 /* Messages that affect channel existance */
71 #define LEVEL_CHANNEL   4
72
73 /* Messages that affect channel modes */
74 #define LEVEL_MODE      3
75
76 /* Messages that are only to be propagated somewhere */
77 #define LEVEL_PROPAGATE 2
78
79 /*
80  * Messages that only perform queries
81  * note how every message may need some status query over data structs
82  * and at the same time every query might need to be propagated
83  * somewhere... so the distinction between levels PROPAGATE and
84  * QUERY is quite fuzzy
85  */
86 #define LEVEL_QUERY     1
87
88 /* Messages that only perform queries */
89 #define LEVEL_PARSED    0
90
91 #ifdef MSGLOG_ENABLED
92
93 /*=============================================================================
94  * Macro's
95  */
96
97 #define LogMessage(x) Log_Message x
98 #define StoreBuffer(x) Store_Buffer x
99
100 /* Logging mask, selection on type of connection */
101 #define LOG_PING        (0x8000 >> (8 + STAT_PING))
102 #define LOG_LOG         (0x8000 >> (8 + STAT_LOG))
103 #define LOG_MASTER      (0x8000 >> (8 + STAT_MASTER))
104 #define LOG_CONNECTING  (0x8000 >> (8 + STAT_CONNECTING))
105 #define LOG_HANDSHAKE   (0x8000 >> (8 + STAT_HANDSHAKE))
106 #define LOG_ME          (0x8000 >> (8 + STAT_ME))
107 #define LOG_UNKNOWN     (0x8000 >> (8 + STAT_UNKNOWN))
108 #define LOG_SERVER      (0x8000 >> (8 + STAT_SERVER))
109 #define LOG_CLIENT      (0x8000 >> (8 + STAT_USER))
110
111 /*
112  * Define here the type of connection(s) that will be monitored.
113  * Default is to log messages coming from any connection.
114  */
115 #define LOG_MASK_TYPE \
116     ( LOG_PING | LOG_LOG | LOG_MASTER | LOG_CONNECTING | \
117       LOG_HANDSHAKE | LOG_ME | LOG_UNKNOWN | LOG_SERVER | LOG_CLIENT )
118
119 /*=============================================================================
120  * data structures
121  */
122
123 struct log_entry {
124   int cptr_status;
125   char cptr_name[HOSTLEN + 1];
126   char cptr_yxx[3];
127   int cptr_fd;
128
129   int sptr_status;
130   char sptr_name[HOSTLEN + 1];
131   char sptr_yxx[4];
132   char sptr_from_name[HOSTLEN + 1];
133
134   char buffer[512];
135
136   /* The following may be lost before log gets used,
137      anyhow they are only here for usage through gdb */
138
139   aClient *cptr;
140   aClient *sptr;
141 };
142
143 /*=============================================================================
144  * proto types
145  */
146
147 extern void Log_Message(aClient *sptr, int msgclass);
148 extern void Store_Buffer(char *buf, aClient *cptr);
149
150 #else /* !MSGLOG_ENABLED */
151
152 #define LogMessage(x)
153 #define StoreBuffer(x)
154
155 #endif /* !MSGLOG_ENABLED */
156
157 #endif /* S_DEBUG_H */