mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-02-21 05:44:30 +01:00
Improved manually with the help of neovim LSP warnings and iwyu:
iwyu -Ibuilddir/app/ -Iapp/src/ app/src/XXX.c
32 lines
541 B
C
32 lines
541 B
C
#include "env.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#ifdef _WIN32
|
|
# include "util/str.h"
|
|
#endif
|
|
|
|
char *
|
|
sc_get_env(const char *varname) {
|
|
#ifdef _WIN32
|
|
wchar_t *w_varname = sc_str_to_wchars(varname);
|
|
if (!w_varname) {
|
|
return NULL;
|
|
}
|
|
const wchar_t *value = _wgetenv(w_varname);
|
|
free(w_varname);
|
|
if (!value) {
|
|
return NULL;
|
|
}
|
|
|
|
return sc_str_from_wchars(value);
|
|
#else
|
|
const char *value = getenv(varname);
|
|
if (!value) {
|
|
return NULL;
|
|
}
|
|
|
|
return strdup(value);
|
|
#endif
|
|
}
|