Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Vardas Pavarde Grupe VarPav */
- /* Failas: loginas_ld3.c */
- #include <stdio.h>
- #include <stdlib.h>
- #include <dlfcn.h>
- int (*fptr)(const char *s);
- double *pd;
- int main ( int argc, char *argv[] )
- {
- if ( argc != 2 )
- {
- printf( "Naudojimas: %s kelias/iki/failo\n", argv[0] );
- exit(1);
- }
- else
- {
- printf( "(C) 2013 Vardas Pavarde, %s\n", __FILE__ );
- void *dl = dlopen( argv[1], RTLD_LAZY | RTLD_LOCAL );
- if( dl == NULL )
- {
- puts( dlerror() );
- exit(1);
- }
- else
- {
- pd = dlsym( dl, "ld3tst" );
- if( pd == NULL )
- {
- puts( dlerror() );
- exit(1);
- }
- else
- {
- *(void**)(&fptr) = dlsym( dl, "ld3tst" );
- if( fptr == NULL )
- {
- puts( dlerror() );
- exit(1);
- }
- else
- {
- int val = (*fptr)("");
- printf("%i\n", val);
- }
- }
- }
- dlclose( dl );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement