blob: 62cfecc8cd4b745c6efa6f8c60cb320ac53a2e70 [file] [log] [blame]
Stéphane Marchesinae37e6c2014-08-08 18:19:40 -07001/*
2 * SHL - PTY Helpers
3 *
4 * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@gmail.com>
5 * Dedicated to the Public Domain
6 */
7
8/*
9 * PTY Helpers
10 */
11
12#ifndef SHL_PTY_H
13#define SHL_PTY_H
14
15#include <errno.h>
16#include <stdbool.h>
17#include <stdint.h>
18#include <stdlib.h>
19#include <string.h>
20#include <unistd.h>
21
22/* pty */
23
24struct shl_pty;
25
26typedef void (*shl_pty_input_cb) (struct shl_pty * pty, char *u8,
27 size_t len, void *data);
28
29pid_t shl_pty_open(struct shl_pty **out, shl_pty_input_cb cb, void *data,
30 unsigned short term_width, unsigned short term_height);
31void shl_pty_ref(struct shl_pty *pty);
32void shl_pty_unref(struct shl_pty *pty);
33void shl_pty_close(struct shl_pty *pty);
34
35bool shl_pty_is_open(struct shl_pty *pty);
36int shl_pty_get_fd(struct shl_pty *pty);
37pid_t shl_pty_get_child(struct shl_pty *pty);
38
39int shl_pty_dispatch(struct shl_pty *pty);
40int shl_pty_write(struct shl_pty *pty, const char *u8, size_t len);
41int shl_pty_signal(struct shl_pty *pty, int sig);
42int shl_pty_resize(struct shl_pty *pty, unsigned short term_width,
43 unsigned short term_height);
44
45/* pty bridge */
46
47int shl_pty_bridge_new(void);
48void shl_pty_bridge_free(int bridge);
49
50int shl_pty_bridge_dispatch(int bridge, int timeout);
51int shl_pty_bridge_add(int bridge, struct shl_pty *pty);
52void shl_pty_bridge_remove(int bridge, struct shl_pty *pty);
53
54#endif /* SHL_PTY_H */