~ubuntu-branches/ubuntu/jaunty/pcsc-lite/jaunty-security

« back to all changes in this revision

Viewing changes to src/dyn_win32.c

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Rousseau
  • Date: 2005-11-27 18:04:59 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051127180459-qrex2gzpq9d8jexd
Tags: 1.2.9-beta9-1
* New upstream version
* debian/compat: change from 3 to 4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * MUSCLE SmartCard Development ( http://www.linuxnet.com )
 
3
 *
 
4
 * Copyright (C) 1999
 
5
 *  David Corcoran <corcoran@linuxnet.com>
 
6
 *
 
7
 * $Id: dyn_win32.c,v 1.7 2005-11-27 17:02:43 rousseau Exp $
 
8
 */
 
9
 
 
10
/**
 
11
 * @file
 
12
 * @brief This abstracts dynamic library loading functions and timing.
 
13
 */
 
14
 
 
15
#include "config.h"
 
16
#ifdef WIN32
 
17
#include <string.h>
 
18
 
 
19
#include "windows.h"
 
20
#include <winscard.h>
 
21
#include "dyn_generic.h"
 
22
#include "debuglog.h"
 
23
 
 
24
int DYN_LoadLibrary(void **pvLHandle, char *pcLibrary)
 
25
{
 
26
        *pvLHandle = NULL;
 
27
        *pvLHandle = LoadLibrary(pcLibrary);
 
28
 
 
29
        if (*pvLHandle == NULL)
 
30
        {
 
31
#if 0
 
32
                Log2(PCSC_LOG_ERROR, "DYN_LoadLibrary: dlerror() reports %s", dlerror());
 
33
#endif
 
34
                return SCARD_F_UNKNOWN_ERROR;
 
35
        }
 
36
 
 
37
        return SCARD_S_SUCCESS;
 
38
}
 
39
 
 
40
int DYN_CloseLibrary(void **pvLHandle)
 
41
{
 
42
        int ret;
 
43
 
 
44
        ret = FreeLibrary(*pvLHandle);
 
45
        *pvLHandle = NULL;
 
46
 
 
47
        /* If the function fails, the return value is zero. To get extended error
 
48
         * information, call GetLastError. */
 
49
        if (ret == 0)
 
50
        {
 
51
#if 0
 
52
                Log2(PCSC_LOG_ERROR, "DYN_CloseLibrary: dlerror() reports %s", dlerror());
 
53
#endif
 
54
                return SCARD_F_UNKNOWN_ERROR;
 
55
        }
 
56
 
 
57
        return SCARD_S_SUCCESS;
 
58
}
 
59
 
 
60
int DYN_GetAddress(void *pvLHandle, void **pvFHandle, char *pcFunction)
 
61
{
 
62
        int rv;
 
63
        char *pcFunctionName;
 
64
 
 
65
        /*
 
66
         * Zero out everything 
 
67
         */
 
68
        rv = 0;
 
69
        pcFunctionName = NULL;
 
70
 
 
71
        pcFunctionName = pcFunction;
 
72
 
 
73
        *pvFHandle = NULL;
 
74
        *pvFHandle = GetProcAddress(pvLHandle, pcFunctionName);
 
75
 
 
76
        if (*pvFHandle == NULL)
 
77
        {
 
78
#if 0
 
79
                Log2(PCSC_LOG_ERROR, "DYN_GetAddress: dlerror() reports %s", dlerror());
 
80
#endif
 
81
                rv = SCARD_F_UNKNOWN_ERROR;
 
82
        }
 
83
        else
 
84
                rv = SCARD_S_SUCCESS;
 
85
 
 
86
        return rv;
 
87
}
 
88
 
 
89
#endif  /* WIN32 */
 
90