home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Xplorer 1
/
Scene_Xplorer_1.iso
/
Tools
/
ProNet
/
source
/
filesystem
/
pronet-server.s
< prev
Wrap
Text File
|
1978-01-11
|
25KB
|
1,224 lines
;: > pronet-server.s
;:
;: ©1994-1995 by Michael Krause
;:
;: 16.07.1994 started..
;: 24-01-95 if a port number occurs again while ADDNEWHANDLER, we assume that
;: other side has reset, so we clear all our data and start from the
;: beginning!! v34.1
;: 01-04-95 SegList splitting v34.2
;: 14-04-95 MsgRemDisk (or similar??) won't cause the 50frames-Delay.
;: dann noch ACT_READ bug-gefixt??
;: 15-04-95 read und write geben statt NO_FREE_STORE jetzt OBJECT_TOO_LARGE
;: zurück v34.3
;: 17-04-95 READ-Transfer umgebaut v34.4
;: 29-04-95 EXAMINE-Packets neu programmiert v34.5
;: 08-05-95 Statt des Devicenamens wird jetzt Unitnummer
;: vom CLI-String übernommen v34.6
;: 12-05-95 MsgRemDisk didn't set d7... v34.7
;: 15-06-95 SegList splitting removed. v34.8
;: 07-07-95 UNIT argument didn't work... v35.0
DEBUG equ 0
;++ bei aCT_NEWHANDLER nach CreateStdPacket prüfen -> freemem
include "exec/exec.i"
include "dos/dos.i"
include "dos/dosextens.i"
include "dos/filehandler.i"
include "devices/input.i"
include "devices/inputevent.i"
include "A:ProNET/include/devices/pronet.i"
include "A:OSmacros.i"
include "A:ProNET/source/network.i"
include "exec_lib.i"
include "dos_lib.i"
include "intuition_lib.i"
STRUCTURE PNSHandlerNode,0
APTR phn_next ;Verkettung
UWORD phn_port ;dazugehörige Portnummer
APTR phn_handlerID ;ProcessID des Handlers
APTR phn_packet ;StandardPKT zur Handlerkommunikation
; packet ist *sp_Pkt, nicht *sp_Msg!!
APTR phn_devnode ;DevNode des Handlers
APTR phn_volnode ;aktuelle Volume
APTR phn_dlbuf ;DownLoad-Buffer
APTR phn_dlbufpt ;aktuelle Position
ULONG phn_dlbytes ;wieviel Bytes noch ?? 0 = nix
LABEL phn_SIZEOF
section startup,code
j jsr dec2long
move.l d1,unit
IFNE DEBUG
bsr dinit
ENDC
move.l 4.w,a6
move.l ThisTask(a6),ourtask
lea dosname(pc),a1
moveq #33,d0
jsr -552(a6)
move.l d0,dosbase
beq.s nodos
move.l ourtask(pc),a0
move.l #-1,pr_WindowPtr(a0)
bsr StartInputHandler
bsr startpronet
tst.w d0
bne.s nopronet
bsr startmessage
bra Wait4Message
nopronet move.l dosbase(pc),a1
move.l 4.w,a6
jsr -414(a6)
nodos
IFNE DEBUG
bsr dexit
ENDC
moveq #20,d0
rts
dc.b "$VER: pronet-server 35.0 (07-07-95)",13,10,0
even
startpronet moveq #pnr_Size,d0
bsr GetIORequest
move.l d0,pronetio
beq spnoioreq
bsr CreatePort
move.l d0,pronetmsgport
beq spnomsgport
lea pronetname(pc),a0
move.l unit(pc),d0
moveq #0,d1
move.l pronetio(pc),a1
move.w #0,pnr_NetSourcePort(a1)
move.l pronetmsgport(pc),pnr_MsgPort(a1)
move.l 4.w,a6
LIBCALL OpenDevice
tst.l d0
bne.s spnodev
move.l pronetio(pc),a1
move.w #CMD_WRITE,IO_COMMAND(a1)
clr.l pnr_Length2(a1)
move.l pronetmsgport(pc),a0
move.b MP_SIGBIT(a0),Signal.pronet
moveq #0,d0
rts
spnodev move.l pronetmsgport(pc),a0
bsr DeletePort
spnomsgport move.l pronetio(pc),a0
bsr FreeIORequest
spnoioreq moveq #-1,d0
rts
; -- InputHandler zum Handlen der DISKREMOVED/INSERTED-Messages hochfahren
; -- und entsprechende Signalbits für's Hauptprogramm eintragen.
StartInputHandler
move.l 4.w,a6
moveq #-1,d0
LIBCALL AllocSignal
move.b d0,Signal.diskins
moveq #-1,d0
LIBCALL AllocSignal
move.b d0,Signal.diskrem
moveq #IOSTD_SIZE,d0
bsr GetIORequest
move.l d0,a3
move.l a3,inputio
lea inputname(pc),a0
moveq #0,d0
moveq #0,d1
move.l a3,a1
move.l 4.w,a6
LIBCALL OpenDevice
move.l a3,a1
move.w #IND_ADDHANDLER,IO_COMMAND(a1)
move.l #.int,IO_DATA(a1)
LIBCALL DoIO
rts
.int dc.l 0,0
dc.b NT_INTERRUPT,100
dc.l .intname,0,InputHandlerRout
.intname dc.b "ProNET Server",0
even
startmessage move.l dosbase(pc),a6
LIBCALL Output
move.l d0,d1
move.l #starttext,d2
move.l #starttextl,d3
LIBCALL Write
rts
w4mquitflag dc.w 0
Wait4Message tst.w w4mquitflag
bne .quit
clr.w w4mquitflag
lea Signals(pc),a3 * auf die Messages
moveq #0,d0 * an allen möglichen
moveq #numports-1,d1 * Ports warten
.loop1 move.b (a3),d2
bmi.s .0
bset d2,d0
.0 addq.w #6,a3
dbra d1,.loop1
IFNE DEBUG
lea dwaitt(pc),a0
bsr dtype
ENDC
move.l 4.w,a6
LIBCALL Wait
* entsprechende Routinen
moveq #31,d7 * aufrufen
.00 rol.l #1,d0
bcc.s .notthisbit
lea Signals(pc),a3
moveq #numports-1,d4
.01 cmp.b (a3),d7
bne.s .notthisport
movem.l d0/d4/d7/a3,-(sp)
move.l 2(a3),a3
jsr (a3)
movem.l (sp)+,d0/d4/d7/a3
.notthisport addq.w #6,a3
dbra d4,.01
.notthisbit dbra d7,.00
bra Wait4Message
.quit rts
Signals:
Signal.pronet dc.b -1,0 ;Signalbit
dc.l GetProNETMsg ;entsprechende Routine
Signal.diskins dc.b -1,0
dc.l MsgDiskIns
Signal.diskrem dc.b -1,0
dc.l MsgDiskRem
numports equ 3
InputHandlerRout
movem.l a0/a1/a6,-(sp)
move.l a0,d0
beq.s .ende
move.l 4.w,a6
.1 move.b ie_Class(a0),d0
cmp.b #IECLASS_DISKREMOVED,d0
beq.s .diskrem
cmp.b #IECLASS_DISKINSERTED,d0
beq.s .diskins
.next move.l (a0),a0
move.l a0,d0
bne.s .1
.ende movem.l (sp)+,a0/a1/a6
move.l a0,d0
rts
.diskrem move.l ourtask(pc),a1
moveq #0,d0
move.b Signal.diskrem(pc),d1
bset d1,d0
LIBCALL Signal
bra.s .next
.diskins move.l ourtask(pc),a1
moveq #0,d0
move.b Signal.diskins(pc),d1
bset d1,d0
LIBCALL Signal
bra.s .next
; -- Eine Disk wurde neu eingelegt - hier wird getestet, ob es eine
; -- von unseren Gast-Handlern ist, wenn ja, werden entsprechende
; -- Maßnahmen eingeleitet...
MsgDiskIns
IFNE DEBUG
move.w #$0f0,$dff180
ENDC
move.l #ACTION_DISKINS,d6
moveq #2,d7
bra.s msginsrem_sub
; -- Eine Disk wurde entnommen - siehe 'MsgDiskIns'
MsgDiskRem
IFNE DEBUG
move.w #$f00,$dff180
ENDC
move.l #ACTION_DISKREM,d6
moveq #2,d7
bra.s msginsrem_nodel
msginsrem_sub subq.w #1,d7
bpl.s .0
rts
.0 move.l dosbase(pc),a6
moveq #50,d1
LIBCALL Delay
msginsrem_nodel lea HandlerList(pc),a2 ;in d6 ACTION_DISKINS/REM
.loop move.l (a2),d0
beq.s msginsrem_sub
move.l d0,a2
move.l phn_handlerID(a2),a0
bsr FindVolume
cmp.l phn_volnode(a2),d0
beq.s .loop
move.l d0,a5
move.l d0,phn_volnode(a2) * Disk wurde gewechselt !!
move.l phn_dlbytes(a2),d0 ;es wird gerade downgeloadet
bne.s .ende ;(ne Msg würde den Betrieb
;stören !!)
move.l pronetio(pc),a4 * Message an den Handler
move.w phn_port(a2),pnr_NetDestPort(a4) * schicken..
lea sendbuf,a3
move.l d6,(a3)+
cmp.l #ACTION_DISKREM,d6
beq.s .nocopy
move.l a5,d0
lsr.l #2,d0
move.l d0,(a3)+
lea dol_VolumeDate(a5),a0
move.l (a0)+,(a3)+
move.l (a0)+,(a3)+
move.l (a0)+,(a3)+ ;VolumeDate und Name
move.l dol_Name(a5),a0 ;müssen kopiert werden..
add.l a0,a0
add.l a0,a0
moveq #0,d0
move.b (a0),d0
addq.w #1,d0
.copyname move.b (a0)+,(a3)+
dbra d0,.copyname
.nocopy lea sendbuf,a0
move.l a0,pnr_Data1(a4)
sub.l a0,a3
move.l a3,pnr_Length1(a4)
move.l 4.w,a6
move.l a4,a1
LIBCALL DoIO
.ende rts
GetProNETMsg move.l 4.w,a6
move.l pronetmsgport(pc),a0
LIBCALL GetMsg
tst.l d0
beq .ende
move.l d0,actpronetmsg
move.l d0,a2
lea MN_SIZE(a2),a2
move.w (a2)+,d2 ;[d2] Sourceport [a2] Data
move.l (a2)+,d0 ;[d0] dp_Action
IFNE DEBUG
bsr dtypedec
bsr dcr
ENDC
lea sendbuf+12,a3 ;[a3] sendbuf+12
move.l d0,-12(a3)
move.l pronetio(pc),a4 ;[a4] PNRequest
move.w d2,pnr_NetDestPort(a4)
lea HandlerList(pc),a5
.findnodeloop move.l (a5),a5
move.l a5,d1
beq.s .findrout
cmp.w phn_port(a5),d2
bne.s .findnodeloop
move.l phn_dlbytes(a5),d7
beq.s .nodown
lea ACT_WRITEdownload(pc),a1
bra.s .callit
.nodown move.l phn_packet(a5),a4
move.l d0,dp_Action(a4)
.findrout lea at(pc),a0
moveq #atl-1,d1
.findroutloop cmp.l (a0),d0
bcs.s .next
cmp.l 4(a0),d0
bls.s .jsrroutine
.next lea 12(a0),a0
dbra d1,.findroutloop
bsr ACT_NIL
bra.s .reply
.jsrroutine sub.l (a0),d0
add.l d0,d0
move.l 8(a0),a0
lea at(pc),a1
add.w (a0,d0.l),a1
.callit jsr (a1)
.reply move.l actpronetmsg(pc),a1
move.l 4.w,a6
LIBCALL ReplyMsg
bra GetProNETMsg
.ende rts
cnop 0,4
at ;dc.l lowerbound,upperbound,tableaddress
dc.l 7,34,actiontable1
dc.l 40,40,actiontable2
dc.l 82,82,actiontable3
dc.l 87,87,actiontable4
dc.l 1004,1008,act