Mercurial > mplayer.hg
annotate stream/stream_ftp.c @ 36702:fb14d0cfc36d
Use native names of languages instead of English ones.
(This is a compromise between localization and the effort to translate
every language name into every language we are supporting.)
It should easily allow anyone who understands a certain language to find
the corresponding menu entry.
Additionally, remove languages (almost) ceased to be a living language,
remove collective language codes and arrange all language codes
alphabetically.
author | ib |
---|---|
date | Fri, 07 Feb 2014 18:17:05 +0000 |
parents | 3389262720da |
children |
rev | line source |
---|---|
30426
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
1 /* |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
2 * This file is part of MPlayer. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
3 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
7 * (at your option) any later version. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
8 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
12 * GNU General Public License for more details. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
13 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30376
diff
changeset
|
17 */ |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
18 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
19 #include "config.h" |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
20 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
21 #include <stdlib.h> |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
22 #include <stdio.h> |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
23 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
24 #include <sys/types.h> |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
25 #include <sys/stat.h> |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
26 #include <fcntl.h> |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
27 #include <unistd.h> |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
28 #include <errno.h> |
28402 | 29 #if !HAVE_WINSOCK2_H |
27472
c0b233cd30ca
Revert moving closesocket definition and network headers to network.h.
diego
parents:
27464
diff
changeset
|
30 #include <sys/socket.h> |
c0b233cd30ca
Revert moving closesocket definition and network headers to network.h.
diego
parents:
27464
diff
changeset
|
31 #else |
c0b233cd30ca
Revert moving closesocket definition and network headers to network.h.
diego
parents:
27464
diff
changeset
|
32 #include <winsock2.h> |
c0b233cd30ca
Revert moving closesocket definition and network headers to network.h.
diego
parents:
27464
diff
changeset
|
33 #endif |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
34 |
35333 | 35 #include "libavutil/avutil.h" |
35712
d206960484fe
Add a number of missing libavutil header #includes.
diego
parents:
35398
diff
changeset
|
36 #include "libavutil/common.h" |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
37 #include "mp_msg.h" |
27473
ae5da477539e
Move '#define closesocket close' preprocessor directive to a common place
diego
parents:
27472
diff
changeset
|
38 #include "network.h" |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
39 #include "stream.h" |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
40 #include "help_mp.h" |
17012 | 41 #include "m_option.h" |
42 #include "m_struct.h" | |
19335
2a9d669e5ff6
isolated tcp socket code from network.c to a dedicated file
ben
parents:
19271
diff
changeset
|
43 #include "tcp.h" |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
44 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
45 static struct stream_priv_s { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
46 char* user; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
47 char* pass; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
48 char* host; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
49 int port; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
50 char* filename; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
51 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
52 char *cput,*cget; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
53 int handle; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
54 int cavail,cleft; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
55 char *buf; |
35339 | 56 char *cmd_buf; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
57 } stream_priv_dflts = { |
35397 | 58 .user = "anonymous", |
59 .pass = "no@spam", | |
60 .port = 21, | |
61 .handle = -1, | |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
62 }; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
63 |
35340 | 64 #define CMD_BUFSIZE 8192 |
35339 | 65 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
66 #define BUFSIZE 2048 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
67 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
68 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
69 /// URL definition |
25242 | 70 static const m_option_t stream_opts_fields[] = { |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
71 {"username", ST_OFF(user), CONF_TYPE_STRING, 0, 0 ,0, NULL}, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
72 {"password", ST_OFF(pass), CONF_TYPE_STRING, 0, 0 ,0, NULL}, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
73 {"hostname", ST_OFF(host), CONF_TYPE_STRING, 0, 0 ,0, NULL}, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
74 {"port", ST_OFF(port), CONF_TYPE_INT, 0, 0 ,65635, NULL}, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
75 {"filename", ST_OFF(filename), CONF_TYPE_STRING, 0, 0 ,0, NULL}, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
76 { NULL, NULL, 0, 0, 0, 0, NULL } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
77 }; |
25691 | 78 static const struct m_struct_st stream_opts = { |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
79 "ftp", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
80 sizeof(struct stream_priv_s), |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
81 &stream_priv_dflts, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
82 stream_opts_fields |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
83 }; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
84 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
85 #define TELNET_IAC 255 /* interpret as command: */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
86 #define TELNET_IP 244 /* interrupt process--permanently */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
87 #define TELNET_SYNCH 242 /* for telfunc calls */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
88 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
89 // Check if there is something to read on a fd. This avoid hanging |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
90 // forever if the network stop responding. |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
91 static int fd_can_read(int fd,int timeout) { |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
92 fd_set fds; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
93 struct timeval tv; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
94 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
95 FD_ZERO(&fds); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
96 FD_SET(fd,&fds); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
97 tv.tv_sec = timeout; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
98 tv.tv_usec = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
99 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25691
diff
changeset
|
100 return select(fd+1, &fds, NULL, NULL, &tv) > 0; |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
101 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
102 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
103 /* |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
104 * read a line of text |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
105 * |
35335
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
106 * If the line is too long to fit in the buffer, provided via parameters |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
107 * buf and max, the remaining characters are skipped. So the next call to |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
108 * this function is synchronized to the start of the following response |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
109 * line. |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
110 * |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
111 * The parameter buf will always be initialized as long as max is bigger |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
112 * then 1. If nothing is read it will contain an empty string. |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
113 * |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
114 * return -1 on error or bytecount |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
115 */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
116 static int readline(char *buf,int max,struct stream_priv_s *ctl) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
117 { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
118 int x,retval = 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
119 char *end,*bp=buf; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
120 int eof = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
121 |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
122 if (max <= 0) { |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
123 return -1; |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
124 } |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
125 *bp = '\0'; |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
126 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
127 do { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
128 if (ctl->cavail > 0) { |
35333 | 129 x = FFMIN(ctl->cavail, max-1); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
130 end = memccpy(bp,ctl->cget,'\n',x); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
131 if (end != NULL) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
132 x = end - bp; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
133 retval += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
134 bp += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
135 *bp = '\0'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
136 max -= x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
137 ctl->cget += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
138 ctl->cavail -= x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
139 if (end != NULL) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
140 bp -= 2; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
141 if (strcmp(bp,"\r\n") == 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
142 *bp++ = '\n'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
143 *bp++ = '\0'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
144 --retval; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
145 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
146 break; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
147 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
148 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
149 if (max == 1) { |
35335
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
150 char *q = memchr(ctl->cget, '\n', ctl->cavail); |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
151 |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
152 if (q) { // found EOL: update state and return |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
153 ++q; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
154 ctl->cavail -= q - ctl->cget; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
155 ctl->cget = q; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
156 |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
157 break; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
158 } |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
159 |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
160 // receive more data to find end of current line |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
161 ctl->cget = ctl->cput; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
162 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
163 if (ctl->cput == ctl->cget) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
164 ctl->cput = ctl->cget = ctl->buf; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
165 ctl->cavail = 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
166 ctl->cleft = BUFSIZE; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
167 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
168 if(eof) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
169 if (retval == 0) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
170 retval = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
171 break; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
172 } |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
173 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
174 if(!fd_can_read(ctl->handle, 15)) { |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
175 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] read timed out\n"); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
176 retval = -1; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
177 break; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
178 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
179 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
180 if ((x = recv(ctl->handle,ctl->cput,ctl->cleft,0)) == -1) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
181 mp_msg(MSGT_STREAM,MSGL_ERR, "[ftp] read error: %s\n",strerror(errno)); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
182 retval = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
183 break; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
184 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
185 if (x == 0) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
186 eof = 1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
187 ctl->cleft -= x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
188 ctl->cavail += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
189 ctl->cput += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
190 } while (1); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
191 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
192 return retval; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
193 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
194 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
195 /* |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
196 * read a response from the server |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
197 * |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
198 * return 0 if first char doesn't match |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
199 * return 1 if first char matches |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
200 */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
201 static int readresp(struct stream_priv_s* ctl,char* rsp) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
202 { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
203 static char response[256]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
204 char match[5]; |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
205 int r, len; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
206 |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
207 len = readline(response,256,ctl); |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
208 if (rsp) strcpy(rsp,response); |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
209 if (len == -1) |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
210 return 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
211 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
212 r = atoi(response)/100; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
213 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
214 mp_msg(MSGT_STREAM,MSGL_V, "[ftp] < %s",response); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
215 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
216 if (response[3] == '-') { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
217 strncpy(match,response,3); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
218 match[3] = ' '; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
219 match[4] = '\0'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
220 do { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
221 if (readline(response,256,ctl) == -1) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
222 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] Control socket read failed\n"); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
223 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
224 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
225 mp_msg(MSGT_OPEN,MSGL_V, "[ftp] < %s",response); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
226 } while (strncmp(response,match,4)); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
227 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
228 return r; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
229 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
230 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
231 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
232 static int FtpSendCmd(const char *cmd, struct stream_priv_s *nControl,char* rsp) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
233 { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
234 int l = strlen(cmd); |
16761
1eeb10c3e534
Make FtpSendCmd() function more user friendly by making it append the necessary "\r\n" line break (instead of the caller)
gpoirier
parents:
16750
diff
changeset
|
235 int hascrlf = cmd[l - 2] == '\r' && cmd[l - 1] == '\n'; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
236 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
237 if(hascrlf && l == 2) mp_msg(MSGT_STREAM,MSGL_V, "\n"); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
238 else mp_msg(MSGT_STREAM,MSGL_V, "[ftp] > %s",cmd); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
239 while(l > 0) { |
31500 | 240 int s = send(nControl->handle,cmd,l,DEFAULT_SEND_FLAGS); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
241 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
242 if(s <= 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
243 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] write error: %s\n",strerror(errno)); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
244 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
245 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
246 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
247 cmd += s; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
248 l -= s; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
249 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
250 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
251 if (hascrlf) |
16761
1eeb10c3e534
Make FtpSendCmd() function more user friendly by making it append the necessary "\r\n" line break (instead of the caller)
gpoirier
parents:
16750
diff
changeset
|
252 return readresp(nControl,rsp); |
1eeb10c3e534
Make FtpSendCmd() function more user friendly by making it append the necessary "\r\n" line break (instead of the caller)
gpoirier
parents:
16750
diff
changeset
|
253 else |
1eeb10c3e534
Make FtpSendCmd() function more user friendly by making it append the necessary "\r\n" line break (instead of the caller)
gpoirier
parents:
16750
diff
changeset
|
254 return FtpSendCmd("\r\n", nControl, rsp); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
255 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
256 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
257 static int FtpOpenPort(struct stream_priv_s* p) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
258 int resp,fd; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
259 char rsp_txt[256]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
260 char* par,str[128]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
261 int num[6]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
262 |
16761
1eeb10c3e534
Make FtpSendCmd() function more user friendly by making it append the necessary "\r\n" line break (instead of the caller)
gpoirier
parents:
16750
diff
changeset
|
263 resp = FtpSendCmd("PASV",p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
264 if(resp != 2) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
265 mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] command 'PASV' failed: %s\n",rsp_txt); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
266 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
267 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
268 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
269 par = strchr(rsp_txt,'('); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
270 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
271 if(!par || !par[0] || !par[1]) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
272 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] invalid server response: %s ??\n",rsp_txt); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
273 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
274 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
275 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
276 sscanf(par+1,"%u,%u,%u,%u,%u,%u",&num[0],&num[1],&num[2], |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
277 &num[3],&num[4],&num[5]); |
35394 | 278 snprintf(str,sizeof(str),"%d.%d.%d.%d",num[0],num[1],num[2],num[3]); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
279 fd = connect2Server(str,(num[4]<<8)+num[5],0); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
280 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
281 if(fd < 0) |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
282 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] failed to create data connection\n"); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
283 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
284 return fd; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
285 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
286 |
35885
3389262720da
Fix previous commit, off_t must be replaced by int64_t
reimar
parents:
35881
diff
changeset
|
287 static int FtpOpenData(stream_t* s, int64_t newpos) { |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
288 struct stream_priv_s* p = s->priv; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
289 int resp; |
35339 | 290 char rsp_txt[256]; |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
291 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
292 // Open a new connection |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
293 s->fd = FtpOpenPort(p); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
294 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
295 if(s->fd < 0) return 0; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
296 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
297 if(newpos > 0) { |
35881 | 298 snprintf(p->cmd_buf,CMD_BUFSIZE,"REST %"PRIu64, newpos); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
299 |
35339 | 300 resp = FtpSendCmd(p->cmd_buf,p,rsp_txt); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
301 if(resp != 3) { |
35339 | 302 mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] command '%s' failed: %s\n",p->cmd_buf,rsp_txt); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
303 newpos = 0; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
304 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
305 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
306 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
307 // Get the file |
35394 | 308 snprintf(p->cmd_buf,CMD_BUFSIZE,"RETR %s",p->filename); |
35339 | 309 resp = FtpSendCmd(p->cmd_buf,p,rsp_txt); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
310 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
311 if(resp != 1) { |
35339 | 312 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] command '%s' failed: %s\n",p->cmd_buf,rsp_txt); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
313 return 0; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
314 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
315 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
316 s->pos = newpos; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
317 return 1; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
318 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
319 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
320 static int fill_buffer(stream_t *s, char* buffer, int max_len){ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
321 int r; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
322 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
323 if(s->fd < 0 && !FtpOpenData(s,s->pos)) |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
324 return -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
325 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
326 if(!fd_can_read(s->fd, 15)) { |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
327 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] read timed out\n"); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
328 return -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
329 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
330 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
331 r = recv(s->fd,buffer,max_len,0); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
332 return (r <= 0) ? -1 : r; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
333 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
334 |
35885
3389262720da
Fix previous commit, off_t must be replaced by int64_t
reimar
parents:
35881
diff
changeset
|
335 static int seek(stream_t *s, int64_t newpos) { |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
336 struct stream_priv_s* p = s->priv; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
337 int resp; |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
338 char rsp_txt[256]; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
339 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
340 if(s->pos > s->end_pos) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
341 s->eof=1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
342 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
343 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
344 |
23873 | 345 // Check to see if the server did not already terminate the transfer |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
346 if(fd_can_read(p->handle, 0)) { |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
347 if(readresp(p,rsp_txt) != 2) |
23873 | 348 mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] Warning the server didn't finished the transfer correctly: %s\n",rsp_txt); |
10627 | 349 closesocket(s->fd); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
350 s->fd = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
351 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
352 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
353 // Close current download |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
354 if(s->fd >= 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
355 static const char pre_cmd[]={TELNET_IAC,TELNET_IP,TELNET_IAC,TELNET_SYNCH}; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
356 //int fl; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
357 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
358 // First close the fd |
10627 | 359 closesocket(s->fd); |
35336 | 360 s->fd = -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
361 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
362 // Send send the telnet sequence needed to make the server react |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
363 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
364 // Dunno if this is really needed, lftp have it. I let |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
365 // it here in case it turn out to be needed on some other OS |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
366 //fl=fcntl(p->handle,F_GETFL); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
367 //fcntl(p->handle,F_SETFL,fl&~O_NONBLOCK); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
368 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
369 // send only first byte as OOB due to OOB braindamage in many unices |
31500 | 370 send(p->handle,pre_cmd,1,MSG_OOB|DEFAULT_SEND_FLAGS); |
371 send(p->handle,pre_cmd+1,sizeof(pre_cmd)-1,DEFAULT_SEND_FLAGS); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
372 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
373 //fcntl(p->handle,F_SETFL,fl); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
374 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
375 // Get the 426 Transfer aborted |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
376 // Or the 226 Transfer complete |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
377 resp = readresp(p,rsp_txt); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
378 if(resp != 4 && resp != 2) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
379 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] Server didn't abort correctly: %s\n",rsp_txt); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
380 s->eof = 1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
381 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
382 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
383 // Send the ABOR command |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
384 // Ignore the return code as sometimes it fail with "nothing to abort" |
16761
1eeb10c3e534
Make FtpSendCmd() function more user friendly by making it append the necessary "\r\n" line break (instead of the caller)
gpoirier
parents:
16750
diff
changeset
|
385 FtpSendCmd("ABOR",p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
386 } |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
387 return FtpOpenData(s,newpos); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
388 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
389 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
390 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
391 static void close_f(stream_t *s) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
392 struct stream_priv_s* p = s->priv; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
393 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
394 if(!p) return; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
395 |
35336 | 396 if(s->fd >= 0) { |
10627 | 397 closesocket(s->fd); |
35336 | 398 s->fd = -1; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
399 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
400 |
35337 | 401 if (p->handle >= 0) { |
402 FtpSendCmd("QUIT", p, NULL); | |
403 closesocket(p->handle); | |
404 } | |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
405 |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31500
diff
changeset
|
406 free(p->buf); |
35339 | 407 free(p->cmd_buf); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
408 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
409 m_struct_free(&stream_opts,p); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
410 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
411 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
412 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
413 |
35395 | 414 static int open_f(stream_t *stream,int mode, void* opts, av_unused int* file_format) { |
30376
3365a4658320
Fix ftp support to properly support large files > 2GB.
reimar
parents:
29263
diff
changeset
|
415 int resp; |
3365a4658320
Fix ftp support to properly support large files > 2GB.
reimar
parents:
29263
diff
changeset
|
416 int64_t len = 0; |
35398 | 417 struct stream_priv_s* p = opts; |
35339 | 418 char rsp_txt[256]; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
419 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
420 if(mode != STREAM_READ) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
421 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] Unknown open mode %d\n",mode); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
422 m_struct_free(&stream_opts,opts); |
24257 | 423 return STREAM_UNSUPPORTED; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
424 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
425 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
426 if(!p->filename || !p->host) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
427 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] Bad url\n"); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
428 m_struct_free(&stream_opts,opts); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
429 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
430 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
431 |
35338
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
432 // Allocate buffers |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
433 p->buf = malloc(BUFSIZE); |
35339 | 434 p->cmd_buf = malloc(CMD_BUFSIZE); |
35338
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
435 |
35339 | 436 if (!p->buf || !p->cmd_buf) { |
35338
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
437 close_f(stream); |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
438 m_struct_free(&stream_opts,opts); |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
439 return STREAM_ERROR; |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
440 } |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
441 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
442 // Open the control connection |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
443 p->handle = connect2Server(p->host,p->port,1); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
444 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
445 if(p->handle < 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
446 m_struct_free(&stream_opts,opts); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
447 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
448 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
449 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
450 // We got a connection, let's start serious things |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
451 stream->fd = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
452 stream->priv = p; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
453 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
454 if (readresp(p, NULL) == 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
455 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
456 m_struct_free(&stream_opts,opts); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
457 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
458 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
459 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
460 // Login |
35394 | 461 snprintf(p->cmd_buf,CMD_BUFSIZE,"USER %s",p->user); |
35339 | 462 resp = FtpSendCmd(p->cmd_buf,p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
463 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
464 // password needed |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
465 if(resp == 3) { |
35394 | 466 snprintf(p->cmd_buf,CMD_BUFSIZE,"PASS %s",p->pass); |
35339 | 467 resp = FtpSendCmd(p->cmd_buf,p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
468 if(resp != 2) { |
35339 | 469 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] command '%s' failed: %s\n",p->cmd_buf,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
470 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
471 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
472 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
473 } else if(resp != 2) { |
35339 | 474 mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] command '%s' failed: %s\n",p->cmd_buf,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
475 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
476 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
477 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
478 |
23873 | 479 // Set the transfer type |
16761
1eeb10c3e534
Make FtpSendCmd() function more user friendly by making it append the necessary "\r\n" line break (instead of the caller)
gpoirier
parents:
16750
diff
changeset
|
480 resp = FtpSendCmd("TYPE I",p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
481 if(resp != 2) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
482 mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] command 'TYPE I' failed: %s\n",rsp_txt); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
483 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
484 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
485 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
486 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
487 // Get the filesize |
35394 | 488 snprintf(p->cmd_buf,CMD_BUFSIZE,"SIZE %s",p->filename); |
35339 | 489 resp = FtpSendCmd(p->cmd_buf,p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
490 if(resp != 2) { |
35339 | 491 mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] command '%s' failed: %s\n",p->cmd_buf,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
492 } else { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
493 int dummy; |
30376
3365a4658320
Fix ftp support to properly support large files > 2GB.
reimar
parents:
29263
diff
changeset
|
494 sscanf(rsp_txt,"%d %"SCNd64,&dummy,&len); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
495 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
496 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
497 if(len > 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
498 stream->seek = seek; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
499 stream->end_pos = len; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
500 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
501 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
502 // The data connection is really opened only at the first |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
503 // read/seek. This must be done when the cache is used |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
504 // because the connection would stay open in the main process, |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
505 // preventing correct abort with many servers. |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
506 stream->fd = -1; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
507 stream->priv = p; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
508 stream->fill_buffer = fill_buffer; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
509 stream->close = close_f; |
35396 | 510 stream->type = STREAMTYPE_STREAM; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
511 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
512 return STREAM_OK; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
513 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
514 |
25211 | 515 const stream_info_t stream_info_ftp = { |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
516 "File Transfer Protocol", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
517 "ftp", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
518 "Albeu", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
519 "reuse a bit of code from ftplib written by Thomas Pfau", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
520 open_f, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
521 { "ftp", NULL }, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
522 &stream_opts, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
523 1 // Urls are an option string |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
524 }; |