Change scanner.c license to MIT
[profile/ivi/wayland.git] / wayland / connection.h
1 /*
2  * Copyright © 2008 Kristian Høgsberg
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that copyright
7  * notice and this permission notice appear in supporting documentation, and
8  * that the name of the copyright holders not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission.  The copyright holders make no representations
11  * about the suitability of this software for any purpose.  It is provided "as
12  * is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20  * OF THIS SOFTWARE.
21  */
22
23 #ifndef _CONNECTION_H_
24 #define _CONNECTION_H_
25
26 #include <stdarg.h>
27 #include "wayland-util.h"
28
29 struct wl_connection;
30 struct wl_closure;
31
32 #define WL_CONNECTION_READABLE 0x01
33 #define WL_CONNECTION_WRITABLE 0x02
34
35 typedef int (*wl_connection_update_func_t)(struct wl_connection *connection,
36                                            uint32_t mask, void *data);
37
38 struct wl_connection *wl_connection_create(int fd,
39                                            wl_connection_update_func_t update,
40                                            void *data);
41 void wl_connection_destroy(struct wl_connection *connection);
42 void wl_connection_copy(struct wl_connection *connection, void *data, size_t size);
43 void wl_connection_consume(struct wl_connection *connection, size_t size);
44 int wl_connection_data(struct wl_connection *connection, uint32_t mask);
45 void wl_connection_write(struct wl_connection *connection, const void *data, size_t count);
46
47 struct wl_closure *
48 wl_connection_vmarshal(struct wl_connection *connection,
49                        struct wl_object *sender,
50                        uint32_t opcode, va_list ap,
51                        const struct wl_message *message);
52
53 struct wl_closure *
54 wl_connection_demarshal(struct wl_connection *connection,
55                         uint32_t size,
56                         struct wl_hash_table *objects,
57                         const struct wl_message *message);
58 void
59 wl_closure_invoke(struct wl_closure *closure,
60                   struct wl_object *target, void (*func)(void), void *data);
61 void
62 wl_closure_send(struct wl_closure *closure, struct wl_connection *connection);
63 void
64 wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send);
65 void
66 wl_closure_destroy(struct wl_closure *closure);
67
68 #endif