summaryrefslogtreecommitdiffhomepage
path: root/src/msq/ntapi_msq_fdio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/msq/ntapi_msq_fdio.c')
-rw-r--r--src/msq/ntapi_msq_fdio.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/msq/ntapi_msq_fdio.c b/src/msq/ntapi_msq_fdio.c
new file mode 100644
index 0000000..d186bb6
--- /dev/null
+++ b/src/msq/ntapi_msq_fdio.c
@@ -0,0 +1,64 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2017 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_file.h>
+#include <ntapi/nt_string.h>
+#include <ntapi/nt_atomic.h>
+#include <ntapi/nt_port.h>
+#include <ntapi/nt_ipc.h>
+#include <ntapi/nt_msq.h>
+#include <ntapi/ntapi.h>
+#include "ntapi_impl.h"
+
+static int32_t __msq_fdio(
+ nt_msq_info * msq,
+ nt_iosb * iosb,
+ uint32_t opcode)
+{
+ int32_t status;
+ nt_msq_info_msg msg;
+
+ /* validate */
+ if (!iosb)
+ return NT_STATUS_INVALID_PARAMETER;
+
+ /* msg */
+ __ntapi->tt_aligned_block_memset(
+ &msg,0,sizeof(msg));
+
+ msg.header.msg_type = NT_LPC_NEW_MESSAGE;
+ msg.header.data_size = sizeof(msg.data);
+ msg.header.msg_size = sizeof(msg);
+ msg.data.ttyinfo.opcode = opcode;
+
+ msg.data.msqinfo.msqkey = msq->msqkey;
+ msg.data.msqinfo.msqid = msq->msqid;
+
+ if ((status = __ntapi->zw_request_wait_reply_port(msq->hport,&msg,&msg)))
+ return status;
+ else if (msg.data.ttyinfo.status)
+ return msg.data.ttyinfo.status;
+
+ iosb->status = NT_STATUS_SUCCESS;
+ iosb->info = 0;
+
+ return NT_STATUS_SUCCESS;
+}
+
+int32_t __stdcall __ntapi_msq_cancel(
+ __in nt_msq_info * msq,
+ __out nt_iosb * iosb)
+{
+ return __msq_fdio(msq,iosb,NT_TTY_MSQ_CANCEL);
+}
+
+int32_t __stdcall __ntapi_msq_free(
+ __in nt_msq_info * msq,
+ __out nt_iosb * iosb)
+{
+ return __msq_fdio(msq,iosb,NT_TTY_MSQ_FREE);
+}