2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2013-10-30 18:58:59 +01:00
|
|
|
#pragma once
|
|
|
|
|
2015-02-10 12:56:53 +01:00
|
|
|
#include <stdbool.h>
|
2013-10-30 18:58:59 +01:00
|
|
|
|
2014-10-31 16:54:11 +01:00
|
|
|
#include "sd-event.h"
|
|
|
|
|
2015-12-03 21:13:37 +01:00
|
|
|
#include "macro.h"
|
|
|
|
|
2014-10-31 16:54:11 +01:00
|
|
|
typedef struct PTYForward PTYForward;
|
|
|
|
|
2015-10-07 20:10:48 +02:00
|
|
|
typedef enum PTYForwardFlags {
|
|
|
|
PTY_FORWARD_READ_ONLY = 1,
|
|
|
|
|
|
|
|
/* Continue reading after hangup? */
|
|
|
|
PTY_FORWARD_IGNORE_VHANGUP = 2,
|
|
|
|
|
|
|
|
/* Continue reading after hangup but only if we never read anything else? */
|
|
|
|
PTY_FORWARD_IGNORE_INITIAL_VHANGUP = 4,
|
|
|
|
} PTYForwardFlags;
|
|
|
|
|
2018-12-04 09:29:54 +01:00
|
|
|
typedef int (*PTYForwardHandler)(PTYForward *f, int rcode, void *userdata);
|
2016-08-17 14:24:17 +02:00
|
|
|
|
2015-10-07 20:10:48 +02:00
|
|
|
int pty_forward_new(sd_event *event, int master, PTYForwardFlags flags, PTYForward **f);
|
2014-10-31 16:54:11 +01:00
|
|
|
PTYForward *pty_forward_free(PTYForward *f);
|
|
|
|
|
2015-01-07 03:08:00 +01:00
|
|
|
int pty_forward_get_last_char(PTYForward *f, char *ch);
|
|
|
|
|
2015-01-07 14:46:45 +01:00
|
|
|
int pty_forward_set_ignore_vhangup(PTYForward *f, bool ignore_vhangup);
|
2016-08-17 14:24:17 +02:00
|
|
|
bool pty_forward_get_ignore_vhangup(PTYForward *f);
|
|
|
|
|
|
|
|
bool pty_forward_is_done(PTYForward *f);
|
|
|
|
|
|
|
|
void pty_forward_set_handler(PTYForward *f, PTYForwardHandler handler, void *userdata);
|
2014-12-22 19:45:32 +01:00
|
|
|
|
2016-12-24 00:35:58 +01:00
|
|
|
bool pty_forward_drain(PTYForward *f);
|
|
|
|
|
2017-12-05 18:31:32 +01:00
|
|
|
int pty_forward_set_priority(PTYForward *f, int64_t priority);
|
|
|
|
|
2018-07-24 17:15:33 +02:00
|
|
|
int pty_forward_set_width_height(PTYForward *f, unsigned width, unsigned height);
|
|
|
|
|
2014-10-31 16:54:11 +01:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free);
|