Ignore:
Timestamp:
May 7, 2019, 2:17:08 PM (5 years ago)
Author:
djay
Message:

Merge prototype-v0 branch in trunk

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/zoo-project/zoo-kernel/request_parser.c

    r889 r917  
    2828#include "response_print.h"
    2929#include "caching.h"
     30#include "cgic.h"
    3031
    3132/**
     
    154155      addToMap(cursor->content,"base64_value",tmp->value);
    155156      int size=0;
    156       char *s=strdup(tmp->value);
     157      char *s=zStrdup(tmp->value);
    157158      free(tmp->value);
    158159      tmp->value=base64d(s,strlen(s),&size);
     
    174175          addToMap(cursor->content,key,tmp->value);
    175176          int size=0;
    176           char *s=strdup(tmp->value);
     177          char *s=zStrdup(tmp->value);
    177178          free(tmp->value);
    178179          tmp->value=base64d(s,strlen(s),&size);
     
    521522  int l = 0;
    522523  map* version=getMapFromMaps(*main_conf,"main","rversion");
     524  map* memory=getMapFromMaps(*main_conf,"main","memory");
    523525  int vid=getVersionId(version->value);
    524526  for (k=0; k < nodes->nodeNr; k++)
     
    533535            xmlChar *val = xmlGetProp (cur, BAD_CAST "id");
    534536            tmpmaps = createMaps((char *) val);
     537            xmlFree(val);
    535538          }
    536539
     
    624627                            tmpmaps->content =
    625628                              createMap (refs[l], (char *) val);
    626 
    627629                          map *ltmp = getMap (tmpmaps->content, "method");
    628630                          if (l == 4 )
    629631                            {
    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))
    632633                                {
    633634                                  if (loadRemoteFile
     
    751752                                      map *btmp =
    752753                                        getMap (tmpmaps->content, "Reference");
     754                                      addToMap (tmpmaps->content, "Body", tmp);
    753755                                      if (btmp != NULL)
    754756                                        {
     
    759761                                                           xmlStrlen(btmps),
    760762                                                           INTERNET_FLAG_NO_CACHE_WRITE,
    761                                                            0);
     763                                                           0,
     764                                                           *main_conf);
    762765                                          addIntToMap (tmpmaps->content, "Order", hInternet->nb);
    763766                                        }
     
    778781                                  xmlGetProp (cur3, BAD_CAST "href");
    779782                                HINTERNET bInternet, res1, res;
     783                                maps *tmpConf=createMaps("main");
     784                                tmpConf->content=createMap("memory","load");
    780785                                bInternet = InternetOpen (
    781786#ifndef WIN32
     
    785790                                                          INTERNET_OPEN_TYPE_PRECONFIG,
    786791                                                          NULL, NULL, 0);
     792#ifndef WIN32
    787793                                if (!CHECK_INET_HANDLE (bInternet))
    788794                                  fprintf (stderr,
    789795                                           "WARNING : bInternet handle failed to initialize");
     796#endif
    790797                                bInternet.waitingRequests[0] =
    791                                   strdup ((char *) val);
     798                                  zStrdup ((char *) val);
    792799                                res1 =
    793800                                  InternetOpenUrl (&bInternet,
     
    795802                                                   [0], NULL, 0,
    796803                                                   INTERNET_FLAG_NO_CACHE_WRITE,
    797                                                    0);
     804                                                   0,
     805                                                   tmpConf);
    798806                                processDownloads (&bInternet);
     807                                freeMaps(&tmpConf);
     808                                free(tmpConf);
    799809                                char *tmp =
    800810                                  (char *)
     
    816826                                                  &bRead);
    817827                                tmp[bInternet.ihandle[0].nDataLen] = 0;
    818                                 InternetCloseHandle (&bInternet);
     828                                InternetCloseHandle(&bInternet);
     829                                addToMap (tmpmaps->content, "Body", tmp);
    819830                                map *btmp =
    820831                                  getMap (tmpmaps->content, "href");
     
    829840                                                       strlen(tmp),
    830841                                                       INTERNET_FLAG_NO_CACHE_WRITE,
    831                                                        0);
     842                                                       0,
     843                                                       *main_conf);
    832844                                    addIntToMap (tmpmaps->content, "Order", hInternet->nb);
    833845                                  }
    834846                                free (tmp);
     847                                xmlFree (val);
    835848                              }
    836849                        }
     
    895908                    }
    896909                  }
    897 
    898910
    899911                  while (cur4 != NULL)
     
    967979
    968980                      map *test = getMap (tmpmaps->content, "encoding");
    969 
    970981                      if (test == NULL)
    971                         { 
     982                        {
    972983                          if (tmpmaps->content != NULL)
    973984                            addToMap (tmpmaps->content, "encoding",
     
    979990                        }
    980991
    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);*/
    986999                          map *ltmp =
    9871000                            getMap (tmpmaps->content, "mimeType");
    988                           if (mv == NULL
    989                               ||
     1001                          if (/*mv == NULL
     1002                              ||*/
    9901003                              (xmlStrcasecmp
    9911004                               (cur4->name, BAD_CAST "ComplexData") == 0
     
    10251038                                           buffersize);
    10261039                            }else{
     1040
    10271041                            if(xmlStrcasecmp
    10281042                               (cur4->name, BAD_CAST "BoundingBoxData") == 0){
     
    10391053                              xmlNodePtr cur5 = cur4->children;
    10401054                              while (cur5 != NULL
     1055                                     && cur5->type != XML_ELEMENT_NODE
     1056                                     && cur5->type != XML_TEXT_NODE
    10411057                                     && cur5->type != XML_CDATA_SECTION_NODE)
    10421058                                cur5 = cur5->next;
    10431059                              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                                }
    10481078                              }
    10491079                            }
     
    10881118                cur2 = cur2->next;
    10891119              }
     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");
    10901124            }
    10911125          {
     
    11231157                  }
    11241158              }
    1125             else
     1159            else{
    11261160              addMapsToMaps (request_output, tmpmaps);
     1161            }
    11271162          }
    11281163          freeMaps (&tmpmaps);
     
    11981233      const char ress[4][13] =
    11991234        { "mimeType", "encoding", "schema", "transmission" };
     1235      xmlFree (val);
    12001236      for (l = 0; l < 4; l++){
    12011237        val = xmlGetProp (cur, BAD_CAST ress[l]);
     
    12171253        while (ccur != NULL){
    12181254          if(ccur->type == XML_ELEMENT_NODE){
    1219             char *xpathExpr=(char*)malloc(65+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);           
    12211257            xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr);
    12221258            xmlNodeSet* cnodes = tmpsptr->nodesetval;
    12231259            xmlParseOutputs2(main_conf,request_inputs,&tmpmaps->child,doc,cnodes);
     1260            xmlXPathFreeObject (tmpsptr);
     1261            free(xpathExpr);
    12241262            break;
    12251263          }
     
    14701508
    14711509  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);
    14741511
    14751512  /**
     
    15031540          else
    15041541            addToMap(*request_inputs,"mode","auto");
     1542          xmlFree(val);
    15051543          val = xmlGetProp (cur, BAD_CAST "response");
    15061544          if(val!=NULL){
     
    15151553            addToMap(*request_inputs,"ResponseDocument","");
    15161554          }
     1555          xmlFree(val);
    15171556        }
    15181557      }
     
    17681807#endif
    17691808                  targetFile =
    1770                     open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,
     1809                    zOpen (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,
    17711810                          S_IRWXU | S_IRGRP | S_IROTH);
    17721811                  if (targetFile < 0)
     
    17881827                  addToMap (tmpReqI->content, "lref", storageNameOnServer);
    17891828                  cgiFormFileClose (file);
    1790                   close (targetFile);
     1829                  zClose (targetFile);
    17911830                  free(fileNameOnServer);
    17921831                  free(storageNameOnServer);
     
    18201859  if (r_inputs == NULL){
    18211860    if(mandatory>0){
    1822       const char *replace=_("Mandatory parameter <%s> was not specified");
     1861      char *replace=_("Mandatory parameter <%s> was not specified");
    18231862      char *message=(char*)malloc((strlen(replace)+strlen(toCheck)+1)*sizeof(char));
    18241863      sprintf(message,replace,toCheck);
     
    18691908    }
    18701909    if(hasValidValue<0){
    1871       const 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.");
    18721911      nb=0;
    18731912      char *vvalues=NULL;
    1874       const char* num=_("is");
     1913      char* num=_("is");
    18751914      while(avalues[nb]!=NULL){
    18761915        char *tvalues;
     
    19201959  }
    19211960}
     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 */
     1968void 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.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png