Cleanup stdout write redirection.
- comments, naming, missing include
This commit is contained in:
parent
194b8e420a
commit
70a30a79d7
2 changed files with 26 additions and 5 deletions
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef _STDOUT_REDIRECT_H_
|
||||
#define _STDOUT_REDIRECT_H_
|
||||
|
||||
#include <sys/reent.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
|
@ -14,7 +16,26 @@ extern "C"
|
|||
|
||||
typedef long _WriteFunction(struct _reent *r, int fd, const char *ptr, int len );
|
||||
|
||||
/** Set implementation of write syscall for stdout.
|
||||
*
|
||||
* Use this function to redirect stdout for further processing (save to file, send over network).
|
||||
* It may be good idea to save result of `get_write_stdout()` beforehand and call
|
||||
* it at the end of the supplied function.
|
||||
*
|
||||
* NOTE: use NULL to reset to default implementation.
|
||||
*
|
||||
* @param[in] f New code to handle stdout output
|
||||
*
|
||||
*/
|
||||
void set_write_stdout(_WriteFunction *f);
|
||||
|
||||
/** Get current implementation of write syscall for stdout.
|
||||
*
|
||||
* Save returned value before calling `set_write_stdout`, it allows for chaining
|
||||
* multiple independent handlers.
|
||||
*
|
||||
* @returns current stdout handler
|
||||
*/
|
||||
_WriteFunction *get_write_stdout();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue