annotate src/neon/neon.c @ 3203:f5456241bff9 default tip

changed include path from audacious to audlegacy.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 10 Nov 2009 05:19:25 +0900
parents 647edbe263bd
children
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
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2707
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1751
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
3075
eed75824b3f7 Return bytes in the range 0x80-0xff as positive; negative values indicate an error (fixes bug #27).
John Lindgren <john.lindgren@tds.net>
parents: 2993
diff changeset
20 #include <stdint.h>
eed75824b3f7 Return bytes in the range 0x80-0xff as positive; negative values indicate an error (fixes bug #27).
John Lindgren <john.lindgren@tds.net>
parents: 2993
diff changeset
21
1961
e8ea3a76a84e Various #include cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1926
diff changeset
22 #include "neon.h"
e8ea3a76a84e Various #include cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1926
diff changeset
23
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2835
diff changeset
24 #include <audlegacy/plugin.h>
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
25
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
26 #include <ne_socket.h>
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
27 #include <ne_utils.h>
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
28 #include <ne_redirect.h>
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
29 #include <ne_request.h>
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
30 #include <ne_auth.h>
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
31
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
32 #include "debug.h"
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
33 #include "rb.h"
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
34
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
35 #define NEON_BUFSIZE (128u*1024u)
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
36 #define NEON_NETBLKSIZE (4096u)
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
37 #define NEON_ICY_BUFSIZE (4096)
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
38
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
39
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
40 VFSFile *neon_aud_vfs_fopen_impl(const gchar* path, const gchar* mode);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
41 gint neon_aud_vfs_fclose_impl(VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
42 gsize neon_aud_vfs_fread_impl(gpointer ptr_, gsize size, gsize nmemb, VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
43 gsize neon_aud_vfs_fwrite_impl(gconstpointer ptr, gsize size, gsize nmemb, VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
44 gint neon_aud_vfs_getc_impl(VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
45 gint neon_aud_vfs_ungetc_impl(gint c, VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
46 void neon_aud_vfs_rewind_impl(VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
47 glong neon_aud_vfs_ftell_impl(VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
48 gboolean neon_aud_vfs_feof_impl(VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
49 gint neon_aud_vfs_truncate_impl(VFSFile* file, glong size);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
50 gint neon_aud_vfs_fseek_impl(VFSFile* file, glong offset, gint whence);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
51 gchar *neon_aud_vfs_metadata_impl(VFSFile* file, const gchar * field);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
52 off_t neon_aud_vfs_fsize_impl(VFSFile* file);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
53
1719
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 VFSConstructor neon_http_const = {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
56 "http://",
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
57 neon_aud_vfs_fopen_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
58 neon_aud_vfs_fclose_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
59 neon_aud_vfs_fread_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
60 neon_aud_vfs_fwrite_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
61 neon_aud_vfs_getc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
62 neon_aud_vfs_ungetc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
63 neon_aud_vfs_fseek_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
64 neon_aud_vfs_rewind_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
65 neon_aud_vfs_ftell_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
66 neon_aud_vfs_feof_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
67 neon_aud_vfs_truncate_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
68 neon_aud_vfs_fsize_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
69 neon_aud_vfs_metadata_impl
1719
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
1925
2662c3a11f9f - Enable https:// transport
Ralf Ertzinger <ralf@skytale.net>
parents: 1923
diff changeset
72 VFSConstructor neon_https_const = {
2662c3a11f9f - Enable https:// transport
Ralf Ertzinger <ralf@skytale.net>
parents: 1923
diff changeset
73 "https://",
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
74 neon_aud_vfs_fopen_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
75 neon_aud_vfs_fclose_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
76 neon_aud_vfs_fread_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
77 neon_aud_vfs_fwrite_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
78 neon_aud_vfs_getc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
79 neon_aud_vfs_ungetc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
80 neon_aud_vfs_fseek_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
81 neon_aud_vfs_rewind_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
82 neon_aud_vfs_ftell_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
83 neon_aud_vfs_feof_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
84 neon_aud_vfs_truncate_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
85 neon_aud_vfs_fsize_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
86 neon_aud_vfs_metadata_impl
1925
2662c3a11f9f - Enable https:// transport
Ralf Ertzinger <ralf@skytale.net>
parents: 1923
diff changeset
87 };
2662c3a11f9f - Enable https:// transport
Ralf Ertzinger <ralf@skytale.net>
parents: 1923
diff changeset
88
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
89
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
90 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
91 * ----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
92 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
93
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
94 static void neon_plugin_init(void) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
95
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
96 gint ret;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
97
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
98 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
99
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
100 if (0 != (ret = ne_sock_init())) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
101 _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
102 _LEAVE;
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
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
105 aud_vfs_register_transport(&neon_http_const);
1719
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 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
108 _DEBUG("neon compiled with thread-safe SSL, enabling https:// transport");
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
109 aud_vfs_register_transport(&neon_https_const);
1719
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
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
112 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
113 }
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 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
116 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
117 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
118
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
119 static void neon_plugin_fini(void) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
120
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
121 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
122
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
123 ne_sock_exit();
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
124
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
125 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
126 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
127
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
128 DECLARE_PLUGIN(neon, neon_plugin_init, neon_plugin_fini)
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
129
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
130
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
131 /*
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
132 * ========
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
133 */
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
134
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
135 static struct neon_handle* handle_init(void) {
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
136
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
137 struct neon_handle* h;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
138
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
139 _ENTER;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
140
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
141 if (NULL == (h = g_new0(struct neon_handle, 1))) {
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
142 _ERROR("Could not allocate memory for handle");
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
143 _LEAVE NULL;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
144 }
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
145
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
146 h->reader_status.mutex = g_mutex_new();
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
147 h->reader_status.cond = g_cond_new();
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
148 h->reader_status.reading = FALSE;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
149 h->reader_status.status = NEON_READER_INIT;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
150
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
151 if (0 != init_rb_with_lock(&(h->rb), NEON_BUFSIZE, h->reader_status.mutex)) {
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
152 _ERROR("Could not initialize buffer");
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
153 g_free(h);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
154 _LEAVE NULL;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
155 }
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
156
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
157 h->purl = g_new0(ne_uri, 1);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
158 h->content_length = -1;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
159
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
160 _LEAVE h;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
161 }
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
162
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
163 /*
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
164 * -----
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
165 */
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
166
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
167 static void handle_free(struct neon_handle* h) {
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
168
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
169 _ENTER;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
170
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
171 _DEBUG("<%p> freeing handle", h);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
172
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
173 ne_uri_free(h->purl);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
174 g_free(h->purl);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
175 destroy_rb(&h->rb);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
176 g_free(h->icy_metadata.stream_name);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
177 g_free(h->icy_metadata.stream_title);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
178 g_free(h->icy_metadata.stream_url);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
179 g_free(h->icy_metadata.stream_contenttype);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
180 g_free(h);
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
181
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
182 _LEAVE;
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
183 }
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
184
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
185 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
186 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
187 */
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
188 static gboolean neon_strcmp(const gchar *str, const gchar *cmp)
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
189 {
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
190 return (g_ascii_strncasecmp(str, cmp, strlen(cmp)) == 0);
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
191 }
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
192
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
193
3075
eed75824b3f7 Return bytes in the range 0x80-0xff as positive; negative values indicate an error (fixes bug #27).
John Lindgren <john.lindgren@tds.net>
parents: 2993
diff changeset
194 static void add_icy(struct icy_metadata* m, gchar* name, gchar* value) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
195
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
196 _ENTER;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
197
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
198 if (neon_strcmp(name, "StreamTitle")) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
199 _DEBUG("Found StreamTitle: %s", value);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
200 g_free(m->stream_title);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
201 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
202 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
203
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
204 if (neon_strcmp(name, "StreamUrl")) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
205 _DEBUG("Found StreamUrl: %s", value);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
206 g_free(m->stream_url);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
207 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
208 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
209
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
210 _LEAVE;
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
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 * -----
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
215 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
216
2707
efd4a8ee1965 Use gsize instead of gint.
Matti Hamalainen <ccr@tnsp.org>
parents: 2670
diff changeset
217 static void parse_icy(struct icy_metadata* m, gchar* metadata, gsize 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
218
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
219 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
220 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
221 gchar* tend;
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
222 gchar name[NEON_ICY_BUFSIZE];
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
223 gchar value[NEON_ICY_BUFSIZE];
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
224 gint state;
2707
efd4a8ee1965 Use gsize instead of gint.
Matti Hamalainen <ccr@tnsp.org>
parents: 2670
diff changeset
225 gsize pos;
1730
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 _ENTER;
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 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
240 * 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
241 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
242 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
243 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
244 * 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
245 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
246 *p = '\0';
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
247 g_strlcpy(name, tstart, NEON_ICY_BUFSIZE);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
248 _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
249 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
250 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
251 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
252 };
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
253 break;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
254 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
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 * 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
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 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
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 * 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
261 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
262 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
263 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
264 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
265 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
266 break;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
267 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
268 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
269 * 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
270 */
2652
01ce6cb72e43 Possible fix for IceCast stream titles getting cut at first single quote.
Matti Hamalainen <ccr@tnsp.org>
parents: 2631
diff changeset
271 if ('\'' == *p && ';' == *(p+1)) {
1730
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 * 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
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 *p = '\0';
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
276 g_strlcpy(value, tstart, NEON_ICY_BUFSIZE);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
277 _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
278 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
279 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
280 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
281 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
282 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
283 break;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
284 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
285 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
286 * 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
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 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
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 * 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
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 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
293 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
294 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
295 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
296 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
297 break;
2308
c9200f019176 - Handle invalid states in ICY-Metadata parser
Ralf Ertzinger <ralf@skytale.net>
parents: 2307
diff changeset
298 default:
c9200f019176 - Handle invalid states in ICY-Metadata parser
Ralf Ertzinger <ralf@skytale.net>
parents: 2307
diff changeset
299 /*
c9200f019176 - Handle invalid states in ICY-Metadata parser
Ralf Ertzinger <ralf@skytale.net>
parents: 2307
diff changeset
300 * This should not happen
c9200f019176 - Handle invalid states in ICY-Metadata parser
Ralf Ertzinger <ralf@skytale.net>
parents: 2307
diff changeset
301 */
c9200f019176 - Handle invalid states in ICY-Metadata parser
Ralf Ertzinger <ralf@skytale.net>
parents: 2307
diff changeset
302 _ERROR("Invalid state while parsing metadata, metadata may be corrupted: %d", state);
c9200f019176 - Handle invalid states in ICY-Metadata parser
Ralf Ertzinger <ralf@skytale.net>
parents: 2307
diff changeset
303 _LEAVE;
c9200f019176 - Handle invalid states in ICY-Metadata parser
Ralf Ertzinger <ralf@skytale.net>
parents: 2307
diff changeset
304 break;
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
305 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
306 p++;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
307 pos++;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
308 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
309
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
310 _LEAVE;
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
311 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
312
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
313 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
314 * -----
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
315 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
316
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
317 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
318
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
319 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
320
2567
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
321 if (NULL == h) {
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
322 _LEAVE;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
323 }
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
324
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
325 _DEBUG("Signaling reader thread to terminate");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
326 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
327 h->reader_status.reading = FALSE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
328 g_cond_signal(h->reader_status.cond);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
329 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
330
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
331 _DEBUG("Waiting for reader thread to die...");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
332 g_thread_join(h->reader);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
333 _DEBUG("Reader thread has died");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
334 h->reader = NULL;
2567
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
335
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
336 _LEAVE;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
337 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
338
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
339 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
340 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
341 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
342
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
343 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
344
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
345 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
346 gchar* authcpy;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
347 gchar** authtok;
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 _ENTER;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
350
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
351 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
352 _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
353 _LEAVE 1;
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 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
357 /*
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
358 * No auth data
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
359 */
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
360 _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
361 _LEAVE 1;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
362 }
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
363
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
364 authtok = g_strsplit(authcpy, ":", 2);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
365 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
366 _ERROR("Username/Password too long");
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
367 g_strfreev(authtok);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
368 g_free(authcpy);
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
369 _LEAVE 1;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
370 }
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
371
2656
a2670c689319 Use g_strlcpy instead of strncpy.
Matti Hamalainen <ccr@tnsp.org>
parents: 2655
diff changeset
372 g_strlcpy(username, authtok[0], NE_ABUFSIZ);
a2670c689319 Use g_strlcpy instead of strncpy.
Matti Hamalainen <ccr@tnsp.org>
parents: 2655
diff changeset
373 g_strlcpy(password, authtok[1], NE_ABUFSIZ);
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
374
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
375 _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
376
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
377 g_strfreev(authtok);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
378 g_free(authcpy);
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
379
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
380 _LEAVE attempt;
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
381 }
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
382
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
383 /*
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
384 * -----
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
385 */
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
386
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
387 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
388
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
389 const gchar* name;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
390 const gchar* value;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
391 void* cursor = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
392 long len;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
393 gchar* endptr;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
394
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
395 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
396
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
397 _DEBUG("Header responses:");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
398 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
399 _DEBUG("HEADER: %s: %s", name, value);
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
400 if (neon_strcmp(name, "accept-ranges")) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
401 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
402 * 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
403 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
404 if (NULL != g_strrstr(value, "bytes")) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
405 _DEBUG("server can_ranges");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
406 h->can_ranges = TRUE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
407 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
408
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
409 continue;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
410 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
411
3139
647edbe263bd neon: Don't bother trying to seek on a Twisted server. It lies about it's capabilities, which leads to failure.
William Pitcock <nenolod@atheme.org>
parents: 3133
diff changeset
412 if (neon_strcmp(name, "server")) {
647edbe263bd neon: Don't bother trying to seek on a Twisted server. It lies about it's capabilities, which leads to failure.
William Pitcock <nenolod@atheme.org>
parents: 3133
diff changeset
413 if (NULL != g_strrstr(value, "Twisted/")) {
647edbe263bd neon: Don't bother trying to seek on a Twisted server. It lies about it's capabilities, which leads to failure.
William Pitcock <nenolod@atheme.org>
parents: 3133
diff changeset
414 _DEBUG("ugh. this is a twisted server, and therefore cannot REALLY seek: %s", value);
647edbe263bd neon: Don't bother trying to seek on a Twisted server. It lies about it's capabilities, which leads to failure.
William Pitcock <nenolod@atheme.org>
parents: 3133
diff changeset
415 h->can_ranges = FALSE;
647edbe263bd neon: Don't bother trying to seek on a Twisted server. It lies about it's capabilities, which leads to failure.
William Pitcock <nenolod@atheme.org>
parents: 3133
diff changeset
416 }
647edbe263bd neon: Don't bother trying to seek on a Twisted server. It lies about it's capabilities, which leads to failure.
William Pitcock <nenolod@atheme.org>
parents: 3133
diff changeset
417 }
647edbe263bd neon: Don't bother trying to seek on a Twisted server. It lies about it's capabilities, which leads to failure.
William Pitcock <nenolod@atheme.org>
parents: 3133
diff changeset
418
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
419 if (neon_strcmp(name, "content-length")) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
420 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
421 * 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
422 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
423 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
424 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
425 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
426 * Valid data.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
427 */
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
428 _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
429 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
430 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
431 _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
432 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
433
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
434 continue;
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
435 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
436
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
437 if (neon_strcmp(name, "content-type")) {
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
438 /*
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
439 * 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
440 */
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
441 _DEBUG("Content-Type: %s", value);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
442 g_free(h->icy_metadata.stream_contenttype);
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
443 h->icy_metadata.stream_contenttype = g_strdup(value);
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 }
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
447
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
448 if (neon_strcmp(name, "icy-metaint")) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
449 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
450 * 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
451 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
452 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
453 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
454 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
455 * 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
456 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
457 _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
458 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
459 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
460 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
461 _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
462 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
463
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
464 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
465 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
466
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
467 if (neon_strcmp(name, "icy-name")) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
468 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
469 * 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
470 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
471 _DEBUG("ICY stream name: %s", value);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
472 g_free(h->icy_metadata.stream_name);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
473 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
474 }
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
475
3078
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
476 if (neon_strcmp(name, "icy-br")) {
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
477 /*
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
478 * The server sent us a bitrate. We might want to use it.
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
479 */
3079
1637a04513dd neon: unbreak compile
William Pitcock <nenolod@atheme.org>
parents: 3078
diff changeset
480 _DEBUG("ICY bitrate: %d", atoi(value));
3078
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
481 h->icy_metadata.stream_bitrate = atoi(value);
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
482 }
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
483
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
484 continue;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
485 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
486
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
487 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
488 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
489
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
490 /*
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 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
493
2361
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
494 static int neon_proxy_auth_cb(void *userdata, const char *realm, int attempt, char *username, char *password) {
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
495
2523
769e17da93dd Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents: 2498
diff changeset
496 mcs_handle_t *db;
2361
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
497 gchar *value = NULL;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
498
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
499 _ENTER;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
500
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
501 if ((db = aud_cfg_db_open()) == NULL) {
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
502 _DEBUG("<%p> configdb failed to open!", userdata);
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
503 _LEAVE -1;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
504 }
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
505
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
506 aud_cfg_db_get_string(db, NULL, "proxy_user", &value);
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
507 if (!value) {
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
508 _DEBUG("<%p> proxy_auth requested but no proxy_user", userdata);
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
509 _LEAVE -1;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
510 }
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
511 g_strlcpy(username, value, NE_ABUFSIZ);
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
512 value = NULL;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
513
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
514 aud_cfg_db_get_string(db, NULL, "proxy_pass", &value);
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
515 if (!value) {
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
516 _DEBUG("<%p> proxy_auth requested but no proxy_pass", userdata);
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
517 _LEAVE -1;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
518 }
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
519 g_strlcpy(password, value, NE_ABUFSIZ);
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
520 value = NULL;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
521
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
522 _LEAVE attempt;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
523 }
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
524
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
525 /*
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
526 * -----
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
527 */
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
528
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
529 static int open_request(struct neon_handle* handle, gulong startbyte) {
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 int ret;
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
532 const ne_status* status;
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
533 ne_uri* rediruri;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
534
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
535 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
536
2993
e504acd50ecc Add more assertions.
William Pitcock <nenolod@atheme.org>
parents: 2971
diff changeset
537 g_return_val_if_fail(handle != NULL, -1);
e504acd50ecc Add more assertions.
William Pitcock <nenolod@atheme.org>
parents: 2971
diff changeset
538 g_return_val_if_fail(handle->purl != NULL, -1);
e504acd50ecc Add more assertions.
William Pitcock <nenolod@atheme.org>
parents: 2971
diff changeset
539
2114
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
540 if (handle->purl->query && *(handle->purl->query)) {
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
541 gchar *tmp = g_strdup_printf("%s?%s", handle->purl->path, handle->purl->query);
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
542 handle->request = ne_request_create(handle->session, "GET", tmp);
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
543 g_free(tmp);
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
544 } else {
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
545 handle->request = ne_request_create(handle->session, "GET", handle->purl->path);
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
546 }
0d77ec0c71d4 Send any query strings along with the HTTP request.
William Pitcock <nenolod@atheme.org>
parents: 2035
diff changeset
547
2565
6fd05978fd4b - Just send a "Range: " request header if we do not want to start from zero,
Ralf Ertzinger <ralf@skytale.net>
parents: 2523
diff changeset
548 if (0 < startbyte) {
6fd05978fd4b - Just send a "Range: " request header if we do not want to start from zero,
Ralf Ertzinger <ralf@skytale.net>
parents: 2523
diff changeset
549 ne_print_request_header(handle->request, "Range", "bytes=%ld-", startbyte);
6fd05978fd4b - Just send a "Range: " request header if we do not want to start from zero,
Ralf Ertzinger <ralf@skytale.net>
parents: 2523
diff changeset
550 }
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
551 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
552
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
553 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
554 * Try to connect to the server.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
555 */
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
556 _DEBUG("<%p> Connecting...", handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
557 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
558 status = ne_get_status(handle->request);
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
559 _DEBUG("<%p> Return: %d, Status: %d", handle, ret, status->code);
1740
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
560 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
561 /*
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
562 * Authorization required. Reconnect to
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
563 * authenticate
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
564 */
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
565 _DEBUG("Reconnecting due to 401");
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
566 ne_end_request(handle->request);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
567 ret = ne_begin_request(handle->request);
8feacd004f50 - Add HTTP auth support (http://<username>:<password>@.... scheme)
Ralf Ertzinger <ralf@skytale.net>
parents: 1730
diff changeset
568 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
569
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
570 if ((NE_OK == ret) && ((301 == status->code) || (302 == status->code) || (303 == status->code) || (307 == status->code))) {
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
571 /*
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
572 * Redirect encountered. Reconnect.
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
573 */
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
574 ne_end_request(handle->request);
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
575 ret = NE_REDIRECT;
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
576 }
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
577
2366
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
578 if ((NE_OK == ret) && (407 == status->code)) {
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
579 /*
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
580 * Proxy auth required. Reconnect to authenticate
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
581 */
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
582 _DEBUG("Reconnecting due to 407");
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
583 ne_end_request(handle->request);
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
584 ret = ne_begin_request(handle->request);
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
585 }
f0a895a1e50d - Add final part for proxy auth handling
Ralf Ertzinger <ralf@skytale.net>
parents: 2361
diff changeset
586
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
587 switch (ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
588 case NE_OK:
2566
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
589 if ((status->code > 199) && (status->code < 300)) {
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
590 /* URL opened OK */
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
591 _DEBUG("<%p> URL opened OK", handle);
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
592 handle->content_start = startbyte;
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
593 handle->pos = startbyte;
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
594 handle_headers(handle);
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
595 _LEAVE 0;
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
596 break;
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
597 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
598
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
599 case NE_REDIRECT:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
600 /* We hit a redirect. Handle it. */
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
601 _DEBUG("<%p> Redirect encountered", handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
602 handle->redircount += 1;
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
603 rediruri = (ne_uri*)ne_redirect_location(handle->session);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
604 ne_request_destroy(handle->request);
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
605
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
606 if (NULL == rediruri) {
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
607 _ERROR("<%p> Could not parse redirect response", handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
608 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
609 }
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
610 ne_uri_free(handle->purl);
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
611 ne_uri_copy(handle->purl, rediruri);
1722
2e33cfa6a872 - Correct some compiler warnings
Ralf Ertzinger <ralf@skytale.net>
parents: 1719
diff changeset
612 _LEAVE 1;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
613 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
614
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
615 default:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
616 /* Something went wrong. */
2566
12aa69e560b2 - Ignore status codes other than 2xx for NE_OK
Ralf Ertzinger <ralf@skytale.net>
parents: 2565
diff changeset
617 _ERROR("<%p> Could not open URL: %d (%d)", handle, ret, status->code);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
618 if (1 == ret) {
2333
1a4f8ea5eb2a small fixes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2324
diff changeset
619 _ERROR("<%p> neon error string: %s", handle, ne_get_error(handle->session));
1719
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 ne_request_destroy(handle->request);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
622 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
623 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
624 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
625 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
626
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
627 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
628 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
629 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
630
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
631 static gint open_handle(struct neon_handle* handle, gulong startbyte) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
632
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
633 gint ret;
2523
769e17da93dd Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents: 2498
diff changeset
634 mcs_handle_t* db;
2410
d0c5974cad17 Fix the bug !!!oneoneone+1.
William Pitcock <nenolod@atheme.org>
parents: 2369
diff changeset
635 gchar* proxy_host = NULL;
d0c5974cad17 Fix the bug !!!oneoneone+1.
William Pitcock <nenolod@atheme.org>
parents: 2369
diff changeset
636 gchar* proxy_port_s = NULL;
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
637 gchar* endptr;
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
638 guint proxy_port = 0;
2361
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
639 gboolean use_proxy, use_proxy_auth;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
640
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
641 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
642
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
643 db = aud_cfg_db_open();
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
644 if (FALSE == aud_cfg_db_get_bool(db, NULL, "use_proxy", &use_proxy)) {
1923
bf6a0330c939 - Properly check if we could read the use_proxy property from the config
Ralf Ertzinger <ralf@skytale.net>
parents: 1908
diff changeset
645 use_proxy = FALSE;
bf6a0330c939 - Properly check if we could read the use_proxy property from the config
Ralf Ertzinger <ralf@skytale.net>
parents: 1908
diff changeset
646 }
bf6a0330c939 - Properly check if we could read the use_proxy property from the config
Ralf Ertzinger <ralf@skytale.net>
parents: 1908
diff changeset
647
2361
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
648 if (FALSE == aud_cfg_db_get_bool(db, NULL, "use_proxy_auth", &use_proxy_auth)) {
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
649 use_proxy_auth = FALSE;
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
650 }
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
651
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
652 if (use_proxy) {
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
653 if (FALSE == aud_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host)) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
654 _ERROR("<%p> Could not read proxy host, disabling proxy use", handle);
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
655 use_proxy = FALSE;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
656 }
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
657 if (FALSE == aud_cfg_db_get_string(db, NULL, "proxy_port", &proxy_port_s)) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
658 _ERROR("<%p> Could not read proxy port, disabling proxy use", handle);
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
659 use_proxy = FALSE;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
660 }
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
661 proxy_port = strtoul(proxy_port_s, &endptr, 10);
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
662 if (!((*proxy_port_s != '\0') && (*endptr == '\0') && (proxy_port < 65536))) {
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
663 /*
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
664 * Invalid data
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
665 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
666 _ERROR("<%p> Invalid proxy port, disabling proxy use", handle);
1761
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
667 use_proxy = FALSE;
78d29eb44276 - Fix config db handling
Ralf Ertzinger <ralf@skytale.net>
parents: 1760
diff changeset
668 }
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
669 }
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2114
diff changeset
670 aud_cfg_db_close(db);
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
671
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
672 handle->redircount = 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
673
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
674 _DEBUG("<%p> Parsing URL", handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
675 if (0 != ne_uri_parse(handle->url, handle->purl)) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
676 _ERROR("<%p> Could not parse URL '%s'", handle, handle->url);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
677 _LEAVE -1;
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
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
680 while (handle->redircount < 10) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
681
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
682 if (0 == handle->purl->port) {
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
683 handle->purl->port = ne_uri_defaultport(handle->purl->scheme);
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
684 }
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
685
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
686 _DEBUG("<%p> Creating session to %s://%s:%d", handle, handle->purl->scheme, handle->purl->host, handle->purl->port);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
687 handle->session = ne_session_create(handle->purl->scheme, handle->purl->host, handle->purl->port);
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
688 ne_redirect_register(handle->session);
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
689 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
690 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
691 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
692
2670
53ed12578b57 Don't check for neon 0.27, but for ne_set_connect_timeout.
Jonathan Schleifer <js-audacious@webkeks.org>
parents: 2664
diff changeset
693 #ifdef HAVE_NE_SET_CONNECT_TIMEOUT
2662
8e4abb83e560 Check for libneon >= 0.27 and conditionally compile with ne_set_connect_timeout().
Matti Hamalainen <ccr@tnsp.org>
parents: 2659
diff changeset
694 ne_set_connect_timeout(handle->session, 10);
8e4abb83e560 Check for libneon >= 0.27 and conditionally compile with ne_set_connect_timeout().
Matti Hamalainen <ccr@tnsp.org>
parents: 2659
diff changeset
695 #endif
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
696
1729
eaa8a5747628 - Add network timeouts
Ralf Ertzinger <ralf@skytale.net>
parents: 1722
diff changeset
697 ne_set_read_timeout(handle->session, 10);
2654
90761c8aaba1 Use PACKAGE_VERSION in the user agent string.
Matti Hamalainen <ccr@tnsp.org>
parents: 2653
diff changeset
698 ne_set_useragent(handle->session, "Audacious/" PACKAGE_VERSION );
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
699
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
700 if (use_proxy) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
701 _DEBUG("<%p> Using proxy: %s:%d", handle, proxy_host, proxy_port);
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
702 ne_session_proxy(handle->session, proxy_host, proxy_port);
2361
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
703
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
704 if (use_proxy_auth) {
2369
e145ee199e1d - Fix two debugging statements
Ralf Ertzinger <ralf@skytale.net>
parents: 2367
diff changeset
705 _DEBUG("<%p> Using proxy authentication", handle);
2367
04a5792e0c0f - Try a diffenent approach for proxy auth
Ralf Ertzinger <ralf@skytale.net>
parents: 2366
diff changeset
706 ne_add_proxy_auth(handle->session, NE_AUTH_BASIC, neon_proxy_auth_cb, (void *)handle);
2361
c831816c0b87 Add support for proxy_use_auth.
William Pitcock <nenolod@atheme.org>
parents: 2333
diff changeset
707 }
1760
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
708 }
8f9fd9fbf6cd - Proxy support
Ralf Ertzinger <ralf@skytale.net>
parents: 1752
diff changeset
709
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
710 _DEBUG("<%p> Creating request", handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
711 ret = open_request(handle, startbyte);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
712
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
713 if (0 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
714 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
715 } else if (-1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
716 ne_session_destroy(handle->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
717 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
718 }
2324
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
719
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
720 _DEBUG("<%p> Following redirect...", handle);
6ad2dffcad47 - Work around some funny design decisions regarding redirect handling in neon
Ralf Ertzinger <ralf@skytale.net>
parents: 2310
diff changeset
721 ne_session_destroy(handle->session);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
722 }
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 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
725 * 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
726 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
727
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
728 _ERROR("<%p> Redirect count exceeded for URL %s", handle, handle->url);
1719
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 _LEAVE 1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
731 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
732
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
733 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
734 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
735 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
736
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
737 static gint fill_buffer(struct neon_handle* h) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
738
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
739 gssize bsize;
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
740 gchar buffer[NEON_NETBLKSIZE];
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
741 gssize to_read;
1719
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 _ENTER;
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 bsize = free_rb(&h->rb);
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
746 to_read = MIN(bsize, NEON_NETBLKSIZE);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
747
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
748 _DEBUG("<%p> %d bytes free in buffer, trying to read %d bytes max", h, bsize, to_read);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
749
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
750 _DEBUG("<%p> Reading from the network....", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
751 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
752 if (0 == bsize) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
753 _DEBUG("<%p> End of file encountered", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
754 _LEAVE 1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
755 } else {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
756 _ERROR("<%p> Error while reading from the network", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
757 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
758 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
759 }
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
760 _DEBUG("<%p> Read %d bytes from the network", h, bsize);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
761
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
762 if (0 != write_rb(&(h->rb), buffer, bsize)) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
763 _ERROR("<%p> Error putting data into buffer", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
764 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
765 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
766
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
767 _LEAVE 0;
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 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
771 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
772 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
773
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
774 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
775
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
776 gssize bfree;
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
777 gint ret;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
778
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
779 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
780
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
781 bfree = free_rb(&h->rb);
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
782 _DEBUG("<%p> Filling buffer up to max %d bytes free, %d bytes free now", h, maxfree, bfree);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
783
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
784 while (bfree > maxfree) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
785 ret = fill_buffer(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
786 if (-1 == ret) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
787 _ERROR("<%p> Error while filling buffer", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
788 _LEAVE ret;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
789 } else if (1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
790 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
791 * 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
792 */
2567
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
793 _LEAVE 1;
1719
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 bfree = free_rb(&h->rb);
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 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
800 }
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 /*
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 */
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 static gpointer reader_thread(void* data) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
807
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
808 struct neon_handle* h = (struct neon_handle*)data;
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
809 gint ret;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
810
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
811 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
812
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
813 g_mutex_lock(h->reader_status.mutex);
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 while(h->reader_status.reading) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
816
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
817 /*
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
818 * Hit the network only if we have more than NEON_NETBLKSIZE of free buffer
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
819 */
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
820 if (NEON_NETBLKSIZE < free_rb_locked(&h->rb)) {
2152
8a5231ff9c4f - Use a single lock for the ring buffer and the condition variable
Ralf Ertzinger <ralf@skytale.net>
parents: 2124
diff changeset
821 g_mutex_unlock(h->reader_status.mutex);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
822
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
823 _DEBUG("<%p> Filling buffer...", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
824 ret = fill_buffer(h);
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 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
827 if (-1 == ret) {
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 * Error encountered while reading from the network.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
830 * Set the error flag and terminate the
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
831 * reader thread.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
832 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
833 _ERROR("<%p> Error while reading from the network. Terminating reader thread", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
834 h->reader_status.status = NEON_READER_ERROR;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
835 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
836 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
837 } else if (1 == ret) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
838 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
839 * EOF encountered while reading from the
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
840 * network. Set the EOF status and exit.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
841 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
842 _DEBUG("<%p> EOF encountered while reading from the network. Terminating reader thread", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
843 h->reader_status.status = NEON_READER_EOF;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
844 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
845 _LEAVE NULL;
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
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 * 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
850 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
851 _DEBUG("<%p> Network read succeeded", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
852 } else {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
853 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
854 * Not enough free space in the buffer.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
855 * 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
856 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
857 _DEBUG("<%p> Reader thread going to sleep", h);
2152
8a5231ff9c4f - Use a single lock for the ring buffer and the condition variable
Ralf Ertzinger <ralf@skytale.net>
parents: 2124
diff changeset
858 g_cond_wait(h->reader_status.cond, h->reader_status.mutex);
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
859 _DEBUG("<%p> Reader thread woke up", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
860 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
861 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
862
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
863 _DEBUG("<%p> Reader thread terminating gracefully", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
864 h->reader_status.status = NEON_READER_TERM;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
865 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
866
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
867 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
868 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
869
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
870 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
871 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
872 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
873
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
874 VFSFile* neon_aud_vfs_fopen_impl(const gchar* path, const gchar* mode) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
875 VFSFile* file;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
876 struct neon_handle* handle;
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 _ENTER;
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 _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
881
2031
e3d9ef56fec8 back out my change
William Pitcock <nenolod@atheme.org>
parents: 2029
diff changeset
882 if (NULL == (file = g_new0(VFSFile, 1))) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
883 _ERROR("Could not allocate memory for filehandle");
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
884 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
885 }
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 (NULL == (handle = handle_init())) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
888 _ERROR("Could not allocate memory for neon handle");
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
889 g_free(file);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
890 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
891 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
892
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
893 _DEBUG("Allocated new handle: %p", handle);
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
894
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
895 if (NULL == (handle->url = strdup(path))) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
896 _ERROR("<%p> Could not copy URL string", handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
897 handle_free(handle);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
898 g_free(file);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
899 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
900 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
901
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
902 if (0 != open_handle(handle, 0)) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
903 _ERROR("<%p> Could not open URL", handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
904 handle_free(handle);
2655
50f6dce4b91a Use Glib memory allocation and free() consistently -- libc malloc and free
Matti Hamalainen <ccr@tnsp.org>
parents: 2654
diff changeset
905 g_free(file);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
906 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
907 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
908
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
909 file->handle = handle;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
910 file->base = &neon_http_const;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
911
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
912 _LEAVE file;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
913 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
914
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
915 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
916 * ----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
917 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
918
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
919 gint neon_aud_vfs_fclose_impl(VFSFile* file) {
1719
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 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
922
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
923 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
924
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
925 if (NULL != h->reader) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
926 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
927 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
928
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
929 _DEBUG("<%p> Destroying request", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
930 if (NULL != h->request) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
931 ne_request_destroy(h->request);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
932 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
933
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
934 _DEBUG("<%p> Destroying session", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
935 ne_session_destroy(h->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
936
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
937 handle_free(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
938
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 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
941
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 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
944 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
945
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
946 gsize neon_aud_vfs_fread_impl(gpointer ptr_, gsize size, gsize nmemb, VFSFile* file) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
947
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
948 struct neon_handle* h = (struct neon_handle*)file->handle;
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
949 gint belem;
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
950 gint relem;
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
951 gint ret;
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
952 gchar icy_metadata[NEON_ICY_BUFSIZE];
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
953 guchar icy_metalen;
1719
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 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
956
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
957 if (NULL == h->request) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
958 _ERROR("<%p> No request to read from, seek gone wrong?", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
959 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
960 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
961
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
962 _DEBUG("<%p> Requesting %d elements of %d bytes size each (%d bytes total), to be stored at %p",
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
963 h, nmemb, size, (nmemb*size), ptr_);
1719
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 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
966 * 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
967 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
968 belem = used_rb(&h->rb) / size;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
969
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
970 if ((NULL != h->reader) && (0 == belem)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
971 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
972 * 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
973 * 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
974 * Kill the reader thread and restart.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
975 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
976 g_mutex_lock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
977 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
978 g_mutex_unlock(h->reader_status.mutex);
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
979 _ERROR("<%p> Buffer underrun, trying rebuffering", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
980 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
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 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
983 * 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
984 * again
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
985 */
2184
f2590691d4b7 - Fix locking issues causing spurious error messages (and possibly deadlocks)
Ralf Ertzinger <ralf@skytale.net>
parents: 2152
diff changeset
986 if ((NEON_READER_TERM != h->reader_status.status) &&
f2590691d4b7 - Fix locking issues causing spurious error messages (and possibly deadlocks)
Ralf Ertzinger <ralf@skytale.net>
parents: 2152
diff changeset
987 (NEON_READER_EOF != h->reader_status.status)) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
988 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
989 * 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
990 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
991 _ERROR("<%p> Reader thread did not terminate gracefully: %d", h, h->reader_status.status);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
992 _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
993 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
994 } else {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
995 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
996 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
997 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
998
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
999 if (NULL == h->reader) {
3126
2d2a50196556 Backed out changeset 617cd51dfee5
William Pitcock <nenolod@atheme.org>
parents: 3124
diff changeset
1000 if (NEON_READER_EOF != h->reader_status.status) {
2567
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1001 /*
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1002 * There is no reader thread yet. Read the first bytes from
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1003 * the network ourselves, and then fire up the reader thread
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1004 * to keep the buffer filled up.
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1005 */
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1006 _DEBUG("<%p> Doing initial buffer fill", h);
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
1007 ret = fill_buffer_limit(h, NEON_BUFSIZE/2);
2567
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1008
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1009 if (-1 == ret) {
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1010 _ERROR("<%p> Error while reading from the network", h);
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1011 _LEAVE 0;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1012 } else if (1 == ret) {
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1013 _DEBUG("<%p> EOF during initial read", h);
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1014 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1015
2567
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1016 /*
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1017 * We have some data in the buffer now.
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1018 * Start the reader thread if we did not reach EOF during
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1019 * the initial fill
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1020 */
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1021 g_mutex_lock(h->reader_status.mutex);
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1022 if (0 == ret) {
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1023 h->reader_status.reading = TRUE;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1024 _DEBUG("<%p> Starting reader thread", h);
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1025 if (NULL == (h->reader = g_thread_create(reader_thread, h, TRUE, NULL))) {
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1026 h->reader_status.reading = FALSE;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1027 g_mutex_unlock(h->reader_status.mutex);
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1028 _ERROR("<%p> Error creating reader thread!", h);
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1029 _LEAVE 0;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1030 }
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1031 h->reader_status.status = NEON_READER_RUN;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1032 } else {
2568
92f6d0503c04 - Print the EOF status in _feof()
Ralf Ertzinger <ralf@skytale.net>
parents: 2567
diff changeset
1033 _DEBUG("<%p> No reader thread needed (stream has reached EOF during fill)", h);
2567
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1034 h->reader_status.reading = FALSE;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1035 h->reader_status.status = NEON_READER_EOF;
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1036 }
a9d6ce7b8c68 - Handle situations better where the initial buffer fill hits EOF on the stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2566
diff changeset
1037 g_mutex_unlock(h->reader_status.mutex);
1719
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 } else {
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 * 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
1042 * shape.
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 g_mutex_lock(h->reader_status.mutex);
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1045 _DEBUG("<%p> Reader thread status: %d", h, h->reader_status.status);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1046 switch (h->reader_status.status) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1047 case NEON_READER_INIT:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1048 case NEON_READER_RUN:
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 * All is well, nothing to be done.
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 break;
3132
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1053 case NEON_READER_ERROR:
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1054 /*
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1055 * A reader error happened. Log it, and treat it like an EOF condition, by falling through
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1056 * to the NEON_READER_EOF codepath. --nenolod
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1057 */
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1058 _DEBUG("<%p> NEON_READER_ERROR happened. Terminating reader thread and marking EOF.", h);
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1059 h->reader_status.status = NEON_READER_EOF;
3133
005959102811 neon: avoid deadlocks in NEON_STATUS_ERROR codepath.
William Pitcock <nenolod@atheme.org>
parents: 3132
diff changeset
1060 g_mutex_unlock(h->reader_status.mutex);
3132
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1061
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1062 if (NULL != h->reader)
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1063 kill_reader(h);
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1064
3133
005959102811 neon: avoid deadlocks in NEON_STATUS_ERROR codepath.
William Pitcock <nenolod@atheme.org>
parents: 3132
diff changeset
1065 g_mutex_lock(h->reader_status.mutex);
005959102811 neon: avoid deadlocks in NEON_STATUS_ERROR codepath.
William Pitcock <nenolod@atheme.org>
parents: 3132
diff changeset
1066
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1067 case NEON_READER_EOF:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1068 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1069 * 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
1070 * 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
1071 */
2184
f2590691d4b7 - Fix locking issues causing spurious error messages (and possibly deadlocks)
Ralf Ertzinger <ralf@skytale.net>
parents: 2152
diff changeset
1072 if (0 == used_rb_locked(&h->rb)) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1073 _DEBUG("<%p> Reached end of stream", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1074 g_mutex_unlock(h->reader_status.mutex);
3132
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1075
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1076 if (NULL != h->reader)
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1077 kill_reader(h);
f8686c591e49 neon: More gracefully handle the NEON_READER_ERROR condition.
William Pitcock <nenolod@atheme.org>
parents: 3126
diff changeset
1078
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1079 h->eof = TRUE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1080 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1081 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1082 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1083 case NEON_READER_TERM:
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 * The reader thread terminated gracefully, most
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1086 * likely on our own request.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1087 * We should not get here.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1088 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1089 _ERROR("<%p> Reader thread terminated and fread() called. How did we get here?", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1090 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1091 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1092 _LEAVE 0;
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 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1095 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1096
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 * Deliver data from the buffer
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1099 */
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1100 if (0 == used_rb(&h->rb)) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1101 /*
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1102 * 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
1103 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1104 _ERROR("<%p> Buffer still underrun, fatal.", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1105 _LEAVE 0;
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
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1108 if (0 != h->icy_metaint) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1109 _DEBUG("<%p> %ld bytes left before next ICY metadata announcement", h, h->icy_metaleft);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1110 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
1111 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1112 * 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
1113 * 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
1114 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1115 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
1116
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1117 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1118 * 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
1119 * 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
1120 * 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
1121 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1122 _DEBUG("<%p> Expecting %d bytes of ICY metadata", h, (icy_metalen*16));
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1123
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1124 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
1125 /* 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
1126 * 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
1127 * 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
1128 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1129 _ERROR("<%p> Buffer underrun when reading metadata. Expect audio degradation", 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
1130 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
1131 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1132 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1133 * 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
1134 */
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1135 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
1136 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
1137 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
1138 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1139 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1140
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1141 /*
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1142 * 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
1143 * 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
1144 */
1749
d2e3eef90719 - Read the correct amount of data from the buffer when handling ShoutCast metadata
Ralf Ertzinger <ralf@skytale.net>
parents: 1742
diff changeset
1145 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
1146 } else {
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1147 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
1148 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1149
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1150 relem = MIN(belem, nmemb);
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1151 _DEBUG("<%p> %d elements of returnable data in the buffer", h, 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
1152 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
1153
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1154 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1155 * Signal the network thread to continue reading
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1156 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1157 g_mutex_lock(h->reader_status.mutex);
2569
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1158 if (NEON_READER_EOF == h->reader_status.status) {
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1159 if (0 == free_rb_locked(&h->rb)) {
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1160 _DEBUG("<%p> stream EOF reached and buffer empty", h);
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1161 h->eof = TRUE;
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1162 }
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1163 } else {
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1164 _DEBUG("<%p> Waking up reader thread", h);
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1165 g_cond_signal(h->reader_status.cond);
049f212e7e00 - Fix case where the prebuffering exhausts the stream, and all data is read on the first go
Ralf Ertzinger <ralf@skytale.net>
parents: 2568
diff changeset
1166 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1167 g_mutex_unlock(h->reader_status.mutex);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1168
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1169 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
1170 h->icy_metaleft -= (relem*size);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1171
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1172 _DEBUG("<%p> Returning %d elements", h, relem);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1173
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1174 _LEAVE relem;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1175 }
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 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1179 * -----
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
2653
c71b550c3345 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2652
diff changeset
1182 gsize neon_aud_vfs_fwrite_impl(gconstpointer ptr, gsize size, gsize nmemb, VFSFile* file) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1183
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1184 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1185
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1186 _ERROR("<%p> NOT IMPLEMENTED", file->handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1187
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1188 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1189 }
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 /*
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 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1194
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1195 gint neon_aud_vfs_getc_impl(VFSFile* file) {
3075
eed75824b3f7 Return bytes in the range 0x80-0xff as positive; negative values indicate an error (fixes bug #27).
John Lindgren <john.lindgren@tds.net>
parents: 2993
diff changeset
1196 unsigned char c;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1197 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1198
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1199 if (1 != neon_aud_vfs_fread_impl(&c, 1, 1, file)) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1200 _ERROR("<%p> Could not getc()!", file->handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1201 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1202 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1203
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1204 _LEAVE c;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1205 }
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 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1208 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1209 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1210
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1211 gint neon_aud_vfs_ungetc_impl(gint c, VFSFile* stream) {
1719
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 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1214
2310
11b4a4e15f63 - Fix typo in neon_aud_vfs_ungetc_impl()
Ralf Ertzinger <ralf@skytale.net>
parents: 2308
diff changeset
1215 _ERROR("<%p> NOT IMPLEMENTED", stream->handle);
1719
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
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1224 void neon_aud_vfs_rewind_impl(VFSFile* file) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1225
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1226 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1227
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1228 (void)neon_aud_vfs_fseek_impl(file, 0L, SEEK_SET);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1229
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1230 _LEAVE;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1231 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1232
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1233 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1234 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1235 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1236
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1237 glong neon_aud_vfs_ftell_impl(VFSFile* file) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1238
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1239 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
1240
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1241 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1242
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1243 _DEBUG("<%p> Current file position: %ld", h, h->pos);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1244
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1245 _LEAVE h->pos;
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
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1252 gboolean neon_aud_vfs_feof_impl(VFSFile* file) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1253
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1254 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
1255
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1256 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1257
2568
92f6d0503c04 - Print the EOF status in _feof()
Ralf Ertzinger <ralf@skytale.net>
parents: 2567
diff changeset
1258 _DEBUG("<%p> EOF status: %s", h, h->eof?"TRUE":"FALSE");
92f6d0503c04 - Print the EOF status in _feof()
Ralf Ertzinger <ralf@skytale.net>
parents: 2567
diff changeset
1259
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1260 _LEAVE h->eof;
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
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1263 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1264 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1265 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1266
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1267 gint neon_aud_vfs_truncate_impl(VFSFile* file, glong size) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1268
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1269 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1270
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1271 _ERROR("<%p> NOT IMPLEMENTED", file->handle);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1272
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1273 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1274 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1275
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1276 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1277 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1278 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1279
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1280 gint neon_aud_vfs_fseek_impl(VFSFile* file, glong offset, gint whence) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1281
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1282 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
1283 long newpos;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1284 long content_length;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1285
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1286 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1287
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1288 _DEBUG("<%p> Seek requested: offset %ld, whence %d", h, offset, whence);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1289 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1290 * 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
1291 * - the server must advertise a content-length
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1292 * - the server must advertise accept-ranges: bytes
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1293 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1294 if ((-1 == h->content_length) || !h->can_ranges) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1295 _DEBUG("<%p> Can not seek due to server restrictions", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1296 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1297 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1298
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1299 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
1300
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1301 switch (whence) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1302 case SEEK_SET:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1303 newpos = offset;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1304 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1305 case SEEK_CUR:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1306 newpos = h->pos + offset;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1307 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1308 case SEEK_END:
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1309 newpos = content_length + offset;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1310 break;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1311 default:
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1312 _ERROR("<%p> Invalid whence specified", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1313 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1314 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1315
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1316 _DEBUG("<%p> Position to seek to: %ld, current: %ld", h, newpos, h->pos);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1317 if (0 > newpos) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1318 _ERROR("<%p> Can not seek before start of stream", h);
2031
e3d9ef56fec8 back out my change
William Pitcock <nenolod@atheme.org>
parents: 2029
diff changeset
1319 _LEAVE -1;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1320 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1321
2630
76924684ee4f - Fix seeking beyond end of stream
Ralf Ertzinger <ralf@skytale.net>
parents: 2569
diff changeset
1322 if (newpos >= content_length) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1323 _ERROR("<%p> Can not seek beyond end of stream", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1324 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1325 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1326
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1327 if (newpos == h->pos) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1328 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1329 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1330
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1331 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1332 * 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
1333 * - 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
1334 * - destroy the current request
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1335 * - dump all data currently in the ringbuffer
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1336 * - create a new request starting at newpos
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1337 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1338 if (NULL != h->reader) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1339 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1340 * There may be a thread still running.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1341 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1342 kill_reader(h);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1343 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1344
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1345 ne_request_destroy(h->request);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1346 ne_session_destroy(h->session);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1347 reset_rb(&h->rb);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1348
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1349 if (0 != open_handle(h, newpos)) {
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1350 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1351 * 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
1352 * 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
1353 * 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
1354 * read request
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1355 */
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1356 _ERROR("<%p> Error while creating new request!", h);
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1357 h->request = NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1358 _LEAVE -1;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1359 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1360
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1361 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1362 * 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
1363 * the reader thread again.
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1364 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1365
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1366 _LEAVE 0;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1367 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1368
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1369 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1370 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1371 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1372
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1373 gchar *neon_aud_vfs_metadata_impl(VFSFile* file, const gchar* field) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1374
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1375 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
1376
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1377 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1378
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1379 _DEBUG("<%p> Field name: %s", h, field);
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1380
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
1381 if (neon_strcmp(field, "track-name")) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1382 _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
1383 }
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1384
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
1385 if (neon_strcmp(field, "stream-name")) {
1730
50d151b259bb - Add lots of code to support the completely braindead concept that is StreamCast
Ralf Ertzinger <ralf@skytale.net>
parents: 1729
diff changeset
1386 _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
1387 }
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1388
2664
21c036700033 Add and use a neon_strcmp() function to simplify string comparisions.
Matti Hamalainen <ccr@tnsp.org>
parents: 2663
diff changeset
1389 if (neon_strcmp(field, "content-type")) {
1742
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
1390 _LEAVE g_strdup(h->icy_metadata.stream_contenttype);
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
1391 }
4f4634573e41 - Free memory for ICY tags
Ralf Ertzinger <ralf@skytale.net>
parents: 1741
diff changeset
1392
3078
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
1393 if (neon_strcmp(field, "content-bitrate")) {
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
1394 _LEAVE g_strdup_printf("%d", h->icy_metadata.stream_bitrate * 1000);
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
1395 }
3f023c46e40c neon: Add support for icy-br.
William Pitcock <nenolod@atheme.org>
parents: 3075
diff changeset
1396
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1397 _LEAVE NULL;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1398 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1399
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1400 /*
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1401 * -----
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1402 */
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1403
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1972
diff changeset
1404 off_t neon_aud_vfs_fsize_impl(VFSFile* file) {
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1405
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1406 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
1407
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1408 _ENTER;
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1409
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1410 if (-1 == h->content_length) {
2307
1606353a9fcb - Whenever possible, mention the currently used handle in error/debug messages, to aid debugging of concurrent requests
Ralf Ertzinger <ralf@skytale.net>
parents: 2184
diff changeset
1411 _DEBUG("<%p> Unknown content length", h);
1926
a1ed9f7cb4cc - Return -1 from fsize() on unknown content length
Ralf Ertzinger <ralf@skytale.net>
parents: 1925
diff changeset
1412 _LEAVE -1;
1719
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1413 }
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1414
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1415 _LEAVE (h->content_start + h->content_length);
29c35cb8873e - Add neon HTTP transport plugin sources (for real)
Ralf Ertzinger <ralf@skytale.net>
parents:
diff changeset
1416 }
2663
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
1417
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
1418
45aea2e3592a General code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2662
diff changeset
1419