2001-08-21 16:56:08 +04:00
/*
2001-10-03 15:06:31 +04:00
* Copyright ( C ) 2001 Sistina Software ( UK ) Limited .
2001-08-21 16:56:08 +04:00
*
2001-12-17 22:46:10 +03:00
* This file is released under the LGPL .
2001-08-21 16:56:08 +04:00
*/
2001-09-25 16:49:28 +04:00
# ifndef _LVM_CONFIG_H
# define _LVM_CONFIG_H
2002-01-10 19:47:58 +03:00
# include <inttypes.h>
2001-08-21 16:56:08 +04:00
enum {
CFG_STRING ,
CFG_FLOAT ,
CFG_INT ,
} ;
struct config_value {
int type ;
union {
int i ;
float r ;
char * str ;
} v ;
struct config_value * next ; /* for arrays */
} ;
struct config_node {
char * key ;
struct config_node * sib , * child ;
struct config_value * v ;
} ;
struct config_file {
struct config_node * root ;
} ;
2001-10-30 20:53:21 +03:00
struct config_file * create_config_file ( void ) ;
2001-08-21 16:56:08 +04:00
void destroy_config_file ( struct config_file * cf ) ;
int read_config ( struct config_file * cf , const char * file ) ;
int write_config ( struct config_file * cf , const char * file ) ;
struct config_node * find_config_node ( struct config_node * cn ,
const char * path , char seperator ) ;
const char * find_config_str ( struct config_node * cn ,
const char * path , char sep , const char * fail ) ;
int find_config_int ( struct config_node * cn , const char * path ,
char sep , int fail ) ;
float find_config_float ( struct config_node * cn , const char * path ,
char sep , float fail ) ;
2002-01-07 13:23:52 +03:00
/*
* Understands ( 0 , ~ 0 ) , ( y , n ) , ( yes , no ) , ( on ,
* off ) , ( true , false ) .
*/
int find_config_bool ( struct config_node * cn , const char * path ,
char sep , int fail ) ;
2002-01-10 19:47:58 +03:00
int get_config_uint32 ( struct config_node * cn , const char * path ,
char sep , uint32_t * result ) ;
int get_config_uint64 ( struct config_node * cn , const char * path ,
char sep , uint64_t * result ) ;
2001-08-21 16:56:08 +04:00
# endif