[mapserver-commits] r11128 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Mar 9 15:38:48 EST 2011
Author: dmorissette
Date: 2011-03-09 12:38:48 -0800 (Wed, 09 Mar 2011)
New Revision: 11128
Modified:
trunk/mapserver/mapdebug.c
trunk/mapserver/maperror.h
trunk/mapserver/mapobject.c
trunk/mapserver/shp2img.c
trunk/mapserver/sortshp.c
Log:
Support for MS_ERRORFILE relative to mapfile path (#2853)
Modified: trunk/mapserver/mapdebug.c
===================================================================
--- trunk/mapserver/mapdebug.c 2011-03-09 19:05:25 UTC (rev 11127)
+++ trunk/mapserver/mapdebug.c 2011-03-09 20:38:48 UTC (rev 11128)
@@ -129,12 +129,27 @@
**
** Set output target, ready to write to it, open file if necessary
**
+** If pszRelToPath != NULL then we will try to make the value relative to
+** this path if it is not absolute already and it's not one of the special
+** values (stderr, stdout, windowsdebug)
+**
** Returns MS_SUCCESS/MS_FAILURE
*/
-int msSetErrorFile(const char *pszErrorFile)
+int msSetErrorFile(const char *pszErrorFile, const char *pszRelToPath)
{
+ char extended_path[MS_MAXPATHLEN];
debugInfoObj *debuginfo = msGetDebugInfoObj();
+ if (strcmp(pszErrorFile, "stderr") != 0 &&
+ strcmp(pszErrorFile, "stdout") != 0 &&
+ strcmp(pszErrorFile, "windowsdebug") != 0)
+ {
+ /* Try to make the path relative */
+ if(msBuildPath(extended_path, pszRelToPath, pszErrorFile) == NULL)
+ return MS_FAILURE;
+ pszErrorFile = extended_path;
+ }
+
if (debuginfo && debuginfo->errorfile && pszErrorFile &&
strcmp(debuginfo->errorfile, pszErrorFile) == 0)
{
@@ -271,7 +286,7 @@
if( (val=getenv( "MS_ERRORFILE" )) != NULL )
{
- if ( msSetErrorFile(val) != MS_SUCCESS )
+ if ( msSetErrorFile(val, NULL) != MS_SUCCESS )
return MS_FAILURE;
}
Modified: trunk/mapserver/maperror.h
===================================================================
--- trunk/mapserver/maperror.h 2011-03-09 19:05:25 UTC (rev 11127)
+++ trunk/mapserver/maperror.h 2011-03-09 20:38:48 UTC (rev 11128)
@@ -159,7 +159,7 @@
MS_DLL_EXPORT void msDebug( const char * pszFormat, ... );
-MS_DLL_EXPORT int msSetErrorFile(const char *pszErrorFile);
+MS_DLL_EXPORT int msSetErrorFile(const char *pszErrorFile, const char *pszRelToPath);
MS_DLL_EXPORT void msCloseErrorFile( void );
MS_DLL_EXPORT const char *msGetErrorFile( void );
MS_DLL_EXPORT void msSetGlobalDebugLevel(int level);
Modified: trunk/mapserver/mapobject.c
===================================================================
--- trunk/mapserver/mapobject.c 2011-03-09 19:05:25 UTC (rev 11127)
+++ trunk/mapserver/mapobject.c 2011-03-09 20:38:48 UTC (rev 11128)
@@ -191,10 +191,12 @@
}
/* Same for MS_ERRORFILE, we want it to kick in as early as possible
- * to catch parsing errors */
+ * to catch parsing errors.
+ * Value can be relative to mapfile, unless it's already absolute
+ */
if( strcasecmp(key,"MS_ERRORFILE") == 0 )
{
- if (msSetErrorFile( value ) != MS_SUCCESS)
+ if (msSetErrorFile( value, map->mappath ) != MS_SUCCESS)
return MS_FAILURE;
}
@@ -245,7 +247,7 @@
}
else if( strcasecmp(key,"MS_ERRORFILE") == 0 )
{
- msSetErrorFile( value );
+ msSetErrorFile( value, map->mappath );
}
else
{
Modified: trunk/mapserver/shp2img.c
===================================================================
--- trunk/mapserver/shp2img.c 2011-03-09 19:05:25 UTC (rev 11127)
+++ trunk/mapserver/shp2img.c 2011-03-09 20:38:48 UTC (rev 11128)
@@ -64,7 +64,7 @@
/* Send output to stderr by default */
if (msGetErrorFile() == NULL)
- msSetErrorFile("stderr");
+ msSetErrorFile("stderr", NULL);
continue;
}
@@ -213,7 +213,7 @@
/* Send output to stderr by default */
if (msGetErrorFile() == NULL)
- msSetErrorFile("stderr");
+ msSetErrorFile("stderr", NULL);
}
if(strcmp(argv[i], "-layer_debug") == 0) /* debug */
@@ -235,7 +235,7 @@
/* Send output to stderr by default */
if (msGetErrorFile() == NULL)
- msSetErrorFile("stderr");
+ msSetErrorFile("stderr", NULL);
}
if(strcmp(argv[i],"-e") == 0) { /* change extent */
Modified: trunk/mapserver/sortshp.c
===================================================================
--- trunk/mapserver/sortshp.c 2011-03-09 19:05:25 UTC (rev 11127)
+++ trunk/mapserver/sortshp.c 2011-03-09 20:38:48 UTC (rev 11128)
@@ -104,7 +104,7 @@
exit(0);
}
- msSetErrorFile("stderr");
+ msSetErrorFile("stderr", NULL);
/* ------------------------------------------------------------------------------- */
/* Open the shapefile */
More information about the mapserver-commits
mailing list