summaryrefslogtreecommitdiffhomepage
path: root/src/internal/ptycon_driver_impl.h
blob: 486def3028d180bb9ac424b7becaa0f9b14b1274 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef PTYCON_DRIVER_IMPL_H
#define PTYCON_DRIVER_IMPL_H

#include <ntapi/ntapi.h>
#include <ntcon/ntcon.h>
#include <gdi/gdi.h>

#include <stdint.h>
#include <stdio.h>

#include <ptycon/ptycon.h>
#include "ptycon_bridge_impl.h"
#include "argv/argv.h"

#define PTYC_OPTV_ELEMENTS 64

extern   const struct argv_option ptyc_default_options[];
extern   const ntapi_vtbl * ptyc_ntapi;
extern   const ntcon_vtbl * const ptyc_ntcon;
extern   const gdi_vtbl *   const ptyc_gdi;

#define  ntapi ptyc_ntapi
#define  ntcon ptyc_ntcon
#define  gdi   ptyc_gdi

enum app_tags {
	TAG_HELP,
	TAG_VERSION,
	TAG_DAEMON,
	TAG_DEBUG,
	TAG_SYSROOT,
	TAG_BELL,
	TAG_CAT,
	TAG_EXEC,
	TAG_WAIT,
};

struct ptyc_loop_ctx {
	nt_thread_params	treader;
	nt_thread_params	twriter;
	nt_thread_params	tpoller;
	nt_thread_params	tdbgevent;
	nt_thread_params	tdbgoven;
	nt_thread_params	tdbgraw;
	int32_t			ficonic;
	int32_t			fwinsize;
};

struct ptyc_client_ctx {
	void *			hprocess;
	void *			hthread;
	nt_cid			cid;
	nt_pty_client_info	clinfo;
};

struct ptyc_driver_ctx_impl {
	nt_rtdata *		rtdata;
	struct ptyc_client_ctx	clctx;
	struct ptyc_term_ctx	tctx;
	struct ptyc_loop_ctx	lctx;
	struct ptyc_common_ctx	cctx;
	struct ptyc_driver_ctx	ctx;
};

static inline struct ptyc_driver_ctx_impl * ptyc_get_driver_ictx(struct ptyc_driver_ctx * dctx)
{
	uintptr_t addr;

	if (dctx) {
		addr = (uintptr_t)dctx - offsetof(struct ptyc_driver_ctx_impl,ctx);
		return (struct ptyc_driver_ctx_impl *)addr;
	}

	return 0;
}

int32_t ptyc_open_file(void ** hfile, void * hat, const char * arg, bool fprivate);
int32_t ptyc_open_dir(void ** hfile, void * hat, const char * arg, bool fprivate);

#endif