⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stafproc.cpp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        STAFString logicalID = logicalInterfaceID.subString(0,                                   logicalInterfaceID.find(kUTF8_PERIOD));        unsigned int numLogicalBytes =            (logicalID.length() < 4) ? logicalID.length() : 4;        unsigned int logicalStartIndex =            logicalID.length() - numLogicalBytes;        for (unsigned int logicalIndex = 0; logicalIndex < numLogicalBytes;            ++logicalIndex)        {            UUIDBytes[12 + logicalIndex] =                logicalID.buffer()[logicalStartIndex + logicalIndex];        }        for (unsigned int UUIDByteIndex = 0; UUIDByteIndex < sizeof(UUIDBytes);             ++UUIDByteIndex)        {            unsigned int aUUIDByte = UUIDBytes[UUIDByteIndex];            unsigned int upperValue = (aUUIDByte >> 4) & 0x0000000F;            unsigned int lowerValue = aUUIDByte & 0x0000000F;            gSTAFInstanceUUID += STAFString(upperValue, 16);            gSTAFInstanceUUID += STAFString(lowerValue, 16);        }        // Display STAFProc startup information        cout << endl << "Machine          : " << gMachine << endl;        cout << "Machine nickname : " << gMachineNickname << endl;        cout << "Startup time     : " << startupTime.asString() << endl;        // Initialize the Authenticator services        STAFServiceManager::OrderedServiceList authenticatorMap =            gServiceManager.getAuthenticatorMapCopy();        STAFServiceManager::OrderedServiceList::iterator authIter;        for(authIter = authenticatorMap.begin();            authIter != authenticatorMap.end(); ++authIter)        {            STAFServiceResult result = authIter->second->initialize();            if (result.fRC)            {                cout << "Error initializing authenticator service, "                     << authIter->second->name()                      << ", RC: " << result.fRC                      << ", Result: " << result.fResult                     << endl;            }        }        // Don't hold on to service pointers we will never use        authenticatorMap = STAFServiceManager::OrderedServiceList();        // Initialize the service loader services        STAFServiceManager::ServiceList slsList =                                        gServiceManager.getSLSListCopy();        STAFServiceManager::ServiceList::iterator slsIter;        for(slsIter = slsList.begin();            slsIter != slsList.end(); ++slsIter)        {            STAFServiceResult result = (*slsIter)->initialize();            if (result.fRC)            {                cout << "Error initializing service loader service, "                     << (*slsIter)->name()                      << ", RC: " << result.fRC                      << ", Result: " << result.fResult                     << endl;            }        }        // Don't hold on to service pointers we will never use        slsList = STAFServiceManager::ServiceList();        // Create gSTAFWriteLocation directory if it doesn't exist         // Note that if the default location was overridden, it will have        // already been created.        STAFFSPath dataPath;        dataPath.setRoot(gSTAFWriteLocation);                try        {            if (!dataPath.exists())            {                try                {                    dataPath.createDirectory(kSTAFFSCreatePath);                }                catch (...)                { /* Do Nothing */ }                if (!dataPath.exists())                {                    cout << "Error creating DATADIR directory: "                         << gSTAFWriteLocation << endl;                    return 1;                }            }        }        catch (...)        {            cout << "Error checking if DATADIR directory "                 << gSTAFWriteLocation << " exists" << endl;            return 1;        }                // Delete <gSTAFWriteLocation>/tmp directory and all its contents        // if it exists and then create the directory                STAFFSPath tmpPath;        tmpPath.setRoot(gSTAFWriteLocation);        tmpPath.addDir("tmp");                if (tmpPath.exists())        {            STAFFSEntryPtr entry = tmpPath.getEntry();            STAFString namePattern(kUTF8_STAR);            STAFString extPattern(kUTF8_STAR);            unsigned int entryTypesUInt = kSTAFFSAll;            STAFFSCaseSensitive_t caseSensitive = kSTAFFSCaseDefault;            STAFString removeResult;            STAFRC_t removeRC = removeDir(                entry, namePattern, extPattern, entryTypesUInt,                caseSensitive, removeResult);            if (removeRC != kSTAFOk)            {                cout << "Error deleting temp directory: "                     << tmpPath.asString()                      << ", RC: " << removeRC << ", Result: "                     << removeResult << endl;            }        }        try        {            // Don't want exceptions here            STAFFSEntryPtr tmpdir =                 tmpPath.createDirectory(kSTAFFSCreatePath);        }        catch (...)        { /* Do Nothing */ }        if (!tmpPath.exists())        {            cout << "Error creating temp directory: " << tmpPath.asString()                 << endl;        }        // Create <gSTAFWriteLocation>/user directory if it doesn't exist.        STAFFSPath userPath;        userPath.setRoot(gSTAFWriteLocation);        userPath.addDir("user");        if (!userPath.exists())        {            try            {                userPath.createDirectory(kSTAFFSCreatePath);            }            catch (...)            { /* Do Nothing */ }            if (!userPath.exists())            {                cout << "Error creating user directory: "                     << userPath.asString() << endl;            }        }                // XXX: Is the comment below true?        // Initialize the services.  Note that the internal services were        // already initialized, so this will only initialize the external        // services.        STAFServiceManager::ServiceList serviceList =                                        gServiceManager.getServiceListCopy();        STAFServiceManager::ServiceList::iterator serviceIter;        for(serviceIter = serviceList.begin();            serviceIter != serviceList.end(); ++serviceIter)        {            STAFServiceResult result = (*serviceIter)->initialize();            if (result.fRC)            {                cout << "Error initializing service, "                     << (*serviceIter)->name()                      << ", RC: " << result.fRC                      << ", Result: " << result.fResult                      << endl;                gServiceManager.remove((*serviceIter)->name());            }        }        // Don't hold on to service pointers we will never use        serviceList = STAFServiceManager::ServiceList();        cout << endl << "STAFProc version " << gVersion << " initialized"             << endl;        // Send start notifications        gNotifyOnStart.sendNotification("STAF/Start", "");        // Call registration program if necessary        STAFString infFileName = STAFString(configInfo.exePath) +            gFileSeparator + "STAFReg.inf";        STAFString cmpFileName = gSTAFWriteLocation + *gFileSeparatorPtr +            "register" + *gFileSeparatorPtr + "STAFReg.cmp";        if (STAFFSPath(infFileName).exists() &&            !STAFFSPath(cmpFileName).exists())        {            system("STAFReg");        }        // Wait for signal to end        gShutdownSemaphore->wait();        cout << "STAFProc ending normally" << endl;                gContinueGCPolling = 0;        gGCPollingSem->post();                // Allow the polling thread to end        gThreadManagerPtr->sleepCurrentThread(1000);        // Send shutdown notifications        gNotifyOnShutdown.sendNotification("STAF/Shutdown", "");        // Terminate services        serviceList = gServiceManager.getServiceListCopy();        for(STAFServiceManager::ServiceList::reverse_iterator serviceIter2 =                serviceList.rbegin();            serviceIter2 != serviceList.rend(); ++serviceIter2)        {            STAFServicePtr theService = *serviceIter2;            gServiceManager.remove(theService->name());                        STAFServiceResult result = theService->terminate();            if (result.fRC)            {                STAFString message("Error terminating service, ");                message += theService->name() + ", RC: " +                    STAFString(result.fRC) + ", Result: " + result.fResult;                STAFTrace::trace(kSTAFTraceError, message);            }        }        // Terminate service loader services        slsList = gServiceManager.getSLSListCopy();        for(STAFServiceManager::ServiceList::reverse_iterator slsIter2 =                slsList.rbegin();            slsIter2 != slsList.rend(); ++slsIter2)        {            STAFServicePtr theService = *slsIter2;            gServiceManager.removeSLS(theService);                        STAFServiceResult result = theService->terminate();            if (result.fRC)            {                STAFString message(                    "Error terminating service loader service, ");                message += theService->name() + ", RC: " +                    STAFString(result.fRC) + ", Result: " + result.fResult;                STAFTrace::trace(kSTAFTraceError, message);            }        }        // Terminate any remaining services that might have been re-initialized        // by a service loader during another service's terminiation        serviceList = gServiceManager.getServiceListCopy();        for(STAFServiceManager::ServiceList::reverse_iterator serviceIter3 =                serviceList.rbegin();            serviceIter3 != serviceList.rend(); ++serviceIter3)        {            STAFServicePtr theService = *serviceIter3;            gServiceManager.remove(theService->name());            STAFServiceResult result = theService->terminate();            if (result.fRC)            {                STAFString message("Error terminating service, ");                message += theService->name() + ", RC: " +                    STAFString(result.fRC) + ", Result: " + result.fResult;                STAFTrace::trace(kSTAFTraceError, message);            }        }        // Terminate authenticator services        authenticatorMap = gServiceManager.getAuthenticatorMapCopy();        for(STAFServiceManager::OrderedServiceList::reverse_iterator            authIter2 = authenticatorMap.rbegin();            authIter2 != authenticatorMap.rend(); ++authIter2)        {            STAFServicePtr theService = authIter2->second;            gServiceManager.removeAuthenticator(theService->name());                        STAFServiceResult result = theService->terminate();            if (result.fRC)            {                STAFString message(                    "Error terminating authenticator service, ");                message += theService->name() + ", RC: " +                    STAFString(result.fRC) + ", Result: " + result.fResult;                STAFTrace::trace(kSTAFTraceError, message);            }        }        // Stop the connection providers                connProvList = gConnectionManager.getConnectionProviderListCopy();                for (STAFConnectionManager::ConnectionProviderList::iterator             cpIter = connProvList.begin(); cpIter != connProvList.end();             ++cpIter)        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -