From: Fabian Keil Date: Sat, 14 Jul 2007 07:28:47 +0000 (+0000) Subject: Add translation function for JB_ERR_FOO codes. X-Git-Tag: v_3_0_7~207 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=b79a11a6c8e05e1970386131f0ffc1879795b5b1 Add translation function for JB_ERR_FOO codes. --- diff --git a/errlog.c b/errlog.c index e9e8daae..6562d763 100644 --- 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 /********************************************************************* * diff --git a/errlog.h b/errlog.h index 86f8caaa..47c63531 100644 --- 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 $ @@ -35,6 +35,11 @@ * * 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[];