-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparserYml.cpp
85 lines (53 loc) · 1.21 KB
/
parserYml.cpp
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
#include<stdio.h>
#include<Windows.h>
//1. get the file size from disk and allocate in memory,
long fileSize = 0;
long currentOffset = 0;
void* heapFileDate = NULL;
char fileLines[50][200];
int totalLines = 0;
void printLineByLineFromHeapMemory( ) {
char* p = (char*)heapFileDate;
char line[200];
int i = 0;
DWORD currentIndex = 0;
for ( ; i < fileSize; i++) {
line[currentIndex] = p[i];
if(p[i] == '\n'){
line[currentIndex] = '\0';
currentIndex = 0;
printf("%s\n", line);
strncpy(fileLines[totalLines], line, strlen(line)+1);
//sprintf(fileLines[totalLines], "%s", line);
totalLines++;
}
else
{
currentIndex++;
}
}
if (fileSize == i) {
line[currentIndex] = '\0';
printf("%s\n", line);
}
}
void parseYamlFileLines() {
}
int main() {
FILE* hamadFile = fopen("C:\\Users\\DFIR\\Desktop\\H9_rewritng\\memoryRules.yml", "rb");
if (hamadFile) {
fseek(hamadFile, 0, SEEK_END);
fileSize = ftell(hamadFile);
fseek(hamadFile, 0, SEEK_SET);
heapFileDate = malloc(fileSize);
fread(heapFileDate, fileSize, 1, hamadFile);
fclose(hamadFile);
}
else
{
printf("failed to read file");
}
printLineByLineFromHeapMemory();
fileLines;
return 0;
}