-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
executable file
·80 lines (70 loc) · 1.86 KB
/
main.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "defs.h"
#include "mhtdefs.h"
#include "dbqueue.h"
#include "mhtfile.h"
extern PQNode g_pQHeader;
extern PQNode g_pQ;
/*
Testing functions of queue
*/
void test_queue();
void test_queue() {
const char str[32] = TEST_STR1;
int i = 0;
PQNode qnode_ptr = NULL;
PMHTNode mhtnode_ptr = NULL;
if(g_pQHeader != NULL && g_pQ != NULL)
freeQueue(&g_pQHeader, &g_pQ);
else if(g_pQHeader){
freeQueue2(&g_pQHeader);
}
else if(g_pQ){
freeQueue3(&g_pQ);
}
else{ // both of g_pQHeader and g_pQ are NULL
; // do nothing
}
initQueue(&g_pQHeader, &g_pQ);
check_pointer((void*)g_pQHeader, "g_pQHeader");
check_pointer((void*)g_pQ, "g_pQ");
for(i = 0; i < 100; i++){
mhtnode_ptr = makeMHTNode(i+1, str); check_pointer((void*)mhtnode_ptr, "mhtnode_ptr");
qnode_ptr = makeQNode(mhtnode_ptr, 0); check_pointer((void*)qnode_ptr, "qnode_ptr");
enqueue(&g_pQHeader, &g_pQ, qnode_ptr);
}
printf("%d\n", g_pQHeader->m_length);
//output
while(qnode_ptr = dequeue(&g_pQHeader, &g_pQ)){
check_pointer((void*)qnode_ptr, "qnode_ptr");
printf("Node page number: %d, hash value: %s, level: %d\n",
qnode_ptr->m_MHTNode_ptr->m_pageNo,
qnode_ptr->m_MHTNode_ptr->m_hash,
qnode_ptr->m_level);
deleteQNode(&qnode_ptr);
}
printf("%d\n", g_pQHeader->m_length);
freeQueue(&g_pQHeader, &g_pQ);
}
int main(int argc, char const *argv[])
{
char hash1[40] = {0};
char hash2[40] = {0};
char combinedHash[40] = {0};
char hash_string[65] = {0};
// testMHTQueue();
buildMHTFile();
/*
generateHashByPageNo_SHA256(0, hash1, 40);
generateHashByPageNo_SHA256(26, hash2, 40);
print_hash_value(hash1);
print_hash_value(hash2);
generateCombinedHash_SHA256(hash1, hash2, combinedHash, 40);
print_hash_value(combinedHash);
convert_hash_to_string(combinedHash, hash_string, 65);
printf("%s\n", hash_string);
*/
return 0;
}