source: mainline/uspace/lib/c/include/stdio.h@ 9bfa8c8

Last change on this file since 9bfa8c8 was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Replace some license headers with SPDX identifier

Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.

  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[3eddaff]1/*
[d7f7a4a]2 * SPDX-FileCopyrightText: 2005 Martin Decky
3 * SPDX-FileCopyrightText: 2018 Jiri Svoboda
[3eddaff]4 *
[d7f7a4a]5 * SPDX-License-Identifier: BSD-3-Clause
[3eddaff]6 */
7
[fadd381]8/** @addtogroup libc
[b2951e2]9 * @{
10 */
11/** @file
12 */
13
[4805495]14#ifndef _LIBC_STDIO_H_
15#define _LIBC_STDIO_H_
[3eddaff]16
[3214a20]17#include <stdarg.h>
[aa492fe]18#include <io/verify.h>
[4e6a610]19#include <_bits/NULL.h>
[1d6dd2a]20#include <_bits/size_t.h>
21#include <_bits/wchar_t.h>
[28a5ebd]22#include <_bits/uchar.h>
[ed88c8e]23#include <_bits/wint_t.h>
[bc56f30]24#include <_bits/decls.h>
[c23275a]25
[4e6a610]26#ifndef _HELENOS_SOURCE
27#define _IONBF 0
28#define _IOLBF 1
29#define _IOFBF 2
[c23275a]30#endif
31
[ef8bcc6]32/** Default size for stream I/O buffers */
[db24058]33#define BUFSIZ 4096
[ef8bcc6]34
[4e6a610]35#define EOF (-1)
36
[777832e]37/** Max number of files that is guaranteed to be able to open at the same time */
[bc56f30]38#define FOPEN_MAX 16
[777832e]39
[55092672]40/** Recommended size of fixed-size array for holding file names. */
41#define FILENAME_MAX 4096
42
[4e6a610]43/** Length of "/tmp/tmp.XXXXXX" + 1 */
44#define L_tmpnam 16
[04b687b]45
[4e6a610]46#ifndef SEEK_SET
47#define SEEK_SET 0
48#endif
49
50#ifndef SEEK_CUR
51#define SEEK_CUR 1
52#endif
53
54#ifndef SEEK_END
55#define SEEK_END 2
56#endif
57
58/** Minimum number of unique temporary file names */
59#define TMP_MAX 1000000
[777832e]60
[bc56f30]61__C_DECLS_BEGIN;
62
63/** Forward declaration */
64struct _IO_FILE;
65typedef struct _IO_FILE FILE;
66
67/** File position */
68typedef struct {
69 long long pos;
70} fpos_t;
71
[2595dab]72extern FILE *stdin;
73extern FILE *stdout;
74extern FILE *stderr;
75
76/* Character and string input functions */
77extern int fgetc(FILE *);
[c62d2e1]78extern char *fgets(char *, int, FILE *);
[296890f3]79extern char *gets(char *, size_t) __attribute__((deprecated));
[1c1002a]80
[bc56f30]81static inline int getc(FILE *f)
82{
83 return fgetc(f);
84}
85
[b27a97bb]86extern int getchar(void);
87
[2595dab]88/* Character and string output functions */
[ed88c8e]89extern int fputc(int, FILE *);
[2595dab]90extern int fputs(const char *, FILE *);
91
[bc56f30]92static inline int putc(int i, FILE *f)
93{
94 return fputc(i, f);
95}
96
[ed88c8e]97extern int putchar(int);
[ab00d5a]98extern int puts(const char *);
[3eddaff]99
[bd5414e]100extern int ungetc(int, FILE *);
101
[ed88c8e]102extern wint_t fputwc(wchar_t, FILE *);
103extern wint_t putwchar(wchar_t);
104
[28a5ebd]105extern wint_t fputuc(char32_t, FILE *);
106extern wint_t putuchar(char32_t);
107
[2595dab]108/* Formatted string output functions */
[1433ecda]109extern int fprintf(FILE *, const char *, ...)
[09d13c8e]110 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
[2595dab]111extern int vfprintf(FILE *, const char *, va_list);
[3214a20]112
[9ac2013]113extern int printf(const char *, ...)
[09d13c8e]114 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
[ab00d5a]115extern int vprintf(const char *, va_list);
[3214a20]116
[1433ecda]117extern int snprintf(char *, size_t, const char *, ...)
[09d13c8e]118 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
[55092672]119#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
[a9763c6]120extern int vasprintf(char **, const char *, va_list);
[9ac2013]121extern int asprintf(char **, const char *, ...)
[09d13c8e]122 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
[296890f3]123#endif
[2595dab]124extern int vsnprintf(char *, size_t, const char *, va_list);
[a8e9ab8d]125
[296890f3]126extern int sprintf(char *, const char *, ...)
127 __attribute__((deprecated)) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
128extern int vsprintf(char *, const char *, va_list) __attribute__((deprecated));
129
[5a6c28d1]130/* Formatted input */
131extern int scanf(const char *, ...);
132extern int vscanf(const char *, va_list);
133extern int fscanf(FILE *, const char *, ...);
134extern int vfscanf(FILE *, const char *, va_list);
135extern int sscanf(const char *, const char *, ...);
136extern int vsscanf(const char *, const char *, va_list);
[ed18e14]137
[2595dab]138/* File stream functions */
[04b687b]139extern FILE *fopen(const char *, const char *);
[80bee81]140extern FILE *freopen(const char *, const char *, FILE *);
[04b687b]141extern int fclose(FILE *);
[2595dab]142
[04b687b]143extern size_t fread(void *, size_t, size_t, FILE *);
144extern size_t fwrite(const void *, size_t, size_t, FILE *);
[2595dab]145
[777832e]146extern int fgetpos(FILE *, fpos_t *);
147extern int fsetpos(FILE *, const fpos_t *);
148
[456c086]149extern int fseek(FILE *, long, int);
[080ad7f]150extern void rewind(FILE *);
[456c086]151extern long ftell(FILE *);
[04b687b]152extern int feof(FILE *);
[2595dab]153
154extern int fflush(FILE *);
[04b687b]155extern int ferror(FILE *);
156extern void clearerr(FILE *);
157
[777832e]158extern void perror(const char *);
159
[58daded]160extern int setvbuf(FILE *, void *, int, size_t);
[7699c21]161extern void setbuf(FILE *, void *);
[ef8bcc6]162
[b942a66]163/* Misc file functions */
164extern int remove(const char *);
[4e6a610]165extern int rename(const char *, const char *);
[b942a66]166
[4e6a610]167extern FILE *tmpfile(void);
[b79903b]168extern char *tmpnam(char *s);
[bc1b297]169
[bc56f30]170__C_DECLS_END;
171
[bc1b297]172#ifdef _HELENOS_SOURCE
173
[bc56f30]174#include <_bits/off64_t.h>
175
176__HELENOS_DECLS_BEGIN;
177
[bc1b297]178/* Nonstandard extensions. */
179
[bc56f30]180enum __buffer_type {
[bc1b297]181 /** No buffering */
182 _IONBF,
183 /** Line buffering */
184 _IOLBF,
185 /** Full buffering */
186 _IOFBF
187};
188
[cca2d93b]189extern int vprintf_length(const char *, va_list);
190extern int printf_length(const char *, ...)
[bc1b297]191 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
192extern FILE *fdopen(int, const char *);
193extern int fileno(FILE *);
194
[1c7f381]195extern int fseek64(FILE *, off64_t, int);
196extern off64_t ftell64(FILE *);
197
[bc56f30]198__HELENOS_DECLS_END;
[82fd245]199#endif
200
[3eddaff]201#endif
[b2951e2]202
[fadd381]203/** @}
[b2951e2]204 */
Note: See TracBrowser for help on using the repository browser.