1 /*
2 * Gopher protocol
3 *
4 * Copyright (c) 2009 Toshimitsu Kimura
5 *
6 * based on libavformat/http.c, Copyright (c) 2000, 2001 Fabrice Bellard
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
30
34
36 {
39 }
40
42 {
44
45 if (!*path)
return AVERROR(EINVAL);
46 switch (*++path) {
47 case '5':
48 case '9':
49 path = strchr(path, '/');
50 if (!path)
return AVERROR(EINVAL);
51 break;
52 default:
54 "Gopher protocol type '%c' not supported yet!\n",
55 *path);
57 }
58
59 /* send gopher sector */
60 snprintf(buffer,
sizeof(buffer),
"%s\r\n", path);
61
64
65 return 0;
66 }
67
69 {
74 }
75 return 0;
76 }
77
79 {
81 char hostname[1024], auth[1024], path[1024],
buf[1024];
82 int port, err;
83
85
86 /* needed in any case to build the host string */
88 path, sizeof(path), uri);
89
90 if (port < 0)
91 port = 70;
92
94
98 if (err < 0)
99 goto fail;
100
102 goto fail;
103 return 0;
104 fail:
106 return err;
107 }
108
110 {
114 }
115
116
125 };