[Pcsclite-git-commit] [PCSC] 01/03: Doxygen: SCardGetAttrib() pbAttr can be NULL

Ludovic Rousseau rousseau at moszumanska.debian.org
Thu Mar 31 15:44:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository PCSC.

commit 84a9441d52e72e1fbec6aa2b0dd6db27d3f5ce38
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Thu Mar 31 11:42:39 2016 +0200

    Doxygen: SCardGetAttrib() pbAttr can be NULL
    
    If pbAttr is NULL then the correct buffer size is indicated in
    pcbAttrLen.
    
    Also modify the example to use the double call.
---
 src/winscard_clnt.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/winscard_clnt.c b/src/winscard_clnt.c
index 23c9c3e..67fb1a9 100644
--- a/src/winscard_clnt.c
+++ b/src/winscard_clnt.c
@@ -2319,6 +2319,10 @@ end:
  * - \ref SCARD_ATTR_VENDOR_IFD_VERSION
  * - \ref SCARD_ATTR_VENDOR_NAME
  * @param[out] pbAttr Pointer to a buffer that receives the attribute.
+ * If this value is NULL, SCardGetAttrib() ignores the buffer length
+ * supplied in \p pcbAttrLen, writes the length of the buffer that would
+ * have been returned if this parameter had not been NULL to \p pcbAttrLen,
+ * and returns a success code.
  * @param[in,out] pcbAttrLen Length of the \p pbAttr buffer in bytes.
  *
  * @return Error code.
@@ -2340,14 +2344,19 @@ end:
  * SCARDCONTEXT hContext;
  * SCARDHANDLE hCard;
  * DWORD dwActiveProtocol;
- * unsigned char pbAtr[MAX_ATR_SIZE];
- * DWORD dwAtrLen;
+ * unsigned char *pbAttr;
+ * DWORD dwAttrLen;
  * ...
  * rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
  * rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED,
  *          SCARD_PROTOCOL_RAW, &hCard, &dwActiveProtocol);
- * dwAtrLen = sizeof(pbAtr);
- * rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAtr, &dwAtrLen);
+ * rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, NULL, &dwAttrLen);
+ * if (SCARD_S_SUCCESS == rv)
+ * {
+ *     pbAttr = malloc(dwAttrLen);
+ *     rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAttr, &dwAttrLen);
+ *     free(pbAttr);
+ * }
  * @endcode
  *
  * @code

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/PCSC.git



More information about the Pcsclite-cvs-commit mailing list