本文整理汇总了C++中Sql::dbConnect方法的典型用法代码示例。如果您正苦于以下问题:C++ Sql::dbConnect方法的具体用法?C++ Sql::dbConnect怎么用?C++ Sql::dbConnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql::dbConnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threadHandler
void threadHandler(char driveLtr)
{
/* Lock the mutex so we don't try and access the database at the same time */
gMutex.lock();
bool authorized = false;
/* Lock the USB drive */
UsbOps ops;
ops.lockUSB(driveLtr);
/* Query authorized devices */
Sql sql;
if (!sql.dbConnect((char*)Paths::getDatabasePath().c_str(), false))
{
ErrorLog::logErrorToFile("*CRITICAL*", "Unable to open authorized drives database!");
ops.ejectUSB();
gMutex.unlock();
return;
}
std::vector<authedDrive> drvs;
sql.queryAuthedDrives(&drvs);
/* Get the serial key of the device */
UsbKey usbKey;
UsbKeyhdr hdr;
ops.unlockUSB();
usbKey.getUsbKeyHdr(&hdr, driveLtr);
ops.lockUSB(driveLtr);
/* Check if the serial exists in the database */
for (std::vector<authedDrive>::iterator it = drvs.begin(); it != drvs.end(); it++)
{
std::cout << it->serial.c_str() << " " << hdr.serialkey.c_str() << std::endl;
if (it->serial.compare(hdr.serialkey) == 0)
{
authorized = true;
break;
}
}
ops.unlockUSB();
/* Log media insertion event */
AccessLog *log = new AccessLog();
log->createLogStruct(&log->logUSBStruct, driveLtr, (char*)hdr.serialkey.c_str());
log->logUSBStruct.accepted = authorized;
/* Get config settings, check if remote SQL is enabled */
ConfigParser configParser((char*)Paths::getConfigPath().c_str());
if (configParser.getValue("SQLenabled") == "1")
{
/* SQL enabled = true */
log->logUsbDrive(log->logUSBStruct, true);
}
else
log->logUsbDrive(log->logUSBStruct, false);
/* If not authorized, eject it! */
if (!authorized)
{
ops.lockUSB(driveLtr);
ops.ejectUSB();
}
/* Check for viruses here... */
gMutex.unlock();
delete log;
}