Changeset 889
- Timestamp:
- Jan 3, 2019, 12:44:57 PM (6 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/request_parser.c
r870 r889 628 628 if (l == 4 ) 629 629 { 630 if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0)) 630 if ((ltmp==NULL || strncasecmp (ltmp->value, "POST",4) != 0)) // 631 //if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0)) 631 632 { 632 633 if (loadRemoteFile … … 1168 1169 } 1169 1170 } 1171 return 0; 1170 1172 } 1171 1173 … … 1468 1470 1469 1471 xmlInitParser (); 1470 xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER); 1472 //xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER); 1473 xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER | XML_PARSE_HUGE); // 1471 1474 1472 1475 /** -
trunk/zoo-project/zoo-kernel/response_print.c
r820 r889 2611 2611 map* tmpIV=getMap(request_inputs1,"RawDataOutput"); 2612 2612 if(tmpIV!=NULL){ 2613 tmpI=getMaps(request_outputs,tmpIV->value); 2613 tmpI=getMaps(request_outputs,tmpIV->value); 2614 2614 } 2615 2615 if(tmpI==NULL) 2616 2616 tmpI=request_outputs; 2617 2617 2618 elements* e=getElements(s->outputs,tmpI->name); 2618 2619 if(e!=NULL && strcasecmp(e->format,"BoundingBoxData")==0){ … … 2621 2622 map *gfile=getMap(tmpI->content,"generated_file"); 2622 2623 if(gfile!=NULL){ 2623 gfile=getMap(tmpI->content,"expected_generated_file"); 2624 gfile=getMap(tmpI->content,"expected_generated_file"); 2624 2625 if(gfile==NULL){ 2625 2626 gfile=getMap(tmpI->content,"generated_file"); … … 2627 2628 readGeneratedFile(m,tmpI->content,gfile->value); 2628 2629 } 2629 toto=getMap(tmpI->content,"value"); 2630 toto=getMap(tmpI->content,"value"); 2630 2631 if(toto==NULL){ 2631 2632 char tmpMsg[1024]; … … 2633 2634 errorException(m,tmpMsg,"InvalidParameterValue","RawDataOutput"); 2634 2635 return; 2635 } 2636 map* fname=getMapFromMaps(tmpI,tmpI->name,"filename"); 2636 } 2637 map* fname=getMapFromMaps(tmpI,tmpI->name,"filename"); 2637 2638 if(fname!=NULL) 2638 2639 printf("Content-Disposition: attachment; filename=\"%s\"\r\n",fname->value); -
trunk/zoo-project/zoo-kernel/server_internal.c
r820 r889 942 942 (char *) 943 943 malloc ((strlen (r_inputs->value) + strlen (pid) + 7) * sizeof (char)); 944 sprintf (fbkpid, "%s/%s.pid", r_inputs->value, pid); 944 sprintf (fbkpid, "%s/%s.pid", r_inputs->value, pid); 945 945 FILE* f0 = fopen (fbkpid, "r"); 946 946 if(f0!=NULL){ … … 970 970 }else{ 971 971 map* statusInfo=createMap("JobID",pid); 972 if(isRunning(conf,pid)>0){ 972 if(isRunning(conf,pid)>0){ 973 973 if(strncasecmp(req,"GetResult",strlen(req))==0){ 974 974 errorException (conf, _("The result for the requested JobID has not yet been generated. "), -
trunk/zoo-project/zoo-kernel/service.c
r868 r889 25 25 #include "service.h" 26 26 27 // knut: time utilities required for new log function (logMessage) 28 #include <ctime> 29 #include <chrono> 30 #include <process.h> 27 31 28 32 #if defined(_MSC_VER) && _MSC_VER < 1800 … … 450 454 */ 451 455 void addToMap(map* m,const char* n,const char* v){ 452 if(hasKey(m,n)==false){ 453 map* _cursor=m; 454 while(_cursor->next!=NULL){ 455 _cursor=_cursor->next; 456 } 457 _cursor->next=createMap(n,v); 458 } 459 else{ 460 map *tmp=getMap(m,n); 461 if(tmp->value!=NULL) 462 free(tmp->value); 463 tmp->value=zStrdup(v); 456 if (m != NULL) { // knut: add NULL-pointer check 457 if(hasKey(m,n)==false){ 458 map* _cursor=m; 459 while(_cursor->next!=NULL){ 460 _cursor=_cursor->next; 461 } 462 _cursor->next=createMap(n,v); 463 } 464 else{ 465 map *tmp=getMap(m,n); 466 if(tmp->value!=NULL) 467 free(tmp->value); 468 tmp->value=zStrdup(v); 469 } 464 470 } 465 471 } … … 1597 1603 } 1598 1604 1605 /** 1606 * Verify that a map has a value 1607 * 1608 * @param map pointer to map that should be checked 1609 * @return true if map has a value or false if value is missing/empty/NULL 1610 */ 1611 bool nonempty( map* map ) { 1612 return ( map != NULL && map->value != NULL && strlen(map->value) > 0 && strcmp(map->value, "NULL") != 0 ); 1613 } 1614 1615 /** 1616 * Verify that a particular map value exists in a maps 1617 * data structure, and obtain that value 1618 * 1619 * @param source pointer to maps structure 1620 * @param node name of maps node to search 1621 * @param key name of map node to find 1622 * @param address to the map* if it exists, otherwise NULL 1623 * @return true if map has a value or false if value is missing/NULL 1624 */ 1625 bool hasvalue( maps* source, const char* node, const char* key, map** kvp ) { 1626 *kvp = getMapFromMaps(source, node, key); 1627 return ( *kvp != NULL && (*kvp)->value != NULL && 1628 strlen((*kvp)->value) > 0 && strcmp((*kvp)->value, "NULL") != 0 ); 1629 } 1630 1631 /* 1632 * Set error message in configuration maps 1633 * 1634 * @param conf reference to configuration maps 1635 * @param service name of service 1636 * @param exc WPSException code 1637 * @param message exception text (default: exception text in WPS specification) 1638 */ 1639 void setErrorMessage( maps*& conf, const char* service, WPSException exc, const char* message ) { 1640 1641 if (message == NULL) { 1642 message = WPSExceptionText[exc]; 1643 } 1644 1645 size_t len = strlen( service ) + strlen(": ") + strlen( message ) + strlen(": ") + strlen(WPSExceptionCode[exc]) + 16; 1646 char* msg = (char*) malloc( len * sizeof(char) ); 1647 1648 if (msg != NULL) { 1649 snprintf( msg, len*sizeof(char), "\n%s: %s: %s\n", service, message, WPSExceptionCode[exc] ); 1650 setMapInMaps( conf, "lenv", "message", msg ); 1651 free( msg ); 1652 } 1653 } 1654 1655 void logMessage(const char* source, const char* function, int line, const char* file, const char* message) { //, const char* source, const char* function, int line) { 1656 1657 size_t msglen = 512; 1658 const char empty[] = ""; 1659 1660 FILE* log; 1661 1662 // system time, process time [nanoseconds] 1663 unsigned long long sys_t, proc_t; 1664 1665 // processor time consumed by the program: 1666 clock_t t = clock(); 1667 1668 // system time: 1669 std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); 1670 1671 std::time_t now_t = std::chrono::system_clock::to_time_t( now ); 1672 std::tm* tm = localtime( &now_t ); 1673 char* str = asctime(tm); 1674 str[strlen(str)-1] = '\0'; // remove newline 1675 1676 sys_t = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count(); 1677 //proc_t = (unsigned long long)(1.0e9*t/CLOCKS_PER_SEC); 1678 proc_t = t; 1679 1680 if ( message != NULL ) { 1681 msglen += strlen(message); 1682 } 1683 else { 1684 message = empty; 1685 } 1686 //getLastErrorMessage(); // cgiScriptName 1687 char* text = (char*) malloc( sizeof(char)*msglen ); 1688 1689 snprintf( text, msglen, "pid: %d %s line %d %s() %s systime: %lld ns ticks: %lld %s\n", 1690 _getpid(), source, line, function, str, sys_t, proc_t, message ); // __FILE__ __LINE__ __func__ // 1691 1692 if ( file != NULL && (log = fopen( file, "a+" )) != NULL ) { 1693 fputs( text, log ); 1694 fclose( log ); 1695 } 1696 else { 1697 #ifdef MSG_LOG_FILE 1698 if ( (log = fopen( MSG_LOG_FILE, "a+" )) != NULL ) { 1699 fputs( text, log ); 1700 fclose( log ); 1701 } 1702 #endif 1703 } 1704 1705 if ( text != NULL ) free( text ); 1706 } 1707 1708 // knut: 1709 // Example: 1710 // zooLog; 1711 // zooLogMsg(NULL, getLastErrorMessage()); 1712 // zooLogMsg(log.txt, getLastErrorMessage()); 1713 1599 1714 #ifdef WIN32 1600 1715 #ifndef USE_MS -
trunk/zoo-project/zoo-kernel/service.h
r847 r889 40 40 #endif 41 41 42 // knut: add bool if necessary 43 #ifndef __cplusplus 44 #ifndef WIN32 45 #include <stdbool.h> 46 #else 47 typedef int bool; 48 #define false 0 49 #define true 1 50 #endif 51 #endif 52 #ifndef __bool_true_false_are_defined 53 #define __bool_true_false_are_defined 1 54 #endif 55 42 56 #ifdef WIN32 43 57 #define strncasecmp _strnicmp … … 47 61 #define snprintf _snprintf 48 62 #endif 63 /* knut: see new definition of bool above 49 64 #if defined(_MSC_VER) && _MSC_VER < 1800 50 65 #define false 0 … … 52 67 #define bool int 53 68 #endif 69 */ 54 70 #define zStrdup _strdup 55 71 #define zMkdir _mkdir … … 124 140 #ifndef WIN32 125 141 #include <ctype.h> 126 #include <stdbool.h> 142 //#include <stdbool.h> // knut: see new definition of bool above 127 143 #endif 128 144 … … 274 290 struct registry* next; //!< the next registry pointer 275 291 } registry; 292 293 // knut 294 enum WPSException { 295 /* 296 * StatusOK is not a WPS exception, it is added 297 * here for convenience. 298 */ 299 StatusOK, 300 /* 301 * See WPS 1.0 specification, Table 38 and Table 62. 302 */ 303 MissingParameterValue, 304 InvalidParameterValue, 305 NoApplicableCode, 306 NotEnoughStorage, 307 ServerBusy, 308 FileSizeExceeded, 309 StorageNotSupported, 310 VersionNegotiationFailed, 311 /* 312 * See WPS 2.0 specification, Tables 41, 46, 48, and 50. 313 */ 314 NoSuchProcess, 315 NoSuchMode, 316 NoSuchInput, 317 NoSuchOutput, 318 DataNotAccessible, 319 SizeExceeded, 320 TooManyInputs, 321 TooManyOutputs, 322 NoSuchFormat, 323 WrongInputData, 324 InternalServerError, 325 NoSuchJob, 326 ResultNotReady 327 }; 328 329 static const char* const WPSExceptionCode[] = { 330 "StatusOK", 331 "MissingParameterValue", 332 "InvalidParameterValue", 333 "NoApplicableCode", 334 "NotEnoughStorage", 335 "ServerBusy", 336 "FileSizeExceeded", 337 "StorageNotSupported", 338 "VersionNegotiationFailed", 339 "NoSuchProcess", 340 "NoSuchMode", 341 "NoSuchInput", 342 "NoSuchOutput", 343 "DataNotAccessible", 344 "SizeExceeded", 345 "TooManyInputs", 346 "TooManyOutputs", 347 "NoSuchFormat", 348 "WrongInputData", 349 "InternalServerError", 350 "NoSuchJob", 351 "ResultNotReady" 352 }; 353 354 static const char* const WPSExceptionText[] = { 355 "No problem detected", 356 "Operation request does not include a parameter value, and this server did not declare a default value for that parameter.", 357 "Operation request contains an invalid parameter value.", 358 "No other exceptionCode specified by this service and server applies to this exception.", 359 "The server does not have enough space available to store the inputs and outputs associated with the request.", 360 "The server is too busy to accept and queue the request at this time.", 361 "The file size of one of the input parameters was too large for this process to handle.", 362 "Execute operation request included transmission=”reference” for one of the outputs, but storage is not offered by this server.", 363 "Service version for a ComplexData xlink:href input was not supported by the referenced server, and version negotiation failed.", 364 "One of the identifiers passed does not match with any of the processes offered by this server.", 365 "The process does not permit the desired execution mode.", 366 "One or more of the input identifiers passed does not match with any of the input identifiers of this process.", 367 "One or more of the output identifiers passed does not match with any of the input identifiers of this process.", 368 "One of the referenced input data sets was inaccessible.", 369 "The size of one of the input parameters was too large for this process to handle.", 370 "Too many input items have been specified.", 371 "Too many output items have been specified.", 372 "One or more of the input or output formats specified in the request did not match with any of the formats defined for that particular input or output.", 373 "One or more of inputs for which the service was able to retrieve the data but could not read it.", 374 "", 375 "The JobID from the request does not match any of the Jobs running on this server.", 376 "The result for the requested JobID has not yet been generated." 377 }; 276 378 277 379 ZOO_DLL_EXPORT void _dumpMap(map*); … … 340 442 ZOO_DLL_EXPORT int snprintf(char *buffer, size_t n, const char *format, ...); 341 443 #endif 444 445 // knut: some new utility functions; logMessage is primarily intended for debugging 446 ZOO_DLL_EXPORT bool nonempty(map* map); 447 ZOO_DLL_EXPORT bool hasvalue(maps* source, const char* node, const char* key, map** kvp); 448 ZOO_DLL_EXPORT void setErrorMessage(maps*& conf, const char* service, WPSException exc, const char* message = NULL); 449 ZOO_DLL_EXPORT void logMessage(const char* source, const char* function, int line, const char* file = NULL, const char* message = NULL); 450 #define zooLogMsg(file,message) logMessage(__FILE__, __func__, __LINE__, (file), (message)) 451 #define zooLog logMessage(__FILE__, __func__, __LINE__) 452 342 453 #ifdef __cplusplus 343 454 } -
trunk/zoo-project/zoo-kernel/service_internal.c
r788 r889 243 243 * @param conf the map containing the setting of the main.cfg file 244 244 */ 245 void unhandleStatus(maps *conf){ 245 void unhandleStatus(maps *conf){ 246 246 map* r_inputs = getMapFromMaps (conf, "main", "tmpPath"); 247 247 map* usid = getMapFromMaps (conf, "lenv", "usid"); -
trunk/zoo-project/zoo-kernel/service_internal_ms.h
r586 r889 38 38 #endif 39 39 40 40 41 #include <mapserver.h> 41 42 -
trunk/zoo-project/zoo-kernel/ulinet.c
r841 r889 91 91 ; 92 92 #endif 93 tmp=strtok( buffer,";");93 tmp=strtok((char*) buffer,";"); // knut: added cast to char* 94 94 cnt=0; 95 95 psInternet=(_HINTERNET *)data; … … 247 247 char *token, *saveptr; 248 248 int cnt; 249 char* host; 250 token = strtok_r (url, "//", &saveptr); 249 char* host; 250 251 // knut: make a copy of url since strtok family modifies first argument and cannot be used on constant strings 252 char* urlcpy = (char*) malloc(sizeof(char)*(strlen(url)+1)); 253 urlcpy = strncpy(urlcpy, url, strlen(url)+1); // since count > strlen(url), a null character is properly appended 254 255 //token = strtok_r (url, "//", &saveptr); 256 token = strtok_r (urlcpy, "//", &saveptr); // knut 251 257 cnt=0; 252 258 while(token!=NULL && cnt<=1){ … … 257 263 if(cnt==1 && strstr(protectedHosts,token)!=NULL){ 258 264 fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,strstr(protectedHosts,token)); 265 free(urlcpy); 259 266 return 1; 260 267 } … … 262 269 cnt+=1; 263 270 } 271 free(urlcpy); 264 272 return 0; 265 273 } -
trunk/zoo-project/zoo-kernel/ulinet.h
r834 r889 44 44 #include "jsapi.h" 45 45 #endif 46 /* knut: see new definition of bool in service.h 46 47 #ifndef bool 47 48 #define bool int … … 51 52 #define false 0 52 53 #endif 54 */ 53 55 54 56 #define MAX_REQ 50 … … 151 153 typedef size_t* LPDWORD; 152 154 #endif 155 /* knut: see new definition of bool in service.h 153 156 #ifndef bool 154 157 #define bool int 155 158 #endif 159 */ 156 160 157 161 # define CHECK_INET_HANDLE(h) (h.handle != 0) -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r844 r889 159 159 lockShm (lid); 160 160 #endif 161 FILE *f3 = fopen (fbkp, "wb+"); 162 free (fbkp); 161 FILE *f3 = fopen (fbkp, "wb+"); 162 free (fbkp); 163 163 fseek (f2, 0, SEEK_END); 164 164 long flen = ftell (f2); 165 165 fseek (f2, 0, SEEK_SET); 166 166 char *tmps1 = (char *) malloc ((flen + 1) * sizeof (char)); 167 fread (tmps1, flen, 1, f2); 167 fread (tmps1, flen, 1, f2); 168 168 #ifdef WIN32 169 char *pchr=strrchr(tmps1,'>'); 170 flen=strlen(tmps1)-strlen(pchr)+1; 171 tmps1[flen]=0; 172 #endif 169 /* knut: I think this block can be dropped; pchr may be NULL if result is not in XML format 170 char *pchr=strrchr(tmps1,'>'); 171 flen=strlen(tmps1)-strlen(pchr)+1; 172 tmps1[flen]=0; 173 */ 174 #endif 173 175 fwrite (tmps1, 1, flen, f3); 176 free(tmps1); 174 177 fclose (f2); 175 fclose (f3); 178 fclose (f3); 176 179 return 1; 177 180 } … … 2218 2221 addToMap(bmap->content,"sid",tmpm->value); 2219 2222 addIntToMap(bmap->content,"pid",getpid()); 2220 2223 2221 2224 // Create PID file referencing the OS process identifier 2222 2225 fbkpid = … … 2309 2312 if(dumpBackFinalFile(m,fbkp,fbkp1)<0) 2310 2313 return -1; 2311 unlink (fbkpid); 2314 unlink (fbkpid); 2312 2315 unhandleStatus (m); 2313 2316 freeMaps (&m); … … 2364 2367 signal (SIGABRT, donothing); 2365 2368 #endif 2366 2367 2369 if (((int) getpid ()) != cpid || cgiSid != NULL) 2368 { 2370 { 2369 2371 fclose (stdout); 2370 2372 fclose (stderr); … … 2372 2374 fclose (f0); 2373 2375 fclose (f1); 2374 2375 if(dumpBackFinalFile(m,fbkp,fbkp1)<0) 2376 return -1; 2377 unlink (fbkpid); 2376 2377 if (dumpBackFinalFile(m, fbkp, fbkp1) < 0) 2378 return -1; 2379 2380 unlink (fbkpid); 2378 2381 switch(eres){ 2379 2382 default: … … 2387 2390 break; 2388 2391 } 2389 #ifndef RELY_ON_DB 2392 #ifndef RELY_ON_DB 2390 2393 dumpMapsToFile(bmap,fbkpres,1); 2391 2394 removeShmLock (m, 1);
Note: See TracChangeset
for help on using the changeset viewer.