IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8848


Ignore:
Timestamp:
Sep 19, 2006, 4:36:36 PM (20 years ago)
Author:
Paul Price
Message:

When writing concepts to headers, if given a list, write out all the keywords (use blank value, if required). Removed excess code in this regard (pmConceptsWriteToHeader had code already in writeHeader). Include string.h where required.

Location:
trunk/psModules/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPACopy.c

    r8823 r8848  
    55#include <stdio.h>
    66#include <assert.h>
     7#include <string.h>
    78
    89#include <pslib.h>
  • trunk/psModules/src/camera/pmFPAUtils.c

    r8815 r8848  
    44
    55#include <stdio.h>
     6#include <string.h>
     7
    68#include <pslib.h>
    79#include "pmFPA.h"
  • trunk/psModules/src/camera/pmFPA_JPEG.c

    r8815 r8848  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-09-15 09:49:01 $
     7 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-09-20 02:36:36 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020/*****************************************************************************/
    2121
     22#include <stdio.h>
     23#include <string.h>
    2224#include <pslib.h>
    2325
  • trunk/psModules/src/camera/pmFPAfile.c

    r8815 r8848  
    44
    55#include <stdio.h>
     6#include <string.h>
    67#include <pslib.h>
    78
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r8815 r8848  
    44
    55#include <stdio.h>
     6#include <string.h>
    67#include <pslib.h>
    78
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r8815 r8848  
    44
    55#include <stdio.h>
     6#include <string.h>
    67#include <pslib.h>
    78
  • trunk/psModules/src/camera/pmHDU.c

    r8815 r8848  
    55#include <stdio.h>
    66#include <assert.h>
     7#include <string.h>
    78
    89#include <pslib.h>
  • trunk/psModules/src/camera/pmHDUGenerate.c

    r8815 r8848  
    55#include <stdio.h>
    66#include <assert.h>
     7#include <string.h>
    78#include <pslib.h>
    89
  • trunk/psModules/src/concepts/pmConceptsRead.c

    r8821 r8848  
    55#include <stdio.h>
    66#include <assert.h>
     7#include <string.h>
    78#include <pslib.h>
    89
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r8820 r8848  
    44
    55#include <stdio.h>
     6#include <string.h>
    67#include <assert.h>
    78
  • trunk/psModules/src/concepts/pmConceptsWrite.c

    r8815 r8848  
    55#include <stdio.h>
    66#include <assert.h>
    7 #include <strings.h>
     7#include <string.h>
    88#include <pslib.h>
    99
     
    132132static bool writeSingleHeader(pmHDU *hdu, // HDU for which to add to the header
    133133                              const char *keyword, // Keyword to add
    134                               psMetadataItem *item // Item to add to the header
     134                              psMetadataItem *item // Item to add to the header; may be NULL
    135135                             )
    136136{
    137137    assert(hdu);
    138138    assert(keyword && strlen(keyword) > 0);
    139     assert(item);
    140139
    141140    if (!hdu->header) {
    142141        hdu->header = psMetadataAlloc();
     142    }
     143    if (!item) {
     144        psTrace("psModules.concepts", 9, "Writing header %s: <<<BLANK>>>\n", keyword);
     145        // Assume it's a NULL string: it's most easily parsed.
     146        return psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, NULL, NULL);
    143147    }
    144148    switch (item->type) {
     
    188192    if (item->type == PS_DATA_LIST) {
    189193        psList *values = item->data.V;  // List of outputs
    190         if (values->n == 0) {
    191             // Nothing to write
     194        psList *keys = psStringSplit(keywords, " ,;", true); // List of keywords
     195        if (keys->n != values->n && values->n != 0) {
     196            psError(PS_ERR_UNKNOWN, true, "Number of keywords (%ld) does not match number of "
     197                    "values (%ld).\n", keys->n, values->n);
     198            psFree(keys);
    192199            return false;
    193         }
    194         psList *keys = psStringSplit(keywords, " ,;", true); // List of keywords
    195         if (keys->n != values->n) {
    196             psLogMsg(__func__, PS_LOG_WARN, "Number of keywords (%ld) does not match number of values (%ld).\n",
    197                      keys->n, values->n);
    198200        }
    199201        psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator for keywords
    200202        psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values
    201203        psString key = NULL;            // Keyword from iteration
    202         psMetadataItem *value = NULL;   // Value from iteration
    203         while ((key = psListGetAndIncrement(keysIter)) && (value = psListGetAndIncrement(valuesIter))) {
     204        while ((key = psListGetAndIncrement(keysIter))) {
     205            psMetadataItem *value = psListGetAndIncrement(valuesIter); // Value from iteration; may be NULL
    204206            status |= writeSingleHeader(hdu, key, value);
    205207        }
     
    394396                continue;
    395397            }
    396             psList *keywords = psStringSplit(headerItem->data.V, " ,;", true); // List of header keywords
    397             if (formatted->type == PS_DATA_LIST) {
    398                 psList *values = formatted->data.V; // The values for the headers
    399                 if (values->n != keywords->n) {
    400                     psLogMsg(__func__, PS_LOG_WARN, "Number of headers specified does not match number "
    401                              "of values for concept %s.\n", name);
    402                 }
    403                 psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator
    404                 psListIterator *keywordsIter = psListIteratorAlloc(keywords, PS_LIST_HEAD, false);
    405                 psMetadataItem *valuesItem = NULL; // Item from list
    406                 while ((valuesItem = psListGetAndIncrement(valuesIter))) {
    407                     psString keyword = psListGetAndIncrement(keywordsIter); // Keyword from the list
    408                     if (strlen(keyword) > 0) {
    409                         writeHeader(hdu, keyword, formatted);
    410                     }
    411                 }
    412                 psFree(valuesIter);
    413                 psFree(keywordsIter);
    414             } else {
    415                 psString keyword = psListGet(keywords, PS_LIST_HEAD); // The keyword
    416                 writeHeader(hdu, keyword, formatted);
    417             }
     398            writeHeader(hdu, headerItem->data.V, formatted);
    418399            psFree(formatted);
    419             psFree(keywords);
    420400        }
    421401    }
  • trunk/psModules/src/detrend/pmDetrendDB.c

    r8815 r8848  
    33#endif
    44
    5 # include <pslib.h>
    6 # include "pmFPA.h"
    7 # include "pmDetrendDB.h"
     5#include <stdio.h>
     6#include <string.h>
     7#include <pslib.h>
     8#include "pmFPA.h"
     9#include "pmDetrendDB.h"
    810
    911// ************* detrend select functions **************
  • trunk/psModules/src/detrend/pmFringeStats.c

    r8815 r8848  
    33 *  @author Eugene Magnier, IfA
    44 *
    5  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-09-15 09:49:01 $
     5 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-09-20 02:36:36 $
    77 *
    88 *  Copyright 2004 IfA
     
    1515#include <stdio.h>
    1616#include <assert.h>
     17#include <string.h>
    1718#include <pslib.h>
    1819#include "pmFPA.h"
  • trunk/psModules/src/detrend/psIOBuffer.c

    r8815 r8848  
    44#endif
    55
    6 # include <unistd.h>
    7 # include <pslib.h>
    8 # include "pmFPA.h"
    9 # include "pmDetrendDB.h"
     6#include <stdio.h>
     7#include <string.h>
     8#include <unistd.h>
     9#include <pslib.h>
     10#include "pmFPA.h"
     11#include "pmDetrendDB.h"
    1012
    1113static void psIOBufferFree (psIOBuffer *buffer)
  • trunk/psModules/src/detrend/psPipe.c

    r8815 r8848  
    33#endif
    44
    5 # include <sys/types.h>
    6 # include <unistd.h>
    7 # include <fcntl.h>
    8 # include <pslib.h>
    9 # include "pmFPA.h"
    10 # include "pmDetrendDB.h"
     5#include <stdio.h>
     6#include <string.h>
     7#include <sys/types.h>
     8#include <unistd.h>
     9#include <fcntl.h>
     10#include <pslib.h>
     11#include "pmFPA.h"
     12#include "pmDetrendDB.h"
    1113
    1214void closePipes (int *stdin_fd, int *stdout_fd, int *stderr_fd)
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r8815 r8848  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-09-15 09:49:01 $
     7 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-09-20 02:36:36 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1717
    1818#include <stdio.h>
     19#include <string.h>
    1920#include <assert.h>
    2021#include <pslib.h>
Note: See TracChangeset for help on using the changeset viewer.