O D I R ; ; input: @r5 wildcarded filespec ; output: r0 error code ; ; DODIR prints a directory listing at the local terminal. ; ; ; S D O D I R ; ; Passed: @r5 wildcarded name ; Return: r0 error code, zero for no errors ; r1 next character in the directory listing ; ; SDODIR is called by the server to respond to a remote directory ; command. Instead of the pre 2.38 method of dumping output to a ; disk file and then sending the disk file in an extended replay, ; SDODIR returns the next character so that BUFFIL can use it. ; The routine GETCR0 is actually a dispatch routine to call the ; currently selected GET_NEXT_CHARACTER routine. .save .psect dirmap ,rw,d,gbl,rel,ovr dirnam: .blkw 1 ; /51/ Filled in at startup dirbfr: .blkw 1 ; /51/ Ditto .psect rtdir1 ,rw,d,gbl,rel,con diridx: .word 0 dirptr: .word 0 wild: .asciz /*.*/ dspace: .byte 40,0 dcrlf: .byte 15,12,0 .even .restore dodir:: save ; save these please mov 2(r5) ,outlun 10$: mov @r5 ,-(sp) mov #1 ,-(sp) mov sp ,r5 call .dodir cmp (sp)+ ,(sp)+ 100$: unsave clr r0 return .dodir: tst itsopen ; need to open it up beq 10$ ; yes .close #lun.sr ; please close up shop first clr itsopen ; say it's closed now 10$: call opndev ; get the disk opened up please tst r0 ; any errors ? bne 100$ ; yes, we will have to die then mov sp ,itsopen ; device is open for next call 50$: call pridir ; lookup the next one please tst r0 ; errors ? beq 50$ ; no 90$: mov r0 ,-(sp) ; yes, close the device please .close #lun.sr ; close the device up on errors clr itsopen ; insure we do an open next time mov (sp)+ ,r0 ; restore the error code now 100$: return ; return any errors in r0 .sbttl SDODIR directoty stuff for a server sdirin::strcpy dirnam ,@r5 ; copy name over mov dirbfr ,dirptr ; yes, init pointers please clr diridx ; ditto call dirini ; init for calls to sdodir bcs 100$ mov dirbfr ,dirptr ; yes, init pointers please clrb @dirptr ; yes, zap the buffer call dirnex ; preload buffer 100$: return sdodir::save 10$: movb @dirptr ,r1 ; get the next character please bne 20$ ; something was there mov dirbfr ,dirptr ; reset the pointer clrb @dirptr ; yes, zap the buffer call dirnex ; empty buffer, load with next file bcs 90$ ; no more, return ER$EOF br 10$ ; and try again 20$: inc dirptr ; pointer++ clr r0 ; no errors br 100$ ; exit 90$: mov #ER$EOF ,r0 ; failure, return(EOF) 95$: clr r1 ; return no data also clr diridx ; init for next time through 100$: unsave return dirini: clr diridx ; clear context flag mov dirbfr ,dirptr ; set pointer up for SDODIR clrb @dirptr ; clear buffer return ; thats all folks dirnex: movb defdir ,-(sp) ; anything in DEFDIR ? bne 10$ ; yes, don't alter it please strcpy #defdir ,#wild ; nothing, insert *.*;* 10$: mov dirbfr ,r2 ; pointer to buffer mov #junk ,r3 ; pointer to work buffer calls lookup ,<#3,dirnam,#diridx,r2> tst r0 ; successfull? bne 80$ ; no strlen r2 ; get the length of the string mov #20 ,r1 ; and format the string sub r0 ,r1 ; number of spaces to append ble 30$ ; can't happen 20$: strcat r2 ,#dspace ; append spaces please sob r1 ,20$ ; next please 30$: deccvt loklen ,r3 ; filesize clrb 6(r3) ; insure .asciz please strcat r2 ,r3 ; append it please strcat r2 ,#dspace ; a space mov lokdate ,r0 ; get date converted bne 40$ ; valid dec r0 ; invalid, force 00-xxx-00 40$: calls cvtdat ,,nogbl ; append the date please strcat r2 ,r3 ; strcat r2 ,#dcrlf ; yes, append clr r0 ; success br 100$ ; exit 80$: cmp r0 ,#ER$NMF ; no more files error ? bne 90$ ; no tst diridx ; ever do anything? bne 90$ ; yes mov #ER$FNF ,r0 ; no, convert to file not found 90$: sec 100$: movb (sp)+ ,defdir ; restore DEFDIR return .sbttl open the disk up K11RTDMAC[.050032]K11RTD.MAC[.050032]    X14|H [4;Ik(&'( k ߫H&P` \RrPP2PPzPP{PPPPP2P~\$\\TD 0D \~ hi) +\ ^( n ^( np\^txY\^ˀ\!kVk<\F˰<˴ˬ\VVkˤ1`@lP ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789<@<SЬTЬ UQS>?\\\\\\\\\`:#@'="\abcdefghi\\\\\\\jklmnopqr\\\\\\\~stuvwxyz\\\\\\\\\\\\\\\\\\\\\\{ABCDEFGHI\\\\\\}JKLMNOPQR\\\\\\\\STUVWXYZ\\\\\\0123456789\\\\\  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~@ggh<i|o<m<4p<p<k|Zn<l fr rwx<x<x<x޺<w@]@@fjnr]Ze@@|> | |v<H|  |  |xz|  |zt f r   < &^ @&@'*/V,"?Lh:hmBmz|z{x`y~|fN|@@|@͂|@ ݃ƃ<ns<|Ŏ |️|ep|u|-@率|<ᄇ2ֻr||ZRM | ntB|xyvZw|J=|R>|J? nnaa|bddfand exit br 100$ ; bye 90$: movb @#errbyt,r0 ; get the error code asl r0 ; times two mov reaerr(r0),r0 ; map it into a unique global error 100$: mov (sp)+ ,r2 ; /54/ mov (sp)+ ,r1 ; /54/ return ; bye .save ; /54/ .psect $PDATA ,D ; /54/ rt: .asciz /DECRT11/ ; /54/ vms: .asciz /DECVMSEX/ ; /54/ From EXCHANGE under VMS4.x .even ; /54/ .restore ; /54/ gethdr: .readw #rtwork,#lun.sr,#dirbuf,#1000,r1 bcs 90$ ; it failed, bye mov #dirbuf ,r0 ; point to the buffer now mov h$nseg(r0),h.nseg ; get the total segment count now asl h$next(r0) ; segments are two blocks in length beq 5$ ; no more segments if zero add #4 ,h$next(r0) ; and at last, the offset 5$: mov h$next(r0),h.next ; get the link to the next one tst h.max ; already set up ? bne 10$ ; yes, don't touch it please mov h$max(r0) ,h.max ; get the maximum segment in use 10$: mov h$ext(r0) ,h.ext ; get the extra words per dir entry mov h$blk(r0) ,h.blk ; and the starting block for data mov #7*2 ,dirsiz ; the default entry size add h$ext(r0),dirsiz ; plus extra bytes per entry clr r0 ; no errors br 100$ ; and exit 90$: movb @#errbyt,r0 ; get the error code asl r0 ; times two mov reaerr(r0),r0 ; map it into a unique global error 100$: return ; bye global .sbttl print the directory out pridir: save ; save temps call gethom ; read in the home block tst r0 ; did it work ? bne 100$ ; no, exit with the error please mov hd.fir ,r1 ; get this directory entry 10$: tst r1 ; end of the directory list ? beq 90$ ; yes, return 'no more files' please call gethdr ; the the first directory header tst r0 ; did this work out ? bne 100$ ; no, return mapped error code please mov #dirbuf ,r3 ; point to the directory buffer add #5*2 ,r3 ; skip past the header information 20$: bit #endseg ,f.stat(r3) ; end of this segment ? bne 80$ ; yes, try the next one please bit #perm ,f.stat(r3) ; is this a real file ? beq 70$ ; no, skip it please call match ; see if the file matches up tst r0 ; well ? beq 70$ ; no, try again please mov #junk ,r2 ; a local buffer to use call convert ; convert to asciz mov #junk ,-(sp) ; push the buffer address call 110$ ; dump it please deccvt f.len(r3),#junk ; convert size to decimal clrb junk+6 ; insure .asciz please mov #junk ,-(sp) ; push the buffer address call 110$ ; and do it mov #210$ ,-(sp) ; push buffer call 110$ ; dump it mov f.date(r3),r0 ; a real date today? bne 60$ ; yes dec r0 ; no, force 00-xxx-00 60$: calls cvtdat ,<#junk,r0>,nogbl; and convert the date mov #junk ,-(sp) ; same again call 110$ ; mov #200$ ,-(sp) ; call 110$ ; 70$: add dirsiz ,r3 ; skip to the next entry please br 20$ ; and check this one out please 80$: mov h.next ,r1 ; end of segment, check the next one br 10$ ; simple to do 90$: mov #er$nmf ,r0 100$: unsave ; pop temps and exit return 110$: save ; save registers mov 12(sp) ,r3 ; get the buffer address tst outlun ; output to disk or terminal beq 150$ ; tt: strlen r3 ; disk, get the buffer size mov r0 ,r2 ; save it please beq 190$ ; nothing to do 120$: movb (r3)+ ,r0 ; get the next character mov outlun ,r1 ; set the lun up also call putcr0 ; dump the character sob r2 ,120$ ; and get the next one br 190$ ; exit 150$: .print r3 ; output to tt: 190$: unsave ; pop registers and exit mov (sp)+ ,(sp) ; move return address up and exit return ; bye 200$: .byte 15,12,0 210$: .byte 40,40,40,0 .even .sbttl get the next entry matching a possibly wildcarded name getnth: save ; save temps clr r4 ; counter for number of matches call gethom ; read in the home block tst r0 ; did it work ? bne 100$ ; no, exit with the error please mov hd.fir ,r1 ; get this directory entry 10$: tst r1 ; end of the directory list ?K11RTDMAC[.050032]K11RTD.MAC[.050032]    X14|H [4;Ik(&'( k ߫H&P` \RrPP2PPzPP{PPPPP2P~\$\\TD 0D \~ hi) +\ ^( n ^( np\^txY\^ˀ\!kVk<\F˰<˴ˬ\VVkˤ1`@lP ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789<@<SЬTЬ UQS>?\\\\\\\\\`:#@'="\abcdefghi\\\\\\\jklmnopqr\\\\\\\~stuvwxyz\\\\\\\\\\\\\\\\\\\\\\{ABCDEFGHI\\\\\\}JKLMNOPQR\\\\\\\\STUVWXYZ\\\\\\0123456789\\\\\  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~@ggh<i|o<m<4p<p<k|Zn<l fr rwx<x<x<x޺<w@]@@fjnr]Ze@@|> | |v<H|  |  |xz|  |zt f r   < &^ @&@'*/V,"?Lh:hmBmz|z{x`y~|fN|@@|@͂|@ ݃ƃ<ns<|Ŏ |️|ep|u|-@率|<ᄇ2ֻr||ZRM | ntB|xyvZw|J=|R>|J? nnaa|bddfstar ; check the filetype for wildcards beq 20$ ; a match, return success cmp filnam+6,f.type(r3) ; no wildcard, check for exact match bne 90$ ; failure, exit 20$: mov sp ,r0 ; success, return r0 <> 0 br 100$ ; bye 90$: clr r0 ; failure 100$: return ; and exit at last .endc percent = 131574 wildc = '. match: save ; we may need these here mov filnam+2,rtwork+0 ; copy the name and type please mov filnam+4,rtwork+2 ; copy the name and type please mov filnam+6,rtwork+4 ; copy the name and type please cmp rtwork ,#star ; if we parsed a star, convert it bne 20$ ; into '%%%%%%' for the filename mov #percent,rtwork+0 ; do it mov #percent,rtwork+2 20$: cmp rtwork+4,#star ; if we had a * for the filetype bne 30$ ; then convert it into a '.%%%' mov #percent,rtwork+4 30$: mov #name1 ,r1 ; was not a simple pattern so convert mov #rtwork ,r2 ; both names back to ascii and check mov #3 ,r0 ; for individual character wildcarding 40$: calls rdtoa , ; convert the patter filename back add #3 ,r1 ; increment the pointer by 3 characters sob r0 ,40$ ; next please mov #name2 ,r1 ; a buffer for the file we just found mov r3 ,r2 ; on the disk. Now get the address of add #f.nam1 ,r2 ; the name and filetype and convert this mov #3 ,r0 ; to ascii in a loop 50$: calls rdtoa , ; convert add #3 ,r1 ; next please sob r0 ,50$ 60$: mov #11 ,r0 ; the loop count for scanning mov #name1 ,r1 ; the pattern mov #name2 ,r2 ; the current filename on disk 70$: cmpb @r1 ,(r2)+ ; if they match, no problem beq 80$ ; simply check the next character cmpb @r1 ,#wildc ; check for the converted % bne 90$ ; match failure 80$: inc r1 ; sob r0 ,70$ ; match so far, check the next ones mov sp ,r0 ; flag success and exit br 100$ ; bye 90$: clr r0 ; failure, exit 100$: unsave return ; and exit at last .sbttl ascdat convert to ascii date for RT11 .mcall .date ; input: @r5 output buffer address ; 2(r5) value of date, zero implies current ; ; I certainly could use my ASH and DIV macros, but may as ; well do it this way for future possibilities. ; ; N O T E : This is a LOCAL copy of ASCDAT so I can overlay ; the real ACSDAT oppossing this overlay. cvtdat: save ; save these please mov @r5 ,r1 ; the result address cmp 2(r5) ,#-1 ; if -1, then return 00-XXX-00 bne 5$ ; no copyz #310$ ,r1 ; yes, then exit br 100$ ; bye 5$: mov 2(r5) ,r0 ; get the date desired please bne 10$ ; it's ok .date ; zero, assume todays date then 10$: bic #100000 ,r0 ; undefined mov r0 ,r3 ; copy the date asr r3 ; /2 asr r3 ; /2 again asr r3 ; ditto asr r3 ; sigh asr r3 ; at last bic #^C37 ,r3 ; the date, at last call 200$ ; convert it mov r0 ,r3 ; get the date once again please swab r3 ; get the month to bits 2..7 asr r3 ; /2 asr r3 ; /2 again bic #^C17 ,r3 ; get rid of the unwanted bits now dec r3 ; convert to 0..11 asl r3 ; convert to word offset asl r3 ; quad offset add #300$ ,r3 ; the address of the text movb #'- ,(r1)+ ; copy it over please movb (r3)+ ,(r1)+ ; three characters please movb (r3)+ ,(r1)+ ; three characters please movb (r3)+ ,(r1)+ ; three characters please movb #'- ,(r1)+ ; copy it over please mov r0 ,r3 ; copy the date bic #^C37 ,r3 ; the year, at last add #110 ,r3 ; plus the bias please call 200$ ; convert clrb @r1 ; .asciz and exit 100$: unsave return 200$: clr r2 ; subtract 10 a few times 210$: inc r2 ; high digit number sub #12 ,r3 ; until we get a negative number tst r3 ; done yet ? bge 210$ ; no dec r2 ; yes add #12 ,r3 ; correct it please add #'0 ,r2 ; and copy the day number please add #'0 ,r3 ; simple movb r2 ,(r1)+ ; copy it movb r3 ,(r1)+ ; copy it return 300$: .ascii /Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec / 310$: .asciz /00-XXX-00/ .even .end K11RTDMAC[.050032]K11RTD.MAC[.050032]   X14|H [4;Ik(&'( k ߫H&P` \RrPP2PPzPP{PPPPP2P~\$\\TD 0D \~ hi) +\ ^( n ^( np\^txY\^ˀ\!kVk<\F˰<˴ˬ\VVkˤ1`@lP ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789<@<SЬTЬ UQS>?\\\\\\\\\`:#@'="\abcdefghi\\\\\\\jklmnopqr\\\\\\\~stuvwxyz\\\\\\\\\\\\\\\\\\\\\\{ABCDEFGHI\\\\\\}JKLMNOPQR\\\\\\\\STUVWXYZ\\\\\\0123456789\\\\\  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~@ggh<i|o<m<4p<p<k|Zn<l fr rwx<x<x<x޺<w@]@@fjnr]