MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
toml.c File Reference
#include "toml.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for toml.c:

Go to the source code of this file.

Classes

struct  toml_keyval_t
struct  toml_arritem_t
struct  toml_array_t
struct  toml_table_t
struct  token_t
struct  context_t
struct  tabpath_t

Macros

#define _POSIX_C_SOURCE   200809L
#define ALIGN8(sz)
#define MALLOC(a)
#define FREE(a)
#define malloc(x)
#define free(x)
#define calloc(x, y)
#define strdup(x)
#define strndup(x)
#define STRINGIFY(x)
#define TOSTRING(x)
#define FLINE   __FILE__ ":" TOSTRING(__LINE__)

Typedefs

typedef struct toml_keyval_t toml_keyval_t
typedef struct toml_arritem_t toml_arritem_t
typedef enum tokentype_t tokentype_t
typedef struct token_t token_t
typedef struct context_t context_t
typedef struct tabpath_t tabpath_t

Enumerations

enum  tokentype_t {
  INVALID , DOT , COMMA , EQUAL ,
  LBRACE , RBRACE , NEWLINE , LBRACKET ,
  RBRACKET , STRING
}

Functions

void toml_set_memutil (void *(*xxmalloc)(size_t), void(*xxfree)(void *))
static void * CALLOC (size_t nmemb, size_t sz)
static char * STRDUP (const char *s)
static char * STRNDUP (const char *s, size_t n)
int toml_utf8_to_ucs (const char *orig, int len, int64_t *ret)
int toml_ucs_to_utf8 (int64_t code, char buf[6])
static void xfree (const void *x)
static int next_token (context_t *ctx, int dotisspecial)
static int e_outofmemory (context_t *ctx, const char *fline)
static int e_internal (context_t *ctx, const char *fline)
static int e_syntax (context_t *ctx, int lineno, const char *msg)
static int e_badkey (context_t *ctx, int lineno)
static int e_keyexists (context_t *ctx, int lineno)
static int e_forbid (context_t *ctx, int lineno, const char *msg)
static void * expand (void *p, int sz, int newsz)
static void ** expand_ptrarr (void **p, int n)
static toml_arritem_t * expand_arritem (toml_arritem_t *p, int n)
static char * norm_lit_str (const char *src, int srclen, int multiline, char *errbuf, int errbufsz)
static char * norm_basic_str (const char *src, int srclen, int multiline, char *errbuf, int errbufsz)
static char * normalize_key (context_t *ctx, token_t strtok)
static int check_key (toml_table_t *tab, const char *key, toml_keyval_t **ret_val, toml_array_t **ret_arr, toml_table_t **ret_tab)
static int key_kind (toml_table_t *tab, const char *key)
static toml_keyval_t * create_keyval_in_table (context_t *ctx, toml_table_t *tab, token_t keytok)
static toml_table_t * create_keytable_in_table (context_t *ctx, toml_table_t *tab, token_t keytok)
static toml_array_t * create_keyarray_in_table (context_t *ctx, toml_table_t *tab, token_t keytok, char kind)
static toml_arritem_t * create_value_in_array (context_t *ctx, toml_array_t *parent)
static toml_array_t * create_array_in_array (context_t *ctx, toml_array_t *parent)
static toml_table_t * create_table_in_array (context_t *ctx, toml_array_t *parent)
static int skip_newlines (context_t *ctx, int isdotspecial)
static int parse_keyval (context_t *ctx, toml_table_t *tab)
static int eat_token (context_t *ctx, tokentype_t typ, int isdotspecial, const char *fline)
static int parse_inline_table (context_t *ctx, toml_table_t *tab)
static int valtype (const char *val)
static int parse_array (context_t *ctx, toml_array_t *arr)
static int fill_tabpath (context_t *ctx)
static int walk_tabpath (context_t *ctx)
static int parse_select (context_t *ctx)
toml_table_t * toml_parse (char *conf, char *errbuf, int errbufsz)
toml_table_t * toml_parse_file (FILE *fp, char *errbuf, int errbufsz)
static void xfree_kval (toml_keyval_t *p)
static void xfree_tab (toml_table_t *p)
static void xfree_arr (toml_array_t *p)
void toml_free (toml_table_t *tab)
static void set_token (context_t *ctx, tokentype_t tok, int lineno, char *ptr, int len)
static void set_eof (context_t *ctx, int lineno)
static int scan_digits (const char *p, int n)
static int scan_date (const char *p, int *YY, int *MM, int *DD)
static int scan_time (const char *p, int *hh, int *mm, int *ss)
static int scan_string (context_t *ctx, char *p, int lineno, int dotisspecial)
const char * toml_key_in (const toml_table_t *tab, int keyidx)
int toml_key_exists (const toml_table_t *tab, const char *key)
toml_raw_t toml_raw_in (const toml_table_t *tab, const char *key)
toml_array_t * toml_array_in (const toml_table_t *tab, const char *key)
toml_table_t * toml_table_in (const toml_table_t *tab, const char *key)
toml_raw_t toml_raw_at (const toml_array_t *arr, int idx)
char toml_array_kind (const toml_array_t *arr)
char toml_array_type (const toml_array_t *arr)
int toml_array_nelem (const toml_array_t *arr)
const char * toml_array_key (const toml_array_t *arr)
int toml_table_nkval (const toml_table_t *tab)
int toml_table_narr (const toml_table_t *tab)
int toml_table_ntab (const toml_table_t *tab)
const char * toml_table_key (const toml_table_t *tab)
toml_array_t * toml_array_at (const toml_array_t *arr, int idx)
toml_table_t * toml_table_at (const toml_array_t *arr, int idx)
static int parse_millisec (const char *p, const char **endp)
int toml_rtots (toml_raw_t src_, toml_timestamp_t *ret)
int toml_rtob (toml_raw_t src, int *ret_)
int toml_rtoi (toml_raw_t src, int64_t *ret_)
int toml_rtod_ex (toml_raw_t src, double *ret_, char *buf, int buflen)
int toml_rtod (toml_raw_t src, double *ret_)
int toml_rtos (toml_raw_t src, char **ret)
toml_datum_t toml_string_at (const toml_array_t *arr, int idx)
toml_datum_t toml_bool_at (const toml_array_t *arr, int idx)
toml_datum_t toml_int_at (const toml_array_t *arr, int idx)
toml_datum_t toml_double_at (const toml_array_t *arr, int idx)
toml_datum_t toml_timestamp_at (const toml_array_t *arr, int idx)
toml_datum_t toml_string_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_bool_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_int_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_double_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_timestamp_in (const toml_table_t *arr, const char *key)

Variables

static void *(* ppmalloc )(size_t) = malloc
static void(* ppfree )(void *) = free

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

Definition at line 27 of file toml.c.

◆ ALIGN8

#define ALIGN8 ( sz)
Value:
(((sz) + 7) & ~7)

Definition at line 48 of file toml.c.

Referenced by CALLOC().

◆ calloc

#define calloc ( x,
y )
Value:
error - forbidden - use CALLOC instead
static void * CALLOC(size_t nmemb, size_t sz)
Definition toml.c:56

Definition at line 54 of file toml.c.

Referenced by add_halfc(), clas_ctx_init(), decodefile(), decoderaw(), gen_strfile(), has_complete(), has_new(), init_rt17(), mrtk_context_new(), mrtk_ctx_create(), openserial(), readpreceph(), rtcm_lclblk(), rtksvrstart(), strconvnew(), udbiass(), update_clas(), update_stas(), and zeros().

◆ FLINE

◆ FREE

#define FREE ( a)
Value:
static void(* ppfree)(void *)
Definition toml.c:39

Definition at line 50 of file toml.c.

Referenced by expand(), expand_ptrarr(), and xfree().

◆ free

#define free ( x)
Value:
error - forbidden - use FREE instead
#define FREE(a)
Definition toml.c:50

Definition at line 53 of file toml.c.

Referenced by add_eph(), add_eph(), add_geph(), add_geph(), add_seph(), add_seph(), addbia(), addisbdata(), addobsdata(), addobsdata(), addpcv(), addpeph(), addsol(), addsolstat(), addtec(), calc_3points_weight(), clas_ctx_free(), clas_get_grid_index(), clas_osr_zdres(), clas_ssr2osr(), clas_stec_grid_data(), clas_trop_grid_data(), closefile(), closeftp(), closemembuf(), closentrip(), closentripc(), closeserial(), closeses(), closetcpcli(), closetcpsvr(), closeudpcli(), closeudpsvr(), combpclk(), combtec(), convrnx_s(), ddres(), ddres(), ddres(), decodefile(), decoderaw(), estpos(), estvel(), execses(), execses_b(), execses_r(), filter(), filter2(), filter2(), filter2_(), filter2_(), filter_(), free_raw(), free_rnxctr(), free_rt17(), free_rtcm(), free_strfile(), freebia(), freenav(), freeobs(), freeobsnav(), freepreceph(), freesolbuf(), freesolstatbuf(), gen_strfile(), genudp(), has_complete(), has_free(), holdamb(), holdamb(), holdamb(), l6_file_service(), lambda(), lambda_reduction(), lambda_search(), LD(), loadopts_toml(), lsq(), ludcmp(), matinv(), mrtk_context_free(), mrtk_ctx_destroy(), openfile(), openmembuf(), openntrip(), openntripc(), openserial(), opentcpcli(), opentcpsvr(), pntpos(), postpos(), ppp_amb_ILS(), ppp_rtk_pos(), pppos(), raim_fde(), readbnxt(), readdcb(), readerp(), readfcb(), readisb(), readmsgs(), readpreceph(), readrnxc(), readrnxclk(), readrnxobs(), readrnxt(), readsap(), readsp3(), readtec(), relpos(), relposvrs(), resamb_LAMBDA(), resamb_LAMBDA(), resamb_LAMBDA(), residual_test(), residual_test(), rtkfree(), rtksvrfree(), rtksvrstart(), rtksvrthread(), sbsreadmsgt(), sddop(), sddop(), search(), set_init_pb(), set_init_pb(), smoother(), solve(), sort_solbuf(), sort_solstat(), strconvfree(), strconvnew(), strsvrstart(), strsvrthread(), toml_val_to_str(), udbias(), udbias_ppp(), udbias_ppp(), udbiass(), udpos(), udpos(), udpos_ppp(), udpos_ppp(), uniqeph(), uniqgeph(), uniqseph(), update_clas(), update_states(), write_trace_sd_amb(), zddop(), and zddop().

◆ MALLOC

#define MALLOC ( a)
Value:
static void *(* ppmalloc)(size_t)
Definition toml.c:38

Definition at line 49 of file toml.c.

Referenced by CALLOC(), expand(), expand_ptrarr(), STRDUP(), STRNDUP(), toml_timestamp_at(), and toml_timestamp_in().

◆ malloc

◆ strdup

#define strdup ( x)
Value:
error - forbidden - use STRDUP instead
static char * STRDUP(const char *s)
Definition toml.c:69

Definition at line 67 of file toml.c.

◆ STRINGIFY

#define STRINGIFY ( x)
Value:
#x

Definition at line 371 of file toml.c.

◆ strndup

#define strndup ( x)
Value:
error - forbiden - use STRNDUP instead
static char * STRNDUP(const char *s, size_t n)
Definition toml.c:83

Definition at line 81 of file toml.c.

◆ TOSTRING

#define TOSTRING ( x)
Value:
#define STRINGIFY(x)
Definition toml.c:371

Definition at line 372 of file toml.c.

Typedef Documentation

◆ context_t

typedef struct context_t context_t

Definition at line 353 of file toml.c.

◆ tabpath_t

typedef struct tabpath_t tabpath_t

Definition at line 1191 of file toml.c.

◆ token_t

typedef struct token_t token_t

Definition at line 344 of file toml.c.

◆ tokentype_t

typedef enum tokentype_t tokentype_t

Definition at line 342 of file toml.c.

◆ toml_arritem_t

typedef struct toml_arritem_t toml_arritem_t

Definition at line 288 of file toml.c.

◆ toml_keyval_t

typedef struct toml_keyval_t toml_keyval_t

Definition at line 282 of file toml.c.

Enumeration Type Documentation

◆ tokentype_t

Enumerator
INVALID 
DOT 
COMMA 
EQUAL 
LBRACE 
RBRACE 
NEWLINE 
LBRACKET 
RBRACKET 
STRING 

Definition at line 330 of file toml.c.

Function Documentation

◆ CALLOC()

void * CALLOC ( size_t nmemb,
size_t sz )
static

Definition at line 56 of file toml.c.

References ALIGN8, and MALLOC.

Referenced by create_array_in_array(), create_keyarray_in_table(), create_keytable_in_table(), create_keyval_in_table(), create_table_in_array(), toml_parse(), and walk_tabpath().

Here is the caller graph for this function:

◆ check_key()

int check_key ( toml_table_t * tab,
const char * key,
toml_keyval_t ** ret_val,
toml_array_t ** ret_arr,
toml_table_t ** ret_tab )
static

Definition at line 692 of file toml.c.

References toml_table_t::arr, toml_array_t::key, toml_keyval_t::key, toml_table_t::key, toml_table_t::kval, toml_table_t::narr, toml_table_t::nkval, toml_table_t::ntab, and toml_table_t::tab.

Referenced by create_keytable_in_table(), key_kind(), and walk_tabpath().

Here is the caller graph for this function:

◆ create_array_in_array()

toml_array_t * create_array_in_array ( context_t * ctx,
toml_array_t * parent )
static

Definition at line 879 of file toml.c.

References toml_arritem_t::arr, CALLOC(), e_outofmemory(), expand_arritem(), FLINE, toml_array_t::item, and toml_array_t::nitem.

Referenced by parse_array().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_keyarray_in_table()

toml_array_t * create_keyarray_in_table ( context_t * ctx,
toml_table_t * tab,
token_t keytok,
char kind )
static

Definition at line 825 of file toml.c.

References toml_table_t::arr, CALLOC(), e_keyexists(), e_outofmemory(), expand_ptrarr(), FLINE, toml_array_t::key, key_kind(), toml_array_t::kind, token_t::lineno, toml_table_t::narr, normalize_key(), and xfree().

Referenced by parse_keyval(), and parse_select().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_keytable_in_table()

toml_table_t * create_keytable_in_table ( context_t * ctx,
toml_table_t * tab,
token_t keytok )
static

Definition at line 777 of file toml.c.

References CALLOC(), check_key(), e_keyexists(), e_outofmemory(), expand_ptrarr(), FLINE, toml_table_t::implicit, toml_table_t::key, token_t::lineno, normalize_key(), toml_table_t::ntab, toml_table_t::tab, and xfree().

Referenced by parse_keyval(), and parse_select().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_keyval_in_table()

toml_keyval_t * create_keyval_in_table ( context_t * ctx,
toml_table_t * tab,
token_t keytok )
static

Definition at line 736 of file toml.c.

References CALLOC(), e_keyexists(), e_outofmemory(), expand_ptrarr(), FLINE, toml_keyval_t::key, key_kind(), toml_table_t::kval, token_t::lineno, toml_table_t::nkval, normalize_key(), and xfree().

Referenced by parse_keyval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_table_in_array()

toml_table_t * create_table_in_array ( context_t * ctx,
toml_array_t * parent )
static

Definition at line 900 of file toml.c.

References CALLOC(), e_outofmemory(), expand_arritem(), FLINE, toml_array_t::item, toml_array_t::nitem, and toml_arritem_t::tab.

Referenced by parse_array(), and parse_select().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_value_in_array()

toml_arritem_t * create_value_in_array ( context_t * ctx,
toml_array_t * parent )
static

Definition at line 864 of file toml.c.

References e_outofmemory(), expand_arritem(), FLINE, toml_array_t::item, and toml_array_t::nitem.

Referenced by parse_array().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ e_badkey()

int e_badkey ( context_t * ctx,
int lineno )
static

Definition at line 395 of file toml.c.

References context_t::errbuf, and context_t::errbufsz.

Referenced by normalize_key().

Here is the caller graph for this function:

◆ e_forbid()

int e_forbid ( context_t * ctx,
int lineno,
const char * msg )
static

Definition at line 405 of file toml.c.

References context_t::errbuf, and context_t::errbufsz.

Referenced by parse_keyval().

Here is the caller graph for this function:

◆ e_internal()

int e_internal ( context_t * ctx,
const char * fline )
static

Definition at line 385 of file toml.c.

References context_t::errbuf, and context_t::errbufsz.

Referenced by eat_token(), and walk_tabpath().

Here is the caller graph for this function:

◆ e_keyexists()

int e_keyexists ( context_t * ctx,
int lineno )
static

Definition at line 400 of file toml.c.

References context_t::errbuf, and context_t::errbufsz.

Referenced by create_keyarray_in_table(), create_keytable_in_table(), create_keyval_in_table(), and walk_tabpath().

Here is the caller graph for this function:

◆ e_outofmemory()

int e_outofmemory ( context_t * ctx,
const char * fline )
static

Definition at line 380 of file toml.c.

References context_t::errbuf, and context_t::errbufsz.

Referenced by create_array_in_array(), create_keyarray_in_table(), create_keytable_in_table(), create_keyval_in_table(), create_table_in_array(), create_value_in_array(), normalize_key(), parse_array(), parse_keyval(), parse_select(), toml_parse(), and walk_tabpath().

Here is the caller graph for this function:

◆ e_syntax()

int e_syntax ( context_t * ctx,
int lineno,
const char * msg )
static

Definition at line 390 of file toml.c.

References context_t::errbuf, and context_t::errbufsz.

Referenced by fill_tabpath(), normalize_key(), parse_array(), parse_inline_table(), parse_keyval(), parse_select(), scan_string(), and toml_parse().

Here is the caller graph for this function:

◆ eat_token()

int eat_token ( context_t * ctx,
tokentype_t typ,
int isdotspecial,
const char * fline )
inlinestatic

Definition at line 931 of file toml.c.

References e_internal(), next_token(), context_t::tok, and token_t::tok.

Referenced by parse_array(), parse_inline_table(), parse_keyval(), parse_select(), and toml_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand()

void * expand ( void * p,
int sz,
int newsz )
static

Definition at line 410 of file toml.c.

References FREE, and MALLOC.

Referenced by expand_arritem(), norm_basic_str(), norm_lit_str(), and toml_parse_file().

Here is the caller graph for this function:

◆ expand_arritem()

toml_arritem_t * expand_arritem ( toml_arritem_t * p,
int n )
static

Definition at line 435 of file toml.c.

References expand().

Referenced by create_array_in_array(), create_table_in_array(), and create_value_in_array().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand_ptrarr()

void ** expand_ptrarr ( void ** p,
int n )
static

Definition at line 422 of file toml.c.

References FREE, and MALLOC.

Referenced by create_keyarray_in_table(), create_keytable_in_table(), create_keyval_in_table(), and walk_tabpath().

Here is the caller graph for this function:

◆ fill_tabpath()

int fill_tabpath ( context_t * ctx)
static

Definition at line 1201 of file toml.c.

References DOT, e_syntax(), context_t::key, token_t::lineno, next_token(), normalize_key(), RBRACKET, STRING, context_t::tok, token_t::tok, context_t::top, context_t::tpath, and xfree().

Referenced by parse_select().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ key_kind()

int key_kind ( toml_table_t * tab,
const char * key )
static

Definition at line 730 of file toml.c.

References check_key().

Referenced by create_keyarray_in_table(), and create_keyval_in_table().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_token()

int next_token ( context_t * ctx,
int dotisspecial )
static

Definition at line 1803 of file toml.c.

References COMMA, DOT, EQUAL, LBRACE, LBRACKET, token_t::len, token_t::lineno, NEWLINE, token_t::ptr, RBRACE, RBRACKET, scan_string(), set_eof(), set_token(), context_t::stop, and context_t::tok.

Referenced by eat_token(), fill_tabpath(), parse_keyval(), skip_newlines(), and toml_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ norm_basic_str()

char * norm_basic_str ( const char * src,
int srclen,
int multiline,
char * errbuf,
int errbufsz )
static

Definition at line 493 of file toml.c.

References expand(), toml_ucs_to_utf8(), and xfree().

Referenced by normalize_key(), and toml_rtos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ norm_lit_str()

char * norm_lit_str ( const char * src,
int srclen,
int multiline,
char * errbuf,
int errbufsz )
static

Definition at line 444 of file toml.c.

References expand(), and xfree().

Referenced by toml_rtos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize_key()

char * normalize_key ( context_t * ctx,
token_t strtok )
static

Definition at line 626 of file toml.c.

References e_badkey(), e_outofmemory(), e_syntax(), FLINE, token_t::len, token_t::lineno, norm_basic_str(), token_t::ptr, STRNDUP(), and xfree().

Referenced by create_keyarray_in_table(), create_keytable_in_table(), create_keyval_in_table(), fill_tabpath(), parse_keyval(), and parse_select().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_array()

int parse_array ( context_t * ctx,
toml_array_t * arr )
static

Definition at line 1006 of file toml.c.

References COMMA, create_array_in_array(), create_table_in_array(), create_value_in_array(), e_outofmemory(), e_syntax(), eat_token(), FLINE, toml_array_t::kind, LBRACE, LBRACKET, token_t::len, token_t::lineno, toml_array_t::nitem, parse_array(), parse_inline_table(), token_t::ptr, RBRACKET, skip_newlines(), STRING, STRNDUP(), context_t::tok, token_t::tok, toml_array_t::type, toml_arritem_t::val, toml_arritem_t::valtype, and valtype().

Referenced by parse_array(), and parse_keyval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_inline_table()

int parse_inline_table ( context_t * ctx,
toml_table_t * tab )
static

Definition at line 945 of file toml.c.

References COMMA, e_syntax(), eat_token(), FLINE, LBRACE, token_t::lineno, NEWLINE, parse_keyval(), RBRACE, toml_table_t::readonly, STRING, context_t::tok, and token_t::tok.

Referenced by parse_array(), and parse_keyval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_keyval()

int parse_keyval ( context_t * ctx,
toml_table_t * tab )
static

Definition at line 1106 of file toml.c.

References create_keyarray_in_table(), create_keytable_in_table(), create_keyval_in_table(), DOT, e_forbid(), e_outofmemory(), e_syntax(), eat_token(), EQUAL, FLINE, LBRACE, LBRACKET, token_t::len, token_t::lineno, next_token(), normalize_key(), parse_array(), parse_inline_table(), parse_keyval(), token_t::ptr, toml_table_t::readonly, STRING, STRNDUP(), context_t::tok, token_t::tok, toml_table_in(), toml_keyval_t::val, and xfree().

Referenced by parse_inline_table(), parse_keyval(), and toml_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_millisec()

int parse_millisec ( const char * p,
const char ** endp )
static

Definition at line 2384 of file toml.c.

Referenced by toml_rtots().

Here is the caller graph for this function:

◆ parse_select()

int parse_select ( context_t * ctx)
static

Definition at line 1312 of file toml.c.

References create_keyarray_in_table(), create_keytable_in_table(), create_table_in_array(), context_t::curtab, e_outofmemory(), e_syntax(), eat_token(), fill_tabpath(), FLINE, context_t::key, toml_table_t::key, toml_array_t::kind, LBRACKET, token_t::lineno, NEWLINE, normalize_key(), token_t::ptr, RBRACKET, context_t::stop, STRDUP(), context_t::tok, token_t::tok, toml_array_in(), context_t::top, context_t::tpath, walk_tabpath(), and xfree().

Referenced by toml_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan_date()

int scan_date ( const char * p,
int * YY,
int * MM,
int * DD )
static

Definition at line 1610 of file toml.c.

References scan_digits().

Referenced by scan_string(), and toml_rtots().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan_digits()

int scan_digits ( const char * p,
int n )
static

Definition at line 1602 of file toml.c.

Referenced by scan_date(), and scan_time().

Here is the caller graph for this function:

◆ scan_string()

int scan_string ( context_t * ctx,
char * p,
int lineno,
int dotisspecial )
static

Definition at line 1638 of file toml.c.

References e_syntax(), scan_date(), scan_time(), set_token(), and STRING.

Referenced by next_token().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan_time()

int scan_time ( const char * p,
int * hh,
int * mm,
int * ss )
static

Definition at line 1624 of file toml.c.

References scan_digits().

Referenced by scan_string(), and toml_rtots().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_eof()

void set_eof ( context_t * ctx,
int lineno )
static

Definition at line 1596 of file toml.c.

References token_t::eof, NEWLINE, set_token(), context_t::stop, and context_t::tok.

Referenced by next_token().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_token()

void set_token ( context_t * ctx,
tokentype_t tok,
int lineno,
char * ptr,
int len )
static

Definition at line 1585 of file toml.c.

References token_t::eof, token_t::len, token_t::lineno, token_t::ptr, context_t::tok, and token_t::tok.

Referenced by next_token(), scan_string(), and set_eof().

Here is the caller graph for this function:

◆ skip_newlines()

int skip_newlines ( context_t * ctx,
int isdotspecial )
static

Definition at line 919 of file toml.c.

References token_t::eof, NEWLINE, next_token(), context_t::tok, and token_t::tok.

Referenced by parse_array().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ STRDUP()

char * STRDUP ( const char * s)
static

Definition at line 69 of file toml.c.

References MALLOC.

Referenced by parse_select(), and walk_tabpath().

Here is the caller graph for this function:

◆ STRNDUP()

char * STRNDUP ( const char * s,
size_t n )
static

Definition at line 83 of file toml.c.

References MALLOC.

Referenced by normalize_key(), parse_array(), and parse_keyval().

Here is the caller graph for this function:

◆ toml_array_at()

toml_array_t * toml_array_at ( const toml_array_t * arr,
int idx )

Definition at line 1956 of file toml.c.

References toml_arritem_t::arr, toml_array_t::item, and nitem().

Here is the call graph for this function:

◆ toml_array_in()

toml_array_t * toml_array_in ( const toml_table_t * tab,
const char * key )

Definition at line 1906 of file toml.c.

References toml_table_t::arr, toml_array_t::key, and toml_table_t::narr.

Referenced by loadopts_toml(), parse_select(), and toml_val_to_str().

Here is the caller graph for this function:

◆ toml_array_key()

const char * toml_array_key ( const toml_array_t * arr)

Definition at line 1942 of file toml.c.

References toml_array_t::key.

◆ toml_array_kind()

char toml_array_kind ( const toml_array_t * arr)

Definition at line 1928 of file toml.c.

References toml_array_t::kind.

◆ toml_array_nelem()

int toml_array_nelem ( const toml_array_t * arr)

Definition at line 1940 of file toml.c.

References toml_array_t::nitem.

Referenced by loadopts_toml(), and toml_val_to_str().

Here is the caller graph for this function:

◆ toml_array_type()

char toml_array_type ( const toml_array_t * arr)

Definition at line 1930 of file toml.c.

References toml_array_t::kind, toml_array_t::nitem, and toml_array_t::type.

◆ toml_bool_at()

toml_datum_t toml_bool_at ( const toml_array_t * arr,
int idx )

Definition at line 2272 of file toml.c.

References toml_datum_t::b, toml_datum_t::ok, toml_raw_at(), toml_rtob(), and toml_datum_t::u.

Here is the call graph for this function:

◆ toml_bool_in()

toml_datum_t toml_bool_in ( const toml_table_t * arr,
const char * key )

Definition at line 2333 of file toml.c.

References toml_datum_t::b, toml_datum_t::ok, toml_raw_in(), toml_rtob(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_double_at()

toml_datum_t toml_double_at ( const toml_array_t * arr,
int idx )

Definition at line 2286 of file toml.c.

References toml_datum_t::d, toml_datum_t::ok, toml_raw_at(), toml_rtod(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_double_in()

toml_datum_t toml_double_in ( const toml_table_t * arr,
const char * key )

Definition at line 2347 of file toml.c.

References toml_datum_t::d, toml_datum_t::ok, toml_raw_in(), toml_rtod(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_free()

void toml_free ( toml_table_t * tab)

Definition at line 1583 of file toml.c.

References xfree_tab().

Referenced by loadopts_toml(), and toml_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_int_at()

toml_datum_t toml_int_at ( const toml_array_t * arr,
int idx )

Definition at line 2279 of file toml.c.

References toml_datum_t::i, toml_datum_t::ok, toml_raw_at(), toml_rtoi(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_int_in()

toml_datum_t toml_int_in ( const toml_table_t * arr,
const char * key )

Definition at line 2340 of file toml.c.

References toml_datum_t::i, toml_datum_t::ok, toml_raw_in(), toml_rtoi(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_key_exists()

int toml_key_exists ( const toml_table_t * tab,
const char * key )

Definition at line 1880 of file toml.c.

References toml_table_t::arr, toml_array_t::key, toml_keyval_t::key, toml_table_t::key, toml_table_t::kval, toml_table_t::narr, toml_table_t::nkval, toml_table_t::ntab, and toml_table_t::tab.

Referenced by loadopts_toml().

Here is the caller graph for this function:

◆ toml_key_in()

const char * toml_key_in ( const toml_table_t * tab,
int keyidx )

Definition at line 1865 of file toml.c.

References toml_table_t::arr, toml_array_t::key, toml_keyval_t::key, toml_table_t::key, toml_table_t::kval, toml_table_t::narr, toml_table_t::nkval, and toml_table_t::tab.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_parse()

toml_table_t * toml_parse ( char * conf,
char * errbuf,
int errbufsz )

Definition at line 1402 of file toml.c.

References CALLOC(), context_t::curtab, e_outofmemory(), e_syntax(), eat_token(), token_t::eof, context_t::errbuf, context_t::errbufsz, FLINE, context_t::key, LBRACKET, token_t::len, token_t::lineno, NEWLINE, next_token(), parse_keyval(), parse_select(), token_t::ptr, context_t::root, context_t::start, context_t::stop, STRING, context_t::tok, token_t::tok, toml_free(), context_t::top, context_t::tpath, and xfree().

Referenced by toml_parse_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_parse_file()

toml_table_t * toml_parse_file ( FILE * fp,
char * errbuf,
int errbufsz )

Definition at line 1480 of file toml.c.

References expand(), toml_parse(), and xfree().

Referenced by loadopts_toml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_raw_at()

toml_raw_t toml_raw_at ( const toml_array_t * arr,
int idx )

Definition at line 1924 of file toml.c.

References toml_array_t::item, nitem(), and toml_arritem_t::val.

Referenced by toml_bool_at(), toml_double_at(), toml_int_at(), toml_string_at(), and toml_timestamp_at().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_raw_in()

toml_raw_t toml_raw_in ( const toml_table_t * tab,
const char * key )

Definition at line 1897 of file toml.c.

References toml_keyval_t::key, toml_table_t::kval, toml_table_t::nkval, and toml_keyval_t::val.

Referenced by toml_bool_in(), toml_double_in(), toml_int_in(), toml_string_in(), and toml_timestamp_in().

Here is the caller graph for this function:

◆ toml_rtob()

int toml_rtob ( toml_raw_t src,
int * ret_ )

Definition at line 2055 of file toml.c.

Referenced by toml_bool_at(), toml_bool_in(), and valtype().

Here is the caller graph for this function:

◆ toml_rtod()

int toml_rtod ( toml_raw_t src,
double * ret_ )

Definition at line 2205 of file toml.c.

References toml_rtod_ex().

Referenced by toml_double_at(), toml_double_in(), and valtype().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_rtod_ex()

int toml_rtod_ex ( toml_raw_t src,
double * ret_,
char * buf,
int buflen )

Definition at line 2146 of file toml.c.

References dot().

Referenced by toml_rtod().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_rtoi()

int toml_rtoi ( toml_raw_t src,
int64_t * ret_ )

Definition at line 2073 of file toml.c.

Referenced by toml_int_at(), toml_int_in(), and valtype().

Here is the caller graph for this function:

◆ toml_rtos()

int toml_rtos ( toml_raw_t src,
char ** ret )

Definition at line 2210 of file toml.c.

References norm_basic_str(), and norm_lit_str().

Referenced by toml_string_at(), and toml_string_in().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_rtots()

int toml_rtots ( toml_raw_t src_,
toml_timestamp_t * ret )

Definition at line 1966 of file toml.c.

References toml_timestamp_t::__buffer, toml_timestamp_t::day, toml_timestamp_t::hour, toml_timestamp_t::millisec, toml_timestamp_t::minute, toml_timestamp_t::month, parse_millisec(), scan_date(), scan_time(), toml_timestamp_t::second, toml_timestamp_t::year, and toml_timestamp_t::z.

Referenced by toml_timestamp_at(), toml_timestamp_in(), and valtype().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_set_memutil()

void toml_set_memutil ( void *(* xxmalloc )(size_t),
void(* xxfree )(void *) )

Definition at line 41 of file toml.c.

References ppfree, and ppmalloc.

◆ toml_string_at()

toml_datum_t toml_string_at ( const toml_array_t * arr,
int idx )

Definition at line 2265 of file toml.c.

References toml_datum_t::ok, toml_datum_t::s, toml_raw_at(), toml_rtos(), and toml_datum_t::u.

Referenced by loadopts_toml(), and toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_string_in()

toml_datum_t toml_string_in ( const toml_table_t * arr,
const char * key )

Definition at line 2323 of file toml.c.

References toml_datum_t::ok, toml_datum_t::s, toml_raw_in(), toml_rtos(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_table_at()

toml_table_t * toml_table_at ( const toml_array_t * arr,
int idx )

Definition at line 1960 of file toml.c.

References toml_array_t::item, nitem(), and toml_arritem_t::tab.

Here is the call graph for this function:

◆ toml_table_in()

toml_table_t * toml_table_in ( const toml_table_t * tab,
const char * key )

Definition at line 1915 of file toml.c.

References toml_table_t::key, toml_table_t::ntab, and toml_table_t::tab.

Referenced by check_unknown_keys(), navigate_table(), and parse_keyval().

Here is the caller graph for this function:

◆ toml_table_key()

const char * toml_table_key ( const toml_table_t * tab)

Definition at line 1952 of file toml.c.

References toml_table_t::key.

◆ toml_table_narr()

int toml_table_narr ( const toml_table_t * tab)

Definition at line 1948 of file toml.c.

References toml_table_t::narr.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_table_nkval()

int toml_table_nkval ( const toml_table_t * tab)

Definition at line 1946 of file toml.c.

References toml_table_t::nkval.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_table_ntab()

int toml_table_ntab ( const toml_table_t * tab)

Definition at line 1950 of file toml.c.

References toml_table_t::ntab.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_timestamp_at()

toml_datum_t toml_timestamp_at ( const toml_array_t * arr,
int idx )

Definition at line 2293 of file toml.c.

References toml_timestamp_t::__buffer, toml_timestamp_t::day, toml_timestamp_t::hour, MALLOC, toml_timestamp_t::millisec, toml_timestamp_t::minute, toml_timestamp_t::month, toml_datum_t::ok, toml_timestamp_t::second, toml_raw_at(), toml_rtots(), toml_datum_t::ts, toml_datum_t::u, toml_timestamp_t::year, and toml_timestamp_t::z.

Here is the call graph for this function:

◆ toml_timestamp_in()

toml_datum_t toml_timestamp_in ( const toml_table_t * arr,
const char * key )

Definition at line 2354 of file toml.c.

References toml_timestamp_t::__buffer, toml_timestamp_t::day, toml_timestamp_t::hour, MALLOC, toml_timestamp_t::millisec, toml_timestamp_t::minute, toml_timestamp_t::month, toml_datum_t::ok, toml_timestamp_t::second, toml_raw_in(), toml_rtots(), toml_datum_t::ts, toml_datum_t::u, toml_timestamp_t::year, and toml_timestamp_t::z.

Here is the call graph for this function:

◆ toml_ucs_to_utf8()

int toml_ucs_to_utf8 ( int64_t code,
char buf[6] )

Convert a UCS char to utf8 code, and return it in buf. Return #bytes used in buf to encode the char, or -1 on error.

Definition at line 198 of file toml.c.

Referenced by norm_basic_str().

Here is the caller graph for this function:

◆ toml_utf8_to_ucs()

int toml_utf8_to_ucs ( const char * orig,
int len,
int64_t * ret )

Convert a char in utf8 into UCS, and store it in *ret. Return #bytes consumed or -1 on failure.

Definition at line 97 of file toml.c.

◆ valtype()

int valtype ( const char * val)
static

Definition at line 985 of file toml.c.

References toml_timestamp_t::hour, toml_rtob(), toml_rtod(), toml_rtoi(), toml_rtots(), and toml_timestamp_t::year.

Referenced by parse_array().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ walk_tabpath()

int walk_tabpath ( context_t * ctx)
static

Definition at line 1250 of file toml.c.

References CALLOC(), check_key(), context_t::curtab, e_internal(), e_keyexists(), e_outofmemory(), expand_ptrarr(), FLINE, toml_table_t::implicit, toml_array_t::item, context_t::key, toml_array_t::kind, token_t::lineno, toml_array_t::nitem, toml_table_t::ntab, context_t::root, STRDUP(), toml_arritem_t::tab, toml_table_t::tab, context_t::tok, context_t::top, and context_t::tpath.

Referenced by parse_select().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xfree()

void xfree ( const void * x)
inlinestatic

Definition at line 325 of file toml.c.

References FREE.

Referenced by create_keyarray_in_table(), create_keytable_in_table(), create_keyval_in_table(), fill_tabpath(), norm_basic_str(), norm_lit_str(), normalize_key(), parse_keyval(), parse_select(), toml_parse(), toml_parse_file(), xfree_arr(), xfree_kval(), and xfree_tab().

Here is the caller graph for this function:

◆ xfree_arr()

void xfree_arr ( toml_array_t * p)
static

Definition at line 1541 of file toml.c.

References toml_arritem_t::arr, toml_array_t::item, toml_array_t::key, toml_array_t::nitem, toml_arritem_t::tab, toml_arritem_t::val, xfree(), xfree_arr(), and xfree_tab().

Referenced by xfree_arr(), and xfree_tab().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xfree_kval()

void xfree_kval ( toml_keyval_t * p)
static

Definition at line 1531 of file toml.c.

References toml_keyval_t::key, toml_keyval_t::val, and xfree().

Referenced by xfree_tab().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xfree_tab()

void xfree_tab ( toml_table_t * p)
static

Definition at line 1560 of file toml.c.

References toml_table_t::arr, toml_table_t::key, toml_table_t::kval, toml_table_t::narr, toml_table_t::nkval, toml_table_t::ntab, toml_table_t::tab, xfree(), xfree_arr(), xfree_kval(), and xfree_tab().

Referenced by toml_free(), xfree_arr(), and xfree_tab().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ppfree

void(* ppfree) (void *) ( void * ) = free
static

Definition at line 39 of file toml.c.

Referenced by toml_set_memutil().

◆ ppmalloc

void *(* ppmalloc) (size_t) ( size_t ) = malloc
static

Definition at line 38 of file toml.c.

Referenced by toml_set_memutil().