0001
0002 #ifndef __SUBCMD_HELP_H
0003 #define __SUBCMD_HELP_H
0004
0005 #include <sys/types.h>
0006 #include <stdio.h>
0007
0008 struct cmdnames {
0009 size_t alloc;
0010 size_t cnt;
0011 struct cmdname {
0012 size_t len;
0013 char name[];
0014 } **names;
0015 };
0016
0017 static inline void mput_char(char c, unsigned int num)
0018 {
0019 while(num--)
0020 putchar(c);
0021 }
0022
0023 void load_command_list(const char *prefix,
0024 struct cmdnames *main_cmds,
0025 struct cmdnames *other_cmds);
0026 void add_cmdname(struct cmdnames *cmds, const char *name, size_t len);
0027 void clean_cmdnames(struct cmdnames *cmds);
0028 int cmdname_compare(const void *a, const void *b);
0029 void uniq(struct cmdnames *cmds);
0030
0031 void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
0032 int is_in_cmdlist(struct cmdnames *c, const char *s);
0033 void list_commands(const char *title, struct cmdnames *main_cmds,
0034 struct cmdnames *other_cmds);
0035
0036 #endif