Modify it to adjust Tizen IVI enviroment
[platform/upstream/kmscon.git] / src / pty.h
1 /*
2  * kmscon - Pseudo Terminal Handling
3  *
4  * Copyright (c) 2012 Ran Benita <ran234@gmail.com>
5  *
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:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
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.
24  */
25
26 /*
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.
30  *
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).
35  *
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.
40  */
41
42 #ifndef KMSCON_PTY_H
43 #define KMSCON_PTY_H
44
45 #include <stdbool.h>
46 #include <stdlib.h>
47
48 struct kmscon_pty;
49
50 typedef void (*kmscon_pty_input_cb)
51         (struct kmscon_pty *pty, const char *u8, size_t len, void *data);
52
53 int kmscon_pty_new(struct kmscon_pty **out, kmscon_pty_input_cb input_cb,
54                    void *data);
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);
63
64 int kmscon_pty_get_fd(struct kmscon_pty *pty);
65 void kmscon_pty_dispatch(struct kmscon_pty *pty);
66
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);
70
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);
75
76 #endif /* KMSCON_PTY_H */