iolib.h

00001 #ifndef _IOLIB_H
00002 #define _IOLIB_H
00003 
00004 #include "nasal.h"
00005 
00006 // Note use of 32 bit ints, should fix at some point to use
00007 // platform-dependent fpos_t/size_t or just punt and use int64_t
00008 // everywhere...
00009 
00010 // The naContext is passed in for error reporting via
00011 // naRuntimeError().
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; // descriptor, FILE*, HANDLE, etc...
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 // Defined in iolib.c, there is no "library" header to put this in
00034 naRef naIOGhost(naContext c, FILE* f);
00035 
00036 #endif // _IOLIB_H

Generated on Mon Dec 17 09:30:54 2007 for SimGear by  doxygen 1.5.1