4 This file is part of PulseAudio.
6 Copyright 2004-2006 Lennart Poettering
8 PulseAudio is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published
10 by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
13 PulseAudio is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with PulseAudio; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include <pulse/xmalloc.h>
29 #include <pulsecore/props.h>
30 #include <pulsecore/log.h>
32 #include "authkey-prop.h"
39 int pa_authkey_prop_get(pa_core *c, const char *name, void *data, size_t len) {
40 struct authkey_data *a;
41 assert(c && name && data && len > 0);
43 if (!(a = pa_property_get(c, name)))
46 assert(a->length == len);
47 memcpy(data, a+1, len);
51 int pa_authkey_prop_put(pa_core *c, const char *name, const void *data, size_t len) {
52 struct authkey_data *a;
55 if (pa_property_get(c, name))
58 a = pa_xmalloc(sizeof(struct authkey_data) + len);
61 memcpy(a+1, data, len);
63 pa_property_set(c, name, a);
68 void pa_authkey_prop_ref(pa_core *c, const char *name) {
69 struct authkey_data *a;
72 a = pa_property_get(c, name);
73 assert(a && a->ref >= 1);
78 void pa_authkey_prop_unref(pa_core *c, const char *name) {
79 struct authkey_data *a;
82 a = pa_property_get(c, name);
83 assert(a && a->ref >= 1);
86 pa_property_remove(c, name);