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

Function msValidateContexts

maputil.c:311–347  ·  view source on GitHub ↗

** Function to take a look at all layers with REQUIRES/LABELREQUIRES set to make sure there are no ** recursive context requirements set (e.g. layer1 requires layer2 and layer2 requires layer1). This ** is bug 1059. */

Source from the content-addressed store, hash-verified

309** is bug 1059.
310*/
311int msValidateContexts(mapObj *map)
312{
313 int i;
314 char **ltags;
315 int status = MS_SUCCESS;
316
317 ltags = (char **) msSmallMalloc(map->numlayers*sizeof(char *));
318 for(i=0; i<map->numlayers; i++) {
319 if(GET_LAYER(map, i)->name == NULL) {
320 ltags[i] = msStrdup("[NULL]");
321 } else {
322 ltags[i] = (char *) msSmallMalloc(sizeof(char)*strlen(GET_LAYER(map, i)->name) + 3);
323 sprintf(ltags[i], "[%s]", GET_LAYER(map, i)->name);
324 }
325 }
326
327 /* check each layer's REQUIRES and LABELREQUIRES parameters */
328 for(i=0; i<map->numlayers; i++) {
329 /* printf("working on layer %s, looking for references to %s\n", GET_LAYER(map, i)->name, ltags[i]); */
330 if(searchContextForTag(map, ltags, ltags[i], GET_LAYER(map, i)->requires, MS_TRUE) == MS_SUCCESS) {
331 msSetError(MS_PARSEERR, "Recursion error found for REQUIRES parameter for layer %s.", "msValidateContexts", GET_LAYER(map, i)->name);
332 status = MS_FAILURE;
333 break;
334 }
335 if(searchContextForTag(map, ltags, ltags[i], GET_LAYER(map, i)->labelrequires, MS_FALSE) == MS_SUCCESS) {
336 msSetError(MS_PARSEERR, "Recursion error found for LABELREQUIRES parameter for layer %s.", "msValidateContexts", GET_LAYER(map, i)->name);
337 status = MS_FAILURE;
338 break;
339 }
340 /* printf("done layer %s\n", GET_LAYER(map, i)->name); */
341 }
342
343 /* clean up */
344 msFreeCharArray(ltags, map->numlayers);
345
346 return status;
347}
348
349int msEvalContext(mapObj *map, layerObj *layer, char *context)
350{

Callers 3

msPrepareImageFunction · 0.85
msDrawLegendFunction · 0.85
generateLegendTemplateFunction · 0.85

Calls 5

msSmallMallocFunction · 0.85
msStrdupFunction · 0.85
searchContextForTagFunction · 0.85
msSetErrorFunction · 0.85
msFreeCharArrayFunction · 0.85

Tested by

no test coverage detected