rpc.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 
00025 #ifndef _EYEDBLIB_RPC_H
00026 #define _EYEDBLIB_RPC_H
00027 
00028 #include <stdio.h>
00029 #include <eyedblib/machtypes.h>
00030 
00031 enum {
00032   rpc_VoidType = 1,
00033   rpc_ByteType,
00034   rpc_Int16Type,
00035   rpc_Int32Type,
00036   rpc_Int64Type,
00037   rpc_StringType,
00038   rpc_DataType,
00039   rpc_StatusType,
00040   rpc_NBaseType
00041 };
00042 
00043 typedef unsigned int rpc_ArgType;
00044 
00045 typedef enum {
00046   rpc_Send = 0x1,
00047   rpc_Rcv  = 0x2
00048 } rpc_SendRcv;
00049 
00050 typedef struct {
00051   rpc_ArgType type;
00052   rpc_SendRcv send_rcv;
00053 } rpc_Arg;
00054 
00055 enum {
00056   rpc_Success = 0,
00057   rpc_ConnectionFailure,
00058   rpc_ServerFailure,
00059   rpc_Error
00060 };
00061 
00062 typedef unsigned int rpc_Status;
00063 typedef unsigned int rpc_RpcCode;
00064 
00065 typedef enum {
00066   rpc_False = 0,
00067   rpc_True = 1
00068 } rpc_Boolean;
00069 
00070 typedef struct {
00071   rpc_RpcCode code;
00072   int nargs;
00073   rpc_Arg *args;
00074   rpc_ArgType arg_ret;
00075 } rpc_RpcDescription;
00076 
00077 typedef enum {
00078   rpc_To   = 0x10,
00079   rpc_From = 0x11
00080 } rpc_FromTo;
00081 
00082 #define RPC_DATA \
00083   int size; \
00084   void *data; \
00085   int status
00086 
00087 typedef struct {
00088   RPC_DATA;
00089 } rpc_Data;
00090 
00091 typedef void (*rpc_UserArgFunction)(rpc_Arg *, char **, void *, rpc_SendRcv,
00092                                     rpc_FromTo);
00093 
00094 /* function prototypes */
00095 extern rpc_RpcDescription *rpc_newRpcDescription(rpc_RpcCode, int);
00096 extern void rpc_deleteRpcDescription(rpc_RpcDescription *);
00097 extern rpc_Boolean rpc_portIsAddress(const char *);
00098 
00099 extern const char *rpc_getPortAttr(const char *, int *domain, int *type);
00100 
00101 #define rpc_ObjectNone (void *)-1
00102 #define rpc_SizeVariable -1
00103 
00104 #define rpc_assert(X) \
00105   if (!(X)) \
00106     { \
00107        fprintf(stderr, "assertion failed `%s' in file `%s', line %d\n", #X, \
00108                 __FILE__, __LINE__); \
00109        return 0; \
00110     }
00111 
00112 #endif

Generated on Mon Dec 22 18:16:07 2008 for eyedb by  doxygen 1.5.3