kmx.io/kv/kv.h

Branch

Thomas de Grivel 78c072be1 2022-01-03T17:17:35
wip unquote
/*
 * kv - key value text file format
 *
 * Copyright 2022 Thomas de Grivel
*/

#ifndef KV_H
#define KV_H

#include "buffer.h"

/* parse
 * access key path through b->k */

typedef int f_kv (s_buffer *b, const char *v, size_t vsz);

int kv_parse (s_buffer *b, f_kv *f);

/* chars */
int kv_is_quotable_char (int c);
int kv_is_reserved_char (int c);
int kv_is_space (int c);

/* quote */
int kv_contains_reserved_char (const char *str, size_t str_size);
int kv_contains_triple_double_quotes (const char *str, size_t str_size);
int kv_needs_quoting (const char *str, size_t str_size);
int kv_quote (char **str, size_t *str_size);
int kv_quote_delim (char **str, size_t *str_size, const char *delim);
int kv_quote_double_quotes (char **str, size_t *str_size);
int kv_quote_triple_double_quotes (char **str, size_t *str_size);
int kv_unquote (char **str, size_t *str_size);
int kv_unquote_delim (char **str, size_t *str_size, const char *delim);
int kv_unquote_double_quotes (char **str, size_t *str_size);
int kv_unquote_triple_double_quotes (char **str, size_t *str_size);

#endif
Download