EPICS Base  7.0.7.0
 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, const char *format, ...) EPICS_PRINTF_STYLE(3,4);
162 LIBCOM_API int epicsStdCall epicsVsnprintf(
163  char *str, size_t size, const char *format, va_list ap);
164 
165 enum TF_RETURN {TF_OK=0, TF_ERROR=1};
174 LIBCOM_API enum TF_RETURN truncateFile ( const char *pFileName, unsigned long size );
175 
176 /* The following are for redirecting stdin,stdout,stderr */
177 LIBCOM_API FILE * epicsStdCall epicsGetStdin(void);
178 LIBCOM_API FILE * epicsStdCall epicsGetStdout(void);
179 LIBCOM_API FILE * epicsStdCall epicsGetStderr(void);
180 /* These are intended for iocsh only */
181 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdin(void);
182 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdout(void);
183 LIBCOM_API FILE * epicsStdCall epicsGetThreadStderr(void);
184 LIBCOM_API void epicsStdCall epicsSetThreadStdin(FILE *);
185 LIBCOM_API void epicsStdCall epicsSetThreadStdout(FILE *);
186 LIBCOM_API void epicsStdCall epicsSetThreadStderr(FILE *);
187 
188 LIBCOM_API int epicsStdCall epicsStdoutPrintf(
189  const char *pformat, ...) EPICS_PRINTF_STYLE(1,2);
190 LIBCOM_API int epicsStdCall epicsStdoutVPrintf(
191  const char *pformat, va_list ap);
192 LIBCOM_API int epicsStdCall epicsStdoutPuts(const char *str);
193 LIBCOM_API int epicsStdCall epicsStdoutPutchar(int c);
194 
195 #ifdef __cplusplus
196 }
197 
198 /* Also pull functions into the std namespace (see lp:1786927) */
199 #if !defined(__GNUC__) || (__GNUC__ > 2)
200 namespace std {
201 using ::epicsGetStdin;
202 using ::epicsGetStdout;
203 using ::epicsGetStderr;
204 using ::epicsStdoutPrintf;
205 using ::epicsStdoutVPrintf;
206 using ::epicsStdoutPuts;
207 using ::epicsStdoutPutchar;
208 }
209 #endif /* __GNUC__ > 2 */
210 
211 #endif /* __cplusplus */
212 
213 #endif /* epicsStdioh */
LIBCOM_API int epicsStdCall epicsSnprintf(char *str, size_t size, const char *format,...) EPICS_PRINTF_STYLE(3
epicsSnprintf() is meant to have the same semantics as the C99 function snprintf() ...
Compiler specific declarations.
OS-independent way to create temporary files.
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.