IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2005, 4:05:11 PM (21 years ago)
Author:
jhoblitt
Message:

factor out p_pmFPAGetExtName()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/neb/archive/scripts/src/phase2/pmFPAWrite.c

    r5648 r5649  
    77#include "pmFPARead.h"
    88
    9 static bool writeHDU(psFits *fits,  // FITS file to which to write
     9static psString p_pmFPAGetExtName(psString name, pmCell *cell, psString filename);
     10
     11static bool writeHDU(psFits *fits,   // FITS file to which to write
    1012                     p_pmHDU *hdu // Pixel data to write
    1113                    )
     
    2224
    2325
    24 bool pmFPAWrite(psFits *fits,   // FITS file to which to write
    25                 pmFPA *fpa,   // FPA to write
     26bool pmFPAWrite(psFits *fits,    // FITS file to which to write
     27                pmFPA *fpa,    // FPA to write
    2628                psDB *db  // Database to update
    2729               )
     
    7880
    7981
    80 bool pmFPAWriteMask(pmFPA *fpa,   // FPA containing mask to write
     82bool pmFPAWriteMask(pmFPA *fpa,    // FPA containing mask to write
    8183                    psFits *fits // FITS file for image
    8284                   )
     
    136138                    {
    137139                        // Source is a file (with optional extension, e.g., "myMaskFile.fits:thisExt"
    138                         psString filenameExt = p_pmFPATranslateName(name, cell);
    139                         char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn
    140140                        psString filename = NULL; // The filename
    141141                        psString extname = NULL; // The extenstion name
    142                         if (colon)
    143                         {
    144                             filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
    145                             if (strlen(colon) > 1)
    146                             {
    147                                 extname = psStringCopy(colon + 1);
    148                             }
    149                         }
    150                         else
    151                         {
    152                             filename = psMemIncrRefCounter(filenameExt);
    153                         }
     142                        extname = p_pmFPAGetExtName(name, cell, filename);
    154143
    155144                        psFree(maskDest);
     
    161150                        psFree(filename);
    162151                        psFree(extname);
    163                         psFree(filenameExt);
    164152                    }
    165153                    else if (strncasecmp(sourceType, "EXT", 3) == 0)
     
    203191
    204192
    205 bool pmFPAWriteWeight(pmFPA *fpa,   // FPA containing mask to write
     193bool pmFPAWriteWeight(pmFPA *fpa,    // FPA containing mask to write
    206194                      psFits *fits // FITS file for image
    207195                     )
     
    261249                    {
    262250                        // Source is a file (with optional extension, e.g., "myWeightFile.fits:thisExt"
    263                         psString filenameExt = p_pmFPATranslateName(name, cell);
    264                         char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn
    265251                        psString filename = NULL; // The filename
    266252                        psString extname = NULL; // The extenstion name
    267                         if (colon)
    268                         {
    269                             filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
    270                             if (strlen(colon) > 1)
    271                             {
    272                                 extname = psStringCopy(colon + 1);
    273                             }
    274                         }
    275                         else
    276                         {
    277                             filename = psMemIncrRefCounter(filenameExt);
    278                         }
     253                        extname = p_pmFPAGetExtName(name, cell, filename);
    279254
    280255                        psFree(weightDest);
     
    286261                        psFree(filename);
    287262                        psFree(extname);
    288                         psFree(filenameExt);
    289263                    }
    290264                    else if (strncasecmp(sourceType, "EXT", 3) == 0)
     
    325299    return true;
    326300}
     301
     302static psString p_pmFPAGetExtName(psString name, pmCell *cell, psString filename)
     303{
     304    psString filenameExt = p_pmFPATranslateName(name, cell);
     305    char *colon = strchr(filenameExt, ':');    // Pointer to a colon in the filename-extn
     306    psString extname = NULL;            // The extenstion name
     307    filename = NULL;                    // The filename
     308    if (colon)
     309    {
     310        filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
     311        if (strlen(colon) > 1)
     312        {
     313            extname = psStringCopy(colon + 1);
     314        }
     315    }
     316    else
     317    {
     318        filename = psMemIncrRefCounter(filenameExt);
     319    }
     320
     321    psFree(filenameExt);
     322
     323    return extname;
     324}
Note: See TracChangeset for help on using the changeset viewer.