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

LONG SCardCancel ( SCARDCONTEXT  hContext )

This function cancels all pending blocking requests on the SCardGetStatusChange() function.

Parameters:
[in]hContextConnection context to the PC/SC Resource Manager.
Returns:
Error code.
Return values:
SCARD_S_SUCCESSSuccessful (SCARD_S_SUCCESS)
SCARD_E_INVALID_HANDLEInvalid hContext handle (SCARD_E_INVALID_HANDLE)
SCARD_E_NO_SERVICEServer is not running (SCARD_E_NO_SERVICE)
SCARD_F_COMM_ERRORAn internal communications error has been detected (SCARD_F_COMM_ERROR)
 SCARDCONTEXT hContext;
 DWORD cReaders;
 SCARD_READERSTATE rgReaderStates;
 LONG rv;
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 rgReaderStates.szReader = strdup("Reader X");
 rgReaderStates.dwCurrentState = SCARD_STATE_EMPTY;
 ...
 / * Spawn off thread for following function * /
 ...
 rv = SCardGetStatusChange(hContext, 0, rgReaderStates, cReaders);
 rv = SCardCancel(hContext);

Definition at line 3250 of file winscard_clnt.c.

References ClientCloseSession(), ClientSetupSession(), MessageReceive(), MessageSendWithHeader(), SCARD_CANCEL, SCARD_E_INVALID_HANDLE, SCARD_E_NO_SERVICE, SCARD_S_SUCCESS, and SCardGetContext().

{
      SCONTEXTMAP * currentContextMap;
      LONG rv = SCARD_S_SUCCESS;
      uint32_t dwClientID = 0;
      struct cancel_struct scCancelStruct;

      PROFILE_START
      API_TRACE_IN("%ld", hContext)

      /*
       * Make sure this context has been opened
       */
      currentContextMap = SCardGetContext(hContext);
      if (NULL == currentContextMap)
      {
            rv = SCARD_E_INVALID_HANDLE;
            goto error;
      }

      if (! currentContextMap->cancellable)
      {
            rv = SCARD_S_SUCCESS;
            goto error;
      }

      /* create a new connection to the server */
      if (ClientSetupSession(&dwClientID) != 0)
      {
            rv = SCARD_E_NO_SERVICE;
            goto error;
      }

      scCancelStruct.hContext = hContext;
      scCancelStruct.rv = SCARD_S_SUCCESS;

      rv = MessageSendWithHeader(SCARD_CANCEL, dwClientID,
            sizeof(scCancelStruct), (void *) &scCancelStruct);

      if (rv != SCARD_S_SUCCESS)
            goto end;

      /*
       * Read a message from the server
       */
      rv = MessageReceive(&scCancelStruct, sizeof(scCancelStruct), dwClientID);

      if (rv != SCARD_S_SUCCESS)
            goto end;

      rv = scCancelStruct.rv;
end:
      ClientCloseSession(dwClientID);

error:
      PROFILE_END(rv)
      API_TRACE_OUT("")

      return rv;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index