^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __SUBCMD_HELP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __SUBCMD_HELP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <sys/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct cmdnames {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) size_t alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) size_t cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct cmdname {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) size_t len; /* also used for similarity index in help.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) char name[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) } **names;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) static inline void mput_char(char c, unsigned int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) while(num--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) putchar(c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) void load_command_list(const char *prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct cmdnames *main_cmds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct cmdnames *other_cmds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) void add_cmdname(struct cmdnames *cmds, const char *name, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) void clean_cmdnames(struct cmdnames *cmds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int cmdname_compare(const void *a, const void *b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) void uniq(struct cmdnames *cmds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* Here we require that excludes is a sorted list. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int is_in_cmdlist(struct cmdnames *c, const char *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void list_commands(const char *title, struct cmdnames *main_cmds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct cmdnames *other_cmds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #endif /* __SUBCMD_HELP_H */