Lines Matching defs:plist

50 				     bhnd_nvram_plist *plist, const char *name);
64 bhnd_nvram_plist *plist;
66 plist = bhnd_nv_calloc(1, sizeof(*plist));
67 if (plist == NULL)
71 plist->refs = 1;
74 plist->num_entries = 0;
75 TAILQ_INIT(&plist->entries);
78 for (size_t i = 0; i < nitems(plist->names); i++)
79 LIST_INIT(&plist->names[i]);
81 return (plist);
85 * Retain a reference and return @p plist to the caller.
90 * @param plist The property list to be retained.
93 bhnd_nvram_plist_retain(bhnd_nvram_plist *plist)
95 BHND_NV_ASSERT(plist->refs >= 1, ("plist over-released"));
97 refcount_acquire(&plist->refs);
98 return (plist);
102 * Release a reference to @p plist.
106 * @param plist The property list to be released.
109 bhnd_nvram_plist_release(bhnd_nvram_plist *plist)
113 BHND_NV_ASSERT(plist->refs >= 1, ("plist over-released"));
116 if (!refcount_release(&plist->refs))
120 TAILQ_FOREACH_SAFE(ple, &plist->entries, pl_link, ple_next) {
125 /* Free plist instance */
126 bhnd_nv_free(plist);
130 * Return a shallow copy of @p plist.
139 bhnd_nvram_plist_copy(bhnd_nvram_plist *plist)
145 /* Allocate new, empty plist */
151 while ((prop = bhnd_nvram_plist_next(plist, prop)) != NULL) {
169 * Return the number of properties in @p plist.
172 bhnd_nvram_plist_count(bhnd_nvram_plist *plist)
174 return (plist->num_entries);
178 * Return true if @p plist contains a property name @p name, false otherwise.
180 * @param plist The property list to be queried.
184 bhnd_nvram_plist_contains(bhnd_nvram_plist *plist, const char *name)
186 if (bhnd_nvram_plist_get_entry(plist, name) != NULL)
194 * of @p prop, maintaining the property's current order in @p plist.
196 * If a matching property is not found in @p plist, @p prop will instead be
199 * @param plist The property list to be modified.
204 * @retval non-zero if modifying @p plist otherwise fails, a regular unix
208 bhnd_nvram_plist_replace(bhnd_nvram_plist *plist, bhnd_nvram_prop *prop)
213 entry = bhnd_nvram_plist_get_entry(plist, prop->name);
216 return (bhnd_nvram_plist_append(plist, prop));
228 * maintaining the property's order in @p plist.
230 * If @p name is not found in @p plist, a new property will be appended.
232 * @param plist The property list to be modified.
238 * @retval non-zero if modifying @p plist otherwise fails, a regular unix
242 bhnd_nvram_plist_replace_val(bhnd_nvram_plist *plist, const char *name,
253 error = bhnd_nvram_plist_replace(plist, prop);
263 * The current property order of @p name in @p plist will be maintained.
265 * If @p name is not found in @p plist, a new property will be appended.
267 * @param plist The property list to be modified.
275 * @retval non-zero if modifying @p plist otherwise fails, a regular unix
279 bhnd_nvram_plist_replace_bytes(bhnd_nvram_plist *plist, const char *name,
288 error = bhnd_nvram_plist_replace(plist, prop);
298 * The current property order of @p name in @p plist will be maintained.
300 * If @p name is not found in @p plist, a new property will be appended.
302 * @param plist The property list to be modified.
308 * @retval non-zero if modifying @p plist otherwise fails, a regular unix
312 bhnd_nvram_plist_replace_string(bhnd_nvram_plist *plist, const char *name,
315 return (bhnd_nvram_plist_replace_bytes(plist, name, val, strlen(val)+1,
322 * @param plist The property list to be modified.
326 bhnd_nvram_plist_remove(bhnd_nvram_plist *plist, const char *name)
331 entry = bhnd_nvram_plist_get_entry(plist, name);
336 TAILQ_REMOVE(&plist->entries, entry, pl_link);
339 /* Free plist entry */
344 BHND_NV_ASSERT(plist->num_entries > 0, ("entry count over-release"));
345 plist->num_entries--;
351 * @param plist The property list to be queried.
358 bhnd_nvram_plist_get_entry(bhnd_nvram_plist *plist, const char *name)
365 hash_list = &plist->names[h % nitems(plist->names)];
377 * Append all properties from @p tail to @p plist.
379 * @param plist The property list to be modified.
384 * @retval EEXIST an existing property from @p tail was found in @p plist.
387 bhnd_nvram_plist_append_list(bhnd_nvram_plist *plist, bhnd_nvram_plist *tail)
394 if ((error = bhnd_nvram_plist_append(plist, p)))
402 * Append @p prop to @p plist.
404 * @param plist The property list to be modified.
409 * @retval EEXIST an existing property with @p name was found in @p plist.
412 bhnd_nvram_plist_append(bhnd_nvram_plist *plist, bhnd_nvram_prop *prop)
418 if (bhnd_nvram_plist_contains(plist, prop->name))
422 if (plist->num_entries == SIZE_MAX)
433 TAILQ_INSERT_TAIL(&plist->entries, entry, pl_link);
437 hash_list = &plist->names[h % nitems(plist->names)];
441 plist->num_entries++;
447 * Append a new property to @p plist with @p name and @p val.
449 * @param plist The property list to be modified.
455 * @retval EEXIST an existing property with @p name was found in @p plist.
458 bhnd_nvram_plist_append_val(bhnd_nvram_plist *plist, const char *name,
467 error = bhnd_nvram_plist_append(plist, prop);
474 * Append a new property to @p plist, copying the property value from the
477 * @param plist The property list to be modified.
485 * @retval EEXIST an existing property with @p name was found in @p plist.
488 bhnd_nvram_plist_append_bytes(bhnd_nvram_plist *plist, const char *name,
497 error = bhnd_nvram_plist_append(plist, prop);
504 * Append a new string property to @p plist, copying the property value from
507 * @param plist The property list to be modified.
513 * @retval EEXIST an existing property with @p name was found in @p plist.
516 bhnd_nvram_plist_append_string(bhnd_nvram_plist *plist, const char *name,
519 return (bhnd_nvram_plist_append_bytes(plist, name, val, strlen(val)+1,
524 * Iterate over all properties in @p plist.
526 * @param plist The property list to be iterated.
527 * @param prop A property in @p plist, or NULL to return the first
528 * property in @p plist.
530 * @retval non-NULL A borrowed reference to the next property in @p plist.
532 * is not found in @p plist.
535 bhnd_nvram_plist_next(bhnd_nvram_plist *plist, bhnd_nvram_prop *prop)
540 if ((entry = TAILQ_FIRST(&plist->entries)) == NULL)
547 if ((entry = bhnd_nvram_plist_get_entry(plist, prop->name)) == NULL)
563 * not found in @p plist.
565 * @param plist The property list to be queried.
572 bhnd_nvram_plist_get_prop(bhnd_nvram_plist *plist, const char *name)
576 if ((entry = bhnd_nvram_plist_get_entry(plist, name)) == NULL)
584 * @p name is not found in @p plist.
586 * @param plist The property list to be queried.
593 bhnd_nvram_plist_get_val(bhnd_nvram_plist *plist, const char *name)
597 if ((prop = bhnd_nvram_plist_get_prop(plist, name)) == NULL)
607 * @param plist The property list to be queried.
617 * @retval ENOENT If @p name is not found in @p plist.
626 bhnd_nvram_plist_get_encoded(bhnd_nvram_plist *plist, const char *name,
631 if ((prop = bhnd_nvram_plist_get_prop(plist, name)) == NULL)
640 * @param plist The property list to be queried.
645 * @retval ENOENT If @p name is not found in @p plist.
651 bhnd_nvram_plist_get_char(bhnd_nvram_plist *plist, const char *name,
654 return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val),
661 * @param plist The property list to be queried.
666 * @retval ENOENT If @p name is not found in @p plist.
672 bhnd_nvram_plist_get_uint8(bhnd_nvram_plist *plist, const char *name,
675 return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val),
682 * @param plist The property list to be queried.
687 * @retval ENOENT If @p name is not found in @p plist.
693 bhnd_nvram_plist_get_uint16(bhnd_nvram_plist *plist, const char *name,
696 return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val),
703 * @param plist The property list to be queried.
708 * @retval ENOENT If @p name is not found in @p plist.
714 bhnd_nvram_plist_get_uint32(bhnd_nvram_plist *plist, const char *name,
717 return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val),
724 * @param plist The property list to be queried.
729 * @retval ENOENT If @p name is not found in @p plist.
735 bhnd_nvram_plist_get_uint64(bhnd_nvram_plist *plist, const char *name,
738 return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val),
745 * @param plist The property list to be queried.
750 * @retval ENOENT If @p name is not found in @p plist.
756 bhnd_nvram_plist_get_bool(bhnd_nvram_plist *plist, const char *name,
759 return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val),