-
Notifications
You must be signed in to change notification settings - Fork 4
/
ckuus3.c
1767 lines (1479 loc) · 31.7 KB
/
ckuus3.c
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
/* C K U U S 3 -- "User Interface" */
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright (c) 2021, 2022, 2023 Jeffrey H. Johnson <[email protected]>
*
* Copyright (c) 1981-2011,
* Trustees of Columbia University in the City of New York.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* - Neither the name of Columbia University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* SET and REMOTE commands; screen, debug,
* interrupt, and logging functions
*/
#include "ckcdeb.h"
#include "ckcker.h"
#include "ckucmd.h"
#include "ckuusr.h"
#include <ctype.h>
#include <stdio.h>
#ifdef UXIII
#ifdef CK_TERMIOS
#include <termios.h>
#else
#include <termio.h>
#endif /* ifdef CK_TERMIOS */
#endif /* ifdef UXIII */
#ifdef __linux__
#include <string.h>
#endif /* ifdef __linux__ */
#ifndef NOICP
extern int size, spsiz, rpsiz, urpsiz, npad, timint,
srvtim, rtimo, speed, local, lpcapr;
#ifndef NOSERVER
extern int server;
#endif /* ifndef NOSERVER */
#ifndef NOATTR
extern int atcapr;
#endif /* ifndef NOATTR */
extern int fmask, cmask, backgrd, flow, displa,
binary, fncnv, delay, parity, deblog, escape,
xargc, turn, duplex, cxseen, czseen, nfils,
ckxech, pktlog, seslog, tralog, stdouf, turnch,
bctr, bctu, dfloc, mdmtyp, keep, maxtry,
rptflg, ebqflg, warn, quiet, cnflg, timef,
spsizf, mypadn;
extern long filcnt, tlci, tlco, ffc, tfc, fsize;
extern char *versio, *protv, *ckxv, *ckzv, *fnsv, *connv, *dftty, *cmdv;
extern char *cmarg, *cmarg2, **xargv, **cmlist;
extern CHAR stchr, mystch, sstate, padch, mypadc, eol, seol, ctlq;
extern CHAR filnam[], ttname[];
char *strcpy();
extern char cmdbuf[]; /* Command buffer */
extern char \
line[CMDBL + 10], *lp; /* Character buffer for anything */
extern char debfil[50], /* Debugging log file name */
pktfil[50], /* Packet log file name */
sesfil[50], /* Session log file name */
trafil[50]; /* Transaction log file name */
extern int tlevel; /* Take Command file level */
extern FILE *tfile[]; /* Array of take command fd's */
char coninc(int timo);
/*
* Keyword tables
* for SET commands
*/
/*
* Block
* checks
*/
struct keytab blktab[] = {
{ "1", 1, 0, },
{ "2", 2, 0, },
{ "3", 3, 0 }
};
/*
* Duplex keyword
* table
*/
struct keytab dpxtab[] = {
{ "full", 0, 0, },
{ "half", 1, 0 }
};
struct keytab filtab[] = {
{ "display", XYFILD, 0, },
{ "names", XYFILN, 0, },
{ "type", XYFILT, 0, },
{ "rename", XYFILW, 0 }
};
int nfilp = ( sizeof ( filtab ) / sizeof ( struct keytab ));
/*
* Send/Receive
* Parameters
*/
struct keytab srtab[] = {
{ "end-of-packet", XYEOL, 0, },
{ "packet-length", XYLEN, 0, },
{ "pad-character", XYPADC, 0, },
{ "padding", XYNPAD, 0, },
{ "start-of-packet", XYMARK, 0, },
{ "timeout", XYTIMO, 0 }
};
int nsrtab = ( sizeof ( srtab ) / sizeof ( struct keytab ));
/*
* Flow
* Control
*/
struct keytab flotab[] = {
{ "none", 0, 0, },
{ "xon/xoff", 1, 0 }
};
int nflo = ( sizeof ( flotab ) / sizeof ( struct keytab ));
/*
* Handshake
* characters
*/
struct keytab hshtab[] = {
{ "bell", 007, 0, },
{ "cr", 015, 0, },
{ "esc", 033, 0, },
{ "lf", 012, 0, },
{ "none", 999, 0, },
{ "xoff", 023, 0, },
{ "xon", 021, 0 }
};
int nhsh = ( sizeof ( hshtab ) / sizeof ( struct keytab ));
struct keytab fntab[] = { /* File naming */
{ "converted", 1, 0, },
{ "literal", 0, 0 }
};
struct keytab fttab[] = { /* File types */
{ "binary", 1, 0, },
{ "text", 0, 0 }
};
#ifndef NOCKUDIA
extern struct keytab mdmtab[]; /* Modem types (in module ckudia.c) */
extern int nmdm;
#endif /* ifndef NOCKUDIA */
/*
* Parity keyword
* table
*/
struct keytab partab[] = {
{ "even", 'e', 0, },
{ "mark", 'm', 0, },
{ "none", 0, 0, },
{ "odd", 'o', 0, },
{ "space", 's', 0 }
};
int npar = ( sizeof ( partab ) / sizeof ( struct keytab ));
/*
* On/Off
* table
*/
struct keytab onoff[] = {
{ "off", 0, 0, },
{ "on", 1, 0 }
};
/*
* Incomplete File
* Disposition table
*/
struct keytab ifdtab[] = {
{ "discard", 0, 0, },
{ "keep", 1, 0 }
};
/*
* Terminal parameters
* table
*/
struct keytab trmtab[] = {
{ "bytesize", 0, 0 }
};
/*
* Server parameters
* table
*/
struct keytab srvtab[] = {
{ "timeout", 0, 0 }
};
/* D O P R M -- Set a parameter */
/*
* Returns:
* -2: illegal input
* -1: reparse needed
* 0: success
*/
int
doprm(xx)
int xx;
{
int x = 0;
int y = 0;
int z = 0; /* XXX(jhj): init y & z to 0 */
char *s;
switch (xx)
{
case XYEOL: /* These have all been moved to set send/receive... */
case XYLEN: /* Let the user know what to do. */
case XYMARK:
case XYNPAD:
case XYPADC:
case XYTIMO:
printf("Use 'set send' or 'set receive'.\n");
#ifndef NODOHLP
printf("Type 'help set send' or 'help set receive' for more info.\n");
#endif /* ifndef NODOHLP */
return ( 0 );
#ifndef NOATTR
case XYATTR: /* File Attribute packets */
return ( seton(&atcapr));
#endif /* ifndef NOATTR */
case XYIFD: /* Incomplete file disposition */
if (( y = cmkey(ifdtab, 2, "", "discard")) < 0)
{
return ( y );
}
if (( x = cmcfm()) < 0)
{
return ( x );
}
keep = y;
return ( 0 );
case XYLINE:
if (( x = cmtxt("Device name", dftty, &s)) < 0)
{
return ( x );
}
ttclos(); /* close old line, if any was open */
x = strcmp(s, dftty) ? -1 : dfloc; /* Maybe let ttopen figure it out */
if (ttopen(s, &x, mdmtyp) < 0) /* Can we open the new line? */
{
perror("Can't open line");
return ( -2 ); /* If not, give bad return */
}
if (x > -1)
{
local = x; /* Set local/remote status. */
}
strcpy(ttname, s); /* OK, copy name into real place. */
if (!local)
{
speed = -1; /* If remote, say speed unknown. */
}
debug(F111, "set line ", ttname, local);
return ( 0 );
case XYCHKT:
if (( y = cmkey(blktab, 3, "", "1")) < 0)
{
return ( y );
}
if (( x = cmcfm()) < 0)
{
return ( x );
}
bctr = y;
return ( 0 );
#ifndef NOLOGS
#ifdef DEBUG
case XYDEBU:
return ( seton(&deblog));
#endif /* ifdef DEBUG */
#endif /* ifndef NOLOGS */
case XYDELA:
y = cmnum("Seconds to delay send", "5", 10, &x);
debug(F101, "XYDELA: y", "", y);
return ( setnum(&delay, x, y, 94));
case XYDUPL:
if (( y = cmkey(dpxtab, 2, "", "full")) < 0)
{
return ( y );
}
if (( x = cmcfm()) < 0)
{
return ( x );
}
duplex = y;
return ( 0 );
case XYESC:
y = cmnum("ASCII code for escape character", "", 10, &x);
return ( setcc(&escape, x, y));
case XYFILE:
if (( y = cmkey(filtab, nfilp, "File parameter", "")) < 0)
{
return ( y );
}
switch (y)
{
case XYFILD: /* Display */
y = seton(&z);
if (y < 0)
{
return ( y );
}
quiet = !z;
return ( 0 );
case XYFILN: /* Names */
if (( x =
cmkey(fntab, 2, "how to handle filenames", "converted")) < 0)
{
return ( x );
}
if (( z = cmcfm()) < 0)
{
return ( z );
}
fncnv = x;
return ( 0 );
case XYFILT: /* Type */
if (( x = cmkey(fttab, 2, "type of file", "text")) < 0)
{
return ( x );
}
if (( y = cmnum("file byte size", "8", 10, &z)) < 0)
{
return ( y );
}
if (z != 7 && z != 8)
{
printf("\n?7 or 8\n");
return ( -2 );
}
if (( y = cmcfm()) < 0)
{
return ( y );
}
binary = x;
if (z == 7)
{
fmask = 0177;
}
else if (z == 8)
{
fmask = 0377;
}
return ( 0 );
case XYFILW: /* Rename */
return ( seton(&warn));
default:
printf("?unexpected parameter\n");
return ( -2 );
}
case XYFLOW: /* Flow control */
if (( y = cmkey(flotab, nflo, "", "xon/xoff")) < 0)
{
return ( y );
}
if (( x = cmcfm()) < 0)
{
return ( x );
}
flow = y;
return ( 0 );
case XYHAND: /* Handshake */
if (( y = cmkey(hshtab, nhsh, "", "none")) < 0)
{
return ( y );
}
if (( x = cmcfm()) < 0)
{
return ( x );
}
turn = ( y > 0127 ) ? 0 : 1;
turnch = y;
return ( 0 );
case XYMODM:
#ifndef NOCKUDIA
if (( x = cmkey(
mdmtab,
nmdm,
"type of modem, or direct",
"direct")) < 0)
{
return ( x );
}
#endif /* ifndef NOCKUDIA */
if (( z = cmcfm()) < 0)
{
return ( z );
}
mdmtyp = x;
return ( 0 );
case XYPARI: /* Parity */
if (( y = cmkey(partab, npar, "", "none")) < 0)
{
return ( y );
}
if (( x = cmcfm()) < 0)
{
return ( x );
}
/*
* If parity not none, then
* we also want 8th-bit prefixing
*/
if (( parity = y ))
{
ebqflg = 1;
}
else
{
ebqflg = 0;
}
return ( 0 );
case XYPROM:
if (( x = cmtxt("local prompt", "uCKermit>", &s)) < 0)
{
return ( x );
}
if (*s == '\42') /* Quoted string? */
{
x = strlen(s) - 1; /* Yes, strip quotes. */
if (*( s + x ) == '\42') /* This allows leading or trailing */
{
*( s + x ) = '\0'; /* blanks. */
}
s++;
}
cmsetp(s);
return ( 0 );
case XYRETR: /* Per-packet retry limit */
y = cmnum("retries per packet", "10", 10, &x);
return ( setnum(&maxtry, x, y, 94));
case XYSERV: /* Server timeout */
if (( y = cmkey(srvtab, 1, "", "timeout")) < 0)
{
return ( y );
}
switch (y)
{
char tmp[20];
case XYSERT:
sprintf(tmp, "%d", DSRVTIM);
if (( y = cmnum(
"interval for server NAKs, 0 = none",
tmp,
10,
&x)) < 0)
{
return ( y );
}
if (x < 0)
{
printf("\n?Positive number, 0 to disable.\n");
return ( -2 );
}
if (( y = cmcfm()) < 0)
{
return ( y );
}
srvtim = x; /* Set the server timeout variable */
return ( y );
default:
return ( -2 );
}
case XYTERM: /* Terminal parameters */
if (( y = cmkey(trmtab, 1, "", "bytesize")) < 0)
{
return ( y );
}
switch (y)
{
case 0:
if (( y = cmnum("bytesize for terminal", "8", 10, &x)) < 0)
{
return ( y );
}
if (x != 7 && x != 8)
{
printf("\n?Only 7 and 8\n");
return ( -2 );
}
if (( y = cmcfm()) < 0)
{
return ( y );
}
if (x == 7)
{
cmask = 0177;
}
else if (x == 8)
{
cmask = 0377;
}
return ( y );
default: /* Add more cases when we think of more parameters */
return ( -2 );
}
/*
* SET
* SEND/RECEIVE
*/
case XYRECV:
case XYSEND:
if (xx == XYRECV)
{
strcpy(line, "Parameter for inbound packets");
}
else
{
strcpy(line, "Parameter for outbound packets");
}
if (( y = cmkey(srtab, nsrtab, line, "")) < 0)
{
return ( y );
}
switch (y)
{
case XYEOL:
y = cmnum("ASCII code for terminator", "13", 10, &x);
if (( y = setcc(&z, x, y)) < 0)
{
return ( y );
}
if (xx == XYRECV)
{
eol = z;
}
else
{
seol = z;
}
return ( y );
case XYLEN:
y = cmnum("Max chars in packet", "90", 10, &x);
if (xx == XYRECV) /* Receive... */
{
if (( y = setnum(&z, x, y, MAXRP)) < 0)
{
return ( y );
}
urpsiz = z;
rpsiz = ( z > 94 ) ? 94 : z;
}
else /* Send... */
{
if (( y = setnum(&z, x, y, MAXSP)) < 0)
{
return ( y );
}
spsiz = z; /* Set it and flag that it was set */
spsizf = 1; /* to allow overriding Send-Init. */
}
return ( y );
case XYMARK:
y = cmnum(
"ASCII code for start character",
"1",
10,
&x);
if (( y = setcc(&z, x, y)) < 0)
{
return ( y );
}
if (xx == XYRECV)
{
stchr = z;
}
else
{
mystch = z;
}
return ( y );
case XYNPAD: /* Padding */
y = cmnum(
"Padding characters for inbound packets",
"0",
10,
&x);
if (( y = setnum(&z, x, y, 94)) < 0)
{
return ( y );
}
if (xx == XYRECV)
{
mypadn = z;
}
else
{
npad = z;
}
return ( y );
case XYPADC: /* Pad character */
y = cmnum(
"ASCII code for pad character",
"0",
10,
&x);
if (( y = setcc(&z, x, y)) < 0)
{
return ( y );
}
if (xx == XYRECV)
{
mypadc = z;
}
else
{
padch = z;
}
return ( y );
case XYTIMO:
y = cmnum("Interpacket timeout", "5", 10, &x);
if (( y = setnum(&z, x, y, 94)) < 0)
{
return ( y );
}
if (xx == XYRECV)
{
timef = 1;
timint = z;
}
else
{
rtimo = z;
}
return ( y );
}
case XYSPEE:
if (!local)
{
printf("\nSpeed setting only for external lines,\n");
printf("You must 'set line' first\n");
return ( 0 );
}
lp = line;
sprintf(lp, "Baud for %s", ttname);
if (( y = cmnum(line, "", 10, &x)) < 0)
{
return ( y );
}
if (( y = cmcfm()) < 0)
{
return ( y );
}
y = chkspd(x);
if (y < 0)
{
#ifndef NODOHLP
printf("?Unsupported line speed - %d\n", x);
#else /* ifndef NODOHLP */
printf("?Bad speed - %d\n", x);
#endif /* ifndef NODOHLP */
}
else
{
speed = y;
if (!backgrd)
{
printf("%s, %d baud\n", ttname, speed);
}
}
return ( 0 );
default:
if (( x = cmcfm()) < 0)
{
return ( x );
}
printf("Not working yet - %s\n", cmdbuf);
return ( 0 );
}
}
#endif /* ifndef NOICP */
/* C H K S P D -- Check if argument is a valid baud rate */
int
chkspd(x)
int x;
{ /* XXX(jhj): Needs fixin! */
switch (x)
{
case 0:
case 110:
case 150:
case 300:
case 600:
case 1200:
case 1800:
case 2400:
case 4800:
case 9600:
case 19200:
#ifdef __linux__ /* XXX(jhj): nonononono */
case 38400:
case 57600:
case 115200:
case 230400:
case 460800:
case 921600:
case 1000000:
case 1152000:
case 1500000:
case 2000000:
case 2500000:
case 3000000:
case 3500000:
case 4000000:
#endif /* ifdef __linux__ */
return ( x );
default:
return ( -1 );
}
}
#ifndef NOICP
/* S E T O N -- Parse on/off (default on), set parameter to result */
int
seton(prm)
int *prm;
{
int x, y;
if (( y = cmkey(onoff, 2, "", "on")) < 0)
{
return ( y );
}
if (( x = cmcfm()) < 0)
{
return ( x );
}
*prm = y;
return ( 0 );
}
/* S E T N U M -- Set parameter to result of cmnum() parse */
/*
* Call with
* x - number from cnum parse,
* y - return code from cmnum
*/
int
setnum(prm, x, y, max)
int x, y, *prm, max;
{
debug(F101, "setnum", "", y);
if (y < 0)
{
return ( y );
}
if (x > max)
{
printf("\n?%d max\n", max);
return ( -2 );
}
if (( y = cmcfm()) < 0)
{
return ( y );
}
*prm = x;
return ( 0 );
}
/* S E T C C -- Set parameter to an ASCII control character value */
int
setcc(prm, x, y)
int x, y, *prm;
{
if (y < 0)
{
return ( y );
}
if (( x > 037 ) && ( x != 0177 ))
{
printf("\n?Not a control char - %d\n", x);
return ( -2 );
}
if (( y = cmcfm()) < 0)
{
return ( y );
}
*prm = x;
return ( 0 );
}
/* D O R M T -- Do a remote command */
int
dormt(xx)
int xx;
{
int x;
char *s, sbuf[50], *s2;
if (xx < 0)
{
return ( xx );
}
switch (xx)
{
case XZCWD: /* CWD */
if (( x = cmtxt("Remote dir", "", &s)) < 0)
{
return ( x );
}
debug(F111, "XZCWD: ", s, x);
*sbuf = NUL;
s2 = sbuf;
if (*s != NUL) /* If directory name given, */
/* get password on separate line. */
{
if (tlevel > -1) /* From take file... */
{
if (fgets(sbuf, 50, tfile[tlevel]) == NULL)
{
fatal("take file ended in 'remote cwd'");
}
#ifdef DEBUG
debug(F110, " pswd from take file", s2, 0);
#endif /* ifdef DEBUG */
for (x = strlen(sbuf);
x > 0 && ( sbuf[x - 1] == NL || sbuf[x - 1] == CR ); x--)
{