-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLINKEDLIST.C
109 lines (83 loc) · 2.43 KB
/
LINKEDLIST.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
#include "LINKEDLIST.H"
#define MAX_NUMBER_OF_OPTS 4
int optList_maker(char const *part)
{
if (optTypeChecker(part) == 0)
{
return 0;
}
new_opt = (opt *)malloc(sizeof(opt));
if (new_opt == NULL)
{
puts(ANSI_COLOR_RED Bold "ERORR:" ANSI_COLOR_RESET ANSI_COLOR_Bright_Yellow "HEAP IS UNDERFLOW CAN'T CREAT COMMAND LINKED LIST.\a" ANSI_COLOR_RESET);
exit(0);
}
if (head_opt == NULL)
{
head_opt = new_opt;
strcpy(new_opt->part, part);
new_opt->next = NULL;
current_opt = new_opt;
}
else
{
strcpy(new_opt->part, part);
new_opt->next = NULL;
current_opt->next = new_opt;
current_opt = new_opt;
}
return 1;
}
void filesList_maker(char const *arr)
{
fileTypeChecker(arr);
fileOccurance(arr);
fileEmpty(arr);
new_file_list = (file_list *)malloc(sizeof(file_list));
if (new_file_list == NULL)
{
puts(ANSI_COLOR_RED Bold "ERORR:" ANSI_COLOR_RESET ANSI_COLOR_Bright_Yellow "HEAP IS UNDERFLOW CAN'T CREAT FILES LINKEDLIST.\a" ANSI_COLOR_RESET);
exit(0);
}
if (head_file_list == NULL)
{
head_file_list = new_file_list;
strcpy(new_file_list->file, arr);
new_file_list->next = NULL;
current_file_list = new_file_list;
}
else
{
strcpy(new_file_list->file, arr);
new_file_list->next = NULL;
current_file_list->next = new_file_list;
current_file_list = new_file_list;
}
}
void fileContain_maker(char *string)
{
new_fileContain = (fileContain *)malloc(sizeof(fileContain));
if (new_fileContain == NULL)
{
puts(ANSI_COLOR_RED Bold "ERORR:" ANSI_COLOR_RESET ANSI_COLOR_Bright_Yellow "HEAP IS UNDERFLOW CAN'T CREAT FILES LINKEDLIST.\a" ANSI_COLOR_RESET);
exit(0);
}
if (head_fileContain == NULL)
{
head_fileContain = new_fileContain;
strcpy(new_fileContain->word, string);
new_fileContain->next = NULL;
new_fileContain->prev = NULL;
tail_fileContain = new_fileContain;
current_fileContain = new_fileContain;
}
else
{
strcpy(new_fileContain->word, string);
new_fileContain->next = NULL;
new_fileContain->prev = current_fileContain;
current_fileContain->next = new_fileContain;
tail_fileContain = new_fileContain ;
current_fileContain = new_fileContain;
}
}