Add translation function for JB_ERR_FOO codes.
authorFabian Keil <fk@fabiankeil.de>
Sat, 14 Jul 2007 07:28:47 +0000 (07:28 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sat, 14 Jul 2007 07:28:47 +0000 (07:28 +0000)
errlog.c
errlog.h

index e9e8daa..6562d76 100644 (file)
--- a/errlog.c
+++ b/errlog.c
@@ -1,4 +1,4 @@
-const char errlog_rcs[] = "$Id: errlog.c,v 1.50 2007/04/11 10:55:44 fabiankeil Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.51 2007/05/11 11:51:34 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/errlog.c,v $
@@ -33,6 +33,9 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.50 2007/04/11 10:55:44 fabiankeil E
  *
  * Revisions   :
  *    $Log: errlog.c,v $
+ *    Revision 1.51  2007/05/11 11:51:34  fabiankeil
+ *    Fix a type mismatch warning.
+ *
  *    Revision 1.50  2007/04/11 10:55:44  fabiankeil
  *    Enforce some assertions that could be triggered
  *    on mingw32 and other systems where we use threads
@@ -1507,6 +1510,48 @@ void log_error(int loglevel, const char *fmt, ...)
 #endif /* defined(USE_NEW_LOG_ERROR) */
 
 
+/*********************************************************************
+ *
+ * Function    :  jb_err_to_string
+ *
+ * Description :  Translates JB_ERR_FOO codes into strings.
+ *
+ *                XXX: the type of error codes is jb_err
+ *                but the typedef'inition is currently not
+ *                visible to all files that include errlog.h.
+ *
+ * Parameters  :
+ *          1  :  error = a valid jb_err code
+ *
+ * Returns     :  A string with the jb_err translation
+ *
+ *********************************************************************/
+const char *jb_err_to_string(int error)
+{
+   switch (error)
+   {
+      case JB_ERR_OK:
+         return "Success, no error";
+      case JB_ERR_MEMORY:
+         return "Out of memory";
+      case JB_ERR_CGI_PARAMS:
+         return "Missing or corrupt CGI parameters";
+      case JB_ERR_FILE:
+         return "Error opening, reading or writing a file";
+      case JB_ERR_PARSE:
+         return "Parse error";
+      case JB_ERR_MODIFIED:
+         return "File has been modified outside of the CGI actions editor.";
+      case JB_ERR_COMPRESS:
+         return "(De)compression failure";
+      default:
+         assert(0);
+         return "Unknown error";
+   }
+   assert(0);
+   return "Internal error";
+}
+
 #ifdef _WIN32
 /*********************************************************************
  *
index 86f8caa..47c6353 100644 (file)
--- a/errlog.h
+++ b/errlog.h
@@ -1,6 +1,6 @@
 #ifndef ERRLOG_H_INCLUDED
 #define ERRLOG_H_INCLUDED
-#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.16 2006/11/28 15:29:50 fabiankeil Exp $"
+#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.17 2007/03/31 13:33:28 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/errlog.h,v $
  *
  * Revisions   :
  *    $Log: errlog.h,v $
+ *    Revision 1.17  2007/03/31 13:33:28  fabiankeil
+ *    Add alternative log_error() with timestamps
+ *    that contain milliseconds and without using
+ *    strcpy(), strcat() or sprintf().
+ *
  *    Revision 1.16  2006/11/28 15:29:50  fabiankeil
  *    Define LOG_LEVEL_REDIRECTS independently of
  *    FEATURE_FAST_REDIRECTS. It is used by redirect{}
@@ -171,6 +176,7 @@ extern "C" {
 
 extern void init_error_log(const char *prog_name, const char *logfname, int debuglevel);
 extern void log_error(int loglevel, const char *fmt, ...);
+extern const char *jb_err_to_string(int error);
 
 /* Revision control strings from this header and associated .c file */
 extern const char errlog_rcs[];