File: confparse.h

package info (click to toggle)
rtl-433 25.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,192 kB
  • sloc: ansic: 55,982; cpp: 3,263; python: 2,544; php: 55; javascript: 43; sh: 18; makefile: 16
file content (43 lines) | stat: -rw-r--r-- 1,235 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/** @file
    Light-weight (i.e. dumb) config-file parser.

    Copyright (C) 2018 Christian W. Zuckschwerdt <zany@triq.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.
*/

#ifndef INCLUDE_CONFPARSE_H_
#define INCLUDE_CONFPARSE_H_

struct conf_keywords {
    char const *keyword;
    int key;
};

/** Check if a file exists and can be read.

    @param path input file name
    @return 1 if the file exists and is readable, 0 otherwise
*/
int hasconf(char const *path);

/** Open a config file, read contents to memory.

    @param path input file name
    @return allocated memory containing the config file
*/
char *readconf(char const *path);

/** Return the next keyword token and set the optional argument.

    @param conf current position in conf
    @param keywords list of possible keywords
    @param arg optional out pointer to a argument string
    @return the next keyword token, -1 otherwise.
*/
int getconf(char **conf, struct conf_keywords const keywords[], char **arg);

#endif /* INCLUDE_CONFPARSE_H_ */