1: / write -- write to another user
   2: 
   3: .globl  ttyn
   4: 
   5:         cmp     (sp)+,$2
   6:         beq     1f
   7:         bgt     2f
   8:         mov     $1,r0
   9:         sys     write; argm; eargm-argm
  10:         sys     exit
  11: 2:
  12:         movb    *4(sp),ltty
  13: 1:
  14:         tst     (sp)+
  15:         mov     (sp)+,r5
  16:         sys     open; utmp; 0
  17:         bec     1f
  18:         mov     $1,r0
  19:         sys     write; film; efilm-film
  20:         sys     exit
  21: 1:
  22:         mov     r0,ufil
  23: 1:
  24:         mov     ufil,r0
  25:         sys     read; ubuf; 16.
  26:         tst     r0
  27:         bne     2f
  28:         jmp     8f
  29: 2:
  30:         tstb    ltty
  31:         beq     2f
  32:         cmpb    ltty,8.+ubuf
  33:         bne     1b
  34: 2:
  35:         mov     $ubuf,r3
  36:         mov     r5,r4
  37:         mov     $9.,r2
  38: 2:
  39:         dec     r2
  40:         beq     2f
  41:         cmpb    (r4)+,(r3)+
  42:         beq     2b
  43:         tstb    -1(r4)
  44:         bne     1b
  45:         cmpb    $' ,-1(r3)
  46:         bne     1b
  47: 2:
  48:         movb    8.+ubuf,ttyno
  49:         sys     open; ttyx; 1
  50:         bes     3f
  51:         sys     stat; ttyx; statbuf
  52:         bes     3f
  53:         bit     $2,statbuf+4
  54:         bne     2f
  55: 3:
  56:         mov     $1,r0
  57:         sys     write; dnymes; ednymes-dnymes
  58:         sys     exit
  59: 2:
  60:         mov     r0,ttyf
  61:         clr     r0
  62:         jsr     pc,ttyn
  63:         mov     r0,r3
  64:         mov     statbuf,r4
  65:         mov     ufil,r0
  66:         sys     seek; 0; 0
  67: 1:
  68:         mov     ufil,r0
  69:         sys     read; ubuf; 16.
  70:         tst     r0
  71:         beq     unknown
  72:         cmp     r3,ubuf+8.
  73:         bne     1b
  74:         mov     $ubuf,r0
  75:         mov     $8.,r1
  76: 1:
  77:         cmpb    $' ,(r0)+
  78:         beq     1f
  79:         dec     r1
  80:         bne     1b
  81: 1:
  82:         neg     r1
  83:         add     $8,r1
  84:         mov     r1,0f
  85: 6:
  86:         mov     ttyf,r0
  87:         sys     write; mesg; emesg-mesg
  88:         mov     ttyf,r0
  89:         sys     0; 5f
  90: .data
  91: 5:
  92:         sys     write; ubuf; 0:2
  93: .text
  94:         mov     ttyf,r0
  95:         sys     write; qnl; 4
  96:         sys     signal; 2; 9f
  97: 7:
  98:         clr     r0
  99:         sys     read; ch; 1
 100:         tst     r0
 101:         beq     9f
 102:         tst     nlflg
 103:         beq     1f
 104:         cmp     ch,$'!
 105:         bne     1f
 106:         sys     fork
 107:                 br mshproc
 108:         sys     wait
 109:         mov     $1,r0
 110:         sys     write; excl; 2
 111:         br      7b
 112: 1:
 113:         clr     nlflg
 114:         cmp     ch,$'\n
 115:         bne     1f
 116:         inc     nlflg
 117: 1:
 118:         mov     ttyf,r0
 119:         sys     write; ch; 1
 120:         br      7b
 121: 8:
 122:         movb    (r5)+,ch
 123:         beq     8f
 124:         mov     $1,r0
 125:         sys     write; ch; 1
 126:         br      8b
 127: 8:
 128:         tstb    ltty
 129:         beq     8f
 130:         mov     $1,r0
 131:         sys     write; ltty-1; 2
 132: 8:
 133:         mov     $1,r0
 134:         sys     write; errmsg; eerrmsg-errmsg
 135:         sys     exit
 136: 9:
 137:         mov     ttyf,r0
 138:         sys     write; endmsg; eendmsg-endmsg
 139:         sys     exit
 140: 
 141: unknown:
 142:         mov     $"??,ubuf
 143:         br      6b
 144: 
 145: mshproc:
 146:         sys     exec; msh; mshp
 147:         sys     exit
 148: 
 149: .data
 150: nlflg:
 151:         1
 152: .text
 153: 
 154: mshp:
 155:         msh
 156:         minust
 157:         0
 158: msh:
 159:         </bin/sh\0>
 160: minust:
 161:         <-t\0>
 162: argm:
 163:         <Arg count\n>
 164: eargm:
 165: film:
 166:         <Cannot open utmp\n>
 167: efilm:
 168: .data
 169:         < >             / is ltty -1
 170: ltty:
 171:         .=.+1
 172: .text
 173: excl:
 174:         <!\n>
 175: qnl:
 176:         <...\n>
 177: .data
 178: ttyx:
 179:         </dev/ttyx\0>
 180: ttyno   = .-2
 181: .text
 182: utmp:
 183:         </etc/utmp\0>
 184: endmsg:
 185:         <EOT\n>
 186: eendmsg:
 187: errmsg:
 188:         < not logged in.\n>
 189: eerrmsg:
 190: mesg:
 191:         <\nMessage from >
 192: emesg:
 193: dnymes:
 194:         <Permission denied.\n>
 195: ednymes:
 196:         .even
 197:         .bss
 198: 
 199: ttyf:   .=.+2
 200: ubuf:   .=.+16.
 201: statbuf:.=.+40.
 202: ch:     .=.+2
 203: ufil:   .=.+2
 204: signal = 48.

Defined functions

argm defined in line 162; used 2 times
  • in line 9(2)
dnymes defined in line 193; used 2 times
  • in line 57(2)
eargm defined in line 164; used 1 times
  • in line 9
ednymes defined in line 195; used 1 times
  • in line 57
eendmsg defined in line 186; used 1 times
eerrmsg defined in line 189; used 1 times
efilm defined in line 167; used 1 times
  • in line 19
emesg defined in line 192; used 1 times
  • in line 87
endmsg defined in line 184; used 2 times
  • in line 138(2)
errmsg defined in line 187; used 2 times
  • in line 134(2)
excl defined in line 173; used 1 times
film defined in line 165; used 2 times
  • in line 19(2)
mesg defined in line 190; used 2 times
  • in line 87(2)
minust defined in line 160; used 1 times
msh defined in line 158; used 2 times
mshp defined in line 154; used 1 times
mshproc defined in line 145; used 1 times
qnl defined in line 175; used 1 times
  • in line 95
unknown defined in line 141; used 1 times
  • in line 71
utmp defined in line 182; used 1 times
  • in line 16

Defined variables

ch defined in line 202; used 6 times
ltty defined in line 170; used 5 times
nlflg defined in line 150; used 3 times
signal defined in line 204; used 1 times
  • in line 96
statbuf defined in line 201; used 3 times
ttyf defined in line 199; used 6 times
ttyno defined in line 180; used 1 times
  • in line 48
ttyx defined in line 178; used 2 times
ubuf defined in line 200; used 8 times
ufil defined in line 203; used 4 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 586
Valid CSS Valid XHTML 1.0 Strict