dyn_hpux.c

00001 /*
00002  * MUSCLE SmartCard Development ( http://www.linuxnet.com )
00003  *
00004  * Copyright (C) 2001
00005  *  David Corcoran <corcoran@linuxnet.com>
00006  * Copyright (C) 2004
00007  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
00008  *
00009  * $Id: dyn_hpux.c 2265 2006-12-03 13:17:42Z rousseau $
00010  */
00011 
00012 /*
00013  * @file
00014  * @brief This abstracts dynamic library loading functions and timing.
00015  */
00016 
00017 #include "config.h"
00018 #include <string.h>
00019 #ifdef HAVE_DL_H
00020 #include <dl.h>
00021 #include <errno.h>
00022 
00023 #include "pcsclite.h"
00024 #include "debug.h"
00025 #include "dyn_generic.h"
00026 
00027 int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
00028 {
00029 
00030     shl_t myHandle;
00031 
00032     *pvLHandle = 0;
00033     myHandle =
00034         shl_load(pcLibrary, BIND_IMMEDIATE | BIND_VERBOSE | BIND_NOSTART,
00035         0L);
00036 
00037     if (myHandle == 0)
00038     {
00039         Log3(PCSC_LOG_ERROR, "%s: %s", pcLibrary, strerror(errno));
00040         return SCARD_F_UNKNOWN_ERROR;
00041     }
00042 
00043     *pvLHandle = (void *) myHandle;
00044     return SCARD_S_SUCCESS;
00045 }
00046 
00047 int DYN_CloseLibrary(void **pvLHandle)
00048 {
00049 
00050     int rv;
00051 
00052     rv = shl_unload((shl_t) * pvLHandle);
00053     *pvLHandle = 0;
00054 
00055     if (rv == -1)
00056     {
00057         Log2(PCSC_LOG_ERROR, "%s", strerror(errno));
00058         return SCARD_F_UNKNOWN_ERROR;
00059     }
00060 
00061     return SCARD_S_SUCCESS;
00062 }
00063 
00064 int DYN_GetAddress(void *pvLHandle, void **pvFHandle, const char *pcFunction)
00065 {
00066 
00067     int rv;
00068 
00069     *pvFHandle = 0;
00070     rv = shl_findsym((shl_t *) & pvLHandle, pcFunction, TYPE_PROCEDURE,
00071         pvFHandle);
00072 
00073     if (rv == -1)
00074     {
00075         Log3(PCSC_LOG_ERROR, "%s: %s", pcFunction, strerror(errno));
00076         rv = SCARD_F_UNKNOWN_ERROR;
00077     }
00078     else
00079         rv = SCARD_S_SUCCESS;
00080 
00081     return rv;
00082 }
00083 
00084 #endif  /* HAVE_DL_H */
00085 

Generated on Mon Aug 17 01:00:08 2009 for pcsc-lite by  doxygen 1.5.9