Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Filesystem/posix_compat.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/14/*15compatibility with posix APIs using AP_Filesystem16*/17#pragma once1819#include <sys/types.h>20#include <stdio.h>21#include <stddef.h>22#include <stdbool.h>23#include <stdint.h>2425#ifdef __cplusplus26extern "C" {27#endif2829/*30these are here to allow lua to build on HAL_ChibiOS31*/3233typedef struct apfs_file {34int fd;35bool error;36bool eof;37int16_t unget;38char *tmpfile_name;39} APFS_FILE;4041APFS_FILE *apfs_fopen(const char *pathname, const char *mode);42int apfs_fprintf(APFS_FILE *stream, const char *format, ...);43int apfs_fflush(APFS_FILE *stream);44size_t apfs_fread(void *ptr, size_t size, size_t nmemb, APFS_FILE *stream);45size_t apfs_fwrite(const void *ptr, size_t size, size_t nmemb, APFS_FILE *stream);46int apfs_fputs(const char *s, APFS_FILE *stream);47char *apfs_fgets(char *s, int size, APFS_FILE *stream);48void apfs_clearerr(APFS_FILE *stream);49int apfs_fseek(APFS_FILE *stream, long offset, int whence);50int apfs_ferror(APFS_FILE *stream);51int apfs_fclose(APFS_FILE *stream);52APFS_FILE *apfs_tmpfile(void);53int apfs_getc(APFS_FILE *stream);54int apfs_ungetc(int c, APFS_FILE *stream);55int apfs_feof(APFS_FILE *stream);56long apfs_ftell(APFS_FILE *stream);57APFS_FILE *apfs_freopen(const char *pathname, const char *mode, APFS_FILE *stream);58int apfs_remove(const char *pathname);59int apfs_rename(const char *oldpath, const char *newpath);6061#undef stdin62#undef stdout63#undef stderr64#define stdin ((APFS_FILE*)1)65#define stdout ((APFS_FILE*)2)66#define stderr ((APFS_FILE*)3)6768#undef BUFSIZ69#define BUFSIZ 25670#define EOF (-1)7172#ifndef SEEK_SET73#define SEEK_SET 074#define SEEK_CUR 175#define SEEK_END 276#endif7778#define FILE APFS_FILE7980#ifndef __cplusplus81/*82only redefine posix functions for C code (eg. lua).83for C++ use the AP_Filsystem APIs84*/85#define fopen(p,m) apfs_fopen(p,m)86#define fprintf(stream, format, args...) apfs_fprintf(stream, format, ##args)87#define fflush(s) apfs_fflush(s)88#define fread(ptr,size,nmemb, stream) apfs_fread(ptr, size, nmemb, stream)89#define fwrite(ptr, size, nmemb, stream) apfs_fwrite(ptr, size, nmemb, stream)90#define fputs(s, stream) apfs_fputs(s, stream)91#define fgets(s, size, stream) apfs_fgets(s, size, stream)92#define clearerr(stream) apfs_clearerr(stream)93#define fseek(stream, offset, whence) apfs_fseek(stream, offset, whence)94#define ferror(stream) apfs_ferror(stream)95#define fclose(stream) apfs_fclose(stream)96#define tmpfile() apfs_tmpfile()97#undef getc98#define getc(stream) apfs_getc(stream)99#define ungetc(c, stream) apfs_ungetc(c, stream)100#define feof(stream) apfs_ferror(stream)101#define ftell(stream) apfs_ftell(stream)102#define freopen(pathname, mode, stream) apfs_freopen(pathname, mode, stream)103#define rename(oldpath, newpath) apfs_rename(oldpath, newpath)104#if !defined(__APPLE__)105#define remove(pathname) apfs_remove(pathname)106int sprintf(char *str, const char *format, ...);107#endif108#endif // __cplusplus109110#ifdef __cplusplus111}112#endif113114115