cmd_help.c 536 B

1234567891011121314151617181920212223242526272829
  1. #include "cmd_help.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. struct help_table_item_t
  5. {
  6. void (*func)();
  7. };
  8. struct help_table_item_t help_table[] = {
  9. {shell_help_cd},
  10. };
  11. static const int help_table_num = sizeof(help_table) / sizeof(struct help_table_item_t);
  12. int shell_help(int argc, char **argv)
  13. {
  14. printf("Help:\n");
  15. for (int i = 0; i < help_table_num; ++i)
  16. help_table[i].func();
  17. if (argc > 1)
  18. free(argv);
  19. return 0;
  20. }
  21. void shell_help_cd()
  22. {
  23. printf("Example of cd: cd [destination]\n");
  24. }