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

Function processIfTag

maptemplate.c:684–819  ·  view source on GitHub ↗

! * this function process all if tag in pszInstr. * this function return a modified pszInstr. * ht mus contain all variables needed by the function * to interpret if expression. * * If bLastPass is true then all tests for 'null' values will be * considered true if the corresponding value is not set. */

Source from the content-addressed store, hash-verified

682 * considered true if the corresponding value is not set.
683*/
684int processIfTag(char **pszInstr, hashTableObj *ht, int bLastPass)
685{
686/* char *pszNextInstr = pszInstr; */
687 char *pszStart, *pszEnd=NULL;
688 char *pszName, *pszValue, *pszOperator, *pszThen=NULL, *pszHTValue;
689 char *pszIfTag;
690 char *pszPatIn=NULL, *pszPatOut=NULL, *pszTmp;
691 int nInst = 0;
692 int bEmpty = 0;
693 int nLength;
694
695 hashTableObj *ifArgs=NULL;
696
697 if(!*pszInstr) {
698 msSetError(MS_WEBERR, "Invalid pointer.", "processIfTag()");
699 return MS_FAILURE;
700 }
701
702 /* find the if start tag */
703
704 pszStart = findTag(*pszInstr, "if");
705
706 while (pszStart) {
707 pszPatIn = findTag(pszStart, "if");
708 pszPatOut = strstr(pszStart, "[/if]");
709 pszTmp = pszPatIn;
710
711 do {
712 if(pszPatIn && pszPatIn < pszPatOut) {
713 nInst++;
714 pszTmp = pszPatIn;
715 }
716
717 if(pszPatOut && ((pszPatIn == NULL) || pszPatOut < pszPatIn)) {
718 pszEnd = pszPatOut;
719 nInst--;
720 pszTmp = pszPatOut;
721 }
722
723 pszPatIn = findTag(pszTmp+1, "if");
724 pszPatOut = strstr(pszTmp+1, "[/if]");
725
726 } while (pszTmp != NULL && nInst > 0);
727
728 /* get the then string (if expression is true) */
729 if(getInlineTag("if", pszStart, &pszThen) != MS_SUCCESS) {
730 msSetError(MS_WEBERR, "Malformed then if tag.", "processIfTag()");
731 return MS_FAILURE;
732 }
733
734 /* retrieve if tag args */
735 if(getTagArgs("if", pszStart, &ifArgs) != MS_SUCCESS) {
736 msSetError(MS_WEBERR, "Malformed args if tag.", "processIfTag()");
737 return MS_FAILURE;
738 }
739
740 pszName = msLookupHashTable(ifArgs, "name");
741 pszValue = msLookupHashTable(ifArgs, "value");

Callers 3

generateGroupTemplateFunction · 0.85
generateLayerTemplateFunction · 0.85
generateClassTemplateFunction · 0.85

Calls 10

msSetErrorFunction · 0.85
findTagFunction · 0.85
getInlineTagFunction · 0.85
getTagArgsFunction · 0.85
msLookupHashTableFunction · 0.85
msSmallMallocFunction · 0.85
strlcpyFunction · 0.85
strcasecmpFunction · 0.85
msReplaceSubstringFunction · 0.85
msFreeHashTableFunction · 0.85

Tested by

no test coverage detected