Changeset 877 for branches/prototype-v0/zoo-project/zoo-kernel
- Timestamp:
- Aug 16, 2018, 8:00:56 AM (6 years ago)
- Location:
- branches/prototype-v0/zoo-project/zoo-kernel
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r872 r877 23 23 */ 24 24 25 #include <openssl/md5.h> 26 #include <openssl/evp.h> 25 27 #include "caching.h" 26 28 #include "service.h" 27 29 #include "service_internal.h" 28 30 #include "response_print.h" 29 #include <openssl/md5.h>30 #include <openssl/hmac.h>31 #include <openssl/evp.h>32 #include <openssl/bio.h>33 #include <openssl/buffer.h>34 31 35 32 /** … … 61 58 return fresult; 62 59 } 60 61 /** 62 * Compute md5 of a file 63 * 64 * @param file the char* 65 * @return a char* representing the md5 of the url 66 * @warning make sure to free resources returned by this function 67 */ 68 char* getMd5f(char* file){ 69 EVP_MD_CTX md5ctx; 70 char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char)); 71 unsigned char result[EVP_MAX_MD_SIZE]; 72 unsigned int len; 73 int bytes; 74 unsigned char data[1024]; 75 FILE *inFile = fopen (file, "rb"); 76 EVP_DigestInit(&md5ctx, EVP_md5()); 77 while ((bytes = fread (data, 1, 1024, inFile)) != 0) 78 EVP_DigestUpdate(&md5ctx, data, bytes); 79 EVP_DigestFinal_ex(&md5ctx,result,&len); 80 EVP_MD_CTX_cleanup(&md5ctx); 81 int i; 82 for(i = 0; i < len; i++){ 83 if(i>0){ 84 char *tmp=zStrdup(fresult); 85 sprintf(fresult,"%s%02x", tmp,result[i]); 86 free(tmp); 87 } 88 else 89 sprintf(fresult,"%02x",result[i]); 90 } 91 fclose (inFile); 92 return fresult; 93 } 94 63 95 64 96 … … 145 177 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 146 178 char contentr[4096]; 179 char* md5fstr=NULL; 147 180 int cred=0; 148 181 if(tmp!=NULL){ … … 183 216 fclose(fo); 184 217 fclose(fi); 185 218 219 // Store mimeType 186 220 sprintf(fname,"%s/%s.zcm",tmp->value,md5str); 187 221 fo=fopen(fname,"w+"); … … 192 226 fclose(fo); 193 227 228 // Store provenance 194 229 sprintf(fname,"%s/%s.zcp",tmp->value,md5str); 195 230 fo=fopen(fname,"w+"); … … 199 234 #endif 200 235 fwrite(origin,sizeof(char),strlen(origin),fo); 236 fclose(fo); 237 238 // Store md5 239 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 240 md5fstr=getMd5f(fname); 241 sprintf(fname,"%s/%s.zmd",tmp->value,md5str); 242 fo=fopen(fname,"w+"); 243 #ifdef DEBUG 244 fprintf(stderr,"MD5: %s\n",md5fstr); 245 #endif 246 fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo); 247 free(md5fstr); 201 248 fclose(fo); 202 249 -
branches/prototype-v0/zoo-project/zoo-kernel/configure.ac
r873 r877 68 68 [AS_HELP_STRING([--with-json=PATH], [Specifies an alternative location for the json-c library])], 69 69 [JSON_DIR="$withval"], [JSON_DIR="/usr/"]) 70 JSON_CPPFLAGS="-I$JSON_DIR/include/json-c/" 71 JSON_LDFLAGS="-L$JSON_DIR/lib -ljson-c" 72 CPPFLAGS_SAVE="$CPPFLAGS" 73 CPPFLAGS="$JSON_CPPFLAGS" 74 LIBS_SAVE="$LIBS" 75 LIBS="$JSON_LDFLAGS" 76 echo $CPPFLAGS 77 AC_CHECK_HEADERS([json_object.h], 78 [], [AC_MSG_ERROR([could not find header file json_object.h])]) 79 AC_CHECK_LIB([json-c], [json_object_new_object], 80 [], [AC_MSG_ERROR([could not find function in json-c library])]) 81 CPPFLAGS="$CPPFLAGS_SAVE" 82 JSON_FILE="service_json.o" 83 JSON_ENABLED="-DJSON" 70 if test "x$JSON_DIR" != "x" 71 then 72 JSON_CPPFLAGS="-I$JSON_DIR/include/json-c/" 73 JSON_LDFLAGS="-L$JSON_DIR/lib -ljson-c" 74 CPPFLAGS_SAVE="$CPPFLAGS" 75 CPPFLAGS="$JSON_CPPFLAGS" 76 LIBS_SAVE="$LIBS" 77 LIBS="$JSON_LDFLAGS" 78 AC_CHECK_HEADERS([json_object.h], 79 [], [AC_MSG_ERROR([could not find header file json_object.h])]) 80 AC_CHECK_LIB([json-c], [json_object_new_object], 81 [], [AC_MSG_ERROR([could not find function in json-c library])]) 82 CPPFLAGS="$CPPFLAGS_SAVE" 83 JSON_FILE="service_json.o" 84 JSON_ENABLED="-DJSON" 85 fi 84 86 AC_SUBST([JSON_CPPFLAGS]) 85 87 AC_SUBST([JSON_LDFLAGS]) … … 112 114 #============================================================================ 113 115 114 #AC_ARG_WITH([gettext], 115 # [AS_HELP_STRING([--with-gettext=PATH], [Specifies an alternative location for the openssl library])], 116 # [GETTEXT_DIR="$withval"], [GETTEXT_DIR="/usr/"]) 117 #GETTEXT_CFLAGS="-I$GETTEXT_DIR/include" 118 #GETTEXT_LDFLAGS="-L$GETTEXT_DIR/lib -lintl" 116 AC_ARG_WITH([gettext], 117 [AS_HELP_STRING([--with-gettext=PATH], [Specifies an alternative location for the openssl library])], 118 [GETTEXT_DIR="$withval"], [GETTEXT_DIR="/usr/"]) 119 120 GETTEXT_CFLAGS="-I$GETTEXT_DIR/include" 121 GETTEXT_LDFLAGS="-L$GETTEXT_DIR/lib -lintl" 119 122 #CFLAGS_SAVE="$CFLAGS" 120 123 #CFLAGS="$GETTEXT_CFLAGS" … … 232 235 [HPCWITH="$withval"], [HPCWITH="no"]) 233 236 237 238 AC_ARG_WITH([ssh2], 239 [AS_HELP_STRING([--with-ssh2=PATH], [Specifies an alternative location for the ssh2 library])], 240 [SSH2PATH="$withval"], [SSH2PATH="/usr"]) 241 234 242 if test "x$HPCWITH" = "xyes"; then 235 243 HPC_FILES="service_internal_hpc.o sshapi.o" … … 237 245 HPC_CPPFLAGS="" 238 246 HPC_LDFLAGS="" 247 # Extract the linker and include flags 248 SSH2_LDFLAGS="-L$SSH2PATH/lib -lssh2" 249 SSH2_CPPFLAGS="-I$SSH2PATH/include" 250 # Check headers file 251 CPPFLAGS_SAVE="$CPPFLAGS" 252 CPPFLAGS="$SSH2_CPPFLAGS" 253 LIBS_SAVE="$LIBS" 254 LIBS="$SSH2_LDFLAGS" 255 256 AC_CHECK_HEADERS([libssh2.h], 257 [], [AC_MSG_ERROR([could not find headers related to libssh2])]) 258 AC_CHECK_LIB([ssh2], [libssh2_session_init]) 259 260 LIBS="$LIBS_SAVE" 239 261 fi 240 262 … … 244 266 AC_SUBST([HPC_FILES]) 245 267 246 AC_ARG_WITH([ssh2],247 [AS_HELP_STRING([--with-ssh2=PATH], [Specifies an alternative location for the ssh2 library])],248 [SSH2PATH="$withval"], [SSH2PATH="/usr"])249 250 # Extract the linker and include flags251 SSH2_LDFLAGS="-L$SSH2PATH/lib -lssh2"252 SSH2_CPPFLAGS="-I$SSH2PATH/include"253 # Check headers file254 CPPFLAGS_SAVE="$CPPFLAGS"255 CPPFLAGS="$SSH2_CPPFLAGS"256 LIBS_SAVE="$LIBS"257 LIBS="$SSH2_LDFLAGS"258 echo $CPPFLAGS259 echo $LIBS260 261 AC_CHECK_HEADERS([libssh2.h],262 [], [AC_MSG_ERROR([could not find headers related to libssh2])])263 AC_CHECK_LIB([ssh2], [libssh2_session_init])264 265 LIBS="$LIBS_SAVE"266 268 AC_SUBST([SSH2_CPPFLAGS]) 267 269 AC_SUBST([SSH2_LDFLAGS]) … … 805 807 806 808 AC_LANG([C++]) 807 echo $JAVA_CPPFLAGS809 #echo $JAVA_CPPFLAGS 808 810 # Check headers file (second time we check that in fact) 809 811 CPPFLAGS_SAVE="$CPPFLAGS" … … 855 857 856 858 AC_LANG([C++]) 857 echo $JAVA_CPPFLAGS859 #echo $JAVA_CPPFLAGS 858 860 # Check headers file (second time we check that in fact) 859 861 CPPFLAGS_SAVE="$CFLAGS" -
branches/prototype-v0/zoo-project/zoo-kernel/makefile.vc
r788 r877 50 50 $(CPP) $(CFLAGS) /c caching.c 51 51 52 service_json.obj: service_json.c service_json.h 53 $(CPP) $(CFLAGS) /c service_json.c 54 52 55 request_parser.obj: request_parser.c request_parser.h 53 56 $(CPP) $(CFLAGS) /c request_parser.c … … 89 92 $(CPP) /c $(CFLAGS) $(PHP_CFLAGS) service_internal_php.c 90 93 94 service_callback.obj: service_callback.c service_callback.h service.h 95 $(CPP) /c $(CFLAGS) service_callback.c 96 91 97 service_internal_php7.obj: service_internal_php7.c service_internal_php.h service.h 92 98 $(CPP) /c $(CFLAGS) $(PHP_CFLAGS) service_internal_php7.c … … 95 101 link /dll /out:$(LIBZOO_SERVICE) ./service.obj ./service_internal.obj ./sqlapi.obj $(LDFLAGS) /FORCE:MULTIPLE 96 102 97 $(PROGRAMNAME): version.h $(LIBZOO_SERVICE) zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj request_parser.obj response_print.obj server_internal.obj caching.obj 98 link zoo_loader.obj request_parser.obj response_print.obj server_internal.obj caching.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj zoo_service_loader.obj ./libzoo_service.lib /out:$(PROGRAMNAME) $(LDFLAGS) $(LDFLAGSCGI)103 $(PROGRAMNAME): version.h $(LIBZOO_SERVICE) zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj request_parser.obj response_print.obj server_internal.obj caching.obj service_json.obj service_callback.obj 104 link zoo_loader.obj request_parser.obj response_print.obj server_internal.obj caching.obj service_json.obj service_callback.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj zoo_service_loader.obj ./libzoo_service.lib /out:$(PROGRAMNAME) $(LDFLAGS) $(LDFLAGSCGI) ..\..\thirds\sdk\release-1800-x64/lib/json-c.lib ..\..\thirds\sdk\release-1800-x64/lib/pthread_dll.lib ..\..\thirds\sdk\release-1800-x64/lib/libxslt.lib 99 105 100 106 zcfg2yaml: version.h zcfg2yaml.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj … … 105 111 106 112 embed-manifest: zoo_loader.cgi 107 mt.exe -manifest zoo_loader.cgi.manifest -outputresource:zoo_loader.cgi; 1113 mt.exe -manifest zoo_loader.cgi.manifest -outputresource:zoo_loader.cgi; -
branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c
r871 r877 521 521 int l = 0; 522 522 map* version=getMapFromMaps(*main_conf,"main","rversion"); 523 map* memory=getMapFromMaps(*main_conf,"main","memory"); 523 524 int vid=getVersionId(version->value); 524 525 for (k=0; k < nodes->nodeNr; k++) … … 788 789 INTERNET_OPEN_TYPE_PRECONFIG, 789 790 NULL, NULL, 0); 791 #ifndef WIN32 790 792 if (!CHECK_INET_HANDLE (bInternet)) 791 793 fprintf (stderr, 792 794 "WARNING : bInternet handle failed to initialize"); 795 #endif 793 796 bInternet.waitingRequests[0] = 794 797 strdup ((char *) val); … … 1109 1112 } 1110 1113 } 1114 if(memory!=NULL && strncasecmp(memory->value,"load",4)!=0) 1115 if(getMap(tmpmaps->content,"to_load")==NULL){ 1116 addToMap(tmpmaps->content,"to_load","false"); 1117 } 1111 1118 { 1112 1119 map* test=getMap(tmpmaps->content,"value"); … … 1189 1196 } 1190 1197 } 1198 return 0; 1191 1199 } 1192 1200 … … 1970 1978 addToMap(res->content,name,token1); 1971 1979 free(name); 1980 name=NULL; 1972 1981 i=0; 1973 1982 } 1974 1983 token1 = strtok_r (NULL, "=", &saveptr1); 1975 1984 } 1985 if(name!=NULL) 1986 free(name); 1976 1987 token = strtok_r (NULL, "; ", &saveptr); 1977 1988 } -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r872 r877 693 693 tmp1=serv->metadata; 694 694 695 addMetadata(tmp1,doc,nc1,ns_ows,ns_xlink );695 addMetadata(tmp1,doc,nc1,ns_ows,ns_xlink,vid); 696 696 tmp1=serv->additional_parameters; 697 697 int fromDb=-1; … … 750 750 * @param ns_ows the OWS namespace 751 751 * @param ns_xlink the xlink namespace 752 */ 753 void addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink){ 752 * @param vid the version of WPS to use (0 for 1.0.0 and 1 for 2.0) 753 */ 754 void addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int vid){ 754 755 int hasTitle=-1; 755 756 int hasValue=-1; … … 757 758 map* oMeta=meta; 758 759 int isAdditionalParameters=-1; 759 //if(count(oMeta)>=2){760 760 int level=0; 761 761 map* test=getMap(meta,"title"); … … 770 770 if(count(oMeta)>level+1) 771 771 isAdditionalParameters=1; 772 //}773 772 char *ctitle=NULL; 774 773 while(meta!=NULL){ … … 815 814 meta=meta->next; 816 815 if(hasTitle<0){ 817 if(isAdditionalParameters)818 xmlAddChild(nc,nc1);819 816 hasValue=1; 817 if(isAdditionalParameters){ 818 if(vid==0){ 819 meta=NULL; 820 break; 821 }else 822 xmlAddChild(nc,nc1); 823 } 820 824 } 821 825 } … … 1049 1053 tmp1=serv->metadata; 1050 1054 while(tmp1!=NULL){ 1051 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink); 1052 /*nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 1053 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value); 1054 xmlAddChild(nc,nc1);*/ 1055 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink,vid); 1055 1056 tmp1=tmp1->next; 1056 1057 } … … 1063 1064 }else{ 1064 1065 tmp1=serv->metadata; 1065 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink );1066 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink,vid); 1066 1067 addInheritedMetadata(nc,ns_ows,ns_xlink,reg,m,serv); 1067 1068 tmp1=serv->additional_parameters; 1068 addAdditionalParameters(tmp1,doc,nc,ns_ows,ns_xlink,fromDb); 1069 if(vid!=0) 1070 addAdditionalParameters(tmp1,doc,nc,ns_ows,ns_xlink,fromDb); 1069 1071 } 1070 1072 … … 1126 1128 int isAnyValue=1; 1127 1129 nc2 = xmlNewNode(NULL, BAD_CAST type); 1130 // Extract min/max Occurence information 1128 1131 if(strstr(type,"Input")!=NULL){ 1129 1132 tmp1=getMap(e->content,"minOccurs"); … … 1168 1171 //Build the (Literal/Complex/BoundingBox)Data node 1169 1172 if(strncmp(type,"Output",6)==0){ 1170 if(strncasecmp(e->format,"LITERAL DATA",strlen(e->format))==0)1173 if(strncasecmp(e->format,"LITERAL",7)==0) 1171 1174 nc3 = xmlNewNode(ns1, BAD_CAST "LiteralOutput"); 1172 1175 else if(strncasecmp(e->format,"COMPLEXDATA",strlen(e->format))==0) … … 1214 1217 strcmp(e->format,"BoundingBoxData")==0){ 1215 1218 datatype=2; 1216 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 1219 if(vid==0) 1220 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 1221 else{ 1222 xmlNodePtr nc6 = xmlNewNode(ns1, BAD_CAST "Format"); 1223 xmlNewProp(nc6,BAD_CAST "mimeType",BAD_CAST "text/xml"); 1224 xmlNewProp(nc6,BAD_CAST "default",BAD_CAST "true"); 1225 xmlAddChild(nc3,nc6); 1226 nc5 = xmlNewNode(NULL, BAD_CAST "SupportedCRS"); 1227 } 1217 1228 } 1218 1229 else{ … … 1424 1435 strncasecmp(tmp1->name,"range",5)!=0){ 1425 1436 if(datatype!=1){ 1426 char *tmp2=zCapitalize1(tmp1->name); 1427 nc9 = xmlNewNode(NULL, BAD_CAST tmp2); 1428 free(tmp2); 1437 if(datatype==2 && vid==1){ 1438 nc9 = xmlNewNode(ns, BAD_CAST "SupportedCRS"); 1439 xmlNewProp(nc9,BAD_CAST "default",BAD_CAST "true"); 1440 } 1441 else{ 1442 char *tmp2=zCapitalize1(tmp1->name); 1443 nc9 = xmlNewNode(NULL, BAD_CAST tmp2); 1444 free(tmp2); 1445 } 1429 1446 } 1430 1447 else{ … … 1435 1452 xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value)); 1436 1453 if(vid==0 || oI>=3){ 1437 if(vid==0 || oI!=4) 1438 xmlAddChild(nc5,nc9); 1454 if(vid==0 || oI!=4){ 1455 if(datatype==2 && vid==1) 1456 xmlAddChild(nc3,nc9); 1457 else 1458 xmlAddChild(nc5,nc9); 1459 } 1439 1460 if(oI==4 && vid==1){ 1440 1461 xmlNewProp(nc9,BAD_CAST "default",BAD_CAST "true"); … … 1447 1468 hasUOM1=true; 1448 1469 hasUOM=true; 1449 }else 1450 tmp1=tmp1->next; 1470 } 1451 1471 } 1452 1472 } … … 1463 1483 }else{ 1464 1484 if(hasUOM1==false && vid==0){ 1465 xmlFreeNode(nc5); 1485 if(nc5!=NULL) 1486 xmlFreeNode(nc5); 1466 1487 if(datatype==1){ 1467 1488 xmlFreeNode(nc4); 1468 1489 } 1469 1490 } 1470 else 1491 else{ 1471 1492 xmlAddChild(nc3,nc5); 1493 } 1472 1494 } 1473 1495 }else{ 1474 xmlAddChild(nc3,nc5); 1496 if(vid==0) 1497 xmlAddChild(nc3,nc5); 1498 else 1499 xmlFreeNode(nc5); 1475 1500 } 1476 1501 1477 if(datatype !=1&& default1<0){1502 if(datatype==0 && default1<0){ 1478 1503 xmlFreeNode(nc5); 1479 1504 if(datatype!=2){ … … 1530 1555 nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2); 1531 1556 free(tmp2); 1532 //xmlNewProp(nc9, BAD_CAST "default", BAD_CAST "true");1533 1557 xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value)); 1534 1558 xmlAddChild(nc5,nc9); 1535 /*struct iotype * _ltmp=e->supported;1536 while(_ltmp!=NULL){1537 tmp1=getMap(_ltmp->content,"uom");1538 if(tmp1!=NULL){1539 char *tmp2=zCapitalize(tmp1->name);1540 nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);1541 free(tmp2);1542 xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));1543 xmlAddChild(nc5,nc9);1544 }1545 _ltmp=_ltmp->next;1546 }*/1547 1548 1559 } 1549 1560 } … … 1560 1571 xmlNsPtr ns_xlink=usedNs[xlinkId]; 1561 1572 1562 //dumpMap(metadata);1563 addMetadata(metadata,doc,nc2,ns_ows,ns_xlink);1564 addAdditionalParameters(e->additional_parameters,doc,nc2,ns_ows,ns_xlink,fromDb);1573 addMetadata(metadata,doc,nc2,ns_ows,ns_xlink,vid); 1574 if(vid!=0) 1575 addAdditionalParameters(e->additional_parameters,doc,nc2,ns_ows,ns_xlink,fromDb); 1565 1576 1566 1577 } 1567 1578 1568 1579 _tmp=e->supported; 1569 if(_tmp==NULL && datatype !=1)1580 if(_tmp==NULL && datatype==0) 1570 1581 _tmp=e->defaults; 1571 1582 … … 1613 1624 strcasecmp(tmp1->name,"extension")!=0){ 1614 1625 if(datatype!=1){ 1615 char *tmp2=zCapitalize1(tmp1->name); 1616 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 1617 free(tmp2); 1626 if(datatype==2 && vid==1){ 1627 nc6 = xmlNewNode(ns, BAD_CAST "SupportedCRS"); 1628 } 1629 else{ 1630 char *tmp2=zCapitalize1(tmp1->name); 1631 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 1632 free(tmp2); 1633 } 1618 1634 } 1619 1635 else{ … … 1639 1655 } 1640 1656 if(vid==0 || oI>=3){ 1641 if(vid==0 || oI!=4) 1642 xmlAddChild(nc5,nc6); 1657 if(vid==0 || oI!=4){ 1658 if(datatype==2 && vid==1) 1659 xmlAddChild(nc3,nc6); 1660 else 1661 xmlAddChild(nc5,nc6); 1662 } 1643 1663 else{ 1644 1664 xmlFreeNode(nc6); … … 1658 1678 } 1659 1679 else{ 1660 xmlAddChild(nc3,nc5); 1680 if(datatype!=2) 1681 xmlAddChild(nc3,nc5); 1661 1682 } 1662 1683 1663 1684 }else{ 1664 if(datatype !=1)1685 if(datatype==2 && vid==0) 1665 1686 xmlAddChild(nc3,nc5); 1666 1687 } … … 1678 1699 } 1679 1700 else 1680 if(datatype !=1){1701 if(datatype==0){ 1681 1702 xmlFreeNode(nc4); 1682 1703 xmlAddChild(nc3,nc5); … … 1713 1734 xmlAddChild(nc2,nc3); 1714 1735 }else{ 1715 if(e->child!=NULL){ 1716 if(e->child!=NULL && vid!=0){ 1717 printFullDescription(doc,in,e->child,type,ns,ns_ows,nc2,vid,fromDb,NULL); 1718 } 1736 if(e->child!=NULL && vid!=0){ 1737 printFullDescription(doc,in,e->child,type,ns,ns_ows,nc2,vid,fromDb,NULL); 1719 1738 } 1720 1739 } 1721 1740 if(e->child!=NULL && vid==0){ 1722 xmlFreeNode(nc3);1723 1741 elements* children=dupElements(e->child); 1724 1742 elements* cursor=children; 1725 1743 while(cursor!=NULL){ 1726 char* tmp=strdup(cursor->name); 1727 free(cursor->name); 1728 cursor->name=(char*)malloc((strlen(tmp)+strlen(e->name)+2)*sizeof(char)); 1729 sprintf(cursor->name,"%s.%s",e->name,tmp); 1744 elements* ccursor=cursor; 1745 char* tmp=strdup(ccursor->name); 1746 free(ccursor->name); 1747 ccursor->name=(char*)malloc((strlen(tmp)+strlen(e->name)+2)*sizeof(char)); 1748 sprintf(ccursor->name,"%s.%s",e->name,tmp); 1730 1749 cursor=cursor->next; 1731 1750 } 1732 printFullDescription(doc,in,children,type,ns,ns_ows,nc2,vid,fromDb,serviceType); 1733 xmlAddChild(nc1,nc2); 1751 printFullDescription(doc,in,children,type,ns,ns_ows,nc1,vid,fromDb,serviceType); 1734 1752 freeElements(&children); 1735 1753 free(children); 1736 }else 1737 xmlAddChild(nc1,nc2); 1754 }else{ 1755 if(nc2!=NULL){ 1756 xmlAddChild(nc1,nc2); 1757 } 1758 } 1738 1759 e=e->next; 1739 1760 } … … 1966 1987 nc = xmlNewNode(ns, BAD_CAST "ProcessOutputs"); 1967 1988 } 1989 //dumpMaps(outputs); 1968 1990 maps* mcursor=outputs; 1969 1991 elements* scursor=serv->outputs; … … 1977 1999 if(testResponse==NULL || tmp0==NULL){ 1978 2000 if(vid==0) 1979 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);2001 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1980 2002 else 1981 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);2003 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1982 2004 } 1983 2005 else 1984 1985 2006 if(tmp0!=NULL && strncmp(tmp0->value,"true",4)==0){ 1986 2007 if(vid==0) … … 2058 2079 #endif 2059 2080 } 2081 2060 2082 printDocument(m,doc,pid); 2061 2083 … … 2699 2721 return; 2700 2722 } 2723 2724 if(res!=SERVICE_SUCCEEDED){ 2725 printProcessResponse(m,request_inputs1,cpid, 2726 s, s->name,res, // replace serviceProvider with serviceName in stored response file name 2727 request_inputs, 2728 request_outputs); 2729 return; 2730 } 2731 2701 2732 2702 2733 map *tmp1=getMapFromMaps(m,"main","tmpPath"); -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.h
r854 r877 221 221 void printStatusInfo(maps*,map*,char*); 222 222 void addAdditionalParameters(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int); 223 void addMetadata(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr );223 void addMetadata(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int); 224 224 225 225 void outputResponse(service*,maps*,maps*,map*,int,maps*,int); -
branches/prototype-v0/zoo-project/zoo-kernel/service.c
r873 r877 539 539 */ 540 540 map* addToMapWithSize(map* m,const char* n,const char* v,int size){ 541 char sin[128]; 542 char sname[10]="size"; 543 map *tmp; 541 544 if(hasKey(m,n)==false){ 542 545 map* _cursor=m; … … 547 550 } 548 551 } 549 char sname[10]="size";550 552 if(strlen(n)>5) 551 553 sprintf(sname,"size_%s",n+6); 552 map *tmp=getMap(m,n);554 tmp=getMap(m,n); 553 555 if(tmp->value!=NULL) 554 556 free(tmp->value); … … 557 559 memmove(tmp->value,v,size*sizeof(char)); 558 560 tmp->value[size]=0; 559 char sin[128];560 561 sprintf(sin,"%d",size); 561 562 addToMap(m,sname,sin); … … 578 579 } 579 580 else{ 580 #ifdef DEBUG581 fprintf(stderr,"_CURSOR\n");582 dumpMap(_cursor);583 #endif584 while(_cursor->next!=NULL)585 _cursor=_cursor->next;586 581 map* tmp1=getMap(*mo,tmp->name); 587 582 if(tmp1==NULL){ 583 while(_cursor->next!=NULL) 584 _cursor=_cursor->next; 588 585 _cursor->next=createMap(tmp->name,tmp->value); 589 586 } … … 594 591 _cursor=*mo; 595 592 tmp=tmp->next; 596 #ifdef DEBUG597 fprintf(stderr,"MO\n");598 dumpMap(*mo);599 #endif600 593 } 601 594 } … … 711 704 map* size=getMap(in,"size"); 712 705 map *lout=*out; 706 map *tmpVin,*tmpVout; 713 707 if(size!=NULL && pos>0){ 714 708 char tmp[11]; … … 716 710 size=getMap(in,tmp); 717 711 sprintf(tmp,"value_%d",pos); 718 map*tmpVin=getMap(in,tmp);719 map*tmpVout=getMap(lout,tmp);712 tmpVin=getMap(in,tmp); 713 tmpVout=getMap(lout,tmp); 720 714 free(tmpVout->value); 721 715 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); … … 724 718 }else{ 725 719 if(size!=NULL){ 726 map*tmpVin=getMap(in,"value");727 map*tmpVout=getMap(lout,"value");720 tmpVin=getMap(in,"value"); 721 tmpVout=getMap(lout,"value"); 728 722 free(tmpVout->value); 729 723 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); … … 745 739 map* size=getMap(in,"size"); 746 740 map* length=getMap(in,"length"); 741 map* toload=getMap(in,"to_load"); 742 if(toload!=NULL && strcasecmp(toload->value,"false")==0){ 743 fprintf(stderr,"NO LOAD %s %d \n",__FILE__,__LINE__); 744 return ; 745 } 747 746 if(length!=NULL){ 748 747 int len=atoi(length->value); … … 767 766 maps* res=NULL; 768 767 if(_cursor!=NULL){ 768 map* mc=_cursor->content; 769 maps* mcs=_cursor->child; 769 770 res=createMaps(_cursor->name); 770 map* mc=_cursor->content;771 771 if(mc!=NULL){ 772 772 addMapToMap(&res->content,mc); 773 773 loadMapBinaries(&res->content,mc); 774 774 } 775 maps* mcs=_cursor->child;776 775 if(mcs!=NULL){ 777 776 res->child=dupMaps(&mcs); … … 797 796 } 798 797 else{ 798 maps* tmp1=getMaps(*mo,tmp->name); 799 799 while(_cursor->next!=NULL) 800 800 _cursor=_cursor->next; 801 maps* tmp1=getMaps(*mo,tmp->name);802 801 if(tmp1==NULL){ 803 802 _cursor->next=dupMaps(&tmp); … … 830 829 map* getMapArray(map* m,const char* key,int index){ 831 830 char tmp[1024]; 831 map* tmpMap; 832 832 if(index>0) 833 833 sprintf(tmp,"%s_%d",key,index); … … 837 837 fprintf(stderr,"** KEY %s\n",tmp); 838 838 #endif 839 map*tmpMap=getMap(m,tmp);839 tmpMap=getMap(m,tmp); 840 840 #ifdef DEBUG 841 841 if(tmpMap!=NULL) … … 856 856 void setMapArray(map* m,const char* key,int index,const char* value){ 857 857 char tmp[1024]; 858 map* tmpSize; 858 859 if(index>0){ 860 map* len=getMap(m,"length"); 859 861 sprintf(tmp,"%s_%d",key,index); 860 map* len=getMap(m,"length");861 862 if((len!=NULL && atoi(len->value)<index+1) || len==NULL){ 862 863 char tmp0[5]; … … 869 870 addToMap(m,"length","1"); 870 871 } 871 map*tmpSize=getMapArray(m,"size",index);872 tmpSize=getMapArray(m,"size",index); 872 873 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ 874 map* ptr=getMapOrFill(&m,tmp,(char *)""); 873 875 #ifdef DEBUG 874 876 fprintf(stderr,"%s\n",tmpSize->value); 875 877 #endif 876 map* ptr=getMapOrFill(&m,tmp,(char *)"");877 878 free(ptr->value); 878 879 ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char)); … … 930 931 maps* tmp=mi; 931 932 maps* _cursor=getMaps(*mo,tmp->name); 932 933 if(_cursor==NULL)934 return -1;935 936 map* tmpLength=getMap(_cursor->content,"length");937 933 char tmpLen[10]; 938 934 int len=1; 939 if(tmpLength!=NULL){940 len=atoi(tmpLength->value);941 }942 943 935 char *tmpV[14]={ 944 936 (char*)"size", … … 957 949 (char*)"UpperCorner" 958 950 }; 951 int i=0; 952 map* tmpLength; 953 954 if(_cursor==NULL) 955 return -1; 956 957 tmpLength=getMap(_cursor->content,"length"); 958 if(tmpLength!=NULL){ 959 len=atoi(tmpLength->value); 960 } 961 959 962 sprintf(tmpLen,"%d",len+1); 960 963 addToMap(_cursor->content,"length",tmpLen); 961 int i=0;962 964 for(i=0;i<14;i++){ 963 965 map* tmpVI=getMap(tmp->content,tmpV[i]); … … 1071 1073 elements* tmp=e; 1072 1074 while(tmp!=NULL){ 1075 iotype* tmpio=tmp->defaults; 1076 int ioc=0; 1073 1077 fprintf(stderr,"ELEMENT [%s]\n",tmp->name); 1074 1078 fprintf(stderr," > CONTENT [%s]\n",tmp->name); … … 1079 1083 dumpMap(tmp->additional_parameters); 1080 1084 fprintf(stderr," > FORMAT [%s]\n",tmp->format); 1081 iotype* tmpio=tmp->defaults;1082 int ioc=0;1083 1085 while(tmpio!=NULL){ 1084 1086 fprintf(stderr," > DEFAULTS [%s] (%i)\n",tmp->name,ioc); … … 1113 1115 int i; 1114 1116 while(tmp!=NULL){ 1117 map* mcurs=tmp->content; 1118 int ioc=0; 1119 iotype* tmpio; 1115 1120 for(i=0;i<2+(4*level);i++) 1116 1121 fprintf(stderr," "); 1117 1122 fprintf(stderr,"%s:\n",tmp->name); 1118 map* mcurs=tmp->content;1119 1123 while(mcurs!=NULL){ 1120 1124 for(i=0;i<4+(4*level);i++) … … 1144 1148 dumpElementsAsYAML(tmp->child,level+1); 1145 1149 } 1146 iotype* tmpio=tmp->defaults; 1147 int ioc=0; 1150 tmpio=tmp->defaults; 1148 1151 while(tmpio!=NULL){ 1149 1152 for(i=0;i<6+(4*level);i++) … … 1225 1228 tmp->defaults=NULL; 1226 1229 if(cursor->supported!=NULL && cursor->supported->content!=NULL){ 1230 iotype *tmp2=cursor->supported->next; 1227 1231 tmp->supported=(iotype*)malloc(IOTYPE_SIZE); 1228 1232 tmp->supported->content=NULL; 1229 1233 addMapToMap(&tmp->supported->content,cursor->supported->content); 1230 1234 tmp->supported->next=NULL; 1231 iotype *tmp2=cursor->supported->next; 1232 while(tmp2!=NULL){ 1235 while(tmp2!=NULL){ 1233 1236 addMapToIoType(&tmp->supported,tmp2->content); 1234 1237 #ifdef DEBUG … … 1373 1376 registry* p=r; 1374 1377 while(p!=NULL){ 1378 services* s=p->content; 1375 1379 fprintf(stderr,"%s \n",p->name); 1376 services* s=p->content;1377 1380 s=p->content; 1378 1381 while(s!=NULL){ … … 1573 1576 */ 1574 1577 void inheritance(registry *r,service** s){ 1578 service* ls=*s; 1579 map *profile,*level; 1575 1580 if(r==NULL) 1576 1581 return; 1577 service* ls=*s; 1578 if(ls->content==NULL) 1582 if(ls==NULL || ls->content==NULL) 1579 1583 return; 1580 map*profile=getMap(ls->content,"extend");1581 map*level=getMap(ls->content,"level");1584 profile=getMap(ls->content,"extend"); 1585 level=getMap(ls->content,"level"); 1582 1586 if(profile!=NULL&&level!=NULL){ 1583 1587 service* s1; … … 1614 1618 memset(tmp,0,1024*10*10); 1615 1619 while(tm!=NULL){ 1620 map* tc=tm->content; 1616 1621 if(i>=10) 1617 1622 break; … … 1620 1625 strcpy(tmp[i][j],tm->name); 1621 1626 j++; 1622 map* tc=tm->content;1623 1627 while(tc!=NULL){ 1624 1628 if(j>=30) -
branches/prototype-v0/zoo-project/zoo-kernel/service.h
r860 r877 35 35 36 36 #ifdef WIN32 37 #define strtok_r strtok_s 37 38 #define strncasecmp _strnicmp 38 39 #define strcasecmp _stricmp … … 196 197 #ifdef WIN32 197 198 #define NULLMAP ((map*) 0) 199 #define bool int 200 #define true 1 201 #define false 0 198 202 #else 199 203 #define NULLMAP NULL … … 295 299 ZOO_DLL_EXPORT void addToMap(map*,const char*,const char*); 296 300 ZOO_DLL_EXPORT void addIntToMap(map*,const char*,const int); 301 ZOO_DLL_EXPORT void addIntToMapArray(map*,const char*,int,const int); 297 302 ZOO_DLL_EXPORT map* addToMapWithSize(map*,const char*,const char*,int); 298 303 ZOO_DLL_EXPORT void addMapToMap(map**,map*); -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
r865 r877 220 220 tmp1 = (char*)malloc((TIME_SIZE+1)*sizeof(char)); 221 221 len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm ); 222 fprintf(stderr,"************************* From thread %d %s %d: RESPONSE CONTENT (%s)\n",pthread_self(),__FILE__,__LINE__, ,tmp1);222 fprintf(stderr,"************************* From thread %d %s %d: RESPONSE CONTENT (%s)\n",pthread_self(),__FILE__,__LINE__,tmp1); 223 223 for(i=0;i<7;i++){ 224 224 fprintf(stderr,"%d) %d %d\n",i,steps[i][0],steps[i][1]); -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.h
r851 r877 36 36 #include <service.h> 37 37 #include <ulinet.h> 38 #include <service_json.h>39 38 40 39 #ifdef __cplusplus -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal.c
r862 r877 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 5GeoLabs SARL4 * Copyright (c) 2009-2018 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 38 38 #endif 39 39 40 #ifdef WIN32 41 // cf. https://stackoverflow.com/questions/3168504/lockfileex-read-write-upgrade-downgrade 42 // only works for (SEEK_SET, start=0, len=0) file locking. 43 __inline int fcntl(int fd, int cmd, ...) 44 { 45 va_list a; 46 va_start(a, cmd); 47 switch(cmd) 48 { 49 case F_SETLK: 50 { 51 struct flock *l = va_arg(a, struct flock*); 52 switch(l->l_type) 53 { 54 case F_RDLCK: 55 { 56 LPOVERLAPPED o = { 0 }; 57 HANDLE h = (HANDLE)_get_osfhandle(fd); 58 if (l->l_whence != SEEK_SET || l->l_start != 0 || l->l_len != 0) 59 { 60 _set_errno(ENOTSUP); 61 return -1; 62 } 63 if (!LockFileEx(h, LOCKFILE_FAIL_IMMEDIATELY, 0, 0, 1, o)) // read lock 64 { 65 unsigned long x = GetLastError(); 66 _set_errno(GetLastError() == ERROR_LOCK_VIOLATION ? EAGAIN : EBADF); 67 return -1; 68 } 69 UnlockFile(h, 0, 0, 1, 1); // write lock 70 } 71 break; 72 case F_WRLCK: 73 { 74 LPOVERLAPPED o = { 0 }; 75 HANDLE h = (HANDLE)_get_osfhandle(fd); 76 if (l->l_whence != SEEK_SET || l->l_start != 0 || l->l_len != 0) 77 { 78 _set_errno(ENOTSUP); 79 return -1; 80 } 81 if (!LockFileEx(h, LOCKFILE_FAIL_IMMEDIATELY|LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 1, o)) // write lock 82 { 83 unsigned long x = GetLastError(); 84 _set_errno(GetLastError() == ERROR_LOCK_VIOLATION ? EAGAIN : EBADF); 85 return -1; 86 } 87 UnlockFile(h, 0, 0, 0, 1); // read lock 88 } 89 break; 90 case F_UNLCK: 91 { 92 HANDLE h = (HANDLE)_get_osfhandle(fd); 93 if (l->l_whence != SEEK_SET || l->l_start != 0 || l->l_len != 0) 94 { 95 _set_errno(ENOTSUP); 96 return -1; 97 } 98 UnlockFile(h, 0, 0, 0, 1); // read lock 99 UnlockFile(h, 0, 0, 1, 1); // write lock 100 } 101 break; 102 default: 103 _set_errno(ENOTSUP); 104 return -1; 105 } 106 } 107 break; 108 case F_SETLKW: 109 { 110 struct flock *l = va_arg(a, struct flock*); 111 switch(l->l_type) 112 { 113 case F_RDLCK: 114 { 115 LPOVERLAPPED o = { 0 }; 116 HANDLE h = (HANDLE)_get_osfhandle(fd); 117 if (l->l_whence != SEEK_SET || l->l_start != 0 || l->l_len != 0) 118 { 119 _set_errno(ENOTSUP); 120 return -1; 121 } 122 if(!LockFileEx(h, 0, 0, 0, 1, o)) // read lock 123 { 124 unsigned long x = GetLastError(); 125 return -1; 126 } 127 UnlockFile(h, 0, 0, 1, 1); // write lock 128 } 129 break; 130 case F_WRLCK: 131 { 132 LPOVERLAPPED o = { 0 }; 133 HANDLE h = (HANDLE)_get_osfhandle(fd); 134 if (l->l_whence != SEEK_SET || l->l_start != 0 || l->l_len != 0) 135 { 136 _set_errno(ENOTSUP); 137 return -1; 138 } 139 if (!LockFileEx(h, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 1, o)) // write lock 140 { 141 unsigned long x = GetLastError(); 142 return -1; 143 } 144 UnlockFile(h, 0, 0, 0, 1); // read lock 145 } 146 break; 147 case F_UNLCK: 148 { 149 flock *l = va_arg(a, flock*); 150 HANDLE h = (HANDLE)_get_osfhandle(fd); 151 if (l->l_whence != SEEK_SET || l->l_start != 0 || l->l_len != 0) 152 { 153 _set_errno(ENOTSUP); 154 return -1; 155 } 156 UnlockFile(h, 0, 0, 0, 1); // read lock 157 UnlockFile(h, 0, 0, 1, 1); // write lock 158 } 159 break; 160 default: 161 _set_errno(ENOTSUP); 162 return -1; 163 } 164 } 165 break; 166 default: 167 _set_errno(ENOTSUP); 168 return -1; 169 } 170 171 return 0; 172 } 173 #endif 174 40 175 #define ERROR_MSG_MAX_LENGTH 1024 41 176 … … 53 188 struct zooLock* myLock=(struct zooLock*)malloc(sizeof(struct flock)+sizeof(FILE*)+sizeof(char*)); 54 189 int len=6; 55 char * template="%s.lock";190 char *myTemplate="%s.lock"; 56 191 int res=-1; 57 192 retryLockFile: 58 193 myLock->filename=(char*)malloc((strlen(filename)+len)*sizeof(char)); 59 sprintf(myLock->filename, "%s.lock",filename);194 sprintf(myLock->filename,myTemplate,filename); 60 195 s=stat(myLock->filename, &f_status); 61 196 if(s==0 && mode!='r'){ … … 64 199 fprintf(stderr,"(%d) Wait for write lock on %s, tried %d times (sleep) ... \n",getpid(),myLock->filename,itn); 65 200 fflush(stderr); 66 sleep(5);201 zSleep(5); 67 202 free(myLock->filename); 68 203 goto retryLockFile; … … 105 240 if((res=fcntl(fileno(myLock->lockfile), F_SETLK, &(myLock->lock)))==-1 && 106 241 (errno==EAGAIN || errno==EACCES)){ 107 if(cnt >= ZOO_LOCK_MAX_RETRY){108 char message[51];109 sprintf(message,"Unable to get the lock after %d attempts.\n",cnt);110 setMapInMaps(conf,"lenv","message",message);111 fclose(myLock->lockfile);112 free(myLock->filename);113 free(myLock);114 return NULL;115 }116 fprintf(stderr,"(%d) Wait for lock on %s, tried %d times ... \n",getpid(),myLock->filename,cnt);117 fflush(stderr);118 sleep(1);119 cnt++;120 121 break;242 if(cnt >= ZOO_LOCK_MAX_RETRY){ 243 char message[51]; 244 sprintf(message,"Unable to get the lock after %d attempts.\n",cnt); 245 setMapInMaps(conf,"lenv","message",message); 246 fclose(myLock->lockfile); 247 free(myLock->filename); 248 free(myLock); 249 return NULL; 250 } 251 fprintf(stderr,"(%d) Wait for lock on %s, tried %d times ... \n",getpid(),myLock->filename,cnt); 252 fflush(stderr); 253 zSleep(1); 254 cnt++; 255 }else 256 break; 122 257 } 123 258 if(res<0){ … … 163 298 164 299 #ifndef RELY_ON_DB 165 #include <dirent.h>300 #include "dirent.h" 166 301 167 302 /** -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal.h
r854 r877 96 96 #endif 97 97 98 #ifdef WIN32 99 // fcntl flock definitions 100 #define F_SETLK 8 // Non-Blocking set or clear a lock 101 #define F_SETLKW 9 // Blocking set or clear a lock 102 #define F_GETLK 10 103 #define F_RDLCK 1 // read lock 104 #define F_WRLCK 2 // write lock 105 #define F_UNLCK 3 // remove lock 106 struct flock { 107 short l_type; // F_RDLCK, F_WRLCK, or F_UNLCK 108 short l_whence; // flag to choose starting offset, must be SEEK_SET 109 long l_start; // relative offset, in bytes, must be 0 110 long l_len; // length, in bytes; 0 means lock to EOF, must be 0 111 short l_pid; // unused (returned with the unsupported F_GETLK) 112 short l_xxx; // reserved for future use 113 }; 114 115 #endif 116 98 117 /** 99 118 * The lock structure used by the ZOO-Kernel to ensure atomicity of operations -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r862 r877 50 50 return; 51 51 } 52 if(*s==NULL || (*s)->outputs==NULL ){52 if(*s==NULL || (*s)->outputs==NULL || (*s)->content==NULL){ 53 53 return; 54 54 } … … 621 621 fprintf(scriptFile,"\n"); 622 622 fprintf(scriptFile,"echo \"Job finished at: $(date)\"\n"); 623 map* footerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_footer"); 624 if(footerMap!=NULL){ 625 // Use the footer file if defined in the HPC section of the main.cfg file 626 struct stat f_status; 627 int s=stat(footerMap->value, &f_status); 628 if(s==0){ 629 char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 630 FILE* f=fopen(footerMap->value,"rb"); 631 fread(fcontent,f_status.st_size,1,f); 632 int fsize=f_status.st_size; 633 fcontent[fsize]=0; 634 fclose(f); 635 char* ffcontent=(char*)malloc((strlen(fcontent)+(3*strlen(uuid->value))+1)*sizeof(char)); 636 sprintf(ffcontent,fcontent,uuid->value,uuid->value,uuid->value); 637 fprintf(scriptFile,"%s\n### --- ZOO-Service FOOTER end --- ###\n\n",ffcontent); 638 free(fcontent); 639 }else 640 fprintf(scriptFile,"### *** Default ZOO-Service FOOTER (footer file failed to load) *** ###\n\n"); 641 }else 642 fprintf(scriptFile,"### *** Default ZOO-Service FOOTER (no footer found) *** ###\n\n"); 623 643 fflush(scriptFile); 624 644 fclose(scriptFile); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_java.c
r863 r877 208 208 #endif 209 209 #ifdef JAVA7 210 cls_gr = (*env) NewGlobalRef(cls);210 cls_gr = (*env).NewGlobalRef(cls); 211 211 #else 212 212 cls_gr = (*env)->NewGlobalRef(env, cls); … … 215 215 if (cls != NULL) { 216 216 #ifdef JAVA7 217 @(*env).ExceptionClear();217 (*env).ExceptionClear(); 218 218 pmid=(*env).GetStaticMethodID(cls, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I"); 219 219 #else … … 284 284 } 285 285 #ifdef JAVA7 286 286 (*jvm).DestroyJavaVM(); 287 287 #else 288 288 (*jvm)->DestroyJavaVM(jvm); … … 438 438 jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value)); 439 439 (*env).SetByteArrayRegion(tmpData,0,atoi(sizeV->value),(const jbyte *)tmp1->value); 440 (*env).CallObjectMethod( env,scObject1, put_mid, (*env).NewStringUTF(env,tmp1->name), tmpData);440 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), tmpData); 441 441 #else 442 442 jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value)); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r867 r877 1020 1020 m->outputformatlist[outputIndex]->imagemode=((pixel_type==GDT_Byte)?MS_IMAGEMODE_BYTE:((pixel_type==GDT_Int16 || pixel_type==GDT_UInt16)?MS_IMAGEMODE_INT16:((pixel_type!=GDT_Float32)?MS_IMAGEMODE_FLOAT32:MS_IMAGEMODE_BYTE))); 1021 1021 outputIndex=msGetOutputFormatIndex(m,"geotiff"); 1022 m->outputformatlist[outputIndex]->imagemode=((pixel_type==GDT_Byte)?MS_IMAGEMODE_BYTE:((pixel_type==GDT_Int16 || pixel_type==GDT_UInt16)?MS_IMAGEMODE_INT16:((pixel_type!=GDT_Float32)?MS_IMAGEMODE_FLOAT32:MS_IMAGEMODE_BYTE))); 1022 if(outputIndex>=0) 1023 m->outputformatlist[outputIndex]->imagemode=((pixel_type==GDT_Byte)?MS_IMAGEMODE_BYTE:((pixel_type==GDT_Int16 || pixel_type==GDT_UInt16)?MS_IMAGEMODE_INT16:((pixel_type!=GDT_Float32)?MS_IMAGEMODE_FLOAT32:MS_IMAGEMODE_BYTE))); 1023 1024 } 1024 1025 // -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_r.c
r873 r877 379 379 int istatus; 380 380 char* cstatus=NULL; 381 if (!isInteger(status) ){381 if (!isInteger(status) && !isReal(status)){ 382 382 #ifdef DEBUG 383 383 fprintf(stderr,"Incorrect arguments to update status function"); … … 385 385 return R_NilValue; 386 386 } 387 istatus=asInteger(status); 387 if(isInteger(status)) 388 istatus=asInteger(status); 389 else 390 istatus=asReal(status); 388 391 if (istatus < 0 || istatus > 100){ 389 392 return R_NilValue; -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r862 r877 96 96 97 97 map* hpc_config=getMapFromMaps(conf,"lenv","configId"); 98 99 98 map* hpc_host=getMapFromMaps(conf,hpc_config->value,"ssh_host"); 100 99 map* hpc_port=getMapFromMaps(conf,hpc_config->value,"ssh_port"); … … 102 101 map* hpc_password=getMapFromMaps(conf,hpc_config->value,"ssh_password"); 103 102 map* hpc_public_key=getMapFromMaps(conf,hpc_config->value,"ssh_key"); 104 103 105 104 char ip[100]; 106 105 struct hostent *my_hostent; -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_loader.c
r862 r877 68 68 fprintf(FCGI_stderr,"ZOO-Kernel initialization %s %d ... \n",__FILE__,__LINE__); 69 69 fflush(FCGI_stderr); 70 return 0; 70 71 } 71 72 -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c
r873 r877 68 68 #ifdef WIN32 69 69 #include "caching.h" 70 extern wchar_t**_wenviron; 70 71 #endif 71 72 … … 111 112 #include <dirent.h> 112 113 #include <signal.h> 114 #ifndef WIN32 113 115 #include <execinfo.h> 116 #endif 114 117 #include <unistd.h> 115 118 #ifndef WIN32 … … 365 368 fflush (stderr); 366 369 #endif 367 inheritance(r,&s1); 370 if(s1!=NULL) 371 inheritance(r,&s1); 368 372 func (r, m, doc, n, s1); 369 373 freeService (&s1); … … 1449 1453 r_inputs = NULL; 1450 1454 r_inputs = getMap (request_inputs, "version"); 1455 #ifdef DEBUG 1451 1456 fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__); 1452 1457 fflush(stderr); 1458 #endif 1453 1459 xmlNodePtr n = printWPSHeader(doc,m,"DescribeProcess", 1454 1460 root_nodes[vid][1],(version!=NULL?version->value:"1.0.0"),1); … … 1628 1634 hasVal = 1; 1629 1635 setMapInMaps (m, "lenv", "level", "0"); 1630 /*1631 #ifdef META_DB1632 }1633 #endif1634 */1635 1636 } 1636 1637 else … … 1726 1727 addNestedOutputs(&s1); 1727 1728 #endif 1728 json_object* jobj=serviceToJson(s1);1729 /*json_object* jobj=serviceToJson(s1); 1729 1730 const char* jsonStr=json_object_to_json_string_ext(jobj,JSON_C_TO_STRING_PLAIN); 1730 fprintf(stderr,"*** %s %d %s \n",__FILE__,__LINE__,jsonStr); 1731 fprintf(stderr,"*** %s %d %s \n",__FILE__,__LINE__,jsonStr);*/ 1731 1732 1732 1733 printDescribeProcessForProcess (zooRegistry,m, doc, n, s1); … … 1942 1943 dup2 (fileno (stderr), fileno (stdout)); 1943 1944 t = readServiceFile (m, tmps1, &s1, r_inputs->value); 1944 inheritance(zooRegistry,&s1); 1945 fprintf(stderr,"%d %s %d",t,__FILE__,__LINE__); 1946 fflush(stderr); 1947 if(t>=0){ 1948 inheritance(zooRegistry,&s1); 1945 1949 #ifdef USE_HPC 1946 addNestedOutputs(&s1); 1947 #endif 1950 addNestedOutputs(&s1); 1951 #endif 1952 } 1948 1953 if(zooRegistry!=NULL){ 1949 1954 freeRegistry(&zooRegistry); … … 2254 2259 #endif 2255 2260 int ei = 1; 2256 char **orig =2261 2257 2262 #ifdef WIN32 2258 GetEnvironmentStrings() 2263 LPVOID orig = GetEnvironmentStrings(); 2264 LPTSTR s = (LPTSTR) orig; 2259 2265 #else 2260 environ 2261 #endif 2262 ; 2266 char **orig = environ; 2263 2267 char *s=*orig; 2268 #endif 2269 2264 2270 _tmpMaps = createMaps("renv"); 2265 2271 for (; s; ei++) { … … 2277 2283 free(tmpName); 2278 2284 } 2285 #ifdef WIN32 2286 s++; 2287 #else 2279 2288 s = *(orig+ei); 2289 #endif 2280 2290 } 2281 2291 if(_tmpMaps->content!=NULL && getMap(_tmpMaps->content,"HTTP_COOKIE")!=NULL){ … … 2285 2295 freeMaps (&_tmpMaps); 2286 2296 free (_tmpMaps); 2297 2287 2298 if(postRequest!=NULL) 2288 2299 setMapInMaps (m, "renv", "xrequest", postRequest->value); … … 2335 2346 return -1; 2336 2347 } 2348 map* testMap=getMapFromMaps(m,"main","memory"); 2349 if(testMap!=NULL && strcasecmp(testMap->value,"load")!=0) 2350 dumpMapsValuesToFiles(&m,&request_input_real_format); 2337 2351 loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format, 2338 2352 &request_output_real_format, &eres); … … 2379 2393 else if (pid == 0) 2380 2394 { 2395 eres = SERVICE_ACCEPTED; 2381 2396 // 2382 2397 // son : have to close the stdout, stdin and stderr to let the parent … … 2457 2472 recordServiceStatus(m); 2458 2473 #endif 2474 #ifdef USE_HPC 2459 2475 invokeCallback(m,NULL,NULL,0,0); 2476 #endif 2460 2477 if(vid==0){ 2461 2478 // … … 2499 2516 free(flenv); 2500 2517 2518 #ifdef USE_HPC 2501 2519 invokeCallback(m,request_input_real_format,NULL,1,0); 2520 #endif 2502 2521 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2503 2522 freeService (&s1); … … 2514 2533 #else 2515 2534 recordResponse(m,fbkp1); 2535 #ifdef USE_HPC 2516 2536 invokeCallback(m,NULL,NULL,7,0); 2537 #endif 2517 2538 #endif 2518 2539 unlink (fbkpid); … … 2539 2560 if(getMapFromMaps(m,"lenv","mapError")!=NULL){ 2540 2561 setMapInMaps(m,"lenv","message",_("Issue with geographic data")); 2562 #ifdef USE_HPC 2541 2563 invokeCallback(m,NULL,NULL,7,0); 2564 #endif 2542 2565 eres=-1;//SERVICE_FAILED; 2543 2566 }else{ 2567 map* testMap=getMapFromMaps(m,"main","memory"); 2568 if(testMap!=NULL && strcasecmp(testMap->value,"load")!=0) 2569 dumpMapsValuesToFiles(&m,&request_input_real_format); 2544 2570 loadServiceAndRun (&m, s1, request_inputs, 2545 2571 &request_input_real_format, … … 2567 2593 rewind(stdout); 2568 2594 2569 fprintf(stderr,"%s %d %d\n",__FILE__,__LINE__,eres);2595 //fprintf(stderr,"%s %d %d\n",__FILE__,__LINE__,eres); 2570 2596 2571 2597 if (eres != -1) … … 2592 2618 { 2593 2619 if (eres == SERVICE_SUCCEEDED) 2620 #ifdef USE_HPC 2594 2621 invokeCallback(m,NULL,request_output_real_format,5,1); 2595 2622 #endif 2596 2623 fflush(stderr); 2597 2624 fflush(stdout); … … 2622 2649 recordResponse(m,fbkp1); 2623 2650 if (eres == SERVICE_SUCCEEDED) 2651 #ifdef USE_HPC 2624 2652 invokeCallback(m,NULL,request_output_real_format,6,0); 2653 #endif 2625 2654 #endif 2626 2655 freeMaps(&bmap);
Note: See TracChangeset
for help on using the changeset viewer.