const std = @import("std"); pub const c = @import("c.zig").c; const properties_api = @import("properties.zig"); const iostream_api = @import("iostream.zig"); pub const PropertiesID = properties_api.PropertiesID; pub const IOStream = iostream_api.IOStream; pub const Process = opaque { pub inline fn getProcessProperties(process: *Process) PropertiesID { return c.SDL_GetProcessProperties(@ptrCast(process)); } pub inline fn readProcess(process: *Process, datasize: *usize, exitcode: *c_int) ?*anyopaque { return c.SDL_ReadProcess(@ptrCast(process), @ptrCast(datasize), @ptrCast(exitcode)); } pub inline fn getProcessInput(process: *Process) ?*IOStream { return @ptrCast(c.SDL_GetProcessInput(@ptrCast(process))); } pub inline fn getProcessOutput(process: *Process) ?*IOStream { return @ptrCast(c.SDL_GetProcessOutput(@ptrCast(process))); } pub inline fn killProcess(process: *Process, force: bool) bool { return @bitCast(c.SDL_KillProcess(@ptrCast(process), @bitCast(force))); } pub inline fn waitProcess(process: *Process, block: bool, exitcode: *c_int) bool { return @bitCast(c.SDL_WaitProcess(@ptrCast(process), @bitCast(block), @ptrCast(exitcode))); } pub inline fn destroyProcess(process: *Process) void { return c.SDL_DestroyProcess(@ptrCast(process)); } }; pub inline fn createProcess(args: [*c]const [*c]const u8, pipe_stdio: bool) ?*Process { return @ptrCast(c.SDL_CreateProcess(args, @bitCast(pipe_stdio))); } pub const ProcessIO = enum(c_int) { processStdioInherited, //The I/O stream is inherited from the application. processStdioNull, //The I/O stream is ignored. processStdioApp, //The I/O stream is connected to a new SDL_IOStream that the application can read or write processStdioRedirect, //The I/O stream is redirected to an existing SDL_IOStream. }; pub inline fn createProcessWithProperties(props: PropertiesID) ?*Process { return @ptrCast(c.SDL_CreateProcessWithProperties(props)); }