Add the "workpath" to the Engine parameters so the current working directory can be found at runtime.

git-svn-id: http://voip.null.ro/svn/yate@4223 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2011-03-28 13:32:24 +00:00
parent b43b297f95
commit 4494821757
3 changed files with 24 additions and 2 deletions

View File

@ -104,6 +104,10 @@ AC_HEADER_TIME
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([malloc gettimeofday inet_ntoa memmove strerror], , [AC_MSG_ERROR([This function is required.])])
HAVE_GETCWD=""
AC_CHECK_FUNCS([getcwd], [HAVE_GETCWD="-DHAVE_GETCWD"])
AC_SUBST(HAVE_GETCWD)
HAVE_PRCTL=""
AC_MSG_CHECKING([for prctl])
have_prctl="no"

View File

@ -142,6 +142,10 @@ using namespace TelEngine;
#define HOST_NAME_MAX 255
#endif
#ifndef PATH_MAX
#define PATH_MAX 270
#endif
static u_int64_t s_nextinit = 0;
static u_int64_t s_restarts = 0;
static bool s_makeworker = true;
@ -1077,6 +1081,20 @@ int Engine::run()
s_params.addParam("supervised",String::boolText(s_super_handle >= 0));
s_params.addParam("runattempt",String(s_run_attempt));
s_params.addParam("maxworkers",String(s_maxworkers));
#ifdef _WINDOWS
{
char buf[PATH_MAX];
DWORD ret = ::GetCurrentDirectoryA(PATH_MAX,buf);
if (ret && (ret < PATH_MAX))
s_params.addParam("workpath",buf);
}
#elif defined (HAVE_GETCWD)
{
char buf[PATH_MAX];
if (::getcwd(buf,PATH_MAX))
s_params.addParam("workpath",buf);
}
#endif
DDebug(DebugAll,"Engine::run()");
install(new EngineStatusHandler);
install(new EngineCommand);

View File

@ -60,7 +60,7 @@ moddir = @libdir@/yate
all: ../$(YLIB)
debug:
$(MAKE) all DEBUG=-g3
$(MAKE) all DEBUG=-g3
ddebug:
$(MAKE) all DEBUG='-g3 -DDEBUG'
@ -77,7 +77,7 @@ strip: all
-strip --strip-debug --discard-locals ../$(YLIB)
Engine.o: @srcdir@/Engine.cpp $(MKDEPS) $(EINC) ../yateversn.h ../yatepaths.h
$(COMPILE) @FDSIZE_HACK@ @HAVE_PRCTL@ -c $<
$(COMPILE) @FDSIZE_HACK@ @HAVE_PRCTL@ @HAVE_GETCWD@ -c $<
Channel.o: @srcdir@/Channel.cpp $(MKDEPS) $(PINC)
$(COMPILE) -c $<