treewide: Run refresh on all packages
[feed/packages.git] / utils / sane-backends / patches / 102-pixma_Restore_old_behaviour_in_case_XML_support_is_missing.patch
1 From a380fb089499f6b5192c07ae2feaa3376997382f Mon Sep 17 00:00:00 2001
2 From: Olaf Meeuwissen <paddy-hack@member.fsf.org>
3 Date: Sun, 13 Sep 2020 18:47:32 +0900
4 Subject: [PATCH] pixma: Restore old behaviour in case XML support is missing
5
6 Fixes #345.
7 ---
8 backend/pixma/pixma_common.c | 4 ++--
9 backend/pixma/pixma_common.h | 2 ++
10 backend/pixma/pixma_mp150.c | 8 ++++++++
11 backend/pixma/pixma_mp800.c | 8 ++++++++
12 4 files changed, 20 insertions(+), 2 deletions(-)
13
14 --- a/backend/pixma/pixma_common.c
15 +++ b/backend/pixma/pixma_common.c
16 @@ -56,8 +56,6 @@
17
18 #if defined(HAVE_LIBXML2)
19 # include <libxml/parser.h>
20 -#else
21 -# error "The pixma backend requires libxml2"
22 #endif
23
24 #include "pixma_rename.h"
25 @@ -1241,6 +1239,7 @@ pixma_get_device_status (pixma_t * s, pi
26 return s->ops->get_status (s, status);
27 }
28
29 +#if defined(HAVE_LIBXML2)
30 static const char *
31 format_xml_response(const char *resp_details)
32 {
33 @@ -1334,3 +1333,4 @@ clean:
34 xmlFreeDoc(doc);
35 return status;
36 }
37 +#endif
38 --- a/backend/pixma/pixma_common.h
39 +++ b/backend/pixma/pixma_common.h
40 @@ -205,7 +205,9 @@ uint8_t *pixma_newcmd (pixma_cmdbuf_t *,
41 int pixma_exec (pixma_t *, pixma_cmdbuf_t *);
42 int pixma_exec_short_cmd (pixma_t *, pixma_cmdbuf_t *, unsigned cmd);
43 int pixma_map_status_errno (unsigned status);
44 +#if defined(HAVE_LIBXML2)
45 int pixma_parse_xml_response(const char *xml_message);
46 +#endif
47 /**@}*/
48
49 #define pixma_fill_checksum(start, end) do { \
50 --- a/backend/pixma/pixma_mp150.c
51 +++ b/backend/pixma/pixma_mp150.c
52 @@ -322,6 +322,10 @@
53 <ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\
54 </ivec:param_set></ivec:contents></cmd>"
55
56 +#if !defined(HAVE_LIBXML2)
57 +#define XML_OK "<ivec:response>OK</ivec:response>"
58 +#endif
59 +
60 enum mp150_state_t
61 {
62 state_idle,
63 @@ -459,7 +463,11 @@ send_xml_dialog (pixma_t * s, const char
64 PDBG (pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message));
65 PDBG (pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf));
66
67 +#if defined(HAVE_LIBXML2)
68 return pixma_parse_xml_response((const char*)mp->cb.buf) == PIXMA_STATUS_OK;
69 +#else
70 + return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL);
71 +#endif
72 }
73
74 static int
75 --- a/backend/pixma/pixma_mp800.c
76 +++ b/backend/pixma/pixma_mp800.c
77 @@ -152,6 +152,10 @@
78 <ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\
79 </ivec:param_set></ivec:contents></cmd>"
80
81 +#if !defined(HAVE_LIBXML2)
82 +#define XML_OK "<ivec:response>OK</ivec:response>"
83 +#endif
84 +
85 enum mp810_state_t
86 {
87 state_idle,
88 @@ -291,7 +295,11 @@ static int send_xml_dialog (pixma_t * s,
89 PDBG(pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message));
90 PDBG(pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf));
91
92 +#if defined(HAVE_LIBXML2)
93 return pixma_parse_xml_response((const char*)mp->cb.buf) == PIXMA_STATUS_OK;
94 +#else
95 + return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL);
96 +#endif
97 }
98
99 static void new_cmd_tpu_msg (pixma_t *s, pixma_cmdbuf_t * cb, uint16_t cmd)