summaryrefslogtreecommitdiff
path: root/ext/dba/libinifile/inifile.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dba/libinifile/inifile.c')
-rw-r--r--ext/dba/libinifile/inifile.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/ext/dba/libinifile/inifile.c b/ext/dba/libinifile/inifile.c
index 6b64872649..52c5d730bc 100644
--- a/ext/dba/libinifile/inifile.c
+++ b/ext/dba/libinifile/inifile.c
@@ -79,13 +79,13 @@ void inifile_line_free(line_type *ln)
/* }}} */
/* {{{ inifile_alloc */
-inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC)
+inifile * inifile_alloc(php_stream *fp, int readonly, int persistent)
{
inifile *dba;
if (!readonly) {
if (!php_stream_truncate_supported(fp)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't truncate this stream");
+ php_error_docref(NULL, E_WARNING, "Can't truncate this stream");
return NULL;
}
}
@@ -164,7 +164,7 @@ static char *etrim(const char *str)
/* {{{ inifile_findkey
*/
-static int inifile_read(inifile *dba, line_type *ln TSRMLS_DC) {
+static int inifile_read(inifile *dba, line_type *ln) {
char *fline;
char *pos;
@@ -224,7 +224,7 @@ static int inifile_read(inifile *dba, line_type *ln TSRMLS_DC) {
* 1 = GROUP-EQUAL,NAME-DIFFERENT
* 2 = DIFFERENT
*/
-static int inifile_key_cmp(const key_type *k1, const key_type *k2 TSRMLS_DC)
+static int inifile_key_cmp(const key_type *k1, const key_type *k2)
{
assert(k1->group && k1->name && k2->group && k2->name);
@@ -242,12 +242,12 @@ static int inifile_key_cmp(const key_type *k1, const key_type *k2 TSRMLS_DC)
/* {{{ inifile_fetch
*/
-val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) {
+val_type inifile_fetch(inifile *dba, const key_type *key, int skip) {
line_type ln = {{NULL,NULL},{NULL}};
val_type val;
int res, grp_eq = 0;
- if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
+ if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, key)) {
/* we got position already from last fetch */
php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
} else {
@@ -259,8 +259,8 @@ val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) {
if (skip == -1) {
skip = 0;
}
- while(inifile_read(dba, &ln TSRMLS_CC)) {
- if (!(res=inifile_key_cmp(&ln.key, key TSRMLS_CC))) {
+ while(inifile_read(dba, &ln)) {
+ if (!(res=inifile_key_cmp(&ln.key, key))) {
if (!skip) {
val.value = estrdup(ln.val.value ? ln.val.value : "");
/* allow faster access by updating key read into next */
@@ -285,22 +285,22 @@ val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) {
/* {{{ inifile_firstkey
*/
-int inifile_firstkey(inifile *dba TSRMLS_DC) {
+int inifile_firstkey(inifile *dba) {
inifile_line_free(&dba->curr);
dba->curr.pos = 0;
- return inifile_nextkey(dba TSRMLS_CC);
+ return inifile_nextkey(dba);
}
/* }}} */
/* {{{ inifile_nextkey
*/
-int inifile_nextkey(inifile *dba TSRMLS_DC) {
+int inifile_nextkey(inifile *dba) {
line_type ln = {{NULL,NULL},{NULL}};
/*inifile_line_free(&dba->next); ??? */
php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET);
ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : "");
- inifile_read(dba, &ln TSRMLS_CC);
+ inifile_read(dba, &ln);
inifile_line_free(&dba->curr);
dba->curr = ln;
return ln.key.group || ln.key.name;
@@ -309,12 +309,12 @@ int inifile_nextkey(inifile *dba TSRMLS_DC) {
/* {{{ inifile_truncate
*/
-static int inifile_truncate(inifile *dba, size_t size TSRMLS_DC)
+static int inifile_truncate(inifile *dba, size_t size)
{
int res;
if ((res=php_stream_truncate_set_size(dba->fp, size)) != 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in ftruncate: %d", res);
+ php_error_docref(NULL, E_WARNING, "Error in ftruncate: %d", res);
return FAILURE;
}
php_stream_seek(dba->fp, size, SEEK_SET);
@@ -325,7 +325,7 @@ static int inifile_truncate(inifile *dba, size_t size TSRMLS_DC)
/* {{{ 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 TSRMLS_DC)
+static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start)
{
int ret = FAILURE;
@@ -339,8 +339,8 @@ static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp
line_type ln = {{NULL,NULL},{NULL}};
res = 1;
- while(inifile_read(dba, &ln TSRMLS_CC)) {
- if ((res=inifile_key_cmp(&ln.key, key TSRMLS_CC)) < 2) {
+ while(inifile_read(dba, &ln)) {
+ if ((res=inifile_key_cmp(&ln.key, key)) < 2) {
ret = SUCCESS;
break;
}
@@ -362,15 +362,15 @@ 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 TSRMLS_DC)
+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}};
*pos_grp_start = php_stream_tell(dba->fp);
ln.key.group = estrdup(key->group);
- while(inifile_read(dba, &ln TSRMLS_CC)) {
- if (inifile_key_cmp(&ln.key, key TSRMLS_CC) == 2) {
+ while(inifile_read(dba, &ln)) {
+ if (inifile_key_cmp(&ln.key, key) == 2) {
ret = SUCCESS;
break;
}
@@ -383,7 +383,7 @@ static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp
/* {{{ inifile_copy_to
*/
-static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy TSRMLS_DC)
+static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy)
{
php_stream *fp;
@@ -392,18 +392,18 @@ static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifi
return SUCCESS;
}
if ((fp = php_stream_temp_create(0, 64 * 1024)) == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create temporary stream");
+ php_error_docref(NULL, E_WARNING, "Could not create temporary stream");
*ini_copy = NULL;
return FAILURE;
}
- if ((*ini_copy = inifile_alloc(fp, 1, 0 TSRMLS_CC)) == NULL) {
+ if ((*ini_copy = inifile_alloc(fp, 1, 0)) == NULL) {
/* writes error */
return FAILURE;
}
php_stream_seek(dba->fp, pos_start, SEEK_SET);
if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy group [%zu - %zu] to temporary stream", pos_start, pos_end);
+ php_error_docref(NULL, E_WARNING, "Could not copy group [%zu - %zu] to temporary stream", pos_start, pos_end);
return FAILURE;
}
return SUCCESS;
@@ -413,7 +413,7 @@ static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifi
/* {{{ inifile_filter
* copy from to dba while ignoring key name (group must equal)
*/
-static int inifile_filter(inifile *dba, inifile *from, const key_type *key, zend_bool *found TSRMLS_DC)
+static int inifile_filter(inifile *dba, inifile *from, const key_type *key, zend_bool *found)
{
size_t pos_start = 0, pos_next = 0, pos_curr;
int ret = SUCCESS;
@@ -421,8 +421,8 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key, zend
php_stream_seek(from->fp, 0, SEEK_SET);
php_stream_seek(dba->fp, 0, SEEK_END);
- while(inifile_read(from, &ln TSRMLS_CC)) {
- switch(inifile_key_cmp(&ln.key, key TSRMLS_CC)) {
+ while(inifile_read(from, &ln)) {
+ switch(inifile_key_cmp(&ln.key, key)) {
case 0:
if (found) {
*found = (zend_bool) 1;
@@ -431,7 +431,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key, zend
if (pos_start != pos_next) {
php_stream_seek(from->fp, pos_start, SEEK_SET);
if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
+ php_error_docref(NULL, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
ret = FAILURE;
}
php_stream_seek(from->fp, pos_curr, SEEK_SET);
@@ -450,7 +450,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key, zend
if (pos_start != pos_next) {
php_stream_seek(from->fp, pos_start, SEEK_SET);
if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
+ php_error_docref(NULL, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
ret = FAILURE;
}
}
@@ -461,7 +461,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key, zend
/* {{{ inifile_delete_replace_append
*/
-static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, int append, zend_bool *found TSRMLS_DC)
+static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, int append, zend_bool *found)
{
size_t pos_grp_start=0, pos_grp_next;
inifile *ini_tmp = NULL;
@@ -482,26 +482,26 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
assert(!append || (key->name && value)); /* missuse */
/* 1 - 3 */
- inifile_find_group(dba, key, &pos_grp_start TSRMLS_CC);
- inifile_next_group(dba, key, &pos_grp_next TSRMLS_CC);
+ inifile_find_group(dba, key, &pos_grp_start);
+ inifile_next_group(dba, key, &pos_grp_next);
if (append) {
ret = SUCCESS;
} else {
- ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp TSRMLS_CC);
+ ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp);
}
/* 4 */
if (ret == SUCCESS) {
fp_tmp = php_stream_temp_create(0, 64 * 1024);
if (!fp_tmp) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create temporary stream");
+ php_error_docref(NULL, E_WARNING, "Could not create temporary stream");
ret = FAILURE;
} else {
php_stream_seek(dba->fp, 0, SEEK_END);
if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) {
php_stream_seek(dba->fp, pos_grp_next, SEEK_SET);
if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy remainder to temporary stream");
+ php_error_docref(NULL, E_WARNING, "Could not copy remainder to temporary stream");
ret = FAILURE;
}
}
@@ -511,7 +511,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))) {
- ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start TSRMLS_CC); /* writes error on fail */
+ ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start); /* writes error on fail */
}
}
@@ -519,7 +519,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
if (key->name && strlen(key->name)) {
/* 6 */
if (!append && ini_tmp) {
- ret = inifile_filter(dba, ini_tmp, key, found TSRMLS_CC);
+ ret = inifile_filter(dba, ini_tmp, key, found);
}
/* 7 */
@@ -528,9 +528,9 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
*/
if (value) {
if (pos_grp_start == pos_grp_next && key->group && strlen(key->group)) {
- php_stream_printf(dba->fp TSRMLS_CC, "[%s]\n", key->group);
+ php_stream_printf(dba->fp, "[%s]\n", key->group);
}
- php_stream_printf(dba->fp TSRMLS_CC, "%s=%s\n", key->name, value->value ? value->value : "");
+ php_stream_printf(dba->fp, "%s=%s\n", key->name, value->value ? value->value : "");
}
}
@@ -542,7 +542,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
php_stream_seek(fp_tmp, 0, SEEK_SET);
php_stream_seek(dba->fp, 0, SEEK_END);
if (SUCCESS != php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) {
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Could not copy from temporary stream - ini file truncated");
+ php_error_docref(NULL, E_RECOVERABLE_ERROR, "Could not copy from temporary stream - ini file truncated");
ret = FAILURE;
}
}
@@ -564,41 +564,41 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
/* {{{ inifile_delete
*/
-int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC)
+int inifile_delete(inifile *dba, const key_type *key)
{
- return inifile_delete_replace_append(dba, key, NULL, 0, NULL TSRMLS_CC);
+ return inifile_delete_replace_append(dba, key, NULL, 0, NULL);
}
/* }}} */
/* {{{ inifile_delete_ex
*/
-int inifile_delete_ex(inifile *dba, const key_type *key, zend_bool *found TSRMLS_DC)
+int inifile_delete_ex(inifile *dba, const key_type *key, zend_bool *found)
{
- return inifile_delete_replace_append(dba, key, NULL, 0, found TSRMLS_CC);
+ 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 TSRMLS_DC)
+int inifile_replace(inifile *dba, const key_type *key, const val_type *value)
{
- return inifile_delete_replace_append(dba, key, value, 0, NULL TSRMLS_CC);
+ return inifile_delete_replace_append(dba, key, value, 0, NULL);
}
/* }}} */
/* {{{ inifile_replace_ex
*/
-int inifile_replace_ex(inifile *dba, const key_type *key, const val_type *value, zend_bool *found TSRMLS_DC)
+int inifile_replace_ex(inifile *dba, const key_type *key, const val_type *value, zend_bool *found)
{
- return inifile_delete_replace_append(dba, key, value, 0, found TSRMLS_CC);
+ return inifile_delete_replace_append(dba, key, value, 0, found);
}
/* }}} */
/* {{{ inifile_append
*/
-int inifile_append(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC)
+int inifile_append(inifile *dba, const key_type *key, const val_type *value)
{
- return inifile_delete_replace_append(dba, key, value, 1, NULL TSRMLS_CC);
+ return inifile_delete_replace_append(dba, key, value, 1, NULL);
}
/* }}} */