IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 3, 2004, 3:05:00 PM (22 years ago)
Author:
desonia
Message:

changed the psError signature to match SDRS. Also made misc. cleanups as
I was combing the files.

Location:
trunk/psLib/src/collections
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psBitSet.c

    r2204 r2273  
    1111 *  @author Robert DeSonia, MHPCC
    1212 *
    13  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:04:57 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7272
    7373    if (n < 0) {
    74         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetAlloc",
    75                    PS_ERR_BAD_PARAMETER_VALUE, true,
    76                    PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
    77                    n);
     74        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     75                PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
     76                n);
    7877        return NULL;
    7978    }
     
    9998
    10099    if (inBitSet == NULL) {
    101         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
    102                    PS_ERR_BAD_PARAMETER_NULL, true,
    103                    PS_ERRORTEXT_psBitSet_SET_NULL);
     100        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     101                PS_ERRORTEXT_psBitSet_SET_NULL);
    104102        return inBitSet;
    105103    } else if ( (bit < 0) ||
    106104                (bit > inBitSet->n * 8 - 1) ) {
    107         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
    108                    PS_ERR_BAD_PARAMETER_VALUE, true,
    109                    PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
    110                    bit,inBitSet->n * 8 - 1);
     105        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     106                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     107                bit,inBitSet->n * 8 - 1);
    111108        return inBitSet;
    112109    }
     
    124121
    125122    if (inBitSet == NULL) {
    126         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
    127                    PS_ERR_BAD_PARAMETER_NULL, true,
    128                    PS_ERRORTEXT_psBitSet_SET_NULL);
     123        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     124                PS_ERRORTEXT_psBitSet_SET_NULL);
    129125        return inBitSet;
    130126    } else if ( (bit < 0) ||
    131127                (bit > inBitSet->n * 8 - 1) ) {
    132         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
    133                    PS_ERR_BAD_PARAMETER_VALUE, true,
    134                    PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
    135                    bit,inBitSet->n * 8 - 1);
     128        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     129                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     130                bit,inBitSet->n * 8 - 1);
    136131        return inBitSet;
    137132    }
     
    149144
    150145    if (inBitSet == NULL) {
    151         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
    152                    PS_ERR_BAD_PARAMETER_NULL, true,
    153                    PS_ERRORTEXT_psBitSet_SET_NULL);
     146        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     147                PS_ERRORTEXT_psBitSet_SET_NULL);
    154148        return false;
    155149    } else if ( (bit < 0) ||
    156150                (bit > inBitSet->n * 8 - 1) ) {
    157         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
    158                    PS_ERR_BAD_PARAMETER_VALUE, true,
    159                    PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
    160                    bit,inBitSet->n * 8 - 1);
     151        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     152                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
     153                bit,inBitSet->n * 8 - 1);
    161154        return false;
    162155    }
     
    180173
    181174    if (inBitSet1 == NULL) {
    182         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
    183                    PS_ERR_BAD_PARAMETER_NULL, true,
    184                    PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
     175        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     176                PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
    185177        psFree(outBitSet);
    186178        return NULL;
     
    189181
    190182    if (operator == NULL) {
    191         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
    192                    PS_ERR_BAD_PARAMETER_NULL, true,
    193                    PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
     183        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     184                PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
    194185        psFree(outBitSet);
    195186        return NULL;
     
    217208        psFree(tempStr);
    218209        psFree(outBitSet);
    219         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
    220                    PS_ERR_BAD_PARAMETER_VALUE, true,
    221                    PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
    222                    operator);
     210        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     211                PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
     212                operator);
    223213        return NULL;
    224214    }
     
    227217    if (op != NOT_OP) {
    228218        if (inBitSet2 == NULL) {
    229             psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
    230                        PS_ERR_BAD_PARAMETER_NULL, true,
    231                        PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
     219            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     220                    PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
    232221            psFree(outBitSet);
    233222            return NULL;
     
    235224
    236225        if (inBitSet1->n != inBitSet2->n) {
    237             psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
    238                        PS_ERR_BAD_PARAMETER_SIZE, true,
    239                        PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
     226            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     227                    PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
    240228            psFree(outBitSet);
    241229            return NULL;
     
    287275{
    288276    if (inBitSet == NULL) {
    289         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
    290                    PS_ERR_BAD_PARAMETER_NULL, true,
    291                    PS_ERRORTEXT_psBitSet_OPERAND_NULL);
     277        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     278                PS_ERRORTEXT_psBitSet_OPERAND_NULL);
    292279        psFree(outBitSet);
    293280        return NULL;
     
    297284
    298285    if (outBitSet == NULL) {
    299         psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
    300                    PS_ERR_UNKNOWN, false,
    301                    PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
     286        psError(PS_ERR_UNKNOWN, false,
     287                PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
    302288    }
    303289
  • trunk/psLib/src/collections/psHash.c

    r2221 r2273  
    1111*  @author George Gusciora, MHPCC
    1212*
    13 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-10-27 23:31:43 $
     13*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-11-04 01:04:57 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    228228    // the way this procedure is called.
    229229    if ((table == NULL) || (key == NULL)) {
    230         psErrorMsg(PS_ERRORNAME_DOMAIN "doHashWork",
    231                    PS_ERR_BAD_PARAMETER_NULL, true,
    232                    PS_ERRORTEXT_psHash_KEY_NULL);
     230        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     231                PS_ERRORTEXT_psHash_KEY_NULL);
    233232        return NULL;
    234233    }
     
    249248    // anyway.
    250249    if ((hash < 0) || (hash >= table->nbucket)) {
    251         psError(__func__, "Internal hash function out of range (%d)", hash);
     250        psError(PS_ERR_UNKNOWN, true,
     251                "Internal hash function out of range (%d)", hash);
    252252    }
    253253    // ptr will have the correct hash bucket.
     
    347347{
    348348    if (table == NULL) {
    349         psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
    350                    PS_ERR_BAD_PARAMETER_NULL, true,
    351                    PS_ERRORTEXT_psHash_KEY_NULL);
     349        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     350                PS_ERRORTEXT_psHash_KEY_NULL);
    352351        return false;
    353352    }
    354353    if (key == NULL) {
    355         psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
    356                    PS_ERR_BAD_PARAMETER_NULL, true,
    357                    PS_ERRORTEXT_psHash_TABLE_NULL);
     354        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     355                PS_ERRORTEXT_psHash_TABLE_NULL);
    358356        return false;
    359357    }
    360358    if (data == NULL) {
    361         psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
    362                    PS_ERR_BAD_PARAMETER_NULL, true,
    363                    PS_ERRORTEXT_psHash_DATA_NULL);
     359        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     360                PS_ERRORTEXT_psHash_DATA_NULL);
    364361    }
    365362
     
    382379{
    383380    if (table == NULL) {
    384         psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup",
    385                    PS_ERR_BAD_PARAMETER_NULL, true,
    386                    PS_ERRORTEXT_psHash_KEY_NULL);
     381        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     382                PS_ERRORTEXT_psHash_KEY_NULL);
    387383        return NULL;
    388384    }
    389385    if (key == NULL) {
    390         psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup",
    391                    PS_ERR_BAD_PARAMETER_NULL, true,
    392                    PS_ERRORTEXT_psHash_TABLE_NULL);
     386        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     387                PS_ERRORTEXT_psHash_TABLE_NULL);
    393388        return NULL;
    394389    }
     
    414409
    415410    if (table == NULL) {
    416         psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove",
    417                    PS_ERR_BAD_PARAMETER_NULL, true,
    418                    PS_ERRORTEXT_psHash_TABLE_NULL);
     411        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     412                PS_ERRORTEXT_psHash_TABLE_NULL);
    419413        return false;
    420414    }
    421415    if (key == NULL) {
    422         psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove",
    423                    PS_ERR_BAD_PARAMETER_NULL, true,
    424                    PS_ERRORTEXT_psHash_KEY_NULL);
     416        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     417                PS_ERRORTEXT_psHash_KEY_NULL);
    425418        return false;
    426419    }
  • trunk/psLib/src/collections/psList.c

    r2204 r2273  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:31 $
     8 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:04:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    136136
    137137        if (position == NULL) {
    138             psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, location);
     138            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     139                    "Failed to move cursor to specified location (%d)", location);
    139140            position = list->head;         // since we no list->size != 0, this must be non-NULL
    140141        }
     
    173174
    174175    if (list == NULL) {
    175         psError(__func__, "list parameter found to be NULL in %s", __func__);
     176        psError(PS_ERR_BAD_PARAMETER_NULL, true, "list parameter found to be NULL.");
    176177        return false;
    177178    }
     
    194195
    195196        if (location == PS_LIST_UNKNOWN) {
    196             psError(__func__, "Failed to find item in given psList.");
     197            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Failed to find item in given psList.");
    197198            pthread_mutex_unlock(&list->lock)
    198199            ;
     
    206207
    207208    if (elem == NULL) {
    208         psError(__func__, "Couldn't position to given index (%d) to remove element from list.", location);
     209        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     210                "Couldn't position to given index (%d) to remove element from list.", location);
    209211        pthread_mutex_unlock(&list->lock)
    210212        ;
     
    257259
    258260    if (list == NULL) {
    259         psError(__func__, "Unexpected null pointer for psList parameter (%s:%d).", __FILE__, __LINE__);
     261        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     262                "Unexpected null pointer for psList parameter.");
    260263        return;
    261264    }
     
    314317    default:
    315318        if (where <= PS_LIST_HEAD) {   // bascially same as PS_LIST_UNKNOWN above
    316             psError(__func__, "Can't move to an unknown position.  Not moving the iterator position.");
     319            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     320                    "Can't move to an unknown position.  Not moving the iterator position.");
    317321        } else {
    318322            cursor = listGetIterator(list);
  • trunk/psLib/src/collections/psMetadata.c

    r2204 r2273  
    1212*  @author Ross Harman, MHPCC
    1313*
    14 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-10-27 00:57:30 $
     14*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-11-04 01:04:57 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "psMetadata.h"
    3636#include "psString.h"
     37#include "psAstronomyErrors.h"
     38#include "psConstants.h"
    3739
    3840/******************************************************************************/
     
    123125
    124126
    125     if (name == NULL) {
    126         psError(__func__, "Null value for name not allowed");
    127         return NULL;
    128     }
     127    PS_PTR_CHECK_NULL(name,NULL);
     128
    129129    // Allocate metadata item
    130130    metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem));
     
    147147    // Set metadata item type
    148148    metadataItem->type = type;
     149    metadataItem->data.V = NULL;
     150
     151    // Allocate metadata items with same name.
     152    metadataItem->items = psListAlloc(NULL);
     153
     154    // Allocate and set metadata item name
     155    metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
     156    vsprintf(metadataItem->name, name, argPtr);
    149157
    150158    // Set metadata item value
    151159    switch (type) {
    152160    case PS_META_ITEM_SET:
    153         metadataItem->data.V = NULL;
    154161        break;
    155162    case PS_META_BOOL:
     
    180187    case PS_META_UNKNOWN:
    181188    default:
    182         psError(__func__, "Invalid psMetadataType: %d", type);
    183     }
    184 
    185     // Allocate and set metadata item name
    186     metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
    187     vsprintf(metadataItem->name, name, argPtr);
    188 
    189     // Allocate metadata items with same name.
    190     metadataItem->items = psListAlloc(NULL);
     189        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     190                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
     191                type);
     192        psFree(metadataItem);
     193        metadataItem = NULL;
     194    }
    191195
    192196    return metadataItem;
     
    224228    psMetadataType newType = PS_META_ITEM_SET;
    225229
    226     if(md == NULL) {
    227         psError( __func__, "Null metadata collection not allowed" );
    228         return false;
    229     }
    230 
    231     if(metadataItem == NULL) {
    232         psError( __func__, "Null metadata item not allowed" );
    233         return false;
    234     }
     230    PS_PTR_CHECK_NULL(md,NULL);
     231    PS_PTR_CHECK_NULL(md->table,NULL);
     232    PS_PTR_CHECK_NULL(md->list,NULL);
     233    PS_PTR_CHECK_NULL(metadataItem,NULL);
     234    PS_PTR_CHECK_NULL(metadataItem->name,NULL);
    235235
    236236    newType = metadataItem->type;
    237 
    238237    mdTable = md->table;
    239     if(mdTable == NULL) {
    240         psError( __func__, "Null metadata table not allowed" );
    241         return false;
    242     }
    243 
    244238    mdList = md->list;
    245     if(mdList == NULL) {
    246         psError( __func__, "Null metadata list not allowed");
    247         return false;
    248     }
    249 
    250239    key = metadataItem->name;
    251     if(key == NULL) {
    252         psError(__func__, "Null key item not allowed");
    253         return false;
    254     }
    255240
    256241    // See if key is already in table
     
    262247            // Add leaf node to existing folder node
    263248            if(!psListAdd(existingEntry->items, PS_LIST_TAIL, metadataItem)) {
    264                 psError( __func__, "Couldn't add metadata item to items list. Name: %s",
    265                          metadataItem->name );
     249                psError(PS_ERR_UNKNOWN,false,
     250                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
     251                        metadataItem->name );
    266252                return false;
    267253            }
     
    272258
    273259            if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, existingEntry)) {
    274                 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
     260                psError(PS_ERR_UNKNOWN,false,
     261                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
     262                        key);
    275263                psFree(newFolderEntry);
    276264                return false;
     
    278266
    279267            if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, metadataItem)) {
    280                 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
     268                psError(PS_ERR_UNKNOWN,false,
     269                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
     270                        key);
    281271                psFree(newFolderEntry);
    282272                return false;
     
    284274
    285275            if(!psHashRemove(mdTable, key)) {
    286                 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
     276                psError(PS_ERR_UNKNOWN,false,
     277                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
     278                        key);
    287279                psFree(newFolderEntry);
    288280                return false;
     
    290282
    291283            if(!psHashAdd(mdTable, key, newFolderEntry)) {
    292                 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
     284                psError(PS_ERR_UNKNOWN,false,
     285                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
     286                        key);
    293287                psFree(newFolderEntry);
    294288                return false;
     
    301295            // Folder node replaces leaf or folder node - Put old node into new folder and remove from table
    302296            if(!psListAdd(metadataItem->items, PS_LIST_TAIL, existingEntry)) {
    303                 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
     297                psError(PS_ERR_UNKNOWN,false,
     298                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
     299                        key);
    304300                return false;
    305301            }
    306302
    307303            if(!psHashRemove(mdTable, key)) {
    308                 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
     304                psError(PS_ERR_UNKNOWN,false,
     305                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
     306                        key);
    309307                return false;
    310308            }
    311309
    312310            if(!psHashAdd(mdTable, key, metadataItem)) {
    313                 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
     311                psError(PS_ERR_UNKNOWN,false,
     312                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
     313                        key);
    314314                return false;
    315315            }
     
    319319        // Node doesn't exist - Add new metadata item to metadata collection's hash
    320320        if(!psHashAdd(mdTable, key, metadataItem)) {
    321             psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
     321            psError(PS_ERR_UNKNOWN,false,
     322                    PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
     323                    key);
    322324            return false;
    323325        }
     
    328330    if(metadataItem->type != PS_META_ITEM_SET) {
    329331        if(!psListAdd(mdList, location, metadataItem)) {
    330             psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",
    331                      metadataItem->name );
     332            psError(PS_ERR_UNKNOWN,false,
     333                    PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED,
     334                    key);
    332335            return false;
    333336        }
     
    348351
    349352    if (!psMetadataAddItem(md, metadataItem, where)) {
    350         psError(__func__, "Couldn't add metadata item to metadata collection list. Name: %s",
    351                 metadataItem->name);
     353        psError(PS_ERR_UNKNOWN,false,
     354                PS_ERRORTEXT_psMetadata_ADD_FAILED);
    352355        psFree(metadataItem);
    353356        return false;
     
    368371
    369372
    370     if (md == NULL) {
    371         psError(__func__, "Null metadata collection not allowed");
    372         return false;
    373     }
     373    PS_PTR_CHECK_NULL(md,NULL);
     374    PS_PTR_CHECK_NULL(md->table,NULL);
     375    PS_PTR_CHECK_NULL(md->list,NULL);
    374376
    375377    mdList = md->list;
    376     if (mdList == NULL) {
    377         psError(__func__, "Null metadata list not allowed");
    378         return false;
    379     }
    380 
    381378    mdTable = md->table;
    382     if (mdTable == NULL) {
    383         psError(__func__, "Null metadata table not allowed");
    384         return false;
    385     }
     379
    386380    // Select removal by key or index
    387381    if (key != NULL) {
     
    390384        entry = (psMetadataItem* ) psHashLookup(mdTable, key);
    391385        if (entry == NULL) {
    392             psError(__func__, "Couldn't find metadata item. Name: %s", key);
     386            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     387                    PS_ERRORTEXT_psMetadata_FIND_FAILED,
     388                    key);
    393389            return false;
    394390        }
     
    402398            while (entryChild != NULL) {
    403399                if (!psListRemove(mdList, PS_LIST_UNKNOWN, entryChild)) {
    404                     psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
     400                    psError(PS_ERR_UNKNOWN,false,
     401                            PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
     402                            key);
    405403                    return false;
    406404                }
     
    411409            // Table entry has no children. Remove entry from metadata collection's list
    412410            if (!psListRemove(mdList, PS_LIST_UNKNOWN, entry)) {
    413                 psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
     411                psError(PS_ERR_UNKNOWN,false,
     412                        PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
     413                        key);
    414414                return false;
    415415            }
     
    417417        // Remove entry from metadata collection's table
    418418        if (!psHashRemove(mdTable, key)) {
    419             psError(__func__, "Couldn't remove metadata item from table. Name: %s", key);
     419            psError(PS_ERR_UNKNOWN,false,
     420                    PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
     421                    key);
    420422            return false;
    421423        }
     
    425427        entry = psListGet(mdList, where);
    426428        if (entry == NULL) {
    427             psError(__func__, "Couldn't find metadata item in list. Index: %d", where);
     429            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     430                    PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
     431                    where);
    428432            return false;
    429433        }
     
    431435        key = entry->name;
    432436        if (key == NULL) {
    433             psError(__func__, "Null key name not allowed. Index: %d", where);
     437            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     438                    PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED,
     439                    where);
    434440            return false;
    435441        }
     
    447453
    448454
    449     if (md == NULL) {
    450         psError(__func__, "Null metadata collection not allowed");
    451         return NULL;
    452     }
     455    PS_PTR_CHECK_NULL(md,NULL);
     456    PS_PTR_CHECK_NULL(md->table,NULL);
     457    PS_PTR_CHECK_NULL(key,NULL);
    453458
    454459    mdTable = md->table;
    455     if (mdTable == NULL) {
    456         psError(__func__, "Null metadata table not allowed");
    457         return NULL;
    458     }
    459 
    460     if (key == NULL) {
    461         psError(__func__, "Null key name not allowed");
    462         return NULL;
    463     }
    464460
    465461    entry = (psMetadataItem* ) psHashLookup(mdTable, key);
     
    473469psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where)
    474470{
     471    psMetadataItem* entry = NULL;
     472
     473    PS_PTR_CHECK_NULL(md,NULL);
     474    PS_PTR_CHECK_NULL(md->list,NULL);
     475
     476    entry = (psMetadataItem* ) psListGet(md->list, where);
     477    if (entry == NULL) {
     478        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     479                PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
     480                where);
     481        return NULL;
     482    }
     483
     484    return entry;
     485}
     486
     487psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
     488{
     489    PS_PTR_CHECK_NULL(md,NULL);
     490    PS_PTR_CHECK_NULL(md->list,NULL);
     491
     492    psListSetIterator(md->list, where);
     493
     494    return true;
     495}
     496
     497psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
     498{
    475499    psList* mdList = NULL;
    476500    psMetadataItem* entry = NULL;
    477501
    478502
    479     if (md == NULL) {
    480         psError(__func__, "Null metadata collection not allowed");
    481         return NULL;
    482     }
     503    PS_PTR_CHECK_NULL(md,NULL);
     504    PS_PTR_CHECK_NULL(md->list,NULL);
    483505
    484506    mdList = md->list;
    485     if (mdList == NULL) {
    486         psError(__func__, "Null metadata list not allowed");
    487         return NULL;
    488     }
    489 
    490     entry = (psMetadataItem* ) psListGet(mdList, where);
    491     if (entry == NULL) {
    492         psError(__func__, "Couldn't find metadata item with given index. Index: %d", where);
    493         return NULL;
    494     }
    495 
    496     return entry;
    497 }
    498 
    499 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
    500 {
    501     psList* mdList = NULL;
    502 
    503     if (md == NULL) {
    504         psError(__func__, "Null metadata collection not allowed");
    505         return false;
    506     }
    507 
    508     mdList = md->list;
    509     if (mdList == NULL) {
    510         psError(__func__, "Null metadata list not allowed");
    511         return false;
    512     }
    513 
    514     psListSetIterator(mdList, where);
    515 
    516     return true;
    517 }
    518 
    519 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
    520 {
    521     psList* mdList = NULL;
    522     psMetadataItem* entry = NULL;
    523 
    524 
    525     if (md == NULL) {
    526         psError(__func__, "Null metadata collection not allowed");
    527         return NULL;
    528     }
    529 
    530     mdList = md->list;
    531     if (mdList == NULL) {
    532         psError(__func__, "Null metadata list not allowed");
    533         return NULL;
    534     }
    535507
    536508    psListSetIterator(mdList, which);
     
    559531
    560532
    561     if (md == NULL) {
    562         psError(__func__, "Null metadata collection not allowed");
    563         return NULL;
    564     }
     533    PS_PTR_CHECK_NULL(md,NULL);
     534    PS_PTR_CHECK_NULL(md->list,NULL);
    565535
    566536    mdList = md->list;
    567     if (mdList == NULL) {
    568         psError(__func__, "Null metadata list not allowed");
    569         return NULL;
    570     }
    571537
    572538    psListSetIterator(mdList, which);
  • trunk/psLib/src/collections/psMetadataIO.c

    r2204 r2273  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-10-27 00:57:30 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-11-04 01:04:57 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "psMetadata.h"
    3030#include "psMetadataIO.h"
     31#include "psConstants.h"
     32#include "psAstronomyErrors.h"
    3133
    3234
     
    3840#define FITS_ERROR(STRING,PS_ERROR) \
    3941fits_get_errstatus(status, fitsErr); \
    40 psError(__func__, STRING, PS_ERROR, fitsErr); \
     42psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
    4143status = 0; \
    4244fits_close_file(fd, &status); \
    4345if(status){ \
    4446    fits_get_errstatus(status, fitsErr); \
    45     psError(__func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \
     47    psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \
    4648} \
    4749status = 0; \
     
    281283            default:
    282284                *status = 1;
    283                 psError(__func__, "Invalid type: %d", elemType);
     285                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
     286                        PS_ERRORTEXT_psMetadataIO_TYPE_INVALID,
     287                        elemType);
    284288            }
    285289
     
    302306    psMetadataType type;
    303307
    304     if (fd == NULL) {
    305         psError(__func__, "Null file descriptor not allowed");
    306         return;
    307     }
    308 
    309     if (format == NULL) {
    310         psError(__func__, "Null format not allowed");
    311         return;
    312     }
    313 
    314     if (metadataItem == NULL) {
    315         psError(__func__, "Null metadata not allowed");
    316         return;
    317     }
     308    PS_PTR_CHECK_NULL(fd,);
     309    PS_PTR_CHECK_NULL(format,);
     310    PS_PTR_CHECK_NULL(metadataItem,);
    318311
    319312    type = metadataItem->type;
     
    336329        break;
    337330    default:
    338         psError(__func__, " Invalid psMetadataType to print: %d", type);
     331        psError(PS_ERR_BAD_PARAMETER_TYPE,true,
     332                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
     333                (int)type);
    339334    }
    340335}
     
    358353    fitsfile *fd = NULL;
    359354
    360     if(fileName == NULL) {
    361         psError(__func__, "Null fileName not allowed");
    362         return NULL;
    363     }
     355    PS_PTR_CHECK_NULL(fileName,NULL);
    364356
    365357    fits_open_file(&fd, fileName, READONLY, &status);
     
    369361    }
    370362
    371     if (extName == NULL && extNum == 0) {
    372         psError(__func__, "Null extName and extNum = 0 not allowed");
    373         return NULL;
    374     } else if (extName && (extNum != -1) ) {
    375         psError(__func__, "If extName specified, extNum arguments should be -1.");
     363    if (extName == NULL && extNum < 1) {
     364        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     365                PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE,
     366                extNum);
    376367        return NULL;
    377368    }
     
    435426        case 'X':
    436427        default:
    437             psError(__func__, "Invalid psMetadataType: %c", keyType);
     428            psError(PS_ERR_IO, true,
     429                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
     430                    keyType);
    438431            return output;
    439432        }
    440433
    441434        if (!success) {
    442             psError(__func__, "Failed to add metadata item. Name: %s", keyName);
     435            psError(PS_ERR_UNKNOWN, false,
     436                    PS_ERRORTEXT_psMetadataIO_ADD_FAILED,
     437                    keyName);
    443438            return output;
    444439        }
     
    471466
    472467    // Check for nulls
    473     if(fileName == NULL) {
    474         psError(__func__, "Null fileName not allowed");
    475         return -1;
    476     } else if((fp=fopen(fileName, "r")) == NULL) {
    477         psError(__func__, "Couldn't open file. Name: %s", fileName);
     468    PS_PTR_CHECK_NULL(fileName,-1);
     469    if((fp=fopen(fileName, "r")) == NULL) {
     470        psError(PS_ERR_IO, true,
     471                PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED,
     472                fileName);
    478473        return -1;
    479474    }
     
    486481    // Create reusable line for continuous read
    487482    line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
    488     if (line == NULL) {
    489         psAbort(__func__, "Failed to allocate reusable line");
    490     }
    491483
    492484    // While loop to parse the file
     
    504496            if(repeatedChars(linePtr, '@') > 1) {
    505497                failedLines++;
    506                 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line);
     498                psError(PS_ERR_IO, true,
     499                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
     500                        '@', lineCount, fileName);
    507501                continue;
    508502            } else if(repeatedChars(linePtr, '*') > 1) {
    509503                failedLines++;
    510                 psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line);
     504                psError(PS_ERR_IO, true,
     505                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
     506                        '*', lineCount, fileName);
    511507                continue;
    512508            } else if(repeatedChars(linePtr, '~') > 0) {
    513509                failedLines++;
    514                 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line);
     510                psError(PS_ERR_IO, true,
     511                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
     512                        '~', lineCount, fileName);
    515513                continue;
    516514            }
     
    521519                failedLines++;
    522520                status = 0;
    523                 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line);
     521                psError(PS_ERR_IO, true,
     522                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
     523                        "name",lineCount, fileName);
    524524                continue;
    525525            }
     
    530530                failedLines++;
    531531                status = 0;
    532                 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line);
     532                psError(PS_ERR_IO, true,
     533                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
     534                        "type",lineCount, fileName);
    533535                continue;
    534536            } else if(!strncmp(strType, "*", 1)) {
     
    551553            } else {
    552554                failedLines++;
    553                 psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line);
     555                psError(PS_ERR_IO, true,
     556                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
     557                        strType, lineCount, fileName);
    554558                continue;
    555559            }
     
    565569                    failedLines++;
    566570                    status = 0;
    567                     psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line);
     571                    psError(PS_ERR_IO, true,
     572                            PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
     573                            "value",lineCount, fileName);
    568574                    continue;
    569575                }
     
    575581                failedLines++;
    576582                status = 0;
    577                 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line);
     583                psError(PS_ERR_IO, true,
     584                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
     585                        "comment",lineCount, fileName);
    578586                continue;
    579587            }
     
    589597                    } else {
    590598                        failedLines++;
    591                         psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName,
    592                                 lineCount, line);
     599                        psError(PS_ERR_IO, true,
     600                                PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM,
     601                                strName, lineCount, fileName);
    593602                        continue;
    594603                    }
     
    608617                    status = 0;
    609618                    failedLines++;
    610                     psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
     619                    psError(PS_ERR_IO, true,
     620                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
     621                            strValue, strName, strType, lineCount, fileName);
    611622                    continue;
    612623                }
     
    619630                    status = 0;
    620631                    failedLines++;
    621                     psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
     632                    psError(PS_ERR_IO, true,
     633                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
     634                            strValue, strName, strType, lineCount, fileName);
    622635                    continue;
    623636                }
     
    631644                    status = 0;
    632645                    failedLines++;
    633                     psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
     646                    psError(PS_ERR_IO, true,
     647                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
     648                            strValue, strName, strType, lineCount, fileName);
    634649                    continue;
    635650                }
     
    645660                    status = 0;
    646661                    failedLines++;
    647                     psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
     662                    psError(PS_ERR_IO, true,
     663                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
     664                            strValue, strName, strType, lineCount, fileName);
    648665                    continue;
    649666                }
     
    651668            default:
    652669                failedLines++;
    653                 psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line);
     670                psError(PS_ERR_IO, true,
     671                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
     672                        mdType, lineCount, fileName);
    654673                continue;
    655674            } // switch
  • trunk/psLib/src/collections/psScalar.c

    r2055 r2273  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-12 19:32:44 $
     10 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-11-04 01:04:57 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7070        break;
    7171    default:
    72         psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarAlloc",
    73                    PS_ERR_BAD_PARAMETER_TYPE, true,
    74                    PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
    75                    dataType);
     72        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     73                PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
     74                dataType);
    7675    }
    7776
     
    8584
    8685    if (scalar == NULL) {
    87         psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
    88                    PS_ERR_BAD_PARAMETER_NULL, true,
    89                    PS_ERRORTEXT_psScalar_COPY_NULL);
     86        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     87                PS_ERRORTEXT_psScalar_COPY_NULL);
    9088        return NULL;
    9189    }
     
    130128        break;
    131129    default:
    132         psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
    133                    PS_ERR_BAD_PARAMETER_TYPE, true,
    134                    PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
    135                    dataType);
     130        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     131                PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
     132                dataType);
    136133    }
    137134
  • trunk/psLib/src/collections/psVector.c

    r2204 r2273  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-10-27 00:57:31 $
     12*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-11-04 01:04:57 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7070
    7171    if (in == NULL) {
    72         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRealloc",
    73                    PS_ERR_BAD_PARAMETER_NULL, true,
    74                    PS_ERRORTEXT_psVector_REALLOC_NULL);
     72        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     73                PS_ERRORTEXT_psVector_REALLOC_NULL);
    7574        return NULL;
    7675    } else if (in->nalloc != nalloc) {     // No need to realloc to same size
     
    9998            in->type.dimen !=  PS_DIMEN_TRANSV) {
    10099        psFree(in);
    101         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRecycle",
    102                    PS_ERR_BAD_PARAMETER_TYPE, true,
    103                    PS_ERRORTEXT_psVector_NOT_A_VECTOR);
     100        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     101                PS_ERRORTEXT_psVector_NOT_A_VECTOR);
    104102        return NULL;
    105103    }
     
    122120{
    123121    if (in == NULL) {
    124         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
    125                    PS_ERR_BAD_PARAMETER_NULL, true,
    126                    PS_ERRORTEXT_psVector_SORT_NULL);
     122        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     123                PS_ERRORTEXT_psVector_SORT_NULL);
    127124        psFree(out);
    128125        return NULL;
     
    183180                char* typeStr; \
    184181                PS_TYPE_NAME(typeStr,type); \
    185                 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", \
    186                            PS_ERR_BAD_PARAMETER_TYPE, true, \
    187                            PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \
    188                            typeStr); \
     182                psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     183                        PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \
     184                        typeStr); \
    189185                psFree(out); \
    190186            } \
     
    209205            char* typeStr;
    210206            PS_TYPE_NAME(typeStr,type);
    211             psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
    212                        PS_ERR_BAD_PARAMETER_TYPE, true,
    213                        PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
    214                        typeStr);
     207            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     208                    PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
     209                    typeStr);
    215210            psFree(out);
    216211
     
    232227
    233228    if (inVector == NULL) {
    234         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
    235                    PS_ERR_BAD_PARAMETER_NULL, true,
    236                    PS_ERRORTEXT_psVector_SORT_NULL);
     229        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     230                PS_ERRORTEXT_psVector_SORT_NULL);
    237231        psFree(outVector);
    238232        return NULL;
     
    300294        break;
    301295    default:
    302         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
    303                    PS_ERR_BAD_PARAMETER_TYPE, true,
    304                    PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
    305                    inType);
     296        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     297                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
     298                inType);
    306299    }
    307300
     
    317310
    318311    if (inVector == NULL) {
    319         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
    320                    PS_ERR_BAD_PARAMETER_NULL, true,
    321                    PS_ERRORTEXT_psVector_SORT_NULL);
     312        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     313                PS_ERRORTEXT_psVector_SORT_NULL);
    322314        psFree(outVector);
    323315        return NULL;
     
    400392        break;
    401393    default:
    402         psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
    403                    PS_ERR_BAD_PARAMETER_TYPE, true,
    404                    PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
    405                    inType);
     394        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     395                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
     396                inType);
    406397    }
    407398
Note: See TracChangeset for help on using the changeset viewer.