Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
int myopenimage(const char *in)
|
||||
{
|
||||
static int handle=0;
|
||||
fprintf(stderr, "internal openimage opens %s...\n", in);
|
||||
return handle++;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
void *imglib;
|
||||
int (*extopenimage)(const char *);
|
||||
int imghandle;
|
||||
|
||||
imglib = dlopen("./fakeimglib.so", RTLD_LAZY);
|
||||
if ( imglib != NULL ) {
|
||||
/* extopenimage = (int (*)(const char *))dlsym(imglib,...)
|
||||
"man dlopen" says that C99 standard leaves casting from
|
||||
"void *" to a function pointer undefined. The following is the
|
||||
POSIX.1-2003 workaround found in man */
|
||||
*(void **)(&extopenimage) = dlsym(imglib, "openimage");
|
||||
/* the following works with gcc, gives no warning even with
|
||||
-Wall -std=c99 -pedantic options... :D */
|
||||
/* extopenimage = dlsym(imglib, "openimage"); */
|
||||
imghandle = extopenimage("fake.img");
|
||||
} else {
|
||||
imghandle = myopenimage("fake.img");
|
||||
}
|
||||
printf("opened with handle %d\n", imghandle);
|
||||
/* ... */
|
||||
if (imglib != NULL ) dlclose(imglib);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#include <stdio.h>
|
||||
/* gcc -shared -nostartfiles fakeimglib.c -o fakeimglib.so */
|
||||
int openimage(const char *s)
|
||||
{
|
||||
static int handle = 100;
|
||||
fprintf(stderr, "opening %s\n", s);
|
||||
return handle++;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue