.TITLE DBSSTS ... Database File Initializer .IDENT /120582/ .ENABL LC ; ; ; ; Written by Ray Di Marco ; 12-May-82 ; ; ;_____________________________________________________________________________ ; ; ; This is the main module for the DBSMNG cusp DBSSTS, that will DISASSEMBLE ; a (.OBJ/.SAV format) database template. The program is created by linking ; this module with the database library, DBSLIB, and optionally with the user ; template. If the template is not linked in the user will be asked for the ; name of the file that holds the template (in .SAV format) when the program ; is executed. ; ; When run, the program will output the names and important attributes of ; the record and key fields. The information output is ; ; Type ... the type of the field. (P <-> protected) ; Size ... number of characters in field ; Offset ... offset of field from start of record-buffer ; Check ... defined check value ; Name ... logical name of field ; ; This program can be envoked as a CUSP from a DBSMNG MENU program, and will ; accept commands via core common. ; ; .SBTTL Declarations ; ; .MCALL CNAF ; CNAF ; .GLOBL FORM$$ ; address template .GLOBL $$FORM ; pointer to template .GLOBL DBSLDR ; template loader ; .GLOBL CON.ST,CON.EX ; CONIO .GLOBL RPTINT,RPTOUC,RPTEND,RPTNME ; RPTFIO ; ; ; CR = 'M-'@ ; ascii for CR LF = 'J-'@ ; ascii for LF FF = 'L-'@ ; ascii for FF ; ; .PSECT CODE ; open code area ; ====== ==== .SBTTL Macro Definitions ; .MACRO PRINT STR=R0 .GLOBL CON.LO MOV STR,R0 CALL CON.LO .ENDM PRINT ; .MACRO GTLIN BUF=R0,STR .IF NB,STR .GLOBL CON.LO MOV STR,R0 CALL CON.LO .ENDC MOV BUF,R0 .GLOBL CON.LI CALL CON.LI .ENDM GTLIN ; .MACRO OUTCHR CHR .IRP X, MOVB X',R0 CALL RPTOUC .ENDR .ENDM OUTCHR ; .MACRO OUTTXT TEXT JSR R1,OUTLIN .ASCIZ /TEXT/ .EVEN .ENDM OUTTXT ; .MACRO OUTLIN TEXT JSR R1,OUTLIN .ASCII /TEXT/ .ASCIZ .EVEN .ENDM OUTLIN ; .MACRO OUTSTR STR MOV STR,R0 CALL OUTSTR .ENDM OUTSTR ; .SBTTL Main Code ; ; ; If TEMPLATE not linked in with the program use DBSLDR to load the template. ; If the template was linked in, $$FORM. If have to load the template ; ourselves we must store the load address (returned in R0 by DBSLDR) in ; $$FORM as its needed later. ; START: CALL CON.ST ; ensure CONIO inited TST $$FORM ; template linked in? BNE 100$ ; yes -> skip GTLIN #BUF,#PRMT ; get TEMPLATE name MOV #BUF,R0 ; R0 -> name CALL DBSLDR ; load template MOV R0,$$FORM ; set up pointer ; ; We must now open the output stream to recieve the status data. ; 100$: GTLIN #RPTNME,#M.RPTN ; get report file name CALL RPTINT ; initialize report file ; ; ; Output report heading and disassemble template. ; OUTCHR <#FF,#CR,#LF> ; start on a new page OUTLIN OUTLIN <------> OUTLIN < > OUTTXT ; output text MOV $$FORM,R0 ; R0 -> template ADD #40,R0 ; R0 -> name CALL OUTSTR ; output string OUTTXT < Record size: > ; output text MOV $$FORM,R0 ; R0 -> template MOV 6(R0),R2 ; R2 = record size CNAF SSSSD,STRING=#BUF ; want as ascii CLRB (R1) ; terminate OUTSTR #BUF ; output ; OUTLIN < > ; leave line OUTLIN ; heading OUTLIN < Type Size Offset Check Name> MOV $$FORM,R0 ; R0 -> RDT CALL FDTASC ; output FDT ; OUTLIN < > ; leave line OUTLIN ; heading OUTLIN < Type Size Offset Check Name> MOV $$FORM,R0 ; R0 -> RDT ADD #30,R0 ; R0 -> KDT CALL FDTASC ; output FDT CALL RPTEND ; close out JMP CON.EX ; .SBTTL Routine - "FDTASC" ... Convert FDT @R0 into ascii and output ; ; ; This routine translates and outputs the contents of the FDT passed ; over in R0. ; FDTASC: MOV 2(R0),R5 ; R5 -> entries MOV 4(R0),R4 ; R4 = number entries 100$: OUTCHR #11 ; indent output MOV #40,R3 ; clear protect flag MOV (R5),R2 ; R2 = Type word BPL 110$ ; no protected -> skip BIC #100000,R2 ; clear protect bit MOV #'P,R3 ; set protect flag 110$: CNAF SSSSSD,STRING=#BUF ; set up type MOVB R3,(R1)+ ; set up P flag CNAF SSSSSSD,NUMBER=2(R5) ; set up SIZE CNAF NUMBER=4(R5) ; set up OFFSET CNAF NUMBER=12(R5) ; set up CHECK MOVB #40,(R1)+ ; insert a space MOVB #200,(R1)+ ; terminate string OUTSTR #BUF ; output attributes OUTSTR 22(R5) ; output field name OUTCHR <#CR,#LF> ; new line ADD #40,R5 ; R5 -> next field SOB R4,100$ ; loop time RETURN ; all done ; ; .SBTTL Primitives to output to report file ; ; ; This routines are used in conjunction with the output macros ; to send text to the report stream. ; OUTLIN: MOVB (R1)+,R0 BEQ 100$ CALL RPTOUC BR OUTLIN 100$: ADD #1,R1 BIC #1,R1 RTS R1 ; OUTSTR: MOV R0,R1 40$: MOVB (R1)+,R0 BEQ 100$ BMI 140$ CALL RPTOUC BR 40$ 100$: OUTCHR <#CR,#LF> 140$: RETURN ; ; .SBTTL Data structures and messages ; ; .PSECT DATA ; open data area ; ====== ==== ; ; $$FORM: .WORD FORM$$ ; points to FDTs BUF: .BLKB 100 ; input buffer PRMT: .ASCII /DBSSTS RDM300482/<15><12> .ASCII / Enter name of TEMPLATE: /<200> M.RPTN: .ASCII / Enter output file name: /<200> .END START