本文整理汇总了C++中OsPath::getNativePath方法的典型用法代码示例。如果您正苦于以下问题:C++ OsPath::getNativePath方法的具体用法?C++ OsPath::getNativePath怎么用?C++ OsPath::getNativePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsPath
的用法示例。
在下文中一共展示了OsPath::getNativePath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPathInfo
void testPathInfo()
{
UtlString testDir = "../../filename.ext";
OsPath testPath = testDir;
UtlString parentPath;
parentPath.append("..").append(OsPath::separator).append("..").append(OsPath::separator);
ASSERT_STR_EQUAL_MESSAGE("Extension", ".ext", testPath.getExt().data());
ASSERT_STR_EQUAL_MESSAGE("Parent Path", parentPath, testPath.getDirName().data());
ASSERT_STR_EQUAL_MESSAGE("Volume", "", testPath.getVolume().data());
ASSERT_STR_EQUAL_MESSAGE("Filename no extension", "filename",
testPath.getFilename().data());
// little risky, may not have permissions, but '../../' is too
// good a test to not try. Refactor if this is bad assumption
OsFile file(testPath);
file.touch();
OsPath nativePath;
testPath.getNativePath(nativePath);
// dont' know what's right, but know whats wrong
CPPUNIT_ASSERT_MESSAGE("Resolved relative path", !nativePath.contains(".."));
//printf("Native path is %s\n", nativePath.data());
file.remove();
}
示例2: getSipConfigServerAgent
SipConfigServerAgent* SipConfigServerAgent::getSipConfigServerAgent()
{
UtlBoolean isStarted ;
// If the task object already exists, and the corresponding low-level task
// has been started, then use it
if (spInstance != NULL && spInstance->isStarted())
return spInstance;
// If the task does not yet exist or hasn't been started, then acquire
// the lock to ensure that only one instance of the task is started
sLock.acquire();
if (spInstance == NULL)
{
OsPath workingDirectory ;
if ( OsFileSystem::exists( CONFIG_ETC_DIR ) )
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString ConfigfileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE ;
// Initialize the OsSysLog
OsConfigDb configDb ;
configDb.loadFromFile(ConfigfileName) ;
initializeLog(&configDb) ;
spInstance = startAgents(ConfigfileName);
}
isStarted = spInstance->isStarted();
if (!isStarted)
{
isStarted = spInstance->start();
// assert(isStarted);
}
sLock.release();
return spInstance;
}
示例3: path
StatusServer*
StatusServer::getInstance()
{
// crit sec, ensure only one instance starts the status server
sLock.acquire();
if ( spInstance == NULL )
{
OsPath workingDirectory;
if ( OsFileSystem::exists( CONFIG_ETC_DIR ) )
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
"status-config";
spInstance = startStatusServer(
workingDirectory,
fileName );
}
// If the task object already exists, and the corresponding low-level task
// has been started, then use it
if ( !spInstance->isStarted() )
{
UtlBoolean isStarted = spInstance->start();
assert(isStarted);
}
// release the critsec
sLock.release();
return spInstance;
}
示例4: mLock
// Old Constructor
XmlRpcDispatch::XmlRpcDispatch(int httpServerPort,
bool isSecureServer,
const char* uriPath,
const char* bindIp)
: mLock(OsBSem::Q_PRIORITY, OsBSem::FULL)
, mManageHttpServer(true)
{
UtlString osBaseUriDirectory ;
OsPath workingDirectory;
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
osBaseUriDirectory = workingDirectory + OsPathBase::separator;
// Create a HTTPS Server
OsServerSocket* pServerSocket = NULL;
if (isSecureServer)
{
pServerSocket = new OsSSLServerSocket(50, httpServerPort, bindIp);
}
else
{
pServerSocket = new OsServerSocket(50, httpServerPort, bindIp);
}
mpHttpServer = new HttpServer(pServerSocket,
NULL, // no valid ip address list
true // use persistent http connections
);
mpHttpServer->start();
// Add the XmlRpcDispatch to the HttpServer
mpHttpServer->addHttpService(uriPath, (HttpService*)this);
}
示例5: main
//
// The main entry point to the sipXpark
//
int main(int argc, char* argv[])
{
// Block all signals in this the main thread.
// Any threads created from now on will have all signals masked.
OsTask::blockSignals();
// Create a new task to wait for signals. Only that task
// will ever see a signal from the outside.
SignalTask* signalTask = new SignalTask();
signalTask->start();
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
UtlString argString;
for(int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if(argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPX_VERSION, SIPX_BUILD);
return(1);
} else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return(1);
}
}
// Load configuration file file
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
} else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int UdpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, UdpPort) != OS_SUCCESS)
UdpPort = PARK_DEFAULT_UDP_PORT;
int TcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, TcpPort) != OS_SUCCESS)
TcpPort = PARK_DEFAULT_TCP_PORT;
int RtpBase;
if (configDb.get(CONFIG_SETTING_RTP_PORT, RtpBase) != OS_SUCCESS)
RtpBase = DEFAULT_RTP_PORT;
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
bindIp = PARK_DEFAULT_BIND_IP;
int MaxSessions;
if (configDb.get(CONFIG_SETTING_MAX_SESSIONS, MaxSessions) != OS_SUCCESS)
{
MaxSessions = DEFAULT_MAX_SESSIONS;
}
UtlBoolean OneButtonBLF =
configDb.getBoolean(CONFIG_SETTING_ONE_BUTTON_BLF, DEFAULT_ONE_BUTTON_BLF);
UtlString domain;
UtlString realm;
UtlString user;
SipLine* line = NULL;
SipLineMgr* lineMgr = NULL;
OsConfigDb domainConfiguration;
OsPath domainConfigPath = SipXecsService::domainConfigPath();
if (OS_SUCCESS == domainConfiguration.loadFromFile(domainConfigPath.data()))
{
//.........这里部分代码省略.........
示例6: initSysLog
// Initialize the OsSysLog
void initSysLog(OsConfigDb* pConfig)
{
UtlString logLevel; // Controls Log Verbosity
UtlString consoleLogging; // Enable console logging by default?
UtlString fileTarget; // Path to store log file.
UtlBoolean bSpecifiedDirError ; // Set if the specified log dir does not
// exist
OsSysLog::initialize(0, "sipxpark");
OsSysLog::add(FAC_SIP, PRI_INFO, ">>>>>>>>>>>>>>>> Starting - version %s build %s",
SIPX_VERSION, SIPX_BUILD
);
//
// Get/Apply Log Filename
//
fileTarget.remove(0);
if ((pConfig->get(CONFIG_SETTING_LOG_DIR, fileTarget) != OS_SUCCESS) ||
fileTarget.isNull() || !OsFileSystem::exists(fileTarget))
{
bSpecifiedDirError = !fileTarget.isNull();
// If the log file directory exists use that, otherwise place the log
// in the current directory
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_LOG_DIR))
{
fileTarget = CONFIG_LOG_DIR;
OsPath path(fileTarget);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
}
fileTarget = workingDirectory +
OsPathBase::separator +
CONFIG_LOG_FILE;
}
else
{
bSpecifiedDirError = false;
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, fileTarget.data());
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, fileTarget.data());
fileTarget = fileTarget +
OsPathBase::separator +
CONFIG_LOG_FILE;
}
OsSysLog::setOutputFile(0, fileTarget);
//
// Get/Apply Log Level
//
SipXecsService::setLogPriority(*pConfig, CONFIG_SETTING_PREFIX, PRI_ERR);
OsSysLog::setLoggingPriorityForFacility(FAC_SIP_INCOMING_PARSED, PRI_ERR);
//
// Get/Apply console logging
//
UtlBoolean bConsoleLoggingEnabled = false;
if ((pConfig->get(CONFIG_SETTING_LOG_CONSOLE, consoleLogging) == OS_SUCCESS))
{
consoleLogging.toUpper();
if (consoleLogging == "ENABLE")
{
OsSysLog::enableConsoleOutput(true);
bConsoleLoggingEnabled = true;
}
}
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_CONSOLE, bConsoleLoggingEnabled ? "ENABLE" : "DISABLE") ;
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_CONSOLE, bConsoleLoggingEnabled ? "ENABLE" : "DISABLE") ;
if (bSpecifiedDirError)
{
OsSysLog::add(FAC_LOG, PRI_CRIT, "Cannot access %s directory; please check configuration.", CONFIG_SETTING_LOG_DIR);
}
}
示例7: initSysLog
/**
* Description:
* closes any open connections to the IMDB safely using a mutex lock
*/
void initSysLog(OsConfigDb* pConfig)
{
UtlString consoleLogging; // Enable console logging by default?
UtlString fileTarget; // Path to store log file.
UtlBoolean bSpecifiedDirError ; // Set if the specified log dir does not
// exist
Os::LoggerHelper::instance().processName = "SipXProxy";
//
// Get/Apply Log Filename
//
if ((pConfig->get(CONFIG_SETTING_LOG_DIR, fileTarget) != OS_SUCCESS) ||
fileTarget.isNull() || !OsFileSystem::exists(fileTarget))
{
bSpecifiedDirError = !fileTarget.isNull() ;
// If the log file directory exists use that, otherwise place the log
// in the current directory
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_LOG_DIR))
{
fileTarget = CONFIG_LOG_DIR;
OsPath path(fileTarget);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
}
fileTarget = workingDirectory + OsPathBase::separator + SIPX_PROXY_LOG_FILE;
}
else
{
bSpecifiedDirError = false ;
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, fileTarget.data()) ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, fileTarget.data()) ;
fileTarget = fileTarget +
OsPathBase::separator +
SIPX_PROXY_LOG_FILE;
}
//
// Get/Apply Log Level
//
SipXecsService::setLogPriority( CONFIG_SETTINGS_FILE, PROXY_CONFIG_PREFIX );
Os::Logger::instance().setLoggingPriorityForFacility(FAC_SIP_INCOMING_PARSED, PRI_ERR);
Os::LoggerHelper::instance().initialize(fileTarget.data());
//
// Get/Apply console logging
//
UtlBoolean bConsoleLoggingEnabled = false ;
if ((pConfig->get(CONFIG_SETTING_LOG_CONSOLE, consoleLogging) ==
OS_SUCCESS))
{
consoleLogging.toUpper();
if (consoleLogging == "ENABLE")
{
Os::Logger::instance().enableConsoleOutput(true);
bConsoleLoggingEnabled = true ;
}
}
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_CONSOLE, bConsoleLoggingEnabled ? "ENABLE" : "DISABLE") ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s",
CONFIG_SETTING_LOG_CONSOLE, bConsoleLoggingEnabled ? "ENABLE" : "DISABLE") ;
if (bSpecifiedDirError)
{
Os::Logger::instance().log(FAC_LOG, PRI_CRIT,
"Cannot access %s directory; please check configuration.",
CONFIG_SETTING_LOG_DIR);
}
}
示例8: main
//
// The main entry point to sipXrls.
//
int main(int argc, char* argv[])
{
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
UtlString argString;
for (int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if (argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", VERSION, PACKAGE_REVISION);
return 1;
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return 1;
}
}
// Load configuration file.
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
fprintf(stderr, "Failed to load config DB from file '%s'",
fileName.data());
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int udpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, udpPort) != OS_SUCCESS)
{
udpPort = RLS_DEFAULT_UDP_PORT;
}
int tcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, tcpPort) != OS_SUCCESS)
{
tcpPort = RLS_DEFAULT_TCP_PORT;
}
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
bindIp = RLS_DEFAULT_BIND_IP;
UtlString resourceListFile;
if ((configDb.get(CONFIG_SETTING_RLS_FILE, resourceListFile) !=
OS_SUCCESS) ||
resourceListFile.isNull())
{
Os::Logger::instance().log(LOG_FACILITY, PRI_CRIT,
"Resource list file name is not configured");
return 1;
}
UtlString domainName;
if ((configDb.get(CONFIG_SETTING_DOMAIN_NAME, domainName) !=
OS_SUCCESS) ||
domainName.isNull())
{
Os::Logger::instance().log(LOG_FACILITY, PRI_CRIT,
"Resource domain name is not configured");
return 1;
}
UtlString realm;
if ((configDb.get(CONFIG_SETTING_AUTHENTICATE_REALM, realm) !=
OS_SUCCESS) ||
realm.isNull())
{
Os::Logger::instance().log(LOG_FACILITY, PRI_CRIT,
//.........这里部分代码省略.........
示例9: main
//
// The main entry point to the sipXpark
//
int main(int argc, char* argv[])
{
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
// Register Signal handlers so we can perform graceful shutdown
pt_signal(SIGINT, sigHandler); // Trap Ctrl-C on NT
pt_signal(SIGILL, sigHandler);
pt_signal(SIGABRT, sigHandler); // Abort signal 6
pt_signal(SIGFPE, sigHandler); // Floading Point Exception
pt_signal(SIGSEGV, sigHandler); // Address access violations signal 11
pt_signal(SIGTERM, sigHandler); // Trap kill -15 on UNIX
#if defined(__pingtel_on_posix__)
pt_signal(SIGHUP, sigHandler); // Hangup
pt_signal(SIGQUIT, sigHandler);
pt_signal(SIGPIPE, SIG_IGN); // Handle TCP Failure
pt_signal(SIGBUS, sigHandler);
pt_signal(SIGSYS, sigHandler);
pt_signal(SIGXCPU, sigHandler);
pt_signal(SIGXFSZ, sigHandler);
pt_signal(SIGUSR1, sigHandler);
pt_signal(SIGUSR2, sigHandler);
#endif
UtlString argString;
for (int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if(argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPXCHANGE_VERSION, SIPXCHANGE_VERSION_COMMENT);
return(1);
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return(1);
}
}
// Load configuration file file
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int UdpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, UdpPort) != OS_SUCCESS)
{
UdpPort = DEFAULT_UDP_PORT;
}
int TcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, TcpPort) != OS_SUCCESS)
{
TcpPort = DEFAULT_TCP_PORT;
}
int HttpPort;
if (configDb.get(CONFIG_SETTING_HTTP_PORT, HttpPort) != OS_SUCCESS)
{
HttpPort = DEFAULT_HTTP_PORT;
}
// Bind the SIP user agent to a port and start it up
SipUserAgent* userAgent = new SipUserAgent(TcpPort, UdpPort);
userAgent->start();
UtlString domainName;
configDb.get(CONFIG_SETTING_DOMAIN_NAME, domainName);
int refreshTimeout;
//.........这里部分代码省略.........
示例10: initSysLog
// Initialize the OsSysLog
void initSysLog(OsConfigDb* pConfig)
{
UtlString logLevel; // Controls Log Verbosity
UtlString consoleLogging; // Enable console logging by default?
UtlString fileTarget; // Path to store log file.
UtlBoolean bSpecifiedDirError ; // Set if the specified log dir does not
// exist
struct tagPrioriotyLookupTable
{
const char* pIdentity;
OsSysLogPriority ePriority;
};
struct tagPrioriotyLookupTable lkupTable[] =
{
{ "DEBUG", PRI_DEBUG},
{ "INFO", PRI_INFO},
{ "NOTICE", PRI_NOTICE},
{ "WARNING", PRI_WARNING},
{ "ERR", PRI_ERR},
{ "CRIT", PRI_CRIT},
{ "ALERT", PRI_ALERT},
{ "EMERG", PRI_EMERG},
};
OsSysLog::initialize(0, "sipxdialog");
//
// Get/Apply Log Filename
//
fileTarget.remove(0);
if ((pConfig->get(CONFIG_SETTING_LOG_DIR, fileTarget) != OS_SUCCESS) ||
fileTarget.isNull() || !OsFileSystem::exists(fileTarget))
{
bSpecifiedDirError = !fileTarget.isNull();
// If the log file directory exists use that, otherwise place the log
// in the current directory
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_LOG_DIR))
{
fileTarget = CONFIG_LOG_DIR;
OsPath path(fileTarget);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data());
}
fileTarget = workingDirectory +
OsPathBase::separator +
CONFIG_LOG_FILE;
}
else
{
bSpecifiedDirError = false;
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, fileTarget.data());
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, fileTarget.data());
fileTarget = fileTarget +
OsPathBase::separator +
CONFIG_LOG_FILE;
}
OsSysLog::setOutputFile(0, fileTarget);
//
// Get/Apply Log Level
//
if ((pConfig->get(CONFIG_SETTING_LOG_LEVEL, logLevel) != OS_SUCCESS) ||
logLevel.isNull())
{
logLevel = "ERR";
}
logLevel.toUpper();
OsSysLogPriority priority = PRI_ERR;
int iEntries = sizeof(lkupTable) / sizeof(struct tagPrioriotyLookupTable);
for (int i = 0; i < iEntries; i++)
{
if (logLevel == lkupTable[i].pIdentity)
{
priority = lkupTable[i].ePriority;
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_LEVEL, lkupTable[i].pIdentity);
OsSysLog::add(LOG_FACILITY, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_LEVEL, lkupTable[i].pIdentity);
break;
}
}
OsSysLog::setLoggingPriority(priority);
OsSysLog::setLoggingPriorityForFacility(FAC_SIP_INCOMING_PARSED, PRI_ERR);
//.........这里部分代码省略.........
示例11: main
//
// The main entry point to the sipXpark
//
int main(int argc, char* argv[])
{
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
// Register Signal handlers so we can perform graceful shutdown
pt_signal(SIGINT, sigHandler); // Trap Ctrl-C on NT
pt_signal(SIGILL, sigHandler);
pt_signal(SIGABRT, sigHandler); // Abort signal 6
pt_signal(SIGFPE, sigHandler); // Floading Point Exception
pt_signal(SIGSEGV, sigHandler); // Address access violations signal 11
pt_signal(SIGTERM, sigHandler); // Trap kill -15 on UNIX
#if defined(__pingtel_on_posix__)
pt_signal(SIGHUP, sigHandler); // Hangup
pt_signal(SIGQUIT, sigHandler);
pt_signal(SIGPIPE, SIG_IGN); // Handle TCP Failure
pt_signal(SIGBUS, sigHandler);
pt_signal(SIGSYS, sigHandler);
pt_signal(SIGXCPU, sigHandler);
pt_signal(SIGXFSZ, sigHandler);
pt_signal(SIGUSR1, sigHandler);
pt_signal(SIGUSR2, sigHandler);
#endif
UtlString argString;
for(int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if(argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPXCHANGE_VERSION, SIPXCHANGE_VERSION_COMMENT);
return(1);
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return(1);
}
}
// Load configuration file file
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int UdpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, UdpPort) != OS_SUCCESS)
{
UdpPort = PRESENCE_DEFAULT_UDP_PORT;
}
int TcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, TcpPort) != OS_SUCCESS)
{
TcpPort = PRESENCE_DEFAULT_TCP_PORT;
}
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
{
bindIp = PRESENCE_DEFAULT_BIND_IP;
}
// Bind the SIP user agent to a port and start it up
SipUserAgent* userAgent = new SipUserAgent(TcpPort, UdpPort, PORT_NONE,
NULL, NULL, bindIp );
userAgent->start();
if (!userAgent->isOk())
{
//.........这里部分代码省略.........
示例12: main
//
// The main entry point to sipXsaa.
//
int main(int argc, char* argv[])
{
// Block all signals in this the main thread.
// Any threads created from now on will have all signals masked.
OsTask::blockSignals();
// Create a new task to wait for signals. Only that task
// will ever see a signal from the outside.
SignalTask* signalTask = new SignalTask();
signalTask->start();
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
UtlString argString;
for (int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if (argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPXCHANGE_VERSION,
SIPXCHANGE_VERSION_COMMENT);
return 1;
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return 1;
}
}
// Load configuration file.
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int udpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, udpPort) != OS_SUCCESS)
{
udpPort = SAA_DEFAULT_UDP_PORT;
}
int tcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, tcpPort) != OS_SUCCESS)
{
tcpPort = SAA_DEFAULT_TCP_PORT;
}
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
bindIp = SAA_DEFAULT_BIND_IP;
UtlString appearanceGroupFile;
if ((configDb.get(CONFIG_SETTING_SAA_FILE, appearanceGroupFile) !=
OS_SUCCESS) ||
appearanceGroupFile.isNull())
{
OsSysLog::add(LOG_FACILITY, PRI_CRIT,
"Appearance group file name is not configured");
return 1;
}
UtlString domainName;
if ((configDb.get(CONFIG_SETTING_DOMAIN_NAME, domainName) !=
OS_SUCCESS) ||
domainName.isNull())
{
OsSysLog::add(LOG_FACILITY, PRI_CRIT,
"Resource domain name is not configured");
//.........这里部分代码省略.........
示例13: if
/** The main entry point to the StatusServer */
int
main(int argc, char* argv[] )
{
OsConfigDb configDb ; // Params for OsSysLog init
UtlBoolean interactiveSet = false;
UtlString argString;
for(int argIndex = 1; argIndex < argc; argIndex++)
{
Os::Logger::instance().log(LOG_FACILITY, PRI_INFO, "arg[%d]: %s\n", argIndex, argv[argIndex]) ;
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if(argString.compareTo("-v") == 0)
{
Os::Logger::instance().log(LOG_FACILITY, PRI_INFO, "Version: %s %s\n", VERSION, PACKAGE_REVISION);
return(1);
}
else if( argString.compareTo("-i") == 0)
{
interactiveSet = true;
Os::Logger::instance().log(LOG_FACILITY, PRI_INFO, "Entering Interactive Mode\n");
}
else
{
Os::Logger::instance().log(LOG_FACILITY, PRI_INFO, "usage: %s [-v] [-i]\nwhere:\n -v provides the software version\n"
" -i start the server in an interactive made\n",
argv[0]);
return(1);
}
}
// initialize log file
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
initSysLog(&configDb) ;
// Fetch Pointer to the OsServer task object, note that
// object uses the IMDB so it is important to shut this thread
// cleanly before the signal handler exits
StatusServer* pStatusServer = StatusServer::getInstance();
pServerTask = static_cast<OsServerTask*>(pStatusServer);
// Do not exit, let the proxy do its stuff
while( !Os::UnixSignals::instance().isTerminateSignalReceived() )
{
if( interactiveSet)
{
int charCode = getchar();
if(charCode != '\n' && charCode != '\r')
{
if( charCode == 'e')
{
Os::Logger::instance().enableConsoleOutput(true);
} else if( charCode == 'd')
{
Os::Logger::instance().enableConsoleOutput(false);
} else
{
// pStatusServer->printMessageLog();
}
}
} else
{
OsTask::delay(2000);
}
}
// Remove the current process's row from the IMDB
// Persisting the database if necessary
cout << "Cleaning Up..Start." << endl;
// This is a server task so gracefully shutdown the
// server task using the waitForShutdown method, this
// will implicitly request a shutdown for us if one is
// not already in progress
if ( pServerTask != NULL )
{
//.........这里部分代码省略.........