#include #include #include #include "lsh_main_func.c" #include "lsh_builtins.c" typedef struct{ char *prompt; } SHELL_OB; void lsh_loop(SHELL_OB *shell_obj) { char *line; char **args; int status; do { printf("%s",shell_obj->prompt); line = lsh_read_line(); args = lsh_split_line(line); status = lsh_execute(args); free(line); free(args); } while (status); } int main(int argc, char **argv){ SHELL_OB shell_obj; shell_obj.prompt = (char *)malloc(sizeof(char) * 1024); //get the hostname char *hostname = (char *)malloc(sizeof(char) * 1024); gethostname(hostname,sizeof(char) * 1024); snprintf(shell_obj.prompt,sizeof(char) * 1024,"%s@%s> ",getenv("USER"),hostname); lsh_loop(&shell_obj); free(hostname); free(shell_obj.prompt); return EXIT_SUCCESS; }