; WNEWS - Read all *.KIN files and enter 'em into the database as texts KIN = 7 ; Channel to use for Writing news ; Structure of block 1 in .KIN-files .asect . = 0 netrec: .blkb 200 ; receiver's name as a STRING comto: .blkb 200 ; comment to text # as a id-STRING $dummy: .blkb 400 sect code proc WNEWS var EB, word var EO, word var TB, word var TO, word var RC, word ; Receiver of this letter! var NP, word ; Net Person on this system var CT, word ; Comment-To text # (physical) var SW, word ; Status Word for TEXT begin clr CT(r5) ; Comment to nothing by default mov #xEXT!xEXIN!xBREV, SW(r5) ; Default status word setnam #"WN mov #LIBINF+16, r1 ; This is where the netperson's id call getadr ; is hidden mov (r1), NP(r5) ; Store it! 10$: gos wopen <#KIN,#INFILE,> ; Wild open next file (always first ; file) bcs 100$ call kill ; Kill the file we just opened call filerr gos get <#KIN,#1,#FB1,#1,> ; Get header block of .KIN-file mov #FB1+netrec, r1 ; Look up the receiver. Destroy FB3 mov #GRPLST, r0 ; Why is this needed? (Anders!) call FindAd ; bcc 15$ bpt br 90$ 15$: mov (r0), RC(r5) ; Save receiver mov #FB1+comto, r1 ; Find out if this is a comment to clr r0 ; some other text. And if so to bisb (r1)+, r0 ; which. beq 17$ call val32 ; Make it into a long text # mov r1, FB1+$dummy mov r0, FB1+$dummy+2 mov #FB1+$dummy, r1 mov #FB3, r0 bpt call FysTxt ; Convert text # to TEXT record # bpt mov r0, CT(r5) beq 17$ bis #xKOM, SW(r5) ; Indicate it's a comment 17$: call Get1st ; Lock block #1 of file 3. mov r3, EB(r5) ; Save block # for EXTERN node mov r4, EO(r5) ; Calculate offset for EXTERN node add #FB4, r4 ; Make it work! 20$: mov #FB2+1000, r1 ; Use this buffer for blocks call xfrtxt ; TRansfer QXTERN from input to output mov FB4-2, TB(r5) ; Block for TEXT mov r4, TO(r5) ; ditto offset sub #FB4, TO(r5) call xfrtxt ; Then transfer the TEXT 40$: call putlst ; Put last block of file 3. Unlock gos mklet2 60$: mov RC(r5), r2 call putlet ; Send it tst CT(r5) ; Any comment beq 90$ ; Nope -> 90$ gos clink ; Link the comment 90$: gos close <#KIN> ; Close the channel in case it was open br 10$ 100$: ret proc clink var tmprec, word begin call MtxBgn gos getrec <#2, toprec(r5), buffer(r5),> tst 32(r1) ; Any comments already? bne 230$ mov comrec(r5), 32(r1) ; comrec(r5) is current record gos put <#2,,buffer(r5)> br 250$ 230$: mov #2, r0 call release ; Release the lock mov 32(r1), tmprec(r5) gos tryrec <#2, 32(r1), buffer(r5),> mov 30(r1), toprec(r5) mov comrec(r5), 30(r1) tst toprec(r5) bne 233$ mov tmprec(r5), toprec(r5) br 235$ 233$: gos putget <#2, toprec(r5), buffer(r5)> 235$: mov comrec(r5), 26(r1) gos putget <#2, comrec(r5), buffer(r5)> mov toprec(r5), 30(r1) gos put <#2,,buffer(r5)> call MtxEnd 250$: ret ; Transfer text from KIN-file to file 3 xfrtxt: call copych ; Copy oe char from KIN/FB2/r1 to mov r0, r2 ; file3/FB4/r4 call copych swab r0 bis r0, r2 ; r2 is the number of lines to copy beq 40$ 10$: call copych ; Copy length byte mov r0, r3 beq 30$ 20$: call copych sob r3, 20$ 30$: sob r2, 10$ 40$: bit #1, r4 ; Odd? beq 50$ call copych 50$: return ; Copy one char from input to output. return in r0 copych: cmp r1, #FB2+1000 blo 10$ gos get <#-KIN, , r1, #1,> ; C set if EOF bcs 20$ 10$: clr r0 bisb (r1)+, r0 call PutChr 20$: rts pc ; Wildcard open proc wopen begin bpt gos fsscan call filerr bcs 20$ movb #UU.LOK, firqb+fqfun mov idx(r5), firqb+4 ; index # for file in directory .uuo ; do it! cmpb firqb, #5 ; NOSUCH ? bne 10$ ; Nope - skip forward sec br 20$ 10$: call filerr bcs 20$ movb chan(r5), firqb+fqfil ; Calculate channel # times 2 asl firqb+fqfil movb #OPNFQ, firqb+fqfun calfip ; Open it! call filerr 20$: ret ; FSSCAN - FSS a file name. Put result in FIRQB proc fsscan begin call clrfqb call clrxrb clr (r1) movb @n(r5), (r1) ; Length of string mov (r1)+, (r1)+ ; " " " mov n(r5), (r1) ; Then the address inc (r1) .fss ret ; CLOSE indicated channel. proc close begin call clrfqb movb ch(r5), firqb+fqfil asl firqb+fqfil calfip ret ; Delete (mark for deletion) the file indicated by firqb contents kill: movb #DLNFQ, firqb+fqfun calfip return RNEWS: setnam #"RN mov #UTFile, r1 call opnfil 10$: clr r0 call nexinl ; Check if any unread tst r0 beq 99$ 20$: call (r0) ; Do it! clr commp br 10$ 99$: bis #UtmOn, KSW Write #EOFM bic #UtmOn, KSW call UtmOff rts pc Text UTFile, <"NETNWS.KUT"> Text INFILE, <"NET:*.KIN">