1: .TH LC_GETERRNO 3 "25 Oct 04" "@PACKAGE_STRING@" 2: .SH NAME 3: lc_geterrno \- Retrieve a numeric error code. 4: 5: .SH SYNOPSIS 6: .B #include <libconfig.h> 7: .sp 8: .BI "lc_err_t lc_geterrno(void);" 9: 10: .SH DESCRIPTION 11: The 12: .BR lc_geterrno (3) 13: function returns the last numeric error code set as an 14: .IR "lc_err_t" 15: which is an enumerated type and can be cast to any integer type. 16: 17: The 18: .IR lc_err_t 19: type specifies the following defined values: 20: .TP 21: LC_ERR_NONE 22: No error was found. Success. 23: .TP 24: LC_ERR_INVCMD 25: A command was specified for which there was no handler. 26: .TP 27: LC_ERR_INVSECTION 28: A section was specified for which there was no handler. 29: .TP 30: LC_ERR_INVDATA 31: A value that does not make sense was specified, such as a non-existant type to the 32: .BR lc_process_file (3) 33: function. 34: .TP 35: LC_ERR_BADFORMAT 36: An invalid format was detected, such as no argument where on was expected, or a value passed to a boolean-specified variable whose value was not one of: enable, true, yes, on, y, 1, disable, false, off, no, n, 0. 37: .TP 38: LC_ERR_CANTOPEN 39: Unable to open a specified file. 40: .TP 41: LC_ERR_CALLBACK 42: A callback function returned an error (LC_CBRET_ERROR). 43: .TP 44: LC_ERR_ENOMEM 45: Memory could not be allocated for internal structures. 46: 47: .SH EXAMPLE 48: .nf 49: #include <libconfig.h> 50: #include <stdlib.h> 51: #include <stdio.h> 52: 53: int main(int argc, char **argv) { 54: int lc_p_ret, lc_rv_ret; 55: char *filename = NULL; 56: 57: lc_rv_ret = lc_register_var("File", LC_VAR_STRING, 58: &filename, 'f'); 59: 60: if (lc_rv_ret != 0) { 61: fprintf(stderr, "Error registering variable: %i.\\n", 62: lc_geterrno()); 63: return(EXIT_FAILURE); 64: } 65: 66: lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, 67: NULL); 68: 69: lc_cleanup(); 70: 71: if (lc_p_ret != 0) { 72: fprintf(stderr, "Error processing configuration: \\ 73: %s\\n", lc_geterrstr()); 74: return(EXIT_FAILURE); 75: } 76: 77: if (filename != NULL) { 78: printf("File specified was: %s\\n", filename); 79: } else { 80: printf("No filename specified.\\n"); 81: } 82: 83: return(EXIT_SUCCESS); 84: } 85: .fi 86: 87: .SH "SEE ALSO" 88: .BR libconfig (3), 89: .BR lc_register_var (3), 90: .BR lc_register_callback (3), 91: .BR lc_geterrstr (3), 92: .BR lc_seterrstr (3), 93: .BR lc_handle_type (3), 94: .BR lc_process (3), 95: .BR lc_process_file (3), 96: .BR lc_cleanup (3) |