8468a552baa0c13f2599d2474e4619e77a3b8fe1
[external/dbus-glib.git] / dbus / dbus-gutils.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-gutils.h Utils shared between convenience lib and installed lib
3  *
4  * Copyright (C) 2003  Red Hat, Inc.
5  *
6  * Licensed under the Academic Free License version 2.1
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23
24 #ifndef DBUS_GLIB_UTILS_H
25 #define DBUS_GLIB_UTILS_H
26
27 #include <dbus/dbus.h>
28 #include <glib-object.h>
29
30 G_BEGIN_DECLS
31
32 char      **_dbus_gutils_split_path     (const char *path);
33
34 char       *_dbus_gutils_wincaps_to_uscore (const char *uscore);
35
36 /* These munge the pointer to enforce that a plain cast won't work,
37  * accessor functions must be used; i.e. to ensure the ABI
38  * reflects our encapsulation.
39  */
40 #define _DBUS_POINTER_SHIFT(p)   ((void*) (((char*)p) + sizeof (void*)))
41 #define _DBUS_POINTER_UNSHIFT(p) ((void*) (((char*)p) - sizeof (void*)))
42
43 #define DBUS_CONNECTION_FROM_G_CONNECTION(x)     ((DBusConnection*) _DBUS_POINTER_UNSHIFT(x))
44 #define DBUS_MESSAGE_FROM_G_MESSAGE(x)           ((DBusMessage*) _DBUS_POINTER_UNSHIFT(x))
45 #define DBUS_PENDING_CALL_FROM_G_PENDING_CALL(x) ((DBusPendingCall*) _DBUS_POINTER_UNSHIFT(x))
46
47 #define DBUS_G_CONNECTION_FROM_CONNECTION(x)     ((DBusGConnection*) _DBUS_POINTER_SHIFT(x))
48 #define DBUS_G_MESSAGE_FROM_MESSAGE(x)           ((DBusGMessage*) _DBUS_POINTER_SHIFT(x))
49 #define DBUS_G_PENDING_CALL_FROM_PENDING_CALL(x) ((DBusGPendingCall*) _DBUS_POINTER_SHIFT(x))
50
51 G_END_DECLS
52
53 #endif /* DBUS_GLIB_UTILS_H */