Index: lc_geterrno.3.in ================================================================== --- lc_geterrno.3.in +++ lc_geterrno.3.in @@ -0,0 +1,90 @@ +.TH LC_GETERRNO 3 "25 Oct 04" "@PACKAGE_STRING@" +.SH NAME +lc_geterrno \- Retrieve a numeric error code. + +.SH SYNOPSIS +.B #include +.sp +.BI "lc_err_t lc_geterrno(void);" + +.SH DESCRIPTION +The +.BR lc_geterrno (3) +function returns the last numeric error code set as an +.IR "lc_err_t" +which is an enumerated type and can be cast to any integer type. + +The +.IR lc_err_t +type specifies the following defined values: +.TP +LC_ERR_NONE +No error was found. Success. +.TP +LC_ERR_INVCMD +A command was specified for which there was no handler. +.TP +LC_ERR_INVSECTION +A section was specified for which there was no handler. +.TP +LC_ERR_INVDATA +A value that does not make sense was specified, such as a non-existant type to the +.BR lc_process_file (3) +function. +.TP +LC_ERR_BADFORMAT +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. +.TP +LC_ERR_CANTOPEN +Unable to open a specified file. +.TP +LC_ERR_CALLBACK +A callback function returned an error (LC_CBRET_ERROR). +.TP +LC_ERR_ENOMEM +Memory could not be allocated for internal structures. + +.SH EXAMPLE +.nf +#include +#include +#include + + +int main(int argc, char **argv) { + int lc_p_ret, lc_rv_ret; + char *filename = NULL; + + lc_rv_ret = lc_register_var("File", LC_VAR_STRING, + &filename, 'f'); + + if (lc_rv_ret != 0) { + fprintf(stderr, "Error registering variable: %i.\\n", + lc_geterrno()); + return(EXIT_FAILURE); + } + + lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, + NULL); + if (lc_p_ret != 0) { + fprintf(stderr, "Error processing configuration: \\ + %s\\n", lc_geterrstr()); + return(EXIT_FAILURE); + } + + if (filename != NULL) { + printf("File specified was: %s\\n", filename); + } else { + printf("No filename specified.\\n"); + } + + return(EXIT_SUCCESS); +} +.fi + +.SH "SEE ALSO" +.BR lc_register_var (3), +.BR lc_register_callback (3), +.BR lc_geterrstr (3), +.BR lc_process (3), +.BR lc_register_var (3) Index: lc_geterrstr.3.in ================================================================== --- lc_geterrstr.3.in +++ lc_geterrstr.3.in @@ -0,0 +1,57 @@ +.TH LC_GETERRSTR 3 "25 Oct 04" "@PACKAGE_STRING@" +.SH NAME +lc_geterrstr \- Retrieve a human readable error message. + +.SH SYNOPSIS +.B #include +.sp +.BI "char *lc_geterrstr(void);" + +.SH DESCRIPTION +The +.BR lc_geterrstr (3) +function returns a string describing the last error code set. + +.SH EXAMPLE +.nf +#include +#include +#include + +int main(int argc, char **argv) { + int lc_p_ret, lc_rv_ret; + char *filename = NULL; + + lc_rv_ret = lc_register_var("File", LC_VAR_STRING, + &filename, 'f'); + + if (lc_rv_ret != 0) { + fprintf(stderr, "Error registering variable: %s.\\n", + lc_geterrstr()); + return(EXIT_FAILURE); + } + + lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, + NULL); + if (lc_p_ret != 0) { + fprintf(stderr, "Error processing configuration: \\ + %s\\n", lc_geterrstr()); + return(EXIT_FAILURE); + } + + if (filename != NULL) { + printf("File specified was: %s\\n", filename); + } else { + printf("No filename specified.\\n"); + } + + return(EXIT_SUCCESS); +} +.fi + +.SH "SEE ALSO" +.BR lc_register_var (3), +.BR lc_register_callback (3), +.BR lc_geterrno (3), +.BR lc_process (3), +.BR lc_register_var (3) Index: lc_register_callback.3.in ================================================================== --- lc_register_callback.3.in +++ lc_register_callback.3.in @@ -7,11 +7,11 @@ .sp .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); .SH DESCRIPTION The -.B lc_register_callback +.BR lc_register_callback (3) function registers a function to be called when .IR var is encounted in a configuration file, command line, or environment variable. The parameters are as follows: .TP @@ -68,11 +68,11 @@ This may be .B NULL if the .IR var parameter to -.BI lc_register_callback (3) +.BR lc_register_callback (3) was .B NULL too. .RE .TP @@ -84,11 +84,11 @@ This may be .B NULL if the .IR var parameter to -.BI lc_register_callback (3) +.BR lc_register_callback (3) was .B NULL too. .RE .TP @@ -110,11 +110,11 @@ This may be .B NULL if no value was specified. Values are required if the .IR type parameter to -.BI lc_register_callback (3) +.BR lc_register_callback (3) was not specified as one of LC_VAR_NONE, LC_VAR_SECTION, LC_VAR_SECTIONSTART, or LC_VAR_SECTIONEND. .RE .TP .I "lc_flags_t flags" .RS @@ -134,11 +134,11 @@ The .I extra parameter is just a copy of the .IR extra parameter passed to -.BI lc_register_callback (3) +.BR lc_register_callback (3) when the callback was registered. .RE The .IR callback @@ -150,11 +150,11 @@ LC_CBRET_OKAY Returning LC_CBRET_OKAY from a callback indicates that all went well and further processing may continue. .TP LC_CBRET_ERROR Returnning LC_CBRET_ERROR from a callback indicates that the command failed for some reason, the error will be passed back down the chain back to the -.BI lc_process (3) +.BR lc_process (3) call that began processing the configuration data. If LC_CBRET_ERROR is returned from a callback that begins a section, the entire section is ignored. "RETURN VALUE" On success 0 is returned, otherwise -1 is returned.