Changeset 789 for trunk/zoo-project/zoo-kernel
- Timestamp:
- Nov 4, 2016, 4:58:41 PM (8 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/server_internal.c
r785 r789 35 35 #endif 36 36 #include <signal.h> 37 38 // #include <stdlib.h> 39 /* 40 * Compare two file path strings to see if they refer to the same file. 41 * 42 * @param path1 the first file path 43 * @param path2 the second file path 44 * 45 * @return 0 if the files are identical 46 */ 47 #define PATHBUFSIZE 4096 48 int zoo_path_compare(char* path1, char* path2) { 49 50 if (path1 == NULL || path2 == NULL) { 51 return -1; 52 } 53 54 char realpath1[PATHBUFSIZE]; 55 char realpath2[PATHBUFSIZE]; 56 57 #ifdef WIN32 58 int res1 = GetFullPathName(path1, PATHBUFSIZE, realpath1, NULL); 59 int res2 = GetFullPathName(path2, PATHBUFSIZE, realpath2, NULL); 60 61 if (res1 == 0 || res2 == 0) { 62 return -1; 63 } 64 else { 65 return strncasecmp(realpath1, realpath2, PATHBUFSIZE); 66 } 67 #else 68 char* ptr1 = realpath(path1, realpath1); 69 char* ptr2 = realpath(path2, realpath2); 70 71 if (ptr1 == NULL || ptr2 == NULL) { 72 return -1; 73 } 74 else { 75 return strncmp(realpath1, realpath2, PATHBUFSIZE); 76 } 77 #endif 78 } 37 79 38 80 /** -
trunk/zoo-project/zoo-kernel/server_internal.h
r767 r789 25 25 #ifdef WIN32 26 26 #pragma comment(lib, "rpcrt4.lib") 27 #endif 28 29 #ifndef IMPORTSERVICE 30 #define IMPORTSERVICE "include" // default name of [include] block in main.cfg 27 31 #endif 28 32 … … 66 70 int createRegistry (maps*,registry **,char *); 67 71 72 int zoo_path_compare(char* path1, char* path2); 73 68 74 #ifdef WIN32 69 75 char* getMapsAsKVP(maps*,int,int); -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r788 r789 287 287 memset (tmps1, 0, 1024); 288 288 snprintf (tmps1, 1024, "%s/%s", conf_dir, dp->d_name); 289 service *s1 = (service *) malloc (SERVICE_SIZE); 290 if (s1 == NULL) 291 { 292 dup2 (saved_stdout, fileno (stdout)); 293 errorException (m, _("Unable to allocate memory"), 294 "InternalError", NULL); 295 return -1; 296 } 297 #ifdef DEBUG 298 fprintf (stderr, "#################\n%s\n#################\n", 299 tmps1); 300 #endif 289 301 290 char *tmpsn = zStrdup (dp->d_name); 302 291 tmpsn[strlen (tmpsn) - 5] = 0; 303 t = readServiceFile (m, tmps1, &s1, tmpsn); 304 free (tmpsn); 305 if (t < 0) 306 { 307 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 308 char tmp01[1024]; 309 if (tmp00 != NULL) 310 sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"), 311 dp->d_name, tmp00->value); 312 else 313 sprintf (tmp01, _("Unable to parse the ZCFG file: %s."), 314 dp->d_name); 315 dup2 (saved_stdout, fileno (stdout)); 316 errorException (m, tmp01, "InternalError", NULL); 317 return -1; 318 } 319 #ifdef DEBUG 320 dumpService (s1); 321 fflush (stdout); 322 fflush (stderr); 323 #endif 324 inheritance(r,&s1); 325 func (r, m, n, s1); 326 freeService (&s1); 327 free (s1); 328 scount++; 292 293 map* import = getMapFromMaps (m, IMPORTSERVICE, tmpsn); 294 if (import == NULL || import->value == NULL || zoo_path_compare(tmps1, import->value) != 0 ) { // service is not in [include] block 295 service *s1 = (service *) malloc (SERVICE_SIZE); 296 if (s1 == NULL) 297 { 298 dup2 (saved_stdout, fileno (stdout)); 299 errorException (m, _("Unable to allocate memory"), 300 "InternalError", NULL); 301 return -1; 302 } 303 #ifdef DEBUG 304 fprintf (stderr, "#################\n%s\n#################\n", 305 tmps1); 306 #endif 307 t = readServiceFile (m, tmps1, &s1, tmpsn); 308 free (tmpsn); 309 if (t < 0) 310 { 311 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 312 char tmp01[1024]; 313 if (tmp00 != NULL) 314 sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"), 315 dp->d_name, tmp00->value); 316 else 317 sprintf (tmp01, _("Unable to parse the ZCFG file: %s."), 318 dp->d_name); 319 dup2 (saved_stdout, fileno (stdout)); 320 errorException (m, tmp01, "InternalError", NULL); 321 return -1; 322 } 323 #ifdef DEBUG 324 dumpService (s1); 325 fflush (stdout); 326 fflush (stderr); 327 #endif 328 inheritance(r,&s1); 329 func (r, m, n, s1); 330 freeService (&s1); 331 free (s1); 332 scount++; 333 } 329 334 } 330 335 } … … 1245 1250 int saved_stdout = dup (fileno (stdout)); 1246 1251 dup2 (fileno (stderr), fileno (stdout)); 1252 1253 maps* imports = getMaps(m, IMPORTSERVICE); 1254 if (imports != NULL) { 1255 map* zcfg = imports->content; 1256 1257 while (zcfg != NULL) { 1258 if (zcfg->value != NULL) { 1259 service* svc = (service*) malloc(SERVICE_SIZE); 1260 if (svc == NULL || readServiceFile(m, zcfg->value, &svc, zcfg->name) < 0) { 1261 // pass over silently 1262 zcfg = zcfg->next; 1263 continue; 1264 } 1265 inheritance(zooRegistry, &svc); 1266 printGetCapabilitiesForProcess(zooRegistry, m, n, svc); 1267 freeService(&svc); 1268 free(svc); 1269 } 1270 zcfg = zcfg->next; 1271 } 1272 } 1273 1247 1274 if (int res = 1248 1275 recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0, … … 1345 1372 if (strcasecmp ("all", orig) == 0) 1346 1373 { 1374 maps* imports = getMaps(m, IMPORTSERVICE); 1375 if (imports != NULL) { 1376 map* zcfg = imports->content; 1377 1378 while (zcfg != NULL) { 1379 if (zcfg->value != NULL) { 1380 service* svc = (service*) malloc(SERVICE_SIZE); 1381 if (svc == NULL || readServiceFile(m, zcfg->value, &svc, zcfg->name) < 0) { 1382 // pass over silently 1383 zcfg = zcfg->next; 1384 continue; 1385 } 1386 inheritance(zooRegistry, &svc); 1387 printDescribeProcessForProcess(zooRegistry, m, n, svc); 1388 freeService(&svc); 1389 free(svc); 1390 } 1391 zcfg = zcfg->next; 1392 } 1393 } 1394 1347 1395 if (int res = 1348 1396 recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0, … … 1361 1409 int hasVal = -1; 1362 1410 char *corig = zStrdup (tmps); 1363 if (strstr (corig, ".") != NULL) 1411 map* import = getMapFromMaps (m, IMPORTSERVICE, corig); 1412 if (import != NULL && import->value != NULL) 1413 { 1414 s1 = (service *) malloc (SERVICE_SIZE); 1415 t = readServiceFile (m, import->value, &s1, import->name); 1416 1417 if (t < 0) // failure reading zcfg 1418 { 1419 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1420 char tmp01[1024]; 1421 if (tmp00 != NULL) 1422 sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"), import->value, tmp00->value); 1423 else 1424 sprintf (tmp01, _("Unable to parse the ZCFG file: %s."), import->value); 1425 1426 dup2 (saved_stdout, fileno (stdout)); 1427 errorException (m, tmp01, "InternalError", NULL); 1428 1429 freeMaps (&m); 1430 free (m); 1431 1432 if(zooRegistry!=NULL){ 1433 freeRegistry(&zooRegistry); 1434 free(zooRegistry); 1435 } 1436 free (orig); 1437 free (REQUEST); 1438 closedir (dirp); 1439 xmlFreeDoc (doc); 1440 xmlCleanupParser (); 1441 zooXmlCleanupNs (); 1442 1443 return 1; 1444 } 1445 #ifdef DEBUG 1446 dumpService (s1); 1447 #endif 1448 1449 inheritance(zooRegistry,&s1); 1450 printDescribeProcessForProcess (zooRegistry,m, n, s1); 1451 freeService (&s1); 1452 free (s1); 1453 s1 = NULL; 1454 scount++; 1455 hasVal = 1; 1456 } 1457 else if (strstr (corig, ".") != NULL) 1364 1458 { 1365 1459 … … 1640 1734 1641 1735 r_inputs = getMap (request_inputs, "Identifier"); 1642 snprintf (tmps1, 1024, "%s/%s.zcfg", conf_dir, r_inputs->value); 1643 #ifdef DEBUG 1644 fprintf (stderr, "Trying to load %s\n", tmps1); 1645 #endif 1646 if (strstr (r_inputs->value, ".") != NULL) 1647 { 1648 char *identifier = zStrdup (r_inputs->value); 1649 parseIdentifier (m, conf_dir, identifier, tmps1); 1650 map *tmpMap = getMapFromMaps (m, "lenv", "metapath"); 1651 if (tmpMap != NULL) 1652 addToMap (request_inputs, "metapath", tmpMap->value); 1653 free (identifier); 1654 } 1655 else 1656 { 1736 1737 map* import = getMapFromMaps (m, IMPORTSERVICE, r_inputs->value); 1738 if (import != NULL && import->value != NULL) { 1739 strncpy(tmps1, import->value, 1024); 1657 1740 setMapInMaps (m, "lenv", "Identifier", r_inputs->value); 1658 1741 setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value); 1659 } 1742 } 1743 else { 1744 snprintf (tmps1, 1024, "%s/%s.zcfg", conf_dir, r_inputs->value); 1745 #ifdef DEBUG 1746 fprintf (stderr, "Trying to load %s\n", tmps1); 1747 #endif 1748 if (strstr (r_inputs->value, ".") != NULL) 1749 { 1750 char *identifier = zStrdup (r_inputs->value); 1751 parseIdentifier (m, conf_dir, identifier, tmps1); 1752 map *tmpMap = getMapFromMaps (m, "lenv", "metapath"); 1753 if (tmpMap != NULL) 1754 addToMap (request_inputs, "metapath", tmpMap->value); 1755 free (identifier); 1756 } 1757 else 1758 { 1759 setMapInMaps (m, "lenv", "Identifier", r_inputs->value); 1760 setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value); 1761 } 1762 } 1660 1763 1661 1764 r_inputs = getMapFromMaps (m, "lenv", "Identifier");
Note: See TracChangeset
for help on using the changeset viewer.