1/* see copyright notice in squirrel.h */
2#ifndef _SQSTDIO_H_
3#define _SQSTDIO_H_
4
5#ifdef __cplusplus
6
7#define SQSTD_STREAM_TYPE_TAG 0x80000000
8
9struct SQStream {
10 virtual ~SQStream() {}
11 virtual SQInteger Read(void *buffer, SQInteger size) = 0;
12 virtual SQInteger Write(void *buffer, SQInteger size) = 0;
13 virtual SQInteger Flush() = 0;
14 virtual SQInteger Tell() = 0;
15 virtual SQInteger Len() = 0;
16 virtual SQInteger Seek(SQInteger offset, SQInteger origin) = 0;
17 virtual bool IsValid() = 0;
18 virtual bool EOS() = 0;
19};
20
21extern "C" {
22#endif
23
24#define SQ_SEEK_CUR 0
25#define SQ_SEEK_END 1
26#define SQ_SEEK_SET 2
27
28typedef void* SQFILE;
29
30SQUIRREL_API SQFILE sqstd_fopen(const SQChar *,const SQChar *);
31SQUIRREL_API SQInteger sqstd_fread(SQUserPointer, SQInteger, SQInteger, SQFILE);
32SQUIRREL_API SQInteger sqstd_fwrite(const SQUserPointer, SQInteger, SQInteger, SQFILE);
33SQUIRREL_API SQInteger sqstd_fseek(SQFILE , SQInteger , SQInteger);
34SQUIRREL_API SQInteger sqstd_ftell(SQFILE);
35SQUIRREL_API SQInteger sqstd_fflush(SQFILE);
36SQUIRREL_API SQInteger sqstd_fclose(SQFILE);
37SQUIRREL_API SQInteger sqstd_feof(SQFILE);
38
39SQUIRREL_API SQRESULT sqstd_createfile(HSQUIRRELVM v, SQFILE file,SQBool own);
40SQUIRREL_API SQRESULT sqstd_getfile(HSQUIRRELVM v, SQInteger idx, SQFILE *file);
41
42//compiler helpers
43SQUIRREL_API SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror);
44SQUIRREL_API SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror);
45SQUIRREL_API SQRESULT sqstd_writeclosuretofile(HSQUIRRELVM v,const SQChar *filename);
46
47SQUIRREL_API SQRESULT sqstd_register_iolib(HSQUIRRELVM v);
48
49#ifdef __cplusplus
50} /*extern "C"*/
51#endif
52
53#endif /*_SQSTDIO_H_*/
54
55