EPICS Base  7.0.8.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
epicsStdio.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
57 #ifndef epicsStdioh
58 #define epicsStdioh
59 
60 #include <stdio.h>
61 #include <stdarg.h>
62 
63 #include "libComAPI.h"
64 #include "compilerDependencies.h"
65 #include "epicsTempFile.h"
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 #ifndef epicsStdioStdStreams
72 # undef stdin
73 # define stdin epicsGetStdin()
74 # undef stdout
75 # define stdout epicsGetStdout()
76 # undef stderr
77 # define stderr epicsGetStderr()
78 #endif
79 
80 /* Make printf, puts and putchar use *our* version of stdout */
81 
82 #ifndef epicsStdioStdPrintfEtc
83 # ifdef printf
84 # undef printf
85 # endif
86 # define printf epicsStdoutPrintf
87 
88 # ifdef vprintf
89 # undef vprintf
90 # endif
91 # define vprintf epicsStdoutVPrintf
92 
93 # ifdef puts
94 # undef puts
95 # endif
96 # define puts epicsStdoutPuts
97 
98 # ifdef putchar
99 # undef putchar
100 # endif
101 # define putchar epicsStdoutPutchar
102 #endif
103 
132 LIBCOM_API int epicsStdCall epicsSnprintf(
133  char *str, size_t size, EPICS_PRINTF_FMT(const char *format), ...
134 ) EPICS_PRINTF_STYLE(3,4);
163 LIBCOM_API int epicsStdCall epicsVsnprintf(
164  char *str, size_t size, const char *format, va_list ap);
165 
166 enum TF_RETURN {TF_OK=0, TF_ERROR=1};
175 LIBCOM_API enum TF_RETURN truncateFile ( const char *pFileName, unsigned long size );
176 
177 /* The following are for redirecting stdin,stdout,stderr */
178 LIBCOM_API FILE * epicsStdCall epicsGetStdin(void);
179 LIBCOM_API FILE * epicsStdCall epicsGetStdout(void);
180 LIBCOM_API FILE * epicsStdCall epicsGetStderr(void);
181 /* These are intended for iocsh only */
182 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdin(void);
183 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdout(void);
184 LIBCOM_API FILE * epicsStdCall epicsGetThreadStderr(void);
185 LIBCOM_API void epicsStdCall epicsSetThreadStdin(FILE *);
186 LIBCOM_API void epicsStdCall epicsSetThreadStdout(FILE *);
187 LIBCOM_API void epicsStdCall epicsSetThreadStderr(FILE *);
188 
189 LIBCOM_API int epicsStdCall epicsStdoutPrintf(
190  const char *pformat, ...) EPICS_PRINTF_STYLE(1,2);
191 LIBCOM_API int epicsStdCall epicsStdoutVPrintf(
192  const char *pformat, va_list ap);
193 LIBCOM_API int epicsStdCall epicsStdoutPuts(const char *str);
194 LIBCOM_API int epicsStdCall epicsStdoutPutchar(int c);
195 
196 #ifdef __cplusplus
197 }
198 
199 /* Also pull functions into the std namespace (see lp:1786927) */
200 #if !defined(__GNUC__) || (__GNUC__ > 2)
201 namespace std {
202 using ::epicsGetStdin;
203 using ::epicsGetStdout;
204 using ::epicsGetStderr;
205 using ::epicsStdoutPrintf;
206 using ::epicsStdoutVPrintf;
207 using ::epicsStdoutPuts;
208 using ::epicsStdoutPutchar;
209 }
210 #endif /* __GNUC__ > 2 */
211 
212 #endif /* __cplusplus */
213 
214 #endif /* epicsStdioh */
Compiler specific declarations.
OS-independent way to create temporary files.
LIBCOM_API int epicsStdCall epicsSnprintf(char *str, size_t size, EPICS_PRINTF_FMT(const char *format),...) EPICS_PRINTF_STYLE(3
epicsSnprintf() is meant to have the same semantics as the C99 function snprintf() ...
LIBCOM_API int epicsStdCall LIBCOM_API int epicsStdCall epicsVsnprintf(char *str, size_t size, const char *format, va_list ap)
epicsVsnprintf() is meant to have the same semantics as the C99 function vsnprintf() ...
LIBCOM_API enum TF_RETURN truncateFile(const char *pFileName, unsigned long size)
Truncate a file to a specified size.