diff th_util.h @ 96:3df6bec3c6b1

Add error handling stuff.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 22 May 2014 03:29:08 +0300
parents d86ad68f326f
children a285cdc05810
line wrap: on
line diff
--- a/th_util.h	Wed May 21 22:31:10 2014 +0300
+++ b/th_util.h	Thu May 22 03:29:08 2014 +0300
@@ -58,6 +58,42 @@
 #  endif
 #endif
 
+
+/* Error codes
+ */
+enum {
+    // General error codes
+    THERR_OK = 0,
+    THERR_PROGRESS,     // Status OK, but operation in progress
+
+    THERR_INTERNAL,
+	
+    THERR_FOPEN,
+    THERR_FREAD,
+    THERR_FWRITE,
+    THERR_FSEEK,
+    THERR_NOT_FOUND,    // Resource/data not found
+
+    THERR_INVALID_DATA, // Some data was invalid
+    THERR_MALLOC,       // Memory allocation failure
+    THERR_ALREADY_INIT, // Resource has already been initialized
+    THERR_INIT_FAIL,    // General initialization failure
+    THERR_INVALID_ARGS,
+
+    THERR_NULLPTR,      // NULL pointer specified in critical argument
+    THERR_NOT_SUPPORTED,// Operation not supported
+    THERR_OUT_OF_DATA,
+    THERR_EXTRA_DATA,
+    THERR_BOUNDS,
+    THERR_TIMED_OUT,
+
+    // Network errors
+    THERR_AUTH_FAILED,
+};
+
+#define TH_SYSTEM_ERRORS 100000
+
+
 /* Global variables
  */
 extern int  th_verbosityLevel;
@@ -73,6 +109,9 @@
                char *author, char *license);
 void    th_print_banner(FILE *outFile, const char *binName, const char *usage);
 
+int     th_get_errno();
+const char *th_error_str(int error);
+
 void    THERR(const char *, ...);
 void    THMSG(int, const char *, ...);
 void    THPRINT(int, const char *, ...);