]>
code.delx.au - pulseaudio/blob - src/polypcore/authkey-prop.c
4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include <polypcore/xmalloc.h>
26 #include <polypcore/props.h>
27 #include <polypcore/log.h>
29 #include "authkey-prop.h"
36 int pa_authkey_prop_get(pa_core
*c
, const char *name
, void *data
, size_t len
) {
37 struct authkey_data
*a
;
38 assert(c
&& name
&& data
&& len
> 0);
40 if (!(a
= pa_property_get(c
, name
)))
43 assert(a
->length
== len
);
44 memcpy(data
, a
+1, len
);
48 int pa_authkey_prop_put(pa_core
*c
, const char *name
, const void *data
, size_t len
) {
49 struct authkey_data
*a
;
52 if (pa_property_get(c
, name
))
55 a
= pa_xmalloc(sizeof(struct authkey_data
) + len
);
58 memcpy(a
+1, data
, len
);
60 pa_property_set(c
, name
, a
);
65 void pa_authkey_prop_ref(pa_core
*c
, const char *name
) {
66 struct authkey_data
*a
;
69 a
= pa_property_get(c
, name
);
70 assert(a
&& a
->ref
>= 1);
75 void pa_authkey_prop_unref(pa_core
*c
, const char *name
) {
76 struct authkey_data
*a
;
79 a
= pa_property_get(c
, name
);
80 assert(a
&& a
->ref
>= 1);
83 pa_property_remove(c
, name
);