.\" This manpage has been automatically generated by docbook2man .\" from a DocBook document. This tool can be found at: .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . .TH "CFG_PARSE" "3" "17 February 2004" "libcfg+ 0.6.2" "libcfg+ 0.6.2" .SH NAME cfg_parse, cfg_get_next_opt, cfg_get_cur_opt, cfg_get_cur_arg, cfg_get_cur_idx \- libcfg+ parsing .SH "SYNOPSIS | PARSING" .PP After a libcfg+ context is created and its flags are set (optional), one can initiate the parsing. This chapter provides information about the available parsing methods. .sp \fB#include .sp int cfg_parse (const CFG_CONTEXT \fIcon\fB); .sp int cfg_get_next_opt (const CFG_CONTEXT \fIcon\fB); \fR .SH "DESCRIPTION" .PP These functions take a context as their only argument. Depending on the type of the context, either a file or a command line option will be processed. If the option just parsed matches one of the options in the option set (see\~Options set\~section) and the arguments of the parsed option are stored in memory and \fBvalue\fR is set to point to them. However, if the \fBvalue\fR of the relevant option in the option is set to NULL, the arguments will not be stored. .PP The main and only difference between the two functions is in the way they interpret the \fBval\fR field of the relevant option after a matching token was found in the token stream. The function \fBcfg_get_next_opt()\fR respects the value of this field and if it is not 0, returns the value upon a match. If the field is set to 0, the function proceeds to the next token without returning a value. In the case of \fBcfg_parse()\fR, \fBval\fR is ignored. .PP If an error occurs during parsing, the functions return a negative integer. This is why it is a good idea to set the \fBval\fR member of the cfg_option to a value equal or greater than 0. Detailed information about error codes as well as their descriptions can be found in the Error handling section. .PP At the end of parsing 0 is returned. .SH "SYNOPSIS | ADDITIONAL INFORMATION" .PP The following functions provide additional information about a matched option. .sp \fB#include .sp char *cfg_get_cur_opt (const CFG_CONTEXT \fIcon\fB); .sp char *cfg_get_cur_arg (const CFG_CONTEXT \fIcon\fB); .sp int cfg_get_cur_idx (const CFG_CONTEXT \fIcon\fB); \fR .SH "DESCRIPTION" .PP Use \fBcfg_get_cur_opt()\fR to get the name of the option being processed. Use \fBcfg_get_cur_arg()\fRto get the current argument. Finally, use \fBcfg_get_cur_idx()\fR to get the current offset in the parsing stream. If the context is associated with the command line, the value is the current offset in the \fIargv\fR array. If the context is associated with a configuration file, then depending on the value of CFG_FILE_LINE_POS_USAGE, it is either the current byte offset or line number in the file. .\" This is common footer for libcfg+ manpages. .\" Written by Ondrej Jombik in 14th September 2002 .SH "SEE ALSO" You can get library overview, table of contents and such additional information info from main \fBlibcfg+\fR(3) manpage by typing "man libcfg+" on UNIX-based systems. Also use this command to get information about authors, homepage and license conditions.