3 /* messaging - high level communication (send/receive messages) */
5 /* module's public interface exported to end user. */
7 /* Authors: Martin Quinson */
8 /* Copyright (C) 2003, 2004 Martin Quinson. */
10 /* This program is free software; you can redistribute it and/or modify it
11 under the terms of the license (GNU LGPL) which comes with this package. */
14 #ifndef GRAS_MESSAGES_H
15 #define GRAS_MESSAGES_H
17 /*! C++ users need love */
20 # define BEGIN_DECL extern "C" {
26 /*! C++ users need love */
34 /* End of cruft for C++ */
38 /* msgtype declaration and retrival */
39 typedef struct s_gras_msgtype gras_msgtype_t;
41 gras_error_t gras_msgtype_declare (const char *name,
42 gras_datadesc_type_t *payload);
43 gras_error_t gras_msgtype_declare_v(const char *name,
45 gras_datadesc_type_t *payload);
47 gras_error_t gras_msgtype_by_name (const char *name,
48 gras_msgtype_t **dst);
49 gras_error_t gras_msgtype_by_namev(const char *name,
51 gras_msgtype_t **dst);
56 * @msg: The message itself
57 * @Returns: true if the message was consumed by the callback.
59 * Type of message callback functions. Once a such a function is registered to
60 * handle messages of a given type with RegisterCallback(), it will be called
61 * each time such a message incomes.
63 * If the callback accepts the message, it should free it after use.
65 typedef int (*gras_cb_t)(gras_socket_t *expeditor,
67 gras_error_t gras_cb_register (gras_msgtype_t *msgtype,
69 void gras_cb_unregister(gras_msgtype_t *msgtype,
72 gras_error_t gras_msg_send(gras_socket_t *sock,
73 gras_msgtype_t *msgtype,
75 gras_error_t gras_msg_wait(double timeout,
76 gras_msgtype_t *msgt_want,
77 gras_socket_t **expeditor,
79 gras_error_t gras_msg_handle(double timeOut);
84 #endif /* GRAS_MSG_H */