-
Notifications
You must be signed in to change notification settings - Fork 0
/
social_media.c
74 lines (57 loc) · 1.17 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
/**
* The entrypoint of the program. 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"
/**
* Initializes 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();
list_graph_t *graph = lg_create(MAX_PEOPLE);
char *input = (char *)malloc(MAX_COMMAND_LEN);
posts_t *posts = (posts_t *)malloc(sizeof(posts_t));
posts->size = 0;
posts->capacity = 1;
posts->posts = (post_t **)malloc(sizeof(post_t *));
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, posts);
#endif
#ifdef TASK_3
handle_input_feed(input, posts, graph);
#endif
}
lg_free(graph);
free_posts(&posts);
free_users();
free(input);
return 0;
}