MCPcopy Index your code
hub / github.com/MapServer/MapServer / processMetadata

Function processMetadata

maptemplate.c:2285–2343  ·  view source on GitHub ↗

! * this function process all metadata * in pszInstr. ht mus contain all corresponding * metadata value. * * this function return a modified pszInstr */

Source from the content-addressed store, hash-verified

2283 * this function return a modified pszInstr
2284*/
2285int processMetadata(char** pszInstr, hashTableObj *ht)
2286{
2287/* char *pszNextInstr = pszInstr; */
2288 char *pszEnd, *pszStart;
2289 char *pszMetadataTag;
2290 char *pszHashName;
2291 char *pszHashValue;
2292 int nLength, nOffset;
2293
2294 hashTableObj *metadataArgs = NULL;
2295
2296 if(!*pszInstr) {
2297 msSetError(MS_WEBERR, "Invalid pointer.", "processMetadata()");
2298 return MS_FAILURE;
2299 }
2300
2301 /* set position to the begining of metadata tag */
2302 pszStart = findTag(*pszInstr, "metadata");
2303
2304 while (pszStart) {
2305 /* get metadata args */
2306 if(getTagArgs("metadata", pszStart, &metadataArgs) != MS_SUCCESS)
2307 return MS_FAILURE;
2308
2309 pszHashName = msLookupHashTable(metadataArgs, "name");
2310 pszHashValue = msLookupHashTable(ht, pszHashName);
2311
2312 nOffset = pszStart - *pszInstr;
2313
2314 if(pszHashName && pszHashValue) {
2315 /* set position to the end of metadata start tag */
2316 pszEnd = strchr(pszStart, ']');
2317 pszEnd++;
2318
2319 /* build the complete metadata tag ([metadata all_args]) */
2320 /* to replace it by the corresponding value from ht */
2321 nLength = pszEnd - pszStart;
2322 pszMetadataTag = (char*)msSmallMalloc(nLength + 1);
2323 strlcpy(pszMetadataTag, pszStart, nLength+1);
2324
2325 *pszInstr = msReplaceSubstring(*pszInstr, pszMetadataTag, pszHashValue);
2326
2327 free(pszMetadataTag);
2328 pszMetadataTag=NULL;
2329 }
2330
2331 msFreeHashTable(metadataArgs);
2332 metadataArgs=NULL;
2333
2334
2335 /* set position to the begining of the next metadata tag */
2336 if((*pszInstr)[nOffset] != '\0')
2337 pszStart = findTag(*pszInstr+nOffset+1, "metadata");
2338 else
2339 pszStart = NULL;
2340 }
2341
2342 return MS_SUCCESS;

Callers 3

generateGroupTemplateFunction · 0.85
generateLayerTemplateFunction · 0.85
generateClassTemplateFunction · 0.85

Calls 8

msSetErrorFunction · 0.85
findTagFunction · 0.85
getTagArgsFunction · 0.85
msLookupHashTableFunction · 0.85
msSmallMallocFunction · 0.85
strlcpyFunction · 0.85
msReplaceSubstringFunction · 0.85
msFreeHashTableFunction · 0.85

Tested by

no test coverage detected