Ejemplo n.º 1
0
void Client::close()
{
  const auto disconnectResult = disconnect();
  throwIfError("disconnect", disconnectResult);

  const auto stopResult = loop_stop();
  throwIfError("loop_stop", stopResult);
}
Ejemplo n.º 2
0
 CAAFInitializePlugins() :
   pPluginMgr(NULL)
 {
   throwIfError(AAFGetPluginManager(&pPluginMgr));
   throwIfError(pPluginMgr->RegisterSharedPlugins());
   pPluginMgr->Release();
   pPluginMgr = NULL;
 }
Ejemplo n.º 3
0
void Client::connect()
{
  configuration->configure(*this);

  throwIfError("connect", mosqpp::mosquittopp::connect(configuration->address().c_str(), configuration->port()));

  throwIfError("loop_start", loop_start());
}
Ejemplo n.º 4
0
        cWrapper(string const cppvalue) {
            env_wrap env;

            this->valueP = xmlrpc_datetime_new_str(&env.env_c,
                                                   cppvalue.c_str());
            throwIfError(env);
        }
Ejemplo n.º 5
0
 cWrapper(vector<unsigned char> const& cppvalue) {
     env_wrap env;
     
     this->valueP = 
         xmlrpc_base64_new(&env.env_c, cppvalue.size(), &cppvalue[0]);
     throwIfError(env);
 }
Ejemplo n.º 6
0
            cWrapper(xmlrpc_value *const arrayP,
                     unsigned int const index) {
                env_wrap env;

                xmlrpc_array_read_item(&env.env_c, arrayP, index, &valueP);

                throwIfError(env);
            }
Ejemplo n.º 7
0
void FirmwareArchive::Data::processXml(std::string string)
{
    // Parse the string as XML.
    tinyxml2::XMLDocument doc;
    doc.Parse(string.c_str(), string.size());
    throwIfError(doc);

    // Check the FirmwareArchive element.
    tinyxml2::XMLElement * root = doc.RootElement();
    if (std::string(root->Name()) != "FirmwareArchive")
    {
        throw std::runtime_error("The root element has an invalid name.");
    }

    // Check the FirmwareArchive format attribute.  If we add any information to
    // the FMI format that *must* be processed by all readers, we will increment
    // the major version number.  If we add any information that is optional, we
    // might increment the minor version.  Therefore, we don't need to check the
    // minor version here, and we don't need to worry about unrecognized
    // attributes or tags, but we must check the major version.
    std::string format = root->Attribute("format");
    std::vector<std::string> parts = split(format, '.');
    if (parts[0] != "1")
    {
        throw std::runtime_error(
            "The firmware archive format is different than expected.  "
            "Try installing the latest version of this software.");
    }

    // Get the FirmwareArchive name attribute.
    const char * name = root->Attribute("name");
    if (name != NULL) { this->name = name; }

    // Process the images.
    for (const tinyxml2::XMLNode * node = root->FirstChild();
         node != NULL; node = node->NextSibling())
    {
        const tinyxml2::XMLElement * element = node->ToElement();
        if (element == NULL)
        {
            continue;
        }

        if (std::string(element->Name()) != "FirmwareImage")
        {
            continue;
        }

        images.push_back(processXmlFirmwareImage(element));
    }

    if (images.empty())
    {
        throw std::runtime_error("The firmware archive has no images.");
    }
}
Ejemplo n.º 8
0
value_int::operator int() const {

    int retval;
    env_wrap env;

    xmlrpc_read_int(&env.env_c, this->cValueP, &retval);
    throwIfError(env);

    return retval;
}
Ejemplo n.º 9
0
            cMemberWrapper(xmlrpc_value *const structP,
                           unsigned int const index) {

                env_wrap env;

                xmlrpc_struct_read_member(&env.env_c, structP, index,
                                          &keyP, &valueP);

                throwIfError(env);
            }
Ejemplo n.º 10
0
value_i8::operator xmlrpc_int64() const {

    xmlrpc_int64 retval;
    env_wrap env;

    xmlrpc_read_i8(&env.env_c, this->cValueP, &retval);
    throwIfError(env);

    return retval;
}
Ejemplo n.º 11
0
value_datetime::operator timespec() const {

    struct timespec retval;
    env_wrap env;

    xmlrpc_read_datetime_timespec(&env.env_c, this->cValueP, &retval);
    throwIfError(env);

    return retval;
}
Ejemplo n.º 12
0
void
value::appendToCArray(xmlrpc_value * const arrayP) const {
/*----------------------------------------------------------------------------
  Append this value to the C array 'arrayP'.
----------------------------------------------------------------------------*/
    env_wrap env;

    xmlrpc_array_append_item(&env.env_c, arrayP, this->cValueP);

    throwIfError(env);
}
Ejemplo n.º 13
0
value_double::operator double() const {

    double retval;

    env_wrap env;

    xmlrpc_read_double(&env.env_c, this->cValueP, &retval);
    throwIfError(env);

    return retval;
}
Ejemplo n.º 14
0
value_boolean::operator bool() const {

    xmlrpc_bool retval;

    env_wrap env;

    xmlrpc_read_bool(&env.env_c, this->cValueP, &retval);
    throwIfError(env);

    return (retval != false);
}
Ejemplo n.º 15
0
size_t
value_array::size() const {

    env_wrap env;
    unsigned int arraySize;

    arraySize = xmlrpc_array_size(&env.env_c, this->cValueP);
    throwIfError(env);
    
    return arraySize;
}
Ejemplo n.º 16
0
size_t
value_bytestring::length() const {

    env_wrap env;
    size_t length;

    xmlrpc_read_base64_size(&env.env_c, this->cValueP, &length);
    throwIfError(env);

    return length;
}
Ejemplo n.º 17
0
value_datetime::operator timeval() const {

    this->validateInstantiated();

    struct timeval retval;
    env_wrap env;

    xmlrpc_read_datetime_timeval(&env.env_c, this->cValueP, &retval);
    throwIfError(env);

    return retval;
}
Ejemplo n.º 18
0
void
value::addToCStruct(xmlrpc_value * const structP,
                    string         const key) const {
/*----------------------------------------------------------------------------
  Add this value to the C array 'arrayP' with key 'key'.
----------------------------------------------------------------------------*/
    env_wrap env;

    xmlrpc_struct_set_value_n(&env.env_c, structP,
                              key.c_str(), key.length(),
                              this->cValueP);

    throwIfError(env);
}
Ejemplo n.º 19
0
value_struct::operator map<string, xmlrpc_c::value>() const {

    this->validateInstantiated();

    env_wrap env;
    unsigned int structSize;

    structSize = xmlrpc_struct_size(&env.env_c, this->cValueP);
    throwIfError(env);

    map<string, xmlrpc_c::value> retval;

    for (unsigned int i = 0; i < structSize; ++i) {
        class cMemberWrapper {
        public:
            xmlrpc_value *keyP;
            xmlrpc_value *valueP;

            cMemberWrapper(xmlrpc_value *const structP,
                           unsigned int const index) {

                env_wrap env;

                xmlrpc_struct_read_member(&env.env_c, structP, index,
                                          &keyP, &valueP);

                throwIfError(env);
            }

            ~cMemberWrapper() {
                xmlrpc_DECREF(keyP);
                xmlrpc_DECREF(valueP);
            }
        };

        cMemberWrapper memberWrapper(this->cValueP, i);

        cStringWrapper keyWrapper(memberWrapper.keyP);

        string const key(keyWrapper.str, keyWrapper.length);

        retval[key] = xmlrpc_c::value(memberWrapper.valueP);
    }

    return retval;
}
Ejemplo n.º 20
0
string
value_datetime::iso8601Value() const {

    string retval;

    this->validateInstantiated();

    const char *iso8601;
    env_wrap env;

    xmlrpc_read_datetime_8601(&env.env_c, this->cValueP, &iso8601);
    throwIfError(env);

    retval = iso8601;

    xmlrpc_strfree(iso8601);

    return retval;
}
Ejemplo n.º 21
0
vector<xmlrpc_c::value>
value_array::vectorValueValue() const {

    this->validateInstantiated();

    env_wrap env;

    unsigned int arraySize;

    arraySize = xmlrpc_array_size(&env.env_c, this->cValueP);
    throwIfError(env);

    vector<xmlrpc_c::value> retval(arraySize);

    for (unsigned int i = 0; i < arraySize; ++i) {

        class cWrapper {
        public:
            xmlrpc_value *valueP;

            cWrapper(xmlrpc_value *const arrayP,
                     unsigned int const index) {
                env_wrap env;

                xmlrpc_array_read_item(&env.env_c, arrayP, index, &valueP);

                throwIfError(env);
            }

            ~cWrapper() {
                xmlrpc_DECREF(valueP);
            }
        };

        cWrapper wrapper(this->cValueP, i);

        retval[i].instantiate(wrapper.valueP);
    }

    return retval;
}
Ejemplo n.º 22
0
    cNewStringWrapper(string const cppvalue,
                      value_string::nlCode const nlCode) {
        env_wrap env;

        switch (nlCode) {
        case value_string::nlCode_all:
            this->valueP = xmlrpc_string_new_lp(&env.env_c,
                                                cppvalue.length(),
                                                cppvalue.c_str());
            break;
        case value_string::nlCode_lf:
            this->valueP = xmlrpc_string_new_lp_cr(&env.env_c,
                                                   cppvalue.length(),
                                                   cppvalue.c_str());
            break;
        default:
            throw (error("Newline encoding argument to value_string "
                         "constructor is not one of the defined "
                         "enumerations of value_string::nlCode"));
        }
        throwIfError(env);
    }
Ejemplo n.º 23
0
	CAAFInitialize(const char *dllname = NULL) {
		std::wcout << "Attempting to load the AAF dll... " << std::flush;
#if defined(CHECKLEAKS)
		// Send	all	reports	to STDOUT
		_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE	);
		_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
		//_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
		//_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
		//_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE	);
		//_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
		_CrtMemCheckpoint( &_memoryState );
#endif

		HRESULT hr = AAFLoad(dllname);
		if (S_OK != hr)
		{
			std::wcout << L"FAILED!" << std::endl;;
			throwIfError(hr);
		}
		std::wcout << L"DONE" << std::endl;
		dumpLibInfo(std::wcout);
	}
Ejemplo n.º 24
0
        cWrapper(double const cppvalue) {
            env_wrap env;

            this->valueP = xmlrpc_double_new(&env.env_c, cppvalue);
            throwIfError(env);
        }
Ejemplo n.º 25
0
        cWrapper() {
            env_wrap env;

            this->valueP = xmlrpc_nil_new(&env.env_c);
            throwIfError(env);
        }
Ejemplo n.º 26
0
        cWrapper(xmlrpc_value *valueP) {
            env_wrap env;

            xmlrpc_read_string_lp_crlf(&env.env_c, valueP, &length, &str);
            throwIfError(env);
        }
Ejemplo n.º 27
0
void Client::send(const presentation::Message &message)
{
  const auto result = publish(nullptr, configuration->sendTopic().c_str(), message.asBinary().size(), message.asBinary().data(), configuration->qos());
  throwIfError("publish", result);
}
Ejemplo n.º 28
0
        cWrapper(xmlrpc_value *const valueP) {
            env_wrap env;

            xmlrpc_read_base64(&env.env_c, valueP, &length, &contents);
            throwIfError(env);
        }
CFDataRef decodePrivateKeyHeader(SecKeychainRef keychain, const FVPrivateKeyHeader &inHeader)
{	
	// kSecKeyLabel is defined in libsecurity_keychain/lib/SecKey.h
	SecKeychainAttribute attrs[] =
	{
		{ 6 /* kSecKeyLabel */, inHeader.publicKeyHashSize, const_cast<uint8 *>(inHeader.publicKeyHash) }
	};
	SecKeychainAttributeList attrList =
	{
		sizeof(attrs) / sizeof(SecKeychainAttribute),
		attrs
	};
	CSSM_CSP_HANDLE cspHandle = 0;
	const CSSM_KEY *cssmKey = NULL;
    const CSSM_ACCESS_CREDENTIALS *accessCred = NULL;
    CSSM_CC_HANDLE cc = 0;
	
	SecKeychainSearchRef _searchRef;
	throwIfError(SecKeychainSearchCreateFromAttributes(keychain, (SecItemClass) CSSM_DL_DB_RECORD_PRIVATE_KEY, &attrList, &_searchRef));
	CFRef<SecKeychainSearchRef> searchRef(_searchRef);
	
	SecKeychainItemRef _item;
    if (SecKeychainSearchCopyNext(searchRef, &_item) != 0) {
		return NULL;  // XXX possibly should throw here?
    }
	
	CFRef<SecKeyRef> keyItem(reinterpret_cast<SecKeyRef>(_item));
	throwIfError(SecKeyGetCSPHandle(keyItem, &cspHandle));
	throwIfError(SecKeyGetCSSMKey(keyItem, &cssmKey));
    throwIfError(SecKeyGetCredentials(keyItem, CSSM_ACL_AUTHORIZATION_DECRYPT, kSecCredentialTypeDefault, &accessCred));
    throwIfError(CSSM_CSP_CreateAsymmetricContext(cspHandle, cssmKey->KeyHeader.AlgorithmId, accessCred, cssmKey, CSSM_PADDING_PKCS1, &cc));
	CFDataRef result;
	
	try
	{		
		CssmMemoryFunctions memFuncs;
		throwIfError(CSSM_GetAPIMemoryFunctions(cspHandle, &memFuncs));
		CssmMemoryFunctionsAllocator allocator(memFuncs);
		
		const CssmData cipherBuf(const_cast<uint8 *>(inHeader.encryptedBlob), inHeader.encryptedBlobSize);
		CssmAutoData clearBuf(allocator);
		CssmAutoData remData(allocator);
		size_t bytesDecrypted;
		CSSM_RETURN crx = CSSM_DecryptData(cc, &cipherBuf, 1, &clearBuf.get(), 1, &bytesDecrypted, &remData.get());
		secinfo("FDERecovery", "decodePrivateKeyHeader: CSSM_DecryptData result: %d", crx);
		throwIfError(crx);
//		throwIfError(CSSM_DecryptData(cc, &cipherBuf, 1, &clearBuf.get(), 1, &bytesDecrypted, &remData.get()));
		clearBuf.length(bytesDecrypted);
//		rawKey.copy(clearBuf.get());
		result = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)clearBuf.get().data(), clearBuf.get().length());
//		result = parseKeyBlob(clearBuf.get());
	}
	catch(...)
	{
		CSSM_DeleteContext(cc);
		throw;
	}
	
	throwIfError(CSSM_DeleteContext(cc));
	
	return result;
}
Ejemplo n.º 30
0
        cWrapper(xmlrpc_bool const cppvalue) {
            env_wrap env;

            this->valueP = xmlrpc_bool_new(&env.env_c, cppvalue);
            throwIfError(env);
        }