Example #1
0
void bsConnectAndQuery(int *sockfd,int server_cnt, char **servers, 
	struct queryNodeHederFormat *header, 
	struct subnamesFormat *colls, int colls_cnt,
	int offset, int port) {
	
	
	bsMultiConnect(sockfd, server_cnt, servers, port, offset);
	
	// send data.
	int i;
	for (i = 0; i < server_cnt; i++) {
		if (!sockfd[i + offset]) 
			continue;
		if (!bsQuery(&sockfd[i + offset], header, sizeof *header)
		 || !bsQuery(&sockfd[i + offset], &colls_cnt, sizeof colls_cnt)
		 || (colls_cnt > 0 && !bsQuery(&sockfd[i + offset], colls,
		 	sizeof(struct subnamesFormat) * colls_cnt))) {
			warnx("Can't send. Server %s:%i", servers[i], port);
		}
	}
}
Example #2
0
HRESULT CIIS7XMLConfigHelper::RemoveModuleNodes(IXMLDOMDocument* pDoc, LPCSTR pszModuleName)
{
	if (pDoc == NULL || pszModuleName == NULL)
		return E_POINTER;

	CAtlStringW sQuery;
	sQuery.Format(L"//add[@name='%hs']", pszModuleName);	

	CComBSTR bsQuery(sQuery);

	CComPtr<IXMLDOMNodeList> pModuleNodes;
	HRESULT hr = pDoc->selectNodes(bsQuery, &pModuleNodes);

	if (hr == S_OK)
	{
		LONG nModules = 0;
		hr = pModuleNodes->get_length(&nModules);

		for (LONG i = 0; i < nModules; i++)
		{
			CComPtr<IXMLDOMNode> pModuleNode;
			hr = pModuleNodes->get_item(i, &pModuleNode);
			if (hr != S_OK || pModuleNode == NULL)
				continue;

			CComPtr<IXMLDOMNode> pParentNode;
			hr = pModuleNode->get_parentNode(&pParentNode);
			if (hr != S_OK || pParentNode == NULL)
				continue;

			CComPtr<IXMLDOMNode> pTemp;
			hr = pParentNode->removeChild(pModuleNode, &pTemp);
			if (hr != S_OK)
				break;
		}
	}

	return hr;
}
Example #3
0
HRESULT CIIS7XMLConfigHelper::AddNativeModuleNode(IXMLDOMDocument* pDoc, 
												  IXMLDOMNode* pModulesNode, 
												  LPCSTR pszModuleName,
												  LPCSTR pszModulePath,
												  int bitness)
{
	if (pDoc == NULL || pModulesNode == NULL || pszModuleName == NULL)
		return E_POINTER;

	CAtlStringW sQuery;
	sQuery.Format(L"add[@name='%hs']", pszModuleName);	

	CComBSTR bsQuery(sQuery);

	// find the module node, if it doesn't exist then add it
	CComPtr<IXMLDOMNode> pModuleNode;
	HRESULT hr = pModulesNode->selectSingleNode(bsQuery, &pModuleNode);
	if (hr != S_OK || pModuleNode == NULL)
	{		
		hr = pDoc->createNode(CComVariant(NODE_ELEMENT), L"add", L"", &pModuleNode);
		if (hr != S_OK || pModuleNode == NULL)
			return hr;

		CComPtr<IXMLDOMNamedNodeMap> pAttrs;
		hr = pModuleNode->get_attributes(&pAttrs);
		if (hr != S_OK || pAttrs == NULL)
			return hr;

		CComPtr<IXMLDOMAttribute> pNameAttr;
		hr = pDoc->createAttribute(L"name", &pNameAttr);
		if (hr != S_OK || pNameAttr == NULL)
			return hr;

		hr = pNameAttr->put_text(CComBSTR(pszModuleName));
		hr = pAttrs->setNamedItem(pNameAttr, NULL);

		if (pszModulePath != NULL)
		{
			CComPtr<IXMLDOMAttribute> pImageAttr;
			hr = pDoc->createAttribute(L"image", &pImageAttr);
			if (hr != S_OK || pNameAttr == NULL)
				return hr;

			hr = pImageAttr->put_text(CComBSTR(pszModulePath));
			hr = pAttrs->setNamedItem(pImageAttr, NULL);
		}

		// set the bitness precondition
		if (bitness > 0)
		{
			CComPtr<IXMLDOMAttribute> pPreconditionAttr;
			hr = pDoc->createAttribute(L"preCondition", &pPreconditionAttr);
			if (hr != S_OK || pPreconditionAttr == NULL)
				return hr;
			
			CAtlString sBitness;
			sBitness.Format(_T("bitness%d"), bitness);

			hr = pPreconditionAttr->put_text(CComBSTR(sBitness));
			hr = pAttrs->setNamedItem(pPreconditionAttr, NULL);
		}

		hr = pModulesNode->appendChild(pModuleNode, NULL);
	}

	return hr;
}