-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlists.h
More file actions
55 lines (46 loc) · 1.63 KB
/
lists.h
File metadata and controls
55 lines (46 loc) · 1.63 KB
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
#ifndef LISTS_H
#define LISTS_H
/* Calendars are kept in reverse order of creation
with newest calendars at the head of the list. */
struct calendar{
char *name;
struct event *events;
struct calendar *next;
};
/* Events are kept in order by time with soonest events first.
New events could be inserted at any point in the list. */
struct event{
char *description;
time_t time;
struct event *next;
};
/* Users are kept in any order but names must be unique. If a
user already exists with this name, another can not be added */
struct user {
char *name;
struct subscription *subscriptions;
struct user *next;
};
/* Subscriptions are kept in order as they are added. Newest
subscriptions are at the tail of the list */
struct subscription{
struct calendar *calendar;
struct subscription *next;
};
typedef struct calendar Calendar;
typedef struct event Event;
typedef struct user User;
typedef struct subscription Subscription;
// helper functions not directly related to only one command in the API
Calendar *find_calendar(Calendar *cal_list, char *cal_name);
User *find_user(User *user_list, char *user_name);
void error(char *msg);
// functions provided as the API to a calendar
int add_calendar(Calendar **cal_list_ptr, char *cal_name);
char * list_calendars(Calendar *cal_list);
int add_event(Calendar *cal_list, char *cal_name, char *event_name, time_t date);
char * list_events(Calendar *cal_list, char *cal_name);
int add_user(User **user_list_ptr, char *user_name);
char * list_users(User *user_list);
int subscribe(User *user_list, Calendar *cal_list, char *user_name, char *cal_name);
#endif