Loadable filter support for FilterFactory using dlopen/dlsym. Only
[metaproxy-moved-to-github.git] / src / tstdl.cpp
diff --git a/src/tstdl.cpp b/src/tstdl.cpp
new file mode 100644 (file)
index 0000000..4f3eb66
--- /dev/null
@@ -0,0 +1,49 @@
+/* $Id: tstdl.cpp,v 1.1 2005-12-10 09:59:10 adam Exp $
+   Copyright (c) 2005, Index Data.
+
+%LICENSE%
+ */
+
+#include "config.hpp"
+
+#include <stdlib.h>
+#include <iostream>
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+using namespace std;
+
+int main(int argc, char **argv)
+{
+#if HAVE_DLFCN_H
+    if (argc != 3)
+    {
+       cerr << "bad args" << endl << "Usage: tstdl filename symbol" << endl;
+       exit(1);
+    }
+    void *mod = dlopen(argv[1][0] ? argv[1] : 0, RTLD_NOW|RTLD_LOCAL);
+    if (!mod)
+    {
+       cerr << "dlopen failed for file " << argv[1] << 
+           "dlerror=" << dlerror() << endl;
+       exit(1);
+    }
+    void *sym = dlsym(mod, argv[2]);
+    printf("sym=%p\n", sym);
+    dlclose(mod);
+    exit(0);
+#else
+    cerr << "dl lib not enabled or not supported" << endl;
+    exit(1);
+#endif
+
+}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */