Changeset 9798 for trunk/psLib
- Timestamp:
- Oct 30, 2006, 2:08:19 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/types/psMetadataConfig.c (modified) (41 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psMetadataConfig.c
r9763 r9798 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.10 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-10- 27 02:26:42$12 * @version $Revision: 1.102 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-31 00:08:19 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 152 152 ptrB++; 153 153 } 154 } else { 155 while (isspace(*ptrB)) { 156 ptrB++; 157 } 158 } 154 } 155 /* else { 156 while (isspace(*ptrB)) { 157 ptrB++; 158 } 159 } 160 */ 159 161 160 162 // Skip over trailing whitespace, null terminators, and # characters … … 229 231 // Move to end of token 230 232 (*inString) += sLen; 231 } else if(**inString!='\0' && sLen==0) { 232 *status = 1; 233 } 234 233 } 234 /* else if(**inString!='\0' && sLen==0) { 235 *status = 1; 236 } 237 */ 235 238 return cleanToken; 236 239 } … … 247 250 if(*end != '\0') { 248 251 *status = 1; 249 } else if(inString==end) { 250 *status = 1; 251 } 252 252 } 253 /* else if(inString==end) { 254 *status = 1; 255 } 256 */ 253 257 return value; 254 258 } … … 265 269 if(*end != '\0') { 266 270 *status = 1; 267 } else if(inString==end) { 268 *status = 1; 269 } 270 271 } 272 /* else if(inString==end) { 273 *status = 1; 274 } 275 */ 271 276 return value; 272 277 } … … 283 288 if(*end != '\0') { 284 289 *status = 1; 285 } else if(inString==end) { 286 *status = 1; 287 } 288 290 } 291 /* else if(inString==end) { 292 *status = 1; 293 } 294 */ 289 295 return value; 290 296 } … … 295 301 { 296 302 // if inString is NULL return flalse, status = 0 297 if (!inString) {298 if (status) {299 *status = 0;300 }301 return false;302 }303 303 /* if (!inString) { 304 if (status) { 305 *status = 0; 306 } 307 return false; 308 } 309 */ 304 310 if (!strncasecmp(inString, "T", 2) || 305 311 !strncmp(inString, "1", 2) || 306 312 !strncasecmp(inString, "true", 5)) { 307 if (status ) {313 if (status != NULL) { 308 314 *status = 0; 309 315 } … … 313 319 !strncmp(inString, "0", 2) || 314 320 !strncasecmp(inString, "false", 6)) { 315 if (status ) {321 if (status != NULL) { 316 322 *status = 0; 317 323 } … … 319 325 } 320 326 321 if (status ) {327 if (status != NULL) { 322 328 *status = 1; 323 329 } … … 331 337 { 332 338 PS_ASSERT_PTR_NON_NULL(status, NULL); 333 if (!inString) {334 *status = 0;335 return NULL;336 }337 339 /* if (!inString) { 340 *status = 0; 341 return NULL; 342 } 343 */ 338 344 // handle "NULL" as the time value 339 345 if (strncmp(inString, "NULL", 5) == 0) { … … 373 379 while(*inString!='\0') { 374 380 strtod(inString, &end); 375 if(inString==end) { 376 *status = 1; 377 return NULL; 378 } 379 while(*end==' ' || *end==',') { // Commas or spaces may be used as delimiters for vector values 381 /* if(inString==end) { 382 *status = 1; 383 return NULL; 384 } 385 */ 386 // Commas or spaces may be used as delimiters for vector values 387 while(*end==' ' || *end==',') { 380 388 end++; 381 389 } … … 392 400 while(*inString!='\0') { 393 401 value = strtod(inString, &end); 394 if(inString==end) { 395 *status = 1; 396 return vec; 397 } 402 /* if(inString==end) { 403 *status = 1; 404 return vec; 405 } 406 */ 398 407 switch(elemType) { 399 408 case PS_TYPE_U8: … … 425 434 break; 426 435 case PS_TYPE_F64: 436 default: 427 437 vec->data.F64[i++] = (psF64)value; 428 438 break; 429 default:430 *status = 1;431 psError(PS_ERR_BAD_PARAMETER_VALUE,true,432 _("Specified type, %d, is not supported."),433 elemType);439 /* *status = 1; 440 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 441 _("Specified type, %d, is not supported."), 442 elemType); 443 */ 434 444 } 435 445 vec->n++; … … 585 595 // Create metadata item to represent token read 586 596 tempItem = psMetadataItemAllocStr(token,"",""); 587 if(tempItem == NULL) { 588 psFree(metadataTemplate); 589 psFree(token); 590 metadataTemplate = NULL; 591 break; 592 } 593 594 // Add item to template 595 if(!psMetadataAddItem(metadataTemplate, tempItem, PS_LIST_TAIL, PS_META_DEFAULT)) { 596 psFree(metadataTemplate); 597 psFree(tempItem); 598 psFree(token); 599 metadataTemplate = NULL; 600 break; 601 } 597 psMetadataAddItem(metadataTemplate, tempItem, PS_LIST_TAIL, PS_META_DEFAULT); 598 /* if(tempItem == NULL) { 599 psFree(metadataTemplate); 600 psFree(token); 601 metadataTemplate = NULL; 602 break; 603 } 604 605 // Add item to template 606 if(!psMetadataAddItem(metadataTemplate, tempItem, PS_LIST_TAIL, PS_META_DEFAULT)) { 607 psFree(metadataTemplate); 608 psFree(tempItem); 609 psFree(token); 610 metadataTemplate = NULL; 611 break; 612 } 613 */ 602 614 psFree(tempItem); 603 615 psFree(token); … … 712 724 // Check for no type 713 725 if(strType==NULL) { 714 psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "type",lineCount); 726 psError(PS_ERR_IO, true, 727 _("Failed to read a metadata %s on line %u."), "type",lineCount); 715 728 returnValue = false; 716 729 } else { … … 743 756 vectorType = PS_TYPE_F64; 744 757 } else { 745 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), "", keyName, 746 strType, lineCount); 758 psError(PS_ERR_IO, true, 759 _("Failed to parse the value '%s' of metadata item %s, type %s, " 760 "on line %u."), "", keyName, strType, lineCount); 747 761 psFree(strType); 748 762 return false; … … 758 772 } else if(!strncmp(strType, "S32", 3)) { 759 773 mdType = PS_DATA_S32; 774 } else if(!strncmp(strType, "S64", 3)) { 775 mdType = PS_DATA_S64; 760 776 } else if(!strncmp(strType, "U8", 2)) { 761 777 mdType = PS_DATA_U8; … … 764 780 } else if(!strncmp(strType, "U32", 3)) { 765 781 mdType = PS_DATA_U32; 782 } else if(!strncmp(strType, "U64", 3)) { 783 mdType = PS_DATA_U64; 766 784 } else if(!strncmp(strType, "F32", 3)) { 767 785 mdType = PS_DATA_F32; … … 785 803 // Add metadata item 786 804 md = ((p_psParseLevelInfo*)(levelArray->data[*level]))->metadata; 787 addStatus = psMetadataAdd(md,PS_LIST_TAIL,keyName,PS_DATA_METADATA | flags,"",tempMeta); 805 addStatus = psMetadataAdd(md,PS_LIST_TAIL,keyName, 806 PS_DATA_METADATA | flags,"",tempMeta); 788 807 // Check for add failure 789 808 if (! addStatus) { 790 psError(PS_ERR_IO, true, _("Duplicate Metadata item, %s, found on line %u. Overwrite not allowed."), 809 psError(PS_ERR_IO, true, 810 _("Duplicate Metadata item, %s, found on line %u. " 811 "Overwrite not allowed."), 791 812 keyName, lineCount); 792 813 psFree(strType); … … 797 818 } else { 798 819 // Metadata type read error 799 psError(PS_ERR_IO,true,_("Failed to read a metadata %s on line %u."), 820 psError(PS_ERR_IO,true, 821 _("Failed to read a metadata %s on line %u."), 800 822 keyName, lineCount); 801 823 psFree(strType); … … 807 829 } 808 830 if(!typeFound) { 809 psError(PS_ERR_IO, true, _("Metadata type '%s', found on line %u, is invalid."), 831 psError(PS_ERR_IO, true, 832 _("Metadata type '%s', found on line %u, is invalid."), 810 833 strType, lineCount); 811 834 psFree(strType); … … 824 847 strValue = getToken(&linePtr, "#", &status,true); 825 848 if(status) { 826 psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "value", lineCount); 849 psError(PS_ERR_IO, true, 850 _("Failed to read a metadata %s on line %u."), "value", lineCount); 827 851 psFree(strType); 828 852 psFree(strValue); … … 830 854 } 831 855 if(strValue==NULL) { 832 psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "value", lineCount); 856 psError(PS_ERR_IO, true, 857 _("Failed to read a metadata %s on line %u."), "value", lineCount); 833 858 psFree(strType); 834 859 psFree(strValue); … … 839 864 strComment = getToken(&linePtr,"~", &status,true); 840 865 if(status) { 841 psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "comment", lineCount); 866 psError(PS_ERR_IO, true, 867 _("Failed to read a metadata %s on line %u."), "comment", lineCount); 842 868 psFree(strType); 843 869 psFree(strValue); … … 863 889 strComment, tempBool); 864 890 } else { 865 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 866 strType, lineCount); 891 psError(PS_ERR_IO, true, 892 _("Failed to parse the value '%s' of metadata item %s, type %s, " 893 "on line %u."), strValue, keyName, strType, lineCount); 867 894 returnValue = false; 868 895 } … … 877 904 } else { 878 905 psError(PS_ERR_IO, true, 879 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, strType, lineCount); 906 _("Failed to parse the value '%s' of metadata item %s, type %s, " 907 "on line %u."), strValue, keyName, strType, lineCount); 880 908 returnValue = false; 881 909 } … … 884 912 tempInt = (psS8) parseSignedInt(strValue, &status); 885 913 if(!status) { 886 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt); 914 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, 915 strComment, tempInt); 887 916 } else { 888 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 889 strType, lineCount); 917 psError(PS_ERR_IO, true, 918 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 919 strValue, keyName, strType, lineCount); 890 920 returnValue = false; 891 921 } … … 894 924 tempInt = (psS16) parseSignedInt(strValue, &status); 895 925 if(!status) { 896 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt); 926 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, 927 strComment, tempInt); 897 928 } else { 898 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 899 strType, lineCount); 929 psError(PS_ERR_IO, true, 930 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 931 strValue, keyName, strType, lineCount); 900 932 returnValue = false; 901 933 } … … 904 936 tempInt = (psS32) parseSignedInt(strValue, &status); 905 937 if(!status) { 906 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt); 938 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, 939 strComment, tempInt); 907 940 } else { 908 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 909 strType, lineCount); 941 psError(PS_ERR_IO, true, 942 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 943 strValue, keyName, strType, lineCount); 910 944 returnValue = false; 911 945 } … … 914 948 tempUint = (psU8)parseUnsignedInt(strValue, &status); 915 949 if(!status) { 916 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint); 950 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, 951 strComment, tempUint); 917 952 } else { 918 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 919 strType, lineCount); 953 psError(PS_ERR_IO, true, 954 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 955 strValue, keyName, strType, lineCount); 920 956 returnValue = false; 921 957 } … … 924 960 tempUint = (psU16)parseUnsignedInt(strValue, &status); 925 961 if(!status) { 926 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint); 962 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, 963 strComment, tempUint); 927 964 } else { 928 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 929 strType, lineCount); 965 psError(PS_ERR_IO, true, 966 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 967 strValue, keyName, strType, lineCount); 930 968 returnValue = false; 931 969 } … … 934 972 tempUint = (psU32)parseUnsignedInt(strValue, &status); 935 973 if(!status) { 936 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint); 974 addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, 975 strComment, tempUint); 937 976 } else { 938 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 939 strType, lineCount); 977 psError(PS_ERR_IO, true, 978 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 979 strValue, keyName, strType, lineCount); 940 980 returnValue = false; 941 981 } … … 958 998 strComment, mTime); 959 999 } else { 960 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 961 strType, lineCount); 1000 psError(PS_ERR_IO, true, 1001 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 1002 strValue, keyName, strType, lineCount); 962 1003 returnValue = false; 963 1004 } … … 971 1012 strComment, tempVec); 972 1013 } else { 973 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, 974 strType, lineCount); 1014 psError(PS_ERR_IO, true, 1015 _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), 1016 strValue, keyName, strType, lineCount); 975 1017 returnValue = false; 976 1018 } … … 1009 1051 break; 1010 1052 default: 1011 psError(PS_ERR_IO, true,_("Metadata of unknown type found on line %u."),1012 lineCount);1053 psError(PS_ERR_IO, true, 1054 _("Metadata of unknown type found on line %u."), lineCount); 1013 1055 break; 1014 1056 } … … 1056 1098 if(repeatedChars(linePtr, '@') > 1) { 1057 1099 psError(PS_ERR_IO, true, 1058 _("More than one '%c' character not allowed. Found on line %u."), '@', lineCount); 1100 _("More than one '%c' character not allowed. Found on line %u."), 1101 '@', lineCount); 1059 1102 return false; 1060 1103 } … … 1074 1117 strType = getToken(&linePtr," ",&status,true); 1075 1118 if(strType == NULL) { 1076 psError(PS_ERR_IO,true,_("Failed to read a metadata %s on line %u."),"type",lineCount); 1119 psError(PS_ERR_IO,true, 1120 _("Failed to read a metadata %s on line %u."), "type", lineCount); 1077 1121 psFree(keyName); 1078 1122 return false; … … 1087 1131 // Compare type name with the list of current types 1088 1132 if(strcmp(strType,(char*)typeArray->data[k]) == 0) { 1089 psError(PS_ERR_IO,true,_("Specified type, %s, on line %u is already defined."), 1133 psError(PS_ERR_IO,true, 1134 _("Specified type, %s, on line %u is already defined."), 1090 1135 strType,lineCount); 1091 1136 psFree(tempTemplate); … … 1102 1147 psFree(tempTemplate); 1103 1148 } else { 1104 psError(PS_ERR_IO,true,_("Metadata type '%s', found on line %u, is invalid."), 1149 psError(PS_ERR_IO,true, 1150 _("Metadata type '%s', found on line %u, is invalid."), 1105 1151 strType,lineCount); 1106 1152 psFree(keyName); … … 1450 1496 } 1451 1497 psString timeStr = psTimeToISO(time); 1452 psStringAppend(&content, "%-15s", timeStr); 1498 psString timeOutput; 1499 timeOutput = psStringNCopy(timeStr, 19); 1500 psStringAppend(&content, "%s", timeOutput); 1501 psStringAppend(&content, "Z"); 1453 1502 psFree(timeStr); 1503 psFree(timeOutput); 1454 1504 } else { 1455 1505 // psTime is a NULL pointer … … 1524 1574 psStringAppend(&content, "F64 "); 1525 1575 for (int i = 0; i < vector->n; i++) { 1526 psStringAppend(&content, "%.15g ", vector->data.F64[i]);1576 psStringAppend(&content, "%.15g ", vector->data.F64[i]); 1527 1577 } 1528 1578 break;
Note:
See TracChangeset
for help on using the changeset viewer.
