%%s 6/6/372 %%d D 1.3.4 22-Feb-86 18:50:16 dpm 7 6 %%c Widened Term field to 7 characters for VMS 4.x %%s 6/3/372 %%d D 1.3.3 02-Jan-85 15:11:37 graves 6 5 %%c Modified main to search for ] in the image name from the right to fix a %%c version 4 formatting problem. %%s 3/3/372 %%d D 1.3.2 30-Jul-83 08:59:04 tools 5 4 %%c Removed trailing periods from quoted strings. %%s 42/16/333 %%d D 1.3.1 12-Jul-82 17:19:11 dpm 4 3 %%c Added base/current priority display after PID column. %%c Required changes to who.w`whosym, who.w`cllist, who.w`who.r`main %%c and who.w`who.r`fmtbuf. %%s 3/3/346 %%d D 1.3 03-May-82 13:53:30 tools 3 2 %%c Modified who.w`who.r`main to not fold the process name to lower %%c case, as many folks change their process name to be a mixture of %%c upper and lower case. %%s 9/9/340 %%d D 1.2 05-Apr-82 20:24:04 tools 2 1 %%c Modified the constants IMAG_WIDTH and PROC_WIDTH in `whosym' to reflect %%c the maximum possible values. Also modified the header strings in %%c who.r`main to reflect the change in column sizes. %%s 0/0/0 %%d D 1.1 27-Mar-82 15:04:07 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- whosym 755 asc 25-mar-82 09:43:45 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 4 #-h- whosym 755 asc 05-apr-82 20:22:25 tools (lblh csam sventek) %%E 4 %%E 2 %%I 4 %%D 7 #-h- whosym 852 asc 12-jul-82 17:16:25 dpm (dave martin) %%E 7 %%E 4 %%I 7 #-h- whosym 852 asc 22-feb-86 18:49:29 dpm (dave martin) %%E 7 # definitions used by the who tool # DEC defined symbols define(JPI_USERNAME,16%202) define(JPI_PRCNAM,16%31c) define(JPI_IMAGNAME,16%207) # for now define(JPI_LOGINTIM,16%206) define(JPI_TERMINAL,16%31d) define(JPI_PID,16%319) %%I 4 define(JPI_PRI,16%302) define(JPI_PRIB,16%309) %%E 4 define(DIBK_LENGTH,24) define(SS_NOSUCHDEV,16%908) define(SS_NORMAL,1) define(SS_NOPRIV,16%24) define(SS_NOMOREPROC,16%9a8) define(SS_SUSPENDED,16%3a4) # symbols used to format buffer %%D 7 define(TTY_WIDTH,6) %%E 7 %%I 7 define(TTY_WIDTH,8) %%E 7 define(USER_WIDTH,13) %%D 2 define(PROC_WIDTH,13) %%E 2 %%I 2 define(PROC_WIDTH,16) %%E 2 %%D 4 define(PID_WIDTH,8) %%E 4 %%I 4 define(PID_WIDTH,9) %%E 4 define(CONNECT_WIDTH,13) %%D 2 define(IMAG_WIDTH,13) %%E 2 %%I 2 define(IMAG_WIDTH,10) %%E 2 %%I 4 define(CURPRI_WIDTH,3) define(BASPRI_WIDTH,3) %%E 4 define(JPI_EVENT_FLAG,1) # symbols for linked list define(MAX_PROCESSES,100) define(HEAD,incr(MAX_PROCESSES)) define(TAIL,incr(HEAD)) define(FLINK,1) define(BLINK,2) define(DATAPTR,3) #-h- cwho 353 asc 25-mar-82 09:43:45 v1.1 (sw-tools v1.1) common / cwho / verbos, whoami, total, dohead, mytty(FILENAMESIZE) integer verbos # if verbose list desired - init = NO integer whoami # if doing who am i - init = NO integer total # if total no of users desired - init = NO integer dohead # if user desires column header - init = NO character mytty # string for user's terminal when who am i %%D 4 #-h- cllist 559 asc 25-mar-82 09:43:46 v1.1 (sw-tools v1.1) %%E 4 %%I 4 #-h- cllist 693 asc 12-jul-82 17:16:31 dpm (dave martin) %%E 4 common / cllist / llist(3, TAIL), nprocs, prid(MAX_PROCESSES), logt(2, MAX_PROCESSES), %%I 4 baspri(MAX_PROCESSES), curpri(MAX_PROCESSES), %%E 4 term(TTY_WIDTH, MAX_PROCESSES), user(USER_WIDTH, MAX_PROCESSES), proc(PROC_WIDTH, MAX_PROCESSES), imag(IMAG_WIDTH, MAX_PROCESSES) integer llist # doubly linked list of process headers integer nprocs # current value of next free data block integer prid # process id integer logt # login time for process %%I 4 integer baspri # base priority integer curpri # current priority %%E 4 character term # terminal name character user # user name character proc # process name character imag # de-noised image name %%D 2 #-h- who.r 6403 asc 25-mar-82 09:43:47 v1.1 (sw-tools v1.1) #-h- main 3281 asc 25-mar-82 09:43:31 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- who.r 6408 asc 05-apr-82 20:22:26 tools (lblh csam sventek) #-h- main 3281 asc 05-apr-82 20:20:36 tools (lblh csam sventek) %%E 3 %%E 2 %%I 3 %%D 4 #-h- who.r 6409 asc 03-may-82 13:51:41 tools (lblh csam sventek) #-h- main 3282 asc 03-may-82 13:49:43 tools (lblh csam sventek) %%E 4 %%E 3 %%I 4 %%D 5 #-h- who.r 6969 asc 12-jul-82 17:16:33 dpm (dave martin) %%E 5 %%I 5 %%D 6 #-h- who.r 6973 asc 30-jul-83 08:58:46 tools (lblh csam sventek) %%E 6 %%E 5 %%D 6 #-h- main 3532 asc 12-jul-82 17:08:12 dpm (dave martin) %%E 6 %%E 4 %%I 6 %%D 7 #-h- who.r 7067 asc 02-jan-85 15:09:31 graves (wayne graves) #-h- main 3622 asc 02-jan-85 15:06:17 graves (wayne graves) %%E 7 %%E 6 %%I 7 #-h- who.r 7067 asc 22-feb-86 18:40:36 dpm (dave martin) #-h- main 3626 asc 22-feb-86 18:31:52 dpm (dave martin) %%E 7 include whosym subroutine main %%D 4 integer*2 list(38), iosb(4) integer ub, ul, pb, pl, ib, il, tb, tl, lb, pidb, short, ttylen, userlen, proclen, imaglen, logtim(2), curtim(2), nusers, wildpid, pid, sys$getjpi, i, index, status, equal, j %%E 4 %%I 4 integer*2 list(50), iosb(4) integer ub, ul, pb, pl, ib, il, tb, tl, bb, cb integer lb, pidb, short, ttylen integer userlen, proclen, imaglen, logtim(2), curtim(2), nusers integer wildpid, pid, sys$getjpi, i, index, status, equal, j integer bpri, cpri %%E 4 character tty(10), userbuf(16), procbuf(16), imagbuf(65), buf(MAXLINE) equivalence ( ub , list(3) ), ( ul, list(5) ), ( tb , list(9) ), ( tl, list(11)), ( pb , list(15)), ( pl, list(17)), ( lb , list(21)), ( ib , list(27)), ( il, list(29)), ( pidb , list(33)), %%I 4 ( bb , list(39)), ( cb , list(45)), %%E 4 ( short, list(13)) include cwho include cllist %%D 2 string hdr1 "Term User Name Process Name " string hdr2 " Image Name Connect Time PID" string hdr3 "===== ============ ============ " string hdr4 "============ ============ ========" %%E 2 %%I 2 %%D 7 string hdr1 "Term User Name Process Name " %%E 7 %%D 4 string hdr2 " Image Connect Time PID" %%E 4 %%I 4 %%I 7 string hdr1 " Term User Name Process Name " %%E 7 string hdr2 " Image Connect Time PID Prior" %%E 4 %%D 7 string hdr3 "===== ============ =============== " %%E 7 %%D 4 string hdr4 "========= ============ ========" %%E 4 %%E 2 %%I 4 %%I 7 string hdr3 "======= ============ =============== " %%E 7 string hdr4 "========= ============ ======== =====" %%E 4 string twonl "@n@n" string footer "@nTotal number of interactive users = " string dclstr "(dcl)" data list / 15, JPI_USERNAME, 4*0, 7, JPI_TERMINAL, 4*0, 15, JPI_PRCNAM, 4*0, 8, JPI_LOGINTIM, 4*0, 64, JPI_IMAGNAME, 4*0, 4, JPI_PID, 4*0, %%I 4 4, JPI_PRIB, 4*0, 4, JPI_PRI, 4*0, %%E 4 2*0/ data wildpid /-1/ call whoarg # process arguments if (dohead == YES & verbos == NO) { hdr1(18) = EOS hdr2(1) = EOS hdr3(18) = EOS hdr4(1) = EOS } call sys$gettim(curtim) # get current time ub = %loc(userbuf) # JPI list initialization ul = %loc(userlen) pb = %loc(procbuf) pl = %loc(proclen) ib = %loc(imagbuf) il = %loc(imaglen) tb = %loc(tty) tl = %loc(ttylen) lb = %loc(logtim) %%I 4 bb = %loc(bpri) cb = %loc(cpri) %%E 4 pidb = %loc(pid) call initll # initialize linked list if (dohead == YES) { call putlin(hdr1, STDOUT) call putlin(hdr2, STDOUT) call putch( '@n', STDOUT) call putlin(hdr3, STDOUT) call putlin(hdr4, STDOUT) call putlin(twonl, STDOUT) } if (verbos == NO) short = 0 # only fetch process name nusers = 0 repeat { call sys$clref(%val(JPI_EVENT_FLAG)) status = sys$getjpi(%val(JPI_EVENT_FLAG), wildpid,, list, iosb,,) if (status == SS_NOPRIV | status == SS_SUSPENDED) next if (status == SS_NOMOREPROC) break call sys$waitfr(%val(JPI_EVENT_FLAG)) if (ttylen == 0) next userbuf(userlen+1) = EOS call fold(userbuf) call strcpy(userbuf, user(1, nprocs)) tty(ttylen+1) = EOS call fold(tty) if (whoami == YES & equal(tty, mytty) != YES) next call strcpy(tty, term(1, nprocs)) if (verbos == YES) { imagbuf(imaglen+1) = EOS %%D 6 i = index(imagbuf, ']') + 1 %%E 6 %%I 6 for (i = imaglen; i > 0; i = i - 1) if (imagbuf(i) == ']') break i = i + 1 %%E 6 call scopy(imagbuf, i, imagbuf, 1) i = index(imagbuf, '.') if (i > 0) imagbuf(i) = EOS call fold(imagbuf) if (imagbuf(1) == EOS) call strcpy(dclstr, imagbuf) procbuf(proclen+1) = EOS %%D 3 call fold(procbuf) %%E 3 %%I 3 # call fold(procbuf) %%E 3 call strcpy(imagbuf, imag(1, nprocs)) call strcpy(procbuf, proc(1, nprocs)) logt(1, nprocs) = logtim(1) logt(2, nprocs) = logtim(2) prid(nprocs) = pid %%I 4 baspri(nprocs) = bpri curpri(nprocs) = cpri %%E 4 } llist(DATAPTR, nprocs) = nprocs call insertll(nprocs) nprocs = nprocs + 1 nusers = nusers + 1 } for (j=llist(FLINK, HEAD); j != TAIL; j=llist(FLINK, j)) { i = llist(DATAPTR, j) call fmtbuf(buf, term(1,i), user(1,i), proc(1,i), prid(i), curtim, %%D 4 logt(1,i), imag(1,i), verbos) %%E 4 %%I 4 logt(1,i), imag(1,i), baspri(i), curpri(i), verbos) %%E 4 call putlin(buf, STDOUT) } if (total == YES) { call putlin(footer, STDOUT) call putdec(nusers, 1) call putch('@n', STDOUT) } return end %%D 5 #-h- whoarg 777 asc 25-mar-82 09:43:33 v1.1 (sw-tools v1.1) %%E 5 %%I 5 #-h- whoarg 776 asc 30-jul-83 08:56:55 tools (lblh csam sventek) %%E 5 subroutine whoarg integer nargs, i, junk integer getarg, index, trnlog character arg(FILENAMESIZE) include cwho string tt "TT" verbos = NO whoami = NO total = NO dohead = NO nargs = 0 for (i=1; getarg(i, arg, FILENAMESIZE) != EOF; i=i+1) if (arg(1) == '-') { call fold(arg) if (index(arg, 'l') > 0 | index(arg, 'v') > 0) verbos = YES if (index(arg, 't') > 0) total = YES if (index(arg, 'h') > 0) dohead = YES } else if (arg(1) == '?' & arg(2) == EOS) %%D 5 call error("usage: who [-hvt] [am i].") %%E 5 %%I 5 call error("usage: who [-hvt] [am i]") %%E 5 else nargs = nargs + 1 if (nargs == 2) # doing who am i { whoami = YES junk = trnlog(tt, mytty) call fold(mytty) for (i=1; mytty(i) == '_'; i=i+1) ; call scopy(mytty, i, mytty, 1) } return end #-h- cpystr 212 asc 25-mar-82 09:43:34 v1.1 (sw-tools v1.1) subroutine cpystr(in, out, i, w) integer i, w, j character in(ARB), out(ARB) for (j=1; in(j) != EOS; j=j+1) call chcopy(in(j), out, i) for ( ; j <= w; j=j+1) call chcopy(' ', out, i) return end %%D 4 #-h- fmtbuf 633 asc 25-mar-82 09:43:35 v1.1 (sw-tools v1.1) subroutine fmtbuf(buf, tty, user, proc, pid, curtim, logtim, image, verbos) %%E 4 %%I 4 #-h- fmtbuf 954 asc 12-jul-82 17:13:33 dpm (dave martin) subroutine fmtbuf(buf, tty, user, proc, pid, curtim, logtim, image, bpri, cpri, verbos) %%E 4 character buf(ARB), tty(ARB), user(ARB), proc(ARB), image(ARB), temp(30) %%D 4 integer pid, curtim(2), logtim(2), verbos, i %%E 4 %%I 4 integer pid, curtim(2), logtim(2), verbos, i, bpri, cpri integer itoc %%E 4 i = 1 call cpystr(tty, buf, i, TTY_WIDTH) if (verbos == NO) call cpystr(user, buf, i, 0) else { call cpystr(user, buf, i, USER_WIDTH) call cpystr(proc, buf, i, PROC_WIDTH) call cpystr(image, buf, i, IMAG_WIDTH) call connect_time(curtim, logtim, temp) call cpystr(temp(3), buf, i, CONNECT_WIDTH) call puthex(pid, temp) %%D 4 call cpystr(temp, buf, i, 0) %%E 4 %%I 4 call cpystr(temp, buf, i, PID_WIDTH) if( itoc( bpri, temp, BASPRI_WIDTH) == 1 ) call chcopy( ' ', buf, i) call stcopy( temp, 1, buf, i) call chcopy( '/', buf, i) if( itoc( cpri, temp, CURPRI_WIDTH) == 1 ) call chcopy( ' ', buf, i) call stcopy( temp, 1, buf, i) %%E 4 } call chcopy('@n', buf, i) return end #-h- connect 343 asc 25-mar-82 09:43:36 v1.1 (sw-tools v1.1) subroutine connect_time(curtim, logtim, buf) integer curtim(2), logtim(2), final(2), dsc(2), timlen, i, index integer lib$subx character buf(ARB) call lib$subx( logtim, curtim, final, 2) dsc(1) = 17 dsc(2) = %loc(buf) call sys$asctim(timlen, dsc, final, %val(0)) buf(timlen+1) = EOS i = index(buf, '.') buf(i) = EOS return end #-h- initll 186 asc 25-mar-82 09:43:37 v1.1 (sw-tools v1.1) # subroutine to initialize the doubly linked list of process headers subroutine initll include cllist nprocs = 1 llist(FLINK, HEAD) = TAIL llist(BLINK, TAIL) = HEAD return end #-h- insertll 460 asc 25-mar-82 09:43:38 v1.1 (sw-tools v1.1) # insert node pointed to by i into the doubly linked list, ordered by PID subroutine insertll(i) integer i, j, pid, prev, k, l integer strcmp include cllist k = llist(DATAPTR, i) for (j=llist(FLINK, HEAD); j != TAIL; j=llist(FLINK, j)) { l = llist(DATAPTR, j) if (strcmp(term(1,k), term(1,l)) < 0) break } prev = llist(BLINK, j) llist(FLINK, i) = j llist(BLINK, i) = prev llist(BLINK, j) = i llist(FLINK, prev) = i return end #-h- who.fmt 567 asc 25-mar-82 09:43:50 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Who (1) 11-Jan-79 show who is on the system .sy who [-htv] [am i] .ds who lists the name and terminal number for each current system user. The following switches affect the format of the listing: .sp .in +5 .ti -3 -h Generate a line of column headers above the display. .ti -3 -t Print the total number of users at bottom of display. .ti -3 -v Generate a verbose display, with system dependent information constituting the verbose portion. .in -5 .fl .sa The Unix command 'who' .di .au Joe Sventek (DEC machines); Sheldon Furst (CDC machines) .bu %%E 1