blob: 9d2a5ce4e3885cbad0e365173446ff7de1056325 (
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
34
35
36
37
38
39
40
41
|
#include "cookie.h"
#include <stdlib.h>
#include <string.h>
int magi_cookie_list_add(struct magi_cookie_list ** list,
struct magi_cookie * item)
{
struct magi_cookie_list * node = malloc(sizeof(*node));
if (node) {
node->next = *list;
node->item = *item;
*list = node;
}
return !!node;
}
char * magi_cookie_list_get(struct magi_cookie_list * list, const char * name)
{
if (!list || !name) {
return 0;
} else if (!strcmp(list->item.name, name)) {
return list->item.data;
} else {
return magi_cookie_list_get(list->next, name);
}
}
void magi_cookie_list_destroy(struct magi_cookie_list * list)
{
if (list) {
magi_cookie_list_destroy(list->next);
free(list->next);
free(list->item.name);
free(list->item.data);
free(list->item.path);
free(list->item.domain);
free(list->item.port);
}
}
|