-
Notifications
You must be signed in to change notification settings - Fork 0
/
social_media.c
82 lines (62 loc) · 1.16 KB
/
social_media.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
/**
* The entrypoint of the homework. Every initialization must be done here
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "users.h"
#include "friends.h"
#include "posts.h"
#include "feed.h"
#include "graph.h"
/**
* Initialises every task based on which task we are running
*/
void init_tasks(void)
{
#ifdef TASK_1
#endif
#ifdef TASK_2
#endif
#ifdef TASK_3
#endif
}
/**
* Entrypoint of the program, compiled with different defines for each task
*/
int main(void)
{
init_users();
init_tasks();
#ifdef TASK_1
list_graph_t *graph = lg_create(MAX_PEOPLE);
#endif
#ifdef TASK_2
post_trees_t *tree = init_posts(MAX_PEOPLE);
#endif
char *input = (char *)malloc(MAX_COMMAND_LEN);
while (1) {
char *command = fgets(input, MAX_COMMAND_LEN, stdin);
// If fgets returns null, we reached EOF
if (!command)
break;
#ifdef TASK_1
handle_input_friends(input, graph);
#endif
#ifdef TASK_2
handle_input_posts(input, tree);
#endif
#ifdef TASK_3
handle_input_feed(input, graph, tree);
#endif
}
free_users();
free(input);
#ifdef TASK_1
lg_free(&graph);
#endif
#ifdef TASK_2
tree_free(&tree);
#endif
return 0;
}