/**
* Unescape the given string until a non escaped terminating char,
* and return the token corresponding to the unescaped string.
*
* The normal \ and ' escaping is supported. Leading and trailing
* whitespaces are removed, unless they are escaped with '\' or are
* enclosed between ''.
*
* @param buf the buffer to parse, buf will be updated to point to the
* terminating char
* @param term a 0-terminated list of terminating chars
* @return the malloced unescaped string, which must be av_freed by
* the user, NULL in case of allocation failure
*/
char *av_get_token(const char **buf, const char *term);
从*buf字符串找到第一个出现在term中的任意一个字符,将*buf进行截断,前面一部分(不包含term中的任意一个字符)通过返回值反馈,后面一部分在*buf反馈。
测试程序:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/avstring.h"
int main(int argc, char **argv)
{
char *str = (char *)malloc(16);

本文介绍了`av_get_token`函数的用途,它用于从字符串中提取未转义的子串直到遇到指定的终止字符。测试程序展示了如何使用该函数,并给出了不同终止字符的测试案例,演示了函数如何截取并返回字符串的不同部分。
最低0.47元/天 解锁文章
5188

被折叠的 条评论
为什么被折叠?



