home *** CD-ROM | disk | FTP | other *** search
/ Scene Xplorer 1 / Scene_Xplorer_1.iso / Tools / ProNet / source / filesystem / pronet-server.s < prev   
Text File  |  1978-01-11  |  25KB  |  1,224 lines

  1. ;: > pronet-server.s
  2. ;:
  3. ;: ©1994-1995 by Michael Krause
  4. ;:
  5. ;: 16.07.1994    started..
  6. ;: 24-01-95 if a port number occurs again while ADDNEWHANDLER, we assume that
  7. ;:          other side has reset, so we clear all our data and start from the
  8. ;:        beginning!! v34.1
  9.  
  10. ;: 01-04-95 SegList splitting v34.2
  11.  
  12. ;: 14-04-95 MsgRemDisk (or similar??) won't cause the 50frames-Delay.
  13. ;:        dann noch ACT_READ bug-gefixt??
  14. ;: 15-04-95 read und write geben statt NO_FREE_STORE jetzt OBJECT_TOO_LARGE
  15. ;:        zurück v34.3
  16.  
  17. ;: 17-04-95 READ-Transfer umgebaut v34.4
  18. ;: 29-04-95 EXAMINE-Packets neu programmiert v34.5
  19.  
  20. ;: 08-05-95 Statt des Devicenamens wird jetzt Unitnummer
  21. ;:        vom CLI-String übernommen v34.6
  22.  
  23. ;: 12-05-95 MsgRemDisk didn't set d7... v34.7
  24.  
  25. ;: 15-06-95 SegList splitting removed. v34.8
  26.  
  27. ;: 07-07-95 UNIT argument didn't work... v35.0
  28.  
  29. DEBUG        equ    0
  30.  
  31. ;++ bei aCT_NEWHANDLER nach CreateStdPacket prüfen -> freemem
  32.  
  33.         include    "exec/exec.i"
  34.         include    "dos/dos.i"
  35.         include    "dos/dosextens.i"
  36.         include    "dos/filehandler.i"
  37.         include    "devices/input.i"
  38.         include    "devices/inputevent.i"
  39.         include    "A:ProNET/include/devices/pronet.i"
  40.         include    "A:OSmacros.i"
  41.  
  42.         include    "A:ProNET/source/network.i"
  43.  
  44.         include    "exec_lib.i"
  45.         include    "dos_lib.i"
  46.         include    "intuition_lib.i"
  47.  
  48.           STRUCTURE    PNSHandlerNode,0
  49.         APTR    phn_next        ;Verkettung
  50.         UWORD    phn_port        ;dazugehörige Portnummer
  51.         APTR    phn_handlerID        ;ProcessID des Handlers
  52.         APTR    phn_packet        ;StandardPKT zur Handlerkommunikation
  53.                     ; packet ist *sp_Pkt, nicht *sp_Msg!!
  54.         APTR    phn_devnode    ;DevNode des Handlers
  55.         APTR    phn_volnode    ;aktuelle Volume
  56.         APTR    phn_dlbuf    ;DownLoad-Buffer
  57.         APTR    phn_dlbufpt    ;aktuelle Position
  58.         ULONG    phn_dlbytes    ;wieviel Bytes noch ?? 0 = nix
  59.         LABEL    phn_SIZEOF
  60.  
  61.         section    startup,code
  62.  
  63. j        jsr    dec2long
  64.         move.l    d1,unit
  65.  
  66.     IFNE    DEBUG
  67.     bsr    dinit
  68.     ENDC
  69.  
  70.         move.l    4.w,a6
  71.         move.l    ThisTask(a6),ourtask
  72.         lea    dosname(pc),a1
  73.         moveq    #33,d0
  74.         jsr    -552(a6)
  75.         move.l    d0,dosbase
  76.         beq.s    nodos
  77.  
  78.         move.l    ourtask(pc),a0
  79.         move.l    #-1,pr_WindowPtr(a0)
  80.  
  81.         bsr    StartInputHandler
  82.  
  83.         bsr    startpronet
  84.         tst.w    d0
  85.         bne.s    nopronet
  86.  
  87.         bsr    startmessage
  88.         bra    Wait4Message
  89.  
  90. nopronet    move.l    dosbase(pc),a1
  91.         move.l    4.w,a6
  92.         jsr    -414(a6)
  93. nodos
  94.     IFNE    DEBUG
  95.     bsr    dexit
  96.     ENDC
  97.         moveq    #20,d0
  98.         rts
  99.  
  100.         dc.b    "$VER: pronet-server 35.0 (07-07-95)",13,10,0
  101.         even
  102.  
  103. startpronet    moveq    #pnr_Size,d0
  104.         bsr    GetIORequest
  105.         move.l    d0,pronetio
  106.         beq    spnoioreq
  107.         bsr    CreatePort
  108.         move.l    d0,pronetmsgport
  109.         beq    spnomsgport
  110.         lea    pronetname(pc),a0
  111.         move.l    unit(pc),d0
  112.         moveq    #0,d1
  113.         move.l    pronetio(pc),a1
  114.         move.w    #0,pnr_NetSourcePort(a1)
  115.         move.l    pronetmsgport(pc),pnr_MsgPort(a1)
  116.         move.l    4.w,a6
  117.         LIBCALL    OpenDevice
  118.         tst.l    d0
  119.         bne.s    spnodev
  120.         move.l    pronetio(pc),a1
  121.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  122.         clr.l    pnr_Length2(a1)
  123.         move.l    pronetmsgport(pc),a0
  124.         move.b    MP_SIGBIT(a0),Signal.pronet
  125.         moveq    #0,d0
  126.         rts
  127.  
  128. spnodev        move.l    pronetmsgport(pc),a0
  129.         bsr    DeletePort
  130. spnomsgport    move.l    pronetio(pc),a0
  131.         bsr    FreeIORequest
  132. spnoioreq    moveq    #-1,d0
  133.         rts
  134.  
  135. ; -- InputHandler zum Handlen der DISKREMOVED/INSERTED-Messages hochfahren
  136. ; -- und entsprechende Signalbits für's Hauptprogramm eintragen.
  137. StartInputHandler
  138.         move.l    4.w,a6
  139.         moveq    #-1,d0
  140.         LIBCALL    AllocSignal
  141.         move.b    d0,Signal.diskins
  142.         moveq    #-1,d0
  143.         LIBCALL    AllocSignal
  144.         move.b    d0,Signal.diskrem
  145.  
  146.         moveq    #IOSTD_SIZE,d0
  147.         bsr    GetIORequest
  148.         move.l    d0,a3
  149.         move.l    a3,inputio
  150.         lea    inputname(pc),a0
  151.         moveq    #0,d0
  152.         moveq    #0,d1
  153.         move.l    a3,a1
  154.         move.l    4.w,a6
  155.         LIBCALL    OpenDevice
  156.  
  157.         move.l    a3,a1
  158.         move.w    #IND_ADDHANDLER,IO_COMMAND(a1)
  159.         move.l    #.int,IO_DATA(a1)
  160.         LIBCALL    DoIO
  161.         rts
  162. .int        dc.l    0,0
  163.         dc.b    NT_INTERRUPT,100
  164.         dc.l    .intname,0,InputHandlerRout
  165. .intname    dc.b    "ProNET Server",0
  166.         even
  167.  
  168. startmessage    move.l    dosbase(pc),a6
  169.         LIBCALL    Output
  170.         move.l    d0,d1
  171.         move.l    #starttext,d2
  172.         move.l    #starttextl,d3
  173.         LIBCALL    Write
  174.         rts
  175.  
  176. w4mquitflag    dc.w    0
  177. Wait4Message    tst.w    w4mquitflag
  178.         bne    .quit
  179.         clr.w    w4mquitflag
  180.  
  181.         lea    Signals(pc),a3    * auf die Messages
  182.         moveq    #0,d0        * an allen möglichen
  183.         moveq    #numports-1,d1    * Ports warten
  184. .loop1        move.b    (a3),d2
  185.         bmi.s    .0
  186.         bset    d2,d0
  187. .0        addq.w    #6,a3
  188.         dbra    d1,.loop1
  189.     IFNE    DEBUG
  190.     lea    dwaitt(pc),a0
  191.     bsr    dtype
  192.     ENDC
  193.         move.l    4.w,a6
  194.         LIBCALL    Wait
  195.                     * entsprechende Routinen
  196.         moveq    #31,d7        * aufrufen
  197. .00        rol.l    #1,d0
  198.         bcc.s    .notthisbit
  199.         lea    Signals(pc),a3
  200.         moveq    #numports-1,d4
  201. .01        cmp.b    (a3),d7
  202.         bne.s    .notthisport
  203.         movem.l    d0/d4/d7/a3,-(sp)
  204.         move.l    2(a3),a3
  205.         jsr    (a3)
  206.         movem.l    (sp)+,d0/d4/d7/a3
  207. .notthisport    addq.w    #6,a3
  208.         dbra    d4,.01
  209. .notthisbit    dbra    d7,.00    
  210.  
  211.         bra    Wait4Message
  212. .quit        rts
  213. Signals:
  214. Signal.pronet    dc.b    -1,0            ;Signalbit
  215.         dc.l    GetProNETMsg        ;entsprechende Routine
  216. Signal.diskins    dc.b    -1,0
  217.         dc.l    MsgDiskIns
  218. Signal.diskrem    dc.b    -1,0
  219.         dc.l    MsgDiskRem
  220. numports    equ    3
  221.  
  222. InputHandlerRout
  223.         movem.l    a0/a1/a6,-(sp)
  224.         move.l    a0,d0
  225.         beq.s    .ende
  226.         move.l    4.w,a6
  227. .1        move.b    ie_Class(a0),d0
  228.         cmp.b    #IECLASS_DISKREMOVED,d0
  229.         beq.s    .diskrem
  230.         cmp.b    #IECLASS_DISKINSERTED,d0
  231.         beq.s    .diskins
  232. .next        move.l    (a0),a0
  233.         move.l    a0,d0
  234.         bne.s    .1
  235. .ende        movem.l    (sp)+,a0/a1/a6
  236.         move.l    a0,d0
  237.         rts
  238. .diskrem    move.l    ourtask(pc),a1
  239.         moveq    #0,d0
  240.         move.b    Signal.diskrem(pc),d1
  241.         bset    d1,d0
  242.         LIBCALL    Signal
  243.         bra.s    .next
  244. .diskins    move.l    ourtask(pc),a1
  245.         moveq    #0,d0
  246.         move.b    Signal.diskins(pc),d1
  247.         bset    d1,d0
  248.         LIBCALL    Signal
  249.         bra.s    .next
  250.  
  251. ; -- Eine Disk wurde neu eingelegt - hier wird getestet, ob es eine
  252. ; -- von unseren Gast-Handlern ist, wenn ja, werden entsprechende
  253. ; -- Maßnahmen eingeleitet...
  254. MsgDiskIns
  255.         IFNE    DEBUG
  256.         move.w    #$0f0,$dff180
  257.         ENDC
  258.         move.l    #ACTION_DISKINS,d6
  259.         moveq    #2,d7
  260.         bra.s    msginsrem_sub
  261.  
  262. ; -- Eine Disk wurde entnommen - siehe 'MsgDiskIns'
  263. MsgDiskRem
  264.         IFNE    DEBUG
  265.         move.w    #$f00,$dff180
  266.         ENDC
  267.         move.l    #ACTION_DISKREM,d6
  268.         moveq    #2,d7
  269.         bra.s    msginsrem_nodel
  270.  
  271. msginsrem_sub    subq.w    #1,d7
  272.         bpl.s    .0
  273.         rts
  274. .0        move.l    dosbase(pc),a6
  275.         moveq    #50,d1
  276.         LIBCALL    Delay
  277.  
  278. msginsrem_nodel    lea    HandlerList(pc),a2    ;in d6 ACTION_DISKINS/REM
  279. .loop        move.l    (a2),d0
  280.         beq.s    msginsrem_sub
  281.         move.l    d0,a2
  282.         move.l    phn_handlerID(a2),a0
  283.         bsr    FindVolume
  284.         cmp.l    phn_volnode(a2),d0
  285.         beq.s    .loop
  286.         move.l    d0,a5
  287.         move.l    d0,phn_volnode(a2)    * Disk wurde gewechselt !!
  288.  
  289.         move.l    phn_dlbytes(a2),d0    ;es wird gerade downgeloadet
  290.         bne.s    .ende            ;(ne Msg würde den Betrieb
  291.                         ;stören !!)
  292.         move.l    pronetio(pc),a4        * Message an den Handler
  293.         move.w    phn_port(a2),pnr_NetDestPort(a4)    * schicken..
  294.         lea    sendbuf,a3
  295.         move.l    d6,(a3)+
  296.         cmp.l    #ACTION_DISKREM,d6
  297.         beq.s    .nocopy
  298.         move.l    a5,d0
  299.         lsr.l    #2,d0
  300.         move.l    d0,(a3)+
  301.         lea    dol_VolumeDate(a5),a0
  302.         move.l    (a0)+,(a3)+
  303.         move.l    (a0)+,(a3)+
  304.         move.l    (a0)+,(a3)+    ;VolumeDate und Name
  305.         move.l    dol_Name(a5),a0    ;müssen kopiert werden..
  306.         add.l    a0,a0
  307.         add.l    a0,a0
  308.         moveq    #0,d0
  309.         move.b    (a0),d0
  310.         addq.w    #1,d0
  311. .copyname    move.b    (a0)+,(a3)+
  312.         dbra    d0,.copyname
  313. .nocopy        lea    sendbuf,a0
  314.         move.l    a0,pnr_Data1(a4)
  315.         sub.l    a0,a3
  316.         move.l    a3,pnr_Length1(a4)
  317.         move.l    4.w,a6
  318.         move.l    a4,a1
  319.         LIBCALL    DoIO
  320. .ende        rts
  321.  
  322. GetProNETMsg    move.l    4.w,a6
  323.         move.l    pronetmsgport(pc),a0
  324.         LIBCALL    GetMsg
  325.         tst.l    d0
  326.         beq    .ende
  327.         move.l    d0,actpronetmsg
  328.         move.l    d0,a2
  329.         lea    MN_SIZE(a2),a2
  330.         move.w    (a2)+,d2    ;[d2] Sourceport [a2] Data
  331.         move.l    (a2)+,d0    ;[d0] dp_Action
  332.     IFNE    DEBUG
  333.     bsr    dtypedec
  334.     bsr    dcr
  335.     ENDC
  336.         lea    sendbuf+12,a3    ;[a3] sendbuf+12
  337.         move.l    d0,-12(a3)
  338.         move.l    pronetio(pc),a4    ;[a4] PNRequest
  339.         move.w    d2,pnr_NetDestPort(a4)
  340.         lea    HandlerList(pc),a5
  341. .findnodeloop    move.l    (a5),a5
  342.         move.l    a5,d1
  343.         beq.s    .findrout
  344.         cmp.w    phn_port(a5),d2
  345.         bne.s    .findnodeloop
  346.         move.l    phn_dlbytes(a5),d7
  347.         beq.s    .nodown
  348.         lea    ACT_WRITEdownload(pc),a1
  349.         bra.s    .callit
  350. .nodown        move.l    phn_packet(a5),a4
  351.         move.l    d0,dp_Action(a4)
  352. .findrout    lea    at(pc),a0
  353.         moveq    #atl-1,d1
  354. .findroutloop    cmp.l    (a0),d0
  355.         bcs.s    .next
  356.         cmp.l    4(a0),d0
  357.         bls.s    .jsrroutine
  358. .next        lea    12(a0),a0
  359.         dbra    d1,.findroutloop
  360.         bsr    ACT_NIL
  361.         bra.s    .reply
  362. .jsrroutine    sub.l    (a0),d0
  363.         add.l    d0,d0
  364.         move.l    8(a0),a0
  365.         lea    at(pc),a1
  366.         add.w    (a0,d0.l),a1
  367. .callit        jsr    (a1)
  368. .reply        move.l    actpronetmsg(pc),a1
  369.         move.l    4.w,a6
  370.         LIBCALL    ReplyMsg
  371.         bra    GetProNETMsg
  372. .ende        rts
  373.  
  374.         cnop    0,4
  375. at        ;dc.l    lowerbound,upperbound,tableaddress
  376.         dc.l    7,34,actiontable1
  377.         dc.l    40,40,actiontable2
  378.         dc.l    82,82,actiontable3
  379.         dc.l    87,87,actiontable4
  380.         dc.l    1004,1008,act