URLProtocol结构体

typedef struct URLProtocol

{

const char *name;

//用的统一的模板函数

int(*url_open)(URLContext *h, const char *filename, int flags);

int(*url_read)(URLContext *h, unsigned char *buf, int size);

int(*url_write)(URLContext *h, unsigned char *buf, int size);

offset_t(*url_seek)(URLContext *h, offset_t pos, int whence);

int(*url_close)(URLContext *h);

struct URLProtocol *next;

} URLProtocol;ffurl_connect

file的主要结构的初始化如下:

URLProtocol ff_file_protocol = {

    .name                = "file",

    .url_open            = file_open,

    .url_read            = file_read,

    .url_write           = file_write,

    .url_seek            = file_seek,

    .url_close           = file_close,

    .url_get_file_handle = file_get_handle,

    .url_check           = file_check,

}

说明:

URLProtocol 是类似COM接口的数据结构,表示广义的输入文件,着重于功能函数,一种广义的输入文件对应一个URLProtocol结构,比如filepipetcp等等,定义了对file tcp等方式的通用模板函数。next变量用于把所有支持的广义的输入文件连接成链表,便于遍历查找。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值