70 lines
1.4 KiB
C
70 lines
1.4 KiB
C
/******************************************************************************
|
|
*
|
|
* Copyright (c) 2017-2019 by Löwenware Ltd
|
|
* Please, refer LICENSE file for legal information
|
|
*
|
|
******************************************************************************/
|
|
|
|
/**
|
|
* @file config.h
|
|
* @author Ilja Kartašov <ik@lowenware.com>
|
|
* @brief
|
|
*
|
|
* @see https://lowenware.com/
|
|
*/
|
|
|
|
#ifndef CSTUFF_CONFIG_H_6207A85E_26F1_4B64_818F_92C6286FC5F0
|
|
#define CSTUFF_CONFIG_H_6207A85E_26F1_4B64_818F_92C6286FC5F0
|
|
|
|
#ifndef CSTUFF_CONFIG_PATH_SIZE
|
|
#define CSTUFF_CONFIG_PATH_SIZE 64
|
|
#endif
|
|
|
|
typedef enum {
|
|
CSTUFF_CONFIG_NONE
|
|
, CSTUFF_CONFIG_NODE
|
|
, CSTUFF_CONFIG_PAIR
|
|
, CSTUFF_CONFIG_ERROR
|
|
} CStuffConfigEvent;
|
|
|
|
struct cstuff_config_node {
|
|
const char *node;
|
|
int node_len;
|
|
};
|
|
|
|
struct cstuff_config_pair {
|
|
const char *key;
|
|
const char *value;
|
|
int key_len;
|
|
int value_len;
|
|
};
|
|
|
|
struct cstuff_config_error {
|
|
const char *line_text;
|
|
const char *err_text;
|
|
int char_num;
|
|
};
|
|
|
|
struct cstuff_config {
|
|
CStuffConfigEvent evt;
|
|
int line_number;
|
|
union {
|
|
struct cstuff_config_node node;
|
|
struct cstuff_config_pair pair;
|
|
struct cstuff_config_ierror error;
|
|
} data;
|
|
};
|
|
|
|
typedef struct cstuff_config * CStuffConfig;
|
|
|
|
|
|
typedef int
|
|
(* CStuffConfigCallback)(struct cstuff_config *config, void *u_ptr);
|
|
|
|
|
|
CStuffRetcode
|
|
cstuff_config_parse(const char *file, CStuffConfigCallback callback, void *u_ptr);
|
|
|
|
|
|
#endif /* !CSTUFF_CONFIG_H */
|