source: mainline/uspace/lib/posix/stdio.h@ 3f466c33

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3f466c33 was 8b5fb5e, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

stdio.h: Add and implement more functions

  • Property mode set to 100644
File size: 5.5 KB
RevLine 
[3a3ef72]1/*
2 * Copyright (c) 2011 Jiri Zarevucky
[4f4b4e7]3 * Copyright (c) 2011 Petr Koupy
[3a3ef72]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
[4f4b4e7]30/** @addtogroup libposix
31 * @{
32 */
33/** @file
34 */
35
[3a3ef72]36#ifndef POSIX_STDIO_H_
37#define POSIX_STDIO_H_
38
39#include "libc/stdio.h"
[b08ef1fd]40#include "sys/types.h"
[823a929]41#include "libc/stdarg.h"
[8b5fb5e]42#include "limits.h"
[3a3ef72]43
[8b5fb5e]44#undef L_ctermid
45#define L_ctermid PATH_MAX
46
47extern void posix_clearerr(FILE *stream);
48extern char *posix_ctermid(char *s);
49
50/* Input/Output */
[e3891262]51#undef putc
[3a3ef72]52#define putc fputc
[e3891262]53#undef getc
[09b0b1fb]54#define getc fgetc
[59f799b]55extern int posix_ungetc(int c, FILE *stream);
[09b0b1fb]56
[8b5fb5e]57extern ssize_t posix_getdelim(char **restrict lineptr, size_t *restrict n,
58 int delimiter, FILE *restrict stream);
59extern ssize_t posix_getline(char **restrict lineptr, size_t *restrict n,
60 FILE *restrict stream);
61
[4f4b4e7]62/* Opening Streams */
63extern FILE *posix_freopen(
64 const char *restrict filename,
65 const char *restrict mode,
66 FILE *restrict stream);
[09b0b1fb]67
[8b5fb5e]68/* Memory Streams */
69
70extern FILE *posix_fmemopen(void *restrict buf, size_t size,
71 const char *restrict mode);
72extern FILE *posix_open_memstream(char **bufp, size_t *sizep);
73
[4f4b4e7]74/* Error Messages */
[09b0b1fb]75extern void posix_perror(const char *s);
76
[b08ef1fd]77/* File Positioning */
[8b5fb5e]78
79typedef struct _posix_fpos posix_fpos_t;
80extern int posix_fsetpos(FILE *stream, const posix_fpos_t *pos);
81extern int posix_fgetpos(FILE *restrict stream, posix_fpos_t *restrict pos);
82extern int posix_fseek(FILE *stream, long offset, int whence);
[b08ef1fd]83extern int posix_fseeko(FILE *stream, posix_off_t offset, int whence);
[8b5fb5e]84extern long posix_ftell(FILE *stream);
[b08ef1fd]85extern posix_off_t posix_ftello(FILE *stream);
86
[59f799b]87/* Formatted Input/Output */
[8b5fb5e]88extern int posix_dprintf(int fildes, const char *restrict format, ...)
89 PRINTF_ATTRIBUTE(2, 3);
90extern int posix_vdprintf(int fildes, const char *restrict format, va_list ap);
91extern int posix_sprintf(char *restrict s, const char *restrict format, ...)
92 PRINTF_ATTRIBUTE(2, 3);
[823a929]93extern int posix_vsprintf(char *restrict s, const char *restrict format, va_list ap);
[8b5fb5e]94
95extern int posix_fscanf(
96 FILE *restrict stream, const char *restrict format, ...);
97extern int posix_vfscanf(
98 FILE *restrict stream, const char *restrict format, va_list arg);
99extern int posix_scanf(const char *restrict format, ...);
100extern int posix_vscanf(const char *restrict format, va_list arg);
101extern int posix_sscanf(
102 const char *restrict s, const char *restrict format, ...);
103extern int posix_vsscanf(
104 const char *restrict s, const char *restrict format, va_list arg);
105
106/* File Locking */
107
108extern void posix_flockfile(FILE *file);
109extern int posix_ftrylockfile(FILE *file);
110extern void posix_funlockfile(FILE *file);
111
112extern int posix_getc_unlocked(FILE *stream);
113extern int posix_getchar_unlocked(void);
114extern int posix_putc_unlocked(int c, FILE *stream);
115extern int posix_putchar_unlocked(int c);
[59f799b]116
[823a929]117/* Deleting Files */
118extern int posix_remove(const char *path);
119
120/* Temporary Files */
[e3891262]121#undef L_tmpnam
122#define L_tmpnam PATH_MAX
123
[823a929]124extern char *posix_tmpnam(char *s);
125
[491e1ee]126#ifndef LIBPOSIX_INTERNAL
[8b5fb5e]127 #define clearerr posix_clearerr
128 #define ctermid posix_ctermid
129
[59f799b]130 #define ungetc posix_ungetc
131
[8b5fb5e]132 #define getdelim posix_getdelim
133 #define getline posix_getline
134
[09b0b1fb]135 #define freopen posix_freopen
[4f4b4e7]136
[8b5fb5e]137 #define fmemopen posix_fmemopen
138 #define open_memstream posix_open_memstream
139
[09b0b1fb]140 #define perror posix_perror
[b08ef1fd]141
[8b5fb5e]142 #define fpos_t posix_fpos_t
143 #define fsetpos posix_fsetpos
144 #define fgetpos posix_fgetpos
145 #define fseek posix_fseek
[b08ef1fd]146 #define fseeko posix_fseeko
[8b5fb5e]147 #define ftell posix_ftell
[b08ef1fd]148 #define ftello posix_ftello
[59f799b]149
[8b5fb5e]150 #define dprintf posix_dprintf
151 #define vdprintf posix_vdprintf
[59f799b]152 #define sprintf posix_sprintf
[823a929]153 #define vsprintf posix_vsprintf
[8b5fb5e]154
155 #define fscanf posix_fscanf
156 #define vfscanf posix_vfscanf
157 #define vscanf posix_vscanf
158 #define scanf posix_scanf
[59f799b]159 #define sscanf posix_sscanf
[8b5fb5e]160 #define vsscanf posix_vsscanf
161
162 #define flockfile posix_flockfile
163 #define ftrylockfile posix_ftrylockfile
164 #define funlockfile posix_funlockfile
165
166 #define getc_unlocked posix_getc_unlocked
167 #define getchar_unlocked posix_getchar_unlocked
168 #define putc_unlocked posix_putc_unlocked
169 #define putchar_unlocked posix_putchar_unlocked
[823a929]170
171 #define remove posix_remove
172
173 #define tmpnam posix_tmpnam
[09b0b1fb]174#endif
[3a3ef72]175
176#endif /* POSIX_STDIO_H_ */
177
[4f4b4e7]178/** @}
179 */
Note: See TracBrowser for help on using the repository browser.