]>
code.delx.au - pulseaudio/blob - src/polypcore/authkey-prop.c
6172d4320a6be3787a68140a0628a4234350fc46
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 <polyp/xmalloc.h>
27 #include <polypcore/props.h>
28 #include <polypcore/log.h>
30 #include "authkey-prop.h"
37 int pa_authkey_prop_get(pa_core
*c
, const char *name
, void *data
, size_t len
) {
38 struct authkey_data
*a
;
39 assert(c
&& name
&& data
&& len
> 0);
41 if (!(a
= pa_property_get(c
, name
)))
44 assert(a
->length
== len
);
45 memcpy(data
, a
+1, len
);
49 int pa_authkey_prop_put(pa_core
*c
, const char *name
, const void *data
, size_t len
) {
50 struct authkey_data
*a
;
53 if (pa_property_get(c
, name
))
56 a
= pa_xmalloc(sizeof(struct authkey_data
) + len
);
59 memcpy(a
+1, data
, len
);
61 pa_property_set(c
, name
, a
);
66 void pa_authkey_prop_ref(pa_core
*c
, const char *name
) {
67 struct authkey_data
*a
;
70 a
= pa_property_get(c
, name
);
71 assert(a
&& a
->ref
>= 1);
76 void pa_authkey_prop_unref(pa_core
*c
, const char *name
) {
77 struct authkey_data
*a
;
80 a
= pa_property_get(c
, name
);
81 assert(a
&& a
->ref
>= 1);
84 pa_property_remove(c
, name
);