diff options
author | (no author) <(no author)@unknown> | 1999-08-24 05:50:38 +0000 |
---|---|---|
committer | (no author) <(no author)@unknown> | 1999-08-24 05:50:38 +0000 |
commit | 6154ab7b1e862927c90ae6afa4dc6c57ee657ceb (patch) | |
tree | 9600a7a8672c30de1b898febf0383af458593f20 /file_io/unix | |
parent | 0dc12a018bb675ccf2859e3785702d5d2982646d (diff) | |
download | apr-APACHE_1_3_9.tar.gz apr-APACHE_1_3_9.zip |
This commit was manufactured by cvs2svn to create tag 'APACHE_1_3_9'.APACHE_1_3_9
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/tags/APACHE_1_3_9@59168 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/unix')
-rw-r--r-- | file_io/unix/.cvsignore | 1 | ||||
-rw-r--r-- | file_io/unix/Makefile.in | 95 | ||||
-rw-r--r-- | file_io/unix/dir.c | 319 | ||||
-rw-r--r-- | file_io/unix/fileacc.c | 250 | ||||
-rw-r--r-- | file_io/unix/filedup.c | 108 | ||||
-rw-r--r-- | file_io/unix/fileio.h | 103 | ||||
-rw-r--r-- | file_io/unix/filestat.c | 86 | ||||
-rw-r--r-- | file_io/unix/open.c | 282 | ||||
-rw-r--r-- | file_io/unix/pipe.c | 114 | ||||
-rw-r--r-- | file_io/unix/readwrite.c | 260 | ||||
-rw-r--r-- | file_io/unix/seek.c | 90 |
11 files changed, 0 insertions, 1708 deletions
diff --git a/file_io/unix/.cvsignore b/file_io/unix/.cvsignore deleted file mode 100644 index f3c7a7c5d..000000000 --- a/file_io/unix/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/file_io/unix/Makefile.in b/file_io/unix/Makefile.in deleted file mode 100644 index c0f45d701..000000000 --- a/file_io/unix/Makefile.in +++ /dev/null @@ -1,95 +0,0 @@ -#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -#LIBS=$(EXTRA_LIBS) $(LIBS1) -#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) -#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) - -RM=@RM@ -CC=@CC@ -RANLIB=@RANLIB@ -CFLAGS=@CFLAGS@ @OPTIM@ -LIBS=@LIBS@ -LDFLAGS=@LDFLAGS@ $(LIBS) -INCDIR=../../inc -INCDIR1=../../include -INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I. - -LIB=../libfile.a - -OBJS=dir.o \ - fileacc.o \ - filedup.o \ - filestat.o \ - open.o \ - pipe.o \ - readwrite.o \ - seek.o - -.c.o: - $(CC) $(CFLAGS) -c $(INCLUDES) $< - -all: $(LIB) - -clean: - $(RM) -f *.o *.a *.so - -distclean: clean - -$(RM) -f Makefile - -$(OBJS): Makefile - -$(LIB): $(OBJS) - $(RM) -f $@ - $(AR) cr $@ $(OBJS) - $(RANLIB) $@ - -# -# We really don't expect end users to use this rule. It works only with -# gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after -# using it. -# -depend: - cp Makefile.in Makefile.in.bak \ - && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > Makefile.new \ - && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \ - && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \ - -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \ - > Makefile.in \ - && rm Makefile.new - -# DO NOT REMOVE -dir.o: dir.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h ../../include/apr_lib.h \ - ../../include/hsregex.h ../../include/apr_portable.h \ - ../../include/apr_thread_proc.h ../../include/apr_win.h \ - ../../include/apr_network_io.h ../../include/apr_lock.h \ - ../../include/apr_time.h -fileacc.o: fileacc.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h ../../include/apr_lib.h \ - ../../include/hsregex.h -filedup.o: filedup.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h ../../include/apr_lib.h \ - ../../include/hsregex.h -filestat.o: filestat.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h -open.o: open.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h ../../include/apr_portable.h \ - ../../include/apr_thread_proc.h ../../include/apr_win.h \ - ../../include/apr_network_io.h ../../include/apr_lock.h \ - ../../include/apr_time.h ../../include/apr_lib.h \ - ../../include/hsregex.h -pipe.o: pipe.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h ../../include/apr_lib.h \ - ../../include/hsregex.h -readwrite.o: readwrite.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h ../../include/apr_lib.h \ - ../../include/hsregex.h -seek.o: seek.c fileio.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_file_io.h diff --git a/file_io/unix/dir.c b/file_io/unix/dir.c deleted file mode 100644 index ac992d783..000000000 --- a/file_io/unix/dir.c +++ /dev/null @@ -1,319 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include <sys/types.h> -#include <errno.h> -#include <string.h> -#include <dirent.h> -#include <sys/stat.h> -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_portable.h" - -ap_status_t dir_cleanup(void *thedir) -{ - struct dir_t *dir = thedir; - if (closedir(dir->dirstruct) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_opendir(ap_context_t *, char *, ap_dir_t **) - * Open the specified directory. - * arg 1) The context to use. - * arg 2) The full path to the directory (use / on all systems) - * arg 3) The opened directory descriptor. - */ -ap_status_t ap_opendir(ap_context_t *cont, const char *dirname, struct dir_t **new) -{ - (*new) = (struct dir_t *)ap_palloc(cont, sizeof(struct dir_t)); - - (*new)->cntxt = cont; - (*new)->dirname = strdup(dirname); - (*new)->dirstruct = opendir(dirname); - (*new)->entry = NULL; - - if ((*new)->dirstruct == NULL) { - (*new)->dirstruct = NULL; - return errno; - } - else { - ap_register_cleanup((*new)->cntxt, (void *)(*new), dir_cleanup, NULL); - return APR_SUCCESS; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_closedir(ap_dir_t *) - * close the specified directory. - * arg 1) the directory descriptor to close. - */ -ap_status_t ap_closedir(struct dir_t *thedir) -{ - ap_status_t rv; - - if ((rv = dir_cleanup(thedir)) == APR_SUCCESS) { - ap_kill_cleanup(thedir->cntxt, thedir, dir_cleanup); - return APR_SUCCESS; - } - return rv; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_readdir(ap_dir_t *) - * Read the next entry from the specified directory. - * arg 1) the directory descriptor to read from, and fill out. - * NOTE: All systems return . and .. as the first two files. - */ -ap_status_t ap_readdir(struct dir_t *thedir) -{ - thedir->entry = readdir(thedir->dirstruct); - if (thedir->entry == NULL) { - return errno; - } - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_readdir(ap_dir_t *) - * Rewind the directory to the first entry. - * arg 1) the directory descriptor to rewind. - */ -ap_status_t ap_rewinddir(struct dir_t *thedir) -{ - rewinddir(thedir->dirstruct); - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_make_dir(ap_context_t *, const char *, ap_fileperms_t) - * Create a new directory on the file system. - * arg 1) the context to use. - * arg 2) the path for the directory to be created. (use / on all systems) - * arg 3) Permissions for the new direcoty. - */ -ap_status_t ap_make_dir(ap_context_t *cont, const char *path, ap_fileperms_t perm) -{ - mode_t mode = get_fileperms(perm); - if (mkdir(path, mode) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_remove_dir(ap_context_t *, const char *) - * Remove directory from the file system. - * arg 1) the context to use. - * arg 2) the path for the directory to be removed. (use / on all systems) - */ -ap_status_t ap_remove_dir(ap_context_t *cont, const char *path) -{ - if (rmdir(path) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_dir_entry_size(ap_dir_t *, ap_ssize_t *) - * Get the size of the current directory entry. - * arg 1) the currently open directory. - * arg 2) the size of the directory entry. - */ -ap_status_t ap_dir_entry_size(struct dir_t *thedir, ap_ssize_t *size) -{ - struct stat filestat; - char *fname = NULL; - - if (thedir->entry == NULL) { - *size = -1; - return APR_ENOFILE; - } - fname = ap_pstrcat(thedir->cntxt, thedir->dirname, "/", - thedir->entry->d_name, NULL); - if (stat(fname, &filestat) == -1) { - *size = -1; - return APR_ENOSTAT; - } - - *size = filestat.st_size; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_dir_entry_mtime(ap_dir_t *, time_t *) - * Get the last modified time of the current directory entry. - * arg 1) the currently open directory. - * arg 2) the last modified time of the directory entry. - */ -ap_status_t ap_dir_entry_mtime(struct dir_t *thedir, time_t *time) -{ - struct stat filestat; - char *fname = NULL; - - if (thedir->entry == NULL) { - *time = -1; - return APR_ENOFILE; - } - - fname = ap_pstrcat(thedir->cntxt, thedir->dirname, "/", - thedir->entry->d_name, NULL); - if (stat(fname, &filestat) == -1) { - *time = -1; - return APR_ENOSTAT; - } - - *time = filestat.st_mtime; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_dir_entry_ftype(ap_dir_t *, ap_filetype_e *) - * Get the file type of the current directory entry. - * arg 1) the currently open directory. - * arg 2) the file type of the directory entry. - */ -ap_status_t ap_dir_entry_ftype(struct dir_t *thedir, ap_filetype_e *type) -{ - struct stat filestat; - char *fname = NULL; - - if (thedir->entry == NULL) { - *type = APR_REG; - return APR_ENOFILE; - } - - fname = ap_pstrcat(thedir->cntxt, thedir->dirname, "/", - thedir->entry->d_name, NULL); - if (stat(fname, &filestat) == -1) { - *type = APR_REG; - return APR_ENOSTAT; - } - - if (S_ISREG(filestat.st_mode)) - *type = APR_REG; - if (S_ISDIR(filestat.st_mode)) - *type = APR_DIR; - if (S_ISCHR(filestat.st_mode)) - *type = APR_CHR; - if (S_ISBLK(filestat.st_mode)) - *type = APR_BLK; - if (S_ISFIFO(filestat.st_mode)) - *type = APR_PIPE; - if (S_ISLNK(filestat.st_mode)) - *type = APR_LNK; - if (S_ISSOCK(filestat.st_mode)) - *type = APR_SOCK; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_dir_entry_filename(ap_dir_t *, char **) - * Get the file name of the current directory entry. - * arg 1) the currently open directory. - * arg 2) the file name of the directory entry. - */ -ap_status_t ap_get_dir_filename(struct dir_t *thedir, char **new) -{ - (*new) = ap_pstrdup(thedir->cntxt, thedir->entry->d_name); - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_os_dir(ap_dir_t *, ap_os_dir_t *) - * convert the dir from apr type to os specific type. - * arg 1) The apr dir to convert. - * arg 2) The os specific dir we are converting to - */ -ap_status_t ap_get_os_dir(struct dir_t *dir, ap_os_dir_t *thedir) -{ - if (dir == NULL) { - return APR_ENODIR; - } - thedir = dir->dirstruct; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_os_dir(ap_dir_t *, ap_os_dir_t *) - * convert the dir from os specific type to apr type. - * arg 1) The os specific dir to convert - * arg 2) The apr dir we are converting to. - */ -ap_status_t ap_put_os_dir(ap_context_t *cont, struct dir_t **dir, - ap_os_dir_t *thedir) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*dir) == NULL) { - (*dir) = (struct dir_t *)ap_palloc(cont, sizeof(struct dir_t)); - (*dir)->cntxt = cont; - } - (*dir)->dirstruct = thedir; - return APR_SUCCESS; -} - - diff --git a/file_io/unix/fileacc.c b/file_io/unix/fileacc.c deleted file mode 100644 index 829ac7586..000000000 --- a/file_io/unix/fileacc.c +++ /dev/null @@ -1,250 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include <errno.h> -#include <string.h> -#include <sys/types.h> - -/* A file to put ALL of the accessor functions for struct file_t types. */ - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_filename(ap_file_t *, char **) - * return the file name of the current file. - * arg 1) The currently open file. - * arg 2) The path of the file. - */ -ap_status_t ap_get_filename(struct file_t *thefile, char **new) -{ - if (thefile != NULL) { - *new = ap_pstrdup(thefile->cntxt, thefile->fname); - return APR_SUCCESS; - } - else { - *new = NULL; - return APR_ENOFILE; - } -} - -mode_t get_fileperms(ap_fileperms_t mode) -{ - mode_t rv = 0; - - if (mode & APR_UREAD) - rv |= S_IRUSR; - if (mode & APR_UWRITE) - rv |= S_IWUSR; - if (mode & APR_UEXECUTE) - rv |= S_IXUSR; - - if (mode & APR_GREAD) - rv |= S_IRGRP; - if (mode & APR_GWRITE) - rv |= S_IWGRP; - if (mode & APR_GEXECUTE) - rv |= S_IXGRP; - - if (mode & APR_WREAD) - rv |= S_IROTH; - if (mode & APR_WWRITE) - rv |= S_IWOTH; - if (mode & APR_WEXECUTE) - rv |= S_IXOTH; - - return rv; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_filesize(ap_file_t *, ap_ssize_t *) - * Return the size of the current file. - * arg 1) The currently open file. - * arg 2) The size of the file. - */ -ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size) -{ - if (file != NULL) { - if (!file->stated) { - ap_getfileinfo(file); - } - *size = file->size; - return APR_SUCCESS; - } - else { - *size = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_fileperms(ap_file_t *, ap_fileperms_t *) - * Return the permissions of the current file. - * arg 1) The currently open file. - * arg 2) The permissions of the file. - */ -ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm) -{ - if (file != NULL) { - if (!file->stated) { - ap_getfileinfo(file); - } - *perm = file->protection; - return APR_SUCCESS; - } - else { - *perm = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_fileatime(ap_file_t *, time_t *) - * Return the last access time of the current file. - * arg 1) The currently open file. - * arg 2) The last access time of the file. - */ -ap_status_t ap_get_fileatime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - if (!file->stated) { - ap_getfileinfo(file); - } - *time = file->atime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_filectime(ap_file_t *, time_t *) - * Return the time of the last change to the current file. - * arg 1) The currently open file. - * arg 2) The last change time of the file. - */ -ap_status_t ap_get_filectime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - if (!file->stated) { - ap_getfileinfo(file); - } - *time = file->ctime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_filemtime(ap_file_t *, time_t *) - * Return the last modified time of the current file. - * arg 1) The currently open file. - * arg 2) The last modified time of the file. - */ -ap_status_t ap_get_filemtime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - if (!file->stated) { - ap_getfileinfo(file); - } - *time = file->mtime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_filedata(ap_file_t *, void *) - * Return the data associated with the current file. - * arg 1) The currently open file. - * arg 2) The user data associated with the file. - */ -ap_status_t ap_get_filedata(struct file_t *file, void *data) -{ - if (file != NULL) { - return ap_get_userdata(file->cntxt, &data); - } - else { - data = NULL; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_filedata(ap_file_t *, void *) - * Set the data associated with the current file. - * arg 1) The currently open file. - * arg 2) The user data to associate with the file. - */ -ap_status_t ap_set_filedata(struct file_t *file, void *data) -{ - if (file != NULL) { - return ap_set_userdata(file->cntxt, data); - } - else { - data = NULL; - return APR_ENOFILE; - } -} - diff --git a/file_io/unix/filedup.c b/file_io/unix/filedup.c deleted file mode 100644 index 42df990ea..000000000 --- a/file_io/unix/filedup.c +++ /dev/null @@ -1,108 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include <string.h> - -/* ***APRDOC******************************************************** - * ap_status_t ap_dupfile(ap_file_t *, ap_file_t **) - * duplicate the specified file descriptor. - * arg 1) The file to duplicate. - * arg 2) The structure to duplicate into. - */ -ap_status_t ap_dupfile(struct file_t *old_file, struct file_t **new_file) -{ - char *buf_oflags; - (*new_file) = (struct file_t *)ap_palloc(old_file->cntxt, - sizeof(struct file_t)); - - if ((*new_file) == NULL) { - return APR_ENOMEM; - } - (*new_file)->cntxt = old_file->cntxt; - if (old_file->buffered) { - switch (old_file->oflags) { - case O_RDONLY: - buf_oflags = "r"; - break; - case O_WRONLY: - buf_oflags = "w"; - break; - case O_RDWR: - buf_oflags = "r+"; - break; - } - (*new_file)->filehand = freopen(old_file->fname, buf_oflags, - old_file->filehand); - } - else { - (*new_file)->filedes = dup(old_file->filedes); - } - (*new_file)->fname = ap_pstrdup(old_file->cntxt, old_file->fname); - (*new_file)->buffered = old_file->buffered; - (*new_file)->protection = old_file->protection; - (*new_file)->user = old_file->user; - (*new_file)->group = old_file->group; - (*new_file)->size = old_file->size; - (*new_file)->atime = old_file->atime; - (*new_file)->mtime = old_file->mtime; - (*new_file)->ctime = old_file->ctime; - ap_register_cleanup((*new_file)->cntxt, (void *)(*new_file), file_cleanup, NULL); - return APR_SUCCESS; -} - diff --git a/file_io/unix/fileio.h b/file_io/unix/fileio.h deleted file mode 100644 index 1800205fb..000000000 --- a/file_io/unix/fileio.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#ifndef FILE_IO_H -#define FILE_IO_H - -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <time.h> -#include <dirent.h> -#include <sys/uio.h> -#include "apr_general.h" -#include "apr_file_io.h" -#include "apr_errno.h" - -struct file_t { - ap_context_t *cntxt; - int filedes; - FILE *filehand; - char * fname; - int oflags; - int buffered; - int stated; - int eof_hit; - mode_t protection; - uid_t user; - gid_t group; - off_t size; - time_t atime; - time_t mtime; - time_t ctime; -}; - -struct dir_t { - ap_context_t *cntxt; - char *dirname; - DIR *dirstruct; - struct dirent *entry; -}; - -struct iovec_t { - ap_context_t *cntxt; - struct iovec *iovec; -}; - -ap_status_t file_cleanup(void *); -mode_t get_fileperms(ap_fileperms_t); - -#endif /* ! FILE_IO_H */ - diff --git a/file_io/unix/filestat.c b/file_io/unix/filestat.c deleted file mode 100644 index d7e2de444..000000000 --- a/file_io/unix/filestat.c +++ /dev/null @@ -1,86 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_errno.h" - -/* ***APRDOC******************************************************** - * ap_status_t ap_getfileinfo(ap_file_t *) - * get the specified file's stats.. - * arg 1) The full to get information about. - */ -ap_status_t ap_getfileinfo(struct file_t *thefile) -{ - struct stat info; - int rv = stat(thefile->fname, &info); - - if (rv == 0) { - thefile->protection = info.st_mode; - thefile->user = info.st_uid; - thefile->group = info.st_gid; - thefile->size = info.st_size; - thefile->atime = info.st_atime; - thefile->mtime = info.st_mtime; - thefile->ctime = info.st_ctime; - thefile->stated = 1; - return APR_SUCCESS; - } - else { - return APR_ENOSTAT; - } -} - diff --git a/file_io/unix/open.c b/file_io/unix/open.c deleted file mode 100644 index 5c805838a..000000000 --- a/file_io/unix/open.c +++ /dev/null @@ -1,282 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_portable.h" -#include "apr_lib.h" -#include <errno.h> -#include <string.h> -#include <stdio.h> - -ap_status_t file_cleanup(void *thefile) -{ - struct file_t *file = thefile; - int rv; - if (file->buffered) { - rv = fclose(file->filehand); - } - else { - rv = close(file->filedes); - } - - if (rv == 0) { - file->filedes = -1; - return APR_SUCCESS; - } - else { - return errno; - /* Are there any error conditions other than EINTR or EBADF? */ - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_open(ap_context_t *, char *, ap_int32, - * ap_fileperms, ap_file_t **) - * Open the specified file. - * arg 1) The context to use. - * arg 2) The full path to the file (using / on all systems) - * arg 3) Or'ed value of: - * APR_READ open for reading - * APR_WRITE open for writing - * APR_CREATE create the file if not there - * APR_APPEND file ptr is set to end prior to all writes - * APR_TRUNCATE set length to zero if file exists - * APR_BINARY not a test file - * APR_BUFFERED buffer the data. Default is non-buffered - * APR_EXCL return error if APR_CREATE and file exists - * arg 4) Access permissions for file. - * arg 5) The opened file descriptor. - * NOTE: If mode is APR_OS_DEFAULT, the system open command will be - * called without any mode parameters. - */ -ap_status_t ap_open(ap_context_t *cont, char *fname, ap_int32_t flag, ap_fileperms_t perm, struct file_t **new) -{ - int oflags = 0; - struct stat info; - mode_t mode = get_fileperms(perm); - char *buf_oflags; - - (*new) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - - (*new)->cntxt = cont; - (*new)->oflags = oflags; - - if ((flag & APR_READ) && (flag & APR_WRITE)) { - oflags = O_RDWR; - } - else if (flag & APR_READ) { - oflags = O_RDONLY; - } - else if (flag & APR_WRITE) { - oflags = O_WRONLY; - } - else { - (*new)->filedes = -1; - return APR_EACCES; - } - - if (flag & APR_BUFFERED) { - (*new)->buffered = TRUE; - } - (*new)->fname = strdup(fname); - - if (flag & APR_CREATE) { - oflags |= O_CREAT; - if (flag & APR_EXCL) { - oflags |= O_EXCL; - } - } - if ((flag & APR_EXCL) && !(flag & APR_CREATE)) { - (*new)->filedes = -1; - return APR_EACCES; - } - - if (flag & APR_APPEND) { - oflags |= O_APPEND; - } - if (flag & APR_TRUNCATE) { - oflags |= O_TRUNC; - } - - if (perm == APR_OS_DEFAULT) { - (*new)->filedes = open(fname, oflags); - } - else { - (*new)->filedes = open(fname, oflags, mode); - } - - if ((*new)->filedes < 0) { - (*new)->filedes = -1; - (*new)->eof_hit = 1; - return errno; - } - - if ((*new)->buffered) { - switch (oflags) { - case O_RDONLY: - buf_oflags = "r"; - break; - case O_WRONLY: - buf_oflags = "w"; - break; - case O_RDWR: - buf_oflags = "r+"; - break; - } - (*new)->filehand = fdopen((*new)->filedes, buf_oflags); - if ((*new)->filehand == NULL) { - file_cleanup(*new); - return errno; - } - } - (*new)->stated = 0; /* we haven't called stat for this file yet. */ - (*new)->eof_hit = 0; - ap_register_cleanup((*new)->cntxt, (void *)(*new), file_cleanup, NULL); - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_close(ap_file_t *) - * Close the specified file. - * arg 1) The file descriptor to close. - */ -ap_status_t ap_close(struct file_t *file) -{ - ap_status_t rv; - - if ((rv = file_cleanup(file)) == APR_SUCCESS) { - ap_kill_cleanup(file->cntxt, file, file_cleanup); - return APR_SUCCESS; - } - return rv; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_remove_file(ap_context_t *, char *) - * delete the specified file. - * arg 1) The context to use. - * arg 2) The full path to the file (using / on all systems) - * NOTE: If the file is open, it won't be removed until all instances are - * closed. - */ -ap_status_t ap_remove_file(ap_context_t *cont, char *path) -{ - if (unlink(path) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_os_file(ap_file_t *, ap_os_file_t *) - * convert the file from apr type to os specific type. - * arg 1) The apr file to convert. - * arg 2) The os specific file we are converting to - */ -ap_status_t ap_get_os_file(struct file_t *file, ap_os_file_t *thefile) -{ - if (file == NULL) { - return APR_ENOFILE; - } - thefile = &(file->filedes); - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_put_os_file(ap_context_t *, ap_file_t *, ap_os_file_t *) - * convert the file from os specific type to apr type. - * arg 1) The context to use if it is needed. - * arg 2) The apr file we are converting to. - * arg 3) The os specific file to convert - */ -ap_status_t ap_put_os_file(ap_context_t *cont, struct file_t **file, - ap_os_file_t *thefile) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*file) == NULL) { - (*file) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*file)->cntxt = cont; - } - (*file)->filedes = *thefile; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_eof(ap_file_t *) - * Are we at the end of the file - * arg 1) The apr file we are testing. - * NOTE: Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise. - */ -ap_status_t ap_eof(ap_file_t *fptr) -{ - char ch; - if (fptr->buffered) { - if (feof(fptr->filehand) == 0) { - return APR_SUCCESS; - } - return APR_EOF; - } - if (fptr->eof_hit == 1) { - return APR_EOF; - } - APR_SUCCESS; -} - diff --git a/file_io/unix/pipe.c b/file_io/unix/pipe.c deleted file mode 100644 index ca842de1a..000000000 --- a/file_io/unix/pipe.c +++ /dev/null @@ -1,114 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include <errno.h> -#include <string.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> - -/* ***APRDOC******************************************************** - * ap_status_t ap_create_pipe(ap_context_t *, ap_file_t **, ap_file_t **) - * Create an anonymous pipe. - * arg 1) The context to operate on. - * arg 2) The file descriptor to use as input to the pipe. - * arg 3) The file descriptor to use as output from the pipe. - */ -ap_status_t ap_create_pipe(ap_context_t *cont, struct file_t **in, struct file_t **out) -{ - int filedes[2]; - - if (pipe(filedes) == -1) { - return errno; - } - - (*in) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*in)->cntxt = cont; - (*in)->filedes = filedes[0]; - (*in)->fname = ap_pstrdup(cont, "PIPE"); - - (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*out)->cntxt = cont; - (*out)->filedes = filedes[1]; - (*out)->fname = ap_pstrdup(cont, "PIPE"); - - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_create_namedpipe(ap_context_t *, char *, ap_fileperms_t, - * char **) - * Create a named pipe. - * arg 1) The context to operate on. - * arg 2) The directory to create the pipe in. - * arg 3) The permissions for the newly created pipe. - * arg 4) The name of the new pipe. - */ -ap_status_t ap_create_namedpipe(ap_context_t *cont, char *dirpath, - ap_fileperms_t perm, char **new) -{ - mode_t mode = get_fileperms(perm); - - *new = tempnam(dirpath, NULL); - if (mkfifo((*new), mode) == -1) { - return errno; - } - return APR_SUCCESS; -} - diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c deleted file mode 100644 index a1d46af9d..000000000 --- a/file_io/unix/readwrite.c +++ /dev/null @@ -1,260 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_errno.h" -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_SYS_UIO_H -#include <sys/uio.h> -#endif - -/* ***APRDOC******************************************************** - * ap_status_t ap_read(ap_file_t *, void *, ap_ssize_t *) - * Read data from the specified file. - * arg 1) The file descriptor to read from. - * arg 2) The buffer to store the data to. - * arg 3) The number of bytes to read. - * NOTE: ap_read will read up to the specified number of bytes, but never - * more. If there isn't enough data to fill that number of bytes, all of - * the available data is read. The third argument is modified to reflect the - * number of bytes read. - */ -ap_status_t ap_read(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) -{ - ap_ssize_t rv; - - if (thefile->filedes < 0) { - *nbytes = -1; - return APR_EBADF; - } - - if (thefile->buffered) { - rv = fread(buf, *nbytes, 1, thefile->filehand); - } - else { - rv = read(thefile->filedes, buf, *nbytes); - } - - if ((*nbytes != rv) && (errno != EINTR) && !thefile->buffered) { - thefile->eof_hit = 1; - } - *nbytes = rv; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_write(ap_file_t *, void *, ap_ssize_t *) - * Write data to the specified file. - * arg 1) The file descriptor to write to. - * arg 2) The buffer which contains the data. - * arg 3) The number of bytes to write. - * NOTE: ap_write will write up to the specified number of bytes, but never - * more. If the OS cannot write that many bytes, it will write as many as it - * can. The third argument is modified to reflect the * number of bytes - * written. - */ -ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) -{ - ap_size_t rv; - struct stat info; - - if (thefile->filedes < 0) { - *nbytes = -1; - return APR_EBADF; - } - - if (thefile->buffered) { - rv = fwrite(buf, *nbytes, 1, thefile->filehand); - } - else { - rv = write(thefile->filedes, buf, *nbytes); - } - - if (strcmp(thefile->fname, "PIPE")) { - if (stat(thefile->fname, &info) == 0) { - thefile->size = info.st_size; - thefile->atime = info.st_atime; - thefile->mtime = info.st_mtime; - thefile->ctime = info.st_ctime; - } - } - *nbytes = rv; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_writev(ap_file_t *, ap_iovec_t *, ap_ssize_t *) - * Write data from ap_iovec array to the specified file. - * arg 1) The file descriptor to write to. - * arg 2) The array from which to get the data to write to the file. - * arg 3) The number of elements in the ap_iovec array. This must be - * smaller than AP_MAX_IOVEC_SIZE. If it isn't, the function will - * fail with APR_EINVAL. - * NOTE: The third arguement is updated with the number of bytes actually - * written on function exit. - */ -#ifdef HAVE_WRITEV -ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt) -{ - int bytes; - if ((bytes = writev(thefile->filedes, vec->iovec, *iocnt)) < 0) { - *iocnt = bytes; - return errno; - } - else { - *iocnt = bytes; - return APR_SUCCESS; - } -} -#endif - -/* ***APRDOC******************************************************** - * ap_status_t ap_putc(ap_file_t *, char) - * put a character into the specified file. - * arg 1) The file descriptor to write to - * arg 2) The character to write. - */ -ap_status_t ap_putc(ap_file_t *thefile, char ch) -{ - if (thefile->buffered) { - if (fputc(ch, thefile->filehand) == ch) { - return APR_SUCCESS; - } - return errno; - } - if (write(thefile->filedes, &ch, 1) != 1) { - return errno; - } - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_getc(ap_file_t *, char *) - * put a character into the specified file. - * arg 1) The file descriptor to write to - * arg 2) The character to write. - */ -ap_status_t ap_getc(ap_file_t *thefile, char *ch) -{ - ssize_t rv; - - if (thefile->buffered) { - if ((*ch) = fgetc(thefile->filehand)) { - return APR_SUCCESS; - } - if (feof(thefile->filehand)) { - return APR_EOF; - } - return errno; - } - rv = read(thefile->filedes, ch, 1); - if (rv == 0) { - thefile->eof_hit = TRUE; - return APR_EOF; - } - else if (rv != 1) { - return errno; - } - return APR_SUCCESS; -} - -static int printf_flush(ap_vformatter_buff_t *vbuff) -{ - /* I would love to print this stuff out to the file, but I will - * get that working later. :) For now, just return. - */ - return -1; -} - -API_EXPORT(int) ap_fprintf(struct file_t *fptr, const char *format, ...) -{ - int cc; - va_list ap; - ap_vformatter_buff_t vbuff; - char *buf; - int len; - - buf = malloc(HUGE_STRING_LEN); - if (buf == NULL) { - return 0; - } - /* save one byte for nul terminator */ - vbuff.curpos = buf; - vbuff.endpos = buf + len - 1; - va_start(ap, format); -#if 0 - cc = ap_vformatter(printf_flush, &vbuff, format, ap); - va_end(ap); - *vbuff.curpos = '\0'; -#endif - vsprintf(buf, format, ap); - len = strlen(buf); - cc = ap_write(fptr, buf, &len); - va_end(ap); - return (cc == -1) ? len : cc; -} - - diff --git a/file_io/unix/seek.c b/file_io/unix/seek.c deleted file mode 100644 index aae8ece94..000000000 --- a/file_io/unix/seek.c +++ /dev/null @@ -1,90 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The Apache Group. 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. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" 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 names without prior written - * permission of the Apache Group. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP 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 Group. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - */ - -#include "fileio.h" -#include "apr_file_io.h" -#include <errno.h> -#include <string.h> - -/* ***APRDOC******************************************************** - * ap_status_t ap_seek(ap_file_t *, ap_seek_where_t, ap_off_t *) - * Move the read/write file offset to a specified byte within a file. - * arg 1) The file descriptor - * arg 2) How to move the pointer, one of: - * APR_SET -- set the offset to offset - * APR_CUR -- add the offset to the current position - * APR_END -- add the offset to the current file size - * arg 3) The offset to move the pointer to. - * NOTE: The third argument is modified to be the offset the pointer - * was actually moved to. - */ -ap_status_t ap_seek(struct file_t *thefile, ap_seek_where_t where, ap_off_t *offset) -{ - ap_off_t rv; - if (thefile->buffered) { - rv = fseek(thefile->filehand, *offset, where); - } - else { - rv = lseek(thefile->filedes, *offset, where); - } - if (rv == -1) { - *offset = -1; - return errno; - } - else { - *offset = rv; - return APR_SUCCESS; - } -} |