sqstdio.h 1.7 KB

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