Date: Monday, April 16, 2007 @ 16:01:28
Author: marc
Path: /cvsroot/carob/libmysequoia/ldtest
Modified: main.cpp (1.7 -> 1.8) orig.c (1.1 -> 1.2) override.c (1.1 ->
1.2) plugin.c (1.1 -> 1.2)
Implemented orig_calling_intercepted. Now returning booleans instead
of strings (paves the way for automation). Better names?
------------+
main.cpp | 31 +++++++++++++++++++++----------
orig.c | 9 +++++++--
override.c | 4 ++--
plugin.c | 11 ++++++++---
4 files changed, 38 insertions(+), 17 deletions(-)
Index: libmysequoia/ldtest/main.cpp
diff -u libmysequoia/ldtest/main.cpp:1.7 libmysequoia/ldtest/main.cpp:1.8
--- libmysequoia/ldtest/main.cpp:1.7 Mon Apr 16 14:37:09 2007
+++ libmysequoia/ldtest/main.cpp Mon Apr 16 16:01:27 2007
@@ -52,20 +52,31 @@
exit (1);
}
- char * (*plugin_function)() = ( char* (*)() ) dlsym(plugin,
"plugin_function");
-
- const char *error = dlerror();
- if (error) {
- std::cerr << "failed to find plugin function: " << error << std::endl;
- exit(2);
- }
-
#ifdef RTLD_DEEPBIND
std::cout << "RTLD_DEEPBIND=" << deepbind << ", " ;
#endif
- std::cout << "RTLD_GLOBAL=" << global ;
+ std::cout << "RTLD_GLOBAL=" << global << " ---> ";
- std::cout << " ---> " << (*plugin_function) () << std::endl;
+
+ const char *functions[2] = { "intercepted", "orig_calling_intercepted" };
+ for (int i = 0; i<2; i++)
+ {
+ std::string funct("plugin_"); funct += functions[i];
+ bool (*plugin_function)() = ( bool (*)() ) dlsym(plugin, funct.c_str());
+
+ const char *error = dlerror();
+ if (error) {
+ std::cerr << "failed to find plugin function: " << error << std::endl;
+ exit(2);
+ }
+
+ std::cout << functions[i] << "() = "
+ << ( (*plugin_function) () ? "INTERCEPTED" : " NOT " )
+ << " " ;
+
+ }
+
+ std::cout << std::endl;
dlclose(plugin);
Index: libmysequoia/ldtest/orig.c
diff -u libmysequoia/ldtest/orig.c:1.1 libmysequoia/ldtest/orig.c:1.2
--- libmysequoia/ldtest/orig.c:1.1 Fri Apr 13 18:07:45 2007
+++ libmysequoia/ldtest/orig.c Mon Apr 16 16:01:27 2007
@@ -1,6 +1,11 @@
-char * my_function()
+int intercepted()
{
- return "ORIG";
+ return 0;
+}
+
+int orig_calling_intercepted()
+{
+ return intercepted();
}
Index: libmysequoia/ldtest/override.c
diff -u libmysequoia/ldtest/override.c:1.1 libmysequoia/ldtest/override.c:1.2
--- libmysequoia/ldtest/override.c:1.1 Fri Apr 13 18:07:45 2007
+++ libmysequoia/ldtest/override.c Mon Apr 16 16:01:27 2007
@@ -1,6 +1,6 @@
-char * my_function()
+int intercepted()
{
- return "OVERRIDE";
+ return 1;
}
Index: libmysequoia/ldtest/plugin.c
diff -u libmysequoia/ldtest/plugin.c:1.1 libmysequoia/ldtest/plugin.c:1.2
--- libmysequoia/ldtest/plugin.c:1.1 Fri Apr 13 18:07:45 2007
+++ libmysequoia/ldtest/plugin.c Mon Apr 16 16:01:27 2007
@@ -1,10 +1,15 @@
-char * my_function();
+int intercepted();
+int orig_calling_intercepted();
-char *plugin_function()
+int plugin_intercepted()
{
- return my_function();
+ return intercepted();
}
+int plugin_orig_calling_intercepted()
+{
+ return orig_calling_intercepted();
+}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits