Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

LONG SCardBeginTransaction ( SCARDHANDLE  hCard  ) 

This function establishes a temporary exclusive access mode for doing a series of commands or transaction.

You might want to use this when you are selecting a few files and then writing a large file so you can make sure that another application will not change the current file. If another application has a lock on this reader or this application is in SCARD_SHARE_EXCLUSIVE there will be no action taken.

Parameters:
[in] hCard Connection made from SCardConnect.
Returns:
Error code.
Return values:
SCARD_S_SUCCESS Successful.
SCARD_E_INVALID_HANDLE Invalid hCard handle.
SCARD_E_SHARING_VIOLATION Someone else has exclusive rights.
SCARD_E_READER_UNAVAILABLE The reader has been removed.
Test:
 SCARDCONTEXT hContext;
 SCARDHANDLE hCard;
 DWORD dwActiveProtocol;
 LONG rv;
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol);
 rv = SCardBeginTransaction(hCard);
 ...
 / * Do some transmit commands * /

Definition at line 847 of file winscard.c.

References rxSharedSegment::data, begin_struct::hCard, _psContextMap::psChannelMap, psContextMap, _psChannelMap::readerName, begin_struct::rv, SCardCheckDaemonAvailability(), SCardLockThread(), SCardUnlockThread(), SHMClientRead(), SYS_MutexLock(), SYS_MutexUnLock(), SYS_USleep(), and WrapSHMWrite().

Referenced by MSGFunctionDemarshall().

{
      LONG rv;
      PREADER_CONTEXT rContext;

      if (hCard == 0)
            return SCARD_E_INVALID_HANDLE;

      rv = RFReaderInfoById(hCard, &rContext);

      /*
       * Cannot find the hCard in this context
       */
      if (rv != SCARD_S_SUCCESS)
            return rv;

      /*
       * Make sure the reader is working properly
       */
      rv = RFCheckReaderStatus(rContext);
      if (rv != SCARD_S_SUCCESS)
            return rv;

      rv = RFFindReaderHandle(hCard);
      if (rv != SCARD_S_SUCCESS)
            return rv;

      /*
       * Make sure some event has not occurred
       */
      if ((rv = RFCheckReaderEventState(rContext, hCard)) != SCARD_S_SUCCESS)
            return rv;

      rv = RFLockSharing(hCard);

      Log2(PCSC_LOG_DEBUG, "Status: %d.", rv);

      return rv;
}


Generated by  Doxygen 1.6.0   Back to index