Changeset 17507
- Timestamp:
- May 4, 2008, 1:40:26 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080430/psLib/src/types/psMetadataConfig.c
r17498 r17507 11 11 * @author Joshua Hoblitt, University of Hawaii 2006-2007 12 12 * 13 * @version $Revision: 1.142.8. 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2008-05-0 2 00:10:43$13 * @version $Revision: 1.142.8.3 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2008-05-04 23:40:26 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 63 63 /*****************************************************************************/ 64 64 65 static psMetadata *genTypeTemplate(char *linePtr);66 static psMetadata * parseTypeValues(psMetadata* template, char*linePtr)65 static psMetadata *genTypeTemplate(char *linePtr); 66 static psMetadata *parseTypeValues(psMetadata *template, char *linePtr) 67 67 ; 68 static bool parseLine(psArray *levelArray,69 char *linePtr,68 static bool parseLine(psArray *levelArray, 69 char *linePtr, 70 70 bool overwrite, 71 71 bool *notBlank); 72 static bool parseMetadataItem(char * keyName, psArray*levelArray,73 char *linePtr, psMetadataFlags flags);72 static bool parseMetadataItem(char *keyName, psArray *levelArray, 73 char *linePtr, psMetadataFlags flags); 74 74 static psString formatMetadataItem(psMetadataItem *item); 75 75 static psArray *p_psMetadataKeyArray(psMetadata *md); 76 static bool parseGeneric(char *keyName,77 psArray *levelArray,78 char *linePtr,76 static bool parseGeneric(char *keyName, 77 psArray *levelArray, 78 char *linePtr, 79 79 psMetadataFlags flags); 80 static bool parseType(char *keyName,81 psArray *levelArray,82 char *linePtr,80 static bool parseType(char *keyName, 81 psArray *levelArray, 82 char *linePtr, 83 83 psMetadataFlags flags); 84 static bool parseMetadataEnd(char *keyName,85 psArray *levelArray,86 char *linePtr,84 static bool parseMetadataEnd(char *keyName, 85 psArray *levelArray, 86 char *linePtr, 87 87 psMetadataFlags flags); 88 88 … … 92 92 typedef struct 93 93 { 94 psArray *nonUniqueKeyArray; ///< non-unique key names95 psHash *typeTemplates; ///< hash of user type templates96 psMetadata *metadata; ///< metadata container94 psArray * nonUniqueKeyArray; ///< non-unique key names 95 psHash * typeTemplates; ///< hash of user type templates 96 psMetadata *metadata; ///< metadata container 97 97 } 98 98 p_psParseLevelInfo; 99 99 100 static void parseLevelInfoFree(p_psParseLevelInfo *info)100 static void parseLevelInfoFree(p_psParseLevelInfo *info) 101 101 { 102 102 psFree(info->nonUniqueKeyArray); … … 105 105 } 106 106 107 static p_psParseLevelInfo *p_psParseLevelInfoAlloc(void)107 static p_psParseLevelInfo *p_psParseLevelInfoAlloc(void) 108 108 { 109 109 // Allocate memory for parse level info … … 200 200 // Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location 201 201 // the beginning of the string. Tokens are newly allocated null terminated strings. 202 static char* getToken(char **inString, 202 // XXX EAM : not sure this API is well-thought-out: 203 // *status must be set to 0 going in. 204 // status is 1 if delimeter is found, but no valid token 205 // returned string is NULL if no valid token is found 206 static char *getToken(char **inString, 203 207 char *delimiter, 204 208 psS32 *status, … … 353 357 354 358 /** Returns parsed vector filled with with data. The input string must be null terminated. */ 355 static psVector *parseVector(char *inString,359 static psVector *parseVector(char *inString, 356 360 psElemType elemType, 357 361 psS32 *status) … … 436 440 /*****************************************************************************/ 437 441 438 bool psMetadataItemPrint(FILE *fd,442 bool psMetadataItemPrint(FILE *fd, 439 443 const char *format, 440 444 const psMetadataItem* item) … … 450 454 451 455 // determining the format type 452 char *fType = strchr(format,'%');456 char *fType = strchr(format,'%'); 453 457 if (fType == NULL) { 454 458 // well, the format contains no reference to the metadataItem's data: … … 459 463 460 464 // skip over any format modifiers 461 const char *formatEnd = format+strlen(format);465 const char *formatEnd = format+strlen(format); 462 466 while ( (fType < formatEnd) && 463 467 (strchr(" +-01234567890.$#, hlL",*(++fType)) != NULL) ) {} … … 549 553 } 550 554 551 static psMetadata * genTypeTemplate(char*linePtr)555 static psMetadata *genTypeTemplate(char *linePtr) 552 556 { 553 557 psMetadata* metadataTemplate = NULL; … … 593 597 594 598 595 static psMetadata * parseTypeValues(psMetadata*template,596 char *linePtr)599 static psMetadata *parseTypeValues(psMetadata *template, 600 char *linePtr) 597 601 { 598 602 psMetadata* md = NULL; … … 660 664 } 661 665 662 bool parseMetadataItem(char *keyName,663 psArray *levelArray,664 char *linePtr,666 bool parseMetadataItem(char *keyName, 667 psArray *levelArray, 668 char *linePtr, 665 669 psMetadataFlags flags) 666 670 { … … 804 808 // If type is MULTI or META then check for the (optional) directives UPDATE or RESET; 805 809 // otherwise, get the value and comment. 810 // line may have the following forms: 811 // NAME METADATA 812 // NAME METADATA # Comment 813 // NAME METADATA#Comment 814 // NAME METADATA UPDATE # Comment 815 // NAME METADATA RESET # Comment 816 // NAME METADATA UPDATE 817 // NAME METADATA RESET 806 818 if((mdType == PS_DATA_METADATA_MULTI) || (mdType == PS_DATA_METADATA)) { 807 // Get the metadata item value if there is one. 819 820 // Get the metadata directive if there is one. 808 821 status = 0; 809 822 strValue = getToken (&linePtr, "#", &status, true); 810 811 if (status) { 812 psError(PS_ERR_IO, true, _("Failed to examine line for optional directive.")); 813 psFree(strType); 814 psFree(strValue); 815 return false; 816 } 817 818 if (strValue) { 823 824 if (!status && strValue) { 819 825 // found a directive, what does it say? 820 if (strcasecmp (strValue, "UPDATE") && strcasecmp (strValue, " UPDATE")) {826 if (strcasecmp (strValue, "UPDATE") && strcasecmp (strValue, "RESET")) { 821 827 psError(PS_ERR_IO, true, _("Invalid directive %s for METADATA or MULTI."), strValue); 822 828 psFree(strType); … … 834 840 flags |= PS_META_REPLACE; 835 841 } 836 } 837 psFree(strValue);838 strValue = NULL;842 psFree(strValue); 843 strValue = NULL; 844 } 839 845 840 846 // Not all lines will have comments, so NULL is ok. … … 846 852 847 853 if (status) { 848 psError(PS_ERR_IO, true, _("Error reading a metadata comment"));854 psError(PS_ERR_IO, true, _("Error reading metadata line")); 849 855 psFree(strType); 850 856 psFree(strComment); … … 965 971 // Add key to non-unique array of keys 966 972 // Check for duplicate MULTI lines 973 974 // XXX currently, we only place the name of the MULTI on this list. we thus lose 975 // the associated comment (if any) and the flags (if any) we could probably fix this 976 // behavior by allowing psMetadataAddItem to be passed an empty MULTI, which would 977 // have a null data pointer until an element is added (in other words, treat MULTI 978 // as another type of folder, but without a link of its own on the metadata->list 979 967 980 addStatus = true; 968 981 for(psS32 k=0; k < nonUniqueKeys->n; k++) { … … 1034 1047 } 1035 1048 1036 static bool parseLine(psArray *levelArray,1037 char *linePtr,1049 static bool parseLine(psArray *levelArray, 1050 char *linePtr, 1038 1051 bool overwrite, 1039 1052 bool *notBlank) … … 1101 1114 } 1102 1115 1103 static bool parseGeneric(char *keyName,1104 psArray *levelArray,1105 char *linePtr,1116 static bool parseGeneric(char *keyName, 1117 psArray *levelArray, 1118 char *linePtr, 1106 1119 psMetadataFlags flags) 1107 1120 { … … 1130 1143 } 1131 1144 1132 static bool parseType(char *keyName,1133 psArray *levelArray,1134 char *linePtr,1145 static bool parseType(char *keyName, 1146 psArray *levelArray, 1147 char *linePtr, 1135 1148 psMetadataFlags flags) 1136 1149 { … … 1188 1201 } 1189 1202 1190 static bool parseMetadataEnd(char *keyName,1191 psArray *levelArray,1192 char *linePtr,1203 static bool parseMetadataEnd(char *keyName, 1204 psArray *levelArray, 1205 char *linePtr, 1193 1206 psMetadataFlags flags) 1194 1207 { … … 1214 1227 } 1215 1228 1216 psMetadata * psMetadataConfigRead(psMetadata*md,1229 psMetadata *psMetadataConfigRead(psMetadata *md, 1217 1230 unsigned int *nFail, 1218 1231 const char *filename, … … 1228 1241 psError(PS_ERR_IO, true, _("failed to parse file '%s'"), filename); 1229 1242 psFree(md); 1230 return false; 1243 psFree(file); 1244 return NULL; 1231 1245 } 1232 1246 1233 1247 psFree(file); 1234 1235 1248 return md; 1236 1249 }
Note:
See TracChangeset
for help on using the changeset viewer.
