00001 #ifndef _IOLIB_H
00002 #define _IOLIB_H
00003
00004 #include "nasal.h"
00005
00006
00007
00008
00009
00010
00011
00012 struct naIOType {
00013 void (*close)(naContext c, void* f);
00014 int (*read) (naContext c, void* f, char* buf, unsigned int len);
00015 int (*write)(naContext c, void* f, char* buf, unsigned int len);
00016 void (*seek) (naContext c, void* f, unsigned int off, int whence);
00017 int (*tell) (naContext c, void* f);
00018 void (*flush) (naContext c, void* f);
00019 void (*destroy)(void* f);
00020 };
00021
00022 struct naIOGhost {
00023 struct naIOType* type;
00024 void* handle;
00025 };
00026
00027 extern naGhostType naIOGhostType;
00028 extern struct naIOType naStdIOType;
00029
00030 #define IOGHOST(r) ((struct naIOGhost*)naGhost_ptr(r))
00031 #define IS_IO(r) (IS_GHOST(r) && naGhost_type(r) == &naIOGhostType)
00032 #define IS_STDIO(r) (IS_IO(r) && (IOGHOST(r)->type == &naStdIOType))
00033
00034
00035 naRef naIOGhost(naContext c, FILE* f);
00036
00037 #endif // _IOLIB_H