diff options
Diffstat (limited to 'file_io')
46 files changed, 0 insertions, 5771 deletions
diff --git a/file_io/beos/Makefile.in b/file_io/beos/Makefile.in deleted file mode 100644 index dc09ff79f..000000000 --- a/file_io/beos/Makefile.in +++ /dev/null @@ -1,78 +0,0 @@ -#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -#LIBS=$(EXTRA_LIBS) $(LIBS1) -#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) -#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) - -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_errno.h ../../include/apr_file_io.h \ - $(INCDIR)/apr_lib.h $(INCDIR)/apr_config.h \ - $(INCDIR)/hsregex.h -fileacc.o: fileacc.c fileio.h ../../include/apr_general.h \ - ../../include/apr_errno.h ../../include/apr_file_io.h -filedup.o: filedup.c fileio.h ../../include/apr_general.h \ - ../../include/apr_errno.h ../../include/apr_file_io.h -filestat.o: filestat.c fileio.h ../../include/apr_general.h \ - ../../include/apr_errno.h ../../include/apr_file_io.h -open.o: open.c fileio.h ../../include/apr_general.h \ - ../../include/apr_errno.h ../../include/apr_file_io.h \ - $(INCDIR)/apr_lib.h $(INCDIR)/apr_config.h \ - $(INCDIR)/hsregex.h -pipe.o: pipe.c fileio.h ../../include/apr_general.h \ - ../../include/apr_errno.h ../../include/apr_file_io.h -readwrite.o: readwrite.c fileio.h ../../include/apr_general.h \ - ../../include/apr_errno.h ../../include/apr_file_io.h -seek.o: seek.c fileio.h ../../include/apr_general.h \ - ../../include/apr_errno.h ../../include/apr_file_io.h diff --git a/file_io/beos/dir.c b/file_io/beos/dir.c deleted file mode 100644 index 43d35ad20..000000000 --- a/file_io/beos/dir.c +++ /dev/null @@ -1,220 +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 <errno.h> -#include <string.h> -#include <dirent.h> -#include <sys/stat.h> -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_lib.h" - -ap_status_t dir_cleanup(void *thedir) -{ - struct dir_t *dir = thedir; - if (closedir(dir->dirstruct) ==0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -ap_status_t ap_opendir(ap_context_t *cont, const char *dirname, ap_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; - } -} - -ap_status_t ap_closedir(struct dir_t *thedir) -{ - if (dir_cleanup(thedir) == APR_SUCCESS) { - ap_kill_cleanup(thedir->cntxt, thedir, dir_cleanup); - return APR_SUCCESS; - } - else { - return errno; - } -} - -ap_status_t ap_readdir(struct dir_t *thedir) -{ - thedir->entry = readdir(thedir->dirstruct); - if (thedir->entry == NULL){ - return errno; - } - return APR_SUCCESS; -} - -ap_status_t ap_rewinddir(struct dir_t *thedir) -{ - rewinddir(thedir->dirstruct); - return APR_SUCCESS; -} - -ap_status_t ap_make_dir(ap_context_t *cont, const char *path, ap_fileperms_t mode) -{ - if (mkdir(path, mode) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -ap_status_t ap_remove_dir(ap_context_t *cont, const char *path) -{ - if (rmdir(path) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -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; -} - -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; -} - -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; -} - -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; -} - diff --git a/file_io/beos/fileacc.c b/file_io/beos/fileacc.c deleted file mode 100644 index 901d2edc5..000000000 --- a/file_io/beos/fileacc.c +++ /dev/null @@ -1,164 +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 <errno.h> -#include <string.h> -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" - -/* A file to put ALL of the accessor functions for struct file_t types. */ - -ap_status_t ap_get_filename(struct file_t *thefile, char **new) -{ - if (thefile != NULL) { - *new = (char*)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; -} - - -ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size) -{ - if (file != NULL) { - *size = file->size; - return APR_SUCCESS; - } - else { - *size = -1; - return APR_ENOFILE; - } -} - -ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm) -{ - if (file != NULL) { - *perm = file->protection; - return APR_SUCCESS; - } - else { - *perm = -1; - return APR_ENOFILE; - } -} - -ap_status_t ap_get_fileatime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - *time = file->atime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -ap_status_t ap_get_filectime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - *time = file->ctime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -ap_status_t ap_get_filemtime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - *time = file->mtime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - diff --git a/file_io/beos/filedup.c b/file_io/beos/filedup.c deleted file mode 100644 index eaf465197..000000000 --- a/file_io/beos/filedup.c +++ /dev/null @@ -1,82 +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 <strings.h> -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" - -ap_status_t ap_dupfile(struct file_t *old_file, struct file_t **new_file) -{ - (*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; - (*new_file)->filedes = dup(old_file->filedes); - (*new_file)->fname = (char*)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/beos/fileio.h b/file_io/beos/fileio.h deleted file mode 100644 index 6c1e11dc3..000000000 --- a/file_io/beos/fileio.h +++ /dev/null @@ -1,100 +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" - -#define ENOFILE B_ENTRY_NOT_FOUND - -struct file_t { - ap_context_t *cntxt; - int filedes; - char * fname; - int buffered; - 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/beos/filestat.c b/file_io/beos/filestat.c deleted file mode 100644 index 0dba48711..000000000 --- a/file_io/beos/filestat.c +++ /dev/null @@ -1,99 +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_general.h" -#include "apr_file_io.h" -#include "apr_errno.h" - -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; - return APR_SUCCESS; - } - else { - return APR_ENOSTAT; - } -} - -ap_status_t ap_updatefileinfo(struct file_t *thefile) -{ - struct stat info; - int rv = fstat(thefile->filedes, &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; - return APR_SUCCESS; - } - else { - return APR_ENOSTAT; - } -} diff --git a/file_io/beos/open.c b/file_io/beos/open.c deleted file mode 100644 index a8ccabfc8..000000000 --- a/file_io/beos/open.c +++ /dev/null @@ -1,166 +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/>. - * - */ - - -// BeOS port by David Reid 23 Feb 1999 - -#include <errno.h> -#include <support/SupportDefs.h> -#include <kernel/OS.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" - -ap_status_t file_cleanup(void *thefile) -{ - struct file_t *file = thefile; - if (close(file->filedes) == 0) { - file->filedes = -1; - return APR_SUCCESS; - } - else { - return errno; - /* Are there any error conditions other than EINTR or EBADF? */ - } -} - -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); - - (*new) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - - (*new)->cntxt = cont; - - if ((flag & APR_READ) && (flag & APR_WRITE)) { - oflags = B_READ_WRITE; - } - else if (flag & APR_READ) { - oflags = B_READ_ONLY; - } - else if (flag & APR_WRITE) { - oflags = B_WRITE_ONLY; - } - else { - (*new)->filedes = -1; - return APR_EACCES; - } - if (flag & APR_BUFFERED) { - (*new)->buffered = TRUE; - } - - (*new)->fname = (char*)strdup(fname); - if (flag & APR_CREATE) { - oflags |= B_CREATE_FILE; - if (flag & APR_EXCL) { - oflags |= B_FAIL_IF_EXISTS; - } - } - if ((flag & APR_EXCL) && !(flag & APR_CREATE)) { - (*new)->filedes = -1; - return APR_EACCES; - } - - if (flag & APR_APPEND) { - oflags |= B_OPEN_AT_END; - } - if (flag & APR_TRUNCATE) { - oflags |= B_ERASE_FILE; - } - - (*new)->filedes = open(fname, oflags, mode); - - if ((*new)->filedes < 0) { - (*new)->filedes = -1; - return errno; - } - if (ap_updatefileinfo(*new) == APR_SUCCESS) { - ap_register_cleanup((*new)->cntxt, (void *)(*new), - file_cleanup, NULL); - return APR_SUCCESS; - } - else { - (*new)->filedes = -1; - return APR_ENOSTAT; - } -} - -ap_status_t ap_close(struct file_t * file) -{ - if (file_cleanup(file) == APR_SUCCESS) { - ap_kill_cleanup(file->cntxt, file, file_cleanup); - return APR_SUCCESS; - } - else { - return errno; - /* Are there any error conditions other than EINTR or EBADF? */ - } -} - -ap_status_t ap_remove_file(ap_context_t *cont, char *path) -{ - if (unlink(path) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} diff --git a/file_io/beos/pipe.c b/file_io/beos/pipe.c deleted file mode 100644 index 3641e7895..000000000 --- a/file_io/beos/pipe.c +++ /dev/null @@ -1,94 +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 <errno.h> -#include <string.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" - -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 = (char*)ap_pstrdup(cont, "PIPE"); - - (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*out)->cntxt = cont; - (*out)->filedes = filedes[1]; - (*out)->fname = (char*)ap_pstrdup(cont, "PIPE"); - - return APR_SUCCESS; -} - -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/beos/readwrite.c b/file_io/beos/readwrite.c deleted file mode 100644 index 17cc15182..000000000 --- a/file_io/beos/readwrite.c +++ /dev/null @@ -1,112 +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 <errno.h> -#include <unistd.h> -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_errno.h" - -ap_status_t ap_read(const struct file_t *thefile, void *buf, ap_ssize_t *nbytes) -{ - ap_size_t rv; - - if (thefile->filedes < 0) { - *nbytes = -1; - return APR_EBADF; - } - - rv = read(thefile->filedes, buf, *nbytes); - - *nbytes = rv; - return APR_SUCCESS; -} - -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; - } - - rv = write(thefile->filedes, buf, *nbytes); - - 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; -} - -ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt) -{ - ap_ssize_t bytes; - if ((bytes = writev(thefile->filedes, vec->iovec, *iocnt)) < 0){ - *iocnt = bytes; - return errno; - } - else { - *iocnt = bytes; - return APR_SUCCESS; - } -} diff --git a/file_io/beos/seek.c b/file_io/beos/seek.c deleted file mode 100644 index 76772658f..000000000 --- a/file_io/beos/seek.c +++ /dev/null @@ -1,74 +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 <errno.h> -#include <string.h> -#include "fileio.h" -#include "apr_file_io.h" - -ap_status_t ap_seek(struct file_t *thefile, ap_seek_where_t where, ap_off_t *offset) -{ - ap_off_t rv; - rv = lseek(thefile->filedes, *offset, where); - if (rv == -1) { - *offset = -1; - return errno; - } - else { - *offset = rv; - return APR_SUCCESS; - } - -} diff --git a/file_io/os2/Makefile.in b/file_io/os2/Makefile.in deleted file mode 100644 index 2807b9373..000000000 --- a/file_io/os2/Makefile.in +++ /dev/null @@ -1,77 +0,0 @@ -#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -#LIBS=$(EXTRA_LIBS) $(LIBS1) -#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) -#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) - -CC=@CC@ -RANLIB=@RANLIB@ -CFLAGS=@CFLAGS@ @OPTIM@ -LIBS=@LIBS@ -LDFLAGS=@LDFLAGS@ $(LIBS) -INCDIR=../../inc -INCDIR1=../../include -INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I. - -LIB=../file.a - -OBJS=dir.o \ - fileacc.o \ - filedup.o \ - filestat.o \ - open.o \ - pipe.o \ - readwrite.o \ - seek.o \ - maperrorcode.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 ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h -fileacc.o: fileacc.c ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h -filedup.o: filedup.c ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h -filestat.o: filestat.c ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h -open.o: open.c ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h \ - ../include/apr_lib.h ../include/apr_config.h \ - ../include/hsregex.h -pipe.o: pipe.c ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h -readwrite.o: readwrite.c ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h -seek.o: seek.c ../../include/apr_file_io.h fileio.h \ - ../../include/apr_errno.h ../../include/apr_general.h diff --git a/file_io/os2/dir.c b/file_io/os2/dir.c deleted file mode 100644 index 3072a2243..000000000 --- a/file_io/os2/dir.c +++ /dev/null @@ -1,223 +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_lib.h" -#include <string.h> - -#define INCL_DOS -#include <os2.h> - -ap_status_t dir_cleanup(void *thedir) -{ - struct dir_t *dir = thedir; - return ap_closedir(dir); -} - - - -ap_status_t ap_opendir(ap_context_t *cntxt, const char *dirname, struct dir_t **new) -{ - struct dir_t *thedir = (struct dir_t *)ap_palloc(cntxt, sizeof(struct dir_t)); - - if (thedir == NULL) - return APR_ENOMEM; - - thedir->cntxt = cntxt; - thedir->dirname = ap_pstrdup(cntxt, dirname); - thedir->handle = 0; - thedir->validentry = FALSE; - *new = thedir; - return APR_SUCCESS; -} - - - -ap_status_t ap_closedir(struct dir_t *thedir) -{ - int rv = 0; - - if (thedir->handle) { - rv = DosFindClose(thedir->handle); - - if (rv == 0) { - thedir->handle = 0; - } - } - - return os2errno(rv); -} - - - -ap_status_t ap_readdir(struct dir_t *thedir) -{ - int rv; - ULONG entries = 1; - - if (thedir->handle == 0) { - thedir->handle = HDIR_CREATE; - rv = DosFindFirst(ap_pstrcat(thedir->cntxt, thedir->dirname, "/*", NULL), &thedir->handle, - FILE_ARCHIVED|FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY, - &thedir->entry, sizeof(thedir->entry), &entries, FIL_STANDARD); - } else { - rv = DosFindNext(thedir->handle, &thedir->entry, sizeof(thedir->entry), &entries); - } - - if (rv == 0 && entries == 1) { - thedir->validentry = TRUE; - return APR_SUCCESS; - } - - thedir->validentry = FALSE; - - if (rv) - return os2errno(rv); - - return APR_ENOENT; -} - - - -ap_status_t ap_rewinddir(struct dir_t *thedir) -{ - return ap_closedir(thedir); -} - - - -ap_status_t ap_make_dir(ap_context_t *cont, const char *path, ap_fileperms_t perm) -{ - return os2errno(DosCreateDir(path, NULL)); -} - - - -ap_status_t ap_remove_dir(ap_context_t *cont, const char *path) -{ - return os2errno(DosDeleteDir(path)); -} - - - -ap_status_t ap_dir_entry_size(struct dir_t *thedir, ap_ssize_t *size) -{ - if (thedir->validentry) { - *size = thedir->entry.cbFile; - return APR_SUCCESS; - } - - return APR_ENOFILE; -} - - - -ap_status_t ap_dir_entry_mtime(struct dir_t *thedir, time_t *time) -{ - if (thedir->validentry) { - *time = os2date2unix(thedir->entry.fdateLastWrite, thedir->entry.ftimeLastWrite); - return APR_SUCCESS; - } - - return APR_ENOFILE; -} - - - -ap_status_t ap_dir_entry_ftype(struct dir_t *thedir, ap_filetype_e *type) -{ - int rc; - HFILE hFile; - ULONG action, Type, Attr; - ap_filetype_e typemap[8] = { APR_REG, APR_CHR, APR_PIPE }; - - if (thedir->validentry) { - if (thedir->entry.attrFile & FILE_DIRECTORY) { - *type = APR_DIR; - return APR_SUCCESS; - } else { - rc = DosOpen(ap_pstrcat(thedir->cntxt, thedir->dirname, "/", thedir->entry.achName, NULL) , - &hFile, &action, 0, 0, - OPEN_ACTION_FAIL_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE|OPEN_ACCESS_READONLY, - NULL); - - if ( rc == 0 ) { - rc = DosQueryHType( hFile, &Type, &Attr ); - - if ( rc == 0 ) { - *type = typemap[(Type & 0x0007)]; - } - DosClose( hFile ); - } - - return os2errno(rc); - } - } - - return APR_ENOFILE; -} - - - -ap_status_t ap_get_dir_filename(struct dir_t *thedir, char **new) -{ - if (thedir->validentry) { - *new = thedir->entry.achName; - return APR_SUCCESS; - } - - return APR_ENOFILE; -} diff --git a/file_io/os2/fileacc.c b/file_io/os2/fileacc.c deleted file mode 100644 index a31519265..000000000 --- a/file_io/os2/fileacc.c +++ /dev/null @@ -1,188 +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. */ - -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; - } -} - - - -ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size) -{ - ap_status_t rv; - - if (file != NULL) { - if (!file->validstatus) { - rv = ap_getfileinfo(file); - - if (rv) - return rv; - } - - *size = file->status.cbFile; - return APR_SUCCESS; - } else { - *size = -1; - return APR_ENOFILE; - } -} - - - -ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm) -{ - ap_status_t rv; - - if (file != NULL) { - if (!file->validstatus) { - rv = ap_getfileinfo(file); - - if (rv) - return rv; - } - - *perm = (file->status.attrFile & FILE_READONLY) ? 0555 : 0777; - return APR_SUCCESS; - } else { - *perm = -1; - return APR_ENOFILE; - } -} - - - -ap_status_t ap_get_fileatime(struct file_t *file, time_t *time) -{ - ap_status_t rv; - - if (file != NULL) { - if (!file->validstatus) { - rv = ap_getfileinfo(file); - - if (rv) - return rv; - } - - *time = os2date2unix( file->status.fdateLastAccess, file->status.ftimeLastAccess ); - return APR_SUCCESS; - } else { - *time = -1; - return APR_ENOFILE; - } -} - - - -ap_status_t ap_get_filectime(struct file_t *file, time_t *time) -{ - ap_status_t rv; - - if (file != NULL) { - if (!file->validstatus) { - rv = ap_getfileinfo(file); - - if (rv) - return rv; - } - - *time = os2date2unix( file->status.fdateCreation, file->status.ftimeCreation ); - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - - - -ap_status_t ap_get_filemtime(struct file_t *file, time_t *time) -{ - ap_status_t rv; - - if (file != NULL) { - if (!file->validstatus) { - rv = ap_getfileinfo(file); - - if (rv) - return rv; - } - - *time = os2date2unix( file->status.fdateLastWrite, file->status.ftimeLastWrite ); - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - diff --git a/file_io/os2/filedup.c b/file_io/os2/filedup.c deleted file mode 100644 index 884c8e67a..000000000 --- a/file_io/os2/filedup.c +++ /dev/null @@ -1,88 +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_lib.h" -#include <string.h> - -#define INCL_DOS -#include <os2.h> - -ap_status_t ap_dupfile(struct file_t *old_file, struct file_t **new_file) -{ - int rv; - struct file_t *dup_file = (struct file_t *)ap_palloc(old_file->cntxt, sizeof(struct file_t)); - - if (new_file == NULL) { - return APR_ENOMEM; - } - - dup_file->filedes = -1; - rv = DosDupHandle(old_file->filedes, &dup_file->filedes); - - if (rv) { - return os2errno(rv); - } - - dup_file->cntxt = old_file->cntxt; - dup_file->fname = ap_pstrdup(dup_file->cntxt, old_file->fname); - dup_file->buffered = old_file->buffered; - dup_file->status = old_file->status; - dup_file->isopen = old_file->isopen; - *new_file = dup_file; - ap_register_cleanup(dup_file->cntxt, dup_file, file_cleanup, NULL); - return APR_SUCCESS; -} diff --git a/file_io/os2/fileio.h b/file_io/os2/fileio.h deleted file mode 100644 index 0d40b4af7..000000000 --- a/file_io/os2/fileio.h +++ /dev/null @@ -1,94 +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 - -#define INCL_DOS -#include <os2.h> - -#include "apr_general.h" -#include "apr_file_io.h" -#include "apr_errno.h" - -struct file_t { - ap_context_t *cntxt; - ULONG filedes; - char * fname; - int isopen; - int buffered; - FILESTATUS3 status; - int validstatus; -}; - -struct dir_t { - ap_context_t *cntxt; - char *dirname; - ULONG handle; - FILEFINDBUF3 entry; - int validentry; -}; - -struct iovec_t { - struct iovec *iovec; -}; - -ap_status_t file_cleanup(void *); -mode_t get_fileperms(ap_fileperms_t); -long os2date2unix( FDATE os2date, FTIME os2time ); -int os2errno( ULONG oserror ); - -#endif /* ! FILE_IO_H */ - diff --git a/file_io/os2/filestat.c b/file_io/os2/filestat.c deleted file mode 100644 index 425215c5c..000000000 --- a/file_io/os2/filestat.c +++ /dev/null @@ -1,112 +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_lib.h" -#include <sys/time.h> - -#define INCL_DOS -#include <os2.h> - - -typedef struct { - USHORT sec2:5; - USHORT min:6; - USHORT hour:5; -} DOSTIME; - -typedef struct { - USHORT day:5; - USHORT month:4; - USHORT year:7; -} DOSDATE; - -long os2date2unix( FDATE os2date, FTIME os2time ) -{ - struct tm tmpdate; - - memset(&tmpdate, 0, sizeof(tmpdate)); - tmpdate.tm_hour = os2time.hours; - tmpdate.tm_min = os2time.minutes; - tmpdate.tm_sec = os2time.twosecs * 2; - - tmpdate.tm_mday = os2date.day; - tmpdate.tm_mon = os2date.month - 1; - tmpdate.tm_year = os2date.year + 80; - tmpdate.tm_isdst = -1; - - return mktime( &tmpdate ); -} - - - -ap_status_t ap_getfileinfo(struct file_t *thefile) -{ - ULONG rc; - - if (thefile->isopen) - rc = DosQueryFileInfo(thefile->filedes, FIL_STANDARD, &thefile->status, sizeof(thefile->status)); - else - rc = DosQueryPathInfo(thefile->fname, FIL_STANDARD, &thefile->status, sizeof(thefile->status)); - - if (rc == 0) { - thefile->validstatus = TRUE; - return APR_SUCCESS; - } - - thefile->validstatus = FALSE; - return os2errno(rc); -} diff --git a/file_io/os2/maperrorcode.c b/file_io/os2/maperrorcode.c deleted file mode 100644 index 0c7fb4fb9..000000000 --- a/file_io/os2/maperrorcode.c +++ /dev/null @@ -1,91 +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 "apr_file_io.h" -#include <errno.h> -#include <string.h> - -#define INCL_DOSERRORS -#include <os2.h> - -int errormap[][2] = { - { NO_ERROR, APR_SUCCESS }, - { ERROR_FILE_NOT_FOUND, APR_ENOENT }, - { ERROR_PATH_NOT_FOUND, APR_ENOENT }, - { ERROR_TOO_MANY_OPEN_FILES, APR_EMFILE }, - { ERROR_ACCESS_DENIED, APR_EACCES }, - { ERROR_SHARING_VIOLATION, APR_EACCES }, - { ERROR_INVALID_PARAMETER, APR_EINVAL }, - { ERROR_OPEN_FAILED, APR_ENOENT }, - { ERROR_DISK_FULL, APR_ENOSPC }, - { ERROR_FILENAME_EXCED_RANGE, APR_ENAMETOOLONG }, - { ERROR_INVALID_FUNCTION, APR_EINVAL }, - { ERROR_INVALID_HANDLE, APR_EBADF }, - { ERROR_NEGATIVE_SEEK, APR_ESPIPE } -}; - -#define MAPSIZE (sizeof(errormap)/sizeof(errormap[0])) - -int os2errno( ULONG oserror ) -{ - int rv = -1, index; - - for (index=0; index<MAPSIZE && errormap[index][0] != oserror; index++); - - if (index<MAPSIZE) - rv = errormap[index][1]; - - return rv; -} diff --git a/file_io/os2/open.c b/file_io/os2/open.c deleted file mode 100644 index 090d33f62..000000000 --- a/file_io/os2/open.c +++ /dev/null @@ -1,161 +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_lib.h" -#include <string.h> - -#define INCL_DOS -#include <os2.h> - -ap_status_t file_cleanup(void *thefile) -{ - struct file_t *file = thefile; - return ap_close(file); -} - - - -ap_status_t ap_open(ap_context_t *cntxt, char *fname, ap_int32_t flag, ap_fileperms_t perm, struct file_t **new) -{ - int oflags = 0; - int mflags = OPEN_FLAGS_FAIL_ON_ERROR|OPEN_SHARE_DENYNONE; - int rv; - ULONG action; - ap_file_t *dafile = (struct file_t *)ap_palloc(cntxt, sizeof(struct file_t)); - - *new = dafile; - dafile->cntxt = cntxt; - dafile->isopen = FALSE; - dafile->validstatus = FALSE; - - if ((flag & APR_READ) && (flag & APR_WRITE)) { - mflags |= OPEN_ACCESS_READWRITE; - } else if (flag & APR_READ) { - mflags |= OPEN_ACCESS_READONLY; - } else if (flag & APR_WRITE) { - mflags |= OPEN_ACCESS_WRITEONLY; - } else { - dafile->filedes = -1; - return APR_EACCES; - } - - dafile->buffered = (flag & APR_BUFFERED) > 0; - - if (flag & APR_CREATE) { - oflags |= OPEN_ACTION_CREATE_IF_NEW; - if (!(flag & APR_EXCL)) { - if (flag & APR_APPEND) - oflags |= OPEN_ACTION_OPEN_IF_EXISTS; - else - oflags |= OPEN_ACTION_REPLACE_IF_EXISTS; - } - } - - if ((flag & APR_EXCL) && !(flag & APR_CREATE)) - return APR_EACCES; - - if (flag & APR_TRUNCATE) { - oflags |= OPEN_ACTION_REPLACE_IF_EXISTS; - } - - rv = DosOpen(fname, (HFILE *)&(dafile->filedes), &action, 0, 0, oflags, mflags, NULL); - - if (rv == 0 && (flag & APR_APPEND)) { - ULONG newptr; - rv = DosSetFilePtr(dafile->filedes, 0, FILE_END, &newptr ); - - if (rv) - DosClose(dafile->filedes); - } - - if (rv != 0) - return os2errno(rv); - - dafile->isopen = TRUE; - dafile->fname = ap_pstrdup(cntxt, fname); - ap_register_cleanup(dafile->cntxt, dafile, file_cleanup, NULL); - return APR_SUCCESS; -} - - - -ap_status_t ap_close(ap_file_t *file) -{ - ULONG rc; - - if (file && file->isopen) { - rc = DosClose(file->filedes); - - if (rc == 0) { - file->isopen = FALSE; - return APR_SUCCESS; - } else { - return os2errno(rc); - } - } - - return APR_SUCCESS; -} - - - -ap_status_t ap_remove_file(ap_context_t *cntxt, char *path) -{ - ULONG rc = DosDelete(path); - return os2errno(rc); -} - diff --git a/file_io/os2/pipe.c b/file_io/os2/pipe.c deleted file mode 100644 index 50595d700..000000000 --- a/file_io/os2/pipe.c +++ /dev/null @@ -1,98 +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> - -ap_status_t ap_create_pipe(ap_context_t *cont, struct file_t **in, struct file_t **out) -{ - ULONG filedes[2]; - ULONG rc; - - rc = DosCreatePipe(filedes, filedes+1, 4096); - - if (rc) { - return os2errno(rc); - } - - (*in) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*in)->cntxt = cont; - (*in)->filedes = filedes[0]; - (*in)->fname = ap_pstrdup(cont, "PIPE"); - (*in)->isopen = TRUE; - ap_register_cleanup(cont, *in, file_cleanup, NULL); - - (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*out)->cntxt = cont; - (*out)->filedes = filedes[1]; - (*out)->fname = ap_pstrdup(cont, "PIPE"); - (*out)->isopen = TRUE; - ap_register_cleanup(cont, *out, file_cleanup, NULL); - - return APR_SUCCESS; -} - - - -ap_status_t ap_create_namedpipe(ap_context_t *cont, char *dirpath, ap_fileperms_t perm, char **new) -{ - /* Not yet implemented, interface not suitable */ - return -1; -} - - diff --git a/file_io/os2/readwrite.c b/file_io/os2/readwrite.c deleted file mode 100644 index b3740b3e9..000000000 --- a/file_io/os2/readwrite.c +++ /dev/null @@ -1,105 +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_lib.h" - -#define INCL_DOS -#include <os2.h> - -ap_status_t ap_read(const struct file_t *thefile, void *buf, ap_ssize_t *nbytes) -{ - ULONG rc; - ULONG bytesread; - - if (!thefile->isopen) { - *nbytes = 0; - return APR_EBADF; - } - - rc = DosRead(thefile->filedes, buf, *nbytes, &bytesread); - - if (rc) { - *nbytes = 0; - return os2errno(rc); - } - - *nbytes = bytesread; - return APR_SUCCESS; -} - - - -ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) -{ - ULONG rc; - ULONG byteswritten; - - if (!thefile->isopen) { - *nbytes = 0; - return APR_EBADF; - } - - rc = DosWrite(thefile->filedes, buf, *nbytes, &byteswritten); - - if (rc) { - *nbytes = 0; - return os2errno(rc); - } - - *nbytes = byteswritten; - return APR_SUCCESS; -} diff --git a/file_io/os2/seek.c b/file_io/os2/seek.c deleted file mode 100644 index 847233dac..000000000 --- a/file_io/os2/seek.c +++ /dev/null @@ -1,88 +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_lib.h" -#include <string.h> -#include <io.h> - -#define INCL_DOS -#include <os2.h> - -int os2errno( ULONG oserror ); - -ap_status_t ap_seek(struct file_t *thefile, ap_seek_where_t where, ap_off_t *offset) -{ - if (!thefile->isopen) { - return APR_EBADF; - } - - switch (where) { - case APR_SET: - where = FILE_BEGIN; - break; - - case APR_CUR: - where = FILE_CURRENT; - break; - - case APR_END: - where = FILE_END; - break; - } - - return os2errno(DosSetFilePtr(thefile->filedes, *offset, where, (ULONG *)&offset)); -} 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 078be7da4..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 $(INCDIR)/apr_lib.h \ - $(INCDIR)/apr_config.h $(INCDIR)/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 $(INCDIR)/apr_lib.h \ - $(INCDIR)/apr_config.h $(INCDIR)/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 $(INCDIR)/apr_lib.h \ - $(INCDIR)/apr_config.h $(INCDIR)/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 $(INCDIR)/apr_lib.h $(INCDIR)/apr_config.h \ - $(INCDIR)/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 $(INCDIR)/apr_lib.h \ - $(INCDIR)/apr_config.h $(INCDIR)/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 $(INCDIR)/apr_lib.h \ - $(INCDIR)/apr_config.h $(INCDIR)/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 90f812c08..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 -1, 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 (mode == -1) { - (*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 5c224c884..000000000 --- a/file_io/unix/readwrite.c +++ /dev/null @@ -1,251 +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" -#include <errno.h> -#include <unistd.h> -#include <sys/uio.h> - -/* ***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; - } -} diff --git a/file_io/win32/.test.swp b/file_io/win32/.test.swp Binary files differdeleted file mode 100644 index 8cb1a36d9..000000000 --- a/file_io/win32/.test.swp +++ /dev/null diff --git a/file_io/win32/dir.c b/file_io/win32/dir.c deleted file mode 100644 index 1c4741147..000000000 --- a/file_io/win32/dir.c +++ /dev/null @@ -1,233 +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/>. - * - */ -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_DIRENT_H -#include <dirent.h> -#endif -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef WIN32 -#include "apr_win.h" -#include <windows.h> -#endif -#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 (CloseHandle(dir->dirhand) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -ap_status_t ap_opendir(ap_context_t *cont, const char *dirname, struct dir_t **new) -{ - char * temp; - (*new) = ap_palloc(cont, sizeof(struct dir_t)); - (*new)->cntxt = cont; - (*new)->entry = NULL; - temp = canonical_filename((*new)->cntxt, dirname); - if (temp[strlen(temp)] == '/') { - (*new)->dirname = ap_pstrcat(cont, dirname, "*", NULL); - } - else { - (*new)->dirname = ap_pstrcat(cont, dirname, "/*", NULL); - } - (*new)->dirhand = INVALID_HANDLE_VALUE; - ap_register_cleanup((*new)->cntxt, (void *)(*new), dir_cleanup, NULL); - return APR_SUCCESS; -} - -ap_status_t ap_closedir(struct dir_t *thedir) -{ - if (FindClose(thedir->dirhand)) { - ap_kill_cleanup(thedir->cntxt, thedir, dir_cleanup); - return APR_SUCCESS; - } - return APR_EEXIST; -} - -ap_status_t ap_readdir(struct dir_t *thedir) -{ - if (thedir->dirhand == INVALID_HANDLE_VALUE) { - thedir->entry = ap_palloc(thedir->cntxt, sizeof(WIN32_FIND_DATA)); - thedir->dirhand = FindFirstFile(thedir->dirname, thedir->entry); - if (thedir->dirhand == INVALID_HANDLE_VALUE) { - return APR_EEXIST; - } - return APR_SUCCESS; - } - if (FindNextFile(thedir->dirhand, thedir->entry)) { - return APR_SUCCESS; - } - return APR_EEXIST; -} - -ap_status_t ap_rewinddir(struct dir_t *thedir) -{ - ap_status_t stat; - ap_context_t *cont = thedir->cntxt; - char *temp = strdup(thedir->dirname); - temp[strlen(temp) - 2] = '\0'; /*remove the \* at the end */ - if (thedir->dirhand == INVALID_HANDLE_VALUE) { - return APR_SUCCESS; - } - if ((stat = ap_closedir(thedir)) == APR_SUCCESS) { - if ((stat = ap_opendir(cont, temp, &thedir)) == APR_SUCCESS) { - ap_readdir(thedir); - return APR_SUCCESS; - } - } - return stat; -} - -ap_status_t ap_make_dir(ap_context_t *cont, const char *path, ap_fileperms_t perm) -{ - if (CreateDirectory(path, NULL)) { - return APR_SUCCESS; - } - return APR_EEXIST; -} - -ap_status_t ap_remove_dir(ap_context_t *cont, const char *path) -{ -DWORD huh; - char *temp = canonical_filename(cont, path); - if (RemoveDirectory(temp)) { - return APR_SUCCESS; - } - huh = GetLastError(); - return APR_EEXIST; -} - -ap_status_t ap_dir_entry_size(struct dir_t *thedir, ap_ssize_t *size) -{ - if (thedir == NULL || thedir->entry == NULL) { - return APR_ENODIR; - } - (*size) = (thedir->entry->nFileSizeHigh * MAXDWORD) + - thedir->entry->nFileSizeLow; - return APR_SUCCESS; -} - -ap_status_t ap_dir_entry_mtime(struct dir_t *thedir, time_t *time) -{ - if (thedir == NULL || thedir->entry == NULL) { - return APR_ENODIR; - } - - *time = WinTimeToUnixTime(&thedir->entry->ftLastWriteTime); - - return APR_SUCCESS; -} - -ap_status_t ap_dir_entry_ftype(struct dir_t *thedir, ap_filetype_e *type) -{ - switch(thedir->entry->dwFileAttributes) { - case FILE_ATTRIBUTE_DIRECTORY: { - (*type) = APR_DIR; - return APR_SUCCESS; - } - case FILE_ATTRIBUTE_NORMAL: { - (*type) = APR_REG; - return APR_SUCCESS; - } - default: { - (*type) = APR_REG; /* As valid as anything else.*/ - return APR_SUCCESS; - } - } -} - -ap_status_t ap_get_dir_filename(struct dir_t *thedir, char **new) -{ - (*new) = ap_pstrdup(thedir->cntxt, thedir->entry->cFileName); - return APR_SUCCESS; -} - -ap_status_t ap_get_os_dir(struct dir_t *dir, ap_os_dir_t *thedir) -{ - if (dir == NULL) { - return APR_ENODIR; - } - thedir = dir->dirhand; - return APR_SUCCESS; -} - -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)->dirhand = thedir; - return APR_SUCCESS; -} diff --git a/file_io/win32/file_io.def b/file_io/win32/file_io.def deleted file mode 100644 index 58e099fc2..000000000 --- a/file_io/win32/file_io.def +++ /dev/null @@ -1,40 +0,0 @@ -; file_io.def : - -LIBRARY file_io -DESCRIPTION '' - -EXPORTS - ; Add new API calls to the end of this list. - ap_opendir @1 - ap_closedir @2 - ap_readdir @3 - ap_rewinddir @4 - ap_make_dir @5 - ap_remove_dir @6 - ap_dir_entry_size @7 - ap_dir_entry_mtime @8 - ap_dir_entry_ftype @9 - ap_get_dir_filename @10 - ap_get_filename @11 - ap_get_filesize @12 - ap_get_fileatime @13 - ap_get_filectime @14 - ap_get_filemtime @15 - ap_dupfile @16 - ap_getfileinfo @17 - ap_open @18 - ap_close @19 - ap_remove_file @20 - ap_create_pipe @21 - ap_read @22 - ap_write @23 - ap_seek @24 - ap_get_filedata @25 - ap_set_filedata @26 - ap_get_os_file @27 - ap_get_os_dir @28 - ap_putc @29 - ap_getc @30 - ap_fprintf @31 - ap_eof @32 -
\ No newline at end of file diff --git a/file_io/win32/file_io.dsp b/file_io/win32/file_io.dsp deleted file mode 100644 index 59bca59e8..000000000 --- a/file_io/win32/file_io.dsp +++ /dev/null @@ -1,130 +0,0 @@ -# Microsoft Developer Studio Project File - Name="file_io" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=file_io - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "file_io.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "file_io.mak" CFG="file_io - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "file_io - Win32 Release" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE "file_io - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "file_io - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 - -!ELSEIF "$(CFG)" == "file_io - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\misc\win32\Debug\misc.lib ..\..\lib\Debug\lib.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "file_io - Win32 Release" -# Name "file_io - Win32 Debug" -# Begin Source File - -SOURCE=.\dir.c -# End Source File -# Begin Source File - -SOURCE=.\file_io.def -# End Source File -# Begin Source File - -SOURCE=.\fileacc.c -# End Source File -# Begin Source File - -SOURCE=.\filedup.c -# End Source File -# Begin Source File - -SOURCE=.\fileio.h -# End Source File -# Begin Source File - -SOURCE=.\filestat.c -# End Source File -# Begin Source File - -SOURCE=.\open.c -# End Source File -# Begin Source File - -SOURCE=.\pipe.c -# End Source File -# Begin Source File - -SOURCE=.\readwrite.c -# End Source File -# Begin Source File - -SOURCE=.\seek.c -# End Source File -# End Target -# End Project diff --git a/file_io/win32/fileacc.c b/file_io/win32/fileacc.c deleted file mode 100644 index 270b397c5..000000000 --- a/file_io/win32/fileacc.c +++ /dev/null @@ -1,186 +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. */ - -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; -}*/ - -ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size) -{ - if (file != NULL) { - *size = file->size; - return APR_SUCCESS; - } - else { - *size = -1; - return APR_ENOFILE; - } -} -/* -ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm) -{ - if (file != NULL) { - *perm = file->protection; - return APR_SUCCESS; - } - else { - *perm = -1; - return APR_ENOFILE; - } -} -*/ -ap_status_t ap_get_fileatime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - *time = file->atime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -ap_status_t ap_get_filectime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - *time = file->ctime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -ap_status_t ap_get_filemtime(struct file_t *file, time_t *time) -{ - if (file != NULL) { - *time = file->mtime; - return APR_SUCCESS; - } - else { - *time = -1; - return APR_ENOFILE; - } -} - -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; - } -} - -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/win32/filedup.c b/file_io/win32/filedup.c deleted file mode 100644 index 2d3135a3b..000000000 --- a/file_io/win32/filedup.c +++ /dev/null @@ -1,87 +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> - -ap_status_t ap_dupfile(struct file_t *old_file, struct file_t **new_file) -{ - (*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; - (*new_file)->filehand = old_file->filehand; - (*new_file)->fname = ap_pstrdup(old_file->cntxt, old_file->fname); - (*new_file)->demonfname = ap_pstrdup(old_file->cntxt, old_file->demonfname); - (*new_file)->lowerdemonfname = ap_pstrdup(old_file->cntxt, old_file->lowerdemonfname); - (*new_file)->buffered = old_file->buffered; - (*new_file)->append = old_file->append; - /* (*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/win32/fileio.h b/file_io/win32/fileio.h deleted file mode 100644 index 5bb8f9a6e..000000000 --- a/file_io/win32/fileio.h +++ /dev/null @@ -1,121 +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 - -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_FCNTL_H -#include <fcntl.h> -#endif -#ifdef HAVE_TIME_H -#include <time.h> -#endif -#ifdef HAVE_DIRENT_H -#include <dirent.h> -#endif -#ifdef HAVE_UIO_H -#include <sys/uio.h> -#endif -#include "apr_win.h" -#include "apr_pools.h" -#include "apr_general.h" -#include "apr_file_io.h" -#include "apr_errno.h" - -struct file_t { - ap_context_t *cntxt; - HANDLE filehand; - char *fname; - char *demonfname; - char *lowerdemonfname; - int buffered; - int append; - 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; - HANDLE dirhand; - WIN32_FIND_DATA *entry; -}; - -struct iovec_t { - ap_context_t *cntxt; - struct iovec *iovec; -}; - -ap_status_t file_cleanup(void *); -/*mode_t get_fileperms(ap_fileperms_t); -*/ -API_EXPORT(char *) ap_os_systemcase_filename(struct context_t *pCont, - const char *szFile); -char * canonical_filename(struct context_t *pCont, const char *szFile); - -#endif /* ! FILE_IO_H */ - diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c deleted file mode 100644 index d11449de7..000000000 --- a/file_io/win32/filestat.c +++ /dev/null @@ -1,78 +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 "apr_win.h" -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_errno.h" - -ap_status_t ap_getfileinfo(struct file_t *thefile) -{ - FILETIME atime, ctime, mtime; - -/* thefile->protection = info.st_mode; - thefile->user = info.st_uid; - thefile->group = info.st_gid;*/ - thefile->size = GetFileSize(thefile->filehand, NULL); - GetFileTime(thefile->filehand, &ctime, &atime, &mtime); - thefile->atime = WinTimeToUnixTime(&atime); - thefile->mtime = WinTimeToUnixTime(&mtime); - thefile->ctime = WinTimeToUnixTime(&ctime); - return APR_SUCCESS; -} - - - diff --git a/file_io/win32/open.c b/file_io/win32/open.c deleted file mode 100644 index a539ee190..000000000 --- a/file_io/win32/open.c +++ /dev/null @@ -1,195 +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/>. - * - */ -#ifdef WIN32 -#include "apr_win.h" -#endif -#include "fileio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include <errno.h> -#include <string.h> -#include <sys/stat.h> - -ap_status_t file_cleanup(void *thefile) -{ - struct file_t *file = thefile; - if (CloseHandle(file->filehand)) { - file->filehand = INVALID_HANDLE_VALUE; - return APR_SUCCESS; - } - else { - return APR_EEXIST; - /* Are there any error conditions other than EINTR or EBADF? */ - } -} - -ap_status_t ap_open(ap_context_t *cont, char *fname, ap_int32_t flag, ap_fileperms_t perm, - struct file_t **dafile) -{ - DWORD oflags = 0; - DWORD createflags = 0; - DWORD theerror; - /*mode_t mode = get_fileperms(perm);*/ - - (*dafile) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - - (*dafile)->cntxt = cont; - - if (flag & APR_READ) { - oflags |= GENERIC_READ; - } - if (flag & APR_WRITE) { - oflags |= GENERIC_WRITE; - } - if (!(flag & APR_READ) && !(flag & APR_WRITE)) { - (*dafile)->filehand = INVALID_HANDLE_VALUE; - return APR_EACCES; - } - - if (flag & APR_BUFFERED) { - (*dafile)->buffered = FALSE; - } - (*dafile)->fname = strdup(fname); - - (*dafile)->demonfname = canonical_filename((*dafile)->cntxt, fname); - (*dafile)->lowerdemonfname = strlwr((*dafile)->demonfname); - - createflags = OPEN_ALWAYS; - if (flag & APR_CREATE) { - if (flag & APR_EXCL) { - createflags = CREATE_NEW; - } - } - if ((flag & APR_EXCL) && !(flag & APR_CREATE)) { - (*dafile)->filehand = INVALID_HANDLE_VALUE; - return APR_EACCES; - } - - if (flag & APR_APPEND) { - (*dafile)->append = 1; - } - else { - (*dafile)->append = 0; - } - - if (flag & APR_TRUNCATE) { - createflags = TRUNCATE_EXISTING; - } - - (*dafile)->filehand = CreateFile(fname, oflags, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, createflags, FILE_ATTRIBUTE_NORMAL, 0); - - if ((*dafile)->filehand == INVALID_HANDLE_VALUE) { - theerror = GetLastError(); - return APR_EEXIST; - } - (*dafile)->eof_hit = 0; - return APR_SUCCESS; -} - -ap_status_t ap_close(struct file_t *file) -{ - ap_status_t stat; - if ((stat = file_cleanup(file)) == APR_SUCCESS) { - ap_kill_cleanup(file->cntxt, file, file_cleanup); - return APR_SUCCESS; - } - return stat; -} - -ap_status_t ap_remove_file(ap_context_t *cont, char *path) -{ - char *temp = canonical_filename(cont, path); - - if (DeleteFile(temp)) { - return APR_SUCCESS; - } - else { - return APR_EEXIST; - } -} - -ap_status_t ap_get_os_file(struct file_t *file, ap_os_file_t *thefile) -{ - if (file == NULL) { - return APR_ENOFILE; - } - thefile = &(file->filehand); - return APR_SUCCESS; -} - -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)->filehand = *thefile; - return APR_SUCCESS; -} - -ap_status_t ap_eof(ap_file_t *fptr) -{ - if (fptr->eof_hit == 1) { - return APR_EOF; - } - APR_SUCCESS; -} diff --git a/file_io/win32/pipe.c b/file_io/win32/pipe.c deleted file mode 100644 index 9db2ab8d1..000000000 --- a/file_io/win32/pipe.c +++ /dev/null @@ -1,101 +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> - -ap_status_t ap_create_pipe(ap_context_t *cont, struct file_t **in, struct file_t **out) -{ - SECURITY_ATTRIBUTES sa; - - sa.nLength = sizeof(sa); - sa.bInheritHandle = TRUE; - sa.lpSecurityDescriptor = NULL; - - (*in) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*in)->cntxt = cont; - (*in)->fname = ap_pstrdup(cont, "PIPE"); - - (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); - (*out)->cntxt = cont; - (*out)->fname = ap_pstrdup(cont, "PIPE"); - - if (CreatePipe(&(*in)->filehand, &(*out)->filehand, &sa, 0) == -1) { - return errno; - } - - return APR_SUCCESS; -} - -/* -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/win32/readdir.c b/file_io/win32/readdir.c deleted file mode 100644 index c03c90d99..000000000 --- a/file_io/win32/readdir.c +++ /dev/null @@ -1,80 +0,0 @@ -#include <malloc.h> -#include <string.h> -#include <errno.h> - -#include "readdir.h" - -/********************************************************************** - * Implement dirent-style opendir/readdir/closedir on Window 95/NT - * - * Functions defined are opendir(), readdir() and closedir() with the - * same prototypes as the normal dirent.h implementation. - * - * Does not implement telldir(), seekdir(), rewinddir() or scandir(). - * The dirent struct is compatible with Unix, except that d_ino is - * always 1 and d_off is made up as we go along. - * - * The DIR typedef is not compatible with Unix. - **********************************************************************/ - -API_EXPORT(DIR *) opendir(const char *dir) -{ - DIR *dp; - char *filespec; - long handle; - int index; - - filespec = malloc(strlen(dir) + 2 + 1); - strcpy(filespec, dir); - index = strlen(filespec) - 1; - if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\')) - filespec[index] = '\0'; - strcat(filespec, "/*"); - - dp = (DIR *)malloc(sizeof(DIR)); - dp->offset = 0; - dp->finished = 0; - dp->dir = strdup(dir); - - if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) { - if (errno == ENOENT) - dp->finished = 1; - else - return NULL; - } - - dp->handle = handle; - free(filespec); - - return dp; -} - -API_EXPORT(struct dirent *) readdir(DIR *dp) -{ - if (!dp || dp->finished) return NULL; - - if (dp->offset != 0) { - if (_findnext(dp->handle, &(dp->fileinfo)) < 0) { - dp->finished = 1; - return NULL; - } - } - dp->offset++; - - strncpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME); - dp->dent.d_ino = 1; - dp->dent.d_reclen = strlen(dp->dent.d_name); - dp->dent.d_off = dp->offset; - - return &(dp->dent); -} - -API_EXPORT(int) closedir(DIR *dp) -{ - if (!dp) return 0; - _findclose(dp->handle); - if (dp->dir) free(dp->dir); - if (dp) free(dp); - - return 0; -} diff --git a/file_io/win32/readdir.h b/file_io/win32/readdir.h deleted file mode 100644 index d87fd1987..000000000 --- a/file_io/win32/readdir.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Structures and types used to implement opendir/readdir/closedir - * on Windows 95/NT. - */ - -#include <io.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> - -#ifndef API_EXPORT -# define API_EXPORT(type) __declspec(dllexport) type __stdcall -#endif - -/* struct dirent - same as Unix */ -struct dirent { - long d_ino; /* inode (always 1 in WIN32) */ - off_t d_off; /* offset to this dirent */ - unsigned short d_reclen; /* length of d_name */ - char d_name[_MAX_FNAME+1]; /* filename (null terminated) */ -}; - -/* typedef DIR - not the same as Unix */ -typedef struct { - long handle; /* _findfirst/_findnext handle */ - short offset; /* offset into directory */ - short finished; /* 1 if there are not more files */ - struct _finddata_t fileinfo; /* from _findfirst/_findnext */ - char *dir; /* the dir we are reading */ - struct dirent dent; /* the dirent to return */ -} DIR; - -/* Function prototypes */ -API_EXPORT(DIR *) opendir(const char *); -API_EXPORT(struct dirent *) readdir(DIR *); -API_EXPORT(int) closedir(DIR *); diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c deleted file mode 100644 index 3e8c05a8b..000000000 --- a/file_io/win32/readwrite.c +++ /dev/null @@ -1,181 +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" -#include <windows.h> - -ap_status_t ap_read(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) -{ - DWORD bread; - int lasterror; - - if (thefile->filehand == INVALID_HANDLE_VALUE) { - *nbytes = -1; - return APR_EBADF; - } - - if (ReadFile(thefile->filehand, buf, *nbytes, &bread, NULL)) { - *nbytes = bread; - return APR_SUCCESS; - } - *nbytes = -1; - lasterror = GetLastError(); - return APR_EEXIST; -} - -ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) -{ - DWORD bwrote; - FILETIME atime, mtime, ctime; - - if (thefile->filehand == INVALID_HANDLE_VALUE) { - *nbytes = -1; - return APR_EBADF; - } - - if (WriteFile(thefile->filehand, buf, *nbytes, &bwrote, NULL)) { - if (strcmp(thefile->fname, "PIPE")) { - FlushFileBuffers(thefile->filehand); - thefile->size = GetFileSize(thefile->filehand, NULL); - GetFileTime(thefile->filehand, &ctime, &atime, &mtime); - thefile->atime = WinTimeToUnixTime(&atime); - thefile->mtime = WinTimeToUnixTime(&mtime); - thefile->ctime = WinTimeToUnixTime(&ctime); - } - *nbytes = bwrote; - return APR_SUCCESS; - } - (*nbytes) = -1; - return APR_EEXIST; -} -/* -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; - 12} - else { - *iocnt = bytes; - return APR_SUCCESS; - } -} -*/ - -ap_status_t ap_putc(ap_file_t *thefile, char ch) -{ - DWORD bwrote; - - if (WriteFile(thefile->filehand, &ch, 1, &bwrote, NULL)) { - return APR_EEXIST; - } - return APR_SUCCESS; -} - -ap_status_t ap_getc(ap_file_t *thefile, char *ch) -{ - DWORD bread; - if (!ReadFile(thefile->filehand, ch, 1, &bread, NULL)) { - return APR_EEXIST; - } - if (bread == 0) { - thefile->eof_hit = TRUE; - return APR_EOF; - } - 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/win32/seek.c b/file_io/win32/seek.c deleted file mode 100644 index fe1439c32..000000000 --- a/file_io/win32/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> - -ap_status_t ap_seek(struct file_t *thefile, ap_seek_where_t where, ap_off_t *offset) -{ - DWORD howmove; - DWORD rv; - - switch(where) { - case APR_SET: { - howmove = FILE_BEGIN; - break; - } - case APR_CUR: { - howmove = FILE_CURRENT; - break; - } - case APR_END: { - howmove = FILE_END; - break; - } - } - - rv = SetFilePointer(thefile->filehand, *offset,NULL, howmove); - if (rv == -1) { - *offset = -1; - return APR_EEXIST; - } - else { - *offset = rv; - return APR_SUCCESS; - } -} |