Changeset 5057
- Timestamp:
- Sep 15, 2005, 11:22:22 AM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 18 edited
-
src/fits/psFits.c (modified) (54 diffs)
-
src/fits/psFits.h (modified) (2 diffs)
-
src/imageops/psImageConvolve.c (modified) (2 diffs)
-
src/imageops/psImageStructManip.c (modified) (6 diffs)
-
src/mathtypes/psImage.c (modified) (4 diffs)
-
src/mathtypes/psImage.h (modified) (2 diffs)
-
src/mathtypes/psScalar.h (modified) (2 diffs)
-
src/mathtypes/psVector.h (modified) (2 diffs)
-
src/sys/psLogMsg.h (modified) (2 diffs)
-
src/sys/psTrace.h (modified) (3 diffs)
-
src/sys/psType.h (modified) (3 diffs)
-
src/types/psBitSet.h (modified) (4 diffs)
-
src/types/psMetadata.c (modified) (4 diffs)
-
src/types/psMetadata.h (modified) (4 diffs)
-
src/types/psMetadataConfig.c (modified) (2 diffs)
-
src/xml/psXML.c (modified) (2 diffs)
-
test/imageops/tst_psImageGeomManip.c (modified) (2 diffs)
-
test/types/tst_psMetadata_04.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFits.c
r4898 r5057 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 8-30 01:14:13$9 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-09-15 21:22:21 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 186 186 int status = 0; 187 187 188 fits_get_hdrspace(fits-> p_fd, &keysexist, &morekeys, &status);188 fits_get_hdrspace(fits->fd, &keysexist, &morekeys, &status); 189 189 190 190 // if no keys exist and not primary HDU, this really is an empty HDU … … 202 202 203 203 if (fits != NULL) { 204 (void)fits_close_file(fits-> p_fd, &status);204 (void)fits_close_file(fits->fd, &status); 205 205 psFree(fits->filename); 206 206 } … … 247 247 psFits* fits = psAlloc(sizeof(psFits)); 248 248 fits->filename = psAlloc(strlen(name)+1); 249 fits-> p_fd = fptr;249 fits->fd = fptr; 250 250 strcpy((char*)fits->filename,name); 251 251 psMemSetDeallocator(fits,(psFreeFunc)fitsFree); … … 279 279 280 280 281 if (fits_movnam_hdu(fits-> p_fd, ANY_HDU, (char*)extname, 0, &status) != 0) {281 if (fits_movnam_hdu(fits->fd, ANY_HDU, (char*)extname, 0, &status) != 0) { 282 282 char fitsErr[MAX_STRING_LENGTH]; 283 283 fits_get_errstatus(status, fitsErr); … … 305 305 306 306 if (relative) { 307 fits_movrel_hdu(fits-> p_fd, extnum, &hdutype, &status);307 fits_movrel_hdu(fits->fd, extnum, &hdutype, &status); 308 308 if (status != 0) { 309 309 char fitsErr[MAX_STRING_LENGTH]; … … 315 315 } 316 316 } else { 317 fits_movabs_hdu(fits-> p_fd, extnum+1, &hdutype, &status);317 fits_movabs_hdu(fits->fd, extnum+1, &hdutype, &status); 318 318 if (status != 0) { 319 319 char fitsErr[MAX_STRING_LENGTH]; … … 340 340 341 341 342 return fits_get_hdu_num(fits-> p_fd,&hdunum) - 1;342 return fits_get_hdu_num(fits->fd,&hdunum) - 1; 343 343 } 344 344 … … 354 354 char name[MAX_STRING_LENGTH]; 355 355 356 if (fits_read_key_str(fits-> p_fd, "EXTNAME", name, NULL, &status) != 0) {356 if (fits_read_key_str(fits->fd, "EXTNAME", name, NULL, &status) != 0) { 357 357 status = 0; 358 if (fits_read_key_str(fits-> p_fd, "HDUNAME", name, NULL, &status) != 0) {358 if (fits_read_key_str(fits->fd, "HDUNAME", name, NULL, &status) != 0) { 359 359 int num = psFitsGetExtNum(fits); 360 360 snprintf(name, MAX_STRING_LENGTH, "EXT-%3d",num); … … 380 380 int status = 0; 381 381 382 if (fits_update_key_str(fits-> p_fd, "EXTNAME", (char*)name, NULL, &status) != 0) {382 if (fits_update_key_str(fits->fd, "EXTNAME", (char*)name, NULL, &status) != 0) { 383 383 char fitsErr[MAX_STRING_LENGTH]; 384 384 (void)fits_get_errstatus(status, fitsErr); … … 403 403 int status = 0; 404 404 405 if (fits_get_num_hdus(fits-> p_fd, &num, &status) != 0) {405 if (fits_get_num_hdus(fits->fd, &num, &status) != 0) { 406 406 char fitsErr[MAX_STRING_LENGTH]; 407 407 fits_get_errstatus(status, fitsErr); … … 426 426 int hdutype = PS_FITS_TYPE_NONE; 427 427 428 if (fits_get_hdu_type(fits-> p_fd, &hdutype, &status) != 0) {428 if (fits_get_hdu_type(fits->fd, &hdutype, &status) != 0) { 429 429 char fitsErr[MAX_STRING_LENGTH]; 430 430 fits_get_errstatus(status, fitsErr); … … 466 466 int keyNum = 0; 467 467 int status = 0; 468 fits_get_hdrpos(fits-> p_fd, &numKeys, &keyNum, &status);468 fits_get_hdrpos(fits->fd, &numKeys, &keyNum, &status); 469 469 470 470 // Get each key name. Keywords start at one. … … 478 478 for (int i = 1; i <= numKeys; i++) { 479 479 480 fits_read_keyn(fits-> p_fd, i, keyName, keyValue, keyComment, &status);480 fits_read_keyn(fits->fd, i, keyName, keyValue, keyComment, &status); 481 481 482 482 stdKey = false; … … 657 657 // check to see if we even are positioned on an image HDU 658 658 int hdutype; 659 if ( fits_get_hdu_type(fits-> p_fd,&hdutype, &status) != 0) {659 if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) { 660 660 char fitsErr[MAX_STRING_LENGTH]; 661 661 (void)fits_get_errstatus(status, fitsErr); … … 672 672 673 673 /* Get the data type 'bitPix' from the FITS image */ 674 if (fits_get_img_equivtype(fits-> p_fd, &bitPix, &status) != 0) {674 if (fits_get_img_equivtype(fits->fd, &bitPix, &status) != 0) { 675 675 fits_get_errstatus(status, fitsErr); 676 676 psError(PS_ERR_IO, true, … … 682 682 683 683 /* Get the dimensions 'nAxis' from the FITS image */ 684 if (fits_get_img_dim(fits-> p_fd, &nAxis, &status) != 0) {684 if (fits_get_img_dim(fits->fd, &nAxis, &status) != 0) { 685 685 (void)fits_get_errstatus(status, fitsErr); 686 686 psError(PS_ERR_IO, true, … … 701 701 702 702 /* Get the Image size from the FITS file */ 703 if (fits_get_img_size(fits-> p_fd, nAxis, nAxes, &status) != 0) {703 if (fits_get_img_size(fits->fd, nAxis, nAxes, &status) != 0) { 704 704 (void)fits_get_errstatus(status, fitsErr); 705 705 psError(PS_ERR_IO, true, … … 787 787 788 788 // n.b., this assumes contiguous image buffer 789 if (fits_read_subset(fits-> p_fd, fitsDatatype, firstPixel, lastPixel, increment,789 if (fits_read_subset(fits->fd, fitsDatatype, firstPixel, lastPixel, increment, 790 790 NULL, output->data.V[0], &anynull, &status) != 0) { 791 791 psFree(output); … … 842 842 } 843 843 844 fits_create_img(fits-> p_fd, bitPix, naxis, naxes, &status);844 fits_create_img(fits->fd, bitPix, naxis, naxes, &status); 845 845 846 846 if (bZero != 0) { // set the bscale/bzero 847 fits_write_key_dbl(fits-> p_fd, "BZERO", bZero, 12, "Pixel Value Offset", &status);848 fits_write_key_dbl(fits-> p_fd, "BSCALE", 1.0, 12, "Pixel Value Scale", &status);849 fits_set_bscale(fits-> p_fd, 1.0, bZero, &status);847 fits_write_key_dbl(fits->fd, "BZERO", bZero, 12, "Pixel Value Offset", &status); 848 fits_write_key_dbl(fits->fd, "BSCALE", 1.0, 12, "Pixel Value Scale", &status); 849 fits_set_bscale(fits->fd, 1.0, bZero, &status); 850 850 } 851 851 … … 856 856 857 857 if (input->parent == NULL) { // if no parent, assume that the image data is contiguous 858 fits_write_img(fits-> p_fd,858 fits_write_img(fits->fd, 859 859 dataType, // datatype 860 860 1, // writing to the first z-plane … … 865 865 int firstPixel = 1; 866 866 for (int row = 0; row < numRows; row++) { 867 fits_write_img(fits-> p_fd,867 fits_write_img(fits->fd, 868 868 dataType, // datatype 869 869 firstPixel, … … 909 909 // check to see if we are positioned on an image HDU 910 910 int hdutype; 911 if ( fits_get_hdu_type(fits-> p_fd,&hdutype, &status) != 0) {911 if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) { 912 912 char fitsErr[MAX_STRING_LENGTH]; 913 913 (void)fits_get_errstatus(status, fitsErr); … … 939 939 long nAxes[3]; 940 940 nAxes[2] = 1; 941 fits_get_img_param(fits-> p_fd, 3, &fileBitpix, &naxis, nAxes, &status);941 fits_get_img_param(fits->fd, 3, &fileBitpix, &naxis, nAxes, &status); 942 942 943 943 //check to see if the HDU has the same datatype … … 1012 1012 } 1013 1013 1014 fits_write_subset(fits-> p_fd, dataType, firstPixel, lastPixel, subset->data.V[0], &status);1014 fits_write_subset(fits->fd, dataType, firstPixel, lastPixel, subset->data.V[0], &status); 1015 1015 1016 1016 if ( status != 0) { … … 1052 1052 case PS_META_BOOL: { 1053 1053 int value = item->data.B; 1054 fits_update_key(fits-> p_fd,1054 fits_update_key(fits->fd, 1055 1055 TLOGICAL, 1056 1056 item->name, … … 1061 1061 } 1062 1062 case PS_META_S32: 1063 fits_update_key(fits-> p_fd,1063 fits_update_key(fits->fd, 1064 1064 TINT, 1065 1065 item->name, … … 1069 1069 break; 1070 1070 case PS_META_F32: 1071 fits_update_key(fits-> p_fd,1071 fits_update_key(fits->fd, 1072 1072 TFLOAT, 1073 1073 item->name, … … 1077 1077 break; 1078 1078 case PS_META_F64: 1079 fits_update_key(fits-> p_fd,1079 fits_update_key(fits->fd, 1080 1080 TDOUBLE, 1081 1081 item->name, … … 1085 1085 break; 1086 1086 case PS_META_STR: 1087 fits_update_key(fits-> p_fd,1087 fits_update_key(fits->fd, 1088 1088 TSTRING, 1089 1089 item->name, … … 1124 1124 // check to see if we even are positioned on a table HDU 1125 1125 int hdutype; 1126 fits_get_hdu_type(fits-> p_fd,&hdutype, &status);1126 fits_get_hdu_type(fits->fd,&hdutype, &status); 1127 1127 if ( status != 0) { 1128 1128 char fitsErr[MAX_STRING_LENGTH]; … … 1140 1140 1141 1141 // get the size of the FITS table 1142 fits_get_num_rows(fits-> p_fd, &numRows, &status);1143 fits_get_num_cols(fits-> p_fd, &numCols, &status);1142 fits_get_num_rows(fits->fd, &numRows, &status); 1143 fits_get_num_cols(fits->fd, &numCols, &status); 1144 1144 if ( status != 0) { 1145 1145 char fitsErr[MAX_STRING_LENGTH]; … … 1169 1169 // get the column name 1170 1170 if (hdutype == BINARY_TBL) { 1171 fits_get_bcolparms(fits-> p_fd, col, name,1171 fits_get_bcolparms(fits->fd, col, name, 1172 1172 NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status); 1173 1173 } else { 1174 fits_get_acolparms(fits-> p_fd, col, name,1174 fits_get_acolparms(fits->fd, col, name, 1175 1175 NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status); 1176 1176 } 1177 1177 // get the column type 1178 fits_get_coltype(fits-> p_fd, col, &typecode, &repeat, &width, &status);1178 fits_get_coltype(fits->fd, col, &typecode, &repeat, &width, &status); 1179 1179 1180 1180 if (status == 0) { … … 1184 1184 NATIVETYPE value = 0; \ 1185 1185 int anynul = 0; \ 1186 fits_read_col(fits-> p_fd, FITSTYPE, col,row+1, \1186 fits_read_col(fits->fd, FITSTYPE, col,row+1, \ 1187 1187 1, 1, NULL, &value, &anynul, &status); \ 1188 1188 psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, Value = %g\n", \ … … 1205 1205 char* value = psAlloc(repeat+1); 1206 1206 int anynul = 0; 1207 fits_read_col(fits-> p_fd, TSTRING, col,row+1,1207 fits_read_col(fits->fd, TSTRING, col,row+1, 1208 1208 1, 1, NULL, &value, &anynul, &status); 1209 1209 psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, value = %s\n", … … 1253 1253 // check to see if we even are positioned on a table HDU 1254 1254 int hdutype; 1255 if ( fits_get_hdu_type(fits-> p_fd,&hdutype, &status) != 0) {1255 if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) { 1256 1256 char fitsErr[MAX_STRING_LENGTH]; 1257 1257 (void)fits_get_errstatus(status, fitsErr); … … 1268 1268 1269 1269 // find the column by name 1270 if ( fits_get_colnum(fits-> p_fd, CASESEN, (char*)colname, &colnum, &status) != 0) {1270 if ( fits_get_colnum(fits->fd, CASESEN, (char*)colname, &colnum, &status) != 0) { 1271 1271 char fitsErr[MAX_STRING_LENGTH]; 1272 1272 (void)fits_get_errstatus(status, fitsErr); … … 1279 1279 // get the number of rows 1280 1280 long numRows = 0; 1281 fits_get_num_rows(fits-> p_fd, &numRows, &status);1281 fits_get_num_rows(fits->fd, &numRows, &status); 1282 1282 1283 1283 // get the column length. 1284 1284 int width; 1285 if ( fits_get_col_display_width(fits-> p_fd, colnum, &width, &status) != 0) {1285 if ( fits_get_col_display_width(fits->fd, colnum, &width, &status) != 0) { 1286 1286 char fitsErr[MAX_STRING_LENGTH]; 1287 1287 (void)fits_get_errstatus(status, fitsErr); … … 1299 1299 result->n = numRows; 1300 1300 1301 fits_read_col_str(fits-> p_fd,1301 fits_read_col_str(fits->fd, 1302 1302 colnum, 1303 1303 1, // firstrow … … 1335 1335 // check to see if we even are positioned on a table HDU 1336 1336 int hdutype; 1337 if ( fits_get_hdu_type(fits-> p_fd,&hdutype, &status) != 0) {1337 if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) { 1338 1338 char fitsErr[MAX_STRING_LENGTH]; 1339 1339 (void)fits_get_errstatus(status, fitsErr); … … 1350 1350 1351 1351 // find the column by name 1352 if ( fits_get_colnum(fits-> p_fd, CASESEN, (char*)colname, &colnum, &status) != 0) {1352 if ( fits_get_colnum(fits->fd, CASESEN, (char*)colname, &colnum, &status) != 0) { 1353 1353 char fitsErr[MAX_STRING_LENGTH]; 1354 1354 (void)fits_get_errstatus(status, fitsErr); … … 1361 1361 // get the number of rows 1362 1362 long numRows = 0; 1363 fits_get_num_rows(fits-> p_fd,1363 fits_get_num_rows(fits->fd, 1364 1364 &numRows, 1365 1365 &status); … … 1369 1369 long repeat; 1370 1370 long width; 1371 if ( fits_get_eqcoltype(fits-> p_fd, colnum, &typecode, &repeat, &width, &status) != 0) {1371 if ( fits_get_eqcoltype(fits->fd, colnum, &typecode, &repeat, &width, &status) != 0) { 1372 1372 char fitsErr[MAX_STRING_LENGTH]; 1373 1373 (void)fits_get_errstatus(status, fitsErr); … … 1380 1380 psVector* result = psVectorAlloc(numRows, convertFitsToPsType(typecode)); 1381 1381 1382 fits_read_col(fits-> p_fd,1382 fits_read_col(fits->fd, 1383 1383 typecode, 1384 1384 colnum, … … 1416 1416 // check to see if we even are positioned on a table HDU 1417 1417 int hdutype; 1418 if ( fits_get_hdu_type(fits-> p_fd,&hdutype, &status) != 0) {1418 if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) { 1419 1419 char fitsErr[MAX_STRING_LENGTH]; 1420 1420 (void)fits_get_errstatus(status, fitsErr); … … 1432 1432 // get the size of the FITS table 1433 1433 long numRows = 0; 1434 fits_get_num_rows(fits-> p_fd, &numRows, &status);1434 fits_get_num_rows(fits->fd, &numRows, &status); 1435 1435 if ( status != 0) { 1436 1436 char fitsErr[MAX_STRING_LENGTH]; … … 1535 1535 } 1536 1536 1537 fits_create_tbl(fits-> p_fd,1537 fits_create_tbl(fits->fd, 1538 1538 BINARY_TBL, 1539 1539 table->n, // number of rows in table … … 1562 1562 item->name); 1563 1563 } 1564 fits_write_col_int(fits-> p_fd,1564 fits_write_col_int(fits->fd, 1565 1565 n+1, // column number 1566 1566 1, // firstrow … … 1577 1577 item->name); 1578 1578 } 1579 fits_write_col_flt(fits-> p_fd,1579 fits_write_col_flt(fits->fd, 1580 1580 n+1, // column number 1581 1581 1, // firstrow … … 1592 1592 item->name); 1593 1593 } 1594 fits_write_col_dbl(fits-> p_fd,1594 fits_write_col_dbl(fits->fd, 1595 1595 n+1, // column number 1596 1596 1, // firstrow … … 1607 1607 item->name); 1608 1608 } 1609 fits_write_col_log(fits-> p_fd,1609 fits_write_col_log(fits->fd, 1610 1610 n+1, // column number 1611 1611 1, // firstrow … … 1625 1625 col->data[row] = item->data.V; 1626 1626 } 1627 fits_write_col_str(fits-> p_fd,1627 fits_write_col_str(fits->fd, 1628 1628 n, // column number 1629 1629 1, // firstrow … … 1661 1661 // check to see if we even are positioned on a table HDU 1662 1662 int hdutype; 1663 if ( fits_get_hdu_type(fits-> p_fd,&hdutype, &status) != 0) {1663 if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) { 1664 1664 char fitsErr[MAX_STRING_LENGTH]; 1665 1665 (void)fits_get_errstatus(status, fitsErr); … … 1684 1684 int colnum = 0; 1685 1685 1686 if ( fits_get_colnum(fits-> p_fd, CASESEN, item->name, &colnum, &status) == 0) {1686 if ( fits_get_colnum(fits->fd, CASESEN, item->name, &colnum, &status) == 0) { 1687 1687 // cooresponding column found in table 1688 1688 int dataType = 0; 1689 1689 convertPsTypeToFits(item->type, NULL, NULL, &dataType); 1690 1690 1691 if (fits_write_col(fits-> p_fd, dataType, colnum, row+1, 1, 1, &item->data,&status) != 0) {1691 if (fits_write_col(fits->fd, dataType, colnum, row+1, 1, 1, &item->data,&status) != 0) { 1692 1692 char fitsErr[MAX_STRING_LENGTH]; 1693 1693 (void)fits_get_errstatus(status, fitsErr); -
trunk/psLib/src/fits/psFits.h
r4898 r5057 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 8-30 01:14:13$9 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-09-15 21:22:21 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 48 48 typedef struct 49 49 { 50 fitsfile* p_fd;///< the CFITSIO fits files handle.50 fitsfile* fd; ///< the CFITSIO fits files handle. 51 51 const char* filename; ///< the filename of the fits file 52 bool writable; ///< Is the file writable? 52 53 } 53 54 psFits; -
trunk/psLib/src/imageops/psImageConvolve.c
r4920 r5057 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-0 8-31 02:07:11$7 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-09-15 21:22:22 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 64 64 result->yMax = yMax; 65 65 result->image = psImageAlloc(numCols,numRows,PS_TYPE_KERNEL); 66 memset( result->image->rawDataBuffer,0,numCols*numRows*PSELEMTYPE_SIZEOF(PS_TYPE_KERNEL));66 memset((result->image->p_rawDataBuffer),0,numCols*numRows*PSELEMTYPE_SIZEOF(PS_TYPE_KERNEL)); 67 67 result->p_kernelRows = psAlloc(sizeof(float*)*numRows); 68 68 -
trunk/psLib/src/imageops/psImageStructManip.c
r4544 r5057 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 7-12 19:33:49$10 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-09-15 21:22:22 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 91 91 92 92 // increment the raw data buffer before freeing anything in the 'out' 93 psPtr rawData = psMemIncrRefCounter(image-> rawDataBuffer);93 psPtr rawData = psMemIncrRefCounter(image->p_rawDataBuffer); 94 94 95 95 if (out != NULL) { … … 100 100 } 101 101 102 psFree(out-> rawDataBuffer); // free the previous data reference102 psFree(out->p_rawDataBuffer); // free the previous data reference 103 103 } else { 104 104 out = psAlloc(sizeof(psImage)); … … 116 116 out->parent = image; 117 117 out->children = NULL; 118 out-> rawDataBuffer = rawData;118 out->p_rawDataBuffer = rawData; 119 119 120 120 // set the new psImage's deallocator to the same as the input image … … 357 357 psU32 rowSize = elementSize*numCols; 358 358 psU32 colOffset = elementSize * col0; 359 psU8* imageData = image-> rawDataBuffer;359 psU8* imageData = image->p_rawDataBuffer; 360 360 for (psS32 row = row0; row < row1; row++) { 361 361 memmove(imageData,image->data.U8[row] + colOffset,rowSize); … … 368 368 // XXX: should I really resize the buffers? 369 369 image->data.V = psRealloc(image->data.V,sizeof(psPtr)*numRows); 370 image-> rawDataBuffer = psRealloc(image->rawDataBuffer,rowSize*numRows);371 372 image->data.V[0] = image-> rawDataBuffer;370 image->p_rawDataBuffer = psRealloc(image->p_rawDataBuffer,rowSize*numRows); 371 372 image->data.V[0] = image->p_rawDataBuffer; 373 373 for (psS32 r = 1; r < numRows; r++) { 374 374 image->data.U8[r] = image->data.U8[r-1] + rowSize; -
trunk/psLib/src/mathtypes/psImage.c
r4980 r5057 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.8 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09- 09 02:02:54$11 * @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-15 21:22:22 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 44 44 psImageFreeChildren(image); 45 45 46 psFree(image-> rawDataBuffer);46 psFree(image->p_rawDataBuffer); 47 47 psFree(image->data.V); 48 48 } … … 71 71 image->data.V = psAlloc(sizeof(psPtr ) * numRows); 72 72 73 image-> rawDataBuffer = psAlloc(area * elementSize);73 image->p_rawDataBuffer = psAlloc(area * elementSize); 74 74 75 75 // set the row pointers. 76 image->data.V[0] = image-> rawDataBuffer;76 image->data.V[0] = image->p_rawDataBuffer; 77 77 for (psS32 i = 1; i < numRows; i++) { 78 78 image->data.V[i] = (psPtr )((int8_t *) image->data.V[i - 1] + rowSize); … … 293 293 } 294 294 // Resize the image buffer 295 old-> rawDataBuffer = psRealloc(old->data.V[0],296 numCols * numRows * elementSize);295 old->p_rawDataBuffer = psRealloc(old->data.V[0], 296 numCols * numRows * elementSize); 297 297 old->data.V = (psPtr *)psRealloc(old->data.V, numRows * sizeof(psPtr )); 298 298 299 299 // recreate the row pointers 300 old->data.V[0] = old-> rawDataBuffer;300 old->data.V[0] = old->p_rawDataBuffer; 301 301 for (psS32 i = 1; i < numRows; i++) { 302 302 old->data.V[i] = (psPtr )((int8_t *) old->data.V[i - 1] + rowSize); -
trunk/psLib/src/mathtypes/psImage.h
r4985 r5057 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.6 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-09-1 0 00:16:58$13 * @version $Revision: 1.68 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-15 21:22:22 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 59 59 60 60 union { 61 psS8** S8; ///< Signed 8-bit integer data. 62 psS16** S16; ///< Signed 16-bit integer data. 63 psS32** S32; ///< Signed 32-bit integer data. 64 psS64** S64; ///< Signed 64-bit integer data. 61 65 psU8** U8; ///< Unsigned 8-bit integer data. 62 66 psU16** U16; ///< Unsigned 16-bit integer data. 63 67 psU32** U32; ///< Unsigned 32-bit integer data. 64 68 psU64** U64; ///< Unsigned 64-bit integer data. 65 psS8** S8; ///< Signed 8-bit integer data.66 psS16** S16; ///< Signed 16-bit integer data.67 psS32** S32; ///< Signed 32-bit integer data.68 psS64** S64; ///< Signed 64-bit integer data.69 69 psF32** F32; ///< Single-precision float data. 70 70 psF64** F64; ///< Double-precision float data. 71 71 psC32** C32; ///< Single-precision complex data. 72 72 psC64** C64; ///< Double-precision complex data. 73 // psPtr** PTR; ///< Void pointers.74 73 psPtr* V; ///< Pointer to data. 75 74 } data; ///< Union for data types. 76 75 const struct psImage* parent; ///< Parent, if a subimage. 76 psPtr p_rawDataBuffer; ///< Raw data buffer for Allocating/Freeing Images; private 77 77 psArray* children; ///< Children of this region. 78 79 psPtr rawDataBuffer; ///< Raw data buffer for Allocating/Freeing Images80 78 void *lock; ///< Optional lock for thread safety 81 79 } -
trunk/psLib/src/mathtypes/psScalar.h
r4935 r5057 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-0 8-31 22:00:10$13 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-15 21:22:22 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 35 35 36 36 union { 37 psS8 S8; ///< Signed 8-bit integer data. 38 psS16 S16; ///< Signed 16-bit integer data. 39 psS32 S32; ///< Signed 32-bit integer data. 40 psS64 S64; ///< Signed 64-bit integer data. 37 41 psU8 U8; ///< Unsigned 8-bit integer data. 38 42 psU16 U16; ///< Unsigned 16-bit integer data. 39 43 psU32 U32; ///< Unsigned 32-bit integer data. 40 44 psU64 U64; ///< Unsigned 64-bit integer data. 41 psS8 S8; ///< Signed 8-bit integer data.42 psS16 S16; ///< Signed 16-bit integer data.43 psS32 S32; ///< Signed 32-bit integer data.44 psS64 S64; ///< Signed 64-bit integer data.45 45 psF32 F32; ///< Single-precision float data. 46 46 psF64 F64; ///< Double-precision float data. -
trunk/psLib/src/mathtypes/psVector.h
r4944 r5057 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-09- 02 21:32:06$13 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-15 21:22:22 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 38 38 const long nalloc; ///< Total number of elements available. 39 39 union { 40 psS8* S8; ///< Signed 8-bit integer data. 41 psS16* S16; ///< Signed 16-bit integer data. 42 psS32* S32; ///< Signed 32-bit integer data. 43 psS64* S64; ///< Signed 64-bit integer data. 40 44 psU8* U8; ///< Unsigned 8-bit integer data. 41 45 psU16* U16; ///< Unsigned 16-bit integer data. 42 46 psU32* U32; ///< Unsigned 32-bit integer data. 43 47 psU64* U64; ///< Unsigned 64-bit integer data. 44 psS8* S8; ///< Signed 8-bit integer data.45 psS16* S16; ///< Signed 16-bit integer data.46 psS32* S32; ///< Signed 32-bit integer data.47 psS64* S64; ///< Signed 64-bit integer data.48 48 psF32* F32; ///< Single-precision float data. 49 49 psF64* F64; ///< Double-precision float data. -
trunk/psLib/src/sys/psLogMsg.h
r4979 r5057 11 11 * @author GLG, MHPCC 12 12 * 13 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-09- 09 01:11:22 $13 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-15 21:22:22 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 107 107 ///< Destinations for log messages 108 108 enum { 109 PS_LOG_ NONE,///< turn off logging110 PS_LOG_TO_STDERR ,///< log to system's stderr111 PS_LOG_TO_STDOUT ///< log to system's stdout109 PS_LOG_TO_NONE = 0, ///< turn off logging 110 PS_LOG_TO_STDERR = 1, ///< log to system's stderr 111 PS_LOG_TO_STDOUT = 2 ///< log to system's stdout 112 112 }; 113 113 -
trunk/psLib/src/sys/psTrace.h
r5012 r5057 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09-1 3 00:54:15$11 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-15 21:22:22 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 * \{ 26 26 */ 27 28 enum { 29 PS_TRACE_TO_NONE = 0, ///< turn off all traces 30 PS_TRACE_TO_STDOUT = 1, ///< trace to system's stdout 31 PS_TRACE_TO_STDERR = 2, ///< trace to system's stderr 32 }; 27 33 28 34 /** Functions **************************************************************/ … … 137 143 * @return FILE*: File Destination 138 144 */ 139 int psTraceGetDestination( void);145 int psTraceGetDestination(); 140 146 141 147 /* \} */// End of SystemGroup Functions -
trunk/psLib/src/sys/psType.h
r4920 r5057 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 8-31 02:07:11$12 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-09-15 21:22:22 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 105 105 PS_DATA_ARRAY, ///< psArray 106 106 PS_DATA_BITSET, ///< psBitSet 107 PS_DATA_CELL, ///< psCell108 PS_DATA_CHIP, ///< psChip107 // PS_DATA_CELL, ///< psCell 108 // PS_DATA_CHIP, ///< psChip 109 109 PS_DATA_CUBE, ///< psCube 110 110 PS_DATA_FITS, ///< psFits … … 127 127 PS_DATA_POLYNOMIAL4D, ///< psPolynomial4D 128 128 PS_DATA_PROJECTION, ///< psProjection 129 PS_DATA_READOUT, ///< psReadout130 PS_DATA_REGION, ///< psRegion129 // PS_DATA_READOUT, ///< psReadout 130 // PS_DATA_REGION, ///< psRegion 131 131 PS_DATA_SCALAR, ///< psScalar 132 132 PS_DATA_SPHERE, ///< psSphere -
trunk/psLib/src/types/psBitSet.h
r4898 r5057 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 8-30 01:14:13$14 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-09-15 21:22:22 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 58 58 ; 59 59 60 61 60 /** Allocate a psBitSet. 62 61 * … … 92 91 */ 93 92 psBitSet* psBitSetClear( 94 /* @returned@ */95 93 psBitSet* bitSet, ///< Pointer to psBitSet to be cleared. 96 94 long bit ///< Bit to be cleared. … … 120 118 */ 121 119 psBitSet* psBitSetOp( 122 /* @returned@ */123 120 psBitSet* outBitSet, ///< Resulting psBitSet from binary operation 124 121 const psBitSet* inBitSet1, ///< First psBitSet on which to operate -
trunk/psLib/src/types/psMetadata.c
r5000 r5057 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.8 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-09-1 2 21:36:54$14 * @version $Revision: 1.83 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-09-15 21:22:22 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 #include "psConstants.h" 40 40 #include "psLogMsg.h" 41 #include "psTrace.h" 41 42 42 43 /******************************************************************************/ … … 811 812 812 813 813 char *psMetadataLookupStr ing(bool *status,814 const psMetadata *md,815 const char *key)814 char *psMetadataLookupStr(bool *status, 815 const psMetadata *md, 816 const char *key) 816 817 { 817 818 psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); // The metadata with instruments … … 893 894 894 895 896 // Set verbosity level 897 int psArgumentVerbosity(int *argc, char **argv) 898 { 899 int logLevel = 2; // Default log level 900 int argnum = 0; // Argument number 901 902 // set in order, so that -vvv overrides -vv overrides -v 903 if ( (argnum = psArgumentGet(*argc, argv, "-v")) ) { 904 psArgumentRemove(argnum, argc, argv); 905 logLevel = 3; 906 } 907 if ( (argnum = psArgumentGet(*argc, argv, "-vv")) ) { 908 psArgumentRemove(argnum, argc, argv); 909 logLevel = 4; 910 } 911 if ( (argnum = psArgumentGet(*argc, argv, "-vvv")) ) { 912 psArgumentRemove(argnum, argc, argv); 913 logLevel = 5; 914 } 915 psLogSetLevel (logLevel); // XXX: This function should return an error if the log level is invalid 916 917 if ( (argnum = psArgumentGet(*argc, argv, "-logfmt")) ) { 918 if (*argc < argnum + 2) { 919 psError(PS_ERR_IO, true, "-logfmt switch specified without a format."); 920 } else { 921 psArgumentRemove(argnum, argc, argv); 922 psLogSetFormat(argv[argnum]); // XXX EAM : this function should return an error if the log format is invalid 923 psArgumentRemove(argnum, argc, argv); 924 } 925 } 926 927 // Now the trace stuff 928 // argument format is: -trace (facil) (level) 929 while ( (argnum = psArgumentGet(*argc, argv, "-trace")) ) { 930 if ( (*argc < argnum + 3) ) { 931 psError(PS_ERR_IO, true, "-trace switch specified without facility and level."); 932 } 933 psArgumentRemove(argnum, argc, argv); 934 psTraceSetLevel(argv[argnum], atoi(argv[argnum+1])); // XXX: This function should return an error if the trace level is invalid 935 psArgumentRemove(argnum, argc, argv); 936 psArgumentRemove(argnum, argc, argv); 937 } 938 if ((argnum = psArgumentGet(*argc, argv, "-trace-levels"))) { 939 psTracePrintLevels(); 940 exit(2); 941 } 942 943 return logLevel; 944 } 945 946 // Find the location of the specified argument 947 int psArgumentGet(int argc, char **argv, const char *arg) 948 { 949 for (int i = 1; i < argc; i++) { 950 if (!strcmp(argv[i], arg)) 951 return i; 952 } 953 954 return 0; 955 } 956 957 // Remove the specified argument (by location) 958 bool psArgumentRemove(int argnum, int *argc, char **argv) 959 { 960 if (argnum > 0) { 961 (*argc)--; 962 for (int i = argnum; i < *argc; i++) { 963 argv[i] = argv[i+1]; 964 } 965 } else { 966 return false; 967 } 968 969 return true; 970 } 971 972 973 static psMetadataItem *argumentRead(psMetadataItem *item, // Item to read into 974 int argnum, // Argument number 975 int *argc, // Number of arguments in total 976 char **argv) // The arguments 977 978 { 979 psMetadataItem *newItem = NULL; 980 switch(item->type) 981 { 982 // Only doing a representative set of types 983 case PS_META_S32: 984 newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atoi(argv[argnum])); 985 psArgumentRemove(argnum, argc, argv); 986 break; 987 case PS_META_F32: 988 newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atof(argv[argnum])); 989 psArgumentRemove(argnum, argc, argv); 990 break; 991 case PS_META_BOOL: 992 // Turn option on; no optional argument to remove 993 newItem = psMetadataItemAlloc(item->name, item->type, item->comment, true); 994 break; 995 // XXX: Include the other numerical types 996 case PS_META_STR: { 997 //psString string = psStringCopy(argv[argnum]); // Get the argument into PS memory management 998 //psFree(string); 999 newItem = psMetadataItemAlloc(item->name, item->type, item->comment, argv[argnum]); 1000 psArgumentRemove(argnum, argc, argv); 1001 } 1002 break; 1003 default: 1004 psError(PS_ERR_IO, true, "Argument type (%x) is not supported --- argument %s ignored\n", 1005 item->type, item->name); 1006 psFree(newItem); 1007 return NULL; 1008 } 1009 1010 return newItem; 1011 } 1012 1013 1014 // XXX: There is a memory leak in the MULTI section. I think it might have something to do with reference 1015 // counting between lists and MD, in the second section of the code (copy newArgs into arguments), but I'm not 1016 // entirely sure. 1017 bool psArgumentParse(psMetadata *arguments, 1018 int *argc, 1019 char **argv) 1020 { 1021 // We need to do a bit of mucking around in order to preserve the arguments metadata until the last 1022 // minute --- if there is a bad argument, we need to return the old "arguments", since they contain 1023 // the default values, which we probably want to output in a "help" message (we don't want to print 1024 // the changed values and have the user think that they are default values). 1025 1026 psMetadata *newArgs = psMetadataAlloc(); // Place to read arguments into 1027 psList *changed = psListAlloc(NULL);// List of keys that have changed 1028 1029 for (int i = 1; i < *argc; i++) { 1030 psTrace(__func__, 7, "Looking at %s\n", argv[i]); 1031 psMetadataItem *argItem = psMetadataLookup(arguments, argv[i]); 1032 if (argItem) { 1033 psArgumentRemove(i, argc, argv); // Remove the switch 1034 if (argItem->type != PS_META_MULTI) { 1035 if (argItem->type != PS_META_BOOL && *argc < i + 1) { 1036 psError(PS_ERR_IO, true, "Required argument for %s is missing.\n", argItem->name); 1037 // XXX: Cleanup before returning 1038 psFree(newArgs); 1039 return false; 1040 } 1041 psMetadataItem *newItem = argumentRead(argItem, i, argc, argv); 1042 psMetadataAddItem(newArgs, newItem, PS_LIST_TAIL, PS_META_REPLACE); 1043 psFree(newItem); 1044 } else { 1045 // Go through the MULTI 1046 psList *multi = argItem->data.V; // The list of MULTI psMetadataItems 1047 if (*argc < i + multi->n) { 1048 psError(PS_ERR_IO, true, "Not enough arguments for %s.\n", argItem->name); 1049 // Remove the arguments --- they will be ignored 1050 for (int j = i; j < *argc; j++) { 1051 psArgumentRemove(i, argc, argv); 1052 } 1053 // XXX: Cleanup before returning 1054 psFree(newArgs); 1055 return false; 1056 } 1057 1058 // Remove any prior existence in the newArgs --- this is important because we specify 1059 // adding the new items as DUPLICATE_OK, so if some idiot specifies it twice, we'd end 1060 // up with two copies of everything. 1061 psMetadataItem *checkItem = psMetadataLookup(newArgs, argItem->name); 1062 if (checkItem) { 1063 (void)psMetadataRemove(newArgs, 0, argItem->name); 1064 (void)psListRemoveData(changed, argItem->name); 1065 } 1066 1067 psListIterator *multiIter = psListIteratorAlloc(multi, PS_LIST_HEAD, true); 1068 psMetadataItem *nextItem = NULL; // Item from list 1069 while ( (nextItem = psListGetAndIncrement(multiIter)) ) { 1070 psMetadataItem *newItem = argumentRead(nextItem, i, argc, argv); 1071 psMetadataAddItem(newArgs, newItem, PS_LIST_TAIL, PS_META_DUPLICATE_OK); 1072 //psFree(newItem); 1073 } 1074 psFree(multiIter); 1075 } 1076 1077 // Some book-keeping 1078 // psString name = psStringCopy(argItem->name); 1079 psListAdd(changed, PS_LIST_TAIL, argItem->name); 1080 i--; 1081 1082 } else if ( (strncmp(argv[i], "-", 1) == 0 ) || (strncmp(argv[i], "+", 1) == 0) ) { 1083 // Someone's specified a bad option 1084 psError(PS_ERR_IO, true, "Unknown option: %s\n", argv[i]); 1085 psFree(newArgs); 1086 return false; 1087 } 1088 } 1089 1090 // All the arguments are good, so now we can copy the newArgs over 1091 psListIterator *changedIter = psListIteratorAlloc(changed, PS_LIST_HEAD, false); // Iterator 1092 psString name = NULL; // Item from iteration 1093 while ( (name = psListGetAndIncrement(changedIter)) ) { 1094 printf("Updating %s\n", name); 1095 psMetadataItem *oldItem = psMetadataLookup(arguments, name); 1096 psMetadataItem *newItem = psMetadataLookup(newArgs, name); 1097 if ( (oldItem->type != newItem->type) ) { 1098 psAbort(__func__, "Shouldn't reach here!\n"); 1099 } 1100 switch (oldItem->type) { 1101 // Only doing a representative set of types 1102 case PS_META_S32: 1103 oldItem->data.S32 = newItem->data.S32; 1104 break; 1105 case PS_META_F32: 1106 oldItem->data.F32 = newItem->data.F32; 1107 break; 1108 case PS_META_BOOL: 1109 oldItem->data.B = newItem->data.B; 1110 break; 1111 // XXX: Include the other numerical types 1112 case PS_META_STR: 1113 psFree(oldItem->data.V); 1114 oldItem->data.V = psMemIncrRefCounter(newItem->data.V); 1115 break; 1116 case PS_META_MULTI: { 1117 psList *newMulti = psMemIncrRefCounter(newItem->data.V); // The new list of MULTI 1118 psList *oldMulti = oldItem->data.V; // The old list of MULTI 1119 psListIterator *newMultiIter = psListIteratorAlloc(newMulti, PS_LIST_HEAD, false); 1120 psListIterator *oldMultiIter = psListIteratorAlloc(oldMulti, PS_LIST_HEAD, true); 1121 psMetadataItem *newMultiItem = NULL; // Item from iterator 1122 while ( (newMultiItem = psListGetAndIncrement(newMultiIter)) ) { 1123 psMetadataItem *oldMultiItem = psListGetAndIncrement(oldMultiIter); 1124 if (!oldMultiItem) { 1125 psAbort(__func__, 1126 "Something went very wrong here! The lists SHOULD be of the same length!\n"); 1127 } 1128 switch (oldMultiItem->type) { 1129 // Only doing a representative set of types 1130 case PS_META_S32: 1131 oldItem->data.S32 = newItem->data.S32; 1132 break; 1133 case PS_META_F32: 1134 oldItem->data.F32 = newItem->data.F32; 1135 break; 1136 // XXX: Include the other numerical types 1137 case PS_META_STR: 1138 psFree(oldItem->data.V); 1139 oldItem->data.V = psMemIncrRefCounter(newItem->data.V); 1140 break; 1141 default: 1142 psAbort(__func__, "Should never ever get here, ever.\n"); 1143 } 1144 psFree(oldMultiItem); 1145 psFree(newMultiItem); 1146 } 1147 psFree(newMultiIter); 1148 psFree(oldMultiIter); 1149 } 1150 break; 1151 default: 1152 psAbort(__func__, "Should never ever ever get here.\n"); 1153 } 1154 } 1155 psFree(changedIter); 1156 psFree(changed); 1157 1158 // Now, blow away the newArgs and we're done. 1159 psFree(newArgs); 1160 return true; 1161 } 1162 1163 1164 static int argLength(psMetadataItem *arg) 1165 { 1166 switch (arg->type) { 1167 // Only doing a representative set of types 1168 case PS_META_S32: 1169 return arg->data.S32 >= 0 ? (int)log10f((float)arg->data.S32) + 1 : 1170 (int)log10f(-(float)arg->data.S32) + 2; 1171 // XXX: Other numerical types 1172 case PS_META_F32: 1173 return arg->data.F32 >= 0 ? 12 : 13; // -d.dddddde?dd 1174 case PS_META_F64: 1175 return arg->data.F64 >= 0 ? 12 : 13; // -d.dddddde?dd 1176 case PS_META_BOOL: 1177 return arg->data.B ? 4 : 5; 1178 case PS_META_STR: 1179 return strlen(arg->data.V); 1180 default: 1181 psAbort(__func__, "Argument type (%x) is not supported.\n", arg->type); 1182 } 1183 1184 return 0; 1185 } 1186 1187 #define NUM_SPACES 4 // Number of spaces between 1188 1189 void psArgumentHelp(psMetadata *arguments) 1190 { 1191 printf("Optional arguments, with default values:\n"); 1192 psMetadataIterator *argIter = psMetadataIteratorAlloc(arguments, PS_LIST_HEAD, NULL); 1193 psMetadataItem *argItem = NULL; // Item from iterator 1194 int maxName = 4; // Maximum length of a name 1195 int maxValue = 4; // Maximum length of a value 1196 1197 // First pass to get the sizes 1198 while ( (argItem = psMetadataGetAndIncrement(argIter)) ) { 1199 if (strlen(argItem->name) > maxName) { 1200 maxName = strlen(argItem->name); 1201 } 1202 int valLength = argLength(argItem); 1203 if (valLength > maxValue) { 1204 maxValue = valLength; 1205 } 1206 } 1207 1208 // Second pass to print 1209 psMetadataIteratorSet(argIter, PS_LIST_HEAD); 1210 psString lastName = NULL; // Last name we printed 1211 while ( (argItem = psMetadataGetAndIncrement(argIter)) ) { 1212 // Initial indent 1213 for (int i = 0; i < NUM_SPACES; i++) { 1214 printf(" "); 1215 } 1216 1217 // Print the name if required 1218 int position = 0; // Number of spaces in 1219 if (! lastName || strcmp(lastName, argItem->name) != 0) { 1220 // A new name 1221 printf("%s", argItem->name); 1222 position += strlen(argItem->name); 1223 lastName = argItem->name; 1224 } 1225 for (int i = position; i < maxName + NUM_SPACES; i++) { 1226 printf(" "); 1227 } 1228 1229 // Print the value 1230 printf("("); 1231 switch (argItem->type) { 1232 // Only doing a representative set of types 1233 case PS_META_S32: 1234 printf("%d", argItem->data.S32); 1235 break; 1236 // XXX: Other numerical types 1237 case PS_META_F32: 1238 printf("%.6e", argItem->data.F32); 1239 break; 1240 case PS_META_F64: 1241 printf("%.6e", argItem->data.F64); 1242 break; 1243 case PS_META_BOOL: 1244 if (argItem->data.B) { 1245 printf("TRUE"); 1246 } else { 1247 printf("FALSE"); 1248 } 1249 break; 1250 case PS_META_STR: 1251 printf("%s", (char*)(argItem->data.V)); 1252 break; 1253 default: 1254 psAbort(__func__, "Argument type (%x) is not supported.\n", argItem->type); 1255 } 1256 printf(")"); 1257 for (int i = argLength(argItem); i < maxValue + NUM_SPACES; i++) { 1258 printf(" "); 1259 } 1260 1261 // Print the comment 1262 if (argItem->comment) { 1263 printf("%s", argItem->comment); 1264 } 1265 printf("\n"); 1266 } 1267 1268 psFree(argIter); 1269 } 1270 -
trunk/psLib/src/types/psMetadata.h
r5010 r5057 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.6 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-09-1 2 23:27:48$13 * @version $Revision: 1.64 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-15 21:22:22 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 122 122 union { 123 123 psBool B; ///< boolean data 124 psS8 S8; ///< Signed 8-bit integer data. 125 psS16 S16; ///< Signed 16-bit integer data. 124 126 psS32 S32; ///< Signed 32-bit integer data. 127 psU8 U8; ///< Unsigned 8-bit integer data. 128 psU16 U16; ///< Unsigned 16-bit integer data. 129 psU32 U32; ///< Unsigned 32-bit integer data. 125 130 psF32 F32; ///< Single-precision float data. 126 131 psF64 F64; ///< Double-precision float data. … … 686 691 * @return char*: Value of metadata item. 687 692 */ 688 char *psMetadataLookupStr ing(693 char *psMetadataLookupStr( 689 694 bool *status, ///< Status of lookup. 690 695 const psMetadata *md, ///< Metadata collection to lookup metadata item. … … 698 703 ); 699 704 705 /** Implements the various verbosity controls. 706 * 707 * Arguments shall be removed from the argument list as they are processed. 708 * 709 * @return int: The resultant logging level. 710 */ 711 int psArgumentVerbosity( 712 int *argc, ///< number or arguments 713 char **argv ///< the argument list 714 ); 715 716 /** Checks for an argument and returns its index position if found. 717 * 718 * @return int: The index of the element in the argument list, otherwise 0. 719 */ 720 int psArgumentGet( 721 int argc, ///< number or arguments 722 char **argv, ///< the argument list 723 const char *arg ///< the specified argument to match 724 ); 725 726 /** Removes from the argument list the argument whose index is argnum. 727 * 728 * The number of entries in the argument list shall be decremented. 729 * 730 * @return bool: True if the argnum is in the argument list, otherwise false. 731 */ 732 bool psArgumentRemove( 733 int argnum, ///< the argument to remove 734 int *argc, ///< number or arguments 735 char **argv ///< the argument list 736 ); 737 738 /** Parses the command line arguments into a metadata container of arguments. 739 * 740 * The input arguments shall contain the list of possible arguments as the keywords providing 741 * the default values. As matching arguments are found on the command line, the values shall be 742 * read into the arguments metadata, with the appropriate type. The arguments and their values 743 * shall be removed from the list of command line arguments as they are processed. 744 * 745 * @return bool: False if any argument was encountered that is not present in arguments. 746 */ 747 bool psArgumentParse( 748 psMetadata *arguments, ///< metadata container for arguments 749 int *argc, ///< number or arguments 750 char **argv ///< the argument list 751 ); 752 753 /** Prints to stdout a guide to the command-line arguments. */ 754 void psArgumentHelp( 755 psMetadata *arguments ///< metadata container for arguments 756 ); 757 700 758 /// @} 701 759 -
trunk/psLib/src/types/psMetadataConfig.c
r5013 r5057 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-09-1 3 01:04:39$12 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-09-15 21:22:22 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1242 1242 while ( (item = psMetadataGetAndIncrement(iter)) ) { 1243 1243 type = item->type; 1244 if ( type == 65537)1244 if ( type == PS_META_STR) 1245 1245 type = PS_DATA_STRING; 1246 if ( type == 65538)1246 if ( type == PS_META_VEC) 1247 1247 type = PS_DATA_VECTOR; 1248 if ( type == 65551)1248 if ( type == PS_META_TIME) 1249 1249 type = PS_DATA_TIME; 1250 1250 if ( item->type == PS_META_META) -
trunk/psLib/src/xml/psXML.c
r5010 r5057 10 10 * @author David Robbins, MHPCC 11 11 * 12 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-09-1 2 23:27:48$12 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-09-15 21:22:22 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 68 68 while ( item != NULL ) { 69 69 type = item->type; 70 if ( type == 65537)70 if ( type == PS_META_STR) 71 71 type = PS_DATA_STRING; 72 if ( type == 65538)72 if ( type == PS_META_VEC) 73 73 type = PS_DATA_VECTOR; 74 // if ( type == 65547) 75 // type = PS_DATA_METADATA; 76 if ( type == 65551) 74 if ( type == PS_META_TIME) 77 75 type = PS_DATA_TIME; 78 76 switch (type) { -
trunk/psLib/test/imageops/tst_psImageGeomManip.c
r4558 r5057 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 7-15 02:40:20$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-09-15 21:22:22 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1055 1055 psErrorClear(); 1056 1056 psImage* invImage = psImageAlloc(cols,rows,PS_TYPE_BOOL); 1057 memset(invImage-> rawDataBuffer,0,cols*rows*PSELEMTYPE_SIZEOF(PS_TYPE_BOOL)); // make sure the image is of all NULLs1057 memset(invImage->p_rawDataBuffer,0,cols*rows*PSELEMTYPE_SIZEOF(PS_TYPE_BOOL)); // make sure the image is of all NULLs 1058 1058 result = psImageResample(result,invImage,2,PS_INTERPOLATE_FLAT); 1059 1059 if (result != NULL) { -
trunk/psLib/test/types/tst_psMetadata_04.c
r4891 r5057 25 25 * @author Ross Harman, MHPCC 26 26 * 27 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $28 * @date $Date: 2005-0 8-27 01:33:41$27 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 28 * @date $Date: 2005-09-15 21:22:22 $ 29 29 * 30 30 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 224 224 printPositiveTestHeader(stdout, "psMetadata", "Test K - Lookup metadata item and return psString value"); 225 225 char *newSTR; 226 newSTR = psMetadataLookupStr ing(&status, metadata, "myItem8");226 newSTR = psMetadataLookupStr(&status, metadata, "myItem8"); 227 227 if( strncmp(newSTR, string, 50) ) { 228 228 printf("ERROR: Bad string value \n");
Note:
See TracChangeset
for help on using the changeset viewer.
