blob: 53cb4261ff4ab562d2306f1096c2327838ed22c2 [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
Stéphane Marchesinf8807af2014-08-18 10:34:41 -070026typedef void (*shl_pty_input_cb) (struct shl_pty *pty, char *u8,
Stéphane Marchesinae37e6c2014-08-08 18:19:40 -070027 size_t len, void *data);
28
29pid_t shl_pty_open(struct shl_pty **out, shl_pty_input_cb cb, void *data,
Dominik Behrda6df412016-08-02 12:56:42 -070030 unsigned short term_width, unsigned short term_height,
31 int pts_fd);
Stéphane Marchesinae37e6c2014-08-08 18:19:40 -070032void shl_pty_ref(struct shl_pty *pty);
33void shl_pty_unref(struct shl_pty *pty);
34void shl_pty_close(struct shl_pty *pty);
35
36bool shl_pty_is_open(struct shl_pty *pty);
37int shl_pty_get_fd(struct shl_pty *pty);
38pid_t shl_pty_get_child(struct shl_pty *pty);
39
40int shl_pty_dispatch(struct shl_pty *pty);
41int shl_pty_write(struct shl_pty *pty, const char *u8, size_t len);
42int shl_pty_signal(struct shl_pty *pty, int sig);
43int shl_pty_resize(struct shl_pty *pty, unsigned short term_width,
44 unsigned short term_height);
45
46/* pty bridge */
47
48int shl_pty_bridge_new(void);
49void shl_pty_bridge_free(int bridge);
50
51int shl_pty_bridge_dispatch(int bridge, int timeout);
52int shl_pty_bridge_add(int bridge, struct shl_pty *pty);
53void shl_pty_bridge_remove(int bridge, struct shl_pty *pty);
54
55#endif /* SHL_PTY_H */