void FeistelCipher::operator()(NTupleRW<symbol>& Vec, int mode /*=Encrypt*/) const { m_Init(Vec); if (m_f.GetSize()==1) { //SubArray<symbol> R(Vec,1,1); for (int i=0;i<m_Rounds;i++) { symbol t=Vec[1]; //m_f(R,mode==Decrypt?m_Rounds-1-i:i); Vec[1]=m_f(Vec[1],mode==Decrypt?m_Rounds-1-i:i); Vec[1]=Vec[1]^Vec[0]; Vec[0]=t; } #if !defined(_MSC_VER) || _MSC_VER <= 1200 swap(Vec[0],Vec[1]); #else std::swap(Vec[0],Vec[1]); #endif } else { int len=m_f.GetSize(); //SubArray L(Vec,0,len); // benutze Vec stattdessen, ist schneller NTupleRW<symbol>& L=Vec; SubArray<symbol> R(Vec,len,len); static Array<symbol,symbol> t(len); for (int i=0;i<m_Rounds;i++) { //symbol t=Vec[1]; Copy(t,R,len); //for (int j=0;j<len;j++) t[j]=R[j]; m_f(R,mode==Decrypt?m_Rounds-1-i:i); //Vec[1]=Vec[1]^Vec[0]; for (int j=0;j<len;j++) R[j]=R[j]^L[j]; //Vec[0]=t; Copy(L,t,len); //for (int j=0;j<len;j++) L[j]=t[j]; } #if !defined(_MSC_VER) || _MSC_VER <= 1200 for (int j=0;j<len;j++) swap(Vec[j],Vec[j+len]); #else for (int j=0;j<len;j++) std::swap(Vec[j],Vec[j+len]); #endif } m_End(Vec); }
//TODO: Check some functions. bool CUnitSync::load() { if (IsLoaded) return true; Library.setFileName(Settings.value("Spring/UnitSyncPath", "unitsync").toString()); #ifdef Q_OS_WIN QString OriginalPath = QDir::currentPath(); QDir::setCurrent(QFileInfo(Library.fileName()).absoluteDir().path()); #endif if (!Library.load()) { qCritical("Couldn't load unitsync library: %s", Library.errorString().toLocal8Bit().data()); emit(error(HoSpLo::CRITICAL, tr("Couldn't load unitsync library: %1 Check your settings").arg(Library.errorString()))); IsLoaded = false; return false; } #define loadFunction(X) Library.resolve(X) m_GetSpringVersion = (GetSpringVersion) loadFunction("GetSpringVersion"); m_Message = (Message) loadFunction("Message"); m_UnInit = (UnInit) loadFunction("UnInit"); m_Init = (Init) loadFunction("Init"); m_InitArchiveScanner = (InitArchiveScanner) loadFunction("InitArchiveScanner"); m_ProcessUnits = (ProcessUnits) loadFunction("ProcessUnits"); m_ProcessUnitsNoChecksum = (ProcessUnitsNoChecksum) loadFunction("ProcessUnitsNoChecksum"); m_GetCurrentList = (GetCurrentList) loadFunction("GetCurrentList"); m_AddClient = (AddClient) loadFunction("AddClient"); m_RemoveClient = (RemoveClient) loadFunction("RemoveClient"); m_GetClientDiff = (GetClientDiff) loadFunction("GetClientDiff"); m_InstallClientDiff = (InstallClientDiff) loadFunction("InstallClientDiff"); m_GetUnitCount = (GetUnitCount) loadFunction("GetUnitCount"); m_GetUnitName = (GetUnitName) loadFunction("GetUnitName"); m_GetFullUnitName = (GetFullUnitName) loadFunction("GetFullUnitName"); m_IsUnitDisabled = (IsUnitDisabled) loadFunction("IsUnitDisabled"); m_IsUnitDisabledByClient = (IsUnitDisabledByClient) loadFunction("IsUnitDisabledByClient"); m_AddArchive = (AddArchive) loadFunction("AddArchive"); m_AddAllArchives = (AddAllArchives) loadFunction("AddAllArchives"); m_RemoveAllArchives = (RemoveAllArchives) loadFunction("RemoveAllArchives"); m_GetArchiveChecksum = (GetArchiveChecksum) loadFunction("GetArchiveChecksum"); m_GetArchivePath = (GetArchivePath) loadFunction("GetArchivePath"); m_GetMapCount = (GetMapCount) loadFunction("GetMapCount"); m_GetMapName = (GetMapName) loadFunction("GetMapName"); m_GetMapInfoEx = (GetMapInfoEx) loadFunction("GetMapInfoEx"); m_GetMapInfo = (GetMapInfo) loadFunction("GetMapInfo"); m_GetMapArchiveCount = (GetMapArchiveCount) loadFunction("GetMapArchiveCount"); m_GetMapArchiveName = (GetMapArchiveName) loadFunction("GetMapArchiveName"); m_GetMapChecksum = (GetMapChecksum) loadFunction("GetMapChecksum"); m_GetMapChecksumFromName = (GetMapChecksumFromName) loadFunction("GetMapChecksumFromName"); m_GetMinimap = (GetMinimap) loadFunction("GetMinimap"); m_GetInfoMapSize = (GetInfoMapSize) loadFunction("GetInfoMapSize"); m_GetInfoMap = (GetInfoMap) loadFunction("GetInfoMap"); m_GetMapMinHeight = (GetMapMinHeight) loadFunction("GetMapMinHeight"); m_GetMapMaxHeight = (GetMapMaxHeight) loadFunction("GetMapMaxHeight"); m_GetPrimaryModCount = (GetPrimaryModCount) loadFunction("GetPrimaryModCount"); m_GetPrimaryModName = (GetPrimaryModName) loadFunction("GetPrimaryModName"); m_GetPrimaryModShortName = (GetPrimaryModShortName) loadFunction("GetPrimaryModShortName"); m_GetPrimaryModVersion = (GetPrimaryModVersion) loadFunction("GetPrimaryModVersion"); m_GetPrimaryModMutator = (GetPrimaryModMutator) loadFunction("GetPrimaryModMutator"); m_GetPrimaryModGame = (GetPrimaryModGame) loadFunction("GetPrimaryModGame"); m_GetPrimaryModShortGame = (GetPrimaryModShortGame) loadFunction("GetPrimaryModShortGame"); m_GetPrimaryModDescription = (GetPrimaryModDescription) loadFunction("GetPrimaryModDescription"); m_GetPrimaryModArchive = (GetPrimaryModArchive) loadFunction("GetPrimaryModArchive"); m_GetPrimaryModArchiveCount = (GetPrimaryModArchiveCount) loadFunction("GetPrimaryModArchiveCount"); m_GetPrimaryModArchiveList = (GetPrimaryModArchiveList) loadFunction("GetPrimaryModArchiveList"); m_GetPrimaryModIndex = (GetPrimaryModIndex) loadFunction("GetPrimaryModIndex"); m_GetPrimaryModChecksum = (GetPrimaryModChecksum) loadFunction("GetPrimaryModChecksum"); m_GetPrimaryModChecksumFromName = (GetPrimaryModChecksumFromName) loadFunction("GetPrimaryModChecksumFromName"); m_GetSideCount = (GetSideCount) loadFunction("GetSideCount"); m_GetSideName = (GetSideName) loadFunction("GetSideName"); m_GetLuaAICount = (GetLuaAICount) loadFunction("GetLuaAICount"); m_GetLuaAIName = (GetLuaAIName) loadFunction("GetLuaAIName"); m_GetLuaAIDesc = (GetLuaAIDesc) loadFunction("GetLuaAIDesc"); m_GetMapOptionCount = (GetMapOptionCount) loadFunction("GetMapOptionCount"); m_GetModOptionCount = (GetModOptionCount) loadFunction("GetModOptionCount"); m_GetOptionKey = (GetOptionKey) loadFunction("GetOptionKey"); m_GetOptionName = (GetOptionName) loadFunction("GetOptionName"); m_GetOptionDesc = (GetOptionDesc) loadFunction("GetOptionDesc"); m_GetOptionType = (GetOptionType) loadFunction("GetOptionType"); m_GetOptionBoolDef = (GetOptionBoolDef) loadFunction("GetOptionBoolDef"); m_GetOptionNumberDef = (GetOptionNumberDef) loadFunction("GetOptionNumberDef"); m_GetOptionNumberMin = (GetOptionNumberMin) loadFunction("GetOptionNumberMin"); m_GetOptionNumberMax = (GetOptionNumberMax) loadFunction("GetOptionNumberMax"); m_GetOptionNumberStep = (GetOptionNumberStep) loadFunction("GetOptionNumberStep"); m_GetOptionSection = (GetOptionSection) loadFunction("GetOptionSection"); m_GetOptionStringDef = (GetOptionStringDef) loadFunction("GetOptionStringDef"); m_GetOptionStringMaxLen = (GetOptionStringMaxLen) loadFunction("GetOptionStringMaxLen"); m_GetOptionListCount = (GetOptionListCount) loadFunction("GetOptionListCount"); m_GetOptionListDef = (GetOptionListDef) loadFunction("GetOptionListDef"); m_GetOptionListItemKey = (GetOptionListItemKey) loadFunction("GetOptionListItemKey"); m_GetOptionListItemName = (GetOptionListItemName) loadFunction("GetOptionListItemName"); m_GetOptionListItemDesc = (GetOptionListItemDesc) loadFunction("GetOptionListItemDesc"); m_GetModValidMapCount = (GetModValidMapCount) loadFunction("GetModValidMapCount"); m_GetModValidMap = (GetModValidMap) loadFunction("GetModValidMap"); m_GetWritableDataDirectory = (GetWritableDataDirectory) loadFunction("GetWritableDataDirectory"); m_OpenFileVFS = (OpenFileVFS) loadFunction("OpenFileVFS"); m_CloseFileVFS = (CloseFileVFS) loadFunction("CloseFileVFS"); m_ReadFileVFS = (ReadFileVFS) loadFunction("ReadFileVFS"); m_FileSizeVFS = (FileSizeVFS) loadFunction("FileSizeVFS"); m_InitFindVFS = (InitFindVFS) loadFunction("InitFindVFS"); m_FindFilesVFS = (FindFilesVFS) loadFunction("FindFilesVFS"); m_OpenArchive = (OpenArchive) loadFunction("OpenArchive"); m_CloseArchive = (CloseArchive) loadFunction("CloseArchive"); m_FindFilesArchive = (FindFilesArchive) loadFunction("FindFilesArchive"); m_OpenArchiveFile = (OpenArchiveFile) loadFunction("OpenArchiveFile"); m_ReadArchiveFile = (ReadArchiveFile) loadFunction("ReadArchiveFile"); m_CloseArchiveFile = (CloseArchiveFile) loadFunction("CloseArchiveFile"); m_SizeArchiveFile = (SizeArchiveFile) loadFunction("SizeArchiveFile"); m_GetSpringConfigString = (GetSpringConfigString) loadFunction("GetSpringConfigString"); m_GetSpringConfigInt = (GetSpringConfigInt) loadFunction("GetSpringConfigInt"); m_GetSpringConfigFloat = (GetSpringConfigFloat) loadFunction("GetSpringConfigFloat"); m_SetSpringConfigString = (SetSpringConfigString) loadFunction("SetSpringConfigString"); m_SetSpringConfigInt = (SetSpringConfigInt) loadFunction("SetSpringConfigInt"); m_SetSpringConfigFloat = (SetSpringConfigFloat) loadFunction("SetSpringConfigFloat"); #ifdef Q_OS_WIN QDir::setCurrent(OriginalPath); #endif if(!m_Init(false, 0)) { qCritical("Couldn't load unitsync library"); emit(error(HoSpLo::CRITICAL, tr("Couldn't load unitsync library"))); IsLoaded = false; return false; } IsLoaded = true; init(); return true; }
BOOL MibExtLoad::Init(DWORD dwTimeZeroReference,HANDLE *hPollForTrapEvent,AsnObjectIdentifier *supportedView) { if(m_hInst && m_Init) return m_Init(dwTimeZeroReference,hPollForTrapEvent,supportedView); return FALSE; }