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