Esempio n. 1
0
void tst_QBluetoothServiceInfo::tst_construction()
{
    const QString serviceName("My Service");
    const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);

    {
        QBluetoothServiceInfo serviceInfo;

        QVERIFY(!serviceInfo.isValid());
        QVERIFY(!serviceInfo.isComplete());
    }

    {
        QBluetoothServiceInfo serviceInfo;
        serviceInfo.setServiceName(serviceName);
        serviceInfo.setDevice(deviceInfo);

        QVERIFY(serviceInfo.isValid());

        QCOMPARE(serviceInfo.serviceName(), serviceName);
        QCOMPARE(serviceInfo.device().address(), deviceInfo.address());

        QBluetoothServiceInfo copyInfo(serviceInfo);

        QVERIFY(copyInfo.isValid());

        QCOMPARE(copyInfo.serviceName(), serviceName);
        QCOMPARE(copyInfo.device().address(), deviceInfo.address());
    }
}
Esempio n. 2
0
int main (int argc, char * argv[]) {
header *head;
DIR * dircurr;
struct dirent *curr_dir;
struct stat curr_st;
int outFile, inFile;
    if(argc < 3) {
        perror("Usage");
        exit(1);
    }
    if((inFile = open(argv[2], O_RDONLY, S_IRUSR | S_IWUSR)) < 0) {
        perror("bad inFile");
        exit(1);
    }

    dircurr = opendir(".");
    curr_dir = readdir(dircurr);
    stat(curr_dir->d_name, &curr_st);
    while((head = readHeader(inFile, &outFile))) {
        if(!head->size) {
            chdir(head->name);
            continue;
        }
        

        copyInfo(((head->size/512)+1), inFile, outFile);
        close(outFile);
        free(head);
    }
    close(inFile);
    close(outFile);

    return 0;
}
Esempio n. 3
0
void ArchiveMailInfoTest::shouldCopyArchiveInfo()
{
    ArchiveMailInfo info;
    info.setSaveCollectionId(Akonadi::Collection::Id(42));
    info.setUrl(QUrl::fromLocalFile(QStringLiteral("/foo/foo")));
    info.setArchiveType(MailCommon::BackupJob::TarBz2);
    info.setArchiveUnit(ArchiveMailInfo::ArchiveMonths);
    info.setArchiveAge(5);
    info.setLastDateSaved(QDate::currentDate());
    info.setMaximumArchiveCount(5);
    info.setEnabled(false);

    ArchiveMailInfo copyInfo(info);
    QCOMPARE(info, copyInfo);
}
void tst_QBluetoothDeviceInfo::tst_construction()
{
    {
        QBluetoothDeviceInfo deviceInfo;

        QVERIFY(!deviceInfo.isValid());
    }

    {
        QFETCH(QBluetoothAddress, address);
        QFETCH(QString, name);
        QFETCH(quint32, classOfDevice);
        QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
        QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
        QFETCH(quint8, minorDeviceClass);              

        QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);

        QVERIFY(deviceInfo.isValid());

        QCOMPARE(deviceInfo.address(), address);
        QCOMPARE(deviceInfo.name(), name);
        QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
        QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
        QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);

        QBluetoothDeviceInfo copyInfo(deviceInfo);

        QVERIFY(copyInfo.isValid());

        QCOMPARE(copyInfo.address(), address);
        QCOMPARE(copyInfo.name(), name);
        QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
        QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
        QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
    }
}
Esempio n. 5
0
void DbPdiskInfo::getResult(SQLHSTMT sqlStmt,void** holder)
{
    SQLRETURN ret;
    *holder = new vector<tlgpfs_pdisk_info_t*>;
    vector<tlgpfs_pdisk_info_t*>* status = (vector<tlgpfs_pdisk_info_t*>*)* holder;
    tlgpfs_pdisk_info_t* tmp = allocateMemory();


    SQLLEN clusterIdLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 1, SQL_C_CHAR, tmp->cluster_id, CLUSTER_ID_SIZE, &clusterIdLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 1 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN rgNameLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 2, SQL_C_CHAR, tmp->rg_name, RG_NAME_SIZE, &rgNameLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 2 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN daNameLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 3, SQL_C_CHAR, tmp->da_name, DA_NAME_SIZE, &daNameLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 3 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN pdiskNameLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 4, SQL_C_CHAR, tmp->pdisk_name, PDISK_NAME_SIZE, &pdiskNameLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 4 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN pdiskDevPathLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 5, SQL_C_CHAR, tmp->pdisk_dev_path, PDISK_DEV_PATH_SIZE, &pdiskDevPathLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 5 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN pdiskStateLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 6, SQL_C_CHAR, tmp->pdisk_state, PDISK_STATE_SIZE, &pdiskStateLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 6 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN pdiskFruLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 7, SQL_C_CHAR, tmp->pdisk_fru, PDISK_FRU_SIZE, &pdiskFruLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 7 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN pdiskLocationLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 8, SQL_C_CHAR, tmp->pdisk_location, PDISK_LOCATION_SIZE, &pdiskLocationLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 8 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN pdiskReplPriorLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 9, SQL_C_SLONG, tmp->pdisk_repl_prior, 0, &pdiskReplPriorLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 9 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN pdiskFreeSpaceLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 10, SQL_C_UBIGINT, tmp->pdisk_free_space, 0, &pdiskFreeSpaceLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 10 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN changeLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 11, SQL_C_SLONG, tmp->change, 0, &changeLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 11 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN healthLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 12, SQL_C_SLONG, tmp->health, 0, &healthLen);
    DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLBindCol 12 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    ret = DbInterface::dbModule.SQLFetch(sqlStmt);
    if(ret != SQL_NO_DATA)//don't roll back even if empty row.
        DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLFetch",ret,sqlStmt,SQL_HANDLE_STMT);

    while((ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO))
    {

        tlgpfs_pdisk_info_t* temp = allocateMemory();
        copyInfo(temp,tmp);
        status->push_back(temp);
        resetMemory(tmp);
        ret = DbInterface::dbModule.SQLFetch(sqlStmt);
        if(ret != SQL_NO_DATA)//don't roll back even if empty row.
            DbInterface::checkSqlRetcode("DbPdiskInfo::getResult SQLFetch",ret,sqlStmt,SQL_HANDLE_STMT);
    }

}
Esempio n. 6
0
bool Server::init(cgicc::Cgicc cgicc) {
    std::cout << "Access-Control-Allow-Origin: \"*\"\r\n";

    serverReceiveImageTime = timestamp_usec();

    //gets the fields of the request
    cgicc::form_iterator fiImage = cgicc.getElement("image");
    cgicc::form_iterator fiScreenWidthPixel = cgicc.getElement("screenWidthPixel");
    cgicc::form_iterator fiScreenHeightPixel = cgicc.getElement("screenHeightPixel");
    cgicc::form_iterator fiNumSnapshot = cgicc.getElement("numSnapshot");
    cgicc::form_iterator fiSnapshotType = cgicc.getElement("snapshotType");
    cgicc::form_iterator fiIsBoundingBox = cgicc.getElement("isBoundingBox");
    //    cgicc::form_iterator fiSeed = cgicc.getElement("seed");
    //    cgicc::form_iterator fiToken = cgicc.getElement("token");
    //    cgicc::form_iterator fiSessionName = cgicc.getElement("sessionName");
    cgicc::form_iterator fiOldIp = cgicc.getElement("ip");
    if (((fiImage != (*cgicc).end()) && (!fiImage->isEmpty()))
            && ((fiScreenWidthPixel != (*cgicc).end()) && (!fiScreenWidthPixel->isEmpty()))
            && ((fiScreenHeightPixel != (*cgicc).end()) && (!fiScreenHeightPixel->isEmpty()))
            && ((fiNumSnapshot != (*cgicc).end()) && (!fiNumSnapshot->isEmpty()))
            && ((fiSnapshotType != (*cgicc).end()) && (!fiSnapshotType->isEmpty()))
            && ((fiIsBoundingBox != (*cgicc).end()) && (!fiIsBoundingBox->isEmpty()))
            //            && ((fiSeed != (*cgicc).end()) && (!fiSeed->isEmpty()))
            //            && ((fiToken != (*cgicc).end()) && (!fiToken->isEmpty()))
            //            && ((fiSessionName != (*cgicc).end()))
            && ((fiOldIp != (*cgicc).end()))
            ) {

        //TODO: if the diff flag is true, use the difference construction of the image
        //      using the rules in the .js file

        std::string stringUrlImage = (**fiImage);
        const char * urlImage = stringUrlImage.c_str();

        if (strlen(urlImage) > 4) {
            char * imageDecoded;

            //if the url has not the "data:" in the firsts characters, probably is because isn't decoded
            if (urlImage[4] != ':') {
                imageDecoded = CGI_decode_url(urlImage);
            }
            else {
                imageDecoded = new char[stringUrlImage.size() + 1];
                copy(stringUrlImage.begin(), stringUrlImage.end(), imageDecoded);
                imageDecoded[stringUrlImage.size()] = '\0';
            }

            //find the comma that splits the header of the url image, to the data of the image
            int iPreviousComma = -1;
            int strlenImageDecoded = strlen(imageDecoded);
            for (int i = 0; i < strlenImageDecoded; i++) {
                if (imageDecoded[i] == ',') {
                    iPreviousComma = i + 1;
                    break;
                }
            }

            if (iPreviousComma > -1) {
                //takes the data of the image
                char imageDecodeWithoutContent[strlenImageDecoded - iPreviousComma];
                for (int i = iPreviousComma, j = 0; i < strlenImageDecoded; i++, j++) {
                    imageDecodeWithoutContent[j] = imageDecoded[i];
                }

                //convert the url image in a byte array
                std::vector<BYTE> imageByteArray = base64_decode(imageDecodeWithoutContent);

                //convert the byte array in a Mat
                cv::Mat image = cv::imdecode(imageByteArray, CV_LOAD_IMAGE_COLOR);


                /*SAVE THE IMAGE*/
                long long now = timestamp_usec();
                std::stringstream fileName;
                fileName << "stream/" << now << ".jpeg";
                int i = 0;
                while (fileExists(fileName.str().c_str())) {
                    fileName << "stream/" << now << i << ".jpeg";
                    i++;
                }
                cv::imwrite(fileName.str(), image);

                numSnapshot = atoi((**fiNumSnapshot).c_str());
                snapshotType = (**fiSnapshotType).c_str();
                screenWidthPixel = atoi((**fiScreenWidthPixel).c_str());
                screenHeightPixel = atoi((**fiScreenHeightPixel).c_str());
                isBoundingBox = atoi((**fiIsBoundingBox).c_str());
                //                seed = atoi((**fiSeed).c_str());
                //                token = atoi((**fiSeed).c_str());
                //                sessionName = (**fiSessionName).c_str();
                std::string oldIp = (**fiOldIp).c_str();

                ip = cgicc.getEnvironment().getRemoteAddr();


                //activate those lines to see the print of the code and see the debug in the webservice mode
                //                                saveCookies();
                std::cout << "Content-type:text/html\r\n\r\n";

                createSessionName();

                if (oldIp.compare("") != 0) {
                    if (ip.compare(oldIp) != 0) {
                        if (copyInfo(oldIp, ip) == -1) {
                            //error on copy
                            eraseSessionInfo();
                        }
                        std::stringstream filePath;
                        filePath << "session/" << oldIp << "/";
                        removeDirectoryElements(filePath.str().c_str(), "");
                    }
                }

                readInfo();

                setPreviousFrame(getPersistentImage("frame"));
                setFrame(image);
                setPersistentImage("frame", image);
                setPersistentImage("previousFrame", previousFrame);

                /*GET COOKIES*/

                // get environment variables
                //initCookies(cgicc.getEnvironment().getCookieList());
                //                const cgicc::CgiEnvironment& env = cgicc.getEnvironment();
                //                cgicc::const_cookie_iterator cci;
                //                for(cci = env.getCookieList().begin(); cci != env.getCookieList().end(); cci++) {
                //                    Server::getServer()->setCookie(cci->getName(), cci->getValue());
                //                    //std::cout << "<tr><td>" << cci->getName() << "</td><td>";
                //                    //std::cout << cci->getValue();
                //                    //std::cout << "</td></tr>\n";
                //                }
                //std::cout << "</table><\n";

                //std::cout << "<br/>\n";
                //std::cout << "</body>\n";
                //std::cout << "</html>\n";

                return true;
            }
        }
    }

    return false;
}
void tst_QBluetoothServiceInfo::tst_construction()
{
    const QString serviceName("My Service");
    const QString alternateServiceName("Another ServiceName");
    const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);
    const QBluetoothDeviceInfo alternatedeviceInfo(QBluetoothAddress("554433221100"), "Test Device2", 0);

    QList<QBluetoothUuid::ProtocolUuid> protUuids;
    //list taken from qbluetoothuuid.h
    protUuids << QBluetoothUuid::Sdp;
    protUuids << QBluetoothUuid::Udp;
    protUuids << QBluetoothUuid::Rfcomm;
    protUuids << QBluetoothUuid::Tcp;
    protUuids << QBluetoothUuid::TcsBin;
    protUuids << QBluetoothUuid::TcsAt;
    protUuids << QBluetoothUuid::Att;
    protUuids << QBluetoothUuid::Obex;
    protUuids << QBluetoothUuid::Ip;
    protUuids << QBluetoothUuid::Ftp;
    protUuids << QBluetoothUuid::Http;
    protUuids << QBluetoothUuid::Wsp;
    protUuids << QBluetoothUuid::Bnep;
    protUuids << QBluetoothUuid::Upnp;
    protUuids << QBluetoothUuid::Hidp;
    protUuids << QBluetoothUuid::HardcopyControlChannel;
    protUuids << QBluetoothUuid::HardcopyDataChannel;
    protUuids << QBluetoothUuid::HardcopyNotification;
    protUuids << QBluetoothUuid::Avctp;
    protUuids << QBluetoothUuid::Avdtp;
    protUuids << QBluetoothUuid::Cmtp;
    protUuids << QBluetoothUuid::UdiCPlain;
    protUuids << QBluetoothUuid::McapControlChannel;
    protUuids << QBluetoothUuid::McapDataChannel;
    protUuids << QBluetoothUuid::L2cap;

    {
        QBluetoothServiceInfo serviceInfo;

        QVERIFY(!serviceInfo.isValid());
        QVERIFY(!serviceInfo.isComplete());
        QVERIFY(!serviceInfo.isRegistered());
        QCOMPARE(serviceInfo.serviceName(), QString());
        QCOMPARE(serviceInfo.serviceDescription(), QString());
        QCOMPARE(serviceInfo.serviceProvider(), QString());
        QCOMPARE(serviceInfo.serviceUuid(), QBluetoothUuid());
        QCOMPARE(serviceInfo.serviceClassUuids().count(), 0);
        QCOMPARE(serviceInfo.attributes().count(), 0);
        QCOMPARE(serviceInfo.serverChannel(), -1);
        QCOMPARE(serviceInfo.protocolServiceMultiplexer(), -1);

        foreach (QBluetoothUuid::ProtocolUuid u, protUuids)
            QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0);
    }

    {
        QBluetoothServiceInfo serviceInfo;
        serviceInfo.setServiceName(serviceName);
        serviceInfo.setDevice(deviceInfo);

        QVERIFY(serviceInfo.isValid());
        QVERIFY(!serviceInfo.isComplete());
        QVERIFY(!serviceInfo.isRegistered());

        QCOMPARE(serviceInfo.serviceName(), serviceName);
        QCOMPARE(serviceInfo.device().address(), deviceInfo.address());

        QBluetoothServiceInfo copyInfo(serviceInfo);

        QVERIFY(copyInfo.isValid());
        QVERIFY(!copyInfo.isComplete());
        QVERIFY(!copyInfo.isRegistered());

        QCOMPARE(copyInfo.serviceName(), serviceName);
        QCOMPARE(copyInfo.device().address(), deviceInfo.address());


        copyInfo.setAttribute(QBluetoothServiceInfo::ServiceName, alternateServiceName);
        copyInfo.setDevice(alternatedeviceInfo);
        QCOMPARE(copyInfo.serviceName(), alternateServiceName);
        QCOMPARE(copyInfo.attribute(QBluetoothServiceInfo::ServiceName).toString(), alternateServiceName);
        QCOMPARE(serviceInfo.serviceName(), alternateServiceName);
        QCOMPARE(copyInfo.device().address(), alternatedeviceInfo.address());
        QCOMPARE(serviceInfo.device().address(), alternatedeviceInfo.address());

        foreach (QBluetoothUuid::ProtocolUuid u, protUuids)
            QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0);
        foreach (QBluetoothUuid::ProtocolUuid u, protUuids)
            QCOMPARE(copyInfo.protocolDescriptor(u).count(), 0);
    }
}
Esempio n. 8
0
void DbDiskInfo::getResult(SQLHSTMT sqlStmt,void** holder)
{
    SQLRETURN ret;
    *holder = new vector<tlgpfs_disk_info_t*>;
    vector<tlgpfs_disk_info_t*>* status = (vector<tlgpfs_disk_info_t*>*)* holder;
    tlgpfs_disk_info_t* tmp = allocateMemory();

    SQLLEN clusterIdLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 1, SQL_C_CHAR, tmp->cluster_id, CLUSTER_ID_SIZE, &clusterIdLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 1 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN diskNameLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 2, SQL_C_CHAR, tmp->disk_name, DISK_NAME_SIZE, &diskNameLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 2 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN nodeNameLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 3, SQL_C_CHAR, tmp->node_name, NODE_NAME_SIZE, &nodeNameLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 3 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN statusLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 4, SQL_C_CHAR, tmp->status, STATUS_SIZE, &statusLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 4 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN availabilityLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 5, SQL_C_CHAR, tmp->availability, AVAILABILITY_SIZE, &availabilityLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 5 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN poolNameLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 6, SQL_C_CHAR, tmp->pool_name, POOL_NAME_SIZE, &poolNameLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 6 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN volIdLen = SQL_NTS;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 7, SQL_C_CHAR, tmp->vol_id, VOL_ID_SIZE, &volIdLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 7 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN metaDataLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 8, SQL_C_CHAR, tmp->meta_data, META_DATA_SIZE, &metaDataLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 8 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN dataLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 9, SQL_C_CHAR, tmp->data, DATA_SIZE, &dataLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 9 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN diskWaitLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 10, SQL_C_CHAR, tmp->disk_wait, DISK_WAIT_SIZE, &diskWaitLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 10 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN totalSpaceLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 11, SQL_C_UBIGINT, tmp->total_space, 0, &totalSpaceLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 11 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN fullBlkSpaceLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 12, SQL_C_UBIGINT, tmp->full_blk_space, 0, &fullBlkSpaceLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 12 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN subBlkSpaceLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 13, SQL_C_UBIGINT, tmp->sub_blk_space, 0, &subBlkSpaceLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 13 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN failGroupIdLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 14, SQL_C_SLONG, tmp->fail_group_id, 0, &failGroupIdLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 14 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN isFreeLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 15, SQL_C_SLONG, tmp->is_free, 0, &isFreeLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 15 STMT",ret,sqlStmt,SQL_HANDLE_STMT);
    
    SQLLEN changeLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 16, SQL_C_SLONG, tmp->change, 0, &changeLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 16 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    SQLLEN healthLen = 0;
    ret = DbInterface::dbModule.SQLBindCol(sqlStmt, 17, SQL_C_SLONG, tmp->health, 0, &healthLen);
    DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLBindCol 17 STMT",ret,sqlStmt,SQL_HANDLE_STMT);

    ret = DbInterface::dbModule.SQLFetch(sqlStmt);
    if(ret != SQL_NO_DATA)//don't roll back even if empty row.
        DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLFetch",ret,sqlStmt,SQL_HANDLE_STMT);
    while((ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO))
    {
        
        tlgpfs_disk_info_t* temp = allocateMemory();
        copyInfo(temp,tmp);
        status->push_back(temp);
        resetMemory(tmp);
        ret = DbInterface::dbModule.SQLFetch(sqlStmt);
        if(ret != SQL_NO_DATA)//don't roll back even if empty row.
            DbInterface::checkSqlRetcode("DbDiskInfo::getResult SQLFetch",ret,sqlStmt,SQL_HANDLE_STMT);
    }

}
Esempio n. 9
0
int main(void) {

	int result;

	person * person1;
	person * person2;
	person * person3 = NULL;

	/*Start createPerson Test*/
	printf("\nTesting createPerson function...\n");

	person1 = createPerson();
	printf("person1 pointer value: %p\n", &person1);

	person2 = createPerson();
	printf("person2 pointer value: %p\n", &person2);

	if(&person1 != &person2) {
		printf("Success! pointers are referencing different mem locations. EXPECTED\n\n");
	}
	else {
		printf("Fail... pointers are referencing same mem location.\n\n");
	}
	/*End createPerson Test*/


	/*Start destroyPerson Test*/
	printf("Testing destroyPerson function...\n");
	destroyPerson(person1);
	person1 = NULL;

	printf("person1 deleted... ptr value: %p\n", &person1);
	printf("trying to delete again...\n");

	destroyPerson(person1);
	printf("NOTE: must set the pointer to NULL after using destroyPerson, or program will crash due to invalid pointer\n\n");
	/*End destroyPerson Test*/


	/*Start printPerson Test*/
	printf("Testing printPerson function...\n");

	printf("printing the destroyed person1...\n");
	printPerson(person1);
	
	printf("printing the valid person2...\n");
	printPerson(person2);

	printf("\n");
	/*End printPerson Test*/


	/*Start changeInfo Test*/
	printf("Testing changeInfo function...\n")
;
	printf("Attempting to changeInfo on destroyed person1...\n");
	if(changeInfo(person1, "Justin","Fuerth",25)) {
		printf("Error! person1 is NULL\n");
	}
	else {
		printf("Successfully changed info... something went wrong...\n");
	}

	printf("Attempting to changeInfo on valid person2...\n");
	if(changeInfo(person2, "Justin","Fuerth",25)) {
		printf("Error! person2 is NULL... that's not right\n");
	}
	else {
		printf("Successfully changed info for person2!\n");
	}

	printf("Printing person2 again...\n");
	printPerson(person2);

	printf("\n");
	/*End changeInfo Test*/


	/*recreating person1 for further testing purposes*/
	printf("Creating person1 again and giving it values: Stephen, Fuerth, 62\n\n");
	person1 = createPerson();
	changeInfo(person1, "Stephen", "Fuerth", 62);


	/*Start equalTo Test*/
	printf("Testing the equalTo function...\n");

	printf("Testing equalTo with NULL pointer person3...\n");
	if((result = equalTo(person3,person3))>-1) {
		if(result == 0) {
			printf("the two people are different!\n");
		}
		else {
			printf("the two people are equal!\n");
		}
	}
	else {
		printf("There was an error with the equalTo function. EXPECTED\n");
	}

	printf("Testing equalTo with one NULL and one valid...\n");
	if((result = equalTo(person1,person3))>-1) {
		if(result == 0) {
			printf("the two people are different!\n");
		}
		else {
			printf("the two people are equal!\n");
		}
	}
	else {
		printf("There was an error with the equalTo function. EXPECTED\n");
	}
	printf("Testing equalTo function with two valid, different people...\n");
	if((result = equalTo(person1,person2))>-1) {
		if(result == 0) {
			printf("the two people are different! EXPECTED\n");
		}
		else {
			printf("the two people are equal!\n");
		}
	}
	else {
		printf("There was an error with the equalTo function.\n");
	}

	printf("Testing equalTo function with two valid, equal people...\n");
	if((result = equalTo(person1,person1))>-1) {
		if(result == 0) {
			printf("the two people are different!\n");
		}
		else {
			printf("the two people are equal! EXPECTED\n");
		}
	}
	else {
		printf("There was an error with the equalTo function.\n");
	}
	
	printf("\n");
	/*End equalTo Test*/

	
	/*Start copyInfo Test*/
	printf("Testing copyInfo function...\n");

	printf("Attempting to copy into a NULL pointer...\n");
	if(copyInfo(person1,person3)) {
		printf("there was an error with the copyInfo function... EXPECTED\n");
	}

	printf("Attempting to copy from a NULL pointer...\n");
	if(copyInfo(person3,person1)) {
		printf("there was an error with the copyInfo function... EXPECTED\n");
	}

	/*creating an empty person3 to copy info into*/
	person3 = createPerson();

	printf("Attempting to copy from valid person1 to valid person3...\n");
	if(copyInfo(person1,person3)) {
		printf("there was an error with the copyInfo function...\n");
	}
	else {
		printf("SUCCESS! EXPECTED\n");
	}

	printf("Printing person3... expected: Stephen Fuerth, 62\n");
	printPerson(person3);
	/*End copyInfo Test*/

	/*freeing all memory to check memleaks with valgrind*/
	destroyPerson(person1);
	destroyPerson(person2);
	destroyPerson(person3);
	/*Aug 26 8:53 - valgrind shows no memory leaks*/

	printf("\n");
	return 0;

}
Esempio n. 10
0
void tst_QBluetoothDeviceInfo::tst_construction()
{
    {
        QBluetoothDeviceInfo deviceInfo;

        QVERIFY(!deviceInfo.isValid());
        QVERIFY(deviceInfo.coreConfigurations()
                    == QBluetoothDeviceInfo::UnknownCoreConfiguration);
    }

    {
        QFETCH(QBluetoothAddress, address);
        QFETCH(QString, name);
        QFETCH(quint32, classOfDevice);
        QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
        QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
        QFETCH(quint8, minorDeviceClass);
        QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
        QFETCH(QBluetoothUuid, deviceUuid);

        QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
        QVERIFY(deviceInfo.isValid());

        QCOMPARE(deviceInfo.address(), address);
        QCOMPARE(deviceInfo.name(), name);
        QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
        QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
        QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);
        QCOMPARE(deviceInfo.coreConfigurations(), QBluetoothDeviceInfo::UnknownCoreConfiguration);

        deviceInfo.setCoreConfigurations(coreConfiguration);
        QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);

        deviceInfo.setDeviceUuid(deviceUuid);
        QCOMPARE(deviceInfo.deviceUuid(), deviceUuid);

        QBluetoothDeviceInfo copyInfo(deviceInfo);
        QVERIFY(copyInfo.isValid());

        QCOMPARE(copyInfo.address(), address);
        QCOMPARE(copyInfo.name(), name);
        QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
        QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
        QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
        QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
        QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
    }

    {
        // Test construction from the device unique UUID, without an address.
        QFETCH(QString, name);
        QFETCH(quint32, classOfDevice);
        QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
        QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
        QFETCH(quint8, minorDeviceClass);
        QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
        QFETCH(QBluetoothUuid, deviceUuid);

        QBluetoothDeviceInfo deviceInfo(deviceUuid, name, classOfDevice);
        QVERIFY(deviceInfo.isValid());

        QCOMPARE(deviceInfo.name(), name);
        QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
        QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
        QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);
        QCOMPARE(deviceInfo.coreConfigurations(), QBluetoothDeviceInfo::UnknownCoreConfiguration);

        deviceInfo.setCoreConfigurations(coreConfiguration);
        QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);

        QBluetoothDeviceInfo copyInfo(deviceInfo);
        QVERIFY(copyInfo.isValid());

        QCOMPARE(copyInfo.name(), name);
        QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
        QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
        QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
        QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
        QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
    }
}