00001 /* $Id$ 00002 * 00003 * SER Remote Procedure Call Interface 00004 * 00005 * Copyright (C) 2005 iptelorg GmbH 00006 * 00007 * This file is part of ser, a free SIP server. 00008 * 00009 * ser is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version 00013 * 00014 * For a license to use the ser software under conditions 00015 * other than those described here, or to purchase support for this 00016 * software, please contact iptel.org by e-mail at the following addresses: 00017 * info@iptel.org 00018 * 00019 * ser is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * along with this program; if not, write to the Free Software 00026 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00027 */ 00028 00029 #ifndef _RPC_H 00030 #define _RPC_H 00031 00032 /* 00033 * TODO: Add the possibility to add printf-like formatted string to fault 00034 */ 00035 00036 enum rpc_flags { 00037 RET_ARRAY = (1 << 0), 00038 RET_VALUE = (1 << 1) 00039 }; 00040 00041 typedef enum rpc_capabilities { 00042 RPC_DELAYED_REPLY = (1 <<0) /* delayed reply support */ 00043 } rpc_capabilities_t; 00044 00045 struct rpc_delayed_ctx; 00046 00047 00048 /* Send the result to the caller */ 00049 typedef int (*rpc_send_f)(void* ctx); /* Send the reply to the client */ 00050 typedef void (*rpc_fault_f)(void* ctx, int code, char* fmt, ...); /* Signal a failure to the client */ 00051 typedef int (*rpc_add_f)(void* ctx, char* fmt, ...); /* Add a new piece of data to the result */ 00052 typedef int (*rpc_scan_f)(void* ctx, char* fmt, ...); /* Retrieve request parameters */ 00053 typedef int (*rpc_printf_f)(void* ctx, char* fmt, ...); /* Add printf-like formated data to the result set */ 00054 typedef int (*rpc_struct_add_f)(void* ctx, char* fmt, ...); /* Create a new structure */ 00055 typedef int (*rpc_struct_scan_f)(void* ctx, char* fmt, ...); /* Scan attributes of a structure */ 00056 typedef int (*rpc_struct_printf_f)(void* ctx, char* name, char* fmt, ...); /* Struct version of rpc_printf */ 00057 00058 /* returns the supported capabilities */ 00059 typedef rpc_capabilities_t (*rpc_capabilities_f)(void* ctx); 00060 /* create a special "context" for delayed replies */ 00061 typedef struct rpc_delayed_ctx* (*rpc_delayed_ctx_new_f)(void* ctx); 00062 /* close the special "context" for delayed replies */ 00063 typedef void (*rpc_delayed_ctx_close_f)(struct rpc_delayed_ctx* dctx); 00064 00065 /* 00066 * RPC context, this is what RPC functions get as a parameter and use 00067 * it to obtain the value of the parameters of the call and reference 00068 * to the result structure that will be returned to the caller 00069 */ 00070 typedef struct rpc { 00071 rpc_fault_f fault; 00072 rpc_send_f send; 00073 rpc_add_f add; 00074 rpc_scan_f scan; 00075 rpc_printf_f printf; 00076 rpc_struct_add_f struct_add; 00077 rpc_struct_scan_f struct_scan; 00078 rpc_struct_printf_f struct_printf; 00079 rpc_capabilities_f capabilities; 00080 rpc_delayed_ctx_new_f delayed_ctx_new; 00081 rpc_delayed_ctx_close_f delayed_ctx_close; 00082 } rpc_t; 00083 00084 00085 typedef struct rpc_delayed_ctx{ 00086 rpc_t rpc; 00087 void* reply_ctx; 00088 /* more private data might follow */ 00089 } rpc_delayed_ctx_t; 00090 00091 00092 /* 00093 * RPC Function Prototype 00094 */ 00095 00096 typedef void (*rpc_function_t)(rpc_t* rpc, void* ctx); 00097 00098 /* 00099 * RPC callback context. 00100 * 00101 * Defines a convenient way of packing an rpc callback 00102 * (rpc_function_t) parameters and it's not used/needed 00103 * by the rpc api/interface. 00104 */ 00105 typedef struct rpc_cb_ctx { 00106 rpc_t *rpc; 00107 void *c; 00108 } rpc_cb_ctx_t; 00109 00110 00111 /* 00112 * Remote Procedure Call Export 00113 */ 00114 typedef struct rpc_export { 00115 const char* name; /* Name of the RPC function (null terminated) */ 00116 rpc_function_t function; /* Pointer to the function */ 00117 const char** doc_str; /* Documentation strings, method signature and description */ 00118 unsigned int flags; /* Various flags, reserved for future use */ 00119 } rpc_export_t; 00120 00121 00122 #endif /* _RPC_H */
1.7.1