Skip to content
Snippets Groups Projects
Commit b99ac059 authored by rswindell's avatar rswindell
Browse files

Using correct prototype for sopen() - including pmode when used with O_CREAT.

parent 16368def
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2002 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
...@@ -152,25 +152,26 @@ int DLLCALL unlock(int fd, long pos, int len) ...@@ -152,25 +152,26 @@ int DLLCALL unlock(int fd, long pos, int len)
} }
/* Opens a file in specified sharing (file-locking) mode */ /* Opens a file in specified sharing (file-locking) mode */
#ifdef __QNX__ #if !defined(__QNX__)
int DLLCALL qnx_sopen(char *fn, int access, int share) int DLLCALL sopen(const char *fn, int access, int share, ...)
{
#undef sopen /* Stupid macro trick */
return(sopen(fn, access, share, S_IREAD|S_IWRITE));
#define sopen(x,y,z) qnx_sopen(x,y,z)
}
#else
int DLLCALL sopen(char *fn, int access, int share)
{ {
int fd; int fd;
int pmode=S_IREAD;
#ifndef F_SANEWRLCKNO #ifndef F_SANEWRLCKNO
int flock_op=LOCK_NB; /* non-blocking */ int flock_op=LOCK_NB; /* non-blocking */
#endif #endif
#if defined(F_SANEWRLCKNO) || !defined(BSD) #if defined(F_SANEWRLCKNO) || !defined(BSD)
struct flock alock; struct flock alock;
#endif #endif
va_list ap;
if(access&O_CREAT) {
va_start(ap,share);
pmode = va_arg(ap,unsigned int));
va_end(ap);
}
if ((fd = open(fn, access, S_IREAD|S_IWRITE)) < 0) if ((fd = open(fn, access, pmode)) < 0)
return -1; return -1;
if (share == SH_DENYNO) /* no lock needed */ if (share == SH_DENYNO) /* no lock needed */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2002 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
...@@ -59,9 +59,6 @@ ...@@ -59,9 +59,6 @@
#include <windows.h> /* OF_SHARE_ */ #include <windows.h> /* OF_SHARE_ */
#include <share.h> /* SH_DENY */ #include <share.h> /* SH_DENY */
#define sopen(f,o,s) _sopen(f,o,s,S_IREAD|S_IWRITE)
#define close(f) _close(f)
#ifndef SH_DENYNO #ifndef SH_DENYNO
#define SH_DENYNO OF_SHARE_DENY_NONE #define SH_DENYNO OF_SHARE_DENY_NONE
#define SH_DENYWR OF_SHARE_DENY_WRITE #define SH_DENYWR OF_SHARE_DENY_WRITE
...@@ -122,11 +119,9 @@ extern "C" { ...@@ -122,11 +119,9 @@ extern "C" {
#endif #endif
#if !defined(__BORLANDC__) && defined(__unix__) #if !defined(__BORLANDC__) && defined(__unix__)
#if defined(__QNX__) #if !defined(__QNX__)
DLLEXPORT int DLLCALL qnx_sopen(char *fn, int access, int share); DLLEXPORT int DLLCALL sopen(const char* fn, int access, int share, ...);
#else #endif
DLLEXPORT int DLLCALL sopen(char *fn, int access, int share);
#endif /* !QNX */
DLLEXPORT long DLLCALL filelength(int fd); DLLEXPORT long DLLCALL filelength(int fd);
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment