File: ylibrary.cc

package info (click to toggle)
icewm 1.3.8%2Bmod%2B20161220-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 7,160 kB
  • ctags: 5,575
  • sloc: cpp: 48,848; ansic: 1,813; makefile: 1,129; sh: 339; xml: 48
file content (31 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (8)
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
/*
 *  IceWM - Implementation of support for runtime bound shared libraries
 *  Copyright (C) 2002 The Authors of IceWM
 *
 *  Release under terms of the GNU Library General Public License
 */

#include "ylibrary.h"
#include <dlfcn.h>

YSharedLibrary::YSharedLibrary(const char *filename, bool global, bool lazy) {
    fLibrary = ::dlopen(filename, (global ? RTLD_GLOBAL : 0)
                                | (lazy ? RTLD_LAZY : RTLD_NOW));
}
    
YSharedLibrary::~YSharedLibrary() {
    unload();
}

void *YSharedLibrary::getSymbol(const char *symname) {
    return (fLibrary ? dlsym(fLibrary, symname) : 0);
}

const char *YSharedLibrary::getLastError() {
    return dlerror();
}

void YSharedLibrary::unload() {
    if (fLibrary) dlclose(fLibrary);
    fLibrary = 0;
}