Example #1
0
//***************
// r e a d e n v
//***************
// Goes to read directly the environment variables from the operating system on Windows
// and provides a stub for UNIX.
bool readenv(const char* env_name, Firebird::string& env_value)
{
#ifdef WIN_NT
	const DWORD rc = GetEnvironmentVariable(env_name, NULL, 0);
	if (rc)
	{
		env_value.reserve(rc - 1);
		DWORD rc2 = GetEnvironmentVariable(env_name, env_value.begin(), rc);
		if (rc2 < rc && rc2 != 0)
		{
			env_value.recalculate_length();
			return true;
		}
	}
#else
	const char* p = getenv(env_name);
	if (p)
		return env_value.assign(p).length() != 0;
#endif
	// Not found, clear the output var.
	env_value.begin()[0] = 0;
	env_value.recalculate_length();
	return false;
}
Example #2
0
Firebird::string Stream::getFBString() const
{
	Firebird::string string;
	char *p = string.getBuffer (totalLength);

	for (const Segment *segment = segments; segment; segment = segment->next)
	{
		memcpy (p, segment->address, segment->length);
		p += segment->length;
	}

	fb_assert(p - string.begin() == totalLength);

	return string;
}