1: .TH LIBCONFIG 3 "25 Oct 04" "@PACKAGE_STRING@" 2: .SH NAME 3: libconfig \- Consistent configuration library. 4: 5: .SH SYNOPSIS 6: .B #include <libconfig.h> 7: .sp 8: .BI "int lc_register_callback(const char *" var ", char " opt ", lc_var_type_t " type ", int (*" callback ")(const char *, const char *, const char *, const char *, lc_flags_t, void *), void *" extra ");" 9: 10: .BI "int lc_register_var(const char *" var ", lc_var_type_t " type ", void *" data ", char " opt ");" 11: 12: .BI "int lc_process(int " argc ", char **" argv ", const char *" appname ", lc_conf_type_t " type ", const char *" extra ");" 13: 14: .BI "lc_err_t lc_geterrno(void);" 15: 16: .BI "char *lc_geterrstr(void);" 17: 18: .BI "void lc_seterrstr(const char *" errstr ");" 19: 20: .BI "int lc_handle_type(lc_var_type_t " type ", const char *" value ", void *" data ");" 21: 22: .BI "void lc_cleanup(void);" 23: 24: .SH DESCRIPTION 25: Libconfig is a library to provide easy access to configuration data in a consistent and logical manner. Variables (registered through 26: .BR lc_register_var (3) 27: or 28: .BR lc_register_callback (3)) 29: are processed with the 30: .BR lc_process (3) 31: and 32: .BR lc_process_file (3) 33: functions. Errors can be examined through 34: .BR lc_geterrno (3) 35: and 36: .BR lc_geterrstr (3). 37: Clean-up may be performed using the 38: .BR lc_cleanup (3) 39: function. 40: 41: .SH EXAMPLE 42: .nf 43: #include <libconfig.h> 44: #include <stdlib.h> 45: #include <stdio.h> 46: 47: int main(int argc, char **argv) { 48: int lc_p_ret, lc_rv_ret; 49: char *filename = NULL; 50: 51: lc_rv_ret = lc_register_var("File", LC_VAR_STRING, 52: &filename, 'f'); 53: 54: if (lc_rv_ret != 0) { 55: fprintf(stderr, "Error registering variable: %i.\\n", 56: lc_geterrno()); 57: return(EXIT_FAILURE); 58: } 59: 60: lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, 61: NULL); 62: 63: lc_cleanup(); 64: 65: if (lc_p_ret != 0) { 66: fprintf(stderr, "Error processing configuration: \\ 67: %s\\n", lc_geterrstr()); 68: return(EXIT_FAILURE); 69: } 70: 71: if (filename != NULL) { 72: printf("File specified was: %s\\n", filename); 73: } else { 74: printf("No filename specified.\\n"); 75: } 76: 77: return(EXIT_SUCCESS); 78: } 79: .fi 80: 81: .SH "SEE ALSO" 82: .BR lc_register_var (3), 83: .BR lc_register_callback (3), 84: .BR lc_geterrno (3), 85: .BR lc_geterrstr (3), 86: .BR lc_seterrstr (3), 87: .BR lc_handle_type (3), 88: .BR lc_process (3), 89: .BR lc_process_file (3), 90: .BR lc_cleanup (3) |