Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sys_getopt.h File Reference
#include <zephyr/kernel.h>

Go to the source code of this file.

Data Structures

struct  sys_getopt_state
struct  sys_getopt_option

Macros

#define sys_getopt_no_argument   0
#define sys_getopt_required_argument   1
#define sys_getopt_optional_argument   2

Functions

void sys_getopt_init (void)
struct sys_getopt_statesys_getopt_state_get (void)
int sys_getopt (int nargc, char *const nargv[], const char *ostr)
 Parses the command-line arguments.
int sys_getopt_long (int nargc, char *const *nargv, const char *options, const struct sys_getopt_option *long_options, int *idx)
 Parses the command-line arguments.
int sys_getopt_long_only (int nargc, char *const *nargv, const char *options, const struct sys_getopt_option *long_options, int *idx)
 Parses the command-line arguments.

Variables

int sys_getopt_optreset
char * sys_getopt_optarg
int sys_getopt_opterr
int sys_getopt_optind
int sys_getopt_optopt

Macro Definition Documentation

◆ sys_getopt_no_argument

#define sys_getopt_no_argument   0

◆ sys_getopt_optional_argument

#define sys_getopt_optional_argument   2

◆ sys_getopt_required_argument

#define sys_getopt_required_argument   1

Function Documentation

◆ sys_getopt()

int sys_getopt ( int nargc,
char *const nargv[],
const char * ostr )

Parses the command-line arguments.

Note
This function is based on FreeBSD implementation but it does not support environment variable: POSIXLY_CORRECT.
Parameters
[in]nargcArguments count.
[in]nargvArguments.
[in]ostrString containing the legitimate option characters.
Returns
If an option was successfully found, function returns the option character.

◆ sys_getopt_init()

void sys_getopt_init ( void )

◆ sys_getopt_long()

int sys_getopt_long ( int nargc,
char *const * nargv,
const char * options,
const struct sys_getopt_option * long_options,
int * idx )

Parses the command-line arguments.

The sys_getopt_long() function works like sys_getopt() except it also accepts long options, started with two dashes.

Note
This function is based on FreeBSD implementation but it does not support environment variable: POSIXLY_CORRECT.
Parameters
[in]nargcArguments count.
[in]nargvArguments.
[in]optionsString containing the legitimate option characters.
[in]long_optionsPointer to the first element of an array of struct sys_getopt_option.
[in]idxIf idx is not NULL, it points to a variable which is set to the index of the long option relative to long_options.
Returns
If an option was successfully found, function returns the option character.

◆ sys_getopt_long_only()

int sys_getopt_long_only ( int nargc,
char *const * nargv,
const char * options,
const struct sys_getopt_option * long_options,
int * idx )

Parses the command-line arguments.

The sys_getopt_long_only() function works like sys_getopt_long(), but '-' as well as "--" can indicate a long option. If an option that starts with '-' (not "--") doesn't match a long option, but does match a short option, it is parsed as a short option instead.

Note
This function is based on FreeBSD implementation but it does not support environment variable: POSIXLY_CORRECT.
Parameters
[in]nargcArguments count.
[in]nargvArguments.
[in]optionsString containing the legitimate option characters.
[in]long_optionsPointer to the first element of an array of struct sys_getopt_option.
[in]idxIf idx is not NULL, it points to a variable which is set to the index of the long option relative to long_options.
Returns
If an option was successfully found, function returns the option character.

◆ sys_getopt_state_get()

struct sys_getopt_state * sys_getopt_state_get ( void )

Variable Documentation

◆ sys_getopt_optarg

char* sys_getopt_optarg
extern

◆ sys_getopt_opterr

int sys_getopt_opterr
extern

◆ sys_getopt_optind

int sys_getopt_optind
extern

◆ sys_getopt_optopt

int sys_getopt_optopt
extern

◆ sys_getopt_optreset

int sys_getopt_optreset
extern