blob: dd4802a8e49fee423bd5a35cc128c1f04b6321b7 (
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
|
#include "file.h"
#include <stdlib.h>
#include <string.h>
void magi_files_add(magi_files **files, magi_file *newitem)
{
magi_files *node = malloc(sizeof(*node));
if (node) {
node->next = *files;
node->item = *newitem;
*files = node;
}
}
magi_file *magi_files_get(magi_files *files, const char *name)
{
if (!files || !name) {
return 0;
} else if (!strcmp(files->item.field, name)) {
return &files->item;
} else {
return magi_files_get(files->next, name);
}
}
void magi_files_free(magi_files *files)
{
if (files) {
magi_files_free(files->next);
free(files->next);
free(files->item.field);
free(files->item.filename);
magi_params_free(files->item.params);
free(files->item.params);
}
}
|