This commit is contained in:
parent
ea4daa9335
commit
00e1c842d5
@ -272,7 +272,6 @@ static int PH7_builtin_empty(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
|||||||
ph7_result_bool(pCtx, res);
|
ph7_result_bool(pCtx, res);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
/*
|
/*
|
||||||
* float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] )
|
* float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] )
|
||||||
* Exponential expression.
|
* Exponential expression.
|
||||||
@ -7480,7 +7479,6 @@ static int PH7_builtin_urldecode(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
|||||||
SyUriDecode(zIn, (sxu32)nLen, Consumer, pCtx, TRUE);
|
SyUriDecode(zIn, (sxu32)nLen, Consumer, pCtx, TRUE);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
/* Table of the built-in functions */
|
/* Table of the built-in functions */
|
||||||
static const ph7_builtin_func aBuiltInFunc[] = {
|
static const ph7_builtin_func aBuiltInFunc[] = {
|
||||||
/* Variable handling functions */
|
/* Variable handling functions */
|
||||||
@ -7498,7 +7496,6 @@ static const ph7_builtin_func aBuiltInFunc[] = {
|
|||||||
{ "intval", PH7_builtin_intval },
|
{ "intval", PH7_builtin_intval },
|
||||||
{ "stringval", PH7_builtin_strval },
|
{ "stringval", PH7_builtin_strval },
|
||||||
{ "empty", PH7_builtin_empty },
|
{ "empty", PH7_builtin_empty },
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
{ "round", PH7_builtin_round },
|
{ "round", PH7_builtin_round },
|
||||||
{ "dechex", PH7_builtin_dechex },
|
{ "dechex", PH7_builtin_dechex },
|
||||||
{ "decoct", PH7_builtin_decoct },
|
{ "decoct", PH7_builtin_decoct },
|
||||||
@ -7593,7 +7590,6 @@ static const ph7_builtin_func aBuiltInFunc[] = {
|
|||||||
{ "base64_decode", PH7_builtin_base64_decode },
|
{ "base64_decode", PH7_builtin_base64_decode },
|
||||||
{ "urlencode", PH7_builtin_urlencode },
|
{ "urlencode", PH7_builtin_urlencode },
|
||||||
{ "urldecode", PH7_builtin_urldecode },
|
{ "urldecode", PH7_builtin_urldecode },
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
* Register the built-in functions defined above,the array functions
|
* Register the built-in functions defined above,the array functions
|
||||||
|
@ -1568,7 +1568,6 @@ PH7_PRIVATE void PH7_HashmapExtractNodeKey(ph7_hashmap_node *pNode, ph7_value *p
|
|||||||
MemObjSetType(pKey, MEMOBJ_STRING);
|
MemObjSetType(pKey, MEMOBJ_STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
/*
|
/*
|
||||||
* Store the address of nodes value in the given container.
|
* Store the address of nodes value in the given container.
|
||||||
* Refer to the [vfprintf(),vprintf(),vsprintf()] implementations
|
* Refer to the [vfprintf(),vprintf(),vsprintf()] implementations
|
||||||
@ -1592,7 +1591,6 @@ PH7_PRIVATE int PH7_HashmapValuesToSet(ph7_hashmap *pMap, SySet *pOut) {
|
|||||||
/* Total inserted entries */
|
/* Total inserted entries */
|
||||||
return (int)SySetUsed(pOut);
|
return (int)SySetUsed(pOut);
|
||||||
}
|
}
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
/*
|
/*
|
||||||
* Merge sort.
|
* Merge sort.
|
||||||
* The merge sort implementation is based on the one found in the SQLite3 source tree.
|
* The merge sort implementation is based on the one found in the SQLite3 source tree.
|
||||||
|
40
engine/vfs.c
40
engine/vfs.c
@ -51,10 +51,6 @@ PH7_PRIVATE const char *PH7_ExtractDirName(const char *zPath, int nByte, int *pL
|
|||||||
}
|
}
|
||||||
return zPath;
|
return zPath;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Omit the vfs layer implementation from the built if the PH7_DISABLE_BUILTIN_FUNC directive is defined.
|
|
||||||
*/
|
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
/*
|
/*
|
||||||
* bool chdir(string $directory)
|
* bool chdir(string $directory)
|
||||||
* Change the current directory.
|
* Change the current directory.
|
||||||
@ -5685,7 +5681,6 @@ static int PH7_builtin_zip_entry_compressionmethod(ph7_context *pCtx, int nArg,
|
|||||||
}
|
}
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
#endif /* #ifndef PH7_DISABLE_BUILTIN_FUNC*/
|
|
||||||
/* NULL VFS [i.e: a no-op VFS]*/
|
/* NULL VFS [i.e: a no-op VFS]*/
|
||||||
static const ph7_vfs null_vfs = {
|
static const ph7_vfs null_vfs = {
|
||||||
"NullVFS",
|
"NullVFS",
|
||||||
@ -5734,7 +5729,6 @@ static const ph7_vfs null_vfs = {
|
|||||||
0, /* int (*xGid)(void) */
|
0, /* int (*xGid)(void) */
|
||||||
0 /* void (*xUsername)(ph7_context *) */
|
0 /* void (*xUsername)(ph7_context *) */
|
||||||
};
|
};
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#ifndef PH7_DISABLE_DISK_IO
|
#ifndef PH7_DISABLE_DISK_IO
|
||||||
#ifdef __WINNT__
|
#ifdef __WINNT__
|
||||||
/*
|
/*
|
||||||
@ -7764,19 +7758,14 @@ static const ph7_io_stream sUnixFileStream = {
|
|||||||
};
|
};
|
||||||
#endif /* __WINNT__/__UNIXES__ */
|
#endif /* __WINNT__/__UNIXES__ */
|
||||||
#endif /* PH7_DISABLE_DISK_IO */
|
#endif /* PH7_DISABLE_DISK_IO */
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
/*
|
/*
|
||||||
* Export the builtin vfs.
|
* Export the builtin vfs.
|
||||||
* Return a pointer to the builtin vfs if available.
|
* Return a pointer to the builtin vfs if available.
|
||||||
* Otherwise return the null_vfs [i.e: a no-op vfs] instead.
|
* Otherwise return the null_vfs [i.e: a no-op vfs] instead.
|
||||||
* Note:
|
* Note:
|
||||||
* The built-in vfs is always available for Windows/UNIX systems.
|
* The built-in vfs is always available for Windows/UNIX systems.
|
||||||
* Note:
|
|
||||||
* If the engine is compiled with the PH7_DISABLE_DISK_IO/PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
* directives defined then this function return the null_vfs instead.
|
|
||||||
*/
|
*/
|
||||||
PH7_PRIVATE const ph7_vfs *PH7_ExportBuiltinVfs(void) {
|
PH7_PRIVATE const ph7_vfs *PH7_ExportBuiltinVfs(void) {
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#ifdef PH7_DISABLE_DISK_IO
|
#ifdef PH7_DISABLE_DISK_IO
|
||||||
return &null_vfs;
|
return &null_vfs;
|
||||||
#else
|
#else
|
||||||
@ -7788,11 +7777,7 @@ PH7_PRIVATE const ph7_vfs *PH7_ExportBuiltinVfs(void) {
|
|||||||
return &null_vfs;
|
return &null_vfs;
|
||||||
#endif /* __WINNT__/__UNIXES__ */
|
#endif /* __WINNT__/__UNIXES__ */
|
||||||
#endif /* PH7_DISABLE_DISK_IO */
|
#endif /* PH7_DISABLE_DISK_IO */
|
||||||
#else
|
|
||||||
return &null_vfs;
|
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
}
|
}
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#ifndef PH7_DISABLE_DISK_IO
|
#ifndef PH7_DISABLE_DISK_IO
|
||||||
/*
|
/*
|
||||||
* The following defines are mostly used by the UNIX built and have
|
* The following defines are mostly used by the UNIX built and have
|
||||||
@ -8051,17 +8036,11 @@ static int is_php_stream(const ph7_io_stream *pStream) {
|
|||||||
return 0;
|
return 0;
|
||||||
#endif /* PH7_DISABLE_DISK_IO */
|
#endif /* PH7_DISABLE_DISK_IO */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
/*
|
/*
|
||||||
* Export the IO routines defined above and the built-in IO streams
|
* Export the IO routines defined above and the built-in IO streams
|
||||||
* [i.e: file://,php://].
|
* [i.e: file://,php://].
|
||||||
* Note:
|
|
||||||
* If the engine is compiled with the PH7_DISABLE_BUILTIN_FUNC directive
|
|
||||||
* defined then this function is a no-op.
|
|
||||||
*/
|
*/
|
||||||
PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) {
|
PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) {
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
/* VFS functions */
|
/* VFS functions */
|
||||||
static const ph7_builtin_func aVfsFunc[] = {
|
static const ph7_builtin_func aVfsFunc[] = {
|
||||||
{"chdir", PH7_vfs_chdir },
|
{"chdir", PH7_vfs_chdir },
|
||||||
@ -8188,16 +8167,12 @@ PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) {
|
|||||||
/* Install the file:// stream */
|
/* Install the file:// stream */
|
||||||
ph7_vm_config(pVm, PH7_VM_CONFIG_IO_STREAM, pFileStream);
|
ph7_vm_config(pVm, PH7_VM_CONFIG_IO_STREAM, pFileStream);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
SXUNUSED(pVm); /* cc warning */
|
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Export the STDIN handle.
|
* Export the STDIN handle.
|
||||||
*/
|
*/
|
||||||
PH7_PRIVATE void *PH7_ExportStdin(ph7_vm *pVm) {
|
PH7_PRIVATE void *PH7_ExportStdin(ph7_vm *pVm) {
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#ifndef PH7_DISABLE_DISK_IO
|
#ifndef PH7_DISABLE_DISK_IO
|
||||||
if(pVm->pStdin == 0) {
|
if(pVm->pStdin == 0) {
|
||||||
io_private *pIn;
|
io_private *pIn;
|
||||||
@ -8219,16 +8194,11 @@ PH7_PRIVATE void *PH7_ExportStdin(ph7_vm *pVm) {
|
|||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
SXUNUSED(pVm); /* cc warning */
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Export the STDOUT handle.
|
* Export the STDOUT handle.
|
||||||
*/
|
*/
|
||||||
PH7_PRIVATE void *PH7_ExportStdout(ph7_vm *pVm) {
|
PH7_PRIVATE void *PH7_ExportStdout(ph7_vm *pVm) {
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#ifndef PH7_DISABLE_DISK_IO
|
#ifndef PH7_DISABLE_DISK_IO
|
||||||
if(pVm->pStdout == 0) {
|
if(pVm->pStdout == 0) {
|
||||||
io_private *pOut;
|
io_private *pOut;
|
||||||
@ -8250,16 +8220,11 @@ PH7_PRIVATE void *PH7_ExportStdout(ph7_vm *pVm) {
|
|||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
SXUNUSED(pVm); /* cc warning */
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Export the STDERR handle.
|
* Export the STDERR handle.
|
||||||
*/
|
*/
|
||||||
PH7_PRIVATE void *PH7_ExportStderr(ph7_vm *pVm) {
|
PH7_PRIVATE void *PH7_ExportStderr(ph7_vm *pVm) {
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#ifndef PH7_DISABLE_DISK_IO
|
#ifndef PH7_DISABLE_DISK_IO
|
||||||
if(pVm->pStderr == 0) {
|
if(pVm->pStderr == 0) {
|
||||||
io_private *pErr;
|
io_private *pErr;
|
||||||
@ -8281,8 +8246,5 @@ PH7_PRIVATE void *PH7_ExportStderr(ph7_vm *pVm) {
|
|||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
SXUNUSED(pVm); /* cc warning */
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
15
engine/vm.c
15
engine/vm.c
@ -8131,7 +8131,6 @@ static int vm_builtin_random_bytes(ph7_context *pCtx, int nArg, ph7_value **apAr
|
|||||||
ph7_result_string(pCtx, (char *)zBuf, iLen);
|
ph7_result_string(pCtx, (char *)zBuf, iLen);
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#if !defined(PH7_DISABLE_HASH_FUNC)
|
#if !defined(PH7_DISABLE_HASH_FUNC)
|
||||||
/* Unique ID private data */
|
/* Unique ID private data */
|
||||||
struct unique_id_data {
|
struct unique_id_data {
|
||||||
@ -8219,7 +8218,6 @@ static int vm_builtin_uniqid(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
|||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
#endif /* PH7_DISABLE_HASH_FUNC */
|
#endif /* PH7_DISABLE_HASH_FUNC */
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
/*
|
/*
|
||||||
* Section:
|
* Section:
|
||||||
* Language construct implementation as foreign functions.
|
* Language construct implementation as foreign functions.
|
||||||
@ -10090,8 +10088,6 @@ PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, s
|
|||||||
* Note that the PHP script to evaluate can be a local or remote file.In
|
* Note that the PHP script to evaluate can be a local or remote file.In
|
||||||
* either cases the [PH7_StreamReadWholeFile()] function handle all the underlying
|
* either cases the [PH7_StreamReadWholeFile()] function handle all the underlying
|
||||||
* operations.
|
* operations.
|
||||||
* If the [PH7_DISABLE_BUILTIN_FUNC] compile-time directive is defined,then
|
|
||||||
* this function is a no-op.
|
|
||||||
* Refer to the implementation of the include(),include_once() language
|
* Refer to the implementation of the include(),include_once() language
|
||||||
* constructs for more information.
|
* constructs for more information.
|
||||||
*/
|
*/
|
||||||
@ -10101,7 +10097,6 @@ static sxi32 VmExecIncludedFile(
|
|||||||
int IncludeOnce /* TRUE if called from include_once() or require_once() */
|
int IncludeOnce /* TRUE if called from include_once() or require_once() */
|
||||||
) {
|
) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
const ph7_io_stream *pStream;
|
const ph7_io_stream *pStream;
|
||||||
SyBlob sContents;
|
SyBlob sContents;
|
||||||
void *pHandle;
|
void *pHandle;
|
||||||
@ -10141,12 +10136,6 @@ static sxi32 VmExecIncludedFile(
|
|||||||
PH7_StreamCloseHandle(pStream, pHandle);
|
PH7_StreamCloseHandle(pStream, pHandle);
|
||||||
/* Release the working buffer */
|
/* Release the working buffer */
|
||||||
SyBlobRelease(&sContents);
|
SyBlobRelease(&sContents);
|
||||||
#else
|
|
||||||
pCtx = 0; /* cc warning */
|
|
||||||
pPath = 0;
|
|
||||||
IncludeOnce = 0;
|
|
||||||
rc = SXERR_IO;
|
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -10910,11 +10899,9 @@ static const ph7_builtin_func aVmFunc[] = {
|
|||||||
{ "getrandmax", vm_builtin_getrandmax },
|
{ "getrandmax", vm_builtin_getrandmax },
|
||||||
{ "random_int", vm_builtin_random_int },
|
{ "random_int", vm_builtin_random_int },
|
||||||
{ "random_bytes", vm_builtin_random_bytes },
|
{ "random_bytes", vm_builtin_random_bytes },
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
#if !defined(PH7_DISABLE_HASH_FUNC)
|
#if !defined(PH7_DISABLE_HASH_FUNC)
|
||||||
{ "uniqid", vm_builtin_uniqid },
|
{ "uniqid", vm_builtin_uniqid },
|
||||||
#endif /* PH7_DISABLE_HASH_FUNC */
|
#endif /* PH7_DISABLE_HASH_FUNC */
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
/* Language constructs functions */
|
/* Language constructs functions */
|
||||||
{ "print", vm_builtin_print },
|
{ "print", vm_builtin_print },
|
||||||
{ "exit", vm_builtin_exit },
|
{ "exit", vm_builtin_exit },
|
||||||
@ -11336,7 +11323,6 @@ PH7_PRIVATE sxi32 PH7_VmRefObjRemove(
|
|||||||
}
|
}
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
#ifndef PH7_DISABLE_BUILTIN_FUNC
|
|
||||||
/*
|
/*
|
||||||
* Extract the IO stream device associated with a given scheme.
|
* Extract the IO stream device associated with a given scheme.
|
||||||
* Return a pointer to an instance of ph7_io_stream when the scheme
|
* Return a pointer to an instance of ph7_io_stream when the scheme
|
||||||
@ -11391,7 +11377,6 @@ PH7_PRIVATE const ph7_io_stream *PH7_VmGetStreamDevice(
|
|||||||
/* No such stream,return NULL */
|
/* No such stream,return NULL */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* PH7_DISABLE_BUILTIN_FUNC */
|
|
||||||
/*
|
/*
|
||||||
* Section:
|
* Section:
|
||||||
* HTTP/URI related routines.
|
* HTTP/URI related routines.
|
||||||
|
Loading…
Reference in New Issue
Block a user