/[rdesktop]/sourceforge.net/trunk/rdesktop/scard.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/scard.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1309 by stargo, Wed Nov 1 20:52:01 2006 UTC revision 1316 by stargo, Wed Nov 1 22:46:05 2006 UTC
# Line 1  Line 1 
1  /************************************/  /*
2  /* Smart Card support for RDesktop. */     rdesktop: A Remote Desktop Protocol client.
3  /* Copyright (C) by Alexi Volkov    */     Smart Card support
4  /* e-mail:  alexi@myrealbox.com     */     Copyright (C) Alexi Volkov <alexi@myrealbox.com> 2006
5  /* ICQ:     264679502               */  
6  /************************************/     This program is free software; you can redistribute it and/or modify
7       it under the terms of the GNU General Public License as published by
8       the Free Software Foundation; either version 2 of the License, or
9       (at your option) any later version.
10    
11       This program is distributed in the hope that it will be useful,
12       but WITHOUT ANY WARRANTY; without even the implied warranty of
13       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14       GNU General Public License for more details.
15    
16       You should have received a copy of the GNU General Public License
17       along with this program; if not, write to the Free Software
18       Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19    */
20    
21  #include <stdio.h>  #include <stdio.h>
22  #include "rdesktop.h"  #include "rdesktop.h"
# Line 13  Line 26 
26  #include <sys/types.h>  #include <sys/types.h>
27  #include <time.h>  #include <time.h>
28  #ifndef MAKE_PROTO  #ifndef MAKE_PROTO
29    #ifdef PCSC_OSX
30    #include <PCSC/pcsclite.h>
31    #include <PCSC/winscard.h>
32    #else
33  #include <pcsclite.h>  #include <pcsclite.h>
34  #include <winscard.h>  #include <winscard.h>
35    #endif /* PCSC_OSX */
36  #include "scard.h"  #include "scard.h"
37    
38  /* variable segment */  /* variable segment */
# Line 792  TS_SCardConnect(STREAM in, STREAM out, B Line 810  TS_SCardConnect(STREAM in, STREAM out, B
810                            (MYPCSC_DWORD) dwPreferredProtocol, &myHCard, &dwActiveProtocol);                            (MYPCSC_DWORD) dwPreferredProtocol, &myHCard, &dwActiveProtocol);
811          hCard = scHandleToServer(myHCard);          hCard = scHandleToServer(myHCard);
812  #ifdef WITH_SCARD_DEBUG  #ifdef WITH_SCARD_DEBUG
813          printf("[RECEIVED HCARD 0x%016lx]\n", myHCard);          printf("[RECEIVED HCARD 0x%016lx]\n", (unsigned long) myHCard);
814          printf("[MANGLED  HCARD 0x%08x]\n", hCard);          printf("[MANGLED  HCARD 0x%08x]\n", hCard);
815  #endif  #endif
816          if (rv != SCARD_S_SUCCESS)          if (rv != SCARD_S_SUCCESS)
# Line 873  TS_SCardReconnect(STREAM in, STREAM out) Line 891  TS_SCardReconnect(STREAM in, STREAM out)
891          printf("[INIT  = 0x%.8x]\n", (unsigned int) dwInitialization);          printf("[INIT  = 0x%.8x]\n", (unsigned int) dwInitialization);
892          printf("[hContext = 0x%.8x]\n", (unsigned int) hContext);          printf("[hContext = 0x%.8x]\n", (unsigned int) hContext);
893          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);
894          printf("[myHCard = 0x%016lx]\n", myHCard);          printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard);
895  #endif  #endif
896          rv = SCardReconnect(myHCard, (MYPCSC_DWORD) dwShareMode, (MYPCSC_DWORD) dwPreferredProtocol,          rv = SCardReconnect(myHCard, (MYPCSC_DWORD) dwShareMode, (MYPCSC_DWORD) dwPreferredProtocol,
897                              (MYPCSC_DWORD) dwInitialization, &dwActiveProtocol);                              (MYPCSC_DWORD) dwInitialization, &dwActiveProtocol);
# Line 1354  TS_SCardBeginTransaction(STREAM in, STRE Line 1372  TS_SCardBeginTransaction(STREAM in, STRE
1372          myHCard = scHandleToMyPCSC(hCard);          myHCard = scHandleToMyPCSC(hCard);
1373  #ifdef WITH_SCARD_DEBUG  #ifdef WITH_SCARD_DEBUG
1374          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);
1375          printf("[myHCard = 0x%016lx]\n", myHCard);          printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard);
1376  #endif  #endif
1377          rv = SCardBeginTransaction(myHCard);          rv = SCardBeginTransaction(myHCard);
1378  #ifdef WITH_SCARD_DEBUG  #ifdef WITH_SCARD_DEBUG
# Line 1382  TS_SCardEndTransaction(STREAM in, STREAM Line 1400  TS_SCardEndTransaction(STREAM in, STREAM
1400          myHCard = scHandleToMyPCSC(hCard);          myHCard = scHandleToMyPCSC(hCard);
1401  #ifdef WITH_SCARD_DEBUG  #ifdef WITH_SCARD_DEBUG
1402          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);
1403          printf("[myHCard = 0x%016lx]\n", myHCard);          printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard);
1404          printf("[dwDisposition = 0x%.8x]\n", (unsigned int) dwDisposition);          printf("[dwDisposition = 0x%.8x]\n", (unsigned int) dwDisposition);
1405  #endif  #endif
1406          rv = SCardEndTransaction(myHCard, (MYPCSC_DWORD) dwDisposition);          rv = SCardEndTransaction(myHCard, (MYPCSC_DWORD) dwDisposition);
# Line 1539  TS_SCardTransmit(STREAM in, STREAM out) Line 1557  TS_SCardTransmit(STREAM in, STREAM out)
1557          printf("[SEND LEN = %d]\n", (unsigned int) cbSendLength);          printf("[SEND LEN = %d]\n", (unsigned int) cbSendLength);
1558          printf("[RECV LEN = %d]\n", (unsigned int) cbRecvLength);          printf("[RECV LEN = %d]\n", (unsigned int) cbRecvLength);
1559          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);          printf("[hCard = 0x%.8x]\n", (unsigned int) hCard);
1560          printf("[myHCard = 0x%016lx]\n", myHCard);          printf("[myHCard = 0x%016lx]\n", (unsigned long) myHCard);
1561          printf("[pioSendPci]\n");          printf("[pioSendPci]\n");
1562          if (pioSendPci == NULL)          if (pioSendPci == NULL)
1563                  printf("NULL\n");                  printf("NULL\n");
# Line 1656  TS_SCardStatus(STREAM in, STREAM out, BO Line 1674  TS_SCardStatus(STREAM in, STREAM out, BO
1674          myHCard = scHandleToMyPCSC(hCard);          myHCard = scHandleToMyPCSC(hCard);
1675  #ifdef WITH_SCARD_DEBUG  #ifdef WITH_SCARD_DEBUG
1676          printf("[hCard 0x%.8x]\n", (unsigned int) hCard);          printf("[hCard 0x%.8x]\n", (unsigned int) hCard);
1677          printf("[myHCard 0x%016lx]\n", myHCard);          printf("[myHCard 0x%016lx]\n", (unsigned long) myHCard);
1678          printf("[dwReaderLen %d]\n", (unsigned int) dwReaderLen);          printf("[dwReaderLen %d]\n", (unsigned int) dwReaderLen);
1679          printf("[dwAtrLen %d]\n", (unsigned int) dwAtrLen);          printf("[dwAtrLen %d]\n", (unsigned int) dwAtrLen);
1680  #endif  #endif
# Line 2079  TS_SCardControl(STREAM in, STREAM out) Line 2097  TS_SCardControl(STREAM in, STREAM out)
2097          MYPCSC_SCARDHANDLE myHCard;          MYPCSC_SCARDHANDLE myHCard;
2098          SERVER_DWORD map[3];          SERVER_DWORD map[3];
2099          SERVER_DWORD dwControlCode;          SERVER_DWORD dwControlCode;
2100          char *pInBuffer, *pOutBuffer;          unsigned char *pInBuffer, *pOutBuffer;
2101          SERVER_DWORD nInBufferSize, nOutBufferSize, nOutBufferRealSize, nBytesReturned;          SERVER_DWORD nInBufferSize, nOutBufferSize, nOutBufferRealSize, nBytesReturned;
2102          MYPCSC_DWORD sc_nBytesReturned;          MYPCSC_DWORD sc_nBytesReturned;
2103          PMEM_HANDLE lcHandle = NULL;          PMEM_HANDLE lcHandle = NULL;
# Line 2140  TS_SCardControl(STREAM in, STREAM out) Line 2158  TS_SCardControl(STREAM in, STREAM out)
2158          printf("---> Calling SCardControl\n");          printf("---> Calling SCardControl\n");
2159  #endif  #endif
2160    
 #ifdef WITH_PCSC120  
2161          sc_nBytesReturned = nBytesReturned;          sc_nBytesReturned = nBytesReturned;
2162          myHCard = scHandleToMyPCSC(hCard);          myHCard = scHandleToMyPCSC(hCard);
2163    #ifdef WITH_PCSC120
2164          rv = SCardControl(myHCard, pInBuffer, (MYPCSC_DWORD) nInBufferSize, pOutBuffer,          rv = SCardControl(myHCard, pInBuffer, (MYPCSC_DWORD) nInBufferSize, pOutBuffer,
2165                            &sc_nBytesReturned);                            &sc_nBytesReturned);
         nBytesReturned = sc_nBytesReturned;  
2166  #else  #else
         sc_nBytesReturned = nBytesReturned;  
         myHCard = scHandleToMyPCSC(hCard);  
2167          rv = SCardControl(myHCard, (MYPCSC_DWORD) dwControlCode, pInBuffer,          rv = SCardControl(myHCard, (MYPCSC_DWORD) dwControlCode, pInBuffer,
2168                            (MYPCSC_DWORD) nInBufferSize, pOutBuffer,                            (MYPCSC_DWORD) nInBufferSize, pOutBuffer,
2169                            (MYPCSC_DWORD) nOutBufferRealSize, &sc_nBytesReturned);                            (MYPCSC_DWORD) nOutBufferRealSize, &sc_nBytesReturned);
         nBytesReturned = sc_nBytesReturned;  
2170  #endif  #endif
2171            nBytesReturned = sc_nBytesReturned;
2172    
2173  #ifdef WITH_SCARD_DEBUG  #ifdef WITH_SCARD_DEBUG
2174          if (rv != SCARD_S_SUCCESS)          if (rv != SCARD_S_SUCCESS)

Legend:
Removed from v.1309  
changed lines
  Added in v.1316

  ViewVC Help
Powered by ViewVC 1.1.26