version 1.111, 1996/02/14 00:33:35
|
version 1.112, 1996/03/04 03:12:41
|
Line 25
|
Line 25
|
*/ |
*/ |
|
|
/* Library Includes */ |
/* Library Includes */ |
#include "tcp.h" |
#include "sysdep.h" |
#include "HTUtils.h" |
#include "HTUtils.h" |
#include "HTString.h" |
#include "HTString.h" |
#include "HTParse.h" |
#include "HTParse.h" |
Line 73 typedef struct _file_info {
|
Line 73 typedef struct _file_info {
|
|
|
/* Local definition */ |
/* Local definition */ |
struct _HTStream { |
struct _HTStream { |
CONST HTStreamClass * isa; |
const HTStreamClass * isa; |
/* ... */ |
/* ... */ |
}; |
}; |
|
|
Line 124 PUBLIC HTDirReadme HTFile_dirReadme (voi
|
Line 124 PUBLIC HTDirReadme HTFile_dirReadme (voi
|
*/ |
*/ |
PRIVATE int HTFile_readDir (HTRequest * request, file_info *file) |
PRIVATE int HTFile_readDir (HTRequest * request, file_info *file) |
{ |
{ |
#ifndef GOT_READ_DIR |
#ifdef HAVE_READDIR |
return HT_ERROR; |
DIR * dp; |
#else |
|
DIR *dp; |
|
struct stat file_info; |
struct stat file_info; |
char *url = HTAnchor_physical(request->anchor); |
char *url = HTAnchor_physical(request->anchor); |
char fullname[HT_MAX_PATH+1]; |
char fullname[HT_MAX_PATH+1]; |
Line 165 PRIVATE int HTFile_readDir (HTRequest *
|
Line 163 PRIVATE int HTFile_readDir (HTRequest *
|
} |
} |
|
|
if ((dp = opendir(file->local))) { |
if ((dp = opendir(file->local))) { |
STRUCT_DIRENT *dirbuf; |
struct dirent * dirbuf; |
HTDir *dir = HTDir_new(request, dir_show, dir_key); |
HTDir *dir = HTDir_new(request, dir_show, dir_key); |
char datestr[20]; |
char datestr[20]; |
char sizestr[10]; |
char sizestr[10]; |
HTFileMode mode; |
HTFileMode mode; |
#ifdef HT_REENTRANT |
#ifdef HT_REENTRANT |
STRUCT_DIRENT result; /* For readdir_r */ |
struct dirent * result; /* For readdir_r */ |
while ((dirbuf = (STRUCT_DIRENT *) readdir_r(dp, &result))) |
while ((dirbuf = (dirent *) readdir_r(dp, &result))) |
#else |
#else |
while ((dirbuf = readdir(dp))) |
while ((dirbuf = readdir(dp))) |
#endif /* HT_REENTRANT */ |
#endif /* HT_REENTRANT */ |
{ |
{ |
/* Current and parent directories are never shown in list */ |
/* Current and parent directories are never shown in list */ |
|
#ifdef HAVE_DIRENT_INO |
if (!dirbuf->d_ino || |
if (!dirbuf->d_ino || |
!strcmp(dirbuf->d_name, ".") || !strcmp(dirbuf->d_name, "..")) |
!strcmp(dirbuf->d_name, ".") || !strcmp(dirbuf->d_name, "..")) |
|
#else |
|
if (!strcmp(dirbuf->d_name, ".") || !strcmp(dirbuf->d_name, "..")) |
|
#endif |
continue; |
continue; |
|
|
/* Make a lstat on the file */ |
/* Make a lstat on the file */ |
Line 215 PRIVATE int HTFile_readDir (HTRequest *
|
Line 217 PRIVATE int HTFile_readDir (HTRequest *
|
} else |
} else |
HTRequest_addSystemError(request, ERR_FATAL, errno, NO, "opendir"); |
HTRequest_addSystemError(request, ERR_FATAL, errno, NO, "opendir"); |
return HT_LOADED; |
return HT_LOADED; |
#endif /* GOT_READ_DIR */ |
#else |
|
#error "readdir not defined" |
|
#endif /* HAVE_READDIR */ |
} |
} |
|
|
/* Determine write access to a file |
/* Determine write access to a file |
Line 229 PRIVATE int HTFile_readDir (HTRequest *
|
Line 233 PRIVATE int HTFile_readDir (HTRequest *
|
** 1. No code for non-unix systems. |
** 1. No code for non-unix systems. |
** 2. Isn't there a quicker way? |
** 2. Isn't there a quicker way? |
*/ |
*/ |
PRIVATE BOOL HTEditable (CONST char * filename, struct stat * stat_info) |
PRIVATE BOOL HTEditable (const char * filename, struct stat * stat_info) |
{ |
{ |
#ifndef NO_UNIX_IO |
#ifdef GETGROUPS_T |
#ifdef NO_GROUPS |
|
return NO; /* Safe answer till we find the correct algorithm */ |
|
#else |
|
#ifdef NeXT |
|
int groups[NGROUPS]; |
|
#else |
|
gid_t groups[NGROUPS]; |
|
#endif |
|
int i; |
int i; |
uid_t myUid; |
uid_t myUid; |
int ngroups; /* The number of groups */ |
int ngroups; /* The number of groups */ |
struct stat fileStatus; |
struct stat fileStatus; |
struct stat *fileptr = stat_info ? stat_info : &fileStatus; |
struct stat *fileptr = stat_info ? stat_info : &fileStatus; |
|
GETGROUPS_T groups[NGROUPS]; |
if (!stat_info) { |
if (!stat_info) { |
if (HT_STAT(filename, &fileStatus)) |
if (HT_STAT(filename, &fileStatus)) |
return NO; /* Can't even access file! */ |
return NO; /* Can't even access file! */ |
Line 279 PRIVATE BOOL HTEditable (CONST char * fi
|
Line 275 PRIVATE BOOL HTEditable (CONST char * fi
|
} |
} |
if (PROT_TRACE) HTTrace("\tFile is not editable.\n"); |
if (PROT_TRACE) HTTrace("\tFile is not editable.\n"); |
return NO; /* If no excuse, can't do */ |
return NO; /* If no excuse, can't do */ |
#endif |
|
#else |
#else |
/* |
/* |
** We don't know and can't find out. Can we be sure that when opening |
** We don't know and can't find out. Can we be sure that when opening |
** a file in mode "a" that the file is not modified? |
** a file in mode "a" that the file is not modified? |
*/ |
*/ |
return NO; |
return NO; |
#endif /* !NO_UNIX_IO */ |
#endif /* GETGROUPS_T */ |
} |
} |
|
|
|
|
Line 299 PRIVATE BOOL HTEditable (CONST char * fi
|
Line 294 PRIVATE BOOL HTEditable (CONST char * fi
|
PUBLIC HTStream * HTFileSaveStream (HTRequest * request) |
PUBLIC HTStream * HTFileSaveStream (HTRequest * request) |
{ |
{ |
|
|
CONST char * addr = HTAnchor_address((HTAnchor*)request->anchor); |
const char * addr = HTAnchor_address((HTAnchor*)request->anchor); |
char * filename = HTWWWToLocal(addr, ""); |
char * filename = HTWWWToLocal(addr, ""); |
FILE* fp; |
FILE* fp; |
|
|
Line 529 PUBLIC int HTLoadFile (SOCKET soc, HTReq
|
Line 524 PUBLIC int HTLoadFile (SOCKET soc, HTReq
|
** returns 0 when blocking and NOT -1. FNDELAY is ONLY for BSD |
** returns 0 when blocking and NOT -1. FNDELAY is ONLY for BSD |
** and does NOT work on SVR4 systems. O_NONBLOCK is POSIX. |
** and does NOT work on SVR4 systems. O_NONBLOCK is POSIX. |
*/ |
*/ |
#ifndef NO_FCNTL |
#ifdef HAVE_FCNTL |
if (!request->net->preemptive) { |
if (!request->net->preemptive) { |
if ((status = FCNTL(net->sockfd, F_GETFL, 0)) != -1) { |
if ((status = FCNTL(net->sockfd, F_GETFL, 0)) != -1) { |
status |= O_NONBLOCK; /* POSIX */ |
status |= O_NONBLOCK; /* POSIX */ |
Line 542 PUBLIC int HTLoadFile (SOCKET soc, HTReq
|
Line 537 PUBLIC int HTLoadFile (SOCKET soc, HTReq
|
HTTrace("HTLoadFile.. Using NON_BLOCKING I/O\n"); |
HTTrace("HTLoadFile.. Using NON_BLOCKING I/O\n"); |
} |
} |
} |
} |
#endif /* NO_FCNTL */ |
#endif /* HAVE_FCNTL */ |
#else |
#else |
#ifdef VMS |
#ifdef VMS |
if (!(file->fp = fopen(file->local,"r","shr=put","shr=upd"))) { |
if (!(file->fp = fopen(file->local,"r","shr=put","shr=upd"))) { |