Removing code related to old forward and ACL files.
[privoxy.git] / errlog.c
1 const char errlog_rcs[] = "$Id: errlog.c,v 1.10 2001/05/29 11:52:21 oes Exp $";
2 /*********************************************************************
3  *
4  * File        :  $Source: /cvsroot/ijbswa/current/errlog.c,v $
5  *
6  * Purpose     :  Log errors to a designated destination in an elegant,
7  *                printf-like fashion.
8  *
9  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
10  *                IJBSWA team.  http://ijbswa.sourceforge.net
11  *
12  *                Based on the Internet Junkbuster originally written
13  *                by and Copyright (C) 1997 Anonymous Coders and 
14  *                Junkbusters Corporation.  http://www.junkbusters.com
15  *
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.
21  *
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.
27  *
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.
33  *
34  * Revisions   :
35  *    $Log: errlog.c,v $
36  *    Revision 1.10  2001/05/29 11:52:21  oes
37  *    Conditional compilation of w32_socket_error
38  *
39  *    Revision 1.9  2001/05/28 16:15:17  jongfoster
40  *    Improved reporting of errors under Win32.
41  *
42  *    Revision 1.8  2001/05/26 17:25:14  jongfoster
43  *    Added support for CLF (Common Log Format) and fixed LOG_LEVEL_LOG
44  *
45  *    Revision 1.7  2001/05/26 15:21:28  jongfoster
46  *    Activity animation in Win32 GUI now works even if debug==0
47  *
48  *    Revision 1.6  2001/05/25 21:55:08  jongfoster
49  *    Now cleans up properly on FATAL (removes taskbar icon etc)
50  *
51  *    Revision 1.5  2001/05/22 18:46:04  oes
52  *
53  *    - Enabled filtering banners by size rather than URL
54  *      by adding patterns that replace all standard banner
55  *      sizes with the "Junkbuster" gif to the re_filterfile
56  *
57  *    - Enabled filtering WebBugs by providing a pattern
58  *      which kills all 1x1 images
59  *
60  *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
61  *      which is selected by the (nonstandard and therefore
62  *      capital) letter 'U' in the option string.
63  *      It causes the quantifiers to be ungreedy by default.
64  *      Appending a ? turns back to greedy (!).
65  *
66  *    - Added a new interceptor ijb-send-banner, which
67  *      sends back the "Junkbuster" gif. Without imagelist or
68  *      MSIE detection support, or if tinygif = 1, or the
69  *      URL isn't recognized as an imageurl, a lame HTML
70  *      explanation is sent instead.
71  *
72  *    - Added new feature, which permits blocking remote
73  *      script redirects and firing back a local redirect
74  *      to the browser.
75  *      The feature is conditionally compiled, i.e. it
76  *      can be disabled with --disable-fast-redirects,
77  *      plus it must be activated by a "fast-redirects"
78  *      line in the config file, has its own log level
79  *      and of course wants to be displayed by show-proxy-args
80  *      Note: Boy, all the #ifdefs in 1001 locations and
81  *      all the fumbling with configure.in and acconfig.h
82  *      were *way* more work than the feature itself :-(
83  *
84  *    - Because a generic redirect template was needed for
85  *      this, tinygif = 3 now uses the same.
86  *
87  *    - Moved GIFs, and other static HTTP response templates
88  *      to project.h
89  *
90  *    - Some minor fixes
91  *
92  *    - Removed some >400 CRs again (Jon, you really worked
93  *      a lot! ;-)
94  *
95  *    Revision 1.4  2001/05/21 19:32:54  jongfoster
96  *    Added another #ifdef _WIN_CONSOLE
97  *
98  *    Revision 1.3  2001/05/20 01:11:40  jongfoster
99  *    Added support for LOG_LEVEL_FATAL
100  *    Renamed LOG_LEVEL_FRC to LOG_LEVEL_FORCE,
101  *    and LOG_LEVEL_REF to LOG_LEVEL_RE_FILTER
102  *
103  *    Revision 1.2  2001/05/17 22:42:01  oes
104  *     - Cleaned CRLF's from the sources and related files
105  *     - Repaired logging for REF and FRC
106  *
107  *    Revision 1.1.1.1  2001/05/15 13:58:51  oes
108  *    Initial import of version 2.9.3 source tree
109  *
110  *
111  *********************************************************************/
112 \f
113
114 #include "config.h"
115
116 #include <stdlib.h>
117 #include <stdio.h>
118 #include <stdarg.h>
119 #include <string.h>
120
121 #ifndef _WIN32
122 #include <unistd.h>
123 #endif /* ndef _WIN32 */
124
125 #include <errno.h>
126 /* #include <pthread.h> */
127
128 #ifdef _WIN32
129 #include <windows.h>
130 #ifndef _WIN_CONSOLE
131 #include "w32log.h"
132 #endif /* ndef _WIN_CONSOLE */
133 #endif /* def _WIN32 */
134
135 #include "errlog.h"
136 #include "project.h"
137
138 const char errlog_h_rcs[] = ERRLOG_H_VERSION;
139
140
141 /*
142  * LOG_LEVEL_FATAL cannot be turned off.  (There are
143  * some exceptional situations where we need to get a
144  * message to the user).
145  */
146 #define LOG_LEVEL_MINIMUM  LOG_LEVEL_FATAL
147
148 /* where to log (default: stderr) */
149 static FILE *logfp = NULL;
150
151 /* where to log (NULL == stderr) */
152 static char * logfilename = NULL;
153
154 /* logging detail level.  */
155 static int debug = (LOG_LEVEL_FATAL | LOG_LEVEL_ERROR | LOG_LEVEL_INFO);  
156
157 /* static functions */
158 static void fatal_error(const char * error_message);
159 static char * w32_socket_strerr(int errcode, char * tmp_buf);
160
161
162 /*********************************************************************
163  *
164  * Function    :  fatal_error
165  *
166  * Description :  Displays a fatal error to standard error (or, on 
167  *                a WIN32 GUI, to a dialog box), and exits
168  *                JunkBuster with status code 1.
169  *
170  * Parameters  :
171  *          1  :  error_message = The error message to display.
172  *
173  * Returns     :  Does not return.
174  *
175  *********************************************************************/
176 static void fatal_error(const char * error_message)
177 {
178 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
179    MessageBox(g_hwndLogFrame, error_message, "Internet JunkBuster Error", 
180       MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);  
181
182    /* Cleanup - remove taskbar icon etc. */
183    TermLogWindow();
184
185 #else /* if !defined(_WIN32) || defined(_WIN_CONSOLE) */
186    fputs(error_message, stderr);
187 #endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
188
189    exit(1);
190 }
191
192
193 /*********************************************************************
194  *
195  * Function    :  init_errlog
196  *
197  * Description :  Initializes the logging module.  Must call before
198  *                calling log_error.
199  *
200  * Parameters  :
201  *          1  :  prog_name  = The program name.
202  *          2  :  logfname   = The logfile name, or NULL for stderr.
203  *          3  :  debuglevel = The debugging level.
204  *
205  * Returns     :  N/A
206  *
207  *********************************************************************/
208 void init_error_log(const char *prog_name, const char *logfname, int debuglevel)
209 {
210    FILE *fp;
211
212    /* FIXME RACE HAZARD: should start critical section error_log_use here */
213
214    /* set the logging detail level */
215    debug = debuglevel | LOG_LEVEL_MINIMUM;
216
217    if ((logfp != NULL) && (logfp != stderr))
218    {
219       fclose(logfp);
220    }
221    logfp = stderr;
222
223    /* set the designated log file */
224    if( logfname )
225    {
226       if( !(fp = fopen(logfname, "a")) )
227       {
228          log_error(LOG_LEVEL_FATAL, "init_errlog(): can't open logfile: %s", logfname);
229       }
230
231       /* set logging to be completely unbuffered */
232       setbuf(fp, NULL);
233
234       logfp = fp;
235    }
236
237    log_error(LOG_LEVEL_INFO, "Internet JunkBuster version " VERSION);
238    if (prog_name != NULL)
239    {
240       log_error(LOG_LEVEL_INFO, "Program name: %s", prog_name);
241    }
242
243    /* FIXME RACE HAZARD: should end critical section error_log_use here */
244
245 } /* init_error_log */
246
247
248 /*********************************************************************
249  *
250  * Function    :  log_error
251  *
252  * Description :  This is the error-reporting and logging function.
253  *
254  * Parameters  :
255  *          1  :  loglevel  = the type of message to be logged
256  *          2  :  fmt       = the main string we want logged, printf-like
257  *          3  :  ...       = arguments to be inserted in fmt (printf-like).
258  *
259  * Returns     :  N/A
260  *
261  *********************************************************************/
262 void log_error(int loglevel, char *fmt, ...)
263 {
264    va_list ap;
265    char outbuf[BUFSIZ];
266    char * src = fmt;
267    int outc = 0;
268    long this_thread = 1;  /* was: pthread_t this_thread;*/
269
270 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
271    /*
272     * Irrespective of debug setting, a GET/POST/CONNECT makes
273     * the taskbar icon animate.  (There is an option to disable
274     * this but checking that is handled inside LogShowActivity()).
275     */
276    if (loglevel == LOG_LEVEL_GPC)
277    {
278       LogShowActivity();
279    }
280 #endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
281
282    /* verify if loglevel applies to current settings and bail out if negative */
283    if ((loglevel & debug) == 0)
284    {
285       return;
286    }
287
288    /* FIXME get current thread id */
289    /* this_thread = (long)pthread_self(); */
290
291    switch (loglevel)
292    {
293       case LOG_LEVEL_ERROR:
294          outc = sprintf(outbuf, "IJB(%d) Error: ", this_thread);
295          break;
296       case LOG_LEVEL_FATAL:
297          outc = sprintf(outbuf, "IJB(%d) Fatal error: ", this_thread);
298          break;
299       case LOG_LEVEL_GPC:
300          outc = sprintf(outbuf, "IJB(%d) Request: ", this_thread);
301          break;
302       case LOG_LEVEL_CONNECT:
303          outc = sprintf(outbuf, "IJB(%d) Connect: ", this_thread);
304          break;
305       case LOG_LEVEL_LOG:
306          outc = sprintf(outbuf, "IJB(%d) Writing: ", this_thread);
307          break;
308       case LOG_LEVEL_HEADER:
309          outc = sprintf(outbuf, "IJB(%d) Header: ", this_thread);
310          break;
311       case LOG_LEVEL_INFO:
312          outc = sprintf(outbuf, "IJB(%d) Info: ", this_thread);
313          break;
314 #ifdef PCRS
315       case LOG_LEVEL_RE_FILTER:
316          outc = sprintf(outbuf, "IJB(%d) Re-Filter: ", this_thread);
317          break;
318 #endif /* def PCRS */
319 #ifdef FORCE_LOAD
320       case LOG_LEVEL_FORCE:
321          outc = sprintf(outbuf, "IJB(%d) Force: ", this_thread);
322          break;
323 #endif /* def FORCE_LOAD */
324 #ifdef FAST_REDIRECTS
325       case LOG_LEVEL_REDIRECTS:
326          outc = sprintf(outbuf, "IJB(%d) Redirect: ", this_thread);
327          break;
328 #endif /* def FAST_REDIRECTS */
329       case LOG_LEVEL_CLF:
330          outc = 0;
331          outbuf[0] = '\0';
332          break;
333       default:
334          outc = sprintf(outbuf, "IJB(%d) UNKNOWN LOG TYPE(%d): ", this_thread, loglevel);
335          break;
336    }
337    
338    /* get ready to scan var. args. */
339    va_start( ap, fmt );
340
341    /* build formatted message from fmt and var-args */
342    while ((*src) && (outc < BUFSIZ-2))
343    {
344       char tempbuf[BUFSIZ];
345       char *sval;
346       int ival;
347       unsigned uval;
348       long lval;
349       unsigned long ulval;
350       int oldoutc;
351       char ch;
352       
353       ch = *src++;
354       if( ch != '%' )
355       {
356          outbuf[outc++] = ch;
357          continue;
358       }
359
360       ch = *src++;
361       switch (ch) {
362          case '%':
363             outbuf[outc++] = '%';
364             break;
365          case 'd':
366             ival = va_arg( ap, int );
367             oldoutc = outc;
368             outc += sprintf(tempbuf, "%d", ival);
369             if (outc < BUFSIZ-1) 
370             {
371                strcpy(outbuf + oldoutc, tempbuf);
372             }
373             else
374             {
375                outbuf[oldoutc] = '\0';
376             }
377             break;
378          case 'u':
379             uval = va_arg( ap, unsigned );
380             oldoutc = outc;
381             outc += sprintf(tempbuf, "%u", uval);
382             if (outc < BUFSIZ-1) 
383             {
384                strcpy(outbuf + oldoutc, tempbuf);
385             }
386             else
387             {
388                outbuf[oldoutc] = '\0';
389             }
390             break;
391          case 'l':
392             /* this is a modifier that must be followed by u or d */
393             ch = *src++;
394             if (ch == 'd')
395             {
396                lval = va_arg( ap, long );
397                oldoutc = outc;
398                outc += sprintf(tempbuf, "%ld", lval);
399             }
400             else if (ch == 'u')
401             {
402                ulval = va_arg( ap, unsigned long );
403                oldoutc = outc;
404                outc += sprintf(tempbuf, "%lu", ulval);
405             }
406             else
407             {
408                /* Error */
409                sprintf(outbuf, "IJB(%d) Error: log_error(): Bad format string:\n"
410                                "Format = \"%s\"\n"
411                                "Exiting.", this_thread, fmt);
412                /* FIXME RACE HAZARD: should start critical section error_log_use here */
413                if( !logfp )
414                {
415                   logfp = stderr;
416                }
417                fputs(outbuf, logfp);
418                /* FIXME RACE HAZARD: should end critical section error_log_use here */
419                fatal_error(outbuf);
420                /* Never get here */
421                break;
422             }
423             if (outc < BUFSIZ-1) 
424             {
425                strcpy(outbuf + oldoutc, tempbuf);
426             }
427             else
428             {
429                outbuf[oldoutc] = '\0';
430             }
431             break;
432          case 'c':
433             /*
434              * Note that char paramaters are converted to int, so we need to
435              * pass "int" to va_arg.  (See K&R, 2nd ed, section A7.3.2, page 202)
436              */
437             outbuf[outc++] = (char) va_arg( ap, int );
438             break;
439          case 's':
440             sval = va_arg( ap, char * );
441             oldoutc = outc;
442             outc += strlen(sval);
443             if (outc < BUFSIZ-1) 
444             {
445                strcpy(outbuf + oldoutc, sval);
446             }
447             else
448             {
449                outbuf[oldoutc] = '\0';
450             }
451             break;
452          case 'N':
453             /* Non-standard: Print a counted string.  Takes 2 parameters:
454              * int length, const char * string
455              */
456             ival = va_arg( ap, int );
457             sval = va_arg( ap, char * );
458             if (ival < 0)
459             {
460                ival = 0;
461             }
462             oldoutc = outc;
463             outc += ival;
464             if (outc < BUFSIZ-1)
465             {
466                memcpy(outbuf + oldoutc, sval, ival);
467             }
468             else
469             {
470                outbuf[oldoutc] = '\0';
471             }
472             break;
473          case 'E':
474             /* Non-standard: Print error code from errno */
475 #ifdef _WIN32
476             ival = WSAGetLastError();
477             sval = w32_socket_strerr(ival, tempbuf);
478 #else /* ifndef _WIN32 */
479             ival = errno; 
480 #ifdef HAVE_STRERROR
481             sval = strerror(ival);
482 #else /* ifndef HAVE_STRERROR */
483             sval = NULL;
484 #endif /* ndef HAVE_STRERROR */
485             if (sval == NULL)
486             {
487                sprintf(tempbuf, "(errno = %d)", ival);
488                sval = tempbuf;
489             }
490 #endif /* ndef _WIN32 */
491             oldoutc = outc;
492             outc += strlen(sval);
493             if (outc < BUFSIZ-1) 
494             {
495                strcpy(outbuf + oldoutc, sval);
496             }
497             else
498             {
499                outbuf[oldoutc] = '\0';
500             }
501             break;
502          case 'T':
503             /* Non-standard: Print a Common Log File timestamp */
504             {
505                /*
506                 * Write timestamp into tempbuf.
507                 *
508                 * Complex because not all OSs have tm_gmtoff or
509                 * the %z field in strftime()
510                 */
511                time_t now; 
512                struct tm *tm_now; 
513                struct tm gmt; 
514                int days, hrs, mins; 
515                time (&now); 
516                gmt = *gmtime (&now); 
517                tm_now = localtime (&now); 
518                days = tm_now->tm_yday - gmt.tm_yday; 
519                hrs = ((days < -1 ? 24 : 1 < days ? -24 : days * 24) + tm_now->tm_hour - gmt.tm_hour); 
520                mins = hrs * 60 + tm_now->tm_min - gmt.tm_min; 
521                strftime (tempbuf, BUFSIZ-6, "%d/%b/%Y:%H:%M:%S ", tm_now); 
522                sprintf (tempbuf + strlen(tempbuf), "%+03d%02d", mins / 60, abs(mins) % 60); 
523             }
524             oldoutc = outc;
525             outc += strlen(tempbuf);
526             if (outc < BUFSIZ-1) 
527             {
528                strcpy(outbuf + oldoutc, tempbuf);
529             }
530             else
531             {
532                outbuf[oldoutc] = '\0';
533             }
534             break;
535          default:
536             sprintf(outbuf, "IJB(%d) Error: log_error(): Bad format string:\n"
537                             "Format = \"%s\"\n"
538                             "Exiting.", this_thread, fmt);
539             /* FIXME RACE HAZARD: should start critical section error_log_use here */
540             if( !logfp )
541             {
542                logfp = stderr;
543             }
544             fputs(outbuf, logfp);
545             /* FIXME RACE HAZARD: should end critical section error_log_use here */
546             fatal_error(outbuf);
547             /* Never get here */
548             break;
549
550       } /* switch( p ) */
551
552    } /* for( p ... ) */
553    
554    /* done with var. args */
555    va_end( ap );
556    
557    if (outc >= BUFSIZ-2)
558    {
559       /* insufficient room for newline and trailing null. */
560
561       static const char warning[] = "... [too long, truncated]\n";
562
563       if (outc < BUFSIZ)
564       {
565          /* Need to add terminating null in this case. */
566          outbuf[outc] = '\0';
567       }
568
569       /* Truncate output */
570       outbuf[BUFSIZ - sizeof(warning)] = '\0';
571
572       /* Append warning */
573       strcat(outbuf, warning);
574    }
575    else
576    {
577       /* Add terminating newline and null */
578       outbuf[outc++] = '\n';
579       outbuf[outc] = '\0';
580    }
581
582    /* FIXME RACE HAZARD: should start critical section error_log_use here */
583
584    /* deal with glibc stupidity - it won't let you initialize logfp */
585    if( !logfp )
586    {
587       logfp = stderr;
588    }
589
590    fputs(outbuf, logfp);
591
592    if (loglevel == LOG_LEVEL_FATAL)
593    {
594       fatal_error(outbuf);
595       /* Never get here */
596    }
597
598    /* FIXME RACE HAZARD: should end critical section error_log_use here */
599
600 #if defined(_WIN32) && !defined(_WIN_CONSOLE)
601    /* Write to display */
602    LogPutString(outbuf);
603 #endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
604
605 }
606
607
608 #ifdef _WIN32
609 /*********************************************************************
610  *
611  * Function    :  w32_socket_strerr
612  *
613  * Description :  Translate the return value from WSAGetLastError()
614  *                into a string.
615  *
616  * Parameters  :
617  *          1  :  errcode = The return value from WSAGetLastError().
618  *          2  :  tmp_buf = A temporary buffer that might be used to
619  *                          store the string.
620  *
621  * Returns     :  String representing the error code.  This may be
622  *                a global string constant or a string stored in
623  *                tmp_buf.
624  *
625  *********************************************************************/
626 static char * w32_socket_strerr(int errcode, char * tmp_buf)
627 {
628 #define TEXT_FOR_ERROR(code,text) \
629    if (errcode == code)           \
630    {                              \
631       return #code " - " text;    \
632    }
633
634    TEXT_FOR_ERROR(WSAEACCES, "Permission denied")
635    TEXT_FOR_ERROR(WSAEADDRINUSE, "Address already in use.")
636    TEXT_FOR_ERROR(WSAEADDRNOTAVAIL, "Cannot assign requested address.");
637    TEXT_FOR_ERROR(WSAEAFNOSUPPORT, "Address family not supported by protocol family.");
638    TEXT_FOR_ERROR(WSAEALREADY, "Operation already in progress.");
639    TEXT_FOR_ERROR(WSAECONNABORTED, "Software caused connection abort.");
640    TEXT_FOR_ERROR(WSAECONNREFUSED, "Connection refused.");
641    TEXT_FOR_ERROR(WSAECONNRESET, "Connection reset by peer.");
642    TEXT_FOR_ERROR(WSAEDESTADDRREQ, "Destination address required.");
643    TEXT_FOR_ERROR(WSAEFAULT, "Bad address.");
644    TEXT_FOR_ERROR(WSAEHOSTDOWN, "Host is down.");
645    TEXT_FOR_ERROR(WSAEHOSTUNREACH, "No route to host.");
646    TEXT_FOR_ERROR(WSAEINPROGRESS, "Operation now in progress.");
647    TEXT_FOR_ERROR(WSAEINTR, "Interrupted function call.");
648    TEXT_FOR_ERROR(WSAEINVAL, "Invalid argument.");
649    TEXT_FOR_ERROR(WSAEISCONN, "Socket is already connected.");
650    TEXT_FOR_ERROR(WSAEMFILE, "Too many open sockets.");
651    TEXT_FOR_ERROR(WSAEMSGSIZE, "Message too long.");
652    TEXT_FOR_ERROR(WSAENETDOWN, "Network is down.");
653    TEXT_FOR_ERROR(WSAENETRESET, "Network dropped connection on reset.");
654    TEXT_FOR_ERROR(WSAENETUNREACH, "Network is unreachable.");
655    TEXT_FOR_ERROR(WSAENOBUFS, "No buffer space available.");
656    TEXT_FOR_ERROR(WSAENOPROTOOPT, "Bad protocol option.");
657    TEXT_FOR_ERROR(WSAENOTCONN, "Socket is not connected.");
658    TEXT_FOR_ERROR(WSAENOTSOCK, "Socket operation on non-socket.");
659    TEXT_FOR_ERROR(WSAEOPNOTSUPP, "Operation not supported.");
660    TEXT_FOR_ERROR(WSAEPFNOSUPPORT, "Protocol family not supported.");
661    TEXT_FOR_ERROR(WSAEPROCLIM, "Too many processes.");
662    TEXT_FOR_ERROR(WSAEPROTONOSUPPORT, "Protocol not supported.");
663    TEXT_FOR_ERROR(WSAEPROTOTYPE, "Protocol wrong type for socket.");
664    TEXT_FOR_ERROR(WSAESHUTDOWN, "Cannot send after socket shutdown.");
665    TEXT_FOR_ERROR(WSAESOCKTNOSUPPORT, "Socket type not supported.");
666    TEXT_FOR_ERROR(WSAETIMEDOUT, "Connection timed out.");
667    TEXT_FOR_ERROR(WSAEWOULDBLOCK, "Resource temporarily unavailable.");
668    TEXT_FOR_ERROR(WSAHOST_NOT_FOUND, "Host not found.");
669    TEXT_FOR_ERROR(WSANOTINITIALISED, "Successful WSAStartup not yet performed.");
670    TEXT_FOR_ERROR(WSANO_DATA, "Valid name, no data record of requested type.");
671    TEXT_FOR_ERROR(WSANO_RECOVERY, "This is a non-recoverable error.");
672    TEXT_FOR_ERROR(WSASYSNOTREADY, "Network subsystem is unavailable.");
673    TEXT_FOR_ERROR(WSATRY_AGAIN, "Non-authoritative host not found.");
674    TEXT_FOR_ERROR(WSAVERNOTSUPPORTED, "WINSOCK.DLL version out of range.");
675    TEXT_FOR_ERROR(WSAEDISCON, "Graceful shutdown in progress.");
676    /*
677     * The following error codes are documented in the Microsoft WinSock
678     * reference guide, but don't actually exist.
679     *
680     * TEXT_FOR_ERROR(WSA_INVALID_HANDLE, "Specified event object handle is invalid.");
681     * TEXT_FOR_ERROR(WSA_INVALID_PARAMETER, "One or more parameters are invalid.");
682     * TEXT_FOR_ERROR(WSAINVALIDPROCTABLE, "Invalid procedure table from service provider.");
683     * TEXT_FOR_ERROR(WSAINVALIDPROVIDER, "Invalid service provider version number.");
684     * TEXT_FOR_ERROR(WSA_IO_PENDING, "Overlapped operations will complete later.");
685     * TEXT_FOR_ERROR(WSA_IO_INCOMPLETE, "Overlapped I/O event object not in signaled state.");
686     * TEXT_FOR_ERROR(WSA_NOT_ENOUGH_MEMORY, "Insufficient memory available.");
687     * TEXT_FOR_ERROR(WSAPROVIDERFAILEDINIT, "Unable to initialize a service provider.");
688     * TEXT_FOR_ERROR(WSASYSCALLFAILURE, "System call failure.");
689     * TEXT_FOR_ERROR(WSA_OPERATION_ABORTED, "Overlapped operation aborted.");
690     */
691
692    sprintf(tmp_buf, "(error number %d)", errcode);
693    return tmp_buf;
694 }
695 #endif /* def _WIN32 */
696
697
698 /*
699   Local Variables:
700   tab-width: 3
701   end:
702 */
703