mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-05-11 00:24:20 +00:00
export to generate lib
This commit is contained in:
parent
3291d04cec
commit
8b853cf41d
@ -1,6 +1,12 @@
|
||||
#ifndef SEARPC_CLIENT_H
|
||||
#define SEARPC_CLIENT_H
|
||||
|
||||
#ifdef LIBSEARPC_EXPORTS
|
||||
#define LIBSEARPC_API __declspec(dllexport)
|
||||
#else
|
||||
#define LIBSEARPC_API
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <jansson.h>
|
||||
@ -31,85 +37,88 @@ struct _SearpcClient {
|
||||
void *async_arg;
|
||||
};
|
||||
|
||||
typedef struct _SearpcClient SearpcClient;
|
||||
typedef struct _SearpcClient LIBSEARPC_API SearpcClient;
|
||||
|
||||
LIBSEARPC_API
|
||||
SearpcClient *searpc_client_new ();
|
||||
|
||||
void searpc_client_free (SearpcClient *client);
|
||||
LIBSEARPC_API void
|
||||
searpc_client_free (SearpcClient *client);
|
||||
|
||||
void
|
||||
LIBSEARPC_API void
|
||||
searpc_client_call (SearpcClient *client, const char *fname,
|
||||
const char *ret_type, GType gobject_type,
|
||||
void *ret_ptr, GError **error,
|
||||
int n_params, ...);
|
||||
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_call__int (SearpcClient *client, const char *fname,
|
||||
GError **error, int n_params, ...);
|
||||
|
||||
gint64
|
||||
LIBSEARPC_API gint64
|
||||
searpc_client_call__int64 (SearpcClient *client, const char *fname,
|
||||
GError **error, int n_params, ...);
|
||||
|
||||
char *
|
||||
LIBSEARPC_API char *
|
||||
searpc_client_call__string (SearpcClient *client, const char *fname,
|
||||
GError **error, int n_params, ...);
|
||||
|
||||
GObject *
|
||||
LIBSEARPC_API GObject *
|
||||
searpc_client_call__object (SearpcClient *client, const char *fname,
|
||||
GType object_type,
|
||||
GError **error, int n_params, ...);
|
||||
|
||||
GList*
|
||||
LIBSEARPC_API GList*
|
||||
searpc_client_call__objlist (SearpcClient *client, const char *fname,
|
||||
GType object_type,
|
||||
GError **error, int n_params, ...);
|
||||
|
||||
json_t *
|
||||
LIBSEARPC_API json_t *
|
||||
searpc_client_call__json (SearpcClient *client, const char *fname,
|
||||
GError **error, int n_params, ...);
|
||||
|
||||
|
||||
char* searpc_client_transport_send (SearpcClient *client,
|
||||
const gchar *fcall_str,
|
||||
size_t fcall_len,
|
||||
size_t *ret_len);
|
||||
LIBSEARPC_API char*
|
||||
searpc_client_transport_send (SearpcClient *client,
|
||||
const gchar *fcall_str,
|
||||
size_t fcall_len,
|
||||
size_t *ret_len);
|
||||
|
||||
|
||||
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_async_call__int (SearpcClient *client,
|
||||
const char *fname,
|
||||
AsyncCallback callback, void *cbdata,
|
||||
int n_params, ...);
|
||||
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_async_call__int64 (SearpcClient *client,
|
||||
const char *fname,
|
||||
AsyncCallback callback, void *cbdata,
|
||||
int n_params, ...);
|
||||
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_async_call__string (SearpcClient *client,
|
||||
const char *fname,
|
||||
AsyncCallback callback, void *cbdata,
|
||||
int n_params, ...);
|
||||
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_async_call__object (SearpcClient *client,
|
||||
const char *fname,
|
||||
AsyncCallback callback,
|
||||
GType object_type, void *cbdata,
|
||||
int n_params, ...);
|
||||
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_async_call__objlist (SearpcClient *client,
|
||||
const char *fname,
|
||||
AsyncCallback callback,
|
||||
GType object_type, void *cbdata,
|
||||
int n_params, ...);
|
||||
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_async_call__json (SearpcClient *client,
|
||||
const char *fname,
|
||||
AsyncCallback callback, void *cbdata,
|
||||
@ -118,7 +127,7 @@ searpc_client_async_call__json (SearpcClient *client,
|
||||
|
||||
/* called by the transport layer, the rpc layer should be able to
|
||||
* modify the str, but not take ownership of it */
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_client_generic_callback (char *retstr, size_t len,
|
||||
void *vdata, const char *errstr);
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
#ifndef SEARPC_NAMED_PIPE_TRANSPORT_H
|
||||
#define SEARPC_NAMED_PIPE_TRANSPORT_H
|
||||
|
||||
#ifdef LIBSEARPC_EXPORTS
|
||||
#define LIBSEARPC_API __declspec(dllexport)
|
||||
#else
|
||||
#define LIBSEARPC_API
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
@ -34,12 +40,15 @@ struct _SearpcNamedPipeServer {
|
||||
GThreadPool *named_pipe_server_thread_pool;
|
||||
};
|
||||
|
||||
typedef struct _SearpcNamedPipeServer SearpcNamedPipeServer;
|
||||
typedef struct _SearpcNamedPipeServer LIBSEARPC_API SearpcNamedPipeServer;
|
||||
|
||||
LIBSEARPC_API
|
||||
SearpcNamedPipeServer* searpc_create_named_pipe_server(const char *path);
|
||||
|
||||
LIBSEARPC_API
|
||||
SearpcNamedPipeServer* searpc_create_named_pipe_server_with_threadpool(const char *path, int named_pipe_server_thread_pool_size);
|
||||
|
||||
LIBSEARPC_API
|
||||
int searpc_named_pipe_server_start(SearpcNamedPipeServer *server);
|
||||
|
||||
// Client side interface.
|
||||
@ -49,14 +58,18 @@ struct _SearpcNamedPipeClient {
|
||||
SearpcNamedPipe pipe_fd;
|
||||
};
|
||||
|
||||
typedef struct _SearpcNamedPipeClient SearpcNamedPipeClient;
|
||||
typedef struct _SearpcNamedPipeClient LIBSEARPC_API SearpcNamedPipeClient;
|
||||
|
||||
LIBSEARPC_API
|
||||
SearpcNamedPipeClient* searpc_create_named_pipe_client(const char *path);
|
||||
|
||||
LIBSEARPC_API
|
||||
SearpcClient * searpc_client_with_named_pipe_transport(SearpcNamedPipeClient *client, const char *service);
|
||||
|
||||
LIBSEARPC_API
|
||||
int searpc_named_pipe_client_connect(SearpcNamedPipeClient *client);
|
||||
|
||||
LIBSEARPC_API
|
||||
void searpc_free_client_with_pipe_transport (SearpcClient *client);
|
||||
|
||||
#endif // SEARPC_NAMED_PIPE_TRANSPORT_H
|
||||
|
@ -1,6 +1,12 @@
|
||||
#ifndef SEARPC_SERVER_H
|
||||
#define SEARPC_SERVER_H
|
||||
|
||||
#ifdef LIBSEARPC_EXPORTS
|
||||
#define LIBSEARPC_API __declspec(dllexport)
|
||||
#else
|
||||
#define LIBSEARPC_API
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <jansson.h>
|
||||
@ -13,11 +19,17 @@ typedef gchar* (*SearpcMarshalFunc) (void *func, json_t *param_array,
|
||||
gsize *ret_len);
|
||||
typedef void (*RegisterMarshalFunc) (void);
|
||||
|
||||
LIBSEARPC_API
|
||||
void searpc_set_string_to_ret_object (json_t *object, char *ret);
|
||||
LIBSEARPC_API
|
||||
void searpc_set_int_to_ret_object (json_t *object, json_int_t ret);
|
||||
LIBSEARPC_API
|
||||
void searpc_set_object_to_ret_object (json_t *object, GObject *ret);
|
||||
LIBSEARPC_API
|
||||
void searpc_set_objlist_to_ret_object (json_t *object, GList *ret);
|
||||
LIBSEARPC_API
|
||||
void searpc_set_json_to_ret_object (json_t *object, json_t *ret);
|
||||
LIBSEARPC_API
|
||||
char *searpc_marshal_set_ret_common (json_t *object, gsize *len, GError *error);
|
||||
|
||||
/**
|
||||
@ -25,6 +37,7 @@ char *searpc_marshal_set_ret_common (json_t *object, gsize *len, GError *error);
|
||||
*
|
||||
* Inititalize searpc server.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
void searpc_server_init (RegisterMarshalFunc register_func);
|
||||
|
||||
/**
|
||||
@ -32,7 +45,7 @@ void searpc_server_init (RegisterMarshalFunc register_func);
|
||||
*
|
||||
* Inititalize searpc server with slow log file.
|
||||
*/
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_server_init_with_slow_log (RegisterMarshalFunc register_func,
|
||||
const char *slow_log_path,
|
||||
gint64 slow_threshold_in);
|
||||
@ -40,7 +53,7 @@ searpc_server_init_with_slow_log (RegisterMarshalFunc register_func,
|
||||
/**
|
||||
* Used in log rotate.
|
||||
*/
|
||||
int
|
||||
LIBSEARPC_API int
|
||||
searpc_server_reopen_slow_log (const char *slow_log_path);
|
||||
|
||||
/**
|
||||
@ -48,6 +61,7 @@ searpc_server_reopen_slow_log (const char *slow_log_path);
|
||||
*
|
||||
* Free the server structure.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
void searpc_server_final ();
|
||||
|
||||
/**
|
||||
@ -58,6 +72,7 @@ void searpc_server_final ();
|
||||
*
|
||||
* @svc_name: Service name.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
int searpc_create_service (const char *svc_name);
|
||||
|
||||
/**
|
||||
@ -65,6 +80,7 @@ int searpc_create_service (const char *svc_name);
|
||||
*
|
||||
* Remove the service from the server.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
void searpc_remove_service (const char *svc_name);
|
||||
|
||||
/**
|
||||
@ -75,6 +91,7 @@ void searpc_remove_service (const char *svc_name);
|
||||
* @signature: the signature of the marshal, register_marshal() will take
|
||||
* owner of this string.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
gboolean searpc_server_register_marshal (gchar *signature,
|
||||
SearpcMarshalFunc marshal);
|
||||
|
||||
@ -86,6 +103,7 @@ gboolean searpc_server_register_marshal (gchar *signature,
|
||||
* @signature: the signature of the function, register_function() will take
|
||||
* owner of this string.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
gboolean searpc_server_register_function (const char *service,
|
||||
void* func,
|
||||
const gchar *fname,
|
||||
@ -102,6 +120,7 @@ gboolean searpc_server_register_function (const char *service,
|
||||
*
|
||||
* Returns the serialized representatio of the returned value.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
gchar *searpc_server_call_function (const char *service,
|
||||
gchar *func, gsize len, gsize *ret_len);
|
||||
|
||||
@ -112,6 +131,7 @@ gchar *searpc_server_call_function (const char *service,
|
||||
*
|
||||
* Compute function signature.
|
||||
*/
|
||||
LIBSEARPC_API
|
||||
char* searpc_compute_signature (const gchar *ret_type, int pnum, ...);
|
||||
|
||||
#endif
|
||||
|
@ -2,15 +2,23 @@
|
||||
#include <glib-object.h>
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef LIBSEARPC_EXPORTS
|
||||
#define LIBSEARPC_API __declspec(dllexport)
|
||||
#else
|
||||
#define LIBSEARPC_API
|
||||
#endif
|
||||
|
||||
#define SEARPC_JSON_DOMAIN g_quark_from_string("SEARPC_JSON")
|
||||
|
||||
typedef enum {
|
||||
SEARPC_JSON_ERROR_LOAD,
|
||||
SEARPC_JSON_ERROR_PACK,
|
||||
SEARPC_JSON_ERROR_UPACK
|
||||
} SEARPCJSONERROR;
|
||||
} LIBSEARPC_API SEARPCJSONERROR;
|
||||
|
||||
LIBSEARPC_API
|
||||
json_t *json_gobject_serialize (GObject *);
|
||||
LIBSEARPC_API
|
||||
GObject *json_gobject_deserialize (GType , json_t *);
|
||||
|
||||
inline static void setjetoge(const json_error_t *jerror, GError **error)
|
||||
|
@ -71,7 +71,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;LIBSEARPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
|
Loading…
Reference in New Issue
Block a user