[Pcsclite-cvs-commit] r5546 - /trunk/PCSC/src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Jan 25 15:08:28 UTC 2011
Author: rousseau
Date: Tue Jan 25 15:08:19 2011
New Revision: 5546
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5546
Log:
Add API tracing with arguments display
Modified:
trunk/PCSC/src/winscard_clnt.c
Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=5546&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Jan 25 15:08:19 2011
@@ -111,6 +111,40 @@
static char sharing_shall_block = TRUE;
+#define COLOR_RED "\33[01;31m"
+#define COLOR_GREEN "\33[32m"
+#define COLOR_BLUE "\33[34m"
+#define COLOR_MAGENTA "\33[35m"
+#define COLOR_NORMAL "\33[0m"
+
+#undef DO_TRACE
+#ifdef DO_TRACE
+
+#include <stdio.h>
+#include <stdarg.h>
+
+static void trace(const char *func, const char direction, const char *fmt, ...)
+{
+ va_list args;
+
+ printf(COLOR_GREEN "%c " COLOR_BLUE "[%lX] " COLOR_GREEN "%s ",
+ direction, pthread_self(), func);
+
+ printf(COLOR_MAGENTA);
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+
+ printf(COLOR_NORMAL "\n");
+}
+
+#define API_TRACE_IN(...) trace(__FUNCTION__, '<', __VA_ARGS__);
+#define API_TRACE_OUT(...) trace(__FUNCTION__, '>', __VA_ARGS__);
+#else
+#define API_TRACE_IN(...)
+#define API_TRACE_OUT(...)
+#endif
+
#undef DO_PROFILE
#ifdef DO_PROFILE
@@ -385,6 +419,7 @@
int daemon_launched = FALSE;
int retries = 0;
+ API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
PROFILE_START
again:
@@ -474,6 +509,7 @@
end:
PROFILE_END(rv)
+ API_TRACE_OUT("%ld", *phContext)
return rv;
}
@@ -662,6 +698,7 @@
struct release_struct scReleaseStruct;
SCONTEXTMAP * currentContextMap;
+ API_TRACE_IN("%ld", hContext)
PROFILE_START
CHECK_SAME_PROCESS
@@ -718,6 +755,7 @@
(void)SCardUnlockThread();
PROFILE_END(rv)
+ API_TRACE_OUT("")
return rv;
}
@@ -787,6 +825,7 @@
SCONTEXTMAP * currentContextMap;
PROFILE_START
+ API_TRACE_IN("%d %s %d %d", hContext, szReader, dwShareMode, dwPreferredProtocols)
/*
* Check for NULL parameters
@@ -865,6 +904,7 @@
(void)pthread_mutex_unlock(currentContextMap->mMutex);
PROFILE_END(rv)
+ API_TRACE_OUT("%d", *pdwActiveProtocol)
return rv;
}
@@ -1059,6 +1099,7 @@
CHANNEL_MAP * pChannelMap;
PROFILE_START
+ API_TRACE_IN("%d %d", hCard, dwDisposition)
CHECK_SAME_PROCESS
@@ -1114,6 +1155,7 @@
error:
PROFILE_END(rv)
+ API_TRACE_OUT("")
return rv;
}
@@ -1724,6 +1766,14 @@
LONG rv = SCARD_S_SUCCESS;
PROFILE_START
+ API_TRACE_IN("%d %d %d", hContext, dwTimeout, cReaders)
+#ifdef DO_TRACE
+ for (j=0; j<cReaders; j++)
+ {
+ API_TRACE_IN("[%d] %s %X %X", j, rgReaderStates[j].szReader,
+ rgReaderStates[j].dwCurrentState, rgReaderStates[j].dwEventState)
+ }
+#endif
if ((rgReaderStates == NULL && cReaders > 0)
|| (cReaders > PCSCLITE_MAX_READERS_CONTEXTS))
@@ -2174,6 +2224,13 @@
error:
PROFILE_END(rv)
+#ifdef DO_TRACE
+ for (j=0; j<cReaders; j++)
+ {
+ API_TRACE_OUT("[%d] %s %X %X", j, rgReaderStates[j].szReader,
+ rgReaderStates[j].dwCurrentState, rgReaderStates[j].dwEventState)
+ }
+#endif
return rv;
}
@@ -2852,6 +2909,7 @@
(void)mszGroups;
PROFILE_START
+ API_TRACE_IN("%ld", hContext)
/*
* Check for NULL parameters
@@ -2950,6 +3008,7 @@
(void)pthread_mutex_unlock(currentContextMap->mMutex);
PROFILE_END(rv)
+ API_TRACE_OUT("%d", *pcchReaders)
return rv;
}
@@ -3149,6 +3208,7 @@
struct cancel_struct scCancelStruct;
PROFILE_START
+ API_TRACE_IN("%d", hContext)
/*
* Make sure this context has been opened
@@ -3190,6 +3250,7 @@
error:
PROFILE_END(rv)
+ API_TRACE_OUT("")
return rv;
}
@@ -3223,6 +3284,7 @@
SCONTEXTMAP * currentContextMap;
PROFILE_START
+ API_TRACE_IN("%ld", hContext)
rv = SCARD_S_SUCCESS;
@@ -3237,6 +3299,7 @@
rv = SCARD_E_INVALID_HANDLE;
PROFILE_END(rv)
+ API_TRACE_OUT("")
return rv;
}
More information about the Pcsclite-cvs-commit
mailing list