EPICS Base  7.0.6.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 \*************************************************************************/
47 #ifndef epicsStdioh
48 #define epicsStdioh
49 
50 #include <stdio.h>
51 #include <stdarg.h>
52 
53 #include "libComAPI.h"
54 #include "compilerDependencies.h"
55 #include "epicsTempFile.h"
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 #ifndef epicsStdioStdStreams
62 # undef stdin
63 # define stdin epicsGetStdin()
64 # undef stdout
65 # define stdout epicsGetStdout()
66 # undef stderr
67 # define stderr epicsGetStderr()
68 #endif
69 
70 /* Make printf, puts and putchar use *our* version of stdout */
71 
72 #ifndef epicsStdioStdPrintfEtc
73 # ifdef printf
74 # undef printf
75 # endif
76 # define printf epicsStdoutPrintf
77 
78 # ifdef puts
79 # undef puts
80 # endif
81 # define puts epicsStdoutPuts
82 
83 # ifdef putchar
84 # undef putchar
85 # endif
86 # define putchar epicsStdoutPutchar
87 #endif
88 
117 LIBCOM_API int epicsStdCall epicsSnprintf(
118  char *str, size_t size, const char *format, ...) EPICS_PRINTF_STYLE(3,4);
147 LIBCOM_API int epicsStdCall epicsVsnprintf(
148  char *str, size_t size, const char *format, va_list ap);
149 
150 enum TF_RETURN {TF_OK=0, TF_ERROR=1};
159 LIBCOM_API enum TF_RETURN truncateFile ( const char *pFileName, unsigned long size );
160 
161 /* The following are for redirecting stdin,stdout,stderr */
162 LIBCOM_API FILE * epicsStdCall epicsGetStdin(void);
163 LIBCOM_API FILE * epicsStdCall epicsGetStdout(void);
164 LIBCOM_API FILE * epicsStdCall epicsGetStderr(void);
165 /* These are intended for iocsh only */
166 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdin(void);
167 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdout(void);
168 LIBCOM_API FILE * epicsStdCall epicsGetThreadStderr(void);
169 LIBCOM_API void epicsStdCall epicsSetThreadStdin(FILE *);
170 LIBCOM_API void epicsStdCall epicsSetThreadStdout(FILE *);
171 LIBCOM_API void epicsStdCall epicsSetThreadStderr(FILE *);
172 
173 LIBCOM_API int epicsStdCall epicsStdoutPrintf(
174  const char *pformat, ...) EPICS_PRINTF_STYLE(1,2);
175 LIBCOM_API int epicsStdCall epicsStdoutPuts(const char *str);
176 LIBCOM_API int epicsStdCall epicsStdoutPutchar(int c);
177 
178 #ifdef __cplusplus
179 }
180 
181 /* Also pull functions into the std namespace (see lp:1786927) */
182 #if !defined(__GNUC__) || (__GNUC__ > 2)
183 namespace std {
184 using ::epicsGetStdin;
185 using ::epicsGetStdout;
186 using ::epicsGetStderr;
187 using ::epicsStdoutPrintf;
188 using ::epicsStdoutPuts;
189 using ::epicsStdoutPutchar;
190 }
191 #endif /* __GNUC__ > 2 */
192 
193 #endif /* __cplusplus */
194 
195 #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.