[Pcsclite-cvs-commit] r5157 - /trunk/PCSC/src/hotplug_libhal.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Aug 17 14:48:32 UTC 2010
Author: rousseau
Date: Tue Aug 17 14:48:29 2010
New Revision: 5157
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5157
Log:
HPReadBundleValues(): use the new Info.plist parsing API.
Parsing the CCID Info.plist (159 readers supported) was on a i386
machine 264306 µs and is now 5547 µs => gain x47 or 4600%
Modified:
trunk/PCSC/src/hotplug_libhal.c
Modified: trunk/PCSC/src/hotplug_libhal.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/hotplug_libhal.c?rev=5157&op=diff
==============================================================================
--- trunk/PCSC/src/hotplug_libhal.c (original)
+++ trunk/PCSC/src/hotplug_libhal.c Tue Aug 17 14:48:29 2010
@@ -101,7 +101,6 @@
struct dirent *currFP = NULL;
char fullPath[FILENAME_MAX];
char fullLibPath[FILENAME_MAX];
- char keyValue[TOKEN_MAX_VALUE_SIZE];
int listCount = 0;
hpDir = opendir(PCSCLITE_HP_DROPDIR);
@@ -122,11 +121,25 @@
}
driverSize = DRIVER_TRACKER_SIZE_STEP;
+#define GET_KEY(key, values) \
+ rv = LTPBundleFindValueWithKey(&plist, key, values); \
+ if (rv) \
+ { \
+ Log2(PCSC_LOG_ERROR, "Value/Key not defined for " key " in %s", \
+ fullPath); \
+ continue; \
+ }
+
while ((currFP = readdir(hpDir)) != 0)
{
if (strstr(currFP->d_name, ".bundle") != 0)
{
- int alias = 0;
+ unsigned int alias;
+ list_t plist, *values;
+ list_t *manuIDs, *productIDs, *readerNames;
+ char *CFBundleName;
+ char *libraryPath;
+ int ifdCapabilities;
/*
* The bundle exists - let's form a full path name and get the
@@ -136,66 +149,55 @@
PCSCLITE_HP_DROPDIR, currFP->d_name);
fullPath[sizeof(fullPath) - 1] = '\0';
+ rv = bundleParse(fullPath, &plist);
+ if (rv)
+ continue;
+
+ /* get CFBundleExecutable */
+ GET_KEY(PCSCLITE_HP_LIBRKEY_NAME, &values)
+ libraryPath = list_get_at(values, 0);
+ (void)snprintf(fullLibPath, sizeof(fullLibPath),
+ "%s/%s/Contents/%s/%s",
+ PCSCLITE_HP_DROPDIR, currFP->d_name, PCSC_ARCH,
+ libraryPath);
+ fullLibPath[sizeof(fullLibPath) - 1] = '\0';
+
+ /* Get ifdCapabilities */
+ GET_KEY(PCSCLITE_HP_CPCTKEY_NAME, &values)
+ ifdCapabilities = strtol(list_get_at(values, 0), NULL, 16);
+
+ GET_KEY(PCSCLITE_HP_MANUKEY_NAME, &manuIDs)
+ GET_KEY(PCSCLITE_HP_PRODKEY_NAME, &productIDs)
+ GET_KEY(PCSCLITE_HP_NAMEKEY_NAME, &readerNames)
+
+ /* Get CFBundleName */
+ GET_KEY(PCSCLITE_HP_CFBUNDLE_NAME, &values)
+ CFBundleName = list_get_at(values, 0);
+
/* while we find a nth ifdVendorID in Info.plist */
- while (LTPBundleFindValueWithKey(fullPath, PCSCLITE_HP_MANUKEY_NAME,
- keyValue, alias) == 0)
+ for (alias=0; alias<list_size(manuIDs); alias++)
{
+ char *value;
+
+ /* variables entries */
+ value = list_get_at(manuIDs, alias);
+ driverTracker[listCount].manuID = strtol(value, NULL, 16);
+
+ value = list_get_at(productIDs, alias);
+ driverTracker[listCount].productID = strtol(value, NULL, 16);
+
+ driverTracker[listCount].readerName = list_get_at(readerNames, alias);
+
+ /* constant entries for a same driver */
driverTracker[listCount].bundleName = strdup(currFP->d_name);
-
- /* Get ifdVendorID */
- rv = LTPBundleFindValueWithKey(fullPath,
- PCSCLITE_HP_MANUKEY_NAME, keyValue, alias);
- if (0 == rv)
- driverTracker[listCount].manuID = strtol(keyValue, NULL, 16);
-
- /* get ifdProductID */
- rv = LTPBundleFindValueWithKey(fullPath,
- PCSCLITE_HP_PRODKEY_NAME, keyValue, alias);
- if (0 == rv)
- driverTracker[listCount].productID =
- strtol(keyValue, NULL, 16);
-
- /* get ifdFriendlyName */
- rv = LTPBundleFindValueWithKey(fullPath,
- PCSCLITE_HP_NAMEKEY_NAME, keyValue, alias);
- if (0 == rv)
- driverTracker[listCount].readerName = strdup(keyValue);
-
- /* get CFBundleExecutable */
- rv = LTPBundleFindValueWithKey(fullPath,
- PCSCLITE_HP_LIBRKEY_NAME, keyValue, 0);
- if (0 == rv)
- {
- (void)snprintf(fullLibPath, sizeof(fullLibPath),
- "%s/%s/Contents/%s/%s",
- PCSCLITE_HP_DROPDIR, currFP->d_name, PCSC_ARCH,
- keyValue);
- fullLibPath[sizeof(fullLibPath) - 1] = '\0';
- driverTracker[listCount].libraryPath = strdup(fullLibPath);
- }
-
- /* Get ifdCapabilities */
- rv = LTPBundleFindValueWithKey(fullPath,
- PCSCLITE_HP_CPCTKEY_NAME, keyValue, 0);
- if (0 == rv)
- driverTracker[listCount].ifdCapabilities = strtol(keyValue,
- NULL, 16);
-
- /* Get CFBundleName */
- rv = LTPBundleFindOptionalValueWithKey(fullPath,
- PCSCLITE_HP_CFBUNDLE_NAME, keyValue, 0);
- if (0 == rv)
- driverTracker[listCount].CFBundleName = strdup(keyValue);
+ driverTracker[listCount].libraryPath = strdup(fullLibPath);
+ driverTracker[listCount].ifdCapabilities = ifdCapabilities;
+ driverTracker[listCount].CFBundleName = CFBundleName;
#ifdef DEBUG_HOTPLUG
Log2(PCSC_LOG_INFO, "Found driver for: %s",
driverTracker[listCount].readerName);
#endif
- alias++;
-
- if (NULL == driverTracker[listCount].readerName)
- continue;
-
listCount++;
if (listCount >= driverSize)
{
@@ -229,6 +231,7 @@
}
}
}
+ bundleRelease(&plist);
}
}
More information about the Pcsclite-cvs-commit
mailing list