[FFmpeg-devel] [PATCH] Gopher client support
Michael Niedermayer
michaelni
Sat Jan 31 14:50:01 CET 2009
On Sat, Jan 31, 2009 at 10:25:11PM +0900, nazo wrote:
> Michael Niedermayer ????????:
>> [...]
>>> +static int gopher_open(URLContext *h, const char *uri, int flags)
>>> +{
>>> + GopherContext *s;
>>> + char hostname[1024], auth[1024], path[1024], buf[1024];
>>> + int port, err;
>>> + URLContext *hd = NULL;
>>> +
>>> + h->is_streamed = 1;
>>> +
>>> + s = av_malloc(sizeof(GopherContext));
>>> + if (!s) {
>>> + return AVERROR(ENOMEM);
>>> + }
>>> + h->priv_data = s;
>>> +
>>> + /* needed in any case to build the host string */
>>> + url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname),
>>> &port,
>>> + path, sizeof(path), uri);
>>> +
>>> + if (port < 0)
>>> + port = 70;
>>> +
>>> + snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port);
>>> + err = url_open(&hd, buf, URL_RDWR);
>>> + if (err < 0)
>>> + goto fail;
>>> +
>>> + s->hd = hd;
>>> + if ((err = gopher_connect(h, path)) < 0)
>>> + goto fail;
>>> + return 0;
>>> + fail:
>>> + if (hd)
>>> + url_close(hd);
>>> + av_free (s);
>> gopher_close()could be called here instead
>
> done
>
>>> + return err;
>>> +}
>>> +
>> [...]
>>> +static int gopher_close(URLContext *h)
>>> +{
>>> + GopherContext *s = h->priv_data;
>>> + url_close(s->hd);
>> s->hd should be set to NULL for saftey, in case gopher_close() is called
>> twice by mistake
>
> done
>
>>> + av_free(s);
>> av_freep(&h->priv_data);
>
> done
>
>> [...]
>
> attached new patch.
[...]
> +static int gopher_close(URLContext *h);
you dont need that you can move gopher_close before gopher_open
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I hate to see young programmers poisoned by the kind of thinking
Ulrich Drepper puts forward since it is simply too narrow -- Roman Shaposhnik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090131/1199f658/attachment.pgp>
More information about the ffmpeg-devel
mailing list