1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /* Copyright (C) 2016 Jeremiah Orians
- * This file is part of M2-Planet.
- *
- * M2-Planet is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * M2-Planet is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdlib.h>
- /* Required constants */
- /* For file I/O*/
- #define EOF -1
- #define BUFSIZ 0x140000 /* 20MB */
- /* For lseek */
- #define SEEK_SET 0
- #define SEEK_CUR 1
- #define SEEK_END 2
- /* Actual format of FILE */
- struct __IO_FILE
- {
- int fd;
- int bufmode; /* 0 = no buffer, 1 = read, 2 = write */
- int bufpos;
- int buflen;
- char* buffer;
- };
- /* Now give us the FILE we all love */
- typedef struct __IO_FILE FILE;
- /* Required variables */
- extern FILE* stdin;
- extern FILE* stdout;
- extern FILE* stderr;
- /* Standard C functions */
- /* Getting */
- extern int fgetc(FILE* f);
- extern int getchar();
- extern char* fgets(char* str, int count, FILE* stream);
- /* Putting */
- extern void fputc(char s, FILE* f);
- extern void putchar(char s);
- extern int fputs(char const* str, FILE* stream);
- extern int puts(char const* str);
- /* File management */
- extern FILE* fopen(char const* filename, char const* mode);
- extern int fclose(FILE* stream);
- extern int fflush(FILE* stream);
- /* File Positioning */
- extern int ungetc(int ch, FILE* stream);
- extern long ftell(FILE* stream);
- extern int fseek(FILE* f, long offset, int whence);
- extern void rewind(FILE* f);
|