1 const char errlog_rcs[] = "$Id: errlog.c,v 1.24 2001/12/30 14:07:32 steudten Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
6 * Purpose : Log errors to a designated destination in an elegant,
9 * Copyright : Written by and Copyright (C) 2001 the SourceForge
10 * IJBSWA team. http://ijbswa.sourceforge.net
12 * Based on the Internet Junkbuster originally written
13 * by and Copyright (C) 1997 Anonymous Coders and
14 * Junkbusters Corporation. http://www.junkbusters.com
16 * This program is free software; you can redistribute it
17 * and/or modify it under the terms of the GNU General
18 * Public License as published by the Free Software
19 * Foundation; either version 2 of the License, or (at
20 * your option) any later version.
22 * This program is distributed in the hope that it will
23 * be useful, but WITHOUT ANY WARRANTY; without even the
24 * implied warranty of MERCHANTABILITY or FITNESS FOR A
25 * PARTICULAR PURPOSE. See the GNU General Public
26 * License for more details.
28 * The GNU General Public License should be included with
29 * this file. If not, you can view it at
30 * http://www.gnu.org/copyleft/gpl.html
31 * or write to the Free Software Foundation, Inc., 59
32 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 * Revision 1.24 2001/12/30 14:07:32 steudten
37 * - Add signal handling (unix)
38 * - Add SIGHUP handler (unix)
39 * - Add creation of pidfile (unix)
40 * - Add action 'top' in rc file (RH)
41 * - Add entry 'SIGNALS' to manpage
42 * - Add exit message to logfile (unix)
44 * Revision 1.23 2001/11/07 00:02:13 steudten
45 * Add line number in error output for lineparsing for
46 * actionsfile and configfile.
47 * Special handling for CLF added.
49 * Revision 1.22 2001/11/05 23:43:05 steudten
50 * Add time+date to log files.
52 * Revision 1.21 2001/10/25 03:40:47 david__schmidt
53 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
54 * threads to call select() simultaneously. So, it's time to do a real, live,
55 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
56 * (native). Both versions will work, but using __OS2__ offers multi-threading.
58 * Revision 1.20 2001/09/16 23:04:34 jongfoster
61 * Revision 1.19 2001/09/13 20:08:06 jongfoster
62 * Adding support for LOG_LEVEL_CGI
64 * Revision 1.18 2001/09/10 11:27:24 oes
65 * Declaration of w32_socket_strerr now conditional
67 * Revision 1.17 2001/09/10 10:17:13 oes
68 * Removed unused variable; Fixed sprintf format
70 * Revision 1.16 2001/07/30 22:08:36 jongfoster
71 * Tidying up #defines:
72 * - All feature #defines are now of the form FEATURE_xxx
73 * - Permanently turned off WIN_GUI_EDIT
74 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
76 * Revision 1.15 2001/07/29 17:41:10 jongfoster
77 * Now prints thread ID for each message (pthreads only)
79 * Revision 1.14 2001/07/19 19:03:48 haroon
80 * - Added case for LOG_LEVEL_POPUPS
82 * Revision 1.13 2001/07/13 13:58:58 oes
83 * - Added case for LOG_LEVEL_DEANIMATE
84 * - Removed all #ifdef PCRS
86 * Revision 1.12 2001/06/09 10:55:28 jongfoster
87 * Changing BUFSIZ ==> BUFFER_SIZE
89 * Revision 1.11 2001/06/01 18:14:49 jongfoster
90 * Changing the calls to strerr() to check HAVE_STRERR (which is defined
91 * in config.h if appropriate) rather than the NO_STRERR macro.
93 * Revision 1.10 2001/05/29 11:52:21 oes
94 * Conditional compilation of w32_socket_error
96 * Revision 1.9 2001/05/28 16:15:17 jongfoster
97 * Improved reporting of errors under Win32.
99 * Revision 1.8 2001/05/26 17:25:14 jongfoster
100 * Added support for CLF (Common Log Format) and fixed LOG_LEVEL_LOG
102 * Revision 1.7 2001/05/26 15:21:28 jongfoster
103 * Activity animation in Win32 GUI now works even if debug==0
105 * Revision 1.6 2001/05/25 21:55:08 jongfoster
106 * Now cleans up properly on FATAL (removes taskbar icon etc)
108 * Revision 1.5 2001/05/22 18:46:04 oes
110 * - Enabled filtering banners by size rather than URL
111 * by adding patterns that replace all standard banner
112 * sizes with the "Junkbuster" gif to the re_filterfile
114 * - Enabled filtering WebBugs by providing a pattern
115 * which kills all 1x1 images
117 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
118 * which is selected by the (nonstandard and therefore
119 * capital) letter 'U' in the option string.
120 * It causes the quantifiers to be ungreedy by default.
121 * Appending a ? turns back to greedy (!).
123 * - Added a new interceptor ijb-send-banner, which
124 * sends back the "Junkbuster" gif. Without imagelist or
125 * MSIE detection support, or if tinygif = 1, or the
126 * URL isn't recognized as an imageurl, a lame HTML
127 * explanation is sent instead.
129 * - Added new feature, which permits blocking remote
130 * script redirects and firing back a local redirect
132 * The feature is conditionally compiled, i.e. it
133 * can be disabled with --disable-fast-redirects,
134 * plus it must be activated by a "fast-redirects"
135 * line in the config file, has its own log level
136 * and of course wants to be displayed by show-proxy-args
137 * Note: Boy, all the #ifdefs in 1001 locations and
138 * all the fumbling with configure.in and acconfig.h
139 * were *way* more work than the feature itself :-(
141 * - Because a generic redirect template was needed for
142 * this, tinygif = 3 now uses the same.
144 * - Moved GIFs, and other static HTTP response templates
149 * - Removed some >400 CRs again (Jon, you really worked
152 * Revision 1.4 2001/05/21 19:32:54 jongfoster
153 * Added another #ifdef _WIN_CONSOLE
155 * Revision 1.3 2001/05/20 01:11:40 jongfoster
156 * Added support for LOG_LEVEL_FATAL
157 * Renamed LOG_LEVEL_FRC to LOG_LEVEL_FORCE,
158 * and LOG_LEVEL_REF to LOG_LEVEL_RE_FILTER
160 * Revision 1.2 2001/05/17 22:42:01 oes
161 * - Cleaned CRLF's from the sources and related files
162 * - Repaired logging for REF and FRC
164 * Revision 1.1.1.1 2001/05/15 13:58:51 oes
165 * Initial import of version 2.9.3 source tree
168 *********************************************************************/
172 #include "miscutil.h"
179 #if !defined(_WIN32) && !defined(__OS2__)
181 #endif /* !defined(_WIN32) && !defined(__OS2__) */
185 #ifdef FEATURE_PTHREAD
187 #endif /* def FEATURE_PTHREAD */
193 #endif /* ndef _WIN_CONSOLE */
194 #endif /* def _WIN32 */
204 const char errlog_h_rcs[] = ERRLOG_H_VERSION;
208 * LOG_LEVEL_FATAL cannot be turned off. (There are
209 * some exceptional situations where we need to get a
210 * message to the user).
212 #define LOG_LEVEL_MINIMUM LOG_LEVEL_FATAL
214 /* where to log (default: stderr) */
215 static FILE *logfp = NULL;
217 /* logging detail level. */
218 static int debug = (LOG_LEVEL_FATAL | LOG_LEVEL_ERROR | LOG_LEVEL_INFO);
220 /* static functions */
221 static void fatal_error(const char * error_message);
223 static char *w32_socket_strerr(int errcode, char *tmp_buf);
226 /*********************************************************************
228 * Function : fatal_error
230 * Description : Displays a fatal error to standard error (or, on
231 * a WIN32 GUI, to a dialog box), and exits
232 * JunkBuster with status code 1.
235 * 1 : error_message = The error message to display.
237 * Returns : Does not return.
239 *********************************************************************/
240 static void fatal_error(const char * error_message)
242 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
243 MessageBox(g_hwndLogFrame, error_message, "Internet JunkBuster Error",
244 MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
246 /* Cleanup - remove taskbar icon etc. */
249 #else /* if !defined(_WIN32) || defined(_WIN_CONSOLE) */
250 fputs(error_message, stderr);
251 #endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
261 /*********************************************************************
263 * Function : init_errlog
265 * Description : Initializes the logging module. Must call before
269 * 1 : prog_name = The program name.
270 * 2 : logfname = The logfile name, or NULL for stderr.
271 * 3 : debuglevel = The debugging level.
275 *********************************************************************/
276 void init_error_log(const char *prog_name, const char *logfname, int debuglevel)
280 /* FIXME RACE HAZARD: should start critical section error_log_use here */
282 /* set the logging detail level */
283 debug = debuglevel | LOG_LEVEL_MINIMUM;
285 if ((logfp != NULL) && (logfp != stderr))
287 log_error(LOG_LEVEL_INFO, "(Re-)Open logfile %s", logfname ? logfname : "none");
292 /* set the designated log file */
295 if( !(fp = fopen(logfname, "a")) )
297 log_error(LOG_LEVEL_FATAL, "init_errlog(): can't open logfile: %s", logfname);
300 /* set logging to be completely unbuffered */
306 log_error(LOG_LEVEL_INFO, "Internet JunkBuster version " VERSION);
307 if (prog_name != NULL)
309 log_error(LOG_LEVEL_INFO, "Program name: %s", prog_name);
312 /* FIXME RACE HAZARD: should end critical section error_log_use here */
314 } /* init_error_log */
317 /*********************************************************************
319 * Function : log_error
321 * Description : This is the error-reporting and logging function.
324 * 1 : loglevel = the type of message to be logged
325 * 2 : fmt = the main string we want logged, printf-like
326 * 3 : ... = arguments to be inserted in fmt (printf-like).
330 *********************************************************************/
331 void log_error(int loglevel, char *fmt, ...)
335 char *outbuf_save = NULL;
338 long this_thread = 1; /* was: pthread_t this_thread;*/
344 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
346 * Irrespective of debug setting, a GET/POST/CONNECT makes
347 * the taskbar icon animate. (There is an option to disable
348 * this but checking that is handled inside LogShowActivity()).
350 if (loglevel == LOG_LEVEL_GPC)
354 #endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
356 /* verify if loglevel applies to current settings and bail out if negative */
357 if ((loglevel & debug) == 0)
362 /* FIXME get current thread id */
363 #ifdef FEATURE_PTHREAD
364 this_thread = (long)pthread_self();
367 ulrc = DosGetInfoBlocks(&ptib, NULL);
369 this_thread = ptib -> tib_ptib2 -> tib2_ultid;
370 #endif /* def FEATURE_PTHREAD */
372 outbuf_save = outbuf = (char*)malloc(BUFFER_SIZE);
377 * Write timestamp into tempbuf.
379 * Complex because not all OSs have tm_gmtoff or
380 * the %z field in strftime()
385 #ifdef HAVE_LOCALTIME_R
386 tm_now = *localtime_r(&now, &tm_now);
388 tm_now = *localtime (&now);
390 strftime(outbuf, BUFFER_SIZE-6, "%b %d %H:%M:%S ", &tm_now);
391 outbuf += strlen( outbuf );
395 case LOG_LEVEL_ERROR:
396 outc = sprintf(outbuf, "IJB(%ld) Error: ", this_thread);
398 case LOG_LEVEL_FATAL:
399 outc = sprintf(outbuf, "IJB(%ld) Fatal error: ", this_thread);
402 outc = sprintf(outbuf, "IJB(%ld) Request: ", this_thread);
404 case LOG_LEVEL_CONNECT:
405 outc = sprintf(outbuf, "IJB(%ld) Connect: ", this_thread);
408 outc = sprintf(outbuf, "IJB(%ld) Writing: ", this_thread);
410 case LOG_LEVEL_HEADER:
411 outc = sprintf(outbuf, "IJB(%ld) Header: ", this_thread);
414 outc = sprintf(outbuf, "IJB(%ld) Info: ", this_thread);
416 case LOG_LEVEL_RE_FILTER:
417 outc = sprintf(outbuf, "IJB(%ld) Re-Filter: ", this_thread);
419 #ifdef FEATURE_FORCE_LOAD
420 case LOG_LEVEL_FORCE:
421 outc = sprintf(outbuf, "IJB(%ld) Force: ", this_thread);
423 #endif /* def FEATURE_FORCE_LOAD */
424 #ifdef FEATURE_FAST_REDIRECTS
425 case LOG_LEVEL_REDIRECTS:
426 outc = sprintf(outbuf, "IJB(%ld) Redirect: ", this_thread);
428 #endif /* def FEATURE_FAST_REDIRECTS */
429 case LOG_LEVEL_DEANIMATE:
430 outc = sprintf(outbuf, "IJB(%ld) Gif-Deanimate: ", this_thread);
433 outbuf = outbuf_save;
437 #ifdef FEATURE_KILL_POPUPS
438 case LOG_LEVEL_POPUPS:
439 outc = sprintf(outbuf, "IJB(%ld) Kill-Popups: ", this_thread);
441 #endif /* def FEATURE_KILL_POPUPS */
443 outc = sprintf(outbuf, "IJB(%ld) CGI: ", this_thread);
446 outc = sprintf(outbuf, "IJB(%ld) UNKNOWN LOG TYPE(%d): ", this_thread, loglevel);
450 /* get ready to scan var. args. */
453 /* build formatted message from fmt and var-args */
454 while ((*src) && (outc < BUFFER_SIZE-2))
456 char tempbuf[BUFFER_SIZE];
475 outbuf[outc++] = '%';
478 ival = va_arg( ap, int );
480 outc += sprintf(tempbuf, "%d", ival);
481 if (outc < BUFFER_SIZE-1)
483 strcpy(outbuf + oldoutc, tempbuf);
487 outbuf[oldoutc] = '\0';
491 uval = va_arg( ap, unsigned );
493 outc += sprintf(tempbuf, "%u", uval);
494 if (outc < BUFFER_SIZE-1)
496 strcpy(outbuf + oldoutc, tempbuf);
500 outbuf[oldoutc] = '\0';
504 /* this is a modifier that must be followed by u or d */
508 lval = va_arg( ap, long );
510 outc += sprintf(tempbuf, "%ld", lval);
514 ulval = va_arg( ap, unsigned long );
516 outc += sprintf(tempbuf, "%lu", ulval);
521 sprintf(outbuf, "IJB(%ld) Error: log_error(): Bad format string:\n"
523 "Exiting.", this_thread, fmt);
524 /* FIXME RACE HAZARD: should start critical section error_log_use here */
529 fputs(outbuf, logfp);
530 /* FIXME RACE HAZARD: should end critical section error_log_use here */
535 if (outc < BUFFER_SIZE-1)
537 strcpy(outbuf + oldoutc, tempbuf);
541 outbuf[oldoutc] = '\0';
546 * Note that char paramaters are converted to int, so we need to
547 * pass "int" to va_arg. (See K&R, 2nd ed, section A7.3.2, page 202)
549 outbuf[outc++] = (char) va_arg( ap, int );
552 sval = va_arg( ap, char * );
554 outc += strlen(sval);
555 if (outc < BUFFER_SIZE-1)
557 strcpy(outbuf + oldoutc, sval);
561 outbuf[oldoutc] = '\0';
565 /* Non-standard: Print a counted string. Takes 2 parameters:
566 * int length, const char * string
568 ival = va_arg( ap, int );
569 sval = va_arg( ap, char * );
576 if (outc < BUFFER_SIZE-1)
578 memcpy(outbuf + oldoutc, sval, ival);
582 outbuf[oldoutc] = '\0';
586 /* Non-standard: Print error code from errno */
588 ival = WSAGetLastError();
589 sval = w32_socket_strerr(ival, tempbuf);
590 #else /* ifndef _WIN32 */
593 sval = strerror(ival);
594 #else /* ifndef HAVE_STRERROR */
596 #endif /* ndef HAVE_STRERROR */
599 sprintf(tempbuf, "(errno = %d)", ival);
602 #endif /* ndef _WIN32 */
604 outc += strlen(sval);
605 if (outc < BUFFER_SIZE-1)
607 strcpy(outbuf + oldoutc, sval);
611 outbuf[oldoutc] = '\0';
615 /* Non-standard: Print a Common Log File timestamp */
618 * Write timestamp into tempbuf.
620 * Complex because not all OSs have tm_gmtoff or
621 * the %z field in strftime()
626 #ifdef HAVE_LOCALTIME_R
632 gmt = *gmtime_r(&now, &gmt);
636 #ifdef HAVE_LOCALTIME_R
637 tm_now = localtime_r(&now, &dummy);
639 tm_now = localtime (&now);
641 days = tm_now->tm_yday - gmt.tm_yday;
642 hrs = ((days < -1 ? 24 : 1 < days ? -24 : days * 24) + tm_now->tm_hour - gmt.tm_hour);
643 mins = hrs * 60 + tm_now->tm_min - gmt.tm_min;
644 strftime (tempbuf, BUFFER_SIZE-6, "%d/%b/%Y:%H:%M:%S ", tm_now);
645 sprintf (tempbuf + strlen(tempbuf), "%+03d%02d", mins / 60, abs(mins) % 60);
648 outc += strlen(tempbuf);
649 if (outc < BUFFER_SIZE-1)
651 strcpy(outbuf + oldoutc, tempbuf);
655 outbuf[oldoutc] = '\0';
659 sprintf(outbuf, "IJB(%ld) Error: log_error(): Bad format string:\n"
661 "Exiting.", this_thread, fmt);
662 /* FIXME RACE HAZARD: should start critical section error_log_use here */
667 fputs(outbuf_save, logfp);
668 /* FIXME RACE HAZARD: should end critical section error_log_use here */
669 fatal_error(outbuf_save);
677 /* done with var. args */
680 if (outc >= BUFFER_SIZE-2)
682 /* insufficient room for newline and trailing null. */
684 static const char warning[] = "... [too long, truncated]\n";
686 if (outc < BUFFER_SIZE)
688 /* Need to add terminating null in this case. */
692 /* Truncate output */
693 outbuf[BUFFER_SIZE - sizeof(warning)] = '\0';
696 strcat(outbuf, warning);
700 /* Add terminating newline and null */
701 outbuf[outc++] = '\n';
705 /* FIXME RACE HAZARD: should start critical section error_log_use here */
707 /* deal with glibc stupidity - it won't let you initialize logfp */
713 fputs(outbuf_save, logfp);
715 if (loglevel == LOG_LEVEL_FATAL)
717 fatal_error(outbuf_save);
721 /* FIXME RACE HAZARD: should end critical section error_log_use here */
723 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
724 /* Write to display */
725 LogPutString(outbuf_save);
726 #endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
732 /*********************************************************************
734 * Function : w32_socket_strerr
736 * Description : Translate the return value from WSAGetLastError()
740 * 1 : errcode = The return value from WSAGetLastError().
741 * 2 : tmp_buf = A temporary buffer that might be used to
744 * Returns : String representing the error code. This may be
745 * a global string constant or a string stored in
748 *********************************************************************/
749 static char *w32_socket_strerr(int errcode, char *tmp_buf)
751 #define TEXT_FOR_ERROR(code,text) \
752 if (errcode == code) \
754 return #code " - " text; \
757 TEXT_FOR_ERROR(WSAEACCES, "Permission denied")
758 TEXT_FOR_ERROR(WSAEADDRINUSE, "Address already in use.")
759 TEXT_FOR_ERROR(WSAEADDRNOTAVAIL, "Cannot assign requested address.");
760 TEXT_FOR_ERROR(WSAEAFNOSUPPORT, "Address family not supported by protocol family.");
761 TEXT_FOR_ERROR(WSAEALREADY, "Operation already in progress.");
762 TEXT_FOR_ERROR(WSAECONNABORTED, "Software caused connection abort.");
763 TEXT_FOR_ERROR(WSAECONNREFUSED, "Connection refused.");
764 TEXT_FOR_ERROR(WSAECONNRESET, "Connection reset by peer.");
765 TEXT_FOR_ERROR(WSAEDESTADDRREQ, "Destination address required.");
766 TEXT_FOR_ERROR(WSAEFAULT, "Bad address.");
767 TEXT_FOR_ERROR(WSAEHOSTDOWN, "Host is down.");
768 TEXT_FOR_ERROR(WSAEHOSTUNREACH, "No route to host.");
769 TEXT_FOR_ERROR(WSAEINPROGRESS, "Operation now in progress.");
770 TEXT_FOR_ERROR(WSAEINTR, "Interrupted function call.");
771 TEXT_FOR_ERROR(WSAEINVAL, "Invalid argument.");
772 TEXT_FOR_ERROR(WSAEISCONN, "Socket is already connected.");
773 TEXT_FOR_ERROR(WSAEMFILE, "Too many open sockets.");
774 TEXT_FOR_ERROR(WSAEMSGSIZE, "Message too long.");
775 TEXT_FOR_ERROR(WSAENETDOWN, "Network is down.");
776 TEXT_FOR_ERROR(WSAENETRESET, "Network dropped connection on reset.");
777 TEXT_FOR_ERROR(WSAENETUNREACH, "Network is unreachable.");
778 TEXT_FOR_ERROR(WSAENOBUFS, "No buffer space available.");
779 TEXT_FOR_ERROR(WSAENOPROTOOPT, "Bad protocol option.");
780 TEXT_FOR_ERROR(WSAENOTCONN, "Socket is not connected.");
781 TEXT_FOR_ERROR(WSAENOTSOCK, "Socket operation on non-socket.");
782 TEXT_FOR_ERROR(WSAEOPNOTSUPP, "Operation not supported.");
783 TEXT_FOR_ERROR(WSAEPFNOSUPPORT, "Protocol family not supported.");
784 TEXT_FOR_ERROR(WSAEPROCLIM, "Too many processes.");
785 TEXT_FOR_ERROR(WSAEPROTONOSUPPORT, "Protocol not supported.");
786 TEXT_FOR_ERROR(WSAEPROTOTYPE, "Protocol wrong type for socket.");
787 TEXT_FOR_ERROR(WSAESHUTDOWN, "Cannot send after socket shutdown.");
788 TEXT_FOR_ERROR(WSAESOCKTNOSUPPORT, "Socket type not supported.");
789 TEXT_FOR_ERROR(WSAETIMEDOUT, "Connection timed out.");
790 TEXT_FOR_ERROR(WSAEWOULDBLOCK, "Resource temporarily unavailable.");
791 TEXT_FOR_ERROR(WSAHOST_NOT_FOUND, "Host not found.");
792 TEXT_FOR_ERROR(WSANOTINITIALISED, "Successful WSAStartup not yet performed.");
793 TEXT_FOR_ERROR(WSANO_DATA, "Valid name, no data record of requested type.");
794 TEXT_FOR_ERROR(WSANO_RECOVERY, "This is a non-recoverable error.");
795 TEXT_FOR_ERROR(WSASYSNOTREADY, "Network subsystem is unavailable.");
796 TEXT_FOR_ERROR(WSATRY_AGAIN, "Non-authoritative host not found.");
797 TEXT_FOR_ERROR(WSAVERNOTSUPPORTED, "WINSOCK.DLL version out of range.");
798 TEXT_FOR_ERROR(WSAEDISCON, "Graceful shutdown in progress.");
800 * The following error codes are documented in the Microsoft WinSock
801 * reference guide, but don't actually exist.
803 * TEXT_FOR_ERROR(WSA_INVALID_HANDLE, "Specified event object handle is invalid.");
804 * TEXT_FOR_ERROR(WSA_INVALID_PARAMETER, "One or more parameters are invalid.");
805 * TEXT_FOR_ERROR(WSAINVALIDPROCTABLE, "Invalid procedure table from service provider.");
806 * TEXT_FOR_ERROR(WSAINVALIDPROVIDER, "Invalid service provider version number.");
807 * TEXT_FOR_ERROR(WSA_IO_PENDING, "Overlapped operations will complete later.");
808 * TEXT_FOR_ERROR(WSA_IO_INCOMPLETE, "Overlapped I/O event object not in signaled state.");
809 * TEXT_FOR_ERROR(WSA_NOT_ENOUGH_MEMORY, "Insufficient memory available.");
810 * TEXT_FOR_ERROR(WSAPROVIDERFAILEDINIT, "Unable to initialize a service provider.");
811 * TEXT_FOR_ERROR(WSASYSCALLFAILURE, "System call failure.");
812 * TEXT_FOR_ERROR(WSA_OPERATION_ABORTED, "Overlapped operation aborted.");
815 sprintf(tmp_buf, "(error number %d)", errcode);
818 #endif /* def _WIN32 */