#endif
#endif
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0100000
+#endif
+
int (*_select)(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
int (*_poll)(struct pollfd *ufds, unsigned int nfds, int timeout);
int (*_open)(const char *file, int oflag, ...);
#include "stdioemu.c"
-FILE *fopen(const char* path, const char *mode) {
-
+FILE *fopen(const char* path, const char *mode)
+{
if (!initialized)
initialize();
if(!is_dsp_device(path))
return _fopen (path, mode);
- return fake_fopen(path, mode);
+ return fake_fopen(path, mode, 0);
+}
+
+FILE *fopen64(const char* path, const char *mode)
+{
+ if (!initialized)
+ initialize();
+
+ if(!is_dsp_device(path))
+ return _fopen (path, mode);
+
+ return fake_fopen(path, mode, O_LARGEFILE);
}
-#if 1
-# define strong_alias(name, aliasname) \
- extern __typeof (name) aliasname __attribute__ ((alias (#name)));
-strong_alias(open, __open);
-strong_alias(close, __close);
-strong_alias(write, __write);
-strong_alias(read, __read);
-strong_alias(ioctl, __ioctl);
-strong_alias(fcntl, __fcntl);
-strong_alias(mmap, __mmap);
-strong_alias(munmap, __munmap);
-strong_alias(poll, __poll);
-strong_alias(select, __select);
-strong_alias(fopen, __fopen);
-#else
int dup(int fd)
{
return fcntl(fd, F_DUPFD, 0);
return fcntl(fd, F_DUPFD, fd2);
}
-#ifndef O_LARGEFILE
-#define O_LARGEFILE 0100000
-#endif
-
int open64(const char *file, int oflag, ...)
{
va_list args;
}
return open(file, oflag | O_LARGEFILE, mode);
}
-#endif
-static void initialize() __attribute__ ((constructor));
+# define strong_alias(name, aliasname) \
+ extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+
+strong_alias(open, __open);
+strong_alias(open64, __open64);
+strong_alias(close, __close);
+strong_alias(write, __write);
+strong_alias(read, __read);
+strong_alias(ioctl, __ioctl);
+strong_alias(fcntl, __fcntl);
+strong_alias(mmap, __mmap);
+strong_alias(munmap, __munmap);
+strong_alias(poll, __poll);
+strong_alias(select, __select);
+strong_alias(fopen, __fopen);
+strong_alias(fopen64, __fopen64);
+/* called by each override if needed */
static void initialize()
{
char *s = getenv("ALSA_OSS_DEBUG");
- /*
+/*
Copyright (C) 2000 Stefan Westerfeld
stefan@space.twc.de
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+ Modified to add support for 64 bit fopen by Mike Hearn <mike@navi.cx>
+*/
/*
* This source only exists because some very special programs think that
return result;
}
-static FILE *fake_fopen(const char *path, const char *mode)
+static FILE *fake_fopen(const char *path, const char *mode, int flags)
{
cookie_io_functions_t fns = { fdc_read, fdc_write, fdc_seek, fdc_clean };
- struct fd_cookie *fdc =
- (struct fd_cookie *)malloc(sizeof(struct fd_cookie));
+ struct fd_cookie *fdc = (struct fd_cookie *)malloc(sizeof(struct fd_cookie));
const char *mptr;
int open_mode = 0;
FILE *result = 0;
- for(mptr = mode; *mptr; mptr++)
- {
+ for(mptr = mode; *mptr; mptr++) {
if(*mptr == 'r') open_mode |= 1; /* 1 = read */
if(*mptr == 'w') open_mode |= 2; /* 2 = write */
if(*mptr == '+') open_mode |= 3; /* 3 = readwrite */
if(*mptr == 'a') open_mode |= 2; /* append -> write */
}
- if(open_mode == 1) fdc->fd = open(path,O_RDONLY,0666);
- if(open_mode == 2) fdc->fd = open(path,O_WRONLY,0666);
- if(open_mode == 3) fdc->fd = open(path,O_RDWR,0666);
- if(open_mode && fdc->fd > 0)
- {
+ switch (open_mode) {
+ case 1:
+ fdc->fd = open(path, O_RDONLY | flags, 0666);
+ break;
+ case 2:
+ fdc->fd = open(path, O_WRONLY | flags, 0666);
+ break;
+ default:
+ fdc->fd = open(path, O_RDWR | flags, 0666);
+ break;
+ }
+
+ if (open_mode && fdc->fd > 0) {
result = fopencookie (fdc,"w", fns);
result->_fileno = fdc->fd; /* ugly patchy slimy kludgy hack */
}