MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / WriteConfigText

Method WriteConfigText

src/tw/twutil.cpp:527–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525// eSerializer is thrown if reading or writing fails
526
527void cTWUtil::WriteConfigText(const TCHAR* filename,
528 const TSTRING configText,
529 bool bEncrypt,
530 const cElGamalSigPrivateKey* pPrivateKey)
531{
532 cSerializableNString nstring;
533
534 nstring.mString = CONFIG_FILE_MAGIC_8BYTE;
535
536 std::string ns;
537 cStringUtil::Convert(ns, configText);
538 nstring.mString += ns;
539
540 cFileHeader fileHeader;
541 fileHeader.SetID(cConfigFile::GetFileHeaderID());
542
543 fileHeader.SetVersion(CURRENT_FIXED_VERSION);
544
545 if (bEncrypt)
546 {
547 ASSERT(pPrivateKey != 0);
548 cElGamalSigPublicKey publicKey(*pPrivateKey);
549 fileHeader.GetBaggage().MapArchive(0, publicKey.GetWriteLen());
550 publicKey.Write(fileHeader.GetBaggage().GetMap());
551 }
552
553 WriteObject(filename, NULL, nstring, fileHeader, bEncrypt, pPrivateKey);
554
555 iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL,
556 _T("%s%s\n"),
557 TSS_GetString(cTW, tw::STR_WRITE_CONFIG_FILE).c_str(),
558 cDisplayEncoder::EncodeInline(filename).c_str());
559}
560
561
562///////////////////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 10

ConvertFunction · 0.85
WriteObjectFunction · 0.85
SetVersionMethod · 0.80
MapArchiveMethod · 0.80
GetMapMethod · 0.80
NotifyMethod · 0.80
c_strMethod · 0.80
SetIDMethod · 0.45
GetWriteLenMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected