Lines Matching refs:dba

82 	inifile *dba;  in inifile_alloc()  local
91 dba = pemalloc(sizeof(inifile), persistent); in inifile_alloc()
92 memset(dba, 0, sizeof(inifile)); in inifile_alloc()
93 dba->fp = fp; in inifile_alloc()
94 dba->readonly = readonly; in inifile_alloc()
95 return dba; in inifile_alloc()
100 void inifile_free(inifile *dba, int persistent) in inifile_free() argument
102 if (dba) { in inifile_free()
103 inifile_line_free(&dba->curr); in inifile_free()
104 inifile_line_free(&dba->next); in inifile_free()
105 pefree(dba, persistent); in inifile_free()
164 static int inifile_read(inifile *dba, line_type *ln) { in inifile_read() argument
169 while ((fline = php_stream_gets(dba->fp, NULL, 0)) != NULL) { in inifile_read()
181 ln->pos = php_stream_tell(dba->fp); in inifile_read()
201 ln->pos = php_stream_tell(dba->fp); in inifile_read()
241 val_type inifile_fetch(inifile *dba, const key_type *key, int skip) { in inifile_fetch() argument
246 …if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, ke… in inifile_fetch()
248 php_stream_seek(dba->fp, dba->next.pos, SEEK_SET); in inifile_fetch()
249 ln.key.group = estrdup(dba->next.key.group); in inifile_fetch()
253 php_stream_rewind(dba->fp); in inifile_fetch()
254 inifile_line_free(&dba->next); in inifile_fetch()
259 while(inifile_read(dba, &ln)) { in inifile_fetch()
264 inifile_line_free(&dba->next); in inifile_fetch()
265 dba->next = ln; in inifile_fetch()
266 dba->next.pos = php_stream_tell(dba->fp); in inifile_fetch()
278 dba->next.pos = php_stream_tell(dba->fp); in inifile_fetch()
284 int inifile_firstkey(inifile *dba) { in inifile_firstkey() argument
285 inifile_line_free(&dba->curr); in inifile_firstkey()
286 dba->curr.pos = 0; in inifile_firstkey()
287 return inifile_nextkey(dba); in inifile_firstkey()
292 int inifile_nextkey(inifile *dba) { in inifile_nextkey() argument
296 php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET); in inifile_nextkey()
297 ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : ""); in inifile_nextkey()
298 inifile_read(dba, &ln); in inifile_nextkey()
299 inifile_line_free(&dba->curr); in inifile_nextkey()
300 dba->curr = ln; in inifile_nextkey()
306 static int inifile_truncate(inifile *dba, size_t size) in inifile_truncate() argument
310 if ((res=php_stream_truncate_set_size(dba->fp, size)) != 0) { in inifile_truncate()
314 php_stream_seek(dba->fp, size, SEEK_SET); in inifile_truncate()
322 static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start) in inifile_find_group() argument
326 php_stream_flush(dba->fp); in inifile_find_group()
327 php_stream_seek(dba->fp, 0, SEEK_SET); in inifile_find_group()
328 inifile_line_free(&dba->curr); in inifile_find_group()
329 inifile_line_free(&dba->next); in inifile_find_group()
336 while(inifile_read(dba, &ln)) { in inifile_find_group()
341 *pos_grp_start = php_stream_tell(dba->fp); in inifile_find_group()
349 *pos_grp_start = php_stream_tell(dba->fp); in inifile_find_group()
359 static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start) in inifile_next_group() argument
364 *pos_grp_start = php_stream_tell(dba->fp); in inifile_next_group()
366 while(inifile_read(dba, &ln)) { in inifile_next_group()
371 *pos_grp_start = php_stream_tell(dba->fp); in inifile_next_group()
379 static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy) in inifile_copy_to() argument
397 php_stream_seek(dba->fp, pos_start, SEEK_SET); in inifile_copy_to()
398 if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) { in inifile_copy_to()
409 static int inifile_filter(inifile *dba, inifile *from, const key_type *key, bool *found) in inifile_filter() argument
416 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_filter()
426 if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
445 if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
456 static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, … in inifile_delete_replace_append() argument
477 inifile_find_group(dba, key, &pos_grp_start); in inifile_delete_replace_append()
478 inifile_next_group(dba, key, &pos_grp_next); in inifile_delete_replace_append()
482 ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp); in inifile_delete_replace_append()
492 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
493 if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) { in inifile_delete_replace_append()
494 php_stream_seek(dba->fp, pos_grp_next, SEEK_SET); in inifile_delete_replace_append()
495 if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
506 ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start); /* writes error on fail */ in inifile_delete_replace_append()
514 ret = inifile_filter(dba, ini_tmp, key, found); in inifile_delete_replace_append()
523 php_stream_printf(dba->fp, "[%s]\n", key->group); in inifile_delete_replace_append()
525 php_stream_printf(dba->fp, "%s=%s\n", key->name, value->value ? value->value : ""); in inifile_delete_replace_append()
535 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
536 if (SUCCESS != php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
550 php_stream_flush(dba->fp); in inifile_delete_replace_append()
551 php_stream_seek(dba->fp, 0, SEEK_SET); in inifile_delete_replace_append()
558 int inifile_delete(inifile *dba, const key_type *key) in inifile_delete() argument
560 return inifile_delete_replace_append(dba, key, NULL, 0, NULL); in inifile_delete()
565 int inifile_delete_ex(inifile *dba, const key_type *key, bool *found) in inifile_delete_ex() argument
567 return inifile_delete_replace_append(dba, key, NULL, 0, found); in inifile_delete_ex()
572 int inifile_replace(inifile *dba, const key_type *key, const val_type *value) in inifile_replace() argument
574 return inifile_delete_replace_append(dba, key, value, 0, NULL); in inifile_replace()
579 int inifile_replace_ex(inifile *dba, const key_type *key, const val_type *value, bool *found) in inifile_replace_ex() argument
581 return inifile_delete_replace_append(dba, key, value, 0, found); in inifile_replace_ex()
586 int inifile_append(inifile *dba, const key_type *key, const val_type *value) in inifile_append() argument
588 return inifile_delete_replace_append(dba, key, value, 1, NULL); in inifile_append()