root/ext/interbase/php_ibase_includes.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ZEND_BEGIN_MODULE_GLOBALS

   1 /*
   2    +----------------------------------------------------------------------+
   3    | PHP Version 5                                                        |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1997-2016 The PHP Group                                |
   6    +----------------------------------------------------------------------+
   7    | This source file is subject to version 3.01 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_01.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@ewi.tudelft.nl>              |
  18    +----------------------------------------------------------------------+
  19  */
  20 
  21 #ifndef PHP_IBASE_INCLUDES_H
  22 #define PHP_IBASE_INCLUDES_H
  23 
  24 #include <ibase.h>
  25 
  26 #ifndef SQLDA_CURRENT_VERSION
  27 #define SQLDA_CURRENT_VERSION SQLDA_VERSION1
  28 #endif
  29 
  30 #ifndef METADATALENGTH
  31 #define METADATALENGTH 68
  32 #endif
  33 
  34 #define RESET_ERRMSG do { IBG(errmsg)[0] = '\0'; IBG(sql_code) = 0; } while (0)
  35 
  36 #define IB_STATUS (IBG(status))
  37 
  38 /* XXX ZEND_DEBUG_ is misleading, it should be something like IBASE_DEBUG. */
  39 #ifdef ZEND_DEBUG_
  40 #define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
  41 #endif
  42 
  43 #ifndef IBDEBUG
  44 #define IBDEBUG(a)
  45 #endif
  46 
  47 extern int le_link, le_plink, le_trans;
  48 
  49 #define LE_LINK "Firebird/InterBase link"
  50 #define LE_PLINK "Firebird/InterBase persistent link"
  51 #define LE_TRANS "Firebird/InterBase transaction"
  52 
  53 #define IBASE_MSGSIZE 512
  54 #define MAX_ERRMSG (IBASE_MSGSIZE*2)
  55 
  56 #define IB_DEF_DATE_FMT "%Y-%m-%d"
  57 #define IB_DEF_TIME_FMT "%H:%M:%S"
  58 
  59 /* this value should never be > USHRT_MAX */
  60 #define IBASE_BLOB_SEG 4096
  61 
  62 ZEND_BEGIN_MODULE_GLOBALS(ibase)
  63         ISC_STATUS status[20];
  64         long default_link;
  65         long num_links, num_persistent;
  66         char errmsg[MAX_ERRMSG];
  67         long sql_code;
  68 ZEND_END_MODULE_GLOBALS(ibase)
  69 
  70 ZEND_EXTERN_MODULE_GLOBALS(ibase)
  71 
  72 typedef struct {
  73         isc_db_handle handle;
  74         struct tr_list *tr_list;
  75         unsigned short dialect;
  76         struct event *event_head;
  77 } ibase_db_link;
  78 
  79 typedef struct {
  80         isc_tr_handle handle;
  81         unsigned short link_cnt;
  82         unsigned long affected_rows;
  83         ibase_db_link *db_link[1]; /* last member */
  84 } ibase_trans;
  85 
  86 typedef struct tr_list {
  87         ibase_trans *trans;
  88         struct tr_list *next;
  89 } ibase_tr_list;
  90 
  91 typedef struct {
  92         isc_blob_handle bl_handle;
  93         unsigned short type;
  94         ISC_QUAD bl_qd;
  95 } ibase_blob;
  96 
  97 typedef struct event {
  98         ibase_db_link *link;
  99         long link_res_id;
 100         ISC_LONG event_id;
 101         unsigned short event_count;
 102         char **events;
 103         char *event_buffer, *result_buffer;
 104         zval *callback;
 105         void **thread_ctx;
 106         struct event *event_next;
 107         enum event_state { NEW, ACTIVE, DEAD } state;
 108 } ibase_event;
 109 
 110 enum php_interbase_option {
 111         PHP_IBASE_DEFAULT                       = 0,
 112         PHP_IBASE_CREATE            = 0,
 113         /* fetch flags */
 114         PHP_IBASE_FETCH_BLOBS           = 1,
 115         PHP_IBASE_FETCH_ARRAYS      = 2,
 116         PHP_IBASE_UNIXTIME                      = 4,
 117         /* transaction access mode */
 118         PHP_IBASE_WRITE                         = 1,
 119         PHP_IBASE_READ                          = 2,
 120         /* transaction isolation level */
 121         PHP_IBASE_CONCURRENCY           = 4,
 122         PHP_IBASE_COMMITTED             = 8,
 123           PHP_IBASE_REC_NO_VERSION      = 32,
 124           PHP_IBASE_REC_VERSION         = 64,
 125         PHP_IBASE_CONSISTENCY           = 16,
 126         /* transaction lock resolution */
 127         PHP_IBASE_WAIT                          = 128,
 128         PHP_IBASE_NOWAIT                        = 256
 129 };
 130 
 131 #ifdef ZTS
 132 #define IBG(v) TSRMG(ibase_globals_id, zend_ibase_globals *, v)
 133 #else
 134 #define IBG(v) (ibase_globals.v)
 135 #endif
 136 
 137 #define BLOB_ID_LEN             18
 138 #define BLOB_ID_MASK    "0x%" LL_MASK "x"
 139 
 140 #define BLOB_INPUT              1
 141 #define BLOB_OUTPUT             2
 142 
 143 #ifdef PHP_WIN32
 144 #define LL_MASK "I64"
 145 #define LL_LIT(lit) lit ## I64
 146 typedef void (__stdcall *info_func_t)(char*);
 147 #else
 148 #define LL_MASK "ll"
 149 #define LL_LIT(lit) lit ## ll
 150 typedef void (*info_func_t)(char*);
 151 #endif
 152 
 153 void _php_ibase_error(TSRMLS_D);
 154 void _php_ibase_module_error(char * TSRMLS_DC, ...)
 155         PHP_ATTRIBUTE_FORMAT(printf,1,PHP_ATTR_FMT_OFFSET +2);
 156 
 157 /* determine if a resource is a link or transaction handle */
 158 #define PHP_IBASE_LINK_TRANS(pzval, lh, th)                                                                                                     \
 159         do { if (!pzval) {                                                                                                                                              \
 160                         ZEND_FETCH_RESOURCE2(lh, ibase_db_link *, NULL, IBG(default_link),                              \
 161                                 "InterBase link", le_link, le_plink) }                                                                          \
 162                 else                                                                                                                                                            \
 163                         _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, &pzval, &lh, &th);  \
 164                 if (SUCCESS != _php_ibase_def_trans(lh, &th TSRMLS_CC)) { RETURN_FALSE; }                       \
 165         } while (0)
 166 
 167 int _php_ibase_def_trans(ibase_db_link *ib_link, ibase_trans **trans TSRMLS_DC);
 168 void _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAMETERS, zval **link_id,
 169         ibase_db_link **ib_link, ibase_trans **trans);
 170 
 171 /* provided by ibase_query.c */
 172 void php_ibase_query_minit(INIT_FUNC_ARGS);
 173 
 174 /* provided by ibase_blobs.c */
 175 void php_ibase_blobs_minit(INIT_FUNC_ARGS);
 176 int _php_ibase_string_to_quad(char const *id, ISC_QUAD *qd);
 177 char *_php_ibase_quad_to_string(ISC_QUAD const qd);
 178 int _php_ibase_blob_get(zval *return_value, ibase_blob *ib_blob, unsigned long max_len TSRMLS_DC);
 179 int _php_ibase_blob_add(zval **string_arg, ibase_blob *ib_blob TSRMLS_DC);
 180 
 181 /* provided by ibase_events.c */
 182 void php_ibase_events_minit(INIT_FUNC_ARGS);
 183 void _php_ibase_free_event(ibase_event *event TSRMLS_DC);
 184 
 185 /* provided by ibase_service.c */
 186 void php_ibase_service_minit(INIT_FUNC_ARGS);
 187 
 188 #ifndef max
 189 #define max(a,b) ((a)>(b)?(a):(b))
 190 #endif
 191 
 192 #endif /* PHP_IBASE_INCLUDES_H */
 193 
 194 /*
 195  * Local variables:
 196  * tab-width: 4
 197  * c-basic-offset: 4
 198  * End:
 199  */

/* [<][>][^][v][top][bottom][index][help] */