本文整理汇总了C++中firebird::string::copyTo方法的典型用法代码示例。如果您正苦于以下问题:C++ string::copyTo方法的具体用法?C++ string::copyTo怎么用?C++ string::copyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类firebird::string
的用法示例。
在下文中一共展示了string::copyTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fb_msg_format
// Lookup and format message. Return as much of formatted string as fits in caller's buffer.
int fb_msg_format(void* handle, USHORT facility, USHORT number, unsigned int bsize, TEXT* buffer,
const MsgFormat::SafeArg& arg)
{
// The field MESSAGES.TEXT is 118 bytes long.
int total_msg = 0;
char msg[120] = "";
const int n = gds__msg_lookup(handle, facility, number, sizeof(msg), msg, NULL);
if (n > 0 && unsigned(n) < sizeof(msg))
{
// Shameful bridge, gds__msg_format emulation for old format messages.
if (strchr(msg, '%'))
{
const TEXT* rep[5];
arg.dump(rep, 5);
total_msg = fb_utils::snprintf(buffer, bsize, msg, rep[0], rep[1], rep[2], rep[3], rep[4]);
}
else
total_msg = MsgPrint(buffer, bsize, msg, arg);
}
else
{
Firebird::string s;
s.printf("can't format message %d:%d -- ", facility, number);
if (n == -1)
s += "message text not found";
else if (n == -2)
{
s += "message file ";
s += fb_utils::getPrefix(Firebird::DirType::FB_DIR_MSG, MSG_FILE).ToString();
s += " not found";
}
else
{
fb_utils::snprintf(buffer, bsize, "message system code %d", n);
s += buffer;
}
total_msg = s.copyTo(buffer, bsize);
}
return (n > 0 ? total_msg : -total_msg);
}
示例2: fetchPassword
// fetch password from file
FetchPassResult fetchPassword(const Firebird::PathName& name, const char*& password)
{
InputFile file(name);
if (!file)
{
return FETCH_PASS_FILE_OPEN_ERROR;
}
Firebird::string pwd;
if (! pwd.LoadFromFile(file.getStdioFile()))
{
return ferror(file.getStdioFile()) ? FETCH_PASS_FILE_READ_ERROR : FETCH_PASS_FILE_EMPTY;
}
// this is planned leak of a few bytes of memory in utilities
char* pass = FB_NEW_POOL(*getDefaultMemoryPool()) char[pwd.length() + 1];
pwd.copyTo(pass, pwd.length() + 1);
password = pass;
return FETCH_PASS_OK;
}
示例3: changeCryptState
void CryptoManager::changeCryptState(thread_db* tdbb, const Firebird::string& plugName)
{
if (plugName.length() > 31)
{
(Arg::Gds(isc_cp_name_too_long) << Arg::Num(31)).raise();
}
bool newCryptState = plugName.hasData();
{ // window scope
Header hdr(tdbb, LCK_write);
// Check header page for flags
if (hdr->hdr_flags & Ods::hdr_crypt_process)
{
(Arg::Gds(isc_cp_process_active)).raise();
}
bool headerCryptState = hdr->hdr_flags & Ods::hdr_encrypted;
if (headerCryptState == newCryptState)
{
(Arg::Gds(isc_cp_already_crypted)).raise();
}
fb_assert(stateLock);
// Take exclusive stateLock
bool ret = needLock ? LCK_lock(tdbb, stateLock, LCK_PW, LCK_WAIT) :
LCK_convert(tdbb, stateLock, LCK_PW, LCK_WAIT);
if (!ret)
{
fb_assert(tdbb->tdbb_status_vector[1]);
ERR_punt();
}
fb_utils::init_status(tdbb->tdbb_status_vector);
needLock = false;
// Load plugin
if (newCryptState)
{
loadPlugin(plugName.c_str());
}
crypt = newCryptState;
// Write modified header page
Ods::header_page* header = hdr.write();
if (crypt)
{
header->hdr_flags |= Ods::hdr_encrypted;
plugName.copyTo(header->hdr_crypt_plugin, sizeof header->hdr_crypt_plugin);
}
else
{
header->hdr_flags &= ~Ods::hdr_encrypted;
}
header->hdr_flags |= Ods::hdr_crypt_process;
process = true;
}
// Trigger lock on ChangeCryptState
if (!LCK_convert(tdbb, stateLock, LCK_EX, LCK_WAIT))
{
ERR_punt();
}
if (!LCK_convert(tdbb, stateLock, LCK_SR, LCK_WAIT))
{
ERR_punt();
}
fb_utils::init_status(tdbb->tdbb_status_vector);
// Now we may set hdr_crypt_page for crypt thread
{ // window scope
Header hdr(tdbb, LCK_write);
Ods::header_page* header = hdr.write();
header->hdr_crypt_page = 1;
}
startCryptThread(tdbb);
}