Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NQRTGoYgnZQsh7uCh6Jsxm
118 lines
3.3 KiB
C
118 lines
3.3 KiB
C
#ifndef _LIBC_STDIO_H
|
|
#define _LIBC_STDIO_H
|
|
|
|
/* Conventional guard marker: packages like GMP sniff the libc's stdio
|
|
include-guard name to detect that FILE is available. */
|
|
#ifndef _STDIO_H
|
|
#define _STDIO_H 1
|
|
#endif
|
|
|
|
#pragma once
|
|
|
|
#include <stdarg.h>
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define EOF (-1)
|
|
#define SEEK_SET 0
|
|
#define SEEK_CUR 1
|
|
#define SEEK_END 2
|
|
#define BUFSIZ 1024
|
|
#define FILENAME_MAX 256
|
|
#define L_tmpnam 64
|
|
#define TMP_MAX 10000
|
|
#define _IOFBF 0
|
|
#define _IOLBF 1
|
|
#define _IONBF 2
|
|
|
|
typedef struct _FILE {
|
|
int handle;
|
|
unsigned long pos;
|
|
unsigned long size;
|
|
int eof;
|
|
int error;
|
|
int is_std;
|
|
int ungetc_buf;
|
|
} FILE;
|
|
|
|
extern FILE *stdin;
|
|
extern FILE *stdout;
|
|
extern FILE *stderr;
|
|
|
|
int putc(int c, FILE *stream);
|
|
void rewind(FILE *stream);
|
|
int getchar(void);
|
|
typedef long fpos_t;
|
|
|
|
int fgetpos(FILE *stream, fpos_t *pos);
|
|
int fsetpos(FILE *stream, const fpos_t *pos);
|
|
void setbuf(FILE *stream, char *buf);
|
|
int fscanf(FILE *stream, const char *fmt, ...);
|
|
int scanf(const char *fmt, ...);
|
|
int vfscanf(FILE *stream, const char *fmt, va_list ap);
|
|
|
|
int fileno(FILE *stream);
|
|
FILE *fdopen(int fd, const char *mode);
|
|
|
|
int printf(const char *fmt, ...);
|
|
int fprintf(FILE *stream, const char *fmt, ...);
|
|
int sprintf(char *str, const char *fmt, ...);
|
|
int snprintf(char *str, size_t size, const char *fmt, ...);
|
|
int vprintf(const char *fmt, va_list ap);
|
|
int vfprintf(FILE *stream, const char *fmt, va_list ap);
|
|
int vsprintf(char *str, const char *fmt, va_list ap);
|
|
int vsnprintf(char *str, size_t size, const char *fmt, va_list ap);
|
|
|
|
int puts(const char *s);
|
|
int putchar(int c);
|
|
|
|
FILE *fopen(const char *path, const char *mode);
|
|
int fclose(FILE *stream);
|
|
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
|
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
|
int fseek(FILE *stream, long offset, int whence);
|
|
long ftell(FILE *stream);
|
|
int fflush(FILE *stream);
|
|
FILE *freopen(const char *path, const char *mode, FILE *stream);
|
|
int setvbuf(FILE *stream, char *buf, int mode, size_t size);
|
|
|
|
int rename(const char *oldpath, const char *newpath);
|
|
int remove(const char *path);
|
|
|
|
int sscanf(const char *str, const char *fmt, ...);
|
|
|
|
int feof(FILE *stream);
|
|
int ferror(FILE *stream);
|
|
void clearerr(FILE *stream);
|
|
|
|
int fgetc(FILE *stream);
|
|
int getc(FILE *stream);
|
|
int fputc(int c, FILE *stream);
|
|
int ungetc(int c, FILE *stream);
|
|
char *fgets(char *s, int size, FILE *stream);
|
|
int fputs(const char *s, FILE *stream);
|
|
|
|
/* MontaukOS extension: non-blocking readiness probe for stdin.
|
|
Returns 1 when a complete line is buffered, so a following fgets/fgetc on
|
|
stdin returns without blocking; 0 otherwise. Partially typed input is kept.
|
|
This is what a select()-style poll over stdin has to be built on -- stdio
|
|
descriptors are not waitable kernel objects. */
|
|
int montauk_stdin_ready(void);
|
|
|
|
/* Blocks until a complete line is buffered on stdin, then returns 1. Same
|
|
buffer as montauk_stdin_ready(); nothing is consumed either way. */
|
|
int montauk_stdin_wait(void);
|
|
|
|
void perror(const char *s);
|
|
FILE *tmpfile(void);
|
|
char *tmpnam(char *s);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _LIBC_STDIO_H */
|