]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/ptyfwd.h
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / shared / ptyfwd.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2010-2013 Lennart Poettering
6 ***/
7
8 #include <stdbool.h>
9
10 #include "sd-event.h"
11
12 #include "macro.h"
13
14 typedef struct PTYForward PTYForward;
15
16 typedef enum PTYForwardFlags {
17 PTY_FORWARD_READ_ONLY = 1,
18
19 /* Continue reading after hangup? */
20 PTY_FORWARD_IGNORE_VHANGUP = 2,
21
22 /* Continue reading after hangup but only if we never read anything else? */
23 PTY_FORWARD_IGNORE_INITIAL_VHANGUP = 4,
24 } PTYForwardFlags;
25
26 typedef int (*PTYForwardHandler)(PTYForward *f, int rcode, void*userdata);
27
28 int pty_forward_new(sd_event *event, int master, PTYForwardFlags flags, PTYForward **f);
29 PTYForward *pty_forward_free(PTYForward *f);
30
31 int pty_forward_get_last_char(PTYForward *f, char *ch);
32
33 int pty_forward_set_ignore_vhangup(PTYForward *f, bool ignore_vhangup);
34 bool pty_forward_get_ignore_vhangup(PTYForward *f);
35
36 bool pty_forward_is_done(PTYForward *f);
37
38 void pty_forward_set_handler(PTYForward *f, PTYForwardHandler handler, void *userdata);
39
40 bool pty_forward_drain(PTYForward *f);
41
42 int pty_forward_set_priority(PTYForward *f, int64_t priority);
43
44 DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free);