IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 13, 2005, 6:30:21 PM (21 years ago)
Author:
Paul Price
Message:

Made changes from Josh, with some modification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/src/phase2/pmFPARead.c

    r5786 r5789  
    219219
    220220// Translate a name from the configuration file, containing something like "%a_%d" to a real value
    221 psString p_pmFPATranslateName(psString name, // The name to translate
    222                               pmCell *cell // The cell for which to translate
     221psString p_pmFPATranslateName(const psString name, // The name to translate
     222                              const pmCell *cell // The cell for which to translate
    223223    )
    224224{
     
    338338}
    339339
     340// Get filename and extension out of "somefile.fits:ext"
     341psString p_pmFPATranslateFileExt(psString *extName, // Extension name, to be returned
     342                                 const psString name, // The string to be translated and then parsed
     343                                 const pmCell *cell // The cell
     344    )
     345{
     346    psString filenameExt = p_pmFPATranslateName(name, cell);
     347    const char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn
     348    psString filename = NULL;           // The filename
     349    if (extName && *extName) {
     350        psFree(*extName);
     351    }
     352    if (extName) {
     353        *extName = NULL;
     354    }
     355
     356    if (colon) {
     357        filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
     358        if (strlen(colon) > 1) {
     359            if (extName) {
     360                *extName = psStringCopy(colon + 1);
     361            }
     362        }
     363    } else {
     364        filename = psMemIncrRefCounter(filenameExt);
     365    }
     366
     367    return filename;
     368}
     369
    340370// Read a mask into the FPA
    341371bool pmFPAReadMask(pmFPA *fpa,          // FPA to read into
     
    386416                    if (strcasecmp(sourceType, "FILE") == 0) {
    387417                        // Source is a file (with optional extension, e.g., "myMaskFile.fits:thisExt"
    388                         psString filenameExt = p_pmFPATranslateName(name, cell);
    389                         char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn
    390                         psString filename = NULL; // The filename
    391                         psString extname = NULL;// The extenstion name
    392                         if (colon) {
    393                             filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
    394                             if (strlen(colon) > 1) {
    395                                 extname = psStringCopy(colon + 1);
    396                             }
    397                         } else {
    398                             filename = psMemIncrRefCounter(filenameExt);
    399                         }
     418                        psString extname = NULL; // Extension name
     419                        psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename
    400420
    401421                        psFree(maskSource);
     
    410430                        psFree(filename);
    411431                        psFree(extname);
    412                         psFree(filenameExt);
    413432                    } else if (strncasecmp(sourceType, "EXT", 3) == 0) {
    414433                        // Source is an extension in the original file
     
    536555                    if (strcasecmp(sourceType, "FILE") == 0) {
    537556                        // Source is a file (with optional extension, e.g., "myWeightFile.fits:thisExt"
    538                         psString filenameExt = p_pmFPATranslateName(name, cell);
    539                         char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn
    540                         psString filename = NULL; // The filename
    541                         psString extname = NULL;// The extenstion name
    542                         if (colon) {
    543                             filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
    544                             if (strlen(colon) > 1) {
    545                                 extname = psStringCopy(colon + 1);
    546                             }
    547                         } else {
    548                             filename = psMemIncrRefCounter(filenameExt);
    549                         }
     557                        psString extname = NULL; // Extension name
     558                        psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename
    550559
    551560                        psFree(weightSource);
     
    560569                        psFree(filename);
    561570                        psFree(extname);
    562                         psFree(filenameExt);
    563571                    } else if (strncasecmp(sourceType, "EXT", 3) == 0) {
    564572                        // Source is an extension in the original file
Note: See TracChangeset for help on using the changeset viewer.