Changeset 216


Ignore:
Timestamp:
May 31, 2011, 3:13:53 AM (13 years ago)
Author:
djay
Message:

Add WIN32 platform support. Fix for values containing @ passed as KVP.

Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/thirds/cgic206/cgic.c

    r98 r216  
    6868char *cgiUserAgent;
    6969char *cgiReferrer;
     70char *cgiSid;
    7071
    7172FILE *cgiIn;
     
    143144        cgiGetenv(&cgiScriptName, "SCRIPT_NAME");
    144145        cgiGetenv(&cgiQueryString, "QUERY_STRING");
     146        cgiSid=NULL;
    145147        if(strcmp(cgiQueryString,"")==0 && argc>=2){
    146148                cgiQueryString=argv[1];
     149                if(argc>2){
     150                  cgiSid=argv[2];
     151                }
    147152        }
    148153        cgiGetenv(&cgiRemoteHost, "REMOTE_HOST");
  • trunk/thirds/cgic206/cgic.h

    r98 r216  
    124124#endif
    125125char *cgiCookie;
     126
     127extern
     128#ifdef __cplusplus
     129"C"
     130#endif
     131char *cgiSid;
    126132
    127133/* A macro providing the same incorrect spelling that is
  • trunk/thirds/cgic206/makefile.vc

    r1 r216  
    99        -I $(GEODIR)/include
    1010
    11 all: libcgic.lib cgictest.exe capture.exe
     11all: libcgic.lib #cgictest.exe capture.exe
    1212
    1313install: libcgic.lib
     
    2424
    2525cgictest.exe: cgictest.obj
    26         link cgictest.obj $(LIBS1) /out:cgictest.exe
     26        link cgictest.obj $(LIBS) /out:cgictest.exe
    2727
    2828cgic.obj:
     
    3030
    3131capture.exe: capture.obj libcgic.lib
    32         $(CC) $(CFLAGS) capture.c $(LIBS1)
     32        $(CC) $(CFLAGS) capture.c $(LIBS)
    3333
    3434clean:
  • trunk/zoo-kernel/main_conf_read.y

    r114 r216  
    335335
    336336  fclose(crin);
     337#ifndef WIN32
    337338  crlex_destroy();
     339#endif
    338340
    339341  return resultatYYParse;
  • trunk/zoo-kernel/makefile.vc

    r1 r216  
    1 GEODIR=c:/OSGeo4W
    2 DESTDIR=c:/OSGeo4W
    3 TPATH=..\..\..\tools
    4 TOOLS=$(TPATH)\bin
    5 CFLAGS=/EHa /nologo /MT /W3 /GX /O2 /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I./ -I..\thirds\dirent-win32 -IC:\OSGeo4W\apps\Python25\include -I$(GEODIR)/include -I$(TPATH)\include -DLINUX_FREE_ISSUE #-DDEBUG
    6 CC=cl $(CFLAGS)
    7 CPP=cl /TP $(CFLAGS)
     1# WIN32 Makefile tested using VC-9.0
     2# Don't forget to set your PATH using the following command :
     3# c:\Progam Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat
     4# set PATH=%PATH%;$(TOOLS)
     5# using value for TOOLS relative to your local installation
     6#
    87
    9 all:  service_loader
     8!INCLUDE nmake.opt
    109
    11 service_loader: service.h lex.sr.obj service_conf.tab.obj service_conf.y service_internal_python.obj service_loader.obj main_conf_read.tab.obj lex.cr.obj service_internal.obj
    12         cl $(CFLAGS) lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj lex.cr.obj service_internal.obj service_internal_python.obj service_loader.obj -o service_loader -ldl `python-config --libs` `xml2-config --libs` -lfl -lcurl
     10all:  zoo_loader.cgi
    1311
    1412main_conf_read.tab.c: main_conf_read.y service.h
     
    5452        $(CPP) /EHsc /c $(CFLAGS) zoo_loader.c
    5553
     54dirent.obj:
     55        $(CPP) /EHsc /c $(CFLAGS) ..\thirds\dirent-win32\dirent.c
     56
    5657zoo_loader.cgi: zoo_loader.obj zoo_service_loader.obj service_internal.obj service_internal_python.obj ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj dirent.obj
    57         link zoo_loader.obj dirent.obj service_internal.obj service_internal_python.obj ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj  zoo_service_loader.obj /out:zoo_loader.cgi  $(GEODIR)/lib/libfcgi.lib $(GEODIR)/lib/libcurl_imp.lib  $(GEODIR)/apps/Python25/libs/python25.lib $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/libcgic.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)\..\lib\libeay32.dll.a $(TOOLS)\..\lib\libcrypto.a $(TOOLS)\..\lib\libssl32.dll.a /machine:i386
     58        link zoo_loader.obj dirent.obj service_internal.obj service_internal_python.obj ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj  zoo_service_loader.obj /out:zoo_loader.cgi $(LDFLAGS)
    5859
    5960clean:
    60         erase -f *.obj *.tab.c* *.tab.h *.sr.c* lex.* *.lreg *.sibling
     61        erase -f *.cgi *.obj *.tab.c* *.tab.h *.sr.c* lex.* *.lreg *.sibling
  • trunk/zoo-kernel/service.h

    r114 r216  
    2828#pragma once
    2929
     30#ifdef WIN32
     31#define strncasecmp strnicmp
     32#define strcasecmp stricmp
     33#define snprintf sprintf_s
     34#endif
     35
    3036#ifdef __cplusplus
    3137extern "C" {
     
    193199  }
    194200
     201  static map* getLastMap(map* m){
     202    map* tmp=m;
     203    while(tmp!=NULL){
     204      if(tmp->next==NULL){
     205        return tmp;
     206      }
     207      tmp=tmp->next;
     208    }
     209    return NULL;
     210  }
     211
    195212  static map* getMapFromMaps(maps* m,const char* key,const char* subkey){
    196213    maps* _tmpm=getMaps(m,key);
     
    201218    else return NULL;
    202219  }
     220
     221  static char* getMapsAsKVP(maps* m,int length,int type){
     222    char *dataInputsKVP=(char*) malloc(length*sizeof(char));
     223    maps* curs=m;
     224    int i=0;
     225    while(curs!=NULL){
     226      if(i==0)
     227        if(type==0)
     228          sprintf(dataInputsKVP,"%s=",curs->name);
     229        else
     230          sprintf(dataInputsKVP,"%s",curs->name);
     231      else{
     232        char *temp=strdup(dataInputsKVP);
     233        if(type==0)
     234          sprintf(dataInputsKVP,"%s;%s=",temp,curs->name);
     235        else
     236          sprintf(dataInputsKVP,"%s;%s",temp,curs->name);
     237        free(temp);
     238      }
     239      map* icurs=curs->content;
     240      if(type==0){
     241        map* tmp=getMap(curs->content,"value");
     242        char *temp=strdup(dataInputsKVP);
     243        if(getMap(m->content,"xlink:href")!=NULL)
     244          sprintf(dataInputsKVP,"%sReference",temp);
     245        else
     246          sprintf(dataInputsKVP,"%s%s",temp,icurs->value);
     247        free(temp);
     248      }
     249      int j=0;
     250      while(icurs!=NULL){
     251        if(strcasecmp(icurs->name,"value")!=0 &&
     252           strcasecmp(icurs->name,"Reference")!=0 &&
     253           strcasecmp(icurs->name,"minOccurs")!=0 &&
     254           strcasecmp(icurs->name,"maxOccurs")!=0 &&
     255           strcasecmp(icurs->name,"inRequest")!=0){
     256          char *itemp=strdup(dataInputsKVP);
     257          sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value);
     258          free(itemp);
     259        }
     260        icurs=icurs->next;
     261      }
     262      curs=curs->next;
     263      i++;
     264    }
     265    return dataInputsKVP;
     266  }
     267
    203268
    204269  static void freeMap(map** mo){
     
    516581      map* _ztmpm=getMap(_tmpm->content,subkey);
    517582      if(_ztmpm!=NULL){
    518         free(_ztmpm->value);
     583        if(_ztmpm->value!=NULL)
     584          free(_ztmpm->value);
    519585        _ztmpm->value=strdup(value);
    520586      }else{
  • trunk/zoo-kernel/service_conf.y

    r114 r216  
    801801  *service=my_service;
    802802
     803#ifndef WIN32
    803804  srlex_destroy();
     805#endif
    804806  return resultatYYParse;
    805807}
  • trunk/zoo-kernel/service_internal.c

    r114 r216  
    2525#include "service_internal.h"
    2626
    27 void *addLangAttr(xmlNodePtr n,maps *m){
     27#ifdef WIN32
     28char *
     29strtok_r (char *s1, const char *s2, char **lasts)
     30{
     31  char *ret;
     32  if (s1 == NULL)
     33    s1 = *lasts;
     34  while (*s1 && strchr(s2, *s1))
     35    ++s1;
     36  if (*s1 == '\0')
     37    return NULL;
     38  ret = s1;
     39  while (*s1 && !strchr(s2, *s1))
     40    ++s1;
     41  if (*s1)
     42    *s1++ = '\0';
     43  *lasts = s1;
     44  return ret;
     45}
     46#endif
     47
     48void addLangAttr(xmlNodePtr n,maps *m){
    2849  map *tmpLmap=getMapFromMaps(m,"main","language");
    2950  if(tmpLmap!=NULL)
     
    4465}
    4566
    46 void* unhandleStatus(maps *conf){
     67#ifdef WIN32
     68
     69#include <windows.h>
     70#include <stdio.h>
     71#include <conio.h>
     72#include <tchar.h>
     73
     74#define SHMEMSIZE 4096
     75
     76static LPVOID lpvMemG = NULL;      // pointer to shared memory
     77static HANDLE hMapObjectG = NULL;  // handle to file mapping
     78
     79void updateStatus(maps *conf){
     80        fprintf(stderr,"OK Final 1 \n");
     81        fflush(stderr);
     82        LPWSTR lpszTmp;
     83        BOOL fInit;
     84        char *s=NULL;
     85        map *tmpMap=getMapFromMaps(conf,"lenv","sid");
     86        fprintf(stderr,"OK Final 11 \n");
     87        fflush(stderr);
     88        if(hMapObjectG==NULL)
     89        hMapObjectG = CreateFileMapping(
     90                INVALID_HANDLE_VALUE,   // use paging file
     91                NULL,                   // default security attributes
     92                PAGE_READWRITE,         // read/write access
     93                0,                      // size: high 32-bits
     94                SHMEMSIZE,              // size: low 32-bits
     95                TEXT(tmpMap->value));   // name of map object
     96        if (hMapObjectG == NULL){
     97                fprintf(stderr,"Unable to create share memory segment %s !! \n",tmpMap->value);
     98                return ;
     99        }
     100        fprintf(stderr,"OK Final 2 \n");
     101        fflush(stderr);
     102        fInit = (GetLastError() != ERROR_ALREADY_EXISTS);
     103        if(lpvMemG==NULL)
     104        lpvMemG = MapViewOfFile(
     105                hMapObjectG,     // object to map view of
     106                FILE_MAP_WRITE, // read/write access
     107                0,              // high offset:  map from
     108                0,              // low offset:   beginning
     109                0);             // default: map entire file
     110        if (lpvMemG == NULL){
     111                fprintf(stderr,"Unable to create or access the shared memory segment %s !! \n",tmpMap->value);
     112                return ;
     113        }
     114        fprintf(stderr,"OK Final 3 \n");
     115        fflush(stderr);
     116        if (fInit)
     117                memset(lpvMemG, '\0', SHMEMSIZE);
     118        fprintf(stderr,"OK Final 4 \n");
     119        fflush(stderr);
     120        tmpMap=getMapFromMaps(conf,"lenv","status");
     121        lpszTmp = (LPWSTR) lpvMemG;
     122        for(s=tmpMap->value;*s!=NULL;s++)
     123                *lpszTmp++ = *s;
     124        *lpszTmp = '\0';
     125}
     126
     127char* getStatus(int pid){
     128  LPWSTR lpszBuf=NULL;
     129  LPWSTR lpszTmp=NULL;
     130  LPVOID lpvMem = NULL;
     131  HANDLE hMapObject = NULL;
     132  BOOL fIgnore,fInit;
     133  char tmp[100];
     134  sprintf(tmp,"%i",pid);
     135  if(hMapObject==NULL)
     136    hMapObject = CreateFileMapping(
     137                                   INVALID_HANDLE_VALUE,   // use paging file
     138                                   NULL,                   // default security attributes
     139                                   PAGE_READWRITE,         // read/write access
     140                                   0,                      // size: high 32-bits
     141                                   4096,                   // size: low 32-bits
     142                                   TEXT(tmp));   // name of map object
     143  if (hMapObject == NULL)
     144    return FALSE;
     145  if((GetLastError() != ERROR_ALREADY_EXISTS)){
     146    fIgnore = UnmapViewOfFile(lpvMem);
     147    fIgnore = CloseHandle(hMapObject);
     148    return "-1";
     149  }
     150  fInit=TRUE;
     151  if(lpvMem==NULL)
     152    lpvMem = MapViewOfFile(
     153                           hMapObject,     // object to map view of
     154                           FILE_MAP_READ,  // read/write access
     155                           0,              // high offset:  map from
     156                           0,              // low offset:   beginning
     157                           0);             // default: map entire file
     158  if (lpvMem == NULL)
     159    return "-1";
     160  lpszTmp = (LPWSTR) lpvMem;
     161  while (*lpszTmp!=NULL)
     162    *lpszBuf++ = *lpszTmp++;
     163  *lpszBuf = '\0';
     164  fIgnore = UnmapViewOfFile(lpvMem);
     165  fIgnore = CloseHandle(hMapObject);
     166  return (char*)lpszBuf;
     167}
     168
     169void unhandleStatus(maps *conf){
     170  BOOL fIgnore;
     171  fIgnore = UnmapViewOfFile(lpvMemG);
     172  fIgnore = CloseHandle(hMapObjectG);
     173}
     174#else
     175void unhandleStatus(maps *conf){
    47176  int shmid,i;
    48177  key_t key;
     
    69198  }
    70199}
     200
     201void updateStatus(maps *conf){
     202  int shmid,i;
     203  key_t key;
     204  char *shm,*s,*s1;
     205  map *tmpMap=NULL;
     206  tmpMap=getMapFromMaps(conf,"lenv","sid");
     207  if(tmpMap!=NULL){
     208    key=atoi(tmpMap->value);
     209    if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
     210#ifdef DEBUG
     211      fprintf(stderr,"shmget failed to update value\n");
     212#endif
     213    }else{
     214      if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {
     215#ifdef DEBUG
     216        fprintf(stderr,"shmat failed to update value\n");
     217#endif
     218      }
     219      else{
     220        tmpMap=getMapFromMaps(conf,"lenv","status");
     221        s1=shm;
     222        for(s=tmpMap->value;s!=NULL;s++)
     223          *s1++=*s;
     224        shmdt((void *)shm);
     225      }
     226    }
     227  }
     228}
     229
     230char* getStatus(int pid){
     231  int shmid,i;
     232  key_t key;
     233  void *shm;
     234  char *s;
     235  key=pid;
     236  if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
     237#ifdef DEBUG
     238    fprintf(stderr,"shmget failed in getStatus\n");
     239#endif
     240  }else{
     241    if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
     242#ifdef DEBUG
     243      fprintf(stderr,"shmat failed in getStatus\n");
     244#endif
     245    }else{
     246      return (char*)shm;
     247    }
     248  }
     249  return "-1";
     250}
     251
     252#endif
    71253
    72254#ifdef USE_JS
     
    109291#endif
    110292
    111 void* updateStatus(maps *conf){
    112   int shmid,i;
    113   key_t key;
    114   char *shm,*s,*s1;
    115   map *tmpMap=NULL;
    116   tmpMap=getMapFromMaps(conf,"lenv","sid");
    117   if(tmpMap!=NULL){
    118     key=atoi(tmpMap->value);
    119     if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
    120 #ifdef DEBUG
    121       fprintf(stderr,"shmget failed to update value\n");
    122 #endif
    123     }else{
    124       if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {
    125 #ifdef DEBUG
    126         fprintf(stderr,"shmat failed to update value\n");
    127 #endif
    128       }
    129       else{
    130         tmpMap=getMapFromMaps(conf,"lenv","status");
    131         s1=shm;
    132         for(s=tmpMap->value;s!=NULL;s++)
    133           *s1++=*s;
    134         shmdt((void *)shm);
    135       }
    136     }
    137   }
    138 }
    139 
    140 char* getStatus(int pid){
    141   int shmid,i;
    142   key_t key;
    143   void *shm;
    144   char *s;
    145   key=pid;
    146   if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
    147 #ifdef DEBUG
    148     fprintf(stderr,"shmget failed in getStatus\n");
    149 #endif
    150   }else{
    151     if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
    152 #ifdef DEBUG
    153       fprintf(stderr,"shmat failed in getStatus\n");
    154 #endif
    155     }else{
    156       return (char*)shm;
    157     }
    158   }
    159   return "-1";
    160 }
    161293
    162294
     
    11921324    int buffersize;
    11931325    xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "UTF-8", 1);
    1194     fwrite(xmlbuff,1,strlen(xmlbuff)*sizeof(char),output);
     1326    fwrite(xmlbuff,1,xmlStrlen(xmlbuff)*sizeof(char),output);
    11951327    xmlFree(xmlbuff);
    11961328    fclose(output);
     
    12041336
    12051337void printDocument(maps* m, xmlDocPtr doc,int pid){
    1206   rewind(stdout);
    12071338  char *encoding=getEncoding(m);
    12081339  if(pid==getpid()){
     
    12181349  xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1);
    12191350  printf("%s",xmlbuff);
    1220   //fflush(stdout);
     1351  fflush(stdout);
    12211352  /*
    12221353   * Free associated memory.
     
    15271658  maps* tmpMap=getMaps(m,"main");
    15281659
    1529   int nsid=zooXmlAddNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
     1660  int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows");
    15301661  ns=usedNs[nsid];
    15311662  n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
     
    17571888}
    17581889
    1759 char *base64(const unsigned char *input, int length)
     1890char *base64(const char *input, int length)
    17601891{
    17611892  BIO *bmem, *b64;
     
    17791910}
    17801911
    1781 char *base64d(unsigned char *input, int length,int* red)
     1912char *base64d(const char *input, int length,int* red)
    17821913{
    17831914  BIO *b64, *bmem;
     
    17881919    b64 = BIO_new(BIO_f_base64());
    17891920    if(b64){
    1790       bmem = BIO_new_mem_buf(input,length);
     1921      bmem = BIO_new_mem_buf((unsigned char*)input,length);
    17911922      bmem = BIO_push(b64, bmem);
    17921923      *red=BIO_read(bmem, buffer, length);
     
    20782209  ns_ows=usedNs[owsId];
    20792210  n = xmlNewNode(ns_ows, BAD_CAST "BoundingBox");
    2080   xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1","ows");
     2211  xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
    20812212  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
    20822213  ns_xsi=usedNs[xsiId];
  • trunk/zoo-kernel/service_internal.h

    r114 r216  
    3838#include <sys/stat.h>
    3939#include <sys/types.h>
     40#ifndef WIN32
    4041#include <sys/ipc.h>
    4142#include <sys/shm.h>
     43#else
     44#include <direct.h>
     45#endif
    4246#include <stdio.h>
    4347#include <unistd.h>
     
    7175  static int nbNs=0;
    7276
    73   void* unhandleStatus(maps*);
    74   void* updateStatus(maps*);
     77  void unhandleStatus(maps*);
     78  void updateStatus(maps*);
    7579  char* getStatus(int);
    7680
     
    106110  void outputResponse(service*,maps*,maps*,map*,int,maps*,int);
    107111
    108   char *base64(const unsigned char*,int);
    109   char *base64d(unsigned char*,int,int*);
     112  char *base64(const char*,int);
     113  char *base64d(const char*,int,int*);
    110114  void ensureDecodedBase64(maps**);
    111115
  • trunk/zoo-kernel/zoo_loader.c

    r114 r216  
    2626#define MALLOC_CHECK 0
    2727
     28#ifdef WIN32
     29#include "windows.h"
     30#endif
    2831/**
    2932 * Specific includes
     
    6467/* ************************************************************************* */
    6568
    66 #ifndef STRTOK_R
    67 char *
    68 strtok_r (char *s1, const char *s2, char **lasts)
    69 {
    70   char *ret;
    71 
    72   if (s1 == NULL)
    73     s1 = *lasts;
    74   while (*s1 && strchr(s2, *s1))
    75     ++s1;
    76   if (*s1 == '\0')
    77     return NULL;
    78   ret = s1;
    79   while (*s1 && !strchr(s2, *s1))
    80     ++s1;
    81   if (*s1)
    82     *s1++ = '\0';
    83   *lasts = s1;
    84   return ret;
    85 }
    86 
    87 #endif
    8869
    8970#define TRUE 1
  • trunk/zoo-kernel/zoo_service_loader.c

    r214 r216  
    203203#endif
    204204      if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
    205 #ifdef WIN32
    206         //Strange return value needed here !
    207         return 1;
    208 #endif
    209205        r_inputs=getMap(request_inputs,"Identifier");
    210206        char fname[1024];
     
    284280#endif
    285281      }
     282#ifdef WIN32
     283      *ioutputs=dupMaps(&request_output_real_format);
     284      FreeLibrary(so);
     285#else
    286286      dlclose(so);
     287#endif
    287288    } else {
    288289      /**
     
    345346              }
    346347  *myMap=m;
     348#ifndef WIN32
    347349  *ioutputs=request_output_real_format;
     350#endif
    348351}
     352
     353#ifdef WIN32
     354/**
     355 * createProcess function: create a new process after setting some env variables
     356 */
     357void createProcess(maps* m,map* request_inputs,service* s1,char* opts,int cpid, maps* inputs,maps* outputs){
     358  STARTUPINFO si;
     359  PROCESS_INFORMATION pi;
     360  ZeroMemory( &si, sizeof(si) );
     361  si.cb = sizeof(si);
     362  ZeroMemory( &pi, sizeof(pi) );
     363  char *tmp=(char *)malloc((1024+cgiContentLength)*sizeof(char));
     364  char *tmpq=(char *)malloc((1024+cgiContentLength)*sizeof(char));
     365  map *req=getMap(request_inputs,"request");
     366  map *id=getMap(request_inputs,"identifier");
     367  map *di=getMap(request_inputs,"DataInputs");
     368
     369  char *dataInputsKVP=getMapsAsKVP(inputs,cgiContentLength,0);
     370  char *dataOutputsKVP=getMapsAsKVP(outputs,cgiContentLength,1);
     371  fprintf(stderr,"DATAINPUTSKVP %s\n",dataInputsKVP);
     372  fprintf(stderr,"DATAOUTPUTSKVP %s\n",dataOutputsKVP);
     373  map *sid=getMapFromMaps(m,"lenv","sid");
     374  map* r_inputs=getMapFromMaps(m,"main","tmpPath");
     375  map* r_inputs1=getMap(s1->content,"ServiceProvider");
     376  map* r_inputs2=getMap(s1->content,"ResponseDocument");
     377  if(r_inputs2==NULL)
     378    r_inputs2=getMap(s1->content,"RawDataOutput");
     379  map *tmpPath=getMapFromMaps(m,"lenv","cwd");
     380
     381  if(r_inputs2!=NULL){
     382    sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value);
     383        sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP);
     384  }
     385  else{
     386    sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,sid->value);
     387    sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",req->value,id->value,dataInputsKVP,sid->value);
     388  }
     389
     390  char *tmp1=strdup(tmp);
     391  sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value);
     392
     393  free(dataInputsKVP);
     394  free(dataOutputsKVP);
     395  fprintf(stderr,"REQUEST IS : %s \n",tmp);
     396  SetEnvironmentVariable("CGISID",TEXT(sid->value));
     397  SetEnvironmentVariable("QUERY_STRING",TEXT(tmpq));
     398  char clen[1000];
     399  sprintf(clen,"%d",strlen(tmpq));
     400  SetEnvironmentVariable("CONTENT_LENGTH",TEXT(clen));
     401
     402  if( !CreateProcess( NULL,             // No module name (use command line)
     403                      TEXT(tmp),        // Command line
     404                      NULL,             // Process handle not inheritable
     405                      NULL,             // Thread handle not inheritable
     406                      FALSE,            // Set handle inheritance to FALSE
     407                      CREATE_NO_WINDOW, // Apache won't wait until the end
     408                      NULL,             // Use parent's environment block
     409                      NULL,             // Use parent's starting directory
     410                      &si,              // Pointer to STARTUPINFO struct
     411                      &pi )             // Pointer to PROCESS_INFORMATION struct
     412      )
     413    {
     414      fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() );
     415      return ;
     416    }else{
     417    fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() );
     418  }
     419  CloseHandle( pi.hProcess );
     420  CloseHandle( pi.hThread );
     421  fprintf(stderr,"CreateProcess finished !\n");
     422}
     423#endif
    349424
    350425int runRequest(map* request_inputs)
     
    671746#endif
    672747  int saved_stdout = dup(fileno(stdout));
    673   dup2(fileno(stderr),fileno(stdout));
     748    dup2(fileno(stderr),fileno(stdout));
    674749  t=getServiceFromFile(tmps1,&s1);
    675750  fflush(stdout);
    676751  dup2(saved_stdout,fileno(stdout));
    677752  if(t<0){
    678     char tmpMsg[2048+strlen(r_inputs->value)];
     753    char *tmpMsg=(char*)malloc(2048+strlen(r_inputs->value));
     754   
    679755    sprintf(tmpMsg,_("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),r_inputs->value);
    680756    errorException(m, tmpMsg, "InvalidParameterValue");
     757    free(tmpMsg);
    681758    freeService(&s1);
    682759    free(s1);
     
    687764    return 0;
    688765  }
    689   close(saved_stdout);
     766  //close(saved_stdout);
    690767
    691768#ifdef DEBUG
     
    887964        char tmpn[256];
    888965        memset(tmpn,0,256);
    889         strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
    890         tmpn[strlen(tmpc)-strlen(tmpv)]=0;
     966        if(tmpv!=NULL){
     967          strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
     968          tmpn[strlen(tmpc)-strlen(tmpv)]=0;
     969        }
     970        else{
     971          strncpy(tmpn,tmpc,strlen(tmpc)*sizeof(char));
     972          tmpn[strlen(tmpc)]=0;
     973        }
    891974#ifdef DEBUG
    892975        fprintf(stderr,"***\n*** %s = %s ***\n",tmpn,tmpv+1);
     
    898981          }
    899982          tmpmaps->name=strdup(tmpn);
    900           tmpmaps->content=createMap("value",tmpv+1);
     983          if(tmpv!=NULL)
     984            tmpmaps->content=createMap("value",tmpv+1);
     985          else
     986            tmpmaps->content=createMap("value","Reference");
    901987          tmpmaps->next=NULL;
    902988        }
     
    912998          char tmpn1[1024];
    913999          memset(tmpn1,0,1024);
    914           strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1));
    915           tmpn1[strlen(tmpc)-strlen(tmpv1)]=0;
     1000          if(tmpv1!=NULL){
     1001            strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1));
     1002            tmpn1[strlen(tmpc)-strlen(tmpv1)]=0;
     1003            addToMap(tmpmaps->content,tmpn1,tmpv1+1);
     1004          }
     1005          else{
     1006            strncpy(tmpn1,tmpc,strlen(tmpc));
     1007            tmpn1[strlen(tmpc)]=0;
     1008            map* lmap=getLastMap(tmpmaps->content);
     1009            char *tmpValue=(char*)calloc((strlen(lmap->value)+strlen(tmpc)+1),sizeof(char));
     1010            sprintf(tmpValue,"%s@%s",lmap->value,tmpc);
     1011            free(lmap->value);
     1012            lmap->value=strdup(tmpValue);
     1013            free(tmpValue);
     1014            dumpMap(tmpmaps->content);
     1015            tmpc=strtok(NULL,"@");
     1016            continue;
     1017          }
    9161018#ifdef DEBUG
    9171019          fprintf(stderr,"*** NAME NON URL-ENCODED \n***%s***\n",tmpn1);
     
    9201022          if(strcmp(tmpn1,"xlink:href")!=0)
    9211023            addToMap(tmpmaps->content,tmpn1,tmpv1+1);
    922           else{
    923             if(strncasecmp(tmpv1+1,"http://",7)!=0 &&
    924                strncasecmp(tmpv1+1,"ftp://",6)!=0){
    925               char emsg[1024];
    926               sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1);
    927               errorException(m,emsg,"InternalError");
    928               freeMaps(&m);
    929               free(m);
    930               free(REQUEST);
    931               free(SERVICE_URL);
    932               InternetCloseHandle(hInternet);
    933               freeService(&s1);
    934               free(s1);
    935               return 0;
     1024          else
     1025            if(tmpv1!=NULL){
     1026              if(strncasecmp(tmpv1+1,"http://",7)!=0 &&
     1027                 strncasecmp(tmpv1+1,"ftp://",6)!=0){
     1028                char emsg[1024];
     1029                sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1);
     1030                errorException(m,emsg,"InternalError");
     1031                freeMaps(&m);
     1032                free(m);
     1033                free(REQUEST);
     1034                free(SERVICE_URL);
     1035                InternetCloseHandle(hInternet);
     1036                freeService(&s1);
     1037                free(s1);
     1038                return 0;
     1039              }
     1040#ifdef DEBUG
     1041              fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
     1042#endif
     1043#ifndef WIN32
     1044              if(CHECK_INET_HANDLE(hInternet))
     1045#endif
     1046                {
     1047                  res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
     1048                                      INTERNET_FLAG_NO_CACHE_WRITE,0);
     1049#ifdef DEBUG
     1050                  fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
     1051                          tmpv1+1,res.nDataAlloc,res.nDataLen);
     1052#endif
     1053                  char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
     1054                  if(tmpContent == NULL){
     1055                    return errorException(m, _("Unable to allocate memory."), "InternalError");
     1056                  }
     1057                  size_t dwRead;
     1058                  InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
     1059                  map* tmpMap=getMap(tmpmaps->content,"value");
     1060                  if(tmpMap!=NULL){
     1061                    free(tmpMap->value);
     1062                    tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));
     1063                    memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));
     1064                    tmpMap->value[res.nDataLen]=0;
     1065                    if(strlen(tmpContent)!=res.nDataLen){
     1066                      char tmp[256];
     1067                      sprintf(tmp,"%d",res.nDataLen*sizeof(char));
     1068                      addToMap(tmpmaps->content,"size",tmp);
     1069                    }
     1070                  }
     1071                  free(tmpContent);
     1072                }
     1073              char *tmpx=url_encode(tmpv1+1);
     1074              addToMap(tmpmaps->content,tmpn1,tmpx);
     1075              free(tmpx);
     1076              addToMap(tmpmaps->content,"Reference",tmpv1+1);
     1077              dumpMap(tmpmaps->content);
    9361078            }
    937 #ifdef DEBUG
    938             fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
    939 #endif
    940 #ifndef WIN32
    941             if(CHECK_INET_HANDLE(hInternet))
    942 #endif
    943               {
    944                 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
    945                                     INTERNET_FLAG_NO_CACHE_WRITE,0);
    946 #ifdef DEBUG
    947                 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
    948                         tmpv1+1,res.nDataAlloc,res.nDataLen);
    949 #endif
    950                 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
    951                 if(tmpContent == NULL){
    952                   return errorException(m, _("Unable to allocate memory."), "InternalError");
    953                 }
    954                 size_t dwRead;
    955                 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
    956                 map* tmpMap=getMap(tmpmaps->content,"value");
    957                 if(tmpMap!=NULL){
    958                   free(tmpMap->value);
    959                   tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));
    960                   memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));
    961                   tmpMap->value[res.nDataLen]=0;
    962                   if(strlen(tmpContent)!=res.nDataLen){
    963                     char tmp[256];
    964                     sprintf(tmp,"%d",res.nDataLen*sizeof(char));
    965                     addToMap(tmpmaps->content,"size",tmp);
    966                   }
    967                 }
    968                 free(tmpContent);
    969               }
    970             addToMap(tmpmaps->content,tmpn1,tmpv1+1);
    971             addToMap(tmpmaps->content,"Reference",tmpv1+1);
    972           }
    9731079          tmpc=strtok(NULL,"@");
    9741080        }
     
    11321238            hInternet.header=NULL;
    11331239            while(cur3){
     1240              while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE)
     1241                cur2=cur3->next;
    11341242              if(xmlStrcasecmp(cur3->name,BAD_CAST "Header")==0 ){
    11351243                const char *ha[2];
     
    16971805  _tmpMaps->next=NULL;
    16981806  addToMap(_tmpMaps->content,"status","0");
     1807  addToMap(_tmpMaps->content,"cwd",ntmp);
    16991808  if(cgiCookie!=NULL && strlen(cgiCookie)>0){
    17001809    addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1);
     
    17221831  dumpMap(request_inputs);
    17231832#endif
    1724 
     1833#ifdef WIN32
     1834  char *cgiSidL=NULL;
     1835  if(getenv("CGISID")!=NULL)
     1836        addToMap(request_inputs,"cgiSid",getenv("CGISID"));
     1837  map* test1=getMap(request_inputs,"cgiSid");
     1838  if(test1!=NULL){
     1839    cgiSid=test1->value;
     1840  }
     1841  if(cgiSid!=NULL){
     1842    addToMap(request_inputs,"storeExecuteResponse","true");
     1843    addToMap(request_inputs,"status","true");
     1844    status=getMap(request_inputs,"status");
     1845    dumpMap(request_inputs);
     1846    fprintf(stderr,"cgiSID : %s",cgiSid);
     1847  }
     1848#endif
    17251849  if(status!=NULL)
    17261850    if(strcasecmp(status->value,"false")==0)
     
    17381862    pid = fork ();
    17391863#else
    1740     pid = 0;
     1864    if(cgiSid==NULL){
     1865      addToMap(request_inputs,"cgSid",cgiSid);
     1866      createProcess(m,request_inputs,s1,NULL,cpid,request_input_real_format,request_output_real_format);
     1867      pid = cpid;
     1868    }else{
     1869      pid=0;
     1870      cpid=atoi(cgiSid);
     1871    }
     1872    fflush(stderr);
    17411873#endif
    17421874    if (pid > 0) {
     
    17651897      fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value);
    17661898#endif
     1899      freopen(flog,"w+",stderr);
    17671900      freopen(fbkp , "w+", stdout);
    17681901      fclose(stdin);
    1769       freopen(flog,"w+",stderr);
    17701902      free(fbkp);
    17711903      free(flog);
     
    17781910      updateStatus(m);
    17791911      printProcessResponse(m,request_inputs,cpid,
    1780                             s1,r_inputs1->value,SERVICE_STARTED,
    1781                             request_input_real_format,
    1782                             request_output_real_format);
     1912                           s1,r_inputs1->value,SERVICE_STARTED,
     1913                           request_input_real_format,
     1914                           request_output_real_format);
     1915#ifndef WIN32
    17831916      fflush(stdout);
    17841917      rewind(stdout);
     1918#endif
    17851919
    17861920      loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
     
    17981932#ifdef DEBUG
    17991933  dumpMaps(request_output_real_format);
    1800   fprintf(stderr,"Function loaded and returned %d\n",eres);
     1934  fprintf(stderr,"Function loaded and returned %d\n",*eres);
    18011935  fflush(stderr);
    18021936#endif
     
    18051939                   request_output_real_format,request_inputs,
    18061940                   cpid,m,eres);
     1941  fflush(stdout);
    18071942  /**
    18081943   * Ensure that if error occurs when freeing memory, no signal will return
  • trunk/zoo-services/arithmetics/cgi-env/Multiply.zcfg

    r106 r216  
    55 storeSupported = true
    66 statusSupported = true
    7  serviceProvider = demo_service.zo
     7 serviceProvider = test_service.zo
    88 serviceType = C
    99 <MetaData>
  • trunk/zoo-services/arithmetics/makefile.vc

    r1 r216  
    11GEODIR=c:/OSGeo4W/
    22TOOLS=c:/Users/djay/GeoLabs/tools/
    3 CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG
     3CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG -DWIN32
    44CPP=cl /TP
    55
    6 cgi-env/service.zo: service.c
    7         $(CPP) $(CFLAGS) /c service.c
    8         link /dll /out:cgi-env/ogr_service.zso ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a
     6cgi-env/test_service.zo: test_service.c
     7        $(CPP) $(CFLAGS) /c test_service.c
     8        link /dll /out:cgi-env/test_service.zo ../../zoo-kernel/service_internal.obj ./test_service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a $(TOOLS)/lib/libintl.lib
    99
    1010clean:
    11         rm -f cgi-env/ogr_service.zso
     11        erase cgi-env\demo_service.*
  • trunk/zoo-services/arithmetics/test_service.c

    r1 r216  
    33extern "C" {
    44
     5#ifdef WIN32
     6__declspec(dllexport)
     7#endif
    58  int Multiply(maps*& conf,maps*& inputs,maps*& outputs){
    69        fprintf(stderr,"\nService internal print\n");
  • trunk/zoo-services/ogr/base-vect-ops/makefile.vc

    r1 r216  
    1 GEODIR=c:/OSGeo4W/
    2 TOOLS=c:/Users/djay/GeoLabs/tools/
    3 CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG
     1ZOODIR=../../../zoo-kernel
     2THIRDSDIR=../../../thirds
     3!INCLUDE $(ZOODIR)/nmake.opt
     4CFLAGS=-I$(GEODIR)/include -I$(TPATH)/include -I$(ZOODIR) -I./ -DLINUX_FREE_ISSUE -DWIN32 #-DDEBUG
    45CPP=cl /TP
    56
    6 cgi-env/service.zo: service.c
     7cgi-env/ogr_service.zo: service.c
    78        $(CPP) $(CFLAGS) /c service.c
    8         link /dll /out:cgi-env/ogr_service.zso ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a
     9        link /dll /out:cgi-env/ogr_service.zo ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(GEODIR)/lib/geos_c_i.lib $(TPATH)/lib/libeay32.dll.a $(TPATH)/lib/libcrypto.a $(TPATH)/lib/libssl32.dll.a $(LIBINTL_CPATH)/lib/libintl.lib
    910
    1011clean:
    11         rm -f cgi-env/ogr_service.zso
     12        erase cgi-env\ogr_service.*
  • trunk/zoo-services/ogr/base-vect-ops/service.c

    r55 r216  
    4343
    4444  void printExceptionReportResponse(maps*,map*);
    45   char *base64(const unsigned char *input, int length);
     45  char *base64(const char *input, int length);
    4646
    4747  OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){
     
    5656    xpathObj = xmlXPathEvalExpression(BAD_CAST xpathExpr,xpathCtx);
    5757    if(!xpathObj->nodesetval){
    58       map* tmp=createMap("text","Unable to parse Input Polygon");
    59       addToMap(tmp,"code","InvalidParameterValue");
    60       printExceptionReportResponse(conf,tmp);
    61       exit(0);
     58      setMapInMaps(conf,"lenv","message",_ss("Unable to parse Input Polygon"));
     59      setMapInMaps(conf,"lenv","code","InvalidParameterValue");
     60      return NULL;
    6261    }
    6362    int size = (xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0;
     
    8079    xmlFreeDoc(doc);
    8180    xmlFreeDoc(ndoc);
     81#ifndef WIN32
    8282    xmlCleanupParser();
     83#endif
    8384#ifdef DEBUG
    8485    fprintf(stderr,"\nService internal print\n Loading the geometry from GML string ...");
     
    9495  }
    9596
     97#ifdef WIN32
     98  __declspec(dllexport)
     99#endif
    96100  int Simplify(maps*& conf,maps*& inputs,maps*& outputs){
    97101    maps* cursor=inputs;
     
    104108    else
    105109      tolerance=atof(tmp0->value);
     110#ifdef DEBUG
    106111    fprintf(stderr,"Tolerance for Simplify %f",tolerance);
     112#endif
    107113    map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
    108114    if(!tmp){
     
    126132      return SERVICE_FAILED;
    127133    }
     134#ifdef DEBUG
    128135    fprintf(stderr,"Create GEOSGeometry object");
     136#endif
    129137    GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS();
    130138    GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance);
    131     res=OGRGeometryFactory::createFromGEOS(gres);
     139    res=(OGRGeometryH)OGRGeometryFactory::createFromGEOS(gres);
    132140    tmp1=getMapFromMaps(outputs,"Result","mimeType");
    133141    if(tmp1!=NULL){
     
    136144        char *tmpS=OGR_G_ExportToJson(res);
    137145        setMapInMaps(outputs,"Result","value",tmpS);
     146#ifndef WIN32
    138147        setMapInMaps(outputs,"Result","mimeType","text/plain");
    139148        setMapInMaps(outputs,"Result","encoding","UTF-8");
    140149        free(tmpS);
     150#endif
    141151      }
    142152      else{
    143153        char *tmpS=OGR_G_ExportToGML(res);
    144154        setMapInMaps(outputs,"Result","value",tmpS);
     155#ifndef WIN32
    145156        setMapInMaps(outputs,"Result","mimeType","text/xml");
    146157        setMapInMaps(outputs,"Result","encoding","UTF-8");
    147158        setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
    148159        free(tmpS);
     160#endif
    149161      }
    150162    }else{
    151       char *tmpS=OGR_G_ExportToJson(tmp->value);
     163      char *tmpS=OGR_G_ExportToJson(res);
    152164      setMapInMaps(outputs,"Result","value",tmpS);
     165#ifndef WIN32
    153166      setMapInMaps(outputs,"Result","mimeType","text/plain");
    154167      setMapInMaps(outputs,"Result","encoding","UTF-8");
    155168      free(tmpS);
     169#endif
    156170    }
    157171    outputs->next=NULL;
     
    178192      return SERVICE_FAILED;
    179193    }
     194#ifdef DEBUG
    180195    fprintf(stderr,"Service internal print \n");
    181196    dumpMaps(inputs);
    182197    fprintf(stderr,"/Service internal print \n");
     198#endif
    183199    map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
     200#ifdef DEBUG
    184201    fprintf(stderr,"Service internal print \n");
    185202    dumpMap(tmp1);
    186203    fprintf(stderr,"/Service internal print \n");
     204#endif
    187205    if(tmp1!=NULL){
    188206      if(strncmp(tmp1->value,"text/js",7)==0 ||
     
    199217    }
    200218    res=(*myFunc)(geometry);
     219#ifdef DEBUG
    201220    fprintf(stderr,"Service internal print \n");
    202221    dumpMaps(outputs);
    203222    fprintf(stderr,"/Service internal print \n");
     223#endif
    204224    map *tmp_2=getMapFromMaps(outputs,"Result","mimeType");
     225#ifdef DEBUG
    205226    fprintf(stderr,"Service internal print \n");
    206227    dumpMap(tmp_2);
    207228    fprintf(stderr,"/Service internal print \n");
     229#endif
    208230    if(tmp_2!=NULL){
    209231      if(strncmp(tmp_2->value,"text/js",7)==0 ||
     
    211233        char *tmpS=OGR_G_ExportToJson(res);
    212234        setMapInMaps(outputs,"Result","value",tmpS);
     235#ifndef WIN32
    213236        setMapInMaps(outputs,"Result","mimeType","text/plain");
    214237        setMapInMaps(outputs,"Result","encoding","UTF-8");
    215238        free(tmpS);
     239#endif
    216240      }
    217241      else{
    218242        char *tmpS=OGR_G_ExportToGML(res);
    219243        setMapInMaps(outputs,"Result","value",tmpS);
     244#ifndef WIN32
    220245        setMapInMaps(outputs,"Result","mimeType","text/xml");
    221246        setMapInMaps(outputs,"Result","encoding","UTF-8");
    222247        setMapInMaps(outputs,"Result","schema",schema);
    223248        free(tmpS);
     249#endif
    224250      }
    225251    }else{
    226252      char *tmpS=OGR_G_ExportToJson(res);
    227253      setMapInMaps(outputs,"Result","value",tmpS);
     254#ifndef WIN32
    228255      setMapInMaps(outputs,"Result","mimeType","text/plain");
    229256      setMapInMaps(outputs,"Result","encoding","UTF-8");
    230257      free(tmpS);
    231     }
    232     outputs->next=NULL;
     258#endif
     259    }
     260    //outputs->next=NULL;
    233261#ifdef DEBUG
    234262    dumpMaps(outputs);
     
    239267    //CPLFree(res);
    240268    //CPLFree(geometry);
     269#ifdef DEBUG
    241270    fprintf(stderr,"Service internal print \n");
    242271    dumpMaps(outputs);
    243272    fprintf(stderr,"/Service internal print \n");
     273#endif
    244274    return SERVICE_SUCCEEDED;
    245275  }
     
    276306     bufferDistance=atof(tmp->value);
    277307   res=OGR_G_Buffer(geometry,bufferDistance,30);
     308   dumpMap(tmp);
    278309   tmp1=getMapFromMaps(outputs,"Result","mimeType");
     310   dumpMap(tmp);
    279311   if(strncmp(tmp1->value,"application/json",16)==0){
    280312     char *tmpS=OGR_G_ExportToJson(res);
    281313     setMapInMaps(outputs,"Result","value",tmpS);
     314     dumpMap(tmp);
     315#ifndef WIN32
    282316     setMapInMaps(outputs,"Result","mimeType","text/plain");
    283317     setMapInMaps(outputs,"Result","encoding","UTF-8");
    284318     free(tmpS);
     319#endif
    285320   }
    286321   else{
    287322     char *tmpS=OGR_G_ExportToGML(res);
    288323     setMapInMaps(outputs,"Result","value",tmpS);
     324     dumpMap(tmp);
     325#ifndef WIN32
    289326     free(tmpS);
    290327     setMapInMaps(outputs,"Result","mimeType","text/xml");
    291328     setMapInMaps(outputs,"Result","encoding","UTF-8");
    292329     setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
     330#endif
    293331   }
    294    outputs->next=NULL;
     332   //outputs->next=NULL;
    295333   OGR_G_DestroyGeometry(geometry);
    296334   OGR_G_DestroyGeometry(res);
     
    335373    fprintf(stderr,"\nService internal print1\n");
    336374    fflush(stderr);
    337 #endif
    338375    fprintf(stderr,"\nService internal print1\n");
    339376    dumpMaps(inputs);
    340377    fprintf(stderr,"\nService internal print1\n");
     378#endif
    341379
    342380    maps* cursor=inputs;
     
    357395    if(geometry1==NULL){
    358396      setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity1."));
     397#ifdef DEBUG
    359398      fprintf(stderr,"SERVICE FAILED !\n");
    360       return SERVICE_FAILED;
    361     }
     399#endif
     400      return SERVICE_FAILED;
     401    }
     402#ifdef DEBUG
    362403    fprintf(stderr,"\nService internal print1 InputEntity1\n");
     404#endif
    363405    {
    364406      map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
    365407      map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType");
    366       //#ifdef DEBUG
     408#ifdef DEBUG
    367409      fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16));
    368410      //dumpMap(tmp);
    369411      fprintf(stderr,"MY MAP\n");
    370       ///#endif
    371412      fprintf(stderr,"\nService internal print1 InputEntity2\n");
     413#endif
    372414      if(tmp1!=NULL){
    373415        if(strncmp(tmp1->value,"application/json",16)==0){
     416#ifdef DEBUG
    374417          fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n");
     418#endif
    375419          geometry2=OGR_G_CreateGeometryFromJson(tmp->value);
    376420        }
    377421        else{
     422#ifdef DEBUG
    378423          fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n");
     424#endif
    379425          geometry2=createGeometryFromGML(conf,tmp->value);
    380426        }
     
    382428      else
    383429        geometry2=createGeometryFromGML(conf,tmp->value);
     430#ifdef DEBUG
    384431      fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n");
    385     }
     432#endif
     433    }
     434#ifdef DEBUG
    386435    fprintf(stderr,"\nService internal print1 InputEntity2 Final\n");
     436#endif
    387437    if(geometry2==NULL){
    388438      setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity2."));
     439#ifdef DEBUG
    389440      fprintf(stderr,"SERVICE FAILED !\n");
    390       return SERVICE_FAILED;
    391     }
     441#endif
     442      return SERVICE_FAILED;
     443    }
     444#ifdef DEBUG
    392445    fprintf(stderr,"\nService internal print1\n");
     446#endif
    393447    res=(*myFunc)(geometry1,geometry2);
     448#ifdef DEBUG
    394449    fprintf(stderr,"\nService internal print1\n");
    395    
     450#endif   
    396451    /* nuova parte */
    397452    map* tmp2=getMapFromMaps(outputs,"Result","mimeType");
     
    399454      char *tmpS=OGR_G_ExportToJson(res);
    400455      setMapInMaps(outputs,"Result","value",tmpS);
     456#ifndef WIN32
    401457      setMapInMaps(outputs,"Result","mimeType","text/plain");
    402458      setMapInMaps(outputs,"Result","encoding","UTF-8");
    403459      free(tmpS);
     460#endif
    404461    }
    405462    else{
    406463      char *tmpS=OGR_G_ExportToGML(res);
    407464      setMapInMaps(outputs,"Result","value",tmpS);
     465#ifndef WIN32
    408466      setMapInMaps(outputs,"Result","mimeType","text/xml");
    409467      setMapInMaps(outputs,"Result","encoding","UTF-8");
    410468      setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
    411469      free(tmpS);
     470#endif
    412471    }
    413472   
  • trunk/zoo-services/utils/status/service.c

    r34 r216  
    2424
    2525#include "service.h"
     26#ifdef WIN32
     27#include <windows.h>
     28#endif
    2629
    2730extern "C" {
     
    135138      setMapInMaps(conf,"lenv","status",tmp);
    136139      updateStatus(conf);
     140#ifndef WIN32
    137141      sleep(1);
     142#else
     143      Sleep(1000);
     144#endif
    138145      i+=5;
    139146    }
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