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.

231 lines
5.8 KiB

25 years ago
24 years ago
23 years ago
23 years ago
23 years ago
27 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 4 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2003 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.0 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_0.txt. |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Jouni Ahto <jouni.ahto@exdec.fi> |
  16. | Andrew Avdeev <andy@simgts.mv.ru> |
  17. | Ard Biesheuvel <a.k.biesheuvel@its.tudelft.nl> |
  18. +----------------------------------------------------------------------+
  19. */
  20. /* $Id$ */
  21. #ifndef PHP_INTERBASE_H
  22. #define PHP_INTERBASE_H
  23. #if HAVE_IBASE
  24. #include <ibase.h>
  25. extern zend_module_entry ibase_module_entry;
  26. #define phpext_interbase_ptr &ibase_module_entry
  27. #ifndef ISC_INT64_FORMAT
  28. #ifdef PHP_WIN32
  29. #define ISC_INT64_FORMAT "I64"
  30. #else
  31. #define ISC_INT64_FORMAT "ll"
  32. #endif
  33. #endif
  34. PHP_MINIT_FUNCTION(ibase);
  35. PHP_RINIT_FUNCTION(ibase);
  36. PHP_MSHUTDOWN_FUNCTION(ibase);
  37. PHP_RSHUTDOWN_FUNCTION(ibase);
  38. PHP_MINFO_FUNCTION(ibase);
  39. PHP_FUNCTION(ibase_connect);
  40. PHP_FUNCTION(ibase_pconnect);
  41. PHP_FUNCTION(ibase_close);
  42. PHP_FUNCTION(ibase_drop_db);
  43. PHP_FUNCTION(ibase_query);
  44. PHP_FUNCTION(ibase_fetch_row);
  45. PHP_FUNCTION(ibase_fetch_assoc);
  46. PHP_FUNCTION(ibase_fetch_object);
  47. PHP_FUNCTION(ibase_free_result);
  48. PHP_FUNCTION(ibase_name_result);
  49. PHP_FUNCTION(ibase_prepare);
  50. PHP_FUNCTION(ibase_execute);
  51. PHP_FUNCTION(ibase_free_query);
  52. #if HAVE_STRFTIME
  53. PHP_FUNCTION(ibase_timefmt);
  54. #endif
  55. PHP_FUNCTION(ibase_num_fields);
  56. PHP_FUNCTION(ibase_num_params);
  57. PHP_FUNCTION(ibase_num_rows);
  58. PHP_FUNCTION(ibase_affected_rows);
  59. PHP_FUNCTION(ibase_field_info);
  60. PHP_FUNCTION(ibase_param_info);
  61. PHP_FUNCTION(ibase_trans);
  62. PHP_FUNCTION(ibase_commit);
  63. PHP_FUNCTION(ibase_rollback);
  64. PHP_FUNCTION(ibase_commit_ret);
  65. PHP_FUNCTION(ibase_rollback_ret);
  66. PHP_FUNCTION(ibase_blob_create);
  67. PHP_FUNCTION(ibase_blob_add);
  68. PHP_FUNCTION(ibase_blob_cancel);
  69. PHP_FUNCTION(ibase_blob_open);
  70. PHP_FUNCTION(ibase_blob_get);
  71. PHP_FUNCTION(ibase_blob_close);
  72. PHP_FUNCTION(ibase_blob_echo);
  73. PHP_FUNCTION(ibase_blob_info);
  74. PHP_FUNCTION(ibase_blob_import);
  75. #ifdef SQL_DIALECT_V6
  76. PHP_FUNCTION(ibase_add_user);
  77. PHP_FUNCTION(ibase_modify_user);
  78. PHP_FUNCTION(ibase_delete_user);
  79. #endif
  80. PHP_FUNCTION(ibase_errmsg);
  81. PHP_FUNCTION(ibase_errcode);
  82. PHP_FUNCTION(ibase_wait_event);
  83. PHP_FUNCTION(ibase_set_event_handler);
  84. PHP_FUNCTION(ibase_free_event_handler);
  85. #define IBASE_MSGSIZE 256
  86. #define MAX_ERRMSG (IBASE_MSGSIZE*2)
  87. #define IBASE_BLOB_SEG 4096
  88. ZEND_BEGIN_MODULE_GLOBALS(ibase)
  89. ISC_STATUS status[20];
  90. long default_link;
  91. long num_links, num_persistent;
  92. long max_links, max_persistent;
  93. long allow_persistent;
  94. char *default_user, *default_password;
  95. char *timestampformat;
  96. char *cfg_timestampformat;
  97. char *dateformat;
  98. char *cfg_dateformat;
  99. char *timeformat;
  100. char *cfg_timeformat;
  101. char errmsg[MAX_ERRMSG];
  102. long sql_code;
  103. ZEND_END_MODULE_GLOBALS(ibase)
  104. typedef struct {
  105. isc_db_handle handle;
  106. struct tr_list *tr_list;
  107. unsigned short dialect;
  108. } ibase_db_link;
  109. typedef struct {
  110. isc_tr_handle handle;
  111. unsigned short link_cnt;
  112. unsigned long affected_rows;
  113. ibase_db_link *db_link[1];
  114. } ibase_trans;
  115. typedef struct tr_list {
  116. ibase_trans *trans;
  117. struct tr_list *next;
  118. } ibase_tr_list;
  119. typedef struct {
  120. ISC_ARRAY_DESC ar_desc;
  121. int el_type, /* sqltype kinda SQL_TEXT, ...*/
  122. el_size; /* element size in bytes */
  123. ISC_LONG ISC_FAR ar_size; /* all array size in bytes */
  124. } ibase_array;
  125. typedef struct {
  126. isc_tr_handle trans_handle;
  127. isc_db_handle link;
  128. ISC_QUAD bl_qd;
  129. isc_blob_handle bl_handle;
  130. } ibase_blob_handle;
  131. typedef struct {
  132. ibase_db_link *link;
  133. ibase_trans *trans;
  134. isc_stmt_handle stmt;
  135. int drop_stmt;
  136. XSQLDA *in_sqlda, *out_sqlda;
  137. ibase_array *in_array, *out_array;
  138. int in_array_cnt, out_array_cnt;
  139. unsigned short dialect;
  140. int cursor_open;
  141. char statement_type;
  142. char *query;
  143. int trans_res_id;
  144. } ibase_query;
  145. typedef struct {
  146. isc_db_handle link; /* db link for this result */
  147. isc_tr_handle trans;
  148. isc_stmt_handle stmt;
  149. int drop_stmt;
  150. XSQLDA *out_sqlda;
  151. ibase_array *out_array;
  152. unsigned char has_more_rows;
  153. char statement_type;
  154. } ibase_result;
  155. typedef struct {
  156. int link_res_id;
  157. ibase_db_link *link;
  158. ISC_LONG event_id;
  159. unsigned short event_count;
  160. char **events;
  161. char *event_buffer, *result_buffer;
  162. zval *callback;
  163. void **thread_ctx;
  164. } ibase_event;
  165. typedef struct _php_ibase_varchar {
  166. short var_len;
  167. char var_str[1];
  168. } IBASE_VCHAR;
  169. enum php_interbase_option {
  170. PHP_IBASE_DEFAULT = 0,
  171. PHP_IBASE_TEXT = 1,
  172. PHP_IBASE_UNIXTIME = 2,
  173. PHP_IBASE_TIMESTAMP = 4,
  174. PHP_IBASE_DATE = 8,
  175. PHP_IBASE_TIME = 16,
  176. /* transactions */
  177. PHP_IBASE_WRITE = 2,
  178. PHP_IBASE_READ = 4,
  179. PHP_IBASE_COMMITTED = 8,
  180. PHP_IBASE_CONSISTENCY = 16,
  181. PHP_IBASE_CONCURRENCY = 32,
  182. PHP_IBASE_REC_VERSION = 64,
  183. PHP_IBASE_REC_NO_VERSION = 128,
  184. PHP_IBASE_NOWAIT = 256,
  185. PHP_IBASE_WAIT = 512
  186. };
  187. #ifdef ZTS
  188. #define IBG(v) TSRMG(ibase_globals_id, zend_ibase_globals *, v)
  189. #else
  190. #define IBG(v) (ibase_globals.v)
  191. #endif
  192. #else
  193. #define phpext_interbase_ptr NULL
  194. #endif /* HAVE_IBASE */
  195. #endif /* PHP_INTERBASE_H */
  196. /*
  197. * Local variables:
  198. * tab-width: 4
  199. * c-basic-offset: 4
  200. * End:
  201. */