Blob Blame History Raw
#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 "argv/argv.h"

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_DEBUG,
	TAG_CAT,
	TAG_WAIT,
};

struct ptyc_term_ctx {
	void *			hin;
	void *			hout;
};

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_driver_ctx_impl {
	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;
}

#endif