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

Function getInlineTag

maptemplate.c:595–673  ·  view source on GitHub ↗

** 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. */

Source from the content-addressed store, hash-verified

593** first occurence found.
594*/
595int getInlineTag(char *pszTag, char *pszInstr, char **pszResult)
596{
597 char *pszStart, *pszEnd=NULL, *pszEndTag, *pszPatIn, *pszPatOut=NULL, *pszTmp;
598 int nInst=0;
599 int nLength;
600
601 *pszResult = NULL;
602
603 if(!pszInstr || !pszTag) {
604 msSetError(MS_WEBERR, "Invalid pointer.", "getInlineTag()");
605 return MS_FAILURE;
606 }
607
608 pszEndTag = (char*)msSmallMalloc(strlen(pszTag) + 3);
609 strcpy(pszEndTag, "[/");
610 strcat(pszEndTag, pszTag);
611
612 /* find start tag */
613 pszPatIn = findTag(pszInstr, pszTag);
614 pszPatOut = strstr(pszInstr, pszEndTag);
615
616 pszStart = pszPatIn;
617
618 pszTmp = pszInstr;
619
620 if(pszPatIn)
621 {
622 do
623 {
624 if(pszPatIn && pszPatIn < pszPatOut)
625 {
626 nInst++;
627
628 pszTmp = pszPatIn;
629 }
630
631 if(pszPatOut && ((pszPatIn == NULL) || pszPatOut < pszPatIn))
632 {
633 pszEnd = pszPatOut;
634 nInst--;
635
636 pszTmp = pszPatOut;
637 }
638
639 pszPatIn = findTag(pszTmp+1, pszTag);
640 pszPatOut = strstr(pszTmp+1, pszEndTag);
641
642 }while (pszTmp != NULL && nInst > 0);
643 }
644
645 if(pszStart && pszEnd) {
646 /* find end of start tag */
647 pszStart = strchr(pszStart, ']');
648
649 if(pszStart) {
650 pszStart++;
651
652 nLength = pszEnd - pszStart;

Callers 4

processIfTagFunction · 0.85
processFeatureTagFunction · 0.85
processResultSetTagFunction · 0.85
generateLegendTemplateFunction · 0.85

Calls 5

msSetErrorFunction · 0.85
msSmallMallocFunction · 0.85
findTagFunction · 0.85
strlcpyFunction · 0.85
msFreeFunction · 0.85

Tested by

no test coverage detected