You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 1999/05/24 19:28:20 UTC
cvs commit: apache-apr/include apr_errno.h apr_file_io.h
rbb 99/05/24 10:28:19
Modified: apr/file_io/unix dir.c fileacc.c filedup.c filestat.c open.c
pipe.c readwrite.c seek.c
apr/test testfile.c
include apr_errno.h apr_file_io.h
Log:
All file functions now return a status value, and those status values are
defined in apr_errno.h in a platform independant way. The test program for
file functions has also been updated.
Revision Changes Path
1.10 +43 -35 apache-apr/apr/file_io/unix/dir.c
Index: dir.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/dir.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- dir.c 1999/05/24 02:03:59 1.9
+++ dir.c 1999/05/24 17:28:15 1.10
@@ -68,11 +68,11 @@
return APR_SUCCESS;
}
else {
- return APR_FAILURE;
+ return errno;
}
}
-struct dir_t *ap_opendir(ap_context_t *cont, const char *dirname)
+ap_status_t ap_opendir(ap_context_t *cont, const char *dirname, struct dir_t **new)
{
struct dir_t *thedir = (struct dir_t *)ap_palloc(cont->pool, sizeof(struct dir_t));
@@ -83,28 +83,32 @@
if (thedir->dirstruct == NULL) {
thedir->dirstruct = NULL;
- return NULL;
+ *new = thedir;
+ return errno;
}
else {
ap_register_cleanup(thedir->cntxt->pool, (void *)thedir, dir_cleanup, NULL);
- return thedir;
+ *new = thedir;
+ return APR_SUCCESS;
}
}
ap_status_t ap_closedir(struct dir_t *thedir)
{
- if (dir_cleanup(thedir) == APR_SUCCESS) {
+ ap_status_t rv;
+
+ if ((rv = dir_cleanup(thedir)) == APR_SUCCESS) {
ap_kill_cleanup(thedir->cntxt->pool, thedir, dir_cleanup);
return APR_SUCCESS;
}
- return APR_FAILURE;
+ return rv;
}
ap_status_t ap_readdir(struct dir_t *thedir)
{
thedir->entry = readdir(thedir->dirstruct);
if (thedir->entry == NULL) {
- return APR_FAILURE;
+ return errno;
}
return APR_SUCCESS;
}
@@ -122,7 +126,7 @@
return APR_SUCCESS;
}
else {
- return APR_FAILURE;
+ return errno;
}
}
@@ -132,86 +136,90 @@
return APR_SUCCESS;
}
else {
- return APR_FAILURE;
+ return errno;
}
}
-ap_ssize_t ap_dir_entry_size(struct dir_t *thedir)
+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) {
- errno = ENOFILE;
- return -1;
+ *size = -1;
+ return APR_ENOFILE;
}
fname = ap_pstrcat(thedir->cntxt->pool, thedir->dirname, "/",
thedir->entry->d_name, NULL);
if (stat(fname, &filestat) == -1) {
- errno = ENOSTAT;
- return -1;
+ *size = -1;
+ return APR_ENOSTAT;
}
- return filestat.st_size;
+ *size = filestat.st_size;
+ return APR_SUCCESS;
}
-time_t ap_dir_entry_mtime(struct dir_t *thedir)
+ap_status_t ap_dir_entry_mtime(struct dir_t *thedir, time_t *time)
{
struct stat filestat;
char *fname = NULL;
if (thedir->entry == NULL) {
- errno = ENOFILE;
- return -1;
+ *time = -1;
+ return APR_ENOFILE;
}
fname = ap_pstrcat(thedir->cntxt->pool, thedir->dirname, "/",
thedir->entry->d_name, NULL);
if (stat(fname, &filestat) == -1) {
- errno = ENOSTAT;
- return -1;
+ *time = -1;
+ return APR_ENOSTAT;
}
- return filestat.st_mtime;
+ *time = filestat.st_mtime;
+ return APR_SUCCESS;
}
-ap_filetype_e ap_dir_entry_ftype(struct dir_t *thedir)
+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) {
- errno = ENOFILE;
- return -1;
+ *type = APR_REG;
+ return APR_ENOFILE;
}
fname = ap_pstrcat(thedir->cntxt->pool, thedir->dirname, "/",
thedir->entry->d_name, NULL);
if (stat(fname, &filestat) == -1) {
- errno = ENOSTAT;
- return -1;
+ *type = APR_REG;
+ return APR_ENOSTAT;
}
if (S_ISREG(filestat.st_mode))
- return APR_REG;
+ *type = APR_REG;
if (S_ISDIR(filestat.st_mode))
- return APR_DIR;
+ *type = APR_DIR;
if (S_ISCHR(filestat.st_mode))
- return APR_CHR;
+ *type = APR_CHR;
if (S_ISBLK(filestat.st_mode))
- return APR_BLK;
+ *type = APR_BLK;
if (S_ISFIFO(filestat.st_mode))
- return APR_PIPE;
+ *type = APR_PIPE;
if (S_ISLNK(filestat.st_mode))
- return APR_LNK;
+ *type = APR_LNK;
if (S_ISSOCK(filestat.st_mode))
- return APR_SOCK;
+ *type = APR_SOCK;
+ return APR_SUCCESS;
}
-char * ap_get_dir_filename(struct dir_t *thedir)
+ap_status_t ap_get_dir_filename(struct dir_t *thedir, char **new)
{
char *name = (char *)ap_palloc(thedir->cntxt->pool, strlen(thedir->entry->d_name));
name = ap_pstrdup(thedir->cntxt->pool, thedir->entry->d_name);
- return name;
+ *new = name;
+ return APR_SUCCESS;
}
1.9 +50 -13 apache-apr/apr/file_io/unix/fileacc.c
Index: fileacc.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/fileacc.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- fileacc.c 1999/05/24 02:03:59 1.8
+++ fileacc.c 1999/05/24 17:28:15 1.9
@@ -62,13 +62,15 @@
/* A file to put ALL of the accessor functions for struct file_t types. */
-char * ap_get_filename(struct file_t *thefile)
+ap_status_t ap_get_filename(struct file_t *thefile, char **new)
{
if (thefile != NULL) {
- return thefile->fname;
+ *new = thefile->fname;
+ return APR_SUCCESS;
}
else {
- return NULL;
+ *new = NULL;
+ return APR_ENOFILE;
}
}
@@ -100,28 +102,63 @@
return rv;
}
-ap_ssize_t ap_get_filesize(struct file_t *file)
+ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size)
{
- return file->size;
+ if (file != NULL) {
+ *size = file->size;
+ return APR_SUCCESS;
+ }
+ else {
+ *size = -1;
+ return APR_ENOFILE;
+ }
}
-ap_fileperms_t ap_get_fileperms(struct file_t *file)
+ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm)
{
- return file->protection;
+ if (file != NULL) {
+ *perm = file->protection;
+ return APR_SUCCESS;
+ }
+ else {
+ *perm = -1;
+ return APR_ENOFILE;
+ }
}
-time_t ap_get_fileatime(struct file_t *file)
+ap_status_t ap_get_fileatime(struct file_t *file, time_t *time)
{
- return file->atime;
+ if (file != NULL) {
+ *time = file->atime;
+ return APR_SUCCESS;
+ }
+ else {
+ *time = -1;
+ return APR_ENOFILE;
+ }
}
-time_t ap_get_filectime(struct file_t *file)
+ap_status_t ap_get_filectime(struct file_t *file, time_t *time)
{
- return file->ctime;
+ if (file != NULL) {
+ *time = file->ctime;
+ return APR_SUCCESS;
+ }
+ else {
+ *time = -1;
+ return APR_ENOFILE;
+ }
}
-time_t ap_get_filemtime(struct file_t *file)
+ap_status_t ap_get_filemtime(struct file_t *file, time_t *time)
{
- return file->mtime;
+ if (file != NULL) {
+ *time = file->mtime;
+ return APR_SUCCESS;
+ }
+ else {
+ *time = -1;
+ return APR_ENOFILE;
+ }
}
1.12 +5 -3 apache-apr/apr/file_io/unix/filedup.c
Index: filedup.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/filedup.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- filedup.c 1999/05/24 02:03:59 1.11
+++ filedup.c 1999/05/24 17:28:16 1.12
@@ -58,14 +58,14 @@
#include "apr_general.h"
#include <string.h>
-struct file_t *ap_dupfile(struct file_t *old_file)
+ap_status_t ap_dupfile(struct file_t *old_file, struct file_t **new)
{
struct file_t *new_file = (struct file_t *)ap_palloc(old_file->cntxt->pool,
sizeof(struct file_t));
if (new_file == NULL) {
- errno = ENOMEM;
- return NULL;
+ *new = NULL;
+ return APR_ENOMEM;
}
old_file->filedes = dup(new_file->filedes);
old_file->fname = strdup(new_file->fname);
@@ -78,5 +78,7 @@
old_file->mtime = new_file->mtime;
old_file->ctime = new_file->ctime;
ap_register_cleanup(old_file->cntxt->pool, (void *)new_file, file_cleanup, NULL);
+ *new = new_file;
+ return APR_SUCCESS;
}
1.6 +2 -4 apache-apr/apr/file_io/unix/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/filestat.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- filestat.c 1999/05/24 02:04:00 1.5
+++ filestat.c 1999/05/24 17:28:16 1.6
@@ -74,8 +74,7 @@
return APR_SUCCESS;
}
else {
- errno = ENOSTAT;
- return APR_FAILURE;
+ return APR_ENOSTAT;
}
}
@@ -95,8 +94,7 @@
return APR_SUCCESS;
}
else {
- errno = ENOSTAT;
- return APR_FAILURE;
+ return APR_ENOSTAT;
}
}
1.23 +17 -13 apache-apr/apr/file_io/unix/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/open.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- open.c 1999/05/24 02:04:00 1.22
+++ open.c 1999/05/24 17:28:16 1.23
@@ -68,12 +68,12 @@
return APR_SUCCESS;
}
else {
- return APR_FAILURE;
+ return errno;
/* Are there any error conditions other than EINTR or EBADF? */
}
}
-struct file_t *ap_open(ap_context_t *cont, char *fname, ap_int32_t flag, ap_fileperms_t perm)
+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 file_t *dafile;
@@ -94,9 +94,9 @@
oflags = O_WRONLY;
}
else {
- errno = EACCES;
dafile->filedes = -1;
- return NULL;
+ *new = dafile;
+ return APR_EACCES;
}
if (flag & APR_BUFFERED) {
@@ -111,9 +111,9 @@
}
}
if ((flag & APR_EXCL) && !(flag & APR_CREATE)) {
- errno = EACCES;
dafile->filedes = -1;
- return NULL;
+ *new = dafile;
+ return APR_EACCES;
}
if (flag & APR_APPEND) {
@@ -127,27 +127,31 @@
if (dafile->filedes < 0) {
dafile->filedes = -1;
- return NULL;
+ *new = dafile;
+ return errno;
}
if (ap_updatefileinfo(dafile) == APR_SUCCESS) {
ap_register_cleanup(dafile->cntxt->pool, (void *)dafile, file_cleanup, NULL);
- return dafile;
+ *new = dafile;
+ return APR_SUCCESS;
}
else {
- errno = ENOSTAT;
dafile->filedes = -1;
- return NULL;
+ *new = dafile;
+ return APR_ENOSTAT;
}
}
ap_status_t ap_close(struct file_t *file)
{
- if (file_cleanup(file) == APR_SUCCESS) {
+ ap_status_t rv;
+
+ if ((rv = file_cleanup(file)) == APR_SUCCESS) {
ap_kill_cleanup(file->cntxt->pool, file, file_cleanup);
return APR_SUCCESS;
}
- return APR_FAILURE;
+ return rv;
}
ap_status_t ap_remove_file(ap_context_t *cont, char *path)
@@ -156,7 +160,7 @@
return APR_SUCCESS;
}
else {
- return APR_FAILURE;
+ return errno;
}
}
1.8 +6 -4 apache-apr/apr/file_io/unix/pipe.c
Index: pipe.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/pipe.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- pipe.c 1999/05/21 19:53:14 1.7
+++ pipe.c 1999/05/24 17:28:16 1.8
@@ -67,7 +67,7 @@
int filedes[2];
if (pipe(filedes) == -1) {
- return APR_FAILURE;
+ return errno;
}
in->cntxt = cont;
@@ -81,16 +81,18 @@
return APR_SUCCESS;
}
-char *ap_create_namedpipe(ap_context_t *cont, char *dirpath, ap_fileperms_t perm)
+ap_status_t ap_create_namedpipe(ap_context_t *cont, char *dirpath, ap_fileperms_t perm, char **new)
{
char *tmp;
mode_t mode = get_fileperms(perm);
tmp = tempnam(dirpath, NULL);
if (mkfifo(tmp, mode) == -1) {
- return NULL;
+ *new = NULL;
+ return errno;
}
- return tmp;
+ *new = tmp;
+ return APR_SUCCESS;
}
1.10 +18 -14 apache-apr/apr/file_io/unix/readwrite.c
Index: readwrite.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/readwrite.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- readwrite.c 1999/05/24 02:04:00 1.9
+++ readwrite.c 1999/05/24 17:28:16 1.10
@@ -61,31 +61,32 @@
#include <unistd.h>
#include <sys/uio.h>
-ap_ssize_t ap_read(struct file_t *thefile, void *buf, ap_ssize_t nbytes)
+ap_status_t ap_read(struct file_t *thefile, void *buf, ap_ssize_t *nbytes)
{
ap_size_t rv;
if (thefile->filedes < 0) {
- errno = EBADF;
- return -1;
+ *nbytes = -1;
+ return APR_EBADF;
}
- rv = read(thefile->filedes, buf, nbytes);
+ rv = read(thefile->filedes, buf, *nbytes);
- return rv;
+ *nbytes = rv;
+ return APR_SUCCESS;
}
-ap_ssize_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t nbytes)
+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) {
- errno = EBADF;
- return -1;
+ *nbytes = -1;
+ return APR_EBADF;
}
- rv = write(thefile->filedes, buf, nbytes);
+ rv = write(thefile->filedes, buf, *nbytes);
if (stat(thefile->fname, &info) == 0) {
thefile->size = info.st_size;
@@ -93,17 +94,20 @@
thefile->mtime = info.st_mtime;
thefile->ctime = info.st_ctime;
}
- return rv;
+ *nbytes = rv;
+ return APR_SUCCESS;
}
-ap_ssize_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t iocnt)
+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) {
- return APR_FAILURE;
+ if ((bytes = writev(thefile->filedes, vec->iovec, *iocnt)) < 0) {
+ *iocnt = bytes;
+ return errno;
}
else {
- return bytes;
+ *iocnt = bytes;
+ return APR_SUCCESS;
}
}
1.6 +11 -2 apache-apr/apr/file_io/unix/seek.c
Index: seek.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/file_io/unix/seek.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- seek.c 1999/05/24 02:04:00 1.5
+++ seek.c 1999/05/24 17:28:16 1.6
@@ -58,7 +58,16 @@
#include <errno.h>
#include <string.h>
-ap_off_t ap_seek(struct file_t *thefile, ap_off_t offset, ap_seek_where_t where)
+ap_status_t ap_seek(struct file_t *thefile, ap_seek_where_t where, ap_off_t *offset)
{
- return lseek(thefile->filedes, offset, where);
+ ap_off_t rv;
+ rv = lseek(thefile->filedes, *offset, where);
+ if (rv == -1) {
+ *offset = -1;
+ return errno;
+ }
+ else {
+ *offset = rv;
+ return APR_SUCCESS;
+ }
}
1.19 +44 -39 apache-apr/apr/test/testfile.c
Index: testfile.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/test/testfile.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- testfile.c 1999/05/24 02:04:12 1.18
+++ testfile.c 1999/05/24 17:28:18 1.19
@@ -71,8 +71,10 @@
ap_status_t status = 0;
ap_int32_t flag = APR_READ | APR_WRITE | APR_CREATE;
ap_uint64_t rv = 0;
- ap_uint64_t nbytes = 0;
+ ap_ssize_t nbytes = 0;
+ ap_off_t zer = 0;
char buf;
+ char *str;
char *filename = "test.fil";
context = ap_initialize(NULL);
@@ -80,8 +82,7 @@
fprintf(stdout, "Testing file functions.\n");
fprintf(stdout, "\tOpening file.......");
- thefile = ap_open(context, filename, flag, APR_UREAD | APR_UWRITE | APR_GREAD);
- if (thefile == NULL) {
+ if (ap_open(context, filename, flag, APR_UREAD | APR_UWRITE | APR_GREAD, &thefile) != APR_SUCCESS) {
perror("Didn't open file");
exit(-1);
}
@@ -94,7 +95,8 @@
fprintf(stderr, "Bad file des\n");
exit(-1);
}
- if (strcmp(ap_get_filename(thefile), filename) != 0) {
+ ap_get_filename(thefile, &str);
+ if (strcmp(str, filename) != 0) {
fprintf(stderr, "wrong filename\n");
exit(-1);
}
@@ -105,12 +107,11 @@
fprintf(stdout, "\tWriting to file.......");
nbytes = (ap_uint64_t)strlen("this is a test");
- rv = ap_write(thefile, "this is a test", nbytes);
- if (rv == -1) {
+ if (ap_write(thefile, "this is a test", &nbytes) != APR_SUCCESS) {
perror("something's wrong");
exit(-1);
}
- if (rv != nbytes) {
+ if (nbytes != strlen("this is a test")) {
fprintf(stderr, "didn't write properly.\n");
exit(-1);
}
@@ -119,7 +120,8 @@
}
fprintf(stdout, "\tMoving to start of file.......");
- if (ap_seek(thefile, 0, SEEK_SET) != 0) {
+ zer = 0;
+ if (ap_seek(thefile, SEEK_SET, &zer) != 0) {
perror("couldn't seek to beginning of file.");
exit(-1);
}
@@ -129,13 +131,11 @@
fprintf(stdout, "\tReading from the file.......");
nbytes = (ap_uint64_t)strlen("this is a test");
- rv = ap_read(thefile, &buf, nbytes);
- if (rv == -1) {
+ if (ap_read(thefile, &buf, &nbytes) != APR_SUCCESS) {
perror("something's wrong");
exit(-1);
}
- nbytes = (ap_uint64_t)strlen("this is a test");
- if (rv != nbytes) {
+ if (nbytes != strlen("this is a test")) {
fprintf(stderr, "didn't read properly.\n");
exit(-1);
}
@@ -145,7 +145,7 @@
fprintf(stdout, "\tClosing File.......");
status = ap_close(thefile);
- if (status == APR_FAILURE) {
+ if (status != APR_SUCCESS) {
fprintf(stderr, "Couldn't close the file\n");
exit(-1);
}
@@ -155,7 +155,7 @@
fprintf(stdout, "\tDeleting file.......");
status = ap_remove_file(context, filename);
- if (status == APR_FAILURE) {
+ if (status != APR_SUCCESS) {
fprintf(stderr, "Couldn't delete the file\n");
exit(-1);
}
@@ -164,8 +164,8 @@
}
fprintf(stdout, "\tMaking sure it's gone.......");
- thefile = ap_open(context, filename, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD);
- if (thefile != NULL) {
+ status = ap_open(context, filename, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, &thefile);
+ if (status == APR_SUCCESS) {
fprintf(stderr, "I could open the file for some reason?\n");
exit(-1);
}
@@ -183,23 +183,24 @@
{
ap_file_t *thefile;
ap_int32_t flag = APR_READ | APR_WRITE | APR_CREATE;
-
- thefile = ap_open(context, "testdel", flag, APR_UREAD | APR_UWRITE | APR_GREAD);
- if (thefile == NULL) {
- return APR_FAILURE;
+ ap_status_t stat;
+
+ stat = ap_open(context, "testdel", flag, APR_UREAD | APR_UWRITE | APR_GREAD, &thefile);
+ if (stat != APR_SUCCESS) {
+ return stat;
}
- if (ap_remove_file(context, "testdel") == APR_FAILURE) {
- return APR_FAILURE;
+ if ((stat = ap_remove_file(context, "testdel")) != APR_SUCCESS) {
+ return stat;
}
- if (ap_close(thefile) == APR_FAILURE) {
- return APR_FAILURE;
+ if ((stat = ap_close(thefile)) != APR_SUCCESS) {
+ return stat;
}
- thefile = ap_open(context, "testdel", APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD);
- if (thefile != NULL) {
- return APR_FAILURE;
+ stat = ap_open(context, "testdel", APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, &thefile);
+ if (stat == APR_SUCCESS) {
+ return stat;
}
return APR_SUCCESS;
@@ -210,12 +211,13 @@
ap_dir_t *temp;
ap_file_t *file;
ap_ssize_t bytes;
+ ap_filetype_e type;
char *fname;
fprintf(stdout, "Testing Directory functions.\n");
fprintf(stdout, "\tMakeing Directory.......");
- if (ap_make_dir(context, "testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE | APR_GREAD | APR_GWRITE | APR_GEXECUTE | APR_WREAD | APR_WWRITE | APR_WEXECUTE) == APR_FAILURE) {
+ if (ap_make_dir(context, "testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE | APR_GREAD | APR_GWRITE | APR_GEXECUTE | APR_WREAD | APR_WWRITE | APR_WEXECUTE) != APR_SUCCESS) {
fprintf(stderr, "Could not create directory\n");
return -1;
}
@@ -223,14 +225,15 @@
fprintf(stdout, "OK\n");
}
- if ((file = ap_open(context, "testdir/testfile", APR_READ | APR_WRITE | APR_CREATE, APR_UREAD | APR_UWRITE | APR_UEXECUTE)) == NULL) {;
+ if (ap_open(context, "testdir/testfile", APR_READ | APR_WRITE | APR_CREATE, APR_UREAD | APR_UWRITE | APR_UEXECUTE, &file) != APR_SUCCESS) {;
return -1;
}
- bytes = ap_write(file, "Another test!!", strlen("Another test!!"));
+ bytes = strlen("Another test!!!");
+ ap_write(file, "Another test!!", &bytes);
fprintf(stdout, "\tOpening Directory.......");
- if ((temp = ap_opendir(context, "testdir")) == NULL) {
+ if (ap_opendir(context, "testdir", &temp) != APR_SUCCESS) {
fprintf(stderr, "Could not open directory\n");
return -1;
}
@@ -239,7 +242,7 @@
}
fprintf(stdout, "\tReading Directory.......");
- if ((ap_readdir(temp)) == APR_FAILURE) {
+ if ((ap_readdir(temp)) != APR_SUCCESS) {
fprintf(stderr, "Could not read directory\n");
return -1;
}
@@ -254,7 +257,7 @@
* files that are here.
*/
ap_readdir(temp);
- fname = ap_get_dir_filename(temp);
+ ap_get_dir_filename(temp, &fname);
} while (fname[0] == '.');
if (strcmp(fname, "testfile")) {
fprintf(stderr, "Got wrong file name %s\n", fname);
@@ -263,15 +266,17 @@
fprintf(stdout, "OK\n");
fprintf(stdout, "\t\tFile type.......");
- if (ap_dir_entry_ftype(temp) != APR_REG) {
+ ap_dir_entry_ftype(temp, &type);
+ if (type != APR_REG) {
fprintf(stderr, "Got wrong file type\n");
return -1;
}
fprintf(stdout, "OK\n");
fprintf(stdout, "\t\tFile size.......");
- if (ap_dir_entry_size(temp) != bytes) {
- fprintf(stderr, "Got wrong file size %d\n", ap_dir_entry_size(temp));
+ ap_dir_entry_size(temp, &bytes);
+ if (bytes != strlen("Another test!!!")) {
+ fprintf(stderr, "Got wrong file size %d\n", bytes);
return -1;
}
fprintf(stdout, "OK\n");
@@ -281,7 +286,7 @@
fprintf(stdout, "OK\n");
fprintf(stdout, "\tClosing Directory.......");
- if (ap_closedir(temp) == APR_FAILURE) {
+ if (ap_closedir(temp) != APR_SUCCESS) {
fprintf(stderr, "Could not close directory\n");
return -1;
}
@@ -290,7 +295,7 @@
}
fprintf(stdout, "\tRemoving file from directory.......");
- if (ap_remove_file(context, "testdir/testfile") == APR_FAILURE) {
+ if (ap_remove_file(context, "testdir/testfile") != APR_SUCCESS) {
fprintf(stderr, "Could not remove file\n");
return -1;
}
@@ -299,7 +304,7 @@
}
fprintf(stdout, "\tRemoving Directory.......");
- if (ap_remove_dir(context, "testdir") == APR_FAILURE) {
+ if (ap_remove_dir(context, "testdir") != APR_SUCCESS) {
fprintf(stderr, "Could not create directory\n");
return -1;
}
1.11 +302 -6 apache-apr/include/apr_errno.h
Index: apr_errno.h
===================================================================
RCS file: /home/cvs/apache-apr/include/apr_errno.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- apr_errno.h 1999/05/17 11:45:16 1.10
+++ apr_errno.h 1999/05/24 17:28:19 1.11
@@ -67,13 +67,309 @@
*/
typedef int ap_status_t;
-#define APR_SUCCESS 1
-#define APR_FAILURE -1
+#define APR_SUCCESS 0
-#define ENOSTAT 4001
-#define ENOPOOL 4002
-#define ENOFILE 4003
-#define EBAD_DATE 4004
+#ifdef EACCES
+#define APR_EACCES EACCES
+#else
+#define APR_EACCES 3000
+#endif
+
+#ifdef EEXIST
+#define APR_EEXIST EEXIST
+#else
+#define APR_EEXIST 3001
+#endif
+
+#ifdef EISDIR
+#define APR_EISDIR EISDIR
+#else
+#define APR_EISDIR 3002
+#endif
+
+#ifdef ENAMETOOLONG
+#define APR_ENAMETOOLONG ENAMETOOLONG
+#else
+#define APR_ENAMETOOLONG 3003
+#endif
+
+#ifdef ENOENT
+#define APR_ENOENT ENOENT
+#else
+#define APR_ENOENT 3004
+#endif
+
+#ifdef ENOTDIR
+#define APR_ENOTDIR ENOTDIR
+#else
+#define APR_ENOTDIR 3005
+#endif
+
+#ifdef ENXIO
+#define APR_ENXIO ENXIO
+#else
+#define APR_ENXIO 3006
+#endif
+
+#ifdef ENODEV
+#define APR_ENODEV ENODEV
+#else
+#define APR_ENODEV 3007
+#endif
+
+#ifdef EROFS
+#define APR_EROFS EROFS
+#else
+#define APR_EROFS 3008
+#endif
+
+#ifdef ETXTBSY
+#define APR_ETXTBSY ETXTBSY
+#else
+#define APR_ETXTBSY 3009
+#endif
+
+#ifdef EFAULT
+#define APR_EFAULT EFAULT
+#else
+#define APR_EFAULT 3010
+#endif
+
+#ifdef ELOOP
+#define APR_ELOOP ELOOP
+#else
+#define APR_ELOOP 3011
+#endif
+
+#ifdef ENOSPC
+#define APR_ENOSPC ENOSPC
+#else
+#define APR_ENOSPC 3012
+#endif
+
+#ifdef ENONOMEM
+#define APR_ENOMEM ENOMEM
+#else
+#define APR_ENOMEM 3013
+#endif
+
+#ifdef EMFILE
+#define APR_EMFILE EMFILE
+#else
+#define APR_EMFILE 3014
+#endif
+
+#ifdef ENFILE
+#define APR_ENFILE ENFILE
+#else
+#define APR_ENFILE 3015
+#endif
+
+#ifdef EBADF
+#define APR_EBADF EBADF
+#else
+#define APR_EBADF 3016
+#endif
+
+#ifdef EPERM
+#define APR_EPERM EPERM
+#else
+#define APR_EPERM 3017
+#endif
+
+#ifdef EIO
+#define APR_EIO EIO
+#else
+#define APR_EIO 3018
+#endif
+
+#ifdef EINVAL
+#define APR_EINVAL EINVAL
+#else
+#define APR_EINVAL 3019
+#endif
+
+#ifdef ENOEMPTY
+#define APR_ENOEMPTY ENOEMPTY
+#else
+#define APR_ENOEMPTY 3020
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef ESPIPE
+#define APR_ESPIPE ESPIPE
+#else
+#define APR_ESPIPE 3022
+#endif
+/*
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+
+#ifdef EBUSY
+#define APR_EBUSY EBUSY
+#else
+#define APR_EBUSY 3021
+#endif
+*/
+
+
+
+#define APR_ENOSTAT 4001
+#define APR_ENOPOOL 4002
+#define APR_ENOFILE 4003
+#define APR_EBADDATE 4004
#ifdef __cplusplus
}
1.29 +19 -19 apache-apr/include/apr_file_io.h
Index: apr_file_io.h
===================================================================
RCS file: /home/cvs/apache-apr/include/apr_file_io.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- apr_file_io.h 1999/05/24 02:04:23 1.28
+++ apr_file_io.h 1999/05/24 17:28:19 1.29
@@ -104,20 +104,20 @@
typedef ap_int32_t ap_fileperms_t;
/* Function definitions */
-ap_file_t *ap_open(ap_context_t *, char *, ap_int32_t, ap_fileperms_t);
+ap_status_t ap_open(ap_context_t *, char *, ap_int32_t, ap_fileperms_t, ap_file_t **);
ap_status_t ap_close(ap_file_t *);
ap_status_t ap_remove_file(ap_context_t *, char *);
-ap_ssize_t ap_read(ap_file_t *, void *, ap_ssize_t);
-ap_ssize_t ap_write(ap_file_t *, void *, ap_ssize_t);
-ap_ssize_t ap_writev(ap_file_t *, const ap_iovec_t *, ap_ssize_t);
+ap_status_t ap_read(ap_file_t *, void *, ap_ssize_t *);
+ap_status_t ap_write(ap_file_t *, void *, ap_ssize_t *);
+ap_status_t ap_writev(ap_file_t *, const ap_iovec_t *, ap_ssize_t *);
-ap_file_t *ap_dupfile(ap_file_t *);
+ap_status_t ap_dupfile(ap_file_t *, ap_file_t **);
ap_status_t ap_getfileinfo(ap_file_t *);
ap_status_t ap_updatefileinfo(ap_file_t *);
-ap_off_t ap_seek(ap_file_t *, ap_off_t, ap_seek_where_t);
+ap_status_t ap_seek(ap_file_t *, ap_seek_where_t, ap_off_t *);
-ap_dir_t *ap_opendir(ap_context_t *, const char *);
+ap_status_t ap_opendir(ap_context_t *, const char *, ap_dir_t **);
ap_status_t ap_closedir(ap_dir_t *);
ap_status_t ap_readdir(ap_dir_t *);
ap_status_t ap_rewinddir(ap_dir_t *);
@@ -125,21 +125,21 @@
ap_status_t ap_remove_dir(ap_context_t *, const char *);
ap_status_t ap_create_pipe(ap_context_t *, ap_file_t *, ap_file_t *);
-char *ap_create_namedpipe(ap_context_t *, char *, ap_fileperms_t);
+ap_status_t ap_create_namedpipe(ap_context_t *, char *, ap_fileperms_t, char **);
/*accessor and general file_io functions. */
-char *ap_get_filename(ap_file_t *);
-char *ap_get_dir_filename(ap_dir_t *);
+ap_status_t ap_get_filename(ap_file_t *, char **);
+ap_status_t ap_get_dir_filename(ap_dir_t *, char **);
-ap_ssize_t ap_dir_entry_size(ap_dir_t *);
-time_t ap_dir_entry_mtime(ap_dir_t *);
-ap_filetype_e ap_dir_entry_ftype(ap_dir_t *);
-
-ap_ssize_t ap_get_filesize(ap_file_t *);
-ap_fileperms_t ap_get_fileperms(ap_file_t *);
-time_t ap_get_fileatime(ap_file_t *);
-time_t ap_get_filectime(ap_file_t *);
-time_t ap_get_filemtime(ap_file_t *);
+ap_status_t ap_dir_entry_size(ap_dir_t *, ap_ssize_t *);
+ap_status_t ap_dir_entry_mtime(ap_dir_t *, time_t *);
+ap_status_t ap_dir_entry_ftype(ap_dir_t *, ap_filetype_e *);
+
+ap_status_t ap_get_filesize(ap_file_t *, ap_ssize_t *);
+ap_status_t ap_get_fileperms(ap_file_t *, ap_fileperms_t *);
+ap_status_t ap_get_fileatime(ap_file_t *,time_t *);
+ap_status_t ap_get_filectime(ap_file_t *,time_t *);
+ap_status_t ap_get_filemtime(ap_file_t *,time_t *);
#ifdef __cplusplus
}