diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index bf7e8f3e..45fd864c 100644 --- a/include/pocketpy/pocketpy.h +++ b/include/pocketpy/pocketpy.h @@ -8,6 +8,9 @@ #include "pocketpy/export.h" #include "pocketpy/vmath.h" +// for sandbox branch +#include "pocketpy/sandbox.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/pocketpy/sandbox.h b/include/pocketpy/sandbox.h new file mode 100644 index 00000000..dfaf87a2 --- /dev/null +++ b/include/pocketpy/sandbox.h @@ -0,0 +1,25 @@ +#pragma once + +#include "pocketpy/export.h" +#include + +// Fine-grained capabilities of the VM for sandboxing. +typedef struct py_Capabilities { + // FileIO + bool (*file_open)(const char* path, const char* mode); + // os + bool (*os_chdir)(const char* path); + bool (*os_getcwd)(); + bool (*os_system)(const char* command); + bool (*os_remove)(const char* path); + // stdc + bool stdc_write; // memset, write_bytes, ... + bool stdc_read; // memcmp, read_bytes, ... + bool stdc_malloc; // malloc + bool stdc_free; // free +} py_Capabilities; + +/// Setup the capabilities for the current VM. +PK_API py_Capabilities* py_capabilities(); +/// Raise a `KeyboardInterrupt` to interrupt the current execution. +PK_API void py_interrupt();