rtl433  UNKNOWN
RTL-433 utility
confparse.c File Reference

Light-weight (i.e. More...

Functions

static off_t fsize (const char *path)
 
int hasconf (char const *path)
 Check if a file exists and can be read. More...
 
char * readconf (char const *path)
 Open a config file, read contents to memory. More...
 
int getconf (char **conf, struct conf_keywords const keywords[], char **arg)
 Return the next keyword token and set the optional argument. More...
 

Detailed Description

Light-weight (i.e.

dumb) config-file parser.

  • a valid config line is a keyword followed by an argument to the end of line
  • whitespace around the keyword is ignored
  • comments start with a hash sign, no inline comments, empty lines are ok.
  • whitespace is space and tab

Copyright (C) 2018 Christian W. Zuckschwerdt zany@.nosp@m.triq.nosp@m..net

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Function Documentation

◆ fsize()

static off_t fsize ( const char *  path)
static

References stat::st_size, and stat().

Referenced by mg_http_handler2(), and readconf().

◆ getconf()

int getconf ( char **  conf,
struct conf_keywords const  keywords[],
char **  arg 
)

Return the next keyword token and set the optional argument.

Parameters
confcurrent position in conf
keywordslist of possible keywords
argoptional out pointer to a argument string
Returns
the next keyword token, -1 otherwise.

References conf_keywords::key, and conf_keywords::keyword.

Referenced by parse_conf_text().

◆ hasconf()

int hasconf ( char const *  path)

Check if a file exists and can be read.

Parameters
pathinput file name
Returns
1 if the file exists and is readable, 0 otherwise

Referenced by parse_conf_try_default_files().

◆ readconf()

char* readconf ( char const *  path)

Open a config file, read contents to memory.

Parameters
pathinput file name
Returns
allocated memory containing the config file

References fsize().

Referenced by parse_conf_file().