]>
code.delx.au - pulseaudio/blob - src/pulsecore/authkey-prop.c
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
30 #include <pulse/xmalloc.h>
32 #include <pulsecore/props.h>
33 #include <pulsecore/macro.h>
34 #include <pulsecore/log.h>
35 #include <pulsecore/refcnt.h>
37 #include "authkey-prop.h"
44 int pa_authkey_prop_get(pa_core
*c
, const char *name
, void *data
, size_t len
) {
45 struct authkey_data
*a
;
52 if (!(a
= pa_property_get(c
, name
)))
55 pa_assert(a
->length
== len
);
56 memcpy(data
, (uint8_t*) a
+ PA_ALIGN(sizeof(struct authkey_data
)), len
);
61 int pa_authkey_prop_put(pa_core
*c
, const char *name
, const void *data
, size_t len
) {
62 struct authkey_data
*a
;
67 if (pa_property_get(c
, name
))
70 a
= pa_xmalloc(PA_ALIGN(sizeof(struct authkey_data
)) + len
);
73 memcpy((uint8_t*) a
+ PA_ALIGN(sizeof(struct authkey_data
)), data
, len
);
75 pa_property_set(c
, name
, a
);
80 void pa_authkey_prop_ref(pa_core
*c
, const char *name
) {
81 struct authkey_data
*a
;
86 a
= pa_property_get(c
, name
);
88 pa_assert(PA_REFCNT_VALUE(a
) >= 1);
92 void pa_authkey_prop_unref(pa_core
*c
, const char *name
) {
93 struct authkey_data
*a
;
98 a
= pa_property_get(c
, name
);
100 pa_assert(PA_REFCNT_VALUE(a
) >= 1);
102 if (PA_REFCNT_DEC(a
) <= 0) {
103 pa_property_remove(c
, name
);