Changeset 880
- Timestamp:
- Sep 12, 2018, 4:02:49 PM (6 years ago)
- Location:
- branches/prototype-v0/zoo-project/zoo-kernel
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/Makefile.in
r873 r880 129 129 zcfg2yaml: zcfg2yaml.c service.h lex.sr.o service_conf.tab.o service_conf.y main_conf_read.tab.o lex.cr.o response_print.o server_internal.o service_internal.o ${MS_FILE} ${YAML_FILE} 130 130 g++ -g -O2 ${JSCFLAGS} ${RUBYCFLAGS} ${XML2CFLAGS} ${CFLAGS} -c zcfg2yaml.c -fno-common -DPIC -o zcfg2yaml.o 131 g++ ${XML2CFLAGS} ${CFLAGS} zcfg2yaml.o ulinet.o service_callback.o server_internal.o service_internal.o ${MS_FILE} response_print.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o ${YAML_FILE} -o zcfg2yaml -L. ${LDFLAGS}131 g++ ${XML2CFLAGS} ${CFLAGS} zcfg2yaml.o caching.o ulinet.o service_callback.o server_internal.o service_internal.o ${MS_FILE} response_print.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o ${YAML_FILE} -o zcfg2yaml -L. ${LDFLAGS} 132 132 133 133 install: zoo_loader.cgi -
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r877 r880 67 67 */ 68 68 char* getMd5f(char* file){ 69 EVP_MD_CTX md5ctx;69 EVP_MD_CTX *md5ctx=EVP_MD_CTX_create(); 70 70 char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char)); 71 71 unsigned char result[EVP_MAX_MD_SIZE]; 72 72 unsigned int len; 73 73 int bytes; 74 unsigned char data[1024]; 74 int dlen=65536; 75 unsigned char data[dlen+1]; 75 76 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); 77 EVP_DigestInit(md5ctx, EVP_md5()); 78 while ((bytes = fread (data, sizeof(unsigned char), dlen, inFile)) != 0) 79 EVP_DigestUpdate(md5ctx, data, bytes); 80 EVP_DigestFinal_ex(md5ctx,result,&len); 81 EVP_MD_CTX_cleanup(md5ctx); 82 EVP_MD_CTX_destroy(md5ctx); 81 83 int i; 82 84 for(i = 0; i < len; i++){ … … 162 164 163 165 /** 166 * Store MD5 of the content of a file 167 * @file char* the full path of the file 168 */ 169 int storeMd5(char* file){ 170 char* storage=zStrdup(file); 171 char* md5fstr=getMd5f(file); 172 storage[strlen(storage)-2]='m'; 173 storage[strlen(storage)-1]='d'; 174 FILE* fo=fopen(storage,"w+"); 175 if(fo==NULL) 176 return 1; 177 fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo); 178 free(md5fstr); 179 fclose(fo); 180 return 0; 181 } 182 183 /** 164 184 * Cache a file for a given request. 165 185 * For each cached file, the are two files stored, a .zca and a .zcm containing … … 177 197 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 178 198 char contentr[4096]; 179 char* md5fstr=NULL;180 199 int cred=0; 181 200 if(tmp!=NULL){ … … 184 203 free(myRequest); 185 204 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 205 // Store md5 206 char* md5fstr=getMd5f(filename); 207 sprintf(fname,"%s/%s.zmd",tmp->value,md5str); 208 FILE* fo=fopen(fname,"w+"); 209 #ifdef DEBUG 210 fprintf(stderr,"filename: %s\n",filename); 211 fprintf(stderr,"MD5: %s\n",md5fstr); 212 #endif 213 fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo); 214 free(md5fstr); 215 fclose(fo); 216 186 217 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 187 218 zooLock* lck=lockFile(conf,fname,'w'); … … 192 223 #endif 193 224 FILE* fi=fopen(filename,"rb"); 194 FILE* fo=fopen(fname,"w+"); 225 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 226 fo=fopen(fname,"w+"); 195 227 if(fo==NULL){ 196 228 #ifdef DEBUG … … 236 268 fclose(fo); 237 269 238 // Store md5239 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 DEBUG244 fprintf(stderr,"MD5: %s\n",md5fstr);245 #endif246 fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo);247 free(md5fstr);248 fclose(fo);249 250 270 free(md5str); 251 free(fname); 252 } 271 272 } 273 free(fname); 253 274 } 254 275 } … … 342 363 } 343 364 else{ 344 345 365 char* myRequest=getFilenameForRequest(conf,request); 346 366 char* md5str=getMd5(myRequest); … … 436 456 437 457 if(getMap(content->content,icname)==NULL) { 438 if(memUse !=NULL &&strcasecmp(memUse->value,"load")==0){458 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 439 459 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 440 460 if(fcontent == NULL){ … … 456 476 457 477 map* tmpMap=getMapOrFill(&(*in)->content,vname,""); 458 if(memUse !=NULL &&strcasecmp(memUse->value,"load")==0){478 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 459 479 free(tmpMap->value); 460 480 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); … … 518 538 addToMap((*in)->content,sname,ltmp1); 519 539 addToMap((*in)->content,mname,mimeType); 520 if(memUse !=NULL &&strcasecmp(memUse->value,"load")==0){540 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 521 541 addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0); 522 542 free(fcontent); … … 628 648 return -1; 629 649 fsize=f_status.st_size; 630 if(memUse !=NULL &&strcasecmp(memUse->value,"load")==0){650 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 631 651 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 632 652 FILE* f=fopen(cached,"rb"); … … 665 685 666 686 map* tmpMap=getMapOrFill(content,"value",""); 667 if(memUse !=NULL &&strcasecmp(memUse->value,"load")==0){687 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 668 688 free(tmpMap->value); 669 689 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); … … 677 697 addToMap(*content,"size",ltmp1); 678 698 if(cached==NULL){ 679 if(memUse !=NULL &&strcasecmp(memUse->value,"load")==0)699 if(memUse==NULL || strcasecmp(memUse->value,"load")==0) 680 700 addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0); 681 701 else -
branches/prototype-v0/zoo-project/zoo-kernel/caching.h
r797 r880 35 35 void addRequestToQueue(maps**,HINTERNET*,const char*,bool); 36 36 int loadRemoteFile(maps**,map**,HINTERNET*,char*); 37 37 char* getMd5f(char*); 38 int storeMd5(char*); 39 38 40 #ifdef __cplusplus 39 41 } -
branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c
r877 r880 978 978 979 979 map *test = getMap (tmpmaps->content, "encoding"); 980 981 980 if (test == NULL) 982 981 { … … 992 991 if (getMap(tmpmaps->content,"dataType")==NULL && test!=NULL && strcasecmp (test->value, "base64") != 0) 993 992 { 994 xmlChar *mv = xmlNodeListGetString (doc, 995 cur4->xmlChildrenNode, 996 1); 993 xmlChar *mv = NULL; 994 /*if(cur4!=NULL && cur4->xmlChildrenNode!=NULL) 995 xmlChar *mv = xmlNodeListGetString (doc, 996 cur4->xmlChildrenNode, 997 1);*/ 997 998 map *ltmp = 998 getMap (tmpmaps->content, "mimeType"); 999 if ( mv == NULL1000 || 999 getMap (tmpmaps->content, "mimeType"); 1000 if (/*mv == NULL 1001 ||*/ 1001 1002 (xmlStrcasecmp 1002 1003 (cur4->name, BAD_CAST "ComplexData") == 0 … … 1036 1037 buffersize); 1037 1038 }else{ 1039 1038 1040 if(xmlStrcasecmp 1039 1041 (cur4->name, BAD_CAST "BoundingBoxData") == 0){ … … 1051 1053 while (cur5 != NULL 1052 1054 && cur5->type != XML_ELEMENT_NODE 1055 && cur5->type != XML_TEXT_NODE 1053 1056 && cur5->type != XML_CDATA_SECTION_NODE) 1054 1057 cur5 = cur5->next; 1055 1058 if (cur5 != NULL 1056 && cur5->type != XML_CDATA_SECTION_NODE) 1059 && cur5->type != XML_CDATA_SECTION_NODE 1060 && cur5->type != XML_TEXT_NODE) 1057 1061 { 1058 1062 xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0"); … … 1065 1069 buffersize); 1066 1070 } 1067 else /*if (cur5 != NULL1071 else if (cur5 != NULL)/* 1068 1072 && cur5->type == XML_CDATA_SECTION_NODE)*/{ 1069 1073 xmlFree(mv); 1070 mv=xmlStrdup(cur5->content); 1074 if(cur5->content!=NULL){ 1075 mv=xmlStrdup(cur5->content); 1076 } 1071 1077 } 1072 1078 } … … 1150 1156 } 1151 1157 } 1152 else 1158 else{ 1153 1159 addMapsToMaps (request_output, tmpmaps); 1160 } 1154 1161 } 1155 1162 freeMaps (&tmpmaps); -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.h
r877 r880 38 38 39 39 #include <libintl.h> 40 #include < locale.h>40 #include <xlocale.h> 41 41 /** 42 42 * ZOO-Kernel internal messages translation function … … 80 80 #endif 81 81 #ifndef WIN32 82 #include < xlocale.h>82 #include <locale.h> 83 83 #endif 84 84 #include "ulinet.h" -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal.h
r877 r880 38 38 39 39 #include <libintl.h> 40 #include < locale.h>40 #include <xlocale.h> 41 41 /** 42 42 * ZOO-Kernel internal messages translation function -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r877 r880 34 34 #include "server_internal.h" 35 35 #include "response_print.h" 36 #include "caching.h" 36 37 37 38 /** … … 1235 1236 GDALDestroyDriverManager(); 1236 1237 CPLCleanupTLS(); 1238 storeMd5(pszFilename); 1237 1239 return 1; 1238 1240 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_r.c
r877 r880 110 110 if(tmp!=NULL){ 111 111 if(mp!=NULL && strlen(mp->value)>0){ 112 char *mps=zStrdup(mp->value); 113 int i,len=strlen(mps); 114 int j=0; 115 for(i=0;i<len;i++){ 116 if(mps[i]=='/'){ 117 mps[i]='.'; 118 } 119 } 120 char *mn=(char*)malloc((strlen(mps)+strlen(tmp->value)+2)*sizeof(char)); 121 sprintf(mn,"%s.%s",mps,tmp->value); 112 char *mn=(char*)malloc((strlen(mp->value)+strlen(tmp->value)+2)*sizeof(char)); 113 sprintf(mn,"%s/%s",mp->value,tmp->value); 122 114 pName = mkString(mn); 123 115 free(mn); 124 free(mps);125 116 } 126 117 else{ 127 dumpMap(tmp);128 118 char *tmpStr=(char*)malloc((strlen(r_path)+strlen(tmp->value)+2)*sizeof(char)); 129 119 sprintf(tmpStr,"%s/%s",r_path,tmp->value); … … 189 179 char* finalStr=(char*)malloc((strlen(tmpStr)+strlen(_("Unable to run your R service: "))+2)*sizeof(char)); 190 180 sprintf(finalStr,"%s %s",_("Unable to run your R service: "),tmpStr); 191 fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,tmpStr);192 fflush(stderr);193 181 errorException(*main_conf,finalStr,"NoApplicableCode",NULL); 194 182 free(finalStr); -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h
r871 r880 45 45 #include "jsapi.h" 46 46 #endif 47 #ifndef __cplusplus 47 48 #ifndef bool 48 49 #define bool int … … 51 52 #define true 1 52 53 #define false 0 54 #endif 53 55 #endif 54 56 -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c
r877 r880 107 107 #endif 108 108 109 #ifdef USE_HPC 109 110 #include "service_json.h" 110 111 #include "service_callback.h" 112 #endif 111 113 112 114 #include <dirent.h> … … 2347 2349 } 2348 2350 map* testMap=getMapFromMaps(m,"main","memory"); 2349 if(testMap !=NULL &&strcasecmp(testMap->value,"load")!=0)2351 if(testMap==NULL || strcasecmp(testMap->value,"load")!=0) 2350 2352 dumpMapsValuesToFiles(&m,&request_input_real_format); 2351 2353 loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format,
Note: See TracChangeset
for help on using the changeset viewer.