--- sourceforge.net/trunk/rdesktop/scard.c 2006/11/01 21:23:08 1311 +++ sourceforge.net/trunk/rdesktop/scard.c 2006/11/01 22:46:05 1316 @@ -1,9 +1,22 @@ -/************************************/ -/* Smart Card support for RDesktop. */ -/* Copyright (C) by Alexi Volkov */ -/* e-mail: alexi@myrealbox.com */ -/* ICQ: 264679502 */ -/************************************/ +/* + rdesktop: A Remote Desktop Protocol client. + Smart Card support + Copyright (C) Alexi Volkov 2006 + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ #include #include "rdesktop.h" @@ -797,7 +810,7 @@ (MYPCSC_DWORD) dwPreferredProtocol, &myHCard, &dwActiveProtocol); hCard = scHandleToServer(myHCard); #ifdef WITH_SCARD_DEBUG - printf("[RECEIVED HCARD 0x%016lx]\n", myHCard); + printf("[RECEIVED HCARD 0x%016lx]\n", (unsigned long) myHCard); printf("[MANGLED HCARD 0x%08x]\n", hCard); #endif if (rv != SCARD_S_SUCCESS) @@ -878,7 +891,7 @@ printf("[INIT = 0x%.8x]\n", (unsigned int) dwInitialization); printf("[hContext = 0x%.8x]\n", (unsigned int) hContext); printf("[hCard = 0x%.8x]\n", (unsigned int) hCard); - printf("[myHCard = 0x%016lx]\n", myHCard); + printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard); #endif rv = SCardReconnect(myHCard, (MYPCSC_DWORD) dwShareMode, (MYPCSC_DWORD) dwPreferredProtocol, (MYPCSC_DWORD) dwInitialization, &dwActiveProtocol); @@ -1359,7 +1372,7 @@ myHCard = scHandleToMyPCSC(hCard); #ifdef WITH_SCARD_DEBUG printf("[hCard = 0x%.8x]\n", (unsigned int) hCard); - printf("[myHCard = 0x%016lx]\n", myHCard); + printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard); #endif rv = SCardBeginTransaction(myHCard); #ifdef WITH_SCARD_DEBUG @@ -1387,7 +1400,7 @@ myHCard = scHandleToMyPCSC(hCard); #ifdef WITH_SCARD_DEBUG printf("[hCard = 0x%.8x]\n", (unsigned int) hCard); - printf("[myHCard = 0x%016lx]\n", myHCard); + printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard); printf("[dwDisposition = 0x%.8x]\n", (unsigned int) dwDisposition); #endif rv = SCardEndTransaction(myHCard, (MYPCSC_DWORD) dwDisposition); @@ -1544,7 +1557,7 @@ printf("[SEND LEN = %d]\n", (unsigned int) cbSendLength); printf("[RECV LEN = %d]\n", (unsigned int) cbRecvLength); printf("[hCard = 0x%.8x]\n", (unsigned int) hCard); - printf("[myHCard = 0x%016lx]\n", myHCard); + printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard); printf("[pioSendPci]\n"); if (pioSendPci == NULL) printf("NULL\n"); @@ -1661,7 +1674,7 @@ myHCard = scHandleToMyPCSC(hCard); #ifdef WITH_SCARD_DEBUG printf("[hCard 0x%.8x]\n", (unsigned int) hCard); - printf("[myHCard 0x%016lx]\n", myHCard); + printf("[myHCard 0x%016lx]\n", (unsigned long) myHCard); printf("[dwReaderLen %d]\n", (unsigned int) dwReaderLen); printf("[dwAtrLen %d]\n", (unsigned int) dwAtrLen); #endif @@ -2145,20 +2158,17 @@ printf("---> Calling SCardControl\n"); #endif -#ifdef WITH_PCSC120 sc_nBytesReturned = nBytesReturned; myHCard = scHandleToMyPCSC(hCard); +#ifdef WITH_PCSC120 rv = SCardControl(myHCard, pInBuffer, (MYPCSC_DWORD) nInBufferSize, pOutBuffer, &sc_nBytesReturned); - nBytesReturned = sc_nBytesReturned; #else - sc_nBytesReturned = nBytesReturned; - myHCard = scHandleToMyPCSC(hCard); rv = SCardControl(myHCard, (MYPCSC_DWORD) dwControlCode, pInBuffer, (MYPCSC_DWORD) nInBufferSize, pOutBuffer, (MYPCSC_DWORD) nOutBufferRealSize, &sc_nBytesReturned); - nBytesReturned = sc_nBytesReturned; #endif + nBytesReturned = sc_nBytesReturned; #ifdef WITH_SCARD_DEBUG if (rv != SCARD_S_SUCCESS)