From dcdec03406adbb18026ede70c287d590b9a6bfc5 Mon Sep 17 00:00:00 2001 From: Peter Soetens Date: Wed, 15 Dec 2010 23:28:53 +0100 Subject: [PATCH] os: provide argc/argv api in order to allow lookup of program arguments. Signed-off-by: Peter Soetens --- rtt/os/startstop.cpp | 13 +++++++++++++ rtt/os/startstop.h | 11 +++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/rtt/os/startstop.cpp b/rtt/os/startstop.cpp index 5d6b75b..486f527 100644 --- a/rtt/os/startstop.cpp +++ b/rtt/os/startstop.cpp @@ -70,12 +70,18 @@ using namespace RTT; using namespace RTT::os; static os::StartStopManager* initM; +static int os_argc_arg; +static char** os_argv_arg; + int __os_init(int argc, char** argv ) { #ifdef OS_HAVE_MANUAL_CRT DO_GLOBAL_CTORS(); #endif + os_argc_arg = argc; + os_argv_arg = argv; + os::MainThread::Instance(); Logger::log() << Logger::Debug << "MainThread started." << Logger::endl; @@ -102,6 +108,13 @@ int __os_init(int argc, char** argv ) return ret; } +int __os_main_argc(void) { + return os_argc_arg; +} +char** __os_main_argv(void) { + return os_argv_arg; +} + void __os_printFailure(const char* prog) { #ifdef OS_HAVE_IOSTREAM diff --git a/rtt/os/startstop.h b/rtt/os/startstop.h index 2d6c94f..77eb454 100644 --- a/rtt/os/startstop.h +++ b/rtt/os/startstop.h @@ -78,3 +78,14 @@ RTT_API void __os_printException(const char* prog, std::exception& arg); */ RTT_API int __os_checkException(int&, char**); +/** + * Call this function to find out how many arguments were + * passed to the process' main() function. + */ +RTT_API int __os_main_argc(void); + +/** + * Call this function to get the list of arguments of this + * process' main() function. + */ +RTT_API char** __os_main_argv(void); -- 1.7.0.4