.title ac$trn_acr -- translate an accounting record into common ; ; Note: not much validity checking, ignores errors ; doesn't even know how many packets should go with each kind record ; Calling sequence ; ; INCLUDE 'ACCNT.DCK' ; ; CALL AC$TRN_ACR(array-containing-record) ; or CALL AC$TRN_ACR(%ref(string-containing-record)) ; ; where ACCT.DCK contains the common block specifications: ;c ;c common blocks for decoded accounting data ;c ;c common block for integer data ;c ; byte ac$type( 2 ), ac$pri ; integer*2 ac$nodeaddr, ac$uic( 2 ) ; integer*4 ac$cputime, ac$pid, ac$owner, ac$jobid, ac$status, ; - ac$imgcnt, ac$faults, ac$faultio, ac$wspeak, ac$pagefl, ; - ac$diocnt, ac$biocnt, ac$volumes, ac$pagecnt, ac$qiocnt, ; - ac$getcnt ; integer*4 ac$begtime( 2 ), ac$quetime( 2 ), ac$systime( 2 ), ; - ac$priv( 2 ) ; ; common / ac$com_i / ; - ac$begtime, ac$quetime, ac$systime, ac$priv, ac$cputime, ; - ac$pid, ac$owner, ac$jobid, ; - ac$status, ac$imgcnt, ac$faults, ac$faultio, ; - ac$wspeak, ac$pagefl, ac$diocnt, ac$biocnt, ac$volumes, ; - ac$pagecnt, ac$qiocnt, ac$getcnt, ac$nodeaddr, ac$uic, ; - ac$type, ac$prio ;c ;c common block for character data ;c ; character ac$username*12, ac$account*8, ac$nodename*6, ; - ac$terminal*7, ac$jobname*39, ac$queue*16, ac$remoteid*16, ; - ac$junk*256 ; common / ac$com_c / ; - ac$username, ac$account, ac$nodename, ac$terminal, ; - ac$jobname, ac$queue, ac$remoteid, ac$junk ; ; ; ; ; $acrdef GLOBAL ; define some useful symbols .macro movstr s, d, ?x ; move a string into common movzwl s(r6), r0 ; get the offset beql x addl2 r6, r0 ; get addr of counted string movzbl (r0)+, r1 ; get count movc3 r1, (r0), d ; copy the string x: .endm ; ; common block containing integer data ; .psect ac$com_i, pic,ovr,rel,gbl,shr,noexe,rd,wrt,long ac$com_i: ac$begtime: .blkq 1 ; beginning time (i.e. login time) ac$quetime: .blkq 1 ; time print job was entered in queue ac$systime: .blkq 1 ; time record was entered in accounting file ac$priv: .blkq 1 ; privileges ac$cputime: .blkl 1 ; processor time ac$pid: .blkl 1 ; pid ac$owner: .blkl 1 ; owner pid ac$jobid: .blkl 1 ; queue entry number ac$status: .blkl 1 ; final status code ac$imgcnt: .blkl 1 ; execution count ac$faults: .blkl 1 ; page fault count ac$faultio: .blkl 1 ; page fault I/O count ac$wspeak: .blkl 1 ; peak working set ac$pagefl: .blkl 1 ; peak page file usage ac$diocnt: .blkl 1 ; direct I/O count ac$biocnt: .blkl 1 ; buffered I/O count ac$volumes: .blkl 1 ; number of volumes mounted ac$pagecnt: .blkl 1 ; pages printed ac$qiocnt: .blkl 1 ; number of QIOs issued ac$getcnt: .blkl 1 ; number of GETs issued ac$nodeaddr: .blkw 1 ; node address code ac$uic: .blkw 2 ; uic ac$type: .blkb 2 ; record type and subtype ac$prio: .blkb 1 ; priority ac$com_i_len = . - ac$com_i ; ; common block containing character data ; .psect ac$com_c, pic,ovr,rel,gbl,shr,noexe,rd,wrt,long ac$com_c: ac$username: .blkb 12 ; username ac$account: .blkb 8 ; account name ac$nodename: .blkb 6 ; node name ac$terminal: .blkb 7 ; terminal name ac$jobname: .blkb 39 ; job name ac$queue: .blkb 16 ; queue name ac$remoteid: .blkb 16 ; remote id (?) ac$junk: .blkb 256 ; filename, imagename, or user data ac$com_c_len = . - ac$com_c ;----------------------------------------------------------------------- ; the program ; ; register usage: ; r6 -- current position in record ; r7 -- pointer to end of record ; ; ; parameters: p_rec = 4 ; pointer to the accounting file record (passed by reference) ; .psect $code,pic,con,rel,lcl,shr,exe,rd,nowrt,long .entry ac$trn_acr, ^m ; clear the common blocks movc5 #0, (r0), #0, #ac$com_i_len, ac$com_i movc5 #0, (r0), #^a/ /, #ac$com_c_len, ac$com_c ; find the record & it's length movab @p_rec(ap), r6 movzwl acr$w_length(r6), r7 addl2 r6, r7 ; should verify long enough to have valid header ??????????? ; start translating the record movq acr$q_systime(r6), ac$systime ; get system time bsbw trn_type ; read the record type into r0 movw r0, ac$type ; and put it in common addl2 #acr$c_hdrlen, r6 ; step past the header ; loop to translate packets packet_loop: cmpl r6, r7 ; are we done? blss 10$ ret 10$: ; apparently not. bsbw trn_type ; get the packet's type caseb r0, #1, #7 ; what to do now depends on packet type 20$: .word trn_id - 20$ ; 1 = identification packet .word trn_resource - 20$ ; 2 = resource packet .word trn_imagename - 20$ ; 3 = imagename packet .word trn_filename - 20$ ; 4 = filename packet .word trn_user_data - 20$ ; 5 = user data packet .word illegal - 20$ ; 6 = error .word illegal - 20$ ; 7 = error .word trn_print - 20$ ; 8 = print data packet ; illegal packet type: ignore it and hope it'll go away illegal: ; go on to the next packet packet_end: movzwl acr$w_length(r6), r0 addl2 r0, r6 brw packet_loop ; it's an identification packet trn_id: movl acr$l_pid(r6), ac$pid ; copy stuff into common movl acr$l_owner(r6), ac$owner movl acr$l_uic(r6), ac$uic movq acr$q_priv(r6), ac$priv movb acr$b_pri(r6), ac$prio movl acr$l_jobid(r6), ac$jobid movw acr$w_nodeaddr(r6), ac$nodeaddr ; should verify lengths of destination buffers big enough ???? movstr acr$w_username, ac$username ; now for the strings movstr acr$w_account, ac$account movstr acr$w_nodename, ac$nodename movstr acr$w_terminal, ac$terminal movstr acr$w_jobname, ac$jobname movstr acr$w_queue, ac$queue movstr acr$w_remoteid, ac$remoteid brw packet_end ; done with this packet ; it's a resource packet trn_resource: movq acr$q_login(r6), ac$begtime ; copy stuff into common movl acr$l_status(r6), ac$status movl acr$l_imgcnt(r6), ac$imgcnt movl acr$l_cputime(r6), ac$cputime movl acr$l_faults(r6), ac$faults movl acr$l_faultio(r6), ac$faultio movl acr$l_wspeak(r6), ac$wspeak movl acr$l_pagefl(r6), ac$pagefl movl acr$l_diocnt(r6), ac$diocnt movl acr$l_biocnt(r6), ac$biocnt movl acr$l_volumes(r6), ac$volumes brw packet_end ; it's an imagename packet trn_imagename: ; imagename is a counted string movzbl acr$t_imagename(r6), r0 ; get the count movc3 r0, (r6), ac$junk ; then the string brw packet_end ; done with this packet ; it's an imagename packet trn_filename: ; filename is a counted string movzbl acr$t_filename(r6), r0 ; get the count movc3 r0, (r6), ac$junk ; then the string brw packet_end ; done with this packet ; it's an imagename packet trn_user_data: ; user_data is a counted string movzbl acr$t_user_data(r6), r0 ; get the count movc3 r0, (r6), ac$junk ; then the string brw packet_end ; done with this packet ; it's a print data packet trn_print: movl acr$l_printsts(r6), ac$status ; copy stuff into common movq acr$q_quetime(r6), ac$quetime movq acr$q_begtime(r6), ac$begtime ; NOTE: reuses ac$begtime !?? movl acr$l_symcputim(r6), ac$cputime movl acr$l_pagecnt(r6), ac$pagecnt movl acr$l_qiocnt(r6), ac$qiocnt movl acr$l_getcnt(r6), ac$getcnt brw packet_end ; done with this packet ; translate type and subtype fields into a pair of bytes in r0 trn_type: extzv #acr$v_type, #acr$s_type, acr$w_type(r6), r0 extzv #acr$v_subtype, #acr$s_subtype, acr$w_type(r6), r1 insv r1, #8, #8, r0 ; subtype is second byte in r0 rsb .end