source: mainline/uspace/lib/c/include/stdio.h@ 1d2f85e

Last change on this file since 1d2f85e was 08e103d4, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 6 years ago

Use clearer naming for string length functions

This and the following commit change the names of functions, as well as
their documentation, to use unambiguous terms "bytes" and "code points"
instead of ambiguous terms "size", "length", and "characters".

  • 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#ifdef __cplusplus
40extern "C" {
41#endif
42
43#include <offset.h>
44#include <stdarg.h>
45#include <io/verify.h>
46#include <_bits/NULL.h>
47#include <_bits/size_t.h>
48#include <_bits/wchar_t.h>
49#include <_bits/wint_t.h>
50
51/** Forward declaration */
52struct _IO_FILE;
53typedef struct _IO_FILE FILE;
54
55/** File position */
56typedef struct {
57 off64_t pos;
58} fpos_t;
59
60#ifndef _HELENOS_SOURCE
61#define _IONBF 0
62#define _IOLBF 1
63#define _IOFBF 2
64#endif
65
66/** Default size for stream I/O buffers */
67#define BUFSIZ 4096
68
69#define EOF (-1)
70
71/** Max number of files that is guaranteed to be able to open at the same time */
72#define FOPEN_MAX VFS_MAX_OPEN_FILES
73
74/** Recommended size of fixed-size array for holding file names. */
75#define FILENAME_MAX 4096
76
77/** Length of "/tmp/tmp.XXXXXX" + 1 */
78#define L_tmpnam 16
79
80#ifndef SEEK_SET
81#define SEEK_SET 0
82#endif
83
84#ifndef SEEK_CUR
85#define SEEK_CUR 1
86#endif
87
88#ifndef SEEK_END
89#define SEEK_END 2
90#endif
91
92/** Minimum number of unique temporary file names */
93#define TMP_MAX 1000000
94
95extern FILE *stdin;
96extern FILE *stdout;
97extern FILE *stderr;
98
99/* Character and string input functions */
100#define getc fgetc
101extern int fgetc(FILE *);
102extern char *fgets(char *, int, FILE *);
103extern char *gets(char *, size_t) __attribute__((deprecated));
104
105extern int getchar(void);
106
107/* Character and string output functions */
108#define putc fputc
109extern int fputc(int, FILE *);
110extern int fputs(const char *, FILE *);
111
112extern int putchar(int);
113extern int puts(const char *);
114
115extern int ungetc(int, FILE *);
116
117extern wint_t fputwc(wchar_t, FILE *);
118extern wint_t putwchar(wchar_t);
119
120/* Formatted string output functions */
121extern int fprintf(FILE *, const char *, ...)
122 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
123extern int vfprintf(FILE *, const char *, va_list);
124
125extern int printf(const char *, ...)
126 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
127extern int vprintf(const char *, va_list);
128
129extern int snprintf(char *, size_t, const char *, ...)
130 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
131#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
132extern int vasprintf(char **, const char *, va_list);
133extern int asprintf(char **, const char *, ...)
134 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
135#endif
136extern int vsnprintf(char *, size_t, const char *, va_list);
137
138extern int sprintf(char *, const char *, ...)
139 __attribute__((deprecated)) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
140extern int vsprintf(char *, const char *, va_list) __attribute__((deprecated));
141
142/* Formatted input */
143extern int scanf(const char *, ...);
144extern int vscanf(const char *, va_list);
145extern int fscanf(FILE *, const char *, ...);
146extern int vfscanf(FILE *, const char *, va_list);
147extern int sscanf(const char *, const char *, ...);
148extern int vsscanf(const char *, const char *, va_list);
149
150/* File stream functions */
151extern FILE *fopen(const char *, const char *);
152extern FILE *freopen(const char *, const char *, FILE *);
153extern int fclose(FILE *);
154
155extern size_t fread(void *, size_t, size_t, FILE *);
156extern size_t fwrite(const void *, size_t, size_t, FILE *);
157
158extern int fgetpos(FILE *, fpos_t *);
159extern int fsetpos(FILE *, const fpos_t *);
160
161extern int fseek(FILE *, long, int);
162extern void rewind(FILE *);
163extern long ftell(FILE *);
164extern int feof(FILE *);
165
166extern int fflush(FILE *);
167extern int ferror(FILE *);
168extern void clearerr(FILE *);
169
170extern void perror(const char *);
171
172extern int setvbuf(FILE *, void *, int, size_t);
173extern void setbuf(FILE *, void *);
174
175/* Misc file functions */
176extern int remove(const char *);
177extern int rename(const char *, const char *);
178
179extern FILE *tmpfile(void);
180extern char *tmpnam(char *s);
181
182#ifdef _HELENOS_SOURCE
183
184/* Nonstandard extensions. */
185
186enum _buffer_type {
187 /** No buffering */
188 _IONBF,
189 /** Line buffering */
190 _IOLBF,
191 /** Full buffering */
192 _IOFBF
193};
194
195enum _buffer_state {
196 /** Buffer is empty */
197 _bs_empty,
198
199 /** Buffer contains data to be written */
200 _bs_write,
201
202 /** Buffer contains prefetched data for reading */
203 _bs_read
204};
205
206extern int vprintf_code_points(const char *, va_list);
207extern int printf_code_points(const char *, ...)
208 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
209extern FILE *fdopen(int, const char *);
210extern int fileno(FILE *);
211
212#include <offset.h>
213
214extern int fseek64(FILE *, off64_t, int);
215extern off64_t ftell64(FILE *);
216
217#endif
218
219#ifdef __cplusplus
220}
221#endif
222
223#endif
224
225/** @}
226 */
Note: See TracBrowser for help on using the repository browser.