mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 07:27:59 -08:00
Add interface to set/update a data property.
This commit is contained in:
parent
b455f49267
commit
aace55b739
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mdesc.c,v 1.11 2018/09/16 12:17:05 kettenis Exp $ */
|
||||
/* $OpenBSD: mdesc.c,v 1.12 2019/07/14 14:40:55 kettenis Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 Mark Kettenis
|
||||
@ -301,6 +301,21 @@ md_get_prop_data(struct md *md, struct md_node *node, const char *name,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
md_set_prop_data(struct md *md, struct md_node *node, const char *name,
|
||||
const uint8_t *data, size_t len)
|
||||
{
|
||||
struct md_prop *prop;
|
||||
|
||||
prop = md_find_prop(md, node, name);
|
||||
if (prop == NULL || prop->tag != MD_PROP_DATA)
|
||||
return false;
|
||||
|
||||
md_free_data(md, prop->d.data);
|
||||
prop->d.data = md_add_data(md, data, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
md_delete_node(struct md *md, struct md_node *node)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mdesc.h,v 1.7 2018/09/16 12:17:05 kettenis Exp $ */
|
||||
/* $OpenBSD: mdesc.h,v 1.8 2019/07/14 14:40:55 kettenis Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 Mark Kettenis
|
||||
@ -121,6 +121,8 @@ bool md_get_prop_val(struct md *, struct md_node *, const char *, uint64_t *);
|
||||
bool md_set_prop_val(struct md *, struct md_node *, const char *, uint64_t);
|
||||
bool md_get_prop_str(struct md *, struct md_node *, const char *,
|
||||
const char **);
|
||||
bool md_set_prop_data(struct md *, struct md_node *, const char *,
|
||||
const uint8_t *, size_t);
|
||||
bool md_get_prop_data(struct md *, struct md_node *, const char *,
|
||||
const void **, size_t *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user