Commit c53495af authored by deuce's avatar deuce
Browse files

Added _fsopen() function... heavily used in multinode doors.

parent 5e08e016
......@@ -240,3 +240,65 @@ int DLLCALL unlock(int file, long offset, long size)
}
#endif /* !Unix && (MSVC || MinGW) */
#ifdef __unix__
FILE *_fsopen(char *pszFilename, char *pszMode, int shmode)
{
int file;
int Mode=0;
char *p;
for(p=pszMode;*p;p++) {
switch (*p) {
case 'r':
Mode |= 1;
break;
case 'w':
Mode |= 2;
break;
case 'a':
Mode |= 4;
break;
case '+':
Mode |= 8;
break;
case 'b':
case 't':
break;
default:
errno=EINVAL;
return(NULL);
}
}
switch(Mode) {
case 1:
Mode=O_RDONLY;
break;
case 2:
Mode=O_WRONLY|O_CREAT;
break;
case 4:
Mode=O_APPEND|O_WRONLY|O_CREAT;
break;
case 9:
Mode=O_RDWR;
break;
case 10:
Mode=O_RDWR|O_CREAT;
break;
case 12:
Mode=O_RDWR|O_APPEND|O_CREAT;
break;
default:
errno=EINVAL;
return(NULL);
}
if(Mode&O_CREAT)
file=sopen(pszFilename,Mode,shmode,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
else
file=sopen(pszFilename,Mode,shmode);
if(file==-1)
return(NULL);
return(fdopen(file,pszMode));
}
#endif
......@@ -41,6 +41,7 @@
#include "wrapdll.h" /* DLLEXPORT and DLLCALL */
#include <sys/stat.h> /* S_IREAD and S_IWRITE (for use with sopen) */
#include <stdio.h>
#if defined(__unix__)
#include <unistd.h> /* read, write, close, ftruncate, lseek, etc. */
......@@ -130,6 +131,10 @@ extern "C" {
DLLEXPORT long DLLCALL filelength(int fd);
#endif
#if defined(__unix__)
DLLEXPORT FILE * DLLCALL _fsopen(char *pszFilename, char *pszMode, int shmode);
#endif
DLLEXPORT time_t DLLCALL filetime(int fd);
#if defined(__cplusplus)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment