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

LONG IFDPowerICC ( PREADER_CONTEXT  rContext,
DWORD  dwAction,
PUCHAR  pucAtr,
PDWORD  pdwAtrLen 
)

Power up/down or reset's an ICC located in the IFD.

Definition at line 318 of file ifdwrapper.c.

References ATRDecodeAtr(), IFDSetCapabilities(), IFDStatusICC(), SCARD_ABSENT, SCARD_E_NOT_TRANSACTED, SCARD_E_READER_UNAVAILABLE, and SCARD_W_REMOVED_CARD.

Referenced by SCardDisconnect(), SCardEndTransaction(), and SCardReconnect().

{
      RESPONSECODE rv;
      short ret;
      SMARTCARD_EXTENSION sSmartCard;
      DWORD dwStatus;
      UCHAR ucValue[1];

#ifndef PCSCLITE_STATIC_DRIVER
      RESPONSECODE(*IFD_power_icc) (DWORD) = NULL;
      RESPONSECODE(*IFDH_power_icc) (DWORD, DWORD, PUCHAR, PDWORD) = NULL;
#endif

      /*
       * Zero out everything
       */
      rv = IFD_SUCCESS;
      dwStatus = 0;
      ucValue[0] = 0;

      /*
       * Check that the card is inserted first
       */
      (void)IFDStatusICC(rContext, &dwStatus, pucAtr, pdwAtrLen);

      if (dwStatus & SCARD_ABSENT)
            return SCARD_W_REMOVED_CARD;
#ifndef PCSCLITE_STATIC_DRIVER
      if (rContext->dwVersion == IFD_HVERSION_1_0)
            IFD_power_icc = rContext->psFunctions.psFunctions_v1.pvfPowerICC;
      else
            IFDH_power_icc = rContext->psFunctions.psFunctions_v2.pvfPowerICC;
#endif

      /* LOCK THIS CODE REGION */
      (void)SYS_MutexLock(rContext->mMutex);

#ifndef PCSCLITE_STATIC_DRIVER
      if (rContext->dwVersion == IFD_HVERSION_1_0)
      {
            ucValue[0] = rContext->dwSlot;
            (void)IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
            rv = (*IFD_power_icc) (dwAction);
      }
      else
      {
            rv = (*IFDH_power_icc) (rContext->dwSlot, dwAction,
                  pucAtr, pdwAtrLen);

            ret = ATRDecodeAtr(&sSmartCard, pucAtr, *pdwAtrLen);
      }
#else
      if (rContext->dwVersion == IFD_HVERSION_1_0)
      {
            ucValue[0] = rContext->dwSlot;
            (void)IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
            rv = IFD_Power_ICC(dwAction);
      }
      else
            rv = IFDHPowerICC(rContext->dwSlot, dwAction, pucAtr, pdwAtrLen);
#endif

      /* END OF LOCKED REGION */
      (void)SYS_MutexUnLock(rContext->mMutex);

      /* use clean values in case of error */
      if (rv != IFD_SUCCESS)
      {
            *pdwAtrLen = 0;
            pucAtr[0] = '\0';

            if (rv == IFD_NO_SUCH_DEVICE)
            {
                  (void)SendHotplugSignal();
                  return SCARD_E_READER_UNAVAILABLE;
            }

            return SCARD_E_NOT_TRANSACTED;
      }

      /*
       * Get the ATR and it's length
       */
      if (rContext->dwVersion == IFD_HVERSION_1_0)
            (void)IFDStatusICC(rContext, &dwStatus, pucAtr, pdwAtrLen);

      return rv;
}


Generated by  Doxygen 1.6.0   Back to index