Advertisement
Madmouse

structs == <3

Dec 13th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. typedef void (*command_fun_ptr) (int, char**);
  2.  
  3. typedef struct command_t {
  4.     char command[MAX_COMMAND_LENGTH];
  5.     command_fun_ptr function;
  6.     char description[256];
  7. } command_t;
  8.  
  9. #define command_list_size 4
  10. command_t command_list[command_list_size];
  11. void __attribute__((constructor)) debug_shell_init(void)
  12. {
  13.     command_list[0] = (command_t) {"clear", (void*) command_clear, "Clear the screen"};
  14.     command_list[1] = (command_t) {"exit", (void*) command_exit,   "Exit the shell"};
  15.     command_list[2] = (command_t) {"halt", (void*) command_exit,   "Halt the machine"};
  16.     command_list[3] = (command_t) {"echo", command_echo,           "Print out some text"};
  17. }
  18.  
  19. .........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement