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) { 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) { 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)) { 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) { in inifile_firstkey() argument
290 inifile_line_free(&dba->curr); in inifile_firstkey()
291 dba->curr.pos = 0; in inifile_firstkey()
292 return inifile_nextkey(dba); in inifile_firstkey()
298 int inifile_nextkey(inifile *dba) { in inifile_nextkey() argument
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); 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) 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) 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)) { 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) in inifile_next_group() argument
371 *pos_grp_start = php_stream_tell(dba->fp); in inifile_next_group()
373 while(inifile_read(dba, &ln)) { 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) 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, zend_bool *found) in inifile_filter() argument
424 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_filter()
434 if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
453 if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { in inifile_filter()
465 static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, … in inifile_delete_replace_append() argument
486 inifile_find_group(dba, key, &pos_grp_start); in inifile_delete_replace_append()
487 inifile_next_group(dba, key, &pos_grp_next); in inifile_delete_replace_append()
491 ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp); in inifile_delete_replace_append()
501 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
502 if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) { in inifile_delete_replace_append()
503 php_stream_seek(dba->fp, pos_grp_next, SEEK_SET); in inifile_delete_replace_append()
504 if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
515 ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start); /* writes error on fail */ in inifile_delete_replace_append()
523 ret = inifile_filter(dba, ini_tmp, key, found); in inifile_delete_replace_append()
532 php_stream_printf(dba->fp, "[%s]\n", key->group); in inifile_delete_replace_append()
534 php_stream_printf(dba->fp, "%s=%s\n", key->name, value->value ? value->value : ""); in inifile_delete_replace_append()
544 php_stream_seek(dba->fp, 0, SEEK_END); in inifile_delete_replace_append()
545 if (SUCCESS != php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) { in inifile_delete_replace_append()
559 php_stream_flush(dba->fp); in inifile_delete_replace_append()
560 php_stream_seek(dba->fp, 0, SEEK_SET); in inifile_delete_replace_append()
568 int inifile_delete(inifile *dba, const key_type *key) in inifile_delete() argument
570 return inifile_delete_replace_append(dba, key, NULL, 0, NULL); in inifile_delete()
576 int inifile_delete_ex(inifile *dba, const key_type *key, zend_bool *found) in inifile_delete_ex() argument
578 return inifile_delete_replace_append(dba, key, NULL, 0, found); in inifile_delete_ex()
584 int inifile_replace(inifile *dba, const key_type *key, const val_type *value) in inifile_replace() argument
586 return inifile_delete_replace_append(dba, key, value, 0, NULL); in inifile_replace()
592 int inifile_replace_ex(inifile *dba, const key_type *key, const val_type *value, zend_bool *found) in inifile_replace_ex() argument
594 return inifile_delete_replace_append(dba, key, value, 0, found); in inifile_replace_ex()
600 int inifile_append(inifile *dba, const key_type *key, const val_type *value) in inifile_append() argument
602 return inifile_delete_replace_append(dba, key, value, 1, NULL); in inifile_append()