<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    you mean xcaps_path_get_auid_type(), right?<br>
    <br>
    The function seems to be only defined, but not used, did I miss
    something?<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 10/25/12 11:31 AM, Peter Dunkley
      wrote:<br>
    </div>
    <blockquote cite="mid:1351157483.1932.15.camel@pd-notebook-linux"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <meta name="GENERATOR" content="GtkHTML/4.4.4">
      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 moz-do-not-send="true" 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 moz-do-not-send="true" href="mailto:miconda@gmail.com">miconda@gmail.com</a>&gt;
Committer: Daniel-Constantin Mierla &lt;<a moz-do-not-send="true" 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[] = {
+        { { "pres-rules", 10 },
+                        '/', PRES_RULES },
+        { { "org.openmobilealliance.pres-rules", 33 },
+                        '/', PRES_RULES },
+        { { "rls-services", 12 },
+                        '/', RLS_SERVICE },
+        { { "pidf-manipulation", 17 },
+                        '/', PIDF_MANIPULATION },
+        { { "resource-lists", 14 },
+                        '/', RESOURCE_LIST },
+        { { "xcap-caps", 9 },
+                        '/', XCAP_CAPS },
+        { { "org.openmobilealliance.user-profile", 35},
+                        '/', USER_PROFILE },
+        { { "org.openmobilealliance.pres-content", 15},
+                        '/', PRES_CONTENT },
+        { { "org.openmobilealliance.search", 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("matched %.*s\n", _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("unsupported auid in [%.*s]\n", 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, "pres-rules/", 11)==0)
-        {
-                LM_DBG("matched pres-rules\n");
-                xuri-&gt;type = PRES_RULES;
-                xuri-&gt;auid.len = 10;
-        } else if(s.len&gt;34 &amp;&amp; strncmp(s.s, "org.openmobilealliance.pres-rules/", 34)==0) {
-                LM_DBG("matched oma pres-rules\n");
-                xuri-&gt;type = PRES_RULES;
-                xuri-&gt;auid.len = 33;
-        } else if(s.len&gt;13 &amp;&amp; strncmp(s.s, "rls-services/", 13)==0) {
-                LM_DBG("matched rls-services\n");
-                xuri-&gt;type = RLS_SERVICE;
-                xuri-&gt;auid.len = 12;
-        } else if(s.len&gt;18 &amp;&amp; strncmp(s.s, "pidf-manipulation/", 18)==0) {
-                LM_DBG("matched pidf-manipulation\n");
-                xuri-&gt;type = PIDF_MANIPULATION;
-                xuri-&gt;auid.len = 17;
-        } else if(s.len&gt;15 &amp;&amp; strncmp(s.s, "resource-lists/", 15)==0) {
-                LM_DBG("matched resource-lists\n");
-                xuri-&gt;type = RESOURCE_LIST;
-                xuri-&gt;auid.len = 14;
-        } else if(s.len&gt;10 &amp;&amp; strncmp(s.s, "xcap-caps/", 10)==0) {
-                LM_DBG("matched xcap-caps\n");
-                xuri-&gt;type = XCAP_CAPS;
-                xuri-&gt;auid.len = 9;
-        } else if(s.len&gt; 36 &amp;&amp; strncmp(s.s, "org.openmobilealliance.user-profile/", 36)==0) {
-                LM_DBG("matched oma user-profile\n");
-                xuri-&gt;type = USER_PROFILE;
-                xuri-&gt;auid.len = 35;
-        } else if(s.len&gt; 36 &amp;&amp; strncmp(s.s, "org.openmobilealliance.pres-content/", 36)==0) {
-                LM_DBG("matched oma pres-content\n");
-                xuri-&gt;type = PRES_CONTENT;
-                xuri-&gt;auid.len = 35;
-        } else if(s.len&gt; 30 &amp;&amp; strncmp(s.s, "org.openmobilealliance.search?", 30)==0) {
-                LM_DBG("matched oma search\n");
-                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("unsupported auid in [%.*s]\n", xuri-&gt;uri.len,
-                                xuri-&gt;uri.s);
-                return -1;
         }
 
         s.s   += xuri-&gt;auid.len + 1;


_______________________________________________
sr-dev mailing list
<a moz-do-not-send="true" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a moz-do-not-send="true" 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 cellpadding="0" cellspacing="0" width="100%">
        <tbody>
          <tr>
            <td>
              <pre>-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</pre>
            </td>
          </tr>
        </tbody>
      </table>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" 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>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - <a class="moz-txt-link-freetext" href="http://asipto.com/u/kat">http://asipto.com/u/kat</a>
Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - <a class="moz-txt-link-freetext" href="http://asipto.com/u/katu">http://asipto.com/u/katu</a></pre>
  </body>
</html>