aboutsummaryrefslogtreecommitdiff
path: root/src/program.h
blob: 8bf721c68153f1b25f84949f2a18befdde422b87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef PROGRAM_H
#define PROGRAM_H

/* Return 0 if you want to continue reading. @data is null-terminated */
typedef int (*ProgramOutputCallback)(char *data, int size, void *userdata);

int program_buffer_write_callback(char *data, int size, void *userdata);

/*
    @args need to have at least 2 arguments. The first which is the program name
    and the last which is NULL, which indicates end of args.
*/
int program_exec(const char **args, ProgramOutputCallback output_callback, void *userdata);
int program_exec_async(const char **args, int *process_id, int *stdin_file, int *stdout_file);
/* If stdin_file is -1 or stdout_file is -1 then they are not used */
int program_wait_until_exit(int process_id, int stdin_file, int stdout_file, ProgramOutputCallback output_callback, void *userdata);

#endif