1 /* cksum_lis.c - the opkg package management system
3 Copyright (C) 2010,2011 Javier Palacios
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2, or (at
8 your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
20 #include "cksum_list.h"
21 #include "libbb/libbb.h"
24 int cksum_init(cksum_t
*cksum
, char **itemlist
)
26 cksum
->value
= xstrdup(*itemlist
++);
27 cksum
->size
= atoi(*itemlist
++);
28 cksum
->name
= xstrdup(*itemlist
++);
33 void cksum_deinit(cksum_t
*cksum
)
42 void cksum_list_init(cksum_list_t
*list
)
44 void_list_init((void_list_t
*) list
);
47 void cksum_list_deinit(cksum_list_t
*list
)
49 cksum_list_elt_t
*iter
, *n
;
52 list_for_each_entry_safe(iter
, n
, &list
->head
, node
) {
53 cksum
= (cksum_t
*)iter
->data
;
56 /* malloced in cksum_list_append */
60 void_list_deinit((void_list_t
*) list
);
63 cksum_t
*cksum_list_append(cksum_list_t
*list
, char **itemlist
)
65 /* freed in cksum_list_deinit */
66 cksum_t
*cksum
= xcalloc(1, sizeof(cksum_t
));
67 cksum_init(cksum
, itemlist
);
69 void_list_append((void_list_t
*) list
, cksum
);
74 const cksum_t
*cksum_list_find(cksum_list_t
*list
, const char *name
)
76 cksum_list_elt_t
*iter
;
79 list_for_each_entry(iter
, &list
->head
, node
) {
80 cksum
= (cksum_t
*)iter
->data
;
81 if (strcmp(cksum
->name
, name
) == 0) {