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

LONG SCardCancelTransaction ( SCARDHANDLE  hCard  ) 

Deprecated:
This function is not in Microsoft(R) WinSCard API and is deprecated in pcsc-lite API.

Definition at line 1169 of file winscard_clnt.c.

References rxSharedSegment::data, cancel_struct::hCard, _psContextMap::psChannelMap, psContextMap, _psChannelMap::readerName, SCardCheckDaemonAvailability(), SHMClientRead(), SYS_MutexLock(), SYS_MutexUnLock(), and WrapSHMWrite().

{
      LONG rv;
      cancel_struct scCancelStruct;
      sharedSegmentMsg msgStruct;
      int i;
      DWORD dwContextIndex, dwChannelIndex;

      if (SCardCheckDaemonAvailability() != SCARD_S_SUCCESS)
            return SCARD_E_NO_SERVICE;

      /*
       * Make sure this handle has been opened
       */
      rv = SCardGetIndicesFromHandle(hCard, &dwContextIndex, &dwChannelIndex);

      if (rv == -1)
            return SCARD_E_INVALID_HANDLE;

      SYS_MutexLock(psContextMap[dwContextIndex].mMutex);   

      for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
      {
            char *r = psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName;

            /* by default r == NULL */
            if (r && strcmp(r, (readerStates[i])->readerName) == 0)
                  break;
      }

      if (i == PCSCLITE_MAX_READERS_CONTEXTS)
      {
            SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex); 
            return SCARD_E_READER_UNAVAILABLE;
      }

      scCancelStruct.hCard = hCard;

      rv = WrapSHMWrite(SCARD_CANCEL_TRANSACTION, psContextMap[dwContextIndex].dwClientID,
            sizeof(scCancelStruct),
            PCSCLITE_CLIENT_ATTEMPTS, (void *) &scCancelStruct);

      if (rv == -1)
      {
            SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex); 
            return SCARD_E_NO_SERVICE;
      }

      /*
       * Read a message from the server
       */
      rv = SHMClientRead(&msgStruct, psContextMap[dwContextIndex].dwClientID, PCSCLITE_CLIENT_ATTEMPTS);

      memcpy(&scCancelStruct, &msgStruct.data, sizeof(scCancelStruct));

      if (rv == -1)
      {
            SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex); 
            return SCARD_F_COMM_ERROR;
      }

      SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex); 

      return scCancelStruct.rv;
}


Generated by  Doxygen 1.6.0   Back to index