ciabatta/inc/stdio.h

151 lines
4.0 KiB
C
Raw Normal View History

#pragma once
2022-06-08 01:46:36 +00:00
#include <stdarg.h>
2022-08-04 09:47:38 +00:00
#if !defined(NULL)
#define NULL ((void *)0)
#endif
#if defined(_WIN32)
typedef unsigned long long size_t;
#else
typedef unsigned long size_t;
#endif
#if !defined(_mbstate_t_defined)
#define _mbstate_t_defined
typedef struct mbstate_t mbstate_t;
struct mbstate_t {
union {
unsigned short leftover;
unsigned short high_surrogate;
};
};
#endif
2022-06-02 05:18:26 +00:00
2022-06-02 06:28:17 +00:00
typedef struct FILE FILE;
typedef struct {
2022-08-05 11:47:19 +00:00
unsigned long long offset;
mbstate_t mbstate;
} fpos_t;
2022-06-09 09:04:39 +00:00
2022-06-07 02:57:57 +00:00
#if !defined(NULL)
#define NULL ((void *)0)
#endif
#if !defined(__STDC_LIB_EXT1__)
#define __STDC_LIB_EXT1__
typedef int errno_t;
typedef size_t rsize_t;
#endif
#ifdef __STDC_WANT_SECURE_LIB__
#if !defined(__STDC_WANT_LIB_EXT1__)
#define __STDC_WANT_LIB_EXT1__ 1
#endif
#endif
2022-06-21 13:32:46 +00:00
#define _IONBF 0
#define _IOFBF 1
#define _IOLBF 2
#define BUFSIZ 512
#define EOF (-1)
#define FOPEN_MAX 1024
2022-06-02 06:28:17 +00:00
#ifdef _os_win
2022-06-07 02:57:57 +00:00
#define FILENAME_MAX 260
2022-06-02 06:28:17 +00:00
#else
2022-06-07 02:57:57 +00:00
#define FILENAME_MAX 4096
2022-06-02 06:28:17 +00:00
#endif
#define L_tmpnam FILENAME_MAX
2022-07-28 14:16:23 +00:00
#define SEEK_SET 0
2022-06-02 06:28:17 +00:00
#define SEEK_CUR 1
#define SEEK_END 2
2022-06-07 02:57:57 +00:00
#ifdef _os_win
#define TMP_MAX SHORT_MAX
#else
#define TMP_MAX INT_MAX
#endif
2022-06-02 06:28:17 +00:00
2022-06-27 02:58:24 +00:00
extern FILE *stdout;
extern FILE *stderr;
extern FILE *stdin;
2022-06-02 06:28:17 +00:00
2022-06-27 02:58:24 +00:00
// File manipulation
2022-06-02 06:28:17 +00:00
int remove(const char *filename);
int rename(const char *oldname, const char *newname);
FILE *tmpfile(void);
char *tmpnam(char *s);
2022-06-27 02:58:24 +00:00
// Opening and closing files
FILE *fopen (const char *restrict filename, const char *restrict mode);
FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict stream);
int fclose (FILE *stream);
// I/O buffering control
void setbuf (FILE *restrict stream, char *restrict buf);
int setvbuf (FILE *restrict stream, char *restrict buf, int mode, size_t size);
int fflush (FILE *stream);
// String formatted print
int vsnprintf(char *restrict s, size_t n, const char *restrict format, va_list arg);
int vsprintf (char *restrict s, const char *restrict format, va_list arg);
int snprintf (char *restrict s, size_t n, const char *restrict format, ...);
int sprintf (char *restrict s, const char *restrict format, ...);
// File formatted print
int vfprintf (FILE *restrict stream, const char *restrict format, va_list arg);
int fprintf (FILE *restrict stream, const char *restrict format, ...);
int vprintf (const char *restrict format, va_list arg);
int printf (const char *restrict format, ...);
// String formatted scan
int vsscanf(const char *restrict s, const char *restrict format, va_list arg);
int vscanf (const char *restrict format, va_list arg);
int sscanf (const char *restrict s, const char *restrict format, ...);
// String formatted scan
int vfscanf(FILE *restrict stream, const char *restrict format, va_list arg);
int fscanf (FILE *restrict stream, const char *restrict format, ...);
int scanf (const char *restrict format, ...);
// File reading
#define getc fgetc
2022-06-27 02:58:24 +00:00
int fgetc (FILE *stream);
int getchar(void);
int ungetc (int c, FILE *stream);
char *fgets (char *restrict s, int n, FILE *restrict stream);
size_t fread (void *restrict ptr, size_t size, size_t nmemb, FILE *restrict stream);
2022-07-29 05:46:16 +00:00
// File writing
#define putc fputc
2022-06-27 02:58:24 +00:00
int fputc (int c, FILE *stream);
int putchar(int c);
int fputs (const char *restrict s, FILE *restrict stream);
int puts (const char *s);
size_t fwrite (const void *restrict ptr, size_t size, size_t nmemb, FILE *restrict stream);
int fgetpos (FILE *restrict stream, fpos_t *restrict pos);
int fseek (FILE *stream, long int offset, int whence);
int fsetpos (FILE *stream, const fpos_t *pos);
long int ftell (FILE *stream);
void rewind (FILE *stream);
2022-06-02 06:28:17 +00:00
void clearerr(FILE *stream);
2022-06-27 02:58:24 +00:00
int feof (FILE *stream);
int ferror (FILE *stream);
void perror (const char *s);
2022-06-02 06:28:17 +00:00
#if __STDC_WANT_LIB_EXT1__ == 1
#define L_tmpnam_s L_tmpnam
#define TMP_MAX_S TMP_MAX
2022-06-27 02:58:24 +00:00
errno_t tmpfile_s(FILE *restrict *restrict streamptr);
errno_t tmpnam_s (char *s, rsize_t maxsize);
2022-06-02 06:28:17 +00:00
#endif