本文整理汇总了C++中prop_object_release函数的典型用法代码示例。如果您正苦于以下问题:C++ prop_object_release函数的具体用法?C++ prop_object_release怎么用?C++ prop_object_release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prop_object_release函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fd_set_properties
static void
fd_set_properties(struct fd_softc *fd)
{
prop_dictionary_t disk_info, odisk_info, geom;
const struct fd_type *fdt;
int secsize;
fdt = fd->sc_type;
if (fdt == NULL) {
fdt = fd->sc_deftype;
if (fdt == NULL)
return;
}
disk_info = prop_dictionary_create();
geom = prop_dictionary_create();
prop_dictionary_set_uint64(geom, "sectors-per-unit",
fdt->size);
switch (fdt->secsize) {
case 2:
secsize = 512;
break;
case 3:
secsize = 1024;
break;
default:
secsize = 0;
}
prop_dictionary_set_uint32(geom, "sector-size",
secsize);
prop_dictionary_set_uint16(geom, "sectors-per-track",
fdt->sectrac);
prop_dictionary_set_uint16(geom, "tracks-per-cylinder",
fdt->heads);
prop_dictionary_set_uint64(geom, "cylinders-per-unit",
fdt->cyls);
prop_dictionary_set(disk_info, "geometry", geom);
prop_object_release(geom);
prop_dictionary_set(device_properties(fd->sc_dev),
"disk-info", disk_info);
/*
* Don't release disk_info here; we keep a reference to it.
* disk_detach() will release it when we go away.
*/
odisk_info = fd->sc_dk.dk_info;
fd->sc_dk.dk_info = disk_info;
if (odisk_info)
prop_object_release(odisk_info);
}
示例2: show_pkg_info_from_metadir
int
show_pkg_info_from_metadir(struct xbps_handle *xhp,
const char *pkgname,
const char *option)
{
prop_dictionary_t d, pkgdb_d;
const char *instdate, *pname;
bool autoinst;
d = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGPROPS);
if (d == NULL)
return EINVAL;
prop_dictionary_get_cstring_nocopy(d, "pkgname", &pname);
pkgdb_d = xbps_pkgdb_get_pkgd(xhp, pname, false);
if (pkgdb_d == NULL) {
prop_object_release(d);
return EINVAL;
}
if (prop_dictionary_get_cstring_nocopy(pkgdb_d,
"install-date", &instdate))
prop_dictionary_set_cstring_nocopy(d, "install-date",
instdate);
if (prop_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst))
prop_dictionary_set_bool(d, "automatic-install", autoinst);
if (option == NULL)
show_pkg_info(d);
else
show_pkg_info_one(d, option);
prop_object_release(d);
return 0;
}
示例3: npfctl_remove_rule
int
npfctl_remove_rule(u_long cmd, void *data)
{
struct plistref *pref = data;
prop_dictionary_t dict, errdict;
prop_object_t obj;
const char *name;
int error, numrules;
/* Retrieve and construct the rule. */
error = prop_dictionary_copyin_ioctl(pref, cmd, &dict);
if (error) {
return error;
}
/* Dictionary for error reporting. */
errdict = prop_dictionary_create();
obj = prop_dictionary_get(dict, "name");
name = prop_string_cstring_nocopy(obj);
npf_rule_t *rl;
error = npf_mk_singlerule(dict, prop_array_create(), &rl, errdict);
npf_core_enter();
numrules = npf_named_ruleset_remove(name, npf_core_ruleset(), rl);
npf_core_exit();
prop_object_release(dict);
/* Error report. */
prop_dictionary_set_int32(errdict, "errno", error);
prop_dictionary_set_int32(errdict, "numrules", numrules);
prop_dictionary_copyout_ioctl(pref, cmd, errdict);
prop_object_release(errdict);
return error;
}
示例4: _prop_array_internalize_continue
static bool
_prop_array_internalize_continue(prop_stack_t stack,
prop_object_t *obj,
struct _prop_object_internalize_context *ctx,
void *data, prop_object_t child)
{
prop_array_t array;
_PROP_ASSERT(data == NULL);
if (child == NULL)
goto bad; /* Element could not be parsed. */
array = *obj;
if (prop_array_add(array, child) == false) {
prop_object_release(child);
goto bad;
}
prop_object_release(child);
/*
* Current element is processed and added, look for next.
*/
return (_prop_array_internalize_body(stack, obj, ctx));
bad:
prop_object_release(*obj);
*obj = NULL;
return (true);
}
示例5: hdaudioctl_list
static int
hdaudioctl_list(int fd)
{
prop_dictionary_t request, response;
prop_dictionary_t dict;
prop_object_iterator_t iter;
prop_object_t obj;
prop_array_t array;
uint16_t nid, codecid;
uint16_t vendor, product;
uint32_t subsystem;
const char *device = NULL;
int error;
request = prop_dictionary_create();
if (request == NULL) {
fprintf(stderr, "out of memory\n");
return ENOMEM;
}
error = prop_dictionary_sendrecv_ioctl(request, fd,
HDAUDIO_FGRP_INFO, &response);
if (error != 0) {
perror("HDAUDIO_FGRP_INFO failed");
return error;
}
array = prop_dictionary_get(response, "function-group-info");
iter = prop_array_iterator(array);
prop_object_iterator_reset(iter);
while ((obj = prop_object_iterator_next(iter)) != NULL) {
dict = (prop_dictionary_t)obj;
prop_dictionary_get_uint16(dict, "codecid", &codecid);
prop_dictionary_get_uint16(dict, "nid", &nid);
prop_dictionary_get_uint16(dict, "vendor-id", &vendor);
prop_dictionary_get_uint16(dict, "product-id", &product);
prop_dictionary_get_uint32(dict, "subsystem-id", &subsystem);
prop_dictionary_get_cstring_nocopy(dict, "device", &device);
printf("codecid 0x%02X nid 0x%02X vendor 0x%04X "
"product 0x%04X subsystem 0x%08X device %s\n",
codecid, nid, vendor, product, subsystem,
device ? device : "<none>");
}
prop_object_release(array);
prop_object_release(response);
prop_object_release(request);
return 0;
}
示例6: prop_object_iterator_release
/*
* prop_object_iterator_release --
* Release the object iterator.
*/
void
prop_object_iterator_release(prop_object_iterator_t pi)
{
prop_object_release(pi->pi_obj);
_PROP_FREE(pi, M_TEMP);
}
示例7: npfctl_sessions_save
/*
* npfctl_sessions_save: construct a list of sessions and export for saving.
*/
int
npfctl_sessions_save(u_long cmd, void *data)
{
struct plistref *pref = data;
prop_dictionary_t sesdict;
prop_array_t selist, nplist;
int error;
/* Create a dictionary and two lists. */
sesdict = prop_dictionary_create();
selist = prop_array_create();
nplist = prop_array_create();
/* Save the sessions. */
error = npf_session_save(selist, nplist);
if (error) {
goto fail;
}
/* Set the session list, NAT policy list and export the dictionary. */
prop_dictionary_set(sesdict, "session-list", selist);
prop_dictionary_set(sesdict, "nat-policy-list", nplist);
error = prop_dictionary_copyout_ioctl(pref, cmd, sesdict);
fail:
prop_object_release(sesdict);
return error;
}
示例8: _prop_array_internalize_body
static bool
_prop_array_internalize_body(prop_stack_t stack, prop_object_t *obj,
struct _prop_object_internalize_context *ctx)
{
prop_array_t array = *obj;
_PROP_ASSERT(array != NULL);
/* Fetch the next tag. */
if (_prop_object_internalize_find_tag(ctx, NULL,
_PROP_TAG_TYPE_EITHER) == false)
goto bad;
/* Check to see if this is the end of the array. */
if (_PROP_TAG_MATCH(ctx, "array") &&
ctx->poic_tag_type == _PROP_TAG_TYPE_END) {
/* It is, so don't iterate any further. */
return (true);
}
if (_prop_stack_push(stack, array,
_prop_array_internalize_continue, NULL, NULL))
return (false);
bad:
prop_object_release(array);
*obj = NULL;
return (true);
}
示例9: npfctl_sessions_load
/*
* npfctl_sessions_load: import a list of sessions, reconstruct them and load.
*/
int
npfctl_sessions_load(u_long cmd, void *data)
{
const struct plistref *pref = data;
npf_sehash_t *sehasht = NULL;
prop_dictionary_t sesdict, sedict;
prop_object_iterator_t it;
prop_array_t selist;
int error;
/* Retrieve the dictionary containing session and NAT policy lists. */
error = prop_dictionary_copyin_ioctl(pref, cmd, &sesdict);
if (error)
return error;
/*
* Note: session objects contain the references to the NAT policy
* entries. Therefore, no need to directly access it.
*/
selist = prop_dictionary_get(sesdict, "session-list");
if (prop_object_type(selist) != PROP_TYPE_ARRAY) {
error = EINVAL;
goto fail;
}
/* Create a session hash table. */
sehasht = sess_htable_create();
if (sehasht == NULL) {
error = ENOMEM;
goto fail;
}
/*
* Iterate through and construct each session.
*/
error = 0;
it = prop_array_iterator(selist);
npf_core_enter();
while ((sedict = prop_object_iterator_next(it)) != NULL) {
/* Session - dictionary. */
if (prop_object_type(sedict) != PROP_TYPE_DICTIONARY) {
error = EINVAL;
goto fail;
}
/* Construct and insert real session structure. */
error = npf_session_restore(sehasht, sedict);
if (error) {
goto fail;
}
}
npf_core_exit();
sess_htable_reload(sehasht);
fail:
prop_object_release(selist);
if (error && sehasht) {
/* Destroy session table. */
sess_htable_destroy(sehasht);
}
return error;
}
示例10: prop_string_copy
/*
* prop_string_copy --
* Copy a string. If the original string is immutable, then the
* copy is also immutable and references the same external data.
*/
prop_string_t
prop_string_copy(prop_string_t ops)
{
prop_string_t ps;
if (! prop_object_is_string(ops))
return (NULL);
ps = _prop_string_alloc();
if (ps != NULL) {
ps->ps_size = ops->ps_size;
ps->ps_flags = ops->ps_flags;
if (ops->ps_flags & PS_F_NOCOPY)
ps->ps_immutable = ops->ps_immutable;
else {
char *cp = _PROP_MALLOC(ps->ps_size + 1, M_PROP_STRING);
if (cp == NULL) {
prop_object_release(ps);
return (NULL);
}
strcpy(cp, prop_string_contents(ops));
ps->ps_mutable = cp;
}
}
return (ps);
}
示例11: prop_array_remove
/*
* prop_array_remove --
* Remove the reference to an object from an array at the specified
* index. The array will be compacted following the removal.
*/
void
prop_array_remove(prop_array_t pa, unsigned int idx)
{
prop_object_t po;
if (! prop_object_is_array(pa))
return;
_PROP_RWLOCK_WRLOCK(pa->pa_rwlock);
_PROP_ASSERT(idx < pa->pa_count);
/* XXX Should this be a _PROP_ASSERT()? */
if (prop_array_is_immutable(pa)) {
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
return;
}
po = pa->pa_array[idx];
_PROP_ASSERT(po != NULL);
for (++idx; idx < pa->pa_count; idx++)
pa->pa_array[idx - 1] = pa->pa_array[idx];
pa->pa_count--;
pa->pa_version++;
_PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
prop_object_release(po);
}
示例12: prop_dictionary_augment
prop_dictionary_t
prop_dictionary_augment(prop_dictionary_t bottom, prop_dictionary_t top)
{
prop_object_iterator_t i;
prop_dictionary_t d;
prop_object_t ko, o;
prop_dictionary_keysym_t k;
const char *key;
d = prop_dictionary_copy_mutable(bottom);
i = prop_dictionary_iterator(top);
while ((ko = prop_object_iterator_next(i)) != NULL) {
k = (prop_dictionary_keysym_t)ko;
key = prop_dictionary_keysym_cstring_nocopy(k);
o = prop_dictionary_get_keysym(top, k);
if (o == NULL || !prop_dictionary_set(d, key, o)) {
prop_object_release((prop_object_t)d);
d = NULL;
break;
}
}
prop_object_iterator_release(i);
prop_dictionary_make_immutable(d);
return d;
}
示例13: main
int
main(int argc, char **argv)
{
modctl_load_t cmdargs;
prop_dictionary_t props;
char *propsstr;
int ch;
int flags;
flags = 0;
props = prop_dictionary_create();
while ((ch = getopt(argc, argv, "b:fi:s:")) != -1) {
switch (ch) {
case 'b':
parse_param(props, optarg, parse_bool_param);
break;
case 'f':
flags |= MODCTL_LOAD_FORCE;
break;
case 'i':
parse_param(props, optarg, parse_int_param);
break;
case 's':
parse_param(props, optarg, parse_string_param);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 1)
usage();
propsstr = prop_dictionary_externalize(props);
if (propsstr == NULL)
errx(EXIT_FAILURE, "Failed to process properties");
cmdargs.ml_filename = argv[0];
cmdargs.ml_flags = flags;
cmdargs.ml_props = propsstr;
cmdargs.ml_propslen = strlen(propsstr);
if (modctl(MODCTL_LOAD, &cmdargs)) {
err(EXIT_FAILURE, NULL);
}
free(propsstr);
prop_object_release(props);
exit(EXIT_SUCCESS);
}
示例14: dm_table_deps_ioctl
/*
* Get list of physical devices for active table.
* Get dev_t from pdev vnode and insert it into cmd_array.
*
* XXX. This function is called from lvm2tools to get information
* about physical devices, too e.g. during vgcreate.
*/
int
dm_table_deps_ioctl(prop_dictionary_t dm_dict)
{
dm_dev_t *dmv;
dm_table_t *tbl;
dm_table_entry_t *table_en;
prop_array_t cmd_array;
const char *name, *uuid;
uint32_t flags, minor;
int table_type;
name = NULL;
uuid = NULL;
dmv = NULL;
flags = 0;
prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
/* create array for dev_t's */
cmd_array = prop_array_create();
if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
return ENOENT;
}
prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
prop_dictionary_set_cstring(dm_dict, DM_IOCTL_NAME, dmv->name);
prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
aprint_debug("Getting table deps for device: %s\n", dmv->name);
/*
* if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query
* INACTIVE TABLE
*/
if (flags & DM_QUERY_INACTIVE_TABLE_FLAG)
table_type = DM_TABLE_INACTIVE;
else
table_type = DM_TABLE_ACTIVE;
tbl = dm_table_get_entry(&dmv->table_head, table_type);
SLIST_FOREACH(table_en, tbl, next)
table_en->target->deps(table_en, cmd_array);
dm_table_release(&dmv->table_head, table_type);
dm_dev_unbusy(dmv);
prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
prop_object_release(cmd_array);
return 0;
}
示例15: hdaudioctl_set
static int
hdaudioctl_set(int fd, int argc, char *argv[])
{
prop_dictionary_t request, response;
prop_array_t config = NULL;
uint16_t nid, codecid;
int error;
if (argc < 2 || argc > 3)
usage();
codecid = strtol(argv[0], NULL, 0);
nid = strtol(argv[1], NULL, 0);
if (argc == 3) {
config = prop_array_internalize_from_file(argv[2]);
if (config == NULL) {
fprintf(stderr,
"couldn't load configuration from %s\n", argv[2]);
return EIO;
}
}
request = prop_dictionary_create();
if (request == NULL) {
fprintf(stderr, "out of memory\n");
return ENOMEM;
}
prop_dictionary_set_uint16(request, "codecid", codecid);
prop_dictionary_set_uint16(request, "nid", nid);
if (config)
prop_dictionary_set(request, "pin-config", config);
error = prop_dictionary_sendrecv_ioctl(request, fd,
HDAUDIO_FGRP_SETCONFIG, &response);
if (error != 0) {
perror("HDAUDIO_FGRP_SETCONFIG failed");
return error;
}
prop_object_release(response);
prop_object_release(request);
return 0;
}