[FFmpeg-devel] [PATCH] Gopher client support

nazo lovesyao
Sat Jan 31 14:25:11 CET 2009


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.

-- 
Nazo (T.K.) <lovesyao at gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gopher.diff
Type: text/x-patch
Size: 5210 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090131/ea8fcc9c/attachment.bin>



More information about the ffmpeg-devel mailing list