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

120 lines
3.8 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>
#ifndef DFT_DOMAIN
#define DFT_DOMAIN g_quark_from_string(G_LOG_DOMAIN)
#endif
2011-04-08 12:58:15 +00:00
typedef char *(*TransportCB)(void *arg, const gchar *fcall_str,
size_t fcall_len, size_t *ret_len);
2011-09-14 13:55:05 +00:00
/**
* @rpc_priv is used by the rpc_client to store information related to
* this rpc call.
* @fcall_str is an allocated string, and the sender should free it
* when not needed.
*/
typedef int (*AsyncTransportSend)(void *arg, gchar *fcall_str,
2011-09-13 05:07:31 +00:00
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 send;
2011-04-08 12:58:15 +00:00
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);
2012-06-03 16:19:16 +00:00
void
searpc_client_call (SearpcClient *client, const char *fname,
const char *ret_type, GType gobject_type,
2012-06-03 16:19:16 +00:00
void *ret_ptr, GError **error,
int n_params, ...);
int
searpc_client_call__int (SearpcClient *client, const char *fname,
GError **error, int n_params, ...);
gint64
searpc_client_call__int64 (SearpcClient *client, const char *fname,
GError **error, int n_params, ...);
char *
searpc_client_call__string (SearpcClient *client, const char *fname,
GError **error, int n_params, ...);
GObject *
searpc_client_call__object (SearpcClient *client, const char *fname,
GType object_type,
2012-06-03 16:19:16 +00:00
GError **error, int n_params, ...);
GList*
searpc_client_call__objlist (SearpcClient *client, const char *fname,
GType object_type,
2012-06-03 16:19:16 +00:00
GError **error, int n_params, ...);
2011-04-08 12:58:15 +00:00
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
2012-06-03 16:19:16 +00:00
int
searpc_client_async_call__int (SearpcClient *client,
const char *fname,
AsyncCallback callback, void *cbdata,
int n_params, ...);
int
searpc_client_async_call__int64 (SearpcClient *client,
const char *fname,
AsyncCallback callback, void *cbdata,
int n_params, ...);
int
searpc_client_async_call__string (SearpcClient *client,
const char *fname,
AsyncCallback callback, void *cbdata,
int n_params, ...);
int
searpc_client_async_call__object (SearpcClient *client,
const char *fname,
AsyncCallback callback,
GType object_type, void *cbdata,
2012-06-03 16:19:16 +00:00
int n_params, ...);
int
searpc_client_async_call__objlist (SearpcClient *client,
const char *fname,
AsyncCallback callback,
GType object_type, void *cbdata,
2012-06-03 16:19:16 +00:00
int n_params, ...);
2011-09-13 05:07:31 +00:00
2011-09-14 13:55:05 +00:00
/* called by the transport layer, the rpc layer should be able to
* modify the str, but not take ownership of it */
2011-09-13 05:07:31 +00:00
int
searpc_client_generic_callback (char *retstr, size_t len,
void *vdata, const char *errstr);
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
#endif