Changeset 2273 for trunk/psLib/src/collections
- Timestamp:
- Nov 3, 2004, 3:05:00 PM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 7 edited
-
psBitSet.c (modified) (12 diffs)
-
psHash.c (modified) (6 diffs)
-
psList.c (modified) (7 diffs)
-
psMetadata.c (modified) (25 diffs)
-
psMetadataIO.c (modified) (23 diffs)
-
psScalar.c (modified) (4 diffs)
-
psVector.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psBitSet.c
r2204 r2273 11 11 * @author Robert DeSonia, MHPCC 12 12 * 13 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31$13 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 72 72 73 73 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); 78 77 return NULL; 79 78 } … … 99 98 100 99 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); 104 102 return inBitSet; 105 103 } else if ( (bit < 0) || 106 104 (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); 111 108 return inBitSet; 112 109 } … … 124 121 125 122 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); 129 125 return inBitSet; 130 126 } else if ( (bit < 0) || 131 127 (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); 136 131 return inBitSet; 137 132 } … … 149 144 150 145 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); 154 148 return false; 155 149 } else if ( (bit < 0) || 156 150 (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); 161 154 return false; 162 155 } … … 180 173 181 174 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); 185 177 psFree(outBitSet); 186 178 return NULL; … … 189 181 190 182 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); 194 185 psFree(outBitSet); 195 186 return NULL; … … 217 208 psFree(tempStr); 218 209 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); 223 213 return NULL; 224 214 } … … 227 217 if (op != NOT_OP) { 228 218 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); 232 221 psFree(outBitSet); 233 222 return NULL; … … 235 224 236 225 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); 240 228 psFree(outBitSet); 241 229 return NULL; … … 287 275 { 288 276 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); 292 279 psFree(outBitSet); 293 280 return NULL; … … 297 284 298 285 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); 302 288 } 303 289 -
trunk/psLib/src/collections/psHash.c
r2221 r2273 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 23:31:43$13 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 228 228 // the way this procedure is called. 229 229 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); 233 232 return NULL; 234 233 } … … 249 248 // anyway. 250 249 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); 252 252 } 253 253 // ptr will have the correct hash bucket. … … 347 347 { 348 348 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); 352 351 return false; 353 352 } 354 353 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); 358 356 return false; 359 357 } 360 358 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); 364 361 } 365 362 … … 382 379 { 383 380 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); 387 383 return NULL; 388 384 } 389 385 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); 393 388 return NULL; 394 389 } … … 414 409 415 410 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); 419 413 return false; 420 414 } 421 415 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); 425 418 return false; 426 419 } -
trunk/psLib/src/collections/psList.c
r2204 r2273 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:31$8 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:04:57 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 136 136 137 137 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); 139 140 position = list->head; // since we no list->size != 0, this must be non-NULL 140 141 } … … 173 174 174 175 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."); 176 177 return false; 177 178 } … … 194 195 195 196 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."); 197 198 pthread_mutex_unlock(&list->lock) 198 199 ; … … 206 207 207 208 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); 209 211 pthread_mutex_unlock(&list->lock) 210 212 ; … … 257 259 258 260 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."); 260 263 return; 261 264 } … … 314 317 default: 315 318 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."); 317 321 } else { 318 322 cursor = listGetIterator(list); -
trunk/psLib/src/collections/psMetadata.c
r2204 r2273 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:30$14 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:04:57 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "psMetadata.h" 36 36 #include "psString.h" 37 #include "psAstronomyErrors.h" 38 #include "psConstants.h" 37 39 38 40 /******************************************************************************/ … … 123 125 124 126 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 129 129 // Allocate metadata item 130 130 metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem)); … … 147 147 // Set metadata item type 148 148 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); 149 157 150 158 // Set metadata item value 151 159 switch (type) { 152 160 case PS_META_ITEM_SET: 153 metadataItem->data.V = NULL;154 161 break; 155 162 case PS_META_BOOL: … … 180 187 case PS_META_UNKNOWN: 181 188 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 } 191 195 192 196 return metadataItem; … … 224 228 psMetadataType newType = PS_META_ITEM_SET; 225 229 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); 235 235 236 236 newType = metadataItem->type; 237 238 237 mdTable = md->table; 239 if(mdTable == NULL) {240 psError( __func__, "Null metadata table not allowed" );241 return false;242 }243 244 238 mdList = md->list; 245 if(mdList == NULL) {246 psError( __func__, "Null metadata list not allowed");247 return false;248 }249 250 239 key = metadataItem->name; 251 if(key == NULL) {252 psError(__func__, "Null key item not allowed");253 return false;254 }255 240 256 241 // See if key is already in table … … 262 247 // Add leaf node to existing folder node 263 248 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 ); 266 252 return false; 267 253 } … … 272 258 273 259 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); 275 263 psFree(newFolderEntry); 276 264 return false; … … 278 266 279 267 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); 281 271 psFree(newFolderEntry); 282 272 return false; … … 284 274 285 275 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); 287 279 psFree(newFolderEntry); 288 280 return false; … … 290 282 291 283 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); 293 287 psFree(newFolderEntry); 294 288 return false; … … 301 295 // Folder node replaces leaf or folder node - Put old node into new folder and remove from table 302 296 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); 304 300 return false; 305 301 } 306 302 307 303 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); 309 307 return false; 310 308 } 311 309 312 310 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); 314 314 return false; 315 315 } … … 319 319 // Node doesn't exist - Add new metadata item to metadata collection's hash 320 320 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); 322 324 return false; 323 325 } … … 328 330 if(metadataItem->type != PS_META_ITEM_SET) { 329 331 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); 332 335 return false; 333 336 } … … 348 351 349 352 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); 352 355 psFree(metadataItem); 353 356 return false; … … 368 371 369 372 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); 374 376 375 377 mdList = md->list; 376 if (mdList == NULL) {377 psError(__func__, "Null metadata list not allowed");378 return false;379 }380 381 378 mdTable = md->table; 382 if (mdTable == NULL) { 383 psError(__func__, "Null metadata table not allowed"); 384 return false; 385 } 379 386 380 // Select removal by key or index 387 381 if (key != NULL) { … … 390 384 entry = (psMetadataItem* ) psHashLookup(mdTable, key); 391 385 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); 393 389 return false; 394 390 } … … 402 398 while (entryChild != NULL) { 403 399 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); 405 403 return false; 406 404 } … … 411 409 // Table entry has no children. Remove entry from metadata collection's list 412 410 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); 414 414 return false; 415 415 } … … 417 417 // Remove entry from metadata collection's table 418 418 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); 420 422 return false; 421 423 } … … 425 427 entry = psListGet(mdList, where); 426 428 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); 428 432 return false; 429 433 } … … 431 435 key = entry->name; 432 436 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); 434 440 return false; 435 441 } … … 447 453 448 454 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); 453 458 454 459 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 }464 460 465 461 entry = (psMetadataItem* ) psHashLookup(mdTable, key); … … 473 469 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where) 474 470 { 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 487 psBool 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 497 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which) 498 { 475 499 psList* mdList = NULL; 476 500 psMetadataItem* entry = NULL; 477 501 478 502 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); 483 505 484 506 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 }535 507 536 508 psListSetIterator(mdList, which); … … 559 531 560 532 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); 565 535 566 536 mdList = md->list; 567 if (mdList == NULL) {568 psError(__func__, "Null metadata list not allowed");569 return NULL;570 }571 537 572 538 psListSetIterator(mdList, which); -
trunk/psLib/src/collections/psMetadataIO.c
r2204 r2273 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:30$11 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psMetadata.h" 30 30 #include "psMetadataIO.h" 31 #include "psConstants.h" 32 #include "psAstronomyErrors.h" 31 33 32 34 … … 38 40 #define FITS_ERROR(STRING,PS_ERROR) \ 39 41 fits_get_errstatus(status, fitsErr); \ 40 psError( __func__, STRING, PS_ERROR, fitsErr); \42 psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \ 41 43 status = 0; \ 42 44 fits_close_file(fd, &status); \ 43 45 if(status){ \ 44 46 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); \ 46 48 } \ 47 49 status = 0; \ … … 281 283 default: 282 284 *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); 284 288 } 285 289 … … 302 306 psMetadataType type; 303 307 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,); 318 311 319 312 type = metadataItem->type; … … 336 329 break; 337 330 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); 339 334 } 340 335 } … … 358 353 fitsfile *fd = NULL; 359 354 360 if(fileName == NULL) { 361 psError(__func__, "Null fileName not allowed"); 362 return NULL; 363 } 355 PS_PTR_CHECK_NULL(fileName,NULL); 364 356 365 357 fits_open_file(&fd, fileName, READONLY, &status); … … 369 361 } 370 362 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); 376 367 return NULL; 377 368 } … … 435 426 case 'X': 436 427 default: 437 psError(__func__, "Invalid psMetadataType: %c", keyType); 428 psError(PS_ERR_IO, true, 429 PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, 430 keyType); 438 431 return output; 439 432 } 440 433 441 434 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); 443 438 return output; 444 439 } … … 471 466 472 467 // 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); 478 473 return -1; 479 474 } … … 486 481 // Create reusable line for continuous read 487 482 line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char)); 488 if (line == NULL) {489 psAbort(__func__, "Failed to allocate reusable line");490 }491 483 492 484 // While loop to parse the file … … 504 496 if(repeatedChars(linePtr, '@') > 1) { 505 497 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); 507 501 continue; 508 502 } else if(repeatedChars(linePtr, '*') > 1) { 509 503 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); 511 507 continue; 512 508 } else if(repeatedChars(linePtr, '~') > 0) { 513 509 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); 515 513 continue; 516 514 } … … 521 519 failedLines++; 522 520 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); 524 524 continue; 525 525 } … … 530 530 failedLines++; 531 531 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); 533 535 continue; 534 536 } else if(!strncmp(strType, "*", 1)) { … … 551 553 } else { 552 554 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); 554 558 continue; 555 559 } … … 565 569 failedLines++; 566 570 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); 568 574 continue; 569 575 } … … 575 581 failedLines++; 576 582 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); 578 586 continue; 579 587 } … … 589 597 } else { 590 598 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); 593 602 continue; 594 603 } … … 608 617 status = 0; 609 618 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); 611 622 continue; 612 623 } … … 619 630 status = 0; 620 631 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); 622 635 continue; 623 636 } … … 631 644 status = 0; 632 645 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); 634 649 continue; 635 650 } … … 645 660 status = 0; 646 661 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); 648 665 continue; 649 666 } … … 651 668 default: 652 669 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); 654 673 continue; 655 674 } // switch -
trunk/psLib/src/collections/psScalar.c
r2055 r2273 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-1 0-12 19:32:44$10 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-11-04 01:04:57 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 70 70 break; 71 71 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); 76 75 } 77 76 … … 85 84 86 85 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); 90 88 return NULL; 91 89 } … … 130 128 break; 131 129 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); 136 133 } 137 134 -
trunk/psLib/src/collections/psVector.c
r2204 r2273 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:04:57 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 70 70 71 71 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); 75 74 return NULL; 76 75 } else if (in->nalloc != nalloc) { // No need to realloc to same size … … 99 98 in->type.dimen != PS_DIMEN_TRANSV) { 100 99 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); 104 102 return NULL; 105 103 } … … 122 120 { 123 121 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); 127 124 psFree(out); 128 125 return NULL; … … 183 180 char* typeStr; \ 184 181 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); \ 189 185 psFree(out); \ 190 186 } \ … … 209 205 char* typeStr; 210 206 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); 215 210 psFree(out); 216 211 … … 232 227 233 228 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); 237 231 psFree(outVector); 238 232 return NULL; … … 300 294 break; 301 295 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); 306 299 } 307 300 … … 317 310 318 311 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); 322 314 psFree(outVector); 323 315 return NULL; … … 400 392 break; 401 393 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); 406 397 } 407 398
Note:
See TracChangeset
for help on using the changeset viewer.
