Back to index

php5  5.3.10
php_ibase_includes.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Jouni Ahto <jouni.ahto@exdec.fi>                            |
00016    |          Andrew Avdeev <andy@simgts.mv.ru>                           |
00017    |          Ard Biesheuvel <a.k.biesheuvel@ewi.tudelft.nl>              |
00018    +----------------------------------------------------------------------+
00019  */
00020 
00021 /* $Id: php_ibase_includes.h 321634 2012-01-01 13:15:04Z felipe $ */
00022 
00023 #ifndef PHP_IBASE_INCLUDES_H
00024 #define PHP_IBASE_INCLUDES_H
00025 
00026 #include <ibase.h>
00027 
00028 #ifndef SQLDA_CURRENT_VERSION
00029 #define SQLDA_CURRENT_VERSION SQLDA_VERSION1
00030 #endif
00031 
00032 #ifndef METADATALENGTH
00033 #define METADATALENGTH 68
00034 #endif
00035 
00036 #define RESET_ERRMSG do { IBG(errmsg)[0] = '\0'; IBG(sql_code) = 0; } while (0)
00037 
00038 #define IB_STATUS (IBG(status))
00039 
00040 #ifdef ZEND_DEBUG_
00041 #define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
00042 #endif
00043 
00044 #ifndef IBDEBUG
00045 #define IBDEBUG(a)
00046 #endif
00047 
00048 extern int le_link, le_plink, le_trans;
00049 
00050 #define LE_LINK "Firebird/InterBase link"
00051 #define LE_PLINK "Firebird/InterBase persistent link"
00052 #define LE_TRANS "Firebird/InterBase transaction"
00053 
00054 #define IBASE_MSGSIZE 512
00055 #define MAX_ERRMSG (IBASE_MSGSIZE*2)
00056 
00057 #define IB_DEF_DATE_FMT "%Y-%m-%d"
00058 #define IB_DEF_TIME_FMT "%H:%M:%S"
00059 
00060 /* this value should never be > USHRT_MAX */
00061 #define IBASE_BLOB_SEG 4096
00062 
00063 ZEND_BEGIN_MODULE_GLOBALS(ibase)
00064        ISC_STATUS status[20];
00065        long default_link;
00066        long num_links, num_persistent;
00067        char errmsg[MAX_ERRMSG];
00068        long sql_code;
00069 ZEND_END_MODULE_GLOBALS(ibase)
00070 
00071 ZEND_EXTERN_MODULE_GLOBALS(ibase)
00072 
00073 typedef struct {
00074        isc_db_handle handle;
00075        struct tr_list *tr_list;
00076        unsigned short dialect;
00077        struct event *event_head;
00078 } ibase_db_link;
00079 
00080 typedef struct {
00081        isc_tr_handle handle;
00082        unsigned short link_cnt;
00083        unsigned long affected_rows;
00084        ibase_db_link *db_link[1]; /* last member */
00085 } ibase_trans;
00086 
00087 typedef struct tr_list {
00088        ibase_trans *trans;
00089        struct tr_list *next;
00090 } ibase_tr_list;
00091 
00092 typedef struct {
00093        isc_blob_handle bl_handle;
00094        unsigned short type;
00095        ISC_QUAD bl_qd;
00096 } ibase_blob;
00097 
00098 typedef struct event {
00099        ibase_db_link *link;
00100        long link_res_id;
00101        ISC_LONG event_id;
00102        unsigned short event_count;
00103        char **events;
00104        char *event_buffer, *result_buffer;
00105        zval *callback;
00106        void **thread_ctx;
00107        struct event *event_next;
00108        enum event_state { NEW, ACTIVE, DEAD } state;
00109 } ibase_event;
00110 
00111 enum php_interbase_option {
00112        PHP_IBASE_DEFAULT                  = 0,
00113        PHP_IBASE_CREATE            = 0,
00114        /* fetch flags */
00115        PHP_IBASE_FETCH_BLOBS              = 1,
00116        PHP_IBASE_FETCH_ARRAYS      = 2,
00117        PHP_IBASE_UNIXTIME                 = 4,
00118        /* transaction access mode */
00119        PHP_IBASE_WRITE                    = 1,
00120        PHP_IBASE_READ                            = 2,
00121        /* transaction isolation level */
00122        PHP_IBASE_CONCURRENCY              = 4,
00123        PHP_IBASE_COMMITTED         = 8,
00124          PHP_IBASE_REC_NO_VERSION  = 32,
00125          PHP_IBASE_REC_VERSION     = 64,
00126        PHP_IBASE_CONSISTENCY              = 16,
00127        /* transaction lock resolution */
00128        PHP_IBASE_WAIT                            = 128,
00129        PHP_IBASE_NOWAIT                   = 256
00130 };
00131 
00132 #ifdef ZTS
00133 #define IBG(v) TSRMG(ibase_globals_id, zend_ibase_globals *, v)
00134 #else
00135 #define IBG(v) (ibase_globals.v)
00136 #endif
00137 
00138 #define BLOB_ID_LEN         18
00139 #define BLOB_ID_MASK "0x%" LL_MASK "x"
00140 
00141 #define BLOB_INPUT          1
00142 #define BLOB_OUTPUT         2
00143 
00144 #ifdef PHP_WIN32
00145 #define LL_MASK "I64"
00146 #define LL_LIT(lit) lit ## I64
00147 typedef void (__stdcall *info_func_t)(char*);
00148 #else
00149 #define LL_MASK "ll"
00150 #define LL_LIT(lit) lit ## ll
00151 typedef void (*info_func_t)(char*);
00152 #endif
00153 
00154 void _php_ibase_error(TSRMLS_D);
00155 void _php_ibase_module_error(char * TSRMLS_DC, ...)
00156        PHP_ATTRIBUTE_FORMAT(printf,1,PHP_ATTR_FMT_OFFSET +2);
00157 
00158 /* determine if a resource is a link or transaction handle */
00159 #define PHP_IBASE_LINK_TRANS(pzval, lh, th)                                                                                          \
00160        do { if (!pzval) {                                                                                                                          \
00161                      ZEND_FETCH_RESOURCE2(lh, ibase_db_link *, NULL, IBG(default_link),                         \
00162                             "InterBase link", le_link, le_plink) }                                                                   \
00163               else                                                                                                                                        \
00164                      _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, &pzval, &lh, &th);      \
00165               if (SUCCESS != _php_ibase_def_trans(lh, &th TSRMLS_CC)) { RETURN_FALSE; }                  \
00166        } while (0)
00167 
00168 int _php_ibase_def_trans(ibase_db_link *ib_link, ibase_trans **trans TSRMLS_DC);
00169 void _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAMETERS, zval **link_id,
00170        ibase_db_link **ib_link, ibase_trans **trans);
00171 
00172 /* provided by ibase_query.c */
00173 void php_ibase_query_minit(INIT_FUNC_ARGS);
00174 
00175 /* provided by ibase_blobs.c */
00176 void php_ibase_blobs_minit(INIT_FUNC_ARGS);
00177 int _php_ibase_string_to_quad(char const *id, ISC_QUAD *qd);
00178 char *_php_ibase_quad_to_string(ISC_QUAD const qd);
00179 int _php_ibase_blob_get(zval *return_value, ibase_blob *ib_blob, unsigned long max_len TSRMLS_DC);
00180 int _php_ibase_blob_add(zval **string_arg, ibase_blob *ib_blob TSRMLS_DC);
00181 
00182 /* provided by ibase_events.c */
00183 void php_ibase_events_minit(INIT_FUNC_ARGS);
00184 void _php_ibase_free_event(ibase_event *event TSRMLS_DC);
00185 
00186 /* provided by ibase_service.c */
00187 void php_ibase_service_minit(INIT_FUNC_ARGS);
00188 
00189 #ifndef max
00190 #define max(a,b) ((a)>(b)?(a):(b))
00191 #endif
00192 
00193 #endif /* PHP_IBASE_INCLUDES_H */
00194 
00195 /*
00196  * Local variables:
00197  * tab-width: 4
00198  * c-basic-offset: 4
00199  * End:
00200  */