nn::dbg::CTR::GetOpt Function#include <nn/dbg.h>
int GetOpt(
const char * optstring
);
| Name | Description | |
|---|---|---|
| in | optstring | Option String |
Analyzes options from the argument buffer, stored as a string.
Returns the next option character on each successive call.
optstring is a string for holding the option characters.
You must have a parameter argument for the options if there is a : (colon) after the option character. These can be specified successively, such as -A 123, or all together, such as -A123. Call nn::dbg::CTR::GetOptArg to get parameter arguments.
You can include or not include a parameter argument for the options if there is a :: (double colon) after the option character. Call nn::dbg::CTR::GetOptArg to get parameter arguments when you are using them.
The function returns ? (a question mark) for any option characters that cannot be interpreted. Call nn::dbg::CTR::GetOptOpt to get these characters.
Example
int c;
const char* str;
while( (c = nn::dbg::CTR::GetOpt("AB:C::")) > 0 )
{
switch (c)
{
case 'A':
NN_LOG("*** Found option A\n");
break;
case 'B':
if ( (str = nn::dbg::CTR::GetOptArg()) )
{
NN_LOG("*** Found option B with %s\n", str);
}
else
{
NN_LOG("*** Found option B\n");
}
break;
case 'C':
if ( (str = nn::dbg::CTR::GetOptArg()) )
{
NN_LOG("*** Found option C with %s\n", str);
}
else
{
NN_LOG("*** Found option B\n");
}
break;
case '?':
default:
NN_LOG("*** Unknown option %c\n", nn::dbg::CTR::GetOptOpt() );
}
}
Always returns -1 in release builds.
CONFIDENTIAL