pixma: Restore old behaviour in case XML support is missing

Fixes #345.
merge-requests/540/head
Olaf Meeuwissen 2020-09-13 18:47:32 +09:00
rodzic 3ac8ca4e87
commit a380fb0894
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B8A4A88AF84A2DD9
4 zmienionych plików z 20 dodań i 2 usunięć

Wyświetl plik

@ -56,8 +56,6 @@
#if defined(HAVE_LIBXML2) #if defined(HAVE_LIBXML2)
# include <libxml/parser.h> # include <libxml/parser.h>
#else
# error "The pixma backend requires libxml2"
#endif #endif
#include "pixma_rename.h" #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); return s->ops->get_status (s, status);
} }
#if defined(HAVE_LIBXML2)
static const char * static const char *
format_xml_response(const char *resp_details) format_xml_response(const char *resp_details)
{ {
@ -1334,3 +1333,4 @@ clean:
xmlFreeDoc(doc); xmlFreeDoc(doc);
return status; return status;
} }
#endif

Wyświetl plik

@ -205,7 +205,9 @@ uint8_t *pixma_newcmd (pixma_cmdbuf_t *, unsigned cmd,
int pixma_exec (pixma_t *, pixma_cmdbuf_t *); int pixma_exec (pixma_t *, pixma_cmdbuf_t *);
int pixma_exec_short_cmd (pixma_t *, pixma_cmdbuf_t *, unsigned cmd); int pixma_exec_short_cmd (pixma_t *, pixma_cmdbuf_t *, unsigned cmd);
int pixma_map_status_errno (unsigned status); int pixma_map_status_errno (unsigned status);
#if defined(HAVE_LIBXML2)
int pixma_parse_xml_response(const char *xml_message); int pixma_parse_xml_response(const char *xml_message);
#endif
/**@}*/ /**@}*/
#define pixma_fill_checksum(start, end) do { \ #define pixma_fill_checksum(start, end) do { \

Wyświetl plik

@ -322,6 +322,10 @@
<ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\ <ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\
</ivec:param_set></ivec:contents></cmd>" </ivec:param_set></ivec:contents></cmd>"
#if !defined(HAVE_LIBXML2)
#define XML_OK "<ivec:response>OK</ivec:response>"
#endif
enum mp150_state_t enum mp150_state_t
{ {
state_idle, 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 message sent to scanner:\n%s\n", xml_message));
PDBG (pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf)); 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; 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 static int

Wyświetl plik

@ -152,6 +152,10 @@
<ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\ <ivec:param_set servicetype=\"scan\"><ivec:jobID>00000001</ivec:jobID>\
</ivec:param_set></ivec:contents></cmd>" </ivec:param_set></ivec:contents></cmd>"
#if !defined(HAVE_LIBXML2)
#define XML_OK "<ivec:response>OK</ivec:response>"
#endif
enum mp810_state_t enum mp810_state_t
{ {
state_idle, 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 message sent to scanner:\n%s\n", xml_message));
PDBG(pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf)); 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; 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) static void new_cmd_tpu_msg (pixma_t *s, pixma_cmdbuf_t * cb, uint16_t cmd)