Coverage Report

Created: 2025-07-12 06:53

/src/opensc/src/common/libscdl.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * libscdl.c: wrappers for dlfcn() interfaces
3
 *
4
 * Copyright (C) 2010  Martin Paljak <martin@martinpaljak.net>
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20
21
#ifdef HAVE_CONFIG_H
22
#include <config.h>
23
#endif
24
25
#include "libscdl.h"
26
27
#ifdef _WIN32
28
#include <windows.h>
29
#include <shlwapi.h>
30
31
void *sc_dlopen(const char *filename)
32
{
33
  DWORD flags = PathIsRelativeA(filename) ? 0 : LOAD_WITH_ALTERED_SEARCH_PATH;
34
  return (void *)LoadLibraryExA(filename, NULL, flags);
35
}
36
37
void *sc_dlsym(void *handle, const char *symbol)
38
{
39
  return GetProcAddress((HMODULE)handle, symbol);
40
}
41
42
const char *sc_dlerror()
43
{
44
  return "LoadLibrary/GetProcAddress failed";
45
}
46
47
int sc_dlclose(void *handle)
48
{
49
  return FreeLibrary((HMODULE)handle);
50
}
51
#else
52
#include <dlfcn.h>
53
void *sc_dlopen(const char *filename)
54
0
{
55
0
  return dlopen(filename, RTLD_LAZY);
56
0
}
57
58
void *sc_dlsym(void *handle, const char *symbol)
59
0
{
60
0
  return dlsym(handle, symbol);
61
0
}
62
63
const char *sc_dlerror(void)
64
0
{
65
0
  return dlerror();
66
0
}
67
68
int sc_dlclose(void *handle)
69
0
{
70
0
  return dlclose(handle);
71
0
}
72
#endif