** 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. */
| 309 | ** is bug 1059. |
| 310 | */ |
| 311 | int 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 | |
| 349 | int msEvalContext(mapObj *map, layerObj *layer, char *context) |
| 350 | { |
no test coverage detected