Mercurial > audlegacy-plugins
annotate src/curl/curl.c @ 708:9684a1b4e494 trunk
[svn] - close configdb handle
author | nenolod |
---|---|
date | Sat, 24 Feb 2007 08:58:32 -0800 |
parents | 88d78a61a9fb |
children | e758e9d4f861 |
rev | line source |
---|---|
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
1 /* Audacious |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
2 * Copyright (c) 2007 Daniel Barkalow |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
3 * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
7 * (at your option) any later version. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
8 * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
13 * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
15 * along with this program; if not, write to the Free Software |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
17 */ |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
18 |
556
cd730d42b2bd
[svn] - User-Agent: Audacious/$version (curl transport)
nenolod
parents:
543
diff
changeset
|
19 #ifdef HAVE_CONFIG_H |
cd730d42b2bd
[svn] - User-Agent: Audacious/$version (curl transport)
nenolod
parents:
543
diff
changeset
|
20 # include "config.h" |
cd730d42b2bd
[svn] - User-Agent: Audacious/$version (curl transport)
nenolod
parents:
543
diff
changeset
|
21 #endif |
cd730d42b2bd
[svn] - User-Agent: Audacious/$version (curl transport)
nenolod
parents:
543
diff
changeset
|
22 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
23 #include <audacious/vfs.h> |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
24 #include <audacious/plugin.h> |
707 | 25 #include <audacious/configdb.h> |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
26 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
27 #include <curl/curl.h> |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
28 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
29 #include <string.h> |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
30 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
31 #define BUFFER_SIZE 256 * 1024 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
32 #define REVERSE_SEEK_SIZE 2048 |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
33 |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
34 #define DEBUG_CONNECTION 0 |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
35 #define DEBUG_OPEN_CLOSE 0 |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
36 #define DEBUG_SEEK 0 |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
37 #define DEBUG_READ 0 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
38 #define DEBUG_HEADERS 0 |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
39 #define DEBUG_ICY 0 |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
40 #define DEBUG_ICY_WRAP 0 |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
41 #define DEBUG_ICY_VERBOSE 0 |
485 | 42 #define DEBUG_METADATA_REPORT 0 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
43 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
44 typedef struct _CurlHandle CurlHandle; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
45 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
46 struct _CurlHandle { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
47 CURL *curl; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
48 |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
49 gssize length; // the length of the file |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
50 gsize rd_abs; // the absolute position for reading from the stream |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
51 gsize wr_abs; // the absolute position where the input connection is |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
52 |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
53 gsize icy_left; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
54 gsize icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
55 gint in_icy_meta; // 0=no, 1=before size, 2=in data |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
56 gsize meta_abs; // the absolute position where the metadata changes |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
57 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
58 gsize buffer_length; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
59 gchar *buffer; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
60 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
61 gsize rd_index; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
62 gsize wr_index; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
63 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
64 gsize hdr_index; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
65 |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
66 GSList *stream_stack; // stack for stream functions (getc, ungetc) |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
67 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
68 gboolean header; // true if we haven't finished the header yet |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
69 gboolean no_data; // true if we're only looking for length currently |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
70 gboolean cancel; // true if the thread should be cancelled |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
71 gboolean failed; // true if we've tried and failed already |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
72 GThread *thread; // the thread that's reading from the connection |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
73 |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
74 VFSFile *download; // file to write to as we download |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
75 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
76 gchar *name; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
77 gchar *title; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
78 }; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
79 |
483 | 80 VFSConstructor curl_const; |
81 | |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
82 /* TODO: |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
83 * - Fix hang if the server closes the connection in the middle |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
84 * - Clever buffer stuff when you read a bit of the beginning and a bit of the |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
85 * end of a file |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
86 */ |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
87 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
88 /* The goal here is to have a buffering system which handles the following: |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
89 * 1) open, seek, read (without fetching the beginning of the file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
90 * 2) open, seek END, tell (using HEAD only) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
91 * 3) open, read, seek 0, read (without restarting fetch) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
92 */ |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
93 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
94 static size_t buf_space(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
95 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
96 size_t rd_edge = handle->rd_abs - REVERSE_SEEK_SIZE; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
97 size_t buffer_limit; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
98 size_t cont_limit; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
99 if (rd_edge < 0) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
100 rd_edge = 0; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
101 buffer_limit = handle->buffer_length - |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
102 (handle->wr_abs - rd_edge); |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
103 cont_limit = handle->buffer_length - handle->wr_index; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
104 if (cont_limit < buffer_limit) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
105 buffer_limit = cont_limit; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
106 if (handle->icy_interval) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
107 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
108 if (handle->icy_left < buffer_limit) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
109 buffer_limit = handle->icy_left; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
110 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
111 return buffer_limit; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
112 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
113 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
114 static size_t buf_available(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
115 { |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
116 size_t buffer_limit; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
117 size_t cont_limit; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
118 if (handle->header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
119 return 0; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
120 buffer_limit = handle->wr_abs - handle->rd_abs; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
121 cont_limit = handle->buffer_length - handle->rd_index; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
122 if (buffer_limit <= 0) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
123 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
124 return buffer_limit < cont_limit ? buffer_limit : cont_limit; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
125 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
126 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
127 static void check(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
128 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
129 if (!((handle->wr_abs - handle->wr_index) % handle->buffer_length == |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
130 (handle->rd_abs - handle->rd_index) % handle->buffer_length)) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
131 printf("%p Not aligned! wr %d rd %d\n", handle, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
132 (handle->wr_abs - handle->wr_index) % handle->buffer_length, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
133 (handle->rd_abs - handle->rd_index) % handle->buffer_length); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
134 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
135 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
136 static void update_length(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
137 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
138 if (handle->length == -1) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
139 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
140 double value; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
141 int retcode = |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
142 curl_easy_getinfo(handle->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
143 &value); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
144 if (retcode == CURLE_OK) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
145 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
146 handle->length = value; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
147 if (handle->length == 0) |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
148 handle->length = -2; |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
149 //g_print("Length: %d\n", handle->length); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
150 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
151 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
152 { |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
153 handle->length = -2; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
154 g_print("getinfo gave error\n"); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
155 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
156 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
157 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
158 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
159 #define PROBE 262140 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
160 |
534 | 161 #define ICE_NAME "ice-name:" |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
162 #define ICY_NAME "icy-name:" |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
163 #define ICY_METAINT "icy-metaint:" |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
164 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
165 static gboolean match_header(CurlHandle *handle, size_t size, |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
166 const char *header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
167 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
168 if (strlen(header) > size) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
169 return FALSE; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
170 // XXXX wrapped headers |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
171 return !(strncmp(handle->buffer + handle->hdr_index, |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
172 header, strlen(header))); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
173 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
174 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
175 static gchar *get_value(CurlHandle *handle, size_t size, const char *header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
176 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
177 // XXXX wrapped headers |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
178 return strdup(handle->buffer + |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
179 (handle->hdr_index + strlen(header)) % handle->buffer_length); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
180 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
181 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
182 static void got_header(CurlHandle *handle, size_t size) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
183 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
184 if (DEBUG_HEADERS) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
185 g_print("Got header %d bytes\n", size); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
186 if (match_header(handle, size, ICY_NAME)) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
187 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
188 handle->name = get_value(handle, size, ICY_NAME); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
189 if (DEBUG_HEADERS) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
190 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
191 g_print("Stream name: %s\n", handle->name); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
192 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
193 } |
534 | 194 if (match_header(handle, size, ICE_NAME)) |
195 { | |
196 handle->name = get_value(handle, size, ICE_NAME); | |
197 if (DEBUG_HEADERS) | |
198 { | |
199 g_print("Stream name: %s\n", handle->name); | |
200 } | |
201 } | |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
202 if (match_header(handle, size, ICY_METAINT)) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
203 { |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
204 gchar *value = get_value(handle, size, ICY_METAINT); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
205 handle->icy_interval = atoi(value); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
206 free(value); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
207 if (DEBUG_HEADERS) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
208 g_print("Metadata interval: %d\n", handle->icy_interval); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
209 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
210 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
211 |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
212 #define TITLE_INLINE "StreamTitle=" |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
213 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
214 static gboolean match_inline(CurlHandle *handle, size_t posn, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
215 const char *name) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
216 { |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
217 size_t len = strlen(name); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
218 size_t i; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
219 if (DEBUG_ICY_WRAP) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
220 g_print("Posn=%d\n", posn); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
221 if (DEBUG_ICY_WRAP && posn + len > handle->buffer_length) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
222 g_print("Wrapped inline key\n"); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
223 if (((handle->wr_index - posn + handle->buffer_length) % |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
224 handle->buffer_length) <= len) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
225 return FALSE; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
226 for (i = 0; i < len; i++) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
227 if (handle->buffer[(posn + i) % handle->buffer_length] != name[i]) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
228 { |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
229 return FALSE; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
230 } |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
231 return TRUE; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
232 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
233 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
234 static gchar *get_inline_value(CurlHandle *handle, size_t posn, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
235 const char *name) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
236 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
237 size_t end; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
238 size_t sz; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
239 gchar *ret; |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
240 posn = (posn + strlen(name) + 1) % handle->buffer_length; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
241 end = posn; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
242 while (handle->buffer[end % handle->buffer_length] != ';') |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
243 end++; |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
244 sz = (end - posn + handle->buffer_length) % handle->buffer_length; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
245 ret = g_malloc(sz); |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
246 if (end % handle->buffer_length < posn % handle->buffer_length) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
247 { |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
248 size_t prewrap = handle->buffer_length - posn; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
249 memcpy(ret, handle->buffer + posn, prewrap); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
250 memcpy(ret + prewrap, handle->buffer, sz - prewrap); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
251 if (DEBUG_ICY_WRAP) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
252 g_print("Wrapped inline metadata value\n"); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
253 } |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
254 else |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
255 { |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
256 memcpy(ret, handle->buffer + posn, sz); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
257 } |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
258 ret[sz - 1] = '\0'; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
259 return ret; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
260 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
261 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
262 static void got_inline_metadata(CurlHandle *handle) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
263 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
264 size_t i = (handle->hdr_index + 1) % handle->buffer_length; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
265 if (match_inline(handle, i, TITLE_INLINE)) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
266 { |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
267 if (handle->title) |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
268 free(handle->title); |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
269 handle->title = get_inline_value(handle, i, TITLE_INLINE); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
270 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
271 g_print("Title: '%s'\n", handle->title); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
272 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
273 handle->meta_abs = handle->wr_abs; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
274 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
275 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
276 static size_t curl_writecb(void *ptr, size_t size, size_t nmemb, void *stream) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
277 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
278 CurlHandle *handle = stream; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
279 gint sz = size * nmemb; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
280 gint ret = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
281 gint trans; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
282 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
283 if (!handle->header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
284 update_length(handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
285 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
286 while (ret < sz) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
287 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
288 while (!(trans = buf_space(handle)) && !handle->cancel) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
289 { |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
290 //g_print("Wait for free space on %p\n", handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
291 g_usleep(10000); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
292 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
293 if (handle->cancel) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
294 break; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
295 if (trans > sz - ret) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
296 trans = sz - ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
297 memcpy(handle->buffer + handle->wr_index, ptr + ret, trans); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
298 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
299 if (!handle->header) |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
300 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
301 if (handle->icy_interval) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
302 handle->icy_left -= trans; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
303 if (!handle->in_icy_meta) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
304 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
305 handle->wr_abs += trans; |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
306 if (handle->download) |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
307 { |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
308 vfs_fwrite(ptr + ret, trans, 1, handle->download); |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
309 } |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
310 if (handle->icy_interval && !handle->icy_left) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
311 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
312 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
313 g_print("Metadata inline after %d\n", handle->wr_abs); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
314 handle->in_icy_meta = 1; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
315 handle->icy_left = 1; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
316 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
317 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
318 else if (handle->in_icy_meta == 1) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
319 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
320 // Track where the header insert starts |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
321 handle->hdr_index = handle->wr_index; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
322 handle->icy_left = |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
323 ((unsigned char)(handle->buffer[handle->wr_index])) * 16; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
324 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
325 g_print("Metadata of size %d\n", handle->icy_left); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
326 if (handle->icy_left) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
327 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
328 handle->in_icy_meta = 2; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
329 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
330 else |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
331 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
332 handle->in_icy_meta = 0; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
333 handle->icy_left = handle->icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
334 handle->wr_index--; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
335 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
336 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
337 else |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
338 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
339 if (!handle->icy_left) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
340 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
341 handle->wr_index = (handle->wr_index + trans) % |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
342 handle->buffer_length; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
343 if (DEBUG_ICY_VERBOSE) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
344 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
345 if (handle->wr_index < handle->hdr_index) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
346 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
347 // wrapped |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
348 fwrite(handle->buffer + handle->hdr_index + 1, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
349 handle->buffer_length - handle->hdr_index - 1, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
350 1, stdout); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
351 fwrite(handle->buffer, handle->wr_index, 1, stdout); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
352 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
353 else |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
354 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
355 fwrite(handle->buffer + handle->hdr_index, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
356 handle->wr_index - handle->hdr_index, 1, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
357 stdout); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
358 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
359 g_print("\n"); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
360 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
361 got_inline_metadata(handle); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
362 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
363 // Rewind the buffer usage to write over the |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
364 // metadata with content. -trans because we're about |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
365 // to add it. |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
366 handle->wr_index = handle->hdr_index - trans; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
367 handle->in_icy_meta = 0; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
368 handle->icy_left = handle->icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
369 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
370 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
371 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
372 handle->wr_index = (handle->wr_index + trans) % handle->buffer_length; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
373 ret += trans; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
374 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
375 if (handle->header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
376 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
377 gsize i = handle->hdr_index; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
378 while (1) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
379 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
380 if ((i + 1) % handle->buffer_length == handle->wr_index) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
381 break; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
382 if (handle->buffer[i] == '\r' && |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
383 handle->buffer[(i + 1) % handle->buffer_length] == '\n') |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
384 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
385 gsize size = (handle->buffer_length + i - |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
386 handle->hdr_index) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
387 handle->buffer[i] = '\0'; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
388 got_header(handle, size); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
389 if (i == handle->hdr_index) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
390 { |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
391 size_t leftover; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
392 // Empty header means the end of the headers |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
393 handle->header = 0; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
394 handle->hdr_index = (i + 2) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
395 // We read from the start of the data in the request |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
396 handle->rd_index = handle->hdr_index; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
397 // We've already written the amount that's after |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
398 // the header. |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
399 leftover = (handle->wr_index - handle->hdr_index + handle->buffer_length) % handle->buffer_length; |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
400 handle->wr_abs += leftover; |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
401 if (handle->download) |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
402 { |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
403 // the data which has to go into the |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
404 // beginning of the file must be at the end |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
405 // of the input that we've dealt with. |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
406 vfs_fwrite(ptr + ret - leftover, leftover, 1, |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
407 handle->download); |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
408 } |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
409 handle->icy_left = handle->icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
410 if (handle->icy_interval) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
411 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
412 handle->icy_left -= |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
413 (handle->wr_index - handle->hdr_index + handle->buffer_length) % handle->buffer_length; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
414 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
415 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
416 g_print("Left %d\n", handle->icy_left); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
417 handle->in_icy_meta = 0; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
418 break; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
419 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
420 handle->hdr_index = (i + 2) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
421 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
422 i = (i + 1) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
423 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
424 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
425 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
426 return ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
427 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
428 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
429 static gpointer |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
430 curl_manage_request(gpointer arg) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
431 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
432 CurlHandle *handle = arg; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
433 CURLcode result; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
434 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
435 g_print("Connect %p\n", handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
436 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
437 if (handle->no_data) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
438 curl_easy_setopt(handle->curl, CURLOPT_NOBODY, 1); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
439 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
440 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
441 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
442 g_print("Start from %d\n", handle->wr_abs); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
443 curl_easy_setopt(handle->curl, CURLOPT_RESUME_FROM, handle->wr_abs); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
444 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
445 curl_easy_setopt(handle->curl, CURLOPT_NOBODY, 0); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
446 curl_easy_setopt(handle->curl, CURLOPT_HTTPGET, 1); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
447 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
448 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
449 handle->header = 1; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
450 handle->hdr_index = 0; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
451 handle->icy_interval = 0; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
452 |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
453 result = curl_easy_perform(handle->curl); |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
454 if (result == CURLE_OK) |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
455 update_length(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
456 // We expect to get CURLE_WRITE_ERROR if we cancel. |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
457 // We get CURLE_GOT_NOTHING if we send a HEAD request to a shoutcast server. |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
458 // We get CURLE_HTTP_RANGE_ERROR if we try to use range with shoutcast. |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
459 if (result != CURLE_OK && result != CURLE_WRITE_ERROR && |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
460 result != CURLE_GOT_NOTHING && result != CURLE_HTTP_RANGE_ERROR && |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
461 result != CURLE_PARTIAL_FILE) |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
462 { |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
463 g_print("Got curl error %d\n", result); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
464 handle->failed = 1; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
465 } |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
466 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
467 g_print("Done %p%s", handle, handle->cancel ? " (aborted)\n" : "\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
468 handle->cancel = 1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
469 return NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
470 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
471 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
472 static void curl_req_xfer(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
473 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
474 if (handle->failed) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
475 { |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
476 handle->cancel = 1; |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
477 return; |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
478 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
479 if (!handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
480 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
481 handle->cancel = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
482 handle->wr_index = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
483 handle->rd_index = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
484 handle->wr_abs = handle->rd_abs; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
485 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
486 g_print("Starting connection %p at %d\n", handle, handle->wr_abs); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
487 handle->thread = g_thread_create(curl_manage_request, handle, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
488 TRUE, NULL); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
489 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
490 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
491 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
492 static void curl_req_sync_xfer(CurlHandle *handle, size_t old_rd_abs) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
493 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
494 handle->rd_index = (handle->rd_index + handle->rd_abs - old_rd_abs + |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
495 handle->buffer_length) % handle->buffer_length; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
496 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
497 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
498 static void curl_req_no_xfer(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
499 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
500 if (handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
501 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
502 handle->cancel = 1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
503 g_thread_join(handle->thread); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
504 handle->thread = NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
505 handle->cancel = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
506 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
507 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
508 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
509 VFSFile * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
510 curl_vfs_fopen_impl(const gchar * path, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
511 const gchar * mode) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
512 { |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
513 gchar *url; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
514 CurlHandle *handle; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
515 VFSFile *file; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
516 if (!path || !mode) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
517 return NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
518 |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
519 url = g_strdup(path); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
520 |
473 | 521 file = g_new0(VFSFile, 1); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
522 |
473 | 523 handle = g_new0(CurlHandle, 1); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
524 handle->curl = curl_easy_init(); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
525 handle->rd_index = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
526 handle->wr_index = 0; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
527 handle->meta_abs = 0; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
528 handle->rd_abs = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
529 handle->wr_abs = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
530 handle->buffer_length = BUFFER_SIZE; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
531 handle->buffer = g_malloc(handle->buffer_length); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
532 handle->thread = NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
533 handle->length = -1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
534 handle->cancel = 0; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
535 handle->failed = 0; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
536 handle->no_data = 0; |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
537 handle->stream_stack = NULL; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
538 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
539 curl_easy_setopt(handle->curl, CURLOPT_URL, url); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
540 curl_easy_setopt(handle->curl, CURLOPT_WRITEFUNCTION, curl_writecb); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
541 curl_easy_setopt(handle->curl, CURLOPT_WRITEDATA, handle); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
542 curl_easy_setopt(handle->curl, CURLOPT_HEADERDATA, handle); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
543 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
544 curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, 10); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
545 |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
546 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYPEER, 0); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
547 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYHOST, 0); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
548 |
625
fdae06cbebc9
[svn] - set CURLOPT_FOLLOWLOCATION to true, closes #771.
nenolod
parents:
556
diff
changeset
|
549 curl_easy_setopt(handle->curl, CURLOPT_FOLLOWLOCATION, 1); |
fdae06cbebc9
[svn] - set CURLOPT_FOLLOWLOCATION to true, closes #771.
nenolod
parents:
556
diff
changeset
|
550 |
707 | 551 { |
552 gboolean tmp = FALSE; | |
553 ConfigDb *db; | |
554 | |
555 db = bmp_cfg_db_open(); | |
556 | |
557 bmp_cfg_db_get_bool(db, NULL, "proxy_use", &tmp); | |
558 if (tmp == TRUE) | |
559 { | |
560 gchar *proxy_host = NULL; | |
561 gint proxy_port = 0; | |
562 | |
563 bmp_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host); | |
564 bmp_cfg_db_get_int(db, NULL, "proxy_port", &proxy_port); | |
565 | |
566 curl_easy_setopt(handle->curl, CURLOPT_PROXY, proxy_host); | |
567 curl_easy_setopt(handle->curl, CURLOPT_PROXYPORT, proxy_port); | |
568 | |
569 tmp = FALSE; | |
570 | |
571 bmp_cfg_db_get_bool(db, NULL, "proxy_use_auth", &tmp); | |
572 if (tmp == TRUE) | |
573 { | |
574 gchar *userbuf, *proxy_user = NULL, *proxy_pass = NULL; | |
575 | |
576 bmp_cfg_db_get_string(db, NULL, "proxy_user", &proxy_user); | |
577 bmp_cfg_db_get_string(db, NULL, "proxy_pass", &proxy_pass); | |
578 | |
579 userbuf = g_strdup_printf("%s:%s", | |
580 proxy_user != NULL ? proxy_user : "", | |
581 proxy_pass != NULL ? proxy_pass : ""); | |
582 | |
583 if (proxy_user != NULL) | |
584 g_free(proxy_user); | |
585 | |
586 if (proxy_pass != NULL) | |
587 g_free(proxy_pass); | |
588 | |
589 curl_easy_setopt(handle->curl, CURLOPT_PROXYUSERPWD, userbuf); | |
590 | |
591 g_free(userbuf); | |
592 } | |
593 | |
594 if (proxy_host != NULL) | |
595 g_free(proxy_host); | |
596 } | |
708 | 597 |
598 bmp_cfg_db_close(db); | |
707 | 599 } |
600 | |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
601 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
602 struct curl_slist *hdr = NULL; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
603 hdr = curl_slist_append(hdr, "icy-metadata:1"); |
556
cd730d42b2bd
[svn] - User-Agent: Audacious/$version (curl transport)
nenolod
parents:
543
diff
changeset
|
604 hdr = curl_slist_append(hdr, "User-Agent: Audacious/" VERSION " (curl transport)"); |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
605 curl_easy_setopt(handle->curl, CURLOPT_HTTPHEADER, hdr); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
606 } |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
607 |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
608 //handle->download = vfs_fopen(FILENAME, "wb"); |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
609 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
610 file->handle = handle; |
483 | 611 file->base = &curl_const; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
612 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
613 if (DEBUG_OPEN_CLOSE) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
614 g_print("Open %s with curl => %p\n", url, handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
615 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
616 return file; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
617 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
618 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
619 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
620 curl_vfs_fclose_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
621 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
622 gint ret = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
623 if (file == NULL) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
624 return -1; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
625 if (DEBUG_OPEN_CLOSE) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
626 g_print("Close %p\n", file->handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
627 if (file->handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
628 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
629 CurlHandle *handle = file->handle; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
630 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
631 g_print("Cancel transfer\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
632 curl_req_no_xfer(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
633 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
634 g_print("Okay\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
635 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
636 g_free(handle->buffer); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
637 if (handle->name) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
638 g_free(handle->name); |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
639 if (handle->stream_stack != NULL) |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
640 g_slist_free(handle->stream_stack); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
641 curl_easy_cleanup(handle->curl); |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
642 |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
643 if (handle->download) |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
644 { |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
645 vfs_fclose(handle->download); |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
646 } |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
647 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
648 g_free(handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
649 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
650 return ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
651 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
652 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
653 size_t |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
654 curl_vfs_fread_impl(gpointer ptr, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
655 size_t size, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
656 size_t nmemb, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
657 VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
658 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
659 CurlHandle *handle = file->handle; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
660 ssize_t sz = size * nmemb; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
661 size_t ret = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
662 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
663 if (sz < 0) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
664 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
665 |
534 | 666 // g_print("Reading %d*%d=%d from %p\n", size, nmemb, sz, handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
667 |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
668 /* check if there are ungetted chars that should be picked before the real fread */ |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
669 if ( handle->stream_stack != NULL ) |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
670 { |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
671 guchar uc; |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
672 while ( (ret < sz) && (handle->stream_stack != NULL) ) |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
673 { |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
674 uc = GPOINTER_TO_INT(handle->stream_stack->data); |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
675 handle->stream_stack = g_slist_delete_link( handle->stream_stack , handle->stream_stack ); |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
676 memcpy( ptr + ret , &uc , 1 ); |
521 | 677 handle->rd_abs++; |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
678 ret++; |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
679 } |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
680 } |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
681 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
682 curl_req_xfer(handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
683 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
684 if (DEBUG_SEEK) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
685 check(handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
686 |
534 | 687 memset(ptr, '\0', sz); |
688 | |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
689 while (ret < sz) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
690 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
691 size_t available; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
692 while (!(available = buf_available(handle)) && !handle->cancel) |
543
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
693 { |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
694 //g_print("Wait for data on %p\n", handle); |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
695 g_usleep(10000); |
282bede45eef
[svn] Support for writing downloaded data to a file (no UI provided yet).
iabervon
parents:
534
diff
changeset
|
696 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
697 if (available > sz - ret) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
698 available = sz - ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
699 memcpy(ptr + ret, handle->buffer + handle->rd_index, available); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
700 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
701 handle->rd_index = |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
702 (handle->rd_index + available) % handle->buffer_length; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
703 if (handle->rd_abs < handle->meta_abs && |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
704 handle->rd_abs + available >= handle->meta_abs) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
705 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
706 if (DEBUG_METADATA_REPORT) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
707 g_print("New song: '%s'\n", handle->title); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
708 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
709 handle->rd_abs += available; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
710 ret += available; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
711 if (!available) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
712 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
713 //g_print("EOF reading from %p\n", handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
714 break; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
715 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
716 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
717 |
534 | 718 // g_print("Read %d from %p\n", ret, handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
719 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
720 return ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
721 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
722 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
723 size_t |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
724 curl_vfs_fwrite_impl(gconstpointer ptr, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
725 size_t size, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
726 size_t nmemb, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
727 VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
728 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
729 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
730 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
731 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
732 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
733 curl_vfs_getc_impl(VFSFile *stream) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
734 { |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
735 CurlHandle *handle = (CurlHandle *) stream->handle; |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
736 guchar uc; |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
737 |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
738 g_return_val_if_fail(handle != NULL, EOF); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
739 |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
740 if ( handle->stream_stack != NULL ) /* check if some char was ungetc'ed before */ |
494 | 741 { |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
742 uc = GPOINTER_TO_INT(handle->stream_stack->data); |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
743 handle->stream_stack = g_slist_delete_link( handle->stream_stack , handle->stream_stack ); |
521 | 744 handle->rd_abs++; |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
745 return uc; |
494 | 746 } |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
747 else if (curl_vfs_fread_impl(&uc, 1, 1, stream) != 1) |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
748 return EOF; |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
749 return uc; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
750 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
751 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
752 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
753 curl_vfs_ungetc_impl(gint c, VFSFile *stream) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
754 { |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
755 CurlHandle *handle = (CurlHandle *) stream->handle; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
756 |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
757 g_return_val_if_fail(handle != NULL, EOF); |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
758 |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
759 handle->stream_stack = g_slist_prepend( handle->stream_stack , GINT_TO_POINTER(c) ); |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
760 if ( handle->stream_stack != NULL ) |
521 | 761 { |
762 handle->rd_abs--; | |
494 | 763 return c; |
521 | 764 } |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
765 else |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
766 return EOF; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
767 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
768 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
769 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
770 curl_vfs_fseek_impl(VFSFile * file, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
771 glong offset, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
772 gint whence) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
773 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
774 size_t posn; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
775 CurlHandle *handle = file->handle; |
510
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
776 /* when a seek is requested, trash the stack of ungetted chars */ |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
777 if ( handle->stream_stack != NULL ) |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
778 { |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
779 g_slist_free( handle->stream_stack ); |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
780 handle->stream_stack = NULL; |
48e9efba7eb0
[svn] - written ungetc for curl vfs plugin (works along with getc, fread, ftell, feof, fseek)
giacomo
parents:
507
diff
changeset
|
781 } |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
782 if (DEBUG_SEEK) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
783 g_print("Seek %p to %d %d\n", handle, offset, whence); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
784 if (whence == SEEK_END && handle->length == -1) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
785 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
786 if (!handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
787 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
788 // We need a HEAD to find out the length |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
789 handle->no_data = 1; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
790 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
791 g_print("Request for head info\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
792 curl_manage_request(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
793 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
794 g_print("Completed\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
795 handle->no_data = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
796 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
797 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
798 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
799 // Wait a bit? |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
800 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
801 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
802 |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
803 if (whence == SEEK_END && handle->length < 0) |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
804 { |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
805 if (DEBUG_SEEK) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
806 g_print("Tried to seek to the end of a file with unknown length\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
807 // don't know how long it is... |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
808 return -1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
809 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
810 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
811 posn = handle->rd_abs; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
812 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
813 if (whence == SEEK_SET) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
814 handle->rd_abs = offset; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
815 else if (whence == SEEK_END) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
816 handle->rd_abs = handle->length + offset; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
817 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
818 handle->rd_abs = handle->rd_abs + offset; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
819 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
820 // XXXX |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
821 // There's a race here between finding available space and |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
822 // allocating it and the check below. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
823 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
824 if (handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
825 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
826 if (handle->rd_abs + handle->buffer_length < handle->wr_abs || |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
827 handle->rd_abs > handle->wr_abs) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
828 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
829 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
830 g_print("Stop transfer\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
831 curl_req_no_xfer(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
832 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
833 g_print("Okay\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
834 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
835 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
836 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
837 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
838 g_print("Continue transfer\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
839 curl_req_sync_xfer(handle, posn); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
840 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
841 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
842 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
843 if (DEBUG_SEEK) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
844 g_print("Seeked %p from %d to %d\n", handle, posn, handle->rd_abs); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
845 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
846 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
847 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
848 void |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
849 curl_vfs_rewind_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
850 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
851 curl_vfs_fseek_impl(file, 0, SEEK_SET); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
852 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
853 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
854 glong |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
855 curl_vfs_ftell_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
856 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
857 CurlHandle *handle = file->handle; |
521 | 858 return handle->rd_abs; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
859 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
860 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
861 gboolean |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
862 curl_vfs_feof_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
863 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
864 CurlHandle *handle = file->handle; |
521 | 865 return handle->rd_abs == handle->length; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
866 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
867 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
868 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
869 curl_vfs_truncate_impl(VFSFile * file, glong size) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
870 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
871 return -1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
872 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
873 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
874 gchar * |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
875 curl_vfs_metadata_impl(VFSFile * file, const gchar * field) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
876 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
877 CurlHandle *handle = file->handle; |
469 | 878 if (!strcmp(field, "stream-name") && handle->name != NULL) |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
879 return strdup(handle->name); |
469 | 880 if (!strcmp(field, "track-name") && handle->title != NULL) |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
881 return strdup(handle->title); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
882 return NULL; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
883 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
884 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
885 VFSConstructor curl_const = { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
886 "http://", |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
887 curl_vfs_fopen_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
888 curl_vfs_fclose_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
889 curl_vfs_fread_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
890 curl_vfs_fwrite_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
891 curl_vfs_getc_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
892 curl_vfs_ungetc_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
893 curl_vfs_fseek_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
894 curl_vfs_rewind_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
895 curl_vfs_ftell_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
896 curl_vfs_feof_impl, |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
897 curl_vfs_truncate_impl, |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
898 curl_vfs_metadata_impl |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
899 }; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
900 |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
901 VFSConstructor curl_https_const = { |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
902 "https://", |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
903 curl_vfs_fopen_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
904 curl_vfs_fclose_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
905 curl_vfs_fread_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
906 curl_vfs_fwrite_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
907 curl_vfs_getc_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
908 curl_vfs_ungetc_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
909 curl_vfs_fseek_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
910 curl_vfs_rewind_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
911 curl_vfs_ftell_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
912 curl_vfs_feof_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
913 curl_vfs_truncate_impl, |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
914 curl_vfs_metadata_impl |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
915 }; |
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
916 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
917 static void init(void) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
918 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
919 vfs_register_transport(&curl_const); |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
920 vfs_register_transport(&curl_https_const); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
921 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
922 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
923 static void cleanup(void) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
924 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
925 #if 0 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
926 vfs_unregister_transport(&curl_const); |
519
bbc597d9875d
[svn] - re-add code that was accidentally removed after merge of getc/ungetc implementation
giacomo
parents:
510
diff
changeset
|
927 vfs_unregister_transport(&curl_https_const); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
928 #endif |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
929 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
930 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
931 LowlevelPlugin llp_curl = { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
932 NULL, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
933 NULL, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
934 "http:// URI Transport", |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
935 init, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
936 cleanup, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
937 }; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
938 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
939 LowlevelPlugin *get_lplugin_info(void) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
940 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
941 return &llp_curl; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
942 } |