2011-04-08 12:58:15 +00:00
|
|
|
#ifndef SEARPC_CLIENT_H
|
|
|
|
#define SEARPC_CLIENT_H
|
|
|
|
|
2022-04-25 03:58:24 +00:00
|
|
|
#include <glib.h>
|
|
|
|
#include <glib-object.h>
|
|
|
|
#include <jansson.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
#ifdef LIBSEARPC_EXPORTS
|
|
|
|
#define LIBSEARPC_API __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define LIBSEARPC_API
|
|
|
|
#endif
|
|
|
|
|
2012-05-04 07:04:43 +00:00
|
|
|
#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);
|
|
|
|
|
2016-06-15 06:48:04 +00:00
|
|
|
struct _SearpcClient {
|
2012-06-04 03:24:04 +00:00
|
|
|
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;
|
2016-06-15 06:48:04 +00:00
|
|
|
};
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
typedef struct _SearpcClient LIBSEARPC_API SearpcClient;
|
2011-04-08 12:58:15 +00:00
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API
|
2023-04-08 23:53:07 +00:00
|
|
|
SearpcClient *searpc_client_new (void);
|
2011-05-18 09:24:34 +00:00
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API void
|
|
|
|
searpc_client_free (SearpcClient *client);
|
2011-04-08 12:58:15 +00:00
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API void
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_call (SearpcClient *client, const char *fname,
|
2012-06-13 15:52:12 +00:00
|
|
|
const char *ret_type, GType gobject_type,
|
2012-06-03 16:19:16 +00:00
|
|
|
void *ret_ptr, GError **error,
|
|
|
|
int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_call__int (SearpcClient *client, const char *fname,
|
|
|
|
GError **error, int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API gint64
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_call__int64 (SearpcClient *client, const char *fname,
|
|
|
|
GError **error, int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API char *
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_call__string (SearpcClient *client, const char *fname,
|
|
|
|
GError **error, int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API GObject *
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_call__object (SearpcClient *client, const char *fname,
|
2012-06-13 15:52:12 +00:00
|
|
|
GType object_type,
|
2012-06-03 16:19:16 +00:00
|
|
|
GError **error, int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API GList*
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_call__objlist (SearpcClient *client, const char *fname,
|
2012-06-13 15:52:12 +00:00
|
|
|
GType object_type,
|
2012-06-03 16:19:16 +00:00
|
|
|
GError **error, int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API json_t *
|
2016-06-28 02:46:17 +00:00
|
|
|
searpc_client_call__json (SearpcClient *client, const char *fname,
|
|
|
|
GError **error, int n_params, ...);
|
|
|
|
|
2012-06-03 16:19:16 +00:00
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API char*
|
|
|
|
searpc_client_transport_send (SearpcClient *client,
|
|
|
|
const gchar *fcall_str,
|
|
|
|
size_t fcall_len,
|
|
|
|
size_t *ret_len);
|
2011-04-08 12:58:15 +00:00
|
|
|
|
2011-09-13 05:07:31 +00:00
|
|
|
|
2012-06-03 16:19:16 +00:00
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_async_call__int (SearpcClient *client,
|
|
|
|
const char *fname,
|
|
|
|
AsyncCallback callback, void *cbdata,
|
|
|
|
int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_async_call__int64 (SearpcClient *client,
|
|
|
|
const char *fname,
|
|
|
|
AsyncCallback callback, void *cbdata,
|
|
|
|
int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_async_call__string (SearpcClient *client,
|
|
|
|
const char *fname,
|
|
|
|
AsyncCallback callback, void *cbdata,
|
|
|
|
int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_async_call__object (SearpcClient *client,
|
|
|
|
const char *fname,
|
|
|
|
AsyncCallback callback,
|
2012-06-13 15:52:12 +00:00
|
|
|
GType object_type, void *cbdata,
|
2012-06-03 16:19:16 +00:00
|
|
|
int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2012-06-03 16:19:16 +00:00
|
|
|
searpc_client_async_call__objlist (SearpcClient *client,
|
|
|
|
const char *fname,
|
|
|
|
AsyncCallback callback,
|
2012-06-13 15:52:12 +00:00
|
|
|
GType object_type, void *cbdata,
|
2012-06-03 16:19:16 +00:00
|
|
|
int n_params, ...);
|
|
|
|
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2016-06-28 03:37:17 +00:00
|
|
|
searpc_client_async_call__json (SearpcClient *client,
|
|
|
|
const char *fname,
|
|
|
|
AsyncCallback callback, void *cbdata,
|
|
|
|
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 */
|
2019-11-01 07:52:36 +00:00
|
|
|
LIBSEARPC_API int
|
2011-09-13 05:07:31 +00:00
|
|
|
searpc_client_generic_callback (char *retstr, size_t len,
|
|
|
|
void *vdata, const char *errstr);
|
|
|
|
|
2011-04-08 12:58:15 +00:00
|
|
|
|
2011-05-18 09:24:34 +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
|
|
|
|
|
2022-04-25 03:58:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-08 12:58:15 +00:00
|
|
|
|
|
|
|
#endif
|