Lines Matching refs:key
51 void inifile_key_free(key_type *key) in inifile_key_free() argument
53 if (key->group) { in inifile_key_free()
54 efree(key->group); in inifile_key_free()
56 if (key->name) { in inifile_key_free()
57 efree(key->name); in inifile_key_free()
59 memset(key, 0, sizeof(key_type)); in inifile_key_free()
76 inifile_key_free(&ln->key); in inifile_line_free()
116 key_type key; in inifile_key_split() local
120 key.group = estrndup(group_name+1, name - (group_name + 1)); in inifile_key_split()
121 key.name = estrdup(name+1); in inifile_key_split()
123 key.group = estrdup(""); in inifile_key_split()
124 key.name = estrdup(group_name); in inifile_key_split()
126 return key; in inifile_key_split()
131 char * inifile_key_string(const key_type *key) in inifile_key_string() argument
133 if (key->group && *key->group) { in inifile_key_string()
135 spprintf(&result, 0, "[%s]%s", key->group, key->name ? key->name : ""); in inifile_key_string()
137 } else if (key->name) { in inifile_key_string()
138 return estrdup(key->name); in inifile_key_string()
182 inifile_key_free(&ln->key); in inifile_read()
183 ln->key.group = etrim(fline+1); in inifile_read()
184 ln->key.name = estrdup(""); in inifile_read()
197 if (!ln->key.group) { in inifile_read()
198 ln->key.group = estrdup(""); in inifile_read()
200 if (ln->key.name) { in inifile_read()
201 efree(ln->key.name); in inifile_read()
203 ln->key.name = etrim(fline); in inifile_read()
246 val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) { in inifile_fetch() argument
251 …if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, ke… in inifile_fetch()
264 if (!(res=inifile_key_cmp(&ln.key, key TSRMLS_CC))) { in inifile_fetch()
303 ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : ""); in inifile_nextkey()
307 return ln.key.group || ln.key.name; in inifile_nextkey()
329 static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC) in inifile_find_group() argument
338 if (key->group && strlen(key->group)) { in inifile_find_group()
344 if ((res=inifile_key_cmp(&ln.key, key TSRMLS_CC)) < 2) { 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
372 ln.key.group = estrdup(key->group); in inifile_next_group()
374 if (inifile_key_cmp(&ln.key, key TSRMLS_CC) == 2) { in inifile_next_group()
417 static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRMLS_DC) in inifile_filter()
426 switch(inifile_key_cmp(&ln.key, key TSRMLS_CC)) { 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
480 assert(!append || (key->name && value)); /* missuse */ in inifile_delete_replace_append()
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()
511 if (!value || (key->name && strlen(key->name))) { in inifile_delete_replace_append()
517 if (key->name && strlen(key->name)) { in inifile_delete_replace_append()
520 ret = inifile_filter(dba, ini_tmp, key TSRMLS_CC); in inifile_delete_replace_append()
528 if (pos_grp_start == pos_grp_next && key->group && strlen(key->group)) { 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()
565 int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC) in inifile_delete()
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()