hplip/hplip-model-mismatch.patch

65 lines
2.3 KiB
Diff

diff --git a/io/hpmud/jd.c b/io/hpmud/jd.c
index 20df27a..7ed4918 100644
--- a/io/hpmud/jd.c
+++ b/io/hpmud/jd.c
@@ -208,7 +208,22 @@ enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) jd_open(mud_device *pd
{
/* Make sure uri model matches device id model. */
hpmud_get_uri_model(pd->uri, uri_model, sizeof(uri_model));
+
+ /* remove possible hp_ string */
+ if (strncasecmp(uri_model, "HP_", 3) == 0)
+ {
+ memmove(uri_model, uri_model + 3, 127);
+ uri_model[127] = '\0';
+ }
+
hpmud_get_model(pd->id, model, sizeof(model));
+ /* remove possible hp_ string */
+ if (strncasecmp(model, "HP_", 3) == 0)
+ {
+ memmove(model, model + 3, 127);
+ model[127] = '\0';
+ }
+
if (strcasecmp(uri_model, model) != 0)
{
stat = HPMUD_R_INVALID_URI; /* different device plugged in */
diff --git a/io/hpmud/model.c b/io/hpmud/model.c
index d546ec1..adb3d87 100644
--- a/io/hpmud/model.c
+++ b/io/hpmud/model.c
@@ -407,7 +407,10 @@ static int ParseFile(char *datFile, char *model, char *attr, int attrSize, int *
char rcbuf[255];
char section[128];
char file[128];
- int found=0, n;
+ int found=0;
+ size_t n;
+
+ size_t model_len = strlen(model);
if ((fp = fopen(datFile, "r")) == NULL)
goto bugout;
@@ -422,10 +425,17 @@ static int ParseFile(char *datFile, char *model, char *attr, int attrSize, int *
strncpy(section, rcbuf+1, sizeof(section)); /* found new section */
n = strlen(section);
section[n-2]=0; /* remove ']' and CR */
+ n -= 2;
if (strcasecmp(model, section) == 0 ||
- (section[0] == 'h' && section[1] == 'p' &&
- section[2] == '_' &&
- strcasecmp(model, section + 3) == 0))
+ (section[0] == 'h' &&
+ section[1] == 'p' &&
+ section[2] == '_' &&
+ strcasecmp(model, section + 3) == 0) ||
+ (n > model_len &&
+ strncasecmp(section, model, model_len) == 0 &&
+ strncasecmp(section + model_len, "_series", strlen("_series")) == 0
+ )
+ )
{
/* Found model match. */
*bytes_read = ResolveAttributes(fp, attr, attrSize);