summaryrefslogtreecommitdiffhomepage
path: root/src/pty
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-07-07 01:44:58 -0400
committermidipix <writeonce@midipix.org>2016-07-21 03:47:25 -0400
commit9b8e640378356775d25e39259c8feda7132162b7 (patch)
tree26ba131bcd32981f98018aa9b3f394f96421268f /src/pty
parentd36400785af317de621e522772914446dba3fb2a (diff)
downloadptycon-9b8e640378356775d25e39259c8feda7132162b7.tar.bz2
ptycon-9b8e640378356775d25e39259c8feda7132162b7.tar.xz
ptyc_driver_ctx_impl(): implementation and integration (static, inline).
Diffstat (limited to 'src/pty')
-rw-r--r--src/pty/ptyc_pty_ctx.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/pty/ptyc_pty_ctx.c b/src/pty/ptyc_pty_ctx.c
index 31a9c26..d796138 100644
--- a/src/pty/ptyc_pty_ctx.c
+++ b/src/pty/ptyc_pty_ctx.c
@@ -28,15 +28,16 @@ static int32_t ptyc_pty_open(nt_pty * hptm, nt_guid * pty_guid, nt_pty ** hpty)
&oa,0,0,0);
}
-static int32_t ptyc_ptm_open(const struct ptyc_common_ctx * cctx)
+static int32_t ptyc_ptm_open(struct ptyc_common_ctx * cctx)
{
nt_guid pty_guid = TTY_PTM_GUID;
+
return ptyc_pty_open(
0,&pty_guid,
- (nt_pty **)&cctx->hptm);
+ &cctx->hptm);
}
-static int32_t ptyc_pts_open(const struct ptyc_common_ctx * cctx)
+static int32_t ptyc_pts_open(struct ptyc_common_ctx * cctx)
{
int32_t status;
nt_guid pty_guid = TTY_PTS_GUID;
@@ -46,27 +47,34 @@ static int32_t ptyc_pts_open(const struct ptyc_common_ctx * cctx)
return ptyc_pty_open(
cctx->hptm,&pty_guid,
- (nt_pty **)&cctx->hpts);
+ &cctx->hpts);
}
int ptyc_alloc_pty(struct ptyc_driver_ctx * dctx)
{
- int32_t status;
+ int32_t status;
+ struct ptyc_driver_ctx_impl * ictx;
+ struct ptyc_common_ctx * cctx;
+
+ if (!(ictx = ptyc_get_driver_ictx(dctx)))
+ return NT_STATUS_INVALID_HANDLE;
+
+ cctx = &ictx->cctx;
- if (dctx->cctx->hpts || dctx->cctx->hptm)
+ if (cctx->hpts || cctx->hptm)
return ptyc_set_status(
dctx,NT_STATUS_DEVICE_ALREADY_ATTACHED);
- if ((status = ptyc_ptm_open(dctx->cctx)))
+ if ((status = ptyc_ptm_open(cctx)))
return ptyc_set_status(
dctx,status);
- if (!(dctx->cctx->drvflags & PTYC_DRIVER_DBG_OVEN)
- && !(dctx->cctx->drvflags & PTYC_DRIVER_DBG_RAW))
+ if (!(cctx->drvflags & PTYC_DRIVER_DBG_OVEN)
+ && !(cctx->drvflags & PTYC_DRIVER_DBG_RAW))
return ptyc_set_status(
dctx,NT_STATUS_SUCCESS);
- if ((status = ptyc_pts_open(dctx->cctx)))
+ if ((status = ptyc_pts_open(cctx)))
return ptyc_set_status(
dctx,status);
@@ -76,17 +84,18 @@ int ptyc_alloc_pty(struct ptyc_driver_ctx * dctx)
void ptyc_free_pty(struct ptyc_driver_ctx * dctx)
{
- struct ptyc_common_ctx * cctx;
+ struct ptyc_driver_ctx_impl * ictx;
- cctx = (struct ptyc_common_ctx *)dctx->cctx;
+ if (!(ictx = ptyc_get_driver_ictx(dctx)))
+ return;
- if (cctx->hpts) {
- ntapi->pty_close(cctx->hpts);
- cctx->hpts = 0;
+ if (ictx->cctx.hpts) {
+ ntapi->pty_close(ictx->cctx.hpts);
+ ictx->cctx.hpts = 0;
}
- if (cctx->hptm) {
- ntapi->pty_close(cctx->hptm);
- cctx->hptm = 0;
+ if (ictx->cctx.hptm) {
+ ntapi->pty_close(ictx->cctx.hptm);
+ ictx->cctx.hptm = 0;
}
}