2008-10-31 16:02:40 +03:00
|
|
|
/*
|
2012-07-19 22:11:40 +04:00
|
|
|
* Copyright 2004-2012 Haiku, Inc. All Rights Reserved.
|
2009-11-26 19:17:17 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2004-05-03 16:20:52 +04:00
|
|
|
#ifndef _STDIO_H_
|
|
|
|
#define _STDIO_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <null.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
|
2008-05-11 01:30:34 +04:00
|
|
|
/* Dodge gcc 2.95.3's fixincludes hack stdio_va_list by including this string:
|
|
|
|
* __gnuc_va_list */
|
2008-03-16 20:21:37 +03:00
|
|
|
|
|
|
|
|
2009-07-26 19:28:33 +04:00
|
|
|
#define BUFSIZ 8192
|
2004-05-03 16:20:52 +04:00
|
|
|
#define _IOFBF 0 /* fully buffered */
|
|
|
|
#define _IOLBF 1 /* line buffered */
|
|
|
|
#define _IONBF 2 /* not buffered */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FOPEN_MAX is a minimum maximum, and should be the number of descriptors
|
|
|
|
* that the kernel can provide without allocation of a resource that can
|
|
|
|
* fail without the process sleeping. Do not use this for anything
|
|
|
|
*/
|
|
|
|
#define FOPEN_MAX 128
|
|
|
|
#define STREAM_MAX FOPEN_MAX
|
|
|
|
#define FILENAME_MAX 256
|
|
|
|
#define TMP_MAX 32768
|
|
|
|
|
|
|
|
#define L_ctermid 32
|
|
|
|
#define L_cuserid 32
|
|
|
|
#define L_tmpnam 512
|
|
|
|
|
|
|
|
#define P_tmpdir "/tmp/"
|
|
|
|
|
|
|
|
#ifdef EOF
|
|
|
|
# undef EOF
|
|
|
|
#endif
|
|
|
|
#define EOF -1
|
|
|
|
|
|
|
|
#ifndef SEEK_SET
|
|
|
|
# define SEEK_SET 0
|
|
|
|
#endif
|
|
|
|
#ifndef SEEK_CUR
|
|
|
|
# define SEEK_CUR 1
|
|
|
|
#endif
|
|
|
|
#ifndef SEEK_END
|
|
|
|
# define SEEK_END 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
typedef off_t fpos_t;
|
|
|
|
|
|
|
|
#include <stdio_pre.h>
|
|
|
|
|
|
|
|
extern FILE *stdin;
|
|
|
|
extern FILE *stdout;
|
|
|
|
extern FILE *stderr;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* file operations */
|
|
|
|
extern FILE *fopen(const char *name, const char *mode);
|
|
|
|
extern FILE *freopen(const char *name, const char *mode, FILE *stream);
|
|
|
|
extern FILE *fdopen(int fd, const char *mode);
|
|
|
|
extern int fclose(FILE *stream);
|
2015-05-09 00:46:15 +03:00
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
extern int fcloseall(void);
|
|
|
|
#endif
|
2004-05-03 16:20:52 +04:00
|
|
|
|
|
|
|
extern int fileno(FILE *stream);
|
|
|
|
extern int fileno_unlocked(FILE *stream);
|
|
|
|
|
|
|
|
extern int ferror(FILE *stream);
|
|
|
|
extern int ferror_unlocked(FILE *stream);
|
|
|
|
extern void clearerr(FILE *stream);
|
|
|
|
extern void clearerr_unlocked(FILE *stream);
|
|
|
|
|
|
|
|
extern int feof(FILE *stream);
|
|
|
|
extern int feof_unlocked(FILE *stream);
|
|
|
|
|
|
|
|
extern void flockfile(FILE *stream);
|
|
|
|
extern void funlockfile(FILE *stream);
|
|
|
|
extern int ftrylockfile(FILE *stream);
|
|
|
|
|
|
|
|
extern int remove(const char *name);
|
|
|
|
extern int rename(const char *from, const char *to);
|
2009-11-26 19:17:17 +03:00
|
|
|
extern int renameat(int fromFD, const char *from, int toFD, const char *to);
|
2004-05-03 16:20:52 +04:00
|
|
|
|
|
|
|
/* pipes */
|
|
|
|
extern FILE *popen(const char *command, const char *mode);
|
|
|
|
extern int pclose(FILE *stream);
|
|
|
|
extern void perror(const char *errorPrefix);
|
|
|
|
|
2010-08-10 13:56:13 +04:00
|
|
|
/* memory streams */
|
|
|
|
extern FILE *fmemopen(void *buf, size_t size, const char *mode);
|
2011-08-10 23:14:49 +04:00
|
|
|
extern FILE *open_memstream(char **buf, size_t *size);
|
2010-08-10 13:56:13 +04:00
|
|
|
|
2014-11-19 17:13:45 +03:00
|
|
|
/* callback streams */
|
|
|
|
#ifdef _GNU_SOURCE
|
2014-11-19 17:43:09 +03:00
|
|
|
typedef ssize_t (*cookie_read_function_t)(void *cookie, char *buf, size_t size);
|
|
|
|
typedef ssize_t (*cookie_write_function_t)(void *cookie, const char *buf, size_t size);
|
|
|
|
typedef ssize_t (*cookie_seek_function_t)(void *cookie, off_t *offset, int whence);
|
|
|
|
typedef ssize_t (*cookie_close_function_t)(void *cookie);
|
2014-11-19 17:13:45 +03:00
|
|
|
typedef struct {
|
|
|
|
cookie_read_function_t *read;
|
|
|
|
cookie_write_function_t *write;
|
|
|
|
cookie_seek_function_t *seek;
|
|
|
|
cookie_close_function_t *close;
|
|
|
|
} cookie_io_functions_t;
|
|
|
|
extern FILE *fopencookie(void *cookie, const char *mode, cookie_io_functions_t io_funcs);
|
|
|
|
#endif /*_GNU_SOURCE*/
|
|
|
|
|
2004-05-03 16:20:52 +04:00
|
|
|
/* file I/O */
|
|
|
|
extern int fflush(FILE *stream);
|
|
|
|
extern int fflush_unlocked(FILE *stream);
|
2008-10-31 16:02:40 +03:00
|
|
|
extern int fpurge(FILE *stream);
|
2004-05-03 16:20:52 +04:00
|
|
|
|
|
|
|
extern int fgetpos(FILE *stream, fpos_t *position);
|
|
|
|
extern int fsetpos(FILE *stream, const fpos_t *position);
|
|
|
|
extern int fseek(FILE *stream, long offset, int seekType);
|
|
|
|
extern int fseeko(FILE *stream, off_t offset, int seekType);
|
|
|
|
extern int _fseek(FILE *stream, fpos_t offset, int seekType);
|
|
|
|
extern long ftell(FILE *stream);
|
|
|
|
extern off_t ftello(FILE *stream);
|
|
|
|
extern fpos_t _ftell(FILE *stream);
|
|
|
|
|
|
|
|
extern void rewind(FILE *stream);
|
|
|
|
|
2005-01-29 16:06:04 +03:00
|
|
|
extern void setbuf (FILE *file, char *buff);
|
|
|
|
extern int setvbuf(FILE *file, char *buff, int mode, size_t size);
|
|
|
|
extern int setbuffer(FILE *stream, char *buf, size_t size);
|
|
|
|
extern int setlinebuf(FILE *stream);
|
|
|
|
|
2004-05-03 16:20:52 +04:00
|
|
|
extern size_t fwrite(const void *buffer, size_t size, size_t numItems, FILE *stream);
|
2014-03-09 23:09:26 +04:00
|
|
|
extern size_t fwrite_unlocked(const void *buffer, size_t size, size_t numItems, FILE *stream);
|
2004-05-03 16:20:52 +04:00
|
|
|
extern size_t fread(void *buffer, size_t size, size_t numItems, FILE *stream);
|
2014-03-09 23:09:26 +04:00
|
|
|
extern size_t fread_unlocked(void *buffer, size_t size, size_t numItems, FILE *stream);
|
2004-05-03 16:20:52 +04:00
|
|
|
|
|
|
|
extern int putc(int c, FILE *stream);
|
|
|
|
extern int putchar(int c);
|
|
|
|
extern int putc_unlocked(int c, FILE *stream);
|
|
|
|
extern int putchar_unlocked(int c);
|
|
|
|
extern int fputc(int c, FILE *stream);
|
|
|
|
extern int fputc_unlocked(int c, FILE *stream);
|
|
|
|
extern int puts(const char *string);
|
|
|
|
extern int fputs(const char *string, FILE *stream);
|
2014-03-09 23:09:26 +04:00
|
|
|
extern int fputs_unlocked(const char *string, FILE *stream);
|
2004-05-03 16:20:52 +04:00
|
|
|
|
|
|
|
extern int getc(FILE *stream);
|
|
|
|
extern int getc_unlocked(FILE *stream);
|
|
|
|
extern int ungetc(int c, FILE *stream);
|
|
|
|
extern int getchar(void);
|
|
|
|
extern int getchar_unlocked(void);
|
|
|
|
extern int fgetc(FILE *stream);
|
2014-03-09 23:09:26 +04:00
|
|
|
extern int fgetc_unlocked(FILE *stream);
|
2004-05-03 16:20:52 +04:00
|
|
|
extern char *gets(char *buffer);
|
|
|
|
extern char *fgets(char *string, int stringLength, FILE *stream);
|
2014-03-09 23:09:26 +04:00
|
|
|
extern char *fgets_unlocked(char *string, int stringLength, FILE *stream);
|
2004-05-03 16:20:52 +04:00
|
|
|
|
2010-10-04 16:37:48 +04:00
|
|
|
extern ssize_t getdelim(char **_line, size_t *_length, int delimiter,
|
|
|
|
FILE *stream);
|
|
|
|
extern ssize_t getline(char **_line, size_t *_length, FILE *stream);
|
|
|
|
|
2004-05-03 16:20:52 +04:00
|
|
|
/* formatted I/O */
|
|
|
|
extern int printf(char const *format, ...) __PRINTFLIKE(1,2);
|
|
|
|
extern int fprintf(FILE *stream, char const *format, ...) __PRINTFLIKE(2,3);
|
|
|
|
extern int sprintf(char *string, char const *format, ...) __PRINTFLIKE(2,3);
|
|
|
|
extern int snprintf(char *string, size_t size, char const *format, ...) __PRINTFLIKE(3,4);
|
|
|
|
extern int asprintf(char **ret, char const *format, ...) __PRINTFLIKE(2,3);
|
|
|
|
extern int vprintf(char const *format, va_list ap);
|
|
|
|
extern int vfprintf(FILE *stream, char const *format, va_list ap);
|
|
|
|
extern int vsprintf(char *string, char const *format, va_list ap);
|
|
|
|
extern int vsnprintf(char *string, size_t size, char const *format, va_list ap);
|
|
|
|
extern int vasprintf(char **ret, char const *format, va_list ap);
|
|
|
|
|
|
|
|
extern int scanf(char const *format, ...);
|
|
|
|
extern int fscanf(FILE *stream, char const *format, ...);
|
|
|
|
extern int sscanf(char const *str, char const *format, ...);
|
|
|
|
extern int vscanf(char const *format, va_list ap);
|
|
|
|
extern int vsscanf(char const *str, char const *format, va_list ap);
|
|
|
|
extern int vfscanf(FILE *stream, char const *format, va_list ap);
|
|
|
|
|
|
|
|
/* misc */
|
|
|
|
extern char *ctermid(char *controllingTerminal);
|
2004-11-10 23:25:12 +03:00
|
|
|
extern char *cuserid(char *s);
|
2004-05-03 16:20:52 +04:00
|
|
|
|
|
|
|
/* temporary files */
|
2019-12-31 16:21:56 +03:00
|
|
|
extern char *tempnam(char const *path, char const *prefix);
|
2020-01-04 23:26:08 +03:00
|
|
|
extern FILE *tmpfile(void);
|
2019-12-31 16:21:56 +03:00
|
|
|
extern char *tmpnam(char *nameBuffer);
|
2020-01-04 23:26:08 +03:00
|
|
|
extern char *tmpnam_r(char *nameBuffer);
|
2004-05-03 16:20:52 +04:00
|
|
|
|
|
|
|
#include <stdio_post.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-10-04 16:37:48 +04:00
|
|
|
|
2004-05-03 16:20:52 +04:00
|
|
|
#endif /* _STDIO_H_ */
|