Changes in / [30:20]


Ignore:
Location:
/trunk
Files:
3 added
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • /trunk/zoo-api/js/ZOO-api.js

    r30 r20  
    7474
    7575    return Class;
    76   },
    77   UpdateStatus: function(env,value) {
    78     return ZOOUpdateStatus(env,value);
    7976  }
    80 };
    81 
    8277};
    8378
  • /trunk/zoo-kernel/Makefile.in

    r30 r20  
    5555
    5656service_internal.o: service_internal.c service.h
    57         gcc ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -c service_internal.c
     57        g++ ${XML2CFLAGS} ${CFLAGS} -c service_internal.c
    5858
    5959service_internal_python.o: service_internal_python.c service.h
     
    7878
    7979zoo_service_loader.o: zoo_service_loader.c service.h
    80         g++ -g -O2 -Wall ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
     80        g++ -g -O2 -Wall ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PHPCFLAGS} ${JS_ENABLED} ${PHP_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
    8181
    8282zoo_loader.cgi: zoo_loader.c zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y service_internal_python.o  ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE}
  • /trunk/zoo-kernel/configure.ac

    r30 r20  
    128128# ===========================================================================
    129129
    130 
    131 
    132 
    133130AC_ARG_WITH([python],
    134         [AS_HELP_STRING([--with-python=PATH], [To enabled python support or specify an alternative directory for python installation,  disabled by default])],
    135         [PYTHON_PATH="$withval"; PYTHON_ENABLED="-DUSE_PYTHON"], [PYTHON_ENABLED=""])
    136 
    137 
    138 if test -z "$PYTHON_ENABLED"
    139 then
    140         PYTHON_FILE=""
    141 else
    142         PYTHONCONFIG="$PYTHON_PATH/bin/python-config"
    143         PYTHON_FILE="service_internal_python.o"
    144         if test  "$PYTHON_PATH" = "yes"
    145         then
    146                 # PHP was not specified, so search within the current path
    147                 AC_PATH_PROG([PYTHONCONFIG], [python-config])
    148         else
    149                 PYTHONCONFIG="$PYTHON_PATH/bin/python-config"
    150         fi
    151 
    152         # Extract the linker and include flags
    153         PYTHON_LDFLAGS=`$PYTHONCONFIG --ldflags`
    154         PYTHON_CPPFLAGS=`$PYTHONCONFIG --cflags`
    155 
    156         # Check headers file
    157         CPPFLAGS_SAVE="$CPPFLAGS"
    158         CPPFLAGS="$PYTHON_CPPFLAGS"
    159         AC_CHECK_HEADERS([Python.h],
     131        [AS_HELP_STRING([--with-python=PATH], [specify an alternative directory for python installation])],
     132        [PYTHONCONFIG="$withval/bin/python-config"], [PYTHONCONFIG=""])
     133
     134if test "x$PYTHONCONFIG" = "x"; then
     135        # PYTHON was not specified, so search within the current path
     136        AC_PATH_PROG([PYTHONCONFIG], [python-config])
     137
     138        # If we couldn't find python-config, display a warning
     139        if test "x$PYTHONCONFIG" = "x"; then
     140                AC_MSG_ERROR([could not find python-config from libpython within the current path. You may need to try re-running configure with a --with-python parameter.])
     141        fi
     142else
     143        # PYTHON was specified; display a message to the user
     144        if test "x$PYTHON" = "xyes"; then
     145                AC_MSG_ERROR([you must specify a parameter to --with-python, e.g. --with-python=/path/to/python])
     146        else
     147                if test -f $PYTHONCONFIG; then
     148                        AC_MSG_RESULT([Using user-specified python-config file: $PYTHONCONFIG])
     149                else
     150                        AC_MSG_ERROR([the user-specified python-config file $PYTHONCONFIG does not exist])
     151                fi     
     152        fi
     153fi
     154
     155
     156# Extract the linker and include flags
     157PYTHON_LDFLAGS=`$PYTHONCONFIG --libs`
     158PYTHON_CPPFLAGS=`$PYTHONCONFIG --cflags`
     159
     160# Check headers file
     161CPPFLAGS_SAVE="$CPPFLAGS"
     162CPPFLAGS="$PYTHON_CPPFLAGS"
     163AC_CHECK_HEADERS([Python.h],
    160164                 [], [AC_MSG_ERROR([could not find headers include related to libpython])])
    161165
    162         # Ensure we can link against libphp
    163         LIBS_SAVE="$LIBS"
    164         LIBS="$PYTHON_LDFLAGS"
    165         PY_LIB=`$PYTHONCONFIG --libs | sed -e 's/^.*\(python2\..\)$/\1/'`
    166         AC_CHECK_LIB([$PY_LIB], [PyObject_CallObject], [], [AC_MSG_ERROR([could not find libpython])], [])
    167         AC_SUBST([PYTHON_CPPFLAGS])
    168         AC_SUBST([PYTHON_LDFLAGS])
    169 fi
    170 
    171 AC_SUBST([PYTHON_ENABLED])
    172 AC_SUBST([PYTHON_FILE])
     166# Ensure we can link against libpython
     167LIBS_SAVE="$LIBS"
     168LIBS="$PYTHON_LDFLAGS"
     169# Shouldn't we get python here rather than python2.6 :) ??
     170PY_LIB=`$PYTHONCONFIG --libs | sed -e 's/^.*\(python2\..\)$/\1/'`
     171AC_CHECK_LIB([$PY_LIB], [PyObject_CallObject], [], [AC_MSG_ERROR([could not find libpython])], [])
     172
     173AC_SUBST([PYTHON_CPPFLAGS])
     174AC_SUBST([PYTHON_LDFLAGS])
    173175
    174176# ===========================================================================
     
    180182
    181183AC_ARG_WITH([php],
    182         [AS_HELP_STRING([--with-php=PATH], [To enabled php support or specify an alternative directory for php installation,  disabled by default])],
    183         [PHP_PATH="$withval"; PHP_ENABLED="-DUSE_PHP"], [PHP_ENABLED=""])
    184 
    185 
    186 if test -z "$PHP_ENABLED"
    187 then
    188         PHP_FILE=""
    189 else
     184        [AS_HELP_STRING([--with-php=PATH], [specify an alternative directory for php installation or --with-php=no  to disable php support])],
     185        [PHP_PATH="$withval"], [PHP_PATH=""])
     186if test "$PHP_PATH" != "no";
     187then
    190188        PHPCONFIG="$PHP_PATH/bin/php-config"
     189        PHP_ENABLED="-DUSE_PHP"
    191190        PHP_FILE="service_internal_php.o"
    192         if test  "$PHP_PATH" = "yes"
    193         then
    194                 # PHP was not specified, so search within the current path
    195                 AC_PATH_PROG([PHPCONFIG], [php-config])
    196         else
    197                 PHPCONFIG="$PHP_PATH/bin/php-config"
    198         fi
    199 
     191        if test "x$PHPCONFIG" = "x";
     192        then
     193        # PHP was not specified, so search within the current path
     194        AC_PATH_PROG([PHPCONFIG], [php-config])
     195
     196        # If we couldn't find php-config, display a warning
     197        if test "x$PHPCONFIG" = "x";
     198        then
     199                AC_MSG_ERROR([could not find php-config from libphp within the current path. You may need to try re-running configure with a --with-php parameter.])
     200        fi
     201        else
     202                # PHP was specified; display a message to the user
     203                if test "x$PHP" = "xyes";
     204                then
     205                        AC_MSG_ERROR([you must specify a parameter to --with-php, e.g. --with-php=/path/to/php])
     206                else
     207                        if test -f $PHPCONFIG;
     208                        then
     209                                AC_MSG_RESULT([Using user-specified php-config file: $PHPCONFIG])
     210                        else
     211                                AC_MSG_ERROR([the user-specified php-config file $PHPCONFIG does not exist])
     212                        fi     
     213                fi
     214        fi
    200215        # Extract the linker and include flags
    201216        PHP_LDFLAGS="-L/`$PHPCONFIG --prefix`/lib -lphp5"
     
    215230        AC_SUBST([PHP_CPPFLAGS])
    216231        AC_SUBST([PHP_LDFLAGS])
     232else
     233        PHP_ENABLED=""
     234        PHP_FILE=""
    217235fi
    218236
     
    226244
    227245
     246
     247
    228248AC_ARG_WITH([perl],
    229         [AS_HELP_STRING([--with-perl=PATH], [To enabled perl support or specify an alternative directory for perl installation,  disabled by default])],
    230         [PERL_PATH="$withval"; PERL_ENABLED="-DUSE_PERL"], [PERL_ENABLED=""])
    231 
    232 
    233 if test -z "$PERL_ENABLED"
    234 then
    235         PERL_FILE=""
    236 else
    237         PERLCONFIG="$PERL_PATH/bin/perl"
    238         PHP_FILE="service_internal_perl.o"
    239         if test  "$PERL_PATH" = "yes"
    240         then
    241                 # PHP was not specified, so search within the current path
     249        [AS_HELP_STRING([--with-perl=PATH], [specify an alternative directory for perl installation or --with-perl=no  to disable perl support])],
     250        [PERL_PATH="$withval"], [PERL_PATH=""])
     251if test "$PERL_PATH" != "no";
     252then
     253        if test "x$PERL_PATH" = "xyes";
     254        then
    242255                AC_PATH_PROG([PERLCONFIG], [perl])
    243256        else
     
    245258        fi
    246259
     260        if test -f $PERLCONFIG;
     261        then
     262                AC_MSG_RESULT([Using user-specified perl file: $PERLCONFIG])
     263        else
     264                AC_MSG_ERROR([the user-specified perl file $PERLCONFIG does not exist])
     265        fi
     266
     267        PERL_ENABLED="-DUSE_PERL"
     268        PERL_FILE="service_internal_perl.o"
     269       
    247270        # Extract the linker and include flags
    248271        PERL_LDFLAGS=`$PERLCONFIG -MExtUtils::Embed -e ldopts`
     
    257280        AC_SUBST([PERL_CPPFLAGS])
    258281        AC_SUBST([PERL_LDFLAGS])
     282else
     283        PERL_ENABLED=""
     284        PERL_FILE=""
    259285fi
    260286
  • /trunk/zoo-kernel/service.h

    r30 r20  
    5353#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)
    5454
    55 #define SHMSZ     27
     55
     56  /*  static char* mtoupper(char* str){
     57    char* tmp=strdup(str);
     58    if(tmp){
     59      int cnt=strlen(tmp);
     60      int i;
     61      for(i=0;i<cnt;i++){
     62        tmp[i]=toupper(str[i]);
     63        tmp[i+1]=0;
     64      }
     65    }
     66    else
     67      tmp[0]=0;
     68    return tmp;
     69    }*/
    5670
    5771  /**
     
    423437      }
    424438      tmp=tmp->next;
    425     }
    426   }
    427 
    428 
    429   static void* setMapInMaps(maps* m,char* key,char* subkey,char *value){
    430     maps* _tmpm=getMaps(m,key);
    431     if(_tmpm!=NULL){
    432       map* _ztmpm=getMap(_tmpm->content,subkey);
    433       if(_ztmpm!=NULL){
    434         free(_ztmpm->value);
    435         _ztmpm->value=strdup(value);
    436         dumpMap(_ztmpm);
    437       }else{
    438         addToMap(_tmpm->content,subkey,value);
    439       }
    440439    }
    441440  }
  • /trunk/zoo-kernel/service_internal.c

    r30 r20  
    3535  return hex[code & 15];
    3636}
    37 
    38 void* unhandleStatus(maps *conf){
    39   int shmid,i;
    40   key_t key;
    41   void *shm;
    42   struct shmid_ds shmids;
    43   char *s,*s1;
    44   map *tmpMap=getMapFromMaps(conf,"lenv","sid");
    45   if(tmpMap!=NULL){
    46     key=atoi(tmpMap->value);
    47     if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
    48 #ifdef DEBUG
    49       fprintf(stderr,"shmget failed to update value\n");
    50 #endif
    51     }else{
    52       if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
    53 #ifdef DEBUG
    54         fprintf(stderr,"shmat failed to update value\n");
    55 #endif
    56       }else{
    57         shmdt(shm);
    58         shmctl(shmid,IPC_RMID,&shmids);
    59       }
    60     }
    61   }
    62 }
    63 
    64 #ifdef USE_JS
    65 
    66 JSBool
    67 JSUpdateStatus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
    68 {
    69   JS_MaybeGC(cx);
    70   char *sid;
    71   int istatus=0;
    72   char *status=NULL;
    73   maps *conf;
    74   int i=0;
    75   if(argc>2){
    76 #ifdef JS_DEBUG
    77     fprintf(stderr,"Number of arguments used to call the function : %i",argc);
    78 #endif
    79     return JS_FALSE;
    80   }
    81   conf=mapsFromJSObject(cx,argv[0]);
    82   dumpMaps(conf);
    83   if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){
    84     char tmpStatus[4];
    85     sprintf(tmpStatus,"%i",istatus);
    86     tmpStatus[3]=0;
    87     status=strdup(tmpStatus);
    88   }
    89   if(getMapFromMaps(conf,"lenv","status")!=NULL){
    90     if(status!=NULL)
    91       setMapInMaps(conf,"lenv","status",status);
    92     else
    93       setMapInMaps(conf,"lenv","status","15");
    94     updateStatus(conf);
    95   }
    96   freeMaps(&conf);
    97   free(conf);
    98   JS_MaybeGC(cx);
    99   return JS_TRUE;
    100 }
    101 
    102 #endif
    103 
    104 void* updateStatus(maps *conf){
    105   int shmid,i;
    106   key_t key;
    107   char *shm,*s,*s1;
    108   map *tmpMap=NULL;
    109   tmpMap=getMapFromMaps(conf,"lenv","sid");
    110   if(tmpMap!=NULL){
    111     key=atoi(tmpMap->value);
    112     if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
    113 #ifdef DEBUG
    114       fprintf(stderr,"shmget failed to update value\n");
    115 #endif
    116     }else{
    117       if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {
    118 #ifdef DEBUG
    119         fprintf(stderr,"shmat failed to update value\n");
    120 #endif
    121       }
    122       else{
    123         tmpMap=getMapFromMaps(conf,"lenv","status");
    124         s1=shm;
    125         for(s=tmpMap->value;*s!=NULL;s++)
    126           *s1++=*s;
    127         shmdt((void *)shm);
    128       }
    129     }
    130   }
    131 }
    132 
    133 char* getStatus(int pid){
    134   int shmid,i;
    135   key_t key;
    136   void *shm;
    137   char *s;
    138   key=pid;
    139   if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
    140 #ifdef DEBUG
    141     fprintf(stderr,"shmget failed in getStatus\n");
    142 #endif
    143   }else{
    144     if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
    145 #ifdef DEBUG
    146       fprintf(stderr,"shmat failed in getStatus\n");
    147 #endif
    148     }else{
    149       return (char*)shm;
    150     }
    151   }
    152   return "-1";
    153 }
    154 
    15537
    15638/* Returns a url-encoded version of str */
     
    847729          char tmp[1024];
    848730          sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value);
    849           xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp);
     731          xmlNewNsProp(nc6,ns_xlink,BAD_CAST "reference",BAD_CAST tmp);
    850732          xmlAddChild(nc3,nc6);
    851733          tmp1=tmp1->next;
     
    959841  xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
    960842  char tmp[256];
    961   char url[1024];
     843  char url[256];
    962844  memset(tmp,0,256);
    963845  memset(url,0,256);
    964846  maps* tmp_maps=getMaps(m,"main");
    965847  if(tmp_maps!=NULL){
    966     dumpMaps(getMaps(m,"lenv"));
    967     map* tmpm1=getMap(tmp_maps->content,"serverAddress");
    968     /**
    969      * Check if the ZOO Service GetStatus is available in the local directory.
    970      * If yes, then it uses a reference to an URL which the client can access
    971      * to get information on the status of a running Service (using the
    972      * percentCompleted attribute).
    973      * Else fallback to the initial method using the xml file to write in ...
    974      */
    975     char ntmp[1024];
    976 #ifndef WIN32
    977     getcwd(ntmp,1024);
    978 #else
    979     _getcwd(ntmp,1024);
    980 #endif
    981     struct stat myFileInfo;
    982     int statRes;
    983     char file_path[1024];
    984     sprintf(file_path,"%s/GetStatus.zcfg",ntmp);
    985     statRes=stat(file_path,&myFileInfo);
    986     if(statRes==0){
    987       char currentSid[128];
    988       map* tmpm=getMap(tmp_maps->content,"rewriteUrl");
    989       map *tmp_lenv=NULL;
    990       tmp_lenv=getMapFromMaps(m,"lenv","sid");
    991       if(tmp_lenv==NULL)
    992         sprintf(currentSid,"%i",pid);
    993       else
    994         sprintf(currentSid,"%s",tmp_lenv->value);
    995       if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){
    996         sprintf(url,"%s/?request=Execute&amp;service=WPS&amp;version=1.0.0&amp;Identifier=GetStatus&amp;DataInputs=sid=%s&amp;RawDataOutput=Result",tmpm1->value,currentSid);
    997       }else{
    998         if(strlen(tmpm->value)>0)
    999           if(strcasecmp(tmpm->value,"true")!=0)
    1000             sprintf(url,"%s/%s/GetStatus/%s",tmpm1->value,tmpm->value,currentSid);
    1001           else
    1002             sprintf(url,"%s/GetStatus/%s",tmpm1->value,currentSid);
    1003         else
    1004           sprintf(url,"%s/?request=Execute&amp;service=WPS&amp;version=1.0.0&amp;Identifier=GetStatus&amp;DataInputs=sid=%s&amp;RawDataOutput=Result",tmpm1->value,currentSid);
    1005       }
    1006     }else{
    1007       map* tmpm2=getMap(tmp_maps->content,"tmpUrl");
    1008       if(tmpm1!=NULL && tmpm2!=NULL){
    1009         sprintf(url,"%s/%s/%s_%i.xml",tmpm1->value,tmpm2->value,service,pid);
    1010       }
    1011     }
    1012     if(tmpm1!=NULL)
    1013       sprintf(tmp,"%s/",tmpm1->value);
     848    map* tmpm=getMap(tmp_maps->content,"serverAddress");
     849    map* tmpm1=getMap(tmp_maps->content,"tmpUrl");
     850    if(tmpm!=NULL && tmpm1!=NULL){
     851      sprintf(url,"%s/%s/%s_%i.xml",tmpm->value,tmpm1->value,service,pid);
     852    }
     853    if(tmpm!=NULL)
     854      sprintf(tmp,"%s/",tmpm->value);
    1014855  }
    1015856
    1016857  xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp);
    1017   if(status!=SERVICE_SUCCEEDED && status!=SERVICE_FAILED){
     858  if(status!=SERVICE_SUCCEEDED){
    1018859    xmlNewProp(n,BAD_CAST "statusLocation",BAD_CAST url);
    1019860  }
     
    1035876  time_t now;
    1036877  char *tmp1;
    1037   map *tmpStatus;
    1038878 
    1039879  now = time ( NULL );
     
    1044884  len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm );
    1045885
    1046   xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
    1047 
    1048   char sMsg[2048];
    1049886  switch(status){
    1050887  case SERVICE_SUCCEEDED:
     888    xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
    1051889    nc1 = xmlNewNode(ns, BAD_CAST "ProcessSucceeded");
    1052     sprintf(sMsg,"Service \"%s\" run successfully.",serv->name);
    1053     nc3=xmlNewText(BAD_CAST sMsg);
    1054     xmlAddChild(nc1,nc3);
    1055890    break;
    1056891  case SERVICE_STARTED:
     892    xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
    1057893    nc1 = xmlNewNode(ns, BAD_CAST "ProcessStarted");
    1058     tmpStatus=getMapFromMaps(m,"lenv","status");
    1059     xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST tmpStatus->value);
    1060     sprintf(sMsg,"ZOO Service \"%s\" is currently running. Please, reload this document to get the up-to-date status of the Service.",serv->name);
    1061     nc3=xmlNewText(BAD_CAST sMsg);
    1062     xmlAddChild(nc1,nc3);
     894    xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST "NEED_SERVICE_ACCESS");
    1063895    break;
    1064896  case SERVICE_ACCEPTED:
     897    xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
    1065898    nc1 = xmlNewNode(ns, BAD_CAST "ProcessAccepted");
    1066     sprintf(sMsg,"Service \"%s\" was accepted by the ZOO Kernel and it run as a background task. Please consult the statusLocation attribtue providen in this document to get the up-to-date document.",serv->name);
    1067     nc3=xmlNewText(BAD_CAST sMsg);
    1068     xmlAddChild(nc1,nc3);
    1069899    break;
    1070900  case SERVICE_FAILED:
    1071901    nc1 = xmlNewNode(ns, BAD_CAST "ProcessFailed");
    1072     map *errorMap;
    1073     map *te;
    1074     te=getMapFromMaps(m,"lenv","code");
    1075     if(te!=NULL)
    1076       errorMap=createMap("code",te->value);
    1077     else
    1078       errorMap=createMap("code","NoApplicableCode");
    1079     te=getMapFromMaps(m,"lenv","message");
    1080     if(te!=NULL)
    1081       addToMap(errorMap,"text",te->value);
    1082     else
    1083       addToMap(errorMap,"text","No more information available");
    1084     nc3=createExceptionReportNode(m,errorMap,0);
    1085     xmlAddChild(nc1,nc3);
    1086902    break;
    1087903  default :
    1088904    printf("error code not know : %i\n",status);
    1089     //exit(1);
     905    exit(1);
    1090906    break;
    1091907  }
     
    12431059  nc1=xmlNewNode(ns_wps, BAD_CAST type);
    12441060  map *tmp=e->content;
    1245 #ifdef DEBUG
     1061  //#ifdef DEBUG
    12461062  dumpMap(tmp);
    12471063  dumpElements(e);
    1248 #endif
     1064  //#endif
    12491065  nc2=xmlNewNode(ns_ows, BAD_CAST "Identifier");
    12501066  nc3=xmlNewText(BAD_CAST e->name);
     
    12691085   * IO type Reference or full Data ?
    12701086   */
    1271 #ifdef DEBUG
     1087  //#ifdef DEBUG
    12721088  fprintf(stderr,"FORMAT %s %s\n",e->format,e->format);
    1273 #endif
     1089  //#endif
    12741090  map *tmpMap=getMap(m->content,"Reference");
    12751091  if(tmpMap==NULL){
     
    13941210  maps* tmpMap=getMaps(m,"main");
    13951211  char *encoding=getEncoding(tmpMap);
    1396   map *tmpSid=getMapFromMaps(m,"lenv","sid");
    1397   if(tmpSid==NULL)
    1398     printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
     1212  printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
    13991213
    14001214  ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
     
    14031217  ns_xlink=xmlNewNs(n,BAD_CAST "http://www.w3.org/1999/xlink",BAD_CAST "xlink");
    14041218  ns_xsi=xmlNewNs(n,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
    1405   xmlNewProp(n,BAD_CAST "xsi:schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
     1219  xmlNewProp(n,BAD_CAST "xsi:schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1/owsExceptionReport.xsd");
    14061220  xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
    1407   xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
     1221  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
     1222
     1223  xmlNewProp(n,BAD_CAST "version",BAD_CAST getVersion(tmpMap));
    14081224
    14091225  nc = xmlNewNode(ns, BAD_CAST "Exception"); 
     
    14351251  xmlFreeNs(ns);
    14361252  xmlCleanupParser();
    1437 }
    1438 
    1439 xmlNodePtr createExceptionReportNode(maps* m,map* s,int use_ns){
    1440  
    1441   int buffersize;
    1442   xmlChar *xmlbuff;
    1443   xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
    1444   xmlNodePtr n,nc,nc1,nc2;
    1445 
    1446   maps* tmpMap=getMaps(m,"main");
    1447 
    1448   ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
    1449   n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
    1450 
    1451   if(use_ns==1){
    1452     ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
    1453     int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
    1454     ns_xsi=usedNs[xsiId];
    1455     int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
    1456     ns_xlink=usedNs[xlinkId];
    1457     xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
    1458   }
    1459   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
    1460   xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
    1461  
    1462   nc = xmlNewNode(ns, BAD_CAST "Exception");
    1463 
    1464   map* tmp=getMap(s,"code");
    1465   if(tmp!=NULL)
    1466     xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
    1467   else
    1468     xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
    1469 
    1470   tmp=getMap(s,"text");
    1471   nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
    1472   nc2=NULL;
    1473   if(tmp!=NULL){
    1474     xmlNodeSetContent(nc1, BAD_CAST tmp->value);
    1475   }
    1476   else{
    1477     xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
    1478   }
    1479   xmlAddChild(nc,nc1);
    1480   xmlAddChild(n,nc);
    1481   return n;
    14821253}
    14831254
     
    15251296#endif
    15261297    printProcessResponse(m,request_inputs1,cpid,
    1527                          s,r_inputs->value,res,
    1528                          request_inputs,
    1529                          request_outputs);
    1530   }
    1531   else
    1532     if(res!=SERVICE_FAILED){
    1533       /**
    1534        * We get the first output only !!
    1535        */
    1536       char mime[1024];
    1537       map* mi=getMap(request_outputs->content,"mimeType");
    1538 #ifdef DEBUG
    1539       fprintf(stderr,"SERVICE OUTPUTS\n");
    1540       dumpMaps(request_outputs);
    1541       fprintf(stderr,"SERVICE OUTPUTS\n");
    1542 #endif
    1543       map* en=getMap(request_outputs->content,"encoding");
    1544       if(mi!=NULL && en!=NULL)
     1298                          s,r_inputs->value,res,
     1299                          request_inputs,
     1300                          request_outputs);
     1301  }
     1302  else{
     1303    /**
     1304     * We get the first output only !!
     1305     */
     1306    char mime[1024];
     1307    map* mi=getMap(request_outputs->content,"mimeType");
     1308#ifdef DEBUG
     1309    fprintf(stderr,"SERVICE OUTPUTS\n");
     1310    dumpMaps(request_outputs);
     1311    fprintf(stderr,"SERVICE OUTPUTS\n");
     1312#endif
     1313    map* en=getMap(request_outputs->content,"encoding");
     1314    if(mi!=NULL && en!=NULL)
     1315      sprintf(mime,
     1316              "Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n",
     1317              mi->value,en->value);
     1318    else
     1319      if(mi!=NULL)
    15451320        sprintf(mime,
    1546                 "Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n",
    1547                 mi->value,en->value);
     1321                "Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n",
     1322                mi->value);
    15481323      else
    1549         if(mi!=NULL)
    1550           sprintf(mime,
    1551                   "Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n",
    1552                   mi->value);
    1553         else
    1554           sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
    1555       printf("%s",mime);
    1556       toto=getMap(request_outputs->content,"value");
    1557       if(mi!=NULL && strncmp(mi->value,"image",5)==0){
    1558         map* rs=getMapFromMaps(request_outputs,request_outputs->name,"size");
    1559         fwrite(toto->value,atoi(rs->value),1,stdout);
    1560       }
    1561       else
    1562         printf("%s",toto->value);
    1563 #ifdef DEBUG
    1564       dumpMap(toto);
    1565 #endif
    1566     }else{
    1567       char tmp[1024];
    1568       map * errormap;
    1569       map *lenv;
    1570       lenv=getMapFromMaps(m,"lenv","message");
    1571       if(lenv!=NULL)
    1572         sprintf(tmp,"Unable to run the Service. The message returned back by the Service was the following : %s",lenv->value);
    1573       else
    1574         sprintf(tmp,"Unable to run the Service. No more information was returned back by the Service.");
    1575       errormap = createMap("text",tmp);     
    1576       addToMap(errormap,"code", "InternalError");
    1577       printf("Content-Type: text/xml; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
    1578       printExceptionReportResponse(m,errormap);
    1579       freeMap(&errormap);
    1580       free(errormap);
    1581     }
     1324        sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
     1325    printf("%s",mime);
     1326    toto=getMap(request_outputs->content,"value");
     1327    if(mi!=NULL && strncmp(mi->value,"image",5)==0){
     1328      map* rs=getMapFromMaps(request_outputs,request_outputs->name,"size");
     1329      fwrite(toto->value,atoi(rs->value),1,stdout);
     1330    }
     1331    else
     1332      printf("%s",toto->value);
     1333#ifdef DEBUG
     1334    dumpMap(toto);
     1335#endif
     1336  }
    15821337}
    15831338
  • /trunk/zoo-kernel/service_internal.h

    r30 r20  
    3131#define TIME_SIZE 40
    3232
    33 #include <sys/stat.h>
    3433#include <sys/types.h>
    35 #include <sys/ipc.h>
    36 #include <sys/shm.h>
    37 #include <stdio.h>
    3834#include <unistd.h>
    3935#include <time.h>
     
    5248extern   int conf_read(char*,maps*);
    5349
    54 #ifdef USE_JS
    55 #define XP_UNIX 0
    56 #include "service_internal_js.h"
    57 #endif
    58 
    5950#ifdef __cplusplus
    6051extern "C" {
     
    6657  static int nbNs=0;
    6758
    68   void* unhandleStatus(maps*);
    69   void* updateStatus(maps*);
    70   char* getStatus(int);
    7159
    72 #ifdef USE_JS
    73   char* JSValToChar(JSContext*,jsval*);
    74   JSBool JSUpdateStatus(JSContext*,JSObject*,uintN,jsval *,jsval *);
    75 #endif
    76  
    7760  void URLDecode(char *);
    7861  char *url_encode(char *);
     
    8467 
    8568  void printExceptionReportResponse(maps*,map*);
    86   xmlNodePtr createExceptionReportNode(maps*,map*,int);
    8769  void printProcessResponse(maps*,map*,int,service*,char*,int,maps*,maps*);
    8870  xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,char*,maps*);
  • /trunk/zoo-kernel/service_internal_js.c

    r30 r20  
    2323 */
    2424
    25 #include "service_internal.h"
     25#include "service_internal_js.h"
    2626
    2727static char dbg[1024];
     
    7474  if (!JS_DefineFunction(cx, global, "ZOORequest", JSRequest, 4, 0))
    7575    return 1;
    76   if (!JS_DefineFunction(cx, global, "ZOOUpdateStatus", JSUpdateStatus, 2, 0))
    77     return 1;
    7876
    7977  /* Your application code here. This may include JSAPI calls
     
    8482  map* tmpm1=getMap(request,"metapath");
    8583  map* tmpm2=getMap(s->content,"serviceProvider");
     84  char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+6];
    8685  char ntmp[1024];
    8786  getcwd(ntmp,1024);
    88   char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+2];
    8987  sprintf(filename,"%s/%s%s",ntmp,tmpm1->value,tmpm2->value);
    90   filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+1]=0;
    91   fprintf(stderr,"FILENAME %s\n",filename);
    9288  struct stat file_status;
    9389  stat(filename, &file_status);
     
    207203
    208204  /* Cleanup. */
     205  // The JS_MaybeGC call imply segmentation fault
     206  //JS_MaybeGC(cx);
    209207  JS_DestroyScript(cx, script);
    210   JS_MaybeGC(cx);
    211208  // If we use the DestroyContext as requested to release memory then we get
    212209  // issue getting back the main configuration maps after coming back to the
     
    390387#endif
    391388      if(res!=NULL){
    392 #ifdef JS_DEBUG
    393389        fprintf(stderr,"%s - %s\n",JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
    394 #endif
    395390        addToMap(res,JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
    396391      }
     
    399394        res->next=NULL;
    400395      }
    401 #ifdef JS_DEBUG
    402396      dumpMap(res);
    403 #endif
    404397    }
    405398  }
  • /trunk/zoo-kernel/service_internal_perl.c

    r30 r20  
    127127}
    128128       
    129 int zoo_perl_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){
    130         maps* m=*main_conf;
    131         maps* inputs=*real_inputs;
    132         maps* outputs=*real_outputs;
    133         int res=SERVICE_FAILED;
    134         map * tmp=getMap(s->content,"serviceProvide");
    135129
    136         char *my_argv[] = { "", tmp->value };
    137         if ((my_perl = perl_alloc()) == NULL){
    138                 fprintf(stderr,"no memmory");
    139                 exit(1);
    140         }
    141         perl_construct( my_perl );
    142         perl_parse(my_perl, xs_init, 2, my_argv, (char **)NULL);
    143         perl_run(my_perl);
    144        
    145 
    146         HV* h_main_conf = (HV *)sv_2mortal((SV *)newHV());
    147         HV* h_real_inputs = (HV *)sv_2mortal((SV *)newHV());
    148         HV* h_real_outputs = (HV *)sv_2mortal((SV *)newHV());
    149         maps_to_hash(m,&h_main_conf);
    150         maps_to_hash(inputs,&h_real_inputs);
    151         maps_to_hash(outputs,&h_real_outputs);
    152         dSP;
    153         ENTER;
    154         SAVETMPS;
    155         PUSHMARK(SP);
    156         XPUSHs(sv_2mortal(newRV_inc((SV *)h_main_conf)));
    157         XPUSHs(sv_2mortal(newRV_inc((SV *)h_real_inputs)));
    158         XPUSHs(sv_2mortal(newRV_inc((SV *)h_real_outputs)));
    159         PUTBACK;
    160         call_pv(s->name, G_SCALAR);
    161         SPAGAIN;
    162         res = POPi;
    163         hash_to_maps(h_real_outputs,real_outputs);
    164         PUTBACK;
    165         FREETMPS;
    166         LEAVE;
    167         return res;
    168 }
    169 
    170        
    171 
    172 
    173 
    174 
    175 
    176 
    177 
    178 
    179 
    180 
    181 
    182 
    183 
    184 
    185 
    186 
    187 
    188 
    189 
    190 
    191 
    192 
    193 
    194 
    195 
    196 
    197 
    198 
    199 
    200 
    201 
  • /trunk/zoo-kernel/zoo_service_loader.c

    r30 r20  
    4444#include "service.h"
    4545#include "service_internal.h"
    46 
    47 
    48 #ifdef USE_PYTHON
    4946#include "service_internal_python.h"
    50 #endif
    5147
    5248#ifdef USE_JAVA
     
    6157#include "service_internal_js.h"
    6258#endif
    63 
    64 #ifdef USE_PERL
    65 #include "service_internal_perl.h"
    66 #endif
    67 
    6859
    6960
     
    182173    freeMaps(&m);
    183174    free(m);
    184     freeMap(&request_inputs);
    185     free(request_inputs);
    186175    return 1;
    187176  }
     
    194183      freeMaps(&m);
    195184      free(m);
    196       freeMap(&request_inputs);
    197       free(request_inputs);
    198185      free(REQUEST);
    199186      return 1;
     
    15881575    }
    15891576    else{
    1590 #ifdef USE_PYTHON
    15911577      if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
    15921578        eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    15931579      }
    15941580      else
    1595 #endif
    15961581       
    15971582#ifdef USE_JAVA
     
    16081593          else
    16091594#endif
    1610 
    1611 
    1612 #ifdef USE_PERL
    1613           if(strncasecmp(r_inputs->value,"PERL",4)==0){
    1614             eres=zoo_perl_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1615           }
    1616           else
    1617 #endif
    1618 
     1595         
    16191596#ifdef USE_JS
    16201597            if(strncasecmp(r_inputs->value,"JS",2)==0){
     
    18101787        }
    18111788      } else{
    1812 
    1813 #ifdef USE_PYTHON
    18141789        if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
    18151790          eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    18161791        }
    18171792        else
    1818 #endif
    18191793
    18201794#ifdef USE_JAVA
     
    18321806#endif
    18331807             
    1834 #ifdef USE_PERL
    1835           if(strncasecmp(r_inputs->value,"PERL",4)==0){
    1836             eres=zoo_perl_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1837           }
    1838           else
    1839 #endif
    18401808#ifdef USE_JS
    18411809              if(strncasecmp(r_inputs->value,"JS",2)==0){
     
    18731841                   cpid,m,eres);
    18741842
    1875   //if(getpid()==cpid){
    18761843  freeService(&s1);
    18771844  free(s1);
    18781845  freeMaps(&m);
    18791846  free(m);
    1880   freeMaps(&tmpmaps);
    1881   free(tmpmaps);
    18821847 
    18831848  freeMaps(&request_input_real_format);
    18841849  free(request_input_real_format);
    1885  
    1886   //freeMap(&request_inputs);
    1887   //free(request_inputs);
    1888    
     1850
    18891851  /* The following is requested but get issue using with Python support :/ */
    1890   /* freeMaps(&request_output_real_format);
    1891      free(request_output_real_format);
    1892   */
     1852  /*freeMaps(&request_output_real_format);
     1853  free(request_output_real_format);*/
    18931854 
    18941855  free(REQUEST);
     
    18991860  fflush(stderr);
    19001861#endif
    1901     //}
    19021862
    19031863  return 0;
  • /trunk/zoo-services/ogr/base-vect-ops/Makefile

    r30 r20  
    1 CFLAGS=-I../../../zoo-kernel/ -I./ `xsl-config --cflags`  `gdal-config --cflags`  -DLINUX_FREE_ISSUE #-DDEBUG
    2 # if JS_ENABLED flag is set to true in your ZOO-Kernel Makefile then you'll have
    3 # uncomment the following line
    4 # JS_LDFLAGS=../../../zoo-kernel/ulinet.o ../../../zoo-kernel/service_internal_js.o
     1CFLAGS=-I../../../zoo-kernel/ -I./ `xml2-config --cflags` `python-config --cflags`  `gdal-config --cflags`   -DLINUX_FREE_ISSUE #-DDEBUG
     2CC=gcc
    53
    6 cgi-env/ogr_service.zo: service.c
    7         g++ ${CFLAGS} -shared -fpic -o cgi-env/ogr_service.zo ./service.c ../../../zoo-kernel/service_internal.o ${JS_LDFLAGS} `xsl-config --libs` `gdal-config --libs` `geos-config --libs`
     4cgi-env/service.zo: service.c
     5        g++ ${CFLAGS} -shared -fpic -o cgi-env/ogr_service.zo ./service.c ../../../zoo-kernel/service_internal.o `gdal-config --libs`
    86
    97clean:
  • /trunk/zoo-services/ogr/base-vect-ops/service.c

    r30 r20  
    7474    char *tmp=(char*)calloc((xmlStrlen(xmlStrstr(xmlbuff,BAD_CAST "?>"))-1),sizeof(char));
    7575    sprintf(tmp,"%s",xmlStrstr(xmlbuff,BAD_CAST "?>")+2);
     76    //strdup(strstr((char*)xmlbuff,"?>")+2);
    7677    xmlXPathFreeObject(xpathObj);
    7778    xmlXPathFreeContext(xpathCtx);
     
    8687    free(tmp);
    8788    if(res==NULL){
    88       setMapInMaps(conf,"lenv","message","Unable to call OGR_G_CreatFromGML");
    89       return NULL;
     89      map* tmp=createMap("text","Unable to call OGR_G_CreatFromGML");
     90      addToMap(tmp,"code","NoApplicableCode");
     91      printExceptionReportResponse(conf,tmp);
     92      exit(0);
    9093    }
    9194    else
    92       return res;
     95      return res;//OGR_G_CreateFromGML(tmp);
    9396  }
    9497
     
    105108    fprintf(stderr,"Tolerance for Simplify %f",tolerance);
    106109    map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
    107     if(!tmp){
    108       setMapInMaps(conf,"lenv","message","Unagle to parse the input geometry from InputPolygon");
     110    if(!tmp)
    109111      return SERVICE_FAILED;
    110     }
    111     map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
     112    map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeTime");
    112113    if(tmp1!=NULL){
    113114      if(strncmp(tmp1->value,"text/js",7)==0 ||
    114          strncmp(tmp1->value,"application/json",16)==0)
     115         strncmp(tmp1->value,"application/json",7)==0)
    115116        geometry=OGR_G_CreateGeometryFromJson(tmp->value);
    116117      else
    117118        geometry=createGeometryFromGML(conf,tmp->value);
    118119    }
    119     else{
    120       setMapInMaps(conf,"lenv","message","Unable to find any geometry for InputPolygon");
    121       return SERVICE_FAILED;
    122     }
    123     if(geometry==NULL){
    124       setMapInMaps(conf,"lenv","message","Unagle to parse the input geometry from InputPolygon");
    125       return SERVICE_FAILED;
    126     }
    127     fprintf(stderr,"Create GEOSGeometry object");
     120    else
     121      geometry=createGeometryFromGML(conf,tmp->value);
    128122    GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS();
    129123    GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance);
    130124    res=OGRGeometryFactory::createFromGEOS(gres);
    131     tmp1=getMapFromMaps(outputs,"Result","mimeType");
    132125    if(tmp1!=NULL){
    133126      if(strncmp(tmp1->value,"text/js",7)==0 ||
    134127         strncmp(tmp1->value,"application/json",16)==0){
    135         char *tmpS=OGR_G_ExportToJson(res);
    136         setMapInMaps(outputs,"Result","value",tmpS);
    137         setMapInMaps(outputs,"Result","mimeType","text/plain");
    138         setMapInMaps(outputs,"Result","encoding","UTF-8");
    139         free(tmpS);
     128        outputs->content=createMap("value",OGR_G_ExportToJson(tmp->value));
     129        addMapToMap(&outputs->content,createMap("mimeType","text/plain"));
     130        addMapToMap(&outputs->content,createMap("encoding","UTF-8"));
    140131      }
    141132      else{
    142         char *tmpS=OGR_G_ExportToGML(res);
    143         setMapInMaps(outputs,"Result","value",tmpS);
    144         setMapInMaps(outputs,"Result","mimeType","text/xml");
    145         setMapInMaps(outputs,"Result","encoding","UTF-8");
    146         setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
    147         free(tmpS);
     133        outputs->content=createMap("value",OGR_G_ExportToGML(res));
     134        addMapToMap(&outputs->content,createMap("mimeType","text/xml"));
     135        addMapToMap(&outputs->content,createMap("encoding","UTF-8"));
     136        addMapToMap(&outputs->content,createMap("schema","http://fooa/gml/3.1.0/polygon.xsd"));
    148137      }
    149138    }else{
    150       char *tmpS=OGR_G_ExportToJson(tmp->value);
    151       setMapInMaps(outputs,"Result","value",tmpS);
    152       setMapInMaps(outputs,"Result","mimeType","text/plain");
    153       setMapInMaps(outputs,"Result","encoding","UTF-8");
    154       free(tmpS);
     139      outputs->content=createMap("value",OGR_G_ExportToJson(res));
     140      addMapToMap(&outputs->content,createMap("mimeType","text/plain"));
     141      addMapToMap(&outputs->content,createMap("encoding","UTF-8"));
    155142    }
    156143    outputs->next=NULL;
     
    191178    else
    192179      geometry=createGeometryFromGML(conf,tmp->value);
    193     if(geometry==NULL)
    194       return SERVICE_FAILED;
    195180    res=(*myFunc)(geometry);
    196181    fprintf(stderr,"Service internal print \n");
     
    204189      if(strncmp(tmp_2->value,"text/js",7)==0 ||
    205190         strncmp(tmp_2->value,"application/json",16)==0){
    206         char *tmpS=OGR_G_ExportToJson(res);
    207         setMapInMaps(outputs,"Result","value",tmpS);
    208         setMapInMaps(outputs,"Result","mimeType","text/plain");
    209         setMapInMaps(outputs,"Result","encoding","UTF-8");
    210         free(tmpS);
     191        char *tres=OGR_G_ExportToJson(res);
     192        addToMap(outputs->content,"value",tres);
     193        free(tres);
     194        addToMap(outputs->content,"mimeType","text/plain");
     195        addToMap(outputs->content,"encoding","UTF-8");
    211196      }
    212197      else{
    213         char *tmpS=OGR_G_ExportToGML(res);
    214         setMapInMaps(outputs,"Result","value",tmpS);
    215         setMapInMaps(outputs,"Result","mimeType","text/plain");
    216         setMapInMaps(outputs,"Result","encoding","UTF-8");
    217         free(tmpS);
    218 
     198        char *tres=OGR_G_ExportToGML(res);
     199        addToMap(outputs->content,"value",tres);
     200        free(tres);
    219201      }
    220202    }else{
    221       char *tmpS=OGR_G_ExportToJson(res);
    222       setMapInMaps(outputs,"Result","value",tmpS);
    223       setMapInMaps(outputs,"Result","mimeType","text/plain");
    224       setMapInMaps(outputs,"Result","encoding","UTF-8");
    225       free(tmpS);
     203      char *tres=OGR_G_ExportToJson(res);
     204      addToMap(outputs->content,"value",tres);
     205      free(tres);
     206      addToMap(outputs->content,"mimeType","text/plain");
     207      addToMap(outputs->content,"encoding","UTF-8");
    226208    }
    227209    outputs->next=NULL;
     
    253235   else
    254236     geometry=createGeometryFromGML(conf,tmp->value);
    255    if(geometry==NULL){
    256      setMapInMaps(conf,"lenv","message","Unable to parse input geometry");
    257      return SERVICE_FAILED;
    258    }
    259    double bufferDistance;
     237   int bufferDistance=1;
    260238   tmp=getMapFromMaps(inputs,"BufferDistance","value");
    261    if(tmp==NULL){
    262      bufferDistance=atof("10.0");
    263    }
    264    else
    265      bufferDistance=atof(tmp->value);
     239   if(tmp!=NULL)
     240                bufferDistance=atoi(tmp->value);
    266241   res=OGR_G_Buffer(geometry,bufferDistance,30);
    267242   tmp1=getMapFromMaps(outputs,"Result","mimeType");
    268243   if(strncmp(tmp1->value,"application/json",16)==0){
    269      char *tmpS=OGR_G_ExportToJson(res);
    270      setMapInMaps(outputs,"Result","value",tmpS);
    271      setMapInMaps(outputs,"Result","mimeType","text/plain");
    272      setMapInMaps(outputs,"Result","encoding","UTF-8");
    273      free(tmpS);
     244                addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
     245                addToMap(outputs->content,"mimeType","text/plain");
    274246   }
    275247   else{
    276      char *tmpS=OGR_G_ExportToGML(res);
    277      setMapInMaps(outputs,"Result","value",tmpS);
    278      setMapInMaps(outputs,"Result","mimeType","text/xml");
    279      setMapInMaps(outputs,"Result","encoding","UTF-8");
    280      setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
     248                addToMap(outputs->content,"value",OGR_G_ExportToGML(res));
    281249   }
    282250   outputs->next=NULL;
     
    286254}
    287255
     256/*  int Buffer(maps*& conf,maps*& inputs,maps*& outputs){
     257#ifdef DEBUG
     258    fprintf(stderr,"\nService internal print\n");
     259#endif
     260    maps* cursor=inputs;
     261    OGRGeometryH geometry,res;
     262    int bufferDistance;   
     263    if(cursor!=NULL){
     264#ifdef DEBUG
     265      fprintf(stderr,"\nService internal print\n");
     266      dumpMaps(cursor);
     267      fprintf(stderr,"\nService internal print\n");
     268      dumpMaps(inputs);
     269      fprintf(stderr,"\nService internal print\n");
     270#endif
     271      map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
     272      map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
     273      if(tmp1!=NULL){
     274        if(strncmp(tmp1->value,"application/json",16)==0 ||
     275           strncmp(tmp1->value,"text/js",7)==0)
     276          geometry=OGR_G_CreateGeometryFromJson(tmp->value);
     277        else
     278          geometry=createGeometryFromGML(conf,tmp->value);
     279      }
     280      else
     281        geometry=createGeometryFromGML(conf,tmp->value);
     282    }
     283    if(cursor!=NULL){
     284      map* tmp=getMapFromMaps(cursor,"BufferDistance","value");
     285      if(tmp==NULL){
     286        bufferDistance=10;
     287      }
     288      else
     289        bufferDistance=atoi(tmp->value);
     290#ifdef DEBUG
     291      fprintf(stderr,"\nService internal print (BufferDistance value: %i)\n",bufferDistance);
     292#endif
     293    }
     294#ifdef DEBUG
     295    dumpMaps(outputs);
     296#endif
     297    map* tmp=getMapFromMaps(outputs,"Result","mimeType");
     298    res=OGR_G_Buffer(geometry,bufferDistance,30);
     299#ifdef DEBUG
     300    dumpMap(tmp);
     301#endif
     302    if(tmp!=NULL){
     303#ifdef DEBUG
     304      dumpMap(tmp);
     305#endif
     306      if(strncmp(tmp->value,"application/json",16)==0){
     307        addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
     308        addToMap(outputs->content,"mimeType","text/plain");
     309        addToMap(outputs->content,"encoding","UTF-8");
     310      }
     311      else if(strcmp(tmp->value,"text/xml")==0){
     312        xmlInitParser();
     313        xmlDocPtr doc = xmlParseMemory(tmp->value,strlen(tmp->value));
     314        xmlChar *xmlbuff;
     315        int buffersize;
     316        char *buff=OGR_G_ExportToGML(res);
     317        addToMap(outputs->content,"value",buff);
     318        map* tmp1=getMapFromMaps(outputs,"Result","encoding");
     319        if(tmp1!=NULL)
     320          addToMap(outputs->content,"encoding",tmp1->value);
     321        else
     322          addToMap(outputs->content,"encoding","UTF-8");
     323        xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
     324        xmlFree(xmlbuff);
     325        xmlFreeDoc(doc);
     326        xmlCleanupParser();
     327      }
     328      else{
     329        addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
     330        addToMap(outputs->content,"mimeType","text/plain");
     331        addToMap(outputs->content,"encoding","UTF-8");
     332        outputs->next=NULL;
     333      }
     334      outputs->next=NULL;
     335    }
     336    else{
     337      addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
     338      addToMap(outputs->content,"mimeType","text/plain");
     339      addToMap(outputs->content,"encoding","UTF-8");
     340      outputs->next=NULL;
     341    }
     342    outputs->next=NULL;
     343#ifdef DEBUG
     344    dumpMaps(outputs);
     345    fprintf(stderr,"\nService internal print\n===\n");
     346#endif
     347    OGR_G_DestroyGeometry(geometry);
     348    OGR_G_DestroyGeometry(res);
     349    return SERVICE_SUCCEEDED;
     350  }
     351*/
     352
    288353#ifdef WIN32
    289354  __declspec(dllexport)
     
    322387#ifdef DEBUG
    323388    fprintf(stderr,"\nService internal print1\n");
     389#endif
    324390    fflush(stderr);
    325 #endif
    326     fprintf(stderr,"\nService internal print1\n");
    327     dumpMaps(inputs);
    328     fprintf(stderr,"\nService internal print1\n");
    329391
    330392    maps* cursor=inputs;
     
    343405        geometry1=createGeometryFromGML(conf,tmp->value);
    344406    }
    345     if(geometry1==NULL){
    346       setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity1.");
    347       fprintf(stderr,"SERVICE FAILED !\n");
    348       return SERVICE_FAILED;
    349     }
    350     fprintf(stderr,"\nService internal print1 InputEntity1\n");
    351407    {
    352408      map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
    353409      map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType");
    354       //#ifdef DEBUG
    355       fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16));
    356       //dumpMap(tmp);
     410#ifdef DEBUG
    357411      fprintf(stderr,"MY MAP\n");
    358       ///#endif
    359       fprintf(stderr,"\nService internal print1 InputEntity2\n");
     412      dumpMap(tmp1);
     413      fprintf(stderr,"MY MAP\n");
     414#endif
    360415      if(tmp1!=NULL){
    361         if(strncmp(tmp1->value,"application/json",16)==0){
    362           fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n");
     416        if(strncmp(tmp1->value,"application/json",16)==0)
    363417          geometry2=OGR_G_CreateGeometryFromJson(tmp->value);
    364         }
    365         else{
    366           fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n");
     418        else
    367419          geometry2=createGeometryFromGML(conf,tmp->value);
    368         }
    369420      }
    370421      else
    371422        geometry2=createGeometryFromGML(conf,tmp->value);
    372       fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n");
    373     }
    374     fprintf(stderr,"\nService internal print1 InputEntity2 Final\n");
    375     if(geometry2==NULL){
    376       setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity2.");
    377       fprintf(stderr,"SERVICE FAILED !\n");
    378       return SERVICE_FAILED;
    379     }
    380     fprintf(stderr,"\nService internal print1\n");
     423    }
    381424    res=(*myFunc)(geometry1,geometry2);
    382     fprintf(stderr,"\nService internal print1\n");
    383     char *tmpS=OGR_G_ExportToJson(res);
    384     setMapInMaps(outputs,"Result","value",tmpS);
    385     setMapInMaps(outputs,"Result","mimeType","text/plain");
    386     setMapInMaps(outputs,"Result","encoding","UTF-8");
    387     free(tmpS);
     425    addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
     426    addToMap(outputs->content,"mimeType","text/plain");
     427    addToMap(outputs->content,"encoding","UTF-8");
     428    outputs->next=NULL;
    388429    OGR_G_DestroyGeometry(geometry1);
    389430    OGR_G_DestroyGeometry(geometry2);
     
    428469#endif
    429470    fflush(stderr);
     471
    430472    maps* cursor=inputs;
    431473    OGRGeometryH geometry1,geometry2;
     
    449491        geometry1=createGeometryFromGML(conf,tmp->value);
    450492    }
    451     if(geometry1==NULL){
    452       setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity1.");
    453       fprintf(stderr,"SERVICE FAILED !\n");
    454       return SERVICE_FAILED;
    455     }
    456493    {
    457494      map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
     
    472509        geometry2=createGeometryFromGML(conf,tmp->value);
    473510    }
    474     if(geometry2==NULL){
    475       setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity2.");
    476       fprintf(stderr,"SERVICE FAILED !\n");
    477       return SERVICE_FAILED;
    478     }
    479     res=OGR_G_Distance(geometry1,geometry2);   
     511    res=OGR_G_Distance(geometry1,geometry2);
     512    outputs=(maps*)malloc(sizeof(maps*));
     513    outputs->name="Distance";
    480514    char tmpres[100];
    481515    sprintf(tmpres,"%d",res);
    482     setMapInMaps(outputs,"Distance","value",tmpres);
    483     setMapInMaps(outputs,"Distance","dataType","float");
     516    outputs->content=createMap("value",tmpres);
     517    addMapToMap(&outputs->content,createMap("datatype","float"));
     518    outputs->next=NULL;
    484519#ifdef DEBUG
    485520    dumpMaps(outputs);
     
    496531    double res;
    497532    /**
    498      * Extract Geometry from the InputPolygon value
     533     * Extract Geometry from the InputEntity1 value
    499534     */
    500     OGRGeometryH geometry;
    501     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
    502     if(tmp==NULL){
    503       setMapInMaps(conf,"lenv","message","Unable to parse input geometry from InputPolygon");
    504       return SERVICE_FAILED;
    505     }
     535    OGRGeometryH geometry1;
     536    map* tmp=getMapFromMaps(inputs,"InputEntity1","value");
    506537    fprintf(stderr,"geometry creation %s \n",tmp->value);
    507     geometry=createGeometryFromGML(conf,tmp->value);
    508     if(geometry==NULL){
    509       setMapInMaps(conf,"lenv","message","Unable to parse input geometry from InputPolygon");
    510       return SERVICE_FAILED;
    511     }
     538    geometry1=createGeometryFromGML(conf,tmp->value);
    512539    fprintf(stderr,"geometry created %s \n",tmp->value);
    513     res=OGR_G_GetArea(geometry);
     540    res=OGR_G_GetArea(geometry1);
    514541    fprintf(stderr,"area %d \n",res);
    515542    /**
    516      * Filling the outputs
     543     * Creating the outputs
    517544     */
     545    outputs=(maps*)malloc(sizeof(maps*));
     546    outputs->name="Area";
    518547    char tmp1[100];
    519548    sprintf(tmp1,"%d",res);
    520     setMapInMaps(outputs,"Area","value",tmp1);
    521     setMapInMaps(outputs,"Area","dataType","float");
     549    outputs->content=createMap("value",tmp1);
     550    addMapToMap(&outputs->content,createMap("datatype","float"));
     551    outputs->next=NULL;
    522552#ifdef DEBUG
    523553    dumpMaps(outputs);
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