mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 15:23:02 +01:00
Change from getenv to readenv. This is still getenv in Linux/UNIX but GetEnvironmentVariable in Windows.
This commit is contained in:
parent
0a4cc3b0ce
commit
b67b0219ab
@ -66,6 +66,8 @@
|
|||||||
#include "../utilities/common/cmd_util_proto.h"
|
#include "../utilities/common/cmd_util_proto.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../common/utils_proto.h"
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -90,6 +92,7 @@
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// The following structure in only needed if we are building a local exe
|
// The following structure in only needed if we are building a local exe
|
||||||
// I've commented it out to make it clear since this global variable is
|
// I've commented it out to make it clear since this global variable is
|
||||||
// defined in burp.cpp as well, and is not relevant for SERVICE_THREAD
|
// defined in burp.cpp as well, and is not relevant for SERVICE_THREAD
|
||||||
@ -374,21 +377,21 @@ static int api_gbak(int argc,
|
|||||||
BurpGlobals::putSpecific(tdgbl);
|
BurpGlobals::putSpecific(tdgbl);
|
||||||
tdgbl->output_proc = output_main;
|
tdgbl->output_proc = output_main;
|
||||||
|
|
||||||
const TEXT* usr;
|
Firebird::string usr;
|
||||||
if (!user)
|
if (!user)
|
||||||
usr = getenv("ISC_USER");
|
fb_utils::readenv("ISC_USER", usr);
|
||||||
else
|
else
|
||||||
usr = user;
|
usr = user;
|
||||||
|
|
||||||
const TEXT* pswd;
|
Firebird::string pswd;
|
||||||
if (!password)
|
if (!password)
|
||||||
pswd = getenv("ISC_PASSWORD");
|
fb_utils::readenv("ISC_PASSWORD", pswd);
|
||||||
else
|
else
|
||||||
pswd = password;
|
pswd = password;
|
||||||
|
|
||||||
char *const spb = (char *) gds__alloc((SLONG) (2 + 2 + ((usr) ? strlen(usr) : 0) +
|
char *const spb = (char *) gds__alloc((SLONG) (2 + 2 + usr.length() +
|
||||||
2 + ((pswd) ? strlen(pswd) : 0)) +
|
2 + pswd.length() +
|
||||||
2 + length);
|
2 + length));
|
||||||
/* 'isc_spb_version'
|
/* 'isc_spb_version'
|
||||||
'isc_spb_current_version'
|
'isc_spb_current_version'
|
||||||
'isc_spb_user_name'
|
'isc_spb_user_name'
|
||||||
@ -415,20 +418,20 @@ static int api_gbak(int argc,
|
|||||||
*spb_ptr++ = isc_spb_version;
|
*spb_ptr++ = isc_spb_version;
|
||||||
*spb_ptr++ = isc_spb_current_version;
|
*spb_ptr++ = isc_spb_current_version;
|
||||||
|
|
||||||
if (usr) {
|
if (usr.length()) {
|
||||||
*spb_ptr++ = isc_spb_user_name;
|
*spb_ptr++ = isc_spb_user_name;
|
||||||
*spb_ptr++ = strlen(usr);
|
*spb_ptr++ = usr.length();
|
||||||
MEMMOVE(usr, spb_ptr, strlen(usr));
|
MEMMOVE(usr.c_str(), spb_ptr, usr.length());
|
||||||
spb_ptr += strlen(usr);
|
spb_ptr += usr.length();
|
||||||
if (user)
|
if (user)
|
||||||
*user = '\0';
|
*user = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pswd) {
|
if (pswd.length()) {
|
||||||
*spb_ptr++ = isc_spb_password;
|
*spb_ptr++ = isc_spb_password;
|
||||||
*spb_ptr++ = strlen(pswd);
|
*spb_ptr++ = pswd.length();
|
||||||
MEMMOVE(pswd, spb_ptr, strlen(pswd));
|
MEMMOVE(pswd.c_str(), spb_ptr, pswd.length());
|
||||||
spb_ptr += strlen(pswd);
|
spb_ptr += pswd.length();
|
||||||
if (password)
|
if (password)
|
||||||
*password = '\0';
|
*password = '\0';
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,46 @@ int name_length(const TEXT* const name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//***************
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool readenv(const char* env_name, Firebird::PathName& env_value)
|
||||||
|
{
|
||||||
|
Firebird::string result;
|
||||||
|
bool rc = readenv(env_name, result);
|
||||||
|
env_value.assign(result.c_str(), result.length());
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ***************
|
// ***************
|
||||||
// s n p r i n t f
|
// s n p r i n t f
|
||||||
// ***************
|
// ***************
|
||||||
|
@ -39,6 +39,8 @@ namespace fb_utils
|
|||||||
}
|
}
|
||||||
char* exact_name_limit(char* const str, size_t bufsize);
|
char* exact_name_limit(char* const str, size_t bufsize);
|
||||||
int name_length(const TEXT* const name);
|
int name_length(const TEXT* const name);
|
||||||
|
bool readenv(const char* env_name, Firebird::string& env_value);
|
||||||
|
bool readenv(const char* env_name, Firebird::PathName& env_value);
|
||||||
int snprintf(char* buffer, size_t count, const char* format...);
|
int snprintf(char* buffer, size_t count, const char* format...);
|
||||||
} // namespace fb_utils
|
} // namespace fb_utils
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ static void blr_print_verb(gds_ctl*, SSHORT);
|
|||||||
static int blr_print_word(gds_ctl*);
|
static int blr_print_word(gds_ctl*);
|
||||||
|
|
||||||
static void init(void);
|
static void init(void);
|
||||||
static void sanitize(TEXT*);
|
static void sanitize(Firebird::string& locale);
|
||||||
|
|
||||||
static void safe_concat_path(TEXT* destbuf, const TEXT* srcbuf);
|
static void safe_concat_path(TEXT* destbuf, const TEXT* srcbuf);
|
||||||
|
|
||||||
@ -1500,10 +1500,10 @@ SSHORT API_ROUTINE gds__msg_lookup(void* handle,
|
|||||||
if (!messageL && !(messageL = global_default_msg)) {
|
if (!messageL && !(messageL = global_default_msg)) {
|
||||||
/* Try environment variable setting first */
|
/* Try environment variable setting first */
|
||||||
|
|
||||||
TEXT* p = getenv("ISC_MSGS");
|
Firebird::string p;
|
||||||
if (p == NULL ||
|
if (!fb_utils::readenv("ISC_MSGS", p) ||
|
||||||
(status =
|
(status =
|
||||||
gds__msg_open(reinterpret_cast<void**>(&messageL), p)))
|
gds__msg_open(reinterpret_cast<void**>(&messageL), p.c_str())))
|
||||||
{
|
{
|
||||||
TEXT translated_msg_file[sizeof(MSG_FILE_LANG) + LOCALE_MAX + 1];
|
TEXT translated_msg_file[sizeof(MSG_FILE_LANG) + LOCALE_MAX + 1];
|
||||||
|
|
||||||
@ -1516,11 +1516,11 @@ SSHORT API_ROUTINE gds__msg_lookup(void* handle,
|
|||||||
if (!msg_file) /* NOMEM: */
|
if (!msg_file) /* NOMEM: */
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
p = getenv("LC_MESSAGES");
|
if (fb_utils::readenv("LC_MESSAGES", p))
|
||||||
if (p != NULL) {
|
{
|
||||||
sanitize(p); // CVC: Sanitizing environment variable???
|
sanitize(p);
|
||||||
fb_utils::snprintf(translated_msg_file,
|
fb_utils::snprintf(translated_msg_file,
|
||||||
sizeof(translated_msg_file), MSG_FILE_LANG, p);
|
sizeof(translated_msg_file), MSG_FILE_LANG, p.c_str());
|
||||||
gds__prefix_msg(msg_file, translated_msg_file);
|
gds__prefix_msg(msg_file, translated_msg_file);
|
||||||
status =
|
status =
|
||||||
gds__msg_open(reinterpret_cast<void**>(&messageL),
|
gds__msg_open(reinterpret_cast<void**>(&messageL),
|
||||||
@ -2562,8 +2562,9 @@ BOOLEAN API_ROUTINE gds__validate_lib_path(const TEXT* module,
|
|||||||
* else, if the module is not in the path return FALSE.
|
* else, if the module is not in the path return FALSE.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
TEXT* ib_ext_lib_path = getenv(ib_env_var);
|
Firebird::string ib_ext_lib_path;
|
||||||
if (!ib_ext_lib_path) {
|
if (!fb_utils::readenv(ib_env_var, ib_ext_lib_path))
|
||||||
|
{
|
||||||
strncpy(resolved_module, module, length);
|
strncpy(resolved_module, module, length);
|
||||||
resolved_module[length - 1] = 0;
|
resolved_module[length - 1] = 0;
|
||||||
return TRUE; /* The variable is not defined. Return TRUE */
|
return TRUE; /* The variable is not defined. Return TRUE */
|
||||||
@ -2588,13 +2589,11 @@ BOOLEAN API_ROUTINE gds__validate_lib_path(const TEXT* module,
|
|||||||
TEXT abs_path[MAXPATHLEN];
|
TEXT abs_path[MAXPATHLEN];
|
||||||
TEXT path[MAXPATHLEN];
|
TEXT path[MAXPATHLEN];
|
||||||
|
|
||||||
// Let's not modify envvar with strtok!
|
// Warning: ib_ext_lib_path.length() is not coherent since strtok is applied to it.
|
||||||
TEXT temp_path[MAXPATHLEN];
|
const TEXT* token = strtok(ib_ext_lib_path.begin(), ";");
|
||||||
strncpy(temp_path, ib_ext_lib_path, sizeof(temp_path));
|
|
||||||
temp_path[sizeof(temp_path) - 1] = 0;
|
|
||||||
const TEXT* token = strtok(temp_path, ";");
|
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
strcpy(path, token);
|
strncpy(path, token, sizeof(path));
|
||||||
|
path[sizeof(path) - 1] = 0;
|
||||||
/* make sure that there is no traing slash on the path */
|
/* make sure that there is no traing slash on the path */
|
||||||
TEXT* p = path + strlen(path);
|
TEXT* p = path + strlen(path);
|
||||||
if ((p != path) && ((p[-1] == '/') || (p[-1] == '\\')))
|
if ((p != path) && ((p[-1] == '/') || (p[-1] == '\\')))
|
||||||
@ -3576,7 +3575,7 @@ static void init(void)
|
|||||||
/* V4_GLOBAL_MUTEX_UNLOCK; */
|
/* V4_GLOBAL_MUTEX_UNLOCK; */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sanitize(TEXT* locale)
|
static void sanitize(Firebird::string& locale)
|
||||||
{
|
{
|
||||||
/**************************************
|
/**************************************
|
||||||
*
|
*
|
||||||
@ -3591,10 +3590,10 @@ static void sanitize(TEXT* locale)
|
|||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
|
|
||||||
while (*locale) {
|
for (Firebird::string::pointer p = locale.begin(); *p; ++p)
|
||||||
if (*locale == '.')
|
{
|
||||||
*locale = '_';
|
if (*p == '.')
|
||||||
locale++;
|
*p = '_';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3684,8 +3683,8 @@ public:
|
|||||||
ib_prefix = ib_prefix_val;
|
ib_prefix = ib_prefix_val;
|
||||||
|
|
||||||
// Find appropiate temp directory
|
// Find appropiate temp directory
|
||||||
const char* tempDir = getenv(FB_TMP_ENV);
|
Firebird::PathName tempDir;
|
||||||
if (!tempDir)
|
if (!fb_utils::readenv(FB_TMP_ENV, tempDir))
|
||||||
{
|
{
|
||||||
#ifdef WIN_NT
|
#ifdef WIN_NT
|
||||||
const DWORD len = GetTempPath(sizeof(fbTempDir), fbTempDir);
|
const DWORD len = GetTempPath(sizeof(fbTempDir), fbTempDir);
|
||||||
@ -3695,14 +3694,14 @@ public:
|
|||||||
tempDir = fbTempDir;
|
tempDir = fbTempDir;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
tempDir = getenv("TMP");
|
fb_utils::readenv("TMP", tempDir);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (!tempDir || strlen(tempDir) >= MAXPATHLEN)
|
if (!tempDir.length() || tempDir.length() >= MAXPATHLEN)
|
||||||
{
|
{
|
||||||
tempDir = WORKFILE;
|
tempDir = WORKFILE;
|
||||||
}
|
}
|
||||||
strcpy(fbTempDir, tempDir);
|
strcpy(fbTempDir, tempDir.c_str());
|
||||||
|
|
||||||
#ifdef EMBEDDED
|
#ifdef EMBEDDED
|
||||||
// Generate filename based on the current PID
|
// Generate filename based on the current PID
|
||||||
@ -3714,8 +3713,8 @@ public:
|
|||||||
// Find appropriate Firebird lock file prefix
|
// Find appropriate Firebird lock file prefix
|
||||||
// Override conditional defines with the enviroment
|
// Override conditional defines with the enviroment
|
||||||
// variable FIREBIRD_LOCK if it is set.
|
// variable FIREBIRD_LOCK if it is set.
|
||||||
Firebird::PathName lockPrefix(getenv(FB_LOCK_ENV) ? getenv(FB_LOCK_ENV) : "");
|
Firebird::PathName lockPrefix;
|
||||||
if (lockPrefix.isEmpty())
|
if (!fb_utils::readenv(FB_LOCK_ENV, lockPrefix))
|
||||||
{
|
{
|
||||||
#ifdef EMBEDDED
|
#ifdef EMBEDDED
|
||||||
lockPrefix = tempDir;
|
lockPrefix = tempDir;
|
||||||
@ -3727,8 +3726,8 @@ public:
|
|||||||
ib_prefix_lock = ib_prefix_lock_val;
|
ib_prefix_lock = ib_prefix_lock_val;
|
||||||
|
|
||||||
// Find appropriate Firebird message file prefix.
|
// Find appropriate Firebird message file prefix.
|
||||||
Firebird::PathName msgPrefix(getenv(FB_MSG_ENV) ? getenv(FB_MSG_ENV) : "");
|
Firebird::PathName msgPrefix;
|
||||||
if (msgPrefix.isEmpty())
|
if (!fb_utils::readenv(FB_MSG_ENV, msgPrefix))
|
||||||
{
|
{
|
||||||
msgPrefix = prefix;
|
msgPrefix = prefix;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "../common/classes/fb_string.h"
|
#include "../common/classes/fb_string.h"
|
||||||
|
|
||||||
#include "../jrd/os/path_utils.h"
|
#include "../jrd/os/path_utils.h"
|
||||||
|
#include "../common/utils_proto.h"
|
||||||
|
|
||||||
static const char* CONFIG_FILE = "firebird.conf";
|
static const char* CONFIG_FILE = "firebird.conf";
|
||||||
|
|
||||||
@ -104,11 +105,12 @@ private:
|
|||||||
root_dir += PathUtils::dir_sep;
|
root_dir += PathUtils::dir_sep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool getRootFromEnvironment(const char* envName) {
|
bool getRootFromEnvironment(const char* envName)
|
||||||
const char* envValue = getenv(envName);
|
{
|
||||||
if (! envValue) {
|
string envValue;
|
||||||
|
if (!fb_utils::readenv(envName, envValue))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
root_dir = envValue;
|
root_dir = envValue;
|
||||||
addSlash();
|
addSlash();
|
||||||
return true;
|
return true;
|
||||||
|
@ -47,8 +47,8 @@ typedef Firebird::string string;
|
|||||||
ConfigRoot::ConfigRoot()
|
ConfigRoot::ConfigRoot()
|
||||||
{
|
{
|
||||||
// Check the environment variable
|
// Check the environment variable
|
||||||
const char* envPath = getenv("FIREBIRD");
|
Firebird::PathName envPath;
|
||||||
if (envPath != NULL && strcmp("", envPath))
|
if (fb_utils::readenv("FIREBIRD", envPath))
|
||||||
{
|
{
|
||||||
root_dir = envPath;
|
root_dir = envPath;
|
||||||
return;
|
return;
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "../jrd/met_proto.h"
|
#include "../jrd/met_proto.h"
|
||||||
#include "../jrd/opt_proto.h"
|
#include "../jrd/opt_proto.h"
|
||||||
#include "../jrd/vio_proto.h"
|
#include "../jrd/vio_proto.h"
|
||||||
|
#include "../common/utils_proto.h"
|
||||||
|
|
||||||
#include rms
|
#include rms
|
||||||
|
|
||||||
@ -174,9 +175,10 @@ ExternalFile* EXT_file(jrd_rel* relation, TEXT* file_name, bid* description)
|
|||||||
logical name is defined and it is not READONLY, then let there be
|
logical name is defined and it is not READONLY, then let there be
|
||||||
an error. */
|
an error. */
|
||||||
|
|
||||||
const UCHAR* lognam = getenv("GDS_RMSACCESS");
|
Firebird::string lognam;
|
||||||
if (lognam) {
|
if (fb_utils::readenv("GDS_RMSACCESS", lognam))
|
||||||
if (strcmp(lognam, "READONLY") == 0)
|
{
|
||||||
|
if (lognam == "READONLY")
|
||||||
fab.fab$b_fac = FAB$M_GET;
|
fab.fab$b_fac = FAB$M_GET;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -623,6 +623,7 @@ bool SCH_validate(void)
|
|||||||
|
|
||||||
if (!init_flag || !active_thread) {
|
if (!init_flag || !active_thread) {
|
||||||
gds__log("SCH_validate -- not entered");
|
gds__log("SCH_validate -- not entered");
|
||||||
|
// CVC: No need to replace by fb_utils::readenv() I think.
|
||||||
if (getenv("ISC_PUNT"))
|
if (getenv("ISC_PUNT"))
|
||||||
abort();
|
abort();
|
||||||
return false;
|
return false;
|
||||||
|
@ -629,13 +629,13 @@ int API_ROUTINE gds__edit(const TEXT* file_name, USHORT type)
|
|||||||
* Edit a file.
|
* Edit a file.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
const TEXT* editor;
|
Firebird::string editor;
|
||||||
|
|
||||||
#ifndef WIN_NT
|
#ifndef WIN_NT
|
||||||
if (!(editor = getenv("VISUAL")) && !(editor = getenv("EDITOR")))
|
if (!fb_utils::readenv("VISUAL", editor) && !fb_utils::readenv("EDITOR", editor))
|
||||||
editor = "vi";
|
editor = "vi";
|
||||||
#else
|
#else
|
||||||
if (!(editor = getenv("EDITOR")))
|
if (!fb_utils::readenv("EDITOR", editor))
|
||||||
editor = "Notepad";
|
editor = "Notepad";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -644,7 +644,7 @@ int API_ROUTINE gds__edit(const TEXT* file_name, USHORT type)
|
|||||||
// The path of the editor + the path of the file + quotes + one space.
|
// The path of the editor + the path of the file + quotes + one space.
|
||||||
// We aren't using quotes around the editor for now.
|
// We aren't using quotes around the editor for now.
|
||||||
TEXT buffer[MAXPATHLEN * 2 + 5];
|
TEXT buffer[MAXPATHLEN * 2 + 5];
|
||||||
fb_utils::snprintf(buffer, sizeof(buffer), "%s \"%s\"", editor, file_name);
|
fb_utils::snprintf(buffer, sizeof(buffer), "%s \"%s\"", editor.c_str(), file_name);
|
||||||
|
|
||||||
system(buffer);
|
system(buffer);
|
||||||
|
|
||||||
@ -1053,10 +1053,8 @@ void API_ROUTINE isc_set_login(const UCHAR** dpb, SSHORT* dpb_size)
|
|||||||
|
|
||||||
/* look for the environment variables */
|
/* look for the environment variables */
|
||||||
|
|
||||||
const TEXT* username = getenv("ISC_USER");
|
Firebird::string username, password;
|
||||||
const TEXT* password = getenv("ISC_PASSWORD");
|
if (!fb_utils::readenv("ISC_USER", username) && !fb_utils::readenv("ISC_PASSWORD", password))
|
||||||
|
|
||||||
if (!username && !password)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* figure out whether the username or
|
/* figure out whether the username or
|
||||||
@ -1090,18 +1088,19 @@ void API_ROUTINE isc_set_login(const UCHAR** dpb, SSHORT* dpb_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (username && !user_seen) {
|
if (username.length() && !user_seen)
|
||||||
if (password && !password_seen)
|
{
|
||||||
|
if (password.length() && !password_seen)
|
||||||
isc_expand_dpb_internal(dpb, dpb_size,
|
isc_expand_dpb_internal(dpb, dpb_size,
|
||||||
isc_dpb_user_name, username, isc_dpb_password,
|
isc_dpb_user_name, username.c_str(), isc_dpb_password,
|
||||||
password, 0);
|
password.c_str(), 0);
|
||||||
else
|
else
|
||||||
isc_expand_dpb_internal(dpb, dpb_size,
|
isc_expand_dpb_internal(dpb, dpb_size,
|
||||||
isc_dpb_user_name, username, 0);
|
isc_dpb_user_name, username.c_str(), 0);
|
||||||
}
|
}
|
||||||
else if (password && !password_seen)
|
else if (password.length() && !password_seen)
|
||||||
isc_expand_dpb_internal(dpb, dpb_size,
|
isc_expand_dpb_internal(dpb, dpb_size,
|
||||||
isc_dpb_password, password, 0);
|
isc_dpb_password, password.c_str(), 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,8 +1123,8 @@ BOOLEAN API_ROUTINE isc_set_path(TEXT* file_name,
|
|||||||
/* look for the environment variables to tack
|
/* look for the environment variables to tack
|
||||||
onto the beginning of the database path */
|
onto the beginning of the database path */
|
||||||
|
|
||||||
const TEXT* pathname = getenv("ISC_PATH");
|
Firebird::PathName pathname;
|
||||||
if (!pathname)
|
if (!fb_utils::readenv("ISC_PATH", pathname))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!file_length)
|
if (!file_length)
|
||||||
@ -1144,7 +1143,7 @@ BOOLEAN API_ROUTINE isc_set_path(TEXT* file_name,
|
|||||||
|
|
||||||
/* concatenate the strings */
|
/* concatenate the strings */
|
||||||
|
|
||||||
strcpy(expanded_name, pathname);
|
strcpy(expanded_name, pathname.c_str());
|
||||||
|
|
||||||
/* CVC: Make the concatenation work if no slash is present. */
|
/* CVC: Make the concatenation work if no slash is present. */
|
||||||
p = expanded_name + (strlen (expanded_name) - 1);
|
p = expanded_name + (strlen (expanded_name) - 1);
|
||||||
@ -2438,16 +2437,16 @@ inline void setTag(Firebird::ClumpletWriter& dpb, UCHAR tag, const TEXT* value)
|
|||||||
|
|
||||||
void setLogin(Firebird::ClumpletWriter& dpb)
|
void setLogin(Firebird::ClumpletWriter& dpb)
|
||||||
{
|
{
|
||||||
const TEXT* username = getenv("ISC_USER");
|
Firebird::string username;
|
||||||
if (username && !dpb.find(isc_dpb_sys_user_name))
|
if (fb_utils::readenv("ISC_USER", username) && !dpb.find(isc_dpb_sys_user_name))
|
||||||
{
|
{
|
||||||
setTag(dpb, isc_dpb_user_name, username);
|
setTag(dpb, isc_dpb_user_name, username.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
const TEXT* password = getenv("ISC_PASSWORD");
|
Firebird::string password;
|
||||||
if (password && !dpb.find(isc_dpb_password_enc))
|
if (fb_utils::readenv("ISC_PASSWORD", password) && !dpb.find(isc_dpb_password_enc))
|
||||||
{
|
{
|
||||||
setTag(dpb, isc_dpb_password, password);
|
setTag(dpb, isc_dpb_password, password.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "../jrd/gds_proto.h"
|
#include "../jrd/gds_proto.h"
|
||||||
#include "../jrd/perf_proto.h"
|
#include "../jrd/perf_proto.h"
|
||||||
#include "../include/fb_exception.h"
|
#include "../include/fb_exception.h"
|
||||||
|
#include "../common/utils_proto.h"
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
const char* STARTUP_FILE = "QLI_STARTUP";
|
const char* STARTUP_FILE = "QLI_STARTUP";
|
||||||
@ -104,20 +105,15 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
|
|
||||||
// Look at options, if any
|
// Look at options, if any
|
||||||
|
|
||||||
const TEXT* startup_file = STARTUP_FILE;
|
Firebird::PathName startup_file = STARTUP_FILE;
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
// If a Unix system, get home directory from environment
|
// If a Unix system, get home directory from environment
|
||||||
SCHAR home_directory[MAXPATHLEN];
|
SCHAR home_directory[MAXPATHLEN];
|
||||||
startup_file = getenv("HOME");
|
if (!fb_utils::readenv("HOME", startup_file))
|
||||||
if (startup_file == NULL) {
|
|
||||||
startup_file = ".qli_startup";
|
startup_file = ".qli_startup";
|
||||||
}
|
else
|
||||||
else {
|
startup_file.append("/.qli_startup");
|
||||||
strcpy(home_directory, startup_file);
|
|
||||||
strcat(home_directory, "/.qli_startup");
|
|
||||||
startup_file = home_directory;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const TEXT* application_file = NULL;
|
const TEXT* application_file = NULL;
|
||||||
@ -181,7 +177,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
if (argv >= arg_end || **argv == '-')
|
if (argv >= arg_end || **argv == '-')
|
||||||
startup_file = NULL;
|
startup_file = "";
|
||||||
else
|
else
|
||||||
startup_file = *argv++;
|
startup_file = *argv++;
|
||||||
break;
|
break;
|
||||||
@ -256,19 +252,18 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
if (application_file)
|
if (application_file)
|
||||||
LEX_push_file(application_file, true);
|
LEX_push_file(application_file, true);
|
||||||
|
|
||||||
if (startup_file)
|
if (startup_file.length())
|
||||||
LEX_push_file(startup_file, false);
|
LEX_push_file(startup_file.c_str(), false);
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
bool vms_tryagain_flag = false;
|
bool vms_tryagain_flag = false;
|
||||||
if (startup_file)
|
if (startup_file.length())
|
||||||
vms_tryagain_flag = LEX_push_file(startup_file, false);
|
vms_tryagain_flag = LEX_push_file(startup_file.c_str(), false);
|
||||||
|
|
||||||
/* If default value of startup file wasn't altered by the use of -i,
|
/* If default value of startup file wasn't altered by the use of -i,
|
||||||
and LEX returned FALSE (above), try the old logical name, QLI_INIT */
|
and LEX returned false (above), try the old logical name, QLI_INIT */
|
||||||
|
|
||||||
if (!vms_tryagain_flag && startup_file
|
if (!vms_tryagain_flag && startup_file == STARTUP_FILE)
|
||||||
&& !(strcmp(startup_file, STARTUP_FILE)))
|
|
||||||
{
|
{
|
||||||
LEX_push_file("QLI_INIT", false);
|
LEX_push_file("QLI_INIT", false);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "../jrd/gds_proto.h"
|
#include "../jrd/gds_proto.h"
|
||||||
#include "../jrd/utl_proto.h"
|
#include "../jrd/utl_proto.h"
|
||||||
#include "../jrd/gdsassert.h"
|
#include "../jrd/gdsassert.h"
|
||||||
|
#include "../common/utils_proto.h"
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -896,14 +897,17 @@ qli_tok* LEX_token(void)
|
|||||||
token->tok_length = p - token->tok_string;
|
token->tok_length = p - token->tok_string;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
if (token->tok_string[0] == '$' &&
|
if (token->tok_string[0] == '$' && trans_limit < TRANS_LIMIT)
|
||||||
trans_limit < TRANS_LIMIT && (p = getenv(token->tok_string + 1)))
|
|
||||||
{
|
{
|
||||||
LEX_push_string(p);
|
Firebird::string s;
|
||||||
++trans_limit;
|
if (fb_utils::readenv(token->tok_string + 1, s))
|
||||||
token = LEX_token();
|
{
|
||||||
--trans_limit;
|
LEX_push_string(s.c_str());
|
||||||
return token;
|
++trans_limit;
|
||||||
|
token = LEX_token();
|
||||||
|
--trans_limit;
|
||||||
|
return token;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qli_symbol* symbol = HSH_lookup(token->tok_string, token->tok_length);
|
qli_symbol* symbol = HSH_lookup(token->tok_string, token->tok_length);
|
||||||
|
@ -634,6 +634,7 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
INET_start_time = inet_debug_timer();
|
INET_start_time = inet_debug_timer();
|
||||||
|
// CVC: I don't see the point in replacing this with fb_utils::readenv().
|
||||||
const char* p = getenv("INET_force_error");
|
const char* p = getenv("INET_force_error");
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
INET_force_error = atoi(p);
|
INET_force_error = atoi(p);
|
||||||
@ -1244,10 +1245,11 @@ static int accept_connection(rem_port* port,
|
|||||||
* is activiated for the production product.
|
* is activiated for the production product.
|
||||||
* 1995-February-27 David Schnepper
|
* 1995-February-27 David Schnepper
|
||||||
*/
|
*/
|
||||||
const char* home = getenv("ISC_INET_SERVER_HOME");
|
Firebird::PathName home;
|
||||||
if (home) {
|
if (fb_utils::readenv("ISC_INET_SERVER_HOME", home))
|
||||||
if (chdir(home)) {
|
{
|
||||||
gds__log("inet_server: unable to cd to %s errno %d\n", home,
|
if (chdir(home.c_str())) {
|
||||||
|
gds__log("inet_server: unable to cd to %s errno %d\n", home.c_str(),
|
||||||
INET_ERRNO);
|
INET_ERRNO);
|
||||||
/* We continue after the error */
|
/* We continue after the error */
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,7 @@ const USHORT MIN_ROWS_PER_BATCH = 10; /* data rows - picked by SWAG */
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
|
// CVC: I don't see the point in replacing this with fb_utils::readenv().
|
||||||
const char* p = getenv("DEBUG_BATCH_SIZE");
|
const char* p = getenv("DEBUG_BATCH_SIZE");
|
||||||
if (p)
|
if (p)
|
||||||
result = atoi(p);
|
result = atoi(p);
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "../common/classes/ClumpletWriter.h"
|
#include "../common/classes/ClumpletWriter.h"
|
||||||
|
|
||||||
#include "../utilities/gsec/call_service.h"
|
#include "../utilities/gsec/call_service.h"
|
||||||
|
#include "../common/utils_proto.h"
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -150,13 +151,9 @@ inline void envPick(TEXT* dest, size_t size, const TEXT* var)
|
|||||||
{
|
{
|
||||||
if (dest && (!dest[0]))
|
if (dest && (!dest[0]))
|
||||||
{
|
{
|
||||||
const TEXT* val = getenv(var);
|
Firebird::string val;
|
||||||
if (val)
|
if (fb_utils::readenv(var, val))
|
||||||
{
|
val.copyTo(dest, size);
|
||||||
--size;
|
|
||||||
strncpy(dest, val, size);
|
|
||||||
dest[size] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
*
|
*
|
||||||
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
|
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
|
||||||
*
|
*
|
||||||
* $Id: ibmgr.cpp,v 1.17 2005-12-30 15:59:19 alexpeshkoff Exp $
|
* $Id: ibmgr.cpp,v 1.18 2006-01-14 04:48:59 robocop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "firebird.h"
|
#include "firebird.h"
|
||||||
@ -104,12 +104,13 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
/* Let's see if we have something in
|
/* Let's see if we have something in
|
||||||
environment variables
|
environment variables
|
||||||
*/
|
*/
|
||||||
const TEXT* user = getenv("ISC_USER");
|
Firebird::string user, password;
|
||||||
const TEXT* password = getenv("ISC_PASSWORD");
|
fb_utils::readenv("ISC_USER", user);
|
||||||
|
fb_utils::readenv("ISC_PASSWORD", password);
|
||||||
|
|
||||||
const TEXT* host = NULL; // pointer for getenv
|
Firebird::string host;
|
||||||
/* MMM - do not allow to change host now
|
/* MMM - do not allow to change host now
|
||||||
host = getenv("ISC_HOST");
|
fb_utils::readenv("ISC_HOST", host);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TEXT msg[MSG_LEN];
|
TEXT msg[MSG_LEN];
|
||||||
@ -141,16 +142,16 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
copy_str_upper(ibmgr_data.user, pw->pw_name);
|
copy_str_upper(ibmgr_data.user, pw->pw_name);
|
||||||
|
|
||||||
|
|
||||||
if (user)
|
if (user.length())
|
||||||
copy_str_upper(ibmgr_data.user, user);
|
copy_str_upper(ibmgr_data.user, user.c_str());
|
||||||
|
|
||||||
if (password)
|
if (password.length())
|
||||||
strcpy(ibmgr_data.password, password);
|
strcpy(ibmgr_data.password, password.c_str());
|
||||||
else
|
else
|
||||||
ibmgr_data.password[0] = '\0';
|
ibmgr_data.password[0] = '\0';
|
||||||
|
|
||||||
if (host)
|
if (host.length())
|
||||||
strcpy(ibmgr_data.host, host);
|
strcpy(ibmgr_data.host, host.c_str());
|
||||||
else
|
else
|
||||||
strcpy(ibmgr_data.host, "localhost");
|
strcpy(ibmgr_data.host, "localhost");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user