VirtualBox

source: vbox/trunk/include/iprt/nocrt/stdio.h

Last change on this file was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette