mellin@lan.informatik.tu-muenchen.dbp.de (Reiner Mellin) (09/04/89)
Here are now the Sources of my PTY-filemanager written mainly in C. For educational purposes mainly .... #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 2)." # Contents: COPYRIGHT MANIFEST.SRC cpty.a makefile misc.h miscasm.a # pty.a ptydev.a ptydrv.a ptyman.doc ptyman.h ptystat.a tty.a # Wrapped by ram@ramsys on Mon Sep 4 13:16:56 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'COPYRIGHT'\" else echo shar: Extracting \"'COPYRIGHT'\" \(1562 characters\) sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * END_OF_FILE if test 1562 -ne `wc -c <'COPYRIGHT'`; then echo shar: \"'COPYRIGHT'\" unpacked with wrong size! fi # end of 'COPYRIGHT' fi if test -f 'MANIFEST.SRC' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'MANIFEST.SRC'\" else echo shar: Extracting \"'MANIFEST.SRC'\" \(579 characters\) sed "s/^X//" >'MANIFEST.SRC' <<'END_OF_FILE' X File Name Archive # Description X----------------------------------------------------------- X COPYRIGHT 1 X MANIFEST.SRC 1 This shipping list X cpty.a 1 X funcs.c 2 X makefile 1 X misc.h 1 X miscasm.a 1 X pty.a 1 X ptydev.a 1 X ptydrv.a 1 X ptyman.c 2 X ptyman.doc 1 X ptyman.h 1 X ptystat.a 1 X tty.a 1 END_OF_FILE if test 579 -ne `wc -c <'MANIFEST.SRC'`; then echo shar: \"'MANIFEST.SRC'\" unpacked with wrong size! fi # end of 'MANIFEST.SRC' fi if test -f 'cpty.a' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cpty.a'\" else echo shar: Extracting \"'cpty.a'\" \(3373 characters\) sed "s/^X//" >'cpty.a' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * X* X* $Id: cpty.a_v 1.2.1.1 89/09/04 13:12:14 ram Exp $ X* X* $Log: cpty.a_v $ X* Revision 1.2.1.1 89/09/04 13:12:14 ram X* added some comments X* X* Revision 1.2 89/08/31 12:27:06 ram X* Copyright-message added X* X* X X nam PtyMan X ttl PtyMan - Pty File Manager X X use defsfile X XEdition set 2 X XTyp_Lang set (FlMgr<<8)+Objct XAttr_Rev set (ReEnt+SupStat)<<8+0 X X psect PtyMan,Typ_Lang,Attr_Rev,Edition,0,Entry X Xerrno: equ $1e ; !!! PD_Errno in /DEFS/sysio.a !!! X* dadurch koennen C-Routinen die errno setzen, ganz normal genutzt X* werden !! X X page XEntry: X dc.w _Create-Entry X dc.w _Open-Entry X dc.w _MakDir-Entry X dc.w _ChdDir-Entry X dc.w _Delete-Entry X dc.w _Seek-Entry X dc.w _Read-Entry X dc.w _Write-Entry X dc.w _ReadLn-Entry X dc.w _WriteLn-Entry X dc.w _GetStat-Entry X dc.w _SetStat-Entry X dc.w _Close-Entry X X_MakDir: X_ChdDir: X_Delete: X move.w #E$BMode,d1 X ori.w #Carry,ccr X rts X X_Seek: X andi.w #NoCarry,ccr X rts X X_Read: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra Read X X_ReadLn: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra ReadLn X X_Write: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra Write X X_WriteLn: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra WriteLn X X_Create: X_Open: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra Open X X_GetStat: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra GetStat X X_SetStat: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra SetStat X X_Close: X movem.l d0-d7/a0-a6,-(sp) X bsr.s _setup X bra Close X X_setup X move.l a6,PD_Sysglob(a1) ; System Globals X move.l a1,a6 ; Globals fuer C X move.l (sp)+,a0 ; Return-Adresse X move.l a4,d0 ; Process-Desciptor X move.l a5,d1 ; User Stack Frame X jsr (a0) ; Ruecksprung X X tst.l d0 X beq.s _setup90 ; kein Fehler! X X movem.l (sp)+,d0-d7/a0-a6 X move.l PD_Errno(a1),d1 X ori.w #Carry,ccr X rts X X_setup90 X movem.l (sp)+,d0-d7/a0-a6 X andi.w #NoCarry,ccr X rts X X ends END_OF_FILE if test 3373 -ne `wc -c <'cpty.a'`; then echo shar: \"'cpty.a'\" unpacked with wrong size! fi # end of 'cpty.a' fi if test -f 'makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makefile'\" else echo shar: Extracting \"'makefile'\" \(1480 characters\) sed "s/^X//" >'makefile' <<'END_OF_FILE' X# Options: X# ST The Cumana Implementation of OSK supports a BlkWr-like X# SetStat-Call, implement this X# XOPTIONS = -DST X# X# XRDIR = RELS XCFLAGS = -t=/dd -S $(OPTIONS) XLFLAGS = -g X XSYSLIB = -l=/h0/LIB/sys.l XCLIB = -l=/h0/LIB/clib.l X XOBJS = cpty.r ptyman.r funcs.r miscasm.r XLIBOBJS = X XPtyMan: $(OBJS) ptyman.h X chd $(RDIR); l68 -O=../$@ $(OBJS) $(CLIB) $(SYSLIB) $(LFLAGS) -s >-../$@.map X XPtyDrv: ptydrv.r ptystat.r X chd $(RDIR); l68 -O=../$@ $(SYSLIB) ptystat.r \ X $@.r $(LFLAGS) X Xpty: pty.r X chd $(RDIR); l68 -n=$@ -O=../$@ $(SYSLIB) $@.r X Xtty: tty.r X chd $(RDIR); l68 -n=$@ -O=../$@ $(SYSLIB) $@.r X Xbindist.shar: ptyman pty tty ptydrv X uuencode ptyman >-ptyman.uu X uuencode pty >-pty.uu X uuencode tty >-tty.uu X uuencode ptydrv >-ptydrv.uu X shar MANIFEST.BIN COPYRIGHT ptyman.doc *.uu >-bindist.shar X del *.uu X Xsrcdist: cpty.a ptyman.c funcs.c miscasm.a pty.a tty.a ptydrv.a ptystat.a ptyman.h misc.h makefile ptydev.a X makekit -i MANIFEST.SRC -o MANIFEST.SRC COPYRIGHT ptyman.doc cpty.a ptyman.c funcs.c miscasm.a pty.a tty.a \ X ptydrv.a ptystat.a ptyman.h misc.h makefile ptydev.a X del MANIFEST.SRC X Xclean: makefile X del rels/* X del ptyman tty pty ptydrv *.stb *.map X touch makefile X Xco: X co cpty.a ptyman.c funcs.c miscasm.a pty.a tty.a ptydrv.a \ X ptystat.a ptyman.h misc.h makefile ptydev.a X Xci: X ci -u cpty.a ptyman.c funcs.c miscasm.a pty.a tty.a ptydrv.a \ X ptystat.a ptyman.h misc.h makefile ptydev.a END_OF_FILE if test 1480 -ne `wc -c <'makefile'`; then echo shar: \"'makefile'\" unpacked with wrong size! fi # end of 'makefile' fi if test -f 'misc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'misc.h'\" else echo shar: Extracting \"'misc.h'\" \(2579 characters\) sed "s/^X//" >'misc.h' <<'END_OF_FILE' X/* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* */ X X/* X * $Id: misc.h_v 1.2.1.1 89/09/04 13:13:15 ram Exp $ X * X * $Log: misc.h_v $ X * Revision 1.2.1.1 89/09/04 13:13:15 ram X * added some comments X * X * Revision 1.2 89/08/31 12:31:38 ram X * Copyright message added X * X * X */ X X#define NULL 0 X X#define TRUE 1 X#define FALSE 0 X X#define MIN(a,b) ((a)<(b)?(a):(b)) X#define MAX(a,b) ((a)>(b)?(a):(b)) X#define upchar(ch) ( ( ch >= 'a' && ch <= 'z' ) ? ( ch - ' ') : ch) X X#define DEFBUFSIZE 0x200 /* size of Databuffers */ X#define LINEBUFSIZ 0x100 /* size of line-editing-buffer */ X X#define PTY (0) X#define TTY (1) X X#define P_CONDEMNED (0x200) X X#define WAKE(pid,sig) ( pid != 0 ? (kill(pid,sig),pid = 0) : 0) X X/* user-changeable options -- see SS_Opt */ X#define OPTMAX (&((struct pty_opt *) 0)->pd_tbl) X X#ifndef __GNUC__ X#define inline X#endif X X/* returned by getctrlchar() */ X#define BSP 1 X#define DEL 2 X#define EOR 3 X#define EOF 4 X#define RPR 5 X#define DUP 6 X#define PSC 7 X#define INT 8 X#define QUT 9 X END_OF_FILE if test 2579 -ne `wc -c <'misc.h'`; then echo shar: \"'misc.h'\" unpacked with wrong size! fi # end of 'misc.h' fi if test -f 'miscasm.a' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'miscasm.a'\" else echo shar: Extracting \"'miscasm.a'\" \(3687 characters\) sed "s/^X//" >'miscasm.a' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * X* X* $Id: miscasm.a_v 1.2.1.1 89/09/04 13:13:33 ram Exp $ X* X* $Log: miscasm.a_v $ X* Revision 1.2.1.1 89/09/04 13:13:33 ram X* added some comments X* X* Revision 1.2 89/08/31 12:32:39 ram X* copyright message added X* X* X X use <iodev.a> X use ptydev.a X use defsfile X X psect miscasm,0,0,0,0,0 X X* Hilfs-Funktionen fuer Ptyman, da malloc() nicht verwendet werden kann X* X* _srqmem( size ) X X_srqmem: X move.l a2,-(sp) X X OS9 F$SRqMem X bcc.s _srqmem90 X X move.l d1,errno(a6) X move.l (sp)+,a2 X moveq.l #0,d0 X rts X X_srqmem90 X move.l a2,d0 X move.l (sp)+,a2 X rts X X* _srtmem(addr, size) X_srtmem: X move.l a2,-(sp) X X move.l d0,a2 X move.l d1,d0 X OS9 F$SRtMem X bcc.s _srtmem90 X X move.l d1,errno(a6) X X move.l (sp)+,a2 X moveq.l #-1,d0 X rts X X_srtmem90 X move.l (sp)+,a2 X moveq.l #0,d0 X rts X X* wait for pid to finish I/O ( 0 --> free ) Xiowait: X tst.w d0 X beq.s io1 X clr.l d1 X os9 F$IOQu X move.l d1,d0 Xio1 X rts X X* getctrlchar(ch) -- return control-char-index in d0 Xgetctrlchar: X tst.b d0 X beq.s g1 X cmp.b #32,d0 X bge.s g1 X lea PD_BSP(a6),a0 * start of ctl-char array X moveq.l #8,d1 * length Xg2 X cmp.b (a0)+,d0 X beq.s g3 X X dbra d1,g2 Xg1 X clr.l d0 X rts Xg3 X neg d1 * compute index X add.w #9,d1 X move.w d1,d0 X rts X Xstrcmp: X movea.l d0,a1 * simple strcmp X movea.l d1,a0 X moveq.l #0,d0 :2 X move.l d0,d1 X bra.s _6 X_4 tst.b (a1) :2 X beq.s _3 X_9 X_7 X_6 cmpm.b (a0)+,(a1)+ :2 X beq.s _4 X_5 X subq.l #1,a0 X subq.l #1,a1 X move.b (a0),d0 :2 X move.b (a1),d1 :2 X sub.l d0,d1 :2 X move.l d1,d0 :2 X_3 rts :2 X Xmemcpy: X move.l d0,a1 * simple memcpy X move.l d1,a0 X move.l 4(a7),d0 Xm1 X move.b (a0)+,(a1)+ X dbra d0,m1 X rts X X* initbuf Xinitbuf: X move.l d0,a0 * dont change this Function !!!!! X lea in2(pc),a1 Xin1 X move.b (a1)+,d0 X not.b d0 X cmpi.b #$d,d0 X beq.s in3 X move.b d0,(a0)+ X dbra d1,in1 Xin3 X move.b d0,(a0)+ X dbra d1,in3 X rts Xin2 X dc.b ^' ',^'b',^'y',^' ',^'R',^'e',^'i',^'m' * dont change !! X dc.b ^'e',^'r',^' ',^'A',^'.',^' ',^'M',^'e' X dc.b ^'l',^'l',^'i',^'n',^$d X align X Xkill: X tst.w d0 X beq.s k1 X os9 F$Send Xk1 X rts X X ends END_OF_FILE if test 3687 -ne `wc -c <'miscasm.a'`; then echo shar: \"'miscasm.a'\" unpacked with wrong size! fi # end of 'miscasm.a' fi if test -f 'pty.a' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pty.a'\" else echo shar: Extracting \"'pty.a'\" \(2847 characters\) sed "s/^X//" >'pty.a' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * X* X* $Id: pty.a_v 1.2.1.1 89/09/04 13:13:46 ram Exp $ X* X* $Log: pty.a_v $ X* Revision 1.2.1.1 89/09/04 13:13:46 ram X* added some comments X* X* Revision 1.2 89/08/31 12:34:02 ram X* *** empty log message *** X* X* X X nam PtyMan device descriptor module X XEdition equ 0 current edition X X use defsfile X XTypeLang set (Devic<<8)+0 XAtt_Revs set (ReEnt)<<8)+0 X psect pty,TypeLang,Att_Revs,Edition,0,0 X X dc.l 0 no port address X dc.b 0 no trap assignment X dc.b 0 no IRQ hardware interrupt level X dc.b 0 0 no polling priority X dc.b PUpdat_+Updat_ device mode capabilities X dc.w PtyMgr file manager name offset X dc.w PtyDrv device driver name offset X dc.w 0 DevCon X dc.w 0,0,0,0 reserved X dc.w OptLen option byte count X XOptTbl X dc.b 0 its a SCF-like device X dc.b 0 PD_UPC X dc.b 0 PD_BSO X dc.b 0 PD_DLO X dc.b 0 PD_EKO X dc.b 0 PD_ALF X dc.b 0 PD_NUL X dc.b 0 PD_PAU X dc.b 0 PD_PAG X dc.b 0 PD_BSP X dc.b 0 PD_DEL X dc.b 0 PD_EOR X dc.b 0 PD_EOF X dc.b 0 PD_RPR X dc.b 0 PD_DUP X dc.b 0 PD_PSC X dc.b 0 PD_INT X dc.b 0 PD_QUT X dc.b 0 PD_BSE X dc.b 0 PD_OVF X dc.b 0 PD_PAR X dc.b 0 PD_BAU X dc.w echodev X dc.b 0 PD_XON X dc.b 0 PD_XOFF X dc.b 0 PD_TAB X dc.b 0 PD_TABS XOptLen equ *-OptTbl X XPtyMgr dc.b "PtyMan",0 file manager XPtyDrv dc.b "PtyDrv",0 device driver Xechodev dc.b "pty",0 correspondent device X ends END_OF_FILE if test 2847 -ne `wc -c <'pty.a'`; then echo shar: \"'pty.a'\" unpacked with wrong size! fi # end of 'pty.a' fi if test -f 'ptydev.a' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ptydev.a'\" else echo shar: Extracting \"'ptydev.a'\" \(1692 characters\) sed "s/^X//" >'ptydev.a' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * X******************************** X* Pty Static storage requirements X X org V_USER XV_PTY: equ . total PtyManager static overhead X END_OF_FILE if test 1692 -ne `wc -c <'ptydev.a'`; then echo shar: \"'ptydev.a'\" unpacked with wrong size! fi # end of 'ptydev.a' fi if test -f 'ptydrv.a' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ptydrv.a'\" else echo shar: Extracting \"'ptydrv.a'\" \(2210 characters\) sed "s/^X//" >'ptydrv.a' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * X* $Id: ptydrv.a_v 1.2.1.1 89/09/04 13:14:11 ram Exp $ X* X* $Log: ptydrv.a_v $ X* Revision 1.2.1.1 89/09/04 13:14:11 ram X* added some comments X* X* Revision 1.2 89/08/31 12:34:39 ram X* *** empty log message *** X* X* X XEdition equ 0 X XTyp_Lang set (Drivr<<8)+Objct XAttr_Rev set (ReEnt+SupStat)<<8+0 X X psect ptydrv,Typ_Lang,Attr_Rev,Edition,0,Entry X X use defsfile X X page X******************* X* Einsprungstabelle X* total dummy driver XEntry X dc.w Init X dc.w Read X dc.w Write X dc.w GetStat X dc.w PutStat X dc.w TermNat X dc.w 0,0,0,0 X X align X XInit: XRead: XWrite: XTermNat: X move.w #0,d0 X rts X XGetStat: XPutStat: X move.w #E$UnkSvc,d1 X ori.w #Carry,ccr X rts X END_OF_FILE if test 2210 -ne `wc -c <'ptydrv.a'`; then echo shar: \"'ptydrv.a'\" unpacked with wrong size! fi # end of 'ptydrv.a' fi if test -f 'ptyman.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ptyman.doc'\" else echo shar: Extracting \"'ptyman.doc'\" \(9667 characters\) sed "s/^X//" >'ptyman.doc' <<'END_OF_FILE' X Pseudo-Terminal (PTY) File-Manager X ================================== XOverview: X X Pseudo-Terminals (PTY's) are a kind of Interprocess XCommunication (IPC), which are known on a wide variety of UN*X Xcomputers, mostly BSD-like systems. They behave like any other SCF Xdevices like terminals and printer but are in fact pseudo-devices i.e. Xexists only in the memory the system. X X PTY's have two distinct end-points, namely server-pty and Xclient-pty, which behaves by default differently. A server-pty Xsymbolizes the terminal and a client-pty forms the connection to the Xapplication programs. This implies, that the server-pty provides RAW Xinput and output whereas the client-pty can handle line-editing, echoing Xand so on. X X With this mechanism many programms can share one real device, Xlike a real terminal, via one server which multiplexes all connected Xserver-pty's. Something similar can be reached with the usage of pipes, Xbut pipes have the disadvantage of being not a tty-device with echo, Xline-editing, interrupt-chars etc. X XExamples: X - virtual Terminals: one program multiplexes ptys and displays the X outputs on a real Terminal (there exist a programm called 'screen' X which does exactly this). X - In a TCP/IP environment, the program 'rlogin' starts a X login-process on a pty on the remote machine. X X___________________________________________________________________________ X X /***********\ /**************\ X * * * * X * Server- * ----------> * real Device * X * Prg. * * * X \***********/ \**************/ X ___+ + + +_______ X ___/ \ \ \_______ X ___/ \ \________ \________ X / \ \_______ \__________ X | | | | X /***********\ /***********\ /***********\ /***********\ X * * * * * * * * X * 1st Prg. * * 2nd Prg. * * 3rd Prg. * * 4th Prg. * X * * * * * * * * X \***********/ \***********/ \***********/ \***********/ X X'|' meaning client-pty X'+' meaning server-pty X XFig. 1: Typical Server-Client Application X X XImplementation: X X With OS9-68000 (OSK) a own File-Manager was written, which Xhandles both types of PTY's : the client-ptys, and the server-ptys while Xusing only *one* descriptor (device) for each. Server-ptys must be Xopened as "/pty/any_valid_name" , client-ttys must be opened (i.e. Xconnected) with "/tty/any_valid_name". The Open-Call for the client-pty Xwill block until a server-pty with the same name is opened. PTY's can Xbe also implemented with the usage of a special device-driver for the XSCF, but this has serveral draw-backs : X X - A System-Global Variable has to be introduced for the rendezvous X of the PTY-pairs (not implementation independent). X X - For each pair of PTY's there must exist two Device-Descriptors X (waste of memory and Device-Table-entries). X X - The number of PTY's pairs are limited !! X X - Block-writes in RAW modus has still to be done on a char-by-char X basis with single calls to the driver, as required by the SCF X X When creating a server-PTY the Filemanager searches a list of Xalready openend server-ptys for the same name. The name can be any Xlegal OS-9/68000 Filename (no distinction between upper- and Xlower-case). When a identical name is found, the Filemanager return a XE_CEF-error (File already exists), otherwise the Pathdescriptor (PD) is Xinserted into this list and some initialisation is done (allocating XData-Buffers etc.). X X When opening a client-PTY the Filemanager looks thru the above Xmentioned list for a already openend server-pty. If found, it sets a Xspecial pointer pointing to the PD of the server-pty. (the Filemanager Xbasicly distincts server-pty's and client-pty's by the value of this Xpointer). X XRemark: X There exist only *one* named server-pty but there can be many X client-ptys listening (although its possibly to I$DUP a X server-pty-fd). X X When closing a Server-Pty, the Filemanager searches for all Xclient-pty's and sets the special pointer to NULL indicating a XHANGUP-condition. He also tries to send a SIGHUP-Signal (value is Xchangeable via the _ss_dcoff()-Call) to the last/current user of a Xclient-pty. Any further I/O calls to a disconnected client-pty will Xissue a E_HANGUP-Error and a SIGHUP signal ! X X Closing a client-pty requires no special tasks but clearing all Xpending Signals (e.g. pending _ss_signl() ), which is done automaticly. X X Although total compatibility to a SCF-Device was intended, the XPTY-Filemanager does differ in some small aspects from the SCF. The Xreason for that were some features of the SCF, which I do consider Xfaulty e.g. with a ReadLn-count of one the only character you can read Xis CR and nothing else (:-( ). X XDifferences: X - a Readln-Call with a character count of 1 will return the next X character available. X X - The Read-Call may behave differently: kbich and kbach will X abort with the appropriate Error-codes. No Echo, but raw-byte-transfer. X X - The Pause-char, Xon-char and Xoff-char are not supported ! X X - Any signal < 32 and > 1 (SIGWAKE) will abort a pending I/O with an X error-code of the signal (this should be made standard). X X - A close of a server-pty will only generate a SIGHUP (see SS_DCOff) X and will *not* abort the reading processes (the program 'com' X seems to have problems with that !). X X XDescriptions of operation: X X- Read-calls: X absolute raw-read, ignores echo-parameter, but unterstands kbich and X kbach. X X- Write-calls: X absolute raw-write .... but sends QUIT and INT if set. X X- Writeln-calls: X recognizes upc, tabch, tabs, alf, pause and returns on recognizing X the eor-char (normaly CR). sends QUIT and INT if set. X X- Readln-calls: X recognition of echo, upc, bso, bse, bspchar, eorchar, alf (when X echoing), kbich, kbach, eof, delchar, rprchar, dupchar and pause. XCAVEAT: X - A final EOR in the input-stream is not necessary and this was X deliberatly avoided !!! X - The maximum readln-count is 256 Bytes (like in the SCF). You can X specify more but the Filemanger will cut it to 256... X X- GetStat-calls: X supported codes are: SS_Opt, SS_Ready, SS_EOF, SS_DevNm (returns the X name of the pty), SS_BlkRd. X X- SetStat-calls: X supported codes are: SS_Opt, SS_SSig, SS_Relea, SS_EnRTS, SS_DsRTS, X SS_DCOn, SS_DCOff, SS_BlkWr. XCAVEAT: X - SS_DCOn, SS_EnRTS and SS_DsRTS are no-ops. X XNot supported are null (for padding), pausechar, xon and xoff. X X XDescription of GetStat-Codes: X X - SS_Opt: X copy the first 28 Bytes of the option part to the users X (a0)-register. X X - SS_Ready: X return number of chars available for reading in users d1 X register, or return E_NOTRDY if no input is available. X X - SS_EOF: X always returns 0 in callers d1 register (like SCF). X X - SS_DevNm: X return the null-terminated name of the pty into the callers X (a0)-register. X X - SS_BlkRd: X Read x (in users d2-register) Bytes into buffer, users X (a0)-register is pointing to. X X XDescription of SetStat-Codes: X X - SS_Opt: X copy the first 28 Byte from users (a0)-register into the option X part of the pathdescriptor. X X - SS_SSig: X Send signal in users d2-register on receiving the next X available character. If another Process is waiting for input, X return an E_NOTRDY error. X X - SS_Relea: X Clear a SS_SSig action... X X - SS_EnRTS: X no-op X X - SS_DsRTS: X no-op X X - SS_DCOn: X no-op X X - SS_DCOff: X Send Signal in users d2-register on closing the server-pty X (Carrier-lost condition). The Default signal is SIGHUP (Value: 4). X X - SS_BlkWr: X Write x ( in users d2-register ) Bytes from buffer users X (a0)-register is pointing to. X X - SS_Screen (Subfunction ScrOut): X Optional, like BlkWr. exists only on ST's (Cumana Implementation). X X XFinal Thoughts: X X Some tests have shown, that this Filemanager is about 100% Xfaster than an orthodox implementation with a special device Driver for Xthe SCF when doing readln/writeln calls. By using only read/write calls Xsome can expect even much more throughput (no line-editing stuff etc..). X XBUGS: X X This Filemanager seems to have problems in OSK-Versions lower Xthan 2.0 (-> e.g. 1.2). I think the 'openend-Path'-list isnt supported Xby the Kernel (IOMan); maybe the Filemanager should do it itself ?? X 'tmode normal' dont work, since it takes the name returned by XDevNm as a Descriptor-module-name. This is easily changeable by returning X'pty' or 'tty' on SS_DevNm. X XThings to do: X - shrinking the code X - treatment of dir-bit as in PipeMan, to see what ptys are open ? X - more lineediting (emacs-style, history ?) X - implementing the pausechar and maybe xon/xoff ? X XPlease send any suggestions/Bug-reports to: X Reimer Mellin X Sulenstr. 8 X D-8000 Muenchen 71 X X UUCP: mellin@lan.informatik.tu-muenchen.dbp.de (preferred) X mellin@altger.UUCP X ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) END_OF_FILE if test 9667 -ne `wc -c <'ptyman.doc'`; then echo shar: \"'ptyman.doc'\" unpacked with wrong size! fi # end of 'ptyman.doc' fi if test -f 'ptyman.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ptyman.h'\" else echo shar: Extracting \"'ptyman.h'\" \(4793 characters\) sed "s/^X//" >'ptyman.h' <<'END_OF_FILE' X/* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* */ X/* */ X X/* X * $Id: ptyman.h_v 1.2.1.1 89/09/04 13:14:51 ram Exp $ X * X * $Log: ptyman.h_v $ X * Revision 1.2.1.1 89/09/04 13:14:51 ram X * added some comments X * X * Revision 1.2 89/08/31 12:35:20 ram X * *** empty log message *** X * X * X */ X X#ifndef _sysio X#include <sysio.h> X#endif X X/* X * PtyFilemanager PD definitions X */ X Xtypedef struct ptystatic { X sysioStatic v_sysio; /* kernel static storage variables */ X} *Ptystatic; X Xstruct ptybuf { X union pathdesc *lpd; /* pd of last active process */ X u_char *buf; /* buffer */ X u_char *wptr; /* write-ptr of buffer */ X u_char *rptr; /* read-ptr of buffer */ X u_long size; /* buffer-size */ X u_short rpid; /* pid to wake if read is pending */ X u_short rsig; /* signal to send */ X u_short wpid; /* pid to wake if write is pending */ X u_short wsig; /* signal to send */ X}; X Xstruct pty_pvt { X union pathdesc *pd_pty ; /* the server-pty .. */ X struct ptybuf pd_rbuf; /* input-buffer */ X struct ptybuf pd_wbuf; /* output-buffer */ X u_long pd_flags; /* Flags ... */ X u_short pd_esig; /* for SS_DCOn, SS_DCOff, SIGWAKE,SIGHUP */ X u_short pd_line; /* for page-pause */ X u_char pd_typ; /* pty or tty ? */ X}; X Xstruct pty_opt { X u_char pd_dtp; /* device type */ X u_char pd_upc; /* case (0=both, 1=upper only) */ X u_char pd_bso; /* backsp (0=bse, 1=bse,sp,bse) */ X u_char pd_dlo; /* delete (0=bse over line, 1=crlf) */ X u_char pd_eko; /* echo (0=no echo) */ X u_char pd_alf; /* autolf (0=no auto lf) */ X u_char pd_nul; /* end of line null count */ X u_char pd_pau; /* pause (0=no end of page pause) */ X u_char pd_pag; /* lines per page */ X u_char pd_bsp; /* backspace character */ X u_char pd_del; /* delete line character */ X u_char pd_eor; /* end of record char (read only) */ X u_char pd_eof; /* end of file char */ X u_char pd_rpr; /* reprint line char */ X u_char pd_dup; /* dup last line char */ X u_char pd_psc; /* pause char */ X u_char pd_int; /* kbd intr char (ctl c) */ X u_char pd_qut; /* kbd quit char (ctl q) */ X u_char pd_bse; /* backspace echo character */ X u_char pd_ovf; /* line overflow char (bell) */ X u_char pd_par; /* parity code */ X u_char pd_bau; /* acia baud rate (color computer) */ X short pd_d2p; /* dev2 output name offset */ X u_char pd_xon; /* x-on char */ X u_char pd_xoff; /* x-off char */ X u_char pd_Tab; /* Tab character (0=none) */ X u_char pd_Tabs; /* Tab field size */ X Devicetbl pd_tbl; /* Device table addr (copy) */ X u_short pd_Col; /* current column number */ X u_char pd_err; /* most recent I/O error status */ X u_char dummy[96-35]; /* reserved ... */ X u_char pd_name[28]; /* the name of the PTY */ X u_long pd_namlen; /* length of name */ X}; X X#define PTYMAN 1 X#define ptypvt path.fm_pvt.pty X#define ptyopt path.fm_opt.pty X X END_OF_FILE if test 4793 -ne `wc -c <'ptyman.h'`; then echo shar: \"'ptyman.h'\" unpacked with wrong size! fi # end of 'ptyman.h' fi if test -f 'ptystat.a' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ptystat.a'\" else echo shar: Extracting \"'ptystat.a'\" \(1892 characters\) sed "s/^X//" >'ptystat.a' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * X* X* $Id: ptystat.a_v 1.2.1.1 89/09/04 13:15:13 ram Exp $ X* X* $Log: ptystat.a_v $ X* Revision 1.2.1.1 89/09/04 13:15:13 ram X* added some comments X* X* Revision 1.2 89/08/31 12:35:54 ram X* X* X X nam OS-9/68k Pty Static Storage X Xedition set 0 X X use <iodev.a> X use ptydev.a X X psect ptydev,0,0,0,0,0 X vsect X ds.b V_PTY X ends X ends END_OF_FILE if test 1892 -ne `wc -c <'ptystat.a'`; then echo shar: \"'ptystat.a'\" unpacked with wrong size! fi # end of 'ptystat.a' fi if test -f 'tty.a' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tty.a'\" else echo shar: Extracting \"'tty.a'\" \(2927 characters\) sed "s/^X//" >'tty.a' <<'END_OF_FILE' X* This software is copyright (C) 1989 by Reimer Mellin * X* * X* Permission is granted to reproduce and distribute * X* this package by any means so long as no fee is charged * X* above a nominal handling fee and so long as this * X* notice is always included in the copies. * X* Commerical use or incorporation into commercial software * X* is prohibited without the written permission of the * X* author. * X* * X* Other rights are reserved except as explicitly granted * X* by written permission of the author. * X* Reimer Mellin * X* * X* Sulenstr.8 * X* D-8000 Muenchen 71 (Federal Republic of Germany) * X* * X* EMAIL: * X* mellin@lan.informatik.tu-muenchen.dbp.de * X* ram@altger.UUCP * X* ....!pyramid!tmpmbx!doitcr!ramsys!ram (home) * X* * X* $Id: tty.a_v 1.2.1.1 89/09/04 13:15:27 ram Exp $ X* X* $Log: tty.a_v $ X* Revision 1.2.1.1 89/09/04 13:15:27 ram X* added some comments X* X* Revision 1.2 89/08/31 12:36:21 ram X* *** empty log message *** X* X* X X nam PtyMan device descriptor module X XEdition equ 0 X X use defsfile X XTypeLang set (Devic<<8)+0 XAtt_Revs set (ReEnt)<<8)+0 X psect tty,TypeLang,Att_Revs,Edition,0,0 X X dc.l 0 no port address X dc.b 0 no trap assignment X dc.b 0 no IRQ hardware interrupt level X dc.b 0 0 no polling priority X dc.b PUpdat_+Updat_ device mode capabilities X dc.w PtyMgr file manager name offset X dc.w PtyDrv device driver name offset X dc.w 0 DevCon X dc.w 0,0,0,0 reserved X dc.w OptLen option byte count X XOptTbl X dc.b 0 its a SCF-like device X dc.b 0 PD_UPC X dc.b 1 PD_BSO X dc.b 1 PD_DLO X dc.b 1 PD_EKO X dc.b 1 PD_ALF X dc.b 0 PD_NUL X dc.b 0 PD_PAU X dc.b 24 PD_PAG X dc.b 8 PD_BSP X dc.b $18 PD_DEL X dc.b 13 PD_EOR X dc.b $1b PD_EOF X dc.b 4 PD_RPR X dc.b 1 PD_DUP X dc.b $17 PD_PSC X dc.b 3 PD_INT X dc.b 5 PD_QUT X dc.b 8 PD_BSE X dc.b 7 PD_OVF X dc.b 0 PD_PAR X dc.b 0 PD_BAU X dc.w echodev X dc.b 0 PD_XON X dc.b 0 PD_XOFF X dc.b 9 PD_TAB X dc.b 8 PD_TABS XOptLen equ *-OptTbl X XPtyMgr dc.b "PtyMan",0 file manager XPtyDrv dc.b "PtyDrv",0 device driver Xechodev dc.b "tty",0 correspondent device X ends X END_OF_FILE if test 2927 -ne `wc -c <'tty.a'`; then echo shar: \"'tty.a'\" unpacked with wrong size! fi # end of 'tty.a' fi echo shar: End of archive 1 \(of 2\). cp /dev/null ark1isdone MISSING="" for I in 1 2 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked both archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- | Reimer Mellin | mellin@lan.informatik.tu-muenchen.dbp.de | | Sulenstr. 8 | | | D-8000 Muenchen 71 | Technische Universitaet Muenchen |