Skip to content

Commit

Permalink
Doxygen: add a sample code of multi-string use
Browse files Browse the repository at this point in the history
Add a sample code of how to parse the multi-string returned by
SCardListReaders().
  • Loading branch information
LudovicRousseau committed May 18, 2017
1 parent fd1e32d commit 8edd183
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/winscard_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2800,19 +2800,28 @@ LONG SCardTransmit(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci,
* LPSTR mszReaders;
* DWORD dwReaders;
* LONG rv;
* ...
*
* rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
* rv = SCardListReaders(hContext, NULL, NULL, &dwReaders);
* mszReaders = malloc(sizeof(char)*dwReaders);
* rv = SCardListReaders(hContext, NULL, mszReaders, &dwReaders);
*
* char *p = mszReaders;
* while (*p)
* {
* printf("Reader: %s\n", p);
* p += strlen(p) +1;
* }
* @endcode
*
* or, with auto allocation:
*
* @code
* SCARDCONTEXT hContext;
* LPSTR mszReaders;
* DWORD dwReaders;
* LONG rv;
* ...
*
* rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
* dwReaders = SCARD_AUTOALLOCATE;
* rv = SCardListReaders(hContext, NULL, (LPSTR)&mszReaders, &dwReaders);
Expand Down

0 comments on commit 8edd183

Please sign in to comment.