*) autoconfigure struct dirent capabilities

*) move src/os/.../ngx_types.h's content into src/os/.../ngx_files.h and
   delete src/os/.../ngx_types.h
This commit is contained in:
Igor Sysoev 2008-09-05 15:43:34 +00:00
parent 5d4e80b8fb
commit dfc8dadd04
9 changed files with 113 additions and 86 deletions

View File

@ -131,7 +131,6 @@ UNIX_INCS="$CORE_INCS $EVENT_INCS src/os/unix"
UNIX_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/unix/ngx_time.h \
src/os/unix/ngx_types.h \
src/os/unix/ngx_errno.h \
src/os/unix/ngx_alloc.h \
src/os/unix/ngx_files.h \
@ -208,7 +207,6 @@ WIN32_INCS="$CORE_INCS $EVENT_INCS src/os/win32"
WIN32_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/win32/ngx_win32_config.h \
src/os/win32/ngx_time.h \
src/os/win32/ngx_types.h \
src/os/win32/ngx_errno.h \
src/os/win32/ngx_alloc.h \
src/os/win32/ngx_files.h \

View File

@ -229,3 +229,23 @@ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0"
. auto/feature
ngx_feature="struct dirent.d_namlen"
ngx_feature_name="NGX_HAVE_D_NAMLEN"
ngx_feature_run=no
ngx_feature_incs="#include <dirent.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct dirent dir; dir.d_namlen = 0"
. auto/feature
ngx_feature="struct dirent.d_type"
ngx_feature_name="NGX_HAVE_D_TYPE"
ngx_feature_run=no
ngx_feature_incs="#include <dirent.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct dirent dir; dir.d_type = DT_REG"
. auto/feature

View File

@ -40,11 +40,11 @@ typedef void (*ngx_connection_handler_pt)(ngx_connection_t *c);
#include <ngx_rbtree.h>
#include <ngx_time.h>
#include <ngx_socket.h>
#include <ngx_types.h>
#include <ngx_string.h>
#include <ngx_files.h>
#include <ngx_shmem.h>
#include <ngx_process.h>
#include <ngx_user.h>
#include <ngx_string.h>
#include <ngx_parse.h>
#include <ngx_log.h>
#include <ngx_alloc.h>
@ -55,7 +55,6 @@ typedef void (*ngx_connection_handler_pt)(ngx_connection_t *c);
#include <ngx_list.h>
#include <ngx_hash.h>
#include <ngx_file.h>
#include <ngx_files.h>
#include <ngx_crc.h>
#include <ngx_crc32.h>
#if (NGX_PCRE)

View File

@ -249,11 +249,32 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
}
dir->valid_info = 0;
#if (NGX_HAVE_D_TYPE)
dir->valid_type = 1;
#else
dir->valid_type = 0;
#endif
return NGX_OK;
}
ngx_int_t
ngx_read_dir(ngx_dir_t *dir)
{
dir->de = readdir(dir->dir);
if (dir->de) {
#if (NGX_HAVE_D_TYPE)
dir->type = dir->de->d_type;
#endif
return NGX_OK;
}
return NGX_ERROR;
}
ngx_int_t
ngx_open_glob(ngx_glob_t *gl)
{

View File

@ -12,6 +12,31 @@
#include <ngx_core.h>
typedef int ngx_fd_t;
typedef struct stat ngx_file_info_t;
typedef ino_t ngx_file_uniq_t;
typedef struct {
DIR *dir;
struct dirent *de;
struct stat info;
unsigned type:8;
unsigned valid_info:1;
unsigned valid_type:1;
} ngx_dir_t;
typedef struct {
size_t n;
glob_t pglob;
u_char *pattern;
ngx_log_t *log;
ngx_uint_t test;
} ngx_glob_t;
#define NGX_INVALID_FILE -1
#define NGX_FILE_ERROR -1
@ -135,8 +160,7 @@ ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#define ngx_close_dir_n "closedir()"
#define ngx_read_dir(d) \
(((d)->de = readdir((d)->dir)) ? NGX_OK : NGX_ERROR)
ngx_int_t ngx_read_dir(ngx_dir_t *dir);
#define ngx_read_dir_n "readdir()"
@ -152,7 +176,7 @@ ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#define ngx_de_name(dir) ((u_char *) (dir)->de->d_name)
#if (NGX_FREEBSD)
#if (NGX_HAVE_D_NAMLEN)
#define ngx_de_namelen(dir) (dir)->de->d_namlen
#else
#define ngx_de_namelen(dir) ngx_strlen((dir)->de->d_name)
@ -161,23 +185,26 @@ ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#define ngx_de_info_n "stat()"
#define ngx_de_link_info(name, dir) lstat((const char *) name, &(dir)->info)
#define ngx_de_link_info_n "lstat()"
#if (NGX_HAVE_D_TYPE)
#define ngx_de_is_dir(dir) ((dir)->type == DT_DIR)
#define ngx_de_is_file(dir) ((dir)->type == DT_REG)
#define ngx_de_is_link(dir) ((dir)->type == DT_LINK)
#else
#define ngx_de_is_dir(dir) (S_ISDIR((dir)->info.st_mode))
#define ngx_de_is_file(dir) (S_ISREG((dir)->info.st_mode))
#define ngx_de_is_link(dir) (S_ISLNK((dir)->info.st_mode))
#endif
#define ngx_de_access(dir) (((dir)->info.st_mode) & 0777)
#define ngx_de_size(dir) (dir)->info.st_size
#define ngx_de_mtime(dir) (dir)->info.st_mtime
typedef struct {
size_t n;
glob_t pglob;
u_char *pattern;
ngx_log_t *log;
ngx_uint_t test;
} ngx_glob_t;
ngx_int_t ngx_open_glob(ngx_glob_t *gl);
#define ngx_open_glob_n "glob()"
ngx_int_t ngx_read_glob(ngx_glob_t *gl, ngx_str_t *name);

View File

@ -1,27 +0,0 @@
/*
* Copyright (C) Igor Sysoev
*/
#ifndef _NGX_TYPES_H_INCLUDED_
#define _NGX_TYPES_H_INCLUDED_
#include <ngx_config.h>
typedef int ngx_fd_t;
typedef struct stat ngx_file_info_t;
typedef ino_t ngx_file_uniq_t;
typedef struct {
DIR *dir;
struct dirent *de;
struct stat info;
ngx_uint_t valid_info:1; /* unsigned valid_info:1; */
} ngx_dir_t;
#endif /* _NGX_TYPES_H_INCLUDED_ */

View File

@ -330,6 +330,7 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
}
dir->valid_info = 1;
dir->valid_type = 1;
dir->ready = 1;
return NGX_OK;

View File

@ -12,6 +12,36 @@
#include <ngx_core.h>
typedef HANDLE ngx_fd_t;
typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t;
typedef uint64_t ngx_file_uniq_t;
typedef struct {
HANDLE dir;
WIN32_FIND_DATA finddata;
unsigned valid_info:1;
unsigned valid_type:1;
unsigned ready:1;
} ngx_dir_t;
typedef struct {
HANDLE dir;
WIN32_FIND_DATA finddata;
unsigned ready:1;
unsigned test:1;
unsigned no_match:1;
u_char *pattern;
ngx_str_t name;
size_t last;
ngx_log_t *log;
} ngx_glob_t;
/* INVALID_FILE_ATTRIBUTES is specified but not defined at least in MSVC6SP2 */
#ifndef INVALID_FILE_ATTRIBUTES
#define INVALID_FILE_ATTRIBUTES 0xffffffff
@ -184,20 +214,6 @@ ngx_int_t ngx_de_link_info(u_char *name, ngx_dir_t *dir);
| (dir)->finddata.ftLastWriteTime.dwLowDateTime) \
- 116444736000000000) / 10000000)
typedef struct {
HANDLE dir;
WIN32_FIND_DATA finddata;
unsigned ready:1;
unsigned test:1;
unsigned no_match:1;
u_char *pattern;
ngx_str_t name;
size_t last;
ngx_log_t *log;
} ngx_glob_t;
ngx_int_t ngx_open_glob(ngx_glob_t *gl);
#define ngx_open_glob_n "FindFirstFile()"

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) Igor Sysoev
*/
#ifndef _NGX_TYPES_H_INCLUDED_
#define _NGX_TYPES_H_INCLUDED_
#include <ngx_config.h>
#include <ngx_core.h>
typedef HANDLE ngx_fd_t;
typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t;
typedef uint64_t ngx_file_uniq_t;
typedef struct {
HANDLE dir;
WIN32_FIND_DATA finddata;
unsigned valid_info:1;
unsigned ready:1;
} ngx_dir_t;
#endif /* _NGX_TYPES_H_INCLUDED_ */