Changeset 31033 for trunk/ippToPsps/src/FitsGenerator.c
- Timestamp:
- Mar 24, 2011, 11:03:32 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/src/FitsGenerator.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/FitsGenerator.c
r31030 r31033 29 29 } 30 30 31 if (!column) this->logger->print(this->logger, MSG_ERROR, "Could not find column '%s' in table '%s'\n", name, table->name); 31 if (!column) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 32 "Could not find column '%s' in table '%s'\n", name, table->name); 32 33 33 34 return column; … … 49 50 } 50 51 51 if (!table) this->logger->print(this->logger, MSG_ERROR, "Could not find table '%s'\n", name); 52 if (!table) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 53 "Could not find table '%s'\n", name); 52 54 53 55 return table; … … 217 219 218 220 xmlDoc* doc = xmlReadFile(path, NULL, 0); 219 if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "Unable to open XML file at %s\n", path); 221 if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 222 "Unable to open XML file at %s\n", path); 220 223 return doc; 221 224 } … … 253 256 if(!tableNode) { 254 257 255 this->logger->print(this->logger, MSG_ERROR, "Could not find table: %s\n", table->name); 258 this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 259 "Could not find table: %s\n", table->name); 256 260 return false; 257 261 } … … 320 324 321 325 } 322 if (status) this->logger->print(this->logger, MSG_ERROR, "Unable to write value of %s to column %s in table %s\n", 326 if (status) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 327 "Unable to write value of %s to column %s in table %s\n", 323 328 tempStr, table->columns[i].pspsName, table->name); 324 329 } … … 391 396 if (columnNum < 1) { 392 397 393 this->logger->print(this->logger, MSG_ERROR, "Found no columns for table '%s'\n", tableName); 398 this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 399 "Found no columns for table '%s'\n", tableName); 394 400 ret = false; 395 401 } 396 402 397 403 if (columnNum != table->numOfColumns) 398 this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of columns expected (%d) and those found (%d)\n", table->numOfColumns, columnNum); 404 this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 405 "Mismatch between number of columns expected (%d) and those found (%d)\n", 406 table->numOfColumns, columnNum); 399 407 400 408 return ret; … … 424 432 if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) { 425 433 426 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tableDescriptions', as it should be\n"); 434 this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 435 "Root node of XML is not 'tableDescriptions', as it should be\n"); 427 436 return false; 428 437 } … … 452 461 453 462 if (tableNum != this->numOfTables) 454 this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of tables expected (%d) and those found (%d)\n", this->numOfTables, tableNum); 463 this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 464 "Mismatch between number of tables expected (%d) and those found (%d)\n", 465 this->numOfTables, tableNum); 455 466 456 467 closeXmlFile(doc); … … 515 526 bool ret = true; 516 527 528 char path[1000]; 529 sprintf(path, "%s/map.xml", this->configsPath); 530 531 struct stat sts; 532 if ((stat(path, &sts)) == -1) { 533 this->logger->print(this->logger, MSG_INFO, "FitsGenerator", 534 "No map file found at '%s'\n", path); 535 return false; 536 } 537 538 xmlDoc* doc = openXmlFile(this, path); 539 540 if (doc == NULL) { 541 542 this->logger->print(this->logger, MSG_ERROR,"FitsGenerator", 543 "Could not create XML document from '%s'\n", path); 544 return false; 545 } 546 547 this->logger->print(this->logger, MSG_INFO, "FitsGenerator", 548 "Using map file at '%s'\n", path); 549 xmlNode* rootElement = xmlDocGetRootElement(doc); 550 551 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 552 this->logger->print(this->logger, MSG_ERROR,"FitsGenerator", 553 "Root node of XML is not 'tabledata', as it should be\n"); 554 return false; 555 } 556 557 xmlNode* node = NULL; 558 559 // loop round all available tables 560 for (node = rootElement->children; node; node = node->next) { 561 if (node->type == XML_ELEMENT_NODE) { 562 563 if (strcmp((const char*)node->name, "table")==0) { 564 565 if (!loadTableMappings(this, node)) ret = false; 566 } 567 } 568 } 569 570 closeXmlFile(doc); 571 572 return ret; 573 } 574 575 /** 576 Populate the provided table with data from XML 577 */ 578 static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) { 579 580 bool ret = true; 517 581 psString path = NULL; 518 psStringAppend(&path, "%s/ map.xml", this->configsPath);582 psStringAppend(&path, "%s/data.xml", this->configsPath); 519 583 520 584 xmlDoc* doc = openXmlFile(this, path); … … 529 593 530 594 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 531 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n"); 532 return false; 533 } 534 535 xmlNode* node = NULL; 536 537 // loop round all available tables 538 for (node = rootElement->children; node; node = node->next) { 539 if (node->type == XML_ELEMENT_NODE) { 540 541 if (strcmp((const char*)node->name, "table")==0) { 542 543 if (!loadTableMappings(this, node)) ret = false; 544 } 545 } 546 } 547 548 closeXmlFile(doc); 549 550 return ret; 551 } 552 553 /** 554 Populate the provided table with data from XML 555 */ 556 static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) { 557 558 bool ret = true; 559 psString path = NULL; 560 psStringAppend(&path, "%s/data.xml", this->configsPath); 561 562 xmlDoc* doc = openXmlFile(this, path); 563 564 if (doc == NULL) { 565 psFree(path); 566 return false; 567 } 568 psFree(path); 569 570 xmlNode* rootElement = xmlDocGetRootElement(doc); 571 572 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 573 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n"); 595 this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 596 "Root node of XML is not 'tabledata', as it should be\n"); 574 597 return false; 575 598 } … … 679 702 680 703 default: 681 this->logger->print(this->logger, MSG_ERROR, " Don't know IPP type (%d) for mapping from '%d' '%s' to '%s'\n", table->columns[i].ippType,704 this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", "Don't know IPP type (%d) for mapping from '%d' '%s' to '%s'\n", table->columns[i].ippType, 682 705 table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName); 683 706 break;
Note:
See TracChangeset
for help on using the changeset viewer.
