#
# Copyright (C) 2001, 2002 Privoxy Developers http://privoxy.org
#
-# $Id: config,v 1.44 2003/04/20 17:37:28 hal9 Exp $
+# $Id: config,v 1.45 2003/09/22 00:33:01 david__schmidt Exp $
#
####################################################################
# #
# flat, except for confdir/templates, where the HTML templates
# for CGI output reside (e.g. Privoxy's 404 error page).
#
-confdir /home/hal/ptmp/etc
+confdir .
#
# 1.2. logdir
#
# No trailing "/", please
#
-logdir /home/hal/ptmp/var/log/privoxy
+logdir .
#
# 1.3. actionsfile
dnl Process this file with autoconf to produce a configure script.
dnl
-dnl $Id: configure.in,v 1.87 2002/12/28 04:10:22 david__schmidt Exp $
+dnl $Id: configure.in,v 1.88 2003/03/23 02:15:51 hal9 Exp $
dnl
dnl Written by and Copyright (C) 2001, 2002 the SourceForge
dnl Privoxy team. http://www.privoxy.org/
dnl Temple Place - Suite 330, Boston, MA 02111-1307, USA.
dnl
dnl $Log: configure.in,v $
+dnl Revision 1.88 2003/03/23 02:15:51 hal9
+dnl Apply Docbook/FreeBSD patch from a.go at tiscali.nl. Thanks!
+dnl
dnl Revision 1.87 2002/12/28 04:10:22 david__schmidt
dnl Initial drop of dashboard instrumentation - enabled with
dnl --enable-activity-console
dnl AutoConf Initialization
dnl =================================================================
-AC_REVISION($Revision: 1.87 $)
+AC_REVISION($Revision: 1.88 $)
AC_INIT(src/jcc.c)
if test ! -f src/config.h.in; then
echo "You need to run autoheader first. "
dnl =================================================================
case "$host" in
-*-apple-darwin*) SPECIAL_CFLAGS="-Dunix"
+*-apple-darwin*) SPECIAL_CFLAGS="-Dunix -DOSX_DARWIN"
;;
esac
-dnl =================================================================
-dnl Mac OSX specific
-dnl =================================================================
-
-case "$host" in
-*-apple-darwin*) SPECIAL_CFLAGS="-Dunix"
-;;
-esac
-
dnl =================================================================
dnl OpenBSD specific
dnl =================================================================
-const char cgi_rcs[] = "$Id: cgi.c,v 2.2 2002/09/04 15:17:28 oes Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 2.3 2002/11/12 16:19:18 oes Exp $";
/*********************************************************************
*
- * File : $Source: /cvsroot/ijbswa//current/src/cgi.c,v $
+ * File : $Source: /cvsroot/ijbswa/current/src/cgi.c,v $
*
* Purpose : Declares functions to intercept request, generate
* html or gif answers, and to compose HTTP resonses.
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 2.3 2002/11/12 16:19:18 oes
+ * Fix: g_bToggleIJB was used outside #ifdef FEATURE_TOGGLE
+ *
* Revision 2.2 2002/09/04 15:17:28 oes
* Synced with the stable branch:
* Revision 1.70.2.1 2002/08/05 11:17:46 oes
#endif /* def FEATURE_CGI_EDIT_ACTIONS */
#include "loadcfg.h"
/* loadcfg.h is for g_bToggleIJB only */
+#ifdef FEATURE_PTHREAD
+#include <pthread.h>
+#include "jcc.h"
+/* jcc.h is for mutex semaphore globals only */
+#endif /* def FEATURE_PTHREAD */
const char cgi_h_rcs[] = CGI_H_VERSION;
struct tm *t;
time_t current_time;
+#if defined(HAVE_GMTIME_R) && !defined(OSX_DARWIN)
+ /*
+ * Declare dummy up here (instead of inside get/set gmt block) so it
+ * doesn't go out of scope before it's potentially used in snprintf later.
+ * Wrapping declaration inside HAVE_GMTIME_R keeps the compiler quiet when
+ * !defined HAVE_GMTIME_R.
+ */
+ struct tm dummy;
+#endif
assert(buf);
/* get and save the gmt */
{
-#ifdef HAVE_GMTIME_R
- struct tm dummy;
+#ifdef OSX_DARWIN
+ pthread_mutex_lock(&gmtime_mutex);
+ t = gmtime(¤t_time);
+ pthread_mutex_unlock(&gmtime_mutex);
+#elif HAVE_GMTIME_R
t = gmtime_r(¤t_time, &dummy);
#else
t = gmtime(¤t_time);
-const char errlog_rcs[] = "$Id: errlog.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 2.1 2002/09/25 12:51:21 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/errlog.c,v $
*
* Revisions :
* $Log: errlog.c,v $
+ * Revision 2.1 2002/09/25 12:51:21 oes
+ * Made log_error safe against NULL string arguments
+ *
* Revision 2.0 2002/06/04 14:34:21 jongfoster
* Moving source files to src/
*
/* FIXME get current thread id */
#ifdef FEATURE_PTHREAD
this_thread = (long)pthread_self();
+#ifdef __MACH__
+ /*
+ * Mac OSX (and perhaps other Mach instances) doesn't have a debuggable
+ * value at the first 4 bytes of pthread_self()'s return value, a pthread_t.
+ * pthread_t is supposed to be opaque... but it's fairly random, though, so
+ * we make it mostly presentable.
+ */
+ this_thread = abs(this_thread % 1000);
+#endif /* def __MACH__ */
#elif defined(_WIN32)
this_thread = GetCurrentThreadId();
#elif defined(__OS2__)
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
time (&now);
#ifdef HAVE_GMTIME_R
gmt = *gmtime_r(&now, &gmt);
+#elif OSX_DARWIN
+ pthread_mutex_lock(&gmtime_mutex);
+ gmt = *gmtime(&now);
+ pthread_mutex_unlock(&gmtime_mutex);
#else
gmt = *gmtime(&now);
#endif
#ifdef HAVE_LOCALTIME_R
tm_now = localtime_r(&now, &dummy);
+#elif OSX_DARWIN
+ pthread_mutex_lock(&localtime_mutex);
+ tm_now = localtime (&now);
+ pthread_mutex_unlock(&localtime_mutex);
#else
tm_now = localtime (&now);
#endif
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 2.1 2002/12/30 19:56:16 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 2.1 2002/12/30 19:56:16 david__schmidt
+ * End of initial drop of statistics console infrastructure. Data stream
+ * is transmitted on the stats port every interval, provided the data has
+ * changed since the last transmission. More work probably needs to be
+ * done with regard to multiplatform threading; I stole the thread spawning
+ * code from jcc.c, but haven't been able to test it everywhere.
+ *
* Revision 2.0 2002/06/04 14:34:21 jongfoster
* Moving source files to src/
*
#endif
+#ifdef OSX_DARWIN
+#include <pthread.h>
+#include "jcc.h"
+/* jcc.h is for mutex semaphores only */
+#endif /* def OSX_DARWIN */
+
#include "project.h"
#include "jbsockets.h"
#include "filters.h"
#ifndef _WIN32
/*
* This is not needed for Win32 - in fact, it stops
- * duplicate instances of Junkbuster from being caught.
+ * duplicate instances of Privoxy from being caught.
*
* On UNIX, we assume the user is sensible enough not
* to start Junkbuster multiple times on the same IP.
- * Without this, stopping and restarting Junkbuster
+ * Without this, stopping and restarting Privoxy
* from a script fails.
* Note: SO_REUSEADDR is meant to only take over
* sockets which are *not* in listen state in Linux,
{
host = NULL;
}
+#elif defined(OSX_DARWIN)
+ pthread_mutex_lock(&gethostbyaddr_mutex);
+ host = gethostbyaddr((const char *)&server.sin_addr,
+ sizeof(server.sin_addr), AF_INET);
+ pthread_mutex_unlock(&gethostbyaddr_mutex);
#else
host = gethostbyaddr((const char *)&server.sin_addr,
sizeof(server.sin_addr), AF_INET);
{
hostp = NULL;
}
+#elif OSX_DARWIN
+ pthread_mutex_lock(&gethostbyname_mutex);
+ hostp = gethostbyname(host);
+ pthread_mutex_unlock(&gethostbyname_mutex);
#else
hostp = gethostbyname(host);
#endif /* def HAVE_GETHOSTBYNAME_R_(6|5|3)_ARGS */
- if (hostp == NULL)
+ /*
+ * On Mac OSX, if a domain exists but doesn't have a type A
+ * record associated with it, the h_addr member of the struct
+ * hostent returned by gethostbyname is NULL, even if h_length
+ * is 4. Therefore the second test below.
+ */
+ if (hostp == NULL || hostp->h_addr == NULL)
{
errno = EINVAL;
log_error(LOG_LEVEL_ERROR, "could not resolve hostname %s", host);
-const char jcc_rcs[] = "$Id: jcc.c,v 2.5 2003/01/26 20:24:26 david__schmidt Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 2.6 2003/06/24 12:24:24 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 2.6 2003/06/24 12:24:24 oes
+ * Added a line plus Fix-me as a reminder to fix broken force handling in trunk. Thanks to lionel for the hint
+ *
* Revision 2.5 2003/01/26 20:24:26 david__schmidt
* Updated activity console instrumentation locations
*
#define sleep(N) DosSleep(((N) * 100))
#endif
+#ifdef OSX_DARWIN
+/*
+ * Hit OSX over the head with a hammer. Protect all *_r functions.
+ */
+pthread_mutex_t gmtime_mutex;
+pthread_mutex_t localtime_mutex;
+pthread_mutex_t gethostbyaddr_mutex;
+pthread_mutex_t gethostbyname_mutex;
+#endif /* def OSX_DARWIN */
+
#if defined(unix) || defined(__EMX__)
-const char *basedir;
+const char *basedir = NULL;
const char *pidfile = NULL;
int received_hup_signal = 0;
#endif /* defined unix */
InitWin32();
#endif
+#ifdef OSX_DARWIN
+ /*
+ * Prepare global mutex semaphores
+ */
+ pthread_mutex_init(&gmtime_mutex,0);
+ pthread_mutex_init(&localtime_mutex,0);
+ pthread_mutex_init(&gethostbyaddr_mutex,0);
+ pthread_mutex_init(&gethostbyname_mutex,0);
+#endif /* def OSX_DARWIN */
+
/*
* Unix signal handling
*
#ifndef JCC_H_INCLUDED
#define JCC_H_INCLUDED
-#define JCC_H_VERSION "$Id: jcc.h,v 1.12 2002/03/26 22:29:55 swa Exp $"
+#define JCC_H_VERSION "$Id: jcc.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"
/*********************************************************************
*
- * File : $Source: /cvsroot/ijbswa/current/jcc.h,v $
+ * File : $Source: /cvsroot/ijbswa/current/src/jcc.h,v $
*
* Purpose : Main file. Contains main() method, main loop, and
* the main connection-handling function.
*
* Revisions :
* $Log: jcc.h,v $
+ * Revision 2.0 2002/06/04 14:34:21 jongfoster
+ * Moving source files to src/
+ *
* Revision 1.12 2002/03/26 22:29:55 swa
* we have a new homepage!
*
extern int g_terminate;
#endif
+#ifdef OSX_DARWIN
+extern pthread_mutex_t gmtime_mutex;
+extern pthread_mutex_t localtime_mutex;
+extern pthread_mutex_t gethostbyaddr_mutex;
+extern pthread_mutex_t gethostbyname_mutex;
+#endif /* def OSX_DARWIN */
+
/* Functions */
#ifdef __MINGW32__
-const char parsers_rcs[] = "$Id: parsers.c,v 2.3 2002/12/28 03:58:19 david__schmidt 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 $
*
* 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
#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"
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