-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftpu.161
executable file
·2816 lines (2541 loc) · 74.8 KB
/
ftpu.161
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;-*- Mode: MIDAS -*-
TITLE FTPU - NEW FTP USER FOR ITS
.SYMTAB 5001.,7000.
SUBTTL Basic Definitions
;Accumulators
F=0 ; Flags
A=1 ;Standard ACs
B=2
C=3
D=4
E=5
T=6
TT=7
R=10
; =11 ;Not used
OC=12 ; Output package
U1=13 ;UUO accs
U2=14
U3=15
U4=16
P=17 ;Stack pointer.
;Channels
ICPCH==0 ;ICPCH must be 0 for socket table hackery to win!!
TMPC==1 ;temp
NETI==2 ;Net input ch (telnet connection)
NETO==3 ;Net output ch (telnet connection)
NETDI==4 ;Net data input channel
NETDO==5 ;Net data output channel
STRC==6 ;UUO string output channel
DC==7 ;general purpose dsk channel (in and out)
TYIC==10 ;TTY input
TYOC==11 ;TTY output
ERRC==12 ;ERR device
SCRIPC==13 ;Script file out
COMC==14 ;Command file in
; Flags
%LTCP==1 ; LH 1 = Using TCP
%TMP==1 ; RH temporary flag
TIMOUT=30.*120. ;Timeout value is two minutes.
;Subroutine Packages.
DEFINE %%.CRLF C,ARG
IFSN ARG,, .ERR non-null argument "ARG" after CRLF in FWRITE
CRLF C,
TERMIN
$$OUT==1
$$OFLT==1
UAREAS==1 ; Assemble UUO areas
USTRGS==1 ; and string hackery.
UFLOAT==1 ; and floating point typeout
.INSRT KSC;NUUOS >
;and wonderful filename parser
.INSRT KSC;NFNPAR >
$$HST3==1
$$SYMLOOK==1 ;and miraculous network routines
$$HSTMAP==1 ;and routines for the host names table file
$$HOSTNM==1
$$OWNHST==1
$$ICP==1 ;and network connection routines
$$CONNECT==1 ;and tcp net connection routines
$$ANALYZE==1 ;include network error analysis routine
$$ARPA==1 ;handle Arpanet (only, for now)
$$TCP==1 ;handle Internet host parsing.
USETCP: -1 ;For the hostname parser (default)
USENCP: 0 ;For the hostname parser.
.INSRT SYSENG;NETWRK >
FTPSKT==3 ;standard ICP socket #
FTPORT==25 ;TCP FTP port #
SUBTTL Random locations
TMPLOC 41, <JSR 1,UUOH> ;"1," means illegal instructions cause fatal interrupts.
TMPLOC 42, JSR TSINT
PAT:
PATCH: BLOCK 100
PDLLEN==100
PDL: -PDLLEN,,.
BLOCK PDLLEN
POPTJ: POP P,T
POPJ P,
POPBA1: AOS -2(P)
POPBAJ: POP P,B
POP P,A
POPJ P,
POPJ1: AOSA (P)
POP1J: POP P,JUNK
CPOPJ: POPJ P,
POPAJ1: AOS -1(P)
POPAJ: POP P,A
APOPJ: POPJ P,
POPCBJ: POP P,C
POPBJ: POP P,B
POPJ P,
JUNK: 0 ;for random useless writes
VERSHN: .FNAM2
VERSION==.FNAM2
SCRIPT: 0 ;nonzero if writing script file.
READIN: 0 ;nonzero while rubout processing - inhibits script file output.
COMFIL: 0 ;nonzero if reading command file.
TYITTY: 0 ;nonzero if TTY can be read from.
TYOTTY: 0 ;nonzero if TTY can be written on.
TRITTY: 0 ;nonzero if TTY input was translated (not really device TTY)
TROTTY: 0 ;similar, for TTY output.
DISTTY: 0 ;nonzero if TTY is display (can rub out)
HDXTTY: 0 ;nonzero if half duplex TTY and shouldn't echo.
SILENT: 0 ;nonzero if shouldn't type on TTY (cleared if try to read tty).
INHIDE: 0 ;nonzero if TYILIN shouldn't echo input. (eg for pwd)
DEBUG: 0 ;nonzero inhibits death, disowning, etc.
PRREP: 0 ; -1 if printing server replies.
IFNDEF BUFFL,BUFFL==4000
BUFFER: BLOCK BUFFL ;Buffer for the actual file transfer.
XFRBFL==:BUFFL
XFR8BL==<<<XFRBFL*9>+7>/8.> ; # words in 8-bit byte buffer
TMPBUF: BLOCK XFR8BL ; Buffer for packing 8-bit bytes (TCP)
XFRLBV: 0 ;length of buffer except for one word, in characters,
; (used by XFRASC.)
XFRLWP: 0 ;Address of last word in used part of buffer
XFRDIR: 0 ;-1 if writing to net
XFRBPW: 0 ;Bytes per word
DCTYPE: 0 ;Transfer Type. 0=ASCII, -1=Image, 1=Local.
; These are what we think server believes,
DCBYTE: 0 ;Byte size. One of 8., 32., 36.
; not what user has said he prefers. If user wants to
; change it, we ask the server before setting these.
DCSENT: 0 ;-1 => The server knows DCTYPE and DCBYTE, either because they
; are the default (TYPE A, BYTE 8) or because we sent them
; and they were accepted.
;0 => The server doesn't know them, they must be TYPE I,BYTE 36
; so try sending those before next data transfer operation.
; For TCP the desired settings are TYPE L 36.
DKIOSW: 0 ;0 Disk input, -1 Disk output
NTIOSW: 0 ;0 Net input, -1 Net output
ICPSOC: 0 ;frn skt to ICP to
LPORT: 0 ;lcl port we listen for data connection on
LDSOC: 0 ;lcl skt for data skt open
FDSOC: 0 ;frn skt for data skt open
FDHST: 0 ;frn hst for data skt open
OWNHST: 0 ; # of own site.
MACHNM: 0 ; Machine name (AI,MC,ML,DM)
ITSVER: 0 ; ITS version # in sixbit
OWNNAM: 0 ; Addr of ASCIZ string for own site-name.
CNECTD: 0 ;nonzero => connected to a foreign host
NBITS: 0 ;# bits transferred
NTIME: 0 ;starting time in 30ths
FILDEV: SIXBIT /DSK/
FILDIR: 0
FILFN1: 0
FILFN2: SIXBIT />/
SCRIPF: SIXBIT /DSK/
SCRIPS: 0
SCRIP1: SIXBIT /FTPOUT/
SCRIP2: SIXBIT />/
COMDEV: SIXBIT /DSK/
COMDIR: 0
COMFN1: SIXBIT /FTPCOM/
COMFN2: SIXBIT />/
FTPOF1: SIXBIT /_FTPU_/
FTPOF2: SIXBIT /OUTPUT/
THOSTB: BLOCK 10 ;Block for THOSTN to store its host name in.
IFNDEF JCLBFL,JCLBFL==50
JCLFLG: 0 ;-1 => executing command that came from DDT
SUICID: 0 ;-1 => commit suicide after this command if it wins.
JCLTRN: 0 ;-1 => this is implicit TRAN from JCL.
; (Suppresses "N bits in M seconds".)
JCLBF1: ASCII/TRAN /
JCLBUF: BLOCK JCLBFL ;Command Line (read from DDT or from TTY) as ASCIZ string.
BLOCK 400
JCLBFE: ,,-1 ;Nonzero to stop DDT's xfer of JCL. Top byte 0 to end JCL.
JCLBFP: 440700,,JCLBUF ;Addr of block to store JCL in. These 2 words bound
JCLP: 440700,,JCLBUF ;Pointer to read JCL out of. if must "push JCLBUF".
JCLBF2: BLOCK JCLBFL ;Alternate block to read tty input into.
ARGBUF: BLOCK JCLBFL ;ARG reads stuff from JCLBUF, making ASCIZ sting in ARGBUF.
ARGCT: 0 ;These two words are a string variable containing ARGBUF.
ARGPT: 440700,,ARGBUF
ALTARG: BLOCK JCLBFL ;Used to save a way one arg while reading another.
NCPJNM: SIXBIT /NCPFTP/ ;Name of job to do old-style (NCP based) FTPing.
SUBTTL Initialization and Main Loop
GO: MOVE P,PDL ;Set up PDL and TTY
SETOM TYITTY
SETOM TYOTTY
SETZM TRITTY
SETZM TROTTY
SETZM DISTTY
SETZM HDXTTY
SYSCAL OPEN,[%CLBIT,,.UAI ? %CLIMM,,TYIC ? [SIXBIT /TTY/]]
SETZM TYITTY ;Sometimes we dont have a TTY to read from.
SYSCAL RFNAME,[%CLIMM,,TYIC ? %CLOUT,,B]
.LOSE %LSFIL
CAME B,['TTY,,] ;If the device name is not "TTY"
SETOM TRITTY ; there must be an input translation.
SYSCAL TTYGET,[%CLIMM,,TYIC ? %CLOUT,,B ? %CLOUT,,C]
JRST GO1
ANDCM B,[606060606060] ;If TYIC really has a TTY, turn off echo.
ANDCM C,[606060606060]
TLO C,010000 ;Enable ^G/^S interrupts
SYSCAL TTYSET,[%CLIMM,,TYIC ? B ? C]
.LOSE 1400
GO1: SYSCAL OPEN,[%CLBIT,,<.UAO\%TJDIS> ? %CLIMM,,TYOC ? [SIXBIT /TTY/]]
SETZM TYOTTY ;No typeout is maybe OK, if have script XFILE.
SYSCAL RFNAME,[%CLIMM,,TYOC ? %CLOUT,,B]
.LOSE %LSFIL
CAME B,['TTY,,] ;If the device name is not "TTY"
SETOM TROTTY ; there must be an output translation.
SETZM DISTTY
SYSCAL CNSGET,[%CLIMM,,TYOC ? REPEAT 4,[%CLOUT,,JUNK ?] %CLOUT,,A]
JRST GO2
TLNE A,%TOOVR ;DISTTY on also for glass TTY's
TLNE A,%TOERS ;DISTTY gets -1 if we are on a display TTY.
SETOM DISTTY
TLNE A,%TOHDX ;HDXTTY gets -1 if half duplex (shouldn't echo).
SETOM HDXTTY
GO2: .SUSET [.RXJNAM,,B] ;Look at our job name.
TLO F,%LTCP ;We usually do TCP based FTPing.
CAMN B,NCPJNM ;But if our jname is the magic one
JRST [ TLZ F,%LTCP ; we wont use the Internet FTP.
SETZM USETCP
SETZM USENCP
JRST .+1]
MOVEI A,FTPORT ;TCP means we use this port.
TLNN F,%LTCP
MOVEI A,FTPSKT ;NCP means this is the ICP socket
MOVEM A,ICPSOC ;Remember which port or socket to use.
MOVEI A,LSTPAG
MOVEI B,0
PUSHJ P,NETWRK"HSTMAP ;Read in HOSTS3 at LSTPAG
.LOSE
MOVE B,A ;Then make ARPAGS point at all pages left above it.
SUBI B,400 ;HSTMAP leaves A pointing to first unused page.
HRL A,B
MOVEM A,ARPAGS
UARINIT ARPAGS ;initialize core
STRINIT ;initialize strings
OUTOPN TYOC,[$UCXCT,,[PUSHJ P,UUOTYO]]
OUTOPN SCRIPC, ;allow uuos to type out
MOVE A,[NETWRK"NW%ARP] ;Get own host number, on Arpanet
PUSHJ P,NETWRK"OWNHST
.LOSE ;Not connected to Arpanet?
MOVEM A,OWNHST
.SUSET [.RSNAME,,FILDIR]
MOVE A,FILDIR
MOVEM A,COMDIR
MOVEM A,SCRIPS
.SUSET [.ROPTION,,TT] ;Get JCL if present
TLZN TT,OPTCMD
JRST NOJCL
SETZM JCLBUF
MOVE A,[JCLBUF,,JCLBUF+1]
BLT A,JCLBFE
.BREAK 12,[5,,JCLBUF]
MOVE A,JCLP ;If JCL contains an underscore, an implied TRAN
SETOM JCLFLG
TRNCH1: ILDB B,A
CAIE B,^C
CAIN B,^M
JRST TRNCH2
JUMPE B,TRNCH2
CAIE B,"_
CAIN B,"
JRST TRNCH3
CAIE B,"=
JRST TRNCH1
TRNCH3: SOS JCLP ;insert TRAN<sp> in front of JCL
SETOM SUICID ;and exit after completing the transfer.
SETOM JCLTRN ;Suppress the "n bits in m seconds" printout.
TRNCH2: SKIPN JCLBUF
NOJCL: SETZM JCLP
.SUSET [.ROPTION,,TT]
TLO TT,%OPOPC
.SUSET [.SOPTION,,TT]
.SUSET [.SMASK,,[%PIIOC]] ;Enable IOC interrupts
SKIPN TRITTY
.SUSET [.SMSK2,,[1_TYIC]] ;Enable ^G/^S interrupts
JRST MAIN
SUBTTL Main loop.
;Come here after finishing a command, or after an error.
MAIN: PUSHJ P,STILOPN ;If connection was closed by other side, tell user.
PUSHJ P,GRATU ;Check for gratuitous reply from server
TLNE F,%LTCP ;If using Internet FTP,
JRST [ .CLOSE NETDI, ; we use a new PORT each time.
.CLOSE NETDO,
JRST .+1 ]
SKIPE JCLFLG ;Prompt for input unless supplied by superior.
JRST MAIN2
SKIPN CNECTD
OUTI TYOC,"$ ;Prompt with $ if connected, $$ if not.
OUTI TYOC,"$
MAIN2: PUSHJ P,ARGSPC
[ASCIZ //]
LDB A,[350700,,ARGBUF]
JUMPE A,MAIN1 ;Null command is OK. Do nothing.
MOVEI A,ARGBUF
MOVE E,[-COMTBL,,COMTAB]
PUSHJ P,NETWRK"SYMLOOK ;Gobble Command
JRST MAIN3 ; Not a command - try it as a host name.
CAMN B,[-1] ;Numbers are not allowed as commands.
JRST ERRCOM
HLRZ A,(B)
PUSHJ P,(A) ;get address out of table and call the command.
JRST ERRTR1 ;No skip => failed; flush typeahead of all sorts.
MAIN1: SKIPE SUICID
JRST QUIT
JRST ERRTR2
MAIN3: MOVE P,PDL
MOVEI A,ARGBUF ;Couldn't parse command as command name => rescan it
PUSHJ P,NHOSTN ;and try it as a host name.
JRST ERRCOM ; Doesn't make sense as either?
PUSHJ P,CONN ;Command is host number, connect to it
JRST ERRTR1 ;Failure to conect is an error.
JRST MAIN1
ERRCOM: OUTZ TYOC,[ASCIZ /Invalid command or host name?
/]
JRST ERRTR1
ERRCTX: OUTZ TYOC,[ASCIZ /Command not supported under TCP
/]
JRST ERRTR1
ERRHST: OUTZ TYOC,[ASCIZ/Invalid host name?
/]
ERRTR1: SKIPE TYITTY
.RESET TYIC,
SKIPE COMFIL
OUTZ TYOC,[ASCIZ /Closing Command File
/]
.CLOSE COMC,
SETZM COMFIL
SETZM JCLBUF
MOVE A,[440700,,JCLBUF]
MOVEM A,JCLP
SETZM JCLTRN
SETZM SUICID
ERRTR2: MOVE P,PDL ;Fix up PDL before re-entering main loop.
MOVE A,JCLP ;If there's no JCL, next ARG would find out,
ILDB A,A ;but check now so that we prompt before next ARG.
SKIPN A
SETZM JCLFLG
JRST MAIN ;Now go reenter main loop.
SUBTTL Command Tables
COMTAB:
DEFINE CMD NAME,LOC,HELP/
IFNB [HELP] TMPLOC HLPTAB+.-COMTAB, [ASCIZ\HELP\]
LOC,,[ASCIZ\NAME\]
TERMIN
IF1 HLPTAB==0 ;loc of HLPTAB not known until size of COMTAB known
CMD ?,AHELP
CMD NCP,DONCP,Switch to NCP mode.
CMD TCP,DOTCP,Switch to TCP mode.
CMD ACCT,AACCT,Send Account Name
CMD ALLOCATE,AALLOC,Give Size of File to be STOREd
CMD APPEND,AAPPE,Append Local File to Foreign File
CMD ASCII,ATEXT,Transfer File as ASCII Text (TYPE A, BYTE 8)
CMD BYE,ABYE,Disconnect, Giving Server Warning
CMD BYTE,ABYTE,Set Byte Size
CMD CONNECT,ACONN,Connect to Host
CMD CWD,ACWD,Change Foreign Working Directory
CMD DBGET,ADBGET,Debugging get file
CMD DBPUT,ADBPUT,Debugging put file
CMD DEBUG,ADBUG,Toggle Whether to Print Server Replies
CMD DEFAULTS,ADEFA,Set Local Filename Defaults
CMD DELETE,ADELE,Delete File
CMD DIRECTORY,ALSTF,List Foreign File Directory
CMD DISCONNECT,ADISC,Disconnect from Host
CMD DISOWN,ADISOW,Run disowned
CMD ESCRIPT,AESCRIP,Close Script File
CMD GET,AGET,Get File from Foreign Host
CMD HELP,AHELP,List Commands and What They Do
CMD HOSTS,AHSTS,List Hosts
CMD ICPSOCKET,AICPS,Set ICP Socket Number
CMD LISTB,ALSTB,List Foreign Directory Briefly (filenames only)
CMD LISTF,ALSTF,List Foreign File Directory
CMD LISTL,ALSTL,List Local File Directory
CMD LOGIN,ALOGIN,Login to Foreign Host
CMD PASS,APASS,Send Password
CMD PRINT,APRIN,Print File on ML TPL
CMD PROCEED,APROCD,Run without the TTY
CMD PUT,APUT,Put File onto Foreign Host
CMD Q,AQUIT,Leave FTP
CMD QUIT,AQUIT,Leave FTP
CMD QUOTE,AQUOT,Send Arbitrary Command to Server
CMD RENAME,ARENAM,Rename a File at Foreign Host
CMD RETRIEVE,AGET,Get File from Foreign Host
CMD SCRIPT,ASCRIP,Open Script File (gets all typeout)
CMD SEND,APUT,Put File onto Foreign Host
CMD SILENT,ASILNT,Stop typing on the TTY
CMD SOAK,ASOAK,Wait for and Print One Reply From Server
CMD STATUS,ASTAT,Print Server Status
CMD STORE,APUT,Put File onto Foreign Host
CMD TEN,ATEN,Transfer File in Most Efficient Mode (If Both Hosts PDP10s)
CMD TEXT,ATEXT,Transfer File as ASCII Text (TYPE A, BYTE 8)
CMD TRANSFER,ATRAN,Transfer host1filespec_host2filespec
CMD TYPE,ATYPE,Specify Type of Transfer
CMD VALRET,AVALR,Return to superior, not suicidally
CMD XFILE,AXFILE,Read Commands From File
COMTBL==.-COMTAB
IF1 EXPUNGE HLPTAB
HLPTAB: BLOCK COMTBL
SUBTTL Routines called by NETWRK
;PUTCHR Routine. Writes character from T, clobbers no ACs, never skips.
;Called by NETWRK's error analysis routine ANALYZE.
PUTCHR:
;Output to script file if any.
;Output to TTY unless have both com file and script file.
TYO: SKIPE SCRIPT ;Write to script file if we have one.
SKIPE READIN ; Except inside TYILIN.
CAIA
.IOT SCRIPC,T
SKIPE SILENT
POPJ P,
SKIPN SCRIPT
SKIPE TYOTTY
CAIA
JRST DIE ;Nothing to type out on???
SKIPE COMFIL
SKIPN SCRIPT
SKIPN TYOTTY
POPJ P,
.IOT TYOC,T ;Type on TTY if we can
POPJ P, ;unless we have an XFILE and a script.
;IO UUOs on channel "TYOC" XCT UUOTYO for each char.
UUOTYO: PUSH P,T
MOVE T,U1
PUSHJ P,TYO
POP P,T
POPJ P,
;Call "HSTLOOK to translate asciz string <- A into a host number.
;Then set bit 4.9 in A if the host is a PDP10.
NHOSTN: PUSHJ P,NETWRK"HSTLOOK
POPJ P,
MOVE B,A ;Host number in B
PUSHJ P,NETWRK"HSTSRC ;Get SITES table entry addr in D.
JRST [ MOVE A,B ? JRST POPJ1]
MOVE A,B
HLRZ T,NETWRK"STLSYS(D) ;Find host's operating system.
ADD T,NETWRK"HSTADR ;If we guess it's a PDP10,
MOVE T,(T) ; we will be able to use 36 bit mode.
MOVSI TT,-NTENS
NHOST1: CAMN T,TENS(TT)
TLO A,400000 ;Set bit 4.9 in A if machine is a PDP10.
AOBJN TT,NHOST1
JRST POPJ1
;;; Well-known PDP-10 operating systems (machine types are too varied).
TENS: ASCII /ITS/ ;Incompatible Timesharing System
ASCII /WAITS/ ;Wise-assed incompatible timesharing system
ASCII /TOPS1/ ;TOPS-10
ASCII /TOPS2/ ;TOPS-20
ASCII /TENEX/ ;BBN TENEX
ASCII /FOONE/ ;Foonly
ASCII /AUGUS/ ;Foonly
ASCII /TYCOM/ ;Foonly
NTENS==.-TENS
INCHR: ILDB T,JCLP ;Get next JCL char or 0 if exhausted.
JUMPN T,CPOPJ
;If exhausted, read in another line and return its 1st char.
PUSHJ P,TYILIN
JRST INCHR
;Read an argument from the terminal. If there is any of a previous line left,
;we use that; otherwise we read a new line, prompting first. The call should
;be followed by a pointer to the prompt string. Leading and trailing spaces
;are discarded, as is the CR at the end.
;On return, A points at ARGCT, which looks like a string var containing the
;argument, which is an ASCIZ string in ARGBUF.
ARGCON: PUSHJ P,CONTST ;Read arg, but first establish connection if nec.
ARG: SETZM TRANFL'
CAIA
ARGTRN: SETOM TRANFL ;Here to read arg for TRAN command -
;Stop on = or _ or .
SETZM SPCFL'
CAIA
ARGSPC: SETOM SPCFL ;Here to read an arg that a space can terminate.
PUSH P,B
PUSH P,T
MOVE B,JCLP ;Is there any input already?
ILDB B,B
MOVE T,@-2(P)
SKIPN B
OUTZ TYOC,(T) ;If not, prompt the user for some.
MOVE B,[440700,,ARGBUF]
MOVEM B,ARGPT
SETZM ARGCT
ARG1: PUSHJ P,INCHR
CAIN T,40
JRST ARG1
ARGLP: CAIN T,^M
JRST ARGFIN
CAIN T,^C
SETOM SUICID
CAIE T,^C ;Can appear in JCL, not snarfed by TYILIN.
CAIN T,^N
JRST ARGFIN
CAIN T,40 ;In ARGSPC, space terminates once arg is non-null.
SKIPN SPCFL
CAIA
JRST ARGFIN
SKIPN TRANFL ;In TRAN, filenames are terminated by _ or = or
JRST ARGNRM
CAIE T,"= ;so we must be able to ^Q those characters.
CAIN T,"_
JRST ARGFIN
CAIN T,"
JRST ARGFIN
CAIN T,^Q
JRST ARGCTQ
ARGNRM: IDPB T,B
AOS ARGCT
PUSHJ P,INCHR
JRST ARGLP
ARGCTQ: IDPB T,B ;Here for "^Q - put it in the string, then don't
; look for _ or or = in next char.
AOS ARGCT
PUSHJ P,INCHR
CAIE T,"= ;^Q followed by a _, , = or ^Q =>
CAIN T,"_ ; store the quoted character only.
JRST ARGNRM
CAIN T,"
JRST ARGNRM
CAIN T,^Q
JRST ARGNRM
CAIN T,^M ;CR isn't suppressed by ^Q.
JRST ARGFIN
PUSH P,T ;^Q followed by anything else.
;Store both the ^Q and it.
MOVEI T,^Q
IDPB T,B
AOS ARGCT
POP P,T
JRST ARGNRM
ARGFIN: LDB T,B ;Here for a CR "( or _ or or = in TRAN command),
CAIE T,40 ; to end the arg.
JRST ARGFI2 ;Flush trailing spaces.
D7BPT B
SOS ARGCT
JRST ARGFIN
ARGFI2: SETZ T, ;Make sure the arg is an ASCIZ string.
IDPB T,B
POP P,T
POP P,B
MOVEI A,ARGCT ;Return a pointer to a string var
; containing our stuff.
JRST POPJ1
;Throw away rest of line if already read, but if no buffered input don't read any.
FLSLIN: PUSH P,T
MOVE T,JCLP ;If last char read was "EOL",
;we have nothing to flush.
LDB T,T
CAIE T,^M ;This happens when you type,
;eg, PROCEED<cr> with no space.
CAIN T,^N
JRST POPTJ
CAIN T,^C
JRST POPTJ
FLSLI1: PUSHJ P,INCHR
CAIN T,^C
SETOM SUICID
CAIN T,^N
JRST POPTJ
CAIE T,^M
CAIN T,^C
JRST POPTJ
JRST FLSLI1
SUBTTL Connect/Disconnect commands
;CONNECT command.
ACONN: PUSHJ P,ARG
[ASCIZ /host: /]
MOVEI A,ARGBUF
PUSHJ P,NHOSTN
JRST ERRHST
JRST CONN
;Connect to host specified in bits 4.8-1.1 of A.
;For NCP, sign(A) should be 1 to try to use image mode.
;For TCP, we only know how to do ASCII for now.
CONN: JUMPE A,ERRHST ;Meaningless host name.
PUSH P,A
PUSHJ P,BYE ;Flush any existing connection.
JFCL
POP P,A ;A has host number.
SETZM DCTYPE ;Start out assuming ASCII mode
MOVEI B,8.
MOVEM B,DCBYTE ;8-bit bytes.
SETOM DCSENT ;And we are probably content with that too.
TLZE A,(SETZ) ;If it's a PDP10, try to use 36-bit Image.
JRST [ SETZM DCSENT
SKIPE JCLTRN
JRST .+1 ;No message if doing JCL tran command
FWRITE TYOC,[[Will use 36-bit image transfer (TEXT command gives 8-bit ascii mode)],CRLF,,]
JRST .+1 ]
TLNN F,%LTCP
JRST NCPCON ; Dispatch for NCP/TCP processing
TCPCON: MOVEM A,FDHST ;Remember foreign host number.
MOVE B,FDHST
MOVEI A,NETI
MOVE C,ICPSOC
PUSHJ P,NETWRK"TCPCON
JRST NETERR
SETOM CNECTD ;We are now connected sompleace.
JRST ACONN1
NCPCON: MOVE B,A ;Host #
MOVEM B,FDHST
MOVEI A,ICPCH ;Pin #
MOVE C,ICPSOC ;Foreign socket
MOVEI T,FTPSKT
MOVEM T,ICPSOC
MOVE D,[40+.UAI,,40+.UAO] ;Modes
PUSHJ P,NETWRK"ARPICP ;Connect it up
JRST NETERR ;Failed => return error message.
SETOM CNECTD
SYSCAL RCHST,[MOVEI NETI
MOVEM JUNK ;NET
MOVEM LDSOC ;Local socket
MOVEM FDSOC ] ;Foreign socket
.LOSE 1000
MOVEI A,2
ADDM A,LDSOC ;Relocate to data socket base
AOS FDSOC
ACONN1: OUTOPN NETO, ;Prepare for using output UUOs on NETO.
MOVEI A,300. ;Expect 300 Initial Greeting
TLNE F,%LTCP ;If using TCP
MOVEI A,220. ; the greeting is 220.
PUSHJ P,REPLY ;Get reply, skip if winning
JRST ERDISC ;Reply says connection no good => disconnect.
PUSHJ P,REPDIS ;Print the text of the greeting message.
JRST POPJ1
ERDISC: PUSHJ P,DISC
JFCL
JRST ERRTR1
ADISC:
ABYE: PUSHJ P,FLSLIN ;BYE command. No-op if we have no server.
BYE: PUSHJ P,STILOPN
PUSHJ P,GRATU ;Check for gratuitous reply from server.
SKIPN CNECTD
JRST POPJ1
OUTZ NETO,[ASCIZ /QUIT
/]
MOVEI A,221. ;Wait for acknowledgement, then disconnect.
PUSHJ P,REPLY
JFCL ;You don't want to disconnect?
;Too bad! We will anyway.
DISC: SKIPN CNECTD ;Disconnect. No-op if not connected.
JRST POPJ1
SETZM CNECTD
.CLOSE NETO,
.CLOSE NETI,
JRST POPJ1
SUBTTL A few simple commands
AHELP: PUSHJ P,FLSLIN
MOVSI A,-COMTBL
AHELP1: SKIPN HLPTAB(A)
JRST AHELP2
FWRITE TYOC,[CRLF,,TZ$,COMTAB(A),TI,^I,TZ$,HLPTAB(A)]
AHELP2: AOBJN A,AHELP1
OUTZ TYOC,[ASCIZ\
You may also give just a host name or number if not already connected.
Terminate input with CR or LF. Use rubout to delete last character typed.
Commands and Host names may be abbreviated (if the abbreviation is
unambiguous).
\]
JRST POPJ1
AHSTS: PUSHJ P,FLSLIN ;HOSTS command - list all hosts. (Arpanet only)
MOVE A,NETWRK"HSTADR
MOVE B,NETWRK"NAMPTR(A)
ADD B,A ;Get addr of HOSTS3 file NAMES table.
MOVE C,(B) ;C gets number of entries.
MOVE D,1(B) ;D gets words per entry
ADDI B,2 ;B -> first entry
AHSTS1: HLRZ A,NETWRK"NMLSIT(B)
ADD A,NETWRK"HSTADR ;A gets addr of SITES table entry for this host.
HLRZ TT,NETWRK"STLNAM(A) ;Get relative address of the official name
HRRZ T,NETWRK"NMRNAM(B) ;Get relative address of this name
CAME T,TT
JRST AHSTS2 ;Don't mention nicknames
HLRZ TT,NETWRK"STLSYS(A)
ADD TT,NETWRK"HSTADR ;A gets addr of string containing type of system
MOVE TT,(TT)
CAME TT,[ASCIZ /TIP/] ;Dont mention TIPs. Can't FTP to them.
SKIPL NETWRK"STLFLG(A) ;Only mention servers
JRST AHSTS2
HRRZ A,NETWRK"STRADR(A) ;See if this guy is on Internet
AHSTS3: ADD A,NETWRK"HSTADR
MOVE TT,NETWRK"ADDADR(A)
TLNN TT,(NETWRK"NE%UNT) ; Skip if not an internet address.
JRST AHSTS4
HRRZ A,NETWRK"ADRCDR(A)
JUMPN A,AHSTS3
JRST AHSTS2
AHSTS4: ADD T,NETWRK"HSTADR
FWRITE TYOC,[TZ$,T,CRLF,,]
AHSTS2: ADD B,D ;B -> next entry
SOJG C,AHSTS1
JRST POPJ1
AQUOT: PUSHJ P,ARGCON
[ASCIZ /FTP protocol command to give to server: /]
JRST SNDARG
ASTAT: PUSHJ P,ARGCON
[ASCIZ /Server-dependent status-type: /]
OUTZ NETO,[ASCIZ /STAT/]
HRRZ D,(A) ;Get length of arg.
SKIPE D ;If user said anything,
OUTZ NETO,[ASCIZ / /] ;delimit cmd and arg.
JRST SNDARG
AICPS: PUSHJ P,ARG
[ASCIZ /Socket number: /]
PUSHJ P,RDOCT
MOVEM A,ICPSOC
JRST POPJ1
ASOAK: PUSHJ P,FLSLIN
ASOAK0: SETO A, ;Read in and print one reply from server.
PUSH P,PRREP
SETOM PRREP
PUSHJ P,REPLY
JFCL
POP P,PRREP
JRST POPJ1
ADBUG: PUSHJ P,FLSLIN
SETCMM PRREP ;DEBUG - complement printing of server replies.
SKIPN PRREP
OUTZ TYOC,[ASCIZ\not \]
OUTZ TYOC,[ASCIZ\printing server replies.\]
CRLF TYOC,
JRST POPJ1
DONCP: PUSHJ P,ABYE ;Can't change mode with conns open.
JFCL
OUTZ TYOC,[ASCIZ /Switching to NCP mode, which probably do anything good./]
CRLF TYOC,
TLZ F,%LTCP ;Say not doing TCP.
MOVEI A,FTPSKT ;NCP means this is the ICP socket
MOVEM A,ICPSOC ;Remember which port or socket to use.
MOVE A,[NETWRK"NW%ARP] ;Get own host number, on Arpanet
PUSHJ P,NETWRK"OWNHST
.LOSE ;Not connected to Arpanet?
MOVEM A,OWNHST
JRST POPJ1
DOTCP: PUSHJ P,ABYE ;Can't change mode with conns open.
JFCL
OUTZ TYOC,[ASCIZ /Switching to TCP mode./]
CRLF TYOC,
TLO F,%LTCP ;Say doing TCP.
MOVEI A,FTPORT ;TCP means we use this port.
MOVEM A,ICPSOC ;Remember which port or socket to use.
MOVE A,[SQUOZE 0,/IMPUS3/]
.EVAL A, ;If TCP, need the HOSTS3 format address instead.
.LOSE %LSSYS
MOVEM A,OWNHST
JRST POPJ1
AQUIT: PUSHJ P,FLSLIN
QUIT: PUSHJ P,BYE
JFCL
DIE: .CLOSE SCRIPC,
SKIPE DEBUG
.VALUE
.LOGOUT 1,
AVALR: PUSHJ P,FLSLIN ;Flush typed-ahead commands.
.BREAK 16,100000 ;Return to superior. Can be $P'd or $G'd.
JRST POPJ1
APROCD: SKIPA C,[[ASCIZ //]] ;Proceed command.
ADISOW: MOVEI C,[ASCIZ / /];Disown command - disown self, keep running.
PUSHJ P,FLSLIN
MOVE A,JCLP
ILDB A,A ;If have input already buffered, it might
;contain an XFILE and SCRIPT, so we can't be
JUMPN A,ADISO1 ;sure user is losing.
SKIPN TRITTY ;If TTY input is translated,
SKIPE COMFIL ;or redirected with an XFILE, then input is OK.
CAIA
JRST ADISO2
SKIPN TROTTY ;If TTY output is translated
SKIPE SCRIPT ; or redirected with a SCRIPT,
CAIA ; OK.
ADISO2: JRST [ OUTZ TYOC,[ASCIZ /Can't DISOWN or PROCEED if using the TTY
/]
JRST ERRTR1]
ADISO1: SKIPE DEBUG
.VALUE
.VALUE (C)
SKIPN TROTTY ;If TTY output isn't translated,
SETOM SILENT ; we mustn't use it any more.
JRST POPJ1
ASILNT: PUSHJ P,FLSLIN
SETOM SILENT
JRST POPJ1
ALOGIN: PUSHJ P,ARGCON
[ASCIZ /as User name: /]
OUTZ NETO,[ASCIZ /USER /] ;Send the command name.
JRST SNDARG ;Send the arg, handle reply.
APASS: PUSHJ P,ARGCON
[ASCIZ/password: /]
OUTZ NETO,[ASCIZ /PASS /]
SNDARG: FWRITE NETO,[TZ,ARGBUF,CRLF,,]
MOVEI A,200.
JRST REPLY
AACCT: PUSHJ P,ARGCON
[ASCIZ /account number to log in under: /]
OUTZ NETO,[ASCIZ /ACCT /] ;Send the command name.
JRST SNDARG ;Send the arg, handle reply.
ACWD: PUSHJ P,ARGCON
[ASCIZ/to Directory: /]
OUTZ NETO,[ASCIZ /CWD /] ;Send the command name.
JRST SNDARG ;Send the arg, handle reply.
ADEFA: PUSHJ P,ARG ;DEFAULTS - just set local filename.
[ASCIZ /filename defaults: /]
MOVE B,[FILDEV,,FILDEV]
PUSHJ P,FILPAR
JRST POPJ1
AALLOC: PUSHJ P,ARGCON ;ALLOC - send size for file to be STOREd.
[ASCIZ /# bytes: /]
OUTZ NETO,[ASCIZ /ALLO /]
JRST SNDARG
;Delete command.
ADELE: PUSHJ P,ARGCON
[ASCIZ /file: /]
OUTZ NETO,[ASCIZ /DELE /]
JRST SNDARG
;Rename command.
ARENAM: PUSHJ P,ARGCON
[ASCIZ /old file: /]
FWRITE NETO,[[RNFR ],TZ,ARGBUF,CRLF,,] ;Send the old name.
MOVEI A,350.
PUSHJ P,REPLY ;Wait for acceptance.
POPJ P,
PUSHJ P,ARG
[ASCIZ /to new name: /]
FWRITE NETO,[[RNTO ],TZ,ARGBUF,CRLF,,]
MOVEI A,250.
JRST REPLY
;PRINT command - print file on ML's TPL.
APRIN: MOVE B,FDHST
CAIN B,306
SKIPN CNECTD
CAIA
JRST APRIN2
MOVE A,[SETZ 306]
PUSHJ P,CONN ;First connect to ML (if not already connected).
POPJ P,
APRIN2: PUSHJ P,ARG ;Then ask for and open the disk file.
[ASCIZ/local file: /]
MOVE B,[FILDEV,,FILDEV]
PUSHJ P,FILPAR
PUSHJ P,DCSEND ;Tell ML to use image mode.
SKIPLE TT,DCTYPE
SETO TT, ; Assume local-byte means image.
SYSCAL OPEN,[ (TT)1+[.BII,,DC ? .UAI,,DC]
FILDEV ? FILFN1 ? FILFN2 ? FILDIR ]
JRST FILERR
PUSHJ P,NETWLS
OUTZ NETO,[ASCIZ /STOR TPL:
/]
JRST APRIN1 ;Then go do a PUT to TPL:.
SUBTTL Connection Checking
;Commands that need to be connected before they can work call here
;If we aren't connected to a server, ask user which host and try to connect now.
CONTST: SKIPN CNECTD ;If no connection, ask for host name.
JRST CONTS1
PUSHJ P,STILOPN ;If have a server, check that it's really there.
SKIPE CNECTD ;If it is, we win.
POPJ P, ;Otherwise, ask for host to connect to.
SKIPE TYITTY ;In this case, any type-ahead
.RESET TYIC, ;must be intended for something else.
CONTS1: PUSHAE P,[A,JCLBFP,JCLP] ;? *******
MOVE A,[440700,,JCLBF2] ;Read host name using alternate buffer.
MOVEM A,JCLBFP
MOVEM A,JCLP
SETZM JCLBF2
PUSHJ P,ACONN
JRST ERRTR1
POPAE P,[JCLP,JCLBFP,A]
POPJ P,
SUBTTL Error Handling
;Handle File Error
FILERR: .OPEN ERRC,[.UAI,,'ERR ? 1]
.VALUE
FILER1: .IOT ERRC,TT
CAIL TT,40
JRST [ OUTI TYOC,(TT) ? JRST FILER1 ]
FWRITE TYOC,[[ - ],6F,FILDEV,[: ],6F,FILDIR,[; ],6F,FILFN1,[ ],6F,FILFN2,CRLF,,]
JRST ERRTR1
NOTTY: OUTZ TYOC,[ASCIZ /No TTY or Script file to read from
/]
JRST QUIT
;Here for error making data connection. We need to reset.
DCBORE: OUT(TYOC,("Timed out waiting for server to make data connection."),EOL)
JRST NETCLS
;Here for error making data connection. A server reply is expected
;and should be soaked up.
DCNERR: .LOGOUT 0,
PUSHJ P,NETWRK"ANALYZ
.VALUE
CRLF TYOC,
PUSHJ P,STILOPN
SKIPE CNECTD
PUSHJ P,ASOAK0
JFCL
JRST NETCLS
;Here is call to CONNEC or ICP loses.
NTERDI: MOVEI A,NETDI