Path: blob/main/sys/dev/bhnd/nvram/bhnd_nvram_plist.h
39536 views
/*-1* Copyright (c) 2015-2016 Landon Fuller <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer,9* without modification.10* 2. Redistributions in binary form must reproduce at minimum a disclaimer11* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any12* redistribution must be conditioned upon including a substantially13* similar Disclaimer requirement for further binary redistribution.14*15* NO WARRANTY16* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY19* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL20* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,21* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF22* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS23* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER24* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)25* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF26* THE POSSIBILITY OF SUCH DAMAGES.27*28*/2930#ifndef _BHND_NVRAM_BHND_NVRAM_PLIST_H_31#define _BHND_NVRAM_BHND_NVRAM_PLIST_H_3233#ifdef _KERNEL34#include <sys/types.h>35#else /* !_KERNEL */36#include <stdbool.h>37#include <stdint.h>38#endif /* _KERNEL */3940#include "bhnd_nvram.h"41#include "bhnd_nvram_value.h"4243typedef struct bhnd_nvram_prop bhnd_nvram_prop;44typedef struct bhnd_nvram_plist bhnd_nvram_plist;4546bhnd_nvram_plist *bhnd_nvram_plist_new(void);47bhnd_nvram_plist *bhnd_nvram_plist_retain(bhnd_nvram_plist *plist);48void bhnd_nvram_plist_release(bhnd_nvram_plist *plist);4950bhnd_nvram_plist *bhnd_nvram_plist_copy(bhnd_nvram_plist *plist);5152size_t bhnd_nvram_plist_count(bhnd_nvram_plist *plist);5354int bhnd_nvram_plist_append_list(bhnd_nvram_plist *plist,55bhnd_nvram_plist *tail);5657int bhnd_nvram_plist_append(bhnd_nvram_plist *plist,58bhnd_nvram_prop *prop);59int bhnd_nvram_plist_append_val(bhnd_nvram_plist *plist,60const char *name, bhnd_nvram_val *val);61int bhnd_nvram_plist_append_bytes(bhnd_nvram_plist *plist,62const char *name, const void *inp, size_t ilen,63bhnd_nvram_type itype);64int bhnd_nvram_plist_append_string(bhnd_nvram_plist *plist,65const char *name, const char *val);6667int bhnd_nvram_plist_replace(bhnd_nvram_plist *plist,68bhnd_nvram_prop *prop);69int bhnd_nvram_plist_replace_val(bhnd_nvram_plist *plist,70const char *name, bhnd_nvram_val *val);71int bhnd_nvram_plist_replace_bytes(bhnd_nvram_plist *plist,72const char *name, const void *inp, size_t ilen,73bhnd_nvram_type itype);74int bhnd_nvram_plist_replace_string(bhnd_nvram_plist *plist,75const char *name, const char *val);7677void bhnd_nvram_plist_remove(bhnd_nvram_plist *plist,78const char *name);7980bool bhnd_nvram_plist_contains(bhnd_nvram_plist *plist,81const char *name);82bhnd_nvram_prop *bhnd_nvram_plist_next(bhnd_nvram_plist *plist,83bhnd_nvram_prop *prop);8485bhnd_nvram_prop *bhnd_nvram_plist_get_prop(bhnd_nvram_plist *plist,86const char *name);87bhnd_nvram_val *bhnd_nvram_plist_get_val(bhnd_nvram_plist *plist,88const char *name);89int bhnd_nvram_plist_get_encoded(bhnd_nvram_plist *plist,90const char *name, void *outp, size_t olen,91bhnd_nvram_type otype);9293int bhnd_nvram_plist_get_char(bhnd_nvram_plist *plist,94const char *name, u_char *val);95int bhnd_nvram_plist_get_uint8(bhnd_nvram_plist *plist,96const char *name, uint8_t *val);97int bhnd_nvram_plist_get_uint16(bhnd_nvram_plist *plist,98const char *name, uint16_t *val);99int bhnd_nvram_plist_get_uint32(bhnd_nvram_plist *plist,100const char *name, uint32_t *val);101int bhnd_nvram_plist_get_uint64(bhnd_nvram_plist *plist,102const char *name, uint64_t *val);103int bhnd_nvram_plist_get_string(bhnd_nvram_plist *plist,104const char *name, const char **val);105int bhnd_nvram_plist_get_bool(bhnd_nvram_plist *plist,106const char *name, bool *val);107108bhnd_nvram_prop *bhnd_nvram_prop_new(const char *name,109bhnd_nvram_val *val);110bhnd_nvram_prop *bhnd_nvram_prop_bytes_new(const char *name,111const void *inp, size_t ilen,112bhnd_nvram_type itype);113114bhnd_nvram_prop *bhnd_nvram_prop_retain(bhnd_nvram_prop *prop);115void bhnd_nvram_prop_release(bhnd_nvram_prop *prop);116117const char *bhnd_nvram_prop_name(bhnd_nvram_prop *prop);118bhnd_nvram_val *bhnd_nvram_prop_val(bhnd_nvram_prop *prop);119bhnd_nvram_type bhnd_nvram_prop_type(bhnd_nvram_prop *prop);120121bool bhnd_nvram_prop_is_null(bhnd_nvram_prop *prop);122123const void *bhnd_nvram_prop_bytes(bhnd_nvram_prop *prop,124size_t *olen, bhnd_nvram_type *otype);125int bhnd_nvram_prop_encode(bhnd_nvram_prop *prop,126void *outp, size_t *olen, bhnd_nvram_type otype);127128#endif /* _BHND_NVRAM_BHND_NVRAM_PLIST_H_ */129130131