~ubuntu-branches/debian/sid/kamailio/sid

« back to all changes in this revision

Viewing changes to modules/xcap_server/xcap_server.c

  • Committer: Package Import Robot
  • Author(s): Victor Seva
  • Date: 2014-01-06 11:47:13 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140106114713-t8xidp4arzrnyeya
Tags: 4.1.1-1
* New upstream release
* debian/patches:
  - add upstream fixes
* Added tls outbound websocket autheph dnssec modules
  - openssl exception added to their license
* removing sparc and ia64 from supported archs
  for mono module (Closes: #728915)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1070
1070
        str uri;
1071
1071
        str path;
1072
1072
        str etag = {0, 0};
1073
 
        str body;
 
1073
        str body = {0, 0};
 
1074
        str new_body = {0, 0};
1074
1075
        int ret = 0;
1075
1076
        xcap_uri_t xuri;
1076
1077
        str *ctype;
1170
1171
                        LM_ERR("could not fetch xcap document\n");
1171
1172
                        goto error;
1172
1173
                }
1173
 
 
1174
 
                if(ret==0)
 
1174
                if(ret!=0)
1175
1175
                {
1176
 
                        /* doc found */
1177
 
                        ctype = &xcaps_str_appxml;
1178
 
                        if(xuri.type==RESOURCE_LIST)
1179
 
                                ctype = &xcaps_str_apprlxml;
1180
 
                        else if(xuri.type==PRES_RULES)
1181
 
                                ctype = &xcaps_str_appapxml;
1182
 
                        else if(xuri.type==RLS_SERVICE)
1183
 
                                ctype = &xcaps_str_apprsxml;
1184
 
                        else if(xuri.type==USER_PROFILE)
1185
 
                                ctype = &xcaps_str_appupxml;
1186
 
                        else if(xuri.type==PRES_CONTENT)
1187
 
                                ctype = &xcaps_str_apppcxml;
1188
 
                        else if(xuri.type==PIDF_MANIPULATION)
1189
 
                                ctype = &xcaps_str_apppdxml;
1190
 
                        xcaps_send_reply(msg, 200, &xcaps_str_ok, &etag,
1191
 
                                        ctype, &body);
1192
 
                } else {
1193
1176
                        /* doc not found */
1194
1177
                        xcaps_send_reply(msg, 404, &xcaps_str_notfound, NULL,
1195
1178
                                        NULL, NULL);
1196
 
                }
 
1179
                        break;
 
1180
                }
 
1181
 
 
1182
                if(xuri.nss!=NULL && xuri.node.len>0)
 
1183
                {
 
1184
                        if((new_body.s = pkg_malloc(body.len))==NULL)
 
1185
                        {
 
1186
                                LM_ERR("allocating package memory\n");
 
1187
                                goto error;
 
1188
                        }
 
1189
                        new_body.len = body.len;
 
1190
                        
 
1191
                        if(xcaps_xpath_hack(&body, 0)<0)
 
1192
                        {
 
1193
                                LM_ERR("could not hack xcap document\n");
 
1194
                                goto error;
 
1195
                        }
 
1196
                        if(xcaps_xpath_get(&body, &xuri.node, &new_body)<0)
 
1197
                        {
 
1198
                                LM_ERR("could not retrieve element from xcap document\n");
 
1199
                                goto error;
 
1200
                        }
 
1201
                        if(new_body.len<=0)
 
1202
                        {
 
1203
                                /* element not found */
 
1204
                                xcaps_send_reply(msg, 404, &xcaps_str_notfound, NULL,
 
1205
                                        NULL, NULL);
 
1206
                                pkg_free(new_body.s);
 
1207
                                new_body.s = NULL;
 
1208
                                break;
 
1209
                        }
 
1210
                        if(xcaps_xpath_hack(&new_body, 1)<0)
 
1211
                        {
 
1212
                                LM_ERR("could not hack xcap document\n");
 
1213
                                goto error;
 
1214
                        }
 
1215
                        memcpy(body.s, new_body.s, new_body.len);
 
1216
                        body.len = new_body.len;
 
1217
                        pkg_free(new_body.s);
 
1218
                        new_body.s = NULL;
 
1219
                }
 
1220
 
 
1221
                /* doc or element found */
 
1222
                ctype = &xcaps_str_appxml;
 
1223
                if(xuri.type==RESOURCE_LIST)
 
1224
                        ctype = &xcaps_str_apprlxml;
 
1225
                else if(xuri.type==PRES_RULES)
 
1226
                        ctype = &xcaps_str_appapxml;
 
1227
                else if(xuri.type==RLS_SERVICE)
 
1228
                        ctype = &xcaps_str_apprsxml;
 
1229
                else if(xuri.type==USER_PROFILE)
 
1230
                        ctype = &xcaps_str_appupxml;
 
1231
                else if(xuri.type==PRES_CONTENT)
 
1232
                        ctype = &xcaps_str_apppcxml;
 
1233
                else if(xuri.type==PIDF_MANIPULATION)
 
1234
                        ctype = &xcaps_str_apppdxml;
 
1235
                xcaps_send_reply(msg, 200, &xcaps_str_ok, &etag,
 
1236
                                ctype, &body);
1197
1237
 
1198
1238
                break;
1199
1239
        }
1201
1241
        return 1;
1202
1242
 
1203
1243
error:
 
1244
        if (new_body.s) pkg_free(new_body.s);
1204
1245
        xcaps_send_reply(msg, 500, &xcaps_str_srverr, NULL,
1205
1246
                                NULL, NULL);
1206
1247
        return -1;