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
2003-07-05 02:34:56 +04:00
# include "device.h"
2001-08-21 16:56:08 +04:00
enum {
2002-11-18 17:01:16 +03:00
CFG_STRING ,
CFG_FLOAT ,
CFG_INT ,
2002-08-01 16:46:52 +04:00
CFG_EMPTY_ARRAY
2001-08-21 16:56:08 +04:00
} ;
struct config_value {
2002-11-18 17:01:16 +03:00
int type ;
union {
int i ;
float r ;
char * str ;
} v ;
struct config_value * next ; /* for arrays */
2001-08-21 16:56:08 +04:00
} ;
struct config_node {
2002-11-18 17:01:16 +03:00
char * key ;
struct config_node * sib , * child ;
struct config_value * v ;
2001-08-21 16:56:08 +04:00
} ;
2002-11-18 17:01:16 +03:00
struct config_tree {
struct config_node * root ;
2001-08-21 16:56:08 +04:00
} ;
2002-11-18 17:01:16 +03:00
struct config_tree * create_config_tree ( void ) ;
void destroy_config_tree ( struct config_tree * cf ) ;
2001-08-21 16:56:08 +04:00
2002-11-18 17:01:16 +03:00
typedef uint32_t ( * checksum_fn_t ) ( uint32_t initial , void * buf , uint32_t size ) ;
2003-07-05 02:34:56 +04:00
int read_config_fd ( struct config_tree * cf , struct device * dev ,
2002-12-20 02:25:55 +03:00
off_t offset , size_t size , off_t offset2 , size_t size2 ,
2002-11-18 17:01:16 +03:00
checksum_fn_t checksum_fn , uint32_t checksum ) ;
int read_config_file ( struct config_tree * cf , const char * file ) ;
int write_config_file ( struct config_tree * cf , const char * file ) ;
int reload_config_file ( struct config_tree * * cf ) ;
2003-01-07 00:09:04 +03:00
time_t config_file_timestamp ( struct config_tree * cf ) ;
2001-08-21 16:56:08 +04:00
struct config_node * find_config_node ( struct config_node * cn ,
2002-12-20 02:25:55 +03:00
const char * path , const int separator ) ;
2001-08-21 16:56:08 +04:00
const char * find_config_str ( struct config_node * cn ,
2002-12-20 02:25:55 +03:00
const char * path , const int sep , const char * fail ) ;
2001-08-21 16:56:08 +04:00
int find_config_int ( struct config_node * cn , const char * path ,
2002-12-20 02:25:55 +03:00
const int sep , int fail ) ;
2001-08-21 16:56:08 +04:00
float find_config_float ( struct config_node * cn , const char * path ,
2002-12-20 02:25:55 +03:00
const int sep , float fail ) ;
2001-08-21 16:56:08 +04:00
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 ,
2002-12-20 02:25:55 +03:00
const int sep , int fail ) ;
2002-01-10 19:47:58 +03:00
int get_config_uint32 ( struct config_node * cn , const char * path ,
2002-12-20 02:25:55 +03:00
const int sep , uint32_t * result ) ;
2002-01-10 19:47:58 +03:00
int get_config_uint64 ( struct config_node * cn , const char * path ,
2002-12-20 02:25:55 +03:00
const int sep , uint64_t * result ) ;
2002-01-10 19:47:58 +03:00
2002-07-11 18:07:43 +04:00
int get_config_str ( struct config_node * cn , const char * path ,
2002-12-20 02:25:55 +03:00
const int sep , char * * result ) ;
2002-07-11 18:07:43 +04:00
2001-08-21 16:56:08 +04:00
# endif