Rizin
unix-like reverse engineering framework and cli tools
rz_subprocess.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Florian Märkl <info@florianmaerkl.de>, Riccardo Schirone <sirmy15@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef RZ_UTIL_SUBPROCESS_H
5 #define RZ_UTIL_SUBPROCESS_H
6 
7 #include <rz_types.h>
8 #include <rz_util/rz_strbuf.h>
9 
22 
26 #define RZ_SUBPROCESS_STDIN (1 << 0)
27 #define RZ_SUBPROCESS_STDOUT (1 << 1)
28 #define RZ_SUBPROCESS_STDERR (1 << 2)
29 
35 
39 typedef struct rz_process_output_t {
41  ut8 *out;
43  int out_len;
45  ut8 *err;
47  int err_len;
49  int ret;
51  bool timeout;
53 
57 typedef struct rz_subprocess_opt_t {
59  const char *file;
61  const char **args;
63  size_t args_size;
65  const char **envvars;
67  const char **envvals;
69  size_t env_size;
77 
78 typedef struct rz_subprocess_t RzSubprocess;
79 
80 RZ_API bool rz_subprocess_init(void);
81 RZ_API void rz_subprocess_fini(void);
83  const char *file, const char *args[], size_t args_size,
84  const char *envvars[], const char *envvals[], size_t env_size);
97 
98 #endif
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define RZ_API
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
static int buf_size
Definition: debug_qnx.c:35
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
int args
Definition: mipsasm.c:18
int n
Definition: mipsasm.c:19
RZ_API RzSubprocessOutput * rz_subprocess_drain(RzSubprocess *proc)
Definition: subprocess.c:1260
rz_process_wait_reason_t
Definition: rz_subprocess.h:30
@ RZ_SUBPROCESS_TIMEDOUT
Definition: rz_subprocess.h:32
@ RZ_SUBPROCESS_BYTESREAD
Definition: rz_subprocess.h:33
@ RZ_SUBPROCESS_DEAD
Definition: rz_subprocess.h:31
RZ_API RzSubprocessWaitReason rz_subprocess_wait(RzSubprocess *proc, ut64 timeout_ms)
Definition: subprocess.c:1185
struct rz_subprocess_opt_t RzSubprocessOpt
RZ_API void rz_subprocess_free(RzSubprocess *proc)
Definition: subprocess.c:1273
RZ_API ut8 * rz_subprocess_out(RzSubprocess *proc, int *length)
Definition: subprocess.c:1301
enum rz_process_wait_reason_t RzSubprocessWaitReason
RZ_API RzSubprocess * rz_subprocess_start_opt(RzSubprocessOpt *opt)
Definition: subprocess.c:893
RZ_API void rz_subprocess_fini(void)
Definition: subprocess.c:814
RZ_API RzSubprocess * rz_subprocess_start(const char *file, const char *args[], size_t args_size, const char *envvars[], const char *envvals[], size_t env_size)
Definition: subprocess.c:1345
RZ_API void rz_subprocess_output_free(RzSubprocessOutput *out)
Definition: subprocess.c:1323
struct rz_process_output_t RzSubprocessOutput
RZ_API ut8 * rz_subprocess_err(RzSubprocess *proc, int *length)
Definition: subprocess.c:1312
enum rz_subprocess_pipe_create_t RzSubprocessPipeCreate
RZ_API ssize_t rz_subprocess_stdin_write(RzSubprocess *proc, const ut8 *buf, size_t buf_size)
Definition: subprocess.c:1206
RZ_API bool rz_subprocess_init(void)
Definition: subprocess.c:787
RZ_API RzStrBuf * rz_subprocess_stdout_read(RzSubprocess *proc, size_t n, ut64 timeout_ms)
Definition: subprocess.c:1225
rz_subprocess_pipe_create_t
Definition: rz_subprocess.h:14
@ RZ_SUBPROCESS_PIPE_NONE
No pipe should be created. It can be used for stdin, stdout and stderr.
Definition: rz_subprocess.h:16
@ RZ_SUBPROCESS_PIPE_STDOUT
Definition: rz_subprocess.h:20
@ RZ_SUBPROCESS_PIPE_CREATE
Re-use the same pipe as stdout. It can be used for stderr only.
Definition: rz_subprocess.h:18
RZ_API int rz_subprocess_ret(RzSubprocess *proc)
Definition: subprocess.c:1297
RZ_API void rz_subprocess_kill(RzSubprocess *proc)
Definition: subprocess.c:1256
RZ_API RzStrBuf * rz_subprocess_stdout_readline(RzSubprocess *proc, ut64 timeout_ms)
Definition: subprocess.c:1241
int ssize_t
Definition: sftypes.h:39
Definition: gzappend.c:170
ut8 * out
< Output generated by the process
Definition: rz_subprocess.h:41
int out_len
Error generated by the process.
Definition: rz_subprocess.h:43
int ret
True if the process has exited because of a timeout.
Definition: rz_subprocess.h:49
ut8 * err
Number of bytes in the err field.
Definition: rz_subprocess.h:45
int err_len
Return value (exit code) of the sub-process.
Definition: rz_subprocess.h:47
size_t env_size
Specify how to deal with subprocess stdin.
Definition: rz_subprocess.h:69
const char * file
< Name of the executable to run. It is searched also in PATH
Definition: rz_subprocess.h:59
RzSubprocessPipeCreate stderr_pipe
Definition: rz_subprocess.h:75
RzSubprocessPipeCreate stdout_pipe
Specify how to deal with subprocess stderr.
Definition: rz_subprocess.h:73
size_t args_size
Names of environment variables that subprocess should have differently from parent.
Definition: rz_subprocess.h:63
const char ** envvals
Number of elements contained in both envvars and envvals.
Definition: rz_subprocess.h:67
const char ** args
Number of arguments in args array.
Definition: rz_subprocess.h:61
RzSubprocessPipeCreate stdin_pipe
Specify how to deal with subprocess stdout.
Definition: rz_subprocess.h:71
const char ** envvars
Values of environment variables that subprocess should have differently from parent.
Definition: rz_subprocess.h:65
struct Proc * proc
ut64(WINAPI *w32_GetEnabledXStateFeatures)()