help.h 949 B

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