Repository navigation
Expand file tree
/
Copy pathother.c
More file actions
executable file
·163 lines (127 loc) · 2.33 KB
/
Copy pathother.c
File metadata and controls
executable file
·163 lines (127 loc) · 2.33 KB
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
/* other.c by Michael Temari 06/21/92
*
* ftp An ftp client program for use with TNET.
*
* Author: Michael Temari, <temari@ix.netcom.com>
*/
#include <sys/types.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include "ftp.h"
#include "other.h"
void FTPinit()
{
linkopen = 0;
loggedin = 0;
type = TYPE_A;
format = 0;
mode = 0;
structure = 0;
passive = 0;
atty = isatty(0);
}
int DOpass()
{
int s;
struct termios oldtty, newtty;
char *pass;
char password[64];
if(!linkopen) {
printf("You must \"OPEN\" a connection first.\n");
return(0);
}
pass = cmdargv[1];
if(cmdargc < 2) {
tcgetattr(fileno(stdout), &oldtty);
newtty = oldtty;
newtty.c_lflag &= ~ECHO;
tcsetattr(fileno(stdout), TCSANOW, &newtty);
readline("Password: ", password, sizeof(password));
tcsetattr(fileno(stdout), TCSANOW, &oldtty);
printf("\n");
pass = password;
}
s = DOcommand("PASS", pass);
if(s == 230)
loggedin = 1;
return(s);
}
int DOuser()
{
char *user;
int s;
char username[64];
if(!linkopen) {
printf("You must \"OPEN\" a connection first.\n");
return(0);
}
loggedin = 0;
user = cmdargv[1];
if(cmdargc < 2) {
readline("Username: ", username, sizeof(username));
user = username;
}
s = DOcommand("USER", user);
if(atty && s == 331) {
cmdargv[0] = "password";
cmdargc = 1;
return(DOpass());
}
if(s == 230)
loggedin = 1;
return(s);
}
int DOnoop()
{
if(DOcmdcheck())
return(0);
return(DOcommand("NOOP", ""));
}
int DOpassive()
{
passive = 1 - passive;
printf("Passive mode is now %s\n", (passive ? "ON" : "OFF"));
return(0);
}
int DOsyst()
{
if(DOcmdcheck())
return(0);
return(DOcommand("SYST", ""));
}
int DOremotehelp()
{
if(!linkopen) {
printf("You must \"OPEN\" a connection first.\n");
return(0);
}
return(DOcommand("HELP", ""));
}
int DOquote()
{
int i;
static char args[512];
args[0] = '\0';
for(i = 2; i < cmdargc; i++) {
if(i != 2)
strcat(args, " ");
strcat(args, cmdargv[i]);
}
return(DOcommand(cmdargv[1], args));
}
int DOsite()
{
int i;
static char args[512];
args[0] = '\0';
for(i = 1; i < cmdargc; i++) {
if(i != 1)
strcat(args, " ");
strcat(args, cmdargv[i]);
}
return(DOcommand("SITE", args));
}