1 /*
2 * Gopher protocol
3 *
4 * Copyright (c) 2009 Toshimitsu Kimura
5 * Copyright (c) 2021 parazyd <parazyd@dyne.org>
6 *
7 * based on libavformat/http.c, Copyright (c) 2000, 2001 Fabrice Bellard
8 *
9 * This file is part of FFmpeg.
10 *
11 * FFmpeg is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * FFmpeg is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with FFmpeg; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #include "config.h"
27 #include "config_components.h"
28
34
38
40 {
43 }
44
46 {
48
49 if (!*path)
return AVERROR(EINVAL);
50 switch (*++path) {
51 case ';':
52 case '<':
53 case '5':
54 case '9':
55 case 's':
56 path = strchr(path, '/');
57 if (!path)
return AVERROR(EINVAL);
58 break;
59 default:
61 "Gopher protocol type '%c' not supported yet!\n",
62 *path);
64 }
65
66 /* send gopher sector */
68
71
72 return 0;
73 }
74
76 {
79 return 0;
80 }
81
83 {
85 char proto[10], hostname[1024], auth[1024], path[1024], buf[1024];
86 int port, err;
87 const char *lower_proto = "tcp";
88
90
91 /* needed in any case to build the host string */
93 hostname, sizeof(hostname), &port, path, sizeof(path), uri);
94
95 if (port < 0)
96 port = 70;
97
98 if (!strcmp(proto, "gophers"))
99 lower_proto = "tls";
100
102
105 &
h->interrupt_callback,
NULL,
h->protocol_whitelist,
h->protocol_blacklist,
h);
106 if (err < 0)
108
111 return 0;
114 return err;
115 }
116
118 {
122 }
123
124 #if CONFIG_GOPHER_PROTOCOL
133 .default_whitelist = "gopher,tcp"
134 };
135 #endif /* CONFIG_GOPHER_PROTOCOL */
136
137 #if CONFIG_GOPHERS_PROTOCOL
146 .default_whitelist = "gopher,gophers,tcp,tls"
147 };
148 #endif /* CONFIG_GOPHERS_PROTOCOL */