[mapserver-commits] r7541 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Apr 29 00:48:36 EDT 2008
Author: sdlime
Date: 2008-04-29 00:48:36 -0400 (Tue, 29 Apr 2008)
New Revision: 7541
Modified:
trunk/mapserver/maptemplate.c
Log:
A bit more tag handling code for RFC36.
Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c 2008-04-28 13:59:49 UTC (rev 7540)
+++ trunk/mapserver/maptemplate.c 2008-04-29 04:48:36 UTC (rev 7541)
@@ -527,7 +527,7 @@
}
/*
-** Return a substring from instr beetween [tag] and [/tag]
+** Return a substring from instr between [tag] and [/tag]
** char * returned must be freed by caller.
** pszNextInstr will be a pointer at the end of the
** first occurence found.
@@ -758,11 +758,41 @@
return MS_SUCCESS;
}
+/* Helper function to return the text before the supplied string2 in string1. */
+static char *getPreTagText(const char *string1, const char *string2)
+{
+ int n;
+ char *result, *tmpstr;
+
+ if((tmpstr = strstr(string1, string2)) == NULL) return strdup(""); /* return an empty string */
+
+ n = strlen(string1) - strlen(tmpstr);
+ result = (char *) malloc(n + 1);
+ result[n] = '\0';
+ strncpy(result, string1, n);
+
+ return result;
+}
+
+/* Helper function to retunr the text after the supplied string2 in string1. */
+static char *getPostTagText(const char *string1, const char *string2)
+{
+ char *tmpstr;
+
+ if((tmpstr = strstr(string1, string2)) == NULL) return strdup(""); /* return an empty string */
+
+ tmpstr += strlen(string2); /* skip string2 */
+ return strdup(tmpstr);
+}
+
/*
** Function to process an [resultset ...] tag.
*/
static int processResultSetTag(mapservObj *mapserv, char **line, FILE *stream)
{
+ char lineBuffer[MS_BUFFER_LENGTH];
+ int foundTagEnd;
+
char *preTag, *postTag; /* text before and after the tag */
char *tag, *tagStart, *tagEnd;
@@ -779,12 +809,41 @@
}
tagStart = findTag(*line, "resultset");
-
if(!tagStart) return(MS_SUCCESS); /* OK, just return; */
+ if(strstr(*line, "[/resultset]") == NULL) { /* read ahead */
+ foundTagEnd = MS_FALSE;
+ while((fgets(lineBuffer, MS_BUFFER_LENGTH, stream) != NULL) && !foundTagEnd) {
+ *line = msStringConcatenate(*line, lineBuffer);
+ if(strstr(*line, "[/resultset]") != NULL)
+ foundTagEnd = MS_TRUE;
+ }
+ if(foundTagEnd == MS_FALSE) {
+ msSetError(MS_WEBERR, "[resultset] tag found without closing [/resultset]..", "processResultSetTag()");
+ return(MS_FAILURE);
+ }
+ }
+
+ tagStart = findTag(*line, "resultset"); /* redo since **line may have changed */
+
+ if(getInlineTag("resultset", *line, &tag) != MS_SUCCESS) {
+ msSetError(MS_WEBERR, "Malformed then resultset tag.", "processResultSetTag()");
+ return MS_FAILURE;
+ }
+
+ preTag = getPreTagText(*line, "[resultset");
+ postTag = getPostTagText(*line, "[/resultset]");
+
+ printf("*****************************************************************\n");
+
printf("line: %s\n", *line);
printf("tagStart: %s\n", tagStart);
+ printf("tag: %s\n", tag);
+ printf("preTag: %s\n", preTag);
+ printf("postTag: %s\n", postTag);
+ printf("*****************************************************************\n");
+
return(MS_SUCCESS);
}
More information about the mapserver-commits
mailing list