2020-11-18 09:41:58 +00:00
|
|
|
/*
|
|
|
|
* <stdio.h> - input/output
|
|
|
|
* This header is a part of the FENIX C Library and is free software.
|
|
|
|
* You can redistribute and/or modify it subject to the terms of the
|
|
|
|
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
|
|
|
|
*
|
|
|
|
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
|
|
|
|
* The CWPL for more details.
|
|
|
|
*/
|
|
|
|
|
2020-02-12 05:23:27 +00:00
|
|
|
#ifndef _STDIO_H
|
|
|
|
#define _STDIO_H
|
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
#ifdef _XOPEN_SOURCE
|
|
|
|
#ifdef _POSIX_C_SOURCE
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2020-02-12 05:23:27 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
#ifndef NULL
|
|
|
|
#define NULL ((void *) 0)
|
|
|
|
#endif
|
|
|
|
|
2020-12-01 23:32:03 +00:00
|
|
|
#include <types/size_t.h>
|
|
|
|
#include <types/ssize_t.h>
|
|
|
|
#include <types/off_t.h>
|
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
#ifdef _POSIX_C_SOURCE
|
|
|
|
#include <types/ssize_t.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2020-12-01 23:32:03 +00:00
|
|
|
typedef unsigned long int fpos_t;
|
2020-11-18 09:41:58 +00:00
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
typedef struct _FILE_STRUCT {
|
|
|
|
fpos_t position; /* Current position in file */
|
|
|
|
int fildes; /* The file's file descriptor */
|
|
|
|
int rw; /* Is it read-only or read-write? */
|
|
|
|
int errind; /* Have we got an error? */
|
|
|
|
int eofind; /* Have we reached EOF? */
|
|
|
|
char * buffer; /* The file's buffer */
|
|
|
|
int buf_size; /* The size of the file's buffer */
|
|
|
|
int buf_mode; /* How is the file buffered? (_IOFBF, etc.) */
|
|
|
|
} FILE;
|
|
|
|
|
2020-02-12 05:23:27 +00:00
|
|
|
#define EOF (-1)
|
|
|
|
|
2020-12-01 23:32:03 +00:00
|
|
|
#define _IOFBF 01 /* IO fully buffered */
|
|
|
|
#define _IOLBF 02 /* IO line buffered */
|
|
|
|
#define _IONBF 04 /* IO not buffered */
|
|
|
|
|
|
|
|
#define SEEK_CUR 01 /* Seek relative to current position */
|
|
|
|
#define SEEK_END 02 /* Seek relative to end of file */
|
|
|
|
#define SEEK_SET 04 /* Seek relative to start of file */
|
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
#define BUFSIZ 1024
|
|
|
|
#define FILENAME_MAX 4096
|
|
|
|
#define FOPEN_MAX 1024
|
|
|
|
#define L_tmpnam 512
|
|
|
|
#define TMP_MAX 65536
|
|
|
|
#ifdef _POSIX_C_SOURCE
|
|
|
|
#define L_ctermid 1024
|
|
|
|
#endif
|
2020-02-12 05:23:27 +00:00
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
extern const FILE * stdin;
|
|
|
|
extern const FILE * stdout;
|
|
|
|
extern const FILE * stderr;
|
|
|
|
|
|
|
|
#define stdin (stdin)
|
|
|
|
#define stdout (stdout)
|
|
|
|
#define stderr (stderr)
|
2020-02-12 05:23:27 +00:00
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
/* Operations on files (ISO C Std. 7.19.4) */
|
|
|
|
int remove(const char *);
|
|
|
|
int rename(const char *, const char *);
|
|
|
|
|
|
|
|
FILE * tmpfile(void);
|
|
|
|
char * tmpnam(char *);
|
|
|
|
|
|
|
|
/* File access functions (ISO C Std. 7.19.5) */
|
|
|
|
int fclose(FILE *);
|
|
|
|
int fflush(FILE *);
|
|
|
|
FILE * fopen(const char * restrict, const char * restrict);
|
|
|
|
FILE * freopen(const char * restrict, const char * restrict, FILE * restrict);
|
|
|
|
|
|
|
|
void setbuf(FILE * restrict, char * restrict);
|
|
|
|
int setvbuf(FILE * restrict, char * restrict, int, size_t);
|
|
|
|
|
|
|
|
/* Formatted IO functions (ISO C Std. 7.19.6) */
|
|
|
|
int fprintf(FILE * restrict, const char * restrict, ...);
|
|
|
|
int printf(const char * restrict, ...);
|
|
|
|
int sprintf(char * restrict, const char * restrict, ...);
|
|
|
|
int snprintf(char * restrict, size_t n, const char * restrict, ...);
|
|
|
|
int vfprintf(FILE * restrict, const char * restrict, va_list);
|
|
|
|
int vprintf(const char * restrict, va_list);
|
|
|
|
int vsnprintf(char * restrict, size_t n, const char * restrict, va_list);
|
|
|
|
int vsprintf(char * restrict, const char * restrict, va_list);
|
|
|
|
|
|
|
|
int fscanf(FILE * restrict, const char * restrict, ...);
|
|
|
|
int scanf(const char * restrict, ...);
|
|
|
|
int sscanf(const char * restrict, const char * restrict, ...);
|
|
|
|
int vfscanf(FILE * restrict, const char * restrict, va_list);
|
|
|
|
int vscanf(const char * restrict, va_list);
|
|
|
|
int vsscanf(const char * restrict, const char * restrict, va_list);
|
|
|
|
|
|
|
|
/* Character IO functions (ISO C Std. 7.19.7) */
|
|
|
|
int fgetc(FILE *);
|
|
|
|
int fgets(char * restrict, int, FILE * restrict);
|
|
|
|
int fputc(int, FILE *);
|
|
|
|
int fputs(const char * restrict, FILE * restrict);
|
|
|
|
|
|
|
|
#define getc(stream) fgetc(stream)
|
|
|
|
int getchar(void);
|
|
|
|
char * gets(char *);
|
|
|
|
int putc(int, FILE *);
|
|
|
|
int putchar(int);
|
2020-02-12 05:23:27 +00:00
|
|
|
int puts(const char *);
|
|
|
|
|
2020-12-21 02:25:29 +00:00
|
|
|
int ungetc(int, FILE *);
|
|
|
|
|
|
|
|
/* Direct IO functions (ISO C Std. 7.19.8) */
|
|
|
|
size_t fread(void * restrict, size_t, size_t, FILE * restrict);
|
|
|
|
size_t fwrite(const void * restrict, size_t, size_t, FILE * restrict);
|
|
|
|
|
|
|
|
/* File positioning functions (ISO C Std. 7.19.9) */
|
|
|
|
int fgetpos(FILE * restrict, fpos_t * restrict);
|
|
|
|
int fseek(FILE *, long int, int);
|
|
|
|
int fsetpos(FILE *, const fpos_t *);
|
|
|
|
long int ftell(FILE *);
|
|
|
|
void rewind(FILE *);
|
|
|
|
|
|
|
|
/* Error-handling functions (ISO C Std. 7.19.10) */
|
|
|
|
void clearerr(FILE *);
|
|
|
|
int feof(FILE *);
|
|
|
|
int ferror(FILE *);
|
|
|
|
|
2020-11-18 09:41:58 +00:00
|
|
|
void perror(const char *);
|
|
|
|
|
2020-02-12 05:23:27 +00:00
|
|
|
#endif
|