2015-12-15 23:39:40 +08:00
|
|
|
#ifndef __SUBCMD_HELP_H
|
|
|
|
#define __SUBCMD_HELP_H
|
2009-04-20 21:00:56 +08:00
|
|
|
|
2015-12-15 23:39:38 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2009-04-20 21:00:56 +08:00
|
|
|
struct cmdnames {
|
2009-07-01 18:37:06 +08:00
|
|
|
size_t alloc;
|
|
|
|
size_t cnt;
|
2009-04-20 21:00:56 +08:00
|
|
|
struct cmdname {
|
|
|
|
size_t len; /* also used for similarity index in help.c */
|
2015-12-15 23:39:38 +08:00
|
|
|
char name[];
|
2009-04-20 21:00:56 +08:00
|
|
|
} **names;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void mput_char(char c, unsigned int num)
|
|
|
|
{
|
|
|
|
while(num--)
|
|
|
|
putchar(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void load_command_list(const char *prefix,
|
|
|
|
struct cmdnames *main_cmds,
|
|
|
|
struct cmdnames *other_cmds);
|
2009-07-01 18:37:06 +08:00
|
|
|
void add_cmdname(struct cmdnames *cmds, const char *name, size_t len);
|
2015-12-14 12:18:09 +08:00
|
|
|
void clean_cmdnames(struct cmdnames *cmds);
|
|
|
|
int cmdname_compare(const void *a, const void *b);
|
|
|
|
void uniq(struct cmdnames *cmds);
|
2009-04-20 21:00:56 +08:00
|
|
|
/* Here we require that excludes is a sorted list. */
|
|
|
|
void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
|
|
|
|
int is_in_cmdlist(struct cmdnames *c, const char *s);
|
|
|
|
void list_commands(const char *title, struct cmdnames *main_cmds,
|
|
|
|
struct cmdnames *other_cmds);
|
|
|
|
|
2015-12-15 23:39:40 +08:00
|
|
|
#endif /* __SUBCMD_HELP_H */
|