2 * kmscon - Pseudo Terminal Handling
4 * Copyright (c) 2012 Ran Benita <ran234@gmail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * The pty object provides an interface for communicating with a child process
28 * over a pseudo terminal. The child is the host, we act as the TTY terminal,
29 * and the kernel is the driver.
31 * To use this, create a new pty object and open it. You will start receiving
32 * output notifications through the output_cb callback. To communicate with
33 * the other end of the terminal, use the kmscon_pty_input method. All
34 * communication is done using byte streams (presumably UTF-8).
36 * The pty can be closed voluntarily using the kmson_pty_close method. The
37 * child process can also exit at will; this will be communicated through the
38 * input callback. The pty object does not wait on the child processes it
39 * spawns; this is the responsibility of the object's user.
50 typedef void (*kmscon_pty_input_cb)
51 (struct kmscon_pty *pty, const char *u8, size_t len, void *data);
53 int kmscon_pty_new(struct kmscon_pty **out, kmscon_pty_input_cb input_cb,
55 void kmscon_pty_ref(struct kmscon_pty *pty);
56 void kmscon_pty_unref(struct kmscon_pty *pty);
57 int kmscon_pty_set_term(struct kmscon_pty *pty, const char *term);
58 int kmscon_pty_set_colorterm(struct kmscon_pty *pty, const char *colorterm);
59 int kmscon_pty_set_argv(struct kmscon_pty *pty, char **argv);
60 int kmscon_pty_set_seat(struct kmscon_pty *pty, const char *seat);
61 int kmscon_pty_set_vtnr(struct kmscon_pty *pty, unsigned int vtnr);
62 void kmscon_pty_set_env_reset(struct kmscon_pty *pty, bool do_reset);
64 int kmscon_pty_get_fd(struct kmscon_pty *pty);
65 void kmscon_pty_dispatch(struct kmscon_pty *pty);
67 int kmscon_pty_open(struct kmscon_pty *pty, unsigned short width,
68 unsigned short height);
69 void kmscon_pty_close(struct kmscon_pty *pty);
71 int kmscon_pty_write(struct kmscon_pty *pty, const char *u8, size_t len);
72 void kmscon_pty_signal(struct kmscon_pty *pty, int signum);
73 void kmscon_pty_resize(struct kmscon_pty *pty,
74 unsigned short width, unsigned short height);
76 #endif /* KMSCON_PTY_H */