/*-1* Copyright (c) 2014 Pedro Souza <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#ifndef LSTD_H27#define LSTD_H2829#include <stand.h>30#include <sys/types.h>31#include <sys/stdarg.h>32#include <sys/stdint.h>33#include <limits.h>34#include <string.h>3536/*37* Mini stdio FILE and DIR routines. These are the minimal routines needed by38* the lfs module and lua's base code. We define them minimally here so we don't39* have to modify lua on every import. Further, since they aren't completely40* standard, we #define them to other names so they don't conflict with other41* tooling that makes assumptions about these routines that might not be, in42* fact, correct.43*/4445typedef struct FILE46{47int fd;48size_t offset;49size_t size;50} FILE;5152typedef struct DIR53{54int fd;55} DIR;5657#define fopen lua_loader_fopen58#define freopen lua_loader_freopen59#define fread lua_loader_fread60#define fwrite lua_loader_fwrite61#define fclose lua_loader_fclose62#define ferror lua_loader_ferror63#define feof lua_loader_feof64#define getc lua_loader_getc65#define opendir lua_loader_opendir66#define fdopendir lua_loader_fdopendir67#define closedir lua_loader_closedir6869FILE *fopen(const char *filename, const char *mode);70FILE *freopen( const char *filename, const char *mode, FILE *stream);71size_t fread(void *ptr, size_t size, size_t count, FILE *stream);72size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream);73int fclose(FILE *stream);74int ferror(FILE *stream);75int feof(FILE *stream);76int getc(FILE * stream);77DIR *opendir(const char *name);78DIR *fdopendir(int fd);79int closedir(DIR *);8081#ifndef EOF82#define EOF (-1)83#endif8485#define stdin ((FILE*)NULL)86#define stdout 18788#ifndef BUFSIZ89#define BUFSIZ 51290#endif9192#define lua_writestringerror(s, p) do { printf((s), (p)); } while (0)9394void luai_writestring(const char *, int);9596#define lua_writestring(s,l) luai_writestring(s,l)9798#define fflush /* */99#define fgets(b, l, s) fgetstr((b), (l), 0)100101#endif /* LSTD_H */102103104