From 85af3a36d69c507edaeb0cb04c5838679586b606 Mon Sep 17 00:00:00 2001 From: Robert Stachecki Date: Tue, 19 Jan 2021 17:22:35 +0100 Subject: [PATCH] =?UTF-8?q?Usu=C5=84=20'microshell/microshell.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- microshell/microshell.c | 78 ----------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 microshell/microshell.c diff --git a/microshell/microshell.c b/microshell/microshell.c deleted file mode 100644 index 1791ee5..0000000 --- a/microshell/microshell.c +++ /dev/null @@ -1,78 +0,0 @@ -//Skrypt wykonany za pomoca poradnika https://www.youtube.com/watch?v=O5YVGg81Gdo https://www.youtube.com/watch?v=5Qim9wufNP0 oraz kursów i instrukcji ogólno dostępnych w internecie -//Kopiowanie oraz korzytsanie z kodu do własnych potrzeb zabronione - #include - #include - #include - #include - #include - #include - #include - #define space " \n" - #define max_c 500 - #define BRIGHT 1 - #define GREEN 32 - #define BLUE 34 - #define PINK 35 - #define CYAN 36 - void help() { - printf(" Robert Stachecki \n Obslugiwane polecenia: \n exit \n cd \n pwd \n date \n help \n exit \n date \n"); - } - void clear(){ - printf("\033[H\033[J"); - } - const char *getUserName() - { - uid_t uid = geteuid(); - struct passwd *pw = getpwuid(uid); - return pw->pw_name; - } - void date(){ - time_t t = time(NULL); - struct tm *tm = localtime(&t); - char s[64]; - strftime(s, sizeof(s), "%c", tm); - printf("%s\n", s); - } - int main() - { - char cwd[512], hostName[128], *pwd[1000]; - register struct passwd *pw; - register uid_t uid; - uid = geteuid (); - pw = getpwuid (uid); - char line[max_c], lend[max_c], * commands[max_c], ** command; - while (1) { - gethostname(hostName, 128); - getcwd(cwd, 512); - printf("%c[%dm%s",0x1B, GREEN, pw->pw_name); - printf("%c[%dm",0x1B,0); - printf("@"); - printf("%c[%dm%s ",0x1B, PINK, hostName); - printf("%c[%dm%s",0x1B, CYAN, cwd); - printf("%c[%dm $ ",0x1B, GREEN); - printf("%c[%dm",0x1B,0); - fflush(stdout); - if (fgets(line, max_c, stdin )) { - command = commands; - *command++ = strtok(line,space); - while ((*command++ = strtok(NULL,space))); - if (strcmp(commands[0], "help")==0) help(); - - else if (strcmp(commands[0], "exit")==0) { - printf ("Zakończono działanie\n"); - exit(0); - } - else if (strcmp(commands[0], "cd")==0) { - if (commands[1]==0) printf("Wymagany argument\n"); - int ret; - ret = chdir(commands[1]); - strcpy(lend, "pwd"); - } - else if (strcmp(commands[0], "date") == 0){ date(); } - else if (strcmp(commands[0], "clear") == 0){ clear(); } - else if (strcmp(commands[0], "pwd")==0) printf ("%s\n", cwd); - } - } - - return 0; - }