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
RevLine 
[3eddaff]1/*
[df4ed85]2 * Copyright (c) 2005 Martin Decky
[777832e]3 * Copyright (c) 2018 Jiri Svoboda
[3eddaff]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
[fadd381]30/** @addtogroup libc
[b2951e2]31 * @{
32 */
33/** @file
34 */
35
[fadd381]36#ifndef LIBC_STDIO_H_
37#define LIBC_STDIO_H_
[3eddaff]38
[82fd245]39#ifdef __cplusplus
40extern "C" {
41#endif
42
[777832e]43#include <offset.h>
[3214a20]44#include <stdarg.h>
[aa492fe]45#include <io/verify.h>
[4e6a610]46#include <_bits/NULL.h>
[1d6dd2a]47#include <_bits/size_t.h>
48#include <_bits/wchar_t.h>
[ed88c8e]49#include <_bits/wint_t.h>
[9ac2013]50
[4e6a610]51/** Forward declaration */
52struct _IO_FILE;
53typedef struct _IO_FILE FILE;
[c23275a]54
[4e6a610]55/** File position */
56typedef struct {
57 off64_t pos;
58} fpos_t;
[c23275a]59
[4e6a610]60#ifndef _HELENOS_SOURCE
61#define _IONBF 0
62#define _IOLBF 1
63#define _IOFBF 2
[c23275a]64#endif
65
[ef8bcc6]66/** Default size for stream I/O buffers */
[db24058]67#define BUFSIZ 4096
[ef8bcc6]68
[4e6a610]69#define EOF (-1)
70
[777832e]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
[55092672]74/** Recommended size of fixed-size array for holding file names. */
75#define FILENAME_MAX 4096
76
[4e6a610]77/** Length of "/tmp/tmp.XXXXXX" + 1 */
78#define L_tmpnam 16
[04b687b]79
[4e6a610]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
[777832e]94
[2595dab]95extern FILE *stdin;
96extern FILE *stdout;
97extern FILE *stderr;
98
99/* Character and string input functions */
[55092672]100#define getc fgetc
[2595dab]101extern int fgetc(FILE *);
[c62d2e1]102extern char *fgets(char *, int, FILE *);
[296890f3]103extern char *gets(char *, size_t) __attribute__((deprecated));
[1c1002a]104
[b27a97bb]105extern int getchar(void);
106
[2595dab]107/* Character and string output functions */
[55092672]108#define putc fputc
[ed88c8e]109extern int fputc(int, FILE *);
[2595dab]110extern int fputs(const char *, FILE *);
111
[ed88c8e]112extern int putchar(int);
[ab00d5a]113extern int puts(const char *);
[3eddaff]114
[bd5414e]115extern int ungetc(int, FILE *);
116
[ed88c8e]117extern wint_t fputwc(wchar_t, FILE *);
118extern wint_t putwchar(wchar_t);
119
[2595dab]120/* Formatted string output functions */
[1433ecda]121extern int fprintf(FILE *, const char *, ...)
[09d13c8e]122 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
[2595dab]123extern int vfprintf(FILE *, const char *, va_list);
[3214a20]124
[9ac2013]125extern int printf(const char *, ...)
[09d13c8e]126 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
[ab00d5a]127extern int vprintf(const char *, va_list);
[3214a20]128
[1433ecda]129extern int snprintf(char *, size_t, const char *, ...)
[09d13c8e]130 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
[55092672]131#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
[a9763c6]132extern int vasprintf(char **, const char *, va_list);
[9ac2013]133extern int asprintf(char **, const char *, ...)
[09d13c8e]134 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
[296890f3]135#endif
[2595dab]136extern int vsnprintf(char *, size_t, const char *, va_list);
[a8e9ab8d]137
[296890f3]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
[5a6c28d1]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);
[ed18e14]149
[2595dab]150/* File stream functions */
[04b687b]151extern FILE *fopen(const char *, const char *);
[80bee81]152extern FILE *freopen(const char *, const char *, FILE *);
[04b687b]153extern int fclose(FILE *);
[2595dab]154
[04b687b]155extern size_t fread(void *, size_t, size_t, FILE *);
156extern size_t fwrite(const void *, size_t, size_t, FILE *);
[2595dab]157
[777832e]158extern int fgetpos(FILE *, fpos_t *);
159extern int fsetpos(FILE *, const fpos_t *);
160
[456c086]161extern int fseek(FILE *, long, int);
[080ad7f]162extern void rewind(FILE *);
[456c086]163extern long ftell(FILE *);
[04b687b]164extern int feof(FILE *);
[2595dab]165
166extern int fflush(FILE *);
[04b687b]167extern int ferror(FILE *);
168extern void clearerr(FILE *);
169
[777832e]170extern void perror(const char *);
171
[58daded]172extern int setvbuf(FILE *, void *, int, size_t);
[7699c21]173extern void setbuf(FILE *, void *);
[ef8bcc6]174
[b942a66]175/* Misc file functions */
176extern int remove(const char *);
[4e6a610]177extern int rename(const char *, const char *);
[b942a66]178
[4e6a610]179extern FILE *tmpfile(void);
[b79903b]180extern char *tmpnam(char *s);
[bc1b297]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
[08e103d4]206extern int vprintf_code_points(const char *, va_list);
207extern int printf_code_points(const char *, ...)
[bc1b297]208 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
209extern FILE *fdopen(int, const char *);
210extern int fileno(FILE *);
211
[1c7f381]212#include <offset.h>
213
214extern int fseek64(FILE *, off64_t, int);
215extern off64_t ftell64(FILE *);
216
[bc1b297]217#endif
218
[82fd245]219#ifdef __cplusplus
220}
221#endif
222
[3eddaff]223#endif
[b2951e2]224
[fadd381]225/** @}
[b2951e2]226 */
Note: See TracBrowser for help on using the repository browser.