From 41bf3fa4dcae4a5761c68ac72e698fc653ac6239 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 25 Oct 1997 07:40:26 +0000 Subject: [PATCH] Add ability to handle named pipes. This should be all that is necessary to manage the client side of a named pipe. --- v7/src/microcode/ntio.c | 32 +++++++++++++++++++++++--------- v7/src/microcode/ntio.h | 5 +++-- v7/src/microcode/osio.h | 6 +++--- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/v7/src/microcode/ntio.c b/v7/src/microcode/ntio.c index d69a23d33..bb0fe41be 100644 --- a/v7/src/microcode/ntio.c +++ b/v7/src/microcode/ntio.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntio.c,v 1.18 1997/10/24 07:24:56 cph Exp $ +$Id: ntio.c,v 1.19 1997/10/25 07:40:21 cph Exp $ Copyright (c) 1992-97 Massachusetts Institute of Technology @@ -46,7 +46,8 @@ MIT in each case. */ channel_class_t * NT_channel_class_generic; channel_class_t * NT_channel_class_file; channel_class_t * NT_channel_class_screen; -channel_class_t * NT_channel_class_pipe; +channel_class_t * NT_channel_class_anonymous_pipe; +channel_class_t * NT_channel_class_named_pipe; static Tchannel channel_allocate (void); static long cooked_channel_write (Tchannel, const void *, unsigned long) ; @@ -80,11 +81,14 @@ NT_handle_channel_class (HANDLE handle) { if (Screen_IsScreenHandle (handle)) return (NT_channel_class_screen); + /* If GetFileType returns FILE_TYPE_PIPE, assume that it is a named + pipe. This procedure won't be called with an anonymous-pipe + handle. */ switch (GetFileType (handle)) { case FILE_TYPE_DISK: return (NT_channel_class_file); - case FILE_TYPE_PIPE: return (NT_channel_class_pipe); case FILE_TYPE_CHAR: return (NT_channel_class_generic); + case FILE_TYPE_PIPE: return (NT_channel_class_named_pipe); default: return (NT_channel_class_generic); } } @@ -340,11 +344,11 @@ OS_make_pipe (Tchannel * readerp, Tchannel * writerp) STD_BOOL_API_CALL (CreatePipe, ((&hread), (&hwrite), 0, 0)); transaction_begin (); NT_handle_close_on_abort (hwrite); - (*readerp) = (NT_make_channel (hread, NT_channel_class_pipe)); + (*readerp) = (NT_make_channel (hread, NT_channel_class_anonymous_pipe)); transaction_commit (); transaction_begin (); OS_channel_close_on_abort (*readerp); - (*writerp) = (NT_make_channel (hwrite, NT_channel_class_pipe)); + (*writerp) = (NT_make_channel (hwrite, NT_channel_class_anonymous_pipe)); transaction_commit (); } @@ -378,15 +382,24 @@ pipe_channel_n_read (Tchannel channel) } static void -initialize_channel_class_pipe (void) +initialize_channel_class_anonymous_pipe (void) { channel_class_t * class = (OS_malloc (sizeof (channel_class_t))); - (CHANNEL_CLASS_TYPE (class)) = channel_type_win32_pipe; + (CHANNEL_CLASS_TYPE (class)) = channel_type_win32_anonymous_pipe; (CHANNEL_CLASS_OP_READ (class)) = pipe_channel_read; (CHANNEL_CLASS_OP_WRITE (class)) = generic_channel_write; (CHANNEL_CLASS_OP_CLOSE (class)) = generic_channel_close; (CHANNEL_CLASS_OP_N_READ (class)) = pipe_channel_n_read; - NT_channel_class_pipe = class; + NT_channel_class_anonymous_pipe = class; +} + +static void +initialize_channel_class_named_pipe (void) +{ + channel_class_t * class = (OS_malloc (sizeof (channel_class_t))); + (*class) = (*NT_channel_class_anonymous_pipe); + (CHANNEL_CLASS_TYPE (class)) = channel_type_win32_named_pipe; + NT_channel_class_named_pipe = class; } static long @@ -647,5 +660,6 @@ NT_initialize_channels (void) initialize_channel_class_generic (); initialize_channel_class_file (); initialize_channel_class_screen (); - initialize_channel_class_pipe (); + initialize_channel_class_anonymous_pipe (); + initialize_channel_class_named_pipe (); } diff --git a/v7/src/microcode/ntio.h b/v7/src/microcode/ntio.h index 52646ff13..d34556302 100644 --- a/v7/src/microcode/ntio.h +++ b/v7/src/microcode/ntio.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntio.h,v 1.9 1997/10/24 07:25:01 cph Exp $ +$Id: ntio.h,v 1.10 1997/10/25 07:40:26 cph Exp $ Copyright (c) 1992-97 Massachusetts Institute of Technology @@ -87,7 +87,8 @@ extern channel_class_t * NT_channel_class_generic; extern channel_class_t * NT_channel_class_file; extern channel_class_t * NT_channel_class_screen; extern channel_class_t * NT_channel_class_console; -extern channel_class_t * NT_channel_class_pipe; +extern channel_class_t * NT_channel_class_anonymous_pipe; +extern channel_class_t * NT_channel_class_named_pipe; extern struct channel * NT_channel_table; extern Tchannel NT_make_channel (HANDLE, channel_class_t *); diff --git a/v7/src/microcode/osio.h b/v7/src/microcode/osio.h index 7a34a7532..6d505c53f 100644 --- a/v7/src/microcode/osio.h +++ b/v7/src/microcode/osio.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: osio.h,v 1.12 1997/01/01 22:57:34 cph Exp $ +$Id: osio.h,v 1.13 1997/10/25 07:40:15 cph Exp $ Copyright (c) 1990-97 Massachusetts Institute of Technology @@ -55,8 +55,8 @@ enum channel_type channel_type_os2_console, channel_type_os2_unnamed_pipe, channel_type_os2_named_pipe, - channel_type_win32_char, - channel_type_win32_pipe + channel_type_win32_anonymous_pipe, + channel_type_win32_named_pipe }; extern size_t OS_channel_table_size; -- 2.25.1