opkg: include opkg_state.h in libopkg_include_HEADERS
[oweals/opkg-lede.git] / nv_pair_list.h
1 /* nv_pair_list.h - the itsy package management system
2
3    Carl D. Worth
4
5    Copyright (C) 2001 University of Southern California
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2, or (at
10    your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 */
17
18 #ifndef NV_PAIR_LIST_H
19 #define NV_PAIR_LIST_H
20
21 #include "nv_pair.h"
22 #include "void_list.h"
23
24 typedef struct nv_pair_list_elt nv_pair_list_elt_t;
25 struct nv_pair_list_elt
26 {
27     nv_pair_list_elt_t *next;
28     nv_pair_t *data;
29 };
30
31 typedef struct nv_pair_list nv_pair_list_t;
32 struct nv_pair_list
33 {
34     nv_pair_list_elt_t pre_head;
35     nv_pair_list_elt_t *head;
36     nv_pair_list_elt_t *tail;
37 };
38
39 static inline int nv_pair_list_empty(nv_pair_list_t *list)
40 {
41      if (list->head == NULL)
42           return 1;
43      else
44           return 0;
45 }
46
47 int nv_pair_list_elt_init(nv_pair_list_elt_t *elt, nv_pair_t *data);
48 void nv_pair_list_elt_deinit(nv_pair_list_elt_t *elt);
49
50 int nv_pair_list_init(nv_pair_list_t *list);
51 void nv_pair_list_deinit(nv_pair_list_t *list);
52
53 nv_pair_t *nv_pair_list_append(nv_pair_list_t *list,
54                                const char *name, const char *value);
55 int nv_pair_list_push(nv_pair_list_t *list, nv_pair_t *data);
56 nv_pair_list_elt_t *nv_pair_list_pop(nv_pair_list_t *list);
57 char *nv_pair_list_find(nv_pair_list_t *list, char *name);
58
59 #endif
60