2
0
Эх сурвалжийг харах

core: docs - Update type identifiers that can be used in the RPC API

- format as well
Xenofon Karamanos 2 сар өмнө
parent
commit
9a8ab31994

+ 89 - 42
doc/tutorials/rpc/kamailio_rpc.xml

@@ -16,7 +16,7 @@
         <pubdate role="cvs">$Date$</pubdate>
         <pubdate role="cvs">$Date$</pubdate>
     </sectioninfo>
     </sectioninfo>
     -->
     -->
- 
+
     <title>
     <title>
 	The Kamailio RPC Control Interface
 	The Kamailio RPC Control Interface
     </title>
     </title>
@@ -62,7 +62,7 @@
 		 (over HTTP TCP or TLS).
 		 (over HTTP TCP or TLS).
 	</para>
 	</para>
 	<para>
 	<para>
-		 For more information about the existing transport modules, please 
+		 For more information about the existing transport modules, please
 		 refer to their documentation.
 		 refer to their documentation.
 	</para>
 	</para>
 	<para>
 	<para>
@@ -148,7 +148,7 @@ typedef void (*rpc_function_t)(rpc_t* rpc, void* ctx);
 		Each module containing RPC functions has to export all the
 		Each module containing RPC functions has to export all the
 		RPC functions to the &kamailio; core in order to make them visible to the RPC
 		RPC functions to the &kamailio; core in order to make them visible to the RPC
 		transport modules.
 		transport modules.
-		The export process involves a <emphasis>rpc_export_t</emphasis> 
+		The export process involves a <emphasis>rpc_export_t</emphasis>
 		structure (either by itself or in an array):
 		structure (either by itself or in an array):
 		<programlisting>
 		<programlisting>
 <emphasis>
 <emphasis>
@@ -219,11 +219,11 @@ rpc_export_t ul_rpc[] = {
 				contains a new attribute called <varname>rpc_methods</varname>:
 				contains a new attribute called <varname>rpc_methods</varname>:
 				<programlisting>
 				<programlisting>
 struct module_exports {
 struct module_exports {
-    char* name;                 /* null terminated module name */	
+    char* name;                 /* null terminated module name */
     cmd_export_t* cmds;         /* null terminated array of the exported commands */
     cmd_export_t* cmds;         /* null terminated array of the exported commands */
     <emphasis>rpc_export_t* rpc_methods;</emphasis>  /* null terminated array of exported rpc methods */
     <emphasis>rpc_export_t* rpc_methods;</emphasis>  /* null terminated array of exported rpc methods */
     param_export_t* params;     /* null terminated array of the exported module parameters */
     param_export_t* params;     /* null terminated array of the exported module parameters */
-    
+
     init_function init_f;         /* Initialization function */
     init_function init_f;         /* Initialization function */
     response_function response_f; /* function used for responses */
     response_function response_f; /* function used for responses */
     destroy_function destroy_f;   /* function called upon shutdown */
     destroy_function destroy_f;   /* function called upon shutdown */
@@ -236,19 +236,19 @@ struct module_exports {
 				bumper containing zeroes in all the attributes of the
 				bumper containing zeroes in all the attributes of the
 				structure. The following program listing shows the exported RPC
 				structure. The following program listing shows the exported RPC
 				functions of the modules_s/usrloc module, using the rpc_export_t array
 				functions of the modules_s/usrloc module, using the rpc_export_t array
-				<emphasis>ul_rpc</emphasis> defined above, in the 
+				<emphasis>ul_rpc</emphasis> defined above, in the
 				rpc_register_array() example:
 				rpc_register_array() example:
 				<example><title>usrloc Module Exports Declaration</title>
 				<example><title>usrloc Module Exports Declaration</title>
 					<programlisting>
 					<programlisting>
 struct module_exports exports = {
 struct module_exports exports = {
     "usrloc",
     "usrloc",
-    cmds,      /* Exported functions */ 
+    cmds,      /* Exported functions */
     <emphasis>ul_rpc</emphasis>,    /* RPC methods */
     <emphasis>ul_rpc</emphasis>,    /* RPC methods */
-    params,    /* Export parameters */ 
-    mod_init,  /* Module initialization function */ 
-    0,         /* Response function */ 
-    destroy,   /* Destroy function */ 
-    0,         /* OnCancel function */ 
+    params,    /* Export parameters */
+    mod_init,  /* Module initialization function */
+    0,         /* Response function */
+    destroy,   /* Destroy function */
+    0,         /* OnCancel function */
     child_init /* Child initialization function */ };
     child_init /* Child initialization function */ };
 
 
 					</programlisting>
 					</programlisting>
@@ -256,8 +256,9 @@ struct module_exports exports = {
 				<note><para>
 				<note><para>
 					This mode works only with modules using the SER flavour module
 					This mode works only with modules using the SER flavour module
 					interface. It does not work for &kamailio; modules and it
 					interface. It does not work for &kamailio; modules and it
-					will probably not work for future sip-router modules. It is
-					safer and recommended to use instead the
+					will probably not work for future sip-router modules.
+					<emphasis>It is now completely obselete.</emphasis>
+					The correct way is to use instead the
 					<function>rpc_register_array()</function> function.
 					<function>rpc_register_array()</function> function.
 				</para></note>
 				</para></note>
 			</para></listitem>
 			</para></listitem>
@@ -353,34 +354,74 @@ add("sd", string_param, int_param);
 			(2 ints and a string) are optional.
 			(2 ints and a string) are optional.
 		</para>
 		</para>
 		</formalpara>
 		</formalpara>
-	    <table>
+		<table>
 		<title>Data Type Overview</title>
 		<title>Data Type Overview</title>
 		<tgroup cols="3">
 		<tgroup cols="3">
-		    <tbody>
+			<tbody>
 			<row rowsep="1">
 			<row rowsep="1">
-			    <entry>Name</entry>
-			    <entry>Formating String Char</entry>
-			    <entry>C-Style Variable</entry>
+				<entry>Name</entry>
+				<entry>Formating String Char</entry>
+				<entry>C-Style Variable</entry>
+			</row>
+			<row>
+				<entry>Integer</entry>
+				<entry>d</entry>
+				<entry>int</entry>
 			</row>
 			</row>
 			<row>
 			<row>
-			    <entry>Integer</entry>
-			    <entry>d</entry>
-			    <entry>int</entry>
+				<entry>Unsigned Integer</entry>
+				<entry>u</entry>
+				<entry>int</entry>
 			</row>
 			</row>
 			<row>
 			<row>
-			    <entry>Float</entry>
-			    <entry>f</entry>
-			    <entry>double</entry>
+				<entry>Boolean</entry>
+				<entry>b</entry>
+				<entry>int</entry>
 			</row>
 			</row>
 			<row>
 			<row>
-			    <entry>String</entry>
-			    <entry>s</entry>
-			    <entry>char*</entry>
+				<entry>Long</entry>
+				<entry>l</entry>
+				<entry>long</entry>
 			</row>
 			</row>
 			<row>
 			<row>
-			    <entry>String</entry>
-			    <entry>S</entry>
-			    <entry>str*</entry>
+				<entry>Unsigned Long</entry>
+				<entry>j</entry>
+				<entry>unsigned long</entry>
+			</row>
+			<row>
+				<entry>Long Long</entry>
+				<entry>L</entry>
+				<entry>long long</entry>
+			</row>
+			<row>
+				<entry>Unsigned Long Long</entry>
+				<entry>J</entry>
+				<entry>unsigned long long</entry>
+			</row>
+			<row>
+				<entry>Float</entry>
+				<entry>f</entry>
+				<entry>double</entry>
+			</row>
+			<row>
+				<entry>String</entry>
+				<entry>s</entry>
+				<entry>char*</entry>
+			</row>
+			<row>
+				<entry>String</entry>
+				<entry>S</entry>
+				<entry>str*</entry>
+			</row>
+			<row>
+				<entry>time</entry>
+				<entry>t</entry>
+				<entry>int</entry>
+			</row>
+			<row>
+				<entry>Struct</entry>
+				<entry>{</entry>
+				<entry>struct rpc_struct_l </entry>
 			</row>
 			</row>
 			<row>
 			<row>
 				<entry>Optional modifier</entry>
 				<entry>Optional modifier</entry>
@@ -392,9 +433,15 @@ add("sd", string_param, int_param);
 				<entry>.</entry>
 				<entry>.</entry>
 				<entry>requires auto-conversion for the next parameter</entry>
 				<entry>requires auto-conversion for the next parameter</entry>
 			</row>
 			</row>
-		    </tbody>
+			</tbody>
 		</tgroup>
 		</tgroup>
-	    </table>
+		</table>
+
+		<note>
+			<para>
+			The <emphasis>time</emphasis> parameter is of type <emphasis>int</emphasis>. Recent OS use 64-bit time_t (typedef long), so if you are using a 64-bit OS, you should use <emphasis>l</emphasis> or <emphasis>LL</emphasis> instead of <emphasis>t</emphasis> when trying to add/read a time_t value to avoid overflowing.
+			</para>
+		</note>
 	</section>
 	</section>
 
 
 	<section id="rpc.getting_parameters">
 	<section id="rpc.getting_parameters">
@@ -448,7 +495,7 @@ add("sd", string_param, int_param);
 		</para>
 		</para>
 		<para>
 		<para>
 			The '.' modifiers turns on type autoconversion for the next
 			The '.' modifiers turns on type autoconversion for the next
-			parameter. This means that if the type of the next parameter 
+			parameter. This means that if the type of the next parameter
 			differs from the type specified in the formatting string, the
 			differs from the type specified in the formatting string, the
 			parameter will be automatically converted to the formatting string
 			parameter will be automatically converted to the formatting string
 			type (if possible) and if the automatic conversion succeeds, no
 			type (if possible) and if the automatic conversion succeeds, no
@@ -457,13 +504,13 @@ add("sd", string_param, int_param);
 		<para>
 		<para>
 			The function returns the number of parameters read on success
 			The function returns the number of parameters read on success
 			(a number greater or equal 0) and - (minus) the number of
 			(a number greater or equal 0) and - (minus) the number of
-			parameters read on error (for example for an error after 
+			parameters read on error (for example for an error after
 			reading 2 parameters it will return -2).
 			reading 2 parameters it will return -2).
 			When a failure occurs (incorrect parameter type or no more
 			When a failure occurs (incorrect parameter type or no more
 			parameters in the parameter set) the function will
 			parameters in the parameter set) the function will
 			return a negative number (- number of parameters read so far)
 			return a negative number (- number of parameters read so far)
 			and it will also automatically change the reply that will be
 			and it will also automatically change the reply that will be
-			sent to the caller to indicate that a failure has occurred on 
+			sent to the caller to indicate that a failure has occurred on
 			the server (unless the "*" is used and the error is lack
 			the server (unless the "*" is used and the error is lack
 			of more parameters).
 			of more parameters).
 		</para>
 		</para>
@@ -504,7 +551,7 @@ rpc->scan(ctx, "f", &amp;double_val);
 		    <programlisting>
 		    <programlisting>
 rpc->scan(ctx, "{", &amp;handle);
 rpc->scan(ctx, "{", &amp;handle);
 		    </programlisting>
 		    </programlisting>
-		    The corresponding variable (named 
+		    The corresponding variable (named
 		    <varname>handle</varname> in the example above) will contain
 		    <varname>handle</varname> in the example above) will contain
 		    the index of the structure parameter within the parameter
 		    the index of the structure parameter within the parameter
 		    set, but the index cannot be used to retrieve the contents
 		    set, but the index cannot be used to retrieve the contents
@@ -526,7 +573,7 @@ rpc->struct_scan(handle, "sd", "str_attr", &amp;str_val, "int_attr", &amp;int_va
 		    the structure.
 		    the structure.
 		</para>
 		</para>
 	    </section>
 	    </section>
-	
+
 		<section><title>Retrieving Parameters Example</title>
 		<section><title>Retrieving Parameters Example</title>
 		<example>
 		<example>
 		<title>Retrieving Parameters</title>
 		<title>Retrieving Parameters</title>
@@ -569,7 +616,7 @@ static void core_prints(rpc_t* rpc, void* c)
 }
 }
 
 
 /* variable number of parameters and auto conversion:
 /* variable number of parameters and auto conversion:
-   echo back all the parameters, works with any type (everything is 
+   echo back all the parameters, works with any type (everything is
    internally converted to string, notice the '.' modifier) */
    internally converted to string, notice the '.' modifier) */
 static void core_echo(rpc_t* rpc, void* c)
 static void core_echo(rpc_t* rpc, void* c)
 {
 {
@@ -703,7 +750,7 @@ static void core_kill(rpc_t* rpc, void *ctx)
 ]]>
 ]]>
 		    </programlisting>
 		    </programlisting>
 		</example>
 		</example>
-		
+
 	    </section>
 	    </section>
 	    <section>
 	    <section>
 		<title>add</title>
 		<title>add</title>
@@ -867,8 +914,8 @@ static void rpc_register(rpc_t* rpc, void *ctx)
 		module).
 		module).
 		</para></listitem>
 		</para></listitem>
 		<listitem><para>
 		<listitem><para>
-		<emphasis>serweb</emphasis> (php application that can use
-		the <emphasis>XML-RPC</emphasis> interface to call ser 
+		<emphasis>siremis</emphasis> (php application that can use
+		the <emphasis>XML-RPC</emphasis> interface to call &kamailioname;
 		functions).
 		functions).
 		</para></listitem>
 		</para></listitem>
 	</itemizedlist>
 	</itemizedlist>