u-boot-brain/lib
Sean Anderson 72eda5074b lib: Add getopt
Some commands can get very unweildy if they have too many positional
arguments. Adding options makes them easier to read, remember, and
understand.

This implementation of getopt has been taken from barebox, which has had
option support for quite a while. I have made a few modifications to their
version, such as the removal of opterr in favor of a separate getopt_silent
function. In addition, I have moved all global variables into struct
getopt_context.

The getopt from barebox also re-orders the arguments passed to it so that
non-options are placed last. This allows users to specify options anywhere.
For example, `ls -l foo/ -R` would be re-ordered to `ls -l -R foo/` as
getopt parsed the options. However, this feature conflicts with the const
argv in cmd_tbl->cmd. This was originally added in 54841ab50c ("Make sure
that argv[] argument pointers are not modified."). The reason stated in
that commit is that hush requires argv to stay unmodified. Has this
situation changed? Barebox also uses hush, and does not have this problem.
Perhaps we could use their fix?

I have assigned maintenance of getopt to Simon Glass, as it is currently
only used by the log command. I would also be fine maintaining it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2020-10-30 10:56:11 -04:00
..
acpi acpi: Use I2cSerialBusV2() instead of I2cSerialBus() 2020-09-25 11:27:26 +08:00
aes fit: cipher: aes: allow to store the IV in the FIT image 2020-10-12 21:30:37 -04:00
at91 SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
bzip2 common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
crypto lib/crypto: simplify public_key_verify_signature 2020-08-08 19:03:12 +02:00
dhry command: Remove the cmd_tbl_t typedef 2020-05-18 18:36:55 -04:00
efi common: Drop init.h from common header 2020-05-18 17:33:33 -04:00
efi_driver efi: Tidy up header includes 2020-08-03 22:19:54 -04:00
efi_loader efi_loader: daylight saving time 2020-10-27 21:13:16 +01:00
efi_selftest efi: Fix typo in documentation 2020-10-06 07:43:56 +02:00
libavb common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
libfdt fdt_region: move fdt_region.c to common/ from lib/libfdt/ 2020-04-26 14:23:55 -06:00
lzma common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
lzo SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
optee optee: add property no-map to secure reserved memory 2020-09-22 12:54:13 -06:00
rsa xilinx: zynq: Change types from u32 to uint32_t 2020-10-27 08:13:33 +01:00
tizen SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
zlib include/u-boot, lib/zlib: add sources for zlib decompression 2020-08-07 22:31:32 -04:00
zstd dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
.gitignore lib: ignore oid_registry_data.c file 2020-01-22 17:47:57 -05:00
addr_map.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
aes.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
asm-offsets.c common: Drop asm_offsets.h from common header 2020-05-18 21:19:23 -04:00
asn1_decoder.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
bch.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
binman.c binman: Add way to locate an entry in memory 2020-07-17 14:32:24 +08:00
bitrev.c lib: bitrev: Sync with Linux kernel v4.17 2018-09-18 00:01:18 -06:00
charset.c common: rename getc() to getchar() 2020-10-22 09:54:53 -04:00
circbuf.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
crc7.c lib: add crc7 from Linux 2011-01-18 23:38:08 +01:00
crc8.c common: Drop linux/crc8.h 2019-12-02 18:23:07 -05:00
crc16.c Roll CRC16-CCITT into the hash infrastructure 2018-12-08 20:18:44 -05:00
crc32.c crc32: Use the crc.h header for crc functions 2019-12-02 18:23:08 -05:00
crc32c.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ctype.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
date.c lib: add mktime64() for linux compatibility 2019-12-06 16:44:19 -05:00
display_options.c lib: print_freq() should output kHz not KHz 2020-10-22 09:54:54 -04:00
div64.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
elf.c lib: elf: Move the generic elf loading/validating functions to lib 2020-03-03 13:08:14 +05:30
errno_str.c lib: errno: sync error codes 2019-10-31 07:22:53 -04:00
errno.c Add basic errno support. 2010-09-19 19:29:47 +02:00
fdtdec_common.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
fdtdec_test.c command: Remove the cmd_tbl_t typedef 2020-05-18 18:36:55 -04:00
fdtdec.c fdtdec: correct test on return of fdt_node_offset_by_phandle 2020-10-06 09:07:54 -06:00
getopt.c lib: Add getopt 2020-10-30 10:56:11 -04:00
gunzip.c common: Drop part.h from common header 2020-05-18 17:33:33 -04:00
gzip.c common: Move gzip functions into a new gzip header 2019-08-11 16:43:41 -04:00
hang.c common: Move hang() to the same header as panic() 2020-01-17 17:53:40 -05:00
hashtable.c lib/hashtable: remove superfluous check 2020-10-12 21:30:37 -04:00
hexdump.c lib: do not provide hexdump in SPL 2020-04-24 10:51:32 -04:00
image-sparse.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
Kconfig lib: Add getopt 2020-10-30 10:56:11 -04:00
ldiv.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
linux_compat.c common: Drop net.h from common header 2020-05-18 17:33:31 -04:00
linux_string.c Make linux kernel string funcs available to tools 2012-12-13 11:46:07 -07:00
list_sort.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
lmb.c CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined 2020-08-26 09:19:16 +02:00
lz4_wrapper.c lz4: fix decompressor on big-endian powerpc 2020-07-17 08:45:29 -04:00
lz4.c SPDX: Convert a few files that were missed before 2018-05-10 20:38:35 -04:00
Makefile lib: Add getopt 2020-10-30 10:56:11 -04:00
md5.c GCC47: Fix warning in md5.c 2012-04-29 14:14:08 +02:00
membuff.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
net_utils.c common: Drop net.h from common header 2020-05-18 17:33:31 -04:00
of_live.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
oid_registry.c lib: add oid registry utility 2019-12-06 16:44:20 -05:00
panic.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
physmem.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
qsort.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
rand.c common: Move random-number functions into their own header 2019-12-02 18:23:07 -05:00
rbtree.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
rc4.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sha1.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sha256.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sha512.c Add support for SHA384 and SHA512 2020-06-12 13:14:07 -04:00
slre.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
smbios.c smbios: empty strings in smbios_add_string() 2020-06-05 04:04:41 +02:00
sscanf.c xen: Code style conformity 2020-08-24 14:11:31 -04:00
string.c string: Allow arch override of strndup() also 2020-02-05 19:33:46 -07:00
strto.c Revert "lib: Improve _parse_integer_fixup_radix base 16 detection" 2020-06-15 11:23:41 -04:00
tables_csum.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
time.c time: Fix get_ticks being non-monotonic 2020-10-14 11:16:34 -04:00
tiny-printf.c tiny-printf: Support %i 2020-05-01 11:03:24 -04:00
tpm-common.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
tpm-utils.h tpm: Convert to use a device parameter 2018-11-29 09:30:06 -07:00
tpm-v1.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
tpm-v2.c tpm: add TPM2_GetRandom command support 2020-07-08 15:38:32 -04:00
trace.c trace: conserve gd register on RISC-V 2020-10-27 21:13:15 +01:00
uuid.c command: Remove the cmd_tbl_t typedef 2020-05-18 18:36:55 -04:00
vsprintf.c compiler*.h: sync include/linux/compiler*.h with Linux 5.7-rc5 2020-07-01 11:48:05 -04:00
xxhash.c lib: Add xxhash support 2019-05-05 08:48:50 -04:00