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

Function processLine

maptemplate.c:3565–4073  ·  view source on GitHub ↗

** Process a single line in the template. A few tags (e.g. [resultset]...[/resultset]) can be multi-line so ** we pass the filehandle to look ahead if necessary. */

Source from the content-addressed store, hash-verified

3563** we pass the filehandle to look ahead if necessary.
3564*/
3565static char *processLine(mapservObj *mapserv, char *instr, FILE *stream, int mode)
3566{
3567 int i, j;
3568#define PROCESSLINE_BUFLEN 5120
3569 char repstr[PROCESSLINE_BUFLEN], substr[PROCESSLINE_BUFLEN], *outstr; /* repstr = replace string, substr = sub string */
3570 struct hashObj *tp=NULL;
3571 char *encodedstr;
3572
3573#ifdef USE_PROJ
3574 rectObj llextent;
3575 pointObj llpoint;
3576#endif
3577
3578 outstr = msStrdup(instr); /* work from a copy */
3579
3580 if(strstr(outstr, "[version]")) outstr = msReplaceSubstring(outstr, "[version]", msGetVersion());
3581
3582 snprintf(repstr, PROCESSLINE_BUFLEN, "%s%s%s.%s", mapserv->map->web.imageurl, mapserv->map->name, mapserv->Id, MS_IMAGE_EXTENSION(mapserv->map->outputformat));
3583 outstr = msReplaceSubstring(outstr, "[img]", repstr);
3584 snprintf(repstr, PROCESSLINE_BUFLEN, "%s%sref%s.%s", mapserv->map->web.imageurl, mapserv->map->name, mapserv->Id, MS_IMAGE_EXTENSION(mapserv->map->outputformat));
3585 outstr = msReplaceSubstring(outstr, "[ref]", repstr);
3586
3587 if(strstr(outstr, "[errmsg")) {
3588 char *errmsg = msGetErrorString(";");
3589 if(!errmsg) errmsg = msStrdup("Error message buffer is empty."); /* should never happen, but just in case... */
3590 outstr = msReplaceSubstring(outstr, "[errmsg]", errmsg);
3591 encodedstr = msEncodeUrl(errmsg);
3592 outstr = msReplaceSubstring(outstr, "[errmsg_esc]", encodedstr);
3593 free(errmsg);
3594 free(encodedstr);
3595 }
3596
3597 if(strstr(outstr, "[legend]")) {
3598 /* if there's a template legend specified, use it */
3599 if(mapserv->map->legend.template) {
3600 char *legendTemplate;
3601
3602 legendTemplate = generateLegendTemplate(mapserv);
3603 if(legendTemplate) {
3604 outstr = msReplaceSubstring(outstr, "[legend]", legendTemplate);
3605
3606 free(legendTemplate);
3607 }
3608 else /* error already generated by (generateLegendTemplate()) */
3609 return NULL;
3610 }
3611 else { /* if not display gif image with all legend icon */
3612 snprintf(repstr, PROCESSLINE_BUFLEN, "%s%sleg%s.%s", mapserv->map->web.imageurl, mapserv->map->name, mapserv->Id, MS_IMAGE_EXTENSION(mapserv->map->outputformat));
3613 outstr = msReplaceSubstring(outstr, "[legend]", repstr);
3614 }
3615 }
3616
3617 snprintf(repstr, PROCESSLINE_BUFLEN, "%s%ssb%s.%s", mapserv->map->web.imageurl, mapserv->map->name, mapserv->Id, MS_IMAGE_EXTENSION(mapserv->map->outputformat));
3618 outstr = msReplaceSubstring(outstr, "[scalebar]", repstr);
3619
3620 if(mapserv->savequery) {
3621 snprintf(repstr, PROCESSLINE_BUFLEN, "%s%s%s%s", mapserv->map->web.imagepath, mapserv->map->name, mapserv->Id, MS_QUERY_EXTENSION);
3622 outstr = msReplaceSubstring(outstr, "[queryfile]", repstr);

Callers 6

processFeatureTagFunction · 0.85
processIncludeTagFunction · 0.85
processOneToManyJoinFunction · 0.85
msReturnPageFunction · 0.85
msReturnURLFunction · 0.85
msReturnOpenLayersPageFunction · 0.85

Calls 15

msStrdupFunction · 0.85
msReplaceSubstringFunction · 0.85
msGetVersionFunction · 0.85
msGetErrorStringFunction · 0.85
msEncodeUrlFunction · 0.85
generateLegendTemplateFunction · 0.85
msOWSGetOnlineResourceFunction · 0.85
msBuildOnlineResourceFunction · 0.85
strlcatFunction · 0.85
msStringTrimBlanksFunction · 0.85
isOnFunction · 0.85
processDateTagFunction · 0.85

Tested by

no test coverage detected