11#include <netinet/in.h>
23 buf[
sizeof (buf) - 1] =
'\0';
24 n =
recv_line (soc, buf,
sizeof (buf) - 1);
28 if (strncmp (buf,
"220", 3) != 0)
34 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
36 n =
recv_line (soc, buf,
sizeof (buf) - 1);
46 snprintf (buf,
sizeof (buf),
"USER %s\r\n", username);
48 n =
recv_line (soc, buf,
sizeof (buf) - 1);
51 if (strncmp (buf,
"230", 3) == 0)
54 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
56 n =
recv_line (soc, buf,
sizeof (buf) - 1);
62 if (strncmp (buf,
"331", 3) != 0)
69 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
71 n =
recv_line (soc, buf,
sizeof (buf) - 1);
78 snprintf (buf,
sizeof (buf),
"PASS %s\r\n", passwd);
80 n =
recv_line (soc, buf,
sizeof (buf) - 1);
84 if (strncmp (buf,
"230", 3) != 0)
91 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
93 n =
recv_line (soc, buf,
sizeof (buf) - 1);
109 snprintf (buf, 7,
"PASV\r\n");
111 bzero (buf,
sizeof (buf));
112 bzero (addr,
sizeof (
struct sockaddr_in));
113 if (
recv_line (soc, buf,
sizeof (buf) - 1) < 0)
116 if (strncmp (buf,
"227", 3) != 0)
119 t = strchr (buf,
'(');
129 l[0] = (
unsigned char) atoi (t);
135 l[1] = (
unsigned char) atoi (s);
141 l[2] = (
unsigned char) atoi (t);
147 l[3] = (
unsigned char) atoi (s);
153 l[4] = (
unsigned char) atoi (t);
159 l[5] = (
unsigned char) atoi (s);
161 p = (
unsigned short *) (l + 4);
163 addr->sin_addr.s_addr = *a;
165 addr->sin_family = AF_INET;
int ftp_get_pasv_address(int soc, struct sockaddr_in *addr)
int ftp_log_in(int soc, char *username, char *passwd)
Header file for module ftp_funcs.
int write_stream_connection(int fd, void *buf0, int n)
int recv_line(int soc, char *buf, size_t bufsiz)
Reads a text from the socket stream into the argument buffer, always.
Header file for module network.