Changeset 33869
- Timestamp:
- May 16, 2012, 4:16:14 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120405/Ohana/src/libdvo
- Files:
-
- 4 edited
-
include/dvo.h (modified) (3 diffs)
-
src/HostTable.c (modified) (1 diff)
-
src/dvo_catalog.c (modified) (1 diff)
-
src/dvo_catalog_split.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120405/Ohana/src/libdvo/include/dvo.h
r33649 r33869 69 69 NAN_U_INT = (signed int) 0xffffffff, 70 70 } DVO_INT_NAN; 71 72 // max path length 73 # define DVO_MAX_PATH 1024 71 74 72 75 /* RegImage.flag values */ … … 268 271 int Nhosts; 269 272 HostInfo *hosts; 270 unsignedshort *index;273 short *index; 271 274 } HostTable; 272 275 … … 516 519 void dvo_catalog_test (Catalog *catalog, int halt); 517 520 521 int dvo_catalog_backup (Catalog *catalog, int primary); 522 int dvo_catalog_unlink_backup (Catalog *catalog, int primary); 523 518 524 /* catmode-specific APIs */ 519 525 int dvo_catalog_load_raw (Catalog *catalog, int VERBOSE); -
branches/eam_branches/ipp-20120405/Ohana/src/libdvo/src/HostTable.c
r33649 r33869 121 121 table->hosts = hosts; 122 122 123 ALLOCATE (table->index, unsignedshort, maxID + 1);123 ALLOCATE (table->index, short, maxID + 1); 124 124 for (i = 0; i <= maxID; i++) table->index[i] = -1; 125 125 126 126 for (i = 0; i < table->Nhosts; i++) { 127 if (table->index[table->hosts[i].hostID] == -1) {127 if (table->index[table->hosts[i].hostID] != -1) { 128 128 fprintf (stderr, "error: duplicate hostID %d\n", table->hosts[i].hostID); 129 129 exit (1); -
branches/eam_branches/ipp-20120405/Ohana/src/libdvo/src/dvo_catalog.c
r33649 r33869 499 499 } 500 500 501 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 502 int dvo_catalog_backup (Catalog *catalog, int primary) { 503 504 // skip empty cpt files 505 if (primary && !catalog->Naves_disk) { 506 return TRUE; 507 } 508 509 char tmpfilename[DVO_MAX_PATH]; 510 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename); 511 if (status >= DVO_MAX_PATH) { 512 fprintf (stderr, "path name too long: %s\n", catalog->filename); 513 return FALSE; 514 } 515 516 // unlock the catalog here (closes file as well) (also closes subcat files Measure, Secfilt, Missing) 517 if (primary) { 518 status = dvo_catalog_unlock (catalog); 519 if (!status) { 520 fprintf (stderr, "failed to unlock catalog %s\n", catalog->filename); 521 return FALSE; 522 } 523 } 524 525 status = rename (catalog->filename, tmpfilename); 526 if (status) { 527 fprintf (stderr, "failed to rename catalog %s\n", catalog->filename); 528 return FALSE; 529 } 530 531 // keep the same lockmode 532 int lockmode = catalog->lockmode; 533 534 // lock the new catalog file here (re-opens file as well) (does NOT open/lock the subcat files) 535 status = dvo_catalog_lock (catalog, lockmode); 536 if (!status) { 537 fprintf (stderr, "failed to lock new catalog file %s\n", catalog->filename); 538 return FALSE; 539 } 540 541 if (catalog[0].catmode == DVO_MODE_SPLIT) { 542 if (catalog[0].measure_catalog != NULL) { 543 if (!dvo_catalog_backup (catalog[0].measure_catalog, FALSE)) { 544 return FALSE; 545 } 546 } 547 if (catalog[0].missing_catalog != NULL) { 548 if (!dvo_catalog_backup (catalog[0].missing_catalog, FALSE)) { 549 return FALSE; 550 } 551 } 552 if (catalog[0].secfilt_catalog != NULL) { 553 if (!dvo_catalog_backup (catalog[0].secfilt_catalog, FALSE)) { 554 return FALSE; 555 } 556 } 557 } 558 return TRUE; 559 } 560 561 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 562 int dvo_catalog_unlink_backup (Catalog *catalog, int primary) { 563 564 if (primary && !catalog->Naves_disk) { 565 // skip empty files (empty when read, but output may not be empty) 566 return TRUE; 567 } 568 569 char tmpfilename[DVO_MAX_PATH]; 570 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename); 571 if (status >= DVO_MAX_PATH) { 572 fprintf (stderr, "path name too long: %s\n", catalog->filename); 573 return FALSE; 574 } 575 576 status = unlink (tmpfilename); 577 if (status) { 578 fprintf (stderr, "failed to unlink catalog %s\n", catalog->filename); 579 return FALSE; 580 } 581 582 if (catalog[0].catmode == DVO_MODE_SPLIT) { 583 if (catalog[0].measure_catalog != NULL) { 584 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) { 585 return FALSE; 586 } 587 } 588 if (catalog[0].missing_catalog != NULL) { 589 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) { 590 return FALSE; 591 } 592 } 593 if (catalog[0].secfilt_catalog != NULL) { 594 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) { 595 return FALSE; 596 } 597 } 598 } 599 return TRUE; 600 } 601 -
branches/eam_branches/ipp-20120405/Ohana/src/libdvo/src/dvo_catalog_split.c
r33649 r33869 80 80 // write PHU header 81 81 if (!gfits_fwrite_header (catalog->f, &catalog->header)) { 82 fprintf (stderr, "can't write primary header ");82 fprintf (stderr, "can't write primary header\n"); 83 83 return (FALSE); 84 84 } … … 87 87 gfits_create_matrix (&catalog->header, &matrix); 88 88 if (!gfits_fwrite_matrix (catalog->f, &matrix)) { 89 fprintf (stderr, "can't write primary matrix ");89 fprintf (stderr, "can't write primary matrix\n"); 90 90 gfits_free_matrix (&matrix); 91 91 return (FALSE); … … 95 95 // write the table data 96 96 if (!gfits_fwrite_ftable_range (catalog->f, ftable, start, Nrows, Ndisk, Ntotal)) { 97 fprintf (stderr, "can't write table data ");97 fprintf (stderr, "can't write table data\n"); 98 98 return (FALSE); 99 99 }
Note:
See TracChangeset
for help on using the changeset viewer.
