📄 group__apr__getopt.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Apache Portable Runtime: Command Argument Parsing</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.7 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>Command Argument Parsing</h1><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>struct </td><td class="memItemRight" valign=bottom><a class="el" href="structapr__getopt__t.html">apr_getopt_t</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>struct </td><td class="memItemRight" valign=bottom><a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a></td></tr>
<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef void( </td><td class="memItemRight" valign=bottom><a class="el" href="group__apr__getopt.html#ga0">apr_getopt_err_fn_t</a> )(void *arg, const char *err,...)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> </td><td class="memItemRight" valign=bottom><a class="el" href="group__apr__getopt.html#ga1">apr_getopt_t</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> </td><td class="memItemRight" valign=bottom><a class="el" href="group__apr__getopt.html#ga2">apr_getopt_option_t</a></td></tr>
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__apr__errno.html#ga0">apr_status_t</a> </td><td class="memItemRight" valign=bottom><a class="el" href="group__apr__getopt.html#ga3">apr_getopt_init</a> (<a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> **os, <a class="el" href="group__apr__pools.html#ga0">apr_pool_t</a> *cont, int argc, const char *const *argv)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__apr__errno.html#ga0">apr_status_t</a> </td><td class="memItemRight" valign=bottom><a class="el" href="group__apr__getopt.html#ga4">apr_getopt</a> (<a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> *os, const char *opts, char *option_ch, const char **option_arg)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__apr__errno.html#ga0">apr_status_t</a> </td><td class="memItemRight" valign=bottom><a class="el" href="group__apr__getopt.html#ga5">apr_getopt_long</a> (<a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> *os, const <a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> *opts, int *option_ch, const char **option_arg)</td></tr>
</table>
<hr><h2>Typedef Documentation</h2>
<a class="anchor" name="ga0" doxytag="apr_getopt.h::apr_getopt_err_fn_t" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> typedef void( <a class="el" href="group__apr__getopt.html#ga0">apr_getopt_err_fn_t</a>)(void *arg, const char *err,...) </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
defintion of a error function </td>
</tr>
</table>
<a class="anchor" name="ga2" doxytag="apr_getopt.h::apr_getopt_option_t" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> typedef struct <a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> <a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="ga1" doxytag="apr_getopt.h::apr_getopt_t" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> typedef struct <a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> <a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> </dd></dl>
</td>
</tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="ga4" doxytag="apr_getopt.h::apr_getopt" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="group__apr__errno.html#ga0">apr_status_t</a> apr_getopt </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top"><a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> * </td>
<td class="mdname" nowrap> <em>os</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const char * </td>
<td class="mdname" nowrap> <em>opts</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>char * </td>
<td class="mdname" nowrap> <em>option_ch</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const char ** </td>
<td class="mdname" nowrap> <em>option_arg</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Parse the options initialized by <a class="el" href="group__apr__getopt.html#ga3">apr_getopt_init()</a>. <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>os</em> </td><td>The apr_opt_t structure returned by <a class="el" href="group__apr__getopt.html#ga3">apr_getopt_init()</a> </td></tr>
<tr><td></td><td valign=top><em>opts</em> </td><td>A string of characters that are acceptable options to the program. Characters followed by ":" are required to have an option associated </td></tr>
<tr><td></td><td valign=top><em>option_ch</em> </td><td>The next option character parsed </td></tr>
<tr><td></td><td valign=top><em>option_arg</em> </td><td>The argument following the option character: </td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>There are four potential status values on exit. They are: <pre>
APR_EOF -- No more options to parse
APR_BADCH -- Found a bad option character
APR_BADARG -- No argument followed the option flag
APR_SUCCESS -- The next option was found.
</pre> </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="ga3" doxytag="apr_getopt.h::apr_getopt_init" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="group__apr__errno.html#ga0">apr_status_t</a> apr_getopt_init </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top"><a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> ** </td>
<td class="mdname" nowrap> <em>os</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap><a class="el" href="group__apr__pools.html#ga0">apr_pool_t</a> * </td>
<td class="mdname" nowrap> <em>cont</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>int </td>
<td class="mdname" nowrap> <em>argc</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const char *const * </td>
<td class="mdname" nowrap> <em>argv</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Initialize the arguments for parsing by <a class="el" href="group__apr__getopt.html#ga4">apr_getopt()</a>. <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>os</em> </td><td>The options structure created for <a class="el" href="group__apr__getopt.html#ga4">apr_getopt()</a> </td></tr>
<tr><td></td><td valign=top><em>cont</em> </td><td>The pool to operate on </td></tr>
<tr><td></td><td valign=top><em>argc</em> </td><td>The number of arguments to parse </td></tr>
<tr><td></td><td valign=top><em>argv</em> </td><td>The array of arguments to parse </td></tr>
</table>
</dl>
<dl compact><dt><b>Remarks:</b></dt><dd>Arguments 2 and 3 are most commonly argc and argv from main(argc, argv) The errfn is initialized to fprintf(stderr... but may be overridden. </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="ga5" doxytag="apr_getopt.h::apr_getopt_long" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="group__apr__errno.html#ga0">apr_status_t</a> apr_getopt_long </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top"><a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> * </td>
<td class="mdname" nowrap> <em>os</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const <a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> * </td>
<td class="mdname" nowrap> <em>opts</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>int * </td>
<td class="mdname" nowrap> <em>option_ch</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const char ** </td>
<td class="mdname" nowrap> <em>option_arg</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Parse the options initialized by <a class="el" href="group__apr__getopt.html#ga3">apr_getopt_init()</a>, accepting long options beginning with "--" in addition to single-character options beginning with "-". <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>os</em> </td><td>The <a class="el" href="structapr__getopt__t.html">apr_getopt_t</a> structure created by <a class="el" href="group__apr__getopt.html#ga3">apr_getopt_init()</a> </td></tr>
<tr><td></td><td valign=top><em>opts</em> </td><td>A pointer to a list of <a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> structures, which can be initialized with { "name", optch, has_args }. has_args is nonzero if the option requires an argument. A structure with an optch value of 0 terminates the list. </td></tr>
<tr><td></td><td valign=top><em>option_ch</em> </td><td>Receives the value of "optch" from the <a class="el" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> structure corresponding to the next option matched. </td></tr>
<tr><td></td><td valign=top><em>option_arg</em> </td><td>Receives the argument following the option, if any. </td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>There are four potential status values on exit. They are: <pre>
APR_EOF -- No more options to parse
APR_BADCH -- Found a bad option character
APR_BADARG -- No argument followed the option flag
APR_SUCCESS -- The next option was found.
</pre> When APR_SUCCESS is returned, os->ind gives the index of the first non-option argument. On error, a message will be printed to stdout unless os->err is set to 0. If os->interleave is set to nonzero, options can come after arguments, and os->argv will be permuted to leave non-option arguments at the end (the original argv is unaffected). </dd></dl>
</td>
</tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Mon Feb 7 13:18:25 2005 for Apache Portable Runtime by
<a href="../../../www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -