Skip to content

Add SDL_Process subsystem #10618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/misc/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/process/*.c) \
$(wildcard $(LOCAL_PATH)/src/process/dummy/*.c) \
$(wildcard $(LOCAL_PATH)/src/filesystem/*.c) \
$(wildcard $(LOCAL_PATH)/src/filesystem/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/filesystem/posix/*.c) \
Expand Down
53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2860,6 +2860,55 @@ if (SDL_DIALOG)
endif()
endif()

sdl_sources("${SDL3_SOURCE_DIR}/src/process/SDL_process.c")
if(WINDOWS)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/process/windows/*.c")
set(SDL_PROCESS_WINDOWS 1)
set(HAVE_SDL_PROCESS TRUE)
else()
check_c_source_compiles("
#include <spawn.h>
#include <unistd.h>

int main(void)
{
int pipes[2];
int pid;

const char * args[] = {
\"/bin/false\",
NULL
};

const char * env[] = { NULL };

pipe(pipes);

posix_spawnattr_t attr;
posix_spawn_file_actions_t fa;

posix_spawnattr_init(&attr);
posix_spawn_file_actions_init(&fa);

posix_spawn_file_actions_addclose(&fa, pipes[0]);
posix_spawn_file_actions_adddup2(&fa, pipes[1], STDOUT_FILENO);

posix_spawn(&pid, args[0], &fa, &attr, (char * const *) args, (char * const *) env);
posix_spawnp(&pid, args[0], &fa, &attr, (char * const *) args, (char * const *) env);

posix_spawn_file_actions_destroy(&fa);
posix_spawnattr_destroy(&attr);

return 0;
}
" HAVE_POSIX_SPAWN)
if(HAVE_POSIX_SPAWN)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/process/posix/*.c")
set(SDL_PROCESS_POSIX 1)
set(HAVE_SDL_PROCESS TRUE)
endif()
endif()

# Platform-independent options

if(SDL_VIDEO)
Expand Down Expand Up @@ -2949,6 +2998,10 @@ if(NOT HAVE_SDL_DIALOG)
set(SDL_DIALOG_DUMMY 1)
sdl_sources(${SDL3_SOURCE_DIR}/src/dialog/dummy/SDL_dummydialog.c)
endif()
if(NOT HAVE_SDL_PROCESS)
set(SDL_PROCESS_DUMMY 1)
sdl_glob_sources(${SDL3_SOURCE_DIR}/src/process/dummy/*.c)
endif()
if(NOT HAVE_CAMERA)
set(SDL_CAMERA_DRIVER_DUMMY 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/camera/dummy/*.c")
Expand Down
5 changes: 5 additions & 0 deletions VisualC-GDK/SDL/SDL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@
<ClInclude Include="..\..\include\SDL3\SDL_platform.h" />
<ClInclude Include="..\..\include\SDL3\SDL_platform_defines.h" />
<ClInclude Include="..\..\include\SDL3\SDL_power.h" />
<ClInclude Include="..\..\include\SDL3\SDL_process.h" />
<ClInclude Include="..\..\include\SDL3\SDL_properties.h" />
<ClInclude Include="..\..\include\SDL3\SDL_rect.h" />
<ClInclude Include="..\..\include\SDL3\SDL_render.h" />
<ClInclude Include="..\..\include\SDL3\SDL_revision.h" />
Expand Down Expand Up @@ -754,6 +756,9 @@
<ClCompile Include="..\..\src\misc\windows\SDL_sysurl.c" />
<ClCompile Include="..\..\src\power\SDL_power.c" />
<ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
<ClCompile Include="..\..\src\process\SDL_process.c" />
<ClCompile Include="..\..\src\process\dummy\SDL_dummyprocess.c" />
<ClCompile Include="..\..\src\process\windows\SDL_windowsprocess.c" />
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\direct3d12\SDL_render_d3d12.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Xbox.Scarlett.x64'">CompileAsCpp</CompileAs>
Expand Down
5 changes: 5 additions & 0 deletions VisualC-GDK/SDL/SDL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
<ClCompile Include="..\..\src\misc\SDL_url.c" />
<ClCompile Include="..\..\src\misc\windows\SDL_sysurl.c" />
<ClCompile Include="..\..\src\power\SDL_power.c" />
<ClCompile Include="..\..\src\process\SDL_process.c" />
<ClCompile Include="..\..\src\process\dummy\SDL_dummyprocess.c" />
<ClCompile Include="..\..\src\process\windows\SDL_windowsprocess.c" />
<ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\direct3d12\SDL_render_d3d12.c" />
Expand Down Expand Up @@ -283,6 +286,8 @@
<ClInclude Include="..\..\include\SDL3\SDL_platform.h" />
<ClInclude Include="..\..\include\SDL3\SDL_platform_defines.h" />
<ClInclude Include="..\..\include\SDL3\SDL_power.h" />
<ClInclude Include="..\..\include\SDL3\SDL_process.h" />
<ClInclude Include="..\..\include\SDL3\SDL_properties.h" />
<ClInclude Include="..\..\include\SDL3\SDL_rect.h" />
<ClInclude Include="..\..\include\SDL3\SDL_render.h" />
<ClInclude Include="..\..\include\SDL3\SDL_revision.h" />
Expand Down
3 changes: 3 additions & 0 deletions VisualC/SDL/SDL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
<ClInclude Include="..\..\include\SDL3\SDL_platform.h" />
<ClInclude Include="..\..\include\SDL3\SDL_platform_defines.h" />
<ClInclude Include="..\..\include\SDL3\SDL_power.h" />
<ClInclude Include="..\..\include\SDL3\SDL_process.h" />
<ClInclude Include="..\..\include\SDL3\SDL_properties.h" />
<ClInclude Include="..\..\include\SDL3\SDL_rect.h" />
<ClInclude Include="..\..\include\SDL3\SDL_render.h" />
Expand Down Expand Up @@ -615,6 +616,8 @@
<ClCompile Include="..\..\src\misc\windows\SDL_sysurl.c" />
<ClCompile Include="..\..\src\power\SDL_power.c" />
<ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
<ClCompile Include="..\..\src\process\SDL_process.c" />
<ClCompile Include="..\..\src\process\windows\SDL_windowsprocess.c" />
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\direct3d12\SDL_render_d3d12.c" />
<ClCompile Include="..\..\src\render\direct3d12\SDL_shaders_d3d12.c" />
Expand Down
11 changes: 10 additions & 1 deletion VisualC/SDL/SDL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@
<ClInclude Include="..\..\include\SDL3\SDL_power.h">
<Filter>API Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL3\SDL_process.h">
<Filter>API Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL3\SDL_properties.h">
<Filter>API Headers</Filter>
</ClInclude>
Expand Down Expand Up @@ -1538,10 +1541,16 @@
<ClCompile Include="..\..\src\power\SDL_power.c">
<Filter>power</Filter>
</ClCompile>
<ClCompile Include="..\..\src\SDL_log.c" />
<ClCompile Include="..\..\src\power\windows\SDL_syspower.c">
<Filter>power\windows</Filter>
</ClCompile>
<ClCompile Include="..\..\src\process\SDL_process.c">
<Filter>process</Filter>
</ClCompile>
<ClCompile Include="..\..\src\process\windows\SDL_windowsprocess.c">
<Filter>process\windows</Filter>
</ClCompile>
<ClCompile Include="..\..\src\SDL_log.c" />
<ClCompile Include="..\..\src\render\direct3d12\SDL_render_d3d12.c">
<Filter>render\direct3d12</Filter>
</ClCompile>
Expand Down
44 changes: 44 additions & 0 deletions Xcode/SDL/SDL.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@
F3B38CD7296E2E52005DA6D3 /* SDL_init.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B38CCC296E2E52005DA6D3 /* SDL_init.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3B38CDB296E2E52005DA6D3 /* SDL_oldnames.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B38CCD296E2E52005DA6D3 /* SDL_oldnames.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3B38CDF296E2E52005DA6D3 /* SDL_intrin.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B38CCE296E2E52005DA6D3 /* SDL_intrin.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3B439482C93595900792030 /* SDL_process.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B439472C93595900792030 /* SDL_process.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3B439512C935C2400792030 /* SDL_dummyprocess.c in Sources */ = {isa = PBXBuildFile; fileRef = F3B439502C935C2400792030 /* SDL_dummyprocess.c */; };
F3B439532C935C2C00792030 /* SDL_posixprocess.c in Sources */ = {isa = PBXBuildFile; fileRef = F3B439522C935C2C00792030 /* SDL_posixprocess.c */; };
F3B439562C937DAB00792030 /* SDL_process.c in Sources */ = {isa = PBXBuildFile; fileRef = F3B439542C937DAB00792030 /* SDL_process.c */; };
F3B439572C937DAB00792030 /* SDL_sysprocess.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B439552C937DAB00792030 /* SDL_sysprocess.h */; };
F3C2CB222C5DDDB2004D7998 /* SDL_categories_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F3C2CB202C5DDDB2004D7998 /* SDL_categories_c.h */; };
F3C2CB232C5DDDB2004D7998 /* SDL_categories.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C2CB212C5DDDB2004D7998 /* SDL_categories.c */; };
F3D60A8328C16A1900788A3A /* SDL_hidapi_wii.c in Sources */ = {isa = PBXBuildFile; fileRef = F3D60A8228C16A1800788A3A /* SDL_hidapi_wii.c */; };
Expand Down Expand Up @@ -1023,6 +1028,11 @@
F3B38CCC296E2E52005DA6D3 /* SDL_init.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_init.h; path = SDL3/SDL_init.h; sourceTree = "<group>"; };
F3B38CCD296E2E52005DA6D3 /* SDL_oldnames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_oldnames.h; path = SDL3/SDL_oldnames.h; sourceTree = "<group>"; };
F3B38CCE296E2E52005DA6D3 /* SDL_intrin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_intrin.h; path = SDL3/SDL_intrin.h; sourceTree = "<group>"; };
F3B439472C93595900792030 /* SDL_process.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_process.h; path = SDL3/SDL_process.h; sourceTree = "<group>"; };
F3B439502C935C2400792030 /* SDL_dummyprocess.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_dummyprocess.c; sourceTree = "<group>"; };
F3B439522C935C2C00792030 /* SDL_posixprocess.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_posixprocess.c; sourceTree = "<group>"; };
F3B439542C937DAB00792030 /* SDL_process.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_process.c; sourceTree = "<group>"; };
F3B439552C937DAB00792030 /* SDL_sysprocess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysprocess.h; sourceTree = "<group>"; };
F3C2CB202C5DDDB2004D7998 /* SDL_categories_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_categories_c.h; sourceTree = "<group>"; };
F3C2CB212C5DDDB2004D7998 /* SDL_categories.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_categories.c; sourceTree = "<group>"; };
F3D60A8228C16A1800788A3A /* SDL_hidapi_wii.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_wii.c; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1265,6 +1275,7 @@
F3B38CCB296E2E52005DA6D3 /* SDL_platform_defines.h */,
F3F7D8AB2933074900816151 /* SDL_platform.h */,
F3F7D8DB2933074D00816151 /* SDL_power.h */,
F3B439472C93595900792030 /* SDL_process.h */,
F3E5A6EC2AD5E10800293D83 /* SDL_properties.h */,
F3F7D8E22933074D00816151 /* SDL_rect.h */,
F3F7D8DE2933074D00816151 /* SDL_render.h */,
Expand Down Expand Up @@ -1338,6 +1349,7 @@
000082EF09C89B62BD840000 /* main */,
5616CA47252BB278005D5928 /* misc */,
A7D8A7DF23E2513F00DCD162 /* power */,
F3B439492C93597500792030 /* process */,
A7D8A8DA23E2514000DCD162 /* render */,
A7D8A57623E2513D00DCD162 /* sensor */,
A7D8A8D223E2514000DCD162 /* stdlib */,
Expand Down Expand Up @@ -2368,6 +2380,33 @@
path = ios;
sourceTree = "<group>";
};
F3B439492C93597500792030 /* process */ = {
isa = PBXGroup;
children = (
F3B4394A2C93599900792030 /* dummy */,
F3B4394B2C9359A500792030 /* posix */,
F3B439542C937DAB00792030 /* SDL_process.c */,
F3B439552C937DAB00792030 /* SDL_sysprocess.h */,
);
path = process;
sourceTree = "<group>";
};
F3B4394A2C93599900792030 /* dummy */ = {
isa = PBXGroup;
children = (
F3B439502C935C2400792030 /* SDL_dummyprocess.c */,
);
path = dummy;
sourceTree = "<group>";
};
F3B4394B2C9359A500792030 /* posix */ = {
isa = PBXGroup;
children = (
F3B439522C935C2C00792030 /* SDL_posixprocess.c */,
);
path = posix;
sourceTree = "<group>";
};
F59C70FC00D5CB5801000001 /* pkg-support */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2442,6 +2481,7 @@
F3F7D9B92933074E00816151 /* SDL_cpuinfo.h in Headers */,
A7D8B98023E2514400DCD162 /* SDL_d3dmath.h in Headers */,
A7D8B8A223E2514400DCD162 /* SDL_diskaudio.h in Headers */,
F3B439482C93595900792030 /* SDL_process.h in Headers */,
A7D8BB3F23E2514500DCD162 /* SDL_displayevents_c.h in Headers */,
A7D8BA1923E2514400DCD162 /* SDL_draw.h in Headers */,
F3C2CB222C5DDDB2004D7998 /* SDL_categories_c.h in Headers */,
Expand Down Expand Up @@ -2572,6 +2612,7 @@
A7D8AC3F23E2514100DCD162 /* SDL_sysvideo.h in Headers */,
F3F7D9792933074E00816151 /* SDL_thread.h in Headers */,
A7D8B3EC23E2514300DCD162 /* SDL_thread_c.h in Headers */,
F3B439572C937DAB00792030 /* SDL_sysprocess.h in Headers */,
E4F257912C81903800FCEAFC /* Metal_Blit.h in Headers */,
F3F7D90D2933074E00816151 /* SDL_timer.h in Headers */,
A7D8AB3123E2514100DCD162 /* SDL_timer_c.h in Headers */,
Expand Down Expand Up @@ -2800,6 +2841,7 @@
A7D8B9F523E2514400DCD162 /* SDL_rotate.c in Sources */,
A7D8BBE323E2574800DCD162 /* SDL_uikitvideo.m in Sources */,
5616CA4E252BB2A6005D5928 /* SDL_sysurl.m in Sources */,
F3B439562C937DAB00792030 /* SDL_process.c in Sources */,
A7D8A97523E2514000DCD162 /* SDL_coremotionsensor.m in Sources */,
F382071D284F362F004DD584 /* SDL_guid.c in Sources */,
A7D8BB8D23E2514500DCD162 /* SDL_touch.c in Sources */,
Expand Down Expand Up @@ -2862,6 +2904,7 @@
A7D8BA8B23E2514400DCD162 /* s_sin.c in Sources */,
F3F528CE2C29E1C300E6CC26 /* s_modf.c in Sources */,
A7D8BBEB23E2574800DCD162 /* SDL_uikitwindow.m in Sources */,
F3B439532C935C2C00792030 /* SDL_posixprocess.c in Sources */,
F395BF6525633B2400942BFF /* SDL_crc32.c in Sources */,
A7D8B5E723E2514300DCD162 /* SDL_power.c in Sources */,
A7D8AED623E2514100DCD162 /* SDL_cocoakeyboard.m in Sources */,
Expand Down Expand Up @@ -2905,6 +2948,7 @@
A7D8BADF23E2514500DCD162 /* e_fmod.c in Sources */,
A7D8B5CF23E2514300DCD162 /* SDL_syspower.m in Sources */,
A7D8BAEB23E2514500DCD162 /* e_log10.c in Sources */,
F3B439512C935C2400792030 /* SDL_dummyprocess.c in Sources */,
A7D8B76423E2514300DCD162 /* SDL_mixer.c in Sources */,
A7D8BB5723E2514500DCD162 /* SDL_events.c in Sources */,
A7D8ADE623E2514100DCD162 /* SDL_blit_0.c in Sources */,
Expand Down
1 change: 1 addition & 0 deletions include/SDL3/SDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include <SDL3/SDL_pixels.h>
#include <SDL3/SDL_platform.h>
#include <SDL3/SDL_power.h>
#include <SDL3/SDL_process.h>
#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_rect.h>
#include <SDL3/SDL_render.h>
Expand Down
41 changes: 36 additions & 5 deletions include/SDL3/SDL_iostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ typedef struct SDL_IOStreamInterface
*/
size_t (SDLCALL *write)(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status);

/**
* If the stream is buffering, make sure the data is written out.
*
* On failure, you should set `*status` to a value from the
* SDL_IOStatus enum. You do not have to explicitly set this on
* a successful flush.
*
* \return SDL_TRUE if successful or SDL_FALSE on write error when flushing data.
*/
SDL_bool (SDLCALL *flush)(void *userdata, SDL_IOStatus *status);

/**
* Close and free any allocated resources.
*
Expand All @@ -152,8 +163,8 @@ typedef struct SDL_IOStreamInterface
* the code using this interface should be updated to handle the old version.
*/
SDL_COMPILE_TIME_ASSERT(SDL_IOStreamInterface_SIZE,
(sizeof(void *) == 4 && sizeof(SDL_IOStreamInterface) == 24) ||
(sizeof(void *) == 8 && sizeof(SDL_IOStreamInterface) == 48));
(sizeof(void *) == 4 && sizeof(SDL_IOStreamInterface) == 28) ||
(sizeof(void *) == 8 && sizeof(SDL_IOStreamInterface) == 56));

/**
* The read/write operation structure.
Expand Down Expand Up @@ -233,6 +244,7 @@ typedef struct SDL_IOStream SDL_IOStream;
* than your app, trying to use this pointer will almost certainly result in
* a crash! This is mostly a problem on Windows; make sure you build SDL and
* your app with the same compiler and settings to avoid it.
* - `SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER`: a file descriptor that this SDL_IOStream is using to access the filesystem.
* - `SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER`: a pointer, that can be cast
* to an Android NDK `AAsset *`, that this SDL_IOStream is using to access
* the filesystem. If SDL used some other method to access the filesystem,
Expand All @@ -247,6 +259,7 @@ typedef struct SDL_IOStream SDL_IOStream;
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CloseIO
* \sa SDL_FlushIO
* \sa SDL_ReadIO
* \sa SDL_SeekIO
* \sa SDL_TellIO
Expand All @@ -256,6 +269,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, cons

#define SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER "SDL.iostream.windows.handle"
#define SDL_PROP_IOSTREAM_STDIO_FILE_POINTER "SDL.iostream.stdio.file"
#define SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER "SDL.iostream.file_descriptor"
#define SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER "SDL.iostream.android.aasset"

/**
Expand All @@ -282,6 +296,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, cons
*
* \sa SDL_IOFromConstMem
* \sa SDL_CloseIO
* \sa SDL_FlushIO
* \sa SDL_ReadIO
* \sa SDL_SeekIO
* \sa SDL_TellIO
Expand Down Expand Up @@ -465,8 +480,7 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context);
* negative.
* \param whence any of `SDL_IO_SEEK_SET`, `SDL_IO_SEEK_CUR`,
* `SDL_IO_SEEK_END`.
* \returns the final offset in the data stream after the seek or a negative
* error code on failure; call SDL_GetError() for more information.
* \returns the final offset in the data stream after the seek or -1 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
Expand Down Expand Up @@ -539,6 +553,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_ReadIO(SDL_IOStream *context, void *ptr,
* \sa SDL_IOprintf
* \sa SDL_ReadIO
* \sa SDL_SeekIO
* \sa SDL_FlushIO
* \sa SDL_GetIOStatus
*/
extern SDL_DECLSPEC size_t SDLCALL SDL_WriteIO(SDL_IOStream *context, const void *ptr, size_t size);
Expand Down Expand Up @@ -580,6 +595,22 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_IOprintf(SDL_IOStream *context, SDL_PRINT
*/
extern SDL_DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);

/**
* Flush any buffered data in the stream.
*
* This function makes sure that any buffered data is written to the stream. Normally this isn't necessary but if the stream is a pipe or socket it guarantees that any pending data is sent.
*
* \param context SDL_IOStream structure to flush.
* \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
* for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_OpenIO
* \sa SDL_WriteIO
*/
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_FlushIO(SDL_IOStream *context);

/**
* Load all the data from an SDL data stream.
*
Expand All @@ -590,7 +621,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRIN
* The data should be freed with SDL_free().
*
* \param src the SDL_IOStream to read all available data from.
* \param datasize if not NULL, will store the number of bytes read.
* \param datasize a pointer filled in with the number of bytes read, may be NULL.
* \param closeio if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
* even in the case of an error.
* \returns the data or NULL on failure; call SDL_GetError() for more
Expand Down
Loading
Loading