zephyr/lib/posix/getopt
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
..
CMakeLists.txt
Kconfig posix: getopt: select getopt by default with CONFIG_POSIX_API 2023-01-23 09:57:31 -08:00
README shell: fix MISRA 5.7 violations on `struct shell` 2023-04-14 12:21:08 +02:00
getopt.c posix: getopt: move declarations to unistd.h 2022-12-04 14:51:52 +01:00
getopt.h posix: getopt: move declarations to unistd.h 2022-12-04 14:51:52 +01:00
getopt_common.c iterable_sections: move to specific header 2023-05-22 10:42:30 +02:00
getopt_common.h
getopt_long.c lib: getopt: Fix compiler warning. 2023-05-09 11:03:44 -04:00

README

[GetOpt]
#####################

Origin:
   [Lattera FreeBSD]
   [https://github.com/lattera/freebsd/blob/master/lib/libc/stdlib/getopt.c]

Status:
   [So far Zephyr samples were using getopt implementation from: argtable3.c.]

Purpose:
   [Shell users would like to parse options passed to the command handler.]

Description:
   [This library is going to be used by the shell module. Some shell users
   are not satisfied with subcommands alone and need to use the options for
   commands as well. A library is needed that allows the developer to parse
   the arguments string, looking for supported options. Typically, this task
   is accomplished by the getopt function.

   For this purpose I decided to port the getopt library available
   in the FreeBSD project. I had to modify it so that it could be used
   by all instances of the shell at the same time.

   Originally this function was using global variables which were defining
   its state. In my implementation I put those variables in a structure
   and a pointer to that structure is passed as an additional parameter
   to getopt function. In proposed implementation each shell backend has its
   own getopt function state structure which it uses.

   This module is intended to be used inside the shell command handler
   by the abstraction layer "SHELL_GETOPT". For example:
   while ((char c = shell_getopt(sh, argc, argv, "abhc:")) != -1) {
      /* some code */
   }
   ]

Dependencies:
   [This package does not depend on any other component.

   Zephyr project will only need this component if the user configures a shell
   module: SHELL_GETOPT.]

URL:
   [https://github.com/lattera/freebsd]

commit:
   [324e4c082c14aebf00f8dbee0fb7ad285393756a]

Maintained-by:
   [External]

License:
   [BSD 3-Clause "New" or "Revised" License]

License Link:
   [BSD 3-Clause used in getopt: https://spdx.org/licenses/BSD-3-Clause.html]
   [Project license: https://github.com/lattera/freebsd/blob/master/COPYRIGHT]