<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.4.4">
</HEAD>
<BODY>
Hi,<BR>
<BR>
I think xcap_server.c:xcaps_path_get_auid() needs to be updated for this too?<BR>
<BR>
Regards,<BR>
<BR>
Peter<BR>
<BR>
On Thu, 2012-10-25 at 10:58 +0200, Daniel-Constantin Mierla wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Module: sip-router
Branch: master
Commit: 5f813fdab34cb7507bc4dcc1b66ff87f90f69c9a
URL:    <A HREF="http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5f813fdab34cb7507bc4dcc1b66ff87f90f69c9a">http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5f813fdab34cb7507bc4dcc1b66ff87f90f69c9a</A>

Author: Daniel-Constantin Mierla &lt;<A HREF="mailto:miconda@gmail.com">miconda@gmail.com</A>&gt;
Committer: Daniel-Constantin Mierla &lt;<A HREF="mailto:miconda@gmail.com">miconda@gmail.com</A>&gt;
Date:   Thu Oct 25 10:56:41 2012 +0200

xcap_server: use a static table to keep the list of supported auids

- adding new auid requires an entry in this table and define of the
  internal type

---

 modules_k/xcap_server/xcap_misc.c |   99 +++++++++++++++++++++----------------
 1 files changed, 57 insertions(+), 42 deletions(-)

diff --git a/modules_k/xcap_server/xcap_misc.c b/modules_k/xcap_server/xcap_misc.c
index 146e941..9e294c0 100644
--- a/modules_k/xcap_server/xcap_misc.c
+++ b/modules_k/xcap_server/xcap_misc.c
@@ -40,6 +40,59 @@ extern str xcaps_root;
 
 static param_t *_xcaps_xpath_ns_root = NULL;
 
+typedef struct xcaps_auid_list {
+        str auid;  /* auid value */
+        char term; /* ending char (next one after auid) */
+        int type;  /* internaly type id for auid */
+} xcaps_auid_list_t;
+
+/* list of supported auid */
+static xcaps_auid_list_t _xcaps_auid_list[] = {
+        { { &quot;pres-rules&quot;, 10 },
+                        '/', PRES_RULES },
+        { { &quot;org.openmobilealliance.pres-rules&quot;, 33 },
+                        '/', PRES_RULES },
+        { { &quot;rls-services&quot;, 12 },
+                        '/', RLS_SERVICE },
+        { { &quot;pidf-manipulation&quot;, 17 },
+                        '/', PIDF_MANIPULATION },
+        { { &quot;resource-lists&quot;, 14 },
+                        '/', RESOURCE_LIST },
+        { { &quot;xcap-caps&quot;, 9 },
+                        '/', XCAP_CAPS },
+        { { &quot;org.openmobilealliance.user-profile&quot;, 35},
+                        '/', USER_PROFILE },
+        { { &quot;org.openmobilealliance.pres-content&quot;, 15},
+                        '/', PRES_CONTENT },
+        { { &quot;org.openmobilealliance.search&quot;, 29},
+                        '?', SEARCH },
+
+        { { 0, 0 }, 0, 0 }
+};
+
+static int xcaps_find_auid(str *s, xcap_uri_t *xuri)
+{
+        int i;
+        for(i=0; _xcaps_auid_list[i].auid.s!=NULL; i++)
+        {
+                if(s-&gt;len &gt; _xcaps_auid_list[i].auid.len
+                        &amp;&amp; s-&gt;s[_xcaps_auid_list[i].auid.len] == _xcaps_auid_list[i].term
+                        &amp;&amp; strncmp(s-&gt;s, _xcaps_auid_list[i].auid.s,
+                                                        _xcaps_auid_list[i].auid.len) == 0)
+                {
+                        LM_DBG(&quot;matched %.*s\n&quot;, _xcaps_auid_list[i].auid.len,
+                                        _xcaps_auid_list[i].auid.s);
+                        xuri-&gt;type = _xcaps_auid_list[i].type;
+                        xuri-&gt;auid.s = s-&gt;s;
+                        xuri-&gt;auid.len = _xcaps_auid_list[i].auid.len;
+                        return 0;
+                }
+        }
+        LM_ERR(&quot;unsupported auid in [%.*s]\n&quot;, xuri-&gt;uri.len,
+                                xuri-&gt;uri.s);
+        return -1;
+}
+
 /**
  * parse xcap uri
  */
@@ -127,45 +180,11 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri)
         }
 
         /* auid */
-        xuri-&gt;auid.s = s.s;
-        if(s.len&gt;11 &amp;&amp; strncmp(s.s, &quot;pres-rules/&quot;, 11)==0)
-        {
-                LM_DBG(&quot;matched pres-rules\n&quot;);
-                xuri-&gt;type = PRES_RULES;
-                xuri-&gt;auid.len = 10;
-        } else if(s.len&gt;34 &amp;&amp; strncmp(s.s, &quot;org.openmobilealliance.pres-rules/&quot;, 34)==0) {
-                LM_DBG(&quot;matched oma pres-rules\n&quot;);
-                xuri-&gt;type = PRES_RULES;
-                xuri-&gt;auid.len = 33;
-        } else if(s.len&gt;13 &amp;&amp; strncmp(s.s, &quot;rls-services/&quot;, 13)==0) {
-                LM_DBG(&quot;matched rls-services\n&quot;);
-                xuri-&gt;type = RLS_SERVICE;
-                xuri-&gt;auid.len = 12;
-        } else if(s.len&gt;18 &amp;&amp; strncmp(s.s, &quot;pidf-manipulation/&quot;, 18)==0) {
-                LM_DBG(&quot;matched pidf-manipulation\n&quot;);
-                xuri-&gt;type = PIDF_MANIPULATION;
-                xuri-&gt;auid.len = 17;
-        } else if(s.len&gt;15 &amp;&amp; strncmp(s.s, &quot;resource-lists/&quot;, 15)==0) {
-                LM_DBG(&quot;matched resource-lists\n&quot;);
-                xuri-&gt;type = RESOURCE_LIST;
-                xuri-&gt;auid.len = 14;
-        } else if(s.len&gt;10 &amp;&amp; strncmp(s.s, &quot;xcap-caps/&quot;, 10)==0) {
-                LM_DBG(&quot;matched xcap-caps\n&quot;);
-                xuri-&gt;type = XCAP_CAPS;
-                xuri-&gt;auid.len = 9;
-        } else if(s.len&gt; 36 &amp;&amp; strncmp(s.s, &quot;org.openmobilealliance.user-profile/&quot;, 36)==0) {
-                LM_DBG(&quot;matched oma user-profile\n&quot;);
-                xuri-&gt;type = USER_PROFILE;
-                xuri-&gt;auid.len = 35;
-        } else if(s.len&gt; 36 &amp;&amp; strncmp(s.s, &quot;org.openmobilealliance.pres-content/&quot;, 36)==0) {
-                LM_DBG(&quot;matched oma pres-content\n&quot;);
-                xuri-&gt;type = PRES_CONTENT;
-                xuri-&gt;auid.len = 35;
-        } else if(s.len&gt; 30 &amp;&amp; strncmp(s.s, &quot;org.openmobilealliance.search?&quot;, 30)==0) {
-                LM_DBG(&quot;matched oma search\n&quot;);
-                xuri-&gt;type = SEARCH;
-                xuri-&gt;auid.len = 29;
+        if(xcaps_find_auid(&amp;s, xuri)&lt;0)
+                return -1;
 
+        /* handling special auids */
+        if(xuri-&gt;type == SEARCH) {
                 s.s   += xuri-&gt;auid.len + 1;
                 s.len -= xuri-&gt;auid.len + 1;
 
@@ -197,10 +216,6 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri)
                 }
 
                 return 0;
-        } else {
-                LM_ERR(&quot;unsupported auid in [%.*s]\n&quot;, xuri-&gt;uri.len,
-                                xuri-&gt;uri.s);
-                return -1;
         }
 
         s.s   += xuri-&gt;auid.len + 1;


_______________________________________________
sr-dev mailing list
<A HREF="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</A>
<A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</A>
</PRE>
</BLOCKQUOTE>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>