From aaae19eb8462c784daab0cf9afddc934fdbd1b75 Mon Sep 17 00:00:00 2001 From: defanor Date: Fri, 8 Sep 2023 17:23:54 +0300 Subject: Support libexpat as an alternative XML parser --- emacs/xml_interface.c | 20 ++++---------------- emacs/xmpp.el | 3 +-- 2 files changed, 5 insertions(+), 18 deletions(-) (limited to 'emacs') diff --git a/emacs/xml_interface.c b/emacs/xml_interface.c index 76e888c..66cbe7f 100644 --- a/emacs/xml_interface.c +++ b/emacs/xml_interface.c @@ -9,8 +9,8 @@ A basic and ad hoc XML interface. The parent process (e.g., Emacs) is supposed to respond to requests starting with the most recent one. This program's output is separated with NUL ('\0') characters, to -simplify parsing in Emacs, while the input is separated with newline -and EOF ones, to simplify reading with libxml2. +simplify parsing in Emacs, while the input is separated with newlines, +to simplify reading with rexmpp_xml_read_fd (getline). */ @@ -31,18 +31,6 @@ void print_xml (rexmpp_xml_t *node) { free(s); } -rexmpp_xml_t *read_xml () { - rexmpp_xml_t *elem = NULL; - xmlDocPtr doc = xmlReadFd(STDIN_FILENO, "", "utf-8", 0); - if (doc != NULL) { - elem = rexmpp_xml_from_libxml2(xmlDocGetRootElement(doc)); - xmlFreeDoc(doc); - return elem; - } - return NULL; -} - - char *request (rexmpp_t *s, rexmpp_xml_t *payload) { rexmpp_xml_t *req = rexmpp_xml_new_elem("request", NULL); @@ -58,7 +46,7 @@ void req_process (rexmpp_t *s, rexmpp_xml_t *elem); rexmpp_xml_t *read_response (rexmpp_t *s, const char *id) { - rexmpp_xml_t *elem = read_xml(); + rexmpp_xml_t *elem = rexmpp_xml_read_fd(stdin); if (elem != NULL) { if (rexmpp_xml_match(elem, NULL, "response")) { const char *resp_id = rexmpp_xml_find_attr_val(elem, "id"); @@ -339,7 +327,7 @@ int main (int argc, char **argv) { do { /* Check if we have some user input. */ if (n > 0 && FD_ISSET(STDIN_FILENO, &read_fds)) { - rexmpp_xml_t *elem = read_xml(); + rexmpp_xml_t *elem = rexmpp_xml_read_fd(stdin); if (elem != NULL) { req_process(&s, elem); rexmpp_xml_free(elem); diff --git a/emacs/xmpp.el b/emacs/xmpp.el index feb201f..1dbd34b 100644 --- a/emacs/xmpp.el +++ b/emacs/xmpp.el @@ -186,8 +186,7 @@ its printing--which doesn't handle namespaces--can be used too." (with-temp-buffer (xml-print xml) (insert "\n") - (process-send-region cur-proc (point-min) (point-max)) - (process-send-eof cur-proc)))) + (process-send-region cur-proc (point-min) (point-max))))) (defun xmpp-with-message-body (proc message-xml func) (let* ((message-contents (xml-node-children message-xml)) -- cgit v1.2.3