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

Function msLoadMapFromString

mapfile.c:5516–5593  ·  view source on GitHub ↗

** Sets up string-based mapfile loading and calls loadMapInternal to do the work. */

Source from the content-addressed store, hash-verified

5514** Sets up string-based mapfile loading and calls loadMapInternal to do the work.
5515*/
5516mapObj *msLoadMapFromString(char *buffer, char *new_mappath)
5517{
5518 mapObj *map;
5519 struct mstimeval starttime, endtime;
5520 char szPath[MS_MAXPATHLEN], szCWDPath[MS_MAXPATHLEN];
5521 char *mappath=NULL;
5522 int debuglevel;
5523
5524 debuglevel = (int)msGetGlobalDebugLevel();
5525
5526 if (debuglevel >= MS_DEBUGLEVEL_TUNING)
5527 {
5528 /* In debug mode, track time spent loading/parsing mapfile. */
5529 msGettimeofday(&starttime, NULL);
5530 }
5531
5532 if(!buffer) {
5533 msSetError(MS_MISCERR, "No buffer to load.", "msLoadMapFromString()");
5534 return(NULL);
5535 }
5536
5537 /*
5538 ** Allocate mapObj structure
5539 */
5540 map = (mapObj *)calloc(sizeof(mapObj),1);
5541 MS_CHECK_ALLOC(map, sizeof(mapObj), NULL);
5542
5543 if(initMap(map) == -1) { /* initialize this map */
5544 msFree(map);
5545 return(NULL);
5546 }
5547
5548 msAcquireLock( TLOCK_PARSER ); /* might need to move this lock a bit higher, yup (bug 2108) */
5549
5550 msyystate = MS_TOKENIZE_STRING;
5551 msyystring = buffer;
5552 msyylex(); /* sets things up, but doesn't process any tokens */
5553
5554 msyylineno = 1; /* start at line 1 (do lines mean anything here?) */
5555
5556 /* If new_mappath is provided then use it, otherwise use the CWD */
5557 if(NULL == getcwd(szCWDPath, MS_MAXPATHLEN)) {
5558 msSetError(MS_MISCERR, "getcwd() returned a too long path", "msLoadMapFromString()");
5559 msFreeMap(map);
5560 msReleaseLock( TLOCK_PARSER );
5561 }
5562 if (new_mappath) {
5563 mappath = msStrdup(new_mappath);
5564 map->mappath = msStrdup(msBuildPath(szPath, szCWDPath, mappath));
5565 } else
5566 map->mappath = msStrdup(szCWDPath);
5567
5568 msyybasepath = map->mappath; /* for INCLUDEs */
5569
5570 if(loadMapInternal(map) != MS_SUCCESS) {
5571 msFreeMap(map);
5572 msReleaseLock( TLOCK_PARSER );
5573 if(mappath != NULL) free(mappath);

Callers 1

mapObj_newFromStringFunction · 0.85

Calls 14

msGetGlobalDebugLevelFunction · 0.85
msGettimeofdayFunction · 0.85
msSetErrorFunction · 0.85
initMapFunction · 0.85
msFreeFunction · 0.85
msAcquireLockFunction · 0.85
msFreeMapFunction · 0.85
msReleaseLockFunction · 0.85
msStrdupFunction · 0.85
msBuildPathFunction · 0.85
loadMapInternalFunction · 0.85
msDebugFunction · 0.85

Tested by

no test coverage detected