mirror of https://github.com/Genymobile/scrcpy
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.7 KiB
C
74 lines
1.7 KiB
C
4 years ago
|
#ifndef SC_PROCESS_H
|
||
|
#define SC_PROCESS_H
|
||
7 years ago
|
|
||
6 years ago
|
#include <stdbool.h>
|
||
4 years ago
|
|
||
|
#include "config.h"
|
||
7 years ago
|
|
||
|
#ifdef _WIN32
|
||
6 years ago
|
|
||
6 years ago
|
// not needed here, but winsock2.h must never be included AFTER windows.h
|
||
|
# include <winsock2.h>
|
||
6 years ago
|
# include <windows.h>
|
||
5 years ago
|
# define PATH_SEPARATOR '\\'
|
||
7 years ago
|
# define PRIexitcode "lu"
|
||
6 years ago
|
// <https://stackoverflow.com/a/44383330/1987178>
|
||
4 years ago
|
# define PRIsizet "Iu"
|
||
7 years ago
|
# define PROCESS_NONE NULL
|
||
5 years ago
|
# define NO_EXIT_CODE -1u // max value as unsigned
|
||
7 years ago
|
typedef HANDLE process_t;
|
||
|
typedef DWORD exit_code_t;
|
||
6 years ago
|
|
||
7 years ago
|
#else
|
||
6 years ago
|
|
||
7 years ago
|
# include <sys/types.h>
|
||
5 years ago
|
# define PATH_SEPARATOR '/'
|
||
6 years ago
|
# define PRIsizet "zu"
|
||
|
# define PRIexitcode "d"
|
||
7 years ago
|
# define PROCESS_NONE -1
|
||
5 years ago
|
# define NO_EXIT_CODE -1
|
||
7 years ago
|
typedef pid_t process_t;
|
||
|
typedef int exit_code_t;
|
||
6 years ago
|
|
||
7 years ago
|
#endif
|
||
6 years ago
|
|
||
6 years ago
|
enum process_result {
|
||
|
PROCESS_SUCCESS,
|
||
|
PROCESS_ERROR_GENERIC,
|
||
|
PROCESS_ERROR_MISSING_BINARY,
|
||
|
};
|
||
|
|
||
4 years ago
|
// execute the command and write the result to the output parameter "process"
|
||
6 years ago
|
enum process_result
|
||
4 years ago
|
process_execute(const char *const argv[], process_t *process);
|
||
7 years ago
|
|
||
4 years ago
|
// kill the process
|
||
6 years ago
|
bool
|
||
4 years ago
|
process_terminate(process_t pid);
|
||
6 years ago
|
|
||
4 years ago
|
// wait and close the process
|
||
6 years ago
|
bool
|
||
4 years ago
|
process_simple_wait(process_t pid, exit_code_t *exit_code);
|
||
7 years ago
|
|
||
7 years ago
|
// convenience function to wait for a successful process execution
|
||
|
// automatically log process errors with the provided process name
|
||
6 years ago
|
bool
|
||
5 years ago
|
process_check_success(process_t proc, const char *name);
|
||
7 years ago
|
|
||
4 years ago
|
#ifndef _WIN32
|
||
|
// only used to find package manager, not implemented for Windows
|
||
|
bool
|
||
|
search_executable(const char *file);
|
||
|
#endif
|
||
|
|
||
5 years ago
|
// return the absolute path of the executable (the scrcpy binary)
|
||
|
// may be NULL on error; to be freed by SDL_free
|
||
|
char *
|
||
|
get_executable_path(void);
|
||
|
|
||
5 years ago
|
// returns true if the file exists and is not a directory
|
||
|
bool
|
||
|
is_regular_file(const char *path);
|
||
|
|
||
7 years ago
|
#endif
|