diff src/generic.h @ 43:f6db1f060a95

start on outlook 2003 64 bit format
author carl
date Sun, 06 Jan 2008 14:47:06 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/generic.h	Sun Jan 06 14:47:06 2008 -0800
@@ -0,0 +1,48 @@
+/* {{{ Generic.h - thigns every program does:
+ *
+ * - user output (log, debug, etc)
+ * - crash and burn
+ * - allocate memory (or explode)
+ * }}} */
+#ifndef GENERIC_H
+#define GENERIC_H
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+/***************************************************/
+
+#define LOAD_DEBUG 1
+
+#define DIE(...) { fprintf(stderr, "Fatal Error at %s,%d: ", __FILE__, __LINE__); pDIE(__VA_ARGS__); }
+
+//#define WARN(...) { fprintf(stderr, "WARN: %s,%d: ", __FILE__, __LINE__); pWARN(__VA_ARGS__); }
+void pDIE( char *fmt, ... );
+//void pWARN( char *fmt, ... );
+
+#define WARN(...) DB( DB_WARN, __VA_ARGS__ )
+#define ASSERT(x,...) { if( !(x) ) DIE( __VA_ARGS__ ); }
+
+void *F_MALLOC( size_t size );
+void *F_REALLOC( void *p, size_t size );
+
+#define DO_DEBUG 0
+#define DEBUG(x) if( DO_DEBUG ) { x; }
+#define STUPID_CR "\r\n"
+
+#define DB_CRASH   0 // crashing
+#define DB_ERR     1 // error
+#define DB_WARN    2 // warning
+#define DB_INFO    3 // normal, but significant, condition
+#define DB_VERB	   4 // verbose information
+#define DB_0       5 // debug-level message
+#define DB_1       6 // debug-level message
+#define DB_2       7 // debug-level message
+
+extern int DEBUG_LEVEL;
+extern void (*dbfunc)(char *file, int line, int level, char *fmt, ...);
+
+#define DB(...) { dbfunc( __FILE__, __LINE__, __VA_ARGS__ ); }
+
+int set_db_function( void (*func)( char *file, int line, int level, char *fmt, ...) );
+
+#endif