#ifndef FILEOBJECT_H
#define FILEOBJECT_H
-/* a good idea? */
-#include <stdio.h>
-
/*
IOFileObjects are used as part of the IO.Handle
implementation, ensuring that when handles are
typedef struct _IOFileObject {
int fd;
void* buf;
+
int bufWPtr; /* points to next position to write,
bufRPtr >= bufWPtr <= bufSize.
bufRPtr == -1 => buffer is empty.
*/
- int bufSize;
+ int bufSize; /* the size of the buffer, i.e. the number of bytes
+ malloced */
int flags;
struct _IOFileObject* connectedTo;
+
} IOFileObject;
-#define FILEOBJ_FLUSH 1
#define FILEOBJ_LB 2
#define FILEOBJ_BB 4
#define FILEOBJ_EOF 8
#define FILEOBJ_READ 16
#define FILEOBJ_WRITE 32
#define FILEOBJ_STD 64
-#define FILEOBJ_NONBLOCKING_IO 128
/* The next two flags are used for RW file objects only.
They indicate whether the last operation was a read or a write.
(Need this info to determine whether a RW file object's
*/
#define FILEOBJ_RW_READ 256
#define FILEOBJ_RW_WRITE 512
+/*
+ * Under Win32, a file fd is not the same as a socket fd, so
+ * we need to use separate r/w calls.
+ */
+#define FILEOBJ_WINSOCK 1024
+#define FILEOBJ_BINARY 2048
#define FILEOBJ_IS_EOF(x) ((x)->flags & FILEOBJ_EOF)
#define FILEOBJ_SET_EOF(x) ((x)->flags |= FILEOBJ_EOF)