mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-08-02 05:12:55 +00:00
1. Rearraged the source tree
2. modified the autotools scripts, "make distcheck" is ok now
This commit is contained in:
parent
fecbee71a1
commit
02eb0744fc
48
Makefile.am
48
Makefile.am
@ -1,44 +1,16 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/lib
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
GNU_STANDARD_FILES = README README.markdown COPYING COPYING.LESSER AUTHORS ChangeLog News
|
||||
EXTRA_DIST = $(GNU_STANDARD_FILES) rpc_table.py gen-dfun-macro.py
|
||||
SUBDIRS = tests . pysearpc
|
||||
GNU_STANDARD_FILES = README COPYING COPYING.LESSER AUTHORS ChangeLog NEWS
|
||||
|
||||
AM_CFLAGS = @GLIB2_CFLAGS@ @GOBJECT_CFLAGS@ \
|
||||
-I$(top_srcdir)/include -I$(top_srcdir)/include/ccnet \
|
||||
-I$(top_builddir)/include \
|
||||
@JSON_GLIB_CFLAGS@
|
||||
EXTRA_DIST = $(GNU_STANDARD_FILES)
|
||||
|
||||
|
||||
if COMPILE_DEMO
|
||||
noinst_PROGRAMS = searpc-demo-server searpc-demo-client
|
||||
|
||||
searpc_demo_server_SOURCES = searpc-demo-server.c searpc-demo-packet.h
|
||||
|
||||
searpc_demo_server_LDADD = ./libsearpc.la
|
||||
|
||||
searpc_demo_client_SOURCES = searpc-demo-client.c searpc-demo-packet.h
|
||||
|
||||
searpc_demo_client_LDADD = ./libsearpc.la
|
||||
if COMPILE_PYTHON
|
||||
PYTHONDIR = pysearpc
|
||||
endif
|
||||
|
||||
# we need to generate the headers first
|
||||
# BUILT_SOURCES = genrpc
|
||||
if COMPILE_DEMO
|
||||
MAKE_DEMO = demo
|
||||
endif
|
||||
|
||||
|
||||
pkglib_LTLIBRARIES = libsearpc.la
|
||||
|
||||
include_HEADERS = searpc-client.h searpc-server.h searpc-utils.h
|
||||
|
||||
libsearpc_la_SOURCES = searpc-client.c searpc-server.c
|
||||
|
||||
libsearpc_la_LDFLAGS = -Wl,-z -Wl,defs
|
||||
|
||||
libsearpc_la_LIBADD = @GLIB2_LIBS@ @GOBJECT_LIBS@ \
|
||||
@JSON_GLIB_LIBS@
|
||||
|
||||
genrpc: gen-dfun-macro.py
|
||||
python gen-dfun-macro.py gen-fcall > fcall-impr.h
|
||||
python gen-dfun-macro.py gen-fcall-declare > searpc-fcall.h
|
||||
python gen-dfun-macro.py gen-dfun-macro > searpc-dfun.h
|
||||
python gen-dfun-macro.py gen-signature > searpc-signature.h
|
||||
python gen-dfun-macro.py gen-marshal > searpc-marshal.h
|
||||
SUBDIRS = lib ${PYTHONDIR} ${MAKE_DEMO} tests
|
@ -3,7 +3,7 @@
|
||||
|
||||
AC_PREREQ([2.67])
|
||||
AC_INIT([libsearpc], [1.0], [freeplant@gmail.com])
|
||||
AC_CONFIG_SRCDIR([searpc-server.c])
|
||||
AC_CONFIG_SRCDIR([lib/searpc-server.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
@ -79,6 +79,8 @@ fi
|
||||
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
lib/Makefile
|
||||
demo/Makefile
|
||||
pysearpc/Makefile
|
||||
tests/Makefile])
|
||||
AC_OUTPUT
|
||||
|
12
demo/Makefile.am
Normal file
12
demo/Makefile.am
Normal file
@ -0,0 +1,12 @@
|
||||
AM_CFLAGS = @GLIB2_CFLAGS@ @GOBJECT_CFLAGS@ @JSON_GLIB_CFLAGS@ -I${top_builddir}/lib -I${top_srcdir}/lib
|
||||
|
||||
noinst_PROGRAMS = searpc-demo-server searpc-demo-client
|
||||
|
||||
searpc_demo_server_SOURCES = searpc-demo-server.c searpc-demo-packet.h
|
||||
|
||||
searpc_demo_server_LDADD = ${top_builddir}/lib/libsearpc.la
|
||||
|
||||
searpc_demo_client_SOURCES = searpc-demo-client.c searpc-demo-packet.h
|
||||
|
||||
searpc_demo_client_LDADD = ${top_builddir}/lib/libsearpc.la
|
||||
|
111
fcall-impr.h
111
fcall-impr.h
@ -1,111 +0,0 @@
|
||||
|
||||
char*
|
||||
searpc_client_fcall__string (const char* fname, const gchar* param1, gsize *len)
|
||||
{
|
||||
JsonArray *array;
|
||||
|
||||
g_return_val_if_fail (fname != NULL, NULL);
|
||||
|
||||
array = json_array_new ();
|
||||
json_array_add_string_element (array, fname);
|
||||
json_array_add_string_or_null_element (array, param1);
|
||||
|
||||
return fcall_common(array, len);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
searpc_client_fcall__string_string (const char* fname, const gchar* param1, const gchar* param2, gsize *len)
|
||||
{
|
||||
JsonArray *array;
|
||||
|
||||
g_return_val_if_fail (fname != NULL, NULL);
|
||||
|
||||
array = json_array_new ();
|
||||
json_array_add_string_element (array, fname);
|
||||
json_array_add_string_or_null_element (array, param1);
|
||||
json_array_add_string_or_null_element (array, param2);
|
||||
|
||||
return fcall_common(array, len);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
searpc_client_fcall__void (const char* fname, gsize *len)
|
||||
{
|
||||
JsonArray *array;
|
||||
|
||||
g_return_val_if_fail (fname != NULL, NULL);
|
||||
|
||||
array = json_array_new ();
|
||||
json_array_add_string_element (array, fname);
|
||||
|
||||
return fcall_common(array, len);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
searpc_client_fcall__string_int (const char* fname, const gchar* param1, int param2, gsize *len)
|
||||
{
|
||||
JsonArray *array;
|
||||
|
||||
g_return_val_if_fail (fname != NULL, NULL);
|
||||
|
||||
array = json_array_new ();
|
||||
json_array_add_string_element (array, fname);
|
||||
json_array_add_string_or_null_element (array, param1);
|
||||
json_array_add_int_element (array, param2);
|
||||
|
||||
return fcall_common(array, len);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
searpc_client_fcall__int_int (const char* fname, int param1, int param2, gsize *len)
|
||||
{
|
||||
JsonArray *array;
|
||||
|
||||
g_return_val_if_fail (fname != NULL, NULL);
|
||||
|
||||
array = json_array_new ();
|
||||
json_array_add_string_element (array, fname);
|
||||
json_array_add_int_element (array, param1);
|
||||
json_array_add_int_element (array, param2);
|
||||
|
||||
return fcall_common(array, len);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
searpc_client_fcall__string_int_int (const char* fname, const gchar* param1, int param2, int param3, gsize *len)
|
||||
{
|
||||
JsonArray *array;
|
||||
|
||||
g_return_val_if_fail (fname != NULL, NULL);
|
||||
|
||||
array = json_array_new ();
|
||||
json_array_add_string_element (array, fname);
|
||||
json_array_add_string_or_null_element (array, param1);
|
||||
json_array_add_int_element (array, param2);
|
||||
json_array_add_int_element (array, param3);
|
||||
|
||||
return fcall_common(array, len);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
searpc_client_fcall__string_string_int (const char* fname, const gchar* param1, const gchar* param2, int param3, gsize *len)
|
||||
{
|
||||
JsonArray *array;
|
||||
|
||||
g_return_val_if_fail (fname != NULL, NULL);
|
||||
|
||||
array = json_array_new ();
|
||||
json_array_add_string_element (array, fname);
|
||||
json_array_add_string_or_null_element (array, param1);
|
||||
json_array_add_string_or_null_element (array, param2);
|
||||
json_array_add_int_element (array, param3);
|
||||
|
||||
return fcall_common(array, len);
|
||||
}
|
||||
|
38
lib/Makefile.am
Normal file
38
lib/Makefile.am
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
rpc_headers = fcall-impr.h searpc-fcall.h searpc-dfun.h searpc-signature.h searpc-marshal.h
|
||||
|
||||
genrpc_files = gen-dfun-macro.py rpc_table.py
|
||||
|
||||
# rpc_headers = fcall-impr.h searpc-fcall.h searpc-dfun.h searpc-signature.h searpc-marshal.h
|
||||
|
||||
AM_CFLAGS = @GLIB2_CFLAGS@ @GOBJECT_CFLAGS@ @JSON_GLIB_CFLAGS@ -I${top_builddir}/lib -I${top_srcdir}/lib
|
||||
|
||||
# we need to generate the headers first
|
||||
BUILT_SOURCES = genrpc
|
||||
|
||||
pkglib_LTLIBRARIES = libsearpc.la
|
||||
|
||||
include_HEADERS = searpc-client.h searpc-server.h searpc-utils.h
|
||||
|
||||
libsearpc_la_SOURCES = searpc-client.c searpc-server.c
|
||||
|
||||
EXTRA_libsearpc_la_SOURCES = ${genrpc_files}
|
||||
|
||||
libsearpc_la_LDFLAGS = -Wl,-z -Wl,defs
|
||||
|
||||
libsearpc_la_LIBADD = @GLIB2_LIBS@ @GOBJECT_LIBS@ @JSON_GLIB_LIBS@
|
||||
|
||||
|
||||
genrpc: ${rpc_headers} ${genrpc_files}
|
||||
|
||||
|
||||
${rpc_headers}: ${genrpc_files}
|
||||
@echo "[libsearpc]: generating rpc header files"
|
||||
python $< gen-fcall > fcall-impr.h
|
||||
python $< gen-fcall-declare > searpc-fcall.h
|
||||
python $< gen-dfun-macro > searpc-dfun.h
|
||||
python $< gen-signature > searpc-signature.h
|
||||
python $< gen-marshal > searpc-marshal.h
|
||||
@echo "[libsearpc]: done"
|
||||
|
||||
CLEANFILES = ${rpc_headers}
|
@ -54,6 +54,6 @@ gchar *searpc_server_call_function (gchar *func, gsize len, gsize *ret_len);
|
||||
char* searpc_compute_signature (gchar *ret_type, int pnum, ...);
|
||||
|
||||
/* Signatures */
|
||||
#include <searpc-signature.h>
|
||||
#include "searpc-signature.h"
|
||||
|
||||
#endif
|
@ -1,28 +1,27 @@
|
||||
EXTRA_DIST = pysearpc-demo-client.py
|
||||
|
||||
genrpc_files = pysearpc-gen-dfun-macro.py rpc_table.py
|
||||
|
||||
AM_CFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" \
|
||||
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/include \
|
||||
@GLIB2_CFLAGS@ \
|
||||
@PYGOBJECT_CFLAGS@ \
|
||||
-I/usr/include/python$(PYTHON_VERSION)
|
||||
@GLIB2_CFLAGS@ @PYGOBJECT_CFLAGS@ \
|
||||
-I/usr/include/python$(PYTHON_VERSION) \
|
||||
-I${top_builddir}/lib -I${top_srcdir}/lib
|
||||
|
||||
if COMPILE_PYTHON
|
||||
pkgpyexec_PYTHON = __init__.py client.py gen-dfun-macro.py
|
||||
pkgpyexec_PYTHON = __init__.py client.py pysearpc-gen-dfun-macro.py
|
||||
|
||||
# generating the fcallfret module
|
||||
pkgpyexec_LTLIBRARIES = fcallfret.la
|
||||
|
||||
fcallfret_la_LDFLAGS = -module -avoid-version -export-symbols-regex initfcallfret
|
||||
fcallfret_la_SOURCES = fcallfret.c fcallfret.h
|
||||
fcallfret_la_LIBADD = @GLIB2_LIBS@ @GOBJECT_LIBS@ $(top_builddir)/libsearpc.la
|
||||
fcallfret_la_LIBADD = @GLIB2_LIBS@ @GOBJECT_LIBS@ $(top_builddir)/lib/libsearpc.la
|
||||
|
||||
EXTRA_fcallfret_la_SOURCES = ${genrpc_files}
|
||||
|
||||
CLEANFILES = fcallfret.h
|
||||
|
||||
fcallfret.c: gen-dfun-macro.py
|
||||
fcallfret.c: ${genrpc_files}
|
||||
python $< gen-searpcclient > fcallfret.h
|
||||
.PHONY: fcallfret.c
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: fcallfret.c
|
@ -24,7 +24,7 @@
|
||||
#include <glib-object.h>
|
||||
#include <pygobject.h>
|
||||
|
||||
#include <../searpc-client.h>
|
||||
#include <../lib/searpc-client.h>
|
||||
#include <structmember.h>
|
||||
|
||||
static PyObject *SearpcError;
|
||||
|
@ -1,37 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path += ['', '.libs']
|
||||
|
||||
RPC_PROC_ID = 1003
|
||||
|
||||
SC_CLIENT_CALL = "301"
|
||||
SS_CLIENT_CALL = "CLIENT CALL"
|
||||
SC_SERVER_RET = "311"
|
||||
SS_SERVER_RET = "SERVER RET"
|
||||
|
||||
|
||||
def searpc_transport_send(fcall, priv):
|
||||
|
||||
if priv.peerid is None:
|
||||
proc_name = "%s-rpcserver" % (priv.service)
|
||||
else:
|
||||
proc_name = "remote %s %s-rpcserver" % (priv.peerid, priv.service)
|
||||
|
||||
priv.session.send_request(RPC_PROC_ID, proc_name)
|
||||
if priv.session.read_response() < 0:
|
||||
return None
|
||||
rsp = priv.session.response
|
||||
if rsp[0] != "200":
|
||||
print "[Sea RPC] failed to start rpc server.\n"
|
||||
return None
|
||||
|
||||
priv.session.send_update(RPC_PROC_ID, "301", "CLIENT CALL",
|
||||
fcall, len(fcall))
|
||||
if priv.session.read_response() < 0:
|
||||
return None
|
||||
rsp = priv.session.response
|
||||
if rsp[0] == SC_SERVER_RET:
|
||||
return rsp[2]
|
||||
else:
|
||||
print "[Sea RPC] Bad response: %s %s.\n" % (rsp[0], rsp[1])
|
||||
return None
|
20
pysearpc/rpc_table.py
Normal file
20
pysearpc/rpc_table.py
Normal file
@ -0,0 +1,20 @@
|
||||
"""
|
||||
Define RPC functions needed to generate
|
||||
"""
|
||||
|
||||
# [ <ret-type>, [<arg_types>] ]
|
||||
func_table = [
|
||||
[ "int", ["string"] ],
|
||||
[ "int", ["string", "string"] ],
|
||||
[ "string", [] ],
|
||||
[ "string", ["string"] ],
|
||||
[ "string", ["string", "int"] ],
|
||||
[ "objlist", [] ],
|
||||
[ "objlist", ["string"] ],
|
||||
[ "objlist", ["int", "int"] ],
|
||||
[ "objlist", ["string", "int"] ],
|
||||
[ "objlist", ["string", "int", "int"] ],
|
||||
[ "objlist", ["string", "string", "int"] ],
|
||||
[ "object", [] ],
|
||||
[ "object", ["string"] ],
|
||||
]
|
351
searpc-dfun.h
351
searpc-dfun.h
@ -1,351 +0,0 @@
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_INT__STRING(funcname) \
|
||||
int \
|
||||
funcname (SearpcClient *client, const gchar* param1, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
int result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string (#funcname, \
|
||||
param1, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return -1; \
|
||||
} \
|
||||
result = searpc_client_fret__int (fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_INT__STRING_STRING(funcname) \
|
||||
int \
|
||||
funcname (SearpcClient *client, const gchar* param1, const gchar* param2, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
int result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string_string (#funcname, \
|
||||
param1, param2, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return -1; \
|
||||
} \
|
||||
result = searpc_client_fret__int (fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_STRING__VOID(funcname) \
|
||||
gchar* \
|
||||
funcname (SearpcClient *client, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
gchar* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__void (#funcname, \
|
||||
&fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__string (fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_STRING__STRING(funcname) \
|
||||
gchar* \
|
||||
funcname (SearpcClient *client, const gchar* param1, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
gchar* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string (#funcname, \
|
||||
param1, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__string (fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_STRING__STRING_INT(funcname) \
|
||||
gchar* \
|
||||
funcname (SearpcClient *client, const gchar* param1, int param2, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
gchar* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string_int (#funcname, \
|
||||
param1, param2, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__string (fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJLIST__VOID(funcname, gtype) \
|
||||
GList* \
|
||||
funcname (SearpcClient *client, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GList* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__void (#funcname, \
|
||||
&fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__objlist (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJLIST__STRING(funcname, gtype) \
|
||||
GList* \
|
||||
funcname (SearpcClient *client, const gchar* param1, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GList* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string (#funcname, \
|
||||
param1, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__objlist (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJLIST__INT_INT(funcname, gtype) \
|
||||
GList* \
|
||||
funcname (SearpcClient *client, int param1, int param2, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GList* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__int_int (#funcname, \
|
||||
param1, param2, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__objlist (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJLIST__STRING_INT(funcname, gtype) \
|
||||
GList* \
|
||||
funcname (SearpcClient *client, const gchar* param1, int param2, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GList* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string_int (#funcname, \
|
||||
param1, param2, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__objlist (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJLIST__STRING_INT_INT(funcname, gtype) \
|
||||
GList* \
|
||||
funcname (SearpcClient *client, const gchar* param1, int param2, int param3, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GList* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string_int_int (#funcname, \
|
||||
param1, param2, param3, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__objlist (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJLIST__STRING_STRING_INT(funcname, gtype) \
|
||||
GList* \
|
||||
funcname (SearpcClient *client, const gchar* param1, const gchar* param2, int param3, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GList* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string_string_int (#funcname, \
|
||||
param1, param2, param3, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__objlist (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJECT__VOID(funcname, gtype) \
|
||||
GObject* \
|
||||
funcname (SearpcClient *client, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GObject* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__void (#funcname, \
|
||||
&fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__object (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
|
||||
#define SEARPC_CLIENT_DEFUN_OBJECT__STRING(funcname, gtype) \
|
||||
GObject* \
|
||||
funcname (SearpcClient *client, const gchar* param1, GError **error) \
|
||||
{ \
|
||||
char *fcall, *fret; \
|
||||
size_t fcall_len, ret_len; \
|
||||
GObject* result; \
|
||||
\
|
||||
fcall = searpc_client_fcall__string (#funcname, \
|
||||
param1, &fcall_len); \
|
||||
fret = searpc_client_transport_send (client, \
|
||||
fcall, \
|
||||
fcall_len, \
|
||||
&ret_len); \
|
||||
if (!fret) { \
|
||||
g_free (fcall); \
|
||||
g_set_error (error, 0, TRANSPORT_ERROR_CODE, TRANSPORT_ERROR); \
|
||||
return NULL; \
|
||||
} \
|
||||
result = searpc_client_fret__object (gtype, fret, ret_len, error); \
|
||||
\
|
||||
g_free (fcall); \
|
||||
g_free (fret); \
|
||||
return result; \
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
|
||||
char* searpc_client_fcall__string (const char* fname, const gchar* param1, gsize *len);
|
||||
|
||||
|
||||
char* searpc_client_fcall__string_string (const char* fname, const gchar* param1, const gchar* param2, gsize *len);
|
||||
|
||||
|
||||
char* searpc_client_fcall__void (const char* fname, gsize *len);
|
||||
|
||||
|
||||
char* searpc_client_fcall__string_int (const char* fname, const gchar* param1, int param2, gsize *len);
|
||||
|
||||
|
||||
char* searpc_client_fcall__int_int (const char* fname, int param1, int param2, gsize *len);
|
||||
|
||||
|
||||
char* searpc_client_fcall__string_int_int (const char* fname, const gchar* param1, int param2, int param3, gsize *len);
|
||||
|
||||
|
||||
char* searpc_client_fcall__string_string_int (const char* fname, const gchar* param1, const gchar* param2, int param3, gsize *len);
|
||||
|
281
searpc-marshal.h
281
searpc-marshal.h
@ -1,281 +0,0 @@
|
||||
|
||||
static gchar *
|
||||
marshal_int__string (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
|
||||
int ret = ((int (*)(const gchar*, GError **))func) (param1, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_int_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_int__string_string (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
const gchar* param2 = json_array_get_string_or_null_element (param_array, 2);
|
||||
|
||||
int ret = ((int (*)(const gchar*, const gchar*, GError **))func) (param1, param2, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_int_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_string__void (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
gchar* ret = ((gchar* (*)(GError **))func) (&error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_string_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_string__string (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
|
||||
gchar* ret = ((gchar* (*)(const gchar*, GError **))func) (param1, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_string_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_string__string_int (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
int param2 = json_array_get_int_element (param_array, 2);
|
||||
|
||||
gchar* ret = ((gchar* (*)(const gchar*, int, GError **))func) (param1, param2, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_string_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_objlist__void (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
GList* ret = ((GList* (*)(GError **))func) (&error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_objlist_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_objlist__string (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
|
||||
GList* ret = ((GList* (*)(const gchar*, GError **))func) (param1, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_objlist_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_objlist__int_int (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
int param1 = json_array_get_int_element (param_array, 1);
|
||||
int param2 = json_array_get_int_element (param_array, 2);
|
||||
|
||||
GList* ret = ((GList* (*)(int, int, GError **))func) (param1, param2, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_objlist_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_objlist__string_int (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
int param2 = json_array_get_int_element (param_array, 2);
|
||||
|
||||
GList* ret = ((GList* (*)(const gchar*, int, GError **))func) (param1, param2, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_objlist_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_objlist__string_int_int (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
int param2 = json_array_get_int_element (param_array, 2);
|
||||
int param3 = json_array_get_int_element (param_array, 3);
|
||||
|
||||
GList* ret = ((GList* (*)(const gchar*, int, int, GError **))func) (param1, param2, param3, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_objlist_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_objlist__string_string_int (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
const gchar* param2 = json_array_get_string_or_null_element (param_array, 2);
|
||||
int param3 = json_array_get_int_element (param_array, 3);
|
||||
|
||||
GList* ret = ((GList* (*)(const gchar*, const gchar*, int, GError **))func) (param1, param2, param3, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_objlist_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_object__void (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
GObject* ret = ((GObject* (*)(GError **))func) (&error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_object_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
marshal_object__string (void *func, JsonArray *param_array, gsize *ret_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar* param1 = json_array_get_string_or_null_element (param_array, 1);
|
||||
|
||||
GObject* ret = ((GObject* (*)(const gchar*, GError **))func) (param1, &error);
|
||||
|
||||
JsonObject *object = json_object_new ();
|
||||
set_object_to_ret_object (object, ret);
|
||||
return marshal_set_ret_common (object, ret_len, error);
|
||||
}
|
||||
|
||||
static void register_marshals(GHashTable *marshal_table)
|
||||
{
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_int__string;
|
||||
item->signature = searpc_signature_int__string();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_int__string_string;
|
||||
item->signature = searpc_signature_int__string_string();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_string__void;
|
||||
item->signature = searpc_signature_string__void();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_string__string;
|
||||
item->signature = searpc_signature_string__string();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_string__string_int;
|
||||
item->signature = searpc_signature_string__string_int();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_objlist__void;
|
||||
item->signature = searpc_signature_objlist__void();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_objlist__string;
|
||||
item->signature = searpc_signature_objlist__string();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_objlist__int_int;
|
||||
item->signature = searpc_signature_objlist__int_int();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_objlist__string_int;
|
||||
item->signature = searpc_signature_objlist__string_int();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_objlist__string_int_int;
|
||||
item->signature = searpc_signature_objlist__string_int_int();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_objlist__string_string_int;
|
||||
item->signature = searpc_signature_objlist__string_string_int();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_object__void;
|
||||
item->signature = searpc_signature_object__void();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
|
||||
{
|
||||
MarshalItem *item = g_new0(MarshalItem, 1);
|
||||
item->mfunc = marshal_object__string;
|
||||
item->signature = searpc_signature_object__string();
|
||||
g_hash_table_insert (marshal_table, (gpointer)item->signature, item);
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_int__string()
|
||||
{
|
||||
return searpc_compute_signature ("int", 1, "string");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_int__string_string()
|
||||
{
|
||||
return searpc_compute_signature ("int", 2, "string", "string");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_string__void()
|
||||
{
|
||||
return searpc_compute_signature ("string", 0);
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_string__string()
|
||||
{
|
||||
return searpc_compute_signature ("string", 1, "string");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_string__string_int()
|
||||
{
|
||||
return searpc_compute_signature ("string", 2, "string", "int");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_objlist__void()
|
||||
{
|
||||
return searpc_compute_signature ("objlist", 0);
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_objlist__string()
|
||||
{
|
||||
return searpc_compute_signature ("objlist", 1, "string");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_objlist__int_int()
|
||||
{
|
||||
return searpc_compute_signature ("objlist", 2, "int", "int");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_objlist__string_int()
|
||||
{
|
||||
return searpc_compute_signature ("objlist", 2, "string", "int");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_objlist__string_int_int()
|
||||
{
|
||||
return searpc_compute_signature ("objlist", 3, "string", "int", "int");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_objlist__string_string_int()
|
||||
{
|
||||
return searpc_compute_signature ("objlist", 3, "string", "string", "int");
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_object__void()
|
||||
{
|
||||
return searpc_compute_signature ("object", 0);
|
||||
}
|
||||
|
||||
|
||||
inline static const gchar *
|
||||
searpc_signature_object__string()
|
||||
{
|
||||
return searpc_compute_signature ("object", 1, "string");
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
|
||||
AM_CFLAGS = -I$(top_srcdir)/include @GLIB2_CFLAGS@ @GOBJECT_CFLAGS@ \
|
||||
-I$(top_srcdir)/lib -I$(top_srcdir)/lib/searpc \
|
||||
@JSON_GLIB_CFLAGS@
|
||||
AM_CFLAGS = @GLIB2_CFLAGS@ @GOBJECT_CFLAGS@ @JSON_GLIB_CFLAGS@ \
|
||||
-I${top_builddir}/lib -I${top_srcdir}/lib
|
||||
|
||||
|
||||
check_PROGRAMS = test-searpc
|
||||
|
||||
test_searpc_SOURCES = test-searpc.c
|
||||
test_searpc_LDADD = @GLIB2_LIBS@ @GOBJECT_LIBS@ \
|
||||
$(top_builddir)/libsearpc.la
|
||||
$(top_builddir)/lib/libsearpc.la
|
||||
test_searpc_LDFLAGS = -static
|
||||
|
||||
TESTS = test-searpc
|
||||
|
Loading…
Reference in New Issue
Block a user