Changed the low level errno routines public.
[runtime.git] / lib / silcutil / silcerrno.h
index 74a2b126a3fa35e1ed324d27c01d41d4643449ee..c00e9af02c3bd2d24fb7ca77251f10be022107fd 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2007 Pekka Riikonen
+  Copyright (C) 2007 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 
 */
 
-/****h* silcutil/SILC Errno
+/****h* silcutil/Errno Interface
  *
  * DESCRIPTION
  *
@@ -44,7 +44,7 @@
  * // Get the detailed reason for the error too
  * if (silc_some_routine() == FALSE) {
  *   fprintf(stderr, "%s (%d) (%s)", silc_errno_string(silc_errno),
- *          silc_errno, silc_errno_reason);
+ *          silc_errno, silc_errno_reason());
  *   exit(1);
  * }
  *
@@ -53,7 +53,7 @@
 #ifndef SILCERRNO_H
 #define SILCERRNO_H
 
-/****d* silcutil/SilcErrnoAPI/SilcResult
+/****d* silcutil/SilcResult
  *
  * NAME
  *
@@ -80,20 +80,21 @@ typedef enum {
   SILC_ERR_TRY_AGAIN                   = 9,   /* Try again */
   SILC_ERR_PERMISSION_DENIED           = 10,  /* Permission denied */
   SILC_ERR_INVALID_ARGUMENT            = 11,  /* Invalid argument */
-  SILC_ERR_BAD_TIME                    = 13,  /* Bad time value */
-  SILC_ERR_TIMEOUT                     = 14,  /* Timeout occurred */
-  SILC_ERR_ASSERT                      = 15,  /* Assertion failed */
-  SILC_ERR_NOT_FOUND                   = 16,  /* Item/entry not found */
-  SILC_ERR_UNKNOWN_CHAR                = 17,  /* Unknown character */
-  SILC_ERR_PROHIBITED_CHAR             = 18,  /* Prohibited character */
-  SILC_ERR_BAD_CHAR_ENCODING           = 19,  /* Bad character encoding */
-  SILC_ERR_UNSUPPORTED_CHAR_ENCODING   = 20,  /* Unsupported char encoding */
-  SILC_ERR_BAD_VERSION                 = 21,  /* Bad/unsupported version */
-  SILC_ERR_BAD_ADDRESS                 = 22,  /* Bad memory address */
-  SILC_ERR_BAD_ENCODING                = 23,  /* Bad data encoding */
-  SILC_ERR_INTERRUPTED                 = 24,  /* Interrupted */
-  SILC_ERR_NOT_VALID                   = 25,  /* Not valid */
-  SILC_ERR_LIMIT                       = 26,  /* Limit reached */
+  SILC_ERR_BAD_TIME                    = 12,  /* Bad time value */
+  SILC_ERR_TIMEOUT                     = 13,  /* Timeout occurred */
+  SILC_ERR_ASSERT                      = 14,  /* Assertion failed */
+  SILC_ERR_NOT_FOUND                   = 15,  /* Item/entry not found */
+  SILC_ERR_UNKNOWN_CHAR                = 16,  /* Unknown character */
+  SILC_ERR_PROHIBITED_CHAR             = 17,  /* Prohibited character */
+  SILC_ERR_BAD_CHAR_ENCODING           = 18,  /* Bad character encoding */
+  SILC_ERR_UNSUPPORTED_CHAR_ENCODING   = 19,  /* Unsupported char encoding */
+  SILC_ERR_BAD_VERSION                 = 20,  /* Bad/unsupported version */
+  SILC_ERR_BAD_ADDRESS                 = 21,  /* Bad memory address */
+  SILC_ERR_BAD_ENCODING                = 22,  /* Bad data encoding */
+  SILC_ERR_INTERRUPTED                 = 23,  /* Interrupted */
+  SILC_ERR_NOT_VALID                   = 24,  /* Not valid */
+  SILC_ERR_LIMIT                       = 25,  /* Limit reached */
+  SILC_ERR_SYNTAX                      = 26,  /* Syntax error */
 
   /* File, directory and device errors */
   SILC_ERR_NO_SUCH_FILE                = 40,  /* No such file */
@@ -126,11 +127,20 @@ typedef enum {
   SILC_ERR_NET_DOWN                    = 82,  /* Network is down */
   SILC_ERR_EOS                         = 83,  /* End of stream */
 
+  /* Regular expression errors */
+  SILC_ERR_REGEX_PAREN                 = 100, /* Unmatched parenthesis */
+  SILC_ERR_REGEX_HEX                   = 101, /* Bad hex number */
+  SILC_ERR_REGEX_REG                   = 102, /* Bad register number */
+  SILC_ERR_REGEX_SPECIAL               = 103, /* Unmatched special character */
+  SILC_ERR_REGEX_TOO_COMPLEX           = 104, /* Too complex expression */
+  SILC_ERR_REGEX_OPCODE                = 105, /* Bad regex opcode */
+  SILC_ERR_REGEX_REPEAT                = 106, /* Bad repeat value */
+
   SILC_ERR_MAX,
 } SilcResult;
 /***/
 
-/****d* silcutil/SilcErrnoAPI/silc_errno
+/****d* silcutil/silc_errno
  *
  * NAME
  *
@@ -144,7 +154,7 @@ typedef enum {
  ***/
 #define silc_errno silc_get_errno()
 
-/****f* silcutil/SilcErrnoAPI/silc_errno_string
+/****f* silcutil/silc_errno_string
  *
  * NAME
  *
@@ -158,7 +168,7 @@ typedef enum {
  ***/
 const char *silc_errno_string(SilcResult error);
 
-/****d* silcutil/SilcErrnoAPI/silc_errno_string
+/****d* silcutil/silc_errno_reason
  *
  * NAME
  *
@@ -175,22 +185,76 @@ const char *silc_errno_reason(void);
 
 /* Low-level routines for the error handling. */
 
-/* Return last error */
-SilcResult silc_get_errno(void);
-
-/* Set error */
+/****d* silcutil/silc_set_errno
+ *
+ * NAME
+ *
+ *    void silc_set_errno(SilcResult error);
+ *
+ * DESCRIPTION
+ *
+ *    A low level routine to set the error for current thread.
+ *
+ ***/
 void silc_set_errno(SilcResult error);
 
-/* Set error, cannot fail. */
+/****d* silcutil/silc_set_errno_nofail
+ *
+ * NAME
+ *
+ *    void silc_set_errno_nofail(SilcResult error);
+ *
+ * DESCRIPTION
+ *
+ *    A low level routine to set the error for current thread.  This call
+ *    itself cannot cause setting of errno.
+ *
+ ***/
 void silc_set_errno_nofail(SilcResult error);
 
-/* Set error and reason string. */
+/****d* silcutil/silc_set_errno_reason
+ *
+ * NAME
+ *
+ *    void silc_set_errno_reason(SilcResult error, const char *format, ...);
+ *
+ * DESCRIPTION
+ *
+ *    A low level routine to set the error reason for current thread.
+ *
+ ***/
 void silc_set_errno_reason(SilcResult error, const char *format, ...);
 
-/* Set error and reason string, cannot fail. */
+/****d* silcutil/silc_set_errno_reason_nofail
+ *
+ * NAME
+ *
+ *    void silc_set_errno_reason_nofail(SilcResult error,
+ *                                      const char *format, ...);
+ *
+ * DESCRIPTION
+ *
+ *    A low level routine to set the error reason for current thread.  This
+ *    call itself cannot cause setting of errno.
+ *
+ ***/
 void silc_set_errno_reason_nofail(SilcResult error, const char *format, ...);
 
-/* Set error from POSIX errno */
+/****d* silcutil/silc_set_errno_posix
+ *
+ * NAME
+ *
+ *    void silc_set_errno_posix(int error);
+ *
+ * DESCRIPTION
+ *
+ *    A low level routine to set the error for current thread from POSIX
+ *    errno.
+ *
+ ***/
 void silc_set_errno_posix(int error);
 
+/* Return last error */
+SilcResult silc_get_errno(void);
+
 #endif /* SILCERRNO_H */