@@ -962,95 +962,95 @@ char * call::get_last_header(const char * name)
962962 }
963963}
964964
965- /* Return the last tag from the header line . On any error returns the
965+ /* Return the last request URI from the header. On any error returns the
966966 * empty string. The caller must free the result. */
967- char * call::get_last_tag (const char *name)
967+ char * call::get_last_request_uri (const char *name)
968968{
969969 char * tmp;
970970 char * tmp2;
971- char * result ;
972- char * last_To ;
971+ char * last_request_uri ;
972+ char * last_header ;
973973 int tmp_len;
974974
975975 if (!name || !strlen (name)) {
976976 return strdup (" " );
977977 }
978978
979- last_To = get_last_header (name);
980- if (!last_To) {
979+ last_header = get_last_header (name);
980+
981+ if (!last_header) {
981982 return strdup (" " );
982983 }
983984
984- tmp = strcasestr (last_To, " tag= " );
985+ tmp = strchr (last_header, ' < ' );
985986 if (!tmp) {
986987 return strdup (" " );
987988 }
989+ tmp++;
988990
989- tmp += strlen ( " tag= " );
990- tmp2 = tmp;
991-
992- while (*tmp2 && *tmp2 != ' ; ' && *tmp2!= ' \r ' && *tmp2!= ' \n ' ) tmp2++;
991+ tmp2 = strchr (last_header, ' > ' );
992+ if (! tmp2) {
993+ return strdup ( " " );
994+ }
993995
994996 tmp_len = strlen (tmp) - strlen (tmp2);
995997 if (tmp_len < 0 ) {
996998 return strdup (" " );
997999 }
998- if (!(result = (char *) malloc (tmp_len+1 ))) ERROR (" call::get_last_tag: Cannot allocate !\n " );
999- memset (result, 0 , sizeof (&result));
1000- if (tmp && (tmp_len > 0 )){
1001- strncpy (result, tmp, tmp_len);
1000+
1001+ if (!(last_request_uri = (char *)malloc (tmp_len + 1 ))) {
1002+ ERROR (" Cannot allocate !\n " );
10021003 }
1003- result[tmp_len] = ' \0 ' ;
1004- return result;
1004+
1005+ last_request_uri[0 ] = ' \0 ' ;
1006+ if (tmp && (tmp_len > 0 )) {
1007+ strncpy (last_request_uri, tmp, tmp_len);
1008+ }
1009+ last_request_uri[tmp_len] = ' \0 ' ;
1010+
1011+ return last_request_uri;
10051012}
10061013
1007- /* Return the last request URI from the header. On any error returns the
1014+ /* Return the last tag from the header line . On any error returns the
10081015 * empty string. The caller must free the result. */
1009- char * call::get_last_request_uri (const char *name)
1016+ char * call::get_last_tag (const char *name)
10101017{
10111018 char * tmp;
10121019 char * tmp2;
1013- char * last_request_uri ;
1014- char * last_header ;
1020+ char * result ;
1021+ char * last_To ;
10151022 int tmp_len;
10161023
10171024 if (!name || !strlen (name)) {
10181025 return strdup (" " );
10191026 }
10201027
1021- last_header = get_last_header (name);
1022-
1023- if (!last_header) {
1028+ last_To = get_last_header (name);
1029+ if (!last_To) {
10241030 return strdup (" " );
10251031 }
10261032
1027- tmp = strchr (last_header, ' < ' );
1033+ tmp = strcasestr (last_To, " tag= " );
10281034 if (!tmp) {
10291035 return strdup (" " );
10301036 }
1031- tmp++;
10321037
1033- tmp2 = strchr (last_header, ' > ' );
1034- if (! tmp2) {
1035- return strdup ( " " );
1036- }
1038+ tmp += strlen ( " tag= " );
1039+ tmp2 = tmp;
1040+
1041+ while (*tmp2 && *tmp2 != ' ; ' && *tmp2!= ' \r ' && *tmp2!= ' \n ' ) tmp2++;
10371042
10381043 tmp_len = strlen (tmp) - strlen (tmp2);
10391044 if (tmp_len < 0 ) {
10401045 return strdup (" " );
10411046 }
1042-
1043- if (!(last_request_uri = (char *)malloc (tmp_len + 1 ))) {
1044- ERROR (" Cannot allocate !\n " );
1045- }
1046-
1047- last_request_uri[0 ] = ' \0 ' ;
1048- if (tmp && (tmp_len > 0 )) {
1049- strncpy (last_request_uri, tmp, tmp_len);
1047+ if (!(result = (char *) malloc (tmp_len+1 ))) ERROR (" call::get_last_tag: Cannot allocate !\n " );
1048+ memset (result, 0 , sizeof (&result));
1049+ if (tmp && (tmp_len > 0 )){
1050+ strncpy (result, tmp, tmp_len);
10501051 }
1051- last_request_uri[tmp_len] = ' \0 ' ;
1052-
1053- return last_request_uri;
1052+ result[tmp_len] = ' \0 ' ;
1053+ return result;
10541054}
10551055
10561056char * call::send_scene (int index, int *send_status, int *len)
0 commit comments