Help clang understand that we aren't dereferencing
[privoxy.git] / errlog.c
index c69b8d7..9131987 100644 (file)
--- a/errlog.c
+++ b/errlog.c
@@ -1,4 +1,4 @@
-const char errlog_rcs[] = "$Id: errlog.c,v 1.82 2008/11/23 16:06:58 fabiankeil Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.86 2009/02/09 21:21:15 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/errlog.c,v $
@@ -6,7 +6,7 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.82 2008/11/23 16:06:58 fabiankeil E
  * Purpose     :  Log errors to a designated destination in an elegant,
  *                printf-like fashion.
  *
- * Copyright   :  Written by and Copyright (C) 2001-2008 the SourceForge
+ * Copyright   :  Written by and Copyright (C) 2001-2009 the SourceForge
  *                Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
@@ -33,6 +33,20 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.82 2008/11/23 16:06:58 fabiankeil E
  *
  * Revisions   :
  *    $Log: errlog.c,v $
+ *    Revision 1.86  2009/02/09 21:21:15  fabiankeil
+ *    Now that init_log_module() is called earlier, call show_version()
+ *    later on from main() directly so it doesn't get called for --help
+ *    or --version.
+ *
+ *    Revision 1.85  2009/02/06 17:51:38  fabiankeil
+ *    Be prepared if I break the log module initialization again.
+ *
+ *    Revision 1.84  2008/12/14 15:46:22  fabiankeil
+ *    Give crunched requests their own log level.
+ *
+ *    Revision 1.83  2008/12/04 18:14:32  fabiankeil
+ *    Fix some cparser warnings.
+ *
  *    Revision 1.82  2008/11/23 16:06:58  fabiankeil
  *    Update a log message I missed in 1.80.
  *
@@ -546,7 +560,7 @@ static void fatal_error(const char * error_message)
  * Returns     :  Nothing.
  *
  *********************************************************************/
-static void show_version(const char *prog_name)
+void show_version(const char *prog_name)
 {
    log_error(LOG_LEVEL_INFO, "Privoxy version " VERSION);
    if (prog_name != NULL)
@@ -570,13 +584,12 @@ static void show_version(const char *prog_name)
  * Returns     :  Nothing.
  *
  *********************************************************************/
-void init_log_module(const char *prog_name)
+void init_log_module(void)
 {
    lock_logfile();
    logfp = stderr;
    unlock_logfile();
    set_debug_level(debug);
-   show_version(prog_name);
 }
 
 
@@ -708,7 +721,7 @@ void init_error_log(const char *prog_name, const char *logfname)
    /*
     * Prevent the Windows GUI from showing the version two
     * times in a row on startup. It already displayed the show_version()
-    * call from init_log_module() that other systems write to stderr.
+    * call from main() that other systems write to stderr.
     *
     * This means mingw32 users will never see the version in their
     * log file, but I assume they wouldn't look for it there anyway
@@ -952,6 +965,9 @@ static inline const char *get_log_level_string(int loglevel)
       case LOG_LEVEL_DEANIMATE:
          log_level_string = "Gif-Deanimate";
          break;
+      case LOG_LEVEL_CRUNCH:
+         log_level_string = "Crunch";
+         break;
       case LOG_LEVEL_CGI:
          log_level_string = "CGI";
          break;
@@ -1002,7 +1018,7 @@ void log_error(int loglevel, const char *fmt, ...)
     * the taskbar icon animate.  (There is an option to disable
     * this but checking that is handled inside LogShowActivity()).
     */
-   if (loglevel == LOG_LEVEL_GPC)
+   if ((loglevel == LOG_LEVEL_GPC) || (loglevel == LOG_LEVEL_CRUNCH))
    {
       LogShowActivity();
    }
@@ -1019,6 +1035,11 @@ void log_error(int loglevel, const char *fmt, ...)
 #endif
       )
    {
+      if (loglevel == LOG_LEVEL_FATAL)
+      {
+         fatal_error("Fatal error. You're not supposed to"
+            "see this message. Please file a bug report.");
+      }
       return;
    }
 
@@ -1037,6 +1058,7 @@ void log_error(int loglevel, const char *fmt, ...)
             "%s %08lx Fatal error: Out of memory in log_error().",
             timestamp, thread_id);
          fatal_error(tempbuf); /* Exit */
+         return;
       }
    }
    outbuf = outbuf_save;