source: trunk/minix/commands/ftp/other.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.3 KB
Line 
1/* other.c by Michael Temari 06/21/92
2 *
3 * ftp An ftp client program for use with TNET.
4 *
5 * Author: Michael Temari, <temari@ix.netcom.com>
6 */
7
8#include <sys/types.h>
9#include <stdio.h>
10#include <ctype.h>
11#include <unistd.h>
12#include <stdlib.h>
13#include <string.h>
14#include <termios.h>
15
16#include "ftp.h"
17#include "other.h"
18
19void FTPinit()
20{
21 linkopen = 0;
22 loggedin = 0;
23 type = TYPE_A;
24 format = 0;
25 mode = 0;
26 structure = 0;
27 passive = 0;
28 atty = isatty(0);
29}
30
31int DOpass()
32{
33int s;
34struct termios oldtty, newtty;
35char *pass;
36char password[64];
37
38 if(!linkopen) {
39 printf("You must \"OPEN\" a connection first.\n");
40 return(0);
41 }
42
43 pass = cmdargv[1];
44
45 if(cmdargc < 2) {
46 tcgetattr(fileno(stdout), &oldtty);
47 newtty = oldtty;
48 newtty.c_lflag &= ~ECHO;
49 tcsetattr(fileno(stdout), TCSANOW, &newtty);
50 readline("Password: ", password, sizeof(password));
51 tcsetattr(fileno(stdout), TCSANOW, &oldtty);
52 printf("\n");
53 pass = password;
54 }
55
56 s = DOcommand("PASS", pass);
57
58 if(s == 230)
59 loggedin = 1;
60
61 return(s);
62}
63
64int DOuser()
65{
66char *user;
67int s;
68char username[64];
69
70 if(!linkopen) {
71 printf("You must \"OPEN\" a connection first.\n");
72 return(0);
73 }
74
75 loggedin = 0;
76
77 user = cmdargv[1];
78
79 if(cmdargc < 2) {
80 readline("Username: ", username, sizeof(username));
81 user = username;
82 }
83
84 s = DOcommand("USER", user);
85
86 if(atty && s == 331) {
87 cmdargv[0] = "password";
88 cmdargc = 1;
89 return(DOpass());
90 }
91
92 if(s == 230)
93 loggedin = 1;
94
95 return(s);
96}
97
98int DOnoop()
99{
100 if(DOcmdcheck())
101 return(0);
102
103 return(DOcommand("NOOP", ""));
104}
105
106int DOpassive()
107{
108 passive = 1 - passive;
109
110 printf("Passive mode is now %s\n", (passive ? "ON" : "OFF"));
111
112 return(0);
113}
114
115int DOsyst()
116{
117 if(DOcmdcheck())
118 return(0);
119
120 return(DOcommand("SYST", ""));
121}
122
123int DOremotehelp()
124{
125 if(!linkopen) {
126 printf("You must \"OPEN\" a connection first.\n");
127 return(0);
128 }
129
130 return(DOcommand("HELP", ""));
131}
132
133int DOquote()
134{
135int i;
136static char args[512];
137
138 args[0] = '\0';
139
140 for(i = 2; i < cmdargc; i++) {
141 if(i != 2)
142 strcat(args, " ");
143 strcat(args, cmdargv[i]);
144 }
145
146 return(DOcommand(cmdargv[1], args));
147}
148
149int DOsite()
150{
151int i;
152static char args[512];
153
154 args[0] = '\0';
155
156 for(i = 1; i < cmdargc; i++) {
157 if(i != 1)
158 strcat(args, " ");
159 strcat(args, cmdargv[i]);
160 }
161
162 return(DOcommand("SITE", args));
163}
Note: See TracBrowser for help on using the repository browser.