Changeset 917 for trunk/zoo-project/zoo-kernel/request_parser.c
- Timestamp:
- May 7, 2019, 2:17:08 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo
set to
False
/branches/prototype-v0 merged eligible
-
Property
svn:mergeinfo
set to
False
-
trunk/zoo-project/zoo-kernel/request_parser.c
r889 r917 28 28 #include "response_print.h" 29 29 #include "caching.h" 30 #include "cgic.h" 30 31 31 32 /** … … 154 155 addToMap(cursor->content,"base64_value",tmp->value); 155 156 int size=0; 156 char *s= strdup(tmp->value);157 char *s=zStrdup(tmp->value); 157 158 free(tmp->value); 158 159 tmp->value=base64d(s,strlen(s),&size); … … 174 175 addToMap(cursor->content,key,tmp->value); 175 176 int size=0; 176 char *s= strdup(tmp->value);177 char *s=zStrdup(tmp->value); 177 178 free(tmp->value); 178 179 tmp->value=base64d(s,strlen(s),&size); … … 521 522 int l = 0; 522 523 map* version=getMapFromMaps(*main_conf,"main","rversion"); 524 map* memory=getMapFromMaps(*main_conf,"main","memory"); 523 525 int vid=getVersionId(version->value); 524 526 for (k=0; k < nodes->nodeNr; k++) … … 533 535 xmlChar *val = xmlGetProp (cur, BAD_CAST "id"); 534 536 tmpmaps = createMaps((char *) val); 537 xmlFree(val); 535 538 } 536 539 … … 624 627 tmpmaps->content = 625 628 createMap (refs[l], (char *) val); 626 627 629 map *ltmp = getMap (tmpmaps->content, "method"); 628 630 if (l == 4 ) 629 631 { 630 if ((ltmp==NULL || strncasecmp (ltmp->value, "POST",4) != 0)) // 631 //if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0)) 632 if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0)) 632 633 { 633 634 if (loadRemoteFile … … 751 752 map *btmp = 752 753 getMap (tmpmaps->content, "Reference"); 754 addToMap (tmpmaps->content, "Body", tmp); 753 755 if (btmp != NULL) 754 756 { … … 759 761 xmlStrlen(btmps), 760 762 INTERNET_FLAG_NO_CACHE_WRITE, 761 0); 763 0, 764 *main_conf); 762 765 addIntToMap (tmpmaps->content, "Order", hInternet->nb); 763 766 } … … 778 781 xmlGetProp (cur3, BAD_CAST "href"); 779 782 HINTERNET bInternet, res1, res; 783 maps *tmpConf=createMaps("main"); 784 tmpConf->content=createMap("memory","load"); 780 785 bInternet = InternetOpen ( 781 786 #ifndef WIN32 … … 785 790 INTERNET_OPEN_TYPE_PRECONFIG, 786 791 NULL, NULL, 0); 792 #ifndef WIN32 787 793 if (!CHECK_INET_HANDLE (bInternet)) 788 794 fprintf (stderr, 789 795 "WARNING : bInternet handle failed to initialize"); 796 #endif 790 797 bInternet.waitingRequests[0] = 791 strdup ((char *) val);798 zStrdup ((char *) val); 792 799 res1 = 793 800 InternetOpenUrl (&bInternet, … … 795 802 [0], NULL, 0, 796 803 INTERNET_FLAG_NO_CACHE_WRITE, 797 0); 804 0, 805 tmpConf); 798 806 processDownloads (&bInternet); 807 freeMaps(&tmpConf); 808 free(tmpConf); 799 809 char *tmp = 800 810 (char *) … … 816 826 &bRead); 817 827 tmp[bInternet.ihandle[0].nDataLen] = 0; 818 InternetCloseHandle (&bInternet); 828 InternetCloseHandle(&bInternet); 829 addToMap (tmpmaps->content, "Body", tmp); 819 830 map *btmp = 820 831 getMap (tmpmaps->content, "href"); … … 829 840 strlen(tmp), 830 841 INTERNET_FLAG_NO_CACHE_WRITE, 831 0); 842 0, 843 *main_conf); 832 844 addIntToMap (tmpmaps->content, "Order", hInternet->nb); 833 845 } 834 846 free (tmp); 847 xmlFree (val); 835 848 } 836 849 } … … 895 908 } 896 909 } 897 898 910 899 911 while (cur4 != NULL) … … 967 979 968 980 map *test = getMap (tmpmaps->content, "encoding"); 969 970 981 if (test == NULL) 971 { 982 { 972 983 if (tmpmaps->content != NULL) 973 984 addToMap (tmpmaps->content, "encoding", … … 979 990 } 980 991 981 if (getMap(tmpmaps->content,"dataType")==NULL && strcasecmp (test->value, "base64") != 0) 982 { 983 xmlChar *mv = xmlNodeListGetString (doc, 984 cur4->xmlChildrenNode, 985 1); 992 if (getMap(tmpmaps->content,"dataType")==NULL && test!=NULL && strcasecmp (test->value, "base64") != 0) 993 { 994 xmlChar *mv = NULL; 995 /*if(cur4!=NULL && cur4->xmlChildrenNode!=NULL) 996 xmlChar *mv = xmlNodeListGetString (doc, 997 cur4->xmlChildrenNode, 998 1);*/ 986 999 map *ltmp = 987 1000 getMap (tmpmaps->content, "mimeType"); 988 if ( mv == NULL989 || 1001 if (/*mv == NULL 1002 ||*/ 990 1003 (xmlStrcasecmp 991 1004 (cur4->name, BAD_CAST "ComplexData") == 0 … … 1025 1038 buffersize); 1026 1039 }else{ 1040 1027 1041 if(xmlStrcasecmp 1028 1042 (cur4->name, BAD_CAST "BoundingBoxData") == 0){ … … 1039 1053 xmlNodePtr cur5 = cur4->children; 1040 1054 while (cur5 != NULL 1055 && cur5->type != XML_ELEMENT_NODE 1056 && cur5->type != XML_TEXT_NODE 1041 1057 && cur5->type != XML_CDATA_SECTION_NODE) 1042 1058 cur5 = cur5->next; 1043 1059 if (cur5 != NULL 1044 && cur5->type == XML_CDATA_SECTION_NODE){ 1045 if(mv!=NULL) 1046 xmlFree(mv); 1047 mv=xmlStrdup(cur5->content); 1060 && cur5->type != XML_CDATA_SECTION_NODE 1061 && cur5->type != XML_TEXT_NODE) 1062 { 1063 xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0"); 1064 int buffersize; 1065 xmlDocSetRootElement (doc1, cur5); 1066 xmlDocDumpFormatMemoryEnc (doc1, &mv, 1067 &buffersize, 1068 "utf-8", 0); 1069 addIntToMap (tmpmaps->content, "size", 1070 buffersize); 1071 } 1072 else if (cur5 != NULL)/* 1073 && cur5->type == XML_CDATA_SECTION_NODE)*/{ 1074 xmlFree(mv); 1075 if(cur5->content!=NULL){ 1076 mv=xmlStrdup(cur5->content); 1077 } 1048 1078 } 1049 1079 } … … 1088 1118 cur2 = cur2->next; 1089 1119 } 1120 } 1121 if(memory!=NULL && strncasecmp(memory->value,"load",4)!=0) 1122 if(getMap(tmpmaps->content,"to_load")==NULL){ 1123 addToMap(tmpmaps->content,"to_load","false"); 1090 1124 } 1091 1125 { … … 1123 1157 } 1124 1158 } 1125 else 1159 else{ 1126 1160 addMapsToMaps (request_output, tmpmaps); 1161 } 1127 1162 } 1128 1163 freeMaps (&tmpmaps); … … 1198 1233 const char ress[4][13] = 1199 1234 { "mimeType", "encoding", "schema", "transmission" }; 1235 xmlFree (val); 1200 1236 for (l = 0; l < 4; l++){ 1201 1237 val = xmlGetProp (cur, BAD_CAST ress[l]); … … 1217 1253 while (ccur != NULL){ 1218 1254 if(ccur->type == XML_ELEMENT_NODE){ 1219 char *xpathExpr=(char*)malloc(6 5+strlen(tmpmaps->name));1220 sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name); 1255 char *xpathExpr=(char*)malloc(66+strlen(tmpmaps->name)); 1256 sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name); 1221 1257 xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr); 1222 1258 xmlNodeSet* cnodes = tmpsptr->nodesetval; 1223 1259 xmlParseOutputs2(main_conf,request_inputs,&tmpmaps->child,doc,cnodes); 1260 xmlXPathFreeObject (tmpsptr); 1261 free(xpathExpr); 1224 1262 break; 1225 1263 } … … 1470 1508 1471 1509 xmlInitParser (); 1472 //xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER); 1473 xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER | XML_PARSE_HUGE); // 1510 xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER); 1474 1511 1475 1512 /** … … 1503 1540 else 1504 1541 addToMap(*request_inputs,"mode","auto"); 1542 xmlFree(val); 1505 1543 val = xmlGetProp (cur, BAD_CAST "response"); 1506 1544 if(val!=NULL){ … … 1515 1553 addToMap(*request_inputs,"ResponseDocument",""); 1516 1554 } 1555 xmlFree(val); 1517 1556 } 1518 1557 } … … 1768 1807 #endif 1769 1808 targetFile = 1770 open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,1809 zOpen (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC, 1771 1810 S_IRWXU | S_IRGRP | S_IROTH); 1772 1811 if (targetFile < 0) … … 1788 1827 addToMap (tmpReqI->content, "lref", storageNameOnServer); 1789 1828 cgiFormFileClose (file); 1790 close (targetFile);1829 zClose (targetFile); 1791 1830 free(fileNameOnServer); 1792 1831 free(storageNameOnServer); … … 1820 1859 if (r_inputs == NULL){ 1821 1860 if(mandatory>0){ 1822 c onst char *replace=_("Mandatory parameter <%s> was not specified");1861 char *replace=_("Mandatory parameter <%s> was not specified"); 1823 1862 char *message=(char*)malloc((strlen(replace)+strlen(toCheck)+1)*sizeof(char)); 1824 1863 sprintf(message,replace,toCheck); … … 1869 1908 } 1870 1909 if(hasValidValue<0){ 1871 c onst char *replace=_("The value <%s> was not recognized, %s %s the only acceptable value.");1910 char *replace=_("The value <%s> was not recognized, %s %s the only acceptable value."); 1872 1911 nb=0; 1873 1912 char *vvalues=NULL; 1874 c onst char* num=_("is");1913 char* num=_("is"); 1875 1914 while(avalues[nb]!=NULL){ 1876 1915 char *tvalues; … … 1920 1959 } 1921 1960 } 1961 1962 /** 1963 * Parse cookie contained in request headers. 1964 * 1965 * @param conf the conf maps containinfg the main.cfg 1966 * @param cookie the 1967 */ 1968 void parseCookie(maps** conf,const char* cookie){ 1969 char* tcook=zStrdup(cookie); 1970 char *token, *saveptr; 1971 token = strtok_r (tcook, "; ", &saveptr); 1972 maps* res=createMaps("cookies"); 1973 while (token != NULL){ 1974 char *token1, *saveptr1, *name; 1975 int i=0; 1976 token1 = strtok_r (token, "=", &saveptr1); 1977 while (token1 != NULL){ 1978 if(i==0){ 1979 name=zStrdup(token1); 1980 i++; 1981 } 1982 else{ 1983 if(res->content==NULL) 1984 res->content=createMap(name,token1); 1985 else 1986 addToMap(res->content,name,token1); 1987 free(name); 1988 name=NULL; 1989 i=0; 1990 } 1991 token1 = strtok_r (NULL, "=", &saveptr1); 1992 } 1993 if(name!=NULL) 1994 free(name); 1995 token = strtok_r (NULL, "; ", &saveptr); 1996 } 1997 addMapsToMaps(conf,res); 1998 freeMaps(&res); 1999 free(res); 2000 free(tcook); 2001 }
Note: See TracChangeset
for help on using the changeset viewer.