diff --git a/ext/dba/dba_db1.c b/ext/dba/dba_db1.c index 202c05abbb5..94ba4f49ead 100644 --- a/ext/dba/dba_db1.c +++ b/ext/dba/dba_db1.c @@ -31,9 +31,6 @@ #include #include -#define DB1_DATA dba_db1_data *dba = info->dbf -#define DB1_GKEY DBT gkey; gkey.data = (char *) key; gkey.size = keylen - typedef struct { DB *dbp; } dba_db1_data; @@ -84,16 +81,19 @@ DBA_OPEN_FUNC(db1) DBA_CLOSE_FUNC(db1) { - DB1_DATA; + dba_db1_data *dba = info->dbf; dba->dbp->close(dba->dbp); pefree(info->dbf, info->flags&DBA_PERSISTENT); } DBA_FETCH_FUNC(db1) { + dba_db1_data *dba = info->dbf; DBT gval; - DB1_DATA; - DB1_GKEY; + DBT gkey; + + gkey.data = (char *) key; + gkey.size = keylen; memset(&gval, 0, sizeof(gval)); if (dba->dbp->get(dba->dbp, &gkey, &gval, 0) == RET_SUCCESS) { @@ -105,9 +105,12 @@ DBA_FETCH_FUNC(db1) DBA_UPDATE_FUNC(db1) { + dba_db1_data *dba = info->dbf; DBT gval; - DB1_DATA; - DB1_GKEY; + DBT gkey; + + gkey.data = (char *) key; + gkey.size = keylen; gval.data = (char *) val; gval.size = vallen; @@ -117,26 +120,32 @@ DBA_UPDATE_FUNC(db1) DBA_EXISTS_FUNC(db1) { + dba_db1_data *dba = info->dbf; DBT gval; - DB1_DATA; - DB1_GKEY; + DBT gkey; + + gkey.data = (char *) key; + gkey.size = keylen; return dba->dbp->get(dba->dbp, &gkey, &gval, 0) != RET_SUCCESS ? FAILURE : SUCCESS; } DBA_DELETE_FUNC(db1) { - DB1_DATA; - DB1_GKEY; + dba_db1_data *dba = info->dbf; + DBT gkey; + + gkey.data = (char *) key; + gkey.size = keylen; return dba->dbp->del(dba->dbp, &gkey, 0) != RET_SUCCESS ? FAILURE : SUCCESS; } DBA_FIRSTKEY_FUNC(db1) { + dba_db1_data *dba = info->dbf; DBT gkey; DBT gval; - DB1_DATA; memset(&gkey, 0, sizeof(gkey)); memset(&gval, 0, sizeof(gval)); @@ -150,9 +159,9 @@ DBA_FIRSTKEY_FUNC(db1) DBA_NEXTKEY_FUNC(db1) { + dba_db1_data *dba = info->dbf; DBT gkey; DBT gval; - DB1_DATA; memset(&gkey, 0, sizeof(gkey)); memset(&gval, 0, sizeof(gval)); diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c index 2c1cb43b0cf..87ef98caabd 100644 --- a/ext/dba/dba_db2.c +++ b/ext/dba/dba_db2.c @@ -29,12 +29,6 @@ #include DB2_INCLUDE_FILE #endif -#define DB2_DATA dba_db2_data *dba = info->dbf -#define DB2_GKEY \ - DBT gkey = {0}; \ - gkey.data = (char *) key; \ - gkey.size = keylen - typedef struct { DB *dbp; DBC *cursor; @@ -83,7 +77,7 @@ DBA_OPEN_FUNC(db2) DBA_CLOSE_FUNC(db2) { - DB2_DATA; + dba_db2_data *dba = info->dbf; if (dba->cursor) dba->cursor->c_close(dba->cursor); @@ -93,9 +87,12 @@ DBA_CLOSE_FUNC(db2) DBA_FETCH_FUNC(db2) { + dba_db2_data *dba = info->dbf; DBT gval = {0}; - DB2_DATA; - DB2_GKEY; + DBT gkey = {0}; + + gkey.data = (char *) key; + gkey.size = keylen; if (dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { return NULL; @@ -107,9 +104,12 @@ DBA_FETCH_FUNC(db2) DBA_UPDATE_FUNC(db2) { + dba_db2_data *dba = info->dbf; DBT gval = {0}; - DB2_DATA; - DB2_GKEY; + DBT gkey = {0}; + + gkey.data = (char *) key; + gkey.size = keylen; gval.data = (char *) val; gval.size = vallen; @@ -123,9 +123,12 @@ DBA_UPDATE_FUNC(db2) DBA_EXISTS_FUNC(db2) { + dba_db2_data *dba = info->dbf; DBT gval = {0}; - DB2_DATA; - DB2_GKEY; + DBT gkey = {0}; + + gkey.data = (char *) key; + gkey.size = keylen; if (dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { return FAILURE; @@ -135,15 +138,18 @@ DBA_EXISTS_FUNC(db2) DBA_DELETE_FUNC(db2) { - DB2_DATA; - DB2_GKEY; + dba_db2_data *dba = info->dbf; + DBT gkey = {0}; + + gkey.data = (char *) key; + gkey.size = keylen; return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS; } DBA_FIRSTKEY_FUNC(db2) { - DB2_DATA; + dba_db2_data *dba = info->dbf; if (dba->cursor) { dba->cursor->c_close(dba->cursor); @@ -164,7 +170,7 @@ DBA_FIRSTKEY_FUNC(db2) DBA_NEXTKEY_FUNC(db2) { - DB2_DATA; + dba_db2_data *dba = info->dbf; DBT gkey = {0}, gval = {0}; if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) @@ -182,7 +188,7 @@ DBA_OPTIMIZE_FUNC(db2) DBA_SYNC_FUNC(db2) { - DB2_DATA; + dba_db2_data *dba = info->dbf; return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS; } diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c index 2f05901be3a..5d7538d13bf 100644 --- a/ext/dba/dba_db3.c +++ b/ext/dba/dba_db3.c @@ -41,12 +41,6 @@ static void php_dba_db3_errcall_fcn( php_error_docref(NULL, E_NOTICE, "%s%s", errpfx?errpfx:"", msg); } -#define DB3_DATA dba_db3_data *dba = info->dbf -#define DB3_GKEY \ - DBT gkey; \ - memset(&gkey, 0, sizeof(gkey)); \ - gkey.data = (char *) key; gkey.size = keylen - typedef struct { DB *dbp; DBC *cursor; @@ -116,7 +110,7 @@ DBA_OPEN_FUNC(db3) DBA_CLOSE_FUNC(db3) { - DB3_DATA; + dba_db3_data *dba = info->dbf; if (dba->cursor) dba->cursor->c_close(dba->cursor); dba->dbp->close(dba->dbp, 0); @@ -125,10 +119,13 @@ DBA_CLOSE_FUNC(db3) DBA_FETCH_FUNC(db3) { + dba_db3_data *dba = info->dbf; DBT gval; char *new = NULL; - DB3_DATA; - DB3_GKEY; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; gkey.size = keylen; memset(&gval, 0, sizeof(gval)); if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { @@ -140,9 +137,12 @@ DBA_FETCH_FUNC(db3) DBA_UPDATE_FUNC(db3) { + dba_db3_data *dba = info->dbf; DBT gval; - DB3_DATA; - DB3_GKEY; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; gkey.size = keylen; memset(&gval, 0, sizeof(gval)); gval.data = (char *) val; @@ -157,9 +157,12 @@ DBA_UPDATE_FUNC(db3) DBA_EXISTS_FUNC(db3) { + dba_db3_data *dba = info->dbf; DBT gval; - DB3_DATA; - DB3_GKEY; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; gkey.size = keylen; memset(&gval, 0, sizeof(gval)); if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { @@ -170,15 +173,18 @@ DBA_EXISTS_FUNC(db3) DBA_DELETE_FUNC(db3) { - DB3_DATA; - DB3_GKEY; + dba_db3_data *dba = info->dbf; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; gkey.size = keylen; return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS; } DBA_FIRSTKEY_FUNC(db3) { - DB3_DATA; + dba_db3_data *dba = info->dbf; if (dba->cursor) { dba->cursor->c_close(dba->cursor); @@ -195,7 +201,7 @@ DBA_FIRSTKEY_FUNC(db3) DBA_NEXTKEY_FUNC(db3) { - DB3_DATA; + dba_db3_data *dba = info->dbf; DBT gkey, gval; char *nkey = NULL; @@ -219,7 +225,7 @@ DBA_OPTIMIZE_FUNC(db3) DBA_SYNC_FUNC(db3) { - DB3_DATA; + dba_db3_data *dba = info->dbf; return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS; } diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index 93dd36d5be3..da9e6236dab 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -55,12 +55,6 @@ static void php_dba_db4_errcall_fcn( php_error_docref(NULL, E_NOTICE, "%s%s", errpfx?errpfx:"", msg); } -#define DB4_DATA dba_db4_data *dba = info->dbf -#define DB4_GKEY \ - DBT gkey; \ - memset(&gkey, 0, sizeof(gkey)); \ - gkey.data = (char *) key; gkey.size = keylen - typedef struct { DB *dbp; DBC *cursor; @@ -145,7 +139,7 @@ DBA_OPEN_FUNC(db4) DBA_CLOSE_FUNC(db4) { - DB4_DATA; + dba_db4_data *dba = info->dbf; if (dba->cursor) dba->cursor->c_close(dba->cursor); dba->dbp->close(dba->dbp, 0); @@ -154,10 +148,14 @@ DBA_CLOSE_FUNC(db4) DBA_FETCH_FUNC(db4) { + dba_db4_data *dba = info->dbf; DBT gval; char *new = NULL; - DB4_DATA; - DB4_GKEY; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; + gkey.size = keylen; memset(&gval, 0, sizeof(gval)); if (info->flags & DBA_PERSISTENT) { @@ -175,9 +173,13 @@ DBA_FETCH_FUNC(db4) DBA_UPDATE_FUNC(db4) { + dba_db4_data *dba = info->dbf; DBT gval; - DB4_DATA; - DB4_GKEY; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; + gkey.size = keylen; memset(&gval, 0, sizeof(gval)); gval.data = (char *) val; @@ -192,9 +194,13 @@ DBA_UPDATE_FUNC(db4) DBA_EXISTS_FUNC(db4) { + dba_db4_data *dba = info->dbf; DBT gval; - DB4_DATA; - DB4_GKEY; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; + gkey.size = keylen; memset(&gval, 0, sizeof(gval)); @@ -213,15 +219,19 @@ DBA_EXISTS_FUNC(db4) DBA_DELETE_FUNC(db4) { - DB4_DATA; - DB4_GKEY; + dba_db4_data *dba = info->dbf; + DBT gkey; + + memset(&gkey, 0, sizeof(gkey)); + gkey.data = (char *) key; + gkey.size = keylen; return dba->dbp->del(dba->dbp, NULL, &gkey, 0) ? FAILURE : SUCCESS; } DBA_FIRSTKEY_FUNC(db4) { - DB4_DATA; + dba_db4_data *dba = info->dbf; if (dba->cursor) { dba->cursor->c_close(dba->cursor); @@ -238,7 +248,7 @@ DBA_FIRSTKEY_FUNC(db4) DBA_NEXTKEY_FUNC(db4) { - DB4_DATA; + dba_db4_data *dba = info->dbf; DBT gkey, gval; char *nkey = NULL; @@ -274,7 +284,7 @@ DBA_OPTIMIZE_FUNC(db4) DBA_SYNC_FUNC(db4) { - DB4_DATA; + dba_db4_data *dba = info->dbf; return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS; } diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c index 3412124cf95..65512b75ef4 100644 --- a/ext/dba/dba_dbm.c +++ b/ext/dba/dba_dbm.c @@ -35,9 +35,6 @@ #include #include -#define DBM_DATA dba_dbm_data *dba = info->dbf -#define DBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - #define TRUNC_IT(extension, mode) \ snprintf(buf, MAXPATHLEN, "%s" extension, info->path); \ buf[MAXPATHLEN-1] = '\0'; \ @@ -93,8 +90,10 @@ DBA_FETCH_FUNC(dbm) { datum gval; char *new = NULL; + datum gkey; - DBM_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval = fetch(gkey); if(gval.dptr) { if(newlen) *newlen = gval.dsize; @@ -106,8 +105,10 @@ DBA_FETCH_FUNC(dbm) DBA_UPDATE_FUNC(dbm) { datum gval; + datum gkey; - DBM_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; if (mode == 1) { /* insert */ gval = fetch(gkey); @@ -125,7 +126,10 @@ DBA_UPDATE_FUNC(dbm) DBA_EXISTS_FUNC(dbm) { datum gval; - DBM_GKEY; + datum gkey; + + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval = fetch(gkey); if(gval.dptr) { @@ -136,13 +140,16 @@ DBA_EXISTS_FUNC(dbm) DBA_DELETE_FUNC(dbm) { - DBM_GKEY; + datum gkey; + + gkey.dptr = (char *) key; + gkey.dsize = keylen; return(delete(gkey) == -1 ? FAILURE : SUCCESS); } DBA_FIRSTKEY_FUNC(dbm) { - DBM_DATA; + dba_dbm_data *dba = info->dbf; datum gkey; char *key = NULL; @@ -158,7 +165,7 @@ DBA_FIRSTKEY_FUNC(dbm) DBA_NEXTKEY_FUNC(dbm) { - DBM_DATA; + dba_dbm_data *dba = info->dbf; datum gkey; char *nkey = NULL; diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c index 246ba68c4b1..b9d43958ce0 100644 --- a/ext/dba/dba_flatfile.c +++ b/ext/dba/dba_flatfile.c @@ -32,9 +32,6 @@ #include #include -#define FLATFILE_DATA flatfile *dba = info->dbf -#define FLATFILE_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - DBA_OPEN_FUNC(flatfile) { info->dbf = pemalloc(sizeof(flatfile), info->flags&DBA_PERSISTENT); @@ -47,7 +44,7 @@ DBA_OPEN_FUNC(flatfile) DBA_CLOSE_FUNC(flatfile) { - FLATFILE_DATA; + flatfile *dba = info->dbf; if (dba->nextkey.dptr) { efree(dba->nextkey.dptr); @@ -57,11 +54,13 @@ DBA_CLOSE_FUNC(flatfile) DBA_FETCH_FUNC(flatfile) { + flatfile *dba = info->dbf; datum gval; char *new = NULL; + datum gkey; - FLATFILE_DATA; - FLATFILE_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval = flatfile_fetch(dba, gkey); if (gval.dptr) { @@ -76,10 +75,12 @@ DBA_FETCH_FUNC(flatfile) DBA_UPDATE_FUNC(flatfile) { + flatfile *dba = info->dbf; datum gval; + datum gkey; - FLATFILE_DATA; - FLATFILE_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval.dptr = (char *) val; gval.dsize = vallen; @@ -99,10 +100,12 @@ DBA_UPDATE_FUNC(flatfile) DBA_EXISTS_FUNC(flatfile) { + flatfile *dba = info->dbf; datum gval; - FLATFILE_DATA; - FLATFILE_GKEY; + datum gkey; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval = flatfile_fetch(dba, gkey); if (gval.dptr) { efree(gval.dptr); @@ -113,14 +116,17 @@ DBA_EXISTS_FUNC(flatfile) DBA_DELETE_FUNC(flatfile) { - FLATFILE_DATA; - FLATFILE_GKEY; + flatfile *dba = info->dbf; + datum gkey; + + gkey.dptr = (char *) key; + gkey.dsize = keylen; return(flatfile_delete(dba, gkey) == -1 ? FAILURE : SUCCESS); } DBA_FIRSTKEY_FUNC(flatfile) { - FLATFILE_DATA; + flatfile *dba = info->dbf; if (dba->nextkey.dptr) { efree(dba->nextkey.dptr); @@ -137,7 +143,7 @@ DBA_FIRSTKEY_FUNC(flatfile) DBA_NEXTKEY_FUNC(flatfile) { - FLATFILE_DATA; + flatfile *dba = info->dbf; if (!dba->nextkey.dptr) { return NULL; diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c index 2f98b8a97dc..aa7e889967a 100644 --- a/ext/dba/dba_gdbm.c +++ b/ext/dba/dba_gdbm.c @@ -27,9 +27,6 @@ #include GDBM_INCLUDE_FILE #endif -#define GDBM_DATA dba_gdbm_data *dba = info->dbf -#define GDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - typedef struct { GDBM_FILE dbf; datum nextkey; @@ -67,7 +64,7 @@ DBA_OPEN_FUNC(gdbm) DBA_CLOSE_FUNC(gdbm) { - GDBM_DATA; + dba_gdbm_data *dba = info->dbf; if(dba->nextkey.dptr) free(dba->nextkey.dptr); gdbm_close(dba->dbf); @@ -76,11 +73,13 @@ DBA_CLOSE_FUNC(gdbm) DBA_FETCH_FUNC(gdbm) { - GDBM_DATA; + dba_gdbm_data *dba = info->dbf; datum gval; char *new = NULL; + datum gkey; - GDBM_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval = gdbm_fetch(dba->dbf, gkey); if(gval.dptr) { if(newlen) *newlen = gval.dsize; @@ -92,10 +91,12 @@ DBA_FETCH_FUNC(gdbm) DBA_UPDATE_FUNC(gdbm) { + dba_gdbm_data *dba = info->dbf; datum gval; - GDBM_DATA; + datum gkey; - GDBM_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval.dptr = (char *) val; gval.dsize = vallen; @@ -115,23 +116,29 @@ DBA_UPDATE_FUNC(gdbm) DBA_EXISTS_FUNC(gdbm) { - GDBM_DATA; - GDBM_GKEY; + dba_gdbm_data *dba = info->dbf; + datum gkey; + + gkey.dptr = (char *) key; + gkey.dsize = keylen; return gdbm_exists(dba->dbf, gkey) ? SUCCESS : FAILURE; } DBA_DELETE_FUNC(gdbm) { - GDBM_DATA; - GDBM_GKEY; + dba_gdbm_data *dba = info->dbf; + datum gkey; + + gkey.dptr = (char *) key; + gkey.dsize = keylen; return gdbm_delete(dba->dbf, gkey) == -1 ? FAILURE : SUCCESS; } DBA_FIRSTKEY_FUNC(gdbm) { - GDBM_DATA; + dba_gdbm_data *dba = info->dbf; datum gkey; char *key = NULL; @@ -152,7 +159,7 @@ DBA_FIRSTKEY_FUNC(gdbm) DBA_NEXTKEY_FUNC(gdbm) { - GDBM_DATA; + dba_gdbm_data *dba = info->dbf; char *nkey = NULL; datum gkey; @@ -172,14 +179,15 @@ DBA_NEXTKEY_FUNC(gdbm) DBA_OPTIMIZE_FUNC(gdbm) { - GDBM_DATA; + dba_gdbm_data *dba = info->dbf; + gdbm_reorganize(dba->dbf); return SUCCESS; } DBA_SYNC_FUNC(gdbm) { - GDBM_DATA; + dba_gdbm_data *dba = info->dbf; gdbm_sync(dba->dbf); return SUCCESS; diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c index 3d2f4c453e0..6f2bada077a 100644 --- a/ext/dba/dba_inifile.c +++ b/ext/dba/dba_inifile.c @@ -32,20 +32,6 @@ #include #include -#define INIFILE_DATA \ - inifile *dba = info->dbf - -#define INIFILE_GKEY \ - key_type ini_key; \ - if (!key) { \ - php_error_docref(NULL, E_WARNING, "No key specified"); \ - return 0; \ - } \ - ini_key = inifile_key_split((char*)key) /* keylen not needed here */ - -#define INIFILE_DONE \ - inifile_key_free(&ini_key) - DBA_OPEN_FUNC(inifile) { info->dbf = inifile_alloc(info->fp, info->mode == DBA_READER, info->flags&DBA_PERSISTENT); @@ -55,31 +41,41 @@ DBA_OPEN_FUNC(inifile) DBA_CLOSE_FUNC(inifile) { - INIFILE_DATA; + inifile *dba = info->dbf; inifile_free(dba, info->flags&DBA_PERSISTENT); } DBA_FETCH_FUNC(inifile) { + inifile *dba = info->dbf; val_type ini_val; + key_type ini_key; - INIFILE_DATA; - INIFILE_GKEY; + if (!key) { + php_error_docref(NULL, E_WARNING, "No key specified"); + return 0; + } + ini_key = inifile_key_split((char*)key); /* keylen not needed here */ ini_val = inifile_fetch(dba, &ini_key, skip); *newlen = ini_val.value ? strlen(ini_val.value) : 0; - INIFILE_DONE; + inifile_key_free(&ini_key); return ini_val.value; } DBA_UPDATE_FUNC(inifile) { + inifile *dba = info->dbf; val_type ini_val; int res; + key_type ini_key; - INIFILE_DATA; - INIFILE_GKEY; + if (!key) { + php_error_docref(NULL, E_WARNING, "No key specified"); + return 0; + } + ini_key = inifile_key_split((char*)key); /* keylen not needed here */ ini_val.value = val; @@ -88,7 +84,7 @@ DBA_UPDATE_FUNC(inifile) } else { res = inifile_replace(dba, &ini_key, &ini_val); } - INIFILE_DONE; + inifile_key_free(&ini_key); switch(res) { case -1: php_error_docref1(NULL, key, E_WARNING, "Operation not possible"); @@ -103,13 +99,18 @@ DBA_UPDATE_FUNC(inifile) DBA_EXISTS_FUNC(inifile) { + inifile *dba = info->dbf; val_type ini_val; + key_type ini_key; - INIFILE_DATA; - INIFILE_GKEY; + if (!key) { + php_error_docref(NULL, E_WARNING, "No key specified"); + return 0; + } + ini_key = inifile_key_split((char*)key); /* keylen not needed here */ ini_val = inifile_fetch(dba, &ini_key, 0); - INIFILE_DONE; + inifile_key_free(&ini_key); if (ini_val.value) { inifile_val_free(&ini_val); return SUCCESS; @@ -119,21 +120,26 @@ DBA_EXISTS_FUNC(inifile) DBA_DELETE_FUNC(inifile) { + inifile *dba = info->dbf; int res; bool found = 0; + key_type ini_key; - INIFILE_DATA; - INIFILE_GKEY; + if (!key) { + php_error_docref(NULL, E_WARNING, "No key specified"); + return 0; + } + ini_key = inifile_key_split((char*)key); /* keylen not needed here */ res = inifile_delete_ex(dba, &ini_key, &found); - INIFILE_DONE; + inifile_key_free(&ini_key); return (res == -1 || !found ? FAILURE : SUCCESS); } DBA_FIRSTKEY_FUNC(inifile) { - INIFILE_DATA; + inifile *dba = info->dbf; if (inifile_firstkey(dba)) { char *result = inifile_key_string(&dba->curr.key); @@ -146,7 +152,7 @@ DBA_FIRSTKEY_FUNC(inifile) DBA_NEXTKEY_FUNC(inifile) { - INIFILE_DATA; + inifile *dba = info->dbf; if (!dba->curr.key.group && !dba->curr.key.name) { return NULL; diff --git a/ext/dba/dba_ndbm.c b/ext/dba/dba_ndbm.c index 20914b29699..3fd5d20db19 100644 --- a/ext/dba/dba_ndbm.c +++ b/ext/dba/dba_ndbm.c @@ -28,8 +28,6 @@ #include NDBM_INCLUDE_FILE #endif -#define NDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen - DBA_OPEN_FUNC(ndbm) { DBM *dbf; @@ -73,8 +71,10 @@ DBA_FETCH_FUNC(ndbm) { datum gval; char *new = NULL; + datum gkey; - NDBM_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval = dbm_fetch(info->dbf, gkey); if(gval.dptr) { if(newlen) *newlen = gval.dsize; @@ -86,8 +86,10 @@ DBA_FETCH_FUNC(ndbm) DBA_UPDATE_FUNC(ndbm) { datum gval; + datum gkey; - NDBM_GKEY; + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval.dptr = (char *) val; gval.dsize = vallen; @@ -99,7 +101,10 @@ DBA_UPDATE_FUNC(ndbm) DBA_EXISTS_FUNC(ndbm) { datum gval; - NDBM_GKEY; + datum gkey; + + gkey.dptr = (char *) key; + gkey.dsize = keylen; gval = dbm_fetch(info->dbf, gkey); if(gval.dptr) { return SUCCESS; @@ -109,7 +114,10 @@ DBA_EXISTS_FUNC(ndbm) DBA_DELETE_FUNC(ndbm) { - NDBM_GKEY; + datum gkey; + + gkey.dptr = (char *) key; + gkey.dsize = keylen; return(dbm_delete(info->dbf, gkey) == -1 ? FAILURE : SUCCESS); } diff --git a/ext/dba/dba_qdbm.c b/ext/dba/dba_qdbm.c index d18108b3a8e..7a78662b65f 100644 --- a/ext/dba/dba_qdbm.c +++ b/ext/dba/dba_qdbm.c @@ -27,8 +27,6 @@ #include QDBM_INCLUDE_FILE #endif -#define QDBM_DATA dba_qdbm_data *dba = info->dbf - typedef struct { DEPOT *dbf; } dba_qdbm_data; @@ -67,7 +65,7 @@ DBA_OPEN_FUNC(qdbm) DBA_CLOSE_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; dpclose(dba->dbf); pefree(dba, info->flags & DBA_PERSISTENT); @@ -75,7 +73,7 @@ DBA_CLOSE_FUNC(qdbm) DBA_FETCH_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; char *value, *new = NULL; int value_size; @@ -91,7 +89,7 @@ DBA_FETCH_FUNC(qdbm) DBA_UPDATE_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; if (dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER)) { return SUCCESS; @@ -106,7 +104,7 @@ DBA_UPDATE_FUNC(qdbm) DBA_EXISTS_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; char *value; value = dpget(dba->dbf, key, keylen, 0, -1, NULL); @@ -120,14 +118,14 @@ DBA_EXISTS_FUNC(qdbm) DBA_DELETE_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; return dpout(dba->dbf, key, keylen) ? SUCCESS : FAILURE; } DBA_FIRSTKEY_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; int value_size; char *value, *new = NULL; @@ -145,7 +143,7 @@ DBA_FIRSTKEY_FUNC(qdbm) DBA_NEXTKEY_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; int value_size; char *value, *new = NULL; @@ -161,7 +159,7 @@ DBA_NEXTKEY_FUNC(qdbm) DBA_OPTIMIZE_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; dpoptimize(dba->dbf, 0); return SUCCESS; @@ -169,7 +167,7 @@ DBA_OPTIMIZE_FUNC(qdbm) DBA_SYNC_FUNC(qdbm) { - QDBM_DATA; + dba_qdbm_data *dba = info->dbf; dpsync(dba->dbf); return SUCCESS; diff --git a/ext/dba/dba_tcadb.c b/ext/dba/dba_tcadb.c index f1432c988d8..abdfdee3f92 100644 --- a/ext/dba/dba_tcadb.c +++ b/ext/dba/dba_tcadb.c @@ -27,8 +27,6 @@ #include TCADB_INCLUDE_FILE #endif -#define TCADB_DATA dba_tcadb_data *dba = info->dbf - typedef struct { TCADB *tcadb; } dba_tcadb_data; @@ -76,7 +74,7 @@ DBA_OPEN_FUNC(tcadb) DBA_CLOSE_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; tcadbclose(dba->tcadb); pefree(dba, info->flags & DBA_PERSISTENT); @@ -84,7 +82,7 @@ DBA_CLOSE_FUNC(tcadb) DBA_FETCH_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; char *value, *new = NULL; int value_size; @@ -102,7 +100,7 @@ DBA_FETCH_FUNC(tcadb) DBA_UPDATE_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; int result; if (mode == 1) { @@ -124,7 +122,7 @@ DBA_UPDATE_FUNC(tcadb) DBA_EXISTS_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; char *value; int value_len; @@ -139,14 +137,14 @@ DBA_EXISTS_FUNC(tcadb) DBA_DELETE_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; return tcadbout(dba->tcadb, key, keylen) ? SUCCESS : FAILURE; } DBA_FIRSTKEY_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; int value_size; char *value, *new = NULL; @@ -166,7 +164,7 @@ DBA_FIRSTKEY_FUNC(tcadb) DBA_NEXTKEY_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; int value_size; char *value, *new = NULL; @@ -184,7 +182,7 @@ DBA_NEXTKEY_FUNC(tcadb) DBA_OPTIMIZE_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; #if _TC_LIBVER >= 811 return tcadboptimize(dba->tcadb, NULL) ? SUCCESS : FAILURE; @@ -195,7 +193,7 @@ DBA_OPTIMIZE_FUNC(tcadb) DBA_SYNC_FUNC(tcadb) { - TCADB_DATA; + dba_tcadb_data *dba = info->dbf; return tcadbsync(dba->tcadb) ? SUCCESS : FAILURE; }