libPCSCv2part10
 All Data Structures Files Functions Variables Macros Modules
Functions
API

Functions

int PCSCv2Part10_find_TLV_property_by_tag_from_buffer (unsigned char *buffer, int length, int property, int *value)
 Find an integer value by tag from TLV buffer. More...
 
int PCSCv2Part10_find_TLV_property_by_tag_from_hcard (SCARDHANDLE hCard, int property, int *value)
 Find a integer value by tag from a PC/SC card handle. More...
 

Detailed Description

The available PC/SC v2 part 10 tags are (from pcsc-lite 1.8.5):

Example of code:

/*
sample.c: example of use of libPCSCv2part10 helper functions
Copyright (C) 2012 Ludovic Rousseau
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* $Id$
*/
#include <stdio.h>
#ifdef __APPLE__
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#else
#include <winscard.h>
#endif
#include "PCSCv2part10.h"
/* PCSC error */
#define PCSC_ERROR_EXIT(rv) \
if (rv != SCARD_S_SUCCESS) \
{ \
printf("Failed at line %d with %s (0x%lX)\n", __LINE__, pcsc_stringify_error(rv), rv); \
goto end; \
}
int main(void)
{
LONG rv;
SCARDCONTEXT hContext;
SCARDHANDLE hCard;
int value, ret = -1;
DWORD dwReaders, dwPref;
char *mszReaders;
rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
PCSC_ERROR_EXIT(rv)
dwReaders = SCARD_AUTOALLOCATE;
rv = SCardListReaders(hContext, NULL, (LPSTR)&mszReaders, &dwReaders);
PCSC_ERROR_EXIT(rv)
/* use first reader */
printf("Using reader: %s\n", mszReaders);
rv = SCardConnect(hContext, mszReaders,
SCARD_SHARE_DIRECT, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
&hCard, &dwPref);
PCSC_ERROR_EXIT(rv)
/* the interesting part is here */
printf("ret: %d\n", ret);
printf("value for PCSCv2_PART10_PROPERTY_wIdVendor: 0x%04X\n", value),
rv = SCardDisconnect(hCard, SCARD_LEAVE_CARD);
PCSC_ERROR_EXIT(rv)
rv = SCardFreeMemory(hContext, mszReaders);
PCSC_ERROR_EXIT(rv)
rv = SCardReleaseContext(hContext);
PCSC_ERROR_EXIT(rv)
end:
return ret;
}

Function Documentation

int PCSCv2Part10_find_TLV_property_by_tag_from_buffer ( unsigned char *  buffer,
int  length,
int  property,
int *  value 
)

Find an integer value by tag from TLV buffer.

Parameters
bufferbuffer received from FEATURE_GET_TLV_PROPERTIES
lengthbuffer length
propertytag searched
[out]valuevalue found
Returns
Error code
Return values
0success
-1not found
-2invalid length in the TLV
int PCSCv2Part10_find_TLV_property_by_tag_from_hcard ( SCARDHANDLE  hCard,
int  property,
int *  value 
)

Find a integer value by tag from a PC/SC card handle.

Parameters
hCardcard handle as returned by SCardConnect()
propertytag searched
[out]valuevalue found
Returns
Error code (see PCSCv2Part10_find_TLV_property_by_tag_from_buffer())