Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sys_getopt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_SYS_GETOPT_H_
8#define ZEPHYR_INCLUDE_SYS_GETOPT_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include <zephyr/kernel.h>
15
17 int opterr; /* if error message should be printed */
18 int optind; /* index into parent argv vector */
19 int optopt; /* character checked for validity */
20 int optreset; /* reset getopt */
21 char *optarg; /* argument associated with option */
22
23 char *place; /* option letter processing */
24
25#if CONFIG_GETOPT_LONG
26 int nonopt_start;
27 int nonopt_end;
28#endif
29};
30
31extern int sys_getopt_optreset; /* reset getopt */
32extern char *sys_getopt_optarg;
33extern int sys_getopt_opterr;
34extern int sys_getopt_optind;
35extern int sys_getopt_optopt;
36
37#define sys_getopt_no_argument 0
38#define sys_getopt_required_argument 1
39#define sys_getopt_optional_argument 2
40
42 /* name of long option */
43 const char *name;
44 /*
45 * one of no_argument, required_argument, and optional_argument:
46 * whether option takes an argument
47 */
49 /* if not NULL, set *flag to val when option found */
50 int *flag;
51 /* if flag not NULL, value to set *flag to; else return value */
52 int val;
53};
54
55/* Function initializes getopt_state structure for current thread */
56void sys_getopt_init(void);
57
58/* Function returns getopt_state structure for the current thread. */
60
74int sys_getopt(int nargc, char *const nargv[], const char *ostr);
75
97int sys_getopt_long(int nargc, char *const *nargv, const char *options,
98 const struct sys_getopt_option *long_options, int *idx);
99
123int sys_getopt_long_only(int nargc, char *const *nargv, const char *options,
124 const struct sys_getopt_option *long_options, int *idx);
125
126#ifdef __cplusplus
127}
128#endif
129
130#endif /* ZEPHYR_INCLUDE_SYS_GETOPT_H_ */
Public kernel APIs.
Definition sys_getopt.h:41
int has_arg
Definition sys_getopt.h:48
const char * name
Definition sys_getopt.h:43
int * flag
Definition sys_getopt.h:50
int val
Definition sys_getopt.h:52
Definition sys_getopt.h:16
int opterr
Definition sys_getopt.h:17
char * optarg
Definition sys_getopt.h:21
char * place
Definition sys_getopt.h:23
int optreset
Definition sys_getopt.h:20
int optind
Definition sys_getopt.h:18
int optopt
Definition sys_getopt.h:19
char * sys_getopt_optarg
int sys_getopt_opterr
int sys_getopt(int nargc, char *const nargv[], const char *ostr)
Parses the command-line arguments.
int sys_getopt_optreset
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.
void sys_getopt_init(void)
struct sys_getopt_state * sys_getopt_state_get(void)
int sys_getopt_optind
int sys_getopt_optopt