help.h 930 B

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