pcsc-lite  1.8.23
dyn_hpux.c
1 /*
2  * MUSCLE SmartCard Development ( http://pcsclite.alioth.debian.org/pcsclite.html )
3  *
4  * Copyright (C) 2001
5  * David Corcoran <corcoran@musclecard.com>
6  * Copyright (C) 2002-2010
7  * Ludovic Rousseau <ludovic.rousseau@free.fr>
8  *
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12 
13 1. Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright
16  notice, this list of conditions and the following disclaimer in the
17  documentation and/or other materials provided with the distribution.
18 3. The name of the author may not be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * @file
35  * @brief This abstracts dynamic library loading functions and timing.
36  */
37 
38 #include "config.h"
39 #include <string.h>
40 #ifdef HAVE_DL_H
41 #include <dl.h>
42 #include <errno.h>
43 
44 #include "pcsclite.h"
45 #include "debuglog.h"
46 #include "dyn_generic.h"
47 
48 LONG DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
49 {
50 
51  shl_t myHandle;
52 
53  *pvLHandle = 0;
54  myHandle =
55  shl_load(pcLibrary, BIND_IMMEDIATE | BIND_VERBOSE | BIND_NOSTART,
56  0L);
57 
58  if (myHandle == 0)
59  {
60  Log3(PCSC_LOG_ERROR, "%s: %s", pcLibrary, strerror(errno));
61  return SCARD_F_UNKNOWN_ERROR;
62  }
63 
64  *pvLHandle = (void *) myHandle;
65  return SCARD_S_SUCCESS;
66 }
67 
68 LONG DYN_CloseLibrary(void **pvLHandle)
69 {
70 
71  int rv;
72 
73  rv = shl_unload((shl_t) * pvLHandle);
74  *pvLHandle = 0;
75 
76  if (rv == -1)
77  {
78  Log2(PCSC_LOG_ERROR, "%s", strerror(errno));
79  return SCARD_F_UNKNOWN_ERROR;
80  }
81 
82  return SCARD_S_SUCCESS;
83 }
84 
85 LONG DYN_GetAddress(void *pvLHandle, void **pvFHandle, const char *pcFunction,
86  int mayfail)
87 {
88 
89  int rv;
90 
91  *pvFHandle = 0;
92  rv = shl_findsym((shl_t *) & pvLHandle, pcFunction, TYPE_PROCEDURE,
93  pvFHandle);
94 
95  if (rv == -1)
96  {
97  Log3(mayfail ? PCSC_LOG_INFO : PCSC_LOG_ERROR, "%s: %s",
98  pcFunction, strerror(errno));
100  }
101  else
102  rv = SCARD_S_SUCCESS;
103 
104  return rv;
105 }
106 
107 #endif /* HAVE_DL_H */
108 
This abstracts dynamic library loading functions.
#define SCARD_S_SUCCESS
No error was encountered.
Definition: pcsclite.h:107
#define SCARD_F_UNKNOWN_ERROR
An internal error has been detected, but the source is unknown.
Definition: pcsclite.h:147
This keeps a list of defines for pcsc-lite.
This handles debugging.