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 (*destroy)(void* f);
00019 };
00020
00021 struct naIOGhost {
00022 struct naIOType* type;
00023 void* handle;
00024 };
00025
00026 extern naGhostType naIOGhostType;
00027 extern struct naIOType naStdIOType;
00028
00029 #define IOGHOST(r) ((struct naIOGhost*)naGhost_ptr(r))
00030 #define IS_IO(r) (IS_GHOST(r) && naGhost_type(r) == &naIOGhostType)
00031 #define IS_STDIO(r) (IS_IO(r) && (IOGHOST(r)->type == &naStdIOType))
00032
00033
00034 naRef naIOGhost(naContext c, FILE* f);
00035
00036 #endif // _IOLIB_H