httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/file_io/win32 dir.c filedup.c fileio.h filestat.c open.c
Date Wed, 08 Nov 2000 22:26:54 GMT
wrowe       00/11/08 14:26:49

  Modified:    src/lib/apr/include apr_file_io.h
               src/lib/apr/file_io/unix fileacc.c
               src/lib/apr/file_io/win32 dir.c filedup.c fileio.h
                        filestat.c open.c
  Log:
    Catch up on some Unicode stuff that I've discovered while yanking around
    with canon names.  Mostly cleanups and NT vs. 9x fixups, plus some more
    useful canon types I'm playing with.  Hope to close this tommorow.
  
  Revision  Changes    Path
  1.72      +5 -0      apache-2.0/src/lib/apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- apr_file_io.h	2000/11/07 20:21:33	1.71
  +++ apr_file_io.h	2000/11/08 22:26:19	1.72
  @@ -123,8 +123,13 @@
   typedef apr_int32_t               apr_fileperms_t;
   typedef uid_t                    apr_uid_t;
   typedef gid_t                    apr_gid_t;
  +#ifdef WIN32
  +typedef apr_uint64_t             apr_ino_t;
  +typedef apr_uint32_t             apr_dev_t;
  +#else
   typedef ino_t                    apr_ino_t;
   typedef dev_t                    apr_dev_t;
  +#endif
   
   /**
    * The file information structure.  This is analogous to the POSIX
  
  
  
  1.38      +2 -5      apache-2.0/src/lib/apr/file_io/unix/fileacc.c
  
  Index: fileacc.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/fileacc.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- fileacc.c	2000/11/02 17:38:22	1.37
  +++ fileacc.c	2000/11/08 22:26:28	1.38
  @@ -68,9 +68,6 @@
   #else
   #include "fileio.h"
   #endif
  -#if APR_HAS_UNICODE_FS
  -#include "i18n.h"
  -#endif
   
   /* A file to put ALL of the accessor functions for apr_file_t types. */
   
  @@ -92,9 +89,9 @@
               return APR_ENAMETOOLONG;
       }
       else
  -#else /* !APR_HAS_UNICODE_FS */
  +#endif /* !APR_HAS_UNICODE_FS */
           *fname = apr_pstrdup(thefile->cntxt, thefile->n.fname);
  -#endif
  +
   #else /* !def Win32 */
           *fname = apr_pstrdup(thefile->cntxt, thefile->fname);
   #endif 
  
  
  
  1.31      +5 -7      apache-2.0/src/lib/apr/file_io/win32/dir.c
  
  Index: dir.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/dir.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- dir.c	2000/11/02 15:23:39	1.30
  +++ dir.c	2000/11/08 22:26:34	1.31
  @@ -57,9 +57,6 @@
   #include "apr_file_io.h"
   #include "apr_strings.h"
   #include "apr_portable.h"
  -#if APR_HAS_UNICODE_FS
  -#include "i18n.h"
  -#endif
   #include "atime.h"
   
   #if APR_HAVE_ERRNO_H
  @@ -94,16 +91,17 @@
       {
           apr_status_t rv;
           int lremains = len;
  -        int dremains = (len + 3) * 2;
  +        int dremains = len;
           (*new) = apr_pcalloc(cont, sizeof(apr_dir_t));
           (*new)->w.entry = apr_pcalloc(cont, sizeof(WIN32_FIND_DATAW));
  -        (*new)->w.dirname = apr_palloc(cont, dremains);
  +        (*new)->w.dirname = apr_palloc(cont, dremains + 7);
  +        wcscpy((*new)->w.dirname, L"//?/");
           if ((rv = conv_utf8_to_ucs2(dirname, &lremains,
  -                                     (*new)->w.dirname, &dremains)))
  +                                     (*new)->w.dirname + 4, &dremains)))
               return rv;
           if (lremains)
               return APR_ENAMETOOLONG;
  -        len = (len + 3) * 2 - dremains;
  +        len = len + 4 -  dremains;
           if (len && (*new)->w.dirname[len - 1] != '/') {
       	    (*new)->w.dirname[len++] = '/';
           }
  
  
  
  1.25      +0 -4      apache-2.0/src/lib/apr/file_io/win32/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/filedup.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- filedup.c	2000/11/02 15:23:40	1.24
  +++ filedup.c	2000/11/08 22:26:35	1.25
  @@ -57,10 +57,6 @@
   #include "apr_general.h"
   #include "apr_strings.h"
   #include <string.h>
  -#if APR_HAS_UNICODE_FS
  -#include "i18n.h"
  -#include <wchar.h>
  -#endif
   
   apr_status_t apr_dupfile(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p)
   {
  
  
  
  1.35      +14 -0     apache-2.0/src/lib/apr/file_io/win32/fileio.h
  
  Index: fileio.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/fileio.h,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- fileio.h	2000/11/02 15:23:42	1.34
  +++ fileio.h	2000/11/08 22:26:37	1.35
  @@ -89,14 +89,27 @@
   
   #define APR_FILE_BUFSIZE 4096
   
  +#if APR_HAS_UNICODE_FS
  +#include "i18n.h"
  +#include <wchar.h>
  +
   typedef apr_int16_t apr_wchar_t;
   
  +apr_wchar_t *utf8_to_unicode_path(const char* srcstr, apr_pool_t *p);
  +#endif
  +
   typedef enum apr_canon_case_e {
       APR_CANON_CASE_GIVEN,
       APR_CANON_CASE_LOWER,
       APR_CANON_CASE_TRUE
   } apr_canon_case_e;
   
  +typedef enum apr_canon_path_e {
  +    APR_CANON_PATH_VIRUTAL,
  +    APR_CANON_PATH_ABSOLUTE,
  +    APR_CANON_PATH_RELATIVE
  +} apr_canon_path_e;
  +
   /*
    * Internal canonical filename elements for the apr_canon_t elems
    *  ccase   tracks the mechanism used to resolve this element
  @@ -117,6 +130,7 @@
   struct apr_canon_t {
       apr_pool_t *cntxt;
       apr_array_header_t *elems;
  +    apr_canon_path_e type;
   };
   
   /* quick run-down of fields in windows' apr_file_t structure that may have 
  
  
  
  1.32      +11 -28    apache-2.0/src/lib/apr/file_io/win32/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/filestat.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- filestat.c	2000/11/02 15:23:43	1.31
  +++ filestat.c	2000/11/08 22:26:38	1.32
  @@ -58,31 +58,10 @@
   #include "apr_general.h"
   #include "apr_errno.h"
   #include "apr_time.h"
  -#if APR_HAS_UNICODE_FS
  -#include "i18n.h"
  -#endif
   #include <sys/stat.h>
   #include "atime.h"
   #include "misc.h"
   
  -/* XXX: this is wrong for W2K */
  -#define S_ISLNK(m)  (0)
  -#define S_ISREG(m)  (((m) & (S_IFMT))  == S_IFREG)
  -#define S_ISDIR(m)  (((m) & (S_IFDIR)) == S_IFDIR)
  -
  -static apr_filetype_e filetype_from_mode(int mode)
  -{
  -    apr_filetype_e type = APR_NOFILE;
  -
  -    if (S_ISREG(mode))
  -        type = APR_REG;
  -    if (S_ISDIR(mode))
  -        type = APR_DIR;
  -    if (S_ISLNK(mode))
  -        type = APR_LNK;
  -
  -    return type;
  -}
   
   BOOLEAN is_exe(const char* fname, apr_pool_t *cont) {
       /*
  @@ -125,20 +104,22 @@
   
       /* If my rudimentary knowledge of posix serves... inode is the absolute
        * id of the file (uniquifier) that is returned by NT as follows:
  -     * user and group could be related as SID's, although this would ensure
  -     * it's own unique set of issues.  All three fields are significantly
  -     * longer than the posix compatible kernals would ever require.
  -     * TODO: Someday solve this, and fix the executable flag below the
  -     * right way with a security permission test (as well as r/w flags.)
        *
        *     dwVolumeSerialNumber
        *     nFileIndexHigh
        *     nFileIndexLow
  +     *
  +     * user and group could be returned as SID's, although this creates
  +     * it's own unique set of issues.  All three fields are significantly
  +     * longer than the posix compatible kernals would ever require.
  +     * TODO: Someday solve this, and fix the executable flag below the
  +     * right way with a security permission test (as well as r/w flags.)
        */
       finfo->user = 0;
       finfo->group = 0;
  -    finfo->inode = 0;
  -    finfo->device = 0;  /* ### use drive letter - 'A' ? */
  +    finfo->inode = (apr_ino_t) FileInformation.nFileIndexHigh << 16
  +                             | FileInformation.nFileIndexLow;
  +    finfo->device = FileInformation.dwVolumeSerialNumber;
   
       /* Filetype - Directory or file: this case _will_ never happen */
       if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  @@ -160,6 +141,7 @@
   #else
           finfo->protection = S_IFIFO;
   #endif
  +        finfo->filetype = APR_PIPE;
       }
       else {
           finfo->protection = 0;
  @@ -212,6 +194,7 @@
   #if APR_HAS_UNICODE_FS
       if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
       {
  +        
           apr_wchar_t wname[MAX_PATH];
           int len = MAX_PATH;
           int lremains = strlen(fname) + 1;
  
  
  
  1.54      +67 -62    apache-2.0/src/lib/apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/open.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- open.c	2000/11/02 15:23:44	1.53
  +++ open.c	2000/11/08 22:26:41	1.54
  @@ -63,9 +63,23 @@
   #include <string.h>
   #include <sys/stat.h>
   #include "misc.h"
  -#if APR_HAS_UNICODE_FS
  -#include "i18n.h"
  -#endif
  +
  +apr_wchar_t *utf8_to_unicode_path(const char* srcstr, apr_pool_t *p)
  +{
  +    /* TODO: The computations could preconvert the string to determine
  +     * the true size of the retstr, but that's a memory over speed
  +     * tradeoff that isn't appropriate this early in development.
  +     */
  +    int srcremains = strlen(srcstr) + 1;
  +    int retremains = srcremains + 4;
  +    apr_wchar_t *retstr = apr_palloc(p, retremains * 2);
  +    wcscpy (retstr, L"//?/");
  +    if (conv_utf8_to_ucs2(srcstr, &srcremains,
  +                          retstr + 4, &retremains) || srcremains)
  +        return NULL;
  +    else
  +        return retstr;
  +}
   
   apr_status_t file_cleanup(void *thefile)
   {
  @@ -85,12 +99,8 @@
       DWORD createflags = 0;
       DWORD attributes = 0;
       DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE;
  -    apr_oslevel_e level;
  +    apr_oslevel_e os_level;
       apr_status_t rv;
  -#if APR_HAS_UNICODE_FS
  -    int lremains = strlen(fname) + 1;
  -    int dremains = (lremains) * 2;
  -#endif
   
       (*new) = (apr_file_t *)apr_pcalloc(cont, sizeof(apr_file_t));
       (*new)->cntxt = cont;
  @@ -115,20 +125,23 @@
           if (rv)
               return rv;
       }
  -#if APR_HAS_UNICODE_FS
  -    (*new)->w.fname = apr_palloc(cont, dremains);
  -    if ((rv = conv_utf8_to_ucs2(fname, &lremains,
  -                                (*new)->w.fname, &dremains)))
  -        return rv;
  -    if (lremains)
  -        return APR_ENAMETOOLONG;
  -#else
  -    (*new)->n.fname = apr_pstrdup(cont, fname);
  -#endif
   
  -    if (apr_get_oslevel(cont, &level) == APR_SUCCESS && level >= APR_WIN_NT)
{
  +    if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT) 
           sharemode |= FILE_SHARE_DELETE;
  +    else
  +        os_level = 0;
  +
  +#if APR_HAS_UNICODE_FS
  +    if (os_level >= APR_WIN_NT) 
  +    {
  +        (*new)->w.fname = utf8_to_unicode_path(fname, cont);
  +        if (!(*new)->w.fname)
  +            /* XXX: really bad file name */
  +            return APR_ENAMETOOLONG;
       }
  +    else
  +#endif
  +        (*new)->n.fname = apr_pstrdup(cont, fname);
   
       if (flag & APR_CREATE) {
           if (flag & APR_EXCL) {
  @@ -167,12 +180,13 @@
       }
   
   #if APR_HAS_UNICODE_FS
  -    (*new)->filehand = CreateFileW((*new)->w.fname, oflags, sharemode,
  -                                   NULL, createflags, attributes, 0);
  -#else
  -    (*new)->filehand = CreateFile((*new)->n.fname, oflags, sharemode,
  -                                  NULL, createflags, attributes, 0);
  +    if (os_level >= APR_WIN_NT) 
  +        (*new)->filehand = CreateFileW((*new)->w.fname, oflags, sharemode,
  +                                       NULL, createflags, attributes, 0);
  +    else
   #endif
  +        (*new)->filehand = CreateFile((*new)->n.fname, oflags, sharemode,
  +                                      NULL, createflags, attributes, 0);
       if ((*new)->filehand == INVALID_HANDLE_VALUE) {
           return apr_get_os_error();
       }
  @@ -213,51 +227,42 @@
   apr_status_t apr_remove_file(const char *path, apr_pool_t *cont)
   {
   #if APR_HAS_UNICODE_FS
  -    apr_wchar_t wpath[MAX_PATH];
  -    int lremains = strlen(path) + 1;
  -    int dremains = MAX_PATH;
  -    apr_status_t rv;
  -    if ((rv = conv_utf8_to_ucs2(path, &lremains,
  -                                wpath, &dremains)))
  -        return rv;
  -    if (lremains)
  -        return APR_ENAMETOOLONG;
  -    if (DeleteFileW(wpath))
  -#else
  -    if (DeleteFile(path))
  +    apr_oslevel_e os_level;
  +    if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT) 
  +    {
  +        apr_wchar_t *wpath = utf8_to_unicode_path(path, cont);
  +        if (!wpath)
  +            return APR_ENAMETOOLONG;
  +        if (DeleteFileW(wpath))
  +            return APR_SUCCESS;
  +    }
  +    else
   #endif
  -        return APR_SUCCESS;
  +        if (DeleteFile(path))
  +            return APR_SUCCESS;
       return apr_get_os_error();
   }
   
   apr_status_t apr_rename_file(const char *from_path, const char *to_path,
  -                           apr_pool_t *p)
  +                             apr_pool_t *cont)
   {
   #if APR_HAS_UNICODE_FS
  -    apr_wchar_t wfrompath[MAX_PATH];
  -    apr_wchar_t wtopath[MAX_PATH];
  -    int lremains = strlen(from_path) + 1;
  -    int dremains = MAX_PATH;
  -    apr_status_t rv;
  -    if ((rv = conv_utf8_to_ucs2(from_path, &lremains,
  -                                wfrompath, &dremains)))
  -        return rv;
  -    if (lremains)
  -        return APR_ENAMETOOLONG;
  -    lremains = strlen(to_path) + 1;
  -    dremains = MAX_PATH;
  -    if ((rv = conv_utf8_to_ucs2(to_path, &lremains,
  -                                wtopath, &dremains)))
  -        return rv;
  -    if (lremains)
  -        return APR_ENAMETOOLONG;
  -    if (MoveFileExW(wfrompath, wtopath, MOVEFILE_REPLACE_EXISTING |
  -                                        MOVEFILE_COPY_ALLOWED))
  -#else
  -    if (MoveFileEx(from_path, to_path, MOVEFILE_REPLACE_EXISTING |
  -                                        MOVEFILE_COPY_ALLOWED))
  -#endif
  -        return APR_SUCCESS;
  +    apr_oslevel_e os_level;
  +    if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT) 
  +    {
  +        apr_wchar_t *wfrompath = utf8_to_unicode_path(from_path, cont);
  +        apr_wchar_t *wtopath = utf8_to_unicode_path(to_path, cont);
  +        if (!wfrompath || !wtopath)
  +            return APR_ENAMETOOLONG;
  +        if (MoveFileExW(wfrompath, wtopath, MOVEFILE_REPLACE_EXISTING |
  +                                            MOVEFILE_COPY_ALLOWED))
  +            return APR_SUCCESS;
  +    }
  +    else
  +#endif
  +        if (MoveFileEx(from_path, to_path, MOVEFILE_REPLACE_EXISTING |
  +                                           MOVEFILE_COPY_ALLOWED))
  +            return APR_SUCCESS;
       return apr_get_os_error();
   }
   
  
  
  

Mime
View raw message