Adding upstream version 6.03~pre1+dfsg.
[syslinux-debian/hramrach.git] / com32 / lib / syslinux / setup_data.c
bloba36c5b61a120a37dcd8663dbda20e8771bcd95ec
1 #include <stdlib.h>
2 #include <syslinux/linux.h>
3 #include <syslinux/loadfile.h>
5 struct setup_data *setup_data_init(void)
7 struct setup_data *setup_data;
9 setup_data = zalloc(sizeof(*setup_data));
10 if (!setup_data)
11 return NULL;
13 setup_data->prev = setup_data->next = setup_data;
14 return setup_data;
17 int setup_data_add(struct setup_data *head, uint32_t type,
18 const void *data, size_t data_len)
20 struct setup_data *setup_data;
22 setup_data = zalloc(sizeof(*setup_data));
23 if (!setup_data)
24 return -1;
26 setup_data->data = data;
27 setup_data->hdr.len = data_len;
28 setup_data->hdr.type = type;
29 setup_data->prev = head->prev;
30 setup_data->next = head;
31 head->prev->next = setup_data;
32 head->prev = setup_data;
34 return 0;
37 int setup_data_load(struct setup_data *head, uint32_t type,
38 const char *filename)
40 void *data;
41 size_t len;
43 if (loadfile(filename, &data, &len))
44 return -1;
46 return setup_data_add(head, type, data, len);