Rizin
unix-like reverse engineering framework and cli tools
dl.c File Reference
#include "uv.h"
#include "internal.h"
#include <dlfcn.h>
#include <errno.h>
#include <string.h>
#include <locale.h>

Go to the source code of this file.

Functions

static int uv__dlerror (uv_lib_t *lib)
 
int uv_dlopen (const char *filename, uv_lib_t *lib)
 
void uv_dlclose (uv_lib_t *lib)
 
int uv_dlsym (uv_lib_t *lib, const char *name, void **ptr)
 
const char * uv_dlerror (const uv_lib_t *lib)
 

Function Documentation

◆ uv__dlerror()

static int uv__dlerror ( uv_lib_t lib)
static

Definition at line 65 of file dl.c.

65  {
66  const char* errmsg;
67 
68  uv__free(lib->errmsg);
69 
70  errmsg = dlerror();
71 
72  if (errmsg) {
73  lib->errmsg = uv__strdup(errmsg);
74  return -1;
75  }
76  else {
77  lib->errmsg = NULL;
78  return 0;
79  }
80 }
#define NULL
Definition: cris-opc.c:27
char * errmsg
Definition: unix.h:220
char * uv__strdup(const char *s)
Definition: uv-common.c:55
void uv__free(void *ptr)
Definition: uv-common.c:81

References uv_lib_t::errmsg, NULL, uv__free(), and uv__strdup().

Referenced by uv_dlopen(), and uv_dlsym().

◆ uv_dlclose()

void uv_dlclose ( uv_lib_t lib)

Definition at line 41 of file dl.c.

41  {
42  uv__free(lib->errmsg);
43  lib->errmsg = NULL;
44 
45  if (lib->handle) {
46  /* Ignore errors. No good way to signal them without leaking memory. */
47  dlclose(lib->handle);
48  lib->handle = NULL;
49  }
50 }
void * handle
Definition: unix.h:219

◆ uv_dlerror()

const char* uv_dlerror ( const uv_lib_t lib)

Definition at line 60 of file dl.c.

60  {
61  return lib->errmsg ? lib->errmsg : "no error";
62 }

◆ uv_dlopen()

int uv_dlopen ( const char *  filename,
uv_lib_t lib 
)

Definition at line 33 of file dl.c.

33  {
34  dlerror(); /* Reset error status. */
35  lib->errmsg = NULL;
36  lib->handle = dlopen(filename, RTLD_LAZY);
37  return lib->handle ? 0 : uv__dlerror(lib);
38 }
const char * filename
Definition: ioapi.h:137
static int uv__dlerror(uv_lib_t *lib)
Definition: dl.c:65

◆ uv_dlsym()

int uv_dlsym ( uv_lib_t lib,
const char *  name,
void **  ptr 
)

Definition at line 53 of file dl.c.

53  {
54  dlerror(); /* Reset error status. */
55  *ptr = dlsym(lib->handle, name);
56  return uv__dlerror(lib);
57 }
Definition: z80asm.h:102