You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.1 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef Included_SSC_Streams
  2. #define Included_SSC_Streams 1
  3. #define SSC_IOSSeekDir SSC_ios::seekdir
  4. #define SSC_StreamOffT SSC_ios::seekoff
  5. #define SSC_OpenModeT SSC_ios::openmode
  6. class SSC_ios
  7. {
  8. public:
  9. typedef int seekdir;
  10. typedef long seekoff;
  11. typedef unsigned openmode;
  12. typedef unsigned iostate;
  13. static const seekdir beg=seekdir(0);
  14. static const seekdir cur=seekdir(SEEK_CUR);
  15. static const seekdir end=seekdir(SEEK_END);
  16. static const openmode app=1;
  17. static const openmode ate=2;
  18. static const openmode binary=4;
  19. static const openmode bin=4;
  20. static const openmode in=8;
  21. static const openmode out=16;
  22. static const openmode trunc=32;
  23. static const iostate badbit = iostate(4);
  24. static const iostate eofbit = iostate(2);
  25. static const iostate failbit = iostate(1);
  26. static const iostate goodbit = iostate(0);
  27. };
  28. class SSC_streambuf
  29. {
  30. public:
  31. virtual SSC_StreamOffT seekoff(SSC_StreamOffT pos, SSC_IOSSeekDir dir, SSC_OpenModeT mode=0);
  32. SSC_StreamOffT pubseekoff(SSC_StreamOffT pos, SSC_IOSSeekDir dir, SSC_OpenModeT mode=0)
  33. { return seekoff(pos,dir,mode); };
  34. virtual void sync();
  35. void pubsync() { sync(); };
  36. virtual void sputc(char c);
  37. virtual void sputn(char *data, size_t cant);
  38. virtual int sbumpc();
  39. virtual size_t sgetn(char *data, size_t cant);
  40. /*protected:
  41. SSC_streambuf(int =0) {};*/
  42. };
  43. class SSC_filebuf : public SSC_streambuf
  44. {
  45. public:
  46. SSC_filebuf();
  47. SSC_filebuf(int fh, SSC_OpenModeT mode);
  48. SSC_filebuf *open(const char *name, SSC_OpenModeT mode, int prot);
  49. int is_open() { return opened; };
  50. SSC_filebuf *close(); // 0 on error
  51. SSC_filebuf *attach(int fh);
  52. virtual SSC_streambuf *setbuf(char *buffer, size_t len);
  53. virtual SSC_StreamOffT seekoff(SSC_StreamOffT pos, SSC_IOSSeekDir dir,
  54. SSC_OpenModeT mode=0);
  55. virtual void sync();
  56. virtual void sputc(char c);
  57. virtual void sputn(char *data, size_t cant);
  58. virtual int sbumpc();
  59. virtual size_t sgetn(char *data, size_t cant);
  60. int fd() { return fileno(fde); };
  61. protected:
  62. FILE *fde;
  63. int opened;
  64. SSC_OpenModeT mode;
  65. };
  66. #endif // Included_SSC_Streams