duck_io.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //==========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------
  11. #ifndef _duck_io_h
  12. #define _duck_io_h
  13. #if defined(__cplusplus)
  14. extern "C" {
  15. #endif
  16. #if defined (_WIN32)
  17. typedef __int64 int64_t;
  18. #endif
  19. typedef struct
  20. {
  21. int64_t offset; // offset to start from
  22. int blocking; // non-zero for blocking
  23. } ReOpen_t;
  24. typedef enum {
  25. SAL_ERR_MAX = -10,
  26. SAL_ERROR = -11, // Default error
  27. SAL_ERR_WSASTARTUP = -12,
  28. SAL_ERR_SOCKET_CREATE = -13,
  29. SAL_ERR_RESOLVING_HOSTNAME = -14,
  30. SAL_ERR_SERVER_CONNECTION = -15,
  31. SAL_ERR_SENDING_DATA = -16,
  32. SAL_ERR_RECEIVING_DATA = -17,
  33. SAL_ERR_404_FILE_NOT_FOUND = -18,
  34. SAL_ERR_PARSING_HTTP_HEADER = -19,
  35. SAL_ERR_PARSING_CONTENT_LEN = -20,
  36. SAL_ERR_CONNECTION_TIMEOUT = -21,
  37. SAL_ERR_FILE_OPEN_FAILED = -22,
  38. SAL_ERR_MIN = -23
  39. } SAL_ERR; /* EMH 1-15-03 */
  40. typedef struct SalErrMap_temp
  41. {
  42. SAL_ERR code;
  43. const char* decode;
  44. } SalErrMap_t;
  45. static char* SalErrText(SAL_ERR e)
  46. {
  47. int t;
  48. const SalErrMap_t gSalErrMap[] =
  49. {
  50. { SAL_ERR_WSASTARTUP, "Error with WSAStartup" },
  51. { SAL_ERR_SOCKET_CREATE, "Error creating socket" },
  52. { SAL_ERR_RESOLVING_HOSTNAME, "Error resolving hostname" },
  53. { SAL_ERR_SERVER_CONNECTION, "Error connecting to server" },
  54. { SAL_ERR_SENDING_DATA, "Error sending data" },
  55. { SAL_ERR_RECEIVING_DATA, "Error receiving data" },
  56. { SAL_ERR_404_FILE_NOT_FOUND, "Error file not found " },
  57. { SAL_ERR_PARSING_HTTP_HEADER, "Error parsing http header" },
  58. { SAL_ERR_PARSING_CONTENT_LEN, "Error parsing content length" },
  59. { SAL_ERR_CONNECTION_TIMEOUT, "Error Connection timed out" },
  60. { SAL_ERR_FILE_OPEN_FAILED, "Error opening file" }
  61. };
  62. for(t = 0; t < sizeof(gSalErrMap)/sizeof(SalErrMap_t); t++)
  63. {
  64. if (e == gSalErrMap[t].code)
  65. return (char *) gSalErrMap[t].decode;
  66. }
  67. return 0;
  68. }
  69. int duck_open(const char *fname, unsigned long userData);
  70. void duck_close(int ghndl);
  71. int duck_read(int ghndl,unsigned char *buf, int nbytes);
  72. int64_t duck_seek(int gHndl,int64_t offs, int origin);
  73. int duck_readFinished(int han, int flag); /* FWG 7-9-99 */
  74. int duck_name(int handle, char name[], size_t maxLen); /* EMH 9-23-03 */
  75. int duck_read_blocking(int handle,unsigned char *buffer,int bytes); /* EMH 9-23-03 */
  76. int64_t duck_available_data(int handle); /* EMH 10-23-03 */
  77. #if defined(__cplusplus)
  78. }
  79. #endif
  80. #endif