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 * closed_cb 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, struct ev_eloop *loop,
54 kmscon_pty_input_cb input_cb, void *data);
55 void kmscon_pty_ref(struct kmscon_pty *pty);
56 void kmscon_pty_unref(struct kmscon_pty *pty);
58 int kmscon_pty_open(struct kmscon_pty *pty, unsigned short width,
59 unsigned short height);
60 void kmscon_pty_close(struct kmscon_pty *pty);
62 int kmscon_pty_write(struct kmscon_pty *pty, const char *u8, size_t len);
65 * Call this whenever the size of the screen (rows or columns) changes. The
66 * kernel and child process need to be notified.
68 void kmscon_pty_resize(struct kmscon_pty *pty,
69 unsigned short width, unsigned short height);
71 #endif /* KMSCON_PTY_H */