Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
[privoxy.git] / errlog.c
index fad5d6e..4fa7290 100644 (file)
--- a/errlog.c
+++ b/errlog.c
@@ -1,4 +1,4 @@
-const char errlog_rcs[] = "$Id: errlog.c,v 1.18 2001/09/10 11:27:24 oes Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.20 2001/09/16 23:04:34 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/errlog.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/errlog.c,v $
@@ -33,6 +33,12 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.18 2001/09/10 11:27:24 oes Exp $";
  *
  * Revisions   :
  *    $Log: errlog.c,v $
  *
  * Revisions   :
  *    $Log: errlog.c,v $
+ *    Revision 1.20  2001/09/16 23:04:34  jongfoster
+ *    Fixing a warning
+ *
+ *    Revision 1.19  2001/09/13 20:08:06  jongfoster
+ *    Adding support for LOG_LEVEL_CGI
+ *
  *    Revision 1.18  2001/09/10 11:27:24  oes
  *    Declaration of w32_socket_strerr now conditional
  *
  *    Revision 1.18  2001/09/10 11:27:24  oes
  *    Declaration of w32_socket_strerr now conditional
  *
@@ -147,11 +153,12 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.18 2001/09/10 11:27:24 oes Exp $";
 #include <stdarg.h>
 #include <string.h>
 
 #include <stdarg.h>
 #include <string.h>
 
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__OS2__)
 #include <unistd.h>
 #include <unistd.h>
-#endif /* ndef _WIN32 */
+#endif /* !defined(_WIN32) && !defined(__OS2__) */
 
 #include <errno.h>
 
 #include <errno.h>
+#include <assert.h>
 #ifdef FEATURE_PTHREAD
 #include <pthread.h>
 #endif /* def FEATURE_PTHREAD */
 #ifdef FEATURE_PTHREAD
 #include <pthread.h>
 #endif /* def FEATURE_PTHREAD */
@@ -163,6 +170,11 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.18 2001/09/10 11:27:24 oes Exp $";
 #endif /* ndef _WIN_CONSOLE */
 #endif /* def _WIN32 */
 
 #endif /* ndef _WIN_CONSOLE */
 #endif /* def _WIN32 */
 
+#ifdef __OS2__
+#define INCL_DOS
+#include <os2.h>
+#endif
+
 #include "errlog.h"
 #include "project.h"
 
 #include "errlog.h"
 #include "project.h"
 
@@ -291,10 +303,14 @@ void init_error_log(const char *prog_name, const char *logfname, int debuglevel)
 void log_error(int loglevel, char *fmt, ...)
 {
    va_list ap;
 void log_error(int loglevel, char *fmt, ...)
 {
    va_list ap;
-   char outbuf[BUFFER_SIZE];
+   char *outbuf= NULL;
    char * src = fmt;
    int outc = 0;
    long this_thread = 1;  /* was: pthread_t this_thread;*/
    char * src = fmt;
    int outc = 0;
    long this_thread = 1;  /* was: pthread_t this_thread;*/
+#ifdef __OS2__
+   PTIB     ptib;
+   APIRET   ulrc;
+#endif /* __OS2__ */
 
 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
    /*
 
 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
    /*
@@ -317,8 +333,15 @@ void log_error(int loglevel, char *fmt, ...)
    /* FIXME get current thread id */
 #ifdef FEATURE_PTHREAD
    this_thread = (long)pthread_self();
    /* FIXME get current thread id */
 #ifdef FEATURE_PTHREAD
    this_thread = (long)pthread_self();
+#elif __OS2__
+  
+   ulrc = DosGetInfoBlocks(&ptib, NULL);
+   if (ulrc == 0)
+     this_thread = ptib -> tib_ptib2 -> tib2_ultid;
 #endif /* def FEATURE_PTHREAD */
 
 #endif /* def FEATURE_PTHREAD */
 
+   outbuf = (char*)malloc(BUFFER_SIZE);
+   assert(outbuf);
    switch (loglevel)
    {
       case LOG_LEVEL_ERROR:
    switch (loglevel)
    {
       case LOG_LEVEL_ERROR:
@@ -368,7 +391,7 @@ void log_error(int loglevel, char *fmt, ...)
          break;
 #endif /* def FEATURE_KILL_POPUPS */
       case LOG_LEVEL_CGI:
          break;
 #endif /* def FEATURE_KILL_POPUPS */
       case LOG_LEVEL_CGI:
-         outc = sprintf(outbuf, "IJB(%d) CGI: ", this_thread);
+         outc = sprintf(outbuf, "IJB(%ld) CGI: ", this_thread);
          break;
       default:
          outc = sprintf(outbuf, "IJB(%ld) UNKNOWN LOG TYPE(%d): ", this_thread, loglevel);
          break;
       default:
          outc = sprintf(outbuf, "IJB(%ld) UNKNOWN LOG TYPE(%d): ", this_thread, loglevel);
@@ -740,4 +763,3 @@ static char *w32_socket_strerr(int errcode, char *tmp_buf)
   tab-width: 3
   end:
 */
   tab-width: 3
   end:
 */
-