You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@locus.apache.org on 2000/04/20 00:39:35 UTC

cvs commit: apache-2.0/src/lib/apr/misc/unix errorcodes.c Makefile.in

rbb         00/04/19 15:39:35

  Modified:    src/lib/apr/include apr_errno.h apr_general.h
               src/lib/apr/misc/unix Makefile.in
  Added:       src/lib/apr/misc/unix errorcodes.c
  Log:
  First pass at ap_strerrot.  This is probably broken somewhere, but it compiles
  on Linux, and seems to work most of the time.  This also provides an error
  string for every APR error and status code.
  
  Revision  Changes    Path
  1.26      +7 -6      apache-2.0/src/lib/apr/include/apr_errno.h
  
  Index: apr_errno.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_errno.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- apr_errno.h	2000/04/19 22:32:06	1.25
  +++ apr_errno.h	2000/04/19 22:39:33	1.26
  @@ -52,8 +52,9 @@
    * <http://www.apache.org/>.
    */
   
  -#include <errno.h>
  +#include "apr_general.h"
   #include "apr.h"
  +#include <errno.h>
   
   #ifndef APR_ERRNO_H
   #define APR_ERRNO_H
  @@ -62,6 +63,11 @@
   extern "C" {
   #endif /* __cplusplus */
   
  +typedef int ap_status_t;
  +
  +int ap_canonical_error(ap_status_t err);
  +
  +
   /* APR_OS_START_ERROR is where the APR specific error values should start.
    * APR_OS_START_STATUS is where the APR specific status codes should start.
    * APR_OS_START_USEERR are reserved for applications that use APR that
  @@ -74,11 +80,6 @@
   #define APR_OS_START_USEERR    (APR_OS_START_STATUS + 500)
   #define APR_OS_START_CANONERR  (APR_OS_START_USEERR + 500)
   #define APR_OS_START_SYSERR    (APR_OS_START_CANONERR + 500)
  -
  -typedef int ap_status_t;
  -
  -int ap_canonical_error(ap_status_t err);
  -const char *ap_strerror(ap_status_t err);
   
   #define APR_OS2_STATUS(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
   
  
  
  
  1.27      +13 -0     apache-2.0/src/lib/apr/include/apr_general.h
  
  Index: apr_general.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_general.h,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- apr_general.h	2000/04/16 04:46:53	1.26
  +++ apr_general.h	2000/04/19 22:39:34	1.27
  @@ -357,6 +357,19 @@
    */
   ap_status_t ap_set_abort(int (*apr_abort)(int retcode), ap_pool_t *cont);
   
  +/*
  +
  +=head1 const char *ap_strerror(ap_status_t statcode, ap_pool_t *p)
  +
  +B<Return a human readable string describing the specified error.>
  +
  +    arg 1)  The error code the get a string for.
  +    arg 2)  The pool to use to allocate memory for the string.
  +
  +=cut
  + */
  +const char *ap_strerror(ap_status_t statcode, ap_pool_t *p);
  +
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.13      +1 -1      apache-2.0/src/lib/apr/misc/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/unix/Makefile.in,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Makefile.in	2000/04/15 19:05:13	1.12
  +++ Makefile.in	2000/04/19 22:39:34	1.13
  @@ -15,7 +15,7 @@
   
   #LIB=libmisc.a
   
  -OBJS=start.o getopt.o otherchild.o error.o rand.o
  +OBJS=start.o getopt.o otherchild.o errorcodes.o rand.o
   
   .c.o:
   	$(CC) $(CFLAGS) -c $(INCLUDES) $<
  
  
  
  1.1                  apache-2.0/src/lib/apr/misc/unix/errorcodes.c
  
  Index: errorcodes.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "misc.h"
  
  #ifdef WIN32
  #error "not implemented yet"
  #elif OS/2
  #error "not implemented yet"
  #elif BEOS    
  #error "not implemented yet"
  #else
  #define SYS_ERR_STRING(code, p) \
      errstr = strerror(code);
  #endif
  
  static const char *apr_error_string(ap_status_t statcode)
  {
      switch (statcode) {
      case APR_ENOPOOL:
          return "A new pool could not be created.";
      case APR_ENOFILE:
          return "No file was provided and one was required.";
      case APR_EBADDATE:
          return "An invalid date has been provided";
      case APR_EINVALSOCK:
          return "An invalid socket was returned";
      case APR_ENOPROC:
          return "No process was provided and one was required.";
      case APR_ENOTIME:
          return "No time was provided and one was required.";
      case APR_ENODIR:
          return "No directory was provided and one was required.";
      case APR_ENOLOCK:
          return "No lock was provided and one was required.";
      case APR_ENOPOLL:
          return "No poll structure was provided and one was required.";
      case APR_ENOSOCKET:
          return "No socket was provided and one was required.";
      case APR_ENOTHREAD:
          return "No thread was provided and one was required.";
      case APR_ENOTHDKEY:
          return "No thread key structure was provided and one was required.";
      case APR_ENOSHMAVAIL:
          return "No shared memory is currently available";
      case APR_EDSOOPEN:
          return "Could not open the dso.";
      case APR_INCHILD:
          return "Your code just forked, and you are currently executing in the child process";
      case APR_INPARENT:
          return "Your code just forked, and you are currently executing in the parent process";
      case APR_DETACH:
          return "The specified thread is detached";
      case APR_NOTDETACH:
          return "The specified thread is not detached";
      case APR_CHILD_DONE:
          return "The specified child process is done executing";
      case APR_CHILD_NOTDONE:
          return "The specified child process is not done executing";
      case APR_TIMEUP:
          return "The timeout specified has expired";
      case APR_BADCH:
          return "Bad character specified on command line";
      case APR_BADARG:
          return "Missing parameter for the specified command line option";
      case APR_EOF:
          return "End of file found";
      case APR_NOTFOUND:
          return "Could not find specified socket in poll list.";
      case APR_ANONYMOUS:
          return "Shared memory is implemented anonymously";
      case APR_FILEBASED:
          return "Shared memory is implemented using files";
      case APR_KEYBASED:
          return "Shared memory is implemented using a key system";
      case APR_EINIT:
          return "There is no error, this value signifies an initialized error code";
      case APR_ENOTIMPL:
          return "This function has not been implemented on this platform";
      case APR_EMISMATCH:
          return "passwords do not match";
  /* EBADARG needs to be removed soon.  */
      case APR_EBADARG:
      default:
          return "Error string not specified yet";
      }
  }
  
  const char *ap_strerror(ap_status_t statcode, ap_pool_t *p)
  {
      if (statcode < APR_OS_START_ERROR) {
          return strerror(statcode);
      }
      else if (statcode < APR_OS_START_USEERR) {
          return apr_error_string(statcode);
      }
      else if (statcode < APR_OS_START_SYSERR) {
          return "APR does not understand this error code";
      }
      else {
          char *errstr;
          SYS_ERR_STRING(statcode - APR_OS_START_SYSERR, p);
          return errstr;
      }
  }