This is Unofficial EPICS BASE Doxygen Site
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 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 
10 /* epicsStdio.h */
11 
12 #ifndef epicsStdioh
13 #define epicsStdioh
14 
15 #include <stdio.h>
16 #include <stdarg.h>
17 
18 #include "libComAPI.h"
19 #include "compilerDependencies.h"
20 #include "epicsTempFile.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #ifndef epicsStdioStdStreams
27 # undef stdin
28 # define stdin epicsGetStdin()
29 # undef stdout
30 # define stdout epicsGetStdout()
31 # undef stderr
32 # define stderr epicsGetStderr()
33 #endif
34 
35 /* Make printf, puts and putchar use *our* version of stdout */
36 
37 #ifndef epicsStdioStdPrintfEtc
38 # ifdef printf
39 # undef printf
40 # endif
41 # define printf epicsStdoutPrintf
42 
43 # ifdef puts
44 # undef puts
45 # endif
46 # define puts epicsStdoutPuts
47 
48 # ifdef putchar
49 # undef putchar
50 # endif
51 # define putchar epicsStdoutPutchar
52 #endif
53 
54 LIBCOM_API int epicsStdCall epicsSnprintf(
55  char *str, size_t size, const char *format, ...) EPICS_PRINTF_STYLE(3,4);
56 LIBCOM_API int epicsStdCall epicsVsnprintf(
57  char *str, size_t size, const char *format, va_list ap);
58 
59 /*
60  * truncate to specified size (we dont use truncate()
61  * because it is not portable)
62  *
63  * pFileName - name (and optionally path) of file
64  * size - the new file size (if file is curretly larger)
65  *
66  * returns TF_OK if the file is less than size bytes
67  * or if it was successfully truncated. Returns
68  * TF_ERROR if the file could not be truncated.
69  */
70 enum TF_RETURN {TF_OK=0, TF_ERROR=1};
71 LIBCOM_API enum TF_RETURN truncateFile ( const char *pFileName, unsigned long size );
72 
73 /* The following are for redirecting stdin,stdout,stderr */
74 LIBCOM_API FILE * epicsStdCall epicsGetStdin(void);
75 LIBCOM_API FILE * epicsStdCall epicsGetStdout(void);
76 LIBCOM_API FILE * epicsStdCall epicsGetStderr(void);
77 /* These are intended for iocsh only */
78 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdin(void);
79 LIBCOM_API FILE * epicsStdCall epicsGetThreadStdout(void);
80 LIBCOM_API FILE * epicsStdCall epicsGetThreadStderr(void);
81 LIBCOM_API void epicsStdCall epicsSetThreadStdin(FILE *);
82 LIBCOM_API void epicsStdCall epicsSetThreadStdout(FILE *);
83 LIBCOM_API void epicsStdCall epicsSetThreadStderr(FILE *);
84 
85 LIBCOM_API int epicsStdCall epicsStdoutPrintf(
86  const char *pformat, ...) EPICS_PRINTF_STYLE(1,2);
87 LIBCOM_API int epicsStdCall epicsStdoutPuts(const char *str);
88 LIBCOM_API int epicsStdCall epicsStdoutPutchar(int c);
89 
90 #ifdef __cplusplus
91 }
92 
93 /* Also pull functions into the std namespace (see lp:1786927) */
94 #if !defined(__GNUC__) || (__GNUC__ > 2)
95 namespace std {
102 }
103 #endif /* __GNUC__ > 2 */
104 
105 #endif /* __cplusplus */
106 
107 #endif /* epicsStdioh */
LIBCOM_API FILE *epicsStdCall epicsGetThreadStdout(void)
Definition: epicsStdio.c:71
TF_RETURN
Definition: epicsStdio.h:70
LIBCOM_API int epicsStdCall LIBCOM_API int epicsStdCall epicsVsnprintf(char *str, size_t size, const char *format, va_list ap)
Definition: osdStdio.c:26
Definition: memory.hpp:41
LIBCOM_API FILE *epicsStdCall epicsGetThreadStderr(void)
Definition: epicsStdio.c:77
#define str(v)
LIBCOM_API void epicsStdCall epicsSetThreadStdin(FILE *)
Definition: epicsStdio.c:90
#define EPICS_PRINTF_STYLE(f, a)
LIBCOM_API FILE *epicsStdCall epicsGetStdout(void)
Definition: epicsStdio.c:47
LIBCOM_API void epicsStdCall epicsSetThreadStderr(FILE *)
Definition: epicsStdio.c:102
LIBCOM_API int epicsStdCall epicsStdoutPutchar(int c)
Definition: epicsStdio.c:125
LIBCOM_API int epicsStdCall epicsStdoutPrintf(const char *pformat,...) EPICS_PRINTF_STYLE(1
LIBCOM_API FILE *epicsStdCall epicsGetThreadStdin(void)
Definition: epicsStdio.c:65
LIBCOM_API FILE *epicsStdCall epicsGetStderr(void)
Definition: epicsStdio.c:56
Compiler specific declarations.
LIBCOM_API enum TF_RETURN truncateFile(const char *pFileName, unsigned long size)
Definition: truncateFile.c:27
LIBCOM_API int epicsStdCall LIBCOM_API int epicsStdCall epicsStdoutPuts(const char *str)
Definition: epicsStdio.c:120
LIBCOM_API void epicsStdCall epicsSetThreadStdout(FILE *)
Definition: epicsStdio.c:96
LIBCOM_API int epicsStdCall epicsSnprintf(char *str, size_t size, const char *format,...) EPICS_PRINTF_STYLE(3
OS-independent way to create temporary files.
LIBCOM_API FILE *epicsStdCall epicsGetStdin(void)
Definition: epicsStdio.c:38