/* ============================================================================ Name : mplay.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include &quot;head.h&quot; int main(void){ char lu[1024] = {0}; char in[1024] = {0}; int flag = 0; int fd_list = open(&quot;list.txt&quot;, O_RDONLY); if (-1 == fd_list) { perror(&quot;open&quot;); exit(1); } read(fd_list, lu, 1024); printf(&quot;%s\n&quot;, lu); while(1) { Node* head = create_head(); bzero(in, 1024); bzero(lu, 1024); char* arg[3] = {0}; char buffer[100] = {0}; printf(&quot;[%s]&quot;, getcwd(lu, 1024)); fgets(in,1024, stdin); in[strlen(in)-1] = '\0'; char tmp[1024] = {0}; strcpy(tmp,in); arg[0] = strtok(tmp, &quot; &quot;); if (strlen(arg[0]) == strlen(in)) { if (0 == strcmp(arg[0], &quot;exit&quot;)) { break; } if (0 == strcmp(arg[0], &quot;list&quot;)) { list(head); continue; } } if(strlen(arg[0]) != strlen(in)) { if (0 == strcmp(arg[0], &quot;play&quot;)) { flag = 1; arg[1] = strtok(NULL, &quot; &quot;); Node* list_index = get_first(head); pid_t pid = fork(); if (pid > 0) { getchar(); continue; } if (0 == pid) { mplay(arg[1]); exit(1); } if (pid < 0) { perror(&quot;fork&quot;); exit(1); } } } if (0 == strcmp(in, &quot;pause&quot;)) { if (1 == flag) { fifi(in); continue; } } if (0 == strcmp(in, &quot;quit&quot;)) { if (1 == flag) { fifi(in); continue; } } if (0 == strcmp(in, &quot;next&quot;)) { if (1 == flag) { Node* list_index = get_next(head, list_index); bzero(buffer,100); mplay(buffer); continue; } } } puts(&quot;!!!感谢使用!!!&quot;); /* prints !!!Hello World!!! */ return EXIT_SUCCESS;} |