29#ifdef DB4_INCLUDE_FILE
30#include DB4_INCLUDE_FILE
35static void php_dba_db4_errcall_fcn(
36#
if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3))
39 const char *errpfx,
const char *
msg)
42#if (DB_VERSION_MAJOR == 5 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8))
48 && (!
strncmp(
msg,
"fop_read_meta",
sizeof(
"fop_read_meta")-1)
49 || !
strncmp(
msg,
"BDB0004 fop_read_meta",
sizeof(
"BDB0004 fop_read_meta")-1))) {
68 int filemode = info->file_permission;
69 struct stat check_stat;
72#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 7)
73 if (!
s && !check_stat.st_size) {
74 info->mode = DBA_TRUNC;
77 type = info->mode == DBA_READER ? DB_UNKNOWN :
78 info->mode == DBA_TRUNC ? DB_BTREE :
79 s ? DB_BTREE : DB_UNKNOWN;
81 gmode = info->mode == DBA_READER ? DB_RDONLY :
82 (info->mode == DBA_CREAT &&
s) ? DB_CREATE :
83 (info->
mode == DBA_CREAT && !
s) ? 0 :
84 info->
mode == DBA_WRITER ? 0 :
85 info->
mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
87 if (!
s && !check_stat.st_size) {
88 info->mode = DBA_CREAT;
91 type = info->mode == DBA_READER ? DB_UNKNOWN :
92 (info->mode == DBA_TRUNC || info->mode == DBA_CREAT) ? DB_BTREE :
93 s ? DB_BTREE : DB_UNKNOWN;
95 gmode = info->mode == DBA_READER ? DB_RDONLY :
96 info->mode == DBA_CREAT ? DB_CREATE :
97 info->mode == DBA_WRITER ? 0 :
98 info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
105 if (info->flags & DBA_PERSISTENT) {
109 if ((
err=db_create(&dbp,
NULL, 0)) == 0) {
110 dbp->set_errcall(dbp, php_dba_db4_errcall_fcn);
112#
if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1))
138 dba_db4_data *dba = info->dbf;
140 if (dba->cursor) dba->cursor->c_close(dba->cursor);
141 dba->dbp->close(dba->dbp, 0);
142 pefree(dba, info->flags&DBA_PERSISTENT);
147 dba_db4_data *dba = info->dbf;
157 if (info->flags & DBA_PERSISTENT) {
158 gval.flags |= DB_DBT_MALLOC;
161 fetched_value = zend_string_init(
gval.data,
gval.size,
false);
162 if (info->flags & DBA_PERSISTENT) {
166 return fetched_value;
171 dba_db4_data *dba = info->dbf;
184 mode == 1 ? DB_NOOVERWRITE : 0)) {
192 dba_db4_data *dba = info->dbf;
202 if (info->flags & DBA_PERSISTENT) {
203 gval.flags |= DB_DBT_MALLOC;
207 if (info->flags & DBA_PERSISTENT) {
217 dba_db4_data *dba = info->dbf;
227DBA_FIRSTKEY_FUNC(db4)
229 dba_db4_data *dba = info->dbf;
232 dba->cursor->c_close(dba->cursor);
236 if (dba->dbp->cursor(dba->dbp,
NULL, &dba->cursor, 0) != 0) {
240 return dba_nextkey_db4(info);
245 dba_db4_data *dba = info->dbf;
252 if (info->flags & DBA_PERSISTENT) {
253 gkey.flags |= DB_DBT_MALLOC;
254 gval.flags |= DB_DBT_MALLOC;
256 if (dba->cursor && dba->cursor->c_get(dba->cursor, &
gkey, &
gval, DB_NEXT) == 0) {
258 key = zend_string_init(
gkey.data,
gkey.size,
false);
260 if (info->flags & DBA_PERSISTENT) {
273DBA_OPTIMIZE_FUNC(db4)
280 dba_db4_data *dba = info->dbf;
287 return estrdup(DB_VERSION_STRING);
memset(ptr, 0, type->size)
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
unsigned char key[REFLECTION_KEY_LEN]
#define pefree(ptr, persistent)
#define pemalloc(size, persistent)
strncmp(string $string1, string $string2, int $length)
strcmp(string $string1, string $string2)
ZEND_API const char * get_active_function_name(void)
struct _zend_string zend_string
#define VCWD_STAT(path, buff)
function(EX_VAR(opline->result.var))