Expose sc_get_env() to read environment variable

Contrary to getenv(), sc_get_env() returns an allocated string that is
guaranteed to be encoded in UTF-8 on all platforms (it uses _wgetenv()
internally on Windows and converts the strings).

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
This commit is contained in:
Romain Vimont
2024-11-30 16:10:48 +01:00
parent 0fd7534bd5
commit 131372d2c4
5 changed files with 52 additions and 34 deletions

12
app/src/util/env.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef SC_ENV_H
#define SC_ENV_H
#include "common.h"
// Return the value of the environment variable (may be NULL).
//
// The returned value must be freed by the caller.
char *
sc_get_env(const char *varname);
#endif