IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8965


Ignore:
Timestamp:
Sep 25, 2006, 3:41:29 PM (20 years ago)
Author:
drobbin
Message:

Made changes while testing. Due to problems with Makefile, I don't know which of these files actually changed for sure. Do a diff if needed.

Location:
trunk/psLib/src/types
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psArguments.c

    r8808 r8965  
    77 *  @author David Robbins, MHPCC
    88 *
    9  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-09-13 21:11:11 $
     9 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-09-26 01:41:29 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1313 */
    1414
    15 #include <stdio.h>
    16 #include <stdarg.h>
    17 #include <string.h>
    18 #include <inttypes.h>
    19 
     15#include<stdio.h>
     16#include<stdarg.h>
     17#include<string.h>
    2018#include "psArguments.h"
    2119#include "fitsio.h"
     
    317315        // Print the value
    318316        switch (item->type) {
    319             PRINT_CASE(U8, "%u");
    320             PRINT_CASE(U16, "%u");
    321             PRINT_CASE(U32, "%u");
    322             PRINT_CASE(U64, "%" PRIu64);
    323             PRINT_CASE(S8, "%d");
    324             PRINT_CASE(S16, "%d");
    325             PRINT_CASE(S32, "%d");
    326             PRINT_CASE(S64, "%" PRId64);
    327             PRINT_CASE(F32, "%.6e");
    328             PRINT_CASE(F64, "%.6e");
     317            PRINT_CASE(U8,"%u");
     318            PRINT_CASE(U16,"%u");
     319            PRINT_CASE(U32,"%u");
     320            PRINT_CASE(U64,"%lu");
     321            PRINT_CASE(S8,"%d");
     322            PRINT_CASE(S16,"%d");
     323            PRINT_CASE(S32,"%d");
     324            PRINT_CASE(S64,"%ld");
     325            PRINT_CASE(F32,"%.6e");
     326            PRINT_CASE(F64,"%.6e");
    329327        case PS_DATA_BOOL:
    330328            if (item->data.B) {
  • trunk/psLib/src/types/psArray.c

    r8816 r8965  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-09-15 14:38:25 $
     11 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-09-26 01:41:29 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    164164    PS_ASSERT_PTR_NON_NULL(array, false);
    165165
    166     if (position < 0 || position >= array->n) {
     166    if (position > array->n) {
    167167        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    168168                _("position > then the number of elements in the array."));
     
    174174    psFree(array->data[i]);
    175175    memmove(&array->data[i], &array->data[i + 1], (n - i - 1) * sizeof(psPtr));
    176     array->n--;    // reset the array size to indicate the removed item
     176    array->n = --i; // reset the array size to indicate the removed item(s)
    177177
    178178    return true;
  • trunk/psLib/src/types/psBitSet.c

    r8627 r8965  
    1111 *  @author Robert DeSonia, MHPCC
    1212 *
    13  *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-08-26 04:34:28 $
     13 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-09-26 01:41:29 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psAbort.h"
    2828#include "psString.h"
     29#include "psAssert.h"
    2930
    3031
     
    6061static void bitSetFree(psBitSet* inBitSet)
    6162{
    62     if (inBitSet == NULL) {
    63         return;
    64     }
    6563    psFree(inBitSet->bits);
    6664}
     
    7775psBitSet* psBitSetAlloc(long nalloc)
    7876{
     77    if (nalloc < 0) {
     78        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     79                _("The number of bit in a psBitSet (%ld) must be greater than zero."),
     80                nalloc);
     81        return NULL;
     82    }
     83
    7984    psS32 numBytes = 0;
    8085    psBitSet* newObj = NULL;
    81 
    82     if (nalloc < 0) {
    83         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    84                 _("The number of bit in a psBitSet (%ld) must be greater than zero."),
    85                 nalloc);
    86         return NULL;
    87     }
    8886
    8987    numBytes = ceil(nalloc / 8.0);
     
    174172                     const psBitSet* inBitSet2)
    175173{
     174    if (inBitSet1 == NULL) {
     175        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     176                _("First psBitSet operand can not be NULL."));
     177        psFree(outBitSet);
     178        return NULL;
     179    }
     180    if (operator == NULL) {
     181        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     182                _("Specified operator is NULL.  Must specify desired operator."));
     183        psFree(outBitSet);
     184        return NULL;
     185    }
    176186    psS32 i = 0;
    177187    psS32 n = 0;
     
    181191    psS32 op = UNKNOWN_OP;
    182192
    183     if (inBitSet1 == NULL) {
    184         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    185                 _("First psBitSet operand can not be NULL."));
    186         psFree(outBitSet);
    187         return NULL;
    188     }
    189193    inBits1 = inBitSet1->bits;
    190194
    191     if (operator == NULL) {
    192         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    193                 _("Specified operator is NULL.  Must specify desired operator."));
    194         psFree(outBitSet);
    195         return NULL;
    196     }
    197195
    198196    // parse the operator
     
    257255        break;
    258256    case NOT_OP:
     257    default:
    259258        for (i = 0; i < n; i++) {
    260259            outBits[i] = ~inBits1[i];
    261260        }
    262261        break;
    263     default:
    264         psAbort("psBitSetOp",
    265                 "Unexpected error - operator parsed successfully but not valid?");
    266262    }
    267263
     
    281277    outBitSet = psBitSetOp(outBitSet,inBitSet,"NOT",NULL);
    282278
    283     if (outBitSet == NULL) {
    284         psError(PS_ERR_UNKNOWN, false,
    285                 _("Could not perform NOT operation."));
    286     }
    287 
    288279    return outBitSet;
    289280}
     
    291282psString psBitSetToString(const psBitSet* bitSet)
    292283{
     284    PS_ASSERT_PTR_NON_NULL(bitSet, NULL);
    293285    psS32 i = 0;
    294286    psS32 numBits = bitSet->n * 8;
    295     char *outString = psAlloc((size_t) numBits + 1);
     287    //    char *outString = psAlloc((size_t) numBits + 1);
     288    psString outString = psStringAlloc(numBits + 1);
    296289
    297290    for (i = 0; i < numBits; i++) {
  • trunk/psLib/src/types/psBitSet.h

    r5057 r8965  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-09-15 21:22:22 $
     14 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-09-26 01:41:29 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232/** Struct containing array of bytes to hold bit data and corresponding array length.
    3333 *
    34  *  The bits in the struct are assembled in as an array of bytes with eight bits per byte. The bits are
    35  *  arranged with the LSB in first (right most) position of the first array element.
     34 *  The bits in the struct are assembled in as an array of bytes with eight bits per
     35 *  byte. The bits are arranged with the LSB in first (right most) position of the
     36 *  first array element.
    3637 */
    3738typedef struct
     
    5152 *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
    5253 *
    53  *  @return bool:       True if the pointer matches a psBitSet structure, false otherwise.
     54 *  @return bool:     True if the pointer matches a psBitSet structure, false otherwise.
    5455 */
    5556bool psMemCheckBitSet(
     
    6061/** Allocate a psBitSet.
    6162 *
    62  *  Create a psBitSet with the number of bits specified by the user. All bits are set to zero upon
    63  *  allocation.
     63 *  Create a psBitSet with the number of bits specified by the user. All bits are set
     64 *  to zero upon allocation.
    6465 *
    6566 *  @return  psBitSet* : Pointer to struct containing array of bits and size of array.
    6667 */
    6768psBitSet* psBitSetAlloc(
    68     long nalloc                            ///< Number of bits in psBitSet array
     69    long nalloc                        ///< Number of bits in psBitSet array
    6970);
    7071
     
    7273 *
    7374 *  Sets a bit at a given bit location. The bit is set based on a zero index with the
    74  *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
    75  *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
     75 *  first bit set in the zero bit slot of the zero element of the byte array. As an
     76 *  example, setting bit 3 in an array with two elements would result in an psBitSet
     77 *  that looks like 00000000 00001000.
    7678 *
    7779 *  @return  psBitSet* : Pointer to struct containing psBitSet.
     
    9799/** Test the value of a bit.
    98100 *
    99  *  Prints the value of a bit at a given bit location, either one or zero. The resulting bit is based on a
    100  *  zero index format with the first bit set in the zero bit slot of the zero element of the byte array
    101  *  As an example, testing bit 3 in a psBitSet with two bytes that looks like 00000000 00001000 would return a
    102  *  value of one, since that is the value that was set.
     101 *  Prints the value of a bit at a given bit location, either one or zero. The resulting
     102 *  bit is based on a zero index format with the first bit set in the zero bit slot of
     103 *  the zero element of the byte array.  As an example, testing bit 3 in a psBitSet with
     104 *  two bytes that looks like 00000000 00001000 would return a value of one, since that
     105 *  is the value that was set.
    103106 *
    104107 *  @return  bool:      True if successful, otherwise false
    105108 */
    106 
    107109bool psBitSetTest(
    108110    const psBitSet* bitSet,            ///< Pointer psBitSet to be tested.
     
    112114/** Perform a binary operation on two psBitSets
    113115 *
    114  *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size, the operation will not
    115  *  be performed and an error message will be logged.
     116 *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size,
     117 *  the operation will not be performed and an error message will be logged.
    116118 *
    117119 *  @return  psBitSet* : Pointer to struct containing result of binary operation.
    118120 */
    119121psBitSet* psBitSetOp(
    120     psBitSet* outBitSet,                 ///< Resulting psBitSet from binary operation
    121     const psBitSet* inBitSet1,           ///< First psBitSet on which to operate
    122     const char *operator,                    ///< Bit operation
    123     const psBitSet* inBitSet2            ///< First psBitSet on which to operate
     122    psBitSet* outBitSet,               ///< Resulting psBitSet from binary operation
     123    const psBitSet* inBitSet1,         ///< First psBitSet on which to operate
     124    const char *operator,              ///< Bit operation
     125    const psBitSet* inBitSet2          ///< Second psBitSet on which to operate
    124126);
    125127
    126128/** Perform a not operation on a psBitSet
    127129 *
    128  *  Toggles bits in a psBitset. All zero bits are set to one and all one bits are set to zero.
     130 *  Toggles bits in a psBitset. All zero bits are set to one and all one bits are set
     131 *  to zero.
    129132 *
    130133 *  @return  psBitSet* : Pointer to struct containing result of operation.
    131134 */
    132 
    133135psBitSet* psBitSetNot(
    134136    psBitSet* outBitSet,               ///< Resulting psBitSet from operation
     
    138140/** Convert the psBitSet to a string of ones and zeros.
    139141 *
    140  *  Converts the contents of a psBitSet to a string representation of its binary form of ones and zeros. The
    141  *  LSB is the right-most chracter. Each set of eight characters represents one byte.
     142 *  Converts the contents of a psBitSet to a string representation of its binary form of
     143 *  ones and zeros. The LSB is the right-most chracter. Each set of eight characters
     144 *  represents one byte.
    142145 *
    143  *  @return  char*: Pointer to character array containing string data.
     146 *  @return  psString:      Pointer to character array containing string data.
    144147 */
    145 
    146148psString psBitSetToString(
    147     const psBitSet* bitSet             ///< psBitSet to convert */
     149    const psBitSet* bitSet             ///< psBitSet to convert
    148150);
    149151
  • trunk/psLib/src/types/psHash.c

    r8668 r8965  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-08-29 20:23:54 $
     14*  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-09-26 01:41:29 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4747psList* psHashKeyList(const psHash* hash)
    4848{
     49    PS_ASSERT_PTR_NON_NULL(hash, NULL);
    4950    psS32 i = 0;                  // Loop index variable
    5051    psList* myLinkList = NULL;  // The output data structure
    5152    psHashBucket* ptr = NULL;   // Used to step thru linked list.
    5253
    53     if (hash == NULL) {
    54         return NULL;
    55     }
    5654    // Create the linked list
    5755    myLinkList = psListAlloc(NULL);
     
    9896    bucket->key = psStringCopy(key);
    9997
    100     if (data == NULL) {
    101         // NOTE: Should we flag a warning message?
    102         bucket->data = NULL;
    103     } else {
    104         bucket->data = psMemIncrRefCounter(data);
    105     }
     98    //XXX:  Since this function is static and only called by doHashWork,
     99    //data can never be NULL here.
     100    //    if (data == NULL) {
     101    // NOTE: Should we flag a warning message?
     102    //        bucket->data = NULL;
     103    //    } else {
     104    bucket->data = psMemIncrRefCounter(data);
     105    //    }
    106106
    107107    bucket->next = next;
     
    120120static void hashBucketFree(psHashBucket* bucket)
    121121{
    122     if (bucket == NULL) {
    123         return;
    124     }
    125 
    126122    psFree(bucket->key);
    127 
    128123    psFree(bucket->data);
    129124}
     
    139134psHash* psHashAlloc(long nalloc)        // initial number of buckets
    140135{
     136    if (nalloc < 0)
     137    {
     138        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     139                "Can't allocate a psHash of negative size.");
     140        return NULL;
     141    }
    141142    psS32 i = 0;                  // loop index variable
    142143
     
    185186    psS32 i = 0;                  // Loop index variable.
    186187
    187     if (table == NULL) {
    188         return;
    189     }
    190188    // Loop through each bucket in the hash table.  If that bucket is not
    191189    // NULL, then free the bucket via a function call to hashBucketFree();
     
    225223static psPtr doHashWork(psHash* table,
    226224                        const char *key,
    227                         psPtr data, psBool remove
     225                        psPtr data,
     226                        psBool remove
    228227                           )
    229228{
     
    240239    // function, but I'm checking it anyway since future coders might change
    241240    // the way this procedure is called.
    242     if ((table == NULL) || (key == NULL)) {
    243         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    244                 _("Input key can not be NULL."));
    245         return NULL;
    246     }
     241    /*    if ((table == NULL) || (key == NULL)) {
     242            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     243                    _("Input key can not be NULL."));
     244            return NULL;
     245        }
     246    */
    247247    // NOTE: This is the originally supplied hash function.
    248248    // for (psS32 i = 0, len = strlen(key); i < len; i++) {
     
    253253    // This hash algorithm is from Sedgewick.  NOTE: must reread to ensure that
    254254    // the size of the hash table is not required to be a prime number.
     255    if (table->n <= 0)
     256        return NULL;
    255257    tmpchar = (char *)key;
    256258    for (hash = 0; *tmpchar != '\0'; tmpchar++) {
     
    260262    // NOTE: This should not be necessary, but for now, I'm checking bounds
    261263    // anyway.
    262     if ((hash < 0) || (hash >= table->n)) {
    263         psError(PS_ERR_UNKNOWN, true,
    264                 "Internal hash function out of range (%" PRId64 ")", hash);
    265     }
     264    /*    if ((hash < 0) || (hash >= table->n)) {
     265            psError(PS_ERR_UNKNOWN, true,
     266                    "Internal hash function out of range (%" PRId64 ")", hash);
     267        }
     268    */
    266269    // ptr will have the correct hash bucket.
    267270    ptr = table->buckets[hash];
     
    397400                  const char *key)
    398401{
     402    PS_ASSERT_PTR_NON_NULL(hash, false);
     403    PS_ASSERT_PTR_NON_NULL(key, false);
     404
    399405    psPtr data = NULL;
    400406    psBool retVal = false;
    401 
    402     PS_ASSERT_PTR_NON_NULL(hash, false);
    403     PS_ASSERT_PTR_NON_NULL(key, false);
    404407
    405408    data = doHashWork(hash, key, NULL, true);
     
    421424    int nElements = 0;
    422425    int nbucket = hash->n;
     426    //XXX:  If we do psArrayAlloc(0) here and use psArrayAdd(result, 1, tmpBucket->data)
     427    //we can eliminate the 2nd for loop below.
    423428    for (int i = 0; i < nbucket; i++) {
    424429        psHashBucket* tmpBucket = hash->buckets[i];
  • trunk/psLib/src/types/psHash.h

    r8839 r8965  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-09-19 23:54:43 $
     13 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-09-26 01:41:29 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/types/psMetadata.c

    r8846 r8965  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.133 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-09-20 02:08:43 $
     14 *  @version $Revision: 1.134 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-09-26 01:41:29 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    605605        // Node doesn't exist - Add new metadata item to metadata collection's hash
    606606        /*  The following is unneeded.  HashAdd can't return false with non-null inputs.
    607 
     607         
    608608                if(!psHashAdd(mdTable, key, (psPtr)item)) {
    609609                    psError(PS_ERR_UNKNOWN,false,
     
    13151315            }
    13161316        case PS_DATA_LIST:
    1317             fprintf(fd, "<a list of size %ld>\n", ((psList*)item->data.V)->n);
     1317            fprintf(fd, "<a list of unknown contents>\n");
    13181318            break;
    13191319        case PS_DATA_TIME: {
  • trunk/psLib/src/types/psMetadataConfig.c

    r8837 r8965  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.90 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-09-19 03:45:24 $
     12*  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-09-26 01:41:29 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    11571157    PS_ASSERT_PTR_NON_NULL(filename,NULL);
    11581158
     1159    struct stat buf;
     1160
    11591161    // Attempt to open specified file
    11601162    int fd = 0;
     
    11621164        // XXX really should return strerror() here
    11631165        psError(PS_ERR_IO, true, _("Failed to open file '%s'. Check if it exists and it has the proper permissions."), filename);
    1164         return NULL;
    1165     }
    1166 
    1167     struct stat buf;                    // Results of stat() for file
    1168     if (fstat(fd, &buf) != 0) {
    1169         psError(PS_ERR_IO, true, _("Unable to stat file '%s'.\n"), filename);
    1170         close(fd);
    11711166        return NULL;
    11721167    }
     
    13341329        break;
    13351330    case PS_DATA_BOOL:
    1336         psStringAppend (&content, "%-15s  %-8s  %-15s",
     1331        psStringAppend (&content, "%-15s  %-8s  -%15s",
    13371332                        item->name, "BOOL", item->data.B ? "T" : "F");
    13381333        if (item->comment && strncmp(item->comment, "", 2)) {
     
    13721367        break;
    13731368    case PS_DATA_STRING:
    1374         if (item->data.str && strlen(item->data.str) > 0) {
    1375             psStringAppend(&content, "%-15s  %-8s  %-15s",
    1376                            item->name, "STR", item->data.str);
    1377         } else {
    1378             psStringAppend(&content, "%-15s  %-8s  %-15s",
    1379                            item->name, "STR", "NULL");
    1380         }
     1369        psStringAppend(&content, "%-15s  %-8s  -%15s",
     1370                       item->name, "STR", item->data.str);
    13811371        if (item->comment && strncmp(item->comment,"",2)) {
    13821372            psStringAppend(&content, "  # %s", item->comment);
  • trunk/psLib/src/types/psPixels.c

    r8839 r8965  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-09-19 23:54:43 $
     9 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-09-26 01:41:29 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/types/psPixels.h

    r8839 r8965  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-09-19 23:54:43 $
     9 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-09-26 01:41:29 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
Note: See TracChangeset for help on using the changeset viewer.