README
1[GetOpt]
2#####################
3
4Origin:
5 [Lattera FreeBSD]
6 [https://github.com/lattera/freebsd/blob/master/lib/libc/stdlib/getopt.c]
7
8Status:
9 [So far Zephyr samples were using getopt implementation from: argtable3.c.]
10
11Purpose:
12 [Shell users would like to parse options passed to the command handler.]
13
14Description:
15 [This library is going to be used by the shell module. Some shell users
16 are not satisfied with subcommands alone and need to use the options for
17 commands as well. A library is needed that allows the developer to parse
18 the arguments string, looking for supported options. Typically, this task
19 is accomplished by the getopt function.
20
21 For this purpose I decided to port the getopt library available
22 in the FreeBSD project. I had to modify it so that it could be used
23 by all instances of the shell at the same time.
24
25 Originally this function was using global variables which were defining
26 its state. In my implementation I put those variables in a structure
27 and a pointer to that structure is passed as an additional parameter
28 to getopt function. In proposed implementation each shell backend has its
29 own getopt function state structure which it uses.
30
31 This module is intended to be used inside the shell command handler
32 by the abstraction layer "SHELL_GETOPT". For example:
33 while ((char c = shell_getopt(sh, argc, argv, "abhc:")) != -1) {
34 /* some code */
35 }
36 ]
37
38Dependencies:
39 [This package does not depend on any other component.
40
41 Zephyr project will only need this component if the user configures a shell
42 module: SHELL_GETOPT.]
43
44URL:
45 [https://github.com/lattera/freebsd]
46
47commit:
48 [324e4c082c14aebf00f8dbee0fb7ad285393756a]
49
50Maintained-by:
51 [External]
52
53License:
54 [BSD 3-Clause "New" or "Revised" License]
55
56License Link:
57 [BSD 3-Clause used in getopt: https://spdx.org/licenses/BSD-3-Clause.html]
58 [Project license: https://github.com/lattera/freebsd/blob/master/COPYRIGHT]
59