1
#ifndef __BFT_PRINTF_H__
2
#define __BFT_PRINTF_H__
4
/*============================================================================
5
* Base user-definable printf() wrapper or replacement
6
*============================================================================*/
9
This file is part of Code_Saturne, a general-purpose CFD tool.
11
Copyright (C) 1998-2011 EDF S.A.
13
This program is free software; you can redistribute it and/or modify it under
14
the terms of the GNU General Public License as published by the Free Software
15
Foundation; either version 2 of the License, or (at your option) any later
18
This program is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23
You should have received a copy of the GNU General Public License along with
24
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25
Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
/*----------------------------------------------------------------------------*/
30
/* Standard C library headers */
34
/* BFT library headers */
36
/*-----------------------------------------------------------------------------*/
41
} /* Fake brace to force Emacs auto-indentation back to column 0 */
43
#endif /* __cplusplus */
45
/*============================================================================
47
*============================================================================*/
49
/* Function pointers for printf() and fflush(stdout) type functions */
51
typedef int (bft_printf_proxy_t) (const char *const format,
54
typedef int (bft_printf_flush_proxy_t) (void);
56
/*============================================================================
57
* Public function prototypes
58
*============================================================================*/
61
* Replacement for printf() with modifiable behavior.
63
* This function calls vprintf() by default, or a function with similar
64
* arguments indicated by bft_printf_proxy_set().
67
* format: <-- format string, as printf() and family.
68
* ... : <-- variable arguments based on format string.
71
* number of characters printed, not counting the trailing '\0' used
72
* to end output strings
76
bft_printf(const char *const format,
80
* Flush for output of bft_printf() with modifiable behavior.
82
* This function calls fflush(stdout) if bft_printf()'s default behavior is
83
* used. If bft_printf's behavior is modified with bft_printf_proxy_set(),
84
* bft_printf_flush()'s behavior may have to be also adjusted with
85
* bft_printf_flush_proxy_set().
88
* using the default behavior, the return value is that of
89
* fflush(stdout): O upon successful completion, EOF otherwise
90
* (with errno set to indicate the error).
94
bft_printf_flush(void);
97
* Returns function associated with the bft_printf() function.
100
* pointer to the vprintf() or replacement function.
104
bft_printf_proxy_get(void);
107
* Associates a vprintf() type function with the bft_printf() function.
110
* fct: <-- pointer to a vprintf() type function.
114
bft_printf_proxy_set(bft_printf_proxy_t *const fct);
117
* Returns function associated with bft_printf_flush().
120
* pointer to the bft_printf_flush() proxy.
123
bft_printf_flush_proxy_t *
124
bft_printf_flush_proxy_get(void);
127
* Associates a proxy function with bft_printf_flush().
130
* bft_printf() is called by the default bft_error() error handler
131
* (so as to ensure that the error text appears at the end of the
132
* program output), so a bft_print_flush replacement must not itself
133
* call (directly or indirectly) bft_error() if the default error
137
* fct <-- pointer to a function similar to {return fflush(stdout)}.
141
bft_printf_flush_proxy_set(bft_printf_flush_proxy_t *const fct);
143
/*----------------------------------------------------------------------------*/
147
#endif /* __cplusplus */
149
#endif /* __BFT_PRINTF_H__ */