source: mainline/uspace/lib/c/include/stdio.h@ 4e6a610

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4e6a610 was 4e6a610, checked in by Jiri Svoboda <jiri@…>, 7 years ago

Temporary file functions rework. Fix libposix access() not working on directories.

  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 * Copyright (c) 2005 Martin Decky
3 * Copyright (c) 2018 Jiri Svoboda
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup libc
31 * @{
32 */
33/** @file
34 */
35
36#ifndef LIBC_STDIO_H_
37#define LIBC_STDIO_H_
38
39#include <offset.h>
40#include <stdarg.h>
41#include <io/verify.h>
42#include <_bits/NULL.h>
43#include <_bits/size_t.h>
44#include <_bits/wchar_t.h>
45#include <_bits/wint_t.h>
46
47/** Forward declaration */
48struct _IO_FILE;
49typedef struct _IO_FILE FILE;
50
51/** File position */
52typedef struct {
53 off64_t pos;
54} fpos_t;
55
56#ifndef _HELENOS_SOURCE
57#define _IONBF 0
58#define _IOLBF 1
59#define _IOFBF 2
60#endif
61
62/** Default size for stream I/O buffers */
63#define BUFSIZ 4096
64
65#define EOF (-1)
66
67/** Max number of files that is guaranteed to be able to open at the same time */
68#define FOPEN_MAX VFS_MAX_OPEN_FILES
69
70/** Recommended size of fixed-size array for holding file names. */
71#define FILENAME_MAX 4096
72
73/** Length of "/tmp/tmp.XXXXXX" + 1 */
74#define L_tmpnam 16
75
76#ifndef SEEK_SET
77#define SEEK_SET 0
78#endif
79
80#ifndef SEEK_CUR
81#define SEEK_CUR 1
82#endif
83
84#ifndef SEEK_END
85#define SEEK_END 2
86#endif
87
88/** Minimum number of unique temporary file names */
89#define TMP_MAX 1000000
90
91extern FILE *stdin;
92extern FILE *stdout;
93extern FILE *stderr;
94
95/* Character and string input functions */
96#define getc fgetc
97extern int fgetc(FILE *);
98extern char *fgets(char *, int, FILE *);
99extern char *gets(char *, size_t) __attribute__((deprecated));
100
101extern int getchar(void);
102
103/* Character and string output functions */
104#define putc fputc
105extern int fputc(int, FILE *);
106extern int fputs(const char *, FILE *);
107
108extern int putchar(int);
109extern int puts(const char *);
110
111extern int ungetc(int, FILE *);
112
113extern wint_t fputwc(wchar_t, FILE *);
114extern wint_t putwchar(wchar_t);
115
116/* Formatted string output functions */
117extern int fprintf(FILE *, const char *, ...)
118 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
119extern int vfprintf(FILE *, const char *, va_list);
120
121extern int printf(const char *, ...)
122 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
123extern int vprintf(const char *, va_list);
124
125extern int snprintf(char *, size_t, const char *, ...)
126 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
127#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
128extern int vasprintf(char **, const char *, va_list);
129extern int asprintf(char **, const char *, ...)
130 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
131#endif
132extern int vsnprintf(char *, size_t, const char *, va_list);
133
134extern int sprintf(char *, const char *, ...)
135 __attribute__((deprecated)) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
136extern int vsprintf(char *, const char *, va_list) __attribute__((deprecated));
137
138/* Formatted input */
139extern int scanf(const char *, ...);
140extern int vscanf(const char *, va_list);
141extern int fscanf(FILE *, const char *, ...);
142extern int vfscanf(FILE *, const char *, va_list);
143extern int sscanf(const char *, const char *, ...);
144extern int vsscanf(const char *, const char *, va_list);
145
146/* File stream functions */
147extern FILE *fopen(const char *, const char *);
148extern FILE *freopen(const char *, const char *, FILE *);
149extern int fclose(FILE *);
150
151extern size_t fread(void *, size_t, size_t, FILE *);
152extern size_t fwrite(const void *, size_t, size_t, FILE *);
153
154extern int fgetpos(FILE *, fpos_t *);
155extern int fsetpos(FILE *, const fpos_t *);
156
157extern int fseek(FILE *, long, int);
158extern void rewind(FILE *);
159extern long ftell(FILE *);
160extern int feof(FILE *);
161
162extern int fflush(FILE *);
163extern int ferror(FILE *);
164extern void clearerr(FILE *);
165
166extern void perror(const char *);
167
168extern void setvbuf(FILE *, void *, int, size_t);
169extern void setbuf(FILE *, void *);
170
171/* Misc file functions */
172extern int remove(const char *);
173extern int rename(const char *, const char *);
174
175extern FILE *tmpfile(void);
176extern char *tmpnam(char *s) __attribute__((deprecated));
177
178#ifdef _HELENOS_SOURCE
179
180/* Nonstandard extensions. */
181
182enum _buffer_type {
183 /** No buffering */
184 _IONBF,
185 /** Line buffering */
186 _IOLBF,
187 /** Full buffering */
188 _IOFBF
189};
190
191enum _buffer_state {
192 /** Buffer is empty */
193 _bs_empty,
194
195 /** Buffer contains data to be written */
196 _bs_write,
197
198 /** Buffer contains prefetched data for reading */
199 _bs_read
200};
201
202extern int vprintf_size(const char *, va_list);
203extern int printf_size(const char *, ...)
204 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
205extern FILE *fdopen(int, const char *);
206extern int fileno(FILE *);
207
208#include <offset.h>
209
210extern int fseek64(FILE *, off64_t, int);
211extern off64_t ftell64(FILE *);
212
213#endif
214
215
216#endif
217
218/** @}
219 */
Note: See TracBrowser for help on using the repository browser.