File: cardtools.c

package info (click to toggle)
muscleframework 1.1.6-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,328 kB
  • ctags: 1,593
  • sloc: ansic: 13,594; sh: 11,523; makefile: 219
file content (60 lines) | stat: -rw-r--r-- 1,993 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/********************************************************************
 *                                                                  *
 * cardtools.c                                                      *
 *                                                                  *
 ********************************************************************
 *                                                                  *
 * Authors:                                                         *
 *   Mario Strasser       <mast@gmx.net>                            *
 *   Martin Sgesser      <m.sagi@bluemail.ch>                      *
 *                                                                  *
 ********************************************************************
 *                                                                  *
 * Cardtools library.                                               *
 *                                                                  *
 * Usefull library for SmartCard-Programs.                          *
 *                                                                  *
 ********************************************************************/


#include <winscard.h>
#include <stdlib.h>
#include <string.h>
#include <musclecard.h>
#include "cardtools.h"


SCARDCONTEXT context;
SCARDHANDLE card;
MSCUChar8 CLA;

int pcsc_init(MSCLPTokenConnection pConnection, int num)
{
  MSCLong32 rv;
  //int i;
  MSCTokenInfo tokenList[20];
  MSCULong32 arrayLength;

  arrayLength = 20;

  rv = MSCListTokens(MSC_LIST_KNOWN, tokenList, &arrayLength);

  if ( (rv != MSC_SUCCESS) || (arrayLength == 0) ) {
    return MSC_INTERNAL_ERROR;
  }

  rv = MSCEstablishConnection( &tokenList[0], SCARD_SHARE_SHARED, 
                               0, 0, pConnection );

  return rv;
}

void pcsc_release(MSCLPTokenConnection pConnection)
{
  MSCLong32 rv;

  /* disconnect from card, ignore result */
  
  rv = MSCReleaseConnection(pConnection, MSC_RESET_TOKEN);

}