From 4494821757cf3f5f5bd3fb94c6e1478e06897b31 Mon Sep 17 00:00:00 2001 From: paulc Date: Mon, 28 Mar 2011 13:32:24 +0000 Subject: [PATCH] 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 --- configure.in | 4 ++++ engine/Engine.cpp | 18 ++++++++++++++++++ engine/Makefile.in | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index ad03b9ee..84038be7 100644 --- a/configure.in +++ b/configure.in @@ -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" diff --git a/engine/Engine.cpp b/engine/Engine.cpp index f44fd38e..c30d51bf 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -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); diff --git a/engine/Makefile.in b/engine/Makefile.in index 3c96d870..26b9d650 100644 --- a/engine/Makefile.in +++ b/engine/Makefile.in @@ -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 $<