mistream.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * Licensed Materials - Property of IBM and/or HCL
  3. *
  4. * IBM Informix Dynamic Server
  5. * (c) Copyright IBM Corporation 1996, 2004 All rights reserved.
  6. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  7. *
  8. ***************************************************************************
  9. *
  10. * Title: mistream.h
  11. * Description:
  12. * header file for the mi_stream Interface
  13. *
  14. ***************************************************************************
  15. */
  16. #ifndef _MISTREAM_H_
  17. #define _MISTREAM_H_
  18. #include "miconv.h"
  19. /*
  20. * mi_stream specific status (st_flags) control bits
  21. */
  22. #define MI_STREAM_EOF 0x0001 /* End of stream flag */
  23. #define MI_STREAM_MEM_ALLOCED 0x0002 /* MI_STREAM was allocated by */
  24. /* user and will not be */
  25. /* freed mi_stream_close. */
  26. /* For internal use only */
  27. #define MI_STREAM_NO_UDR_LOOKUP 0x0004 /* When set, UDR function */
  28. /* address lookup by name is */
  29. /* disabled, the related function */
  30. /* pointers will be used */
  31. typedef struct mi_stream MI_STREAM;
  32. /*
  33. * The stream operations and names below help stream manipulation. Not all the
  34. * functions need to be implemented. The ones not needed can be easily marked
  35. * as NULL. The ones needed must have related implementation for the stream
  36. * at hand.
  37. */
  38. #define OPS_NAME_LENGTH 40 /* max name for st_ops function name */
  39. typedef struct mi_stream_operations {
  40. /* the pointers to the functions */
  41. mi_integer (*close)(MI_STREAM *stream);
  42. mi_integer (*read)(MI_STREAM *stream, void *buf, mi_integer nbytes);
  43. mi_integer (*write)(MI_STREAM *stream, void *buf, mi_integer nbytes);
  44. mi_integer (*seek)(MI_STREAM *stream, mi_int8 *offset, int whence);
  45. mi_int8 * (*tell)(MI_STREAM *stream);
  46. mi_integer (*setpos)(MI_STREAM *stream, const mi_int8 *pos);
  47. mi_integer (*getpos)(MI_STREAM *stream, mi_int8 *pos);
  48. mi_integer (*length)(MI_STREAM *stream, mi_int8 *length);
  49. /* the names of the functions above */
  50. mi_char close_name [OPS_NAME_LENGTH];
  51. mi_char read_name [OPS_NAME_LENGTH];
  52. mi_char write_name [OPS_NAME_LENGTH];
  53. mi_char seek_name [OPS_NAME_LENGTH];
  54. mi_char tell_name [OPS_NAME_LENGTH];
  55. mi_char setpos_name[OPS_NAME_LENGTH];
  56. mi_char getpos_name[OPS_NAME_LENGTH];
  57. mi_char length_name[OPS_NAME_LENGTH];
  58. /* the function handles for the functions above */
  59. void *close_fhandle;
  60. void *read_fhandle;
  61. void *write_fhandle;
  62. void *seek_fhandle;
  63. void *tell_fhandle;
  64. void *setpos_fhandle;
  65. void *getpos_fhandle;
  66. void *length_fhandle;
  67. } mi_st_ops;
  68. typedef enum mi_stream_error_val
  69. {
  70. /*
  71. * mi_stream specific error status
  72. */
  73. MI_STREAM_EBADARG = -7400, /* Argument values have problem */
  74. MI_STREAM_EEOF = -7590, /* Reading past End Of File/stream marker */
  75. MI_STREAM_EFAIL = -7591, /* Generic failure */
  76. MI_STREAM_ENIMPL = -7592, /* Capability not implemented */
  77. MI_STREAM_ESENDFAIL = -7593, /* Send side failure */
  78. MI_STREAM_ERECEIVEFAIL = -7594, /* Receive side failure */
  79. MI_STREAM_EINT8 = -7595, /* Error in int8 operation */
  80. MI_STREAM_EWHENCE = -7596, /* Error in the "whence" value */
  81. MI_STREAM_ESAPI = -7597, /* SAPI Function module ID lookup failed */
  82. MI_STREAM_EBADSYM = -7598, /* Function symbol lookup failed */
  83. MI_STREAM_EBADFUNC = -7599, /* Function pointer lookup failed */
  84. /*
  85. * Negative status defines for mapping standard operating system
  86. * errno values. These are standard Informix error message values
  87. */
  88. MI_STREAM_EPERM = -1, /* Not super-user */
  89. MI_STREAM_ENOENT = -2, /* No such file or directory */
  90. MI_STREAM_ESRCH = -3, /* No such process */
  91. MI_STREAM_EINTR = -4, /* interrupted system call */
  92. MI_STREAM_EIO = -5, /* I/O error */
  93. MI_STREAM_ENXIO = -6, /* No such device or address */
  94. MI_STREAM_E2BIG = -7, /* Arg list too long */
  95. MI_STREAM_ENOEXEC = -8, /* Exec format error */
  96. MI_STREAM_EBADF = -9, /* Bad file number */
  97. MI_STREAM_ECHILD = -10, /* No children */
  98. MI_STREAM_EAGAIN = -11, /* Resource temporarily unavailable */
  99. MI_STREAM_ENOMEM = -12, /* Not enough core */
  100. MI_STREAM_EACCES = -13, /* Permission denied */
  101. MI_STREAM_EFAULT = -14, /* Bad address */
  102. MI_STREAM_ENOTBLK = -15, /* Block device required */
  103. MI_STREAM_EBUSY = -16, /* Mount device busy */
  104. MI_STREAM_EEXIST = -17, /* File exists */
  105. MI_STREAM_EXDEV = -18, /* Cross-device link */
  106. MI_STREAM_ENODEV = -19, /* No such device */
  107. MI_STREAM_ENOTDIR = -20, /* Not a directory */
  108. MI_STREAM_EISDIR = -21, /* Is a directory */
  109. MI_STREAM_EINVAL = -22, /* Invalid argument */
  110. MI_STREAM_ENFILE = -23, /* File table overflow */
  111. MI_STREAM_EMFILE = -24, /* Too many open files */
  112. MI_STREAM_ENOTTY = -25, /* Inappropriate ioctl for device */
  113. MI_STREAM_ETXTBSY = -26, /* Text file busy */
  114. MI_STREAM_EFBIG = -27, /* File too large */
  115. MI_STREAM_ENOSPC = -28, /* No space left on device */
  116. MI_STREAM_ESPIPE = -29, /* Illegal seek */
  117. MI_STREAM_EROFS = -30, /* Read only file system */
  118. MI_STREAM_EMLINK = -31, /* Too many links */
  119. MI_STREAM_EPIPE = -32, /* Broken pipe */
  120. MI_STREAM_EDOM = -33, /* Math arg out of domain of func */
  121. MI_STREAM_ERANGE = -34, /* Math result not representable */
  122. MI_STREAM_ENOMSG = -35 /* No message of desired type */
  123. } MI_STREAM_ERROR_VAL;
  124. /*
  125. * The public mi_stream inteface.
  126. */
  127. MI_DECL
  128. MI_STREAM * MI_PROC_EXPORT
  129. mi_stream_init ARGS ((struct mi_stream_operations * st_ops,
  130. void *st_data,
  131. MI_STREAM *stream));
  132. MI_DECL
  133. mi_integer MI_PROC_EXPORT
  134. mi_stream_close ARGS ((MI_STREAM *stream));
  135. MI_DECL
  136. mi_integer MI_PROC_EXPORT
  137. mi_stream_read ARGS ((MI_STREAM *stream,
  138. void *buf,
  139. mi_integer nbytes));
  140. MI_DECL
  141. mi_integer MI_PROC_EXPORT
  142. mi_stream_write ARGS ((MI_STREAM *stream,
  143. void *buf,
  144. mi_integer nbytes));
  145. MI_DECL
  146. mi_integer MI_PROC_EXPORT
  147. mi_stream_seek ARGS ((MI_STREAM *stream,
  148. mi_int8 *offset,
  149. int whence));
  150. MI_DECL
  151. mi_int8 * MI_PROC_EXPORT
  152. mi_stream_tell ARGS ((MI_STREAM *stream));
  153. MI_DECL
  154. mi_integer MI_PROC_EXPORT
  155. mi_stream_setpos ARGS ((MI_STREAM *stream,
  156. mi_int8 *pos));
  157. MI_DECL
  158. mi_integer MI_PROC_EXPORT
  159. mi_stream_getpos ARGS ((MI_STREAM *stream,
  160. mi_int8 *pos));
  161. MI_DECL
  162. mi_integer MI_PROC_EXPORT
  163. mi_stream_length ARGS ((MI_STREAM *stream,
  164. mi_int8 *length));
  165. MI_DECL
  166. mi_integer MI_PROC_EXPORT
  167. mi_stream_eof ARGS ((MI_STREAM *stream));
  168. MI_DECL
  169. mi_integer MI_PROC_EXPORT
  170. mi_stream_set_error ARGS ((MI_STREAM *stream,mi_integer error));
  171. MI_DECL
  172. mi_integer MI_PROC_EXPORT
  173. mi_stream_get_error ARGS ((MI_STREAM *stream));
  174. MI_DECL
  175. mi_integer MI_PROC_EXPORT
  176. mi_stream_set_flags ARGS ((MI_STREAM *stream,mi_integer flags));
  177. MI_DECL
  178. mi_integer MI_PROC_EXPORT
  179. mi_stream_get_flags ARGS ((MI_STREAM *stream));
  180. MI_DECL
  181. mi_integer MI_PROC_EXPORT
  182. mi_stream_set_eof ARGS ((MI_STREAM *stream));
  183. MI_DECL
  184. mi_integer MI_PROC_EXPORT
  185. mi_stream_clear_eof ARGS ((MI_STREAM *stream));
  186. /* Get functions functions for accessing mi_stream internal
  187. * members. Typically used in stream implementation, not by
  188. * stream users.
  189. */
  190. /* get user defined data pointer */
  191. MI_DECL
  192. void * MI_PROC_EXPORT
  193. mi_stream_get_dataptr ARGS ((MI_STREAM *stream));
  194. /* get possition pointer */
  195. MI_DECL
  196. mi_int8 * MI_PROC_EXPORT
  197. mi_stream_get_posptr ARGS ((MI_STREAM *stream));
  198. #endif