资源简介
Linux 下的PC/SC服务,智能卡应用,源码包,用gcc编译
代码片段和文件信息
/*
* Sample program to use PC/SC API.
*
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
*
* Copyright (C) 2003-2011
* Ludovic Rousseau
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not write to the Free Software Foundation Inc.
* 51 Franklin Street Fifth Floor Boston MA 02110-1301 USA.
*
* $Id: pcsc_demo.c 5802 2011-06-22 06:53:46Z rousseau $
*/
#include
#include
#include
#include
#include
#include
#include
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
/* PCSC error message pretty print */
#define PCSC_ERROR(rv text) \
if (rv != SCARD_S_SUCCESS) \
{ \
printf(text “: %s (0x%lX)\n“ pcsc_stringify_error(rv) rv); \
goto end; \
} \
else \
{ \
printf(text “: OK\n\n“); \
}
int main(int argc char *argv[])
{
LONG rv;
SCARDCONTEXT hContext;
DWORD dwReaders;
LPSTR mszReaders = NULL;
char *ptr **readers = NULL;
int nbReaders;
SCARDHANDLE hCard;
DWORD dwActiveProtocol dwReaderLen dwState dwProt dwAtrLen;
BYTE pbAtr[MAX_ATR_SIZE] = ““;
char pbReader[MAX_READERNAME] = ““;
int reader_nb;
unsigned int i;
const SCARD_IO_REQUEST *pioSendPci;
SCARD_IO_REQUEST pioRecvPci;
BYTE pbRecvBuffer[10];
BYTE pbSendBuffer[] = { 0x00 0xA4 0x00 0x00 0x02 0x3F 0x00 };
DWORD dwSendLength dwRecvLength;
printf(“PC/SC sample code\n“);
printf(“V 1.4 2003-2009 Ludovic Rousseau \n“);
printf(“\nTHIS PROGRAM IS NOT DESIGNED AS A TESTING TOOL FOR END USERS!\n“);
printf(“Do NOT use it unless you really know what you do.\n\n“);
rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM NULL NULL &hContext);
if (rv != SCARD_S_SUCCESS)
{
printf(“SCardEstablishContext: Cannot Connect to Resource Manager %lX\n“ rv);
return EXIT_FAILURE;
}
/* Retrieve the available readers list. */
dwReaders = SCARD_AUTOALLOCATE;
rv = SCardListReaders(hContext NULL (LPSTR)&mszReaders &dwReaders);
PCSC_ERROR(rv “SCardListReaders“)
/* Extract readers from the null separated string and get the total
* number of readers */
nbReaders = 0;
ptr = mszReaders;
while (*ptr != ‘\0‘)
{
ptr += strlen(ptr)+1;
nbReaders++;
}
if (nbReaders == 0)
{
printf(“No reader found\n“);
goto end;
}
/* allocate the readers table */
readers = calloc(nbReaders sizeof(char *));
if (NULL == readers)
{
printf(“Not enough memory for readers[
相关资源
- 智能卡一卡一密方法和系统
- 智能卡一卡一密方法
- ISO7816-3智能卡传输协议详尽中文版
- Mac上使用pcsc访问智能卡的xcode工程
- ATR 解析工具
- 模拟POS机程序源码
- PCSC+Mifare2操作工具用户NFC及ACR122
- 智能卡操作,pc/sc模式
- 矿用卡车无人驾驶系统实现方式及效
- 智能卡解码程序V4.0
- ACR122 SDK (PCSC) Sample Codes
- 2019款解码软件v1.0.0.4.exe
- 开源版智能卡操作系统(cos)
- pcsc-lite-1.8.8.tar.bz2
- 算法工具集合 智能卡
- 使用微软PC/SC接口操作智能卡的demo
- 基于RFID技术的智能卡--门禁管理系统
评论
共有 条评论