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); }
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; }
nl_rproc_t * npf_rproc_create(const char *name) { prop_dictionary_t rpdict; prop_array_t extcalls; nl_rproc_t *nrp; nrp = malloc(sizeof(nl_rproc_t)); if (nrp == NULL) { return NULL; } rpdict = prop_dictionary_create(); if (rpdict == NULL) { free(nrp); return NULL; } prop_dictionary_set_cstring(rpdict, "name", name); extcalls = prop_array_create(); if (extcalls == NULL) { prop_object_release(rpdict); free(nrp); return NULL; } prop_dictionary_set(rpdict, "extcalls", extcalls); prop_object_release(extcalls); nrp->nrp_dict = rpdict; return nrp; }
nl_table_t * npf_table_create(const char *name, u_int id, int type) { prop_dictionary_t tldict; prop_array_t tblents; nl_table_t *tl; tl = malloc(sizeof(*tl)); if (tl == NULL) { return NULL; } tldict = prop_dictionary_create(); if (tldict == NULL) { free(tl); return NULL; } prop_dictionary_set_cstring(tldict, "name", name); prop_dictionary_set_uint32(tldict, "id", id); prop_dictionary_set_int32(tldict, "type", type); tblents = prop_array_create(); if (tblents == NULL) { prop_object_release(tldict); free(tl); return NULL; } prop_dictionary_set(tldict, "entries", tblents); prop_object_release(tblents); tl->ntl_dict = tldict; return tl; }
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; }
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); }
int npf_config_submit(nl_config_t *ncf, int fd) { const char *plist = ncf->ncf_plist; prop_dictionary_t npf_dict; prop_array_t rlset; int error = 0; npf_dict = prop_dictionary_create(); if (npf_dict == NULL) { return ENOMEM; } prop_dictionary_set_uint32(npf_dict, "version", NPF_VERSION); rlset = _npf_ruleset_transform(ncf->ncf_rules_list); if (rlset == NULL) { prop_object_release(npf_dict); return ENOMEM; } prop_object_release(ncf->ncf_rules_list); ncf->ncf_rules_list = rlset; prop_dictionary_set(npf_dict, "rules", ncf->ncf_rules_list); prop_dictionary_set(npf_dict, "algs", ncf->ncf_alg_list); prop_dictionary_set(npf_dict, "rprocs", ncf->ncf_rproc_list); prop_dictionary_set(npf_dict, "tables", ncf->ncf_table_list); prop_dictionary_set(npf_dict, "translation", ncf->ncf_nat_list); prop_dictionary_set_bool(npf_dict, "flush", ncf->ncf_flush); if (ncf->ncf_debug) { prop_dictionary_set(npf_dict, "debug", ncf->ncf_debug); } if (plist) { if (!prop_dictionary_externalize_to_file(npf_dict, plist)) { error = errno; } prop_object_release(npf_dict); return error; } if (fd) { error = prop_dictionary_sendrecv_ioctl(npf_dict, fd, IOC_NPF_RELOAD, &ncf->ncf_err); if (error) { prop_object_release(npf_dict); assert(ncf->ncf_err == NULL); return error; } prop_dictionary_get_int32(ncf->ncf_err, "errno", &error); } prop_object_release(npf_dict); return error; }
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; }
/* * 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); }
nl_config_t * npf_config_retrieve(int fd, bool *active, bool *loaded) { prop_dictionary_t npf_dict; nl_config_t *ncf; int error; error = prop_dictionary_recv_ioctl(fd, IOC_NPF_GETCONF, &npf_dict); if (error) { return NULL; } ncf = calloc(1, sizeof(*ncf)); if (ncf == NULL) { prop_object_release(npf_dict); return NULL; } ncf->ncf_dict = npf_dict; ncf->ncf_alg_list = prop_dictionary_get(npf_dict, "algs"); ncf->ncf_rules_list = prop_dictionary_get(npf_dict, "rules"); ncf->ncf_rproc_list = prop_dictionary_get(npf_dict, "rprocs"); ncf->ncf_table_list = prop_dictionary_get(npf_dict, "tables"); ncf->ncf_nat_list = prop_dictionary_get(npf_dict, "translation"); prop_dictionary_get_bool(npf_dict, "active", active); *loaded = (ncf->ncf_rules_list != NULL); return ncf; }
/* * 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; }
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); }
/* * 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; }
void npf_rule_destroy(nl_rule_t *rl) { prop_object_release(rl->nrl_dict); free(rl); }
int _npf_ruleset_list(int fd, const char *rname, nl_config_t *ncf) { prop_dictionary_t rldict, ret; int error; rldict = prop_dictionary_create(); if (rldict == NULL) { return ENOMEM; } prop_dictionary_set_cstring(rldict, "ruleset-name", rname); prop_dictionary_set_uint32(rldict, "command", NPF_CMD_RULE_LIST); error = prop_dictionary_sendrecv_ioctl(rldict, fd, IOC_NPF_RULE, &ret); if (!error) { prop_array_t rules; rules = prop_dictionary_get(ret, "rules"); if (rules == NULL) { return EINVAL; } prop_object_release(ncf->ncf_rules_list); ncf->ncf_rules_list = rules; } return error; }
/* * 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); }
/* * 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); }
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; }
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); }
/* * 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; }
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; }
/* * npfctl_update_rule: reload a specific rule identified by the name. */ int npfctl_update_rule(u_long cmd, void *data) { struct plistref *pref = data; prop_dictionary_t dict, errdict; prop_array_t subrules; prop_object_t obj; npf_ruleset_t *rlset; const char *name; int error; /* 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(); /* Create the ruleset and construct sub-rules. */ rlset = npf_ruleset_create(); subrules = prop_dictionary_get(dict, "subrules"); error = npf_mk_subrules(rlset, subrules, NULL, errdict); if (error) { goto out; } /* Lookup the rule by name, and replace its subset (sub-rules). */ obj = prop_dictionary_get(dict, "name"); name = prop_string_cstring_nocopy(obj); if (npf_ruleset_replace(name, rlset) == NULL) { /* Not found. */ error = ENOENT; out: /* Error path. */ npf_ruleset_destroy(rlset); } prop_object_release(dict); /* Error report. */ prop_dictionary_set_int32(errdict, "errno", error); prop_dictionary_copyout_ioctl(pref, cmd, errdict); prop_object_release(errdict); return error; }
static int quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, prop_dictionary_t cmddict, prop_array_t datas) { struct ufsmount *ump = VFSTOUFS(mp); prop_array_t replies; prop_dictionary_t data; int error = 0; if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) return EOPNOTSUPP; replies = prop_array_create(); if (replies == NULL) return ENOMEM; data = prop_dictionary_create(); if (data == NULL) { prop_object_release(replies); return ENOMEM; } #ifdef QUOTA if (ump->um_flags & UFS_QUOTA) { if (!prop_dictionary_set_int8(data, "version", 1)) error = ENOMEM; } else #endif #ifdef QUOTA2 if (ump->um_flags & UFS_QUOTA2) { if (!prop_dictionary_set_int8(data, "version", 2)) error = ENOMEM; } else #endif error = 0; if (error) prop_object_release(data); else if (!prop_array_add_and_rel(replies, data)) error = ENOMEM; if (error) prop_object_release(replies); else if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) error = ENOMEM; return error; }
/* * Configure HF results */ static int config_hf(prop_dictionary_t dict, sdp_data_t *rec) { prop_object_t obj; sdp_data_t value; int32_t channel; uint16_t attr; channel = -1; while (sdp_get_attr(rec, &attr, &value)) { switch (attr) { case SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST: channel = parse_pdl(&value, SDP_UUID_PROTOCOL_RFCOMM); break; default: break; } } if (channel == -1) return ENOATTR; obj = prop_string_create_cstring_nocopy("btsco"); if (obj == NULL || !prop_dictionary_set(dict, BTDEVtype, obj)) return errno; prop_object_release(obj); obj = prop_bool_create(true); if (obj == NULL || !prop_dictionary_set(dict, BTSCOlisten, obj)) return errno; prop_object_release(obj); obj = prop_number_create_integer(channel); if (obj == NULL || !prop_dictionary_set(dict, BTSCOchannel, obj)) return errno; prop_object_release(obj); return 0; }
bool prop_dictionary_set_and_rel(prop_dictionary_t dict, const char *key, prop_object_t po) { bool ret; if (po == NULL) return false; ret = prop_dictionary_set(dict, key, po); prop_object_release(po); return ret; }
static prop_dictionary_t _npf_debug_initonce(nl_config_t *ncf) { if (!ncf->ncf_debug) { prop_array_t iflist = prop_array_create(); ncf->ncf_debug = prop_dictionary_create(); prop_dictionary_set(ncf->ncf_debug, "interfaces", iflist); prop_object_release(iflist); } return ncf->ncf_debug; }
static int hdaudioctl_get(int fd, int argc, char *argv[]) { prop_dictionary_t request, response; prop_array_t config; uint16_t nid, codecid; const char *xml; int error; if (argc != 2) usage(); codecid = strtol(argv[0], NULL, 0); nid = strtol(argv[1], NULL, 0); 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); error = prop_dictionary_sendrecv_ioctl(request, fd, HDAUDIO_FGRP_GETCONFIG, &response); if (error != 0) { perror("HDAUDIO_FGRP_GETCONFIG failed"); return error; } config = prop_dictionary_get(response, "pin-config"); xml = prop_array_externalize(config); printf("%s\n", xml); prop_object_release(response); prop_object_release(request); return 0; }
static void addprop_data(device_t dev, const char *name, const uint8_t *data, int len) { prop_data_t pd; pd = prop_data_create_data(data, len); KASSERT(pd != NULL); if (prop_dictionary_set(device_properties(dev), name, pd) == false) { printf("WARNING: unable to set %s property for %s\n", name, device_xname(dev)); } prop_object_release(pd); }
static void addprop_integer(struct device *dev, const char *name, uint32_t val) { prop_number_t pn; pn = prop_number_create_integer(val); KASSERT(pn != NULL); if (prop_dictionary_set(device_properties(dev), name, pn) == false) { printf("WARNING: unable to set %s property for %s", name, device_xname(dev)); } prop_object_release(pn); }
int npf_rule_setinfo(nl_rule_t *rl, const void *info, size_t len) { prop_dictionary_t rldict = rl->nrl_dict; prop_data_t idata; if ((idata = prop_data_create_data(info, len)) == NULL) { return ENOMEM; } prop_dictionary_set(rldict, "info", idata); prop_object_release(idata); return 0; }