Changeset 105


Ignore:
Timestamp:
Feb 1, 2011, 8:32:02 PM (13 years ago)
Author:
djay
Message:

Simplification of RawDataOutput? and ResponseDocument? parsing code for XML requests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/zoo_service_loader.c

    r95 r105  
    101101  xmlXPathFreeContext(xpathCtx);
    102102  return xpathObj;
     103}
     104
     105void donothing(int sig){
     106  fprintf(stderr,"Signal %d after the ZOO-Kernel returned result !\n",sig);
     107  exit(0);
    103108}
    104109
     
    14171422    xmlXPathFreeObject(tmpsptr);
    14181423    //xmlFree(tmps);
     1424   
    14191425    tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='ResponseDocument']");
     1426    bool asRaw=false;
    14201427    tmps=tmpsptr->nodesetval;
     1428    if(tmps->nodeNr==0){
     1429      tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='RawDataOutput']");
     1430      tmps=tmpsptr->nodesetval;
     1431      asRaw=true;
     1432    }
    14211433#ifdef DEBUG
    14221434    fprintf(stderr,"*****%d*****\n",tmps->nodeNr);
    14231435#endif
    14241436    for(int k=0;k<tmps->nodeNr;k++){
    1425       addToMap(request_inputs,"ResponseDocument","");
     1437      if(asRaw==true)
     1438        addToMap(request_inputs,"RawDataOutput","");
     1439      else
     1440        addToMap(request_inputs,"ResponseDocument","");
    14261441      request_output_real_format;
    14271442      maps *tmpmaps=NULL;
     
    15501565      //xmlFree(cur);
    15511566      if(request_output_real_format==NULL)
    1552         request_output_real_format=tmpmaps;
     1567        request_output_real_format=dupMaps(&tmpmaps);
    15531568      else
    15541569        addMapsToMaps(&request_output_real_format,tmpmaps);
     
    15561571      dumpMaps(tmpmaps);
    15571572#endif
     1573      freeMaps(&tmpmaps);
     1574      free(tmpmaps);
    15581575    }
    1559     xmlXPathFreeObject(tmpsptr);
    1560     //xmlFree(tmps);
    1561     tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='RawDataOutput']");
    1562     tmps=tmpsptr->nodesetval;
    1563 #ifdef DEBUG
    1564     fprintf(stderr,"*****%d*****\n",tmps->nodeNr);
    1565 #endif
    1566     for(int k=0;k<tmps->nodeNr;k++){
    1567       addToMap(request_inputs,"RawDataOutput","");
    1568       xmlNodePtr cur1=tmps->nodeTab[k];
    1569       xmlChar *val;
    1570       /**
    1571        * Get every attribute from a Output node
    1572        * mimeType, encoding, schema, uom, asReference
    1573        */
    1574       char *outs[4];
    1575       outs[0]="mimeType";
    1576       outs[1]="encoding";
    1577       outs[2]="schema";
    1578       outs[3]="uom";
    1579       for(int l=0;l<4;l++){
    1580 #ifdef DEBUG
    1581         fprintf(stderr,"*** %s ***\t",outs[l]);
    1582 #endif
    1583         val=xmlGetProp(cur1,BAD_CAST outs[l]);
    1584         if(val!=NULL && strlen((char*)val)>0){
    1585           if(tmpmaps==NULL){
    1586             tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    1587             if(tmpmaps == NULL){
    1588               return errorException(m, _("Unable to allocate memory."), "InternalError");
    1589             }
    1590             tmpmaps->name="unknownIdentifier";
    1591             tmpmaps->content=createMap(outs[l],(char*)val);
    1592             tmpmaps->next=NULL;
    1593           }
    1594           else
    1595             addToMap(tmpmaps->content,outs[l],(char*)val);
    1596         }
    1597 #ifdef DEBUG
    1598         fprintf(stderr,"%s\n",val);
    1599 #endif
    1600         xmlFree(val);
    1601       }
    1602            
    1603       xmlNodePtr cur2=cur1->children;
    1604       while(cur2){
    1605         /**
    1606          * Indentifier
    1607          */
    1608         if(xmlStrncasecmp(cur2->name,BAD_CAST "Identifier",xmlStrlen(cur2->name))==0){
    1609           val=
    1610             xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
    1611           if(tmpmaps==NULL){
    1612             tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    1613             if(tmpmaps == NULL){
    1614               return errorException(m, _("Unable to allocate memory."), "InternalError");
    1615             }
    1616             tmpmaps->name=strdup((char*)val);
    1617             tmpmaps->content=NULL;
    1618             tmpmaps->next=NULL;
    1619           }
    1620           else
    1621             tmpmaps->name=strdup((char*)val);;
    1622           xmlFree(val);
    1623         }
    1624         cur2=cur2->next;
    1625       }
    1626       if(request_output_real_format==NULL)
    1627         request_output_real_format=tmpmaps;
    1628       else
    1629         addMapsToMaps(&request_output_real_format,tmpmaps);
    1630 #ifdef DEBUG
    1631       dumpMaps(tmpmaps);
    1632 #endif
    1633     }
     1576
    16341577    xmlXPathFreeObject(tmpsptr);
    16351578    //xmlFree(tmps);
    16361579    xmlCleanupParser();
    16371580  }
    1638 
     1581 
    16391582  //if(CHECK_INET_HANDLE(hInternet))
    16401583  InternetCloseHandle(hInternet);
     
    18751818                   request_output_real_format,request_inputs,
    18761819                   cpid,m,eres);
     1820  /**
     1821   * Ensure that if error occurs when freeing memory, no signal will return
     1822   * an ExceptionReport document as the result was already returned to the
     1823   * client.
     1824   */
     1825#ifndef USE_GDB
     1826  (void) signal(SIGSEGV,donothing);
     1827  (void) signal(SIGTERM,donothing);
     1828  (void) signal(SIGINT,donothing);
     1829  (void) signal(SIGILL,donothing);
     1830  (void) signal(SIGFPE,donothing);
     1831  (void) signal(SIGABRT,donothing);
     1832#endif
    18771833
    18781834  if(((int)getpid())!=cpid){
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