Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 92302 invoked by uid 500); 26 Apr 2000 01:54:36 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 92283 invoked by uid 500); 26 Apr 2000 01:54:35 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 26 Apr 2000 01:54:35 -0000 Message-ID: <20000426015435.92279.qmail@locus.apache.org> From: stoddard@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/lib/apr/misc/win32 errorcodes.c stoddard 00/04/25 18:54:34 Modified: src/lib/apr/misc/win32 errorcodes.c Log: Win32: Get ap_strerror working on Windows (for Win32 system errors anyway) Revision Changes Path 1.5 +26 -2 apache-2.0/src/lib/apr/misc/win32/errorcodes.c Index: errorcodes.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/win32/errorcodes.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- errorcodes.c 2000/04/24 21:02:07 1.4 +++ errorcodes.c 2000/04/26 01:54:34 1.5 @@ -132,9 +132,33 @@ } } -static char *ap_os_format_message(ap_status_t code, char *buf, size_t bufsize) +static char *ap_os_format_message(ap_status_t errcode, char *buf, size_t bufsize) { - strcpy(buf, "Not implemented"); + DWORD len; + DWORD i; + + buf = ""; + + len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + errcode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ + (LPTSTR) buf, + bufsize, + NULL); + + /* FormatMessage put the message in the buffer, but it may + * have embedded a newline (\r\n), and possible more than one. + * Remove the newlines replacing them with a space. This is not + * as visually perfect as moving all the remaining message over, + * but more efficient. + */ + i = len; + while (i) { + i--; + if ((buf[i] == '\r') || (buf[i] == '\n')) + buf[i] = ' '; + } return buf; }