pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / ftp101 / other.c
blob8718da757ba14adb9060b9f700ccae62ed7bf474
1 /* other.c Copyright 1992-2000 by Michael Temari All Rights Reserved
3 * ftp An ftp client program for use with TNET.
5 * Author: Michael Temari, <Michael@TemWare.Com>
6 */
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>
16 #include "ftp.h"
17 #include "other.h"
19 _PROTOTYPE(static int docmdargs, (char *cmd, int fa));
21 void FTPinit()
23 linkopen = 0;
24 loggedin = 0;
25 type = TYPE_A;
26 format = 0;
27 mode = MODE_S;
28 structure = 0;
29 passive = 0;
30 atty = isatty(0);
33 int DOpass()
35 int s;
36 struct termios oldtty, newtty;
37 char *pass;
38 char password[64];
40 if(!linkopen) {
41 printf("You must \"OPEN\" a connection first.\n");
42 return(0);
45 pass = cmdargv[1];
47 s = 0;
49 if(cmdargc < 2) {
50 if(atty) {
51 tcgetattr(fileno(stdout), &oldtty);
52 newtty = oldtty;
53 newtty.c_lflag &= ~ECHO;
54 tcsetattr(fileno(stdout), TCSANOW, &newtty);
56 s = readline("Password: ", password, sizeof(password));
57 if(atty) {
58 tcsetattr(fileno(stdout), TCSANOW, &oldtty);
59 printf("\n");
61 pass = password;
64 if(s < 0)
65 return(-1);
67 s = DOcommand("PASS", pass);
69 if(s == 230)
70 loggedin = 1;
72 return(s);
75 int DOuser()
77 char *user;
78 int s;
79 char username[32];
81 if(!linkopen) {
82 printf("You must \"OPEN\" a connection first.\n");
83 return(0);
86 loggedin = 0;
88 user = cmdargv[1];
90 s = 0;
92 if(cmdargc < 2) {
93 if(readline("Username: ", username, sizeof(username)) < 0)
94 return(-1);
95 user = username;
98 s = DOcommand("USER", user);
100 if(atty && s == 331) {
101 cmdargv[0] = "password";
102 cmdargc = 1;
103 return(DOpass());
106 if(s == 230)
107 loggedin = 1;
109 return(s);
112 int DOnoop()
114 if(DOcmdcheck())
115 return(0);
117 return(DOcommand("NOOP", ""));
120 int DOpassive()
122 passive = 1 - passive;
124 printf("Passive mode is now %s\n", (passive ? "ON" : "OFF"));
126 return(0);
129 int DOsyst()
131 if(DOcmdcheck())
132 return(0);
134 return(DOcommand("SYST", ""));
137 int DOremotehelp()
139 if(!linkopen) {
140 printf("You must \"OPEN\" a connection first.\n");
141 return(0);
144 return(DOcommand("HELP", ""));
147 static int docmdargs(cmd, fa)
148 char *cmd;
149 int fa;
151 int i;
152 static char args[512];
154 args[0] = '\0';
156 for(i = fa; i < cmdargc; i++) {
157 if(i != fa)
158 strcat(args, " ");
159 strcat(args, cmdargv[i]);
162 return(DOcommand(cmd, args));
165 int DOquote()
167 return(docmdargs(cmdargv[1], 2));
170 int DOsite()
172 return(docmdargs("SITE", 1));