program files !++ ! ! FILES.BAS - List disk space by user ! ! Author: Don Stokes (don@gp.govt.nz) ! ! This program parses an ANALYZE/DISK/USAGE disk accounting file and ! displays all files used by a particular user. ! ! Three questions are asked: ! ANALYZE/DISK/USAGE output file [USAGE.DAT] : ! Disk accounting file to use. ! ! Output file [SYS$OUTPUT] : ! Output file to write the listing to. ! ! User/UIC : ! User or UIC to display files for. ! !-- option type = explicit external long function SYS$FAO, & SYS$ASCTOID external sub LIB$STOP( long by value ) %include "$SSDEF" %from %library %include "$USGDEF" %from %library map (USAGEFIL) USGDEF i map (USAGEFIL) USGDEF1 f map (CVT) long uic map (CVT) word uic_member, & uic_group declare long constant TRUE = -1, & FALSE = 0 declare long sts, & files, & used, & allocated, & t,n,x,y declare string usage_file, & output_file, & userid ! ! Routine to convert octal to binary ! (required for UIC translation) ! def long oct_to_bin( string o) t = 0 t = t + val%(mid(o, len(o) - n, 1)) * 8^n & for n = 0% to len(o) - 1% oct_to_bin = t end def ! ! Get name of disk accounting file and open ! set no prompt linput "ANALYZE/DISK/USAGE output file [USAGE.DAT] : "; usage_file usage_file = "USAGE.DAT" if usage_file = "" open usage_file for input as file #1, map USAGEFIL ! ! Get output file name and open ! linput "Output file [SYS$OUTPUT] : "; output_file output_file = "SYS$OUTPUT" if output_file = "" open output_file for output as file #2, recordsize 132, & defaultname "FILES.LIS" ! ! Get UIC or username ! If UIC then convert to binary ! If username/rights ID then get binary ! linput "User/UIC : "; userid userid = edit$(userid, 1%+2%+4%+32%) if left(userid, 1%) = "[" then x = instr(0%, userid, ",") y = instr(0%, userid, "]") uic_group = oct_to_bin(seg$(userid, 2%, x - 1%)) uic_member = oct_to_bin(seg$(userid, x + 1%, y - 1%)) else sts = SYS$ASCTOID(userid, uic,) exit program sts unless sts and SS$_NORMAL end if ! ! get #1 print #2, " Volume " + i::USG$T_VOLNAME & + " Owner " + i::USG$T_OWNERNAME & + " Format " + i::USG$T_FORMAT files = 0% used = 0% allocated = 0% while -1% when error in get #1 use continue all_done end when if f::USG$L_FILEOWNER = uic then allocated = allocated + f::USG$L_ALLOCATED - 1% used = used + f::USG$L_USED files = files + 1% print #2, left(f::USG$T_FILESPEC,f::USG$W_SPEC_LEN); & tab(50%); format$(f::USG$L_USED, "########") & + "/" + num1$(f::USG$L_ALLOCATED) end if next all_done: print #2, "Total of " + num1$(files) + " files, " + num1$(used) + "/" & + num1$(allocated) + " blocks." close #1 close #2 end program