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()
256 php_stream_rewind(dba->fp); in inifile_fetch()
257 inifile_line_free(&dba->next); in inifile_fetch()
262 while(inifile_read(dba, &ln TSRMLS_CC)) { in inifile_fetch()
267 inifile_line_free(&dba->next); in inifile_fetch()
268 dba->next = ln; in inifile_fetch()
269 dba->next.pos = php_stream_tell(dba->fp); in inifile_fetch()
281 dba->next.pos = php_stream_tell(dba->fp); in inifile_fetch()
288 int inifile_firstkey(inifile *dba TSRMLS_DC) { in inifile_firstkey()
289 inifile_line_free(&dba->curr); in inifile_firstkey()
290 dba->curr.pos = 0; in inifile_firstkey()
291 return inifile_nextkey(dba TSRMLS_CC); in inifile_firstkey()
297 int inifile_nextkey(inifile *dba TSRMLS_DC) { in inifile_nextkey()
301 php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET); in inifile_nextkey()
302 ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : ""); in inifile_nextkey()
303 inifile_read(dba, &ln TSRMLS_CC); in inifile_nextkey()
304 inifile_line_free(&dba->curr); in inifile_nextkey()
305 dba->curr = ln; in inifile_nextkey()
312 static int inifile_truncate(inifile *dba, size_t size TSRMLS_DC) in inifile_truncate() argument
316 if ((res=php_stream_truncate_set_size(dba->fp, size)) != 0) { in inifile_truncate()
320 php_stream_seek(dba->fp, size, SEEK_SET); in inifile_truncate()
328 static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC) in inifile_find_group() argument
332 php_stream_flush(dba->fp); in inifile_find_group()
333 php_stream_seek(dba->fp, 0, SEEK_SET); in inifile_find_group()
334 inifile_line_free(&dba->curr); in inifile_find_group()
335 inifile_line_free(&dba->next); in inifile_find_group()
342 while(inifile_read(dba, &ln TSRMLS_CC)) { in inifile_find_group()
347 *pos_grp_start = php_stream_tell(dba->fp); in inifile_find_group()
355 *pos_grp_start = php_stream_tell(dba->fp); in inifile_find_group()
365 static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC) in inifile_next_group() argument
370 *pos_grp_start = php_stream_tell(dba->fp); in inifile_next_group()
372 while(inifile_read(dba, &ln TSRMLS_CC)) { in inifile_next_group()
377 *pos_grp_start = php_stream_tell(dba->fp); in inifile_next_group()
386 static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy TSRML… in inifile_copy_to() argument
404 php_stream_seek(dba->fp, pos_start, SEEK_SET); in inifile_copy_to()
405 if (!php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) { in inifile_copy_to()
416 static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRMLS_DC) in inifile_filter() argument
423 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_filter()
430 if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
449 if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
461 static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, … in inifile_delete_replace_append() argument
482 inifile_find_group(dba, key, &pos_grp_start TSRMLS_CC); in inifile_delete_replace_append()
483 inifile_next_group(dba, key, &pos_grp_next TSRMLS_CC); in inifile_delete_replace_append()
487 ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp TSRMLS_CC); in inifile_delete_replace_append()
497 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
498 if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) { in inifile_delete_replace_append()
499 php_stream_seek(dba->fp, pos_grp_next, SEEK_SET); in inifile_delete_replace_append()
500 if (!php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
511 …ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start TSRMLS_CC); /* writes error on f… in inifile_delete_replace_append()
519 ret = inifile_filter(dba, ini_tmp, key TSRMLS_CC); in inifile_delete_replace_append()
528 php_stream_printf(dba->fp TSRMLS_CC, "[%s]\n", key->group); in inifile_delete_replace_append()
530 php_stream_printf(dba->fp TSRMLS_CC, "%s=%s\n", key->name, value->value ? value->value : ""); in inifile_delete_replace_append()
540 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
541 if (!php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
555 php_stream_flush(dba->fp); in inifile_delete_replace_append()
556 php_stream_seek(dba->fp, 0, SEEK_SET); in inifile_delete_replace_append()
564 int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC) in inifile_delete() argument
566 return inifile_delete_replace_append(dba, key, NULL, 0 TSRMLS_CC); in inifile_delete()
572 int inifile_replace(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC) in inifile_replace() argument
574 return inifile_delete_replace_append(dba, key, value, 0 TSRMLS_CC); in inifile_replace()
580 int inifile_append(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC) in inifile_append() argument
582 return inifile_delete_replace_append(dba, key, value, 1 TSRMLS_CC); in inifile_append()