1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-04-28 10:33:20 +00:00
libsearpc/lib/searpc-client.h

82 lines
2.3 KiB
C
Raw Normal View History

2011-04-08 12:58:15 +00:00
#ifndef SEARPC_CLIENT_H
#define SEARPC_CLIENT_H
#include <glib.h>
#include <glib-object.h>
typedef char *(*TransportCB)(void *arg, const gchar *fcall_str,
size_t fcall_len, size_t *ret_len);
2011-09-13 05:07:31 +00:00
/* rpc_priv is used by the rpc_client to store information related to
* this rpc call. */
typedef int (*AsyncTransportSend)(void *arg, const gchar *fcall_str,
size_t fcall_len, void *rpc_priv);
typedef void (*AsyncCallback) (void *result, void *user_data, GError *error);
2011-04-08 12:58:15 +00:00
typedef struct {
TransportCB transport;
void *arg;
2011-09-13 05:07:31 +00:00
AsyncTransportSend async_send;
void *async_arg;
2011-04-08 12:58:15 +00:00
} SearpcClient;
SearpcClient *searpc_client_new ();
2011-04-08 12:58:15 +00:00
void searpc_client_free (SearpcClient *client);
char* searpc_client_transport_send (SearpcClient *client,
const gchar *fcall_str,
size_t fcall_len,
size_t *ret_len);
2011-09-13 05:07:31 +00:00
/**
* Send the serialized function call to server.
*
* @fcall_str: the serialized function.
* @ret_type: the return type.
* @gtype: specify the type id if @ret_type is `object` or `objlist`,
* or 0 otherwise.
* @cbdata: the data that will be given to the callback.
*/
int searpc_client_async_call (SearpcClient *client,
const gchar *fcall_str,
size_t fcall_len,
AsyncCallback callback,
const gchar *ret_type,
int gtype,
void *cbdata);
int
searpc_client_generic_callback (char *retstr, size_t len,
void *vdata, const char *errstr);
2011-04-08 12:58:15 +00:00
#include <searpc-fcall.h>
char*
searpc_client_fret__string (char *data, size_t len, GError **error);
int
searpc_client_fret__int (char *data, size_t len, GError **error);
GObject*
searpc_client_fret__object (GType gtype, char *data,
size_t len, GError **error);
2011-04-08 12:58:15 +00:00
GList*
searpc_client_fret__objlist (GType gtype, char *data,
size_t len, GError **error);
2011-04-08 12:58:15 +00:00
/* in case of transport error, the following code and message will be
* set in GError */
2011-04-08 12:58:15 +00:00
#define TRANSPORT_ERROR "Transport Error"
#define TRANSPORT_ERROR_CODE 500
#include <searpc-dfun.h>
#endif