meta_info.cpp
Go to the documentation of this file.
1 // Tell catch_ros about the package we are using it in
2 // Original Author: Max Schwarz <max.schwarz@uni-bonn.de>
3 // Rewritten using dlopen() by Timo Röhling <timo.roehling@fkie.fraunhofer.de>
4 
5 #include <dlfcn.h>
6 
7 namespace catch_ros
8 {
9  namespace meta
10  {
11  const char* packageName()
12  {
13  static const char* package_name = nullptr;
14  if (package_name == nullptr)
15  {
16  void* handle = dlopen(nullptr, RTLD_NOW);
17  if (handle)
18  {
19  const char* const* package_name_ptr = reinterpret_cast<const char* const*>(dlsym(handle, "catch_ros_local_package_name"));
20  if (package_name_ptr)
21  package_name = *package_name_ptr;
22  dlclose(handle);
23  }
24  if (package_name == nullptr)
25  package_name = "UNKNOWN";
26  }
27  return package_name;
28  }
29  }
30 }
const char * packageName()
Definition: meta_info.cpp:11


catch_ros
Author(s): Max Schwarz
autogenerated on Mon Feb 28 2022 22:02:33