Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > bdbf07027827e6ad7d9208f8a9eaea97 > files > 28

apr-docs-1.2.7-11.el5_6.5.x86_64.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">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></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"><a name="l00001"></a>00001 <span class="comment">/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as</span>
<a name="l00002"></a>00002 <span class="comment"> * applicable.</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> * you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> * You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *     http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> * See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> * limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef APR_GETOPT_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define APR_GETOPT_H</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00020"></a>00020 <span class="comment">/**</span>
<a name="l00021"></a>00021 <span class="comment"> * @file apr_getopt.h</span>
<a name="l00022"></a>00022 <span class="comment"> * @brief APR Command Arguments (getopt)</span>
<a name="l00023"></a>00023 <span class="comment"> */</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
<a name="l00029"></a>00029 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span>
<a name="l00030"></a>00030 <span class="comment"></span>
<a name="l00031"></a>00031 <span class="comment">/**</span>
<a name="l00032"></a>00032 <span class="comment"> * @defgroup apr_getopt Command Argument Parsing</span>
<a name="l00033"></a>00033 <span class="comment"> * @ingroup APR </span>
<a name="l00034"></a>00034 <span class="comment"> * @{</span>
<a name="l00035"></a>00035 <span class="comment"> */</span>
<a name="l00036"></a>00036 <span class="comment"></span>
<a name="l00037"></a>00037 <span class="comment">/** </span>
<a name="l00038"></a>00038 <span class="comment"> * defintion of a error function </span>
<a name="l00039"></a>00039 <span class="comment"> */</span>
<a name="l00040"></a><a class="code" href="group__apr__getopt.html#g87430c13f1899c2ffae847db8c4b585d">00040</a> <span class="keyword">typedef</span> void (<a class="code" href="group__apr__getopt.html#g87430c13f1899c2ffae847db8c4b585d">apr_getopt_err_fn_t</a>)(<span class="keywordtype">void</span> *arg, <span class="keyword">const</span> <span class="keywordtype">char</span> *err, ...);
<a name="l00041"></a>00041 <span class="comment"></span>
<a name="l00042"></a>00042 <span class="comment">/** @see apr_getopt_t */</span>
<a name="l00043"></a><a class="code" href="group__apr__getopt.html#gcbc9bec15d6cec880fecef31abc98bcb">00043</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#gcbc9bec15d6cec880fecef31abc98bcb">apr_getopt_t</a>;
<a name="l00044"></a>00044 <span class="comment"></span>
<a name="l00045"></a>00045 <span class="comment">/**</span>
<a name="l00046"></a>00046 <span class="comment"> * Structure to store command line argument information.</span>
<a name="l00047"></a>00047 <span class="comment"> */</span> 
<a name="l00048"></a><a class="code" href="structapr__getopt__t.html">00048</a> <span class="keyword">struct </span><a class="code" href="group__apr__getopt.html#gcbc9bec15d6cec880fecef31abc98bcb">apr_getopt_t</a> {<span class="comment"></span>
<a name="l00049"></a>00049 <span class="comment">    /** context for processing */</span>
<a name="l00050"></a><a class="code" href="structapr__getopt__t.html#c37f219d003c8fe5d00a15b106aeae33">00050</a>     <a class="code" href="group__apr__pools.html#g06f17a7732f2d04d8ce7010fbb057a8b">apr_pool_t</a> *<a class="code" href="structapr__getopt__t.html#c37f219d003c8fe5d00a15b106aeae33">cont</a>;<span class="comment"></span>
<a name="l00051"></a>00051 <span class="comment">    /** function to print error message (NULL == no messages) */</span>
<a name="l00052"></a><a class="code" href="structapr__getopt__t.html#9b3513f0dce21351d9532e1fc71faed6">00052</a>     <a class="code" href="group__apr__getopt.html#g87430c13f1899c2ffae847db8c4b585d">apr_getopt_err_fn_t</a> *<a class="code" href="structapr__getopt__t.html#9b3513f0dce21351d9532e1fc71faed6">errfn</a>;<span class="comment"></span>
<a name="l00053"></a>00053 <span class="comment">    /** user defined first arg to pass to error message  */</span>
<a name="l00054"></a><a class="code" href="structapr__getopt__t.html#e78b05aa39e73920bc8f31d36c3af252">00054</a>     <span class="keywordtype">void</span> *<a class="code" href="structapr__getopt__t.html#e78b05aa39e73920bc8f31d36c3af252">errarg</a>;<span class="comment"></span>
<a name="l00055"></a>00055 <span class="comment">    /** index into parent argv vector */</span>
<a name="l00056"></a><a class="code" href="structapr__getopt__t.html#8d3c3883230e1effed7f28aa3164212c">00056</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__t.html#8d3c3883230e1effed7f28aa3164212c">ind</a>;<span class="comment"></span>
<a name="l00057"></a>00057 <span class="comment">    /** character checked for validity */</span>
<a name="l00058"></a><a class="code" href="structapr__getopt__t.html#a1926f5c7de2206c7225223d30c19b04">00058</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__t.html#a1926f5c7de2206c7225223d30c19b04">opt</a>;<span class="comment"></span>
<a name="l00059"></a>00059 <span class="comment">    /** reset getopt */</span>
<a name="l00060"></a><a class="code" href="structapr__getopt__t.html#fdcd7383ef2920a5d0998d5e003e4f24">00060</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__t.html#fdcd7383ef2920a5d0998d5e003e4f24">reset</a>;<span class="comment"></span>
<a name="l00061"></a>00061 <span class="comment">    /** count of arguments */</span>
<a name="l00062"></a><a class="code" href="structapr__getopt__t.html#42d33812f24bbf29c90baef2ead8258b">00062</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__t.html#42d33812f24bbf29c90baef2ead8258b">argc</a>;<span class="comment"></span>
<a name="l00063"></a>00063 <span class="comment">    /** array of pointers to arguments */</span>
<a name="l00064"></a><a class="code" href="structapr__getopt__t.html#4013f973da80a6a2bd0161d25e3d5a83">00064</a>     <span class="keyword">const</span> <span class="keywordtype">char</span> **<a class="code" href="structapr__getopt__t.html#4013f973da80a6a2bd0161d25e3d5a83">argv</a>;<span class="comment"></span>
<a name="l00065"></a>00065 <span class="comment">    /** argument associated with option */</span>
<a name="l00066"></a><a class="code" href="structapr__getopt__t.html#45c1cb9286a522323506ade8a1d13531">00066</a>     <span class="keywordtype">char</span> <span class="keyword">const</span>* <a class="code" href="structapr__getopt__t.html#45c1cb9286a522323506ade8a1d13531">place</a>;<span class="comment"></span>
<a name="l00067"></a>00067 <span class="comment">    /** set to nonzero to support interleaving options with regular args */</span>
<a name="l00068"></a><a class="code" href="structapr__getopt__t.html#af72387be0795ffb73ffe4a6611e8123">00068</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__t.html#af72387be0795ffb73ffe4a6611e8123">interleave</a>;<span class="comment"></span>
<a name="l00069"></a>00069 <span class="comment">    /** start of non-option arguments skipped for interleaving */</span>
<a name="l00070"></a><a class="code" href="structapr__getopt__t.html#7cc4478f9cf69945acfc9c0e5ad2f4f7">00070</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__t.html#7cc4478f9cf69945acfc9c0e5ad2f4f7">skip_start</a>;<span class="comment"></span>
<a name="l00071"></a>00071 <span class="comment">    /** end of non-option arguments skipped for interleaving */</span>
<a name="l00072"></a><a class="code" href="structapr__getopt__t.html#7ddcb3a7d13ff55d7754f4a6e3210c0c">00072</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__t.html#7ddcb3a7d13ff55d7754f4a6e3210c0c">skip_end</a>;
<a name="l00073"></a>00073 };
<a name="l00074"></a>00074 <span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">/** @see apr_getopt_option_t */</span>
<a name="l00076"></a><a class="code" href="group__apr__getopt.html#gde59c9a23f085e8b3316d27015de6f8c">00076</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#gde59c9a23f085e8b3316d27015de6f8c">apr_getopt_option_t</a>;
<a name="l00077"></a>00077 <span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment">/**</span>
<a name="l00079"></a>00079 <span class="comment"> * Structure used to describe options that getopt should search for.</span>
<a name="l00080"></a>00080 <span class="comment"> */</span>
<a name="l00081"></a><a class="code" href="structapr__getopt__option__t.html">00081</a> <span class="keyword">struct </span><a class="code" href="group__apr__getopt.html#gde59c9a23f085e8b3316d27015de6f8c">apr_getopt_option_t</a> {<span class="comment"></span>
<a name="l00082"></a>00082 <span class="comment">    /** long option name, or NULL if option has no long name */</span>
<a name="l00083"></a><a class="code" href="structapr__getopt__option__t.html#dd409114a2cb7df741d7f5c096667eb8">00083</a>     <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structapr__getopt__option__t.html#dd409114a2cb7df741d7f5c096667eb8">name</a>;<span class="comment"></span>
<a name="l00084"></a>00084 <span class="comment">    /** option letter, or a value greater than 255 if option has no letter */</span>
<a name="l00085"></a><a class="code" href="structapr__getopt__option__t.html#f8d96ca69126e45f6b4070ce2ef8e746">00085</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__option__t.html#f8d96ca69126e45f6b4070ce2ef8e746">optch</a>;<span class="comment"></span>
<a name="l00086"></a>00086 <span class="comment">    /** nonzero if option takes an argument */</span>
<a name="l00087"></a><a class="code" href="structapr__getopt__option__t.html#53c2409f4fce1a9ac6bb91c462ad293e">00087</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__getopt__option__t.html#53c2409f4fce1a9ac6bb91c462ad293e">has_arg</a>;<span class="comment"></span>
<a name="l00088"></a>00088 <span class="comment">    /** a description of the option */</span>
<a name="l00089"></a><a class="code" href="structapr__getopt__option__t.html#ffdef1958066edb9c34f0cb40d98342c">00089</a>     <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structapr__getopt__option__t.html#ffdef1958066edb9c34f0cb40d98342c">description</a>;
<a name="l00090"></a>00090 };
<a name="l00091"></a>00091 <span class="comment"></span>
<a name="l00092"></a>00092 <span class="comment">/**</span>
<a name="l00093"></a>00093 <span class="comment"> * Initialize the arguments for parsing by apr_getopt().</span>
<a name="l00094"></a>00094 <span class="comment"> * @param os   The options structure created for apr_getopt()</span>
<a name="l00095"></a>00095 <span class="comment"> * @param cont The pool to operate on</span>
<a name="l00096"></a>00096 <span class="comment"> * @param argc The number of arguments to parse</span>
<a name="l00097"></a>00097 <span class="comment"> * @param argv The array of arguments to parse</span>
<a name="l00098"></a>00098 <span class="comment"> * @remark Arguments 2 and 3 are most commonly argc and argv from main(argc, argv)</span>
<a name="l00099"></a>00099 <span class="comment"> * The errfn is initialized to fprintf(stderr... but may be overridden.</span>
<a name="l00100"></a>00100 <span class="comment"> */</span>
<a name="l00101"></a>00101 <a class="code" href="group__apr__platform.html#g4a5cbc739c4e19ab450020163d0899d4">APR_DECLARE</a>(<a class="code" href="group__apr__errno.html#g4cf2ddae3efce70c508ac7fefc1c47f7">apr_status_t</a>) <a class="code" href="group__apr__getopt.html#gca3f4f3be0eb2e847c02e3af6c529e8c">apr_getopt_init</a>(<a class="code" href="group__apr__getopt.html#gcbc9bec15d6cec880fecef31abc98bcb">apr_getopt_t</a> **os, <a class="code" href="group__apr__pools.html#g06f17a7732f2d04d8ce7010fbb057a8b">apr_pool_t</a> *cont,
<a name="l00102"></a>00102                                       <span class="keywordtype">int</span> argc, const <span class="keywordtype">char</span> * const *argv);
<a name="l00103"></a>00103 <span class="comment"></span>
<a name="l00104"></a>00104 <span class="comment">/**</span>
<a name="l00105"></a>00105 <span class="comment"> * Parse the options initialized by apr_getopt_init().</span>
<a name="l00106"></a>00106 <span class="comment"> * @param os     The apr_opt_t structure returned by apr_getopt_init()</span>
<a name="l00107"></a>00107 <span class="comment"> * @param opts   A string of characters that are acceptable options to the </span>
<a name="l00108"></a>00108 <span class="comment"> *               program.  Characters followed by ":" are required to have an </span>
<a name="l00109"></a>00109 <span class="comment"> *               option associated</span>
<a name="l00110"></a>00110 <span class="comment"> * @param option_ch  The next option character parsed</span>
<a name="l00111"></a>00111 <span class="comment"> * @param option_arg The argument following the option character:</span>
<a name="l00112"></a>00112 <span class="comment"> * @return There are four potential status values on exit. They are:</span>
<a name="l00113"></a>00113 <span class="comment"> * &lt;PRE&gt;</span>
<a name="l00114"></a>00114 <span class="comment"> *             APR_EOF      --  No more options to parse</span>
<a name="l00115"></a>00115 <span class="comment"> *             APR_BADCH    --  Found a bad option character</span>
<a name="l00116"></a>00116 <span class="comment"> *             APR_BADARG   --  No argument followed the option flag</span>
<a name="l00117"></a>00117 <span class="comment"> *             APR_SUCCESS  --  The next option was found.</span>
<a name="l00118"></a>00118 <span class="comment"> * &lt;/PRE&gt;</span>
<a name="l00119"></a>00119 <span class="comment"> */</span>
<a name="l00120"></a>00120 <a class="code" href="group__apr__platform.html#g4a5cbc739c4e19ab450020163d0899d4">APR_DECLARE</a>(<a class="code" href="group__apr__errno.html#g4cf2ddae3efce70c508ac7fefc1c47f7">apr_status_t</a>) <a class="code" href="group__apr__getopt.html#gbfd6c4ca03eff6fac2bea385fda08372">apr_getopt</a>(<a class="code" href="group__apr__getopt.html#gcbc9bec15d6cec880fecef31abc98bcb">apr_getopt_t</a> *os, const <span class="keywordtype">char</span> *opts, 
<a name="l00121"></a>00121                                      <span class="keywordtype">char</span> *option_ch, const <span class="keywordtype">char</span> **option_arg);
<a name="l00122"></a>00122 <span class="comment"></span>
<a name="l00123"></a>00123 <span class="comment">/**</span>
<a name="l00124"></a>00124 <span class="comment"> * Parse the options initialized by apr_getopt_init(), accepting long</span>
<a name="l00125"></a>00125 <span class="comment"> * options beginning with "--" in addition to single-character</span>
<a name="l00126"></a>00126 <span class="comment"> * options beginning with "-".</span>
<a name="l00127"></a>00127 <span class="comment"> * @param os     The apr_getopt_t structure created by apr_getopt_init()</span>
<a name="l00128"></a>00128 <span class="comment"> * @param opts   A pointer to a list of apr_getopt_option_t structures, which</span>
<a name="l00129"></a>00129 <span class="comment"> *               can be initialized with { "name", optch, has_args }.  has_args</span>
<a name="l00130"></a>00130 <span class="comment"> *               is nonzero if the option requires an argument.  A structure</span>
<a name="l00131"></a>00131 <span class="comment"> *               with an optch value of 0 terminates the list.</span>
<a name="l00132"></a>00132 <span class="comment"> * @param option_ch  Receives the value of "optch" from the apr_getopt_option_t</span>
<a name="l00133"></a>00133 <span class="comment"> *                   structure corresponding to the next option matched.</span>
<a name="l00134"></a>00134 <span class="comment"> * @param option_arg Receives the argument following the option, if any.</span>
<a name="l00135"></a>00135 <span class="comment"> * @return There are four potential status values on exit.   They are:</span>
<a name="l00136"></a>00136 <span class="comment"> * &lt;PRE&gt;</span>
<a name="l00137"></a>00137 <span class="comment"> *             APR_EOF      --  No more options to parse</span>
<a name="l00138"></a>00138 <span class="comment"> *             APR_BADCH    --  Found a bad option character</span>
<a name="l00139"></a>00139 <span class="comment"> *             APR_BADARG   --  No argument followed the option flag</span>
<a name="l00140"></a>00140 <span class="comment"> *             APR_SUCCESS  --  The next option was found.</span>
<a name="l00141"></a>00141 <span class="comment"> * &lt;/PRE&gt;</span>
<a name="l00142"></a>00142 <span class="comment"> * When APR_SUCCESS is returned, os-&gt;ind gives the index of the first</span>
<a name="l00143"></a>00143 <span class="comment"> * non-option argument.  On error, a message will be printed to stdout unless</span>
<a name="l00144"></a>00144 <span class="comment"> * os-&gt;err is set to 0.  If os-&gt;interleave is set to nonzero, options can come</span>
<a name="l00145"></a>00145 <span class="comment"> * after arguments, and os-&gt;argv will be permuted to leave non-option arguments</span>
<a name="l00146"></a>00146 <span class="comment"> * at the end (the original argv is unaffected).</span>
<a name="l00147"></a>00147 <span class="comment"> */</span>
<a name="l00148"></a>00148 <a class="code" href="group__apr__platform.html#g4a5cbc739c4e19ab450020163d0899d4">APR_DECLARE</a>(<a class="code" href="group__apr__errno.html#g4cf2ddae3efce70c508ac7fefc1c47f7">apr_status_t</a>) <a class="code" href="group__apr__getopt.html#g3f58acc4bf065e91300ca6d92e588a39">apr_getopt_long</a>(<a class="code" href="group__apr__getopt.html#gcbc9bec15d6cec880fecef31abc98bcb">apr_getopt_t</a> *os,
<a name="l00149"></a>00149                                           const <a class="code" href="group__apr__getopt.html#gde59c9a23f085e8b3316d27015de6f8c">apr_getopt_option_t</a> *opts,
<a name="l00150"></a>00150                                           <span class="keywordtype">int</span> *option_ch,
<a name="l00151"></a>00151                                           const <span class="keywordtype">char</span> **option_arg);<span class="comment"></span>
<a name="l00152"></a>00152 <span class="comment">/** @} */</span>
<a name="l00153"></a>00153 
<a name="l00154"></a>00154 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00155"></a>00155 <span class="preprocessor"></span>}
<a name="l00156"></a>00156 <span class="preprocessor">#endif</span>
<a name="l00157"></a>00157 <span class="preprocessor"></span>
<a name="l00158"></a>00158 <span class="preprocessor">#endif  </span><span class="comment">/* ! APR_GETOPT_H */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue May 31 12:20:26 2011 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.4.7 </small></address>
</body>
</html>