示例#1
0
const char *FindVersion(int file_id, BYTE *pbVersionBytes, int cpbVersionBytes, const Category cat) {

	if(!doc[cat]) return 0;

	char version_string[128];
	strncpy(version_string, (char *)pbVersionBytes, cpbVersionBytes);
	version_string[sizeof(version_string)-1] = 0;

	ezxml_t root = ezxml_get(doc[cat], "channel", 0, "item", -1);
    while (root) {
        int id = atoi(ezxml_txt(ezxml_child(root, "id")));
        const char* version = ezxml_txt(ezxml_child(root, "version"));
        
		if (id == file_id && version[0]) {
			if (strncmp(version, (char*)pbVersionBytes, cpbVersionBytes) && VersionLess(version_string, version)) {
				return version;
			} else {
				return "same";
            }
		} 

        root = ezxml_next(root);
    }

	return 0;
}
示例#2
0
HRESULT CPatchDlg::DownloadDiffFile()
{
	HRESULT hr=S_OK;
	POSITION pos=m_mapSvrFileVersion.GetStartPosition();
	PFILEUPDATESVRDATA pData=NULL;
    PFILEUPDATECLIDATA pCliData=NULL;
	CString sKey;
	BOOL bDiff=FALSE;
	CString sUpdataPath;
	sUpdataPath.AppendFormat(_T("%s\\%s"),sAppPath,sSavePath);	
	do{
		bDiff=FALSE;
		pCliData=NULL;
		m_mapSvrFileVersion.GetNextAssoc(pos,sKey,(LPVOID&)pData);
		m_mapCliFileVersion.Lookup(sKey,(LPVOID&)pCliData);
		if(pCliData==NULL)
		{
			bDiff=TRUE;
			Log(_T("S:%-25s, S:%8s,客户端没有,"),pData->sFileName,
				pData->sVersion);
		}
		else
		{
			if(pCliData->sVersion.IsEmpty())
			{
				if(pCliData->nCrc32!=pData->nCrc32)
					bDiff=TRUE;
			}
			else
			{
				bDiff=VersionLess(pCliData->sVersion,pData->sVersion);
				if(!bDiff) //版本一样比较Crc32
				{
					if(pCliData->nCrc32!=pData->nCrc32)
						bDiff=TRUE;
				}

			}
			if(bDiff)
			{
				Log(_T("S:%-25s, C:%-25s, S:%8s, C:%8s,"),pData->sFileName,pCliData->sFileName,
				pData->sVersion,pCliData->sVersion);
				//客户端存在的文件 才视为找到新版本..
				if(!bFindNewVersion && !IsSpecialFile(pCliData->sFileName))
					bFindNewVersion=TRUE;
			}
		}
		if(bDiff)
		{
			hr=DownloadFile(sBaseAddress+pData->sFilePath,sUpdataPath+pData->sFileName,TRUE,pData->nCrc32);
			if(hr==S_OK)
				Log(_T("下载成功。\r\n"));
			else
				Log(_T("下载失败。\r\n"));
		}
	}while(pos!=NULL);
	return hr;
}
示例#3
0
int FindFileID(const char *name, const Category cat, UpdateList *update_list) 
{
	if (!doc[cat]) return -1;

	if (update_list) 
    {
		// couldn't find it in xml file - check if a plugin gave us a file id for a different shortName
		for (int i = 0; i < update_list->getCount(); ++i) 
        {
			UpdateInternal &ui = (*update_list)[i];
			if (ui.file_id != -1 && strcmp(ui.update.szComponentName, name) == 0) 
				return ui.file_id;
		}
	}

	// ignore case in name
	int id = -1;
	char *version = NULL;

	ezxml_t root = ezxml_get(doc[cat], "channel", 0, "item", -1);
    while (root) 
	{
        const char* title = ezxml_txt(ezxml_child(root, "title"));
        if (_stricmp(title, name) == 0) 
		{
            const char* subcategory = ezxml_txt(ezxml_child(root, "subcategory"));
            if (strcmp(subcategory, "Archived")) 
			{
                int id1 = atoi(ezxml_txt(ezxml_child(root, "id")));
                if (id1)
				{
					char *version1 = ezxml_txt(ezxml_child(root, "version"));
					if (!version || (version1 && VersionLess(version, version1)))
					{
						version = version1;
						id = id1;
					}
				}
            }
        }
        root = ezxml_next(root);
    }

	return id;
}