| 80 | } |
| 81 | |
| 82 | static int gopher_open(URLContext *h, const char *uri, int flags) |
| 83 | { |
| 84 | GopherContext *s = h->priv_data; |
| 85 | char proto[10], hostname[1024], auth[1024], path[1024], buf[1024]; |
| 86 | int port, err; |
| 87 | const char *lower_proto = "tcp"; |
| 88 | |
| 89 | h->is_streamed = 1; |
| 90 | |
| 91 | /* needed in any case to build the host string */ |
| 92 | av_url_split(proto, sizeof(proto), auth, sizeof(auth), |
| 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 | |
| 101 | ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL); |
| 102 | |
| 103 | s->hd = NULL; |
| 104 | err = ffurl_open_whitelist(&s->hd, buf, AVIO_FLAG_READ_WRITE, |
| 105 | &h->interrupt_callback, NULL, h->protocol_whitelist, h->protocol_blacklist, h); |
| 106 | if (err < 0) |
| 107 | goto fail; |
| 108 | |
| 109 | if ((err = gopher_connect(h, path)) < 0) |
| 110 | goto fail; |
| 111 | return 0; |
| 112 | fail: |
| 113 | gopher_close(h); |
| 114 | return err; |
| 115 | } |
| 116 | |
| 117 | static int gopher_read(URLContext *h, uint8_t *buf, int size) |
| 118 | { |
nothing calls this directly
no test coverage detected