Resyncing HEAD with v_3_0_branch for two OSX fixes:
[privoxy.git] / src / parsers.c
index c0302b1..c617b56 100644 (file)
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 2.2 2002/11/10 04:20:38 hal9 Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 2.4 2003/01/26 20:24:26 david__schmidt Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/src/parsers.c,v $
@@ -40,6 +40,13 @@ const char parsers_rcs[] = "$Id: parsers.c,v 2.2 2002/11/10 04:20:38 hal9 Exp $"
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 2.4  2003/01/26 20:24:26  david__schmidt
+ *    Updated activity console instrumentation locations
+ *
+ *    Revision 2.3  2002/12/28 03:58:19  david__schmidt
+ *    Initial drop of dashboard instrumentation - enabled with
+ *    --enable-activity-console
+ *
  *    Revision 2.2  2002/11/10 04:20:38  hal9
  *    Fix typo: supressed -> suppressed
  *
@@ -411,6 +418,11 @@ const char parsers_rcs[] = "$Id: parsers.c,v 2.2 2002/11/10 04:20:38 hal9 Exp $"
 #include <unistd.h>
 #endif
 
+#ifdef OSX_DARWIN
+#include <pthread.h>
+#include "jcc.h"
+/* jcc.h is for mutex semapores only */
+#endif /* def OSX_DARWIN */
 #include "project.h"
 #include "list.h"
 #include "parsers.h"
@@ -1097,14 +1109,16 @@ jb_err client_referrer(struct client_state *csp, char **header)
 
    newval = csp->action->string[ACTION_STRING_REFERER];
 
+#ifdef FEATURE_ACTIVITY_CONSOLE
+   /* Otherwise, we're doing something with the referer. */
+   accumulate_stats(STATS_REFERER, 1);
+#endif /* def FEATURE_ACTIVITY_CONSOLE */
+
    if ((newval == NULL) || (0 == strcmpic(newval, "block")) )
    {
       /*
        * Blocking referer
        */
-#ifdef FEATURE_ACTIVITY_CONSOLE
-      accumulate_stats(STATS_REFERER, 1);
-#endif /* def FEATURE_ACTIVITY_CONSOLE */
       log_error(LOG_LEVEL_HEADER, "crunch!");
       return JB_ERR_OK;
    }
@@ -1247,6 +1261,10 @@ jb_err client_from(struct client_state *csp, char **header)
       return JB_ERR_OK;
    }
 
+#ifdef FEATURE_ACTIVITY_CONSOLE
+   /* Otherwise, we're doing something with it. */
+   accumulate_stats(STATS_CLIENT_FROM, 1);
+#endif /* def FEATURE_ACTIVITY_CONSOLE */
    freez(*header);
 
    newval = csp->action->string[ACTION_STRING_FROM];
@@ -1256,9 +1274,6 @@ jb_err client_from(struct client_state *csp, char **header)
     */
    if ((newval == NULL) || (0 == strcmpic(newval, "block")) )
    {
-#ifdef FEATURE_ACTIVITY_CONSOLE
-      accumulate_stats(STATS_CLIENT_FROM, 1);
-#endif /* def FEATURE_ACTIVITY_CONSOLE */
       log_error(LOG_LEVEL_HEADER, "crunch!");
       return JB_ERR_OK;
    }
@@ -1687,6 +1702,10 @@ jb_err server_set_cookie(struct client_state *csp, char **header)
       time (&now); 
 #ifdef HAVE_LOCALTIME_R
       tm_now = *localtime_r(&now, &tm_now);
+#elif OSX_DARWIN
+      pthread_mutex_lock(&localtime_mutex);
+      tm_now = *localtime (&now); 
+      pthread_mutex_unlock(&localtime_mutex);
 #else
       tm_now = *localtime (&now); 
 #endif
@@ -1700,6 +1719,9 @@ jb_err server_set_cookie(struct client_state *csp, char **header)
    if ((csp->action->flags & ACTION_NO_COOKIE_SET) != 0)
    {
       log_error(LOG_LEVEL_HEADER, "Crunched incoming cookie -- yum!");
+#ifdef FEATURE_ACTIVITY_CONSOLE
+      accumulate_stats(STATS_COOKIE, 1);
+#endif /* def FEATURE_ACTIVITY_CONSOLE */
       return crumble(csp, header);
    }
    else if ((csp->action->flags & ACTION_NO_COOKIE_KEEP) != 0)