diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2006-10-02 08:46:45 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2006-10-02 08:46:45 +0000 |
| commit | 97c2f469c342566121bb792c45e8333ad941fb14 (patch) | |
| tree | bcfa00dd6d977982facbd891857dd9d7e15df686 /src/os/unix | |
| parent | 97c7e1a98621857a5eb2d44c477f7f6384417b52 (diff) | |
| download | nginx-97c2f469c342566121bb792c45e8333ad941fb14.tar.gz nginx-97c2f469c342566121bb792c45e8333ad941fb14.tar.bz2 | |
glob support in include
Diffstat (limited to 'src/os/unix')
| -rw-r--r-- | src/os/unix/ngx_files.c | 34 | ||||
| -rw-r--r-- | src/os/unix/ngx_files.h | 14 | ||||
| -rw-r--r-- | src/os/unix/ngx_freebsd_config.h | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_linux_config.h | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_posix_config.h | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_solaris_config.h | 1 |
6 files changed, 52 insertions, 0 deletions
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c index 1801045ab..12e595ee8 100644 --- a/src/os/unix/ngx_files.c +++ b/src/os/unix/ngx_files.c @@ -253,6 +253,40 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir) } +ngx_int_t +ngx_open_glob(ngx_glob_t *gl) +{ + if (glob((char *) gl->pattern, 0, NULL, &gl->pglob) == 0) { + return NGX_OK; + } + + return NGX_ERROR; +} + + +ngx_int_t +ngx_read_glob(ngx_glob_t *gl, ngx_str_t *name) +{ + if (gl->n < gl->pglob.gl_pathc) { + + name->len = (size_t) ngx_strlen(gl->pglob.gl_pathv[gl->n]); + name->data = (u_char *) gl->pglob.gl_pathv[gl->n]; + gl->n++; + + return NGX_OK; + } + + return NGX_DONE; +} + + +void +ngx_close_glob(ngx_glob_t *gl) +{ + globfree(&gl->pglob); +} + + ngx_err_t ngx_trylock_fd(ngx_fd_t fd) { diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h index ff2515699..3e1e22519 100644 --- a/src/os/unix/ngx_files.h +++ b/src/os/unix/ngx_files.h @@ -130,6 +130,20 @@ ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir); #define ngx_de_mtime(dir) (dir)->info.st_mtime +typedef struct { + int n; + glob_t pglob; + u_char *pattern; + ngx_log_t *log; +} 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); +void ngx_close_glob(ngx_glob_t *gl); + + ngx_err_t ngx_trylock_fd(ngx_fd_t fd); ngx_err_t ngx_lock_fd(ngx_fd_t fd); ngx_err_t ngx_unlock_fd(ngx_fd_t fd); diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h index c187191b9..a4e973dc3 100644 --- a/src/os/unix/ngx_freebsd_config.h +++ b/src/os/unix/ngx_freebsd_config.h @@ -21,6 +21,7 @@ #include <pwd.h> #include <grp.h> #include <dirent.h> +#include <glob.h> #include <sys/filio.h> /* FIONBIO */ #include <sys/uio.h> diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h index 74bbfb1bd..980e05d67 100644 --- a/src/os/unix/ngx_linux_config.h +++ b/src/os/unix/ngx_linux_config.h @@ -27,6 +27,7 @@ #include <pwd.h> #include <grp.h> #include <dirent.h> +#include <glob.h> #include <sys/uio.h> #include <sys/stat.h> diff --git a/src/os/unix/ngx_posix_config.h b/src/os/unix/ngx_posix_config.h index 984db9670..8a9509960 100644 --- a/src/os/unix/ngx_posix_config.h +++ b/src/os/unix/ngx_posix_config.h @@ -37,6 +37,7 @@ #include <pwd.h> #include <grp.h> #include <dirent.h> +#include <glob.h> #if (NGX_HAVE_SYS_FILIO_H) #include <sys/filio.h> /* FIONBIO */ diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h index c3d832719..666e5eae9 100644 --- a/src/os/unix/ngx_solaris_config.h +++ b/src/os/unix/ngx_solaris_config.h @@ -25,6 +25,7 @@ #include <pwd.h> #include <grp.h> #include <dirent.h> +#include <glob.h> #include <sys/filio.h> /* FIONBIO */ #include <sys/uio.h> |
