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

LONG SCardListReaderGroups ( SCARDCONTEXT  hContext,
LPTSTR  mszGroups,
LPDWORD  pcchGroups 
)

This function returns a list of currently available reader groups on the system. mszGroups is a pointer to a character string that is allocated by the application. If the application sends mszGroups as NULL then this function will return the size of the buffer needed to allocate in pcchGroups.

The group names is a multi-string and separated by a nul character ('\0') and ended by a double nul character. "SCard$DefaultReaders\\0Group 2\\0\\0".

Parameters:
[in] hContext Connection context to the PC/SC Resource Manager.
[out] mszGroups List of groups to list readers.
pcchGroups [inout] Size of multi-string buffer including NULL's.
Returns:
Error code.
Return values:
SCARD_S_SUCCESS Successful.
SCARD_E_INVALID_HANDLE Invalid Scope Handle.
SCARD_E_INSUFFICIENT_BUFFER Reader buffer not large enough.
Test:
 SCARDCONTEXT hContext;
 LPTSTR mszGroups;
 DWORD dwGroups;
 LONG rv;
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 rv = SCardListReaderGroups(hContext, NULL, &dwGroups);
 mszGroups = (LPTSTR)malloc(sizeof(char)*dwGroups);
 rv = SCardListReaderGroups(hContext, mszGroups, &dwGroups);

Definition at line 2686 of file winscard_clnt.c.

References psContextMap, SCardCheckDaemonAvailability(), SCardGetContextIndice(), SYS_MutexLock(), and SYS_MutexUnLock().

{
      LONG rv = SCARD_S_SUCCESS;
      DWORD dwContextIndex;

      const char ReaderGroup[] = "SCard$DefaultReaders";
      const int dwGroups = strlen(ReaderGroup) + 2;

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

      /*
       * Make sure this context has been opened
       */
      dwContextIndex = SCardGetContextIndice(hContext);
      if (dwContextIndex == -1)
            return SCARD_E_INVALID_HANDLE;

      SYS_MutexLock(psContextMap[dwContextIndex].mMutex);   

      if (mszGroups)
      {

            if (*pcchGroups < dwGroups)
                  rv = SCARD_E_INSUFFICIENT_BUFFER;
            else
            {
                  memset(mszGroups, 0, dwGroups);
                  memcpy(mszGroups, ReaderGroup, strlen(ReaderGroup));
            }
      }

      *pcchGroups = dwGroups;

      SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex); 
      return rv;
}


Generated by  Doxygen 1.6.0   Back to index