Lines Matching refs:dba
84 inifile *dba; in inifile_alloc() local
93 dba = pemalloc(sizeof(inifile), persistent); in inifile_alloc()
94 memset(dba, 0, sizeof(inifile)); in inifile_alloc()
95 dba->fp = fp; in inifile_alloc()
96 dba->readonly = readonly; in inifile_alloc()
97 return dba; in inifile_alloc()
102 void inifile_free(inifile *dba, int persistent) in inifile_free() argument
104 if (dba) { in inifile_free()
105 inifile_line_free(&dba->curr); in inifile_free()
106 inifile_line_free(&dba->next); in inifile_free()
107 pefree(dba, persistent); in inifile_free()
167 static int inifile_read(inifile *dba, line_type *ln TSRMLS_DC) { in inifile_read() argument
172 while ((fline = php_stream_gets(dba->fp, NULL, 0)) != NULL) { in inifile_read()
184 ln->pos = php_stream_tell(dba->fp); in inifile_read()
204 ln->pos = php_stream_tell(dba->fp); in inifile_read()
245 val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) { in inifile_fetch() argument
250 …if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, ke… in inifile_fetch()
252 php_stream_seek(dba->fp, dba->next.pos, SEEK_SET); in inifile_fetch()
253 ln.key.group = estrdup(dba->next.key.group); in inifile_fetch()
257 php_stream_rewind(dba->fp); in inifile_fetch()
258 inifile_line_free(&dba->next); in inifile_fetch()
263 while(inifile_read(dba, &ln TSRMLS_CC)) { in inifile_fetch()
268 inifile_line_free(&dba->next); in inifile_fetch()
269 dba->next = ln; in inifile_fetch()
270 dba->next.pos = php_stream_tell(dba->fp); in inifile_fetch()
282 dba->next.pos = php_stream_tell(dba->fp); in inifile_fetch()
289 int inifile_firstkey(inifile *dba TSRMLS_DC) { in inifile_firstkey()
290 inifile_line_free(&dba->curr); in inifile_firstkey()
291 dba->curr.pos = 0; in inifile_firstkey()
292 return inifile_nextkey(dba TSRMLS_CC); in inifile_firstkey()
298 int inifile_nextkey(inifile *dba TSRMLS_DC) { in inifile_nextkey()
302 php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET); in inifile_nextkey()
303 ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : ""); in inifile_nextkey()
304 inifile_read(dba, &ln TSRMLS_CC); in inifile_nextkey()
305 inifile_line_free(&dba->curr); in inifile_nextkey()
306 dba->curr = ln; in inifile_nextkey()
313 static int inifile_truncate(inifile *dba, size_t size TSRMLS_DC) in inifile_truncate() argument
317 if ((res=php_stream_truncate_set_size(dba->fp, size)) != 0) { in inifile_truncate()
321 php_stream_seek(dba->fp, size, SEEK_SET); in inifile_truncate()
329 static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC) in inifile_find_group() argument
333 php_stream_flush(dba->fp); in inifile_find_group()
334 php_stream_seek(dba->fp, 0, SEEK_SET); in inifile_find_group()
335 inifile_line_free(&dba->curr); in inifile_find_group()
336 inifile_line_free(&dba->next); in inifile_find_group()
343 while(inifile_read(dba, &ln TSRMLS_CC)) { in inifile_find_group()
348 *pos_grp_start = php_stream_tell(dba->fp); in inifile_find_group()
356 *pos_grp_start = php_stream_tell(dba->fp); in inifile_find_group()
366 static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC) in inifile_next_group() argument
371 *pos_grp_start = php_stream_tell(dba->fp); in inifile_next_group()
373 while(inifile_read(dba, &ln TSRMLS_CC)) { in inifile_next_group()
378 *pos_grp_start = php_stream_tell(dba->fp); in inifile_next_group()
387 static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy TSRML… in inifile_copy_to() argument
405 php_stream_seek(dba->fp, pos_start, SEEK_SET); in inifile_copy_to()
406 if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) { in inifile_copy_to()
417 static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRMLS_DC) in inifile_filter() argument
424 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_filter()
431 if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
450 if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
462 static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, … in inifile_delete_replace_append() argument
483 inifile_find_group(dba, key, &pos_grp_start TSRMLS_CC); in inifile_delete_replace_append()
484 inifile_next_group(dba, key, &pos_grp_next TSRMLS_CC); in inifile_delete_replace_append()
488 ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp TSRMLS_CC); in inifile_delete_replace_append()
498 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
499 if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) { in inifile_delete_replace_append()
500 php_stream_seek(dba->fp, pos_grp_next, SEEK_SET); in inifile_delete_replace_append()
501 if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
512 …ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start TSRMLS_CC); /* writes error on f… in inifile_delete_replace_append()
520 ret = inifile_filter(dba, ini_tmp, key TSRMLS_CC); in inifile_delete_replace_append()
529 php_stream_printf(dba->fp TSRMLS_CC, "[%s]\n", key->group); in inifile_delete_replace_append()
531 php_stream_printf(dba->fp TSRMLS_CC, "%s=%s\n", key->name, value->value ? value->value : ""); in inifile_delete_replace_append()
541 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
542 if (SUCCESS != php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
556 php_stream_flush(dba->fp); in inifile_delete_replace_append()
557 php_stream_seek(dba->fp, 0, SEEK_SET); in inifile_delete_replace_append()
565 int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC) in inifile_delete() argument
567 return inifile_delete_replace_append(dba, key, NULL, 0 TSRMLS_CC); in inifile_delete()
573 int inifile_replace(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC) in inifile_replace() argument
575 return inifile_delete_replace_append(dba, key, value, 0 TSRMLS_CC); in inifile_replace()
581 int inifile_append(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC) in inifile_append() argument
583 return inifile_delete_replace_append(dba, key, value, 1 TSRMLS_CC); in inifile_append()