73 wiersze
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
			
		
		
	
	
			73 wiersze
		
	
	
		
			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/
 | 
						|
 */
 | 
						|
 | 
						|
#include "retcode.h"
 | 
						|
 | 
						|
 | 
						|
#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 *name;
 | 
						|
	int name_len;
 | 
						|
};
 | 
						|
 | 
						|
struct cstuff_config_pair {
 | 
						|
	const char *key;
 | 
						|
	const char *val;
 | 
						|
	int key_len;
 | 
						|
	int val_len;
 | 
						|
};
 | 
						|
 | 
						|
struct cstuff_config_error {
 | 
						|
	const char *line_txt;
 | 
						|
	const char *err_txt;
 | 
						|
	int char_num;
 | 
						|
};
 | 
						|
 | 
						|
struct cstuff_config {
 | 
						|
	CStuffConfigEvent evt;
 | 
						|
	int line_num;
 | 
						|
	union {
 | 
						|
		struct cstuff_config_node node;
 | 
						|
		struct cstuff_config_pair pair;
 | 
						|
		struct cstuff_config_error 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 */
 |