Permalink
Browse files

Added ability to toggle on/off use of C system() function call, using…

… OSG_SYSTEM_SUPPORTED Cmake option
  • Loading branch information...
robertosfield committed Jan 12, 2018
1 parent 6a3d9b2 commit ae57f3cd467a742755baab7ea4f46463d16f8674
View
@@ -480,6 +480,7 @@ OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<
OPTION(OSG_USE_REF_PTR_SAFE_DEREFERENCE "Set to ON to throw an exception whenever ref_ptr<> is dereferenced or called. " OFF)
OPTION(OSG_ENVVAR_SUPPORTED "Set to ON to build OpenSceneGraph with the OSG_ENVVAR_SUPPOERTED #define enabled to enable use of getenv() related functions." ON)
OPTION(OSG_SYSTEM_SUPPORTED "Set to ON to build OpenSceneGraph with the OSG_SYSTEM_SUPPOERTED #define enabled to enable use of system() related functions." ON)

This comment has been minimized.

Show comment
Hide comment
@filnet

filnet Jan 13, 2018

Contributor

typo ;) in SUPPOERTED

@filnet

filnet Jan 13, 2018

Contributor

typo ;) in SUPPOERTED

View
@@ -16,13 +16,29 @@
#include <osg/Config>
#ifdef OSG_ENVVAR_SUPPORTED
#if defined(OSG_SYSTEM_SUPPORTED) || defined(OSG_ENVVAR_SUPPORTED)
#include <stdlib.h>
#endif
#ifdef OSG_ENVVAR_SUPPORTED
#include <sstream>
#endif
namespace osg {
#ifdef OSG_SYSTEM_SUPPORTED
inline int system(const char* command)
{
return ::system(command);
}
#else
inline int system(const char* command)
{
OSG_WARN<<"system("<<command<<") not supported on this platform."<<std::endl;
return 0;
}
#endif
inline unsigned int getClampedLength(const char* str, unsigned int maxNumChars=4096)
{
unsigned int i = 0;
View
@@ -35,5 +35,6 @@
#cmakedefine OSG_PROVIDE_READFILE
#cmakedefine OSG_USE_DEPRECATED_API
#cmakedefine OSG_ENVVAR_SUPPORTED
#cmakedefine OSG_SYSTEM_SUPPORTED
#endif
@@ -19,6 +19,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include <osg/Config>
/*
** list of valid conversion specifiers for the 'strftime' function
@@ -78,6 +79,8 @@
static int os_execute (lua_State *L) {
#if defined(OSG_SYSTEM_SUPPORTED)
const char *cmd = luaL_optstring(L, 1, NULL);
int stat = system(cmd);
if (cmd != NULL)
@@ -86,6 +89,9 @@ static int os_execute (lua_State *L) {
lua_pushboolean(L, stat); /* true if there is a shell */
return 1;
}
#else
return 0;
#endif
}
@@ -8,6 +8,7 @@
#include <osg/Geode>
#include <osg/Group>
#include <osg/Notify>
#include <osg/os_utils>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
@@ -77,7 +78,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
mkdir( dirname, 0700 );
#endif
if ( system( command ) ) {
if (osg::system( command ) ) {
return ReadResult::FILE_NOT_HANDLED;
}
@@ -107,7 +108,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
sprintf( command, "rm -rf %s", dirname );
#endif
if ( system( command ) ) {
if (osg::system( command ) ) {
return ReadResult::FILE_NOT_HANDLED;
}
@@ -8,6 +8,7 @@
#include <osg/Geode>
#include <osg/Group>
#include <osg/Notify>
#include <osg/os_utils>
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
@@ -94,7 +95,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
OSG_NOTICE<<"Running command '"<<command<<"'"<<std::endl;
int result = system( command );
int result = osg::system( command );
if (result!=0) return ReadResult::ERROR_IN_READING_FILE;
@@ -137,7 +138,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
#endif
OSG_NOTICE<<"Running command '"<<command<<"'"<<std::endl;
result = system( command );
result = osg::system( command );
if (result!=0) return ReadResult::ERROR_IN_READING_FILE;
if( grp->getNumChildren() == 0 )
@@ -14,6 +14,7 @@
#include <osgPresentation/SlideEventHandler>
#include <osgViewer/Viewer>
#include <osg/os_utils>
#include <osg/Notify>
#include <osgDB/FileUtils>
@@ -119,7 +120,7 @@ void KeyEventHandler::doOperation()
bool commandRunsInBackground = (_command.find("&")!=std::string::npos);
int result = system(_command.c_str());
int result = osg::system(_command.c_str());
OSG_INFO<<"system("<<_command<<") result "<<result<<std::endl;
@@ -17,6 +17,7 @@
#include <osg/Notify>
#include <osgDB/FileUtils>
#include <osg/io_utils>
#include <osg/os_utils>
#include <stdlib.h>
@@ -230,7 +231,7 @@ void PickEventHandler::doOperation()
bool commandRunsInBackground = (_command.find("&")!=std::string::npos);
int result = system(_command.c_str());
int result = osg::system(_command.c_str());
OSG_INFO<<"system("<<_command<<") result "<<result<<std::endl;
@@ -21,6 +21,7 @@
#include <osg/AlphaFunc>
#include <osg/Timer>
#include <osg/io_utils>
#include <osg/os_utils>
#include <osgUtil/TransformCallback>
#include <osgUtil/GLObjectsVisitor>
@@ -420,7 +421,7 @@ struct LayerAttributesOperator : public ObjectOperator
OSG_NOTICE<<"Run "<<itr->c_str()<<std::endl;
osg::Timer_t startTick = osg::Timer::instance()->tick();
int result = system(itr->c_str());
int result = osg::system(itr->c_str());
OSG_INFO<<"system("<<*itr<<") result "<<result<<std::endl;
@@ -1257,7 +1258,7 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
std::stringstream command;
command<<editor<<" "<<filename<<" &"<<std::endl;
int result = system(command.str().c_str());
int result = osg::system(command.str().c_str());
OSG_INFO<<"system("<<command.str()<<") result "<<result<<std::endl;
@@ -31,6 +31,7 @@
#include <osg/ComputeBoundsVisitor>
#include <osg/Notify>
#include <osg/io_utils>
#include <osg/os_utils>
#include <osg/ValueObject>
#include <osgUtil/TransformCallback>
@@ -1749,7 +1750,7 @@ void SlideShowConstructor::addGraph(const std::string& contents, const PositionD
std::stringstream command;
command<<"dot -Tsvg "<<dotFileName<<" -o "<<tmpSvgFileName;
int result = system(command.str().c_str());
int result = osg::system(command.str().c_str());
if (result==0)
{
osg::ref_ptr<osgDB::Options> previousOptions = _options;

0 comments on commit ae57f3c

Please sign in to comment.