15 #define ErrorExit(x) \
20 char *ReadFromPipe(
HANDLE fh,
int *outlen);
22 RZ_API char *rz_sys_get_src_dir_w32(
void) {
23 TCHAR fullpath[MAX_PATH + 1];
24 TCHAR shortpath[MAX_PATH + 1];
26 if (!GetModuleFileName(
NULL, fullpath, MAX_PATH + 1) ||
27 !GetShortPathName(fullpath, shortpath, MAX_PATH + 1)) {
30 char *
path = rz_sys_conv_win_to_utf8(shortpath);
41 PROCESS_INFORMATION pi = { 0 };
42 STARTUPINFO
si = { 0 };
45 const size_t max_length = 32768 *
sizeof(TCHAR);
46 LPTSTR _cmdline_ =
malloc(max_length);
55 si.cb =
sizeof(STARTUPINFO);
59 si.dwFlags |= STARTF_USESTDHANDLES;
60 cmdline_ = rz_sys_conv_utf8_to_win(cmdline);
61 ExpandEnvironmentStrings(cmdline_, _cmdline_, max_length - 1);
62 if ((ret = CreateProcess(
NULL,
73 CloseHandle(pi.hProcess);
74 CloseHandle(pi.hThread);
83 char *ReadFromPipe(
HANDLE fh,
int *outlen) {
86 BOOL bSuccess =
FALSE;
100 if (!bSuccess || dwRead == 0) {
103 if (strl + dwRead > strsz) {
122 RZ_API char **rz_sys_utf8_argv_new(
int argc,
const wchar_t **
argv) {
123 char **utf8_argv =
calloc(argc + 1,
sizeof(
wchar_t *));
128 for (
i = 0;
i < argc;
i++) {
129 utf8_argv[
i] = rz_utf16_to_utf8(
argv[
i]);
134 RZ_API void rz_sys_utf8_argv_free(
int argc,
char **utf8_argv) {
136 for (
i = 0;
i < argc;
i++) {
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
static static fork const void static count static fd const char const char static newpath const char static path const char path
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char argv
RZ_API char * rz_file_dirname(const char *path)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API void rz_sys_perror_str(const char *fun)
RZ_API bool rz_sys_getenv_asbool(const char *key)
Return true if the environment variable has the value 1, false otherwise.