<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Universal Software Radio Peripheral: getopt.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>getopt.h</h1><a href="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">/* Declarations for getopt.</span> <a name="l00002"></a>00002 <span class="comment"> Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.</span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> This program is free software; you can redistribute it and/or modify it</span> <a name="l00005"></a>00005 <span class="comment"> under the terms of the GNU General Public License as published by the</span> <a name="l00006"></a>00006 <span class="comment"> Free Software Foundation; either version 3, or (at your option) any</span> <a name="l00007"></a>00007 <span class="comment"> later version.</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> This program is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00012"></a>00012 <span class="comment"> GNU General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment"> You should have received a copy of the GNU General Public License</span> <a name="l00015"></a>00015 <span class="comment"> along with this program; if not, write to the Free Software</span> <a name="l00016"></a>00016 <span class="comment"> Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */</span> <a name="l00017"></a>00017 <a name="l00018"></a>00018 <span class="preprocessor">#ifndef _GETOPT_H</span> <a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define _GETOPT_H 1</span> <a name="l00020"></a>00020 <span class="preprocessor"></span> <a name="l00021"></a>00021 <span class="preprocessor">#ifdef __cplusplus</span> <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { <a name="l00023"></a>00023 <span class="preprocessor">#endif</span> <a name="l00024"></a>00024 <span class="preprocessor"></span> <a name="l00025"></a>00025 <span class="comment">/* For communication from `getopt' to the caller.</span> <a name="l00026"></a>00026 <span class="comment"> When `getopt' finds an option that takes an argument,</span> <a name="l00027"></a>00027 <span class="comment"> the argument value is returned here.</span> <a name="l00028"></a>00028 <span class="comment"> Also, when `ordering' is RETURN_IN_ORDER,</span> <a name="l00029"></a>00029 <span class="comment"> each non-option ARGV-element is returned here. */</span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="keyword">extern</span> <span class="keywordtype">char</span> *<a class="code" href="getopt_8h.html#adb50a0eab9fed92fc3bfc7dfa4f2c410">optarg</a>; <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="comment">/* Index in ARGV of the next element to be scanned.</span> <a name="l00034"></a>00034 <span class="comment"> This is used for communication to and from the caller</span> <a name="l00035"></a>00035 <span class="comment"> and for communication between successive calls to `getopt'.</span> <a name="l00036"></a>00036 <span class="comment"></span> <a name="l00037"></a>00037 <span class="comment"> On entry to `getopt', zero means this is the first call; initialize.</span> <a name="l00038"></a>00038 <span class="comment"></span> <a name="l00039"></a>00039 <span class="comment"> When `getopt' returns EOF, this is the index of the first of the</span> <a name="l00040"></a>00040 <span class="comment"> non-option elements that the caller should itself scan.</span> <a name="l00041"></a>00041 <span class="comment"></span> <a name="l00042"></a>00042 <span class="comment"> Otherwise, `optind' communicates from one call to the next</span> <a name="l00043"></a>00043 <span class="comment"> how much of ARGV has been scanned so far. */</span> <a name="l00044"></a>00044 <a name="l00045"></a>00045 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#ad5e1c16213bbee2d5e8cc363309f418c">optind</a>; <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="comment">/* Callers store zero here to inhibit the error message `getopt' prints</span> <a name="l00048"></a>00048 <span class="comment"> for unrecognized options. */</span> <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#ae30f05ee1e2e5652f174a35c7875d25e">opterr</a>; <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="comment">/* Set to an option character which was unrecognized. */</span> <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a475b8db98445da73e5f62a1ef6324b95">optopt</a>; <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="comment">/* Describe the long-named options requested by the application.</span> <a name="l00057"></a>00057 <span class="comment"> The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector</span> <a name="l00058"></a>00058 <span class="comment"> of `struct option' terminated by an element containing a name which is</span> <a name="l00059"></a>00059 <span class="comment"> zero.</span> <a name="l00060"></a>00060 <span class="comment"></span> <a name="l00061"></a>00061 <span class="comment"> The field `has_arg' is:</span> <a name="l00062"></a>00062 <span class="comment"> no_argument (or 0) if the option does not take an argument,</span> <a name="l00063"></a>00063 <span class="comment"> required_argument (or 1) if the option requires an argument,</span> <a name="l00064"></a>00064 <span class="comment"> optional_argument (or 2) if the option takes an optional argument.</span> <a name="l00065"></a>00065 <span class="comment"></span> <a name="l00066"></a>00066 <span class="comment"> If the field `flag' is not NULL, it points to a variable that is set</span> <a name="l00067"></a>00067 <span class="comment"> to the value given in the field `val' when the option is found, but</span> <a name="l00068"></a>00068 <span class="comment"> left unchanged if the option is not found.</span> <a name="l00069"></a>00069 <span class="comment"></span> <a name="l00070"></a>00070 <span class="comment"> To have a long-named option do something other than set an `int' to</span> <a name="l00071"></a>00071 <span class="comment"> a compiled-in constant, such as set a value from `optarg', set the</span> <a name="l00072"></a>00072 <span class="comment"> option's `flag' field to zero and its `val' field to a nonzero</span> <a name="l00073"></a>00073 <span class="comment"> value (the equivalent single-letter option character, if there is</span> <a name="l00074"></a>00074 <span class="comment"> one). For long options that have a zero `flag' field, `getopt'</span> <a name="l00075"></a>00075 <span class="comment"> returns the contents of the `val' field. */</span> <a name="l00076"></a>00076 <a name="l00077"></a><a class="code" href="structoption.html">00077</a> <span class="keyword">struct </span><a class="code" href="structoption.html">option</a> <a name="l00078"></a>00078 { <a name="l00079"></a>00079 <span class="preprocessor">#if __STDC__</span> <a name="l00080"></a>00080 <span class="preprocessor"></span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structoption.html#a92c850a23c7828c1dba453bf8d15e1f0">name</a>; <a name="l00081"></a>00081 <span class="preprocessor">#else</span> <a name="l00082"></a><a class="code" href="structoption.html#a92c850a23c7828c1dba453bf8d15e1f0">00082</a> <span class="preprocessor"></span> <span class="keywordtype">char</span> *<a class="code" href="structoption.html#a92c850a23c7828c1dba453bf8d15e1f0">name</a>; <a name="l00083"></a>00083 <span class="preprocessor">#endif</span> <a name="l00084"></a>00084 <span class="preprocessor"></span> <span class="comment">/* has_arg can't be an enum because some compilers complain about</span> <a name="l00085"></a>00085 <span class="comment"> type mismatches in all the code that assumes it is an int. */</span> <a name="l00086"></a><a class="code" href="structoption.html#a90d7ee9a51eea5c002682dbd0af149e4">00086</a> <span class="keywordtype">int</span> <a class="code" href="structoption.html#a90d7ee9a51eea5c002682dbd0af149e4">has_arg</a>; <a name="l00087"></a><a class="code" href="structoption.html#ab366eea5fe7be25c1928328ba715e353">00087</a> <span class="keywordtype">int</span> *<a class="code" href="structoption.html#ab366eea5fe7be25c1928328ba715e353">flag</a>; <a name="l00088"></a><a class="code" href="structoption.html#a13bd155ec3b405d29c41ab8d0793be11">00088</a> <span class="keywordtype">int</span> <a class="code" href="structoption.html#a13bd155ec3b405d29c41ab8d0793be11">val</a>; <a name="l00089"></a>00089 }; <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="comment">/* Names for the values of the `has_arg' field of `struct option'. */</span> <a name="l00092"></a>00092 <a name="l00093"></a><a class="code" href="getopt_8h.html#a3bc1d5f667b5b4ca4b4abb685dc874ce">00093</a> <span class="preprocessor">#define no_argument 0</span> <a name="l00094"></a><a class="code" href="getopt_8h.html#a6ece8d8dfa8378778f7290fdaba5b8bc">00094</a> <span class="preprocessor"></span><span class="preprocessor">#define required_argument 1</span> <a name="l00095"></a><a class="code" href="getopt_8h.html#acca06c0a947656bd8b395bf1084ffb72">00095</a> <span class="preprocessor"></span><span class="preprocessor">#define optional_argument 2</span> <a name="l00096"></a>00096 <span class="preprocessor"></span> <a name="l00097"></a>00097 <span class="preprocessor">#if __STDC__</span> <a name="l00098"></a>00098 <span class="preprocessor"></span><span class="preprocessor">#if defined(__GNU_LIBRARY__)</span> <a name="l00099"></a>00099 <span class="preprocessor"></span><span class="comment">/* Many other libraries have conflicting prototypes for getopt, with</span> <a name="l00100"></a>00100 <span class="comment"> differences in the consts, in stdlib.h. To avoid compilation</span> <a name="l00101"></a>00101 <span class="comment"> errors, only prototype getopt for the GNU C library. */</span> <a name="l00102"></a>00102 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a6c5b232cca42dab05f40b47f69715f8b">getopt</a> (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *<span class="keyword">const</span> *argv, <span class="keyword">const</span> <span class="keywordtype">char</span> *shortopts); <a name="l00103"></a>00103 <span class="preprocessor">#else </span><span class="comment">/* not __GNU_LIBRARY__ */</span> <a name="l00104"></a>00104 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a6c5b232cca42dab05f40b47f69715f8b">getopt</a> (); <a name="l00105"></a>00105 <span class="preprocessor">#endif </span><span class="comment">/* not __GNU_LIBRARY__ */</span> <a name="l00106"></a>00106 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a8616b8a74ae6c01a7ad95ad2876226ec">getopt_long</a> (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *<span class="keyword">const</span> *argv, <span class="keyword">const</span> <span class="keywordtype">char</span> *shortopts, <a name="l00107"></a>00107 <span class="keyword">const</span> <span class="keyword">struct</span> <a class="code" href="structoption.html">option</a> *longopts, <span class="keywordtype">int</span> *longind); <a name="l00108"></a>00108 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#ac07930413317507d5c51c19b3ac6ed20">getopt_long_only</a> (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *<span class="keyword">const</span> *argv, <a name="l00109"></a>00109 <span class="keyword">const</span> <span class="keywordtype">char</span> *shortopts, <a name="l00110"></a>00110 <span class="keyword">const</span> <span class="keyword">struct</span> <a class="code" href="structoption.html">option</a> *longopts, <span class="keywordtype">int</span> *longind); <a name="l00111"></a>00111 <a name="l00112"></a>00112 <span class="comment">/* Internal only. Users should not call this directly. */</span> <a name="l00113"></a>00113 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a60428225710059ca135c6b2a8941855f">_getopt_internal</a> (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *<span class="keyword">const</span> *argv, <a name="l00114"></a>00114 <span class="keyword">const</span> <span class="keywordtype">char</span> *shortopts, <a name="l00115"></a>00115 <span class="keyword">const</span> <span class="keyword">struct</span> <a class="code" href="structoption.html">option</a> *longopts, <span class="keywordtype">int</span> *longind, <a name="l00116"></a>00116 <span class="keywordtype">int</span> long_only); <a name="l00117"></a>00117 <span class="preprocessor">#else </span><span class="comment">/* not __STDC__ */</span> <a name="l00118"></a>00118 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a6c5b232cca42dab05f40b47f69715f8b">getopt</a> (); <a name="l00119"></a>00119 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a8616b8a74ae6c01a7ad95ad2876226ec">getopt_long</a> (); <a name="l00120"></a>00120 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#ac07930413317507d5c51c19b3ac6ed20">getopt_long_only</a> (); <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="getopt_8h.html#a60428225710059ca135c6b2a8941855f">_getopt_internal</a> (); <a name="l00123"></a>00123 <span class="preprocessor">#endif </span><span class="comment">/* not __STDC__ */</span> <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="preprocessor">#ifdef __cplusplus</span> <a name="l00126"></a>00126 <span class="preprocessor"></span>} <a name="l00127"></a>00127 <span class="preprocessor">#endif</span> <a name="l00128"></a>00128 <span class="preprocessor"></span> <a name="l00129"></a>00129 <span class="preprocessor">#endif </span><span class="comment">/* _GETOPT_H */</span> </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Dec 29 19:44:19 2010 for Universal Software Radio Peripheral by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>