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