Fixed gcc43 conversion warnings and replaced sprintf
[privoxy.git] / jcc.c
diff --git a/jcc.c b/jcc.c
index 71f8946..e8f63a4 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.109 2006/12/06 19:41:40 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.113 2006/12/26 17:38:50 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,22 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.109 2006/12/06 19:41:40 fabiankeil Exp $"
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.113  2006/12/26 17:38:50  fabiankeil
+ *    Silence compiler warning I introduced with my last commit.
+ *
+ *    Revision 1.112  2006/12/26 17:31:41  fabiankeil
+ *    Mutex protect rand() if POSIX threading
+ *    is used, warn the user if that's not possible
+ *    and stop using it on _WIN32 where it could
+ *    cause crashes.
+ *
+ *    Revision 1.111  2006/12/23 16:15:06  fabiankeil
+ *    Don't prevent core dumps by catching SIGABRT.
+ *    It's rude and makes debugging unreasonable painful.
+ *
+ *    Revision 1.110  2006/12/13 14:52:53  etresoft
+ *    Fix build failure on MacOS X. Global symbols can be either static or extern, but not both.
+ *
  *    Revision 1.109  2006/12/06 19:41:40  fabiankeil
  *    Privoxy is now able to run as intercepting
  *    proxy in combination with any packet filter
@@ -841,6 +857,11 @@ pthread_mutex_t gethostbyaddr_mutex;
 #ifndef HAVE_GETHOSTBYNAME_R
 pthread_mutex_t gethostbyname_mutex;
 #endif /* ndef HAVE_GETHOSTBYNAME_R */
+
+#ifndef HAVE_RANDOM
+pthread_mutex_t rand_mutex;
+#endif /* ndef HAVE_RANDOM */
+
 #endif /* FEATURE_PTHREAD */
 
 #if defined(unix) || defined(__EMX__)
@@ -896,7 +917,7 @@ const char MISSING_DESTINATION_RESPONSE[] =
  * Function    :  sig_handler 
  *
  * Description :  Signal handler for different signals.
- *                Exit gracefully on ABRT, TERM and  INT
+ *                Exit gracefully on TERM and INT
  *                or set a flag that will cause the errlog
  *                to be reopened by the main thread on HUP.
  *
@@ -910,7 +931,6 @@ static void sig_handler(int the_signal)
 {
    switch(the_signal)
    {
-      case SIGABRT:
       case SIGTERM:
       case SIGINT:
          log_error(LOG_LEVEL_INFO, "exiting by signal %d .. bye", the_signal);
@@ -2067,9 +2087,7 @@ int main(int argc, const char *argv[])
 #endif
 {
    int argc_pos = 0;
-#ifdef HAVE_RANDOM
    unsigned int random_seed;
-#endif /* ifdef HAVE_RANDOM */
 #ifdef unix
    struct passwd *pw = NULL;
    struct group *grp = NULL;
@@ -2236,11 +2254,18 @@ int main(int argc, const char *argv[])
 #ifndef HAVE_GETHOSTBYNAME_R
    pthread_mutex_init(&gethostbyname_mutex,0);
 #endif /* ndef HAVE_GETHOSTBYNAME_R */
+
+#ifndef HAVE_RANDOM
+   pthread_mutex_init(&rand_mutex,0);
+#endif /* ndef HAVE_RANDOM */
+
 #endif /* FEATURE_PTHREAD */
 
+   random_seed = (int)time(NULL);
 #ifdef HAVE_RANDOM
-   random_seed = (unsigned int)time(NULL);
    srandom(random_seed);
+#else
+   srand(random_seed);
 #endif /* ifdef HAVE_RANDOM */
 
    /*
@@ -2253,7 +2278,7 @@ int main(int argc, const char *argv[])
 #if !defined(_WIN32) && !defined(__OS2__) && !defined(AMIGA)
 {
    int idx;
-   const int catched_signals[] = { SIGABRT, SIGTERM, SIGINT, SIGHUP, 0 };
+   const int catched_signals[] = { SIGTERM, SIGINT, SIGHUP, 0 };
    const int ignored_signals[] = { SIGPIPE, 0 };
 
    for (idx = 0; catched_signals[idx] != 0; idx++)
@@ -2697,7 +2722,7 @@ static void listen_loop(void)
             pthread_attr_init(&attrs);
             pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
             errno = pthread_create(&the_thread, &attrs,
-               (void*)serve, csp);
+               (void * (*)(void *))serve, csp);
             child_id = errno ? -1 : 0;
             pthread_attr_destroy(&attrs);
          }