pcsc-lite  1.8.8
dyn_hpux.c
1 /*
2  * MUSCLE SmartCard Development ( http://www.linuxnet.com )
3  *
4  * Copyright (C) 2001
5  * David Corcoran <corcoran@linuxnet.com>
6  * Copyright (C) 2002-2010
7  * Ludovic Rousseau <ludovic.rousseau@free.fr>
8  *
9  * $Id: dyn_hpux.c 5047 2010-06-29 14:39:24Z rousseau $
10  */
11 
12 /*
13  * @file
14  * @brief This abstracts dynamic library loading functions and timing.
15  */
16 
17 #include "config.h"
18 #include <string.h>
19 #ifdef HAVE_DL_H
20 #include <dl.h>
21 #include <errno.h>
22 
23 #include "pcsclite.h"
24 #include "debuglog.h"
25 #include "dyn_generic.h"
26 
27 int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
28 {
29 
30  shl_t myHandle;
31 
32  *pvLHandle = 0;
33  myHandle =
34  shl_load(pcLibrary, BIND_IMMEDIATE | BIND_VERBOSE | BIND_NOSTART,
35  0L);
36 
37  if (myHandle == 0)
38  {
39  Log3(PCSC_LOG_ERROR, "%s: %s", pcLibrary, strerror(errno));
40  return SCARD_F_UNKNOWN_ERROR;
41  }
42 
43  *pvLHandle = (void *) myHandle;
44  return SCARD_S_SUCCESS;
45 }
46 
47 int DYN_CloseLibrary(void **pvLHandle)
48 {
49 
50  int rv;
51 
52  rv = shl_unload((shl_t) * pvLHandle);
53  *pvLHandle = 0;
54 
55  if (rv == -1)
56  {
57  Log2(PCSC_LOG_ERROR, "%s", strerror(errno));
58  return SCARD_F_UNKNOWN_ERROR;
59  }
60 
61  return SCARD_S_SUCCESS;
62 }
63 
64 int DYN_GetAddress(void *pvLHandle, void **pvFHandle, const char *pcFunction)
65 {
66 
67  int rv;
68 
69  *pvFHandle = 0;
70  rv = shl_findsym((shl_t *) & pvLHandle, pcFunction, TYPE_PROCEDURE,
71  pvFHandle);
72 
73  if (rv == -1)
74  {
75  Log3(PCSC_LOG_ERROR, "%s: %s", pcFunction, strerror(errno));
77  }
78  else
79  rv = SCARD_S_SUCCESS;
80 
81  return rv;
82 }
83 
84 #endif /* HAVE_DL_H */
85 
This abstracts dynamic library loading functions.
#define SCARD_F_UNKNOWN_ERROR
An internal error has been detected, but the source is unknown.
Definition: pcsclite.h:100
This keeps a list of defines for pcsc-lite.
#define SCARD_S_SUCCESS
error codes from http://msdn.microsoft.com/en-us/library/aa924526.aspx
Definition: pcsclite.h:80
This handles debugging.