-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.c
More file actions
55 lines (43 loc) · 1.27 KB
/
shell.c
File metadata and controls
55 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <time.h>
#include <sys/sysinfo.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
#include <errno.h>
#include <dirent.h>
#include "headers/colors.h"
#include "headers/command_handler.h"
#include "headers/mkdir.h"
#include "headers/help.h"
#include "headers/uptime.h"
#include "headers/sl.h"
#include "headers/ls.h"
int main(){
char machine_name[HOST_NAME_MAX];
char username[LOGIN_NAME_MAX];
char command[MAX_INPUT];
char folder_name[MAX_INPUT];
char helper[MAX_INPUT];
char flag[MAX_INPUT];
read_machine_data(machine_name,username);
while(1)
{
display_shell(command,machine_name,username);
if(check_valid_command(command)){
if(strncmp(command,"uptime",6)==0) display_uptime(flag,command);
if(strncmp(command,"sl",2)==0) display_sl(flag,command);
if(strncmp(command,"mkdir",5)==0) create_directory(folder_name,command);
if(strncmp(command,"ls",2)==0) display_ls(folder_name,command);
if(strncmp(command,"help",4)==0) display_help(helper,command);
}
else{
display_error(command);
}
}
return 0;
}