]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/ptyfwd.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / shared / ptyfwd.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
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
23 #include <stdbool.h>
24
25 #include "sd-event.h"
26
27 #include "macro.h"
28
29 typedef struct PTYForward PTYForward;
30
31 typedef 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
41 typedef int (*PTYForwardHandler)(PTYForward *f, int rcode, void*userdata);
42
43 int pty_forward_new(sd_event *event, int master, PTYForwardFlags flags, PTYForward **f);
44 PTYForward *pty_forward_free(PTYForward *f);
45
46 int pty_forward_get_last_char(PTYForward *f, char *ch);
47
48 int pty_forward_set_ignore_vhangup(PTYForward *f, bool ignore_vhangup);
49 bool pty_forward_get_ignore_vhangup(PTYForward *f);
50
51 bool pty_forward_is_done(PTYForward *f);
52
53 void pty_forward_set_handler(PTYForward *f, PTYForwardHandler handler, void *userdata);
54
55 bool pty_forward_drain(PTYForward *f);
56
57 DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free);