source: mainline/uspace/lib/c/include/stdio.h@ 163fc09

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 163fc09 was 163fc09, checked in by Jakub Jermar <jakub@…>, 8 years ago

Rename rename() to vfs_rename_path()

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2005 Martin Decky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32/** @file
33 */
34
35#ifndef LIBC_STDIO_H_
36#define LIBC_STDIO_H_
37
38#include <sys/types.h>
39#include <stdarg.h>
40#include <str.h>
41#include <io/verify.h>
42#include <abi/kio.h>
43
44#define EOF (-1)
45
46/** Default size for stream I/O buffers */
47#define BUFSIZ 4096
48
49#define DEBUG(fmt, ...) \
50 { \
51 char _buf[256]; \
52 int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
53 if (_n > 0) \
54 (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \
55 }
56
57enum _buffer_type {
58 /** No buffering */
59 _IONBF,
60 /** Line buffering */
61 _IOLBF,
62 /** Full buffering */
63 _IOFBF
64};
65
66enum _buffer_state {
67 /** Buffer is empty */
68 _bs_empty,
69
70 /** Buffer contains data to be written */
71 _bs_write,
72
73 /** Buffer contains prefetched data for reading */
74 _bs_read
75};
76
77/** Forward declaration */
78struct _IO_FILE;
79typedef struct _IO_FILE FILE;
80
81extern FILE *stdin;
82extern FILE *stdout;
83extern FILE *stderr;
84
85/* Character and string input functions */
86extern int fgetc(FILE *);
87extern char *fgets(char *, int, FILE *);
88
89extern int getchar(void);
90extern char *gets(char *, size_t);
91
92/* Character and string output functions */
93extern int fputc(wchar_t, FILE *);
94extern int fputs(const char *, FILE *);
95
96extern int putchar(wchar_t);
97extern int puts(const char *);
98
99extern int ungetc(int, FILE *);
100
101/* Formatted string output functions */
102extern int fprintf(FILE *, const char*, ...)
103 PRINTF_ATTRIBUTE(2, 3);
104extern int vfprintf(FILE *, const char *, va_list);
105
106extern int printf(const char *, ...)
107 PRINTF_ATTRIBUTE(1, 2);
108extern int vprintf(const char *, va_list);
109
110extern int snprintf(char *, size_t , const char *, ...)
111 PRINTF_ATTRIBUTE(3, 4);
112extern int vasprintf(char **, const char *, va_list);
113extern int asprintf(char **, const char *, ...)
114 PRINTF_ATTRIBUTE(2, 3);
115extern int vsnprintf(char *, size_t, const char *, va_list);
116
117extern int printf_size(const char *, ...)
118 PRINTF_ATTRIBUTE(1, 2);
119extern int vprintf_size(const char *, va_list);
120
121/* File stream functions */
122extern FILE *fopen(const char *, const char *);
123extern FILE *fdopen(int, const char *);
124extern FILE *freopen(const char *, const char *, FILE *);
125extern int fclose(FILE *);
126
127extern size_t fread(void *, size_t, size_t, FILE *);
128extern size_t fwrite(const void *, size_t, size_t, FILE *);
129
130extern int fseek(FILE *, off64_t, int);
131extern void rewind(FILE *);
132extern off64_t ftell(FILE *);
133extern int feof(FILE *);
134extern int fileno(FILE *);
135
136extern int fflush(FILE *);
137extern int ferror(FILE *);
138extern void clearerr(FILE *);
139
140extern void setvbuf(FILE *, void *, int, size_t);
141extern void setbuf(FILE *, void *);
142
143#endif
144
145/** @}
146 */
Note: See TracBrowser for help on using the repository browser.