]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/io: save tty mode as local process state
authorLukáš Ježek <lukas.jezek@nic.cz>
Thu, 23 Apr 2020 06:53:04 +0000 (08:53 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 2 Oct 2020 06:49:38 +0000 (08:49 +0200)
daemon/io.c
daemon/io.h

index 1c879188d03731f0e8217756474cdf5efbfc6165..96e37e8a6ae4a799d626cb2fa572690efd232095 100644 (file)
@@ -501,7 +501,7 @@ void io_tty_process_input(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu
                while (cmd != NULL) {
                        /* Pseudo-command for switching to "binary output"; */
                        if (strcmp(cmd, "__binary") == 0) {
-                               args->tty_binary_output = true;
+                               stream->data = (void *)io_mode_binary;
                                cmd = strtok(NULL, "\n");
                                continue;
                        }
@@ -514,7 +514,7 @@ void io_tty_process_input(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu
                        }
 
                        /* Simpler output in binary mode */
-                       if (args->tty_binary_output) {
+                       if (stream->data == (void *)io_mode_binary) {
                                size_t len_s = strlen(message);
                                if (len_s > UINT32_MAX) {
                                        cmd = strtok(NULL, "\n");
@@ -574,6 +574,7 @@ void io_tty_accept(uv_stream_t *master, int status)
                        free(client);
                        return;
                 }
+                client->data = (void *) io_mode_text;
                 uv_read_start((uv_stream_t *)client, io_tty_alloc, io_tty_process_input);
                 /* Write command line */
                 if (!args->quiet) {
index 15d2e70bebbd046d5ea76b7db30c03091b5dcae9..10cde83d7aad6c849e0c32ba550315b177bfb75b 100644 (file)
 struct tls_ctx;
 struct tls_client_ctx;
 
+enum io_stream_mode {
+       io_mode_text = 0,
+       io_mode_binary = 1,
+};
+
 /** Bind address into a file-descriptor (only, no libuv).  type is e.g. SOCK_DGRAM */
 int io_bind(const struct sockaddr *addr, int type, const endpoint_flags_t *flags);
 /** Initialize a UDP handle and start listening. */