-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeek.c
130 lines (125 loc) · 2.85 KB
/
peek.c
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include "peek.h"
#include "headers.h"
#include <dirent.h>
// For EXIT codes and error handling
#include <errno.h>
#include <stdlib.h>
#include "prompt.h"
#include "time.h"
#include "warp.h"
#include "peek.h"
#include "seek.h"
#include "pastevents.h"
#include "unistd.h"
#include "fcntl.h"
#include "sys/stat.h"
#include "sys/types.h"
#include "proclore.h"
#include <pwd.h>
#include <grp.h>
void peek_function(char *inputs[], int sizeofinputs, int Flag_background)
{
int FLAG_A = 0, FLAG_L = 0;
if (Flag_background)
{
printf("%d\n", getpid());
}
if (sizeofinputs == 4)
{
if (strcmp(inputs[1], "-a") && strcmp(inputs[2], "-a"))
{
printf("Invalid ccc1\n");
return;
}
if (strcmp(inputs[1], "-l") && strcmp(inputs[2], "-l"))
{
printf("Invalid ccc2\n");
return;
}
FLAG_A = 1;
FLAG_L = 1;
calling(inputs[3], FLAG_A, FLAG_L);
}
else if (sizeofinputs == 3)
{
if (strlen(inputs[1]) == 3)
{
if (strcmp(inputs[1], "-a") == 0)
FLAG_A = 1;
else if (strcmp(inputs[1], "-l") == 0)
FLAG_L = 1;
else if (strcmp(inputs[1], "-al") == 0 || strcmp(inputs[1], "-la") == 0)
{
FLAG_L = 1;
FLAG_A = 1;
}
else
{
printf("Invalid ccc\n");
return;
}
}
else if (strlen(inputs[1]) == 2)
{
if (strcmp(inputs[1], "-l") == 0)
{
FLAG_L = 1;
}
else if (strcmp(inputs[1], "-a") == 0)
{
FLAG_A = 1;
}
else
{
printf("Invalid ccc\n");
return;
}
}
else
{
printf("Invalid ccc\n");
return;
}
calling(inputs[2], FLAG_A, FLAG_L);
}
else if (sizeofinputs == 2)
{
if (strcmp(inputs[1], ".") == 0)
{
calling(inputs[1], FLAG_A, FLAG_L);
}
else if (strcmp(inputs[1], "~") == 0)
{
calling(Pardir, FLAG_A, FLAG_L);
}
else if (!strcmp(inputs[1], "-l"))
{
calling(".", 0, 1);
}
else if (!strcmp(inputs[1], ".."))
{
calling(inputs[1], FLAG_A, FLAG_L);
}
else if (!strcmp(inputs[1], "-"))
{
calling(past, FLAG_A, FLAG_L);
}
else if (!strcmp(inputs[1], "-a"))
{
calling(".", 1, 0);
}
else
{
calling(inputs[1], FLAG_A, FLAG_L);
}
}
else if (sizeofinputs == 1)
{
calling(".", 0, 0);
}
else
{
printf("Invalid ccc\n");
return;
}
}