1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" />
7    <title>GetOpt</title>
8  </head>
9  <body>
10    <h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/dbg/Overview.html">dbg</a>::<a href="../../../nn/dbg/CTR/Overview.html">CTR</a>::GetOpt</CODE> Function</h1>
11    <h2>Syntax</h2>
12    <div class="section">
13      <pre class="definition">#include &lt;nn/dbg.h&gt;
14
15int GetOpt(
16     const char * optstring
17);
18</pre>
19    </div>
20    <h2>Parameters</h2>
21    <div class="section">
22      <table class="arguments">
23        <thead>
24          <tr>
25            <td width="15" />
26            <th>Name</th>
27            <td>Description</td>
28          </tr>
29        </thead>
30        <tr>
31          <td>in</td>
32          <th>optstring</th>
33          <td>Option String</td>
34        </tr> </table>
35    </div>
36    <h2>Return Values</h2>
37    <div class="section">Returns the found option character. Returns -1 if no more option characters are found. </div>
38    <h2>Description</h2>
39    <div class="section">
40      <p>Analyzes options from the argument buffer, stored as a string.</p><P>
41Returns the next option character on each successive call.
42</P><P><SPAN class="argument">optstring</SPAN> is a string for holding the option characters.
43</P><P>
44You must have a parameter argument for the options if there is a : (colon) after the option character. These can be specified successively, such as <CODE>-A 123</CODE>, or all together, such as <CODE>-A123</CODE>. Call <CODE><a href="../../../nn/dbg/CTR/GetOptArg.html">nn::dbg::CTR::GetOptArg</a></CODE> to get parameter arguments.
45</P><P>
46You can include or not include a parameter argument for the options if there is a :: (double colon) after the option character. Call <CODE><a href="../../../nn/dbg/CTR/GetOptArg.html">nn::dbg::CTR::GetOptArg</a></CODE> to get parameter arguments when you are using them.
47</P><P>
48The function returns ? (a question mark) for any option characters that cannot be interpreted. Call <CODE><a href="../../../nn/dbg/CTR/GetOptOpt.html">nn::dbg::CTR::GetOptOpt</a></CODE> to get these characters.
49</P><PRE>
50Example
51
52int c;
53const char* str;
54while( (c = <font color="red">nn::dbg::CTR::GetOpt(&quot;AB:C::&quot;)</font>) &gt; 0 )
55{
56    switch (c)
57   {
58   case 'A':
59       NN_LOG(&quot;*** Found option A\n&quot;);
60       break;
61   case 'B':
62       if ( (str = nn::dbg::CTR::GetOptArg()) )
63       {
64           NN_LOG(&quot;*** Found option B with %s\n&quot;, str);
65       }
66       <CODE>else</CODE>
67       {
68           NN_LOG(&quot;*** Found option B\n&quot;);
69       }
70       break;
71   case 'C':
72       if ( (str = nn::dbg::CTR::GetOptArg()) )
73       {
74           NN_LOG(&quot;*** Found option C with %s\n&quot;, str);
75       }
76       <CODE>else</CODE>
77       {
78           NN_LOG(&quot;*** Found option B\n&quot;);
79       }
80       break;
81   case '?':
82   default:
83       NN_LOG(&quot;*** Unknown option %c\n&quot;, nn::dbg::CTR::GetOptOpt() );
84   }
85}
86</PRE><P>
87  Always returns -1 in release builds.
88</P></div>
89    <h2>Revision History</h2>
90    <div class="section">
91      <dl class="history">
92        <dt>2011/12/14</dt>
93        <dd>Initial version.<br />
94        </dd>
95      </dl>
96    </div>
97  <hr><p>CONFIDENTIAL</p></body>
98</html>