]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/ptyfwd.h
ptyfwd: before deciding that a pty is fully drained, ask the kernel again
[thirdparty/systemd.git] / src / shared / ptyfwd.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
4ba93280
LP
2#pragma once
3
4/***
5 This file is part of systemd.
6
7 Copyright 2010-2013 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
c1ff5570 23#include <stdbool.h>
4ba93280 24
023fb90b
LP
25#include "sd-event.h"
26
a8fbdf54
TA
27#include "macro.h"
28
023fb90b
LP
29typedef struct PTYForward PTYForward;
30
ae3dde80
LP
31typedef enum PTYForwardFlags {
32 PTY_FORWARD_READ_ONLY = 1,
33
34 /* Continue reading after hangup? */
35 PTY_FORWARD_IGNORE_VHANGUP = 2,
36
37 /* Continue reading after hangup but only if we never read anything else? */
38 PTY_FORWARD_IGNORE_INITIAL_VHANGUP = 4,
39} PTYForwardFlags;
40
2a453c2e
LP
41typedef int (*PTYForwardHandler)(PTYForward *f, int rcode, void*userdata);
42
ae3dde80 43int pty_forward_new(sd_event *event, int master, PTYForwardFlags flags, PTYForward **f);
023fb90b
LP
44PTYForward *pty_forward_free(PTYForward *f);
45
0ec5543c
LP
46int pty_forward_get_last_char(PTYForward *f, char *ch);
47
da054c37 48int pty_forward_set_ignore_vhangup(PTYForward *f, bool ignore_vhangup);
2a453c2e
LP
49bool pty_forward_get_ignore_vhangup(PTYForward *f);
50
51bool pty_forward_is_done(PTYForward *f);
52
53void pty_forward_set_handler(PTYForward *f, PTYForwardHandler handler, void *userdata);
9b15b784 54
95f1d6bf
LP
55bool pty_forward_drain(PTYForward *f);
56
023fb90b 57DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free);