~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to src/bft/bft_printf.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-01 17:43:32 UTC
  • mto: (6.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20111101174332-tl4vk45no0x3emc3
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __BFT_PRINTF_H__
 
2
#define __BFT_PRINTF_H__
 
3
 
 
4
/*============================================================================
 
5
 * Base user-definable printf() wrapper or replacement
 
6
 *============================================================================*/
 
7
 
 
8
/*
 
9
  This file is part of Code_Saturne, a general-purpose CFD tool.
 
10
 
 
11
  Copyright (C) 1998-2011 EDF S.A.
 
12
 
 
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
 
16
  version.
 
17
 
 
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
 
21
  details.
 
22
 
 
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.
 
26
*/
 
27
 
 
28
/*----------------------------------------------------------------------------*/
 
29
 
 
30
/* Standard C library headers */
 
31
 
 
32
#include <stdarg.h>
 
33
 
 
34
/* BFT library headers */
 
35
 
 
36
/*-----------------------------------------------------------------------------*/
 
37
 
 
38
#ifdef __cplusplus
 
39
extern "C" {
 
40
#if 0
 
41
} /* Fake brace to force Emacs auto-indentation back to column 0 */
 
42
#endif
 
43
#endif /* __cplusplus */
 
44
 
 
45
/*============================================================================
 
46
 * Public types
 
47
 *============================================================================*/
 
48
 
 
49
/* Function pointers for printf() and fflush(stdout) type functions */
 
50
 
 
51
typedef int (bft_printf_proxy_t) (const char     *const format,
 
52
                                  va_list               arg_ptr);
 
53
 
 
54
typedef int (bft_printf_flush_proxy_t) (void);
 
55
 
 
56
/*============================================================================
 
57
 * Public function prototypes
 
58
 *============================================================================*/
 
59
 
 
60
/*
 
61
 * Replacement for printf() with modifiable behavior.
 
62
 *
 
63
 * This function calls vprintf() by default, or a function with similar
 
64
 * arguments indicated by bft_printf_proxy_set().
 
65
 *
 
66
 * parameters:
 
67
 *   format: <-- format string, as printf() and family.
 
68
 *   ... :   <-- variable arguments based on format string.
 
69
 *
 
70
 * returns:
 
71
 *   number of characters printed, not counting the trailing '\0' used
 
72
 *   to end output strings
 
73
 */
 
74
 
 
75
int
 
76
bft_printf(const char  *const format,
 
77
           ...);
 
78
 
 
79
/*
 
80
 * Flush for output of bft_printf() with modifiable behavior.
 
81
 *
 
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().
 
86
 *
 
87
 * returns:
 
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).
 
91
 */
 
92
 
 
93
int
 
94
bft_printf_flush(void);
 
95
 
 
96
/*
 
97
 * Returns function associated with the bft_printf() function.
 
98
 *
 
99
 * returns:
 
100
 *   pointer to the vprintf() or replacement function.
 
101
 */
 
102
 
 
103
bft_printf_proxy_t *
 
104
bft_printf_proxy_get(void);
 
105
 
 
106
/*
 
107
 * Associates a vprintf() type function with the bft_printf() function.
 
108
 *
 
109
 * parameters:
 
110
 *   fct: <-- pointer to a vprintf() type function.
 
111
 */
 
112
 
 
113
void
 
114
bft_printf_proxy_set(bft_printf_proxy_t  *const fct);
 
115
 
 
116
/*
 
117
 * Returns function associated with bft_printf_flush().
 
118
 *
 
119
 * returns:
 
120
 *   pointer to the bft_printf_flush() proxy.
 
121
 */
 
122
 
 
123
bft_printf_flush_proxy_t *
 
124
bft_printf_flush_proxy_get(void);
 
125
 
 
126
/*
 
127
 * Associates a proxy function with bft_printf_flush().
 
128
 *
 
129
 * warning:
 
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
 
134
 *   handler is used.
 
135
 *
 
136
 * parameter:
 
137
 *   fct <-- pointer to a function similar to {return fflush(stdout)}.
 
138
 */
 
139
 
 
140
void
 
141
bft_printf_flush_proxy_set(bft_printf_flush_proxy_t  *const fct);
 
142
 
 
143
/*----------------------------------------------------------------------------*/
 
144
 
 
145
#ifdef __cplusplus
 
146
}
 
147
#endif /* __cplusplus */
 
148
 
 
149
#endif /* __BFT_PRINTF_H__ */