File: mypy.c

package info (click to toggle)
jpy 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,420 kB
  • sloc: ansic: 8,196; java: 3,617; python: 2,952; xml: 180; makefile: 162; sh: 49; javascript: 29
file content (31 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

typedef int (*mypy_run_fn)(int argc, const char** argv);

int main(int argc, const char** argv) 
{
	void* handle;
	mypy_run_fn mypy_run;

    // This one works
	handle = dlopen("./mypydl.so", RTLD_LAZY | RTLD_GLOBAL);
	// This one not
	//handle = dlopen("./mypydl.so", RTLD_LAZY);
	if (handle == NULL) {
		fprintf(stderr, "mypy: error: %s\n", dlerror());
		return 1;	
	}

	mypy_run = (mypy_run_fn) dlsym(handle, "mypy_run");
	if (mypy_run == NULL) {
		fprintf(stderr, "mypy: error: %s\n", dlerror());
		return 2;	
	}

	mypy_run(argc - 1, argv + 1);

	dlclose(handle);
	return 0;
}