From 2ef2b6265c598bcd119ef0ddc63b79f16bddbd17 Mon Sep 17 00:00:00 2001 From: belliash Date: Sat, 29 Jun 2019 11:10:50 +0200 Subject: [PATCH] Never disable IO library. --- engine/vfs.c | 30 +----------------------------- include/ph7.h | 23 ----------------------- 2 files changed, 1 insertion(+), 52 deletions(-) diff --git a/engine/vfs.c b/engine/vfs.c index bbe1853..94ed9dd 100644 --- a/engine/vfs.c +++ b/engine/vfs.c @@ -5652,7 +5652,6 @@ static int PH7_builtin_zip_entry_compressionmethod(ph7_context *pCtx, int nArg, } return PH7_OK; } -#ifndef PH7_DISABLE_DISK_IO #ifdef __WINNT__ /* * Windows VFS implementation for the PH7 engine. @@ -7674,7 +7673,6 @@ static const ph7_io_stream sUnixFileStream = { UnixFile_Stat /* xStat */ }; #endif /* __WINNT__/__UNIXES__ */ -#endif /* PH7_DISABLE_DISK_IO */ /* * Export the builtin vfs. * Return a pointer to the builtin vfs if available. @@ -7683,9 +7681,6 @@ static const ph7_io_stream sUnixFileStream = { * The built-in vfs is always available for Windows/UNIX systems. */ PH7_PRIVATE const ph7_vfs *PH7_ExportBuiltinVfs(void) { -#ifdef PH7_DISABLE_DISK_IO - return &null_vfs; -#else #ifdef __WINNT__ return &sWinVfs; #elif defined(__UNIXES__) @@ -7693,9 +7688,7 @@ PH7_PRIVATE const ph7_vfs *PH7_ExportBuiltinVfs(void) { #else return &null_vfs; #endif /* __WINNT__/__UNIXES__ */ -#endif /* PH7_DISABLE_DISK_IO */ } -#ifndef PH7_DISABLE_DISK_IO /* * The following defines are mostly used by the UNIX built and have * no particular meaning on windows. @@ -7940,18 +7933,12 @@ static const ph7_io_stream sPHP_Stream = { 0, /* xSeek */ 0 /* xStat */ }; -#endif /* PH7_DISABLE_DISK_IO */ /* * Return TRUE if we are dealing with the php:// stream. * FALSE otherwise. */ static int is_php_stream(const ph7_io_stream *pStream) { -#ifndef PH7_DISABLE_DISK_IO return pStream == &sPHP_Stream; -#else - SXUNUSED(pStream); /* cc warning */ - return 0; -#endif /* PH7_DISABLE_DISK_IO */ } /* * Export the IO routines defined above and the built-in IO streams @@ -8068,7 +8055,6 @@ PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) { for(n = 0 ; n < SX_ARRAYSIZE(aIOFunc) ; ++n) { ph7_create_function(&(*pVm), aIOFunc[n].zName, aIOFunc[n].xFunc, pVm); } -#ifndef PH7_DISABLE_DISK_IO /* Register the file stream if available */ #ifdef __WINNT__ pFileStream = &sWinFileStream; @@ -8077,7 +8063,6 @@ PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) { #endif /* Install the php:// stream */ ph7_vm_config(pVm, PH7_VM_CONFIG_IO_STREAM, &sPHP_Stream); -#endif /* PH7_DISABLE_DISK_IO */ if(pFileStream) { /* Install the file:// stream */ ph7_vm_config(pVm, PH7_VM_CONFIG_IO_STREAM, pFileStream); @@ -8088,7 +8073,6 @@ PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) { * Export the STDIN handle. */ PH7_PRIVATE void *PH7_ExportStdin(ph7_vm *pVm) { -#ifndef PH7_DISABLE_DISK_IO if(pVm->pStdin == 0) { io_private *pIn; /* Allocate an IO private instance */ @@ -8106,15 +8090,11 @@ PH7_PRIVATE void *PH7_ExportStdin(ph7_vm *pVm) { /* NULL or STDIN */ return pVm->pStdin; } -#else - return 0; -#endif } /* * Export the STDOUT handle. */ PH7_PRIVATE void *PH7_ExportStdout(ph7_vm *pVm) { -#ifndef PH7_DISABLE_DISK_IO if(pVm->pStdout == 0) { io_private *pOut; /* Allocate an IO private instance */ @@ -8132,15 +8112,11 @@ PH7_PRIVATE void *PH7_ExportStdout(ph7_vm *pVm) { /* NULL or STDOUT */ return pVm->pStdout; } -#else - return 0; -#endif } /* * Export the STDERR handle. */ PH7_PRIVATE void *PH7_ExportStderr(ph7_vm *pVm) { -#ifndef PH7_DISABLE_DISK_IO if(pVm->pStderr == 0) { io_private *pErr; /* Allocate an IO private instance */ @@ -8158,8 +8134,4 @@ PH7_PRIVATE void *PH7_ExportStderr(ph7_vm *pVm) { /* NULL or STDERR */ return pVm->pStderr; } -#else - return 0; -#endif - -} +} \ No newline at end of file diff --git a/include/ph7.h b/include/ph7.h index c674394..3fa8a6e 100644 --- a/include/ph7.h +++ b/include/ph7.h @@ -87,29 +87,6 @@ typedef struct ph7_value ph7_value; typedef struct ph7_vfs ph7_vfs; typedef struct ph7_vm ph7_vm; typedef struct ph7 ph7; -/* - * ------------------------------ - * Compile time directives - * ------------------------------ - * For most purposes, PH7 can be built just fine using the default compilation options. - * However, if required, the compile-time options documented below can be used to omit - * PH7 features (resulting in a smaller compiled library size) or to change the default - * values of some parameters. - * Every effort has been made to ensure that the various combinations of compilation - * options work harmoniously and produce a working library. - * - * Options To Omit/Enable Features: - * The following options can be used to reduce the size of the compiled library - * by omitting optional features. This is probably only useful in embedded systems - * where space is especially tight, as even with all features included the PH7 library - * is relatively small. Don't forget to tell your compiler to optimize for binary - * size! (the -Os option if using GCC). - * Telling your compiler to optimize for size usually has a much larger impact - * on library footprint than employing any of these compile-time options. - * PH7_DISABLE_DISK_IO - * If this directive is enabled, built-in Virtual File System functions such as - * chdir(), mkdir(), chroot(), unlink(), delete(), etc. are omitted from the build. - */ /* Symisc public definitions */ #if !defined(SYMISC_STANDARD_DEFS) #define SYMISC_STANDARD_DEFS