From 430d97ddc6e68e62cc0f2e77319aaa92876f51eb Mon Sep 17 00:00:00 2001 From: defanor Date: Sat, 7 Oct 2023 20:29:00 +0300 Subject: Use file descriptors instead of streams, update Rust sources File descriptors tend to be easier to handle with FFI. --- emacs/xml_interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'emacs') diff --git a/emacs/xml_interface.c b/emacs/xml_interface.c index 66cbe7f..02db77d 100644 --- a/emacs/xml_interface.c +++ b/emacs/xml_interface.c @@ -10,7 +10,7 @@ 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 newlines, -to simplify reading with rexmpp_xml_read_fd (getline). +to simplify reading with rexmpp_xml_read_fd. */ @@ -34,7 +34,7 @@ void print_xml (rexmpp_xml_t *node) { char *request (rexmpp_t *s, rexmpp_xml_t *payload) { rexmpp_xml_t *req = rexmpp_xml_new_elem("request", NULL); - rexmpp_xml_add_id(s, req); + rexmpp_xml_add_id(req); rexmpp_xml_add_child(req, payload); print_xml(req); char *id = strdup(rexmpp_xml_find_attr_val(req, "id")); @@ -46,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 = rexmpp_xml_read_fd(stdin); + rexmpp_xml_t *elem = rexmpp_xml_read_fd(STDIN_FILENO); if (elem != NULL) { if (rexmpp_xml_match(elem, NULL, "response")) { const char *resp_id = rexmpp_xml_find_attr_val(elem, "id"); @@ -327,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 = rexmpp_xml_read_fd(stdin); + rexmpp_xml_t *elem = rexmpp_xml_read_fd(STDIN_FILENO); if (elem != NULL) { req_process(&s, elem); rexmpp_xml_free(elem); -- cgit v1.2.3