httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/misc/win32 errorcodes.c
Date Wed, 26 Apr 2000 01:54:35 GMT
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;
   }
   
  
  
  

Mime
View raw message