从打开的“ FILE *”中获取缓冲参数 [英] Get Buffering Parameters From an Open `FILE*`
问题描述
在C语言中,我们可以使用 setvbuf(...)进行设置缓冲区,缓冲区大小和缓冲模式。我很惊讶地发现,在打开 FILE *
的情况下,没有人问过如何读取这些值(例如 stdout
或由用户提供)。即,如何实现 getvbuf(...)
例程(甚至其中的一部分)?
In C, we can use setvbuf(...) to set a buffer, its size, and a buffering mode. I am surprised to find that no one has asked how to read these values, given an open FILE*
(e.g. stdout
, or user-provided). I.e., how could one implement a "getvbuf(...)
" routine (or even a subset of it)?
void getvbuf(FILE* stream, char** pbuf,int* bufmode,size_t* bufsize);
推荐答案
我认为它不可以作为标准。但是Solaris引入了一些非标准的机制来查询这些属性中的少数几个,这些属性在GNU C编译器中也可用。
I don't think its available as part of the standard. However Solaris has introduced some non standard mechanism to query few of these properties which are also available in GNU C compiler.
请检查此以获得更多详细信息: ://www.gnu.org/software/libc/manual/html_node/Controlling-Buffering.html rel = nofollow noreferrer> https://www.gnu.org/software/libc/manual/html_node/Controlling- Buffering.html
Check this for more details: https://www.gnu.org/software/libc/manual/html_node/Controlling-Buffering.html
我很想知道您想在其中使用getvbuf(..)之类的用例。
I was curious to know the use case where you want to do a getvbuf(..) kind of stuff.
这篇关于从打开的“ FILE *”中获取缓冲参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!