OLD | NEW |
1 /* | 1 /* |
2 * Gopher protocol | 2 * Gopher protocol |
3 * | 3 * |
4 * Copyright (c) 2009 Toshimitsu Kimura | 4 * Copyright (c) 2009 Toshimitsu Kimura |
5 * | 5 * |
6 * based on libavformat/http.c, Copyright (c) 2000, 2001 Fabrice Bellard | 6 * based on libavformat/http.c, Copyright (c) 2000, 2001 Fabrice Bellard |
7 * | 7 * |
8 * This file is part of FFmpeg. | 8 * This file is part of FFmpeg. |
9 * | 9 * |
10 * FFmpeg is free software; you can redistribute it and/or | 10 * FFmpeg is free software; you can redistribute it and/or |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 h->is_streamed = 1; | 83 h->is_streamed = 1; |
84 | 84 |
85 s = av_malloc(sizeof(GopherContext)); | 85 s = av_malloc(sizeof(GopherContext)); |
86 if (!s) { | 86 if (!s) { |
87 return AVERROR(ENOMEM); | 87 return AVERROR(ENOMEM); |
88 } | 88 } |
89 h->priv_data = s; | 89 h->priv_data = s; |
90 | 90 |
91 /* needed in any case to build the host string */ | 91 /* needed in any case to build the host string */ |
92 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, | 92 ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, |
93 path, sizeof(path), uri); | 93 path, sizeof(path), uri); |
94 | 94 |
95 if (port < 0) | 95 if (port < 0) |
96 port = 70; | 96 port = 70; |
97 | 97 |
98 snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port); | 98 ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); |
99 | 99 |
100 s->hd = NULL; | 100 s->hd = NULL; |
101 err = url_open(&s->hd, buf, URL_RDWR); | 101 err = url_open(&s->hd, buf, URL_RDWR); |
102 if (err < 0) | 102 if (err < 0) |
103 goto fail; | 103 goto fail; |
104 | 104 |
105 if ((err = gopher_connect(h, path)) < 0) | 105 if ((err = gopher_connect(h, path)) < 0) |
106 goto fail; | 106 goto fail; |
107 return 0; | 107 return 0; |
108 fail: | 108 fail: |
(...skipping 10 matching lines...) Expand all Loading... |
119 | 119 |
120 | 120 |
121 URLProtocol gopher_protocol = { | 121 URLProtocol gopher_protocol = { |
122 "gopher", | 122 "gopher", |
123 gopher_open, | 123 gopher_open, |
124 gopher_read, | 124 gopher_read, |
125 gopher_write, | 125 gopher_write, |
126 NULL, /*seek*/ | 126 NULL, /*seek*/ |
127 gopher_close, | 127 gopher_close, |
128 }; | 128 }; |
OLD | NEW |