Counter Strike : Global Offensive Source Code
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.

89 lines
2.1 KiB

  1. /*===========================================================================
  2. bistream.h
  3. see parsifal.h for copyright info
  4. ===========================================================================*/
  5. #ifndef BISTREAM__H
  6. #define BISTREAM__H
  7. #include <stddef.h>
  8. #include <limits.h>
  9. #ifdef ICONV_SUPPORT
  10. #include "iconv.h"
  11. #endif
  12. #ifndef BYTE
  13. #define BYTE unsigned char
  14. #endif
  15. #ifndef COUNTBUFSIZE
  16. #define COUNTBUFSIZE(cBytes, blocksize) \
  17. ((!(cBytes)) ? (blocksize) : (!( (cBytes) % (blocksize) ) ? (int)(cBytes) : (int)( (((cBytes) / (blocksize)) + 1) * (blocksize) )) )
  18. #endif
  19. #define BIS_DEFAULT_MAXBUFSIZE INT_MAX
  20. #define BIS_DEFAULT_BLOCKSIZE 512
  21. #define BIS_CHAR_MAX 16
  22. enum BIS_ERRORS { BIS_ERR_MEMALLOC = -40,
  23. BIS_ERR_MAXBUF,
  24. BIS_ERR_INVALIDARG,
  25. BIS_ERR_ENCODING,
  26. BIS_ERR_INPUT,
  27. BIS_EOF = 1 };
  28. typedef int (*LPFNINPUTSRC)(BYTE *buf, int cBytes, int *cBytesActual, void *inputData);
  29. typedef struct tagBUFFEREDISTREAM
  30. {
  31. BYTE *buf;
  32. BYTE *inbuf;
  33. int bufsize;
  34. int maxbufsize;
  35. int blocksize;
  36. int bytesavail;
  37. int pos;
  38. int eof;
  39. int err;
  40. int encerr;
  41. int inbufrest;
  42. void *userdata;
  43. void *inputData;
  44. LPFNINPUTSRC inputsrc;
  45. size_t (*encode) (struct tagBUFFEREDISTREAM *reader, const BYTE **inbuf, size_t *inbytesleft, BYTE **outbuf, size_t *outbytesleft);
  46. #ifdef ICONV_SUPPORT
  47. iconv_t cd;
  48. #endif
  49. } BUFFEREDISTREAM, *LPBUFFEREDISTREAM;
  50. typedef size_t (*LPFNENCODE) (LPBUFFEREDISTREAM r, const BYTE **inbuf, size_t *inbytesleft, BYTE **outbuf, size_t *outbytesleft);
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. int BufferedIStream_EncodeBuffer(LPBUFFEREDISTREAM r);
  55. int BufferedIStream_Peek(LPBUFFEREDISTREAM r,
  56. const BYTE *tok,
  57. int len,
  58. int offset);
  59. int BufferedIStream_ResetBuf(LPBUFFEREDISTREAM r,
  60. int numBytes);
  61. LPBUFFEREDISTREAM BufferedIStream_Init(LPBUFFEREDISTREAM r,
  62. int blocksize);
  63. int BufferedIStream_AppendBytes(LPBUFFEREDISTREAM r,
  64. const BYTE *bytes,
  65. int len);
  66. void BufferedIStream_Free(LPBUFFEREDISTREAM r);
  67. #ifdef __cplusplus
  68. }
  69. #endif /* __cplusplus */
  70. #endif /* BISTREAM__H */