1 | /** @file
|
---|
2 | * IPRT / No-CRT - Mostly empty stdio.h.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_nocrt_stdio_h
|
---|
27 | #define IPRT_INCLUDED_nocrt_stdio_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/stream.h>
|
---|
33 | #include <iprt/nocrt/sys/types.h> /* errno_t, off_t */
|
---|
34 | #ifdef IPRT_NO_CRT_FOR_3RD_PARTY
|
---|
35 | # include <iprt/nocrt/time.h> /* file.h includes fs.h which includes time.h */
|
---|
36 | # include <iprt/file.h> /* for RTFILE_SEEK_XXX */
|
---|
37 | # include <iprt/assertcompile.h>
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | typedef RTFOFF fpos_t;
|
---|
41 |
|
---|
42 |
|
---|
43 | #ifdef IPRT_NO_CRT_FOR_3RD_PARTY
|
---|
44 | /*
|
---|
45 | * Only for external libraries and such, but even then it would be best to
|
---|
46 | * check each printf and fprintf call as IPRT isn't 100% compatible...
|
---|
47 | */
|
---|
48 |
|
---|
49 | /* These are also in unistd.h: */
|
---|
50 | # undef SEEK_SET
|
---|
51 | # define SEEK_SET RTFILE_SEEK_BEGIN
|
---|
52 | # undef SEEK_CUR
|
---|
53 | # define SEEK_CUR RTFILE_SEEK_CURRENT
|
---|
54 | # undef SEEK_END
|
---|
55 | # define SEEK_END RTFILE_SEEK_END
|
---|
56 | AssertCompile(SEEK_SET == 0); AssertCompile(SEEK_CUR == 1); AssertCompile(SEEK_END == 2); /* Also in WDK header mmiscapi.h. */
|
---|
57 |
|
---|
58 |
|
---|
59 | RT_C_DECLS_BEGIN
|
---|
60 |
|
---|
61 | typedef struct RTSTREAM FILE;
|
---|
62 | # define stdin g_pStdIn
|
---|
63 | # define stdout g_pStdOut
|
---|
64 | # define stderr g_pStdErr
|
---|
65 |
|
---|
66 | # define printf RTPrintf
|
---|
67 | # define vprintf RTPrintfV
|
---|
68 | # define fprintf RTStrmPrintf
|
---|
69 | # define vfprintf RTStrmPrintfV
|
---|
70 | int RT_NOCRT(snprintf)(char *, size_t, const char *, ...);
|
---|
71 | int RT_NOCRT(vsnprintf)(char *, size_t, const char *, va_list);
|
---|
72 | int RT_NOCRT(scprintf)(const char *, ...);
|
---|
73 | int RT_NOCRT(vscprintf)(const char *, va_list);
|
---|
74 |
|
---|
75 | FILE *RT_NOCRT(fopen)(const char *pszFilename, const char *pszMode);
|
---|
76 | FILE *RT_NOCRT(fdopen)(int fd, const char *pszMode);
|
---|
77 | FILE *RT_NOCRT(tmpfile)(void);
|
---|
78 | errno_t RT_NOCRT(tmpfile_s)(FILE **ppFile);
|
---|
79 | int RT_NOCRT(fileno)(FILE *pFile);
|
---|
80 | int RT_NOCRT(fclose)(FILE *pFile);
|
---|
81 | int RT_NOCRT(fflush)(FILE *pFile);
|
---|
82 | int RT_NOCRT(setvbuf)(FILE *pFile, char *pchBuf, int iBufferingType, size_t cbBuf);
|
---|
83 | int RT_NOCRT(fseek)(FILE *pFile, long, int);
|
---|
84 | int RT_NOCRT(fseeko)(FILE *pFile, off_t, int);
|
---|
85 | long RT_NOCRT(ftell)(FILE *pFile);
|
---|
86 | off_t RT_NOCRT(ftello)(FILE *pFile);
|
---|
87 | size_t RT_NOCRT(fwrite)(void const *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
|
---|
88 | int RT_NOCRT(fputs)(const char *psz, FILE *pFile);
|
---|
89 | int RT_NOCRT(puts)(const char *psz);
|
---|
90 | int RT_NOCRT(fputc)(int, FILE *pFile);
|
---|
91 | int RT_NOCRT(putc)(int, FILE *pFile);
|
---|
92 | size_t RT_NOCRT(fread)(void *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
|
---|
93 | int RT_NOCRT(fgetc)(FILE *pFile);
|
---|
94 | int RT_NOCRT(getc)(FILE *pFile);
|
---|
95 | int RT_NOCRT(ferror)(FILE *pFile);
|
---|
96 | void RT_NOCRT(clearerr)(FILE *pFile);
|
---|
97 | int RT_NOCRT(remove)(const char *pszFilename);
|
---|
98 | int RT_NOCRT(sscanf)(const char *pszString, const char *pszFormat, ...);
|
---|
99 |
|
---|
100 | # ifndef RT_NOCRT_EOF /* also in string */
|
---|
101 | # define RT_NOCRT_EOF (-1)
|
---|
102 | # endif
|
---|
103 | # define EOF RT_NOCRT_EOF
|
---|
104 |
|
---|
105 | /* Underscored variants: */
|
---|
106 | # define _printf RTPrintf
|
---|
107 | # define _vprintf RTPrintfV
|
---|
108 | # define _fprintf RTStrmPrintf
|
---|
109 | # define _vfprintf RTStrmPrintfV
|
---|
110 | int RT_NOCRT(_snprintf)(char *, size_t, const char *, ...);
|
---|
111 | int RT_NOCRT(_vsnprintf)(char *, size_t, const char *, va_list);
|
---|
112 | int RT_NOCRT(_scprintf)(const char *, ...);
|
---|
113 | int RT_NOCRT(_vscprintf)(const char *, va_list);
|
---|
114 |
|
---|
115 | FILE *RT_NOCRT(_fopen)(const char *pszFilename, const char *pszMode);
|
---|
116 | FILE *RT_NOCRT(_fdopen)(int fd, const char *pszMode);
|
---|
117 | FILE *RT_NOCRT(_tmpfile)(void);
|
---|
118 | errno_t RT_NOCRT(_tmpfile_s)(FILE **ppFile);
|
---|
119 | int RT_NOCRT(_fileno)(FILE *pFile);
|
---|
120 | int RT_NOCRT(_fclose)(FILE *pFile);
|
---|
121 | int RT_NOCRT(_fflush)(FILE *pFile);
|
---|
122 | int RT_NOCRT(_setvbuf)(FILE *pFile, char *pchBuf, int iBufferingType, size_t cbBuf);
|
---|
123 | int RT_NOCRT(_fseek)(FILE *pFile, long, int);
|
---|
124 | int RT_NOCRT(_fseeko)(FILE *pFile, off_t, int);
|
---|
125 | long RT_NOCRT(_ftell)(FILE *pFile);
|
---|
126 | off_t RT_NOCRT(_ftello)(FILE *pFile);
|
---|
127 | size_t RT_NOCRT(_fwrite)(void const *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
|
---|
128 | int RT_NOCRT(_fputs)(const char *psz, FILE *pFile);
|
---|
129 | int RT_NOCRT(_fputc)(int, FILE *pFile);
|
---|
130 | size_t RT_NOCRT(_fread)(void *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
|
---|
131 | int RT_NOCRT(_fgetc)(FILE *pFile);
|
---|
132 | int RT_NOCRT(_getc)(FILE *pFile);
|
---|
133 | int RT_NOCRT(_ferror)(FILE *pFile);
|
---|
134 | void RT_NOCRT(_clearerr)(FILE *pFile);
|
---|
135 | int RT_NOCRT(_remove)(const char *pszFilename);
|
---|
136 | int RT_NOCRT(_sscanf)(const char *pszString, const char *pszFormat, ...);
|
---|
137 |
|
---|
138 | # define _IONBF (1) /**< No buffering. */
|
---|
139 | # define _IOLBF (2) /**< Line buffered. */
|
---|
140 | # define _IOFBF (3) /**< Fully buffered. */
|
---|
141 |
|
---|
142 | /* Aliases: */
|
---|
143 | # if !defined(RT_WITHOUT_NOCRT_WRAPPERS) && !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES)
|
---|
144 | # define snprintf RT_NOCRT(snprintf)
|
---|
145 | # define vsnprintf RT_NOCRT(vsnprintf)
|
---|
146 | # define scprintf RT_NOCRT(scprintf)
|
---|
147 | # define vscprintf RT_NOCRT(vscprintf)
|
---|
148 |
|
---|
149 | # define fopen RT_NOCRT(fopen)
|
---|
150 | # define fdopen RT_NOCRT(fdopen)
|
---|
151 | # define tmpfile RT_NOCRT(tmpfile)
|
---|
152 | # define tmpfile_s RT_NOCRT(tmpfile_s)
|
---|
153 | # define fileno RT_NOCRT(fileno)
|
---|
154 | # define fclose RT_NOCRT(fclose)
|
---|
155 | # define fflush RT_NOCRT(fflush)
|
---|
156 | # define setvbuf RT_NOCRT(setvbuf)
|
---|
157 | # define fseek RT_NOCRT(fseek)
|
---|
158 | # define fseeko RT_NOCRT(fseeko)
|
---|
159 | # define ftell RT_NOCRT(ftell)
|
---|
160 | # define ftello RT_NOCRT(ftello)
|
---|
161 | # define fwrite RT_NOCRT(fwrite)
|
---|
162 | # define fputs RT_NOCRT(fputs)
|
---|
163 | # define fputc RT_NOCRT(fputc)
|
---|
164 | # define fread RT_NOCRT(fread)
|
---|
165 | # define fgetc RT_NOCRT(fgetc)
|
---|
166 | # define getc RT_NOCRT(getc)
|
---|
167 | # define ferror RT_NOCRT(ferror)
|
---|
168 | # define clearerr RT_NOCRT(clearerr)
|
---|
169 | # define remove RT_NOCRT(remove)
|
---|
170 | # define sscanf RT_NOCRT(sscanf)
|
---|
171 |
|
---|
172 |
|
---|
173 | /* Underscored variants: */
|
---|
174 | # define _snprintf RT_NOCRT(snprintf)
|
---|
175 | # define _vsnprintf RT_NOCRT(vsnprintf)
|
---|
176 | # define _scprintf RT_NOCRT(scprintf)
|
---|
177 | # define _vscprintf RT_NOCRT(vscprintf)
|
---|
178 |
|
---|
179 | # define _fopen RT_NOCRT(fopen)
|
---|
180 | # define _fdopen RT_NOCRT(fdopen)
|
---|
181 | # define _tmpfile RT_NOCRT(tmpfile)
|
---|
182 | # define _tmpfile_s RT_NOCRT(tmpfile_s)
|
---|
183 | # define _fileno RT_NOCRT(fileno)
|
---|
184 | # define _fclose RT_NOCRT(fclose)
|
---|
185 | # define _flush RT_NOCRT(fflush)
|
---|
186 | # define _setvbuf RT_NOCRT(setvbuf)
|
---|
187 | # define _fseek RT_NOCRT(fseek)
|
---|
188 | # define _fseeko RT_NOCRT(fseeko)
|
---|
189 | # define _ftell RT_NOCRT(ftell)
|
---|
190 | # define _ftello RT_NOCRT(ftello)
|
---|
191 | # define _fwrite RT_NOCRT(fwrite)
|
---|
192 | # define _fputs RT_NOCRT(fputs)
|
---|
193 | # define _fputc RT_NOCRT(fputc)
|
---|
194 | # define _fread RT_NOCRT(fread)
|
---|
195 | # define _fgetc RT_NOCRT(fgetc)
|
---|
196 | # define _getc RT_NOCRT(getc)
|
---|
197 | # define _ferror RT_NOCRT(ferror)
|
---|
198 | # define _clearerr RT_NOCRT(clearerr)
|
---|
199 | # define _remove RT_NOCRT(remove)
|
---|
200 | # define _sscanf RT_NOCRT(_sscanf)
|
---|
201 | # endif
|
---|
202 |
|
---|
203 | RT_C_DECLS_END
|
---|
204 |
|
---|
205 | #endif
|
---|
206 |
|
---|
207 | #endif /* !IPRT_INCLUDED_nocrt_stdio_h */
|
---|
208 |
|
---|