Sophie

Sophie

distrib > Mandriva > 10.2 > i586 > by-pkgid > 4f37b923758ceff94a2c0ccca62b4b43 > files > 75

libapr1-devel-1.1.1-1mdk.i586.rpm

<!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: apr_getopt.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">home</a>&nbsp;/&nbsp;<a class="el" href="dir_000001.html">oden</a>&nbsp;/&nbsp;<a class="el" href="dir_000002.html">RPM</a>&nbsp;/&nbsp;<a class="el" href="dir_000003.html">BUILD</a>&nbsp;/&nbsp;<a class="el" href="dir_000004.html">apr-1.1.1</a>&nbsp;/&nbsp;<a class="el" href="dir_000005.html">include</a></div>
<h1>apr_getopt.h</h1><a href="apr__getopt_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/* Copyright 2000-2004 The Apache Software Foundation</span>
00002 <span class="comment"> *</span>
00003 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
00004 <span class="comment"> * you may not use this file except in compliance with the License.</span>
00005 <span class="comment"> * You may obtain a copy of the License at</span>
00006 <span class="comment"> *</span>
00007 <span class="comment"> *     http://www.apache.org/licenses/LICENSE-2.0</span>
00008 <span class="comment"> *</span>
00009 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
00010 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
00011 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
00012 <span class="comment"> * See the License for the specific language governing permissions and</span>
00013 <span class="comment"> * limitations under the License.</span>
00014 <span class="comment"> */</span>
00015 
00016 <span class="preprocessor">#ifndef APR_GETOPT_H</span>
00017 <span class="preprocessor"></span><span class="preprocessor">#define APR_GETOPT_H</span>
00018 <span class="preprocessor"></span><span class="comment"></span>
00019 <span class="comment">/**</span>
00020 <span class="comment"> * @file apr_getopt.h</span>
00021 <span class="comment"> * @brief APR Command Arguments (getopt)</span>
00022 <span class="comment"> */</span>
00023 
00024 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span>
00025 
00026 <span class="preprocessor">#ifdef __cplusplus</span>
00027 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
00028 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span>
00029 <span class="comment"></span>
00030 <span class="comment">/**</span>
00031 <span class="comment"> * @defgroup apr_getopt Command Argument Parsing</span>
00032 <span class="comment"> * @ingroup APR </span>
00033 <span class="comment"> * @{</span>
00034 <span class="comment"> */</span>
00035 <span class="comment"></span>
00036 <span class="comment">/** </span>
00037 <span class="comment"> * defintion of a error function </span>
00038 <span class="comment"> */</span>
<a name="l00039"></a><a class="code" href="group__apr__getopt.html#ga0">00039</a> <span class="keyword">typedef</span> void (apr_getopt_err_fn_t)(<span class="keywordtype">void</span> *arg, <span class="keyword">const</span> <span class="keywordtype">char</span> *err, ...);
00040 <span class="comment"></span>
00041 <span class="comment">/** @see apr_getopt_t */</span>
<a name="l00042"></a><a class="code" href="group__apr__getopt.html#ga1">00042</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structapr__getopt__t.html">apr_getopt_t</a> <a class="code" href="group__apr__getopt.html#ga1">apr_getopt_t</a>;
00043 <span class="comment"></span>
00044 <span class="comment">/**</span>
00045 <span class="comment"> * Structure to store command line argument information.</span>
00046 <span class="comment"> */</span> 
<a name="l00047"></a><a class="code" href="structapr__getopt__t.html">00047</a> <span class="keyword">struct </span><a class="code" href="group__apr__getopt.html#ga1">apr_getopt_t</a> {<span class="comment"></span>
00048 <span class="comment">    /** context for processing */</span>
<a name="l00049"></a><a class="code" href="structapr__getopt__t.html#o0">00049</a>     <a class="code" href="group__apr__pools.html#ga0">apr_pool_t</a> *cont;<span class="comment"></span>
00050 <span class="comment">    /** function to print error message (NULL == no messages) */</span>
<a name="l00051"></a><a class="code" href="structapr__getopt__t.html#o1">00051</a>     <a class="code" href="group__apr__getopt.html#ga0">apr_getopt_err_fn_t</a> *errfn;<span class="comment"></span>
00052 <span class="comment">    /** user defined first arg to pass to error message  */</span>
<a name="l00053"></a><a class="code" href="structapr__getopt__t.html#o2">00053</a>     <span class="keywordtype">void</span> *errarg;<span class="comment"></span>
00054 <span class="comment">    /** index into parent argv vector */</span>
<a name="l00055"></a><a class="code" href="structapr__getopt__t.html#o3">00055</a>     <span class="keywordtype">int</span> ind;<span class="comment"></span>
00056 <span class="comment">    /** character checked for validity */</span>
<a name="l00057"></a><a class="code" href="structapr__getopt__t.html#o4">00057</a>     <span class="keywordtype">int</span> opt;<span class="comment"></span>
00058 <span class="comment">    /** reset getopt */</span>
<a name="l00059"></a><a class="code" href="structapr__getopt__t.html#o5">00059</a>     <span class="keywordtype">int</span> reset;<span class="comment"></span>
00060 <span class="comment">    /** count of arguments */</span>
<a name="l00061"></a><a class="code" href="structapr__getopt__t.html#o6">00061</a>     <span class="keywordtype">int</span> argc;<span class="comment"></span>
00062 <span class="comment">    /** array of pointers to arguments */</span>
<a name="l00063"></a><a class="code" href="structapr__getopt__t.html#o7">00063</a>     <span class="keyword">const</span> <span class="keywordtype">char</span> **argv;<span class="comment"></span>
00064 <span class="comment">    /** argument associated with option */</span>
<a name="l00065"></a><a class="code" href="structapr__getopt__t.html#o8">00065</a>     <span class="keywordtype">char</span> <span class="keyword">const</span>* place;<span class="comment"></span>
00066 <span class="comment">    /** set to nonzero to support interleaving options with regular args */</span>
<a name="l00067"></a><a class="code" href="structapr__getopt__t.html#o9">00067</a>     <span class="keywordtype">int</span> interleave;<span class="comment"></span>
00068 <span class="comment">    /** start of non-option arguments skipped for interleaving */</span>
<a name="l00069"></a><a class="code" href="structapr__getopt__t.html#o10">00069</a>     <span class="keywordtype">int</span> skip_start;<span class="comment"></span>
00070 <span class="comment">    /** end of non-option arguments skipped for interleaving */</span>
<a name="l00071"></a><a class="code" href="structapr__getopt__t.html#o11">00071</a>     <span class="keywordtype">int</span> skip_end;
00072 };
00073 <span class="comment"></span>
00074 <span class="comment">/** @see apr_getopt_option_t */</span>
<a name="l00075"></a><a class="code" href="group__apr__getopt.html#ga2">00075</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structapr__getopt__option__t.html">apr_getopt_option_t</a> <a class="code" href="group__apr__getopt.html#ga2">apr_getopt_option_t</a>;
00076 <span class="comment"></span>
00077 <span class="comment">/**</span>
00078 <span class="comment"> * Structure used to describe options that getopt should search for.</span>
00079 <span class="comment"> */</span>
<a name="l00080"></a><a class="code" href="structapr__getopt__option__t.html">00080</a> <span class="keyword">struct </span><a class="code" href="group__apr__getopt.html#ga2">apr_getopt_option_t</a> {<span class="comment"></span>
00081 <span class="comment">    /** long option name, or NULL if option has no long name */</span>
<a name="l00082"></a><a class="code" href="structapr__getopt__option__t.html#o0">00082</a>     <span class="keyword">const</span> <span class="keywordtype">char</span> *name;<span class="comment"></span>
00083 <span class="comment">    /** option letter, or a value greater than 255 if option has no letter */</span>
<a name="l00084"></a><a class="code" href="structapr__getopt__option__t.html#o1">00084</a>     <span class="keywordtype">int</span> optch;<span class="comment"></span>
00085 <span class="comment">    /** nonzero if option takes an argument */</span>
<a name="l00086"></a><a class="code" href="structapr__getopt__option__t.html#o2">00086</a>     <span class="keywordtype">int</span> has_arg;<span class="comment"></span>
00087 <span class="comment">    /** a description of the option */</span>
<a name="l00088"></a><a class="code" href="structapr__getopt__option__t.html#o3">00088</a>     <span class="keyword">const</span> <span class="keywordtype">char</span> *description;
00089 };
00090 <span class="comment"></span>
00091 <span class="comment">/**</span>
00092 <span class="comment"> * Initialize the arguments for parsing by apr_getopt().</span>
00093 <span class="comment"> * @param os   The options structure created for apr_getopt()</span>
00094 <span class="comment"> * @param cont The pool to operate on</span>
00095 <span class="comment"> * @param argc The number of arguments to parse</span>
00096 <span class="comment"> * @param argv The array of arguments to parse</span>
00097 <span class="comment"> * @remark Arguments 2 and 3 are most commonly argc and argv from main(argc, argv)</span>
00098 <span class="comment"> * The errfn is initialized to fprintf(stderr... but may be overridden.</span>
00099 <span class="comment"> */</span>
00100 <a class="code" href="group__apr__platform.html#ga123">APR_DECLARE</a>(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont,
00101                                       <span class="keywordtype">int</span> argc, const <span class="keywordtype">char</span> * const *argv);
00102 <span class="comment"></span>
00103 <span class="comment">/**</span>
00104 <span class="comment"> * Parse the options initialized by apr_getopt_init().</span>
00105 <span class="comment"> * @param os     The apr_opt_t structure returned by apr_getopt_init()</span>
00106 <span class="comment"> * @param opts   A string of characters that are acceptable options to the </span>
00107 <span class="comment"> *               program.  Characters followed by ":" are required to have an </span>
00108 <span class="comment"> *               option associated</span>
00109 <span class="comment"> * @param option_ch  The next option character parsed</span>
00110 <span class="comment"> * @param option_arg The argument following the option character:</span>
00111 <span class="comment"> * @return There are four potential status values on exit. They are:</span>
00112 <span class="comment"> * &lt;PRE&gt;</span>
00113 <span class="comment"> *             APR_EOF      --  No more options to parse</span>
00114 <span class="comment"> *             APR_BADCH    --  Found a bad option character</span>
00115 <span class="comment"> *             APR_BADARG   --  No argument followed the option flag</span>
00116 <span class="comment"> *             APR_SUCCESS  --  The next option was found.</span>
00117 <span class="comment"> * &lt;/PRE&gt;</span>
00118 <span class="comment"> */</span>
00119 APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const <span class="keywordtype">char</span> *opts, 
00120                                      <span class="keywordtype">char</span> *option_ch, const <span class="keywordtype">char</span> **option_arg);
00121 <span class="comment"></span>
00122 <span class="comment">/**</span>
00123 <span class="comment"> * Parse the options initialized by apr_getopt_init(), accepting long</span>
00124 <span class="comment"> * options beginning with "--" in addition to single-character</span>
00125 <span class="comment"> * options beginning with "-".</span>
00126 <span class="comment"> * @param os     The apr_getopt_t structure created by apr_getopt_init()</span>
00127 <span class="comment"> * @param opts   A pointer to a list of apr_getopt_option_t structures, which</span>
00128 <span class="comment"> *               can be initialized with { "name", optch, has_args }.  has_args</span>
00129 <span class="comment"> *               is nonzero if the option requires an argument.  A structure</span>
00130 <span class="comment"> *               with an optch value of 0 terminates the list.</span>
00131 <span class="comment"> * @param option_ch  Receives the value of "optch" from the apr_getopt_option_t</span>
00132 <span class="comment"> *                   structure corresponding to the next option matched.</span>
00133 <span class="comment"> * @param option_arg Receives the argument following the option, if any.</span>
00134 <span class="comment"> * @return There are four potential status values on exit.   They are:</span>
00135 <span class="comment"> * &lt;PRE&gt;</span>
00136 <span class="comment"> *             APR_EOF      --  No more options to parse</span>
00137 <span class="comment"> *             APR_BADCH    --  Found a bad option character</span>
00138 <span class="comment"> *             APR_BADARG   --  No argument followed the option flag</span>
00139 <span class="comment"> *             APR_SUCCESS  --  The next option was found.</span>
00140 <span class="comment"> * &lt;/PRE&gt;</span>
00141 <span class="comment"> * When APR_SUCCESS is returned, os-&gt;ind gives the index of the first</span>
00142 <span class="comment"> * non-option argument.  On error, a message will be printed to stdout unless</span>
00143 <span class="comment"> * os-&gt;err is set to 0.  If os-&gt;interleave is set to nonzero, options can come</span>
00144 <span class="comment"> * after arguments, and os-&gt;argv will be permuted to leave non-option arguments</span>
00145 <span class="comment"> * at the end (the original argv is unaffected).</span>
00146 <span class="comment"> */</span>
00147 APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os,
00148                                           const apr_getopt_option_t *opts,
00149                                           <span class="keywordtype">int</span> *option_ch,
00150                                           const <span class="keywordtype">char</span> **option_arg);<span class="comment"></span>
00151 <span class="comment">/** @} */</span>
00152 
00153 #ifdef __cplusplus
00154 }
00155 #endif
00156 
00157 #endif  <span class="comment">/* ! APR_GETOPT_H */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Mar 20 19:52:26 2005 for Apache Portable Runtime by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
</body>
</html>