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