1 | //x11.c: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010 |
---|
5 | * The code (may) include prototypes and comments (and maybe |
---|
6 | * other code fragements) from libpulse*. They are mostly copyrighted by: |
---|
7 | * Lennart Poettering <poettering@users.sourceforge.net> and |
---|
8 | * Pierre Ossman <drzeus@drzeus.cx> |
---|
9 | * |
---|
10 | * This file is part of libroarpulse a part of RoarAudio, |
---|
11 | * a cross-platform sound system for both, home and professional use. |
---|
12 | * See README for details. |
---|
13 | * |
---|
14 | * This file is free software; you can redistribute it and/or modify |
---|
15 | * it under the terms of the GNU General Public License version 3 |
---|
16 | * as published by the Free Software Foundation. |
---|
17 | * |
---|
18 | * RoarAudio is distributed in the hope that it will be useful, |
---|
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | * GNU General Public License for more details. |
---|
22 | * |
---|
23 | * You should have received a copy of the GNU General Public License |
---|
24 | * along with this software; see the file COPYING. If not, write to |
---|
25 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
26 | * Boston, MA 02110-1301, USA. |
---|
27 | * |
---|
28 | * NOTE for everyone want's to change something and send patches: |
---|
29 | * read README and HACKING! There a addition information on |
---|
30 | * the license of this document you need to read before you send |
---|
31 | * any patches. |
---|
32 | * |
---|
33 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
34 | * or libpulse*: |
---|
35 | * The libs libroaresd, libroararts and libroarpulse link this libroar |
---|
36 | * and are therefore GPL. Because of this it may be illigal to use |
---|
37 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
38 | */ |
---|
39 | |
---|
40 | #include <libroarpulse/libroarpulse.h> |
---|
41 | |
---|
42 | #ifndef ROAR_HAVE_LIBX11 |
---|
43 | typedef void Display; |
---|
44 | #endif |
---|
45 | |
---|
46 | void pa_x11_set_prop(Display *d, const char *name, const char *data) { |
---|
47 | struct roar_x11_connection * x11con = roar_x11_connect_display(d); |
---|
48 | |
---|
49 | if ( x11con == NULL ) |
---|
50 | return; |
---|
51 | |
---|
52 | roar_x11_set_prop(x11con, name, data); |
---|
53 | |
---|
54 | roar_x11_disconnect(x11con); |
---|
55 | } |
---|
56 | |
---|
57 | void pa_x11_del_prop(Display *d, const char *name) { |
---|
58 | struct roar_x11_connection * x11con = roar_x11_connect_display(d); |
---|
59 | |
---|
60 | if ( x11con == NULL ) |
---|
61 | return; |
---|
62 | |
---|
63 | roar_x11_delete_prop(x11con, name); |
---|
64 | |
---|
65 | roar_x11_disconnect(x11con); |
---|
66 | } |
---|
67 | |
---|
68 | char* pa_x11_get_prop(Display *d, const char *name, char *p, size_t l) { |
---|
69 | struct roar_x11_connection * x11con = roar_x11_connect_display(d); |
---|
70 | char * val; |
---|
71 | size_t len; |
---|
72 | |
---|
73 | if ( x11con == NULL ) |
---|
74 | return NULL; |
---|
75 | |
---|
76 | val = roar_x11_get_prop(x11con, name); |
---|
77 | |
---|
78 | roar_x11_disconnect(x11con); |
---|
79 | |
---|
80 | if ( val == NULL ) |
---|
81 | return NULL; |
---|
82 | |
---|
83 | len = strlen(val); |
---|
84 | |
---|
85 | if ( (l - 1) < len ) |
---|
86 | len = l - 1; |
---|
87 | |
---|
88 | memcpy(p, val, len); |
---|
89 | p[len] = 0; |
---|
90 | |
---|
91 | return p; |
---|
92 | } |
---|
93 | |
---|
94 | //ll |
---|