From patchwork Sun Apr 6 22:05:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039540 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64A1019F47E for ; Sun, 6 Apr 2025 22:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977482; cv=none; b=kIDjbCM1XyegzTu1FE4gB337ohM9HlYIgv9wusontcfO3vLpsDWhg6tVP07Yfd+CNnXpxRQjMAfIwhYAV/jc5v5o1TwGfcO/voS9zcCNvw/PLjihfCXRs9OU35ZhpXlnNaNfTuj0ECxaBjEZMN/yfbDf86ocnDGbjfMuHm7ikPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977482; c=relaxed/simple; bh=jgbDCedytmhG51XHymLroEkrW8ucBiHwGdUq23FQAqY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kGBEceJWgQV+EKy/XGYTIH3OkdNGDjCi3UOxgoW4V9P4Vi3Z/OYtbvKWxMsexaE1Inzt5ziySMxbX8hAUj8kdP4kSA1C3svVt04WZOFYjHZaq0g+EuDC0qag7v4fjsU+Tkg7pOtdMPgtOkqBd5AY6pxohGFSSqpes7EH1AuAw3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=VfOLvb2Z; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="VfOLvb2Z" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id B44EA164A15 for ; Sun, 6 Apr 2025 18:06:07 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 659BE124FD0 for ; Sun, 6 Apr 2025 18:06:07 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 1/9] term: Initial revision. Date: Sun, 6 Apr 2025 15:05:57 -0700 Message-ID: <97745aef2f2d08d4fabe6c5499de3f6cc6f11df4.1743976923.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=lqrcw/X1fIiKlbTGAv0DruUokSIcYLgz487yskiApHU=; b=VfOLvb2Z22RNDpH4wd43b0sfmTUtCP8kwSD/DMJYZYKTab7JbAv9x0atIr/DvqlMKKyDXyTPoiTS64xq1vfOwrBRRZqh1sazq3E39E4L+FPxCb3Kph+X2ZhKySqzCqiiQjauje1wC7wr6wRgu9tp1ovBHA7x3BTb+mPLyab75UHCbfMm+nuoSwZypIIHMIzLcBJjag+Y92Pt0eS3p/eCQowMf9wZGIhzwwj79rrv61qeOCzeyCTfi1bPHSnQXdrYYvoOiPLVPNFPJiEoUsQraOwOEyFVxA2Hk+Dn14Cv/ftmbxJ5NAjTMcwze0pmSI1iZzGUArg0Ak5wMUxw/azCzw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Initial revision of 'term.[hc]', an input/output terminal abstraction. --- ell/term.c | 487 +++++++++++++++++++++++++++++++++++++++++++++++++++++ ell/term.h | 69 ++++++++ 2 files changed, 556 insertions(+) create mode 100644 ell/term.c create mode 100644 ell/term.h diff --git a/ell/term.c b/ell/term.c new file mode 100644 index 000000000000..81df771ff07f --- /dev/null +++ b/ell/term.c @@ -0,0 +1,487 @@ +/* + * Embedded Linux library + * Copyright (C) 2023-2024 Intel Corporation + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "private.h" +#include "signal.h" +#include "io.h" +#include "term.h" + +// MARK: Preprocessor Definitions + +#define IO_HANDLER(term, fd, readable, writable) \ + do { \ + if (term && term->io_handler) { \ + term->io_handler(term, \ + fd, \ + readable, \ + writable, \ + term->io_data); \ + } \ + } while (0) + +// MARK: Type Declarations + +struct term_ops { + bool color_support; + bool use_sigwinch; + int (*get_winsize) (int fd, unsigned short *row, unsigned short *col); + int (*get_attr) (int fd, struct termios *c); + int (*set_attr) (int fd, const struct termios *c); +}; + +static int null_get_winsize(int fd, unsigned short *row, unsigned short *col) +{ + if (row) *row = 24; + if (col) *col = 80; + return 0; +} + +static int null_get_attr(int fd, struct termios *c) +{ + return 0; +} + +static int null_set_attr(int fd, const struct termios *c) +{ + return 0; +} + +static const struct term_ops default_null_ops = { + .color_support = false, + .use_sigwinch = false, + .get_winsize = null_get_winsize, + .get_attr = null_get_attr, + .set_attr = null_set_attr, +}; + +static int tty_get_winsize(int fd, unsigned short *row, unsigned short *col) +{ + struct winsize ws; + int res; + + res = ioctl(fd, TIOCGWINSZ, &ws); + if (!res) { + if (row) *row = ws.ws_row; + if (col) *col = ws.ws_col; + } + else + res = -errno; + + return res; +} + +static int tty_get_attr(int fd, struct termios *c) +{ + int retval = 0; + + if (tcgetattr(fd, c) != 0) + retval = -errno; + + return retval; +} + +static int tty_set_attr(int fd, const struct termios *c) +{ + int retval = 0; + + if (tcsetattr(fd, TCSANOW, c) != 0) + retval = -errno; + + return retval; +} + +static const struct term_ops default_tty_ops = { + .color_support = true, + .use_sigwinch = true, + .get_winsize = tty_get_winsize, + .get_attr = tty_get_attr, + .set_attr = tty_set_attr, +}; + +struct l_term { + int in_fd; + int out_fd; + l_term_io_func_t io_handler; + void *io_data; + const struct term_ops *in_ops; + const struct term_ops *out_ops; + struct termios in_termios; + struct termios out_termios; + unsigned short num_row; + unsigned short num_col; + struct l_signal *sigwinch; + bool is_running; + char key_buf[8]; + size_t key_len; + l_term_key_func_t key_handler; + void *key_data; +}; + +LIB_EXPORT struct l_term *l_term_new(void) +{ + struct l_term *term; + + term = l_new(struct l_term, 1); + + term->in_fd = -1; + term->in_ops = NULL; + + term->out_fd = -1; + term->out_ops = NULL; + + term->is_running = false; + + return term; +} + +LIB_EXPORT void l_term_free(struct l_term *term) +{ + if (!term) + return; + + l_free(term); +} + +LIB_EXPORT int l_term_set_io_handler(struct l_term *term, + l_term_io_func_t handler, void *user_data) +{ + if (!term) + return -EINVAL; + + term->io_handler = handler; + term->io_data = user_data; + + return 0; +} + +LIB_EXPORT int l_term_set_input(struct l_term *term, int fd) +{ + if (!term) + return -EINVAL; + + if (fd < 0) + return -EBADF; + + term->in_fd = fd; + term->in_ops = NULL; + + IO_HANDLER(term, fd, 1, 0); + + return 0; +} + +LIB_EXPORT int l_term_set_output(struct l_term *term, int fd) +{ + if (!term) + return -EINVAL; + + if (fd < 0) + return -EBADF; + + term->out_fd = fd; + term->out_ops = NULL; + + IO_HANDLER(term, fd, 0, 1); + + return 0; +} + +LIB_EXPORT int l_term_set_input_stdin(struct l_term *term) +{ + return l_term_set_input(term, STDIN_FILENO); +} + +LIB_EXPORT int l_term_set_output_stdout(struct l_term *term) +{ + return l_term_set_output(term, STDOUT_FILENO); +} + +LIB_EXPORT int l_term_set_key_handler(struct l_term *term, + l_term_key_func_t handler, void *user_data) +{ + if (!term) + return -EINVAL; + + term->key_handler = handler; + term->key_data = user_data; + + return 0; +} + +LIB_EXPORT bool l_term_io_callback(struct l_io *io, void *user_data) +{ + struct l_term *term = user_data; + + l_term_process(term); + + return true; +} + +static void sigwinch_handler(void *user_data) +{ + struct l_term *term = user_data; + + term->out_ops->get_winsize(term->out_fd, + &term->num_row, &term->num_col); +} + +LIB_EXPORT int l_term_open(struct l_term *term) +{ + struct termios termios; + int retval = 0; + + if (!term) + return -EINVAL; + + /* Missing input or output file descriptor is a non-recoverable + * situation at this point. + */ + if (term->in_fd < 0 || term->out_fd < 0) + return -EBADF; + + /* If no input operations are provided, fallback to use TTY + * defaults or null setting. + */ + if (!term->in_ops) { + if (isatty(term->in_fd)) + term->in_ops = &default_tty_ops; + else + term->in_ops = &default_null_ops; + } + + /* If no output operations are provided, fallback to use TTY + * defaults or null setting. + */ + if (!term->out_ops) { + if (isatty(term->out_fd)) + term->out_ops = &default_tty_ops; + else + term->out_ops = &default_null_ops; + } + + /* Save current termios setting of input */ + memset(&term->in_termios, 0, sizeof(term->in_termios)); + retval = term->in_ops->get_attr(term->in_fd, &term->in_termios); + if (retval < 0) + return retval; + + /* Save current termios setting of output */ + memset(&term->out_termios, 0, sizeof(term->out_termios)); + retval = term->out_ops->get_attr(term->out_fd, &term->out_termios); + if (retval < 0) + return retval; + + /* Disable canonical mode (ICANON), disable echoing of input + * characters (ECHO) and disable generating signals. + * + * In noncanonical mode input is available immediately (without + * the user having to type a line-delimiter character), no input + * processing is performed, and line editing is disabled. + * + * When any of the characters INTR, QUIT, SUSP, or DSUSP are + * received, don't generate the corresponding signal. + */ + memcpy(&termios, &term->in_termios, sizeof(termios)); + termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG); + retval = term->in_ops->set_attr(term->in_fd, &termios); + if (retval < 0) + return retval; + + /* Send TIOCGWINSZ ioctl to retrieve col and row number */ + retval = term->out_ops->get_winsize(term->out_fd, + &term->num_row, &term->num_col); + if (retval < 0) + return retval; + + /* Setup SIGWINCH window resize signal handler if supported */ + if (term->out_ops->use_sigwinch) + term->sigwinch = l_signal_create(SIGWINCH, sigwinch_handler, + term, NULL); + + IO_HANDLER(term, term->in_fd, 1, 0); + IO_HANDLER(term, term->out_fd, 0, 1); + + term->is_running = true; + + return retval; +} + +LIB_EXPORT int l_term_close(struct l_term *term) +{ + int retval = 0; + + if (!term) + return -EINVAL; + + term->is_running = false; + + IO_HANDLER(term, term->in_fd, 0, 0); + IO_HANDLER(term, term->out_fd, 0, 0); + + /* Remove SIGWINCH window resize signal handler */ + if (term->out_ops->use_sigwinch) + l_signal_remove(term->sigwinch); + + /* Restore previous termios setting from input and output */ + retval = term->in_ops->set_attr(term->in_fd, &term->in_termios); + if (retval < 0) + return retval; + + retval = term->out_ops->set_attr(term->out_fd, &term->out_termios); + if (retval < 0) + return retval; + + return retval; +} + +LIB_EXPORT void l_term_process(struct l_term *term) +{ + wchar_t wstr[2]; + ssize_t len; + mbstate_t ps; + + if (!term) + return; + + len = read(term->in_fd, term->key_buf + term->key_len, + sizeof(term->key_buf) - term->key_len); + if (len < 0) + return; + + term->key_len += len; + + while (term->key_len > 0) { + memset(&ps, 0, sizeof(ps)); + + len = mbrtowc(wstr, term->key_buf, term->key_len, &ps); + if (len < 0) + break; + + memmove(term->key_buf, term->key_buf + len, + term->key_len - len); + term->key_len -= len; + + if (term->key_handler) { + wint_t wch = wstr[0]; + term->key_handler(term, wch, term->key_data); + } + } +} + +LIB_EXPORT int l_term_putnstr(struct l_term *term, const char *str, size_t n) +{ + ssize_t res; + + if (!term) + return -EINVAL; + + if (!term->is_running) + return -EPERM; + + res = write(term->out_fd, str, n); + if (res < 0) + return -errno; + + return 0; +} + +LIB_EXPORT int l_term_putstr(struct l_term *term, const char *str) +{ + if (!str) + return -EINVAL; + + return l_term_putnstr(term, str, strlen(str)); +} + +LIB_EXPORT int l_term_putchar(struct l_term *term, int ch) +{ + char c = ch; + + return l_term_putnstr(term, &c, 1); +} + +LIB_EXPORT int l_term_print(struct l_term *term, const char *str, ...) +{ + va_list ap; + int retval; + + va_start(ap, str); + + retval = l_term_vprint(term, str, ap); + + va_end(ap); + + return retval; +} + +LIB_EXPORT int l_term_vprint(struct l_term *term, const char *str, va_list ap) +{ + if (!term || !str) + return -EINVAL; + + if (!term->is_running) + return -EPERM; + + if (vdprintf(term->out_fd, str, ap) < 0) + return -errno; + + return 0; +} + +LIB_EXPORT int l_term_set_bounds(struct l_term *term, uint16_t rows, + uint16_t columns) +{ + if (!term) + return -EINVAL; + + term->num_row = rows; + term->num_col = columns; + + return 0; +} + +LIB_EXPORT int l_term_get_rows(struct l_term *term, uint16_t *rows) +{ + int retval = 0; + + if (!term) + return -EINVAL; + + if (!term->out_ops) + return -ENOSYS; + + retval = term->out_ops->get_winsize(term->out_fd, rows, NULL); + + return retval; +} + +LIB_EXPORT int l_term_get_columns(struct l_term *term, uint16_t *columns) +{ + int retval = 0; + + if (!term) + return -EINVAL; + + if (!term->out_ops) + return -ENOSYS; + + retval = term->out_ops->get_winsize(term->out_fd, NULL, columns); + + return retval; +} diff --git a/ell/term.h b/ell/term.h new file mode 100644 index 000000000000..89ed6c97c7ce --- /dev/null +++ b/ell/term.h @@ -0,0 +1,69 @@ +/* + * Embedded Linux library + * Copyright (C) 2023-2024 Intel Corporation + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef __ELL_TERM_H +#define __ELL_TERM_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct l_term; + +struct l_term *l_term_new(void); +void l_term_free(struct l_term *term); + +typedef void (*l_term_io_func_t)(struct l_term *term, + int fd, + bool readable, + bool writable, + void *user_data); + +int l_term_set_io_handler(struct l_term *term, + l_term_io_func_t handler, + void *user_data); + +int l_term_set_input(struct l_term *term, int fd); +int l_term_set_output(struct l_term *term, int fd); + +int l_term_set_input_stdin(struct l_term *term); +int l_term_set_output_stdout(struct l_term *term); + +typedef void (*l_term_key_func_t) (struct l_term *term, wint_t wch, void *user_data); + +int l_term_set_key_handler(struct l_term *term, + l_term_key_func_t handler, void *user_data); + +int l_term_open(struct l_term *term); +int l_term_close(struct l_term *term); + +bool l_term_io_callback(struct l_io *io, void *user_data); + +void l_term_process(struct l_term *term); + +int l_term_putnstr(struct l_term *term, const char *str, size_t n); +int l_term_putstr(struct l_term *term, const char *str); +int l_term_putchar(struct l_term *term, int ch); +int l_term_print(struct l_term *term, const char *str, ...); +int l_term_vprint(struct l_term *term, const char *str, va_list ap); + +int l_term_set_bounds(struct l_term *term, uint16_t rows, uint16_t columns); + +int l_term_get_rows(struct l_term *term, uint16_t *rows); +int l_term_get_columns(struct l_term *term, uint16_t *columns); + +#ifdef __cplusplus +} +#endif + +#endif /* __ELL_TERM_H */ From patchwork Sun Apr 6 22:05:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039537 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C4832E62C for ; Sun, 6 Apr 2025 22:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977482; cv=none; b=bztyfIxmM5ZFBPa6xlDHj2cowww1AvMEbx8lESz87JRTPUgGMh9c3myYeCh7tAwx3AydkCLZZKIcZwYZrSQeFy7YUbShXc/wRIzRKXUa8VWRH2R5VMnxAwQ+YQh1sxMS3+jlIh+rpKoc0/GJHpMbQGF3pKjMyejR84IN4fpDTWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977482; c=relaxed/simple; bh=6hoS0wp7r8aA5i4svIyT6icEwxy0IsxgYMY+v1EsfLk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=am+p0GdQlG1xEIoRy53/z3E9r4Modc+AkoPKCGpcAdryQUd3g2AbQ5Nn1a/9JhxCOtyWigyulRlDdceKovoA9vVNkxzb4fHN05WBkEVK7yMM9rJtRSzYnQZ4fJ83SiAIJNth8VPlbW/a6i+VyLjipuc79XZY4s9vErdU4YEGf9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=mULuoK1Z; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="mULuoK1Z" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 313AF164A4D for ; Sun, 6 Apr 2025 18:06:08 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id D51C4124FD2 for ; Sun, 6 Apr 2025 18:06:07 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 2/9] ell: Add include directive for 'ell/term.h'. Date: Sun, 6 Apr 2025 15:05:58 -0700 Message-ID: <1492d6bfdbf32b52f07c531235bb2437c0313be1.1743976923.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=aEf/AjCWKiblwanNvh2Fi4UB/LwhpwC01iJUuCygrBw=; b=mULuoK1Z3o2EU4arNyvdt+rehA2ppP6Z7Z/zl9tTvXRuo4SP1pfmJ/bheiHKIo+qeyW3oFun18gI7ApnlQNolsMPgQxysUqbB3ktxkXLHe98LfkgYEDVR64Eta8lJ8lWUcp/MY6wkq54FlaXOEquclerPceM6IeQxF894zlztCLKF0kZD4lFh54mhN9w/Zbq3UT8uhVUkxmBzwVXjdR01TuXJrkRuNB8RVlptlGovV+1xWBIpnYIeCXIe1TwVEIWbs0Hl+X1NA8P5j1UsW9Em/mPuVQ5knWWBhBfZaPkEpM4yGwvrw2siiVAwsYW3QaXhPFtDJcGlq2ylYAflHdU8A== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 --- ell/ell.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ell/ell.h b/ell/ell.h index 7a263e9376de..1176c163f4f9 100644 --- a/ell/ell.h +++ b/ell/ell.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include From patchwork Sun Apr 6 22:05:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039541 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64846192D8E for ; Sun, 6 Apr 2025 22:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977483; cv=none; b=tbHzBM516uPkls+34N+6cNR68si/yFTuEIneYCQ1ZL60dwSQKjUH5Bu7sfbOVAVUHCtD7I0W2bq8XgLWD0oP378kP9s+bzsyVy9bFE+l3eViBFTvcW2iRhtUaf2vIT9Jv+nnqTfDzkU/LK33fnlUpptpsK5Vnaa9ZpUjtXIw/Do= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977483; c=relaxed/simple; bh=fRkzmZRGdxbkgj6ayYhovsCM0Axfddw1UotV1+8U4pA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qC+e3B09Y1BRfjmW28B9qyyXC9O5bKMX3CZMWzOzibm9oXDcOT+ELqkpt4ovRryfU6rCISx6KCKnXF9XzZ9VxEWg0h3RZ+wGUyb23WPD3aUbFuz/WG2/qzzO+288VB75i/AMwO5iaKvdwfcvIEUlbGh7tyijVT+7uBYCkEIiH8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=lE3FqXCC; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="lE3FqXCC" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id A2198164A54 for ; Sun, 6 Apr 2025 18:06:08 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 508FD124FD2 for ; Sun, 6 Apr 2025 18:06:08 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 3/9] ell/Makefile: Added 'term.[ch]' to HEADERS and SOURCES. Date: Sun, 6 Apr 2025 15:05:59 -0700 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=gFMIYXSzppPP0Uq6G7EQCpPmi+Fg/KcQ7tS2o2n4KZI=; b=lE3FqXCCP+hWO44+Ddrg8zY00S5OmFP6kRxWPo0KdxRzEW477sShslcrq08EkRxt4yITmGDLkZiTpvuADHz3Obip+HMCQkidZ3M3j9IO8B13A96Qie0fmhucr4gPp5Clir7LI8graDxuLfEax8VVO/1fNiixr3IYF0Gt1xlcW0dLWYsq/OF6ySJ0d8mLAgi7Vtx7DeTOOwf1YSMQTAlnwvZYsbi7g+sjfremC8tXuH/jyjSwYhBgGKFSAuvqIhzpO2OrO7injQwd5EPPvDmFVRTc/jxkZPK3InNsQQmGJfhUEC7aZTKQmiPVmx4z5+42D45dxfy5UEFwBnCe2nHUMQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index 84d008febe0c..abe5ac905684 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,6 +55,7 @@ pkginclude_HEADERS = ell/ell.h \ ell/ecc.h \ ell/ecdh.h \ ell/time.h \ + ell/term.h \ ell/gpio.h \ ell/path.h \ ell/icmp6.h \ @@ -148,6 +149,7 @@ ell_libell_la_SOURCES = $(linux_headers) \ ell/ecdh.c \ ell/time.c \ ell/time-private.h \ + ell/term.c \ ell/gpio.c \ ell/path.c \ ell/icmp6.c \ From patchwork Sun Apr 6 22:06:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039538 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6489B197A8A for ; Sun, 6 Apr 2025 22:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977482; cv=none; b=ujzCoztGXeQ4HtkBfV1C8MU/zqZm4w4shs5JALtTAhqQn+9/QWTSdfKsoFfx/Wg2xrYxYwzkGYNS2hKjjBytSKwfazGsBynveWPD7UY+JRqMALuunT6OEmoxDHG7ARe/PBOe4XdQtlVx4089jRoeM+9kRbGATqXaVfszKY4NaoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977482; c=relaxed/simple; bh=HoH0fnElLVu4zqlw1gFKDPAhSGYzo5E0VyXoVOrwLcQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HX22j8twbixUs+TwM5re05QTyW6fENZ0s++E+Xa5qnuQJ2IZ2psgxTHJ08xR3rc3U7DEg486ej2AUjCPuyEs6aMWGdp3dOc9TDNEorOQe+6qBWHWEwyzbMXrVgsp/FumnUxaNKHQOTpHcbRrvVnkJjXdUwF83mv0ijdPUUARaNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=m2gR3wVN; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="m2gR3wVN" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 14434164A58 for ; Sun, 6 Apr 2025 18:06:09 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id C2D0D124FD2 for ; Sun, 6 Apr 2025 18:06:08 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 4/9] term: Added 'l_term_*' symbols. Date: Sun, 6 Apr 2025 15:06:00 -0700 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=Lu2apvJtfyPUIFb59w3g/V32Nu756tVL2gwncU8sOr8=; b=m2gR3wVN2Cp7JYgGcVCOMwv3QLassAmlOOsnNFfC9wzTxW6w8RNDjYSjQauZ0fwi5LQsmWHy6CRmturefXEaSOvmlF7Tfp7eInOTFKynVXnY8DlQRXbsEykEZFsc1XR1/FVMLaXjfMW/M1rOOhfSKXnQeJep2ldv4Ha+Kmny4CJNKMiDjyXXnQlh+jCTH3wBK4x8o8eMacqdsEgmz3Wxqd84raXwpJnbcxMvJqIgR8FMoDo0X+ecfCx3e8K+M3SYmeQ/ZGdAPxbm1/J3AZk/hts3Cz3w4fiila+Curgrr/CxtDzAEpEj+4yDH6hE3aZ38CxAaCya7G83xq6u2EmULA== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 --- ell/ell.sym | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ell/ell.sym b/ell/ell.sym index f192c471a40c..0d009e2d1927 100644 --- a/ell/ell.sym +++ b/ell/ell.sym @@ -643,6 +643,27 @@ global: l_ecdh_generate_shared_secret; /* time */ l_time_now; + /* term */ + l_term_new; + l_term_free; + l_term_set_io_handler; + l_term_set_input; + l_term_set_input_stdin; + l_term_set_output; + l_term_set_output_stdout; + l_term_set_key_handler; + l_term_open; + l_term_close; + l_term_io_callback; + l_term_process; + l_term_putnstr; + l_term_putstr; + l_term_putchar; + l_term_print; + l_term_vprint; + l_term_set_bounds; + l_term_get_rows; + l_term_get_columns; /* gpio */ l_gpio_chips_with_line_label; l_gpio_chip_new; From patchwork Sun Apr 6 22:06:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039535 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AACF195B37 for ; Sun, 6 Apr 2025 22:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977177; cv=none; b=GqtAff3q6ZPvjfYKI9QvEu51ODZwZmsc1tslQ0PMR9T/aC+8EG5toAHxe+83RjkWhy4duoPEhFrCnA5rocJVNXujVvwd7gsJOOQFQ9q+30Z64gmfHr3h7gLJEoz4m/XK09EBkNeCQsrNEZu9e5xF5YR6a4l11VgiptimNq/T5tQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977177; c=relaxed/simple; bh=5A7aExH5CXnnl7ZSrAAxqeZ0qj7gifHHSe5hE/cYEOw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eDGAeFbr/gMxuHh9WXYG0UCvZigQEz4AaGTX3rIz8EvArL2G96MuEagsv5x4YVQ8CeE2/qtKTETyV5MQHyCgt89I4ywg/J4YOa7U0USvsdDoAWKes/DO00Q7JXHh0L0Q72sTEYs0+y/6MBs1BvWwUtBKsKbF56bv5febAIO7Teg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=VEtnzkDt; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="VEtnzkDt" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 7C6BD164A6C for ; Sun, 6 Apr 2025 18:06:09 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 36870124FD2 for ; Sun, 6 Apr 2025 18:06:09 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 5/9] ell/term: Do not return -EPERM for 'putnstr' and 'vprint' if not running. Date: Sun, 6 Apr 2025 15:06:01 -0700 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=UguIu9Ao5RDzjbSZyHL7echnIxZePIlVRFyTddcKvsI=; b=VEtnzkDtde9mLe3q/d2iEB52A4FEqruq0tp8iFKoRQ/t1VdyJa59jlmRvdXVTpGUs8Rl2vkXShXLggRIu4aPSsIFdGhzfKztOS9nM6Wo7+0Mh4fRqBD5prQPcKJMuWpnaQRxQq5RscRY0IeaIpis2eZ9WUAZDAc0DcuWnIkaqjfFicJFbpFBQFKR+HTto0URzXEwjyibrkc6u7YZy7Rl5D2SXDnTk975YCAbboQki3Pibi5QK1IcQsRXKdb1JiDyzuJtLN6ST2kvrdKhB5BHRZMEFedFXUxewAYTSMis+l5IS/EGR2Ae09lTx1IdFVr+22iA4wD/HluD5ylKN46HlQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 If the 'is_running' flag is not asserted there is no need to return -EPERM since it is still valid to write to the terminal when it is not running. --- ell/term.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ell/term.c b/ell/term.c index 81df771ff07f..c867b240090c 100644 --- a/ell/term.c +++ b/ell/term.c @@ -391,9 +391,6 @@ LIB_EXPORT int l_term_putnstr(struct l_term *term, const char *str, size_t n) if (!term) return -EINVAL; - if (!term->is_running) - return -EPERM; - res = write(term->out_fd, str, n); if (res < 0) return -errno; @@ -435,9 +432,6 @@ LIB_EXPORT int l_term_vprint(struct l_term *term, const char *str, va_list ap) if (!term || !str) return -EINVAL; - if (!term->is_running) - return -EPERM; - if (vdprintf(term->out_fd, str, ap) < 0) return -errno; From patchwork Sun Apr 6 22:06:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039532 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AA048C1F for ; Sun, 6 Apr 2025 22:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977176; cv=none; b=WlOAintK5Jg0O/wN85fTXfDVRP5+1UeT4YvWV2N2GqFynr2mHLnckcWIuqU1k12YjFZwXpiaVNZOFMVB4Vl0yHJi3sq8LSSo114hqz8v+hTeWnwDRwhiBX8w7KUfPz22jqeiqsGHsgUxXlhMHU0Z4HN+Livq8ne3IGEcGrbLEyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977176; c=relaxed/simple; bh=Cu49dRnhNbz1XpUGX7De4zO0o7Qd9uEbPJlTMpR4J9k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HwKGXVFFbIc+UptPKE2HfUPepLwQtBb/SIkqGpB6gMH05W5mb/HytdeSB60LaRmm+BzYT6P+HWpWYHBQCpvQ5C5BgbmoNCB2ZuvFsrfFBlcXDczduBDujkJUA4KLALNATCpaUqMO9RbUPv4QG9UtJqOfm1m7up5Phvhen9Ker24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=jtJHbJEP; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="jtJHbJEP" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id E22F3164A6F for ; Sun, 6 Apr 2025 18:06:09 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 9B8BF124FD2 for ; Sun, 6 Apr 2025 18:06:09 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 6/9] ell/term: Return error on writes if the output descriptor is invalid. Date: Sun, 6 Apr 2025 15:06:02 -0700 Message-ID: <7de7f13c49042a0e09fe9760055c81787b3aee4b.1743976923.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=iktyWn9nIxURY4iSzPRdEdGBc8zwcnlOyw/qDmgcL9k=; b=jtJHbJEPVvcDyXta+CaxM9dvw9R7mR4vl7iZEspXgHNEqV8SoXccvYLHgNRrJKed+HPOvV8wYCVQETgJhApcTXsoU2YOibnmcYuuqcwAzQ6j/n/x1FcDKa6OkFHNZlUONFRJxX7Z7hwcK4zOQlxNIgMfEZtygGp+hiTpzgL0EYPTE2ylFjdaJbY+f3b5KFmIwEVUMpgyO/hkc0VpZPd+N+/9PlJoTwEFgAWwo1OjYR6J+uVZXeIq6oyY7yYd9UDMbYzXS+YjAoIm07RtwpAfpQQTzIebi2tX1izeY9VGPrkKcdcUC1+n0ogAGBkxeazNDzRnPLhOIDZwpgjFAMl1XQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Returns -EBADF for 'putnstr' and 'vdprintf' if the output descriptor for the terminal is invalid. --- ell/term.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ell/term.c b/ell/term.c index c867b240090c..7ec92476e14e 100644 --- a/ell/term.c +++ b/ell/term.c @@ -391,6 +391,9 @@ LIB_EXPORT int l_term_putnstr(struct l_term *term, const char *str, size_t n) if (!term) return -EINVAL; + if (term->out_fd < 0) + return -EBADF; + res = write(term->out_fd, str, n); if (res < 0) return -errno; @@ -432,6 +435,9 @@ LIB_EXPORT int l_term_vprint(struct l_term *term, const char *str, va_list ap) if (!term || !str) return -EINVAL; + if (term->out_fd < 0) + return -EBADF; + if (vdprintf(term->out_fd, str, ap) < 0) return -errno; From patchwork Sun Apr 6 22:06:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039533 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AA3751C5A for ; Sun, 6 Apr 2025 22:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977176; cv=none; b=rvFf+vAAf4S8yGer/B68XMdxVTJv8zaOHELQMzOgACKKGi1XMlCBI5qPsFxpoeno1Y9+5xp+7S15ruBjEXJGmWYdL0CBeMd/AJtTxlb4w0fJml78uJuVLL3LeEtx6zB83p1OZ9w0J7ncc/PXS794nvOTaICBLg3cgq/HZM76nZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977176; c=relaxed/simple; bh=FjOKYUsw/TLYpzGX/kd3ZkR8//BoH7jon518qSbAluI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s/EeHJhy+Esdenovb+6gFS5LzVGKd0Wkz277sTFP/RrueFOSQmL2VLYySaNOwu4Hk/0PVyaE9EkaVHpFsSGtmm/BOeF7ybqCaQu5n4TjTXv2Uw406OdER0LD4KyAR4APGTEIgjFe31goTEV8eCJYo6/3JxSl+u1Bmk8vuUegBtg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=lxSavuDA; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="lxSavuDA" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 56733164A70 for ; Sun, 6 Apr 2025 18:06:10 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 0DBD4124FD2 for ; Sun, 6 Apr 2025 18:06:09 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 7/9] ell/edit: Rename 'l_term_{open,close}'. Date: Sun, 6 Apr 2025 15:06:03 -0700 Message-ID: <0d4caa68d67e0a8f4e0e56c8208c6839248e8c65.1743976923.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=V7ZWljNcSGf85DkFCs4DEofrQf9uRpcrAMQ7kJxeKtA=; b=lxSavuDAUWMvixILq2vL2/lp/qlUXUeHf3MEk5xPtsRXPeghnP6R/UigmSHlf8WhTOSvJbGQEgMdknp86ckbspK5u5yhcK/cL8PXXWzfa2eOucJXFVIKD1VWdLxDHd3gGUCmtQKYV+jk3UQ+obDpQJzccCaBK40MDnqi3xwSMpyLEnXNSGkUkNfb823XTGSmvhFuX+jsEgrV3qKYewaxe43ckDzyLGl1OEVr7kGHROs0ewwMSRqQZyjSV/0wDVolSBFR6HZnykx4nBiVtEwftKMcPZ7ygp9itWaFeWQHrDo2XE5YvZQ7Yez9GJ6ZVElJzgKmIrur3xMrKlDDef5tyg== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Renames 'l_term_{open,close}' to 'l_term_{acquire,release}' since this aligns more closely with what is happening with the underlying file descriptors. In particular, those descriptors are not being opened or closed. Rather, their TTY parameters are being saved and altered on 'open' (now 'acquire') and restored on 'close' (now 'release'). At no point are the descriptors being transformed with the 'open' or 'close' system calls. --- ell/ell.sym | 4 ++-- ell/term.c | 18 ++++++++++++------ ell/term.h | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ell/ell.sym b/ell/ell.sym index 0d009e2d1927..2e198bd57461 100644 --- a/ell/ell.sym +++ b/ell/ell.sym @@ -652,8 +652,8 @@ global: l_term_set_output; l_term_set_output_stdout; l_term_set_key_handler; - l_term_open; - l_term_close; + l_term_acquire; + l_term_release; l_term_io_callback; l_term_process; l_term_putnstr; diff --git a/ell/term.c b/ell/term.c index 7ec92476e14e..f3801bcb1200 100644 --- a/ell/term.c +++ b/ell/term.c @@ -126,7 +126,7 @@ struct l_term { unsigned short num_row; unsigned short num_col; struct l_signal *sigwinch; - bool is_running; + bool is_acquired; char key_buf[8]; size_t key_len; l_term_key_func_t key_handler; @@ -145,7 +145,7 @@ LIB_EXPORT struct l_term *l_term_new(void) term->out_fd = -1; term->out_ops = NULL; - term->is_running = false; + term->is_acquired = false; return term; } @@ -241,7 +241,7 @@ static void sigwinch_handler(void *user_data) &term->num_row, &term->num_col); } -LIB_EXPORT int l_term_open(struct l_term *term) +LIB_EXPORT int l_term_acquire(struct l_term *term) { struct termios termios; int retval = 0; @@ -249,6 +249,9 @@ LIB_EXPORT int l_term_open(struct l_term *term) if (!term) return -EINVAL; + if (term->is_acquired) + return -EALREADY; + /* Missing input or output file descriptor is a non-recoverable * situation at this point. */ @@ -317,19 +320,20 @@ LIB_EXPORT int l_term_open(struct l_term *term) IO_HANDLER(term, term->in_fd, 1, 0); IO_HANDLER(term, term->out_fd, 0, 1); - term->is_running = true; + term->is_acquired = true; return retval; } -LIB_EXPORT int l_term_close(struct l_term *term) +LIB_EXPORT int l_term_release(struct l_term *term) { int retval = 0; if (!term) return -EINVAL; - term->is_running = false; + if (!term->is_acquired) + return -EALREADY; IO_HANDLER(term, term->in_fd, 0, 0); IO_HANDLER(term, term->out_fd, 0, 0); @@ -347,6 +351,8 @@ LIB_EXPORT int l_term_close(struct l_term *term) if (retval < 0) return retval; + term->is_acquired = false; + return retval; } diff --git a/ell/term.h b/ell/term.h index 89ed6c97c7ce..50831c166c78 100644 --- a/ell/term.h +++ b/ell/term.h @@ -44,8 +44,8 @@ typedef void (*l_term_key_func_t) (struct l_term *term, wint_t wch, void *user_d int l_term_set_key_handler(struct l_term *term, l_term_key_func_t handler, void *user_data); -int l_term_open(struct l_term *term); -int l_term_close(struct l_term *term); +int l_term_acquire(struct l_term *term); +int l_term_release(struct l_term *term); bool l_term_io_callback(struct l_io *io, void *user_data); From patchwork Sun Apr 6 22:06:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039534 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AA83192B7D for ; Sun, 6 Apr 2025 22:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977177; cv=none; b=M7k8nDy9xDHnPFh7Pf9vJtKUzETS+XjR73/B4FPOIlnewyBv9Xup67PYMr5xaLcZv1p5su/DtdFWuDnEGzeMLL3TVrnQ+Wmb+xUZR16kHnKr6TrDdP9kIrTXVnFj8hyPymJm9zmBPO8JPygw17c1eppTAaMvoWs7CIh0Vd/MNiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977177; c=relaxed/simple; bh=8BC1eD/l+/I4U7pptyti+bNAYN1xzNUT/OVJvakBtp8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aa0qPeSZV42lg+yBQfM30GKp0dzR2icTzTjC4af6ULkNyi+bVeXNu1PXsC4gXcfwM+ZQxrOzKpXyw4E6WTgPhhp2XOkzO/IJvdMpZRAEfLHm9u9MnogOiIr0knn658L9mEMiwjUXTTnVbnWjwkEeKEQ4+t5TQDO0W91TTcH2IZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=hDn63fQ/; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="hDn63fQ/" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id BDCD7164A71 for ; Sun, 6 Apr 2025 18:06:10 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 76C30124FD2 for ; Sun, 6 Apr 2025 18:06:10 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 8/9] ell/term: Add an 'l_term_is_acquired' introspection function. Date: Sun, 6 Apr 2025 15:06:04 -0700 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=ApiDEOp2NYQK7ekk9BikRmcUGFlx5Z9vqHyRXsK1tl4=; b=hDn63fQ/p9TNCI3Yc4feGU6Zt6TsWw/WeL9/Q+mCS6rYuJCFPmVW8JO/Y9lAtsm6Aw1s19JmdPOtHJKjR13IzeGFx12Uj856YKH/HmkhFR7VJZoJltHaX2qjR9JfbtTo0wKCHZANL0jbEBJbvQaekRHF5hex0IxNcpBSb5YPDwgETgzvaCVhjRwSdkIwDYBhHWiN1shALH9590YURRvM9P+cXx/8YkvvTEt4Cxrbh+zb0ae3XUzVVj5CDhVkuKySYHKPogcukuG6ebNemwCyjlcQONo5StZvDo5IHY4Do4w9dtBEnDg/Nbt9FCjUZEbKK3r6cdanhQRSFDcSJgMRRQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Adds an 'l_term_is_acquired' introspection function that indicates whether the terminal has acquired and modified the TTY settings for the input and output descriptors associated with the terminal. --- ell/ell.sym | 1 + ell/term.c | 8 ++++++++ ell/term.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/ell/ell.sym b/ell/ell.sym index 2e198bd57461..9c149d717e48 100644 --- a/ell/ell.sym +++ b/ell/ell.sym @@ -652,6 +652,7 @@ global: l_term_set_output; l_term_set_output_stdout; l_term_set_key_handler; + l_term_is_acquired; l_term_acquire; l_term_release; l_term_io_callback; diff --git a/ell/term.c b/ell/term.c index f3801bcb1200..a56ede4e98ec 100644 --- a/ell/term.c +++ b/ell/term.c @@ -241,6 +241,14 @@ static void sigwinch_handler(void *user_data) &term->num_row, &term->num_col); } +LIB_EXPORT bool l_term_is_acquired(struct l_term *term) +{ + if (!term) + return false; + + return term->is_acquired; +} + LIB_EXPORT int l_term_acquire(struct l_term *term) { struct termios termios; diff --git a/ell/term.h b/ell/term.h index 50831c166c78..66059212b436 100644 --- a/ell/term.h +++ b/ell/term.h @@ -44,6 +44,8 @@ typedef void (*l_term_key_func_t) (struct l_term *term, wint_t wch, void *user_d int l_term_set_key_handler(struct l_term *term, l_term_key_func_t handler, void *user_data); +bool l_term_is_acquired(struct l_term *term); + int l_term_acquire(struct l_term *term); int l_term_release(struct l_term *term); From patchwork Sun Apr 6 22:06:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 14039536 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACDCC19F47E for ; Sun, 6 Apr 2025 22:06:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977178; cv=none; b=iiQRfgoMDB8Ltx6LqA/zbJOOiyhzSrFMuvUA544vslncNoxfmInnFaF/rc67XCtn2h1P5iK2b4FK5uxbraw8PvewBk/pfQEZ5XSFkbNUDxuRa/E20bA0nVadI15Ind67OzGqc/cZGSq4qcMAy0PjKS+7wE2geB/b+lh+vBsHpIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743977178; c=relaxed/simple; bh=egO+blyFRYLikI1jPGLm0nJ/SESuPuwDPkZcoXbyXkc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D5tXvv1AJoBB/IqH4Jjq5VNACH0JGzRsehkdElhoOWVGY5khQnn2UNNsPyR0BrGafqupDI7JASz9ZNK6jodvjKnIlmtf+C0Es5MRhFiMFoyihWO2v3TwYJvE3wgDI79U9oFyWxEZlfa/OCFRkiOqBXuHz+R3ekjngPMs0ArJsk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=AIGrNwAK; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="AIGrNwAK" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 3389B164A72 for ; Sun, 6 Apr 2025 18:06:11 -0400 (EDT) Received: from localhost.localdomain (c-73-202-173-252.hsd1.ca.comcast.net [73.202.173.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id DEA16124FD2 for ; Sun, 6 Apr 2025 18:06:10 -0400 (EDT) From: Grant Erickson To: ell@lists.linux.dev Subject: [PATCH v9 9/9] ell/term: Added ASCII C0 and C1 control code mnemonics. Date: Sun, 6 Apr 2025 15:06:05 -0700 Message-ID: <5b36d51d3fea051a16ec8ced7f14fdcf73ec2376.1743976923.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: ell@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=7TnTC3Vqi3pTKGHH6obBwZ0+6KemKWYxF5jHkUYUUEQ=; b=AIGrNwAKGbFGlynWbTG6kbVu3qC6LevSbtoIX7VbXratkUoYtPgofHlG7gEKINqG1K3LdW4Dn4kZO3PqMawwDULWGH2CqdFquZ9jFMlOyYqlvrQYVooU6yt5MZAG4KCIB8rXfdw3QtH6FVtMU7MC8gCgRdiIlmQO6DCFxzw2QfZnIXkDxkyv7+8ZiLuo9jnok01kNbAup5RftEY5gQcS7DARaFoeFOW6BlsUOiHfyUJZSW794uaqKvVLPvVZGlG5+NyPJVee2u/6ZGYAbB2AKfq1dONXPMRhmh1NfhP58lglIaBHv1A4HYEC/GwUgL1qo/os0BEu/MA+MRa9s+TF5A== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Added ASCII C0 and C1 control code mnemonics useful to anyone implementing a l_term key handler. --- ell/term.h | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/ell/term.h b/ell/term.h index 66059212b436..7a0338bd95e0 100644 --- a/ell/term.h +++ b/ell/term.h @@ -18,6 +18,150 @@ extern "C" { #endif +enum { + L_TERM_CONTROL_CODE_ASCII_C0_NUL = 0x00, + L_TERM_CONTROL_CODE_ASCII_C0_SOH = 0x01, + L_TERM_CONTROL_CODE_ASCII_C0_TC1 = L_TERM_CONTROL_CODE_ASCII_C0_SOH, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_A = L_TERM_CONTROL_CODE_ASCII_C0_SOH, + L_TERM_CONTROL_CODE_ASCII_C0_STX = 0x02, + L_TERM_CONTROL_CODE_ASCII_C0_TC2 = L_TERM_CONTROL_CODE_ASCII_C0_STX, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_B = L_TERM_CONTROL_CODE_ASCII_C0_STX, + L_TERM_CONTROL_CODE_ASCII_C0_ETX = 0x03, + L_TERM_CONTROL_CODE_ASCII_C0_TC3 = L_TERM_CONTROL_CODE_ASCII_C0_ETX, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_C = L_TERM_CONTROL_CODE_ASCII_C0_ETX, + L_TERM_CONTROL_CODE_ASCII_C0_EOT = 0x04, + L_TERM_CONTROL_CODE_ASCII_C0_TC4 = L_TERM_CONTROL_CODE_ASCII_C0_EOT, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_D = L_TERM_CONTROL_CODE_ASCII_C0_EOT, + L_TERM_CONTROL_CODE_ASCII_C0_ENQ = 0x05, + L_TERM_CONTROL_CODE_ASCII_C0_TC5 = L_TERM_CONTROL_CODE_ASCII_C0_ENQ, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_E = L_TERM_CONTROL_CODE_ASCII_C0_ENQ, + L_TERM_CONTROL_CODE_ASCII_C0_ACK = 0x06, + L_TERM_CONTROL_CODE_ASCII_C0_TC6 = L_TERM_CONTROL_CODE_ASCII_C0_ACK, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_F = L_TERM_CONTROL_CODE_ASCII_C0_ACK, + L_TERM_CONTROL_CODE_ASCII_C0_BEL = 0x07, + L_TERM_CONTROL_CODE_ASCII_C0_BS = 0x08, + L_TERM_CONTROL_CODE_ASCII_C0_FE0 = L_TERM_CONTROL_CODE_ASCII_C0_BS, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_H = L_TERM_CONTROL_CODE_ASCII_C0_BS, + L_TERM_CONTROL_CODE_ASCII_C0_HT = 0x09, + L_TERM_CONTROL_CODE_ASCII_C0_FE1 = L_TERM_CONTROL_CODE_ASCII_C0_HT, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_I = L_TERM_CONTROL_CODE_ASCII_C0_HT, + L_TERM_CONTROL_CODE_ASCII_C0_LF = 0x0A, + L_TERM_CONTROL_CODE_ASCII_C0_FE2 = L_TERM_CONTROL_CODE_ASCII_C0_LF, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_J = L_TERM_CONTROL_CODE_ASCII_C0_LF, + L_TERM_CONTROL_CODE_ASCII_C0_VT = 0x0B, + L_TERM_CONTROL_CODE_ASCII_C0_FE3 = L_TERM_CONTROL_CODE_ASCII_C0_VT, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_K = L_TERM_CONTROL_CODE_ASCII_C0_VT, + L_TERM_CONTROL_CODE_ASCII_C0_FF = 0x0C, + L_TERM_CONTROL_CODE_ASCII_C0_FE4 = L_TERM_CONTROL_CODE_ASCII_C0_FF, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_L = L_TERM_CONTROL_CODE_ASCII_C0_FF, + L_TERM_CONTROL_CODE_ASCII_C0_CR = 0x0D, + L_TERM_CONTROL_CODE_ASCII_C0_FE5 = L_TERM_CONTROL_CODE_ASCII_C0_CR, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_M = L_TERM_CONTROL_CODE_ASCII_C0_CR, + L_TERM_CONTROL_CODE_ASCII_C0_SO = 0x0E, + L_TERM_CONTROL_CODE_ASCII_C0_LS0 = L_TERM_CONTROL_CODE_ASCII_C0_SO, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_N = L_TERM_CONTROL_CODE_ASCII_C0_SO, + L_TERM_CONTROL_CODE_ASCII_C0_SI = 0x0F, + L_TERM_CONTROL_CODE_ASCII_C0_LS1 = L_TERM_CONTROL_CODE_ASCII_C0_SI, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_O = L_TERM_CONTROL_CODE_ASCII_C0_SI, + L_TERM_CONTROL_CODE_ASCII_C0_DLE = 0x10, + L_TERM_CONTROL_CODE_ASCII_C0_TC7 = L_TERM_CONTROL_CODE_ASCII_C0_DLE, + L_TERM_CONTROL_CODE_ASCII_C0_DC0 = L_TERM_CONTROL_CODE_ASCII_C0_DLE, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_P = L_TERM_CONTROL_CODE_ASCII_C0_DLE, + L_TERM_CONTROL_CODE_ASCII_C0_XON = 0x11, + L_TERM_CONTROL_CODE_ASCII_C0_DC1 = L_TERM_CONTROL_CODE_ASCII_C0_XON, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_Q = L_TERM_CONTROL_CODE_ASCII_C0_XON, + L_TERM_CONTROL_CODE_ASCII_C0_TAPE = 0x12, + L_TERM_CONTROL_CODE_ASCII_C0_DC2 = L_TERM_CONTROL_CODE_ASCII_C0_TAPE, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_R = L_TERM_CONTROL_CODE_ASCII_C0_TAPE, + L_TERM_CONTROL_CODE_ASCII_C0_XOFF = 0x13, + L_TERM_CONTROL_CODE_ASCII_C0_DC3 = L_TERM_CONTROL_CODE_ASCII_C0_XOFF, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_S = L_TERM_CONTROL_CODE_ASCII_C0_XOFF, + L_TERM_CONTROL_CODE_ASCII_C0_DC4 = 0x14, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_T = L_TERM_CONTROL_CODE_ASCII_C0_DC4, + L_TERM_CONTROL_CODE_ASCII_C0_NAK = 0x15, + L_TERM_CONTROL_CODE_ASCII_C0_TC8 = L_TERM_CONTROL_CODE_ASCII_C0_NAK, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_U = 0x15, + L_TERM_CONTROL_CODE_ASCII_C0_SYN = 0x16, + L_TERM_CONTROL_CODE_ASCII_C0_TC9 = L_TERM_CONTROL_CODE_ASCII_C0_SYN, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_V = 0x16, + L_TERM_CONTROL_CODE_ASCII_C0_ETB = 0x17, + L_TERM_CONTROL_CODE_ASCII_C0_TC10 = L_TERM_CONTROL_CODE_ASCII_C0_ETB, + L_TERM_CONTROL_CODE_ASCII_C0_CTRL_W = L_TERM_CONTROL_CODE_ASCII_C0_ETB, + L_TERM_CONTROL_CODE_ASCII_C0_CAN = 0x18, + L_TERM_CONTROL_CODE_ASCII_C0_EM = 0x19, + L_TERM_CONTROL_CODE_ASCII_C0_SUB = 0x1A, + L_TERM_CONTROL_CODE_ASCII_C0_ESC = 0x1B, + L_TERM_CONTROL_CODE_ASCII_C0_FS = 0x1C, + L_TERM_CONTROL_CODE_ASCII_C0_IS4 = L_TERM_CONTROL_CODE_ASCII_C0_FS, + L_TERM_CONTROL_CODE_ASCII_C0_GS = 0x1D, + L_TERM_CONTROL_CODE_ASCII_C0_IS3 = L_TERM_CONTROL_CODE_ASCII_C0_GS, + L_TERM_CONTROL_CODE_ASCII_C0_RS = 0x1E, + L_TERM_CONTROL_CODE_ASCII_C0_IS2 = L_TERM_CONTROL_CODE_ASCII_C0_RS, + L_TERM_CONTROL_CODE_ASCII_C0_US = 0x1F, + L_TERM_CONTROL_CODE_ASCII_C0_IS1 = L_TERM_CONTROL_CODE_ASCII_C0_US, + L_TERM_CONTROL_CODE_ASCII_C0_DEL = 0x7F, + + L_TERM_CONTROL_CODE_ASCII_C1_PAD = 0x80, + L_TERM_CONTROL_CODE_ASCII_C1_HOP = 0x81, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_A = L_TERM_CONTROL_CODE_ASCII_C1_HOP, + L_TERM_CONTROL_CODE_ASCII_C1_BPH = 0x82, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_B = L_TERM_CONTROL_CODE_ASCII_C1_BPH, + L_TERM_CONTROL_CODE_ASCII_C1_NBH = 0x83, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_C = L_TERM_CONTROL_CODE_ASCII_C1_NBH, + L_TERM_CONTROL_CODE_ASCII_C1_IND = 0x84, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_D = L_TERM_CONTROL_CODE_ASCII_C1_IND, + L_TERM_CONTROL_CODE_ASCII_C1_NEL = 0x85, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_E = L_TERM_CONTROL_CODE_ASCII_C1_NEL, + L_TERM_CONTROL_CODE_ASCII_C1_SSA = 0x86, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_F = L_TERM_CONTROL_CODE_ASCII_C1_SSA, + L_TERM_CONTROL_CODE_ASCII_C1_ESA = 0x87, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_G = L_TERM_CONTROL_CODE_ASCII_C1_ESA, + L_TERM_CONTROL_CODE_ASCII_C1_HTS = 0x88, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_H = L_TERM_CONTROL_CODE_ASCII_C1_HTS, + L_TERM_CONTROL_CODE_ASCII_C1_HTJ = 0x89, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_I = L_TERM_CONTROL_CODE_ASCII_C1_HTJ, + L_TERM_CONTROL_CODE_ASCII_C1_VTS = 0x8A, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_J = L_TERM_CONTROL_CODE_ASCII_C1_VTS, + L_TERM_CONTROL_CODE_ASCII_C1_PLD = 0x8B, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_K = L_TERM_CONTROL_CODE_ASCII_C1_PLD, + L_TERM_CONTROL_CODE_ASCII_C1_PLU = 0x8C, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_L = L_TERM_CONTROL_CODE_ASCII_C1_PLU, + L_TERM_CONTROL_CODE_ASCII_C1_RI = 0x8D, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_M = L_TERM_CONTROL_CODE_ASCII_C1_RI, + L_TERM_CONTROL_CODE_ASCII_C1_SS2 = 0x8E, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_N = L_TERM_CONTROL_CODE_ASCII_C1_SS2, + L_TERM_CONTROL_CODE_ASCII_C1_SS3 = 0x8F, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_O = L_TERM_CONTROL_CODE_ASCII_C1_SS3, + L_TERM_CONTROL_CODE_ASCII_C1_DCS = 0x90, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_P = L_TERM_CONTROL_CODE_ASCII_C1_DCS, + L_TERM_CONTROL_CODE_ASCII_C1_PU1 = 0x91, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_Q = L_TERM_CONTROL_CODE_ASCII_C1_PU1, + L_TERM_CONTROL_CODE_ASCII_C1_PU2 = 0x92, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_R = L_TERM_CONTROL_CODE_ASCII_C1_PU2, + L_TERM_CONTROL_CODE_ASCII_C1_STS = 0x93, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_S = L_TERM_CONTROL_CODE_ASCII_C1_STS, + L_TERM_CONTROL_CODE_ASCII_C1_CCH = 0x94, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_T = L_TERM_CONTROL_CODE_ASCII_C1_CCH, + L_TERM_CONTROL_CODE_ASCII_C1_MW = 0x95, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_U = L_TERM_CONTROL_CODE_ASCII_C1_MW, + L_TERM_CONTROL_CODE_ASCII_C1_SPA = 0x96, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_V = L_TERM_CONTROL_CODE_ASCII_C1_SPA, + L_TERM_CONTROL_CODE_ASCII_C1_EPA = 0x97, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_W = L_TERM_CONTROL_CODE_ASCII_C1_EPA, + L_TERM_CONTROL_CODE_ASCII_C1_SOS = 0x98, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_X = L_TERM_CONTROL_CODE_ASCII_C1_SOS, + L_TERM_CONTROL_CODE_ASCII_C1_SGC = 0x99, + L_TERM_CONTROL_CODE_ASCII_C1_SGCI = L_TERM_CONTROL_CODE_ASCII_C1_SGC, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_Y = L_TERM_CONTROL_CODE_ASCII_C1_SGC, + L_TERM_CONTROL_CODE_ASCII_C1_SCI = 0x9A, + L_TERM_CONTROL_CODE_ASCII_C1_ESC_Z = L_TERM_CONTROL_CODE_ASCII_C1_SCI, + L_TERM_CONTROL_CODE_ASCII_C1_CSI = 0x9B, + L_TERM_CONTROL_CODE_ASCII_C1_ST = 0x9C, + L_TERM_CONTROL_CODE_ASCII_C1_OSC = 0x9D, + L_TERM_CONTROL_CODE_ASCII_C1_PM = 0x9E, + L_TERM_CONTROL_CODE_ASCII_C1_APC = 0x9F +}; + struct l_term; struct l_term *l_term_new(void);