You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2001/09/04 23:20:57 UTC

cvs commit: apr/misc/unix errorcodes.c

wrowe       01/09/04 14:20:57

  Modified:    dso/win32 dso.c
               misc/unix errorcodes.c
  Log:
    Some message is better than no message.  Modified the lookup to show
    %n substitutions untranslated, and return real (viewable) error code
    from DSO load failure, both for Win32.
  
  Revision  Changes    Path
  1.23      +16 -13    apr/dso/win32/dso.c
  
  Index: dso.c
  ===================================================================
  RCS file: /home/cvs/apr/dso/win32/dso.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- dso.c	2001/08/02 03:15:56	1.22
  +++ dso.c	2001/09/04 21:20:57	1.23
  @@ -75,6 +75,7 @@
                                          const char *path, apr_pool_t *ctx)
   {
       HINSTANCE os_handle;
  +    apr_status_t rv;
       UINT em;
   
   #if APR_HAS_UNICODE_FS
  @@ -82,16 +83,19 @@
       if (!apr_get_oslevel(ctx, &os_level) && os_level >= APR_WIN_NT) 
       {
           apr_wchar_t wpath[APR_PATH_MAX];
  -        apr_status_t rv;
  -        if (rv = utf8_to_unicode_path(wpath, sizeof(wpath) 
  -                                              / sizeof(apr_wchar_t), path)) {
  -            return rv;
  +        if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) 
  +                                            / sizeof(apr_wchar_t), path))
  +                != APR_SUCCESS) {
  +            *res_handle = apr_pcalloc(ctx, sizeof(**res_handle));
  +            return ((*res_handle)->load_error = rv);
           }
           /* Prevent ugly popups from killing our app */
           em = SetErrorMode(SEM_FAILCRITICALERRORS);
           os_handle = LoadLibraryExW(wpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
           if (!os_handle)
               os_handle = LoadLibraryExW(wpath, NULL, 0);
  +        if (!os_handle)
  +            rv = apr_get_os_error();
           SetErrorMode(em);
       }
       else
  @@ -105,7 +109,7 @@
            * that backslashes must be used for the LoadLibrary family of calls.
            */
           apr_cpystrn(fspec, path, sizeof(fspec));
  -        while (p = strchr(p, '/'))
  +        while ((p = strchr(p, '/')) != NULL)
               *p = '\\';
           
           /* Prevent ugly popups from killing our app */
  @@ -113,13 +117,14 @@
           os_handle = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
           if (!os_handle)
               os_handle = LoadLibraryEx(path, NULL, 0);
  +        if (!os_handle)
  +            rv = apr_get_os_error();
           SetErrorMode(em);
       }
       *res_handle = apr_pcalloc(ctx, sizeof(**res_handle));
   
  -    if(os_handle == NULL) {
  -        (*res_handle)->load_error = apr_get_os_error();
  -        return (*res_handle)->load_error;
  +    if (rv) {
  +        return ((*res_handle)->load_error = rv);
       }
   
       (*res_handle)->handle = (void*)os_handle;
  @@ -140,13 +145,11 @@
                            struct apr_dso_handle_t *handle, 
                            const char *symname)
   {
  -    FARPROC retval = GetProcAddress(handle->handle, symname);
  -    if (!retval) {
  +    *ressym = (apr_dso_handle_sym_t)GetProcAddress(handle->handle, symname);
  +
  +    if (!*ressym) {
           return apr_get_os_error();
       }
  -    
  -    *ressym = retval;
  -    
       return APR_SUCCESS;
   }
   
  
  
  
  1.43      +3 -2      apr/misc/unix/errorcodes.c
  
  Index: errorcodes.c
  ===================================================================
  RCS file: /home/cvs/apr/misc/unix/errorcodes.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- errorcodes.c	2001/08/29 15:20:24	1.42
  +++ errorcodes.c	2001/09/04 21:20:57	1.43
  @@ -279,7 +279,8 @@
       apr_size_t len=0, i;
   
   #ifndef NETWARE
  -    len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
  +    len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM 
  +                      | FORMAT_MESSAGE_IGNORE_INSERTS,
                           NULL,
                           errcode,
                           MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
  @@ -315,7 +316,7 @@
       else {
           /* Windows didn't provide us with a message.  Even stuff like                    * WSAECONNREFUSED won't get a message.
            */
  -        apr_cpystrn(buf, "Unrecognized error code", bufsize);
  +        apr_snprintf(buf, bufsize, "Unrecognized Win32 error code %d", errcode);
       }
   
       return buf;