From 17f6e26a15b50d381b9fe9a6ede9f60e968d52b7 Mon Sep 17 00:00:00 2001 From: Thomas Soumarmon Date: Mon, 7 Jul 2003 07:58:26 +0000 Subject: [PATCH] HP5400: Added version string 0.87 reported to work ok. Use of a version list instead of several constants. --- ChangeLog | 6 +++ backend/hp5400_internal.c | 77 +++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index f81fee8bb..8fc23c603 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-07-02 Thomas Soumarmon + + * backend/hp5400_internal.c: Added version string for v0.87 + which has been reported to work ok. Use of a list of versions + instead of several constants. + 2003-07-02 Peter Fales * backend/gphoto2.c: Suppress the "bad parameter" message printed diff --git a/backend/hp5400_internal.c b/backend/hp5400_internal.c index 2d7247830..67b973ed8 100644 --- a/backend/hp5400_internal.c +++ b/backend/hp5400_internal.c @@ -88,8 +88,18 @@ /* #define CALIB_DEBUG */ -const char MatchVersion[] = "SilitekIBlizd C3 ScannerV0.84"; -const char MatchVersion2[] = "SilitekIBlizd C3 ScannerV0.86"; +typedef struct versionString { + const char strVersion[128]; +} versionString; + +versionString MatchVersions[] = { + { "SilitekIBlizd C3 ScannerV0.84" } , + { "SilitekIBlizd C3 ScannerV0.86" } , + { "SilitekIBlizd C3 ScannerV0.87" } + }; + +const int numVersions = 3; + static TScannerModel Model_HP54xx = { "Hewlett-Packard", "HP54xx Flatbed Scanner" }; @@ -1183,6 +1193,9 @@ HP5400Open (THWParams * params, char *filename) int iHandle = hp5400_open (filename); char szVersion[32]; int i; +#ifndef NO_STRING_VERSION_MATCH + int versionMatched; +#endif if (iHandle < 0) { @@ -1202,22 +1215,29 @@ HP5400Open (THWParams * params, char *filename) HP5400_DBG (DBG_MSG, "version String :\n"); for (i=0; i < 32; i++) { - HP5400_DBG (DBG_MSG, "%c", szVersion[i]); + HP5400_DBG (DBG_MSG, "%c\n", szVersion[i]); } HP5400_DBG (DBG_MSG, "\n"); #ifndef NO_STRING_VERSION_MATCH - /* Match on everything except the version number */ - if (memcmp (szVersion + 1, MatchVersion, sizeof (MatchVersion) - 4)) - { - if (memcmp (szVersion + 1, MatchVersion2, sizeof (MatchVersion2) - 4)) - { - HP5400_DBG (DBG_MSG, - "Sorry, unknown scanner version. Attempted match on '%s' and '%s'\n", - MatchVersion, MatchVersion2); - HP5400_DBG (DBG_MSG, "Vesion is '%s'\n", szVersion); - goto hp5400_close_exit; + i = 0; + versionMatched = 0; + while ( !versionMatched && (i < numVersions) ) { + if (!memcmp (szVersion + 1, MatchVersions[i] .strVersion, strlen(MatchVersions[i] .strVersion) - 4)) { + versionMatched = 1; } + i++; + } + if ( !versionMatched ) { + HP5400_DBG (DBG_MSG, + "Sorry, unknown scanner version. Attempted match on :\n"); + i = 0; + while ( i < numVersions ) { + HP5400_DBG (DBG_MSG, "* '%s'\n", MatchVersions[i] .strVersion); + i++; + } + HP5400_DBG (DBG_MSG, "Version is '%s'\n", szVersion); + goto hp5400_close_exit; } #else HP5400_DBG (DBG_MSG, "Warning, Version match is disabled. Version is '%s'\n", @@ -1253,6 +1273,10 @@ HP5400Detect (char *filename, char szVersion[32]; int ret = 0; +#ifndef NO_STRING_VERSION_MATCH + int versionMatched = 0; + int i = 0; +#endif if (iHandle < 0) { @@ -1270,17 +1294,24 @@ HP5400Detect (char *filename, } #ifndef NO_STRING_VERSION_MATCH - if (memcmp (szVersion + 1, MatchVersion, sizeof (MatchVersion) - 1)) - { - if (memcmp (szVersion + 1, MatchVersion2, sizeof (MatchVersion2) - 1)) - { - HP5400_DBG (DBG_MSG, - "Sorry, unknown scanner version. Attempted match on '%s' and '%s'\n", - MatchVersion, MatchVersion2); - HP5400_DBG (DBG_MSG, "Vesion is '%s'\n", szVersion); - ret = -1; - goto hp5400_close_exit; + i = 0; + versionMatched = 0; + while ( !versionMatched && (i < numVersions) ) { + if (!memcmp (szVersion + 1, MatchVersions[i] .strVersion, strlen (MatchVersions[i] .strVersion) - 4)) { + versionMatched = 1; } + i++; + } + if ( !versionMatched ) { + HP5400_DBG (DBG_MSG, + "Sorry, unknown scanner version. Attempted match on :\n"); + i = 0; + while ( i < numVersions ) { + HP5400_DBG (DBG_MSG, "* '%s'\n", MatchVersions[i] .strVersion); + i++; + } + HP5400_DBG (DBG_MSG, "Version is '%s'\n", szVersion); + goto hp5400_close_exit; } #else HP5400_DBG (DBG_MSG, "Warning, Version match is disabled. Version is '%s'\n",