Skip to content

Commit

Permalink
Swapped get_last_request_uri and get_last_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
pbertera committed Oct 5, 2016
1 parent 3a9f928 commit 324cf71
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions src/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,95 +962,95 @@ char * call::get_last_header(const char * name)
}
}

/* Return the last tag from the header line. On any error returns the
/* Return the last request URI from the header. On any error returns the
* empty string. The caller must free the result. */
char * call::get_last_tag(const char *name)
char * call::get_last_request_uri(const char *name)
{
char * tmp;
char * tmp2;
char * result;
char * last_To;
char * last_request_uri;
char * last_header;
int tmp_len;

if (!name || !strlen(name)) {
return strdup("");
}

last_To = get_last_header(name);
if (!last_To) {
last_header = get_last_header(name);

if (!last_header) {
return strdup("");
}

tmp = strcasestr(last_To, "tag=");
tmp = strchr(last_header, '<');
if (!tmp) {
return strdup("");
}
tmp++;

tmp += strlen("tag=");
tmp2 = tmp;

while (*tmp2 && *tmp2 != ';' && *tmp2!='\r' && *tmp2!='\n') tmp2++;
tmp2 = strchr(last_header, '>');
if (!tmp2) {
return strdup("");
}

tmp_len = strlen(tmp) - strlen(tmp2);
if (tmp_len < 0) {
return strdup("");
}
if(!(result = (char *) malloc(tmp_len+1))) ERROR("call::get_last_tag: Cannot allocate !\n");
memset(result, 0, sizeof(&result));
if(tmp && (tmp_len > 0)){
strncpy(result, tmp, tmp_len);

if (!(last_request_uri = (char *)malloc(tmp_len + 1))) {
ERROR("Cannot allocate !\n");
}
result[tmp_len] = '\0';
return result;

last_request_uri[0] = '\0';
if (tmp && (tmp_len > 0)) {
strncpy(last_request_uri, tmp, tmp_len);
}
last_request_uri[tmp_len] = '\0';

return last_request_uri;
}

/* Return the last request URI from the header. On any error returns the
/* Return the last tag from the header line. On any error returns the
* empty string. The caller must free the result. */
char * call::get_last_request_uri(const char *name)
char * call::get_last_tag(const char *name)
{
char * tmp;
char * tmp2;
char * last_request_uri;
char * last_header;
char * result;
char * last_To;
int tmp_len;

if (!name || !strlen(name)) {
return strdup("");
}

last_header = get_last_header(name);

if (!last_header) {
last_To = get_last_header(name);
if (!last_To) {
return strdup("");
}

tmp = strchr(last_header, '<');
tmp = strcasestr(last_To, "tag=");
if (!tmp) {
return strdup("");
}
tmp++;

tmp2 = strchr(last_header, '>');
if (!tmp2) {
return strdup("");
}
tmp += strlen("tag=");
tmp2 = tmp;

while (*tmp2 && *tmp2 != ';' && *tmp2!='\r' && *tmp2!='\n') tmp2++;

tmp_len = strlen(tmp) - strlen(tmp2);
if (tmp_len < 0) {
return strdup("");
}

if (!(last_request_uri = (char *)malloc(tmp_len + 1))) {
ERROR("Cannot allocate !\n");
}

last_request_uri[0] = '\0';
if (tmp && (tmp_len > 0)) {
strncpy(last_request_uri, tmp, tmp_len);
if(!(result = (char *) malloc(tmp_len+1))) ERROR("call::get_last_tag: Cannot allocate !\n");
memset(result, 0, sizeof(&result));
if(tmp && (tmp_len > 0)){
strncpy(result, tmp, tmp_len);
}
last_request_uri[tmp_len] = '\0';

return last_request_uri;
result[tmp_len] = '\0';
return result;
}

char * call::send_scene(int index, int *send_status, int *len)
Expand Down

0 comments on commit 324cf71

Please sign in to comment.