.title INQUIRE ; ; INQUIRE checks for the existence and availability of a file. ; The sub fields of the expanded file-spec are optionally available. ; ; Written by Art Moorshead ; ; Calling sequence: ; ; ret-status.wlc.v = inquire (in-file.rt.dx ; [,[out-file.wt.dx] [,[out-len.wlu.r] ; [,[node.wt.dx] [,[nodel.wlu.r] ; [,[device.wt.dx] [,[devicel.wlu.r] ; [,[directory.wt.dx] [,[directoryl.wlu.r] ; [,[name.wt.dx] [,[namel.wlu.r] ; [,[type.wt.dx] [,[typel.wlu.r] ; [,[version.wt.dx] [,[versionl.wlu.r] ; ]]]]]]]]]]]]]]) ; ; in-file: File to examine ; out-file: Expanded filespec ; out-len: Length of the expanded filespec ; node Optional Node name (including ::) ; nodel Optional Node name length ; device Optional Device name (including :) ; devicel Optional Device name length ; directory Optional directory (including []) ; directoryl Optional directory length ; name: Optional file name ; namel: Optional file name length ; type: Optional file type (including .) ; typel: Optional file type length ; version: Optional file version (including ;) ; versionl: Optional file version length ; ret-status: RMS$_NORMAL, RMS$_FNF, RMS error code ; .psect data, wrt, noexe, pic, long innam: $nam esa = exp,- ess = NAM$C_MAXRSS,- rsa = res,- rss = NAM$C_MAXRSS infab: $fab nam = innam exp: .blkb NAM$C_MAXRSS res: .blkb NAM$C_MAXRSS IN_FILE = 4 ; INQUIRE pass parameters OUT_FILE = 8 OUT_LEN = 12 NODE = 16 NODEL = 20 DEVICE = 24 DEVICEL = 28 DIRECTORY = 32 DIRECTORYL = 36 NAME = 40 NAMEL = 44 TYPE = 48 TYPEL = 52 VERSION = 56 VERSIONL = 60 BLANK = 32 .psect code, nowrt, exe, pic, long, shr .page .subtitle INQUIRE ; ; Open and close the file, and return the desired fields. ; .entry inquire, ^M movq @IN_FILE(ap),r0 ; get input file name movb r0,infab + FAB$B_FNS movl r1,infab + FAB$L_FNA $parse fab=infab ; parse file spec blbs r0,40$ ret ; quit on error 40$: $search fab=infab ; search for file pushl r0 ; save RMS exit status casel (ap), #1, #14 ; see how many arguments given 100$: .word 800$ - 100$ ; only 1 argument .word 290$ - 100$ ; Expanded File-spec .word 280$ - 100$ ; File-spec length .word 270$ - 100$ ; Node .word 260$ - 100$ ; Node length .word 250$ - 100$ ; Device .word 240$ - 100$ ; Device length .word 230$ - 100$ ; Directory .word 220$ - 100$ ; Directory length .word 210$ - 100$ ; Name .word 200$ - 100$ ; Name length .word 190$ - 100$ ; Type .word 180$ - 100$ ; Type length .word 170$ - 100$ ; Version .word 160$ - 100$ ; Version length 160$: tstl VERSIONL (ap) ; Version length beql 170$ movzbl innam + NAM$B_VER, r4 movl r4, @VERSIONL (ap) 170$: tstl VERSION (ap) ; Version string beql 180$ movq @VERSION (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_VER, r4 movl innam + NAM$L_VER, r5 movc5 r4, (r5), #BLANK, r2, (r3) 180$: tstl TYPEL (ap) ; Type length beql 190$ movzbl innam + NAM$B_TYPE, r4 movl r4, @TYPEL (ap) 190$: tstl TYPE (ap) ; Type string beql 200$ movq @TYPE (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_TYPE, r4 movl innam + NAM$L_TYPE, r5 movc5 r4, (r5), #BLANK, r2, (r3) 200$: tstl NAMEL (ap) ; Name length beql 210$ movzbl innam + NAM$B_NAME, @NAMEL (ap) 210$: tstl NAME (ap) ; Name string beql 220$ movq @NAME (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_NAME, r4 movl innam + NAM$L_NAME, r5 movc5 r4, (r5), #BLANK, r2, (r3) 220$: tstl DIRECTORYL (ap) ; Directory length beql 230$ movzbl innam + NAM$B_DIR, @DIRECTORYL (ap) 230$: tstl DIRECTORY(ap) ; Directory string beql 240$ movq @DIRECTORY (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_DIR, r4 movl innam + NAM$L_DIR, r5 movc5 r4, (r5), #BLANK, r2, (r3) 240$: tstl DEVICEL(ap) ; Device length beql 250$ movzbl innam + NAM$B_DEV, @DEVICEL(ap) 250$: tstl DEVICE(ap) ; Device string beql 260$ movq @DEVICE (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_DEV, r4 movl innam + NAM$L_DEV, r5 movc5 r4, (r5), #BLANK, r2, (r3) 260$: tstl NODEL (ap) ; Node length beql 270$ movzbl innam + NAM$B_NODE, @NODEL (ap) 270$: tstl NODE (ap) ; Node string beql 280$ movq @NODE (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_NODE, r4 movl innam + NAM$L_NODE, r5 movc5 r4, (r5), #BLANK, r2, (r3) 280$: tstl OUT_LEN (ap) ; expanded name length beql 290$ movzbl innam + NAM$B_RSL, @OUT_LEN (ap) 290$: tstl OUT_FILE (ap) ; expanded name string beql 800$ movq @OUT_FILE (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_RSL, r4 movl innam + NAM$L_RSA, r5 movc5 r4, (r5), #BLANK, r2, (r3) 800$: popl r0 ; recover r0 ret ; return with status in R0 .page .subtitle CHECK_DIR ; ; CHECK_DIR checks for the existence of a directory and the ; syntactical correctness of a directory specification. It ; optionally returns the device and directory strings. ; ; Calling sequence: ; ; ret-status.wlc.v = check_dir (in-file.rt.dx ; [,[device.wt.dx] [,[devicel.wlu.r] ; [,[dir.wt.dx] [,[dirl.wlu.r]]]]]) ; ; in-file: Directory spec to examine ; device: Device string ; devicel: Length of Device string ; dir: Directory string ; dirl: Directory length ; ret-status: RMS$_NORMAL, RMS$_DNF, RMS$_DIR ; .entry check_dir, ^M DIR_FILE = 4 ; Directory spec to parse DEV = 8 ; Device DEVL = 12 ; Device length DIR = 16 ; Directory DIRL = 20 ; Directory length movq @DIR_FILE (ap), r0 ; get input spec movb r0,infab + FAB$B_FNS movl r1,infab + FAB$L_FNA $parse fab=infab ; parse directory spec blbs r0, 20$ ret ; error 20$: pushl r0 ; save exit status casel (ap), #1, #4 ; see how many arguments given 100$: .word 300$ - 100$ ; only 1 argument .word 230$ - 100$ ; give device .word 220$ - 100$ ; give device length .word 210$ - 100$ ; give directory .word 200$ - 100$ ; give directory length 200$: tstl DIRL (ap) ; directory length beql 210$ movzbl innam + NAM$B_DIR, @DIRL (ap) 210$: tstl DIR (ap) ; directory string beql 220$ movq @DIR (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_DIR, r4 movl innam + NAM$L_DIR, r5 movc5 r4, (r5), #BLANK, r2, (r3) 220$: tstl DEVL (ap) ; device length beql 230$ movzbl innam + NAM$B_DEV, @DEVL (ap) 230$: tstl DEV (ap) ; device string beql 300$ movq @DEV (ap), r2 movzwl r2, r2 movzbl innam + NAM$B_DEV, r4 movl innam + NAM$L_DEV, r5 movc5 r4, (r5), #BLANK, r2, (r3) 300$: popl r0 ret ; return with status in R0 .end