diff options
Diffstat (limited to 'ext/dba')
-rw-r--r-- | ext/dba/dba.c | 76 | ||||
-rw-r--r-- | ext/dba/dba_cdb.c | 30 | ||||
-rw-r--r-- | ext/dba/dba_db2.c | 18 | ||||
-rw-r--r-- | ext/dba/dba_db3.c | 22 | ||||
-rw-r--r-- | ext/dba/dba_db4.c | 30 | ||||
-rw-r--r-- | ext/dba/dba_dbm.c | 10 | ||||
-rw-r--r-- | ext/dba/dba_flatfile.c | 8 | ||||
-rw-r--r-- | ext/dba/dba_gdbm.c | 20 | ||||
-rw-r--r-- | ext/dba/dba_inifile.c | 8 | ||||
-rw-r--r-- | ext/dba/dba_ndbm.c | 2 | ||||
-rw-r--r-- | ext/dba/dba_tcadb.c | 4 | ||||
-rw-r--r-- | ext/dba/libcdb/cdb.c | 22 | ||||
-rw-r--r-- | ext/dba/libcdb/cdb_make.c | 2 | ||||
-rw-r--r-- | ext/dba/libflatfile/flatfile.c | 12 | ||||
-rw-r--r-- | ext/dba/libinifile/inifile.c | 38 | ||||
-rw-r--r-- | ext/dba/php_dba.h | 6 |
16 files changed, 154 insertions, 154 deletions
diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 2ca9092e65..bc8b5b04a6 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -28,12 +28,12 @@ #if HAVE_DBA #include "php_ini.h" -#include <stdio.h> +#include <stdio.h> #include <fcntl.h> #ifdef HAVE_SYS_FILE_H #include <sys/file.h> #endif - + #include "php_dba.h" #include "ext/standard/info.h" #include "ext/standard/php_string.h" @@ -157,7 +157,7 @@ PHP_MINFO_FUNCTION(dba); ZEND_BEGIN_MODULE_GLOBALS(dba) char *default_handler; dba_handler *default_hptr; -ZEND_END_MODULE_GLOBALS(dba) +ZEND_END_MODULE_GLOBALS(dba) ZEND_DECLARE_MODULE_GLOBALS(dba) @@ -165,15 +165,15 @@ ZEND_DECLARE_MODULE_GLOBALS(dba) #define DBA_G(v) TSRMG(dba_globals_id, zend_dba_globals *, v) #else #define DBA_G(v) (dba_globals.v) -#endif +#endif static PHP_GINIT_FUNCTION(dba); zend_module_entry dba_module_entry = { STANDARD_MODULE_HEADER, "dba", - dba_functions, - PHP_MINIT(dba), + dba_functions, + PHP_MINIT(dba), PHP_MSHUTDOWN(dba), NULL, NULL, @@ -206,7 +206,7 @@ static size_t php_dba_make_key(zval *key, char **key_str, char **key_free) zval *group, *name; HashPosition pos; size_t len; - + if (zend_hash_num_elements(Z_ARRVAL_P(key)) != 2) { php_error_docref(NULL, E_RECOVERABLE_ERROR, "Key does not have exactly two elements: (key, name)"); return -1; @@ -406,8 +406,8 @@ PHPAPI dba_handler *dba_get_handler(const char* handler_name) */ /* }}} */ -/* {{{ dba_close - */ +/* {{{ dba_close + */ static void dba_close(dba_info *info) { if (info->hnd) { @@ -441,7 +441,7 @@ static void dba_close(dba_info *info) */ static void dba_close_rsrc(zend_resource *rsrc) { - dba_info *info = (dba_info *)rsrc->ptr; + dba_info *info = (dba_info *)rsrc->ptr; dba_close(info); } @@ -457,7 +457,7 @@ int dba_close_pe_rsrc_deleter(zval *el, void *pDba) /* {{{ dba_close_pe_rsrc */ static void dba_close_pe_rsrc(zend_resource *rsrc) { - dba_info *info = (dba_info *)rsrc->ptr; + dba_info *info = (dba_info *)rsrc->ptr; /* closes the resource by calling dba_close_rsrc() */ zend_hash_apply_with_argument(&EG(persistent_list), dba_close_pe_rsrc_deleter, info); @@ -489,7 +489,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("dba.default_handler", DBA_DEFAULT, PHP_INI_ALL, OnUpdateDefaultHandler, default_handler, zend_dba_globals, dba_globals) PHP_INI_END() /* }}} */ - + /* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(dba) @@ -627,18 +627,18 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) int persistent_flag = persistent ? STREAM_OPEN_PERSISTENT : 0; char *opened_path = NULL; char *lock_name; - + if (ac < 2) { WRONG_PARAM_COUNT; } - + /* we pass additional args to the respective handler */ args = safe_emalloc(ac, sizeof(zval), 0); if (zend_get_parameters_array_ex(ac, args) != SUCCESS) { efree(args); WRONG_PARAM_COUNT; } - + /* we only take string arguments */ for (i = 0; i < ac; i++) { if (Z_TYPE(args[i]) != IS_STRING) { @@ -651,12 +651,12 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) if (persistent) { zend_resource *le; - + /* calculate hash */ key = safe_emalloc(keylen, 1, 1); key[keylen] = '\0'; keylen = 0; - + for(i = 0; i < ac; i++) { memcpy(key+keylen, Z_STRVAL(args[i]), Z_STRLEN(args[i])); keylen += Z_STRLEN(args[i]); @@ -665,11 +665,11 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) /* try to find if we already have this link in our persistent list */ if ((le = zend_hash_str_find_ptr(&EG(persistent_list), key, keylen)) != NULL) { FREENOW; - + if (le->type != le_pdb) { RETURN_FALSE; } - + info = (dba_info *)le->ptr; GC_REFCOUNT(le)++; @@ -677,7 +677,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) return; } } - + if (ac==2) { hptr = DBA_G(default_hptr); if (!hptr) { @@ -739,18 +739,18 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) lock_dbf = 1; } switch (*pmode++) { - case 'r': - modenr = DBA_READER; + case 'r': + modenr = DBA_READER; lock_mode = (lock_flag & DBA_LOCK_READER) ? LOCK_SH : 0; file_mode = "r"; break; - case 'w': - modenr = DBA_WRITER; + case 'w': + modenr = DBA_WRITER; lock_mode = (lock_flag & DBA_LOCK_WRITER) ? LOCK_EX : 0; file_mode = "r+b"; break; - case 'c': - modenr = DBA_CREAT; + case 'c': + modenr = DBA_CREAT; lock_mode = (lock_flag & DBA_LOCK_CREAT) ? LOCK_EX : 0; if (lock_mode) { if (lock_dbf) { @@ -766,7 +766,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) } else { file_mode = "a+b"; } - /* In case of the 'a+b' append mode, the handler is responsible + /* In case of the 'a+b' append mode, the handler is responsible * to handle any rewind problems (see flatfile handler). */ break; @@ -812,7 +812,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) FREENOW; RETURN_FALSE; } - + info = pemalloc(sizeof(dba_info), persistent); memset(info, 0, sizeof(dba_info)); info->path = pestrdup(Z_STRVAL(args[0]), persistent); @@ -909,7 +909,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) RETURN_FALSE; } if (hptr->flags & (DBA_NO_APPEND|DBA_CAST_AS_FD)) { - /* Needed because some systems do not allow to write to the original + /* Needed because some systems do not allow to write to the original * file contents with O_APPEND being set. */ if (SUCCESS != php_stream_cast(info->fp, PHP_STREAM_AS_FD, (void*)&info->fd, 1)) { @@ -923,7 +923,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) fcntl(info->fd, F_SETFL, flags & ~O_APPEND); #endif } - + } } @@ -1020,11 +1020,11 @@ PHP_FUNCTION(dba_fetch) skip = 0; } } else if (!strcmp(info->hnd->name, "inifile")) { - /* "-1" is compareable to 0 but allows a non restrictive + /* "-1" is compareable to 0 but allows a non restrictive * access which is fater. For example 'inifile' uses this * to allow faster access when the key was already found * using firstkey/nextkey. However explicitly setting the - * value to 0 ensures the first value. + * value to 0 ensures the first value. */ if (skip < -1) { php_error_docref(NULL, E_NOTICE, "Handler %s accepts only skip value -1 and greater, using skip=0", info->hnd->name); @@ -1032,17 +1032,17 @@ PHP_FUNCTION(dba_fetch) } } else { php_error_docref(NULL, E_NOTICE, "Handler %s does not support optional skip parameter, the value will be ignored", info->hnd->name); - skip = 0; + skip = 0; } } else { - skip = 0; + skip = 0; } if((val = info->hnd->fetch(info, key_str, key_len, skip, &len)) != NULL) { DBA_ID_DONE; RETVAL_STRINGL(val, len); efree(val); return; - } + } DBA_ID_DONE; RETURN_FALSE; } @@ -1138,9 +1138,9 @@ PHP_FUNCTION(dba_nextkey) PHP_FUNCTION(dba_delete) { DBA_ID_GET2; - + DBA_WRITE_CHECK_WITH_ID; - + if(info->hnd->delete(info, key_str, key_len) == SUCCESS) { DBA_ID_DONE; @@ -1152,7 +1152,7 @@ PHP_FUNCTION(dba_delete) /* }}} */ /* {{{ proto bool dba_insert(string key, string value, resource handle) - If not inifile: Insert value as key, return false, if key exists already + If not inifile: Insert value as key, return false, if key exists already If inifile: Add vakue as key (next instance of key) */ PHP_FUNCTION(dba_insert) { diff --git a/ext/dba/dba_cdb.c b/ext/dba/dba_cdb.c index deab119861..df585af391 100644 --- a/ext/dba/dba_cdb.c +++ b/ext/dba/dba_cdb.c @@ -72,7 +72,7 @@ DBA_OPEN_FUNC(cdb) dba_info *pinfo = (dba_info *) info; switch (info->mode) { - case DBA_READER: + case DBA_READER: #if DBA_CDB_BUILTIN make = 0; file = info->fp; @@ -94,7 +94,7 @@ DBA_OPEN_FUNC(cdb) *error = "Update operations are not supported"; return FAILURE; /* not supported */ #endif - default: + default: *error = "Currently not supported"; return FAILURE; } @@ -113,7 +113,7 @@ DBA_OPEN_FUNC(cdb) cdb_init(&cdb->c, file); #endif cdb->file = file; - + pinfo->dbf = cdb; return SUCCESS; } @@ -151,7 +151,7 @@ DBA_FETCH_FUNC(cdb) CDB_INFO; unsigned int len; char *new_entry = NULL; - + #if DBA_CDB_BUILTIN if (cdb->make) return NULL; /* database was opened writeonly */ @@ -164,16 +164,16 @@ DBA_FETCH_FUNC(cdb) } len = cdb_datalen(&cdb->c); new_entry = safe_emalloc(len, 1, 1); - + if (php_cdb_read(&cdb->c, new_entry, len, cdb_datapos(&cdb->c)) == -1) { efree(new_entry); return NULL; } new_entry[len] = 0; - if (newlen) + if (newlen) *newlen = len; } - + return new_entry; } @@ -222,7 +222,7 @@ DBA_DELETE_FUNC(cdb) if (cdb_file_read(cdb->file, buf, n) < n) return NULL; \ } while (0) -/* {{{ cdb_file_lseek +/* {{{ cdb_file_lseek php_stream_seek does not return actual position */ #if DBA_CDB_BUILTIN int cdb_file_lseek(php_stream *fp, off_t offset, int whence) { @@ -257,13 +257,13 @@ DBA_FIRSTKEY_FUNC(cdb) cdb->eod = -1; CSEEK(0); CREAD(4); - + /* Total length of file in bytes */ uint32_unpack(buf, &cdb->eod); - + CSEEK(2048); CREAD(8); - + /* The first four bytes contain the length of the key */ uint32_unpack(buf, &klen); uint32_unpack(buf + 4, &dlen); @@ -279,7 +279,7 @@ DBA_FIRSTKEY_FUNC(cdb) /* header + klenlen + dlenlen + klen + dlen */ cdb->pos = 2048 + 4 + 4 + klen + dlen; - + return key; } @@ -299,7 +299,7 @@ DBA_NEXTKEY_FUNC(cdb) CREAD(8); uint32_unpack(buf, &klen); uint32_unpack(buf + 4, &dlen); - + key = safe_emalloc(klen, 1, 1); if (cdb_file_read(cdb->file, key, klen) < klen) { efree(key); @@ -308,9 +308,9 @@ DBA_NEXTKEY_FUNC(cdb) key[klen] = '\0'; if (newlen) *newlen = klen; } - + cdb->pos += 8 + klen + dlen; - + return key; } diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c index bde08427ee..b61f48a6ef 100644 --- a/ext/dba/dba_db2.c +++ b/ext/dba/dba_db2.c @@ -60,11 +60,11 @@ DBA_OPEN_FUNC(db2) type = info->mode == DBA_READER ? DB_UNKNOWN : info->mode == DBA_TRUNC ? DB_BTREE : s ? DB_BTREE : DB_UNKNOWN; - + gmode = info->mode == DBA_READER ? DB_RDONLY : - (info->mode == DBA_CREAT && s) ? DB_CREATE : + (info->mode == DBA_CREAT && s) ? DB_CREATE : (info->mode == DBA_CREAT && !s) ? 0 : - info->mode == DBA_WRITER ? 0 : + info->mode == DBA_WRITER ? 0 : info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; if (gmode == -1) { @@ -89,8 +89,8 @@ DBA_OPEN_FUNC(db2) DBA_CLOSE_FUNC(db2) { DB2_DATA; - - if (dba->cursor) + + if (dba->cursor) dba->cursor->c_close(dba->cursor); dba->dbp->close(dba->dbp, 0); pefree(dba, info->flags&DBA_PERSISTENT); @@ -101,7 +101,7 @@ DBA_FETCH_FUNC(db2) DBT gval = {0}; DB2_DATA; DB2_GKEY; - + if (dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { return NULL; } @@ -115,11 +115,11 @@ DBA_UPDATE_FUNC(db2) DBT gval = {0}; DB2_DATA; DB2_GKEY; - + gval.data = (char *) val; gval.size = vallen; - if (dba->dbp->put(dba->dbp, NULL, &gkey, &gval, + if (dba->dbp->put(dba->dbp, NULL, &gkey, &gval, mode == 1 ? DB_NOOVERWRITE : 0)) { return FAILURE; } @@ -131,7 +131,7 @@ DBA_EXISTS_FUNC(db2) DBT gval = {0}; DB2_DATA; DB2_GKEY; - + if (dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { return FAILURE; } diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c index 5e8f1da4ad..746e872726 100644 --- a/ext/dba/dba_db3.c +++ b/ext/dba/dba_db3.c @@ -37,7 +37,7 @@ static void php_dba_db3_errcall_fcn(const char *errpfx, char *msg) { - + php_error_docref(NULL, E_NOTICE, "%s%s", errpfx?errpfx:"", msg); } @@ -68,11 +68,11 @@ DBA_OPEN_FUNC(db3) type = info->mode == DBA_READER ? DB_UNKNOWN : info->mode == DBA_TRUNC ? DB_BTREE : s ? DB_BTREE : DB_UNKNOWN; - + gmode = info->mode == DBA_READER ? DB_RDONLY : - (info->mode == DBA_CREAT && s) ? DB_CREATE : + (info->mode == DBA_CREAT && s) ? DB_CREATE : (info->mode == DBA_CREAT && !s) ? 0 : - info->mode == DBA_WRITER ? 0 : + info->mode == DBA_WRITER ? 0 : info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; if (gmode == -1) { @@ -97,7 +97,7 @@ DBA_OPEN_FUNC(db3) data->dbp = dbp; data->cursor = NULL; info->dbf = data; - + return SUCCESS; } else { dbp->close(dbp, 0); @@ -113,7 +113,7 @@ DBA_OPEN_FUNC(db3) DBA_CLOSE_FUNC(db3) { DB3_DATA; - + if (dba->cursor) dba->cursor->c_close(dba->cursor); dba->dbp->close(dba->dbp, 0); pefree(dba, info->flags&DBA_PERSISTENT); @@ -125,7 +125,7 @@ DBA_FETCH_FUNC(db3) char *new = NULL; DB3_DATA; DB3_GKEY; - + memset(&gval, 0, sizeof(gval)); if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { if (newlen) *newlen = gval.size; @@ -139,12 +139,12 @@ DBA_UPDATE_FUNC(db3) DBT gval; DB3_DATA; DB3_GKEY; - + memset(&gval, 0, sizeof(gval)); gval.data = (char *) val; gval.size = vallen; - if (!dba->dbp->put(dba->dbp, NULL, &gkey, &gval, + if (!dba->dbp->put(dba->dbp, NULL, &gkey, &gval, mode == 1 ? DB_NOOVERWRITE : 0)) { return SUCCESS; } @@ -156,7 +156,7 @@ DBA_EXISTS_FUNC(db3) DBT gval; DB3_DATA; DB3_GKEY; - + memset(&gval, 0, sizeof(gval)); if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { return SUCCESS; @@ -194,7 +194,7 @@ DBA_NEXTKEY_FUNC(db3) DB3_DATA; DBT gkey, gval; char *nkey = NULL; - + memset(&gkey, 0, sizeof(gkey)); memset(&gval, 0, sizeof(gval)); diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index 393c565b2a..d237c6abb2 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -38,7 +38,7 @@ static void php_dba_db4_errcall_fcn( #if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)) - const DB_ENV *dbenv, + const DB_ENV *dbenv, #endif const char *errpfx, const char *msg) { @@ -87,11 +87,11 @@ DBA_OPEN_FUNC(db4) type = info->mode == DBA_READER ? DB_UNKNOWN : info->mode == DBA_TRUNC ? DB_BTREE : s ? DB_BTREE : DB_UNKNOWN; - + gmode = info->mode == DBA_READER ? DB_RDONLY : - (info->mode == DBA_CREAT && s) ? DB_CREATE : + (info->mode == DBA_CREAT && s) ? DB_CREATE : (info->mode == DBA_CREAT && !s) ? 0 : - info->mode == DBA_WRITER ? 0 : + info->mode == DBA_WRITER ? 0 : info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; #else if (!s && !check_stat.st_size) { @@ -101,10 +101,10 @@ DBA_OPEN_FUNC(db4) type = info->mode == DBA_READER ? DB_UNKNOWN : (info->mode == DBA_TRUNC || info->mode == DBA_CREAT) ? DB_BTREE : s ? DB_BTREE : DB_UNKNOWN; - + gmode = info->mode == DBA_READER ? DB_RDONLY : - info->mode == DBA_CREAT ? DB_CREATE : - info->mode == DBA_WRITER ? 0 : + info->mode == DBA_CREAT ? DB_CREATE : + info->mode == DBA_WRITER ? 0 : info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; #endif @@ -135,7 +135,7 @@ DBA_OPEN_FUNC(db4) data->dbp = dbp; data->cursor = NULL; info->dbf = data; - + return SUCCESS; } else { dbp->close(dbp, 0); @@ -151,7 +151,7 @@ DBA_OPEN_FUNC(db4) DBA_CLOSE_FUNC(db4) { DB4_DATA; - + if (dba->cursor) dba->cursor->c_close(dba->cursor); dba->dbp->close(dba->dbp, 0); pefree(dba, info->flags&DBA_PERSISTENT); @@ -163,7 +163,7 @@ DBA_FETCH_FUNC(db4) char *new = NULL; DB4_DATA; DB4_GKEY; - + memset(&gval, 0, sizeof(gval)); if (info->flags & DBA_PERSISTENT) { gval.flags |= DB_DBT_MALLOC; @@ -183,12 +183,12 @@ DBA_UPDATE_FUNC(db4) DBT gval; DB4_DATA; DB4_GKEY; - + memset(&gval, 0, sizeof(gval)); gval.data = (char *) val; gval.size = vallen; - if (!dba->dbp->put(dba->dbp, NULL, &gkey, &gval, + if (!dba->dbp->put(dba->dbp, NULL, &gkey, &gval, mode == 1 ? DB_NOOVERWRITE : 0)) { return SUCCESS; } @@ -200,9 +200,9 @@ DBA_EXISTS_FUNC(db4) DBT gval; DB4_DATA; DB4_GKEY; - + memset(&gval, 0, sizeof(gval)); - + if (info->flags & DBA_PERSISTENT) { gval.flags |= DB_DBT_MALLOC; } @@ -246,7 +246,7 @@ DBA_NEXTKEY_FUNC(db4) DB4_DATA; DBT gkey, gval; char *nkey = NULL; - + memset(&gkey, 0, sizeof(gkey)); memset(&gval, 0, sizeof(gval)); diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c index 47a2e5a2af..61855b4dff 100644 --- a/ext/dba/dba_dbm.c +++ b/ext/dba/dba_dbm.c @@ -63,7 +63,7 @@ DBA_OPEN_FUNC(dbm) convert_to_long_ex(&info->argv[0]); filemode = Z_LVAL(info->argv[0]); } - + if(info->mode == DBA_TRUNC) { char buf[MAXPATHLEN]; @@ -123,7 +123,7 @@ DBA_UPDATE_FUNC(dbm) gval.dptr = (char *) val; gval.dsize = vallen; - + return (store(gkey, gval) == -1 ? FAILURE : SUCCESS); } @@ -131,7 +131,7 @@ DBA_EXISTS_FUNC(dbm) { datum gval; DBM_GKEY; - + gval = fetch(gkey); if(gval.dptr) { return SUCCESS; @@ -166,9 +166,9 @@ DBA_NEXTKEY_FUNC(dbm) DBM_DATA; datum gkey; char *nkey = NULL; - + if(!dba->nextkey.dptr) return NULL; - + gkey = nextkey(dba->nextkey); if(gkey.dptr) { if(newlen) *newlen = gkey.dsize; diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c index 49f39cf2a8..a85df39afe 100644 --- a/ext/dba/dba_flatfile.c +++ b/ext/dba/dba_flatfile.c @@ -86,7 +86,7 @@ DBA_UPDATE_FUNC(flatfile) FLATFILE_GKEY; gval.dptr = (char *) val; gval.dsize = vallen; - + switch(flatfile_store(dba, gkey, gval, mode==1 ? FLATFILE_INSERT : FLATFILE_REPLACE)) { case 0: return SUCCESS; @@ -106,7 +106,7 @@ DBA_EXISTS_FUNC(flatfile) datum gval; FLATFILE_DATA; FLATFILE_GKEY; - + gval = flatfile_fetch(dba, gkey); if (gval.dptr) { efree(gval.dptr); @@ -142,11 +142,11 @@ DBA_FIRSTKEY_FUNC(flatfile) DBA_NEXTKEY_FUNC(flatfile) { FLATFILE_DATA; - + if (!dba->nextkey.dptr) { return NULL; } - + if (dba->nextkey.dptr) { efree(dba->nextkey.dptr); } diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c index 5f2fd1076d..20df5876d6 100644 --- a/ext/dba/dba_gdbm.c +++ b/ext/dba/dba_gdbm.c @@ -46,11 +46,11 @@ DBA_OPEN_FUNC(gdbm) int filemode = 0644; gmode = info->mode == DBA_READER ? GDBM_READER : - info->mode == DBA_WRITER ? GDBM_WRITER : - info->mode == DBA_CREAT ? GDBM_WRCREAT : + info->mode == DBA_WRITER ? GDBM_WRITER : + info->mode == DBA_CREAT ? GDBM_WRCREAT : info->mode == DBA_TRUNC ? GDBM_NEWDB : -1; - - if(gmode == -1) + + if(gmode == -1) return FAILURE; /* not possible */ if(info->argc > 0) { @@ -59,7 +59,7 @@ DBA_OPEN_FUNC(gdbm) } dbf = gdbm_open(info->path, 0, gmode, filemode, NULL); - + if(dbf) { info->dbf = pemalloc(sizeof(dba_gdbm_data), info->flags&DBA_PERSISTENT); memset(info->dbf, 0, sizeof(dba_gdbm_data)); @@ -73,7 +73,7 @@ DBA_OPEN_FUNC(gdbm) DBA_CLOSE_FUNC(gdbm) { GDBM_DATA; - + if(dba->nextkey.dptr) free(dba->nextkey.dptr); gdbm_close(dba->dbf); pefree(dba, info->flags&DBA_PERSISTENT); @@ -130,7 +130,7 @@ DBA_DELETE_FUNC(gdbm) { GDBM_DATA; GDBM_GKEY; - + return gdbm_delete(dba->dbf, gkey) == -1 ? FAILURE : SUCCESS; } @@ -143,7 +143,7 @@ DBA_FIRSTKEY_FUNC(gdbm) if(dba->nextkey.dptr) { free(dba->nextkey.dptr); } - + gkey = gdbm_firstkey(dba->dbf); if(gkey.dptr) { key = estrndup(gkey.dptr, gkey.dsize); @@ -162,7 +162,7 @@ DBA_NEXTKEY_FUNC(gdbm) datum gkey; if(!dba->nextkey.dptr) return NULL; - + gkey = gdbm_nextkey(dba->dbf, dba->nextkey); free(dba->nextkey.dptr); if(gkey.dptr) { @@ -182,7 +182,7 @@ DBA_OPTIMIZE_FUNC(gdbm) return SUCCESS; } -DBA_SYNC_FUNC(gdbm) +DBA_SYNC_FUNC(gdbm) { GDBM_DATA; diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c index 333438163c..e0849908e0 100644 --- a/ext/dba/dba_inifile.c +++ b/ext/dba/dba_inifile.c @@ -84,9 +84,9 @@ DBA_UPDATE_FUNC(inifile) INIFILE_DATA; INIFILE_GKEY; - + ini_val.value = val; - + if (mode == 1) { res = inifile_append(dba, &ini_key, &ini_val); } else { @@ -111,7 +111,7 @@ DBA_EXISTS_FUNC(inifile) INIFILE_DATA; INIFILE_GKEY; - + ini_val = inifile_fetch(dba, &ini_key, 0); INIFILE_DONE; if (ini_val.value) { @@ -151,7 +151,7 @@ DBA_FIRSTKEY_FUNC(inifile) DBA_NEXTKEY_FUNC(inifile) { INIFILE_DATA; - + 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 f7b33efd3f..4708d79b68 100644 --- a/ext/dba/dba_ndbm.c +++ b/ext/dba/dba_ndbm.c @@ -64,7 +64,7 @@ DBA_OPEN_FUNC(ndbm) } dbf = dbm_open(info->path, gmode, filemode); - + pinfo->dbf = dbf; return SUCCESS; } diff --git a/ext/dba/dba_tcadb.c b/ext/dba/dba_tcadb.c index e4771eb641..65224a9c59 100644 --- a/ext/dba/dba_tcadb.c +++ b/ext/dba/dba_tcadb.c @@ -34,7 +34,7 @@ #define TCADB_DATA dba_tcadb_data *dba = info->dbf typedef struct { - TCADB *tcadb; + TCADB *tcadb; } dba_tcadb_data; DBA_OPEN_FUNC(tcadb) @@ -115,7 +115,7 @@ DBA_UPDATE_FUNC(tcadb) return FAILURE; } } - + result = tcadbput(dba->tcadb, key, keylen, val, vallen); if (result) { diff --git a/ext/dba/libcdb/cdb.c b/ext/dba/libcdb/cdb.c index d6578d017d..54c4db7022 100644 --- a/ext/dba/libcdb/cdb.c +++ b/ext/dba/libcdb/cdb.c @@ -50,11 +50,11 @@ static int cdb_match(struct cdb *c, char *key, unsigned int len, uint32 pos) while (len > 0) { n = sizeof(buf); - if (n > len) + if (n > len) n = len; - if (cdb_read(c, buf, n, pos) == -1) + if (cdb_read(c, buf, n, pos) == -1) return -1; - if (memcmp(buf, key, n)) + if (memcmp(buf, key, n)) return 0; pos += n; key += n; @@ -112,7 +112,7 @@ int cdb_read(struct cdb *c, char *buf, unsigned int len, uint32 pos) do { r = php_stream_read(c->fp, buf, len); } while ((r == -1) && (errno == EINTR)); - if (r == -1) + if (r == -1) return -1; if (r == 0) { errno = EPROTO; @@ -134,10 +134,10 @@ int cdb_findnext(struct cdb *c, char *key, unsigned int len) if (!c->loop) { u = cdb_hash(key, len); - if (cdb_read(c, buf, 8, (u << 3) & 2047) == -1) + if (cdb_read(c, buf, 8, (u << 3) & 2047) == -1) return -1; uint32_unpack(buf + 4,&c->hslots); - if (!c->hslots) + if (!c->hslots) return 0; uint32_unpack(buf, &c->hpos); c->khash = u; @@ -148,18 +148,18 @@ int cdb_findnext(struct cdb *c, char *key, unsigned int len) } while (c->loop < c->hslots) { - if (cdb_read(c, buf, 8, c->kpos) == -1) + if (cdb_read(c, buf, 8, c->kpos) == -1) return -1; uint32_unpack(buf + 4, &pos); - if (!pos) + if (!pos) return 0; c->loop += 1; c->kpos += 8; - if (c->kpos == c->hpos + (c->hslots << 3)) + if (c->kpos == c->hpos + (c->hslots << 3)) c->kpos = c->hpos; uint32_unpack(buf, &u); if (u == c->khash) { - if (cdb_read(c, buf, 8, pos) == -1) + if (cdb_read(c, buf, 8, pos) == -1) return -1; uint32_unpack(buf, &u); if (u == len) @@ -187,7 +187,7 @@ int cdb_find(struct cdb *c, char *key, unsigned int len) /* }}} */ /* {{{ cdb_version */ -char *cdb_version() +char *cdb_version() { return "0.75, $Id$"; } diff --git a/ext/dba/libcdb/cdb_make.c b/ext/dba/libcdb/cdb_make.c index 3be1157769..90e11957c1 100644 --- a/ext/dba/libcdb/cdb_make.c +++ b/ext/dba/libcdb/cdb_make.c @@ -238,7 +238,7 @@ int cdb_make_finish(struct cdb_make *c) /* }}} */ /* {{{ cdb_make_version */ -char *cdb_make_version() +char *cdb_make_version() { return "0.75, $Id$"; } diff --git a/ext/dba/libflatfile/flatfile.c b/ext/dba/libflatfile/flatfile.c index 361cc42519..0426e72f0c 100644 --- a/ext/dba/libflatfile/flatfile.c +++ b/ext/dba/libflatfile/flatfile.c @@ -137,7 +137,7 @@ int flatfile_delete(flatfile *dba, datum key_datum) { php_stream_seek(dba->fp, 0L, SEEK_END); efree(buf); return SUCCESS; - } + } /* read in the length of the value */ if (!php_stream_gets(dba->fp, buf, 15)) { @@ -156,7 +156,7 @@ int flatfile_delete(flatfile *dba, datum key_datum) { } efree(buf); return FAILURE; -} +} /* }}} */ /* {{{ flatfile_findkey @@ -188,7 +188,7 @@ int flatfile_findkey(flatfile *dba, datum key_datum) { ret = 1; break; } - } + } if (!php_stream_gets(dba->fp, buf, 15)) { break; } @@ -300,15 +300,15 @@ datum flatfile_nextkey(flatfile *dba) { res.dptr = NULL; res.dsize = 0; return res; -} +} /* }}} */ /* {{{ flatfile_version */ -char *flatfile_version() +char *flatfile_version() { return "1.0, $Id$"; } -/* }}} */ +/* }}} */ /* * Local variables: diff --git a/ext/dba/libinifile/inifile.c b/ext/dba/libinifile/inifile.c index 52c5d730bc..6f3da210f1 100644 --- a/ext/dba/libinifile/inifile.c +++ b/ext/dba/libinifile/inifile.c @@ -40,11 +40,11 @@ */ /* {{{ inifile_version */ -char *inifile_version() +char *inifile_version() { return "1.0, $Id$"; } -/* }}} */ +/* }}} */ /* {{{ inifile_free_key */ void inifile_key_free(key_type *key) @@ -89,7 +89,7 @@ inifile * inifile_alloc(php_stream *fp, int readonly, int persistent) return NULL; } } - + dba = pemalloc(sizeof(inifile), persistent); memset(dba, 0, sizeof(inifile)); dba->fp = fp; @@ -114,7 +114,7 @@ key_type inifile_key_split(const char *group_name) { key_type key; char *name; - + if (group_name[0] == '[' && (name = strchr(group_name, ']')) != NULL) { key.group = estrndup(group_name+1, name - (group_name + 1)); key.name = estrdup(name+1); @@ -146,7 +146,7 @@ static char *etrim(const char *str) { char *val; size_t l; - + if (!str) { return NULL; } @@ -227,7 +227,7 @@ static int inifile_read(inifile *dba, line_type *ln) { static int inifile_key_cmp(const key_type *k1, const key_type *k2) { assert(k1->group && k1->name && k2->group && k2->name); - + if (!strcasecmp(k1->group, k2->group)) { if (!strcasecmp(k1->name, k2->name)) { return 0; @@ -304,7 +304,7 @@ int inifile_nextkey(inifile *dba) { inifile_line_free(&dba->curr); dba->curr = ln; return ln.key.group || ln.key.name; -} +} /* }}} */ /* {{{ inifile_truncate @@ -325,7 +325,7 @@ static int inifile_truncate(inifile *dba, size_t size) /* {{{ inifile_find_group * if found pos_grp_start points to "[group_name]" */ -static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start) +static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start) { int ret = FAILURE; @@ -362,7 +362,7 @@ static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp * only valid after a call to inifile_find_group * if any next group is found pos_grp_start points to "[group_name]" or whitespace before that */ -static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start) +static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start) { int ret = FAILURE; line_type ln = {{NULL,NULL},{NULL}}; @@ -386,7 +386,7 @@ static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy) { php_stream *fp; - + if (pos_start == pos_end) { *ini_copy = NULL; return SUCCESS; @@ -405,7 +405,7 @@ static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifi if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) { php_error_docref(NULL, E_WARNING, "Could not copy group [%zu - %zu] to temporary stream", pos_start, pos_end); return FAILURE; - } + } return SUCCESS; } /* }}} */ @@ -473,7 +473,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons * 3) If not append: Copy group to ini_tmp * 4) Open temp_stream and copy remainder * 5) Truncate stream - * 6) If not append AND key.name given: Filtered copy back from ini_tmp + * 6) If not append AND key.name given: Filtered copy back from ini_tmp * to stream. Otherwise the user wanted to delete the group. * 7) Append value if given * 8) Append temporary stream @@ -507,7 +507,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons } } } - + /* 5 */ if (ret == SUCCESS) { if (!value || (key->name && strlen(key->name))) { @@ -533,8 +533,8 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons php_stream_printf(dba->fp, "%s=%s\n", key->name, value->value ? value->value : ""); } } - - /* 8 */ + + /* 8 */ /* important: do not query ret==SUCCESS again: inifile_filter might fail but * however next operation must be done. */ @@ -564,7 +564,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons /* {{{ inifile_delete */ -int inifile_delete(inifile *dba, const key_type *key) +int inifile_delete(inifile *dba, const key_type *key) { return inifile_delete_replace_append(dba, key, NULL, 0, NULL); } @@ -575,12 +575,12 @@ int inifile_delete(inifile *dba, const key_type *key) int inifile_delete_ex(inifile *dba, const key_type *key, zend_bool *found) { return inifile_delete_replace_append(dba, key, NULL, 0, found); -} +} /* }}} */ /* {{{ inifile_relace */ -int inifile_replace(inifile *dba, const key_type *key, const val_type *value) +int inifile_replace(inifile *dba, const key_type *key, const val_type *value) { return inifile_delete_replace_append(dba, key, value, 0, NULL); } @@ -596,7 +596,7 @@ int inifile_replace_ex(inifile *dba, const key_type *key, const val_type *value, /* {{{ inifile_append */ -int inifile_append(inifile *dba, const key_type *key, const val_type *value) +int inifile_append(inifile *dba, const key_type *key, const val_type *value) { return inifile_delete_replace_append(dba, key, value, 1, NULL); } diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h index 3421b5de93..6fc0357136 100644 --- a/ext/dba/php_dba.h +++ b/ext/dba/php_dba.h @@ -23,7 +23,7 @@ #if HAVE_DBA -typedef enum { +typedef enum { /* do not allow 0 here */ DBA_READER = 1, DBA_WRITER, @@ -49,7 +49,7 @@ typedef struct dba_info { zval *argv; /* private */ int flags; /* whether and how dba did locking and other flags*/ - struct dba_handler *hnd; + struct dba_handler *hnd; dba_lock lock; } dba_info; @@ -127,7 +127,7 @@ typedef struct dba_handler { DBA_INFO_FUNC(x) #define VALLEN(p) Z_STRVAL_PP(p), Z_STRLEN_PP(p) - + PHP_FUNCTION(dba_open); PHP_FUNCTION(dba_popen); PHP_FUNCTION(dba_close); |