217 lines
14 KiB
HTML
217 lines
14 KiB
HTML
<!-- HTML header for doxygen 1.9.1-->
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.15.0"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>L4Re Operating System Framework: Comfortable Command Line Parsing</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript" src="cookie.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
|
<link href="l4re-awesome.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><img alt="Logo" src="L4Re_rgb_logo_quer_hg_h55.png"/></td>
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">L4Re Operating System Framework
|
|
</div>
|
|
<div id="projectbrief">Interface and Usage Documentation</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.15.0 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
|
</script>
|
|
<script type="text/javascript">
|
|
$(function() { codefold.init(); });
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search',true);
|
|
$(function() { init_search(); });
|
|
});
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(function(){initNavTree('group__l4util__parse__cmd.html','',''); });
|
|
</script>
|
|
<div id="container">
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<div id="MSearchResults">
|
|
<div class="SRPage">
|
|
<div id="SRIndex">
|
|
<div id="SRResults"></div>
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="headertitle"><div class="title">Comfortable Command Line Parsing <div class="ingroups"><a class="el" href="group__l4util__api.html">Utility Functions</a></div></div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div id="dynsection-0" onclick="return dynsection.toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;"><span class="dynarrow"><span class="arrowhead closed"></span></span>Collaboration diagram for Comfortable Command Line Parsing:</div>
|
|
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
|
|
</div>
|
|
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
|
|
<div class="center"><iframe scrolling="no" loading="lazy" frameborder="0" src="group__l4util__parse__cmd.svg" width="362" height="51"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
|
</div>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 id="header-typedef-members" class="groupheader"><a id="typedef-members" name="typedef-members"></a>
|
|
Typedefs</h2></td></tr>
|
|
<tr class="memitem:ga774256a7fd39750e4f13fe551b210c00" id="r_ga774256a7fd39750e4f13fe551b210c00"><td class="memItemLeft" align="right" valign="top"><a id="ga774256a7fd39750e4f13fe551b210c00" name="ga774256a7fd39750e4f13fe551b210c00"></a>
|
|
typedef void(* </td><td class="memItemRight" valign="bottom"><b>parse_cmd_fn_t</b>) (int)</td></tr>
|
|
<tr class="memdesc:ga774256a7fd39750e4f13fe551b210c00"><td class="mdescLeft"> </td><td class="mdescRight">Function type for PARSE_CMD_FN. <br /></td></tr>
|
|
<tr class="memitem:ga2c9ca2e2a7f84e57c24ccd1a1f4762fb" id="r_ga2c9ca2e2a7f84e57c24ccd1a1f4762fb"><td class="memItemLeft" align="right" valign="top"><a id="ga2c9ca2e2a7f84e57c24ccd1a1f4762fb" name="ga2c9ca2e2a7f84e57c24ccd1a1f4762fb"></a>
|
|
typedef void(* </td><td class="memItemRight" valign="bottom"><b>parse_cmd_fn_arg_t</b>) (int, const char *, int)</td></tr>
|
|
<tr class="memdesc:ga2c9ca2e2a7f84e57c24ccd1a1f4762fb"><td class="mdescLeft"> </td><td class="mdescRight">Function type for PARSE_CMD_FN_ARG. <br /></td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 id="header-enum-members" class="groupheader"><a id="enum-members" name="enum-members"></a>
|
|
Enumerations</h2></td></tr>
|
|
<tr class="memitem:ga95882b4ad46d2a3e56ceb487044fb388" id="r_ga95882b4ad46d2a3e56ceb487044fb388"><td class="memItemLeft" align="right" valign="top"><a id="ga95882b4ad46d2a3e56ceb487044fb388" name="ga95882b4ad46d2a3e56ceb487044fb388"></a>enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga95882b4ad46d2a3e56ceb487044fb388">parse_cmd_type</a> </td></tr>
|
|
<tr class="memdesc:ga95882b4ad46d2a3e56ceb487044fb388"><td class="mdescLeft"> </td><td class="mdescRight">Types for parsing. <br /></td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:ga026cecb11cc929061d1e901c7c9eeeba" id="r_ga026cecb11cc929061d1e901c7c9eeeba"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__l4sys__defines.html#ga5f022ce5422df9cc6ed415e2bfc90f59">L4_BEGIN_DECLS</a> int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga026cecb11cc929061d1e901c7c9eeeba">parse_cmdline</a> (int *argc, const char ***argv, int arg0,...)</td></tr>
|
|
<tr class="memdesc:ga026cecb11cc929061d1e901c7c9eeeba"><td class="mdescLeft"> </td><td class="mdescRight">Parse the command-line for specified arguments and store the values into variables. <br /></td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
|
|
<a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
|
|
<a id="ga026cecb11cc929061d1e901c7c9eeeba" name="ga026cecb11cc929061d1e901c7c9eeeba"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga026cecb11cc929061d1e901c7c9eeeba">◆ </a></span>parse_cmdline()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="group__l4sys__defines.html#ga5f022ce5422df9cc6ed415e2bfc90f59">L4_BEGIN_DECLS</a> int parse_cmdline </td>
|
|
<td>(</td>
|
|
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>argc</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const char ***</td> <td class="paramname"><span class="paramname"><em>argv</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>arg0</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"></td> <td class="paramname"><span class="paramname"><em>...</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Parse the command-line for specified arguments and store the values into variables. </p>
|
|
<p>This Functions gets the command-line, and a list of command-descriptors. Then, the command-line is parsed according to the given descriptors, storing strings, switches and numeric arguments at given addresses, and possibly calling specified functions. A default help descriptor is added. Its purpose is to present a short command overview in the case the given command-line does not fit to the descriptors.</p>
|
|
<p>Each command-descriptor has the following form:</p>
|
|
<p><em>short</em> <em>option</em> <em>char</em>, <em>long</em> <em>option</em> <em>name</em>, <em>comment</em>, <em>type</em>, <em>val</em>, <em>addr</em>.</p>
|
|
<p>The <em>short</em> <em>option</em> <em>char</em> specifies the short form of the described option. The short form will be recognized after a single dash, or in a group of short options preceeded by a single dash. Specify ' ' if no short form should be used.</p>
|
|
<p>The <em>long</em> <em>option</em> <em>name</em> specifies the long form of the described option. The long form will be recognized after two dashes. Specify 0 if no long form should be used for this option.</p>
|
|
<p>The <em>comment</em> is a string that will be used when presenting the short command-line help.</p>
|
|
<p>The <em>type</em> specifies, if the option should be recognized as</p><ul>
|
|
<li>a number (<code>PARSE_CMD_INT</code>),</li>
|
|
<li>a switch (<code>PARSE_CMD_SWITCH</code>),</li>
|
|
<li>a string (<code>PARSE_CMD_STRING</code>),</li>
|
|
<li>a function call (<code>PARSE_CMD_FN</code>, <code>PARSE_CMD_FN_ARG</code>),</li>
|
|
<li>an increment/decrement operator (<code>PARSE_CMD_INC</code>, <code>PARSE_CMD_DEC</code>).</li>
|
|
</ul>
|
|
<p>If type is <code>PARSE_CMD_INT</code>, the option requires a second argument on the command-line after the option. This argument is parsed as a number. It can be preceeded by 0x to present a hex-value or by 0 to present an octal form. <em>addr</em> is interpreted as an int-pointer. The scanned argument from the command-line is stored in this pointer.</p>
|
|
<p>If <em>type</em> is <code>PARSE_CMD_SWITCH</code>, <em>addr</em> must be a pointer to int, and the value from <em>val</em> is stored at this pointer.</p>
|
|
<p>With <code>PARSE_CMD_STRING</code>, an additional argument is expected at the cmdline. <em>addr</em> must be a pointer to const char*, and a pointer to the argument on the command line is stored at this pointer. The value in <em>val</em> is a default value, which is stored at <em>addr</em> if the corresponding option is not given on the command line.</p>
|
|
<p>With <code>PARSE_CMD_FN_ARG</code>, <em>addr</em> is interpreted as a function pointer of type <a class="el" href="#ga774256a7fd39750e4f13fe551b210c00" title="Function type for PARSE_CMD_FN.">parse_cmd_fn_t</a>. It will be called with <em>val</em> as argument if the corresponding option is found.</p>
|
|
<p>If <em>type</em> is <code>PARSE_CMD_FN_ARG</code>, <em>addr</em> is as a function pointer of type <a class="el" href="#ga2c9ca2e2a7f84e57c24ccd1a1f4762fb" title="Function type for PARSE_CMD_FN_ARG.">parse_cmd_fn_arg_t</a>, and handled similar to <code>PARSE_CMD_FN</code>. An additional argument is expected at the command line, however. It is given to the called function as 2nd argument, and parsed as an integer as with <code>PARSE_CMD_INT</code> as a third argument.</p>
|
|
<p>If <em>type</em> is <code>PARSE_CMD_INC</code> or <code>PARSE_CMD_DEC</code>, <em>addr</em> is interpreted as an int-pointer. The value of <em>val</em> is stored to this pointer first. For every occurence of the option in the command line, the integer referenced by <em>addr</em> is incremented or decremented, respectively.</p>
|
|
<p>The list of command-descriptors is terminated by specifying a binary 0 for the short option char.</p>
|
|
<p>Note: The short option char 'h' and the long option name "help" must not be specified. They are used for the default help descriptor and produce a short command-options help when specified on the command-line.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">argc</td><td>pointer to number of command line parameters as passed to main </td></tr>
|
|
<tr><td class="paramname">argv</td><td>pointer to array of command line parameters as passed to main </td></tr>
|
|
<tr><td class="paramname">arg0</td><td>format list describing the command line options to parse for </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>0 if the command-line was successfully parsed, otherwise:<ul>
|
|
<li>-1 if the given descriptors are somehow wrong.</li>
|
|
<li>-2 if not enough memory was available to hold temporary structs.</li>
|
|
<li>-3 if the given command-line args did not meet the specified set.</li>
|
|
<li>-4 if the help-option was given.</li>
|
|
</ul>
|
|
</dd></dl>
|
|
<p>Upon return, argc and argv point to a list of arguments that were not scanned as arguments. See <code>getoptlong</code> for details on scanning. </p>
|
|
|
|
<p class="reference">References <a class="el" href="arm_2l4_2sys_2linkage_8h_source.html#l00033">L4_CV</a>, and <a class="el" href="compiler_8h_source.html#l00166">L4_END_DECLS</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<div id="page-nav" class="page-nav-panel">
|
|
<div id="page-nav-resize-handle"></div>
|
|
<div id="page-nav-tree">
|
|
<div id="page-nav-contents">
|
|
</div><!-- page-nav-contents -->
|
|
</div><!-- page-nav-tree -->
|
|
</div><!-- page-nav -->
|
|
</div><!-- container -->
|
|
<!-- HTML footer for doxygen 1.9.1-->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="footer">Generated on <span class="timestamp"></span> for L4Re Operating System Framework by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.15.0 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|