aboutsummaryrefslogtreecommitdiff
path: root/src/cookie.h
blob: 94194578083aad6acc01ac2e11b9b1e5807a191d (plain)
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
#ifndef MAGI_INCLUDED_COOKIE
#define MAGI_INCLUDED_COOKIE


struct magi_cookie {
    /* All pointers must be valid as 'free' arguments. */
    char * name;
    char * data;
    char * path;    /* Without '/' at the end. */
    char * domain;  /* With dot at the begining. */
    char * max_age; /* In seconds until discard, used only in response. */
};

struct magi_cookie_list {
    struct magi_cookie_list * next; /* Must be valid as 'free' arguments. */
    struct magi_cookie        item;
};


/* Addition of item to top of list. Null <=> error. */
int magi_cookie_list_add(struct magi_cookie_list ** list,
                         struct magi_cookie *       item);

/* Data of last cookie in list: cookie.name == name, returns null if no such;
 * Last cookie in list is first from request, and from RFC 2109 we know that
 * first cookie is the most accurate for request's domain and path. */
char * magi_cookie_list_get(struct magi_cookie_list * list, const char * name);

/* Freeing and invalidation of list. */
void magi_cookie_list_destroy(struct magi_cookie_list * list);


#endif