Fixed some minor annoyances with dlsym
- Added missing newline character to "File not found" message - Now properly handles relative file paths
This commit is contained in:
parent
118b002ee8
commit
68beb4b1a3
BIN
plugins/dlsym
BIN
plugins/dlsym
Binary file not shown.
|
@ -5,26 +5,29 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *file=NULL;
|
char *file=NULL;
|
||||||
void *dl= NULL;
|
void *dl= NULL;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
char path[PATH_MAX];
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
printf("Usage: dlsym <file>\n");
|
printf("Usage: dlsym <file>\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
file = argv[1];
|
file = argv[1];
|
||||||
fp = fopen(file, "rb");
|
realpath(file, path);
|
||||||
|
fp = fopen(path, "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
printf("File not found.");
|
printf("File not found.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dl = dlopen(file, RTLD_NOW);
|
dl = dlopen(path, RTLD_NOW);
|
||||||
|
|
||||||
if (dl)
|
if (dl)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user