本文整理汇总了C++中OT_API::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ OT_API::Init方法的具体用法?C++ OT_API::Init怎么用?C++ OT_API::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OT_API
的用法示例。
在下文中一共展示了OT_API::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OT_API_Init
// To use this extern "C" API, you must call this function first.
// (Therefore the same is true for all scripting languages that use this file...
// Ruby, Python, Perl, PHP, etc.)
OT_BOOL OT_API_Init(const char * szClientPath)
{
OT_ASSERT(NULL != szClientPath);
static bool bAlreadyInitialized = false;
if (!bAlreadyInitialized)
{
bAlreadyInitialized = true;
if (OT_API::InitOTAPI())
{
OTString strClientPath(szClientPath);
bool bInit = g_OT_API.Init(strClientPath); // SSL gets initialized in here, before any keys are loaded.
if (bInit)
return OT_TRUE;
}
}
return OT_FALSE;
}
示例2: main
int main (int argc, char **argv)
{
OTLog::vOutput(0, "\n\nWelcome to Open Transactions... Test Client -- version %s\n"
"(transport build: OTMessage -> TCP -> SSL)\n"
"IF YOU PREFER TO USE ZMQ (message based), then rebuild from main folder like this:\n"
"cd ..; make clean; make\n\n",
OTLog::Version());
OT_API::InitOTAPI();
// -----------------------------------------------------------------------
// The beginnings of an INI file!!
OTString strPath;
{
CSimpleIniA ini; // We're assuming this file is on the path.
SI_Error rc = ini.LoadFile("./.ot_ini"); // todo: stop hardcoding.
if (rc >=0)
{
const char * pVal = ini.GetValue("paths", "client_path", SERVER_PATH_DEFAULT); // todo stop hardcoding.
if (NULL != pVal)
strPath.Set(pVal);
else
strPath.Set(SERVER_PATH_DEFAULT);
}
else
{
strPath.Set(SERVER_PATH_DEFAULT);
}
}
// -----------------------------------------------------------------------
OTString strCAFile, strKeyFile, strSSLPassword;
if (argc < 2)
{
OTLog::vOutput(0, "\n==> USAGE: %s <SSL-password> <absolute_path_to_data_folder>\n\n"
#if defined (FELLOW_TRAVELER)
"(Password defaults to '%s' if left blank.)\n"
"(Folder defaults to '%s' if left blank.)\n"
#else
"(The test password is always 'test'.\n'cd data_folder' then 'pwd' to see the absolute path.)\n"
#endif
"\n\n", argv[0]
#if defined (FELLOW_TRAVELER)
, KEY_PASSWORD,
strPath.Get()
#endif
);
#if defined (FELLOW_TRAVELER)
strSSLPassword.Set(KEY_PASSWORD);
OTString strClientPath(strPath.Get());
g_OT_API.Init(strClientPath); // SSL gets initialized in here, before any keys are loaded.
#else
exit(1);
#endif
}
else if (argc < 3)
{
OTLog::vOutput(0, "\n==> USAGE: %s <SSL-password> <absolute_path_to_data_folder>\n\n"
#if defined (FELLOW_TRAVELER)
"(Folder defaults to '%s' if left blank.)\n"
#endif
"\n\n", argv[0]
#if defined (FELLOW_TRAVELER)
, strPath.Get()
#endif
);
#if defined (FELLOW_TRAVELER)
strSSLPassword.Set(argv[1]);
OTString strClientPath(strPath.Get());
g_OT_API.Init(strClientPath); // SSL gets initialized in here, before any keys are loaded.
#else
exit(1);
#endif
}
else
{
strSSLPassword.Set(argv[1]);
OTString strClientPath(argv[2]);
g_OT_API.Init(strClientPath); // SSL gets initialized in here, before any keys are loaded.
}
OTLog::vOutput::(0, "Using as path to data folder: %s\n", OTLog::Path());
strCAFile. Format("%s%s%s", OTLog::Path(), OTLog::PathSeparator(), CA_FILE);
strKeyFile.Format("%s%s%s", OTLog::Path(), OTLog::PathSeparator(), KEY_FILE);
// ------------------------------------------------------------------------------
//
//.........这里部分代码省略.........