Serenity Operating System
at portability 118 lines 3.9 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this 9 * list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#pragma once 28 29#define _STDIO_H // Make GMP believe we exist. 30 31#include <limits.h> 32#include <stdarg.h> 33#include <bits/FILE.h> 34#include <sys/cdefs.h> 35#include <sys/types.h> 36 37#define FILENAME_MAX 1024 38 39__BEGIN_DECLS 40#ifndef EOF 41# define EOF (-1) 42#endif 43 44#define SEEK_SET 0 45#define SEEK_CUR 1 46#define SEEK_END 2 47 48#define _IOFBF 0 49#define _IOLBF 1 50#define _IONBF 2 51 52#define L_tmpnam 256 53 54extern FILE* stdin; 55extern FILE* stdout; 56extern FILE* stderr; 57 58typedef long fpos_t; 59 60int fseek(FILE*, long offset, int whence); 61int fgetpos(FILE*, fpos_t*); 62int fsetpos(FILE*, const fpos_t*); 63long ftell(FILE*); 64char* fgets(char* buffer, int size, FILE*); 65int fputc(int ch, FILE*); 66int fileno(FILE*); 67int fgetc(FILE*); 68int getc(FILE*); 69int getc_unlocked(FILE* stream); 70int getchar(); 71ssize_t getdelim(char**, size_t*, int, FILE*); 72ssize_t getline(char**, size_t*, FILE*); 73int ungetc(int c, FILE*); 74int remove(const char* pathname); 75FILE* fdopen(int fd, const char* mode); 76FILE* fopen(const char* pathname, const char* mode); 77FILE* freopen(const char* pathname, const char* mode, FILE*); 78void flockfile(FILE* filehandle); 79void funlockfile(FILE* filehandle); 80int fclose(FILE*); 81void rewind(FILE*); 82void clearerr(FILE*); 83int ferror(FILE*); 84int feof(FILE*); 85int fflush(FILE*); 86size_t fread(void* ptr, size_t size, size_t nmemb, FILE*); 87size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE*); 88int vprintf(const char* fmt, va_list); 89int vfprintf(FILE*, const char* fmt, va_list); 90int vsprintf(char* buffer, const char* fmt, va_list); 91int vsnprintf(char* buffer, size_t, const char* fmt, va_list); 92int fprintf(FILE*, const char* fmt, ...); 93int printf(const char* fmt, ...); 94int dbgprintf(const char* fmt, ...); 95void dbgputch(char); 96int dbgputstr(const char*, ssize_t); 97int sprintf(char* buffer, const char* fmt, ...); 98int snprintf(char* buffer, size_t, const char* fmt, ...); 99int putchar(int ch); 100int putc(int ch, FILE*); 101int puts(const char*); 102int fputs(const char*, FILE*); 103void perror(const char*); 104int scanf(const char* fmt, ...); 105int sscanf(const char* str, const char* fmt, ...); 106int fscanf(FILE*, const char* fmt, ...); 107int vfscanf(FILE*, const char*, va_list); 108int vsscanf(const char*, const char*, va_list); 109int setvbuf(FILE*, char* buf, int mode, size_t); 110void setbuf(FILE*, char* buf); 111void setlinebuf(FILE*); 112int rename(const char* oldpath, const char* newpath); 113FILE* tmpfile(); 114char* tmpnam(char*); 115FILE* popen(const char* command, const char* type); 116int pclose(FILE*); 117 118__END_DECLS