65816-llvm-mos/runtime/include/stdio.h
Scott Duensing f338d93bae Checkpoint
2026-05-02 18:30:15 -05:00

59 lines
1.8 KiB
C

#ifndef _STDIO_H
#define _STDIO_H
#include <stdarg.h>
typedef struct __sFILE FILE;
typedef unsigned int size_t;
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
int putchar(int c);
int puts(const char *s);
int printf(const char *fmt, ...);
int vprintf(const char *fmt, va_list ap);
int sprintf(char *buf, const char *fmt, ...);
int snprintf(char *buf, size_t n, const char *fmt, ...);
int vsprintf(char *buf, const char *fmt, va_list ap);
int vsnprintf(char *buf, size_t n, const char *fmt, va_list ap);
int fprintf(FILE *stream, const char *fmt, ...);
int vfprintf(FILE *stream, const char *fmt, va_list ap);
void perror(const char *prefix);
int fputc(int c, FILE *stream);
int fputs(const char *s, FILE *stream);
int fflush(FILE *stream);
int fclose(FILE *stream);
FILE *fopen(const char *path, const char *mode);
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 feof(FILE *stream);
int ferror(FILE *stream);
void clearerr(FILE *stream);
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define EOF (-1)
int getchar(void);
int fgetc(FILE *stream);
char *fgets(char *buf, int n, FILE *stream);
int ungetc(int c, FILE *stream);
#define getc(s) fgetc(s)
// Memory-backed FS: register a memory region as a named file so
// fopen can open it. `cap` should be >= size; use cap > size for
// files that may grow on write. `writable` controls whether
// fopen("...", "w") / "a" / "r+" succeeds. Returns 0 on success,
// -1 on duplicate name or table full.
int mfsRegister(const char *path, void *buf, size_t size, size_t cap,
int writable);
int mfsUnregister(const char *path);
#endif