File:  [ELWIX - Embedded LightWeight unIX -] / libaitrpc / inc / aitrpc.h
Revision 1.1.1.1.2.23: download - view: text, annotated - select for diffs - revision graph
Mon May 2 23:02:44 2011 UTC (13 years, 5 months ago) by misho
Branches: rpc1_0
Diff to: branchpoint 1.1.1.1: preferred, unified
fix for amd64

    1: /*************************************************************************
    2: * (C) 2010 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
    3: *  by Michael Pounov <misho@openbsd-bg.org>
    4: *
    5: * $Author: misho $
    6: * $Id: aitrpc.h,v 1.1.1.1.2.23 2011/05/02 23:02:44 misho Exp $
    7: *
    8: *************************************************************************/
    9: #ifndef __AITRPC_H
   10: #define __AITRPC_H
   11: 
   12: 
   13: #include <assert.h>
   14: #include <stdlib.h>
   15: #include <string.h>
   16: #include <sys/types.h>
   17: #include <sys/param.h>
   18: #if !defined(__NetBSD__)
   19: #include <sys/limits.h>
   20: #endif
   21: #include <sys/socket.h>
   22: 
   23: 
   24: #define RPC_VERSION		1
   25: #define RPC_DEFPORT		2611
   26: 
   27: 
   28: /* RPC builtin registed calls */
   29: 
   30: #define CALL_BLOBSHUTDOWN	"rpcBLOBServerShutdown"
   31: #define CALL_BLOBCLIENTS	"rpcBLOBServerClients"
   32: #define CALL_BLOBVARS		"rpcBLOBServerVars"
   33: #define CALL_BLOBSTATE		"rpcBLOBServerState"
   34: 
   35: #define CALL_SRVSHUTDOWN	"rpcServerShutdown"
   36: #define CALL_SRVCLIENTS		"rpcServerClients"
   37: #define CALL_SRVCALLS		"rpcServerCalls"
   38: #define CALL_SRVSESSIONS	"rpcServerSessions"
   39: 
   40: 
   41: /* RPC types */
   42: 
   43: typedef enum {
   44: 	empty, 				// empty -> variable is not set
   45: 	buffer, string, blob, 		// buffer -> uint8_t*; string -> int8_t*; blob -> void*(+socket);
   46: 	size, offset, datetime, 	// size -> size_t; offset -> off_t; datetime -> time_t;
   47: 	real, bigreal, 			// real -> float; bigreal -> double;
   48: 	u8, u16, u32, u64,		// unsigned integers ...
   49: 	i8, i16, i32, i64		// integers ...
   50: } rpc_type_t;
   51: 
   52: typedef enum {
   53: 	disable, enable, 		// for blob.state
   54: 	ok, error, 			// for blob reply
   55: 	get, set, unset			// for blob request
   56: } cmd_type_t;
   57: 
   58: /* RPC value */
   59: 
   60: typedef struct {
   61: 	rpc_type_t	val_type;
   62: 	size_t		val_len;
   63: 	union {
   64: 		uint8_t		*buffer;
   65: 		int8_t		*string;
   66: 		uint32_t	blob;
   67: 		size_t		size;
   68: 		off_t		offset;
   69: 		time_t		datetime;
   70: 		float		real;
   71: 		double		bigreal;
   72: 		uint8_t		u8;
   73: 		uint16_t	u16;
   74: 		uint32_t	u32;
   75: 		uint64_t	u64;
   76: 		int8_t		i8;
   77: 		int16_t		i16;
   78: 		int32_t		i32;
   79: 		int64_t		i64;
   80: 	} val;
   81: } __packed rpc_val_t;
   82: 
   83: #define RPC_TYPE_VAL(vl)		((vl)->val_type)
   84: #define RPC_LEN_VAL(vl)			((vl)->val_len)
   85: #define RPC_BLOB_CHUNKS(vl, n)		((vl)->val_len / (n) + ((vl)->val_len % (n)) ? 1 : 0)
   86: #define RPC_EMPTY_VAL(vl)		((vl)->val_type == empty)
   87: 
   88: #define RPC_GET_BUF(vl)			(assert((vl)->val_type == buffer), (vl)->val.buffer)
   89: #define RPC_GET_STR(vl)			(assert((vl)->val_type == string), (vl)->val.string)
   90: #define RPC_GET_BLOB(vl)		(assert((vl)->val_type == blob), (vl)->val.blob)
   91: #define RPC_GET_SIZE(vl)		(assert((vl)->val_type == size), (vl)->val.size)
   92: #define RPC_GET_OFF(vl)			(assert((vl)->val_type == offset), (vl)->val.offset)
   93: #define RPC_GET_TIME(vl)		(assert((vl)->val_type == datetime), (vl)->val.datetime)
   94: #define RPC_GET_REAL(vl)		(assert((vl)->val_type == real), (vl)->val.real)
   95: #define RPC_GET_BREAL(vl)		(assert((vl)->val_type == bigreal), (vl)->val.bigreal)
   96: #define RPC_GET_U8(vl)			(assert((vl)->val_type == u8), (vl)->val.u8)
   97: #define RPC_GET_U16(vl)			(assert((vl)->val_type == u16), (vl)->val.u16)
   98: #define RPC_GET_U32(vl)			(assert((vl)->val_type == u32), (vl)->val.u32)
   99: #define RPC_GET_U64(vl)			(assert((vl)->val_type == u64), (vl)->val.u64)
  100: #define RPC_GET_I8(vl)			(assert((vl)->val_type == i8), (vl)->val.i8)
  101: #define RPC_GET_I16(vl)			(assert((vl)->val_type == i16), (vl)->val.i16)
  102: #define RPC_GET_I32(vl)			(assert((vl)->val_type == i32), (vl)->val.i32)
  103: #define RPC_GET_I64(vl)			(assert((vl)->val_type == i64), (vl)->val.i64)
  104: 
  105: #define RPC_SET_BUF(vl, v, l)		do { rpc_val_t *val = (vl); assert(val); val->val.buffer = malloc(l); \
  106: 						if (val->val.buffer) { \
  107: 							val->val_type = buffer; val->val_len = l; \
  108: 							memcpy(val->val.buffer, v, l); \
  109: 						} } while (0)
  110: #define RPC_SET_STR(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val.string = (int8_t*) strdup(v); \
  111: 						if (val->val.string) { \
  112: 							val->val_type = string; val->val_len = strlen(v) + 1; \
  113: 						} } while (0)
  114: #define RPC_SET_BLOB(vl, v, l)		do { rpc_val_t *val = (vl); assert(val); val->val_type = blob; \
  115: 						val->val.blob = v; val->val_len = l; } while (0)
  116: #define RPC_SET_BLOB2(vl, b)		do { rpc_val_t *val = (vl); assert(val); assert(b); val->val_type = blob; \
  117: 						val->val.blob = b->blob_var; val->val_len = b->blob_len; } while (0)
  118: #define RPC_SET_SIZE(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = size; val->val.size = v; \
  119: 						val->val_len = sizeof(size_t); } while (0)
  120: #define RPC_SET_OFF(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = offset; val->val.offset = v; \
  121: 						val->val_len = sizeof(off_t); } while (0)
  122: #define RPC_SET_TIME(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = datetime; val->val.datetime = v; \
  123: 						val->val_len = sizeof(time_t); } while (0)
  124: #define RPC_SET_REAL(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = real; val->val.real = v; \
  125: 						val->val_len = sizeof(float); } while (0)
  126: #define RPC_SET_BREAL(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = bigreal; val->val.bigreal = v; \
  127: 						val->val_len = sizeof(double); } while (0)
  128: #define RPC_SET_U8(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = u8; val->val.u8 = v; \
  129: 						val->val_len = sizeof(uint8_t); } while (0)
  130: #define RPC_SET_U16(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = u16; val->val.u16 = v; \
  131: 						val->val_len = sizeof(uint16_t); } while (0)
  132: #define RPC_SET_U32(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = u32; val->val.u32 = v; \
  133: 						val->val_len = sizeof(uint32_t); } while (0)
  134: #define RPC_SET_U64(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = u64; val->val.u64 = v; \
  135: 						val->val_len = sizeof(uint64_t); } while (0)
  136: #define RPC_SET_I8(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = i8; val->val.i8 = v; \
  137: 						val->val_len = sizeof(int8_t); } while (0)
  138: #define RPC_SET_I16(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = i16; val->val.i16 = v; \
  139: 						val->val_len = sizeof(int16_t); } while (0)
  140: #define RPC_SET_I32(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = i32; val->val.i32 = v; \
  141: 						val->val_len = sizeof(int32_t); } while (0)
  142: #define RPC_SET_I64(vl, v)		do { rpc_val_t *val = (vl); assert(val); val->val_type = i64; val->val.i64 = v; \
  143: 						val->val_len = sizeof(int64_t); } while (0)
  144: 
  145: #define RPC_FREE_VAL(vl)		do { rpc_val_t *val = (vl); assert(val); \
  146: 						if (val->val_type == buffer && val->val.buffer) { \
  147: 							free(val->val.buffer); \
  148: 							val->val.buffer = NULL; \
  149: 						} \
  150: 						if (val->val_type == string && val->val.string) { \
  151: 							free(val->val.string); \
  152: 							val->val.string = NULL; \
  153: 						} \
  154: 						val->val_type = val->val_len = 0; \
  155: 					} while (0)
  156: 
  157: 
  158: #define RPC_CALLBACK_CHECK_INPUT(x)	do { \
  159: 						if (!x) { \
  160: 							rpc_SetErr(22, "Error:: invalid callback parameters ...\n"); \
  161: 							return -1; \
  162: 						} \
  163: 					} while (0)
  164: #define RPC_CALLBACK_CHK_ARGS(f, n)	do { \
  165: 						RPC_CALLBACK_CHECK_INPUT(f); \
  166: 						if (f && f->func_args != n) { \
  167: 							rpc_SetErr(22, "Error:: different number of arguments!\n"); \
  168: 							return -1; \
  169: 						} \
  170: 					} while (0)
  171: 
  172: 
  173: /* RPC session identification */
  174: 
  175: typedef struct {
  176: 	uint8_t		sess_version;
  177: 	uint32_t	sess_program;
  178: 	uint32_t	sess_process;
  179: } __packed rpc_sess_t;
  180: 
  181: 
  182: /* Server managment RPC functions ... */
  183: 
  184: // RPC function registration element!
  185: typedef struct tagRPCFunc {
  186: 	uint16_t		func_tag;
  187: 	uint32_t		func_hash;
  188: 	int8_t			func_file[MAXPATHLEN];
  189: 	int8_t			func_name[UCHAR_MAX + 1];
  190: 
  191: 	int8_t			func_args;
  192: 	rpc_val_t		*func_vals;
  193: 
  194: 	void			*func_parent;
  195: 	struct tagRPCFunc	*func_next;
  196: } rpc_func_t;
  197: 
  198: 
  199: /* Network RPC packet - Client request */
  200: 
  201: struct tagRPCCall {
  202: 	rpc_sess_t	call_session;
  203: 	uint16_t	call_tag;
  204: 	uint32_t	call_hash;
  205: 	uint8_t		call_argc;
  206: } __packed;
  207: 
  208: /* Network RPC packet - Server response */
  209: 
  210: struct tagRPCRet {
  211: 	rpc_sess_t	ret_session;
  212: 	uint16_t	ret_tag;
  213: 	uint32_t	ret_hash;
  214: 	int32_t		ret_retcode;
  215: 	int32_t		ret_errno;
  216: 	uint8_t		ret_argc;
  217: } __packed;
  218: 
  219: /* Network BLOB packet - Header */
  220: 
  221: struct tagBLOBHdr {
  222: 	rpc_sess_t	hdr_session;
  223: 	uint8_t		hdr_cmd;
  224: 	uint32_t	hdr_var;
  225: 	uint32_t	hdr_len;
  226: 	uint32_t	hdr_ret;
  227: } __packed;
  228: 
  229: /* Network RPC client & server elements */
  230: 
  231: typedef struct {
  232: 	struct sockaddr	cli_sa;		// host info
  233: 	int		cli_sock;	// socket
  234: 	pthread_t	cli_tid;	// TID of thread
  235: 
  236: 	void		*cli_parent;	// pointer to parent rpc_srv_t for server or to rpc_sess_t for client
  237: } rpc_cli_t;
  238: 
  239: 
  240: // BLOB registration element!
  241: typedef struct tagBLOB {
  242: 	uint32_t	blob_var;
  243: 
  244: 	size_t		blob_len;	// size of allocated BLOB data
  245: 	void		*blob_data;	// BLOB data
  246: 
  247: 	struct tagBLOB	*blob_next;
  248: } rpc_blob_t;
  249: 
  250: typedef struct {
  251: 	rpc_sess_t	srv_session;	// RPC session registration info
  252: 	int		srv_numcli;	// maximum concurent client connections
  253: 
  254: 	rpc_cli_t	srv_server;	// RPC server socket
  255: 	rpc_cli_t	*srv_clients;	// connected rpc client sockets
  256: 
  257: 	rpc_func_t	*srv_funcs;	// registered functions list
  258: 
  259: 	pthread_mutex_t	srv_mtx;
  260: 
  261: 	struct {
  262: 		int		state;		// BLOB server state: ==0 disable | !=0 enable
  263: 		char		dir[UCHAR_MAX + 1];
  264: 
  265: 		rpc_cli_t	server;		// BLOB server socket
  266: 		rpc_cli_t	*clients;	// connected blob client sockets
  267: 
  268: 		rpc_blob_t	*blobs;		// registered blob variables list
  269: 
  270: 		pthread_mutex_t	mtx;
  271: 	} 		srv_blob;
  272: } rpc_srv_t;
  273: 
  274: 
  275: /* 
  276:  * (*rpc_callback_t)() Callback type definition for RPC call in server process
  277:  * @arg1 = current execution RPC call function
  278:  * @arg2 = number of items in input array from call request
  279:  * @arg3 = input array with values from RPC call execution request
  280:  * return: -1 error or >-1 success execution
  281:  */
  282: typedef int (*rpc_callback_t)(rpc_func_t *, int, rpc_val_t *);
  283: 
  284: 
  285: // -----------------------------------------------------------------------
  286: 
  287: /* Error support functions */
  288: 
  289: // cli_GetErrno() Get error code of last operation
  290: inline int cli_GetErrno();
  291: // cli_GetError() Get error text of last operation
  292: inline const char *cli_GetError();
  293: 
  294: 
  295: /* RPC Server side functions */
  296: 
  297: /*
  298:  * rpc_srv_initServer() Init & create RPC Server
  299:  * @regProgID = ProgramID for authentication & recognition
  300:  * @regProcID = ProcessID for authentication & recognition
  301:  * @concurentClients = Concurent clients at same time to this server
  302:  * @family = Family socket type, AF_INET or AF_INET6
  303:  * @csHost = Host name or IP address for bind server, if NULL any address
  304:  * @Port = Port for bind server, if Port == 0 default port is selected
  305:  * return: NULL == error or !=NULL bind and created RPC server instance
  306:  */
  307: rpc_srv_t *rpc_srv_initServer(u_int regProgID, u_int regProcID, int concurentClients, 
  308: 		u_short family, const char *csHost, u_short Port);
  309: /*
  310:  * rpc_srv_endServer() Destroy RPC server, close all opened sockets and free resources
  311:  * @srv = RPC Server instance
  312:  * return: none
  313:  */
  314: void rpc_srv_endServer(rpc_srv_t * __restrict srv);
  315: /*
  316:  * rpc_srv_execServer() Execute Main server loop and wait for clients requests
  317:  * @srv = RPC Server instance
  318:  * return: -1 error or 0 ok, infinite loop ...
  319:  */
  320: int rpc_srv_execServer(rpc_srv_t * __restrict srv);
  321: 
  322: /*
  323:  * rpc_srv_initBLOBServer() Init & create BLOB Server
  324:  * @Port = Port for bind server, if Port == 0 default port is selected
  325:  * @diskDir = Disk place for BLOB file objects
  326:  * return: -1 == error or 0 bind and created BLOB server instance
  327:  */
  328: int rpc_srv_initBLOBServer(rpc_srv_t * __restrict srv, u_short Port, const char *diskDir);
  329: /*
  330:  * rpc_srv_endBLOBServer() Destroy BLOB server, close all opened sockets and free resources
  331:  * @srv = RPC Server instance
  332:  * return: none
  333:  */
  334: void rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv);
  335: /*
  336:  * rpc_srv_execBLOBServer() Execute Main BLOB server loop and wait for clients requests
  337:  * @srv = RPC Server instance
  338:  * return: -1 error or 0 ok, infinite loop ...
  339:  */
  340: int rpc_srv_execBLOBServer(rpc_srv_t * __restrict srv);
  341: 
  342: /*
  343:  * rpc_srv_registerCall() Register call to RPC server
  344:  * @srv = RPC Server instance
  345:  * @csModule = Module name, if NULL self binary
  346:  * @csFunc = Function name
  347:  * @args = Number of return function arguments, use for restriction case!
  348:  * return: -1 error or 0 register ok
  349:  */
  350: int rpc_srv_registerCall(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc, 
  351: 		unsigned char args);
  352: /*
  353:  * rpc_srv_unregisterCall() Unregister call from RPC server
  354:  * @srv = RPC Server instance
  355:  * @csModule = Module name, if NULL self binary
  356:  * @csFunc = Function name
  357:  * return: -1 error, 0 not found call, 1 unregister ok
  358:  */
  359: int rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc);
  360: /*
  361:  * rpc_srv_getFunc() Get registered call from RPC server by Name
  362:  * @srv = RPC Server instance
  363:  * @csModule = Module name, if NULL self binary
  364:  * @csFunc = Function name
  365:  * return: NULL not found call, !=NULL return call
  366:  */
  367: rpc_func_t *rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc);
  368: /*
  369:  * rpc_srv_getCall() Get registered call from RPC server
  370:  * @srv = RPC Server instance
  371:  * @tag = tag for function
  372:  * @hash = hash for function
  373:  * return: NULL not found call, !=NULL return call
  374:  */
  375: inline rpc_func_t *rpc_srv_getCall(rpc_srv_t * __restrict srv, uint16_t tag, uint32_t hash);
  376: /*
  377:  * rpc_srv_execCall() Execute registered call from RPC server
  378:  * @call = Register RPC call
  379:  * @rpc = IN RPC call structure
  380:  * @args = IN RPC call array of rpc values
  381:  * return: -1 error, !=-1 ok
  382:  */
  383: int rpc_srv_execCall(rpc_func_t * __restrict call, struct tagRPCCall * __restrict rpc, 
  384: 		rpc_val_t * __restrict args);
  385: 
  386: 
  387: /*
  388:  * rpc_srv_retValsCall() Declare return variables for RPC call and zeroed values
  389: 					(for safe handling return values, use this!)
  390:  * @call = RPC function call
  391:  * @return_vals = Number of return variables
  392:  * return: NULL error, !=NULL array with return values for RPC call with return_vals items
  393:  */
  394: inline rpc_val_t *rpc_srv_retValsCall(rpc_func_t * __restrict call, int return_vals);
  395: /*
  396:  * rpc_srv_declValsCall() Declare return variables for RPC call, 
  397: 				if already allocated memory for RPC call return values 
  398: 				function reallocate used space with return_vals count elements
  399:  * @call = RPC function call
  400:  * @return_vals = Number of return variables
  401:  * return: -1 error, !=-1 ok
  402:  */
  403: inline int rpc_srv_declValsCall(rpc_func_t * __restrict call, int return_vals);
  404: /*
  405:  * rpc_srv_freeValsCall() Free return variables for RPC call
  406:  * @call = RPC function call
  407:  * return: none
  408:  */
  409: inline void rpc_srv_freeValsCall(rpc_func_t * __restrict call);
  410: /*
  411:  * rpc_srv_copyValsCall() Copy return variables for RPC call to new variable
  412:  * @call = RPC function call
  413:  * @newvals = New allocated variables array, must be free after use
  414:  * return: -1 error, !=-1 Returned number of copied RPC variables
  415:  */
  416: inline int rpc_srv_copyValsCall(rpc_func_t * __restrict call, rpc_val_t ** __restrict newvals);
  417: /*
  418:  * rpc_srv_zeroValsCall() Clean values from return variables of RPC call
  419:  * @call = RPC function call
  420:  * return: -1 error, !=-1 Returned number of cleaned RPC variables
  421:  */
  422: inline int rpc_srv_zeroValsCall(rpc_func_t * __restrict call);
  423: /*
  424:  * rpc_srv_getValsCall() Get return variables for RPC call
  425:  * @call = RPC function call
  426:  * @vals = Returned variables, may be NULL
  427:  * return: -1 error, !=-1 Number of returned variables
  428:  */
  429: inline int rpc_srv_getValsCall(rpc_func_t * __restrict call, rpc_val_t ** __restrict vals);
  430: 
  431: 
  432: /*
  433:  * rpc_srv_blobCreate() Create map blob to memory region and return object
  434:  * @srv = RPC Server instance
  435:  * @len = BLOB length object
  436:  * return: NULL error or !=NULL allocated BLOB object
  437:  */
  438: inline rpc_blob_t *rpc_srv_blobCreate(rpc_srv_t * __restrict srv, int len);
  439: /*
  440:  * rpc_srv_blobMap() Map blob to memory region 
  441:  * @srv = RPC Server instance
  442:  * @blob = Map to this BLOB element
  443:  * return: -1 error or 0 ok
  444:  */
  445: inline int rpc_srv_blobMap(rpc_srv_t * __restrict srv, rpc_blob_t * __restrict blob);
  446: /*
  447:  * rpc_srv_blobUnmap() Unmap blob memory region 
  448:  * @blob = Mapped BLOB element
  449:  * return: none
  450:  */
  451: inline void rpc_srv_blobUnmap(rpc_blob_t * __restrict blob);
  452: /*
  453:  * rpc_srv_blobFree() Free blob from disk & memory
  454:  * @srv = RPC Server instance
  455:  * @blob = Mapped BLOB element
  456:  * return: -1 error or 0 ok
  457:  */
  458: inline int rpc_srv_blobFree(rpc_srv_t * __restrict srv, rpc_blob_t * __restrict blob);
  459: 
  460: /*
  461:  * rpc_srv_registerBLOB() Register new BLOB to server
  462:  * @srv = RPC Server instance
  463:  * @len = BLOB length
  464:  * return: NULL error or new registered BLOB
  465:  */
  466: rpc_blob_t *rpc_srv_registerBLOB(rpc_srv_t * __restrict srv, size_t len);
  467: /*
  468:  * rpc_srv_unregisterBLOB() Unregister BLOB from server
  469:  * @srv = RPC Server instance
  470:  * @var = BLOB Variable for unregister
  471:  * return: -1 error, 0 not found call, 1 unregister ok
  472:  */
  473: int rpc_srv_unregisterBLOB(rpc_srv_t * __restrict srv, uint32_t var);
  474: /*
  475:  * rpc_srv_getBLOB() Get registered BLOB 
  476:  * @srv = RPC Server instance
  477:  * @var = hash for variable
  478:  * return: NULL not found, !=NULL return blob var
  479:  */
  480: inline rpc_blob_t *rpc_srv_getBLOB(rpc_srv_t * __restrict srv, uint32_t var);
  481: 
  482: /*
  483:  * rpc_srv_sendBLOB() Send mapped BLOB to client
  484:  * @cli = Client instance
  485:  * @blob = Mapped BLOB element
  486:  * return: -1 error, 0 ok
  487:  */
  488: int rpc_srv_sendBLOB(rpc_cli_t * __restrict cli, rpc_blob_t * __restrict blob);
  489: /*
  490:  * rpc_srv_recvBLOB() Receive BLOB from client
  491:  * @cli = Client instance
  492:  * @blob = Mapped BLOB element
  493:  * return: -1 error, 0 ok, >0 unreceived data from client, may be error?
  494:  */
  495: int rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_t * __restrict blob);
  496: 
  497: /*
  498:  * rpc_cli_sendBLOB() Send BLOB to server
  499:  * @cli = Client instance
  500:  * @var = BLOB variable
  501:  * @data = BLOB data
  502:  * return: -1 error, 0 ok, 1 remote error
  503:  */
  504: int rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, rpc_val_t * __restrict var, void * __restrict data);
  505: /*
  506:  * rpc_cli_recvBLOB() Receive BLOB from server
  507:  * @cli = Client instance
  508:  * @var = BLOB variable
  509:  * @data = BLOB data, must be free after use!
  510:  * return: -1 error, 0 ok, 1 remote error
  511:  */
  512: int rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, rpc_val_t * __restrict var, void ** data);
  513: /*
  514:  * rpc_cli_delBLOB() Delete BLOB from server
  515:  * @cli = Client instance
  516:  * @var = BLOB variable
  517:  * return: -1 error, 0 ok, 1 remote error
  518:  */
  519: int rpc_cli_delBLOB(rpc_cli_t * __restrict cli, rpc_val_t * __restrict var);
  520: /*
  521:  * rpc_cli_getBLOB() Receive BLOB from server and Delete after that.
  522:  * @cli = Client instance
  523:  * @var = BLOB variable
  524:  * @data = BLOB data, must be free after use!
  525:  * return: -1 error, 0 ok, >0 remote error
  526:  */
  527: inline int rpc_cli_getBLOB(rpc_cli_t * __restrict cli, rpc_val_t * __restrict var, void ** data);
  528: 
  529: 
  530: 
  531: /* RPC Client side functions */
  532: 
  533: /*
  534:  * rpc_cli_openClient() Connect to RPC Server
  535:  * @ProgID = ProgramID for RPC session request
  536:  * @ProcID = ProcessID for RPC session request
  537:  * @family = Family socket type, AF_INET or AF_INET6
  538:  * @csHost = Host name or IP address for bind server
  539:  * @Port = Port for bind server, if Port == 0 default port is selected
  540:  * return: NULL == error or !=NULL connection to RPC server established
  541:  */
  542: rpc_cli_t *rpc_cli_openClient(u_int ProgID, u_int ProcID, u_short family, 
  543: 		const char *csHost, u_short Port);
  544: /*
  545:  * rpc_cli_closeClient() Close connection to RPC server and free resources
  546:  * @cli = RPC Client session
  547:  * return: none
  548:  */
  549: void rpc_cli_closeClient(rpc_cli_t * __restrict cli);
  550: /*
  551:  * rpc_cli_execCall() Execute RPC call
  552:  * @cli = RPC Client session
  553:  * @csModule = Module name, if NULL self binary
  554:  * @csFunc = Function name for execute
  555:  * @in_argc = IN count of arguments
  556:  * @in_vals = IN RPC call array of rpc values
  557:  * @out_argc = OUT returned count of arguments
  558:  * @out_vals = OUT returned array of rpc values, must be free after use (see rpc_cli_freeVals())
  559:  * return: -1 error or != -1 ok result
  560:  */
  561: int rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, const char *csFunc, int in_argc, 
  562: 		rpc_val_t * __restrict in_vals, int *out_argc, rpc_val_t ** __restrict out_vals);
  563: /*
  564:  * rpc_cli_freeVals() Free rpc_val_t array returned from RPC call
  565:  * @args = Number of arguments in array
  566:  * @vals = Value elements
  567:  * return: none
  568:  */
  569: inline void rpc_cli_freeVals(int args, rpc_val_t *vals);
  570: 
  571: 
  572: /*
  573:  * rpc_cli_openBLOBClient() Connect to BLOB Server
  574:  * @rpccli = RPC Client session
  575:  * @Port = Port for bind server, if Port == 0 default port is selected
  576:  * return: NULL == error or !=NULL connection to BLOB server established
  577:  */
  578: rpc_cli_t *rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli, u_short Port);
  579: /*
  580:  * rpc_cli_closeBLOBClient() Close connection to BLOB server and free resources
  581:  * @cli = BLOB Client session
  582:  * return: none
  583:  */
  584: void rpc_cli_closeBLOBClient(rpc_cli_t * __restrict cli);
  585: 
  586: 
  587: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>