[Pcsclite-cvs-commit] r5351 - /trunk/PCSC/src/hotplug_linux.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Mon Oct 25 14:08:28 UTC 2010
Author: rousseau
Date: Mon Oct 25 14:08:14 2010
New Revision: 5351
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5351
Log:
Use the new bundle parser code
Modified:
trunk/PCSC/src/hotplug_linux.c
Modified: trunk/PCSC/src/hotplug_linux.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/hotplug_linux.c?rev=5351&op=diff
==============================================================================
--- trunk/PCSC/src/hotplug_linux.c (original)
+++ trunk/PCSC/src/hotplug_linux.c Mon Oct 25 14:08:14 2010
@@ -41,6 +41,7 @@
#include "hotplug.h"
#include "utils.h"
+#undef DEBUG_HOTPLUG
#define PCSCLITE_USB_PATH "/proc/bus/usb"
#define FALSE 0
@@ -97,14 +98,12 @@
static LONG HPReadBundleValues(void)
{
-
LONG rv;
DIR *hpDir;
struct dirent *currFP = 0;
char fullPath[FILENAME_MAX];
char fullLibPath[FILENAME_MAX];
- char keyValue[TOKEN_MAX_VALUE_SIZE];
- int listCount = 0;
+ unsigned int listCount = 0;
hpDir = opendir(PCSCLITE_HP_DROPDIR);
@@ -116,11 +115,23 @@
return -1;
}
+#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 *libraryPath;
/*
* The bundle exists - let's form a full path name and get the
@@ -130,45 +141,47 @@
PCSCLITE_HP_DROPDIR, currFP->d_name);
fullPath[FILENAME_MAX - 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_KEY(PCSCLITE_HP_CPCTKEY_NAME, &values)
+ GET_KEY(PCSCLITE_HP_MANUKEY_NAME, &manuIDs)
+ GET_KEY(PCSCLITE_HP_PRODKEY_NAME, &productIDs)
+ GET_KEY(PCSCLITE_HP_NAMEKEY_NAME, &readerNames)
+
/* 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);
+ bundleTracker[listCount].manuID = strtol(value, NULL, 16);
+
+ value = list_get_at(productIDs, alias);
+ bundleTracker[listCount].productID = strtol(value, NULL, 16);
+
+ bundleTracker[listCount].readerName = strdup(list_get_at(readerNames, alias));
+
+ /* constant entries for a same driver */
bundleTracker[listCount].bundleName = strdup(currFP->d_name);
-
- /* Get ifdVendorID */
- rv = LTPBundleFindValueWithKey(fullPath, PCSCLITE_HP_MANUKEY_NAME,
- keyValue, alias);
- if (rv == 0)
- bundleTracker[listCount].manuID = strtol(keyValue, 0, 16);
-
- /* get ifdProductID */
- rv = LTPBundleFindValueWithKey(fullPath, PCSCLITE_HP_PRODKEY_NAME,
- keyValue, alias);
- if (rv == 0)
- bundleTracker[listCount].productID =
- strtol(keyValue, 0, 16);
-
- /* get ifdFriendlyName */
- rv = LTPBundleFindValueWithKey(fullPath, PCSCLITE_HP_NAMEKEY_NAME,
- keyValue, alias);
- if (rv == 0)
- bundleTracker[listCount].readerName = strdup(keyValue);
-
- /* get CFBundleExecutable */
- rv = LTPBundleFindValueWithKey(fullPath, PCSCLITE_HP_LIBRKEY_NAME,
- keyValue, 0);
- if (rv == 0)
- {
- snprintf(fullLibPath, sizeof(fullLibPath),
- "%s/%s/Contents/%s/%s",
- PCSCLITE_HP_DROPDIR, currFP->d_name, PCSC_ARCH, keyValue);
- fullLibPath[sizeof(fullLibPath) - 1] = '\0';
- bundleTracker[listCount].libraryPath = strdup(fullLibPath);
- }
-
+ bundleTracker[listCount].libraryPath = strdup(fullLibPath);
+
+#ifdef DEBUG_HOTPLUG
+ Log2(PCSC_LOG_INFO, "Found driver for: %s",
+ bundleTracker[listCount].readerName);
+#endif
listCount++;
- alias++;
if (listCount >= sizeof(bundleTracker)/sizeof(bundleTracker[0]))
{
@@ -176,6 +189,7 @@
goto end;
}
}
+ bundleRelease(&plist);
}
}
More information about the Pcsclite-cvs-commit
mailing list