2 * Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
32 #ifndef _BHND_NVRAM_BHND_NVRAM_PLIST_H_
33 #define _BHND_NVRAM_BHND_NVRAM_PLIST_H_
36 #include <sys/types.h>
42 #include "bhnd_nvram.h"
43 #include "bhnd_nvram_value.h"
45 typedef struct bhnd_nvram_prop bhnd_nvram_prop;
46 typedef struct bhnd_nvram_plist bhnd_nvram_plist;
48 bhnd_nvram_plist *bhnd_nvram_plist_new(void);
49 bhnd_nvram_plist *bhnd_nvram_plist_retain(bhnd_nvram_plist *plist);
50 void bhnd_nvram_plist_release(bhnd_nvram_plist *plist);
52 bhnd_nvram_plist *bhnd_nvram_plist_copy(bhnd_nvram_plist *plist);
54 size_t bhnd_nvram_plist_count(bhnd_nvram_plist *plist);
56 int bhnd_nvram_plist_append_list(bhnd_nvram_plist *plist,
57 bhnd_nvram_plist *tail);
59 int bhnd_nvram_plist_append(bhnd_nvram_plist *plist,
60 bhnd_nvram_prop *prop);
61 int bhnd_nvram_plist_append_val(bhnd_nvram_plist *plist,
62 const char *name, bhnd_nvram_val *val);
63 int bhnd_nvram_plist_append_bytes(bhnd_nvram_plist *plist,
64 const char *name, const void *inp, size_t ilen,
65 bhnd_nvram_type itype);
66 int bhnd_nvram_plist_append_string(bhnd_nvram_plist *plist,
67 const char *name, const char *val);
69 int bhnd_nvram_plist_replace(bhnd_nvram_plist *plist,
70 bhnd_nvram_prop *prop);
71 int bhnd_nvram_plist_replace_val(bhnd_nvram_plist *plist,
72 const char *name, bhnd_nvram_val *val);
73 int bhnd_nvram_plist_replace_bytes(bhnd_nvram_plist *plist,
74 const char *name, const void *inp, size_t ilen,
75 bhnd_nvram_type itype);
76 int bhnd_nvram_plist_replace_string(bhnd_nvram_plist *plist,
77 const char *name, const char *val);
79 void bhnd_nvram_plist_remove(bhnd_nvram_plist *plist,
82 bool bhnd_nvram_plist_contains(bhnd_nvram_plist *plist,
84 bhnd_nvram_prop *bhnd_nvram_plist_next(bhnd_nvram_plist *plist,
85 bhnd_nvram_prop *prop);
87 bhnd_nvram_prop *bhnd_nvram_plist_get_prop(bhnd_nvram_plist *plist,
89 bhnd_nvram_val *bhnd_nvram_plist_get_val(bhnd_nvram_plist *plist,
91 int bhnd_nvram_plist_get_encoded(bhnd_nvram_plist *plist,
92 const char *name, void *outp, size_t olen,
93 bhnd_nvram_type otype);
95 int bhnd_nvram_plist_get_char(bhnd_nvram_plist *plist,
96 const char *name, u_char *val);
97 int bhnd_nvram_plist_get_uint8(bhnd_nvram_plist *plist,
98 const char *name, uint8_t *val);
99 int bhnd_nvram_plist_get_uint16(bhnd_nvram_plist *plist,
100 const char *name, uint16_t *val);
101 int bhnd_nvram_plist_get_uint32(bhnd_nvram_plist *plist,
102 const char *name, uint32_t *val);
103 int bhnd_nvram_plist_get_uint64(bhnd_nvram_plist *plist,
104 const char *name, uint64_t *val);
105 int bhnd_nvram_plist_get_string(bhnd_nvram_plist *plist,
106 const char *name, const char **val);
107 int bhnd_nvram_plist_get_bool(bhnd_nvram_plist *plist,
108 const char *name, bool *val);
110 bhnd_nvram_prop *bhnd_nvram_prop_new(const char *name,
111 bhnd_nvram_val *val);
112 bhnd_nvram_prop *bhnd_nvram_prop_bytes_new(const char *name,
113 const void *inp, size_t ilen,
114 bhnd_nvram_type itype);
116 bhnd_nvram_prop *bhnd_nvram_prop_retain(bhnd_nvram_prop *prop);
117 void bhnd_nvram_prop_release(bhnd_nvram_prop *prop);
119 const char *bhnd_nvram_prop_name(bhnd_nvram_prop *prop);
120 bhnd_nvram_val *bhnd_nvram_prop_val(bhnd_nvram_prop *prop);
121 bhnd_nvram_type bhnd_nvram_prop_type(bhnd_nvram_prop *prop);
123 bool bhnd_nvram_prop_is_null(bhnd_nvram_prop *prop);
125 const void *bhnd_nvram_prop_bytes(bhnd_nvram_prop *prop,
126 size_t *olen, bhnd_nvram_type *otype);
127 int bhnd_nvram_prop_encode(bhnd_nvram_prop *prop,
128 void *outp, size_t *olen, bhnd_nvram_type otype);
130 #endif /* _BHND_NVRAM_BHND_NVRAM_PLIST_H_ */