Module: sip-router
Branch: master
Commit: 04938dc72661dfe0c8954f392558812f7aa3da78
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=04938dc…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 14:05:50 2009 +0200
core: futexlock include hack for older futex.h
Older non-fixed linux/futex.h version (<2.6.20) cannot be included from
userspace without additional type declarations (which otherwise
are included only if __KERNEL__ is defined).
Note that most distribution fix this problem by distributing a
modified /usr/include/linux/futex.h and not the default kernel
one. However there are other distributions (like CentOS 5) for
which this hack is needed.
---
futexlock.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/futexlock.h b/futexlock.h
index 19e816d..df93b81 100644
--- a/futexlock.h
+++ b/futexlock.h
@@ -49,6 +49,12 @@
between linux-libc-dev andlibc headers
in recent (6.08.2008) x86_64 debian sid
installations */
+/* hack to work with old linux/futex.h versions, that depend on sched.h in
+ __KERNEL__ mode (futex.h < 2.6.20) */
+#include <linux/types.h>
+typedef __u32 u32;
+struct task_struct;
+/* end of the hack */
#include <linux/futex.h>
#include <sys/syscall.h>
#include <unistd.h>
Bugs item #2822344, was opened at 2009-07-16 11:06
Message generated for change (Tracker Item Submitted) made by axlh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2822344&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: ver 1.4.x
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex Hermann (axlh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Branch route has wrong ruri or missing headers
Initial Comment:
The scenario:
In branch route, I rewrite the ruri and add an additional header. When the destination fails and DNS-based failover takes place, the branch route is called again. For this second branch, the ruri is not the same as the ruri at t_relay time. Also the extra header is missing.
So this bug could be either:
- The ruri and rest of variables/packet for each branch should be the same as the ruri at t_relay time
or
- The header added in the first branch route should also be present for the second branch (in the case of DNS-based failover)
I would either expect the ruri and all other variables and headers to be exactly the same as at t_relay time for each branch, or (for DNS-based failover ONLY) the packet sent to a failover destination to be exactly the same as the first branch (including any added headers / from replacement, etc.) Not a mix of both.
Before t_relay:
$rU = "*1234567890"
t_relay("0x03");
my branch route:
xlog("L_NOTICE", "Branch: <$ru> via <$du>\n");
if (is_method("INVITE") and $(rU{s.substr,0,3}) == "*12") {
strip(3);
append_hf("X-Test: 12\r\n");
}
The log:
Jul 15 09:14:38 Branch: <sip:*1234567890@test.domain;transport=udp> via <<null>>
Jul 15 09:14:38 Reply Status: 503 Service Unavailable
Jul 15 09:14:38 Branch: <sip:234567890@test.domain;transport=udp> via <<null>>
Jul 15 09:14:38 Reply Status: 100 Trying
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2822344&group_…
Module: sip-router
Branch: master
Commit: d6e8fdb3a06aab44c01ce5e5a2ca4f2d43117676
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d6e8fdb…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 10:38:14 2009 +0200
xmlrpc(s) doc: added the autoconversion parameter
---
modules_s/xmlrpc/doc/params.xml | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/modules_s/xmlrpc/doc/params.xml b/modules_s/xmlrpc/doc/params.xml
index 324495d..be7fd63 100644
--- a/modules_s/xmlrpc/doc/params.xml
+++ b/modules_s/xmlrpc/doc/params.xml
@@ -41,8 +41,35 @@ modparam("xmlrpc", "route", "route_for_xmlrpcs")
</example>
</section>
+ <section id="autoconversion">
+ <title><varname>autoconversion</varname> (string)</title>
+ <para>
+ Enable or disable automatic parameter type conversion globally,
+ for all the methods parameters.
+ If on, a type mismatch in a method parameter
+ will not cause a fault if it is possible to automatically
+ convert it to the type expected by the method.
+ </para>
+ <para>
+ Default: off.
+ </para>
+ <para>
+ It is recommended to leave this parameter to its default off value
+ and fix instead the client application (which should use the
+ proper types) or to modify the target rpc to accept any type
+ (see the rpc scan '.' modifier).
+ </para>
+ <example>
+ <title>Set the <varname>autoconversion</varname> parameter</title>
+ <programlisting>
+modparam("xmlrpc", "autoconversion", 1)
+ </programlisting>
+ </example>
+ </section>
+
<!--
- Seems to be obsolete (on always) -andrei
+ Obsolete (hardwired on in the rpc core functions, cannot be turned off)
+ -andrei
<section id="enable_introspection">
<title><varname>enable_introspection</varname> (integer)</title>
<para>
Module: sip-router
Branch: master
Commit: b15f37fc1eb2fceaf8ea04e35e94850164f06cf5
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b15f37f…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 10:39:36 2009 +0200
xmlrpc(s) doc: note about xmlrpclib bug
- added note about xmlrpclib bug (waiting for connection closing)
and workarounds (use a different transport class or make ser
close the tcp connection after each answer).
- list examples/xmlrpc_test.{pl,py} among the client examples
- updated & fixed some links
- README re-generated
---
modules_s/xmlrpc/README | 67 ++++++++++++++++++++++++++++++-----
modules_s/xmlrpc/doc/xmlrpc.xml | 75 ++++++++++++++++++++++++++++++++++-----
2 files changed, 124 insertions(+), 18 deletions(-)
diff --git a/modules_s/xmlrpc/README b/modules_s/xmlrpc/README
index 1961252..b497e66 100644
--- a/modules_s/xmlrpc/README
+++ b/modules_s/xmlrpc/README
@@ -15,11 +15,13 @@ Jan Janak
1.3.2. Replies
1.3.3. Type Conversion
1.3.4. Limitations
+ 1.3.5. Interoperability Problems
1.4. Client Examples
1.5. Parameters
1.5.1. route (string)
+ 1.5.2. autoconversion (string)
1.6. Functions
@@ -217,10 +219,10 @@ if (method == "POST" || method == "GET") {
SER receives GET or POST requests. These two method names indicate
HTTP.
- Step 4. Function dispatch_rpc scans through the list of all exported
- RPC functions searching for statistics function of usrloc module. The
- SER RPC Module API describes in detail how modules export RPC
- functions.
+ Step 4. The function dispatch_rpc scans through the list of all
+ exported RPC functions searching for the statistics function of the
+ usrloc module. The SER RPC Module API describes in detail how modules
+ export RPC functions.
Step 5. As the RPC function from usrloc module is running and gathering
statistics, it calls functions of RPC interface to prepare the result
@@ -366,7 +368,7 @@ Content-Length: 150
If an RPC function adds just a single item (it calls add once with just
one character in the formatting string) then the data will be converted
to XML-RPC representation according to the rules described in SER RPC
- Type Converion and the reply will contain just the single value:
+ Type Conversion and the reply will contain just the single value:
HTTP/1.0 200 OK
Via: SIP/2.0/TCP 127.0.0.1:3793
Server: Sip EXpress router (0.10.99-janakj_experimental (i386/linux))
@@ -438,9 +440,39 @@ Content-Length: 276
need all the bells and whistles of XML-RPC. Parsing and interpreting
nested structures is complex and we try to avoid it.
+1.3.5. Interoperability Problems
+
+ Due to a bug in Python xmlrpclib there is an interoperability problem
+ with basic clients using it: by default an xmlrpclib client expects the
+ server to immediately close the connection after answering and if the
+ server does not close the connections the xmlrpclib client will wait
+ forever.
+
+ There are 2 ways to work around this problem: write a "fixed" Transport
+ class and initialize xmlpclib using it (recommended) or make ser close
+ the tcp connection after each request.
+
+ The examples/xmlrpc_test.py provides a very simple example of using
+ xmlrpclib with a Transport class that works.
+
+ For the second solution (force closing tcp connections after answering)
+ the XMLRPC route should end with a return -1, exit -1 or drop -1.
+
+ Example 1.
+route[XMLRPC]{
+ dispatch_rpc();
+ # close connection only for xmlrpclib user agents
+ if search("^User-Agent:.*xmlrpclib"))
+ return -1 ;
+}
+
1.4. Client Examples
- * ser_ctl (python application that uses the XML-RPC interface
+ * examples/xmlrpc_test.pl (basic perl application that builds and
+ sends an XMLRPC request from its commandline parameters).
+ * examples/xmlrpc_test.py (basic python application that builds and
+ sends an XMLRPC request from its commandline parameters).
+ * ser_ctl (complex python application that uses the XML-RPC interface
implemented by the xmlrpc module).
* serweb (php application that can use the XML-RPC interface to call
ser functions).
@@ -465,9 +497,26 @@ Content-Length: 276
Default: the main route is used.
- Example 1. Set route parameter
+ Example 2. Set route parameter
modparam("xmlrpc", "route", "route_for_xmlrpcs")
+1.5.2. autoconversion (string)
+
+ Enable or disable automatic parameter type conversion globally, for all
+ the methods parameters. If on, a type mismatch in a method parameter
+ will not cause a fault if it is possible to automatically convert it to
+ the type expected by the method.
+
+ Default: off.
+
+ It is recommended to leave this parameter to its default off value and
+ fix instead the client application (which should use the proper types)
+ or to modify the target rpc to accept any type (see the rpc scan '.'
+ modifier).
+
+ Example 3. Set the autoconversion parameter
+modparam("xmlrpc", "autoconversion", 1)
+
1.6. Functions
Revision History
@@ -489,7 +538,7 @@ modparam("xmlrpc", "route", "route_for_xmlrpcs")
function with matching name. If such a function is found then
dispatch_rpc() will pass control to the function to handle the request.
- Example 2. dispatch_rpc usage
+ Example 4. dispatch_rpc usage
#...
modparam("xmlrpc", "route", "XMLRPC");
#...
@@ -502,7 +551,7 @@ route[XMLRPC]{
This function can be called from the config script to directly generate
an XML-RPC reply.
- Example 3. xmlrpc_reply usage
+ Example 5. xmlrpc_reply usage
#...
modparam("xmlrpc", "route", "XMLRPC");
#...
diff --git a/modules_s/xmlrpc/doc/xmlrpc.xml b/modules_s/xmlrpc/doc/xmlrpc.xml
index 4438185..c893e97 100644
--- a/modules_s/xmlrpc/doc/xmlrpc.xml
+++ b/modules_s/xmlrpc/doc/xmlrpc.xml
@@ -302,11 +302,11 @@ if (method == "POST" || method == "GET") {
indicate HTTP.
</para>
<para>
- <emphasis>Step 4.</emphasis> Function
+ <emphasis>Step 4.</emphasis> The function
<function>dispatch_rpc</function> scans through the list of all
- exported RPC functions searching for
- <function>statistics</function> function of usrloc module. The
- <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=doc/rpc/…'>
+ exported RPC functions searching for the
+ <function>statistics</function> function of the usrloc module. The
+ <ulink url='http://sip-router.org/docbook/sip-router/branch/master/rpc/ser_rpc.html'>
SER RPC Module API</ulink>
describes in detail how modules export RPC functions.
</para>
@@ -491,8 +491,8 @@ Content-Length: 150
with just one character in the formatting string) then the data
will be converted to XML-RPC representation according to the
rules described in
- <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=doc/rpc/…'>
- SER RPC Type Converion</ulink> and
+ <ulink url='http://sip-router.org/docbook/sip-router/branch/master/rpc/ser_rpc.html#rpc…'>
+ SER RPC Type Conversion</ulink> and
the reply will contain just the single value:
<programlisting>
<![CDATA[
@@ -655,6 +655,43 @@ Content-Length: 276
complex and we try to avoid it.
</para>
</section>
+ <section id="xmlrpc.interoperability_problems">
+ <title>Interoperability Problems</title>
+ <para>
+ Due to a bug in Python xmlrpclib there is an interoperability
+ problem with basic clients using it: by default an xmlrpclib client
+ expects the server to immediately close the connection after answering
+ and if the server does not close the connections the xmlrpclib client
+ will wait forever.
+ </para>
+ <para>
+ There are 2 ways to work around this problem: write a "fixed"
+ Transport class and initialize xmlpclib using it (recommended) or
+ make ser close the tcp connection after each request.
+ </para>
+ <para>
+ The <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…'>
+ examples/xmlrpc_test.py
+ </ulink> provides a very simple example of using xmlrpclib with a
+ Transport class that works.
+ </para>
+ <para>
+ For the second solution (force closing tcp connections after answering)
+ the XMLRPC route should end with a return -1, exit -1 or drop -1.
+ <example>
+ <programlisting>
+<![CDATA[
+route[XMLRPC]{
+ dispatch_rpc();
+ # close connection only for xmlrpclib user agents
+ if search("^User-Agent:.*xmlrpclib"))
+ return -1 ;
+}
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </section>
</section>
<section id="xmlrpc.client_examples">
@@ -673,12 +710,32 @@ Content-Length: 276
<para>
<itemizedlist>
<listitem><para>
- <emphasis>ser_ctl</emphasis> (python application that uses the
- <emphasis>XML-RPC</emphasis> interface implemented by the
+ <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…'>
+ <emphasis>examples/xmlrpc_test.pl</emphasis>
+ </ulink> (basic perl application that builds and sends an
+ <emphasis>XMLRPC</emphasis> request from its commandline
+ parameters).
+ </para></listitem>
+ <listitem><para>
+ <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…'>
+ <emphasis>examples/xmlrpc_test.py</emphasis>
+ </ulink> (basic python application that builds and sends an
+ <emphasis>XMLRPC</emphasis> request from its commandline
+ parameters).
+ </para></listitem>
+ <listitem><para>
+ <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=ser;a=tree;f=ser_ctl'>
+ <emphasis>ser_ctl</emphasis>
+ </ulink>
+ (complex python application that
+ uses the <emphasis>XML-RPC</emphasis> interface implemented by the
<emphasis>xmlrpc</emphasis> module).
</para></listitem>
<listitem><para>
- <emphasis>serweb</emphasis> (php application that can use
+ <ulink uri='http://www.iptel.org/serweb'>
+ <emphasis>serweb</emphasis>
+ </ulink>
+ (php application that can use
the <emphasis>XML-RPC</emphasis> interface to call ser
functions).
</para></listitem>
Module: sip-router
Branch: master
Commit: 5ca1a775f63f2b5f905fd89cafb0b614ee44b522
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5ca1a77…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 10:45:41 2009 +0200
ctl(s) doc: added the autoconversion parameter
- info about the new autoconversion parameter
- README re-generated
---
modules_s/ctl/README | 24 +++++++++++++++++++++---
modules_s/ctl/doc/params.xml | 26 ++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/modules_s/ctl/README b/modules_s/ctl/README
index 7d538b0..12850b3 100644
--- a/modules_s/ctl/README
+++ b/modules_s/ctl/README
@@ -18,6 +18,7 @@ Andrei Pelinescu-Onciul
1.3.3. user (integer or string)
1.3.4. group (integer or string)
1.3.5. fifo (integer)
+ 1.3.6. autoconversion (integer)
1.4. RPC Functions
@@ -162,6 +163,23 @@ modparam("ctl", "fifo", "/tmp/ser_fifo2")
modparam("ctl", "fifo", "udp:*:2050") # fifo protocol over udp
modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
+1.3.6. autoconversion (integer)
+
+ Enable or disable automatic type conversion globally, for all the
+ methods parameters. If on, a type mismatch in a method parameter will
+ not cause a fault if it is possible to automatically convert it to the
+ expected type.
+
+ Default: off
+
+ It is recommended to leave this parameter to its default off value and
+ fix instead the client application (which should use the proper types)
+ or to modify the target rpc to accept any type (see the rpc scan '.'
+ modifier).
+
+ Example 7. Set the autoconversion parameter
+modparam("ctl", "autoconversion", 1)
+
1.4. RPC Functions
Revision History
@@ -171,7 +189,7 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
List all the sockets on which the ctl module listens.
- Example 7. print usage
+ Example 8. print usage
$ sercmd -f"[%v] %v:%v %v\n" ctl.listen
[binrpc] unix_stream:/tmp/ser_ctl
@@ -181,7 +199,7 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
Returns the number of open binrpc connections (to the ctl module).
- Example 8. ctl.connections usage
+ Example 9. ctl.connections usage
$ sercmd ctl.connections
1
@@ -189,7 +207,7 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
List open binrpc connections (to the ctl module).
- Example 9. ctl.who usage
+ Example 10. ctl.who usage
$ sercmd -f"[%v] %v: %v %v -> %v %v\n" ctl.who
[binrpc] unix_stream: <anonymous unix socket> -> /tmp/ser_ctl
diff --git a/modules_s/ctl/doc/params.xml b/modules_s/ctl/doc/params.xml
index 2b9d807..c2b06c2 100644
--- a/modules_s/ctl/doc/params.xml
+++ b/modules_s/ctl/doc/params.xml
@@ -166,4 +166,30 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
</example>
</section>
+ <section id="autoconversion">
+ <title><varname>autoconversion</varname> (integer)</title>
+ <para>
+ Enable or disable automatic type conversion globally, for all the
+ methods parameters.
+ If on, a type mismatch in a method parameter will not cause a fault
+ if it is possible to automatically convert it to the expected type.
+ </para>
+ <para>
+ Default: off
+ </para>
+ <para>
+ It is recommended to leave this parameter to its default off value
+ and fix instead the client application (which should use the
+ proper types) or to modify the target rpc to accept any type
+ (see the rpc scan '.' modifier).
+ </para>
+ <example>
+ <title>Set the <varname>autoconversion</varname> parameter
+ </title>
+ <programlisting>
+modparam("ctl", "autoconversion", 1)
+ </programlisting>
+ </example>
+ </section>
+
</section>
Module: sip-router
Branch: master
Commit: 46fb4917c2163fd5c8bd01fdd866813211cd6ec7
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=46fb491…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 09:36:22 2009 +0200
doc: rpc api documentation updated: the '.' modifier
---
doc/rpc/ser_rpc.txt | 59 ++++++++++++++++++++++++++++++++++++++------------
doc/rpc/ser_rpc.xml | 60 +++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 98 insertions(+), 21 deletions(-)
diff --git a/doc/rpc/ser_rpc.txt b/doc/rpc/ser_rpc.txt
index 778c03f..b2c5337 100644
--- a/doc/rpc/ser_rpc.txt
+++ b/doc/rpc/ser_rpc.txt
@@ -249,12 +249,13 @@ add("sd", string_param, int_param);
ints and a string) are optional.
Table 1. Data Type Overview
-Name Formating String Char C-Style Variable
-Integer d int
-Float f double
-String s char*
-String S str
-Optional modifier * marks all further parameters as optional
+ Name Formating String Char C-Style Variable
+ Integer d int
+ Float f double
+ String s char*
+ String S str
+ Optional modifier * marks all further parameters as optional
+ Autoconvert modifier . requires auto-conversion for the next parameter
1.2.3. Getting Parameters
@@ -278,17 +279,27 @@ Note
parameters to be retrieved. Each parameter is represented by exactly
one parameter type character in the string. The variable part of
parameters must contain as many pointers to C variables as there are
- formatting non-modifiers characters in the formatting string. The
- formatting string can also contain a "*" modifier that does not have a
- correspondent in the variable part of the parameters. The meaning of
- "*" is that any further parameters (defined by other type characters in
- the formatting string) are optional (they can be missing in the input
- and no rpc fault will automatically be generated).
+ formatting non-modifiers characters in the formatting string.
Warning
The function will crash if you fail to provide enough parameters.
+ Besides characters representing parameter types, the formatting string
+ can contain two special modifiers: "*" and ".". The modifiers do not
+ have a correspondent in the variable part of the parameters.
+
+ The meaning of "*" modifier is that any further parameters (defined by
+ other type characters in the formatting string) are optional (they can
+ be missing in the input and no rpc fault will automatically be
+ generated).
+
+ The '.' modifiers turns on type autoconversion for the next parameter.
+ This means that if the type of the next parameter differs from the type
+ specified in the formatting string, the parameter will be automatically
+ converted to the formatting string type (if possible) and if the
+ automatic conversion succeeds, no fault will be generated.
+
The function returns the number of parameters read on success (a number
greater or equal 0) and - (minus) the number of parameters read on
error (for example for an error after reading 2 parameters it will
@@ -297,8 +308,9 @@ Warning
number (- number of parameters read so far) and it will also
automatically change the reply that will be sent to the caller to
indicate that a failure has occurred on the server (unless the "*" is
- used and the error is lack of more parameters). The prototype of the
- function is:
+ used and the error is lack of more parameters).
+
+ The prototype of the function is:
int scan(char* fmt, ...)
It is possible to either call the function once to scan all the
@@ -368,6 +380,25 @@ static void rpc_delete_contact(rpc_t* rpc)
/* Process retrieved parameters here */
}
+/* variable number of parameters:
+ echo back all the parameters, string type required */
+static void core_prints(rpc_t* rpc, void* c)
+{
+ char* string = 0;
+ while((rpc->scan(c, "*s", &string)>0))
+ rpc->add(c, "s", string);
+}
+
+/* variable number of parameters and auto conversion:
+ echo back all the parameters, works with any type (everything is
+ internally converted to string, notice the '.' modifier) */
+static void core_echo(rpc_t* rpc, void* c)
+{
+ char* string = 0;
+ while((rpc->scan(c, "*.s", &string)>0))
+ rpc->add(c, "s", string);
+}
+
1.2.4. Building Reply
The RPC API contains several functions that can be used to modify
diff --git a/doc/rpc/ser_rpc.xml b/doc/rpc/ser_rpc.xml
index 5a20d8a..698bc9c 100644
--- a/doc/rpc/ser_rpc.xml
+++ b/doc/rpc/ser_rpc.xml
@@ -363,6 +363,11 @@ add("sd", string_param, int_param);
<entry>*</entry>
<entry>marks all further parameters as optional</entry>
</row>
+ <row>
+ <entry>Autoconvert modifier</entry>
+ <entry>.</entry>
+ <entry>requires auto-conversion for the next parameter</entry>
+ </row>
</tbody>
</tgroup>
</table>
@@ -398,18 +403,34 @@ add("sd", string_param, int_param);
The variable part of parameters must contain as many pointers to C
variables as there are formatting non-modifiers characters in the
formatting string.
- The formatting string can also contain a "*" modifier that does not
- have a correspondent in the variable part of the parameters. The
- meaning of "*" is that any further parameters (defined by other
- type characters in the formatting string) are optional (they
- can be missing in the input and no rpc fault will automatically
- be generated).
<warning>
<para>
The function will crash if you fail to provide
enough parameters.
</para>
</warning>
+ </para>
+ <para>
+ Besides characters representing parameter types, the formatting
+ string can contain two special modifiers: "*" and ".". The
+ modifiers do not have a correspondent in the variable part of the
+ parameters.
+ </para>
+ <para>
+ The meaning of "*" modifier is that any further parameters
+ (defined by other type characters in the formatting string) are
+ optional (they can be missing in the input and no rpc fault will
+ automatically be generated).
+ </para>
+ <para>
+ The '.' modifiers turns on type autoconversion for the next
+ parameter. This means that if the type of the next parameter
+ differs from the type specified in the formatting string, the
+ parameter will be automatically converted to the formatting string
+ type (if possible) and if the automatic conversion succeeds, no
+ fault will be generated.
+ </para>
+ <para>
The function returns the number of parameters read on success
(a number greater or equal 0) and - (minus) the number of
parameters read on error (for example for an error after
@@ -420,7 +441,10 @@ add("sd", string_param, int_param);
and it will also automatically change the reply that will be
sent to the caller to indicate that a failure has occurred on
the server (unless the "*" is used and the error is lack
- of more parameters). The prototype of the function is:
+ of more parameters).
+ </para>
+ <para>
+ The prototype of the function is:
<programlisting>
int scan(char* fmt, ...)
</programlisting>
@@ -437,6 +461,8 @@ rpc->scan("d", &int_val);
rpc->scan("f", &double_val);
</programlisting>
</para>
+ <para>
+ </para>
</section>
<section>
<title><function>struct_scan</function></title>
@@ -506,6 +532,26 @@ static void rpc_delete_contact(rpc_t* rpc)
/* Process retrieved parameters here */
}
+
+/* variable number of parameters:
+ echo back all the parameters, string type required */
+static void core_prints(rpc_t* rpc, void* c)
+{
+ char* string = 0;
+ while((rpc->scan(c, "*s", &string)>0))
+ rpc->add(c, "s", string);
+}
+
+/* variable number of parameters and auto conversion:
+ echo back all the parameters, works with any type (everything is
+ internally converted to string, notice the '.' modifier) */
+static void core_echo(rpc_t* rpc, void* c)
+{
+ char* string = 0;
+ while((rpc->scan(c, "*.s", &string)>0))
+ rpc->add(c, "s", string);
+}
+
]]>
</programlisting>
</example>