You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

110 lines
3.5 KiB

From a380fb089499f6b5192c07ae2feaa3376997382f Mon Sep 17 00:00:00 2001
From: Olaf Meeuwissen <paddy-hack@member.fsf.org>
Date: Sun, 13 Sep 2020 18:47:32 +0900
Subject: [PATCH] pixma: Restore old behaviour in case XML support is missing
Fixes #345.
---
backend/pixma/pixma_common.c | 4 ++--
backend/pixma/pixma_common.h | 2 ++
backend/pixma/pixma_mp150.c | 8 ++++++++
backend/pixma/pixma_mp800.c | 8 ++++++++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/backend/pixma/pixma_common.c b/backend/pixma/pixma_common.c
index ff3bd487d..2f46082e2 100644
--- a/backend/pixma/pixma_common.c
+++ b/backend/pixma/pixma_common.c
@@ -56,8 +56,6 @@
#if defined(HAVE_LIBXML2)
# include <libxml/parser.h>
-#else
-# error "The pixma backend requires libxml2"
#endif
#include "pixma_rename.h"
@@ -1241,6 +1239,7 @@ pixma_get_device_status (pixma_t * s, pixma_device_status_t * status)
return s->ops->get_status (s, status);
}
+#if defined(HAVE_LIBXML2)
static const char *
format_xml_response(const char *resp_details)
{
@@ -1334,3 +1333,4 @@ clean:
xmlFreeDoc(doc);
return status;
}
+#endif
diff --git a/backend/pixma/pixma_common.h b/backend/pixma/pixma_common.h
index bee839c2c..1ced88d17 100644
--- a/backend/pixma/pixma_common.h
+++ b/backend/pixma/pixma_common.h
@@ -205,7 +205,9 @@ uint8_t *pixma_newcmd (pixma_cmdbuf_t *, unsigned cmd,
int pixma_exec (pixma_t *, pixma_cmdbuf_t *);
int pixma_exec_short_cmd (pixma_t *, pixma_cmdbuf_t *, unsigned cmd);
int pixma_map_status_errno (unsigned status);
+#if defined(HAVE_LIBXML2)
int pixma_parse_xml_response(const char *xml_message);
+#endif
/**@}*/
#define pixma_fill_checksum(start, end) do { \
diff --git a/backend/pixma/pixma_mp150.c b/backend/pixma/pixma_mp150.c
index cd6cd3ddf..a18fbdce1 100644
--- a/backend/pixma/pixma_mp150.c
+++ b/backend/pixma/pixma_mp150.c
@@ -322,6 +322,10 @@
<ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\
</ivec:param_set></ivec:contents></cmd>"
+#if !defined(HAVE_LIBXML2)
+#define XML_OK "<ivec:response>OK</ivec:response>"
+#endif
+
enum mp150_state_t
{
state_idle,
@@ -459,7 +463,11 @@ send_xml_dialog (pixma_t * s, const char * xml_message)
PDBG (pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message));
PDBG (pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf));
+#if defined(HAVE_LIBXML2)
return pixma_parse_xml_response((const char*)mp->cb.buf) == PIXMA_STATUS_OK;
+#else
+ return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL);
+#endif
}
static int
diff --git a/backend/pixma/pixma_mp800.c b/backend/pixma/pixma_mp800.c
index 8b7b232fd..e05107d04 100644
--- a/backend/pixma/pixma_mp800.c
+++ b/backend/pixma/pixma_mp800.c
@@ -152,6 +152,10 @@
<ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\
</ivec:param_set></ivec:contents></cmd>"
+#if !defined(HAVE_LIBXML2)
+#define XML_OK "<ivec:response>OK</ivec:response>"
+#endif
+
enum mp810_state_t
{
state_idle,
@@ -291,7 +295,11 @@ static int send_xml_dialog (pixma_t * s, const char * xml_message)
PDBG(pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message));
PDBG(pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf));
+#if defined(HAVE_LIBXML2)
return pixma_parse_xml_response((const char*)mp->cb.buf) == PIXMA_STATUS_OK;
+#else
+ return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL);
+#endif
}
static void new_cmd_tpu_msg (pixma_t *s, pixma_cmdbuf_t * cb, uint16_t cmd)
--
GitLab