]> jfr.im git - irc/quakenet/newserv.git/blobdiff - core/error.h
Merge chanserv-live into default.
[irc/quakenet/newserv.git] / core / error.h
index 892251463c823234ce8897c376b99461b74190e8..ac15c4253016fa48fae2e746161b7f376561b05b 100644 (file)
@@ -1,14 +1,63 @@
+#ifndef __ERROR_H
+#define __ERROR_H
+
 /* error.h:
  *
  * Error flagging routines 
  */
 
+/* SEVERITY GUIDELINES:
+ *
+ * ERR_STOP:  Something so bad has happened that the whole service must
+ *            stop.  Something like a malloc() error or similar magnitude
+ *            error.
+ *
+ * ERR_FATAL: Something so bad has happened that the module cannot usefully
+ *            function any more, but won't necessarily prevent other modules
+ *            from working.
+ *
+ * ERR_ERROR: Something is wrong, perhaps a data structure is inconsistent
+ *            or something similar has gone wrong internally.  This might
+ *            indicate a larger problem but the module can continue working
+ *            for now.
+ *
+ * ERR_WARNING: Something slightly out of the ordinary has happened (e.g. 
+ *              the IRCD sent a bogus message).  The module can continue
+ *              working though without serious harm.
+ *
+ * ERR_INFO: Not an error condition.  Something noteworthy has happened,
+ *           like a major module has started up.  These will typically be
+ *           seen all the time on most setups so try not to be too spammy.
+ *
+ * ERR_DEBUG: Not an error condition.  Something less significant has
+ *            happened which might be of interest if someone is attempting
+ *            to debug a problem.  Nevertheless try not to be too spammy.
+ */
 
 #define ERR_DEBUG    0
 #define ERR_INFO     1
 #define ERR_WARNING  2
 #define ERR_ERROR    3
 #define ERR_FATAL    4
+#define ERR_STOP     5
+
+struct error_event {
+  int severity;
+  char *message;
+  char *source;
+};
+
+typedef void (*CoreHandlerFn)(void *arg);
+
+typedef struct corehandler {
+  void *arg;
+  CoreHandlerFn fn;
+  struct corehandler *prev, *next;
+} corehandler;
+
+void Error(char *source, int severity, char *reason, ... ) __attribute__ ((format (printf, 3, 4)));
 
-void Error(char *source, int severity, char *reason, ... );
+corehandler *registercorehandler(CoreHandlerFn fn, void *arg);
+void deregistercorehandler(corehandler *c);
 
+#endif