Browse code

- new management interface

Jan Janak authored on 12/12/2005 23:40:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,85 @@
0
+/* $Id$
1
+ *
2
+ * SER Remote Procedure Call Interface
3
+ *
4
+ * Copyright (C) 2005 iptelorg GmbH
5
+ *
6
+ * This file is part of ser, a free SIP server.
7
+ *
8
+ * ser is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * For a license to use the ser software under conditions
14
+ * other than those described here, or to purchase support for this
15
+ * software, please contact iptel.org by e-mail at the following addresses:
16
+ *    info@iptel.org
17
+ *
18
+ * ser is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License 
24
+ * along with this program; if not, write to the Free Software 
25
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
+ */
27
+
28
+#ifndef _RPC_H
29
+#define _RPC_H
30
+
31
+/*
32
+ * TODO: Add the possibility to add printf-like formatted string to fault
33
+ */
34
+
35
+enum rpc_flags {
36
+	RET_ARRAY = (1 << 0),
37
+	RET_VALUE = (1 << 1)
38
+};
39
+	
40
+
41
+/* Send the result to the caller */
42
+typedef int (*rpc_send_f)(void* ctx);                              /* Send the reply to the client */
43
+typedef void (*rpc_fault_f)(void* ctx, int code, char* reason);          /* Signal a failure to the client */
44
+typedef int (*rpc_add_f)(void* ctx, char* fmt, ...);                     /* Add a new piece of data to the result */
45
+typedef int (*rpc_scan_f)(void* ctx, char* fmt, ...);                    /* Retrieve request parameters */
46
+typedef int (*rpc_printf_f)(void* ctx, char* fmt, ...);                  /* Add printf-like formated data to the result set */
47
+typedef int (*rpc_struct_add_f)(int handle, char* fmt, ...);  /* Create a new structure */
48
+typedef int (*rpc_struct_scan_f)(int handle, char* fmt, ...); /* Scan attributes of a structure */
49
+
50
+/*
51
+ * RPC context, this is what RPC functions get as a parameter and use
52
+ * it to obtain the value of the parameters of the call and reference
53
+ * to the result structure that will be returned to the caller
54
+ */
55
+typedef struct rpc {
56
+	rpc_fault_f fault;
57
+	rpc_send_f send;
58
+	rpc_add_f add;
59
+	rpc_scan_f scan;
60
+	rpc_printf_f printf;
61
+	rpc_struct_add_f struct_add;
62
+	rpc_struct_scan_f struct_scan;
63
+} rpc_t;
64
+
65
+
66
+/*
67
+ * RPC Function Prototype
68
+ */
69
+
70
+typedef void (*rpc_function_t)(rpc_t* rpc, void* ctx);
71
+
72
+
73
+/*
74
+ * Remote Procedure Call Export
75
+ */
76
+typedef struct rpc_export {
77
+	const char* name;        /* Name of the RPC function (null terminated) */
78
+	rpc_function_t function; /* Pointer to the function */
79
+	const char** doc_str;  /* Documentation strings, method signature and description */
80
+	unsigned int flags;      /* Various flags, reserved for future use */
81
+} rpc_export_t;
82
+
83
+
84
+#endif /* _RPC_H */