Changeset 31030 for trunk/ippToPsps/src/FitsGenerator.c
- Timestamp:
- Mar 23, 2011, 4:27:17 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/src/FitsGenerator.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/FitsGenerator.c
r31025 r31030 17 17 Finds a column within this table 18 18 */ 19 static Column* findColumn( Table* table, const char* name) {19 static Column* findColumn(FitsGenerator* this, Table* table, const char* name) { 20 20 21 21 Column* column = NULL; … … 29 29 } 30 30 31 if (!column) psError(PS_ERR_IO, false, "Could not find column '%s' in table '%s'", name, table->name);31 if (!column) this->logger->print(this->logger, MSG_ERROR, "Could not find column '%s' in table '%s'\n", name, table->name); 32 32 33 33 return column; … … 49 49 } 50 50 51 if (!table) psError(PS_ERR_IO, false, "Could not find table '%s'", name);51 if (!table) this->logger->print(this->logger, MSG_ERROR, "Could not find table '%s'\n", name); 52 52 53 53 return table; … … 214 214 opens an XML file and returns the document 215 215 */ 216 static xmlDoc* openXmlFile( const char* path) {216 static xmlDoc* openXmlFile(FitsGenerator* this, const char* path) { 217 217 218 218 xmlDoc* doc = xmlReadFile(path, NULL, 0); 219 if (doc == NULL) psError(PS_ERR_IO, false, "Unable to open XML file at %s", path);219 if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "Unable to open XML file at %s\n", path); 220 220 return doc; 221 221 } … … 235 235 Populates the provided table with data from XML 236 236 */ 237 static bool populateTable( Table* table, xmlNode* rootElement, Fits *fitsOut) {237 static bool populateTable(FitsGenerator* this, Table* table, xmlNode* rootElement, Fits *fitsOut) { 238 238 239 239 char tempStr[100]; … … 253 253 if(!tableNode) { 254 254 255 psError(PS_ERR_IO,"Could not find table: %s", table->name);255 this->logger->print(this->logger, MSG_ERROR, "Could not find table: %s\n", table->name); 256 256 return false; 257 257 } … … 320 320 321 321 } 322 if (status) psError(PS_ERR_IO, false, "Unable to write value of %s to column %s in table %s",322 if (status) this->logger->print(this->logger, MSG_ERROR, "Unable to write value of %s to column %s in table %s\n", 323 323 tempStr, table->columns[i].pspsName, table->name); 324 324 } … … 339 339 Loads a table description from XML 340 340 */ 341 static bool loadTableDescription( Table* table, xmlNode* tableNode) {341 static bool loadTableDescription(FitsGenerator* this, Table* table, xmlNode* tableNode) { 342 342 343 343 bool ret = true; … … 391 391 if (columnNum < 1) { 392 392 393 psError(PS_ERR_IO, false, "Found no columns for table '%s'", tableName);393 this->logger->print(this->logger, MSG_ERROR, "Found no columns for table '%s'\n", tableName); 394 394 ret = false; 395 395 } 396 396 397 397 if (columnNum != table->numOfColumns) 398 psError(PS_ERR_IO, false, "Mismatch between number of columns expected (%d) and those found (%d)", table->numOfColumns, columnNum);398 this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of columns expected (%d) and those found (%d)\n", table->numOfColumns, columnNum); 399 399 400 400 return ret; … … 411 411 psStringAppend(&path, "%s/tables.xml", this->configsPath); 412 412 413 xmlDoc* doc = openXmlFile( path);413 xmlDoc* doc = openXmlFile(this, path); 414 414 415 415 if (doc == NULL) { … … 424 424 if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) { 425 425 426 psError(PS_ERR_IO, false, "Root node of XML is not 'tableDescriptions', as it should be");426 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tableDescriptions', as it should be\n"); 427 427 return false; 428 428 } … … 445 445 table = this->tables+tableNum; 446 446 447 if (!loadTableDescription(t able, node)) ret = false;447 if (!loadTableDescription(this, table, node)) ret = false; 448 448 else tableNum++; 449 449 } … … 452 452 453 453 if (tableNum != this->numOfTables) 454 psError(PS_ERR_IO, false, "Mismatch between number of tables expected (%d) and those found (%d)", this->numOfTables, tableNum);454 this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of tables expected (%d) and those found (%d)\n", this->numOfTables, tableNum); 455 455 456 456 closeXmlFile(doc); … … 486 486 // column type 487 487 getAttribute(node, "pspsName", buffer); 488 column = findColumn(t able, buffer);488 column = findColumn(this, table, buffer); 489 489 490 490 if (!column) continue; … … 518 518 psStringAppend(&path, "%s/map.xml", this->configsPath); 519 519 520 xmlDoc* doc = openXmlFile( path);520 xmlDoc* doc = openXmlFile(this, path); 521 521 522 522 if (doc == NULL) { … … 529 529 530 530 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 531 psError(PS_ERR_IO, false, "Root node of XML is not 'tabledata', as it should be");531 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n"); 532 532 return false; 533 533 } … … 560 560 psStringAppend(&path, "%s/data.xml", this->configsPath); 561 561 562 xmlDoc* doc = openXmlFile( path);562 xmlDoc* doc = openXmlFile(this, path); 563 563 564 564 if (doc == NULL) { … … 571 571 572 572 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 573 psError(PS_ERR_IO, false, "Root node of XML is not 'tabledata', as it should be");573 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n"); 574 574 return false; 575 575 } 576 576 577 577 for (uint32_t i=0; i<this->numOfTables; i++) { 578 if (!populateTable(this ->tables+i, rootElement, fitsOut)) {578 if (!populateTable(this, this->tables+i, rootElement, fitsOut)) { 579 579 ret = false; 580 580 } … … 590 590 */ 591 591 static bool populateTableFromFits( 592 FitsGenerator* this, 592 593 Table* table, 593 594 Fits *fitsIn, … … 678 679 679 680 default: 680 psError(PS_ERR_IO, false, "Don't know IPP type (%d) for mapping from '%d' '%s' to '%s'", table->columns[i].ippType,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, 681 682 table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName); 682 683 break; … … 711 712 712 713 if(!createTable(table, fitsOut, nRows)) return false; 713 return populateTableFromFits(t able, fitsIn, fitsOut, nRows, fromHeader);714 return populateTableFromFits(this, table, fitsIn, fitsOut, nRows, fromHeader); 714 715 } 715 716 … … 733 734 Constructor. 734 735 */ 735 FitsGenerator* new_FitsGenerator( const char* path) {736 FitsGenerator* new_FitsGenerator(Logger* logger, const char* path) { 736 737 737 738 FitsGenerator* this = (FitsGenerator*)calloc(1, sizeof(FitsGenerator)); … … 739 740 this->configsPath = NULL; 740 741 psStringAppend(&this->configsPath, path); 742 this->logger = logger; 741 743 742 744 // method pointers
Note:
See TracChangeset
for help on using the changeset viewer.
