annotate src/neon/neon.c @ 1907:bc245b3ad09c

Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
author William Pitcock <nenolod@atheme.org>
date Thu, 27 Sep 2007 13:04:56 -0500
parents 78d29eb44276
children b37cea7ef4a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1751
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
1 /*
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
2 * A neon HTTP input plugin for Audacious
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
3 * Copyright (C) 2007 Ralf Ertzinger
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
4 *
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
5 * This program is free software; you can redistribute it and/or modify
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
6 * it under the terms of the GNU General Public License as published by
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
8 * (at your option) any later version.
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
9 *
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
10 * This program is distributed in the hope that it will be useful,
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
13 * GNU General Public License for more details.
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
14 *
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
15 * You should have received a copy of the GNU General Public License
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
16 * along with this program; if not, write to the Free Software
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
18 */
dc83901850df - Add license texts to the neon source
Ralf Ertzinger <ralf@skytale.net>
parents: 1749
diff changeset
19
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
20 #include <audacious/vfs.h>
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
21 #include <audacious/plugin.h>
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
22 #include <audacious/configdb.h>
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
23
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
24 #include <ne_socket.h>
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
25 #include <ne_utils.h>
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
26 #include <ne_redirect.h>
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
27 #include <ne_request.h>
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
28 #include <ne_auth.h>
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
29
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
30 #include "debug.h"
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
31 #include "neon.h"
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
32 #include "rb.h"
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
33
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
34 #define NBUFSIZ (128u*1024u)
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
35 #define NETBLKSIZ (4096u)
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
36
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
37 DECLARE_PLUGIN(neon, init, fini)
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
38
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
39 VFSConstructor neon_http_const = {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
40 "http://",
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
41 neon_vfs_fopen_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
42 neon_vfs_fclose_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
43 neon_vfs_fread_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
44 neon_vfs_fwrite_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
45 neon_vfs_getc_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
46 neon_vfs_ungetc_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
47 neon_vfs_fseek_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
48 neon_vfs_rewind_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
49 neon_vfs_ftell_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
50 neon_vfs_feof_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
51 neon_vfs_truncate_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
52 neon_vfs_fsize_impl,
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
53 neon_vfs_metadata_impl
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
54 };
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
55
1907
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
56 /* bring ne_set_connect_timeout in as a weak reference, not using it
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
57 * unless we have it available (neon 0.27) --nenolod
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
58 */
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
59 extern void ne_set_connect_timeout(ne_session *sess, int timeout) __attribute__ ((weak));
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
60
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
61 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
62 * ========
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
63 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
64
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
65 static struct neon_handle* handle_init(void) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
66
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
67 struct neon_handle* h;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
68
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
69 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
70
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
71 if (NULL == (h = malloc(sizeof(struct neon_handle)))) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
72 _ERROR("Could not allocate memory for handle");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
73 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
74 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
75
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
76 if (0 != init_rb(&(h->rb), NBUFSIZ)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
77 _ERROR("Could not initialize buffer");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
78 free(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
79 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
80 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
81
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
82 h->url = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
83 h->purl = &purl;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
84 memset(h->purl, 0, sizeof(ne_uri));
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
85 h->session = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
86 h->request = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
87 h->redircount = 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
88 h->pos = 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
89 h->content_length = -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
90 h->can_ranges = FALSE;
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
91 h->icy_metaint = 0;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
92 h->icy_metaleft = 0;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
93 h->icy_metadata.stream_name = NULL;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
94 h->icy_metadata.stream_title = NULL;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
95 h->icy_metadata.stream_url = NULL;
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
96 h->icy_metadata.stream_contenttype = NULL;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
97 h->reader = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
98 h->reader_status.mutex = g_mutex_new();
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
99 h->reader_status.cond = g_cond_new();
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
100 h->reader_status.reading = FALSE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
101 h->reader_status.status = NEON_READER_INIT;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
102 h->eof = FALSE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
103
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
104 _LEAVE h;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
105 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
106
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
107 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
108 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
109 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
110
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
111 static void handle_free(struct neon_handle* h) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
112
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
113 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
114
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
115 ne_uri_free(h->purl);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
116 destroy_rb(&h->rb);
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
117 if (NULL != h->icy_metadata.stream_name) {
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
118 free(h->icy_metadata.stream_name);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
119 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
120 if (NULL != h->icy_metadata.stream_title) {
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
121 free(h->icy_metadata.stream_title);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
122 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
123 if (NULL != h->icy_metadata.stream_url) {
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
124 free(h->icy_metadata.stream_url);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
125 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
126 if (NULL != h->icy_metadata.stream_contenttype) {
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
127 free(h->icy_metadata.stream_contenttype);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
128 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
129 free(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
130
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
131 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
132 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
133
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
134 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
135 * ----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
136 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
137
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
138 static void init(void) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
139
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
140 int ret;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
141
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
142 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
143
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
144 if (0 != (ret = ne_sock_init())) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
145 _ERROR("Could not initialize neon library: %d\n", ret);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
146 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
147 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
148
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
149 vfs_register_transport(&neon_http_const);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
150
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
151 if (0 != ne_has_support(NE_FEATURE_SSL)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
152 _DEBUG("neon compiled with thread-safe SSL, enabling https:// transport");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
153 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
154
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
155 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
156 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
157
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
158 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
159 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
160 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
161
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
162 static void fini(void) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
163
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
164 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
165
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
166 ne_sock_exit();
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
167
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
168 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
169 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
170
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
171 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
172 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
173 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
174
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
175 static void add_icy(struct icy_metadata* m, gchar* name, gchar* value) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
176
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
177 _ENTER;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
178
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
179 if (0 == g_ascii_strncasecmp(name, "StreamTitle", 11)) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
180 _DEBUG("Found StreamTitle: %s", value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
181 if (NULL != m->stream_title) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
182 free(m->stream_title);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
183 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
184 m->stream_title = g_strdup(value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
185 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
186
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
187 if (0 == g_ascii_strncasecmp(name, "StreamUrl", 9)) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
188 _DEBUG("Found StreamUrl: %s", value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
189 if (NULL != m->stream_url) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
190 free(m->stream_url);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
191 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
192 m->stream_url = g_strdup(value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
193 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
194
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
195 _LEAVE;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
196 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
197
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
198 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
199 * -----
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
200 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
201
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
202 static void parse_icy(struct icy_metadata* m, gchar* metadata, int len) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
203
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
204 gchar* p;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
205 gchar* tstart;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
206 gchar* tend;
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
207 gchar name[4096];
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
208 gchar value[4096];
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
209 int state;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
210 int pos;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
211
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
212 _ENTER;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
213
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
214 p = metadata;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
215 state = 1;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
216 pos = 0;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
217 name[0] = '\0';
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
218 value[0] = '\0';
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
219 tstart = metadata;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
220 tend = metadata;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
221 while ((pos < len) && (*p != '\0')) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
222 switch (state) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
223 case 1:
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
224 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
225 * Reading tag name
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
226 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
227 if ('=' == *p) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
228 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
229 * End of tag name.
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
230 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
231 *p = '\0';
1752
301a2f9b287d - Use g_strlcpy instead of strcpy
Ralf Ertzinger <ralf@skytale.net>
parents: 1751
diff changeset
232 g_strlcpy(name, tstart, 4096);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
233 _DEBUG("Found tag name: %s", name);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
234 state = 2;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
235 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
236 tend = p;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
237 };
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
238 break;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
239 case 2:
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
240 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
241 * Waiting for start of value
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
242 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
243 if ('\'' == *p) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
244 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
245 * Leading ' of value
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
246 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
247 tend = tstart = p + 1;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
248 state = 3;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
249 value[0] = '\0';
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
250 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
251 break;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
252 case 3:
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
253 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
254 * Reading value
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
255 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
256 if ('\'' == *p) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
257 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
258 * End of value
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
259 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
260 *p = '\0';
1752
301a2f9b287d - Use g_strlcpy instead of strcpy
Ralf Ertzinger <ralf@skytale.net>
parents: 1751
diff changeset
261 g_strlcpy(value, tstart, 4096);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
262 _DEBUG("Found tag value: %s", value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
263 add_icy(m, name, value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
264 state = 4;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
265 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
266 tend = p;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
267 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
268 break;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
269 case 4:
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
270 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
271 * Waiting for next tag start
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
272 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
273 if (';' == *p) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
274 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
275 * Next tag name starts after this char
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
276 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
277 tend = tstart = p + 1;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
278 state = 1;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
279 name[0] = '\0';
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
280 value[0] = '\0';
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
281 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
282 break;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
283 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
284 p++;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
285 pos++;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
286 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
287
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
288 _LEAVE;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
289 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
290
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
291 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
292 * -----
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
293 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
294
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
295 static void kill_reader(struct neon_handle* h) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
296
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
297 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
298
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
299 _DEBUG("Signaling reader thread to terminate");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
300 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
301 h->reader_status.reading = FALSE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
302 g_cond_signal(h->reader_status.cond);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
303 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
304
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
305 _DEBUG("Waiting for reader thread to die...");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
306 g_thread_join(h->reader);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
307 _DEBUG("Reader thread has died");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
308 h->reader = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
309 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
310
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
311 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
312 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
313 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
314
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
315 static int server_auth_callback(void* userdata, const char* realm, int attempt, char* username, char* password) {
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
316
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
317 struct neon_handle* h = (struct neon_handle*)userdata;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
318 gchar* authcpy;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
319 gchar** authtok;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
320
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
321 _ENTER;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
322
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
323 if ((NULL == h->purl->userinfo) || ('\0' == *(h->purl->userinfo))) {
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
324 _ERROR("Authentication required, but no credentials set");
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
325 _LEAVE 1;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
326 }
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
327
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
328 if (NULL == (authcpy = g_strdup(h->purl->userinfo))) {
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
329 /*
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
330 * No auth data
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
331 */
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
332 _ERROR("Could not allocate memory for authentication data");
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
333 _LEAVE 1;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
334 }
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
335
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
336 authtok = g_strsplit(authcpy, ":", 2);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
337 if ((strlen(authtok[1]) > (NE_ABUFSIZ-1)) || (strlen(authtok[0]) > (NE_ABUFSIZ-1))) {
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
338 _ERROR("Username/Password too long");
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
339 g_strfreev(authtok);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
340 free(authcpy);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
341 _LEAVE 1;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
342 }
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
343
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
344 strncpy(username, authtok[0], NE_ABUFSIZ);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
345 strncpy(password, authtok[1], NE_ABUFSIZ);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
346
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
347 _DEBUG("Authenticating: Username: %s, Password: %s", username, password);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
348
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
349 g_strfreev(authtok);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
350 free(authcpy);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
351
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
352 _LEAVE attempt;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
353 }
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
354
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
355 /*
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
356 * -----
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
357 */
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
358
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
359 static void handle_headers(struct neon_handle* h) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
360
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
361 const gchar* name;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
362 const gchar* value;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
363 void* cursor = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
364 long len;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
365 gchar* endptr;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
366
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
367 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
368
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
369 _DEBUG("Header responses:");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
370 while(NULL != (cursor = ne_response_header_iterate(h->request, cursor, &name, &value))) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
371 _DEBUG("HEADER: %s: %s", name, value);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
372 if (0 == g_ascii_strncasecmp("accept-ranges", name, 13)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
373 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
374 * The server advertises range capability. we need "bytes"
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
375 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
376 if (NULL != g_strrstr(value, "bytes")) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
377 _DEBUG("server can_ranges");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
378 h->can_ranges = TRUE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
379 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
380
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
381 continue;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
382 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
383
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
384 if (0 == g_ascii_strncasecmp("content-length", name, 14)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
385 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
386 * The server sent us the content length. Parse and store.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
387 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
388 len = strtol(value, &endptr, 10);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
389 if ((*value != '\0') && (*endptr == '\0') && (len >= 0)) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
390 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
391 * Valid data.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
392 */
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
393 _DEBUG("Content length as advertised by server: %ld", len);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
394 h->content_length = len;
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
395 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
396 _ERROR("Invalid content length header: %s", value);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
397 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
398
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
399 continue;
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
400 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
401
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
402 if (0 == g_ascii_strncasecmp("content-type", name, 12)) {
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
403 /*
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
404 * The server sent us a content type. Save it for later
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
405 */
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
406 _DEBUG("Content-Type: %s", value);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
407 if (NULL != h->icy_metadata.stream_contenttype) {
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
408 free(h->icy_metadata.stream_contenttype);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
409 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
410 h->icy_metadata.stream_contenttype = g_strdup(value);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
411
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
412 continue;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
413 }
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
414
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
415 if (0 == g_ascii_strncasecmp("icy-metaint", name, 11)) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
416 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
417 * The server sent us a ICY metaint header. Parse and store.
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
418 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
419 len = strtol(value, &endptr, 10);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
420 if ((*value != '\0') && (*endptr == '\0') && (len > 0)) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
421 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
422 * Valid data
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
423 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
424 _DEBUG("ICY MetaInt as advertised by server: %ld", len);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
425 h->icy_metaint = len;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
426 h->icy_metaleft = len;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
427 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
428 _ERROR("Invalid ICY MetaInt header: %s", value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
429 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
430
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
431 continue;
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
432 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
433
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
434 if (0 == g_ascii_strncasecmp("icy-name", name, 8)) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
435 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
436 * The server sent us a ICY name. Save it for later
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
437 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
438 _DEBUG("ICY stream name: %s", value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
439 if (NULL != h->icy_metadata.stream_name) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
440 free(h->icy_metadata.stream_name);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
441 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
442 h->icy_metadata.stream_name = g_strdup(value);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
443 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
444
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
445 continue;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
446 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
447
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
448 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
449 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
450
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
451 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
452 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
453 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
454
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
455 static int open_request(struct neon_handle* handle, unsigned long startbyte) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
456
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
457 int ret;
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
458 const ne_status* status;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
459
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
460 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
461
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
462 handle->request = ne_request_create(handle->session, "GET", handle->purl->path);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
463 ne_print_request_header(handle->request, "Range", "bytes=%ld-", startbyte);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
464 ne_print_request_header(handle->request, "Icy-MetaData", "1");
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
465
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
466 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
467 * Try to connect to the server.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
468 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
469 _DEBUG("Connecting...");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
470 ret = ne_begin_request(handle->request);
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
471 status = ne_get_status(handle->request);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
472 if ((NE_OK == ret) && (401 == status->code)) {
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
473 /*
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
474 * Authorization required. Reconnect to
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
475 * authenticate
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
476 */
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
477 _DEBUG("Reconnecting due to 401");
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
478 ne_end_request(handle->request);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
479 ret = ne_begin_request(handle->request);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
480 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
481
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
482 switch (ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
483 case NE_OK:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
484 /* URL opened OK */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
485 _DEBUG("URL opened OK");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
486 handle->content_start = startbyte;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
487 handle->pos = startbyte;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
488 handle_headers(handle);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
489 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
490 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
491
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
492 case NE_REDIRECT:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
493 /* We hit a redirect. Handle it. */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
494 _DEBUG("Redirect encountered");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
495 handle->redircount += 1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
496 handle->purl = ne_redirect_location(handle->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
497 ne_request_destroy(handle->request);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
498 if (NULL == handle->purl) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
499 _ERROR("Could not parse redirect response");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
500 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
501 }
1722
2e33cfa6a872 - Correct some compiler warnings
Ralf Ertzinger <ralf@skytale.net>
parents: 1719
diff changeset
502 _LEAVE 1;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
503 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
504
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
505 default:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
506 /* Something went wrong. */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
507 _ERROR("Could not open URL: %d", ret);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
508 if (1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
509 _ERROR("neon error string: %s", ne_get_error(handle->session));
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
510 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
511 ne_request_destroy(handle->request);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
512 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
513 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
514 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
515 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
516
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
517 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
518 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
519 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
520
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
521 static int open_handle(struct neon_handle* handle, unsigned long startbyte) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
522
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
523 int ret;
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
524 ConfigDb* db;
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
525 gchar* proxy_host;
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
526 gchar* proxy_port_s;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
527 gchar* endptr;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
528 unsigned int proxy_port = 0;
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
529 gboolean use_proxy;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
530
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
531 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
532
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
533 db = bmp_cfg_db_open();
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
534 bmp_cfg_db_get_bool(db, NULL, "use_proxy", &use_proxy);
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
535 if (use_proxy) {
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
536 if (FALSE == bmp_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host)) {
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
537 _ERROR("Could not read proxy host, disabling proxy use");
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
538 use_proxy = FALSE;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
539 }
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
540 if (FALSE == bmp_cfg_db_get_string(db, NULL, "proxy_port", &proxy_port_s)) {
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
541 _ERROR("Could not read proxy port, disabling proxy use");
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
542 use_proxy = FALSE;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
543 }
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
544 proxy_port = strtoul(proxy_port_s, &endptr, 10);
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
545 if (!((*proxy_port_s != '\0') && (*endptr == '\0') && (proxy_port < 65536))) {
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
546 /*
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
547 * Invalid data
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
548 */
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
549 _ERROR("Invalid proxy port, disabling proxy use");
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
550 use_proxy = FALSE;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
551 }
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
552 }
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
553
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
554 handle->redircount = 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
555
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
556 _DEBUG("Parsing URL");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
557 if (0 != ne_uri_parse(handle->url, handle->purl)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
558 _ERROR("Could not parse URL '%s'", handle->url);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
559 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
560 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
561
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
562 if (0 == handle->purl->port) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
563 handle->purl->port = 80;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
564 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
565
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
566 while (handle->redircount < 10) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
567
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
568 _DEBUG("Creating session");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
569 handle->session = ne_session_create(handle->purl->scheme, handle->purl->host, handle->purl->port);
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
570 ne_add_server_auth(handle->session, NE_AUTH_BASIC, server_auth_callback, (void *)handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
571 ne_set_session_flag(handle->session, NE_SESSFLAG_ICYPROTO, 1);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
572 ne_set_session_flag(handle->session, NE_SESSFLAG_PERSIST, 0);
1907
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
573
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
574 if (ne_set_connect_timeout != NULL)
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
575 ne_set_connect_timeout(handle->session, 10);
bc245b3ad09c Allow for the neon http VFS plugin to work without neon 0.27 by using weak attributes.
William Pitcock <nenolod@atheme.org>
parents: 1761
diff changeset
576
1729
eaa8a5747628 - Add network timeouts
Ralf Ertzinger <ralf@skytale.net>
parents: 1722
diff changeset
577 ne_set_read_timeout(handle->session, 10);
eaa8a5747628 - Add network timeouts
Ralf Ertzinger <ralf@skytale.net>
parents: 1722
diff changeset
578 ne_set_useragent(handle->session, "Audacious/1.4.0");
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
579 ne_redirect_register(handle->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
580
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
581 if (use_proxy) {
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
582 _DEBUG("Using proxy: %s:%d", proxy_host, proxy_port);
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
583 ne_session_proxy(handle->session, proxy_host, proxy_port);
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
584 }
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
585
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
586 _DEBUG("Creating request");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
587 ret = open_request(handle, startbyte);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
588
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
589 if (0 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
590 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
591 } else if (-1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
592 ne_session_destroy(handle->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
593 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
594 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
595 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
596
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
597 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
598 * If we get here, our redirect count exceeded
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
599 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
600
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
601 _ERROR("Redirect count exceeded for URL");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
602
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
603 _LEAVE 1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
604 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
605
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
606 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
607 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
608 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
609
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
610 static int fill_buffer(struct neon_handle* h) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
611
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
612 ssize_t bsize;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
613 char buffer[NETBLKSIZ];
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
614 ssize_t to_read;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
615
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
616 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
617
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
618 bsize = free_rb(&h->rb);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
619 to_read = MIN(bsize, NETBLKSIZ);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
620
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
621 _DEBUG("%d bytes free in buffer, trying to read %d bytes max", bsize, to_read);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
622
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
623 _DEBUG("Reading from the network....");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
624 if (0 >= (bsize = ne_read_response_block(h->request, buffer, to_read))) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
625 if (0 == bsize) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
626 _DEBUG("End of file encountered");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
627 _LEAVE 1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
628 } else {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
629 _ERROR("Error while reading from the network");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
630 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
631 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
632 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
633 _DEBUG("Read %d bytes from the network", bsize);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
634
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
635 if (0 != write_rb(&(h->rb), buffer, bsize)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
636 _ERROR("Error putting data into buffer");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
637 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
638 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
639
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
640 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
641 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
642
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
643 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
644 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
645 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
646
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
647 static int fill_buffer_limit(struct neon_handle* h, unsigned int maxfree) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
648
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
649 ssize_t bfree;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
650 int ret;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
651
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
652 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
653
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
654 bfree = free_rb(&h->rb);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
655 _DEBUG("Filling buffer up to max %d bytes free, %d bytes free now", maxfree, bfree);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
656
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
657 while (bfree > maxfree) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
658 ret = fill_buffer(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
659 if (-1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
660 _ERROR("Error while filling buffer");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
661 _LEAVE ret;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
662 } else if (1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
663 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
664 * EOF while filling the buffer. Return what we have.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
665 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
666 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
667 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
668
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
669 bfree = free_rb(&h->rb);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
670 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
671
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
672 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
673 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
674
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
675 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
676 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
677 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
678
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
679 static gpointer reader_thread(void* data) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
680
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
681 struct neon_handle* h = (struct neon_handle*)data;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
682 int ret;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
683
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
684 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
685
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
686 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
687
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
688 while(h->reader_status.reading) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
689 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
690
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
691 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
692 * Hit the network only if we have more than NETBLKSIZ of free buffer
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
693 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
694 if (NETBLKSIZ < free_rb(&h->rb)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
695
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
696 _DEBUG("Filling buffer...");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
697 ret = fill_buffer(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
698
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
699 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
700 if (-1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
701 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
702 * Error encountered while reading from the network.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
703 * Set the error flag and terminate the
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
704 * reader thread.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
705 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
706 _DEBUG("Error while reading from the network. Terminating reader thread");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
707 h->reader_status.status = NEON_READER_ERROR;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
708 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
709 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
710 } else if (1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
711 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
712 * EOF encountered while reading from the
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
713 * network. Set the EOF status and exit.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
714 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
715 _DEBUG("EOF encountered while reading from the network. Terminating reader thread");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
716 h->reader_status.status = NEON_READER_EOF;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
717 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
718 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
719 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
720
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
721 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
722 * So we actually got some data out of the stream.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
723 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
724 _DEBUG("Network read succeeded");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
725 } else {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
726 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
727 * Not enough free space in the buffer.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
728 * Sleep until the main thread wakes us up.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
729 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
730 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
731 if (h->reader_status.reading) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
732 _DEBUG("Reader thread going to sleep");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
733 g_cond_wait(h->reader_status.cond, h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
734 _DEBUG("Reader thread woke up");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
735 } else {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
736 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
737 * Main thread has ordered termination of this thread.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
738 * Leave the loop.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
739 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
740 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
741 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
742 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
743 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
744
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
745 _DEBUG("Reader thread terminating gracefully");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
746 h->reader_status.status = NEON_READER_TERM;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
747 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
748
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
749 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
750 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
751
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
752 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
753 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
754 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
755
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
756 VFSFile* neon_vfs_fopen_impl(const gchar* path, const gchar* mode) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
757
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
758 VFSFile* file;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
759 struct neon_handle* handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
760
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
761 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
762
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
763 _DEBUG("Trying to open '%s' with neon", path);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
764
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
765 if (NULL == (file = malloc(sizeof(VFSFile)))) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
766 _ERROR("Could not allocate memory for filehandle");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
767 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
768 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
769
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
770 if (NULL == (handle = handle_init())) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
771 _ERROR("Could not allocate memory for neon handle");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
772 free(file);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
773 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
774 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
775
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
776 if (NULL == (handle->url = strdup(path))) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
777 _ERROR("Could not copy URL string");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
778 handle_free(handle);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
779 free(file);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
780 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
781 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
782
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
783 if (0 != open_handle(handle, 0)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
784 _ERROR("Could not open URL");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
785 handle_free(handle);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
786 free(file);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
787 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
788 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
789
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
790 file->handle = handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
791 file->base = &neon_http_const;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
792
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
793 _LEAVE file;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
794 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
795
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
796 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
797 * ----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
798 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
799
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
800 gint neon_vfs_fclose_impl(VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
801
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
802 struct neon_handle* h = (struct neon_handle *)file->handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
803
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
804 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
805
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
806 if (NULL != h->reader) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
807 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
808 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
809
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
810 _DEBUG("Destroying request");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
811 if (NULL != h->request) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
812 ne_request_destroy(h->request);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
813 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
814
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
815 _DEBUG("Destroying session");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
816 ne_session_destroy(h->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
817
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
818 handle_free(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
819
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
820 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
821 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
822
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
823 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
824 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
825 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
826
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
827 size_t neon_vfs_fread_impl(gpointer ptr_, size_t size, size_t nmemb, VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
828
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
829 struct neon_handle* h = (struct neon_handle*)file->handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
830 int belem;
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
831 int relem;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
832 int ret;
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
833 char icy_metadata[4096];
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
834 unsigned char icy_metalen;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
835
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
836 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
837
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
838 if (NULL == h->request) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
839 _ERROR("No request to read from, seek gone wrong?");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
840 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
841 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
842
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
843 _DEBUG("Requesting %d elements of %d bytes size each (%d bytes total), to be stored at %p",
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
844 nmemb, size, (nmemb*size), ptr_);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
845
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
846 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
847 * Look how much data is in the buffer
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
848 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
849 belem = used_rb(&h->rb) / size;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
850
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
851 if ((NULL != h->reader) && (0 == belem)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
852 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
853 * There is a reader thread, but the buffer is empty.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
854 * If we are running normally we will have to rebuffer.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
855 * Kill the reader thread and restart.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
856 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
857 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
858 if (NEON_READER_RUN == h->reader_status.status) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
859 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
860 _ERROR("Buffer underrun, trying rebuffering");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
861 kill_reader(h);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
862
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
863 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
864 * We have to check if the reader terminated gracefully
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
865 * again
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
866 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
867 if (NEON_READER_TERM != h->reader_status.status) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
868 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
869 * Reader thread did not terminate gracefully.
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
870 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
871 _LEAVE 0;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
872 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
873 } else {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
874 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
875 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
876 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
877
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
878 if (NULL == h->reader) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
879 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
880 * There is no reader thread yet. Read the first bytes from
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
881 * the network ourselves, and then fire up the reader thread
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
882 * to keep the buffer filled up.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
883 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
884 _DEBUG("Doing initial buffer fill");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
885 ret = fill_buffer_limit(h, NBUFSIZ/2);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
886
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
887 if (-1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
888 _ERROR("Error while reading from the network");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
889 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
890 } else if (1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
891 _ERROR("EOF during initial read");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
892 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
893 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
894
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
895 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
896 * We have some data in the buffer now.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
897 * Start the reader thread.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
898 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
899 h->reader_status.reading = TRUE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
900 if (NULL == (h->reader = g_thread_create(reader_thread, h, TRUE, NULL))) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
901 h->reader_status.reading = FALSE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
902 _ERROR("Error creating reader thread!");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
903 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
904 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
905 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
906 h->reader_status.status = NEON_READER_RUN;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
907 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
908 } else {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
909 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
910 * There already is a reader thread. Look if it is in good
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
911 * shape.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
912 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
913 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
914 _DEBUG("Reader thread status: %d", h->reader_status.status);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
915 switch (h->reader_status.status) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
916 case NEON_READER_INIT:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
917 case NEON_READER_RUN:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
918 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
919 * All is well, nothing to be done.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
920 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
921 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
922 case NEON_READER_EOF:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
923 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
924 * If there still is data in the buffer, carry on.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
925 * If not, terminate the reader thread and return 0.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
926 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
927 if (0 == used_rb(&h->rb)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
928 _DEBUG("Reached end of stream");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
929 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
930 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
931 h->eof = TRUE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
932 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
933 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
934 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
935 case NEON_READER_ERROR:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
936 /* Terminate the reader and return 0 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
937 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
938 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
939 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
940 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
941 case NEON_READER_TERM:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
942 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
943 * The reader thread terminated gracefully, most
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
944 * likely on our own request.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
945 * We should not get here.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
946 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
947 _ERROR("Reader thread terminated and fread() called. How did we get here?");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
948 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
949 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
950 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
951 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
952 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
953 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
954
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
955 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
956 * Deliver data from the buffer
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
957 */
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
958 if (0 == used_rb(&h->rb)) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
959 /*
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
960 * The buffer is still empty, we can deliver no data!
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
961 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
962 _ERROR("Buffer still underrun, fatal.");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
963 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
964 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
965
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
966 if (0 != h->icy_metaint) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
967 _DEBUG("%ld bytes left before next ICY metadata announcement", h->icy_metaleft);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
968 if (0 == h->icy_metaleft) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
969 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
970 * The next data in the buffer is a ICY metadata announcement.
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
971 * Get the length byte
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
972 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
973 read_rb(&h->rb, &icy_metalen, 1);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
974
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
975 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
976 * We need enough data in the buffer to
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
977 * a) Read the complete ICY metadata block
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
978 * b) deliver at least one byte to the reader
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
979 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
980 _DEBUG("Expecting %d bytes of ICY metadata", (icy_metalen*16));
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
981
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
982 if ((free_rb(&h->rb)-(icy_metalen*16)) < size) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
983 /* There is not enough data. We do not have much choice at this point,
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
984 * so we'll deliver the metadata as normal data to the reader and
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
985 * hope for the best.
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
986 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
987 _ERROR("Buffer underrun when reading metadata. Expect audio degradation");
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
988 h->icy_metaleft = h->icy_metaint + (icy_metalen*16);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
989 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
990 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
991 * Grab the metadata from the buffer and send it to the parser
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
992 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
993 read_rb(&h->rb, icy_metadata, (icy_metalen*16));
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
994 parse_icy(&h->icy_metadata, icy_metadata, (icy_metalen*16));
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
995 h->icy_metaleft = h->icy_metaint;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
996 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
997 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
998
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
999 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1000 * The maximum number of bytes we can deliver is determined
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1001 * by the number of bytes left until the next metadata announcement
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1002 */
1749
d2e3eef90719 - Read the correct amount of data from the buffer when handling ShoutCast metadata
Ralf Ertzinger <ralf@skytale.net>
parents: 1742
diff changeset
1003 belem = MIN(used_rb(&h->rb), h->icy_metaleft) / size;
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1004 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1005 belem = used_rb(&h->rb) / size;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1006 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1007
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1008 relem = MIN(belem, nmemb);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1009 _DEBUG("%d elements of returnable data in the buffer", belem);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1010 read_rb(&h->rb, ptr_, relem*size);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1011
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1012 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1013 * Signal the network thread to continue reading
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1014 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1015 _DEBUG("Waking up reader thread");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1016 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1017 g_cond_signal(h->reader_status.cond);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1018 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1019
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1020 h->pos += (relem*size);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1021 h->icy_metaleft -= (relem*size);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1022
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1023 _DEBUG("Returning %d elements", relem);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1024
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1025 _LEAVE relem;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1026 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1027
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1028
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1029 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1030 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1031 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1032
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1033 size_t neon_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1034
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1035 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1036
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1037 _ERROR("NOT IMPLEMENTED");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1038
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1039 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1040 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1041
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1042 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1043 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1044 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1045
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1046 gint neon_vfs_getc_impl(VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1047
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1048 gchar c;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1049
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1050 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1051
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1052 if (1 != neon_vfs_fread_impl(&c, 1, 1, file)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1053 _ERROR("Could not getc()!");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1054 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1055 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1056
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1057 _LEAVE c;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1058 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1059
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1060 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1061 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1062 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1063
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1064 gint neon_vfs_ungetc_impl(gint c, VFSFile* stream) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1065
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1066 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1067
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1068 _ERROR("NOT IMPLEMENTED");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1069
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1070 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1071 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1072
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1073 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1074 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1075 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1076
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1077 void neon_vfs_rewind_impl(VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1078
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1079 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1080
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1081 (void)neon_vfs_fseek_impl(file, 0L, SEEK_SET);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1082
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1083 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1084 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1085
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1086 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1087 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1088 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1089
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1090 glong neon_vfs_ftell_impl(VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1091
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1092 struct neon_handle* h = (struct neon_handle *)file->handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1093
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1094 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1095
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1096 _DEBUG("Current file position: %ld", h->pos);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1097
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1098 _LEAVE h->pos;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1099 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1100
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1101 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1102 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1103 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1104
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1105 gboolean neon_vfs_feof_impl(VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1106
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1107 struct neon_handle* h = (struct neon_handle*)file->handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1108
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1109 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1110
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1111 _LEAVE h->eof;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1112 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1113
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1114 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1115 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1116 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1117
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1118 gint neon_vfs_truncate_impl(VFSFile* file, glong size) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1119
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1120 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1121
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1122 _ERROR("NOT IMPLEMENTED");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1123
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1124 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1125 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1126
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1127 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1128 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1129 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1130
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1131 gint neon_vfs_fseek_impl(VFSFile* file, glong offset, gint whence) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1132
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1133 struct neon_handle* h = (struct neon_handle*)file->handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1134 long newpos;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1135 long content_length;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1136
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1137 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1138
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1139 _DEBUG("Seek requested: offset %ld, whence %d", offset, whence);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1140 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1141 * Two things must be satisfied for us to be able to seek:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1142 * - the server must advertise a content-length
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1143 * - the server must advertise accept-ranges: bytes
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1144 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1145 if ((-1 == h->content_length) || !h->can_ranges) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1146 _DEBUG("Can not seek due to server restrictions");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1147 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1148 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1149
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1150 content_length = h->content_length + h->content_start;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1151
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1152 switch (whence) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1153 case SEEK_SET:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1154 newpos = offset;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1155 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1156 case SEEK_CUR:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1157 newpos = h->pos + offset;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1158 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1159 case SEEK_END:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1160 newpos = content_length + offset;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1161 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1162 default:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1163 _ERROR("Invalid whence specified");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1164 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1165 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1166
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1167 _DEBUG("Position to seek to: %ld, current: %ld", newpos, h->pos);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1168 if (0 > newpos) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1169 _ERROR("Can not seek before start of stream");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1170 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1171 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1172
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1173 if (newpos > content_length) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1174 _ERROR("Can not seek beyond end of stream");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1175 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1176 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1177
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1178 if (newpos == h->pos) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1179 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1180 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1181
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1182 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1183 * To seek to the new position we have to
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1184 * - stop the current reader thread, if there is one
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1185 * - destroy the current request
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1186 * - dump all data currently in the ringbuffer
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1187 * - create a new request starting at newpos
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1188 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1189 if (NULL != h->reader) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1190 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1191 * There may be a thread still running.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1192 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1193 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1194 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1195
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1196 ne_request_destroy(h->request);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1197 ne_session_destroy(h->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1198 reset_rb(&h->rb);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1199
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1200 if (0 != open_handle(h, newpos)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1201 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1202 * Something went wrong while creating the new request.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1203 * There is not much we can do now, we'll set the request
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1204 * to NULL, so that fread() will error out on the next
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1205 * read request
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1206 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1207 _ERROR("Error while creating new request!");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1208 h->request = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1209 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1210 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1211
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1212 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1213 * Things seem to have worked. The next read request will start
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1214 * the reader thread again.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1215 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1216
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1217 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1218 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1219
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1220 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1221 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1222 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1223
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1224 gchar *neon_vfs_metadata_impl(VFSFile* file, const gchar* field) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1225
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1226 struct neon_handle* h = (struct neon_handle*)file->handle;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1227
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1228 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1229
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1230 _DEBUG("Field name: %s", field);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1231
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1232 if (0 == g_ascii_strncasecmp(field, "track-name", 10)) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1233 _LEAVE g_strdup(h->icy_metadata.stream_title);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1234 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1235
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1236 if (0 == g_ascii_strncasecmp(field, "stream-name", 11)) {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1237 _LEAVE g_strdup(h->icy_metadata.stream_name);
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1238 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1239
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
1240 if (0 == g_ascii_strncasecmp(field, "content-type", 12)) {
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
1241 _LEAVE g_strdup(h->icy_metadata.stream_contenttype);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
1242 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
1243
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1244 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1245 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1246
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1247 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1248 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1249 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1250
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1251 off_t neon_vfs_fsize_impl(VFSFile* file) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1252
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1253 struct neon_handle* h = (struct neon_handle*)file->handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1254
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1255 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1256
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1257 if (-1 == h->content_length) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1258 _DEBUG("Unknown content length");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1259 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1260 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1261
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1262 _LEAVE (h->content_start + h->content_length);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1263 }