Ignore:
Timestamp:
Sep 29, 2012, 3:59:06 PM (7 years ago)
Author:
djay
Message:

Update to make ZOO-Kernel able to compile and run from Windows Platforms. A special thanks to Espen Messel, Knut Landmark and Benrd Härtwig for providing many patches that I can successfully apply on the SVN source tree and to Farkas for continuing requesting for ZOO-Kernel to run on Windows platforms privately and through the ZOO-Discuss mailing list.

Location:
trunk/zoo-project/zoo-kernel
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/main_conf_read.l

    r354 r364  
    3131attname [a-zA-Z0-9_\-:]+
    3232
    33 attvalue1       [\*,@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+
     33attvalue1       [\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+
    3434
    3535attvalue                \"[^"]*\"|\'[^']*\'
  • trunk/zoo-project/zoo-kernel/makefile.vc

    r304 r364  
    1111
    1212main_conf_read.tab.c: main_conf_read.y service.h
    13         $(TOOLS)\bison -p cr -d main_conf_read.y
     13        bison -p cr -d main_conf_read.y
    1414
    1515main_conf_read.tab.obj: main_conf_read.tab.c service.h
     
    1717
    1818lex.cr.c: main_conf_read.y main_conf_read.l main_conf_read.tab.c service.h
    19         $(TOOLS)\flex -Pcr main_conf_read.l
     19        flex -Pcr main_conf_read.l
    2020
    2121lex.cr.obj: lex.cr.c service.h
     
    2323
    2424service_conf.tab.c: service_conf.y service.h
    25         $(TOOLS)\bison -p sr -d service_conf.y
     25        bison -p sr -d service_conf.y
    2626
    2727service_conf.tab.obj: service_conf.tab.c service.h
     
    2929
    3030lex.sr.c: service_conf.y service_conf.l service_conf.tab.c service.h
    31         $(TOOLS)\flex -Psr service_conf.l
     31        flex -Psr service_conf.l
    3232
    3333lex.sr.obj: lex.sr.c service.h
     
    3737        $(CPP) $(CFLAGS) /c service_internal.c
    3838
     39service_internal_js.obj: service_internal_js.c service.h
     40        $(CPP) /c $(CFLAGS) service_internal_js.c
     41
     42service_internal_java.obj: service_internal_java.c service.h
     43        $(CPP) /c $(CFLAGS) service_internal_java.c
     44
    3945service_internal_python.obj: service_internal_python.c service.h
    4046        $(CPP) /c $(CFLAGS) service_internal_python.c
     47
     48service_internal_ms.obj: service_internal_ms.c service.h
     49        $(CPP) /c $(CFLAGS) service_internal_ms.c
    4150
    4251service_internal_java.obj: service_internal_java.c service.h
     
    5564        $(CPP) /EHsc /c $(CFLAGS) ..\..\thirds\dirent-win32\dirent.c
    5665
    57 zoo_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
    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)
     66zoo_loader.cgi: zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj dirent.obj
     67        link zoo_loader.obj dirent.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) 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)
    5968
    6069clean:
  • trunk/zoo-project/zoo-kernel/nmake.opt

    r304 r364  
    11LIBINTL_CPATH=..\..\..\
    2 PYTHON_CPATH=..\..\..\
     2PYTHON_CPATH=..\..\..\Python-2.7.3
    33TPATH=..\..\..\tools
    4 GEODIR=c:/OSGeo4W
    5 DESTDIR=c:/OSGeo4W
     4#GEODIR=c:/OSGeo4W
     5#DESTDIR=c:/OSGeo4W
    66TOOLS=$(TPATH)\bin
    77
     
    99CPP=cl /TP $(CFLAGS)
    1010
    11 CFLAGS=-DUSE_PYTHON /EHa /nologo /MT /W3 /EHsc /O2 /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I./ -I..\..\thirds\dirent-win32 -I..\..\thirds\include -I$(PYTHON_CPATH)\include -I$(GEODIR)/include -ILIBINTL_CPATH\include -I$(TPATH)\include -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
     11!IFDEF JS_DIR
     12JS_CFLAGS=-DXP_WIN -DUSE_JS -I$(JS_DIR)
     13JS_LDFLAGS=$(JS_DIR)/mozjs185-1.0.lib
     14JS_FILE=service_internal_js.obj
     15!ENDIF
    1216
    13 LDFLAGS=$(GEODIR)/lib/libfcgi.lib $(GEODIR)/lib/libcurl_imp.lib  $(GEODIR)/apps/Python25/libs/python25.lib $(GEODIR)/lib/libxml2.lib ../../thirds/cgic206/libcgic.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)\..\lib\libeay32.dll.a $(TOOLS)\..\lib\libcrypto.a $(TOOLS)\..\lib\libssl32.dll.a $(TOOLS)\..\lib\libintl.lib /machine:i386
     17!IFDEF MS_DIR
     18MS_CFLAGS=-DUSE_MS -I$(MS_DIR)
     19MS_LDFLAGS=$(MS_DIR)/mapserver_i.lib
     20MS_FILE=service_internal_ms.obj
     21!ENDIF
     22
     23!IFDEF JDK_DIR
     24JAVA_CFLAGS=-DJAVA7 -DUSE_JAVA -I"$(JDK_DIR)\include" -I"$(JDK_DIR)\include\win32"
     25JAVA_LDFLAGS="$(JDK_DIR)/lib/jvm.lib"
     26JAVA_FILE=service_internal_java.obj
     27!ENDIF
     28
     29!IFDEF PY_DIR
     30PY_CFLAGS=-DUSE_PYTHON -I$(PY_DIR)\Include -I$(PY_DIR)\PC
     31PY_LDFLAGS=$(PY_LIBRARY)
     32PY_FILE=service_internal_python.obj
     33!ENDIF
     34
     35!IFNDEF ZOOK_DIR
     36ZOOK_DIR=.
     37!ENDIF
     38
     39CFLAGS=-SPOST_DEBUG $(CFLAGS1) /nologo /MD /W3 /EHsc /O2 /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I$(ZOOK_DIR) -I./ $(JAVA_CFLAGS) -I$(TROOT)..\..\thirds\dirent-win32 -I$(INTL_DIR) -I$(CURL_DIR)\include -I$(XML2_DIR)\include -I$(GDAL_DIR)\port $(JS_CFLAGS) -I$(GDAL_DIR)\ogr -I$(GDAL_DIR)\gcore -I$(GD_DIR) -I$(ICONV_DIR) -I$(TROOT)..\..\thirds\include -I$(TROOT)..\..\thirds\cgic206 -I$(PYTHON_CPATH)\include -I$(SSL_DIR)/inc32 -I$(FCGI_DIR)\include $(PY_CFLAGS) -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
     40
     41LDFLAGS=$(FCGI_LIBRARY) $(CURL_LIBRARY) $(PY_LDFLAGS) $(XML2_LIBRARY) $(TROOT)../../thirds/cgic206/libcgic.lib $(SSL_DIR)/out32dll/libeay32.lib $(JAVA_LDFLAGS) $(SSL_DIR)/out32dll/ssleay32.lib $(MS_LDFLAGS) $(INTL_DIR)/intl.lib $(XML2_DIR)/win32/bin.msvc/libxml2.lib $(GDAL_DIR)/gdal_i.lib $(CURL_DIR)/lib/libcurl.lib $(JS_LDFLAGS) /machine:i386
  • trunk/zoo-project/zoo-kernel/service.h

    r362 r364  
    4343#include <string.h>
    4444
     45#ifndef WIN32
    4546#define bool int
    4647#define true 1
    4748#define false -1
     49#endif
    4850
    4951#define SERVICE_ACCEPTED 0
     
    107109      fprintf(stderr,"[%s] => [%s] \n",t->name,t->value);
    108110      fflush(stderr);
    109     }else{
     111        }else{
    110112      fprintf(stderr,"NULL\n");
    111113      fflush(stderr);
     
    124126    map* tmp=t;
    125127    while(tmp!=NULL){
     128#ifdef DEBUG
    126129      fprintf(stderr,"%s = %s\n",tmp->name,tmp->value);
     130#endif
    127131      fprintf(file,"%s = %s\n",tmp->name,tmp->value);
    128132      tmp=tmp->next;
     
    622626    map* tmpSize=getMapArray(m,"size",index);
    623627    if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){
     628#ifdef DEBUG
    624629      fprintf(stderr,"%s\n",tmpSize->value);
     630#endif
    625631      map* ptr=getMapOrFill(m,tmp,"");
    626632      free(ptr->value);
     
    640646      }
    641647    }
    642     dumpMap(tmap);
     648#ifdef DEBUG
     649        dumpMap(tmap);
     650#endif
    643651    return tmap;
    644652  }
     
    676684      map* tmpVI=getMap(tmp->content,tmpV[i]);
    677685      if(tmpVI!=NULL){
     686#ifdef DEBUG
    678687        fprintf(stderr,"%s = %s\n",tmpV[i],tmpVI->value);
     688#endif
    679689        if(i<5)
    680690          setMapArray(_cursor->content,tmpV[i],len,tmpVI->value);
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r360 r364  
    2424
    2525#include "service_internal.h"
    26 
    27 #ifdef WIN32
    28 char *
    29 strtok_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 }
     26#ifdef USE_MS
     27#include "service_internal_ms.h"
    4628#endif
    4729
     
    12151197  }
    12161198
    1217  
     1199
    12181200
    12191201  xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp);
     
    12321214 
    12331215  printDescription(nc,ns_ows,serv->name,serv->content);
    1234   fflush(stderr);
     1216  //fflush(stderr);
    12351217
    12361218  xmlAddChild(n,nc);
     
    13531335    xmlAddChild(n,nc);
    13541336  }
     1337
    13551338#ifdef DEBUG
    13561339  fprintf(stderr,"printProcessResponse 1 202\n");
     
    14811464  xmlAddChild(nc,nc1);
    14821465  // Extract Title required to be first element in the ZCFG file !
    1483   bool isTitle=true;
     1466  bool isTitle=TRUE;
    14841467  if(e!=NULL)
    14851468    tmp=getMap(e->content,"Title");
     
    16251608             strncmp(tmp2->value,"application/vnd.google-earth.kml",32)==0){
    16261609            xmlDocPtr doc =
    1627               xmlParseMemory(BAD_CAST toto->value,strlen(BAD_CAST toto->value));
     1610              xmlParseMemory(toto->value,strlen(toto->value));
    16281611            xmlNodePtr ir = xmlDocGetRootElement(doc);
    16291612            xmlAddChild(nc3,ir);
     
    16341617        xmlAddChild(nc2,nc3);
    16351618      }
    1636       else
    1637         xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
     1619      else{
     1620                  xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
     1621          }
    16381622    }
    16391623  }
     
    16671651    }
    16681652  }
    1669 
    16701653  xmlAddChild(nc1,nc2);
    16711654  xmlAddChild(nc,nc1);
     
    18261809    }
    18271810  }
     1811
    18281812  if(asRaw==0){
    18291813#ifdef DEBUG
     
    18341818    while(tmpI!=NULL){
    18351819#ifdef USE_MS
    1836       map* testMap=getMap(tmpI->content,"useMapserver");
     1820      map* testMap=getMap(tmpI->content,"useMapserver");       
    18371821#endif
    18381822      toto=getMap(tmpI->content,"asReference");
     
    22042188              char *tcn=strdup(tmpContent->name);
    22052189              for(i=1;i<atoi(length->value);i++){
     2190#ifdef DEBUG
    22062191                dumpMap(tmpMaps->content);
    22072192                fprintf(stderr,"addDefaultValues %s_%d => %s\n",tcn,i,tmpContent->value);
    2208                 int len=strlen(tcn);
    2209                 char *tmp1=malloc((len+10)*sizeof(char));
     2193#endif
     2194                int len=strlen((char*) tcn);
     2195                char *tmp1=(char *)malloc((len+10)*sizeof(char));
    22102196                sprintf(tmp1,"%s_%d",tcn,i);
     2197#ifdef DEBUG
    22112198                fprintf(stderr,"addDefaultValues %s => %s\n",tmp1,tmpContent->value);
     2199#endif
    22122200                addToMap(tmpMaps->content,tmp1,tmpContent->value);
    22132201                free(tmp1);
     
    24062394
    24072395
    2408 unsigned char* getMd5(char* url){
     2396char* getMd5(char* url){
    24092397  EVP_MD_CTX md5ctx;
    2410   unsigned char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));
     2398  char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));
    24112399  unsigned char result[EVP_MAX_MD_SIZE];
    24122400  unsigned int len;
     
    24342422  map* tmp=getMapFromMaps(conf,"main","cacheDir");
    24352423  if(tmp!=NULL){
    2436     unsigned char* md5str=getMd5(request);
     2424    char* md5str=getMd5(request);
    24372425    char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6));
    24382426    sprintf(fname,"%s/%s.zca",tmp->value,md5str);
     
    24522440  map* tmpM=getMapFromMaps(conf,"main","cacheDir");
    24532441  if(tmpM!=NULL){
    2454     unsigned char* md5str=getMd5(request);
     2442    char* md5str=getMd5(request);
    24552443#ifdef DEBUG
    24562444    fprintf(stderr,"MD5STR : (%s)\n\n",md5str);
     
    24742462 * Try to load file from cache or download a remote file if not in cache
    24752463 */
    2476 void loadRemoteFile(maps* m,map* content,HINTERNET hInternet,char *url){
     2464int loadRemoteFile(maps* m,map* content,HINTERNET hInternet,char *url){
    24772465  HINTERNET res;
    24782466  char* fcontent;
     
    25162504  free(fcontent);
    25172505  free(cached);
     2506  return 0;
    25182507}
    25192508
  • trunk/zoo-project/zoo-kernel/service_internal.h

    r348 r364  
    6666
    6767#ifdef USE_JS
     68#ifdef WIN32
     69#define XP_WIN 1
     70#else
    6871#define XP_UNIX 0
     72#endif
    6973#include "service_internal_js.h"
    7074#endif
     
    129133  void addToCache(maps*,char*,char*,int);
    130134  char* isInCache(maps*,char*);
    131   void loadRemoteFile(maps*,map*,HINTERNET,char*);
     135  int loadRemoteFile(maps*,map*,HINTERNET,char*);
    132136 
    133137#ifdef __cplusplus
  • trunk/zoo-project/zoo-kernel/service_internal_java.c

    r360 r364  
    4040      classpath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+4)*sizeof(char));
    4141      oclasspath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+22)*sizeof(char));
     42#ifndef WIN32
    4243      sprintf(classpath,"%s/%s/:%s",ntmp,tmp->value,cclasspath);
     44#else
     45      sprintf(classpath,"%s/%s/;%s",ntmp,tmp->value,cclasspath);
     46#endif
    4347    }
    4448    else{
     
    5458#endif
    5559
     60#ifdef WIN32
     61  JavaVMOption options[2];
     62#else
    5663  JavaVMOption options[1];
     64#endif
    5765  JavaVMInitArgs vm_args;
    5866  JavaVM *jvm;
     
    6270  jfieldID fid;
    6371  jobject jobj;
    64   jclass cls,cls_gr;
     72  jclass cls;
     73#ifdef JAVA7
     74  jobject cls_gr;
     75#else
     76  jclass cls_gr;
     77#endif
    6578  int i;
    6679
    6780  options[0].optionString = strdup(oclasspath);
     81#ifdef WIN32
     82  options[1].optionString = "-Xmx512M";
     83#endif
    6884
    6985  JNI_GetDefaultJavaVMInitArgs(&vm_args);
    7086  vm_args.version = JNI_VERSION_1_6;
    7187  vm_args.options = options;
     88#ifdef WIN32
     89  vm_args.nOptions = 2;
     90#else
    7291  vm_args.nOptions = 1;
    73   vm_args.ignoreUnrecognized = JNI_FALSE;
     92#endif
     93  vm_args.ignoreUnrecognized = JNI_TRUE;
    7494
    7595  result = JNI_CreateJavaVM(&jvm,(void **)&env, &vm_args);
     
    7999  }
    80100#ifdef DEBUG
    81   else 
     101  else
    82102    fprintf(stderr,"JAVA VM Started\n");
    83103#endif
    84104
    85105  tmp=getMap(s->content,"serviceProvider");
     106#ifdef JAVA7
     107  cls = env->FindClass(tmp->value);
     108  cls_gr = env->NewGlobalRef(cls);
     109#else
    86110  cls = (*env)->FindClass(env,tmp->value);
    87111  cls_gr = (*env)->NewGlobalRef(env, cls);
     112#endif
    88113  if( cls == NULL ) {
    89114    char pbt[10240];
    90115    sprintf(pbt,"can't find class %s\n",tmp->value);
     116    fprintf(stderr,pbt);
     117    fflush(stderr);
    91118    map* err=createMap("text",pbt);
    92119    addToMap(err,"code","NoApplicableCode");
     
    94121    freeMap(&err);
    95122    free(err);
     123#ifdef JAVA7
     124    (*jvm).DestroyJavaVM();
     125#else
    96126    (*jvm)->DestroyJavaVM(jvm);
     127#endif
    97128    return -1;
    98129  }
     
    104135
    105136  if (cls != NULL) {
     137#ifdef JAVA7
     138    (*env).ExceptionClear();
     139    pmid=(*env).GetStaticMethodID(cls, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I");
     140#else
    106141    (*env)->ExceptionClear(env);
    107142    pmid=(*env)->GetStaticMethodID(env,cls_gr, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I");
     143#endif
    108144    if (pmid!=0){
    109145#ifdef DEBUG
     
    112148      jclass scHashMapClass,scHashMap_class;
    113149      jmethodID scHashMap_constructor;
     150#ifdef JAVA7
     151      scHashMapClass = (*env).FindClass("java/util/HashMap");
     152      scHashMap_class = (jclass)(*env).NewGlobalRef(scHashMapClass);
     153      scHashMap_constructor = (*env).GetMethodID(scHashMap_class, "<init>", "()V");
     154#else
    114155      scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
    115156      scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass);
    116157      scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V");
     158#endif
    117159      /**
    118160       * The 3 standard parameter for each services
     
    123165      jint pValue=0;
    124166
     167#ifdef JAVA7
     168      pValue=(*env).CallStaticIntMethod(cls,pmid,arg1,arg2,arg3);
     169#else
    125170      pValue=(*env)->CallStaticIntMethod(env,cls,pmid,arg1,arg2,arg3);
     171#endif
    126172      if (pValue != (jint)NULL){
    127173        res=pValue;
     
    146192        FILE* new_stdout=fopen(tmps,"w+");
    147193        dup2(fileno(new_stdout),fileno(stdout));
     194#ifdef JAVA7
     195        (*env).ExceptionDescribe();
     196#else
    148197        (*env)->ExceptionDescribe(env);
     198#endif
    149199        fflush(stdout);
    150200        dup2(old_stdout,fileno(stdout));
     
    152202        long flen=ftell(new_stdout);
    153203        rewind(new_stdout);
    154         char tmps1[flen];
     204        char *tmps1=(char*)malloc((flen+1)*sizeof(char));
    155205        fread(tmps1,flen,1,new_stdout);
    156206        fclose(new_stdout);
    157         char pbt[100+flen];
     207        char *pbt=(char*)malloc((100+flen+1)*sizeof(char));
    158208        sprintf(pbt,"Unable to run your java process properly. Server returns : %s",tmps1);
    159209        map* err=createMap("text",pbt);
     
    162212        freeMap(&err);
    163213        free(err);
     214#ifdef JAVA7
     215        (*jvm).DestroyJavaVM();
     216#else
    164217        (*jvm)->DestroyJavaVM(jvm);
     218#endif
    165219        return -1;
    166220      }
     
    173227      freeMap(&err);
    174228      free(err);
     229#ifdef JAVA7
     230      (*jvm).DestroyJavaVM();
     231#else
    175232      (*jvm)->DestroyJavaVM(jvm);
     233#endif
    176234      return -1;
    177235    }
     
    183241    freeMap(&err);
    184242    free(err);
     243#ifdef JAVA7
     244    (*jvm).DestroyJavaVM();
     245#else
    185246    (*jvm)->DestroyJavaVM(jvm);
     247#endif
    186248    return -1;
    187249  }
     250#ifdef JAVA7
     251      (*jvm).DestroyJavaVM();
     252#else
    188253  (*jvm)->DestroyJavaVM(jvm);
     254#endif
    189255  return res;
    190256}
     
    193259  jobject scObject,scObject1;
    194260  if(scHashMap_constructor!=NULL){
     261#ifdef JAVA7
     262    scObject = (*env).NewObject(scHashMap_class, scHashMap_constructor);
     263#else
    195264    scObject = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
     265#endif
    196266    jmethodID put_mid = 0;
    197267
     268#ifdef JAVA7
     269    put_mid = (*env).GetMethodID(scHashMapClass, "put",
     270                                  "(Ljava/lang/Object;Ljava/lang/Object;)"
     271                                  "Ljava/lang/Object;");
     272#else
    198273    put_mid = (*env)->GetMethodID(env,scHashMapClass, "put",
    199274                                  "(Ljava/lang/Object;Ljava/lang/Object;)"
    200275                                  "Ljava/lang/Object;");
     276#endif
    201277    maps* tmp=t;
    202278    while(tmp!=NULL){
    203279      map* tmap=getMapType(tmp->content);
    204280      map* tmp1=tmp->content;
     281#ifdef JAVA7
     282      scObject1 = (*env).NewObject(scHashMap_class, scHashMap_constructor);
     283#else
    205284      scObject1 = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
     285#endif
    206286      map* sizeV=getMap(tmp1,"size");
    207287      map* isArray=getMap(tmp1,"isArray");
     
    211291          if(isArray==NULL){
    212292            if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){
     293#ifdef JAVA7
     294              jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value));
     295              (*env).SetByteArrayRegion(tmpData,0,atoi(sizeV->value),(const jbyte *)tmp1->value);
     296              (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), tmpData);
     297#else
    213298              jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value));
    214299              (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value);
    215300              (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData);
     301#endif
    216302            }else
     303#ifdef JAVA7
     304              (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value));
     305#else
    217306              (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
     307#endif
    218308          }
    219309          else{
     
    224314            jmethodID scArrayList_constructor;
    225315            jobject scObject2,scObject3,scObject4;
     316#ifdef JAVA7
     317            scArrayListClass = (*env).FindClass("java/util/ArrayList");
     318            scArrayList_class = (jclass)(*env).NewGlobalRef(scArrayListClass);
     319            scArrayList_constructor = (*env).GetMethodID(scArrayList_class, "<init>", "()V");
     320            jmethodID add_mid = 0;
     321            scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
     322            scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
     323            scObject4 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
     324
     325            add_mid = (*env).GetMethodID(scArrayListClass,
     326                                          "add","(Ljava/lang/Object;)Z");
     327#else
    226328            scArrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
    227329            scArrayList_class = (*env)->NewGlobalRef(env, scArrayListClass);
     
    234336            add_mid = (*env)->GetMethodID(env,scArrayListClass,
    235337                                          "add","(Ljava/lang/Object;)Z");
    236            
     338#endif     
    237339            int i;
    238340           
     
    243345             
    244346              if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0){
     347#ifdef JAVA7
     348                jbyteArray tmpData=(*env).NewByteArray(atoi(sMap->value));
     349                (*env).SetByteArrayRegion(tmpData,0,atoi(sMap->value),(const jbyte *)vMap->value);
     350                (*env).CallObjectMethod(scObject2, add_mid, tmpData);
     351#else
    245352                jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sMap->value));
    246353                (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sMap->value),vMap->value);
    247354                (*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
     355#endif
    248356              }else{
     357#ifdef JAVA7
     358                jobject tmpData=(*env).NewStringUTF(vMap->value);
     359                (*env).CallObjectMethod(scObject2, add_mid, tmpData);
     360#else
    249361                jobject tmpData=(*env)->NewStringUTF(env,vMap->value);
    250362                (*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
     363#endif
    251364              }
    252365             
    253366            }
    254            
     367
     368#ifdef JAVA7
     369            (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), scObject2);
     370#else       
    255371            (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), scObject2);
    256            
     372#endif
     373
    257374          }
    258375        }
    259376        else
     377#ifdef JAVA7
     378          (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value));
     379#else
    260380          (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
     381#endif
    261382        tmp1=tmp1->next;
    262383      }
     384#ifdef JAVA7
     385      (*env).CallObjectMethod(scObject, put_mid, (*env).NewStringUTF(tmp->name), scObject1);
     386#else
    263387      (*env)->CallObjectMethod(env,scObject, put_mid, (*env)->NewStringUTF(env,tmp->name), scObject1);
     388#endif
    264389      tmp=tmp->next;
    265390    }
     
    292417    return NULL;
    293418  }
     419#ifdef JAVA7
     420  entrySet_mid = (*env).GetMethodID(scHashMapClass, "entrySet", "()Ljava/util/Set;");
     421  containsKey_mid = (*env).GetMethodID(scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z");
     422  get_mid = (*env).GetMethodID(scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
     423#else
    294424  entrySet_mid = (*env)->GetMethodID(env, scHashMapClass, "entrySet", "()Ljava/util/Set;");
    295425  containsKey_mid = (*env)->GetMethodID(env, scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z");
    296426  get_mid = (*env)->GetMethodID(env, scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
     427#endif
    297428
    298429  if(containsKey_mid==0){
     
    319450#endif
    320451
     452#ifdef JAVA7
     453  scSetClass = (*env).FindClass("java/util/Set");
     454  iterator_mid = (*env).GetMethodID(scSetClass, "iterator", "()Ljava/util/Iterator;");
     455#else
    321456  scSetClass = (*env)->FindClass(env, "java/util/Set");
    322457  iterator_mid = (*env)->GetMethodID(env, scSetClass, "iterator", "()Ljava/util/Iterator;");
     458#endif
    323459#ifdef DEBUG
    324460  fprintf(stderr,"mapsFromHashMap 1 (%d) \n",iterator_mid);
    325461#endif
    326462
     463#ifdef JAVA7
     464  scIteratorClass = (*env).FindClass("java/util/Iterator");
     465  hasNext_mid = (*env).GetMethodID(scIteratorClass, "hasNext", "()Z");
     466#else
    327467  scIteratorClass = (*env)->FindClass(env, "java/util/Iterator");
    328468  hasNext_mid = (*env)->GetMethodID(env, scIteratorClass, "hasNext", "()Z");
     469#endif
     470
    329471#ifdef DEBUG
    330472  fprintf(stderr,"mapsFromHashMap 2 (%d)\n",hasNext_mid);
    331473#endif
     474
     475#ifdef JAVA7
     476  next_mid = (*env).GetMethodID(scIteratorClass, "next", "()Ljava/lang/Object;");
     477#else
    332478  next_mid = (*env)->GetMethodID(env, scIteratorClass, "next", "()Ljava/lang/Object;");
     479#endif
    333480#ifdef DEBUG
    334481  fprintf(stderr,"mapsFromHashMap 3 (%d)\n",next_mid);
    335482#endif
    336483
     484#ifdef JAVA7
     485  scMapEntryClass = (*env).FindClass("java/util/Map$Entry");
     486  getKey_mid = (*env).GetMethodID(scMapEntryClass, "getKey", "()Ljava/lang/Object;");
     487#else
    337488  scMapEntryClass = (*env)->FindClass(env, "java/util/Map$Entry");
    338489  getKey_mid = (*env)->GetMethodID(env, scMapEntryClass, "getKey", "()Ljava/lang/Object;");
     490#endif
    339491#ifdef DEBUG
    340492  fprintf(stderr,"mapsFromHashMap 4 (%d)\n",getKey_mid);
    341493#endif
     494#ifdef JAVA7
     495  getValue_mid = (*env).GetMethodID(scMapEntryClass, "getValue", "()Ljava/lang/Object;");
     496#else
    342497  getValue_mid = (*env)->GetMethodID(env, scMapEntryClass, "getValue", "()Ljava/lang/Object;");
     498#endif
    343499#ifdef DEBUG
    344500  fprintf(stderr,"mapsFromHashMap 5 (%d)\n",getValue_mid);
    345501#endif
    346502
     503#ifdef JAVA7
     504  jobject final_set=(*env).CallObjectMethod(t,entrySet_mid);
     505  jobject final_iterator=(*env).CallObjectMethod(final_set,iterator_mid);
     506#else
    347507  jobject final_set=(*env)->CallObjectMethod(env,t,entrySet_mid);
    348508  jobject final_iterator=(*env)->CallObjectMethod(env,final_set,iterator_mid);
    349 
     509#endif
    350510
    351511  maps* final_res=NULL;
    352512  map* res=NULL;
     513#ifdef JAVA7
     514  while((*env).CallBooleanMethod(final_iterator,hasNext_mid)){
     515    jobject tmp=(*env).CallObjectMethod(final_iterator,next_mid);
     516
     517    jobject imap=(*env).CallObjectMethod(tmp,getValue_mid);
     518    jobject set=(*env).CallObjectMethod(imap,entrySet_mid);
     519    jobject iterator=(*env).CallObjectMethod(set,iterator_mid);
     520
     521#else
    353522  while((*env)->CallBooleanMethod(env,final_iterator,hasNext_mid)){
    354523    jobject tmp=(*env)->CallObjectMethod(env,final_iterator,next_mid);
     
    358527    jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid);
    359528
     529#endif
    360530    int size=-1;
     531#ifdef JAVA7
     532    if((*env).CallBooleanMethod(imap,containsKey_mid,(*env).NewStringUTF("size"))){
     533      jobject sizeV=(*env).CallObjectMethod(imap, get_mid,(*env).NewStringUTF("size"));
     534      const char* sizeVS=(*env).GetStringUTFChars((jstring)sizeV, NULL);
     535#else
    361536    if((*env)->CallBooleanMethod(env,imap,containsKey_mid,(*env)->NewStringUTF(env,"size"))){
    362537      jobject sizeV=(*env)->CallObjectMethod(env, imap, get_mid,(*env)->NewStringUTF(env,"size"));
    363538      const char* sizeVS=(*env)->GetStringUTFChars(env, sizeV, NULL);
     539#endif
    364540      size=atoi(sizeVS);
    365541      fprintf(stderr,"SIZE : %s\n",sizeVS);
     542#ifdef JAVA7
     543      (*env).ReleaseStringUTFChars((jstring)sizeV, sizeVS);
     544#else
    366545      (*env)->ReleaseStringUTFChars(env, sizeV, sizeVS);
     546#endif
    367547    }
    368548   
     549#ifdef JAVA7
     550    while((*env).CallBooleanMethod(iterator,hasNext_mid)){
     551      jobject tmp1=(*env).CallObjectMethod(iterator,next_mid);
     552      jobject jk=(*env).CallObjectMethod(tmp1,getKey_mid);
     553      jobject jv=(*env).CallObjectMethod(tmp1,getValue_mid);
     554
     555      const char* jkd=(*env).GetStringUTFChars((jstring)jk, NULL);
     556#else
    369557    while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){
    370558      jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid);
     
    373561
    374562      const char* jkd=(*env)->GetStringUTFChars(env, jk, NULL);
     563#endif
    375564      if(size>=0 && strcmp(jkd,"value")==0){
     565#ifdef JAVA7
     566        jobject value=(jobject)(*env).GetByteArrayElements((jbyteArray)jv, NULL);
     567#else
    376568        jobject value=(*env)->GetByteArrayElements(env, jv, NULL);
     569#endif
    377570        if(res==NULL){
    378571          res=createMap(jkd,"");
     
    390583      }
    391584      else{
     585#ifdef JAVA7
     586        const char* jvd=(*env).GetStringUTFChars((jstring)jv, NULL);
     587#else
    392588        const char* jvd=(*env)->GetStringUTFChars(env, jv, NULL);
     589#endif
    393590        if(res==NULL){
    394591          res=createMap(jkd,jvd);
     
    396593          addToMap(res,jkd,jvd);
    397594        }
     595#ifdef JAVA7
     596        (*env).ReleaseStringUTFChars((jstring)jv, jvd);
     597#else
    398598        (*env)->ReleaseStringUTFChars(env, jv, jvd);
     599#endif
    399600      }
    400601
     602#ifdef JAVA7
     603      (*env).ReleaseStringUTFChars((jstring)jk, jkd);
     604#else
    401605      (*env)->ReleaseStringUTFChars(env, jk, jkd);
     606#endif
    402607
    403608    }
     609#ifdef JAVA7
     610    jobject jk=(*env).CallObjectMethod(tmp,getKey_mid);
     611#else
    404612    jobject jk=(*env)->CallObjectMethod(env,tmp,getKey_mid);
     613#endif
    405614    maps* cmap=(maps*)malloc(sizeof(maps));
     615#ifdef JAVA7
     616    cmap->name=(char*)(*env).GetStringUTFChars((jstring)jk, NULL);
     617#else
    406618    cmap->name=(*env)->GetStringUTFChars(env, jk, NULL);
     619#endif
    407620#ifdef DEBUG
    408621    fprintf(stderr," / %s \n",cmap->name);
  • trunk/zoo-project/zoo-kernel/service_internal_js.c

    r360 r364  
    4545JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1)
    4646{
    47   map* request = JS_GetContextPrivate(cx);
    48   map* tmpm1=getMap(request,"metapath");
     47  //map* request = JS_GetContextPrivate(cx);
     48  //map* tmpm1=getMap(request,"metapath");
    4949  JS_MaybeGC(cx);
    5050
     
    5858    JSString* jsmsg = JS_ValueToString(cx,argv[i]);
    5959    char *filename = JSValToChar(cx,&argv[i]);
    60     char api0[strlen(tmpm1->value)+strlen(ntmp)+strlen(filename)+2];
    61     sprintf(api0,"%s/%s/%s",ntmp,tmpm1->value,filename);
     60    char *api0=(char*)malloc((strlen(ntmp)+strlen(filename)+2)*sizeof(char));
     61    sprintf(api0,"%s/%s",ntmp,filename);
    6262#ifdef JS_DEBUG
    6363    fprintf(stderr,"Trying to load %s\n",api0);
     64    fflush(stderr);
    6465#endif
    6566    JSObject *api_script1=loadZooApiFile(cx,JS_GetGlobalObject(cx),api0);
    66     fflush(stderr);
    6767  }
    6868  JS_MaybeGC(cx);
     
    8383  JSClass global_class = {
    8484    "global", JSCLASS_GLOBAL_FLAGS,
    85     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
     85    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
    8686    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
    8787    JSCLASS_NO_OPTIONAL_MEMBERS
     
    142142   * Load the first part of the ZOO-API
    143143   */
    144   char api0[strlen(tmpm1->value)+strlen(ntmp)+16];
     144  char *api0=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+16);
    145145  sprintf(api0,"%s/%s/ZOO-proj4js.js",ntmp,tmpm1->value);
    146146#ifdef JS_DEBUG
     
    150150  fflush(stderr);
    151151
    152   char api1[strlen(tmpm1->value)+strlen(ntmp)+11];
     152  char *api1=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+11);
    153153  sprintf(api1,"%s/%s/ZOO-api.js",ntmp,tmpm1->value);
    154154#ifdef JS_DEBUG
     
    165165  map* tmpm2=getMap(s->content,"serviceProvider");
    166166
    167   char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+3];
     167  char *filename=(char*)malloc(strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+3);
    168168  sprintf(filename,"%s/%s/%s",ntmp,tmpm1->value,tmpm2->value);
    169169  filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+2]=0;
     
    173173  struct stat file_status;
    174174  stat(filename, &file_status);
    175   char source[file_status.st_size];
     175  char *source=(char*)malloc(file_status.st_size);
    176176  uint16 lineno;
    177177  jsval rval;
     
    244244    fprintf(stderr,"An array was returned !\n");
    245245#endif
    246     jsint len;
     246    jsuint      len;
    247247    if((JS_GetArrayLength(cx, d, &len)==JS_FALSE)){
    248248#ifdef JS_DEBUG
     
    259259    JSBool hasElement=JS_GetElement(cx,d,1,&tmp2);
    260260    if(hasElement==JS_TRUE){
     261          freeMaps(outputs);
     262          free(*outputs);
    261263      *outputs=mapsFromJSObject(cx,tmp2);
    262264    }
     
    285287    *outputs=mapsFromJSObject(cx,tmp2);
    286288#ifdef JS_DEBUG
    287     dumpMaps(outputs);
    288 #endif
    289   }
    290 
     289    dumpMaps(*outputs);
     290#endif
     291  }
    291292  /* Cleanup. */
    292293  JS_DestroyContext(cx);
     
    355356  map* isBinary=getMap(t,"size");
    356357  map* tmap=getMapType(t);
     358#ifdef DEBUG
    357359  if(tmap==NULL)
    358360    fprintf(stderr,"tmap is null !\n");
    359361  else
    360362    fprintf(stderr,"tmap is not null ! (%s = %s)\n",tmap->name,tmap->value);
    361 
     363#endif
    362364  /* Avoid gesture of binary content which failed due to strlen function use */
    363365  if(isBinary!=NULL){
     
    441443
    442444        jsval nvp=JSVAL_NULL;
    443         if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tt), JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
     445        if((JS_GetProperty(cx, tt, JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
    444446#ifdef JS_DEBUG
    445447          fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_EncodeString(cx,jsmsg));
     
    447449        }
    448450       
    449         JSObject *nvp1=JSVAL_NULL;
     451        JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL);
    450452        JS_ValueToObject(cx,nvp,&nvp1);
    451453        jsval nvp1j=OBJECT_TO_JSVAL(nvp1);
     
    467469  }
    468470
    469   jsint len;
     471  jsuint len;
    470472  JSBool hasLen=JS_GetArrayLength(cx, tt, &len);
    471473  if(hasLen==JS_FALSE){
     
    522524        }
    523525
    524         JSObject *nvp1=JSVAL_NULL;
     526        JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL);
    525527        JS_ValueToObject(cx,nvp,&nvp1);
    526528        jsval nvp1j=OBJECT_TO_JSVAL(nvp1);
    527529        if(JSVAL_IS_OBJECT(nvp1j)){
    528530          JSString *jsmsg1;
    529           JSObject *nvp2=JSVAL_NULL;
     531          JSObject *nvp2=JSVAL_TO_OBJECT(JSVAL_NULL);
    530532          jsmsg1 = JS_ValueToString(cx,nvp1j);
    531533          len1 = JS_GetStringLength(jsmsg1);
  • trunk/zoo-project/zoo-kernel/service_internal_js.h

    r348 r364  
    2828#pragma once
    2929
    30 #define XP_UNIX 0
    31 
    3230#include "service.h"
    3331#include "service_internal.h"
     
    3533#include <sys/stat.h>
    3634#include <unistd.h>
    37 #include "jsapi.h"
    3835#include "ulinet.h"
    3936
  • trunk/zoo-project/zoo-kernel/service_internal_ms.c

    r362 r364  
    7777
    7878void setReferenceUrl(maps* m,maps* tmpI){
    79   dumpMaps(tmpI);
     79  //dumpMaps(tmpI);
    8080  outputMapfile(m,tmpI);
    8181  map *msUrl=getMapFromMaps(m,"main","mapserverAddress");
     
    299299      sprintf(tmpSrsStr,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y);
    300300      addToMap(output->content,"wcs_extent",tmpExtent);
    301       dumpMap(output->content);
     301      //dumpMap(output->content);
    302302
    303303    }else{
     
    331331   */
    332332
    333   OGRDataSourceH *poDS1 = NULL;
     333  OGRDataSourceH poDS1 = NULL;
    334334  OGRSFDriverH *poDriver1 = NULL;
    335335  char *dsName=(char*)malloc((8+strlen(pszDataSource)+1)*sizeof(char));
     
    373373    char** demo=VSIReadDir(dsName);
    374374    int i=0;
    375     mkdir(sdsName,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH );
     375    mkdir(sdsName
     376#ifndef WIN32
     377                ,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
     378#endif
     379                );
    376380    while(demo[i]!=NULL){
    377381      fprintf(stderr,"ZIP File content : %s\n",demo[i]);
     
    414418  }
    415419
    416   OGRDataSourceH *poDS = NULL;
     420  OGRDataSourceH poDS = NULL;
    417421  OGRSFDriverH *poDriver = NULL;
    418422  poDS = OGROpen( pszDataSource, FALSE, poDriver );
     
    432436  int iLayer = 0;
    433437  for( iLayer=0; iLayer < OGR_DS_GetLayerCount(poDS); iLayer++ ){
    434     OGRLayerH *poLayer = OGR_DS_GetLayer(poDS,iLayer);
     438    OGRLayerH poLayer = OGR_DS_GetLayer(poDS,iLayer);
    435439
    436440    if( poLayer == NULL ){
     
    530534     * Detect the FID column or use the first attribute field as FID
    531535     */
    532     char *fid=OGR_L_GetFIDColumn(poLayer);
     536    char *fid=(char*)OGR_L_GetFIDColumn(poLayer);
    533537    if(strlen(fid)==0){
    534538      OGRFeatureDefnH def=OGR_L_GetLayerDefn(poLayer);
     
    536540      for(fIndex=0;fIndex<OGR_FD_GetFieldCount(def);fIndex++){
    537541        OGRFieldDefnH fdef=OGR_FD_GetFieldDefn(def,fIndex);
    538         fid=OGR_Fld_GetNameRef(fdef);
     542        fid=(char*)OGR_Fld_GetNameRef(fdef);
    539543        break;
    540544      }
     
    550554
    551555    if(msGrowLayerClasses(myLayer) == NULL)
    552       return;
    553     if(initClass((myLayer->class[myLayer->numclasses])) == -1)
    554       return;
    555     myLayer->class[myLayer->numclasses]->type = myLayer->type;
    556     if(msGrowClassStyles(myLayer->class[myLayer->numclasses]) == NULL)
    557       return ;
    558     if(initStyle(myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]) == -1)
    559       return;
     556      return -1;
     557    if(initClass((myLayer->_class[myLayer->numclasses])) == -1)
     558      return -1;
     559    myLayer->_class[myLayer->numclasses]->type = myLayer->type;
     560    if(msGrowClassStyles(myLayer->_class[myLayer->numclasses]) == NULL)
     561      return -1;
     562    if(initStyle(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]) == -1)
     563      return -1;
    560564
    561565    /**
     
    564568    tmpMap=getMap(output->content,"msStyle");
    565569    if(tmpMap!=NULL)
    566       msUpdateStyleFromString(myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles],tmpMap->value,0);
     570      msUpdateStyleFromString(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles],tmpMap->value,0);
    567571    else{
    568572      /**
    569573       * Set style
    570574       */
    571       myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.red=125;
    572       myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.green=125;
    573       myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.blue=255;
    574       myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.red=80;
    575       myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.green=80;
    576       myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.blue=80;
     575      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.red=125;
     576      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.green=125;
     577      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.blue=255;
     578      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.red=80;
     579      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.green=80;
     580      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.blue=80;
    577581
    578582      /**
     
    580584       */
    581585      if(myLayer->type == MS_LAYER_POLYGON)
    582         myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->width=3;
     586        myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->width=3;
    583587      if(myLayer->type == MS_LAYER_LINE){
    584         myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->width=3;
    585         myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinewidth=1.5;
     588        myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->width=3;
     589        myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinewidth=1.5;
    586590      }
    587591      if(myLayer->type == MS_LAYER_POINT){
    588         myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->symbol=1;
    589         myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->size=15;
    590       }
    591 
    592     }
    593     myLayer->class[myLayer->numclasses]->numstyles++;
     592        myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->symbol=1;
     593        myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->size=15;
     594      }
     595
     596    }
     597    myLayer->_class[myLayer->numclasses]->numstyles++;
    594598    myLayer->numclasses++;
    595599    m->layerorder[m->numlayers] = m->numlayers;
     
    606610
    607611int tryGdal(maps* conf,maps* output,mapObj* m){
    608 
    609612  map* tmpMap=getMap(output->content,"storage");
    610613  char *pszFilename=tmpMap->value;
     
    790793             */
    791794            if(msGrowLayerClasses(myLayer) == NULL)
    792               return;
    793             if(initClass((myLayer->class[myLayer->numclasses])) == -1)
    794               return;
    795             myLayer->class[myLayer->numclasses]->type = myLayer->type;
    796             if(msGrowClassStyles(myLayer->class[myLayer->numclasses]) == NULL)
    797               return ;
    798             if(initStyle(myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]) == -1)
    799               return;
     795              return -1;
     796            if(initClass((myLayer->_class[myLayer->numclasses])) == -1)
     797              return -1;
     798            myLayer->_class[myLayer->numclasses]->type = myLayer->type;
     799            if(msGrowClassStyles(myLayer->_class[myLayer->numclasses]) == NULL)
     800              return -1;
     801            if(initStyle(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]) == -1)
     802              return -1;
    800803           
    801804            /**
     
    804807            char className[7];
    805808            sprintf(className,"class%d",i);
    806             myLayer->class[myLayer->numclasses]->name=strdup(className);
     809            myLayer->_class[myLayer->numclasses]->name=strdup(className);
    807810           
    808811            /**
     
    814817            else
    815818              sprintf(expression,"([pixel]>=%.3f AND [pixel]<=%.3f)",cstep,cstep+interval);
    816             msLoadExpressionString(&myLayer->class[myLayer->numclasses]->expression,expression);
     819            msLoadExpressionString(&myLayer->_class[myLayer->numclasses]->expression,expression);
    817820           
    818821            /**
    819822             * Set color
    820823             */
    821             myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.red=_tmpColors[i][0];
    822             myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.green=_tmpColors[i][1];
    823             myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.blue=_tmpColors[i][2];
     824            myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.red=_tmpColors[i][0];
     825            myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.green=_tmpColors[i][1];
     826            myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.blue=_tmpColors[i][2];
    824827            cstep+=interval;
    825             myLayer->class[myLayer->numclasses]->numstyles++;
     828            myLayer->_class[myLayer->numclasses]->numstyles++;
    826829            myLayer->numclasses++;
    827830           
     
    976979  }
    977980
     981  /*
     982   * Set mapserver PROJ_LIB/GDAL_DATA or any other config parameter from
     983   * the main.cfg [mapserver] section if any
     984   */
     985  maps *tmp3=getMaps(conf,"mapserver");
     986  if(tmp3!=NULL){
     987    map* tmp4=tmp3->content;
     988    while(tmp4!=NULL){
     989      msSetConfigOption(myMap,tmp4->name,tmp4->value);
     990      tmp4=tmp4->next;
     991    }
     992  }
     993
    978994  /**
    979995   * Set a ows_rootlayer_title, 
     
    10061022  if(tryOgr(conf,outputs,myMap)<0)
    10071023    if(tryGdal(conf,outputs,myMap)<0)
    1008       return NULL;
     1024      return ;
    10091025
    10101026  tmp1=getMapFromMaps(conf,"main","dataPath");
  • trunk/zoo-project/zoo-kernel/service_internal_ms.h

    r348 r364  
    77#include "service.h"
    88#include "cpl_conv.h"
     9#include "cpl_multiproc.h"
    910#include "ogr_api.h"
    1011#include "gdal.h"
    1112#include "ogr_srs_api.h"
    1213#include "ulinet.h"
     14#ifdef WIN32
     15#include <unistd.h>
     16#endif
    1317
    1418#include <mapserver.h>
    1519
     20#ifdef __cplusplus
     21extern "C" {
     22#endif
     23  //#include <mapserver.h>
    1624  /**
    1725   * Map composed by a main.cfg maps name as key and the corresponding
     
    4149   */
    4250  void outputMapfile(maps* conf,maps* outputs);
     51#ifdef __cplusplus
     52}
     53#endif
    4354
    4455#endif
  • trunk/zoo-project/zoo-kernel/service_internal_python.c

    r360 r364  
    7070#else
    7171  SetEnvironmentVariable("PYTHONPATH",pythonpath);
     72  char* toto=(char*)malloc((strlen(pythonpath)+12)*sizeof(char));
     73  sprintf(toto,"PYTHONPATH=%s",pythonpath);
     74  putenv(toto);
    7275#endif
    7376  free(python_path);
     
    123126        fprintf(stderr,"Result of call: %i\n", PyInt_AsLong(pValue));
    124127        dumpMaps(inputs);
    125         dumpMaps(outputs);
     128        dumpMaps(*real_outputs);
    126129#endif
    127130      }else{     
  • trunk/zoo-project/zoo-kernel/ulinet.c

    r361 r364  
    375375
    376376#ifdef USE_JS
     377#define XP_WIN 1
    377378#include "jsapi.h"
    378379
    379380char* JSValToChar(JSContext* context, jsval* arg) {
     381  char *c;
     382  char *tmp;
     383  JSString *jsmsg;
     384  size_t len;
     385  int i;
    380386  if(!JSVAL_IS_STRING(*arg)) {
    381387    return NULL;
    382388  }
    383   char *c, *tmp;
    384   JSString *jsmsg;
    385   size_t len;
    386389  jsmsg = JS_ValueToString(context,*arg);
    387390  len = JS_GetStringLength(jsmsg);
     
    389392  c = (char*)malloc((len+1)*sizeof(char));
    390393  c[len] = '\0';
    391   int i;
    392394#ifdef ULINET_DEBUG
    393395  fprintf(stderr,"%d \n",len);
     
    405407HINTERNET setHeader(HINTERNET handle,JSContext *cx,JSObject *header){
    406408  jsuint length=0;
     409  jsint i=0;
     410  char *tmp1;
    407411#ifdef ULINET_DEBUG
    408412  fprintf(stderr,"setHeader\n");
     
    416420    fprintf(stderr,"header is an array of %d elements\n",length);
    417421#endif
    418     jsint i=0;
    419422    handle.header=NULL;
    420423    for(i=0;i<length;i++){
    421424      jsval tmp;
    422425      JS_GetElement(cx,header,i,&tmp);
    423       char *tmp1=JSValToChar(cx,&tmp);
     426      tmp1=JSValToChar(cx,&tmp);
    424427#ifdef ULINET_DEBUG
    425428      fprintf(stderr,"Element of array n° %d, value : %s\n",i,tmp1);
     
    440443  jsval *argv = JS_ARGV(cx,argv1);
    441444  HINTERNET hInternet;
     445  HINTERNET res;
     446  HINTERNET res1;
     447  JSObject *header;
    442448  char *url;
    443449  char *method;
     450  char* tmpValue;
     451  size_t dwRead;
     452  int i=0;
    444453  JS_MaybeGC(cx);
    445454  hInternet=InternetOpen((LPCTSTR)"ZooWPSClient\0",
     
    448457  if(!CHECK_INET_HANDLE(hInternet))
    449458    return JS_FALSE;
    450   int i=0;
    451459  if(argc>=2){
    452460    method=JSValToChar(cx,&argv[0]);
     
    457465    url=JSValToChar(cx,argv);
    458466  }
    459   HINTERNET res;
    460467  if(argc==4){
    461468    char *body;
    462469    body=JSValToChar(cx,&argv[2]);
    463     JSObject *header=JSVAL_TO_OBJECT(argv[3]);
    464     HINTERNET res1;
     470    header=JSVAL_TO_OBJECT(argv[3]);
    465471#ifdef ULINET_DEBUG
    466472    fprintf(stderr,"URL (%s) \nBODY (%s)\n",url,body);
     
    484490                        INTERNET_FLAG_NO_CACHE_WRITE,0);
    485491  }
    486   char* tmpValue=(char*)malloc((res.nDataLen+1)*sizeof(char));
    487   size_t dwRead;
     492  tmpValue=(char*)malloc((res.nDataLen+1)*sizeof(char));
    488493  InternetReadFile(res,(LPVOID)tmpValue,res.nDataLen,&dwRead);
    489494  fprintf(stderr,"content downloaded (%d) (%s) \n",dwRead,tmpValue);
  • trunk/zoo-project/zoo-kernel/ulinet.h

    r348 r364  
    3535#include "time.h"
    3636#ifdef USE_JS
     37#ifdef WIN32
     38# define XP_WIN
     39#else
    3740#define XP_UNIX 0
     41#endif
    3842#include "jsapi.h"
    3943#endif
  • trunk/zoo-project/zoo-kernel/zoo_loader.c

    r348 r364  
    2626#define MALLOC_CHECK 0
    2727
    28 #ifdef WIN32
    29 #include "windows.h"
    30 #endif
    3128/**
    3229 * Specific includes
    3330 */
     31#ifndef WIN32
    3432#include "fcgio.h"
    3533#include "fcgi_config.h"
    3634#include "fcgi_stdio.h"
     35#endif
    3736#include <sys/types.h>
    3837#include <unistd.h>
    3938#include "service_internal.h"
     39#ifdef WIN32
     40#include "windows.h"
     41#define strtok_r strtok_s
     42#endif
    4043
    4144extern "C" {
     
    5558using namespace std;
    5659
     60#ifndef TRUE
    5761#define TRUE 1
     62#endif
     63#ifndef FALSE
    5864#define FALSE -1
     65#endif
    5966
    6067int cgiMain(){
     
    6875  fprintf(cgiOut,"Welcome on ZOO verbose debuging mode \r\n\r\n");
    6976  fflush(cgiOut);
    70 #endif
    71  
    72 #ifdef DEBUG
    7377  fprintf (stderr, "Addr:%s\n", cgiRemoteAddr);
    7478  fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0);
     
    143147  }
    144148  else{
     149#ifdef DEBUG
    145150    dumpMap(tmpMap);
     151#endif
    146152    char **array, **arrayStep;
    147153    if (cgiFormEntries(&array) != cgiFormSuccess) {
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r362 r364  
    7878#include <windows.h>
    7979#include <direct.h>
     80#include <sys/types.h>
     81#include <sys/stat.h>
     82#include <unistd.h>
     83#define pid_t int;
    8084#endif
    8185#include <fcntl.h>
    8286#include <time.h>
    8387#include <stdarg.h>
     88
     89#ifdef WIN32
     90extern "C" {
     91__declspec(dllexport) char *strcasestr(char const *a, char const *b) {
     92    char *x=_strdup(a);
     93    char *y=_strdup(b);
     94
     95    x=_strlwr(x);
     96    y=_strlwr(y);
     97    char *pos = strstr(x, y);
     98    char *ret = pos == NULL ? NULL : (char *)(a + (pos-x));
     99    free(x);
     100    free(y);
     101    return ret;
     102}
     103}
     104#endif
    84105
    85106#define _(String) dgettext ("zoo-kernel",String)
     
    218239  fflush(stderr);
    219240#endif
    220   if(strncasecmp(r_inputs->value,"C",1)==0){
     241  if(strlen(r_inputs->value)==1 && strncasecmp(r_inputs->value,"C",1)==0){
    221242    r_inputs=getMap(request_inputs,"metapath");
    222243    if(r_inputs!=NULL)
     
    402423              }
    403424  *myMap=m;
    404 #ifndef WIN32
    405425  *ioutputs=request_output_real_format;
    406 #endif
    407426}
    408427
     
    521540  bindtextdomain ("zoo-kernel","/usr/share/locale/");
    522541  bindtextdomain ("zoo-services","/usr/share/locale/");
    523  
     542
     543  /**
     544   * Manage our own error log file (usefull to separate standard apache debug
     545   * messages from the ZOO-Kernel ones but also for IIS users to avoid wrong
     546   * headers messages returned by the CGI due to wrong redirection of stderr)
     547   */
     548  FILE * fstde=NULL;
     549  map* fstdem=getMapFromMaps(m,"main","logPath");
     550  if(fstdem!=NULL)
     551        fstde = freopen(fstdem->value, "a+", stderr) ;
     552
    524553  if((r_inputs=getMap(request_inputs,"language"))!=NULL){
    525554    char *tmp=strdup(r_inputs->value);
     
    18291858    return 1;
    18301859  }
    1831 
    18321860  maps* tmpReqI=request_input_real_format;
    18331861  while(tmpReqI!=NULL){
     
    18421870        char fileNameOnServer[64];
    18431871        char contentType[1024];
    1844         char buffer[BufferLen];
     1872        char buffer[1024];
    18451873        char *tmpStr=NULL;
    18461874        int size;
     
    18661894          fprintf(stderr,"fileNameOnServer: %s\n",fileNameOnServer);
    18671895          mode=S_IRWXU|S_IRGRP|S_IROTH;
    1868           targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,mode);
     1896          targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP|S_IROTH);
    18691897          if(targetFile<0){
    18701898            fprintf(stderr,"could not create the new file,%s\n",fileNameOnServer);         
     
    19121940#ifdef DEBUG
    19131941      fflush(stderr);
    1914       fprintf(stderr,"setting variable... %s\n",
     1942      fprintf(stderr,"setting variable... %s\n",(
    19151943#endif
    19161944              SetEnvironmentVariable(mapcs->name,mapcs->value)
    19171945#ifdef DEBUG
    1918               ? "OK" : "FAILED");
     1946              ==0)? "OK" : "FAILED");
    19191947#else
    19201948      ;
    19211949#endif
     1950          char* toto=(char*)malloc((strlen(mapcs->name)+strlen(mapcs->value)+2)*sizeof(char));
     1951      sprintf(toto,"%s=%s",mapcs->name,mapcs->value);
     1952          putenv(toto);
    19221953#ifdef DEBUG
    19231954      fflush(stderr);
     
    20362067    addToMap(request_inputs,"status","true");
    20372068    status=getMap(request_inputs,"status");
    2038     fprintf(stderr,"cgiSID : %s",cgiSid);
     2069    //fprintf(stderr,"cgiSID : %s",cgiSid);
    20392070  }
    20402071#endif
    20412072  if(status!=NULL)
    20422073    if(strcasecmp(status->value,"false")==0)
    2043       status=NULL;
     2074      status=NULLMAP;
    20442075  if(status==NULLMAP){
    20452076    loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
    20462077  }
    20472078  else{
    2048     pid_t   pid;
     2079    int   pid;
    20492080#ifdef DEBUG
    20502081    fprintf(stderr,"\nPID : %d\n",cpid);
     
    21712202  return 0;
    21722203}
     2204
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