Commit 222d057c by Paul Betts

Create cross-platform setenv

parent 71a4c1f1
...@@ -20,5 +20,6 @@ ...@@ -20,5 +20,6 @@
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a) #define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
#define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__) #define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__)
#define p_mkstemp(p) mkstemp(p) #define p_mkstemp(p) mkstemp(p)
#define p_setenv(n,v,o) setenv(n,v,o)
#endif #endif
...@@ -252,3 +252,11 @@ int p_mkstemp(char *tmp_path) ...@@ -252,3 +252,11 @@ int p_mkstemp(char *tmp_path)
return p_creat(tmp_path, 0744); return p_creat(tmp_path, 0744);
} }
int p_setenv(const char* name, const char* value, int overwrite)
{
if (overwrite != 1)
return EINVAL;
return (SetEnvironmentVariableA(name, value) == 0 ? GIT_EOSERR : GIT_SUCCESS);
}
...@@ -32,5 +32,6 @@ extern char *p_realpath(const char *orig_path, char *buffer); ...@@ -32,5 +32,6 @@ extern char *p_realpath(const char *orig_path, char *buffer);
extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr); extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr);
extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4); extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4);
extern int p_mkstemp(char *tmp_path); extern int p_mkstemp(char *tmp_path);
extern int p_setenv(const char* name, const char* value, int overwrite);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment