MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / setenv

Function setenv

src/common/utils.cpp:315–342  ·  view source on GitHub ↗

Set environment variable. If overwrite == false and variable already exist, return true.

Source from the content-addressed store, hash-verified

313// Set environment variable.
314// If overwrite == false and variable already exist, return true.
315bool setenv(const char* name, const char* value, bool overwrite)
316{
317#ifdef WIN_NT
318 int errcode = 0;
319
320 if (!overwrite)
321 {
322 size_t envsize = 0;
323 errcode = getenv_s(&envsize, NULL, 0, name);
324 if (errcode || envsize)
325 return errcode ? false : true;
326 }
327
328 // In Windows, _putenv_s sets only the environment data in the CRT.
329 // Each DLL (for example ICU) may use a different CRT which different data
330 // or use Win32's GetEnvironmentVariable, so we also use SetEnvironmentVariable.
331 // This is a mess and is not guarenteed to work correctly in all situations.
332 if (SetEnvironmentVariable(name, value))
333 {
334 _putenv_s(name, value);
335 return true;
336 }
337 else
338 return false;
339#else
340 return ::setenv(name, value, (int) overwrite) == 0;
341#endif
342}
343
344// ***************
345// s n p r i n t f

Callers 12

TimeZoneDataPathMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected