xref: /PHP-5.5/ext/mysqli/mysqli_libmysql.h (revision 73c1be26)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2015 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: Georg Richter <georg@php.net>                               |
16   |          Andrey Hristov <andrey@php.net>                             |
17   |          Ulf Wendel <uw@php.net>                                     |
18   +----------------------------------------------------------------------+
19 */
20 
21 #ifndef MYSQLI_LIBMYSQL_H
22 #define MYSQLI_LIBMYSQL_H
23 
24 /* These are unused */
25 #define MYSQLI_CLOSE_EXPLICIT 0
26 #define MYSQLI_CLOSE_IMPLICIT 1
27 #define MYSQLI_CLOSE_DISCONNECTED 2
28 #define MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE	200
29 #define MYSQLND_OPT_INT_AND_YEAR_AS_INT				201
30 
31 /* r->data should be always NULL, at least in recent libmysql versions, the status changes once data is read*/
32 #define mysqli_result_is_unbuffered(r)		((r)->handle && (r)->handle->status == MYSQL_STATUS_USE_RESULT && (r)->data == NULL)
33 #define mysqli_result_is_unbuffered_and_not_everything_is_fetched(r)  mysqli_result_is_unbuffered(r)
34 #define mysqli_server_status(c)				(c)->server_status
35 #define mysqli_stmt_get_id(s)				((s)->stmt_id)
36 #define mysqli_stmt_warning_count(s)		mysql_warning_count((s)->mysql)
37 #define mysqli_stmt_server_status(s)		(s)->mysql->server_status
38 #define mysqli_stmt_get_connection(s)		(s)->mysql
39 #define mysqli_close(c, is_forced)			mysql_close((c))
40 #define mysqli_stmt_close(c, implicit)		mysql_stmt_close((c))
41 #define mysqli_free_result(r, is_forced)	mysql_free_result((r))
42 #define mysqli_change_user_silent(c, u, p, d, p_len)   mysql_change_user((c), (u), (p), (d))
43 
44 
45 #define TRANS_START_NO_OPT						0
46 #define TRANS_START_WITH_CONSISTENT_SNAPSHOT	1
47 #define TRANS_START_READ_WRITE					2
48 #define TRANS_START_READ_ONLY					4
49 
50 #define TRANS_COR_NO_OPT		0
51 #define TRANS_COR_AND_CHAIN		1
52 #define TRANS_COR_AND_NO_CHAIN	2
53 #define TRANS_COR_RELEASE		4
54 #define TRANS_COR_NO_RELEASE	8
55 
56 
57 /*
58   These functions also reside in ext/mysqlnd/mysqlnd_portability.h but since it is only made
59   available if one wants to build mysqli against mysqlnd and they are useful for libmysql as
60   well, we check whether they're not defined [build with libmysql is desired] and define them.
61 
62   Bit values are sent in reverted order of bytes, compared to normal !!!
63 */
64 
65 
66 #ifndef uint1korr
67 #define uint1korr(A)	(*(((uint8_t*)(A))))
68 #endif
69 
70 #ifndef bit_uint2korr
71 #define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((unsigned char*) (A))[1])) +\
72                                    ((uint16_t) (((unsigned char*) (A))[0]) << 8)))
73 #endif
74 
75 #ifndef bit_uint3korr
76 #define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
77                                    (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
78                                    (((uint32_t) (((unsigned char*) (A))[0])) << 16)))
79 #endif
80 
81 #ifndef bit_uint4korr
82 #define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
83                                    (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
84                                    (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
85                                    (((uint32_t) (((unsigned char*) (A))[0])) << 24)))
86 #endif
87 
88 #ifndef bit_uint5korr
89 #define bit_uint5korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[4])) +\
90                                     (((uint32_t) (((unsigned char*) (A))[3])) << 8) +\
91                                     (((uint32_t) (((unsigned char*) (A))[2])) << 16) +\
92                                    (((uint32_t) (((unsigned char*) (A))[1])) << 24)) +\
93                                     (((uint64_t) (((unsigned char*) (A))[0])) << 32))
94 #endif
95 
96 #ifndef bit_uint6korr
97 #define bit_uint6korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[5])) +\
98                                     (((uint32_t) (((unsigned char*) (A))[4])) << 8) +\
99                                     (((uint32_t) (((unsigned char*) (A))[3])) << 16) +\
100                                     (((uint32_t) (((unsigned char*) (A))[2])) << 24)) +\
101                         (((uint64_t) (((uint32_t) (((unsigned char*) (A))[1])) +\
102                                     (((uint32_t) (((unsigned char*) (A))[0]) << 8)))) <<\
103                                      32))
104 #endif
105 
106 #ifndef bit_uint7korr
107 #define bit_uint7korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[6])) +\
108                                     (((uint32_t) (((unsigned char*) (A))[5])) << 8) +\
109                                     (((uint32_t) (((unsigned char*) (A))[4])) << 16) +\
110                                    (((uint32_t) (((unsigned char*) (A))[3])) << 24)) +\
111                         (((uint64_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
112                                     (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
113                                     (((uint32_t) (((unsigned char*) (A))[0])) << 16))) <<\
114                                      32))
115 #endif
116 
117 #ifndef bit_uint8korr
118 #define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[7])) +\
119                                     (((uint32_t) (((unsigned char*) (A))[6])) << 8) +\
120                                     (((uint32_t) (((unsigned char*) (A))[5])) << 16) +\
121                                     (((uint32_t) (((unsigned char*) (A))[4])) << 24)) +\
122                         (((uint64_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
123                                     (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
124                                     (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
125                                     (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\
126                                     32))
127 #endif
128 
129 #endif /* MYSQLI_LIBMYSQL_H */
130 
131