[Pcsclite-cvs-commit] r4779 - in /trunk/PCSC: configure.in doc/Makefile.am doc/update-reader.conf.8.in etc/Makefile.am etc/update-reader.conf.in src/configfile.h src/configfile.l src/readerfactory.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Fri Feb 26 13:53:27 UTC 2010


Author: rousseau
Date: Fri Feb 26 13:53:24 2010
New Revision: 4779

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4779
Log:
Add the ability to parse all the configuration files of a directory
instead of just one configuration file.
update-reader.conf is then now obsolete.

See Debian bug #565896 http://bugs.debian.org/565896

Removed:
    trunk/PCSC/doc/update-reader.conf.8.in
    trunk/PCSC/etc/update-reader.conf.in
Modified:
    trunk/PCSC/configure.in
    trunk/PCSC/doc/Makefile.am
    trunk/PCSC/etc/Makefile.am
    trunk/PCSC/src/configfile.h
    trunk/PCSC/src/configfile.l
    trunk/PCSC/src/readerfactory.c

Modified: trunk/PCSC/configure.in
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/configure.in?rev=4779&op=diff
==============================================================================
--- trunk/PCSC/configure.in (original)
+++ trunk/PCSC/configure.in Fri Feb 26 13:53:24 2010
@@ -344,12 +344,10 @@
 doc/doxygen.conf
 doc/pcscd.8
 doc/reader.conf.5
-doc/update-reader.conf.8
 doc/example/Makefile
 etc/Makefile
 etc/pcscd.init
 etc/reader.conf
-etc/update-reader.conf
 src/Makefile
 src/libpcsclite.pc
 src/pcscd.h

Modified: trunk/PCSC/doc/Makefile.am
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/doc/Makefile.am?rev=4779&op=diff
==============================================================================
--- trunk/PCSC/doc/Makefile.am (original)
+++ trunk/PCSC/doc/Makefile.am Fri Feb 26 13:53:24 2010
@@ -6,8 +6,8 @@
 			ifdhandler-3.tex \
 			README.DAEMON
 
-man_MANS = pcscd.8 reader.conf.5 update-reader.conf.8
-man_in = pcscd.8.in reader.conf.5.in update-reader.conf.8.in
+man_MANS = pcscd.8 reader.conf.5 
+man_in = pcscd.8.in reader.conf.5.in
 
 EXTRA_DIST = $(doc_DATA) $(man_in) doxygen.conf.in formaticc.1
 

Modified: trunk/PCSC/etc/Makefile.am
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/etc/Makefile.am?rev=4779&op=diff
==============================================================================
--- trunk/PCSC/etc/Makefile.am (original)
+++ trunk/PCSC/etc/Makefile.am Fri Feb 26 13:53:24 2010
@@ -2,7 +2,6 @@
 
 conf_DATA = reader.conf
 confdir = $(confdir_exp)/reader.conf.d
-sbin_SCRIPTS = update-reader.conf
 
 EXTRA_DIST = StartupParameters.plist SmartcardServices
 

Modified: trunk/PCSC/src/configfile.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/configfile.h?rev=4779&op=diff
==============================================================================
--- trunk/PCSC/src/configfile.h (original)
+++ trunk/PCSC/src/configfile.h Fri Feb 26 13:53:24 2010
@@ -22,6 +22,9 @@
 	int DBGetReaderList(const char *readerconf,
 		/*@out@*/ SerialReader **caller_reader_list);
 
+	int DBGetReaderListDir(const char *readerconf_dir,
+		/*@out@*/ SerialReader **caller_reader_list);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/PCSC/src/configfile.l
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/configfile.l?rev=4779&op=diff
==============================================================================
--- trunk/PCSC/src/configfile.l (original)
+++ trunk/PCSC/src/configfile.l Fri Feb 26 13:53:24 2010
@@ -14,6 +14,8 @@
  */
 
 %{
+#include <dirent.h>
+
 #include "wintypes.h"
 #include "pcscd.h"
 #include "readerfactory.h"
@@ -32,6 +34,7 @@
 static int badError;
 static SerialReader *reader_list;
 static int reader_list_size;
+const char *ConfFile;
 
 void tok_error(char *pcToken_error);
 
@@ -214,8 +217,56 @@
 
 void tok_error(char *token_error)
 {
-	Log3(PCSC_LOG_ERROR, "tok_error: invalid value line %d in " PCSCLITE_READER_CONFIG ": %s", iOldLinenumber, token_error);
+	Log4(PCSC_LOG_ERROR, "tok_error: invalid value line %d in %s: %s",
+		iOldLinenumber, ConfFile, token_error);
 	badError = 1;
+}
+
+int DBGetReaderListDir(const char *readerconf_dir,
+	SerialReader **caller_reader_list)
+{
+	DIR *dir;
+	int ret = 0;
+
+	/* (re)start with an empty list */
+	reader_list = NULL;
+	reader_list_size = 0;
+
+	dir = opendir(readerconf_dir);
+	if (dir)
+	{
+		/* the configuration file is a directory */
+		struct dirent *direntry;
+
+		/* for each configuration file */
+		while ((direntry = readdir(dir)) != NULL)
+		{
+			char filename[FILENAME_MAX];
+			int r;
+
+			/* skip . and .. */
+			if ((strcmp(direntry->d_name, ".") == 0) ||
+				(strcmp(direntry->d_name, "..") == 0))
+				continue;
+
+			snprintf(filename, sizeof(filename), "%s/%s",
+				readerconf_dir, direntry->d_name);
+
+			/* each call to DBGetReaderList() will append to the list */
+			r = DBGetReaderList(filename, caller_reader_list);
+
+			/* set the global return value to the latest error */
+			if (r)
+				ret = r;
+		}
+
+		closedir(dir);
+	}
+	else
+		/* the configuration file is really a file */
+		ret = DBGetReaderList(readerconf_dir, caller_reader_list);
+
+	return ret;
 }
 
 int DBGetReaderList(const char *readerconf, SerialReader **caller_reader_list)
@@ -224,6 +275,11 @@
 
 	*caller_reader_list = NULL;	/* no list by default */
 
+	/* used by tok_error() */
+	ConfFile = readerconf;
+
+	Log2(PCSC_LOG_DEBUG, "Parsing conf file: %s", ConfFile);
+
 	configFile = fopen(readerconf, "r");
 
 	if (configFile == NULL)
@@ -234,8 +290,6 @@
 	/* (re)start with a clean state */
 	iLinenumber = 1;
 	iOldLinenumber = -1;
-	reader_list = NULL;
-	reader_list_size = 0;
 	pcFriendlyname = NULL;
 	pcDevicename = NULL;
 	pcLibpath = NULL;

Modified: trunk/PCSC/src/readerfactory.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.c?rev=4779&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.c (original)
+++ trunk/PCSC/src/readerfactory.c Fri Feb 26 13:53:24 2010
@@ -1284,7 +1284,7 @@
 	/* remember the configuration filename for RFReCheckReaderConf() */
 	ConfigFile = strdup(readerconf);
 
-	rv = DBGetReaderList(readerconf, &reader_list);
+	rv = DBGetReaderListDir(readerconf, &reader_list);
 
 	/* the list is empty */
 	if (NULL == reader_list)
@@ -1306,7 +1306,7 @@
 		for (j=0; j<reader_list[i].pcDevicename[j]; j++)
 			ConfigFileCRC += reader_list[i].pcDevicename[j];
 
-		/* free strings allocated by DBGetReaderList() */
+		/* free strings allocated by DBGetReaderListDir() */
 		free(reader_list[i].pcFriendlyname);
 		free(reader_list[i].pcLibpath);
 		free(reader_list[i].pcDevicename);
@@ -1321,7 +1321,7 @@
 	SerialReader *reader_list;
 	int i, crc;
 
-	(void)DBGetReaderList(ConfigFile, &reader_list);
+	(void)DBGetReaderListDir(ConfigFile, &reader_list);
 
 	/* the list is empty */
 	if (NULL == reader_list)
@@ -1401,7 +1401,7 @@
 				reader_list[i].channelId, reader_list[i].pcLibpath,
 				reader_list[i].pcDevicename);
 
-		/* free strings allocated by DBGetReaderList() */
+		/* free strings allocated by DBGetReaderListDir() */
 		free(reader_list[i].pcFriendlyname);
 		free(reader_list[i].pcLibpath);
 		free(reader_list[i].pcDevicename);




More information about the Pcsclite-cvs-commit mailing list