VirtualBox

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

Last change on this file since 96354 was 96128, checked in by vboxsync, 3 years ago

IPRT/nocrt: sscanf & vsscanf (untested). bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
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
40typedef 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
56AssertCompile(SEEK_SET == 0); AssertCompile(SEEK_CUR == 1); AssertCompile(SEEK_END == 2); /* Also in WDK header mmiscapi.h. */
57
58
59RT_C_DECLS_BEGIN
60
61typedef 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
70int RT_NOCRT(snprintf)(char *, size_t, const char *, ...);
71int RT_NOCRT(vsnprintf)(char *, size_t, const char *, va_list);
72int RT_NOCRT(scprintf)(const char *, ...);
73int RT_NOCRT(vscprintf)(const char *, va_list);
74
75FILE *RT_NOCRT(fopen)(const char *pszFilename, const char *pszMode);
76FILE *RT_NOCRT(fdopen)(int fd, const char *pszMode);
77FILE *RT_NOCRT(tmpfile)(void);
78errno_t RT_NOCRT(tmpfile_s)(FILE **ppFile);
79int RT_NOCRT(fileno)(FILE *pFile);
80int RT_NOCRT(fclose)(FILE *pFile);
81int RT_NOCRT(fflush)(FILE *pFile);
82int RT_NOCRT(setvbuf)(FILE *pFile, char *pchBuf, int iBufferingType, size_t cbBuf);
83int RT_NOCRT(fseek)(FILE *pFile, long, int);
84int RT_NOCRT(fseeko)(FILE *pFile, off_t, int);
85long RT_NOCRT(ftell)(FILE *pFile);
86off_t RT_NOCRT(ftello)(FILE *pFile);
87size_t RT_NOCRT(fwrite)(void const *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
88int RT_NOCRT(fputs)(const char *psz, FILE *pFile);
89int RT_NOCRT(puts)(const char *psz);
90int RT_NOCRT(fputc)(int, FILE *pFile);
91int RT_NOCRT(putc)(int, FILE *pFile);
92size_t RT_NOCRT(fread)(void *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
93int RT_NOCRT(fgetc)(FILE *pFile);
94int RT_NOCRT(getc)(FILE *pFile);
95int RT_NOCRT(ferror)(FILE *pFile);
96void RT_NOCRT(clearerr)(FILE *pFile);
97int RT_NOCRT(remove)(const char *pszFilename);
98int RT_NOCRT(sscanf)(const char *pszString, const char *pszFormat, ...);
99int RT_NOCRT(vsscanf)(const char *pszString, const char *pszFormat, va_list);
100
101# ifndef RT_NOCRT_EOF /* also in string */
102# define RT_NOCRT_EOF (-1)
103# endif
104# define EOF RT_NOCRT_EOF
105
106/* Underscored variants: */
107# define _printf RTPrintf
108# define _vprintf RTPrintfV
109# define _fprintf RTStrmPrintf
110# define _vfprintf RTStrmPrintfV
111int RT_NOCRT(_snprintf)(char *, size_t, const char *, ...);
112int RT_NOCRT(_vsnprintf)(char *, size_t, const char *, va_list);
113int RT_NOCRT(_scprintf)(const char *, ...);
114int RT_NOCRT(_vscprintf)(const char *, va_list);
115
116FILE *RT_NOCRT(_fopen)(const char *pszFilename, const char *pszMode);
117FILE *RT_NOCRT(_fdopen)(int fd, const char *pszMode);
118FILE *RT_NOCRT(_tmpfile)(void);
119errno_t RT_NOCRT(_tmpfile_s)(FILE **ppFile);
120int RT_NOCRT(_fileno)(FILE *pFile);
121int RT_NOCRT(_fclose)(FILE *pFile);
122int RT_NOCRT(_fflush)(FILE *pFile);
123int RT_NOCRT(_setvbuf)(FILE *pFile, char *pchBuf, int iBufferingType, size_t cbBuf);
124int RT_NOCRT(_fseek)(FILE *pFile, long, int);
125int RT_NOCRT(_fseeko)(FILE *pFile, off_t, int);
126long RT_NOCRT(_ftell)(FILE *pFile);
127off_t RT_NOCRT(_ftello)(FILE *pFile);
128size_t RT_NOCRT(_fwrite)(void const *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
129int RT_NOCRT(_fputs)(const char *psz, FILE *pFile);
130int RT_NOCRT(_fputc)(int, FILE *pFile);
131size_t RT_NOCRT(_fread)(void *pvBuf, size_t cbItem, size_t cItems, FILE *pFile);
132int RT_NOCRT(_fgetc)(FILE *pFile);
133int RT_NOCRT(_getc)(FILE *pFile);
134int RT_NOCRT(_ferror)(FILE *pFile);
135void RT_NOCRT(_clearerr)(FILE *pFile);
136int RT_NOCRT(_remove)(const char *pszFilename);
137int RT_NOCRT(_sscanf)(const char *pszString, const char *pszFormat, ...);
138int RT_NOCRT(_vsscanf)(const char *pszString, const char *pszFormat, va_list);
139
140# define _IONBF (1) /**< No buffering. */
141# define _IOLBF (2) /**< Line buffered. */
142# define _IOFBF (3) /**< Fully buffered. */
143
144/* Aliases: */
145# if !defined(RT_WITHOUT_NOCRT_WRAPPERS) && !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES)
146# define snprintf RT_NOCRT(snprintf)
147# define vsnprintf RT_NOCRT(vsnprintf)
148# define scprintf RT_NOCRT(scprintf)
149# define vscprintf RT_NOCRT(vscprintf)
150
151# define fopen RT_NOCRT(fopen)
152# define fdopen RT_NOCRT(fdopen)
153# define tmpfile RT_NOCRT(tmpfile)
154# define tmpfile_s RT_NOCRT(tmpfile_s)
155# define fileno RT_NOCRT(fileno)
156# define fclose RT_NOCRT(fclose)
157# define fflush RT_NOCRT(fflush)
158# define setvbuf RT_NOCRT(setvbuf)
159# define fseek RT_NOCRT(fseek)
160# define fseeko RT_NOCRT(fseeko)
161# define ftell RT_NOCRT(ftell)
162# define ftello RT_NOCRT(ftello)
163# define fwrite RT_NOCRT(fwrite)
164# define fputs RT_NOCRT(fputs)
165# define fputc RT_NOCRT(fputc)
166# define fread RT_NOCRT(fread)
167# define fgetc RT_NOCRT(fgetc)
168# define getc RT_NOCRT(getc)
169# define ferror RT_NOCRT(ferror)
170# define clearerr RT_NOCRT(clearerr)
171# define remove RT_NOCRT(remove)
172# define sscanf RT_NOCRT(sscanf)
173# define vsscanf RT_NOCRT(vsscanf)
174
175
176/* Underscored variants: */
177# define _snprintf RT_NOCRT(snprintf)
178# define _vsnprintf RT_NOCRT(vsnprintf)
179# define _scprintf RT_NOCRT(scprintf)
180# define _vscprintf RT_NOCRT(vscprintf)
181
182# define _fopen RT_NOCRT(fopen)
183# define _fdopen RT_NOCRT(fdopen)
184# define _tmpfile RT_NOCRT(tmpfile)
185# define _tmpfile_s RT_NOCRT(tmpfile_s)
186# define _fileno RT_NOCRT(fileno)
187# define _fclose RT_NOCRT(fclose)
188# define _flush RT_NOCRT(fflush)
189# define _setvbuf RT_NOCRT(setvbuf)
190# define _fseek RT_NOCRT(fseek)
191# define _fseeko RT_NOCRT(fseeko)
192# define _ftell RT_NOCRT(ftell)
193# define _ftello RT_NOCRT(ftello)
194# define _fwrite RT_NOCRT(fwrite)
195# define _fputs RT_NOCRT(fputs)
196# define _fputc RT_NOCRT(fputc)
197# define _fread RT_NOCRT(fread)
198# define _fgetc RT_NOCRT(fgetc)
199# define _getc RT_NOCRT(getc)
200# define _ferror RT_NOCRT(ferror)
201# define _clearerr RT_NOCRT(clearerr)
202# define _remove RT_NOCRT(remove)
203# define _sscanf RT_NOCRT(_sscanf)
204# define _vsscanf RT_NOCRT(_vsscanf)
205# endif
206
207RT_C_DECLS_END
208
209#endif
210
211#endif /* !IPRT_INCLUDED_nocrt_stdio_h */
212
Note: See TracBrowser for help on using the repository browser.

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