Mercurial > mplayer.hg
annotate stream/stream_ftp.c @ 35490:a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
(It has been completely rewritten.)
Now call MediumPrepare() only once for all play events. Check for
current StreamType and clear stuff not being used for this stream
type (and only stuff that need to be cleared).
author | ib |
---|---|
date | Mon, 03 Dec 2012 16:26:39 +0000 |
parents | 14aeceb6c267 |
children | d206960484fe |
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" |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
36 #include "mp_msg.h" |
27473
ae5da477539e
Move '#define closesocket close' preprocessor directive to a common place
diego
parents:
27472
diff
changeset
|
37 #include "network.h" |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
38 #include "stream.h" |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
39 #include "help_mp.h" |
17012 | 40 #include "m_option.h" |
41 #include "m_struct.h" | |
19335
2a9d669e5ff6
isolated tcp socket code from network.c to a dedicated file
ben
parents:
19271
diff
changeset
|
42 #include "tcp.h" |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
43 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
44 static struct stream_priv_s { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
45 char* user; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
46 char* pass; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
47 char* host; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
48 int port; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
49 char* filename; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
50 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
51 char *cput,*cget; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
52 int handle; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
53 int cavail,cleft; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
54 char *buf; |
35339 | 55 char *cmd_buf; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
56 } stream_priv_dflts = { |
35397 | 57 .user = "anonymous", |
58 .pass = "no@spam", | |
59 .port = 21, | |
60 .handle = -1, | |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
61 }; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
62 |
35340 | 63 #define CMD_BUFSIZE 8192 |
35339 | 64 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
65 #define BUFSIZE 2048 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
66 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
67 #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
|
68 /// URL definition |
25242 | 69 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
|
70 {"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
|
71 {"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
|
72 {"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
|
73 {"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
|
74 {"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
|
75 { NULL, NULL, 0, 0, 0, 0, NULL } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
76 }; |
25691 | 77 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
|
78 "ftp", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
79 sizeof(struct stream_priv_s), |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
80 &stream_priv_dflts, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
81 stream_opts_fields |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
82 }; |
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 #define TELNET_IAC 255 /* interpret as command: */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
85 #define TELNET_IP 244 /* interrupt process--permanently */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
86 #define TELNET_SYNCH 242 /* for telfunc calls */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
87 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
88 // 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
|
89 // forever if the network stop responding. |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
90 static int fd_can_read(int fd,int timeout) { |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
91 fd_set fds; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
92 struct timeval tv; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
93 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
94 FD_ZERO(&fds); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
95 FD_SET(fd,&fds); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
96 tv.tv_sec = timeout; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
97 tv.tv_usec = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
98 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25691
diff
changeset
|
99 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
|
100 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
101 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
102 /* |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
103 * read a line of text |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
104 * |
35335
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
105 * 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
|
106 * 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
|
107 * 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
|
108 * line. |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
109 * |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
110 * 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
|
111 * 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
|
112 * |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
113 * return -1 on error or bytecount |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
114 */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
115 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
|
116 { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
117 int x,retval = 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
118 char *end,*bp=buf; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
119 int eof = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
120 |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
121 if (max <= 0) { |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
122 return -1; |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
123 } |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
124 *bp = '\0'; |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
125 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
126 do { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
127 if (ctl->cavail > 0) { |
35333 | 128 x = FFMIN(ctl->cavail, max-1); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
129 end = memccpy(bp,ctl->cget,'\n',x); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
130 if (end != NULL) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
131 x = end - bp; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
132 retval += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
133 bp += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
134 *bp = '\0'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
135 max -= x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
136 ctl->cget += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
137 ctl->cavail -= x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
138 if (end != NULL) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
139 bp -= 2; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
140 if (strcmp(bp,"\r\n") == 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
141 *bp++ = '\n'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
142 *bp++ = '\0'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
143 --retval; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
144 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
145 break; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
146 } |
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 if (max == 1) { |
35335
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
149 char *q = memchr(ctl->cget, '\n', ctl->cavail); |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
150 |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
151 if (q) { // found EOL: update state and return |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
152 ++q; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
153 ctl->cavail -= q - ctl->cget; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
154 ctl->cget = q; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
155 |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
156 break; |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
157 } |
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 // receive more data to find end of current line |
85003f7fa621
stream ftp: readline: Always try to read complete lines
al
parents:
35334
diff
changeset
|
160 ctl->cget = ctl->cput; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
161 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
162 if (ctl->cput == ctl->cget) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
163 ctl->cput = ctl->cget = ctl->buf; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
164 ctl->cavail = 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
165 ctl->cleft = BUFSIZE; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
166 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
167 if(eof) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
168 if (retval == 0) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
169 retval = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
170 break; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
171 } |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
172 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
173 if(!fd_can_read(ctl->handle, 15)) { |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
174 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
|
175 retval = -1; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
176 break; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
177 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
178 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
179 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
|
180 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
|
181 retval = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
182 break; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
183 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
184 if (x == 0) |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
185 eof = 1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
186 ctl->cleft -= x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
187 ctl->cavail += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
188 ctl->cput += x; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
189 } while (1); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
190 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
191 return retval; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
192 } |
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 * read a response from the server |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
196 * |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
197 * 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
|
198 * return 1 if first char matches |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
199 */ |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
200 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
|
201 { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
202 static char response[256]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
203 char match[5]; |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
204 int r, len; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
205 |
35334
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
206 len = readline(response,256,ctl); |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
207 if (rsp) strcpy(rsp,response); |
3397976a029b
stream ftp: readline: Always initialize output parameter buf
al
parents:
35333
diff
changeset
|
208 if (len == -1) |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
209 return 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
210 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
211 r = atoi(response)/100; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
212 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
213 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
|
214 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
215 if (response[3] == '-') { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
216 strncpy(match,response,3); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
217 match[3] = ' '; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
218 match[4] = '\0'; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
219 do { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
220 if (readline(response,256,ctl) == -1) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
221 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
|
222 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
223 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
224 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
|
225 } while (strncmp(response,match,4)); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
226 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
227 return r; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
228 } |
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 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
|
232 { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
233 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
|
234 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
|
235 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
236 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
|
237 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
|
238 while(l > 0) { |
31500 | 239 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
|
240 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
241 if(s <= 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
242 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
|
243 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
244 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
245 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
246 cmd += s; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
247 l -= s; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
248 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
249 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
250 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
|
251 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
|
252 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
|
253 return FtpSendCmd("\r\n", nControl, rsp); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
254 } |
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 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
|
257 int resp,fd; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
258 char rsp_txt[256]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
259 char* par,str[128]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
260 int num[6]; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
261 |
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
|
262 resp = FtpSendCmd("PASV",p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
263 if(resp != 2) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
264 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
|
265 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
266 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
267 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
268 par = strchr(rsp_txt,'('); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
269 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
270 if(!par || !par[0] || !par[1]) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
271 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
|
272 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
273 } |
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 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
|
276 &num[3],&num[4],&num[5]); |
35394 | 277 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
|
278 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
|
279 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
280 if(fd < 0) |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
281 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
|
282 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
283 return fd; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
284 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
285 |
30376
3365a4658320
Fix ftp support to properly support large files > 2GB.
reimar
parents:
29263
diff
changeset
|
286 static int FtpOpenData(stream_t* s,off_t newpos) { |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
287 struct stream_priv_s* p = s->priv; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
288 int resp; |
35339 | 289 char rsp_txt[256]; |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
290 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
291 // Open a new connection |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
292 s->fd = FtpOpenPort(p); |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
293 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
294 if(s->fd < 0) return 0; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
295 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
296 if(newpos > 0) { |
35394 | 297 snprintf(p->cmd_buf,CMD_BUFSIZE,"REST %"PRId64, (int64_t)newpos); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
298 |
35339 | 299 resp = FtpSendCmd(p->cmd_buf,p,rsp_txt); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
300 if(resp != 3) { |
35339 | 301 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
|
302 newpos = 0; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
303 } |
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 // Get the file |
35394 | 307 snprintf(p->cmd_buf,CMD_BUFSIZE,"RETR %s",p->filename); |
35339 | 308 resp = FtpSendCmd(p->cmd_buf,p,rsp_txt); |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
309 |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
310 if(resp != 1) { |
35339 | 311 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
|
312 return 0; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
313 } |
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 s->pos = newpos; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
316 return 1; |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
317 } |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
318 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
319 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
|
320 int r; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
321 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
322 if(s->fd < 0 && !FtpOpenData(s,s->pos)) |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
323 return -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
324 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
325 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
|
326 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
|
327 return -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
328 } |
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 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
|
331 return (r <= 0) ? -1 : r; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
332 } |
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 static int seek(stream_t *s,off_t newpos) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
335 struct stream_priv_s* p = s->priv; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
336 int resp; |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
337 char rsp_txt[256]; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
338 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
339 if(s->pos > s->end_pos) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
340 s->eof=1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
341 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
342 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
343 |
23873 | 344 // 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
|
345 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
|
346 if(readresp(p,rsp_txt) != 2) |
23873 | 347 mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] Warning the server didn't finished the transfer correctly: %s\n",rsp_txt); |
10627 | 348 closesocket(s->fd); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
349 s->fd = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
350 } |
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 // Close current download |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
353 if(s->fd >= 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
354 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
|
355 //int fl; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
356 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
357 // First close the fd |
10627 | 358 closesocket(s->fd); |
35336 | 359 s->fd = -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
360 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
361 // Send send the telnet sequence needed to make the server react |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
362 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
363 // 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
|
364 // 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
|
365 //fl=fcntl(p->handle,F_GETFL); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
366 //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
|
367 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
368 // send only first byte as OOB due to OOB braindamage in many unices |
31500 | 369 send(p->handle,pre_cmd,1,MSG_OOB|DEFAULT_SEND_FLAGS); |
370 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
|
371 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
372 //fcntl(p->handle,F_SETFL,fl); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
373 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
374 // Get the 426 Transfer aborted |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
375 // Or the 226 Transfer complete |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
376 resp = readresp(p,rsp_txt); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
377 if(resp != 4 && resp != 2) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
378 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
|
379 s->eof = 1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
380 return 0; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
381 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
382 // Send the ABOR command |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
383 // 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
|
384 FtpSendCmd("ABOR",p,rsp_txt); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
385 } |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
386 return FtpOpenData(s,newpos); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
387 } |
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 static void close_f(stream_t *s) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
391 struct stream_priv_s* p = s->priv; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
392 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
393 if(!p) return; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
394 |
35336 | 395 if(s->fd >= 0) { |
10627 | 396 closesocket(s->fd); |
35336 | 397 s->fd = -1; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
398 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
399 |
35337 | 400 if (p->handle >= 0) { |
401 FtpSendCmd("QUIT", p, NULL); | |
402 closesocket(p->handle); | |
403 } | |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
404 |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
31500
diff
changeset
|
405 free(p->buf); |
35339 | 406 free(p->cmd_buf); |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
407 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
408 m_struct_free(&stream_opts,p); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
409 } |
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 |
35395 | 413 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
|
414 int resp; |
3365a4658320
Fix ftp support to properly support large files > 2GB.
reimar
parents:
29263
diff
changeset
|
415 int64_t len = 0; |
35398 | 416 struct stream_priv_s* p = opts; |
35339 | 417 char rsp_txt[256]; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
418 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
419 if(mode != STREAM_READ) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
420 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
|
421 m_struct_free(&stream_opts,opts); |
24257 | 422 return STREAM_UNSUPPORTED; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
423 } |
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 if(!p->filename || !p->host) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
426 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
|
427 m_struct_free(&stream_opts,opts); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
428 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
429 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
430 |
35338
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
431 // Allocate buffers |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
432 p->buf = malloc(BUFSIZE); |
35339 | 433 p->cmd_buf = malloc(CMD_BUFSIZE); |
35338
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
434 |
35339 | 435 if (!p->buf || !p->cmd_buf) { |
35338
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
436 close_f(stream); |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
437 m_struct_free(&stream_opts,opts); |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
438 return STREAM_ERROR; |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
439 } |
4fe8922d6242
stream ftp: Create buffers before opening control connection
al
parents:
35337
diff
changeset
|
440 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
441 // Open the control connection |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
442 p->handle = connect2Server(p->host,p->port,1); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
443 |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
444 if(p->handle < 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
445 m_struct_free(&stream_opts,opts); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
446 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
447 } |
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 // 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
|
450 stream->fd = -1; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
451 stream->priv = p; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
452 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
453 if (readresp(p, NULL) == 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
454 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
455 m_struct_free(&stream_opts,opts); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
456 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
457 } |
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 // Login |
35394 | 460 snprintf(p->cmd_buf,CMD_BUFSIZE,"USER %s",p->user); |
35339 | 461 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
|
462 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
463 // password needed |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
464 if(resp == 3) { |
35394 | 465 snprintf(p->cmd_buf,CMD_BUFSIZE,"PASS %s",p->pass); |
35339 | 466 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
|
467 if(resp != 2) { |
35339 | 468 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
|
469 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
470 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
471 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
472 } else if(resp != 2) { |
35339 | 473 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
|
474 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
475 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
476 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
477 |
23873 | 478 // 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
|
479 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
|
480 if(resp != 2) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
481 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
|
482 close_f(stream); |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
483 return STREAM_ERROR; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
484 } |
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 // Get the filesize |
35394 | 487 snprintf(p->cmd_buf,CMD_BUFSIZE,"SIZE %s",p->filename); |
35339 | 488 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
|
489 if(resp != 2) { |
35339 | 490 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
|
491 } else { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
492 int dummy; |
30376
3365a4658320
Fix ftp support to properly support large files > 2GB.
reimar
parents:
29263
diff
changeset
|
493 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
|
494 } |
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 if(len > 0) { |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
497 stream->seek = seek; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
498 stream->end_pos = len; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
499 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
500 |
17854
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
501 // 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
|
502 // 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
|
503 // 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
|
504 // preventing correct abort with many servers. |
a63fa57ecbd7
Fix seeking with cache enabled on systems using fork().
albeu
parents:
17012
diff
changeset
|
505 stream->fd = -1; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
506 stream->priv = p; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
507 stream->fill_buffer = fill_buffer; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
508 stream->close = close_f; |
35396 | 509 stream->type = STREAMTYPE_STREAM; |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
510 |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
511 return STREAM_OK; |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
512 } |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
513 |
25211 | 514 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
|
515 "File Transfer Protocol", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
516 "ftp", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
517 "Albeu", |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
518 "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
|
519 open_f, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
520 { "ftp", NULL }, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
521 &stream_opts, |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
522 1 // Urls are an option string |
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
diff
changeset
|
523 }; |