diff options
Diffstat (limited to 'boot.backup1/termServer.c')
-rw-r--r-- | boot.backup1/termServer.c | 701 |
1 files changed, 0 insertions, 701 deletions
diff --git a/boot.backup1/termServer.c b/boot.backup1/termServer.c deleted file mode 100644 index b24b3157..00000000 --- a/boot.backup1/termServer.c +++ /dev/null @@ -1,701 +0,0 @@ -/* Module term */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -#define EXPORT_BOOLEAN -#include <mach/boolean.h> -#include <mach/kern_return.h> -#include <mach/message.h> -#include <mach/mig_errors.h> -#include <mach/mig_support.h> - -#ifndef mig_internal -#define mig_internal static -#endif - -#ifndef mig_external -#define mig_external -#endif - -#ifndef TypeCheck -#define TypeCheck 1 -#endif - -#ifndef UseExternRCSId -#define UseExternRCSId 1 -#endif - -#define BAD_TYPECHECK(type, check) ({\ - union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ - _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) -#define msgh_request_port msgh_local_port -#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) -#define msgh_reply_port msgh_remote_port -#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) - -#include <mach/std_types.h> -#include <mach/mach_types.h> -#include <device/device_types.h> -#include <device/net_status.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/statfs.h> -#include <sys/resource.h> -#include <sys/utsname.h> -#include <hurd/hurd_types.h> - -/* Routine term_getctty */ -mig_internal void _Xterm_getctty - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t cttyType; - mach_port_t ctty; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_getctty - (io_t terminal, mach_port_t *ctty, mach_msg_type_name_t *cttyPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t cttyType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - mach_msg_type_name_t cttyPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_getctty(In0P->Head.msgh_request_port, &OutP->ctty, &cttyPoly); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->cttyType = cttyType; - - if (MACH_MSG_TYPE_PORT_ANY(cttyPoly)) - msgh_simple = FALSE; - - OutP->cttyType.msgt_name = cttyPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine term_open_ctty */ -mig_internal void _Xterm_open_ctty - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t pidType; - pid_t pid; - mach_msg_type_t pgrpType; - pid_t pgrp; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t newttyType; - mach_port_t newtty; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_open_ctty - (io_t terminal, pid_t pid, pid_t pgrp, mach_port_t *newtty, mach_msg_type_name_t *newttyPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t pidCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t pgrpCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t newttyType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - mach_msg_type_name_t newttyPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 40) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->pidType, &pidCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->pgrpType, &pgrpCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_open_ctty(In0P->Head.msgh_request_port, In0P->pid, In0P->pgrp, &OutP->newtty, &newttyPoly); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->newttyType = newttyType; - - if (MACH_MSG_TYPE_PORT_ANY(newttyPoly)) - msgh_simple = FALSE; - - OutP->newttyType.msgt_name = newttyPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine term_set_nodename */ -mig_internal void _Xterm_set_nodename - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t nameType; - string_t name; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_set_nodename - (io_t terminal, string_t name); - - auto const mach_msg_type_t nameCheck = { - /* msgt_name = */ MACH_MSG_TYPE_STRING_C, - /* msgt_size = */ 8, - /* msgt_number = */ 1024, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 1052) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_set_nodename(In0P->Head.msgh_request_port, In0P->name); -} - -/* Routine term_get_nodename */ -mig_internal void _Xterm_get_nodename - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t nameType; - string_t name; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_get_nodename - (io_t terminal, string_t name); - - auto const mach_msg_type_t nameType = { - /* msgt_name = */ MACH_MSG_TYPE_STRING_C, - /* msgt_size = */ 8, - /* msgt_number = */ 1024, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_get_nodename(In0P->Head.msgh_request_port, OutP->name); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 1060; - - OutP->nameType = nameType; -} - -/* Routine term_set_filenode */ -mig_internal void _Xterm_set_filenode - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t filenodeType; - file_t filenode; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_set_filenode - (io_t terminal, file_t filenode); - - auto const mach_msg_type_t filenodeCheck = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->filenodeType, &filenodeCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_set_filenode(In0P->Head.msgh_request_port, In0P->filenode); -} - -/* Routine term_get_bottom_type */ -mig_internal void _Xterm_get_bottom_type - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ttypeType; - int ttype; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_get_bottom_type - (io_t terminal, int *ttype); - - auto const mach_msg_type_t ttypeType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_get_bottom_type(In0P->Head.msgh_request_port, &OutP->ttype); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->ttypeType = ttypeType; -} - -/* Routine term_on_machdev */ -mig_internal void _Xterm_on_machdev - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t machdevType; - mach_port_t machdev; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_on_machdev - (io_t terminal, mach_port_t machdev); - - auto const mach_msg_type_t machdevCheck = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->machdevType, &machdevCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_on_machdev(In0P->Head.msgh_request_port, In0P->machdev); -} - -/* Routine term_on_hurddev */ -mig_internal void _Xterm_on_hurddev - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t hurddevType; - io_t hurddev; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_on_hurddev - (io_t terminal, io_t hurddev); - - auto const mach_msg_type_t hurddevCheck = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->hurddevType, &hurddevCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_on_hurddev(In0P->Head.msgh_request_port, In0P->hurddev); -} - -/* Routine term_on_pty */ -mig_internal void _Xterm_on_pty - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ptymasterType; - io_t ptymaster; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_on_pty - (io_t terminal, io_t *ptymaster); - - auto const mach_msg_type_t ptymasterType = { - /* msgt_name = */ 19, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_on_pty(In0P->Head.msgh_request_port, &OutP->ptymaster); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; - OutP->Head.msgh_size = 40; - - OutP->ptymasterType = ptymasterType; -} - -/* Routine termctty_open_terminal */ -mig_internal void _Xtermctty_open_terminal - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t flagsType; - int flags; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t terminalType; - mach_port_t terminal; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_termctty_open_terminal - (mach_port_t ctty, int flags, mach_port_t *terminal, mach_msg_type_name_t *terminalPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t flagsCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t terminalType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - mach_msg_type_name_t terminalPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_termctty_open_terminal(In0P->Head.msgh_request_port, In0P->flags, &OutP->terminal, &terminalPoly); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->terminalType = terminalType; - - if (MACH_MSG_TYPE_PORT_ANY(terminalPoly)) - msgh_simple = FALSE; - - OutP->terminalType.msgt_name = terminalPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine term_get_peername */ -mig_internal void _Xterm_get_peername - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t nameType; - string_t name; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_term_get_peername - (io_t terminal, string_t name); - - auto const mach_msg_type_t nameType = { - /* msgt_name = */ MACH_MSG_TYPE_STRING_C, - /* msgt_size = */ 8, - /* msgt_number = */ 1024, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_term_get_peername(In0P->Head.msgh_request_port, OutP->name); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 1060; - - OutP->nameType = nameType; -} - -static mig_routine_t term_server_routines[] = { - _Xterm_getctty, - _Xterm_open_ctty, - _Xterm_set_nodename, - _Xterm_get_nodename, - _Xterm_set_filenode, - _Xterm_get_bottom_type, - _Xterm_on_machdev, - _Xterm_on_hurddev, - _Xterm_on_pty, - _Xtermctty_open_terminal, - _Xterm_get_peername, -}; - -mig_external boolean_t term_server - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - register mach_msg_header_t *InP = InHeadP; - register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; - - auto const mach_msg_type_t RetCodeType = { - /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - register mig_routine_t routine; - - OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); - OutP->Head.msgh_size = sizeof *OutP; - OutP->Head.msgh_remote_port = InP->msgh_reply_port; - OutP->Head.msgh_local_port = MACH_PORT_NULL; - OutP->Head.msgh_seqno = 0; - OutP->Head.msgh_id = InP->msgh_id + 100; - - OutP->RetCodeType = RetCodeType; - - if ((InP->msgh_id > 28010) || (InP->msgh_id < 28000) || - ((routine = term_server_routines[InP->msgh_id - 28000]) == 0)) { - OutP->RetCode = MIG_BAD_ID; - return FALSE; - } - (*routine) (InP, &OutP->Head); - return TRUE; -} - -mig_external mig_routine_t term_server_routine - (const mach_msg_header_t *InHeadP) -{ - register int msgh_id; - - msgh_id = InHeadP->msgh_id - 28000; - - if ((msgh_id > 10) || (msgh_id < 0)) - return 0; - - return term_server_routines[msgh_id]; -} - |