[mapserver-commits] r10171 - branches/branch-5-6/mapserver
svn at osgeo.org
svn at osgeo.org
Thu May 20 17:15:09 EDT 2010
Author: sdlime
Date: 2010-05-20 17:15:08 -0400 (Thu, 20 May 2010)
New Revision: 10171
Modified:
branches/branch-5-6/mapserver/maptemplate.c
Log:
Support multiple resultset tags on a single line. (#3455)
Modified: branches/branch-5-6/mapserver/maptemplate.c
===================================================================
--- branches/branch-5-6/mapserver/maptemplate.c 2010-05-20 21:10:37 UTC (rev 10170)
+++ branches/branch-5-6/mapserver/maptemplate.c 2010-05-20 21:15:08 UTC (rev 10171)
@@ -939,73 +939,80 @@
return(MS_FAILURE);
}
- tagStart = findTag(*line, "resultset");
- if(!tagStart) return(MS_SUCCESS); /* OK, just return; */
-
if(!stream) {
msSetError(MS_WEBERR, "Invalid file pointer.", "processResultSetTag()");
return(MS_FAILURE);
}
- /* check for any tag arguments */
- if(getTagArgs("resultset", tagStart, &tagArgs) != MS_SUCCESS) return(MS_FAILURE);
- if(tagArgs) {
- layerName = msLookupHashTable(tagArgs, "layer");
- }
+ tagStart = findTag(*line, "resultset");
+ if(!tagStart) return(MS_SUCCESS); /* OK, just return; */
- if(!layerName) {
- msSetError(MS_WEBERR, "[resultset] tag missing required 'layer' argument.", "processResultSetTag()");
- return(MS_FAILURE);
- }
+ while (tagStart) {
+ /* initialize the tag arguments */
+ layerName = NULL;
- layerIndex = msGetLayerIndex(mapserv->map, layerName);
- if(layerIndex>=mapserv->map->numlayers || layerIndex<0) {
- msSetError(MS_MISCERR, "Layer named '%s' does not exist.", "processResultSetTag()", layerName);
- return MS_FAILURE;
- }
- lp = GET_LAYER(mapserv->map, layerIndex);
+ /* check for any tag arguments */
+ if(getTagArgs("resultset", tagStart, &tagArgs) != MS_SUCCESS) return(MS_FAILURE);
+ if(tagArgs) {
+ layerName = msLookupHashTable(tagArgs, "layer");
+ }
- if(strstr(*line, "[/resultset]") == NULL) { /* read ahead */
- foundTagEnd = MS_FALSE;
- while(!foundTagEnd) {
- if(fgets(lineBuffer, MS_BUFFER_LENGTH, stream) != NULL) {
- *line = msStringConcatenate(*line, lineBuffer);
- if(strstr(*line, "[/resultset]") != NULL)
- foundTagEnd = MS_TRUE;
- } else
- break; /* ran out of file */
- }
- if(foundTagEnd == MS_FALSE) {
- msSetError(MS_WEBERR, "[resultset] tag found without closing [/resultset].", "processResultSetTag()");
+ if(!layerName) {
+ msSetError(MS_WEBERR, "[resultset] tag missing required 'layer' argument.", "processResultSetTag()");
return(MS_FAILURE);
}
- }
- if(getInlineTag("resultset", *line, &tag) != MS_SUCCESS) {
- msSetError(MS_WEBERR, "Malformed resultset tag.", "processResultSetTag()");
- return MS_FAILURE;
- }
+ layerIndex = msGetLayerIndex(mapserv->map, layerName);
+ if(layerIndex>=mapserv->map->numlayers || layerIndex<0) {
+ msSetError(MS_MISCERR, "Layer named '%s' does not exist.", "processResultSetTag()", layerName);
+ return MS_FAILURE;
+ }
+ lp = GET_LAYER(mapserv->map, layerIndex);
- preTag = getPreTagText(*line, "[resultset"); /* TODO: need to handle tags in these */
- postTag = getPostTagText(*line, "[/resultset]");
+ if(strstr(*line, "[/resultset]") == NULL) { /* read ahead */
+ foundTagEnd = MS_FALSE;
+ while(!foundTagEnd) {
+ if(fgets(lineBuffer, MS_BUFFER_LENGTH, stream) != NULL) {
+ *line = msStringConcatenate(*line, lineBuffer);
+ if(strstr(*line, "[/resultset]") != NULL)
+ foundTagEnd = MS_TRUE;
+ } else
+ break; /* ran out of file */
+ }
+ if(foundTagEnd == MS_FALSE) {
+ msSetError(MS_WEBERR, "[resultset] tag found without closing [/resultset].", "processResultSetTag()");
+ return(MS_FAILURE);
+ }
+ }
- /* start rebuilding **line */
- free(*line); *line = preTag;
+ if(getInlineTag("resultset", *line, &tag) != MS_SUCCESS) {
+ msSetError(MS_WEBERR, "Malformed resultset tag.", "processResultSetTag()");
+ return MS_FAILURE;
+ }
- if(lp->resultcache && lp->resultcache->numresults > 0) {
- /* probably will need a while-loop here to handle multiple instances of [feature ...] tags */
- if(processFeatureTag(mapserv, &tag, lp) != MS_SUCCESS)
- return(MS_FAILURE); /* TODO: how to handle */
- *line = msStringConcatenate(*line, tag);
- }
+ preTag = getPreTagText(*line, "[resultset"); /* TODO: need to handle tags in these */
+ postTag = getPostTagText(*line, "[/resultset]");
- *line = msStringConcatenate(*line, postTag);
+ /* start rebuilding **line */
+ free(*line); *line = preTag;
- /* clean up */
- msFreeHashTable(tagArgs); tagArgs=NULL;
- free(postTag);
- free(tag);
+ if(lp->resultcache && lp->resultcache->numresults > 0) {
+ /* probably will need a while-loop here to handle multiple instances of [feature ...] tags */
+ if(processFeatureTag(mapserv, &tag, lp) != MS_SUCCESS)
+ return(MS_FAILURE); /* TODO: how to handle */
+ *line = msStringConcatenate(*line, tag);
+ }
+ *line = msStringConcatenate(*line, postTag);
+
+ /* clean up */
+ msFreeHashTable(tagArgs); tagArgs=NULL;
+ free(postTag);
+ free(tag);
+
+ tagStart = findTag(*line, "resultset");
+ }
+
return(MS_SUCCESS);
}
More information about the mapserver-commits
mailing list