lib: getopt: rework and extend getopt library
Getopt has been rework in this way that calling it does not require extra state parameter and its execution is thread safe. Global parameters describing the state of the getopt function have been made available to ensure full API compatibility in using this library. However, referencing these global variables directly is not thread safe. In order to get the state of the getopt function for the thread that is currently using it, call: getopt_state_get(); Extended the library with getopt_long and getopt_long_only functions. Moved getopt libary from utils to posix. Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
parent
7f1f1229e1
commit
d4559f53fa
22 changed files with 978 additions and 179 deletions
|
@ -138,10 +138,13 @@ config SHELL_VT100_COLORS
|
|||
If enabled VT100 colors are used in shell (e.g. print errors in red).
|
||||
|
||||
config SHELL_GETOPT
|
||||
bool "Enable getopt support"
|
||||
bool "Enable threadsafe getopt support in shell"
|
||||
select GETOPT
|
||||
help
|
||||
Enables getopt support in the shell.
|
||||
This config creates a separate getopt_state for the shell instance.
|
||||
It ensures that using getopt with shell is thread safe.
|
||||
When more threads are using getopt please call getopt_state_get to
|
||||
get getopt state of the shell thread.
|
||||
|
||||
config SHELL_METAKEYS
|
||||
bool "Enable metakeys"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue