Module: sip-router Branch: master Commit: d646b4b1c746bc36d7765d3fa15779b581c576d1 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d646b4b1...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri May 28 12:51:43 2010 +0200
xcap_server: relaxed detection of auid type from path
---
modules_k/xcap_server/xcap_server.c | 49 ++++++++++++++++++++++------------- 1 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/modules_k/xcap_server/xcap_server.c b/modules_k/xcap_server/xcap_server.c index c29ed98..06b8ae9 100644 --- a/modules_k/xcap_server/xcap_server.c +++ b/modules_k/xcap_server/xcap_server.c @@ -60,7 +60,7 @@ static int mod_init(void); static int child_init(int rank); static void destroy(void);
-int xcaps_get_auid_type(str *path); +int xcaps_path_get_auid_type(str *path); int xcaps_generate_etag_hdr(str *etag);
static str xcaps_db_table = str_init("xcap"); @@ -416,7 +416,7 @@ static int w_xcaps_put(sip_msg_t* msg, char* puri, char* ppath, goto error; }
- dtype = xcaps_get_auid_type(&path); + dtype = xcaps_path_get_auid_type(&path);
if(dtype==-1) { @@ -770,9 +770,13 @@ error: /** * */ -int xcaps_get_auid_type(str *path) +int xcaps_path_get_auid_type(str *path) { str s; + char c; + int ret; + + ret = -1; if(path==NULL) return -1; if(path->len<xcaps_root.len) @@ -784,38 +788,47 @@ int xcaps_get_auid_type(str *path) return -1; }
- s.s = path->s + xcaps_root.len; - s.len = path->len - xcaps_root.len; + s.s = path->s + xcaps_root.len - 1; + s.len = path->len - xcaps_root.len + 1; + + c = s.s[s.len]; + s.s[s.len] = '\0';
- if(s.len>10 && s.s[10]=='/' - && strncmp(s.s, "pres-rules", 10)==0) + if(s.len>12 + && strstr(s.s, "/pres-rules/")!=NULL) { LM_DBG("matched pres-rules\n"); - return PRES_RULES; + ret = PRES_RULES; + goto done; }
- if(s.len>12 && s.s[12]=='/' - && strncmp(s.s, "rls-services", 12)==0) + if(s.len>14 + && strstr(s.s, "/rls-services/")!=NULL) { LM_DBG("matched rls-services\n"); - return RLS_SERVICE; + ret = RLS_SERVICE; + goto done; }
- if(s.len>17 && s.s[17]=='/' - && strncmp(s.s, "pidf-manipulation", 17)==0) + if(s.len>19 + && strstr(s.s, "pidf-manipulation")!=NULL) { LM_DBG("matched pidf-manipulation\n"); - return PIDF_MANIPULATION; + ret = PIDF_MANIPULATION; + goto done; }
- if(s.len>14 && s.s[14]=='/' - && strncmp(s.s, "resource-lists", 14)==0) + if(s.len>16 + && strstr(s.s, "/resource-lists/")!=NULL) { LM_DBG("matched resource-lists\n"); - return RESOURCE_LIST; + ret = RESOURCE_LIST; + goto done; }
- return -1; +done: + s.s[s.len] = c; + return ret; }
/**