diff --git a/contrib/extractor/CMakeLists.txt b/contrib/extractor/CMakeLists.txt index 7c7810240..023359612 100644 --- a/contrib/extractor/CMakeLists.txt +++ b/contrib/extractor/CMakeLists.txt @@ -11,6 +11,10 @@ cmake_minimum_required (VERSION 2.6) project (MANGOS_MAP_EXTRACTOR) +message(FATAL_ERROR + "This project CMakeLists.txt outdated after switch use dep/libmpq and need update use existed Visual Studio projects for build." +) + add_subdirectory (libmpq) add_subdirectory (loadlib) diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp index 21bc95d68..0f5a9b04f 100644 --- a/contrib/extractor/System.cpp +++ b/contrib/extractor/System.cpp @@ -2,17 +2,19 @@ #include #include +#include #include #include #ifdef WIN32 #include "direct.h" +#include #else +#include #include #endif #include "dbcfile.h" -#include "mpq_libmpq.h" #include "loadlib/adt.h" #include "loadlib/wdt.h" @@ -33,7 +35,6 @@ #else #define OPEN_FLAGS (O_RDONLY | O_BINARY) #endif -extern ArchiveSet gOpenArchives; typedef struct { @@ -47,6 +48,7 @@ uint16 *LiqType; char output_path[128] = "."; char input_path[128] = "."; uint32 maxAreaId = 0; +uint32 CONF_max_build = 0; //************************************************** // Extractor options @@ -71,22 +73,13 @@ float CONF_float_to_int16_limit = 2048.0f; // Max accuracy = val/65536 float CONF_flat_height_delta_limit = 0.005f; // If max - min less this value - surface is flat float CONF_flat_liquid_delta_limit = 0.001f; // If max - min less this value - liquid surface is flat -// List MPQ for extract from -char *CONF_mpq_list[]={ - "common.MPQ", - "common-2.MPQ", - "lichking.MPQ", - "expansion.MPQ", - "patch.MPQ", - "patch-2.MPQ", - "patch-3.MPQ", - "patch-4.MPQ", - "patch-5.MPQ", -}; - static char* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" }; #define LANG_COUNT 12 +#define MIN_SUPPORTED_BUILD 15050 // code expect mpq files and mpq content files structure for this build or later +#define EXPANSION_COUNT 3 +#define WORLD_COUNT 2 + void CreateDir( const std::string& Path ) { #ifdef WIN32 @@ -111,13 +104,15 @@ bool FileExists( const char* FileName ) void Usage(char* prg) { printf( - "Usage:\n"\ - "%s -[var] [value]\n"\ - "-i set input path\n"\ - "-o set output path\n"\ - "-e extract only MAP(1)/DBC(2) - standard: both(3)\n"\ - "-f height stored as int (less map size but lost some accuracy) 1 by default\n"\ - "Example: %s -f 0 -i \"c:\\games\\game\"", prg, prg); + "Usage:\n" + "%s -[var] [value]\n" + "-i set input path\n" + "-o set output path\n" + "-e extract only MAP(1)/DBC(2) - standard: both(3)\n" + "-e extract only MAP(1)/DBC(2) - temporary only: DBC(2)\n" + "-f height stored as int (less map size but lost some accuracy) 1 by default\n" + "-b extract data for specific build (at least not greater it from available). Min supported build %u.\n" + "Example: %s -f 0 -i \"c:\\games\\game\"", prg, MIN_SUPPORTED_BUILD, prg); exit(1); } @@ -163,25 +158,81 @@ void HandleArgs(int argc, char * arg[]) else Usage(arg[0]); break; + case 'b': + if(c + 1 < argc) // all ok + { + CONF_max_build = atoi(arg[(c++) + 1]); + if (CONF_max_build < MIN_SUPPORTED_BUILD) + Usage(arg[0]); + } + else + Usage(arg[0]); + break; + default: + Usage(arg[0]); + break; } } } +void AppendDBCFileListTo(HANDLE mpqHandle, std::set& filelist) +{ + SFILE_FIND_DATA findFileData; + + HANDLE searchHandle = SFileFindFirstFile(mpqHandle, "*.dbc", &findFileData, NULL); + if (!searchHandle) + return; + + filelist.insert(findFileData.cFileName); + + while (SFileFindNextFile(searchHandle, &findFileData)) + filelist.insert(findFileData.cFileName); + + SFileFindClose(searchHandle); +} + +void AppendDB2FileListTo(HANDLE mpqHandle, std::set& filelist) +{ + SFILE_FIND_DATA findFileData; + + HANDLE searchHandle = SFileFindFirstFile(mpqHandle, "*.db2", &findFileData, NULL); + if (!searchHandle) + return; + + filelist.insert(findFileData.cFileName); + + while (SFileFindNextFile(searchHandle, &findFileData)) + filelist.insert(findFileData.cFileName); + + SFileFindClose(searchHandle); +} + uint32 ReadBuild(int locale) { // include build info file also std::string filename = std::string("component.wow-")+langs[locale]+".txt"; //printf("Read %s file... ", filename.c_str()); - MPQFile m(filename.c_str()); - if(m.isEof()) + HANDLE fileHandle; + + if (!OpenNewestFile(filename.c_str(), &fileHandle)) { printf("Fatal error: Not found %s file!\n", filename.c_str()); exit(1); } - std::string text = m.getPointer(); - m.close(); + unsigned int data_size = SFileGetFileSize(fileHandle, NULL); + + std::string text; + text.resize(data_size); + + if (!SFileReadFile(fileHandle, &text[0], data_size, NULL, NULL)) + { + printf("Fatal error: Can't read %s file!\n", filename.c_str()); + exit(1); + } + + SFileCloseFile(fileHandle); size_t pos = text.find("version=\""); size_t pos1 = pos + strlen("version=\""); @@ -201,14 +252,33 @@ uint32 ReadBuild(int locale) exit(1); } + if (build < MIN_SUPPORTED_BUILD) + { + printf("Fatal error: tool can correctly extract data only for build %u or later (detected: %u)!\n", MIN_SUPPORTED_BUILD, build); + exit(1); + } + return build; } -uint32 ReadMapDBC() +uint32 ReadMapDBC(int const locale) { - printf("Read Map.dbc file... "); - DBCFile dbc("DBFilesClient\\Map.dbc"); + HANDLE localeFile; + char localMPQ[512]; + sprintf(localMPQ, "%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]); + if (!SFileOpenArchive(localMPQ, 0, MPQ_OPEN_READ_ONLY, &localeFile)) + exit(1); + printf("Read Map.dbc file... "); + + HANDLE dbcFile; + if (!SFileOpenFileEx(localeFile, "DBFilesClient\\Map.dbc", SFILE_OPEN_PATCHED_FILE, &dbcFile)) + { + printf("Fatal error: Cannot find Map.dbc in archive!\n"); + exit(1); + } + + DBCFile dbc(dbcFile); if(!dbc.open()) { printf("Fatal error: Invalid Map.dbc file format!\n"); @@ -226,10 +296,24 @@ uint32 ReadMapDBC() return map_count; } -void ReadAreaTableDBC() +void ReadAreaTableDBC(int const locale) { + HANDLE localeFile; + char localMPQ[512]; + sprintf(localMPQ, "%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]); + if (!SFileOpenArchive(localMPQ, 0, MPQ_OPEN_READ_ONLY, &localeFile)) + exit(1); + printf("Read AreaTable.dbc file..."); - DBCFile dbc("DBFilesClient\\AreaTable.dbc"); + + HANDLE dbcFile; + if (!SFileOpenFileEx(localeFile, "DBFilesClient\\AreaTable.dbc", SFILE_OPEN_PATCHED_FILE, &dbcFile)) + { + printf("Fatal error: Cannot find AreaTable.dbc in archive!\n"); + exit(1); + } + + DBCFile dbc(dbcFile); if(!dbc.open()) { @@ -250,10 +334,24 @@ void ReadAreaTableDBC() printf("Done! (%u areas loaded)\n", area_count); } -void ReadLiquidTypeTableDBC() +void ReadLiquidTypeTableDBC(int const locale) { + HANDLE localeFile; + char localMPQ[512]; + sprintf(localMPQ, "%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]); + if (!SFileOpenArchive(localMPQ, 0, MPQ_OPEN_READ_ONLY, &localeFile)) + exit(1); + printf("Read LiquidType.dbc file..."); - DBCFile dbc("DBFilesClient\\LiquidType.dbc"); + + HANDLE dbcFile; + if (!SFileOpenFileEx(localeFile, "DBFilesClient\\LiquidType.dbc", SFILE_OPEN_PATCHED_FILE, &dbcFile)) + { + printf("Fatal error: Cannot find LiquidType.dbc in archive!\n"); + exit(1); + } + + DBCFile dbc(dbcFile); if(!dbc.open()) { printf("Fatal error: Invalid LiquidType.dbc file format!\n"); @@ -370,16 +468,9 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32 { ADT_file adt; - if (!adt.loadFile(filename)) + if (!adt.loadFile(filename, false)) return false; - adt_MCIN *cells = adt.a_grid->getMCIN(); - if (!cells) - { - printf("Can't find cells in '%s'\n", filename); - return false; - } - memset(liquid_show, 0, sizeof(liquid_show)); memset(liquid_type, 0, sizeof(liquid_type)); @@ -394,7 +485,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32 { for(int j=0;jgetMCNK(i,j); + adt_MCNK * cell = adt.cells[i][j]; uint32 areaid = cell->areaid; if(areaid && areaid <= maxAreaId) { @@ -449,7 +540,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32 { for(int j=0;jgetMCNK(i,j); + adt_MCNK * cell = adt.cells[i][j]; if (!cell) continue; // Height values for triangles stored in order: @@ -691,7 +782,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32 { for(int j=0;jgetMCNK(i, j); + adt_MCNK *cell = adt.cells[i][j]; if (!cell) continue; @@ -836,7 +927,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32 { for(int j = 0; j < ADT_CELLS_PER_GRID; ++j) { - adt_MCNK * cell = cells->getMCNK(i,j); + adt_MCNK * cell = adt.cells[i][j]; if(!cell) continue; holes[i][j] = cell->holes; @@ -898,18 +989,18 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32 return true; } -void ExtractMapsFromMpq(uint32 build) +void ExtractMapsFromMpq(uint32 build, const int locale) { char mpq_filename[1024]; char output_filename[1024]; char mpq_map_name[1024]; - printf("Extracting maps...\n"); + printf("\nExtracting maps...\n"); - uint32 map_count = ReadMapDBC(); + uint32 map_count = ReadMapDBC(locale); - ReadAreaTableDBC(); - ReadLiquidTypeTableDBC(); + ReadAreaTableDBC(locale); + ReadLiquidTypeTableDBC(locale); std::string path = output_path; path += "/maps/"; @@ -923,10 +1014,7 @@ void ExtractMapsFromMpq(uint32 build) sprintf(mpq_map_name, "World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name); WDT_file wdt; if (!wdt.loadFile(mpq_map_name, false)) - { -// printf("Error loading %s map wdt data\n", map_ids[z].name); continue; - } for(uint32 y = 0; y < WDT_MAP_SIZE; ++y) { @@ -934,6 +1022,7 @@ void ExtractMapsFromMpq(uint32 build) { if (!wdt.main->adt_list[y][x].exist) continue; + sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y); sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x); ConvertADT(mpq_filename, output_filename, y, x, build); @@ -946,22 +1035,6 @@ void ExtractMapsFromMpq(uint32 build) delete [] map_ids; } -bool ExtractFile( char const* mpq_name, std::string const& filename ) -{ - FILE *output = fopen(filename.c_str(), "wb"); - if(!output) - { - printf("Can't create the output file '%s'\n", filename.c_str()); - return false; - } - MPQFile m(mpq_name); - if(!m.isEof()) - fwrite(m.getPointer(), 1, m.getSize(), output); - - fclose(output); - return true; -} - void ExtractDBCFiles(int locale, bool basicLocale) { printf("Extracting dbc files...\n"); @@ -969,19 +1042,17 @@ void ExtractDBCFiles(int locale, bool basicLocale) std::set dbcfiles; // get DBC file list - for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) + ArchiveSetBounds archives = GetArchivesBounds(); + for(ArchiveSet::const_iterator i = archives.first; i != archives.second;++i) { - vector files; - (*i)->GetFileListTo(files); - for (vector::iterator iter = files.begin(); iter != files.end(); ++iter) - if (iter->rfind(".dbc") == iter->length() - strlen(".dbc")) - dbcfiles.insert(*iter); + AppendDBCFileListTo(*i, dbcfiles); + AppendDB2FileListTo(*i, dbcfiles); } std::string path = output_path; path += "/dbc/"; CreateDir(path); - if(!basicLocale) + if (!basicLocale) { path += langs[locale]; path += "/"; @@ -990,60 +1061,169 @@ void ExtractDBCFiles(int locale, bool basicLocale) // extract Build info file { - string mpq_name = std::string("component.wow-") + langs[locale] + ".txt"; - string filename = path + mpq_name; + std::string mpq_name = std::string("component.wow-") + langs[locale] + ".txt"; + std::string filename = path + mpq_name; ExtractFile(mpq_name.c_str(), filename); } // extract DBCs int count = 0; - for (set::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) + for (std::set::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) { - string filename = path; + std::string filename = path; filename += (iter->c_str() + strlen("DBFilesClient\\")); - if(ExtractFile(iter->c_str(), filename)) + if (ExtractFile(iter->c_str(), filename)) ++count; } - printf("Extracted %u DBC files\n\n", count); + printf("Extracted %u DBC/DB2 files\n\n", count); +} + +typedef std::pair UpdatesPair; +typedef std::map Updates; + +void AppendPatchMPQFilesToList(char const* subdir, char const* suffix, char const* section, Updates& updates) +{ + char dirname[512]; + if (subdir) + sprintf(dirname,"%s/Data/%s", input_path, subdir); + else + sprintf(dirname,"%s/Data", input_path); + + char scanname[512]; + if (suffix) + sprintf(scanname,"wow-update-%s-%%u.MPQ", suffix); + else + sprintf(scanname,"wow-update-%%u.MPQ"); + +#ifdef WIN32 + + char maskname[512]; + if (suffix) + sprintf(maskname,"%s/wow-update-%s-*.MPQ", dirname, suffix); + else + sprintf(maskname,"%s/wow-update-*.MPQ", dirname); + + WIN32_FIND_DATA ffd; + HANDLE hFind = FindFirstFile(maskname, &ffd); + + if (hFind != INVALID_HANDLE_VALUE) + { + do + { + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + continue; + + uint32 ubuild = 0; + if (sscanf(ffd.cFileName, scanname, &ubuild) == 1 && (!CONF_max_build || ubuild <= CONF_max_build)) + updates[ubuild] = UpdatesPair(ffd.cFileName, section); + } + while (FindNextFile(hFind, &ffd) != 0); + + FindClose(hFind); + } + +#else + + if (DIR *dp = opendir(dirname)) + { + int ubuild = 0; + dirent *dirp; + while ((dirp = readdir(dp)) != NULL) + if (sscanf(dirp->d_name, scanname, &ubuild) == 1 && (!CONF_max_build || ubuild <= CONF_max_build)) + updates[ubuild] = UpdatesPair(dirp->d_name, section); + + closedir(dp); + } + +#endif } void LoadLocaleMPQFiles(int const locale) { char filename[512]; + // first base old version of dbc files sprintf(filename,"%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]); - new MPQArchive(filename); - for(int i = 1; i < 5; ++i) + HANDLE localeMpqHandle; + + if (!OpenArchive(filename, &localeMpqHandle)) { - char ext[3] = ""; - if(i > 1) - sprintf(ext, "-%i", i); + printf("Error open archive: %s\n\n", filename); + return; + } - sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext); - if(FileExists(filename)) - new MPQArchive(filename); + // prepare sorted list patches in locale dir and Data root + Updates updates; + // now update to newer view, locale + AppendPatchMPQFilesToList(langs[locale], langs[locale], NULL, updates); + // now update to newer view, root + AppendPatchMPQFilesToList(NULL, NULL, langs[locale], updates); + + for (Updates::const_iterator itr = updates.begin(); itr != updates.end(); ++itr) + { + if (!itr->second.second) + sprintf(filename,"%s/Data/%s/%s", input_path, langs[locale], itr->second.first.c_str()); + else + sprintf(filename,"%s/Data/%s", input_path, itr->second.first.c_str()); + + //if (!OpenArchive(filename)) + if (!SFileOpenPatchArchive(localeMpqHandle, filename, itr->second.second ? itr->second.second : "", 0)) + printf("Error open patch archive: %s\n\n", filename); } } -void LoadCommonMPQFiles() +void LoadBaseMPQFiles() { char filename[512]; - int count = sizeof(CONF_mpq_list)/sizeof(char*); - for(int i = 0; i < count; ++i) - { - sprintf(filename, "%s/Data/%s", input_path, CONF_mpq_list[i]); - if(FileExists(filename)) - new MPQArchive(filename); - } -} + HANDLE worldMpqHandle; -inline void CloseMPQFiles() -{ - for(ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end();++j) (*j)->close(); - gOpenArchives.clear(); + printf("Loaded MPQ files for map extraction:\n"); + for (int i = 1; i <= WORLD_COUNT; i++) + { + sprintf(filename, "%s/Data/World%s.MPQ", input_path, (i == 2 ? "2" : "")); + printf("%s\n", filename); + + if (!OpenArchive(filename, &worldMpqHandle)) + { + printf("Error open archive: %s\n\n", filename); + return; + } + } + + for (int i = 1; i <= EXPANSION_COUNT; i++) + { + sprintf(filename, "%s/Data/Expansion%i.MPQ", input_path, i); + printf("%s\n", filename); + + if (!OpenArchive(filename, &worldMpqHandle)) + { + printf("Error open archive: %s\n\n", filename); + return; + } + } + + // prepare sorted list patches in Data root + Updates updates; + // now update to newer view, root -base + AppendPatchMPQFilesToList(NULL, NULL, "base", updates); + // now update to newer view, root -base + AppendPatchMPQFilesToList(NULL, "base", NULL, updates); + + for (Updates::const_iterator itr = updates.begin(); itr != updates.end(); ++itr) + { + sprintf(filename,"%s/Data/%s", input_path, itr->second.first.c_str()); + + printf("%s\n", filename); + + if (!OpenArchive(filename, &worldMpqHandle)) + { + printf("Error open patch archive: %s\n\n", filename); + return; + } + } } int main(int argc, char * arg[]) @@ -1087,7 +1267,7 @@ int main(int argc, char * arg[]) ExtractDBCFiles(i, false); //Close MPQs - CloseMPQFiles(); + CloseArchives(); } } @@ -1102,14 +1282,14 @@ int main(int argc, char * arg[]) printf("Using locale: %s\n", langs[FirstLocale]); // Open MPQs + LoadBaseMPQFiles(); LoadLocaleMPQFiles(FirstLocale); - LoadCommonMPQFiles(); // Extract maps - ExtractMapsFromMpq(build); + ExtractMapsFromMpq(build, FirstLocale); // Close MPQs - CloseMPQFiles(); + CloseArchives(); } return 0; diff --git a/contrib/extractor/VC100_AD.sln b/contrib/extractor/VC100_AD.sln index 0c148470f..cebb3efa2 100644 --- a/contrib/extractor/VC100_AD.sln +++ b/contrib/extractor/VC100_AD.sln @@ -1,6 +1,11 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ad", "VC100_ad.vcxproj", "{D7552D4F-408F-4F8E-859B-366659150CF4}" + ProjectSection(ProjectDependencies) = postProject + {78424708-1F6E-4D4B-920C-FB6D26847055} = {78424708-1F6E-4D4B-920C-FB6D26847055} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib", "..\..\dep\StormLib\StormLib.vcxproj", "{78424708-1F6E-4D4B-920C-FB6D26847055}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -12,6 +17,10 @@ Global {D7552D4F-408F-4F8E-859B-366659150CF4}.Debug|Win32.Build.0 = Debug|Win32 {D7552D4F-408F-4F8E-859B-366659150CF4}.Release|Win32.ActiveCfg = Release|Win32 {D7552D4F-408F-4F8E-859B-366659150CF4}.Release|Win32.Build.0 = Release|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.ActiveCfg = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.Build.0 = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.ActiveCfg = ReleaseAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.Build.0 = ReleaseAS|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/contrib/extractor/VC100_ad.vcxproj b/contrib/extractor/VC100_ad.vcxproj index 9b5bde66f..92ea65ad9 100644 --- a/contrib/extractor/VC100_ad.vcxproj +++ b/contrib/extractor/VC100_ad.vcxproj @@ -52,6 +52,7 @@ AllRules.ruleset + ad_debug @@ -65,7 +66,7 @@ Disabled - libmpq;%(AdditionalIncludeDirectories) + ..\..\dep\StormLib\src;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -87,11 +88,10 @@ 0x0419 - zlib.lib;%(AdditionalDependencies) + StormLibDAS.lib;%(AdditionalDependencies) + ..\..\dep\StormLib\bin\StormLib\$(Platform)\$(Configuration)AS;%(AdditionalLibraryDirectories) ad_debug.exe true - ./debug/;%(AdditionalLibraryDirectories) - LIBCD.lib;%(IgnoreSpecificDefaultLibraries) true ./ad_debug.pdb Console @@ -114,7 +114,7 @@ Full OnlyExplicitInline - libmpq;%(AdditionalIncludeDirectories) + ..\..\dep\StormLib\src;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) MultiThreaded @@ -132,11 +132,10 @@ 0x0419 - zlib.lib;%(AdditionalDependencies) + StormLibRAS.lib;%(AdditionalDependencies) + ..\..\dep\StormLib\bin\StormLib\$(Platform)\$(Configuration)AS;%(AdditionalLibraryDirectories) ./ad.exe true - ./release/;%(AdditionalLibraryDirectories) - LIBC.lib;%(IgnoreSpecificDefaultLibraries) ./ad.pdb Console false @@ -147,36 +146,15 @@ - - - - - - - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - true - Full - %(PreprocessorDefinitions) - - + - - - - - - diff --git a/contrib/extractor/VC100_ad.vcxproj.filters b/contrib/extractor/VC100_ad.vcxproj.filters index a32c32c76..a772a4e06 100644 --- a/contrib/extractor/VC100_ad.vcxproj.filters +++ b/contrib/extractor/VC100_ad.vcxproj.filters @@ -14,39 +14,15 @@ Source Files - - Source Files - Source Files - - Source Files - - - Source Files - - - Source Files - Source Files - - Source Files - - - Source Files - - - Source Files - Source Files - - Source Files - Source Files @@ -55,30 +31,12 @@ Header Files - - Header Files - Header Files - - Header Files - - - Header Files - Header Files - - Header Files - - - Header Files - - - Header Files - Header Files diff --git a/contrib/extractor/VC90_AD.sln b/contrib/extractor/VC90_AD.sln index 68dd66e1f..657e0e58d 100644 --- a/contrib/extractor/VC90_AD.sln +++ b/contrib/extractor/VC90_AD.sln @@ -1,6 +1,11 @@ Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ad", "VC90_ad.vcproj", "{D7552D4F-408F-4F8E-859B-366659150CF4}" + ProjectSection(ProjectDependencies) = postProject + {78424708-1F6E-4D4B-920C-FB6D26847055} = {78424708-1F6E-4D4B-920C-FB6D26847055} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib", "..\..\dep\StormLib\StormLib.vcproj", "{78424708-1F6E-4D4B-920C-FB6D26847055}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -12,6 +17,10 @@ Global {D7552D4F-408F-4F8E-859B-366659150CF4}.Debug|Win32.Build.0 = Debug|Win32 {D7552D4F-408F-4F8E-859B-366659150CF4}.Release|Win32.ActiveCfg = Release|Win32 {D7552D4F-408F-4F8E-859B-366659150CF4}.Release|Win32.Build.0 = Release|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.ActiveCfg = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.Build.0 = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.ActiveCfg = ReleaseAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.Build.0 = ReleaseAS|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/contrib/extractor/VC90_ad.vcproj b/contrib/extractor/VC90_ad.vcproj index 9317a60c0..c0a2cb880 100644 --- a/contrib/extractor/VC90_ad.vcproj +++ b/contrib/extractor/VC90_ad.vcproj @@ -49,7 +49,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/extractor/ad b/contrib/extractor/ad deleted file mode 100755 index 564eceaaa..000000000 Binary files a/contrib/extractor/ad and /dev/null differ diff --git a/contrib/extractor/ad.exe b/contrib/extractor/ad.exe index 135a06f77..3bfbdfc45 100755 Binary files a/contrib/extractor/ad.exe and b/contrib/extractor/ad.exe differ diff --git a/contrib/extractor/dbcfile.cpp b/contrib/extractor/dbcfile.cpp index 9e42f876b..fd828527d 100644 --- a/contrib/extractor/dbcfile.cpp +++ b/contrib/extractor/dbcfile.cpp @@ -1,7 +1,7 @@ #define _CRT_SECURE_NO_DEPRECATE #include "dbcfile.h" -#include "mpq_libmpq.h" +#include "loadlib/loadlib.h" DBCFile::DBCFile(const std::string &filename): filename(filename), @@ -9,43 +9,81 @@ DBCFile::DBCFile(const std::string &filename): { } + +DBCFile::DBCFile(HANDLE file) : fileHandle(file), data(0) +{ + +} + bool DBCFile::open() { - MPQFile f(filename.c_str()); + //if (!OpenNewestFile(filename.c_str(), &fileHandle)) + // return false; + char header[4]; unsigned int na,nb,es,ss; - if(f.read(header,4)!=4) // Number of records + if (!SFileReadFile(fileHandle, header, 4, NULL, NULL)) // Magic header + { + SFileCloseFile(fileHandle); return false; + } - if(header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3]!='C') + if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3]!='C') + { + SFileCloseFile(fileHandle); return false; + } - if(f.read(&na,4)!=4) // Number of records + if (!SFileReadFile(fileHandle, &na, 4, NULL, NULL)) // Number of records + { + SFileCloseFile(fileHandle); return false; - if(f.read(&nb,4)!=4) // Number of fields + } + + if (!SFileReadFile(fileHandle, &nb, 4, NULL, NULL)) // Number of fields + { + SFileCloseFile(fileHandle); return false; - if(f.read(&es,4)!=4) // Size of a record + } + + if (!SFileReadFile(fileHandle, &es, 4, NULL, NULL)) // Size of a record + { + SFileCloseFile(fileHandle); return false; - if(f.read(&ss,4)!=4) // String size + } + + if (!SFileReadFile(fileHandle, &ss, 4, NULL, NULL)) // String size + { + SFileCloseFile(fileHandle); return false; + } recordSize = es; recordCount = na; fieldCount = nb; stringSize = ss; - if(fieldCount*4 != recordSize) + if (fieldCount * 4 != recordSize) + { + SFileCloseFile(fileHandle); return false; + } data = new unsigned char[recordSize*recordCount+stringSize]; stringTable = data + recordSize*recordCount; size_t data_size = recordSize*recordCount+stringSize; - if(f.read(data,data_size)!=data_size) + + if (!SFileReadFile(fileHandle, data, data_size, NULL, NULL)) + { + SFileCloseFile(fileHandle); return false; - f.close(); + } + + SFileCloseFile(fileHandle); return true; } + DBCFile::~DBCFile() { delete [] data; diff --git a/contrib/extractor/dbcfile.h b/contrib/extractor/dbcfile.h index 4af2606af..b6db76e59 100644 --- a/contrib/extractor/dbcfile.h +++ b/contrib/extractor/dbcfile.h @@ -3,10 +3,17 @@ #include #include +#ifdef _DLL +#undef _DLL +#endif + +#include "StormLib.h" + class DBCFile { public: DBCFile(const std::string &filename); + DBCFile(HANDLE file); ~DBCFile(); // Open database. It must be openened before it can be used. @@ -107,6 +114,7 @@ public: size_t getMaxId(); private: std::string filename; + HANDLE fileHandle; size_t recordSize; size_t recordCount; size_t fieldCount; diff --git a/contrib/extractor/debug/zlib.lib b/contrib/extractor/debug/zlib.lib deleted file mode 100644 index ffd7d9a26..000000000 Binary files a/contrib/extractor/debug/zlib.lib and /dev/null differ diff --git a/contrib/extractor/libmpq/CMakeLists.txt b/contrib/extractor/libmpq/CMakeLists.txt deleted file mode 100644 index 09682ae66..000000000 --- a/contrib/extractor/libmpq/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (C) 2005-2012 MaNGOS project -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -add_library (libmpq common.cpp explode.cpp extract.cpp huffman.cpp mpq.cpp parser.cpp wave.cpp ) -# link libmpq with zlib -target_link_libraries (libmpq z) diff --git a/contrib/extractor/libmpq/common.cpp b/contrib/extractor/libmpq/common.cpp deleted file mode 100644 index bcb83f071..000000000 --- a/contrib/extractor/libmpq/common.cpp +++ /dev/null @@ -1,792 +0,0 @@ -/* - * common.c -- shared functions used by mpq-tools. - * - * Copyright (C) 2003 Maik Broemme - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id: common.c,v 1.12 2004/02/12 00:42:54 mbroemme Exp $ - */ -#define _CRT_SECURE_NO_DEPRECATE -//#include -#include - -#ifndef WIN32 -#include -#endif - -#include -#include -#include -#include "mpq.h" -#include "common.h" -#include - -unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos) -{ -#ifdef WIN32 - return (unsigned int)_lseeki64(mpq_a->fd, pos, SEEK_SET); -#elif defined(__APPLE__) - return (unsigned int)lseek(mpq_a->fd, pos, SEEK_SET); -#else - return (unsigned int)lseek64(mpq_a->fd, pos, SEEK_SET); -#endif -} - -/* - * This function decrypts a MPQ block. - */ -int libmpq_decrypt_block(mpq_archive *mpq_a, unsigned int *block, unsigned int length, unsigned int seed1) { - unsigned int seed2 = 0xEEEEEEEE; - unsigned int ch; - - /* Round to unsigned int's */ - length >>= 2; - while (length-- > 0) { - seed2 += mpq_a->buf[0x400 + (seed1 & 0xFF)]; - ch = *block ^ (seed1 + seed2); - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - *block++ = ch; - } - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function decrypts the hashtable for the - * file informations. - */ -int libmpq_decrypt_hashtable(mpq_archive *mpq_a, unsigned char *pbKey) { - unsigned int seed1 = 0x7FED7FED; - unsigned int seed2 = 0xEEEEEEEE; - unsigned int ch; /* One key character */ - unsigned int *pdwTable = (unsigned int *)(mpq_a->hashtable); - unsigned int length = mpq_a->header->hashtablesize * 4; - - /* Prepare seeds */ - while (*pbKey != 0) { - ch = toupper(*pbKey++); - seed1 = mpq_a->buf[0x300 + ch] ^ (seed1 + seed2); - seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3; - } - - /* Decrypt it */ - seed2 = 0xEEEEEEEE; - while (length-- > 0) { - seed2 += mpq_a->buf[0x400 + (seed1 & 0xFF)]; - ch = *pdwTable ^ (seed1 + seed2); - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - *pdwTable++ = ch; - } - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function decrypts the blocktable. - */ -int libmpq_decrypt_blocktable(mpq_archive *mpq_a, unsigned char *pbKey) { - unsigned int seed1 = 0x7FED7FED; - unsigned int seed2 = 0xEEEEEEEE; - unsigned int ch; /* One key character */ - unsigned int *pdwTable = (unsigned int *)(mpq_a->blocktable); - unsigned int length = mpq_a->header->blocktablesize * 4; - - /* Prepare seeds */ - while(*pbKey != 0) { - ch = toupper(*pbKey++); - seed1 = mpq_a->buf[0x300 + ch] ^ (seed1 + seed2); - seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3; - } - - /* Decrypt it */ - seed2 = 0xEEEEEEEE; - while(length-- > 0) { - seed2 += mpq_a->buf[0x400 + (seed1 & 0xFF)]; - ch = *pdwTable ^ (seed1 + seed2); - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - *pdwTable++ = ch; - } - return LIBMPQ_TOOLS_SUCCESS; -} - -int libmpq_read_listfile(mpq_archive *mpq_a, FILE *fp) { - int mpq_size; - int mpq_ht_size; - int mpq_bt_size; - int mpq_blocksize; - int mpq_files; - int mpq_csize; - int mpq_fsize; - int entries; - char listdb_version[10]; - char libmpq_version[10]; - int listdb_temp_version = 0; - int libmpq_temp_version = 0; - - /* first check header and version */ - if (libmpq_conf_get_value(fp, "LIBMPQ_VERSION", mpq_a->mpq_l->mpq_version, LIBMPQ_CONF_TYPE_CHAR, sizeof(mpq_a->mpq_l->mpq_version))) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } else { - - /* copy to temp buffer for removing . characters */ - sprintf(listdb_version, (char *)mpq_a->mpq_l->mpq_version); - - /* remove . characters from listfile version */ - libmpq_conf_delete_char(listdb_version, "."); - - /* get libmpq version */ - sprintf(libmpq_version, "%i%i%i",LIBMPQ_MAJOR_VERSION, LIBMPQ_MINOR_VERSION, LIBMPQ_PATCH_VERSION); - - /* convert to number */ - listdb_temp_version = atoi(listdb_version); - libmpq_temp_version = atoi(libmpq_version); - - /* check if installed libmpq version is valid for listfile version */ - if ((libmpq_temp_version < listdb_temp_version) || (libmpq_temp_version == 0) || (listdb_temp_version == 0)) { - return LIBMPQ_CONF_EFILE_VERSION; - } - } - - /* check listfile header, the following entries must be set */ - if (libmpq_conf_get_value(fp, "MPQ_SIZE", &mpq_size, LIBMPQ_CONF_TYPE_INT, 0)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_HASHTABLE_SIZE", &mpq_ht_size, LIBMPQ_CONF_TYPE_INT, 0)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_BLOCKTABLE_SIZE", &mpq_bt_size, LIBMPQ_CONF_TYPE_INT, 0)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_BLOCKSIZE", &mpq_blocksize, LIBMPQ_CONF_TYPE_INT, 0)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_FILES", &mpq_files, LIBMPQ_CONF_TYPE_INT, 0)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_COMPRESSED_SIZE", &mpq_csize, LIBMPQ_CONF_TYPE_INT, 0)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_UNCOMPRESSED_SIZE", &mpq_fsize, LIBMPQ_CONF_TYPE_INT, 0)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_NAME", mpq_a->mpq_l->mpq_name, LIBMPQ_CONF_TYPE_CHAR, PATH_MAX)) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - if (libmpq_conf_get_value(fp, "MPQ_TYPE", mpq_a->mpq_l->mpq_type, LIBMPQ_CONF_TYPE_CHAR, sizeof(mpq_a->mpq_l->mpq_type))) { - return LIBMPQ_CONF_EFILE_CORRUPT; - } - - /* these are optional parameters, if they are empty we set the struct members empty */ - libmpq_conf_get_value(fp, "MPQ_GAME", mpq_a->mpq_l->mpq_game, LIBMPQ_CONF_TYPE_CHAR, sizeof(mpq_a->mpq_l->mpq_game)); - libmpq_conf_get_value(fp, "MPQ_GAME_VERSION", mpq_a->mpq_l->mpq_game_version, LIBMPQ_CONF_TYPE_CHAR, sizeof(mpq_a->mpq_l->mpq_game_version)); - - /* check if we found a valid listfile for the given archive */ - if (mpq_a->header->hashtablesize == mpq_ht_size && mpq_a->header->blocktablesize == mpq_bt_size && mpq_a->blocksize == mpq_blocksize && libmpq_archive_info(mpq_a, LIBMPQ_MPQ_ARCHIVE_SIZE) == mpq_size && libmpq_archive_info(mpq_a, LIBMPQ_MPQ_NUMFILES) == mpq_files && libmpq_archive_info(mpq_a, LIBMPQ_MPQ_COMPRESSED_SIZE) == mpq_csize && libmpq_archive_info(mpq_a, LIBMPQ_MPQ_UNCOMPRESSED_SIZE) == mpq_fsize) { - - /* check if the filelist is correct */ - if (!libmpq_conf_get_array(fp, "FILE_NAMES", (char ***)&mpq_a->mpq_l->mpq_files, &entries)) { - - /* we have a corrupt filelist, so return */ - return LIBMPQ_CONF_EFILE_LIST_CORRUPT; - } else { - - /* now check if filelist entries matches number of files in the archive. */ - if (entries != libmpq_archive_info(mpq_a, LIBMPQ_MPQ_NUMFILES)) { - libmpq_free_listfile((char **)mpq_a->mpq_l->mpq_files); - mpq_a->mpq_l->mpq_files = NULL; - return LIBMPQ_CONF_EFILE_LIST_CORRUPT; - } - } - } - - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function frees up the space reserved by libmpq_get_listfile() - */ -int libmpq_free_listfile(char **filelist) { - int i = 0; - while (filelist[i]) { - free(filelist[i++]); - } - free(filelist); - - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function reads the directory and the subdirectories - * of the listfile database and adds a entry to the lisfile - * array. - */ -/*int libmpq_detect_listfile_rec(char path[PATH_MAX], char ***filelist, int *fl_count, int *fl_size) { - char nextpath[PATH_MAX]; - DIR *dp = opendir(path); - FILE *fp; - struct dirent *entry; - struct stat statbuf; - char buf[LIBMPQ_CONF_BUFSIZE]; - - if (dp == NULL) { - return LIBMPQ_CONF_EOPEN_DIR; - } else { - while ((entry = readdir(dp)) != NULL) { - if (strncmp(entry->d_name, ".", 1) == 0 || strncmp(entry->d_name, "..", 2) == 0) { - continue; - } - if (strnlen(path, PATH_MAX) + strnlen(entry->d_name, PATH_MAX) + 2 > sizeof nextpath) { - continue; - } - - snprintf(nextpath, PATH_MAX, "%s/%s", path, entry->d_name); - - // check if file extension matches listdb file extension - if (strncmp(&entry->d_name[strlen(entry->d_name) - strlen(LIBMPQ_CONF_EXT)], LIBMPQ_CONF_EXT, strlen(LIBMPQ_CONF_EXT)) == 0) { - - // check if it is really a listdb file - if ((fp = fopen(nextpath, "r")) != NULL ) { - while (fgets(buf, LIBMPQ_CONF_BUFSIZE, fp) != NULL) { - char *line; - - buf[strlen(buf) - 1] = '\0'; - - // skip whitespace - for (line = buf; isspace(*line); line++) { - continue; - } - - // skip empty line - if (line[0] == '\0') { - continue; - } - - // skip comments - if (line[0] == '#') { - continue; - } - - //search for listdb header; dirty but works :) - if (!strncasecmp(line, LIBMPQ_CONF_HEADER, strlen(LIBMPQ_CONF_HEADER))) { - - // set the next filelist entry to a copy of the file path - (*filelist)[(*fl_count)++] = strdup(nextpath); - - // increase the array size - if ((*fl_count) == (*fl_size)) { - (*filelist) = realloc((*filelist), ((*fl_size) + LIBMPQ_CONF_FL_INCREMENT) * sizeof(char *)); - (*fl_size) += LIBMPQ_CONF_FL_INCREMENT; - } - - // header found so we could stop reading the file. - break; - } - } - fclose(fp); - } - } - - if (stat(nextpath, &statbuf) < 0) { - continue; - } - - // if entry ia a subdirectory, read it - if (S_ISDIR(statbuf.st_mode)) { - libmpq_detect_listfile_rec(nextpath, filelist, fl_count, fl_size); - } - } - closedir(dp); - } - - return LIBMPQ_TOOLS_SUCCESS; -} -*/ - -/* - * This functions tries to get file decryption key. The trick comes from block - * positions which are stored at the begin of each compressed file. We know the - * file size, that means we know number of blocks that means we know the first - * int value in block position. And if we know encrypted and decrypted value, - * we can find the decryption key. - */ -int libmpq_detect_fileseed(mpq_archive *mpq_a, unsigned int *block, unsigned int decrypted) { - unsigned int saveseed1; - unsigned int temp = *block ^ decrypted; /* temp = seed1 + seed2 */ - int i = 0; - temp -= 0xEEEEEEEE; /* temp = seed1 + mpq_a->buf[0x400 + (seed1 & 0xFF)] */ - - for (i = 0; i < 0x100; i++) { /* Try all 255 possibilities */ - unsigned int seed1; - unsigned int seed2 = 0xEEEEEEEE; - unsigned int ch; - - /* Try the first unsigned int's (We exactly know the value) */ - seed1 = temp - mpq_a->buf[0x400 + i]; - seed2 += mpq_a->buf[0x400 + (seed1 & 0xFF)]; - ch = block[0] ^ (seed1 + seed2); - - if (ch != decrypted) { - continue; - } - - /* Add 1 because we are decrypting block positions */ - saveseed1 = seed1 + 1; - - /* - * If OK, continue and test the second value. We don't know exactly the value, - * but we know that the second one has lower 16 bits set to zero - * (no compressed block is larger than 0xFFFF bytes) - */ - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - seed2 += mpq_a->buf[0x400 + (seed1 & 0xFF)]; - ch = block[1] ^ (seed1 + seed2); - if ((ch & 0xFFFF0000) == 0) { - return saveseed1; - } - } - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function initialize the decryption buffer - */ -int libmpq_init_buffer(mpq_archive *mpq_a) { - unsigned int seed = 0x00100001; - unsigned int index1 = 0; - unsigned int index2 = 0; - int i; - - memset(mpq_a->buf, 0, sizeof(mpq_a->buf)); - - /* Initialize the decryption buffer. */ - for (index1 = 0; index1 < 0x100; index1++) { - for(index2 = index1, i = 0; i < 5; i++, index2 += 0x100) { - unsigned int temp1, temp2; - seed = (seed * 125 + 3) % 0x2AAAAB; - temp1 = (seed & 0xFFFF) << 0x10; - - seed = (seed * 125 + 3) % 0x2AAAAB; - temp2 = (seed & 0xFFFF); - - mpq_a->buf[index2] = (temp1 | temp2); - } - } - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This functions fills the mpq_hash structure with the - * hashtable found in the MPQ file. The hashtable will - * be decrypted for later use. - */ -int libmpq_read_hashtable(mpq_archive *mpq_a) { - unsigned int bytes = 0; - int rb = 0; - - /* - * Allocate memory. Note that the block table should be as large as the - * hash table. (for later file additions) - */ - mpq_a->hashtable = (mpq_hash *)malloc(sizeof(mpq_hash) * mpq_a->header->hashtablesize); - - if (!mpq_a->hashtable) { - return LIBMPQ_EALLOCMEM; - } - - /* Read the hash table into the buffer */ - bytes = mpq_a->header->hashtablesize * sizeof(mpq_hash); - - libmpq_lseek(mpq_a, mpq_a->header->hashtablepos); - - rb = _read(mpq_a->fd, mpq_a->hashtable, bytes); - if (rb != bytes) { - return LIBMPQ_EFILE_CORRUPT; - } - - /* Decrypt hash table and check if it is correctly decrypted */ - mpq_hash *mpq_h_end = mpq_a->hashtable + mpq_a->header->hashtablesize; - mpq_hash *mpq_h = NULL; - - libmpq_decrypt_hashtable(mpq_a, (unsigned char *)"(hash table)"); - - /* Check hash table if is correctly decrypted */ - for (mpq_h = mpq_a->hashtable; mpq_h < mpq_h_end; mpq_h++) { - if (mpq_h->locale != 0xFFFFFFFF && (mpq_h->locale & 0xFFFF0000) != 0) { - return LIBMPQ_EFILE_FORMAT; - } - - /* Remember the highest block table entry */ - if (mpq_h->blockindex < LIBMPQ_HASH_ENTRY_DELETED && mpq_h->blockindex > 0) { - mpq_a->maxblockindex = mpq_h->blockindex; - } - } - - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This functions fills the mpq_block structure with the - * blocktable found in the MPQ file. The blocktable will - * be decrypted for later use. - * - * NOTICE: Some MPQs have decrypted block table, e.g. - * cracked Diablo versions. - */ -int libmpq_read_blocktable(mpq_archive *mpq_a) { - unsigned int bytes = 0; - int rb = 0; - - /* - * Allocate memory. Note that the block table should be as large as the - * hash table. (for later file additions) - */ - mpq_a->blocktable = (mpq_block *)malloc(sizeof(mpq_block) * mpq_a->header->hashtablesize); - mpq_a->blockbuf = (unsigned char *)malloc(mpq_a->blocksize); - - if (!mpq_a->blocktable || !mpq_a->blockbuf) { - return LIBMPQ_EALLOCMEM; - } - - /* Read the block table into the buffer */ - bytes = mpq_a->header->blocktablesize * sizeof(mpq_block); - memset(mpq_a->blocktable, 0, mpq_a->header->blocktablesize * sizeof(mpq_block)); - - libmpq_lseek(mpq_a, mpq_a->header->blocktablepos); - - rb = _read(mpq_a->fd, mpq_a->blocktable, bytes); - if (rb != bytes) { - return LIBMPQ_EFILE_CORRUPT; - } - - /* - * Decrypt block table. Some MPQs don't have encrypted block table, - * e.g. cracked Diablo version. We have to check if block table is - * already decrypted - */ - mpq_block *mpq_b_end = mpq_a->blocktable + mpq_a->maxblockindex + 1; - mpq_block *mpq_b = NULL; - unsigned int archivesize = mpq_a->header->archivesize + mpq_a->mpqpos; - - if (mpq_a->header->offset != mpq_a->blocktable->filepos) { - libmpq_decrypt_blocktable(mpq_a, (unsigned char *)"(block table)"); - } - for (mpq_b = mpq_a->blocktable; mpq_b < mpq_b_end; mpq_b++) { - if (mpq_b->filepos > archivesize || mpq_b->csize > archivesize) { - if ((mpq_a->flags & LIBMPQ_FLAG_PROTECTED) == 0) { - return LIBMPQ_EFILE_FORMAT; - } - } - mpq_b->filepos += mpq_a->mpqpos; - } - - return LIBMPQ_TOOLS_SUCCESS; -} - -int libmpq_file_read_block(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int blockpos, char *buffer, unsigned int blockbytes) { - unsigned char *tempbuf = NULL; /* Buffer for reading compressed data from the file */ - unsigned int readpos; /* Reading position from the file */ - unsigned int toread = 0; /* Number of bytes to read */ - unsigned int blocknum; /* Block number (needed for decrypt) */ - unsigned int bytesread = 0; /* Total number of bytes read */ - unsigned int nblocks; /* Number of blocks to load */ - unsigned int i; - - /* Test parameters. Block position and block size must be block-aligned, block size nonzero */ - if ((blockpos & (mpq_a->blocksize - 1)) || blockbytes == 0) { - return 0; - } - - /* Check the end of file */ - if ((blockpos + blockbytes) > mpq_f->mpq_b->fsize) { - blockbytes = mpq_f->mpq_b->fsize - blockpos; - } - blocknum = blockpos / mpq_a->blocksize; - nblocks = blockbytes / mpq_a->blocksize; - if (blockbytes % mpq_a->blocksize) { - nblocks++; - } - - /* If file has variable block positions, we have to load them */ - if ((mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESSED) && mpq_f->blockposloaded == FALSE) { - unsigned int nread; - - if (mpq_f->mpq_b->filepos != mpq_a->filepos) { - libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos); - } - - /* Read block positions from begin of file. */ - nread = (mpq_f->nblocks + 1) * sizeof(int); - nread = _read(mpq_a->fd, mpq_f->blockpos, nread); - - /* - * If the archive is protected some way, perform additional check - * Sometimes, the file appears not to be encrypted, but it is. - */ - /*if (mpq_f->blockpos[0] != nread) { - mpq_f->mpq_b->flags |= LIBMPQ_FILE_ENCRYPTED; - }*/ - - if ((mpq_f->mpq_b->flags & LIBMPQ_FILE_HAS_METADATA) == 0) { - if (mpq_f->blockpos[0] != nread) { - mpq_f->mpq_b->flags |= LIBMPQ_FILE_ENCRYPTED; - } - } - - /* Decrypt loaded block positions if necessary */ - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_ENCRYPTED) { - - /* If we don't know the file seed, try to find it. */ - if (mpq_f->seed == 0) { - mpq_f->seed = libmpq_detect_fileseed(mpq_a, mpq_f->blockpos, nread); - } - - /* If we don't know the file seed, sorry but we cannot extract the file. */ - if (mpq_f->seed == 0) { - return 0; - } - - /* Decrypt block positions */ - libmpq_decrypt_block(mpq_a, mpq_f->blockpos, nread, mpq_f->seed - 1); - - /* - * Check if the block positions are correctly decrypted - * I don't know why, but sometimes it will result invalid - * block positions on some files. - */ - if (mpq_f->blockpos[0] != nread) { - - /* Try once again to detect file seed and decrypt the blocks */ - libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos); - - nread = _read(mpq_a->fd, mpq_f->blockpos, (mpq_f->nblocks + 1) * sizeof(int)); - mpq_f->seed = libmpq_detect_fileseed(mpq_a, mpq_f->blockpos, nread); - libmpq_decrypt_block(mpq_a, mpq_f->blockpos, nread, mpq_f->seed - 1); - - /* Check if the block positions are correctly decrypted. */ - if (mpq_f->blockpos[0] != nread) { - return 0; - } - } - } - - /* Update mpq_f's variables */ - mpq_f->blockposloaded = TRUE; - mpq_a->filepos = mpq_f->mpq_b->filepos + nread; - } - - /* Get file position and number of bytes to read */ - readpos = blockpos; - toread = blockbytes; - - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESSED) { - readpos = mpq_f->blockpos[blocknum]; - toread = mpq_f->blockpos[blocknum + nblocks] - readpos; - } - - readpos += mpq_f->mpq_b->filepos; - - /* Get work buffer for store read data */ - if ((tempbuf = (unsigned char *)malloc(toread)) == NULL) { - /* Hmmm... We should add a better error handling here :) */ - return 0; - } - - /* Set file pointer, if necessary. */ - if (mpq_a->filepos != readpos) { - mpq_a->filepos = libmpq_lseek(mpq_a, readpos); - } - - /* 15018F87 - Read all requested blocks. */ - bytesread = _read(mpq_a->fd, tempbuf, toread); - mpq_a->filepos = readpos + bytesread; - - /* Block processing part. */ - unsigned int blockstart = 0; /* Index of block start in work buffer. */ - unsigned int blocksize = min(blockbytes, mpq_a->blocksize); - unsigned int index = blocknum; /* Current block index. */ - bytesread = 0; /* Clear read byte counter */ - - /* Walk through all blocks. */ - for (i = 0; i < nblocks; i++, index++) { - int outlength = mpq_a->blocksize; - - /* Get current block length */ - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESSED) { - blocksize = mpq_f->blockpos[index + 1] - mpq_f->blockpos[index]; - } - - /* If block is encrypted, we have to decrypt it. */ - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_ENCRYPTED) { - if (mpq_f->seed == 0) { - return 0; - } - libmpq_decrypt_block(mpq_a, (unsigned int *)&tempbuf[blockstart], blocksize, mpq_f->seed + index); - } - - /* - * If the block is really compressed, recompress it. - * WARNING: Some block may not be compressed, it can - * only be determined by comparing uncompressed and - * compressed size! - */ - if (blocksize < blockbytes) { - - /* Is the file compressed with PKWARE Data Compression Library? */ - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESS_PKWARE) { - libmpq_pkzip_decompress(buffer, &outlength, (char *)&tempbuf[blockstart], blocksize); - } - - /* - * Is it a file compressed by Blizzard's multiple compression ? - * Note that Storm.dll v 1.0.9 distributed with Warcraft III - * passes the full path name of the opened archive as the new - * last parameter. - */ - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESS_MULTI) { - libmpq_multi_decompress(buffer, &outlength, (char *)&tempbuf[blockstart], blocksize); - } - bytesread += outlength; - buffer += outlength; - } else { - memcpy(buffer, tempbuf, blocksize); - bytesread += blocksize; - buffer += blocksize; - } - blockstart += blocksize; - } - - /* Delete input buffer, if necessary. */ - free(tempbuf); - - return bytesread; -} - -int libmpq_file_read_file(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int filepos, char *buffer, unsigned int toread) { - unsigned int bytesread = 0; /* Number of bytes read from the file */ - unsigned int blockpos; /* Position in the file aligned to the whole blocks */ - unsigned int loaded = 0; - - /* File position is greater or equal to file size? */ - if (filepos >= mpq_f->mpq_b->fsize) { - return 0; - } - - /* If to few bytes in the file remaining, cut them */ - if ((mpq_f->mpq_b->fsize - filepos) < toread) { - toread = (mpq_f->mpq_b->fsize - filepos); - } - - /* Block position in the file */ - blockpos = filepos & ~(mpq_a->blocksize - 1); - - /* - * Load the first block, if noncomplete. It may be loaded in the cache buffer. - * We have to check if this block is loaded. If not, load it. - */ - if ((filepos % mpq_a->blocksize) != 0) { - /* Number of bytes remaining in the buffer */ - unsigned int tocopy; - unsigned int loaded = mpq_a->blocksize; - - /* Check if data are loaded in the cache */ - if (mpq_f->accessed == FALSE || blockpos != mpq_a->blockpos) { - - /* Load one MPQ block into archive buffer */ - loaded = libmpq_file_read_block(mpq_a, mpq_f, blockpos, (char *)mpq_a->blockbuf, mpq_a->blocksize); - if (loaded == 0) { - return 0; - } - - /* Save lastly accessed file and block position for later use */ - mpq_f->accessed = TRUE; - mpq_a->blockpos = blockpos; - mpq_a->bufpos = filepos % mpq_a->blocksize; - } - tocopy = loaded - mpq_a->bufpos; - if (tocopy > toread) { - tocopy = toread; - } - - /* Copy data from block buffer into target buffer */ - memcpy(buffer, mpq_a->blockbuf + mpq_a->bufpos, tocopy); - - /* Update pointers */ - toread -= tocopy; - bytesread += tocopy; - buffer += tocopy; - blockpos += mpq_a->blocksize; - mpq_a->bufpos += tocopy; - - /* If all, return. */ - if (toread == 0) { - return bytesread; - } - } - - /* Load the whole ("middle") blocks only if there are more or equal one block */ - if (toread > mpq_a->blocksize) { - unsigned int blockbytes = toread & ~(mpq_a->blocksize - 1); - loaded = libmpq_file_read_block(mpq_a, mpq_f, blockpos, buffer, blockbytes); - if (loaded == 0) { - return 0; - } - - /* Update pointers */ - toread -= loaded; - bytesread += loaded; - buffer += loaded; - blockpos += loaded; - - /* If all, return. */ - if (toread == 0) { - return bytesread; - } - } - - /* Load the terminating block */ - if (toread > 0) { - unsigned int tocopy = mpq_a->blocksize; - - /* Check if data are loaded in the cache */ - if (mpq_f->accessed == FALSE || blockpos != mpq_a->blockpos) { - - /* Load one MPQ block into archive buffer */ - tocopy = libmpq_file_read_block(mpq_a, mpq_f, blockpos, (char *)mpq_a->blockbuf, mpq_a->blocksize); - if (tocopy == 0) { - return 0; - } - - /* Save lastly accessed file and block position for later use */ - mpq_f->accessed = TRUE; - mpq_a->blockpos = blockpos; - } - mpq_a->bufpos = 0; - - /* Check number of bytes read */ - if (tocopy > toread) { - tocopy = toread; - } - - memcpy(buffer, mpq_a->blockbuf, tocopy); - bytesread += tocopy; - mpq_a->bufpos = tocopy; - } - - /* Return what we've read */ - return bytesread; -} diff --git a/contrib/extractor/libmpq/common.h b/contrib/extractor/libmpq/common.h deleted file mode 100644 index 57b34e9cd..000000000 --- a/contrib/extractor/libmpq/common.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * common.h -- defines and structs used by the config files. - * - * Copyright (C) 2003 Maik Broemme - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id: common.h,v 1.4 2004/02/12 00:41:55 mbroemme Exp $ - */ - -#define LIBMPQ_CONF_FL_INCREMENT 512 /* i hope we did not need more :) */ -#define LIBMPQ_CONF_EXT ".conf" /* listdb file seems to be valid with this extension */ -#define LIBMPQ_CONF_HEADER "LIBMPQ_VERSION" /* listdb file must include this entry to be valid */ -#define LIBMPQ_CONF_BUFSIZE 4096 /* maximum number of bytes a line in the file could contain */ - -#define LIBMPQ_CONF_TYPE_CHAR 1 /* value in config file is from type char */ -#define LIBMPQ_CONF_TYPE_INT 2 /* value in config file is from type int */ - -#define LIBMPQ_CONF_EOPEN_DIR -1 /* error on open directory */ -#define LIBMPQ_CONF_EVALUE_NOT_FOUND -2 /* value for the option was not found */ - -#if defined( __GNUC__ ) - #include - #include - - #define _lseek lseek - #define _read read - #define _open open - #define _write write - #define _close close - #define _strdup strdup - - #ifndef O_BINARY - #define O_BINARY 0 - #endif -#else - #include -#endif - -#ifdef O_LARGEFILE - #define MPQ_FILE_OPEN_FLAGS (O_RDONLY | O_BINARY | O_LARGEFILE) -#else - #define MPQ_FILE_OPEN_FLAGS (O_RDONLY | O_BINARY) -#endif - -#ifndef min - #define min(a, b) ((a < b) ? a : b) -#endif - -int libmpq_init_buffer(mpq_archive *mpq_a); -int libmpq_read_hashtable(mpq_archive *mpq_a); -int libmpq_read_blocktable(mpq_archive *mpq_a); -int libmpq_file_read_file(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int filepos, char *buffer, unsigned int toread); -int libmpq_read_listfile(mpq_archive *mpq_a, FILE *fp); - -int libmpq_conf_get_value(FILE *fp, char *search_value, void *return_value, int type, int size); -char *libmpq_conf_delete_char(char *buf, char *chars); -int libmpq_conf_get_array(FILE *fp, char *search_value, char ***filelist, int *entries); -int libmpq_free_listfile(char **filelist); -int libmpq_read_listfile(mpq_archive *mpq_a, FILE *fp); - -unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos); diff --git a/contrib/extractor/libmpq/explode.cpp b/contrib/extractor/libmpq/explode.cpp deleted file mode 100644 index 273718ff7..000000000 --- a/contrib/extractor/libmpq/explode.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - * explode.c -- explode function of PKWARE data compression library. - * - * Copyright (C) 2003 Maik Broemme - * - * This source was adepted from the C++ version of pkware.cpp included - * in stormlib. The C++ version belongs to the following authors, - * - * Ladislav Zezula - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "mpq.h" -#include "explode.h" - -/* Tables */ -static unsigned char pkzip_dist_bits[] = { - 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -}; - -static unsigned char pkzip_dist_code[] = { - 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, - 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, - 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, - 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 -}; - -static unsigned char pkzip_clen_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 -}; - -static unsigned short pkzip_len_base[] = { - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, - 0x0008, 0x000A, 0x000E, 0x0016, 0x0026, 0x0046, 0x0086, 0x0106 -}; - -static unsigned char pkzip_slen_bits[] = { - 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 -}; - -static unsigned char pkzip_len_code[] = { - 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 -}; - -static unsigned char pkzip_bits_asc[] = { - 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, - 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, - 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, - 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, - 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, - 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, - 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D -}; - -static unsigned short pkzip_code_asc[] = { - 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, - 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, - 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, - 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, - 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, - 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, - 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, - 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, - 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, - 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, - 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, - 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, - 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, - 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, - 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, - 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, - 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, - 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, - 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, - 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, - 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, - 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, - 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, - 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, - 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, - 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, - 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, - 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, - 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, - 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, - 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 -}; - -/* Local variables */ -static char copyright[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -/* Local functions */ -static void libmpq_pkzip_gen_decode_tabs(long count, unsigned char *bits, unsigned char *code, unsigned char *buf2) { - long i; - - for (i = count-1; i >= 0; i--) { /* EBX - count */ - unsigned long idx1 = code[i]; - unsigned long idx2 = 1 << bits[i]; - do { - buf2[idx1] = (unsigned char)i; - idx1 += idx2; - } while (idx1 < 0x100); - } -} - -static void libmpq_pkzip_gen_asc_tabs(pkzip_data_cmp *mpq_pkzip) { - unsigned short *code_asc = &pkzip_code_asc[0xFF]; - unsigned long acc, add; - unsigned short count; - - for (count = 0x00FF; code_asc >= pkzip_code_asc; code_asc--, count--) { - unsigned char *bits_asc = mpq_pkzip->bits_asc + count; - unsigned char bits_tmp = *bits_asc; - - if (bits_tmp <= 8) { - add = (1 << bits_tmp); - acc = *code_asc; - do { - mpq_pkzip->offs_2c34[acc] = (unsigned char)count; - acc += add; - } while (acc < 0x100); - } else { - if ((acc = (*code_asc & 0xFF)) != 0) { - mpq_pkzip->offs_2c34[acc] = 0xFF; - if (*code_asc & 0x3F) { - bits_tmp -= 4; - *bits_asc = bits_tmp; - add = (1 << bits_tmp); - acc = *code_asc >> 4; - do { - mpq_pkzip->offs_2d34[acc] = (unsigned char)count; - acc += add; - } while (acc < 0x100); - } else { - bits_tmp -= 6; - *bits_asc = bits_tmp; - add = (1 << bits_tmp); - acc = *code_asc >> 6; - do { - mpq_pkzip->offs_2e34[acc] = (unsigned char)count; - acc += add; - } while (acc < 0x80); - } - } else { - bits_tmp -= 8; - *bits_asc = bits_tmp; - add = (1 << bits_tmp); - acc = *code_asc >> 8; - do { - mpq_pkzip->offs_2eb4[acc] = (unsigned char)count; - acc += add; - } while (acc < 0x100); - } - } - } -} - -/* - * Skips given number of bits in bit buffer. Result is stored in mpq_pkzip->bit_buf - * If no data in input buffer, returns true - */ -static int libmpq_pkzip_skip_bits(pkzip_data_cmp *mpq_pkzip, unsigned long bits) { - /* If number of bits required is less than number of (bits in the buffer) ? */ - if (bits <= mpq_pkzip->extra_bits) { - mpq_pkzip->extra_bits -= bits; - mpq_pkzip->bit_buf >>= bits; - return 0; - } - - /* Load input buffer if necessary */ - mpq_pkzip->bit_buf >>= mpq_pkzip->extra_bits; - if (mpq_pkzip->in_pos == mpq_pkzip->in_bytes) { - mpq_pkzip->in_pos = sizeof(mpq_pkzip->in_buf); - if ((mpq_pkzip->in_bytes = mpq_pkzip->read_buf((char *)mpq_pkzip->in_buf, &mpq_pkzip->in_pos, mpq_pkzip->param)) == 0) { - return 1; - } - mpq_pkzip->in_pos = 0; - } - - /* Update bit buffer */ - mpq_pkzip->bit_buf |= (mpq_pkzip->in_buf[mpq_pkzip->in_pos++] << 8); - mpq_pkzip->bit_buf >>= (bits - mpq_pkzip->extra_bits); - mpq_pkzip->extra_bits = (mpq_pkzip->extra_bits - bits) + 8; - return 0; -} - -/* - * Decompress the imploded data using coded literals. - * Returns: 0x000 - 0x0FF : One byte from compressed file. - * 0x100 - 0x305 : Copy previous block (0x100 = 1 byte) - * 0x306 : Out of buffer (?) - */ -static unsigned long libmpq_pkzip_explode_lit(pkzip_data_cmp *mpq_pkzip) { - unsigned long bits; /* Number of bits to skip */ - unsigned long value; /* Position in buffers */ - - /* Test the current bit in byte buffer. If is not set, simply return the next byte. */ - if (mpq_pkzip->bit_buf & 1) { - - /* Skip current bit in the buffer. */ - if (libmpq_pkzip_skip_bits(mpq_pkzip, 1)) { - return 0x306; - } - - /* The next bits are position in buffers. */ - value = mpq_pkzip->pos2[(mpq_pkzip->bit_buf & 0xFF)]; - - /* Get number of bits to skip */ - if (libmpq_pkzip_skip_bits(mpq_pkzip, mpq_pkzip->slen_bits[value])) { - return 0x306; - } - if ((bits = mpq_pkzip->clen_bits[value]) != 0) { - unsigned long val2 = mpq_pkzip->bit_buf & ((1 << bits) - 1); - if (libmpq_pkzip_skip_bits(mpq_pkzip, bits)) { - if ((value + val2) != 0x10E) { - return 0x306; - } - } - value = mpq_pkzip->len_base[value] + val2; - } - return value + 0x100; /* Return number of bytes to repeat */ - } - - /* Skip one bit */ - if (libmpq_pkzip_skip_bits(mpq_pkzip, 1)) { - return 0x306; - } - - /* If the binary compression type, read 8 bits and return them as one byte. */ - if (mpq_pkzip->cmp_type == LIBMPQ_PKZIP_CMP_BINARY) { - value = mpq_pkzip->bit_buf & 0xFF; - if (libmpq_pkzip_skip_bits(mpq_pkzip, 8)) { - return 0x306; - } - return value; - } - - /* When ASCII compression ... */ - if (mpq_pkzip->bit_buf & 0xFF) { - value = mpq_pkzip->offs_2c34[mpq_pkzip->bit_buf & 0xFF]; - if (value == 0xFF) { - if (mpq_pkzip->bit_buf & 0x3F) { - if (libmpq_pkzip_skip_bits(mpq_pkzip, 4)) { - return 0x306; - } - value = mpq_pkzip->offs_2d34[mpq_pkzip->bit_buf & 0xFF]; - } else { - if (libmpq_pkzip_skip_bits(mpq_pkzip, 6)) { - return 0x306; - } - value = mpq_pkzip->offs_2e34[mpq_pkzip->bit_buf & 0x7F]; - } - } - } else { - if (libmpq_pkzip_skip_bits(mpq_pkzip, 8)) { - return 0x306; - } - value = mpq_pkzip->offs_2eb4[mpq_pkzip->bit_buf & 0xFF]; - } - return libmpq_pkzip_skip_bits(mpq_pkzip, mpq_pkzip->bits_asc[value]) ? 0x306 : value; -} - -/* - * Retrieves the number of bytes to move back. - */ -static unsigned long libmpq_pkzip_explode_dist(pkzip_data_cmp *mpq_pkzip, unsigned long length) { - unsigned long pos = mpq_pkzip->pos1[(mpq_pkzip->bit_buf & 0xFF)]; - unsigned long skip = mpq_pkzip->dist_bits[pos]; /* Number of bits to skip */ - - /* Skip the appropriate number of bits */ - if (libmpq_pkzip_skip_bits(mpq_pkzip, skip) == 1) { - return 0; - } - if (length == 2) { - pos = (pos << 2) | (mpq_pkzip->bit_buf & 0x03); - if (libmpq_pkzip_skip_bits(mpq_pkzip, 2) == 1) { - return 0; - } - } else { - pos = (pos << mpq_pkzip->dsize_bits) | (mpq_pkzip->bit_buf & mpq_pkzip->dsize_mask); - - /* Skip the bits */ - if (libmpq_pkzip_skip_bits(mpq_pkzip, mpq_pkzip->dsize_bits) == 1) { - return 0; - } - } - return pos + 1; -} - -static unsigned long libmpq_pkzip_expand(pkzip_data_cmp *mpq_pkzip) { - unsigned int copy_bytes; /* Number of bytes to copy */ - unsigned long one_byte; /* One byte from compressed file */ - unsigned long result; - - mpq_pkzip->out_pos = 0x1000; /* Initialize output buffer position */ - - /* If end of data or error, terminate decompress */ - while ((result = one_byte = libmpq_pkzip_explode_lit(mpq_pkzip)) < 0x305) { - - /* If one byte is greater than 0x100, means "Repeat n - 0xFE bytes" */ - if (one_byte >= 0x100) { - unsigned char *source; /* ECX */ - unsigned char *target; /* EDX */ - unsigned long copy_length = one_byte - 0xFE; - unsigned long move_back; - - /* Get length of data to copy */ - if ((move_back = libmpq_pkzip_explode_dist(mpq_pkzip, copy_length)) == 0) { - result = 0x306; - break; - } - - /* Target and source pointer */ - target = &mpq_pkzip->out_buf[mpq_pkzip->out_pos]; - source = target - move_back; - mpq_pkzip->out_pos += copy_length; - while (copy_length-- > 0) { - *target++ = *source++; - } - } else { - mpq_pkzip->out_buf[mpq_pkzip->out_pos++] = (unsigned char)one_byte; - } - - /* - * If number of extracted bytes has reached 1/2 of output buffer, - * flush output buffer. - */ - if (mpq_pkzip->out_pos >= 0x2000) { - - /* Copy decompressed data into user buffer. */ - copy_bytes = 0x1000; - mpq_pkzip->write_buf((char *)&mpq_pkzip->out_buf[0x1000], ©_bytes, mpq_pkzip->param); - - /* If there are some data left, keep them alive */ - memcpy(mpq_pkzip->out_buf, &mpq_pkzip->out_buf[0x1000], mpq_pkzip->out_pos - 0x1000); - mpq_pkzip->out_pos -= 0x1000; - } - } - copy_bytes = mpq_pkzip->out_pos - 0x1000; - mpq_pkzip->write_buf((char *)&mpq_pkzip->out_buf[0x1000], ©_bytes, mpq_pkzip->param); - return result; -} - -/* - * Main exploding function. - */ -unsigned int libmpq_pkzip_explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param) { - - pkzip_data_cmp *mpq_pkzip = (pkzip_data_cmp *)work_buf; - - /* Set the whole work buffer to zeros */ - memset(mpq_pkzip, 0, sizeof(pkzip_data_cmp)); - - /* Initialize work struct and load compressed data */ - mpq_pkzip->read_buf = read_buf; - mpq_pkzip->write_buf = write_buf; - mpq_pkzip->param = param; - mpq_pkzip->in_pos = sizeof(mpq_pkzip->in_buf); - mpq_pkzip->in_bytes = mpq_pkzip->read_buf((char *)mpq_pkzip->in_buf, &mpq_pkzip->in_pos, mpq_pkzip->param); - if (mpq_pkzip->in_bytes <= 4) { - return LIBMPQ_PKZIP_CMP_BAD_DATA; - } - mpq_pkzip->cmp_type = mpq_pkzip->in_buf[0]; /* Get the compression type */ - mpq_pkzip->dsize_bits = mpq_pkzip->in_buf[1]; /* Get the dictionary size */ - mpq_pkzip->bit_buf = mpq_pkzip->in_buf[2]; /* Initialize 16-bit bit buffer */ - mpq_pkzip->extra_bits = 0; /* Extra (over 8) bits */ - mpq_pkzip->in_pos = 3; /* Position in input buffer */ - - /* Test for the valid dictionary size */ - if (4 > mpq_pkzip->dsize_bits || mpq_pkzip->dsize_bits > 6) { - return LIBMPQ_PKZIP_CMP_INV_DICTSIZE; - } - mpq_pkzip->dsize_mask = 0xFFFF >> (0x10 - mpq_pkzip->dsize_bits); /* Shifted by 'sar' instruction */ - if (mpq_pkzip->cmp_type != LIBMPQ_PKZIP_CMP_BINARY) { - if (mpq_pkzip->cmp_type != LIBMPQ_PKZIP_CMP_ASCII) { - return LIBMPQ_PKZIP_CMP_INV_MODE; - } - memcpy(mpq_pkzip->bits_asc, pkzip_bits_asc, sizeof(mpq_pkzip->bits_asc)); - libmpq_pkzip_gen_asc_tabs(mpq_pkzip); - } - memcpy(mpq_pkzip->slen_bits, pkzip_slen_bits, sizeof(mpq_pkzip->slen_bits)); - libmpq_pkzip_gen_decode_tabs(0x10, mpq_pkzip->slen_bits, pkzip_len_code, mpq_pkzip->pos2); - memcpy(mpq_pkzip->clen_bits, pkzip_clen_bits, sizeof(mpq_pkzip->clen_bits)); - memcpy(mpq_pkzip->len_base, pkzip_len_base, sizeof(mpq_pkzip->len_base)); - memcpy(mpq_pkzip->dist_bits, pkzip_dist_bits, sizeof(mpq_pkzip->dist_bits)); - libmpq_pkzip_gen_decode_tabs(0x40, mpq_pkzip->dist_bits, pkzip_dist_code, mpq_pkzip->pos1); - if (libmpq_pkzip_expand(mpq_pkzip) != 0x306) { - return LIBMPQ_PKZIP_CMP_NO_ERROR; - } - return LIBMPQ_PKZIP_CMP_ABORT; -} diff --git a/contrib/extractor/libmpq/explode.h b/contrib/extractor/libmpq/explode.h deleted file mode 100644 index 1f916f778..000000000 --- a/contrib/extractor/libmpq/explode.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * explode.h -- header file for PKWARE data decompression library - * used by mpq-tools. - * - * Copyright (C) 2003 Maik Broemme - * - * This source was adepted from the C++ version of pklib.h included - * in stormlib. The C++ version belongs to the following authors, - * - * Ladislav Zezula - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _EXPLODE_H -#define _EXPLODE_H - -#define LIBMPQ_PKZIP_EXP_BUFFER_SIZE 12596 /* Size of decompress buffer */ -#define LIBMPQ_PKZIP_CMP_BINARY 0 /* Binary compression */ -#define LIBMPQ_PKZIP_CMP_ASCII 1 /* Ascii compression */ -#define LIBMPQ_PKZIP_CMP_NO_ERROR 0 -#define LIBMPQ_PKZIP_CMP_INV_DICTSIZE 1 -#define LIBMPQ_PKZIP_CMP_INV_MODE 2 -#define LIBMPQ_PKZIP_CMP_BAD_DATA 3 -#define LIBMPQ_PKZIP_CMP_ABORT 4 - -/* Compression structure (size: 12596 bytes on x86-32) */ -typedef struct { - unsigned long offs0000; /* 0000 */ - unsigned long cmp_type; /* 0004 - Compression type (LIBMPQ_PZIP_CMP_BINARY or LIBMPQ_PKZIP_CMP_ASCII) */ - unsigned long out_pos; /* 0008 - Position in output buffer */ - unsigned long dsize_bits; /* 000C - Dict size (4, 5, 6 for 0x400, 0x800, 0x1000) */ - unsigned long dsize_mask; /* 0010 - Dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000) */ - unsigned long bit_buf; /* 0014 - 16-bit buffer for processing input data */ - unsigned long extra_bits; /* 0018 - Number of extra (above 8) bits in bit buffer */ - unsigned int in_pos; /* 001C - Position in in_buf */ - unsigned long in_bytes; /* 0020 - Number of bytes in input buffer */ - void *param; /* 0024 - Custom parameter */ - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); /* 0028 */ - void (*write_buf)(char *buf, unsigned int *size, void *param); /* 002C */ - unsigned char out_buf[0x2000]; /* 0030 - Output circle buffer. Starting position is 0x1000 */ - unsigned char offs_2030[0x204]; /* 2030 - ??? */ - unsigned char in_buf[0x800]; /* 2234 - Buffer for data to be decompressed */ - unsigned char pos1[0x100]; /* 2A34 - Positions in buffers */ - unsigned char pos2[0x100]; /* 2B34 - Positions in buffers */ - unsigned char offs_2c34[0x100]; /* 2C34 - Buffer for */ - unsigned char offs_2d34[0x100]; /* 2D34 - Buffer for */ - unsigned char offs_2e34[0x80]; /* 2EB4 - Buffer for */ - unsigned char offs_2eb4[0x100]; /* 2EB4 - Buffer for */ - unsigned char bits_asc[0x100]; /* 2FB4 - Buffer for */ - unsigned char dist_bits[0x40]; /* 30B4 - Numbers of bytes to skip copied block length */ - unsigned char slen_bits[0x10]; /* 30F4 - Numbers of bits for skip copied block length */ - unsigned char clen_bits[0x10]; /* 3104 - Number of valid bits for copied block */ - unsigned short len_base[0x10]; /* 3114 - Buffer for */ -} pkzip_data_cmp; -// __attribute__ ((packed)) pkzip_data_cmp; - -typedef struct { - char *in_buf; /* Pointer to input data buffer */ - unsigned int in_pos; /* Current offset in input data buffer */ - int in_bytes; /* Number of bytes in the input buffer */ - char *out_buf; /* Pointer to output data buffer */ - unsigned int out_pos; /* Position in the output buffer */ - int max_out; /* Maximum number of bytes in the output buffer */ -} pkzip_data; - -extern unsigned int libmpq_pkzip_explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param -); - -#endif /* _EXPLODE_H */ diff --git a/contrib/extractor/libmpq/extract.cpp b/contrib/extractor/libmpq/extract.cpp deleted file mode 100644 index 41472b3c4..000000000 --- a/contrib/extractor/libmpq/extract.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - * extract.c -- global extracting function for all known file compressions - * in a MPQ archive. - * - * Copyright (C) 2003 Maik Broemme - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#define HAVE_LIBZ -#ifdef HAVE_LIBZ -#include -#endif - -#include "mpq.h" -#include "explode.h" -#include "huffman.h" - -#include "wave.h" - -/* - * Support functions for PKWARE data compression library. - * - * Function loads data from the input buffer. Used by mpq_pkzip - * "implode" and "explode" function as user-defined callback. - * Returns number of bytes loaded. - * - * char * buf - Pointer to a buffer where to store loaded data - * unsigned int * size - Max. number of bytes to read - * void * param - Custom pointer, parameter of implode/explode - */ -static unsigned int libmpq_pkzip_read_input_data(char *buf, unsigned int *size, void *param) { - pkzip_data *info = (pkzip_data *)param; - unsigned int max_avail = (info->in_bytes - info->in_pos); - unsigned int to_read = *size; - - /* Check the case when not enough data available */ - if (to_read > max_avail) { - to_read = max_avail; - } - - /* Load data and increment offsets */ - memcpy(buf, info->in_buf + info->in_pos, to_read); - info->in_pos += to_read; - - return to_read; -} - -/* - * Support functions for PKWARE data compression library. - * - * Function for store output data. Used by mpq_pkzip "implode" and - * "explode" as user-defined callback. - * - * char * buf - Pointer to data to be written - * unsigned int * size - Number of bytes to write - * void * param - Custom pointer, parameter of implode/explode - */ -static void libmpq_pkzip_write_output_data(char *buf, unsigned int *size, void *param) { - pkzip_data *info = (pkzip_data *)param; - unsigned int max_write = (info->max_out - info->out_pos); - unsigned int to_write = *size; - - /* Check the case when not enough space in the output buffer */ - if (to_write > max_write) { - to_write = max_write; - } - - /* Write output data and increments offsets */ - memcpy(info->out_buf + info->out_pos, buf, to_write); - info->out_pos += to_write; -} - -int libmpq_pkzip_decompress(char *out_buf, int *out_length, char *in_buf, int in_length) { - pkzip_data info; /* Data information */ - char *work_buf = (char *)malloc(LIBMPQ_PKZIP_EXP_BUFFER_SIZE); /* mpq_pkzip work buffer */ - - /* Fill data information structure */ - info.in_buf = in_buf; - info.in_pos = 0; - info.in_bytes = in_length; - info.out_buf = out_buf; - info.out_pos = 0; - info.max_out = *out_length; - - /* Do the decompression */ - libmpq_pkzip_explode(libmpq_pkzip_read_input_data, libmpq_pkzip_write_output_data, work_buf, &info); - *out_length = info.out_pos; - free(work_buf); - return 0; -} - -int libmpq_wave_decompress_mono(char *out_buf, int *out_length, char *in_buf, int in_length) { - *out_length = libmpq_wave_decompress((unsigned char *)out_buf, *out_length, (unsigned char *)in_buf, in_length, 1); - return 1; -} - -int libmpq_wave_decompress_stereo(char *out_buf, int *out_length, char *in_buf, int in_length) { - *out_length = libmpq_wave_decompress((unsigned char *)out_buf, *out_length, (unsigned char *)in_buf, in_length, 2); - return 1; -} - -int libmpq_zlib_decompress(char *out_buf, int *out_length, char *in_buf, int in_length) { -#ifdef HAVE_LIBZ - z_stream z; /* Stream information for zlib */ - int result; - - /* Fill the stream structure for zlib */ - z.next_in = (Bytef *)in_buf; - z.avail_in = (uInt)in_length; - z.total_in = in_length; - z.next_out = (Bytef *)out_buf; - z.avail_out = *out_length; - z.total_out = 0; - z.zalloc = NULL; - z.zfree = NULL; - - /* Initialize the decompression structure. Storm.dll uses zlib version 1.1.3 */ - if ((result = inflateInit(&z)) == 0) { - - /* Call zlib to decompress the data */ - result = inflate(&z, Z_FINISH); - *out_length = z.total_out; - inflateEnd(&z); - } - return result; -#else - memset(out_buf, '0', *out_length); - return 0; -#endif -} - -/* - * Huffmann decompression routine. The in_length parameter is not used, but needs - * to be specified due to compatibility reasons. - * - * 1500F5F0 - */ -int libmpq_huff_decompress(char *out_buf, int *out_length, char *in_buf, int in_length) { - struct huffman_tree *ht = (huffman_tree *)malloc(sizeof(struct huffman_tree)); - struct huffman_input_stream *is = (huffman_input_stream *)malloc(sizeof(struct huffman_input_stream)); - struct huffman_tree_item *hi = (huffman_tree_item *)malloc(sizeof(struct huffman_tree_item)); - memset(ht, 0, sizeof(struct huffman_tree)); - memset(is, 0, sizeof(struct huffman_input_stream)); - memset(hi, 0, sizeof(struct huffman_tree_item)); - - /* Initialize input stream */ - is->bit_buf = *(unsigned long *)in_buf; - in_buf += sizeof(unsigned long); - is->in_buf = (unsigned char *)in_buf; - is->bits = 32; - - /* Initialize the Huffmann tree for decompression */ - libmpq_huff_init_tree(ht, hi, LIBMPQ_HUFF_DECOMPRESS); - - *out_length = libmpq_huff_do_decompress(ht, is, (unsigned char *)out_buf, *out_length); - - free(hi); - free(is); - free(ht); - return 0; -} - -int libmpq_multi_decompress(char *out_buf, int *pout_length, char *in_buf, int in_length) { - char *temp_buf = NULL; /* Temporary storage for decompressed data */ - char *work_buf = NULL; /* Where to store decompressed data */ - int out_length = *pout_length; /* For storage number of output bytes */ - unsigned fDecompressions1; /* Decompressions applied to the block */ - unsigned fDecompressions2; /* Just another copy of decompressions applied to the block */ - int count = 0; /* Counter for every use */ - int entries = (sizeof(dcmp_table) / sizeof(decompress_table)); - int i; - - /* If the input length is the same as output, do nothing. */ - if (in_length == out_length) { - if (in_buf == out_buf) { - return 1; - } - memcpy(out_buf, in_buf, in_length); - return 1; - } - - /* Get applied compression types and decrement data length */ - fDecompressions1 = fDecompressions2 = (unsigned char)*in_buf++; - in_length--; - - /* Search decompression table type and get all types of compression */ - for (i = 0; i < entries; i++) { - /* We have to apply this decompression? */ - if (fDecompressions1 & dcmp_table[i].mask) { - count++; - } - - /* Clear this flag from temporary variable. */ - fDecompressions2 &= ~dcmp_table[i].mask; - } - - /* - * Check if there is some method unhandled - * (E.g. compressed by future versions) - */ - if (fDecompressions2 != 0) { - printf("Unknown Compression\n"); - return 0; - } - - /* If there is more than only one compression, we have to allocate extra buffer */ - if (count >= 2) { - temp_buf = (char *)malloc(out_length); - } - - /* Apply all decompressions */ - for (i = 0, count = 0; i < entries; i++) { - - /* If not used this kind of compression, skip the loop */ - if (fDecompressions1 & dcmp_table[i].mask) { - - /* If odd case, use target buffer for output, otherwise use allocated tempbuf */ - work_buf = (count++ & 1) ? temp_buf : out_buf; - out_length = *pout_length; - - /* Decompress buffer using corresponding function */ - dcmp_table[i].decompress(work_buf, &out_length, in_buf, in_length); - - /* Move output length to src length for next compression */ - in_length = out_length; - in_buf = work_buf; - } - } - - /* If output buffer is not the same like target buffer, we have to copy data */ - if (work_buf != out_buf) { - memcpy(out_buf, in_buf, out_length); - } - *pout_length = out_length; - - /* Delete temporary buffer, if necessary */ - if (temp_buf != NULL) { - free(temp_buf); - } - return 1; -} diff --git a/contrib/extractor/libmpq/huffman.cpp b/contrib/extractor/libmpq/huffman.cpp deleted file mode 100644 index 0c5fee3d8..000000000 --- a/contrib/extractor/libmpq/huffman.cpp +++ /dev/null @@ -1,833 +0,0 @@ -/* - * huffman.c -- functions do decompress files in MPQ files which - * uses a modified huffman version. - * - * Copyright (C) 2003 Maik Broemme - * - * Differences between C++ and C version: - * - * - Removed the object oriented stuff. - * - Replaced the goto things with some better C code. - * - * This source was adepted from the C++ version of huffman.cpp included - * in stormlib. The C++ version belongs to the following authors, - * - * Ladislav Zezula - * ShadowFlare - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include -#include - -#include "mpq.h" -#include "huffman.h" - -unsigned char table1502A630[] = { - - /* Data for compression type 0x00 */ - 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, - - /* Data for compression type 0x01 */ - 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, - 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, - 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, - 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, - 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, - 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, - 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, - 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, - 0x00, 0x00, - - /* Data for compression type 0x02 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, - 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, - 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, - 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - /* Data for compression type 0x03 */ - 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, - 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, - 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, - 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, - 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, - 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, - 0x00, 0x00, - - /* Data for compression type 0x04 */ - 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - /* Data for compression type 0x05 */ - 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, - 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, - 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, - 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - /* Data for compression type 0x06 */ - 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - /* Data for compression type 0x07 */ - 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - /* Data for compression type 0x08 */ - 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, - 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, - 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -/* Gets previous Huffman tree item (?) */ -struct huffman_tree_item *libmpq_huff_get_prev_item(struct huffman_tree_item *hi, long value) { - if (PTR_INT(hi->prev) < 0) { - return PTR_NOT(hi->prev); - } - if (value < 0) { - value = hi - hi->next->prev; - } - return hi->prev + value; -} - -/* 1500BC90 */ -static void libmpq_huff_remove_item(struct huffman_tree_item *hi) { - struct huffman_tree_item *temp; /* EDX */ - - if (hi->next != NULL) { - temp = hi->prev; - if (PTR_INT(temp) <= 0) { - temp = PTR_NOT(temp); - } else { - temp += (hi - hi->next->prev); - } - temp->next = hi->next; - hi->next->prev = hi->prev; - hi->next = hi->prev = NULL; - } -} - -static void libmpq_huff_insert_item(struct huffman_tree_item **p_item, struct huffman_tree_item *item, unsigned long where, struct huffman_tree_item *item2) { - struct huffman_tree_item *next = item->next; /* EDI - next to the first item */ - struct huffman_tree_item *prev = item->prev; /* ESI - prev to the first item */ - struct huffman_tree_item *prev2; /* Pointer to previous item */ - long next2; /* Pointer to the next item */ - - /* The same code like in mpq_huff_remove_item(); */ - if (next != 0) { /* If the first item already has next one */ - if (PTR_INT(prev) < 0) { - prev = PTR_NOT(prev); - } else { - prev += (item - next->prev); - } - - /* - * 150083C1 - * Remove the item from the tree - */ - prev->next = next; - next->prev = prev; - - /* Invalidate 'prev' and 'next' pointer */ - item->next = 0; - item->prev = 0; - } - - if (item2 == NULL) { /* EDX - If the second item is not entered, */ - item2 = PTR_PTR(&p_item[1]); /* take the first tree item */ - } - - switch (where) { - case SWITCH_ITEMS: /* Switch the two items */ - item->next = item2->next; /* item2->next (Pointer to pointer to first) */ - item->prev = item2->next->prev; - item2->next->prev = item; - item2->next = item; /* Set the first item */ - return; - case INSERT_ITEM: /* Insert as the last item */ - item->next = item2; /* Set next item (or pointer to pointer to first item) */ - item->prev = item2->prev; /* Set prev item (or last item in the tree) */ - next2 = PTR_INT(p_item[0]); /* Usually NULL */ - prev2 = item2->prev; /* Prev item to the second (or last tree item) */ - if (PTR_INT(prev2) < 0) { - prev2 = PTR_NOT(prev); - prev2->next = item; - item2->prev = item; /* Next after last item */ - return; - } - if (next2 < 0) { - next2 = item2 - item2->next->prev; - } - prev2 += next2; - prev2->next = item; - item2->prev = item; /* Set the next/last item */ - return; - default: - return; - } -} - -/* Builds Huffman tree. Called with the first 8 bits loaded from input stream. */ -static void libmpq_huff_build_tree(struct huffman_tree *ht, unsigned int cmp_type) { - unsigned long max_byte; /* [ESP+10] - The greatest character found in table */ - unsigned char *byte_array; /* [ESP+1C] - Pointer to unsigned char in table1502A630 */ - unsigned long i; /* egcs in linux doesn't like multiple for loops without an explicit i */ - unsigned int found; /* Thats needed to replace the goto stuff from original source :) */ - struct huffman_tree_item **p_item; /* [ESP+14] - Pointer to Huffman tree item pointer array */ - struct huffman_tree_item *child1; - - /* Loop while pointer has a negative value. */ - while (PTR_INT(ht->last) > 0) { /* ESI - Last entry */ - struct huffman_tree_item *temp; /* EAX */ - - if (ht->last->next != NULL) { /* ESI->next */ - libmpq_huff_remove_item(ht->last); - } - ht->item3058 = PTR_PTR(&ht->item3054);/* [EDI+4] */ - ht->last->prev = ht->item3058; /* EAX */ - temp = libmpq_huff_get_prev_item(PTR_PTR(&ht->item3054), PTR_INT(&ht->item3050)); - temp->next = ht->last; - ht->item3054 = ht->last; - } - - /* Clear all pointers in huffman tree item array. */ - memset(ht->items306C, 0, sizeof(ht->items306C)); - - max_byte = 0; /* Greatest character found init to zero. */ - p_item = (struct huffman_tree_item **)&ht->items306C; /* Pointer to current entry in huffman tree item pointer array */ - - /* Ensure we have low 8 bits only */ - cmp_type &= 0xFF; - byte_array = table1502A630 + cmp_type * 258; /* EDI also */ - - for (i = 0; i < 0x100; i++, p_item++) { - struct huffman_tree_item *item = ht->item3058; /* Item to be created */ - struct huffman_tree_item *p_item3 = ht->item3058; - unsigned char one_byte = byte_array[i]; - - /* Skip all the bytes which are zero. */ - if (byte_array[i] == 0) { - continue; - } - - /* If not valid pointer, take the first available item in the array. */ - if (PTR_INT(item) <= 0) { - item = &ht->items0008[ht->items++]; - } - - /* Insert this item as the top of the tree. */ - libmpq_huff_insert_item(&ht->item305C, item, SWITCH_ITEMS, NULL); - - item->parent = NULL; /* Invalidate child and parent */ - item->child = NULL; - *p_item = item; /* Store pointer into pointer array */ - - item->dcmp_byte = i; /* Store counter */ - item->byte_value = one_byte; /* Store byte value */ - if (one_byte >= max_byte) { - max_byte = one_byte; - continue; - } - - /* Find the first item which has byte value greater than current one byte */ - found = 0; - if (PTR_INT((p_item3 = ht->last)) > 0) {/* EDI - Pointer to the last item */ - - /* 15006AF7 */ - if (p_item3 != NULL) { - do { /* 15006AFB */ - if (p_item3->byte_value >= one_byte) { - found = 1; - break; - } - p_item3 = p_item3->prev; - } while (PTR_INT(p_item3) > 0); - } - } - - if (found == 0) { - p_item3 = NULL; - } - - /* 15006B09 */ - if (item->next != NULL) { - libmpq_huff_remove_item(item); - } - - /* 15006B15 */ - if (p_item3 == NULL) { - p_item3 = PTR_PTR(&ht->first); - } - - /* 15006B1F */ - item->next = p_item3->next; - item->prev = p_item3->next->prev; - p_item3->next->prev = item; - p_item3->next = item; - } - - /* 15006B4A */ - for (; i < 0x102; i++) { - struct huffman_tree_item **p_item2 = &ht->items306C[i]; /* EDI */ - - /* 15006B59 */ - struct huffman_tree_item *item2 = ht->item3058; /* ESI */ - if (PTR_INT(item2) <= 0) { - item2 = &ht->items0008[ht->items++]; - } - libmpq_huff_insert_item(&ht->item305C, item2, INSERT_ITEM, NULL); - - /* 15006B89 */ - item2->dcmp_byte = i; - item2->byte_value = 1; - item2->parent = NULL; - item2->child = NULL; - *p_item2++ = item2; - } - - /* 15006BAA */ - if (PTR_INT((child1 = ht->last)) > 0) { /* EDI - last item (first child to item */ - struct huffman_tree_item *child2; /* EBP */ - struct huffman_tree_item *item; /* ESI */ - - /* 15006BB8 */ - while (PTR_INT((child2 = child1->prev)) > 0) { - if (PTR_INT((item = ht->item3058)) <= 0) { - item = &ht->items0008[ht->items++]; - } - /* 15006BE3 */ - libmpq_huff_insert_item(&ht->item305C, item, SWITCH_ITEMS, NULL); - - /* 15006BF3 */ - item->parent = NULL; - item->child = NULL; - - /* - * EDX = child2->byte_value + child1->byte_value; - * EAX = child1->byte_value; - * ECX = max_byte; The greatest character (0xFF usually) - */ - item->byte_value = child1->byte_value + child2->byte_value; /* 0x02 */ - item->child = child1; /* Prev item in the */ - child1->parent = item; - child2->parent = item; - - /* EAX = item->byte_value; */ - if (item->byte_value >= max_byte) { - max_byte = item->byte_value; - } else { - struct huffman_tree_item *p_item2 = child2->prev; /* EDI */ - found = 0; - if (PTR_INT(p_item2) > 0) { - - /* 15006C2D */ - do { - if (p_item2->byte_value >= item->byte_value) { - found = 1; - break; - } - p_item2 = p_item2->prev; - } while (PTR_INT(p_item2) > 0); - } - if (found == 0) { - p_item2 = NULL; - } - if (item->next != 0) { - struct huffman_tree_item *temp4 = libmpq_huff_get_prev_item(item, -1); - temp4->next = item->next; /* The first item changed */ - item->next->prev = item->prev; /* First->prev changed to negative value */ - item->next = NULL; - item->prev = NULL; - } - - /* 15006C62 */ - if (p_item2 == NULL) { - p_item2 = PTR_PTR(&ht->first); - } - item->next = p_item2->next; /* Set item with 0x100 byte value */ - item->prev = p_item2->next->prev; /* Set item with 0x17 byte value */ - p_item2->next->prev = item; /* Changed prev of item with */ - p_item2->next = item; - } - - /* 15006C7B */ - if (PTR_INT((child1 = child2->prev)) <= 0) { - break; - } - } - } - - /* 15006C88 */ - ht->offs0004 = 1; -} - -/* Gets the whole byte from the input stream. */ -static unsigned long libmpq_huff_get_8bits(struct huffman_input_stream *is) { - unsigned long one_byte; - - if (is->bits <= 8) { - is->bit_buf |= *(unsigned short *)is->in_buf << is->bits; - is->in_buf += sizeof(unsigned short); - is->bits += 16; - } - - one_byte = (is->bit_buf & 0xFF); - is->bit_buf >>= 8; - is->bits -= 8; - - return one_byte; -} - -/* Gets 7 bits from the stream. */ -static unsigned long libmpq_huff_get_7bits(struct huffman_input_stream *is) { - if (is->bits <= 7) { - is->bit_buf |= *(unsigned short *)is->in_buf << is->bits; - is->in_buf += sizeof(unsigned short); - is->bits += 16; - } - - /* Get 7 bits from input stream. */ - return (is->bit_buf & 0x7F); -} - -/* Gets one bit from input stream. */ -unsigned long libmpq_huff_get_bit(struct huffman_input_stream *is) { - unsigned long bit = (is->bit_buf & 1); - - is->bit_buf >>= 1; - if (--is->bits == 0) { - is->bit_buf = *(unsigned long *)is->in_buf; - is->in_buf += sizeof(unsigned long); - is->bits = 32; - } - return bit; -} - -static struct huffman_tree_item *libmpq_huff_call1500E740(struct huffman_tree *ht, unsigned int value) { - struct huffman_tree_item *p_item1 = ht->item3058; /* EDX */ - struct huffman_tree_item *p_item2; /* EAX */ - struct huffman_tree_item *p_next; - struct huffman_tree_item *p_prev; - struct huffman_tree_item **pp_item; - - if (PTR_INT(p_item1) <= 0 || (p_item2 = p_item1) == NULL) { - if((p_item2 = &ht->items0008[ht->items++]) != NULL) { - p_item1 = p_item2; - } else { - p_item1 = ht->first; - } - } else { - p_item1 = p_item2; - } - - p_next = p_item1->next; - if (p_next != NULL) { - p_prev = p_item1->prev; - if (PTR_INT(p_prev) <= 0) { - p_prev = PTR_NOT(p_prev); - } else { - p_prev += (p_item1 - p_item1->next->prev); - } - - p_prev->next = p_next; - p_next->prev = p_prev; - p_item1->next = NULL; - p_item1->prev = NULL; - } - pp_item = &ht->first; /* ESI */ - if (value > 1) { - - /* ECX = ht->first->next; */ - p_item1->next = *pp_item; - p_item1->prev = (*pp_item)->prev; - - (*pp_item)->prev = p_item2; - *pp_item = p_item1; - - p_item2->parent = NULL; - p_item2->child = NULL; - } else { - p_item1->next = (struct huffman_tree_item *)pp_item; - p_item1->prev = pp_item[1]; - /* EDI = ht->item305C; */ - p_prev = pp_item[1]; /* ECX */ - if (p_prev <= 0) { - p_prev = PTR_NOT(p_prev); - p_prev->next = p_item1; - p_prev->prev = p_item2; - - p_item2->parent = NULL; - p_item2->child = NULL; - } else { - if (PTR_INT(ht->item305C) < 0) { - p_prev += (struct huffman_tree_item *)pp_item - (*pp_item)->prev; - } else { - p_prev += PTR_INT(ht->item305C); - } - - p_prev->next = p_item1; - pp_item[1] = p_item2; - p_item2->parent = NULL; - p_item2->child = NULL; - } - } - return p_item2; -} - -static void libmpq_huff_call1500E820(struct huffman_tree *ht, struct huffman_tree_item *p_item) { - struct huffman_tree_item *p_item1; /* EDI */ - struct huffman_tree_item *p_item2 = NULL; /* EAX */ - struct huffman_tree_item *p_item3; /* EDX */ - struct huffman_tree_item *p_prev; /* EBX */ - - for (; p_item != NULL; p_item = p_item->parent) { - p_item->byte_value++; - - for (p_item1 = p_item; ; p_item1 = p_prev) { - p_prev = p_item1->prev; - if (PTR_INT(p_prev) <= 0) { - p_prev = NULL; - break; - } - if (p_prev->byte_value >= p_item->byte_value) { - break; - } - } - - if (p_item1 == p_item) { - continue; - } - - if (p_item1->next != NULL) { - p_item2 = libmpq_huff_get_prev_item(p_item1, -1); - p_item2->next = p_item1->next; - p_item1->next->prev = p_item1->prev; - p_item1->next = NULL; - p_item1->prev = NULL; - } - p_item2 = p_item->next; - p_item1->next = p_item2; - p_item1->prev = p_item2->prev; - p_item2->prev = p_item1; - p_item->next = p_item1; - if ((p_item2 = p_item1) != NULL) { - p_item2 = libmpq_huff_get_prev_item(p_item, -1); - p_item2->next = p_item->next; - p_item->next->prev = p_item->prev; - p_item->next = NULL; - p_item->prev = NULL; - } - - if (p_prev == NULL) { - p_prev = PTR_PTR(&ht->first); - } - p_item2 = p_prev->next; - p_item->next = p_item2; - p_item->prev = p_item2->prev; - p_item2->prev = p_item; - p_prev->next = p_item; - - p_item3 = p_item1->parent->child; - p_item2 = p_item->parent; - if (p_item2->child == p_item) { - p_item2->child = p_item1; - } - - if (p_item3 == p_item1) { - p_item1->parent->child = p_item; - } - - p_item2 = p_item->parent; - p_item->parent = p_item1->parent; - p_item1->parent = p_item2; - ht->offs0004++; - } -} - -int libmpq_huff_do_decompress(struct huffman_tree *ht, struct huffman_input_stream *is, unsigned char *out_buf, unsigned int out_length) { - unsigned int n8bits; /* 8 bits loaded from input stream */ - unsigned int n7bits; /* 7 bits loaded from input stream */ - unsigned int found; /* Thats needed to replace the goto stuff from original source :) */ - unsigned int dcmp_byte = 0; - unsigned long bit_count; - struct huffman_decompress *qd; - unsigned int has_qd; /* Can we use quick decompression? */ - struct huffman_tree_item *p_item1; - struct huffman_tree_item *p_item2; - unsigned char *out_pos = out_buf; - - /* Test the output length. Must not be non zero. */ - if (out_length == 0) { - return 0; - } - - /* Get the compression type from the input stream. */ - n8bits = libmpq_huff_get_8bits(is); - - /* Build the Huffman tree */ - libmpq_huff_build_tree(ht, n8bits); - ht->cmp0 = (n8bits == 0) ? TRUE : FALSE; - - for(;;) { - n7bits = libmpq_huff_get_7bits(is); /* Get 7 bits from input stream */ - - /* - * Try to use quick decompression. Check huffman_decompress array for corresponding item. - * If found, use the result byte instead. - */ - qd = &ht->qd3474[n7bits]; - - /* If there is a quick-pass possible (ebx) */ - has_qd = (qd->offs00 >= ht->offs0004) ? TRUE : FALSE; - - /* If we can use quick decompress, use it. */ - if (has_qd) { - found = 0; - if (qd->bits > 7) { - is->bit_buf >>= 7; - is->bits -= 7; - p_item1 = qd->p_item; - found = 1; - } - if (found == 0) { - is->bit_buf >>= qd->bits; - is->bits -= qd->bits; - dcmp_byte = qd->dcmp_byte; - } - } else { - found = 1; - p_item1 = ht->first->next->prev; - if (PTR_INT(p_item1) <= 0) { - p_item1 = NULL; - } - } - - if (found == 1) { - bit_count = 0; - p_item2 = NULL; - do { - p_item1 = p_item1->child; /* Move down by one level */ - if (libmpq_huff_get_bit(is)) { /* If current bit is set, move to previous */ - p_item1 = p_item1->prev; - } - if (++bit_count == 7) { /* If we are at 7th bit, save current huffman tree item. */ - p_item2 = p_item1; - } - } while (p_item1->child != NULL); /* Walk until tree has no deeper level */ - - if (has_qd == FALSE) { - if (bit_count > 7) { - qd->offs00 = ht->offs0004; - qd->bits = bit_count; - qd->p_item = p_item2; - } else { - unsigned long index = n7bits & (0xFFFFFFFF >> (32 - bit_count)); - unsigned long add = (1 << bit_count); - - for (qd = &ht->qd3474[index]; index <= 0x7F; index += add, qd += add) { - qd->offs00 = ht->offs0004; - qd->bits = bit_count; - qd->dcmp_byte = p_item1->dcmp_byte; - } - } - } - dcmp_byte = p_item1->dcmp_byte; - } - - if (dcmp_byte == 0x101) { /* Huffman tree needs to be modified */ - n8bits = libmpq_huff_get_8bits(is); - p_item1 = (ht->last <= 0) ? NULL : ht->last; - - p_item2 = libmpq_huff_call1500E740(ht, 1); - p_item2->parent = p_item1; - p_item2->dcmp_byte = p_item1->dcmp_byte; - p_item2->byte_value = p_item1->byte_value; - ht->items306C[p_item2->dcmp_byte] = p_item2; - - p_item2 = libmpq_huff_call1500E740(ht, 1); - p_item2->parent = p_item1; - p_item2->dcmp_byte = n8bits; - p_item2->byte_value = 0; - ht->items306C[p_item2->dcmp_byte] = p_item2; - - p_item1->child = p_item2; - libmpq_huff_call1500E820(ht, p_item2); - if (ht->cmp0 == 0) { - libmpq_huff_call1500E820(ht, ht->items306C[n8bits]); - } - dcmp_byte = n8bits; - } - - if (dcmp_byte == 0x100) { - break; - } - - *out_pos++ = (unsigned char)dcmp_byte; - if (--out_length == 0) { - break; - } - if (ht->cmp0) { - libmpq_huff_call1500E820(ht, ht->items306C[dcmp_byte]); - } - } - return (out_pos - out_buf); -} - -int libmpq_huff_init_tree(struct huffman_tree *ht, struct huffman_tree_item *hi, unsigned int cmp) { - int count; - - /* Clear links for all the items in the tree */ - for (hi = ht->items0008, count = 0x203; count != 0; hi++, count--) { - hi->next = hi->prev = NULL; - } - - ht->item3050 = NULL; - ht->item3054 = PTR_PTR(&ht->item3054); - ht->item3058 = PTR_NOT(ht->item3054); - - ht->item305C = NULL; - ht->first = PTR_PTR(&ht->first); - ht->last = PTR_NOT(ht->first); - - ht->offs0004 = 1; - ht->items = 0; - - /* Clear all huffman_decompress items. Do this only if preparing for decompression */ - if (cmp == LIBMPQ_HUFF_DECOMPRESS) { - for (count = 0; count < sizeof(ht->qd3474) / sizeof(struct huffman_decompress); count++) { - ht->qd3474[count].offs00 = 0; - } - } - - return 0; -} diff --git a/contrib/extractor/libmpq/huffman.h b/contrib/extractor/libmpq/huffman.h deleted file mode 100644 index 1f8eae54e..000000000 --- a/contrib/extractor/libmpq/huffman.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * huffman.h -- structures used for huffman compression. - * - * Copyright (C) 2003 Maik Broemme - * - * This source was adepted from the C++ version of huffman.h included - * in stormlib. The C++ version belongs to the following authors, - * - * Ladislav Zezula - * ShadowFlare - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _HUFFMAN_H -#define _HUFFMAN_H - -#define PTR_NOT(ptr) (struct huffman_tree_item *)(~(unsigned long)(ptr)) -#define PTR_PTR(ptr) ((struct huffman_tree_item *)(ptr)) -#define PTR_INT(ptr) (long)(ptr) - -#define INSERT_ITEM 1 -#define SWITCH_ITEMS 2 /* Switch the item1 and item2 */ - -/* - * Input stream for Huffmann decompression - */ -struct huffman_input_stream { - unsigned char *in_buf; /* 00 - Input data */ - unsigned long bit_buf; /* 04 - Input bit buffer */ - unsigned int bits; /* 08 - Number of bits remaining in 'byte' */ -}; - -/* - * Huffmann tree item. - */ -struct huffman_tree_item { - struct huffman_tree_item *next; /* 00 - Pointer to next huffman_tree_item */ - struct huffman_tree_item *prev; /* 04 - Pointer to prev huffman_tree_item (< 0 if none) */ - unsigned long dcmp_byte; /* 08 - Index of this item in item pointer array, decompressed byte value */ - unsigned long byte_value; /* 0C - Some byte value */ - struct huffman_tree_item *parent; /* 10 - Pointer to parent huffman_tree_item (NULL if none) */ - struct huffman_tree_item *child; /* 14 - Pointer to child huffman_tree_item */ -}; - -/* - * Structure used for quick decompress. The 'bits' contains - * number of bits and dcmp_byte contains result decompressed byte - * value. After each walk through Huffman tree are filled all entries - * which are multiplies of number of bits loaded from input stream. - * These entries contain number of bits and result value. At the next - * 7 bits is tested this structure first. If corresponding entry found, - * decompression routine will not walk through Huffman tree and - * directly stores output byte to output stream. - */ -struct huffman_decompress { - unsigned long offs00; /* 00 - 1 if resolved */ - unsigned long bits; /* 04 - Bit count */ - union { - unsigned long dcmp_byte; /* 08 - Byte value for decompress (if bitCount <= 7) */ - struct huffman_tree_item *p_item; /* 08 - THTreeItem (if number of bits is greater than 7 */ - }; -}; - -/* - * Structure for Huffman tree. - */ -struct huffman_tree { - unsigned long cmp0; /* 0000 - 1 if compression type 0 */ - unsigned long offs0004; /* 0004 - Some flag */ - - struct huffman_tree_item items0008[0x203]; /* 0008 - huffman tree items */ - - /* Sometimes used as huffman tree item */ - struct huffman_tree_item *item3050; /* 3050 - Always NULL (?) */ - struct huffman_tree_item *item3054; /* 3054 - Pointer to huffman_tree_item */ - struct huffman_tree_item *item3058; /* 3058 - Pointer to huffman_tree_item (< 0 if invalid) */ - - /* Sometimes used as huffman tree item */ - struct huffman_tree_item *item305C; /* 305C - Usually NULL */ - struct huffman_tree_item *first; /* 3060 - Pointer to top (first) Huffman tree item */ - struct huffman_tree_item *last; /* 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid) */ - unsigned long items; /* 3068 - Number of used huffman tree items */ - - struct huffman_tree_item *items306C[0x102]; /* 306C - huffman_tree_item pointer array */ - struct huffman_decompress qd3474[0x80]; /* 3474 - Array for quick decompression */ - - //unsigned char table1502A630[]; /* Some table to make struct size flexible */ -}; - -int libmpq_huff_init_tree(struct huffman_tree *ht, struct huffman_tree_item *hi, unsigned int cmp); -int libmpq_huff_do_decompress(struct huffman_tree *ht, struct huffman_input_stream *is, unsigned char *out_buf, unsigned int out_length); -#endif /* _HUFFMAN_H */ diff --git a/contrib/extractor/libmpq/mpq.cpp b/contrib/extractor/libmpq/mpq.cpp deleted file mode 100644 index 14b0e8a30..000000000 --- a/contrib/extractor/libmpq/mpq.cpp +++ /dev/null @@ -1,610 +0,0 @@ -/* - * mpq.c -- functions for developers using libmpq. - * - * Copyright (C) 2003 Maik Broemme - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id: mpq.c,v 1.6 2004/02/12 00:49:00 mbroemme Exp $ - */ -#define _CRT_SECURE_NO_DEPRECATE - -#include -#include -//#include -//#include -#include -#include -#include -#include "mpq.h" -#include "common.h" - -/* - * This function returns version information. - * format: MAJOR.MINOR.PATCH - */ -char *libmpq_version() { - static char version[10]; - sprintf(version, "%i.%i.%i", LIBMPQ_MAJOR_VERSION, LIBMPQ_MINOR_VERSION, LIBMPQ_PATCH_VERSION); - return version; -} - -/* - * This function reads a file and verify if it is a legit MPQ archive - * or not. Then it fills the mpq_header structure and reads the hash - * table. - */ -int libmpq_archive_open(mpq_archive *mpq_a, unsigned char *mpq_filename) { - int fd = 0; - int rb = 0; - int ncnt = FALSE; - struct stat fileinfo; - - /* allocate memory */ - mpq_a->mpq_l = (mpq_list *)malloc(sizeof(mpq_list)); - memset(mpq_a->mpq_l, 0, sizeof(mpq_list)); - mpq_a->header = (mpq_header *)malloc(sizeof(mpq_header)); - memset(mpq_a->header, 0, sizeof(mpq_header)); - - /* Check if file exists and is readable */ - fd = _open((char *)mpq_filename, MPQ_FILE_OPEN_FLAGS); - if (fd == LIBMPQ_EFILE) { - return LIBMPQ_EFILE; - } - - /* fill the structures with informations */ - strcpy((char *)mpq_a->filename, (char *)mpq_filename); - libmpq_init_buffer(mpq_a); - mpq_a->fd = fd; - mpq_a->header->id = 0; - mpq_a->maxblockindex = 0; - mpq_a->mpq_l->mpq_files = NULL; - - mpq_a->mpqpos = 0; //k - - while (!ncnt) { - mpq_a->header->id = 0; - - libmpq_lseek(mpq_a, mpq_a->mpqpos); - - rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header)); - - /* if different number of bytes read, break the loop */ - if (rb != sizeof(mpq_header)) { - return LIBMPQ_EFILE_FORMAT; - } - - /* special offset for protected MPQs */ - if (mpq_a->header->offset == LIBMPQ_HEADER_W3M) { - mpq_a->flags |= LIBMPQ_FLAG_PROTECTED; - mpq_a->header->offset = sizeof(mpq_header); - } - - /* if valid signature has been found, break the loop */ - if (mpq_a->header->id == LIBMPQ_ID_MPQ) { - ncnt = true; - } - /*if (mpq_a->header->id == LIBMPQ_ID_MPQ && - mpq_a->header->offset == sizeof(mpq_header) && - mpq_a->header->hashtablepos < mpq_a->header->archivesize && - mpq_a->header->blocktablepos < mpq_a->header->archivesize) { - ncnt = TRUE; - }*/ - - /* move to the next possible offset */ - if (!ncnt) { - mpq_a->mpqpos += 0x200; - } - } - - /* get the right positions of the hash table and the block table. */ - mpq_a->blocksize = (0x200 << mpq_a->header->blocksize); - fstat(mpq_a->fd, &fileinfo); - - /* Normal MPQs must have position of */ - /*if (mpq_a->header->hashtablepos + mpq_a->mpqpos < fileinfo.st_size && - mpq_a->header->blocktablepos + mpq_a->mpqpos < fileinfo.st_size) { - mpq_a->header->hashtablepos += mpq_a->mpqpos; - mpq_a->header->blocktablepos += mpq_a->mpqpos; - } else { - return LIBMPQ_EFILE_FORMAT; - }*/ - - /* Try to read and decrypt the hashtable */ - if (libmpq_read_hashtable(mpq_a) != 0) { - return LIBMPQ_EHASHTABLE; - } - - /* Try to read and decrypt the blocktable */ - if (libmpq_read_blocktable(mpq_a) != 0) { - return LIBMPQ_EBLOCKTABLE; - } - - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function closes the file descriptor opened by - * mpq_open_archive(); and frees the decryption buffer. - */ -int libmpq_archive_close(mpq_archive *mpq_a) { - memset(mpq_a->buf, 0, sizeof(mpq_a->buf)); - - /* free the allocated memory. */ - free(mpq_a->header); - free(mpq_a->mpq_l); - - /* Check if file descriptor is valid. */ - if ((_close(mpq_a->fd)) == LIBMPQ_EFILE) { - return LIBMPQ_EFILE; - } - - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function returns the value for the given infotype. - * If an error occurs something < 0 is returned. - */ -int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype) { - unsigned int filecount = 0; - unsigned int fsize = 0; - unsigned int csize = 0; - mpq_block *mpq_b_end = mpq_a->blocktable + mpq_a->header->blocktablesize; - mpq_block *mpq_b = NULL; - - switch (infotype) { - case LIBMPQ_MPQ_ARCHIVE_SIZE: - return mpq_a->header->archivesize; - case LIBMPQ_MPQ_HASHTABLE_SIZE: - return mpq_a->header->hashtablesize; - case LIBMPQ_MPQ_BLOCKTABLE_SIZE: - return mpq_a->header->blocktablesize; - case LIBMPQ_MPQ_BLOCKSIZE: - return mpq_a->blocksize; - case LIBMPQ_MPQ_NUMFILES: - for (mpq_b = mpq_a->blocktable; mpq_b < mpq_b_end; mpq_b++) { - filecount++; - } - return filecount; - case LIBMPQ_MPQ_COMPRESSED_SIZE: - for (mpq_b = mpq_a->blocktable; mpq_b < mpq_b_end; mpq_b++) { - csize += mpq_b->csize; - } - return csize; - case LIBMPQ_MPQ_UNCOMPRESSED_SIZE: - for (mpq_b = mpq_a->blocktable; mpq_b < mpq_b_end; mpq_b++) { - fsize += mpq_b->fsize; - } - return fsize; - default: - return LIBMPQ_TOOLS_SUCCESS; - } -} - -/* - * This function returns some useful file information. - */ -int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number) { - int blockindex = number; - int i = 0; - mpq_block *mpq_b = NULL; - mpq_hash *mpq_h = NULL; - - /* check if given number is not out of range */ - if (number < 0 || number >= mpq_a->header->blocktablesize) { - return LIBMPQ_EINV_RANGE; - } - - /* check if sizes are correct */ - mpq_b = mpq_a->blocktable + blockindex; - if (mpq_b->filepos > (mpq_a->header->archivesize + mpq_a->mpqpos) || mpq_b->csize > mpq_a->header->archivesize) { - return LIBMPQ_EFILE_CORRUPT; - } - - /* check if file exists */ - if ((mpq_b->flags & LIBMPQ_FILE_EXISTS) == 0) { - return LIBMPQ_EFILE_NOT_FOUND; - } - - switch (infotype) { - case LIBMPQ_FILE_COMPRESSED_SIZE: - return mpq_b->csize; - case LIBMPQ_FILE_UNCOMPRESSED_SIZE: - return mpq_b->fsize; - case LIBMPQ_FILE_COMPRESSION_TYPE: - if (mpq_b->flags & LIBMPQ_FILE_COMPRESS_PKWARE) { - return LIBMPQ_FILE_COMPRESS_PKWARE; - } - if (mpq_b->flags & LIBMPQ_FILE_COMPRESS_MULTI) { - return LIBMPQ_FILE_COMPRESS_MULTI; - } - default: - return LIBMPQ_TOOLS_SUCCESS; - } -} - -/* - * This function searches the listfile for the filename. - * On success it returns the filename, otherwiese a name - * like file000001.xxx and if number is out of range it - * returns NULL. - */ -char *libmpq_file_name(mpq_archive *mpq_a, const int number) { - static char tempfile[PATH_MAX]; - - /* check if we are in the range of available files. */ - if (number > libmpq_archive_info(mpq_a, LIBMPQ_MPQ_NUMFILES) || number < 1) { - return NULL; - } - - /* this is safe because we built a fallback filelist, if something was wrong. */ - sprintf(tempfile, (char *)mpq_a->mpq_l->mpq_files[number - 1], number); - - return tempfile; -} - -/* - * This function returns the number to the given - * filename. - */ -int libmpq_file_number(mpq_archive *mpq_a, const char *name) { - int i; - char tempfile[PATH_MAX]; - - for (i = 0; mpq_a->mpq_l->mpq_files[i]; i++) { - sprintf(tempfile, (char *)mpq_a->mpq_l->mpq_files[i], i + 1); - if (strncmp(tempfile, name, strlen(name)) == 0) { - - /* if file found return the number */ - return i + 1; - } - } - - /* if no matching entry found return LIBMPQ_EFILE_NOT_FOUND */ - return LIBMPQ_EFILE_NOT_FOUND; -} - -/* - * This function verifies if a given file (by number - * or name) is in the opened mpq archive. On success - * it returns 0, otherwise LIBMPQ_EFILE_NOT_FOUND. - */ -int libmpq_file_check(mpq_archive *mpq_a, void *file, int type) { - int found = 0; - int i; - char tempfile[PATH_MAX]; - - switch (type) { - case LIBMPQ_FILE_TYPE_INT: - - /* check if we are in the range of available files. */ - if (*(int *)file > libmpq_archive_info(mpq_a, LIBMPQ_MPQ_NUMFILES) || *(int *)file < 1) { - return LIBMPQ_EFILE_NOT_FOUND; - } else { - return LIBMPQ_TOOLS_SUCCESS; - } - case LIBMPQ_FILE_TYPE_CHAR: - for (i = 0; mpq_a->mpq_l->mpq_files[i]; i++) { - sprintf(tempfile, (char *)mpq_a->mpq_l->mpq_files[i], i); - if (strncmp(tempfile, (char *)file, strlen((char *)file)) == 0) { - - /* if file found break */ - found = 1; - break; - } - } - - /* if a file was found return 0 */ - if (found == 1) { - return LIBMPQ_TOOLS_SUCCESS; - } else { - return LIBMPQ_EFILE_NOT_FOUND; - } - default: - return LIBMPQ_TOOLS_SUCCESS; - } -} - -/* - * This function extracts a file from a MPQ archive - * by the given number. - */ -int libmpq_file_extract(mpq_archive *mpq_a, const int number, const char *filename) { - int blockindex = number; //-1; - int fd = 0; - int i = 0; - char buffer[0x1000]; - //char tempfile[PATH_MAX]; - unsigned int transferred = 1; - mpq_file *mpq_f = NULL; - mpq_block *mpq_b = NULL; - mpq_hash *mpq_h = NULL; - -/* if (number < 1 || number > mpq_a->header->blocktablesize) { - return LIBMPQ_EINV_RANGE; - }*/ -/* - sprintf(tempfile, libmpq_file_name(mpq_a, number)); -*/ - /* check if mpq_f->filename could be written here. */ - fd = _open(filename, O_RDWR|O_CREAT|O_TRUNC, 0644); - if (fd == LIBMPQ_EFILE) { - return LIBMPQ_EFILE; - } - - /* search for correct hashtable */ - /*for (i = 0; i < mpq_a->header->hashtablesize; i++) { - if ((number - 1) == (mpq_a->hashtable[i]).blockindex) { - blockindex = (mpq_a->hashtable[i]).blockindex; - mpq_h = &(mpq_a->hashtable[i]); - break; - } - }*/ - - /* check if file was found */ - if (blockindex == -1 || blockindex > mpq_a->header->blocktablesize) { - return LIBMPQ_EFILE_NOT_FOUND; - } - - /* check if sizes are correct */ - mpq_b = mpq_a->blocktable + blockindex; - if (mpq_b->filepos > (mpq_a->header->archivesize + mpq_a->mpqpos) || mpq_b->csize > mpq_a->header->archivesize) { - return LIBMPQ_EFILE_CORRUPT; - } - - /* check if file exists */ - if ((mpq_b->flags & LIBMPQ_FILE_EXISTS) == 0) { - return LIBMPQ_EFILE_NOT_FOUND; - } - - /* allocate memory for file structure */ - mpq_f = (mpq_file *)malloc(sizeof(mpq_file)); - if (!mpq_f) { - return LIBMPQ_EALLOCMEM; - } - - /* initialize file structure */ - memset(mpq_f, 0, sizeof(mpq_file)); - mpq_f->fd = fd; - mpq_f->mpq_b = mpq_b; - mpq_f->nblocks = (mpq_f->mpq_b->fsize + mpq_a->blocksize - 1) / mpq_a->blocksize; - mpq_f->mpq_h = mpq_h; - mpq_f->accessed = FALSE; - mpq_f->blockposloaded = FALSE; - sprintf((char *)mpq_f->filename, filename); - - /* allocate buffers for decompression. */ - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESSED) { - - /* - * Allocate buffer for block positions. At the begin of file are stored - * unsigned ints holding positions of each block relative from begin of - * file in the archive. - */ - if ((mpq_f->blockpos = (unsigned int *)malloc(sizeof(int) * mpq_f->nblocks + 1)) == NULL) { - return LIBMPQ_EALLOCMEM; - } - } - - while (transferred > 0) { - transferred = libmpq_file_read_file(mpq_a, mpq_f, mpq_f->filepos, buffer, sizeof(buffer)); - if (transferred == 0) { - break; - } else { - mpq_f->accessed = TRUE; - mpq_f->filepos += transferred; - } - - transferred = _write(mpq_f->fd, buffer, transferred); - if (transferred == 0) { - break; - } - } - - _close(fd); - - /* freeing the file structure */ - free(mpq_f); - return LIBMPQ_TOOLS_SUCCESS; -} - -/* - * This function tries to get the filenames for the hashes. It uses - * an internal listfile database and gets the correct listfile from - * some specific archive informations. - */ - -int libmpq_listfile_open(mpq_archive *mpq_a, char file[PATH_MAX]) { - FILE *fp; - //char **filelist; - int i = 0; - //int fl_count; - //int fl_size; - int fl_count_fb; - int fl_size_fb; - int result = LIBMPQ_TOOLS_SUCCESS; - struct stat statbuf; - - /* get file status */ - if (stat(file, &statbuf) < 0) { - result = LIBMPQ_CONF_EFILE_NOT_FOUND; - } - - /* check if file is a filename or directory */ - /*if (S_ISDIR(statbuf.st_mode)) { - - // allocate memory for the file list - filelist = (char **)malloc(LIBMPQ_CONF_FL_INCREMENT * sizeof(char *)); - fl_count = 0; - fl_size = LIBMPQ_CONF_FL_INCREMENT; - - // check if it is a valid listfile - if (libmpq_detect_listfile_rec(file, &filelist, &fl_count, &fl_size)) { - filelist == NULL; - } - - filelist[fl_count] = NULL; - - // return if no listfile was found - if (filelist == NULL) { - result = LIBMPQ_CONF_EFILE_NOT_FOUND; - } - - for (i = 0; filelist[i]; i++) { - if ((fp = fopen(filelist[i], "r")) != NULL ) { - result = libmpq_read_listfile(mpq_a, fp); - fclose(fp); - } - } - - // freeing the listfile struct - libmpq_free_listfile(filelist); - }*/ - - /* if file is a regular file use it */ - //if (S_ISREG(statbuf.st_mode)) { - - /* if specific listfile was forced. */ - if ((fp = fopen(file, "r")) != NULL ) { - result = libmpq_read_listfile(mpq_a, fp); - fclose(fp); - } else { - result = LIBMPQ_CONF_EFILE_OPEN; - } - //} - - /* if error occured we need to create a fallback filelist. */ - if (mpq_a->mpq_l->mpq_files == NULL) { - - /* allocate memory for the file list */ - mpq_a->mpq_l->mpq_files = (unsigned char **)malloc(LIBMPQ_CONF_FL_INCREMENT * sizeof(char *)); - fl_count_fb = 0; - fl_size_fb = LIBMPQ_CONF_FL_INCREMENT; - - for (i = 0; i < libmpq_archive_info(mpq_a, LIBMPQ_MPQ_NUMFILES); i++) { - - /* set the next filelist entry to a copy of the file */ - mpq_a->mpq_l->mpq_files[fl_count_fb++] = (unsigned char *)_strdup("file%06lu.xxx"); - - /* increase the array size */ - if (fl_count_fb == fl_size_fb) { - mpq_a->mpq_l->mpq_files = (unsigned char **)realloc(mpq_a->mpq_l->mpq_files, (fl_size_fb + LIBMPQ_CONF_FL_INCREMENT) * sizeof(char *)); - fl_size_fb += LIBMPQ_CONF_FL_INCREMENT; - } - } - mpq_a->mpq_l->mpq_files[fl_count_fb] = NULL; - - /* if no error occurs and no listfile was assigned, we think there was no matching listfile. */ - if (result == 0) { - result = LIBMPQ_CONF_EFILE_NOT_FOUND; - } - } - - return result; -} - -/* - * This function frees the allocated memory for the listfile. - */ -int libmpq_listfile_close(mpq_archive *mpq_a) { - int i = 0; - - /* safety check if we really have a filelist. */ - if (mpq_a->mpq_l->mpq_files != NULL) { - /* freeing the filelist */ - while (mpq_a->mpq_l->mpq_files[i]) { - free(mpq_a->mpq_l->mpq_files[i++]); - } - free(mpq_a->mpq_l->mpq_files); - } - return 0; -} - -int libmpq_file_getdata(mpq_archive *mpq_a, mpq_hash mpq_h, const int number, unsigned char *dest) { - int blockindex = number; //-1; - int i = 0; - mpq_file *mpq_f = NULL; - mpq_block *mpq_b = NULL; - int success = 0; - - /*if (number < 1 || number > mpq_a->header->blocktablesize) { - return LIBMPQ_EINV_RANGE; - }*/ - - /* search for correct hashtable */ - /*for (i = 0; i < mpq_a->header->hashtablesize; i++) { - if ((number - 1) == (mpq_a->hashtable[i]).blockindex) { - blockindex = (mpq_a->hashtable[i]).blockindex; - mpq_h = &(mpq_a->hashtable[i]); - break; - } - }*/ - - /* check if file was found */ - if (blockindex == -1 || blockindex > mpq_a->header->blocktablesize) { - return LIBMPQ_EFILE_NOT_FOUND; - } - - /* check if sizes are correct */ - mpq_b = mpq_a->blocktable + blockindex; - if (mpq_b->filepos > (mpq_a->header->archivesize + mpq_a->mpqpos) || mpq_b->csize > mpq_a->header->archivesize) { - return LIBMPQ_EFILE_CORRUPT; - } - - /* check if file exists */ - if ((mpq_b->flags & LIBMPQ_FILE_EXISTS) == 0) { - return LIBMPQ_EFILE_NOT_FOUND; - } - - /* allocate memory for file structure */ - mpq_f = (mpq_file*)malloc(sizeof(mpq_file)); - if (!mpq_f) { - return LIBMPQ_EALLOCMEM; - } - - /* initialize file structure */ - memset(mpq_f, 0, sizeof(mpq_file)); - mpq_f->mpq_b = mpq_b; - mpq_f->nblocks = (mpq_f->mpq_b->fsize + mpq_a->blocksize - 1) / mpq_a->blocksize; - mpq_f->mpq_h = &mpq_h; - mpq_f->accessed = FALSE; - mpq_f->blockposloaded = FALSE; - - /* allocate buffers for decompression. */ - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESSED) { - - /* - * Allocate buffer for block positions. At the begin of file are stored - * unsigned ints holding positions of each block relative from begin of - * file in the archive. - */ - if ((mpq_f->blockpos = (unsigned int*)malloc(sizeof(int) * (mpq_f->nblocks + 1))) == NULL) { - return LIBMPQ_EALLOCMEM; - } - } - - if(libmpq_file_read_file(mpq_a, mpq_f, 0, (char*)dest, mpq_b->fsize) == mpq_b->fsize) - success = 1; - - if (mpq_f->mpq_b->flags & LIBMPQ_FILE_COMPRESSED) { - // Free buffer for block positions - - free(mpq_f->blockpos); - } - /* freeing the file structure */ - free(mpq_f); - return success?LIBMPQ_TOOLS_SUCCESS:LIBMPQ_EFILE_CORRUPT; -} diff --git a/contrib/extractor/libmpq/mpq.h b/contrib/extractor/libmpq/mpq.h deleted file mode 100644 index 55b72ad75..000000000 --- a/contrib/extractor/libmpq/mpq.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * mpq.h -- some default types and defines. - * - * Copyright (C) 2003 Maik Broemme - * - * This source was adepted from the C++ version of StormLib.h and - * StormPort.h included in stormlib. The C++ version belongs to - * the following authors, - * - * Ladislav Zezula - * Marko Friedemann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id: mpq.h,v 1.8 2004/02/12 00:45:50 mbroemme Exp $ - */ - -#ifndef _MPQ_H -#define _MPQ_H - -#include - -#ifndef PATH_MAX - #define PATH_MAX 260 -#endif - - -#define LIBMPQ_MAJOR_VERSION 0 /* Major version number... maybe sometimes we reach version 1 :) */ -#define LIBMPQ_MINOR_VERSION 3 /* Minor version number - increased only for small changes */ -#define LIBMPQ_PATCH_VERSION 0 /* Patchlevel - changed on bugfixes etc... */ - -#define LIBMPQ_TOOLS_SUCCESS 0 /* return value for all functions which success */ -#define LIBMPQ_TOOLS_BUFSIZE 0x500 /* buffer size for the decryption engine */ - -#define LIBMPQ_EFILE -1 /* error on file operation */ -#define LIBMPQ_EFILE_FORMAT -2 /* bad file format */ -#define LIBMPQ_EFILE_CORRUPT -3 /* file corrupt */ -#define LIBMPQ_EFILE_NOT_FOUND -4 /* file in archive not found */ -#define LIBMPQ_EFILE_READ -5 /* Read error in archive */ -#define LIBMPQ_EALLOCMEM -6 /* maybe not enough memory? :) */ -#define LIBMPQ_EFREEMEM -7 /* can not free memory */ -#define LIBMPQ_EINV_RANGE -8 /* Given filenumber is out of range */ -#define LIBMPQ_EHASHTABLE -9 /* error in reading hashtable */ -#define LIBMPQ_EBLOCKTABLE -10 /* error in reading blocktable */ - -#define LIBMPQ_ID_MPQ 0x1A51504D /* MPQ archive header ID ('MPQ\x1A') */ -#define LIBMPQ_HEADER_W3M 0x6D9E4B86 /* special value used by W3M Map Protector */ -#define LIBMPQ_FLAG_PROTECTED 0x00000002 /* Set on protected MPQs (like W3M maps) */ -#define LIBMPQ_HASH_ENTRY_DELETED 0xFFFFFFFE /* Block index for deleted hash entry */ - -#define LIBMPQ_FILE_COMPRESS_PKWARE 0x00000100 /* Compression made by PKWARE Data Compression Library */ -#define LIBMPQ_FILE_COMPRESS_MULTI 0x00000200 /* Multiple compressions */ -#define LIBMPQ_FILE_COMPRESSED 0x0000FF00 /* File is compressed */ -#define LIBMPQ_FILE_EXISTS 0x80000000 /* Set if file exists, reset when the file was deleted */ -#define LIBMPQ_FILE_ENCRYPTED 0x00010000 /* Indicates whether file is encrypted */ -#define LIBMPQ_FILE_HAS_METADATA 0x04000000 - -#define LIBMPQ_FILE_COMPRESSED_SIZE 1 /* MPQ compressed filesize of given file */ -#define LIBMPQ_FILE_UNCOMPRESSED_SIZE 2 /* MPQ uncompressed filesize of given file */ -#define LIBMPQ_FILE_COMPRESSION_TYPE 3 /* MPQ compression type of given file */ -#define LIBMPQ_FILE_TYPE_INT 4 /* file is given by number */ -#define LIBMPQ_FILE_TYPE_CHAR 5 /* file is given by name */ - -#define LIBMPQ_MPQ_ARCHIVE_SIZE 1 /* MPQ archive size */ -#define LIBMPQ_MPQ_HASHTABLE_SIZE 2 /* MPQ archive hashtable size */ -#define LIBMPQ_MPQ_BLOCKTABLE_SIZE 3 /* MPQ archive blocktable size */ -#define LIBMPQ_MPQ_BLOCKSIZE 4 /* MPQ archive blocksize */ -#define LIBMPQ_MPQ_NUMFILES 5 /* Number of files in the MPQ archive */ -#define LIBMPQ_MPQ_COMPRESSED_SIZE 6 /* Compressed archive size */ -#define LIBMPQ_MPQ_UNCOMPRESSED_SIZE 7 /* Uncompressed archive size */ - -#define LIBMPQ_HUFF_DECOMPRESS 0 /* Defines that we want to decompress using huffman trees. */ - -#define LIBMPQ_CONF_EFILE_OPEN -1 /* error if a specific listfile was forced and could not be opened. */ -#define LIBMPQ_CONF_EFILE_CORRUPT -2 /* listfile seems to be corrupt */ -#define LIBMPQ_CONF_EFILE_LIST_CORRUPT -3 /* listfile seems correct, but filelist is broken */ -#define LIBMPQ_CONF_EFILE_NOT_FOUND -4 /* error if no matching listfile found */ -#define LIBMPQ_CONF_EFILE_VERSION -5 /* libmpq version does not match required listfile version */ - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -/* -#ifndef min -#define min(a, b) ((a < b) ? a : b) -#endif -*/ - -typedef unsigned int mpq_buffer[LIBMPQ_TOOLS_BUFSIZE]; -typedef int (*DECOMPRESS)(char *, int *, char *, int); -typedef struct { - unsigned long mask; /* Decompression bit */ - DECOMPRESS decompress; /* Decompression function */ -} decompress_table; - -/* MPQ file header */ -typedef struct { - unsigned int id; /* The 0x1A51504D ('MPQ\x1A') signature */ - unsigned int offset; /* Offset of the first file (Relative to MPQ start) */ - unsigned int archivesize; /* Size of MPQ archive */ - unsigned short offsetsc; /* 0000 for SC and BW */ - unsigned short blocksize; /* Size of file block is (0x200 << blockSize) */ - unsigned int hashtablepos; /* File position of hashTable */ - unsigned int blocktablepos; /* File position of blockTable. Each entry has 16 bytes */ - unsigned int hashtablesize; /* Number of entries in hash table */ - unsigned int blocktablesize; /* Number of entries in the block table */ -} mpq_header; -//} __attribute__ ((packed)) mpq_header; - - -/* Hash entry. All files in the archive are searched by their hashes. */ -typedef struct { - unsigned int name1; /* The first two unsigned ints */ - unsigned int name2; /* are the encrypted file name */ - unsigned int locale; /* Locale information. */ - unsigned int blockindex; /* Index to file description block */ -} mpq_hash; - -/* File description block contains informations about the file */ -typedef struct { - unsigned int filepos; /* Block file starting position in the archive */ - unsigned int csize; /* Compressed file size */ - unsigned int fsize; /* Uncompressed file size */ - unsigned int flags; /* Flags */ -} mpq_block; - -/* File handle structure used since Diablo 1.00 (0x38 bytes) */ -typedef struct { - unsigned char filename[PATH_MAX]; /* filename of the actual file in the archive */ - int fd; /* File handle */ - unsigned int seed; /* Seed used for file decrypt */ - unsigned int filepos; /* Current file position */ - unsigned int offset; - unsigned int nblocks; /* Number of blocks in the file (incl. the last noncomplete one) */ - unsigned int *blockpos; /* Position of each file block (only for compressed files) */ - int blockposloaded; /* TRUE if block positions loaded */ - unsigned int offset2; /* (Number of bytes somewhere ?) */ - mpq_hash *mpq_h; /* Hash table entry */ - mpq_block *mpq_b; /* File block pointer */ - - /* Non-Storm.dll members */ - - unsigned int accessed; /* Was something from the file already read? */ -} mpq_file; - -/* List handle structure */ -typedef struct { - unsigned char mpq_version[10]; /* libmpq version required by the listfile */ - unsigned char mpq_name[PATH_MAX]; /* mpq archive name without full path */ - unsigned char mpq_type[20]; /* mpq archive type */ - unsigned char mpq_game[40]; /* blizzard title the file matches */ - unsigned char mpq_game_version[10]; /* game version */ - unsigned char **mpq_files; /* filelist */ -} mpq_list; - -/* Archive handle structure used since Diablo 1.00 */ -typedef struct { - unsigned char filename[PATH_MAX]; /* Opened archive file name */ - int fd; /* File handle */ - unsigned int blockpos; /* Position of loaded block in the file */ - unsigned int blocksize; /* Size of file block */ - unsigned char *blockbuf; /* Buffer (cache) for file block */ - unsigned int bufpos; /* Position in block buffer */ - unsigned int mpqpos; /* MPQ archive position in the file */ - unsigned int filepos; /* Current file pointer */ - unsigned int openfiles; /* Number of open files + 1 */ - mpq_buffer buf; /* MPQ buffer */ - mpq_header *header; /* MPQ file header */ - mpq_hash *hashtable; /* Hash table */ - mpq_block *blocktable; /* Block table */ - - /* Non-Storm.dll members */ - - mpq_list *mpq_l; /* Handle to file list from database */ - - unsigned int flags; /* See LIBMPQ_TOOLS_FLAG_XXXXX */ - unsigned int maxblockindex; /* The highest block table entry */ -} mpq_archive; - -extern char *libmpq_version(); -extern int libmpq_archive_open(mpq_archive *mpq_a, unsigned char *mpq_filename); -extern int libmpq_archive_close(mpq_archive *mpq_a); -extern int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype); -//extern int libmpq_file_extract(mpq_archive *mpq_a, const int number); -extern int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number); -extern char *libmpq_file_name(mpq_archive *mpq_a, const int number); -extern int libmpq_file_number(mpq_archive *mpq_a, const char *name); -extern int libmpq_file_check(mpq_archive *mpq_a, void *file, int type); -extern int libmpq_listfile_open(mpq_archive *mpq_a, char file[PATH_MAX]); -extern int libmpq_listfile_close(mpq_archive *mpq_a); - -extern int libmpq_pkzip_decompress(char *out_buf, int *out_length, char *in_buf, int in_length); -extern int libmpq_zlib_decompress(char *out_buf, int *out_length, char *in_buf, int in_length); -extern int libmpq_huff_decompress(char *out_buf, int *out_length, char *in_buf, int in_length); -extern int libmpq_wave_decompress_stereo(char *out_buf, int *out_length, char *in_buf, int in_length); -extern int libmpq_wave_decompress_mono(char *out_buf, int *out_length, char *in_buf, int in_length); -extern int libmpq_multi_decompress(char *out_buf, int *pout_length, char *in_buf, int in_length); - -static decompress_table dcmp_table[] = { - {0x08, libmpq_pkzip_decompress}, /* Decompression with Pkware Data Compression Library */ - {0x02, libmpq_zlib_decompress}, /* Decompression with the "zlib" library */ - {0x01, libmpq_huff_decompress}, /* Huffmann decompression */ - {0x80, libmpq_wave_decompress_stereo}, /* WAVE decompression for stereo waves */ - {0x40, libmpq_wave_decompress_mono} /* WAVE decompression for mono waves */ -}; - -int libmpq_file_extract(mpq_archive *mpq_a, const int number, const char *filename); -int libmpq_file_getdata(mpq_archive *mpq_a, mpq_hash mpq_h, const int number, unsigned char *dest); -#endif /* _MPQ_H */ diff --git a/contrib/extractor/libmpq/parser.cpp b/contrib/extractor/libmpq/parser.cpp deleted file mode 100644 index 435395b87..000000000 --- a/contrib/extractor/libmpq/parser.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * parser.c -- functions used to parse list or config file. - * - * Copyright (C) 2003 Maik Broemme - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id: parser.c,v 1.5 2004/02/12 00:47:53 mbroemme Exp $ - */ -#define _CRT_SECURE_NO_DEPRECATE - -#include -#include -#include -#include "mpq.h" -#include "common.h" -#include - -/* - * This function deletes the specified characters, but leaves - * escape sequences unaffected. This means that " would be - * deleted but \" would not. - */ -char *libmpq_conf_delete_char(char *buf, char *chars) { - static char *temp; - char ch; - - temp = buf; - - /* strip out special chars like " */ - while (temp = strpbrk(temp, chars)) { - ch = temp[0]; - memmove(&temp[0], &temp[1], strlen(temp)); - if (ch == '\\') { - temp++; - } - } - - return buf; -} - -/* - * This function parses a line for the value to the given option. It - * return 1 on success and the byte array or 0 and null. - */ -int libmpq_conf_parse_line(char *line, char *search_value, char *return_value, int size) { - int level = 0; - int found = 0; - int i = 0; - int pos = 0; - - /* search value */ - while (*(++line)) { - - /* check for spaces */ - if (!isspace(*line) && level == 1) { - - /* we found our value so break */ - found = 1; - break; - } - - /* check for '=' so the value follows as next parameter */ - if (*line == '=' && level == 0) { - level = 1; - } - } - - /* now search for comment in this line */ - for (i = 0; i < int(strlen(line)); i++) { - if (line[i] == '#') { - pos = i - 1; - break; - } - } - - /* now set end of byte array behind value, but only if comment was found */ - if (pos != 0) { - for (i = pos; i >= 0; i--) { - if (line[i] != ' ' && line[i] != '\t') { - line[i + 1] = '\0'; - break; - } - } - } - - /* now check if line has trailing spaces */ - for (i = strlen(line); i >= 0; i--) { - if (line[i] != ' ' && line[i] != '\t') { - line[i + 1] = '\0'; - break; - } - } - - /* now check if value is quoted with "" and if there is a char behind. */ - for (i = strlen(line); i >= 0; i--) { - if (line[i] == '"') { - line[i + 1] = '\0'; - break; - } - } - - /* return the values */ - strncpy(return_value, line, size); - return found; -} - -/* - * This function returns the value for a given option in the - * listdb or config file. On success it returns 1, otherwise 0. - */ -int libmpq_conf_get_value(FILE *fp, char *search_value, void *return_value, int type, int size) { - char buf[LIBMPQ_CONF_BUFSIZE]; - int found = 0; - int result = LIBMPQ_TOOLS_SUCCESS; - - while (fgets(buf, LIBMPQ_CONF_BUFSIZE, fp) != NULL) { - char *line; - - buf[strlen(buf) - 1] = '\0'; - - /* skip whitespace */ - for (line = buf; isspace(*line); line++) { - continue; - } - - /* skip empty line */ - if (line[0] == '\0') { - continue; - } - - /* skip comments */ - if (line[0] == '#') { - continue; - } - - /* process the line */ - //if (!strncasecmp(line, search_value, strlen(search_value))) { - if (!strcmp(line, search_value)) { - found = libmpq_conf_parse_line(line, search_value, line, LIBMPQ_CONF_BUFSIZE); - if (found == 1) { - libmpq_conf_delete_char(line, "\"\\"); - - switch (type) { - case LIBMPQ_CONF_TYPE_INT: - - /* if it is no valid number it is safe to return 0 */ - *(int *)return_value = atoi(line); - break; - default: - strncpy((char *)return_value, line, size); - break; - } - - /* value found, so rewind stream */ - break; - } - } - } - - /* if value was not found */ - if (found == 0) { - switch (type) { - case LIBMPQ_CONF_TYPE_INT: - *(int *)return_value = 0; - result = LIBMPQ_CONF_EVALUE_NOT_FOUND; - break; - default: - strncpy((char *)return_value, "", size); - result = LIBMPQ_CONF_EVALUE_NOT_FOUND; - break; - } - } - fseek(fp, 0L, SEEK_SET); - - return result; -} - -/* - * This function returns a pointer to a byte array, with all values - * found in the config file. As second value it returns th number of - * entries in the byte array. On success it returns 1, otherwise 0. - */ -int libmpq_conf_get_array(FILE *fp, char *search_value, char ***filelist, int *entries) { - char buf[LIBMPQ_CONF_BUFSIZE]; - char temp[LIBMPQ_CONF_BUFSIZE]; - int level = 0; - int array_start = 0; - int array_end = 0; - int fl_count; - int fl_size; - int found = 0; - int i = 0; - - *entries = 0; - - /* allocate memory for the file list */ - (*filelist) = (char **)malloc(LIBMPQ_CONF_FL_INCREMENT * sizeof(char *)); - fl_count = 0; - fl_size = LIBMPQ_CONF_FL_INCREMENT; - - while (fgets(buf, LIBMPQ_CONF_BUFSIZE, fp) != NULL) { - char *line; - - buf[strlen(buf) - 1] = '\0'; - - /* skip whitespace */ - for (line = buf; isspace(*line); line++) { - continue; - } - - /* skip empty line */ - if (line[0] == '\0') { - continue; - } - - /* skip comments */ - if (line[0] == '#') { - continue; - } - - /* check for array end ) */ - if (*line == ')') { - array_end = 1; - break; - } - - /* process entries between () */ - if (array_start == 1 && array_end == 0) { - - /* add dummy option to use with libmpq_conf_parse_line() */ - strncpy(temp, "MPQ_BUFFER = ", LIBMPQ_CONF_BUFSIZE); - strncat(temp, line, LIBMPQ_CONF_BUFSIZE); - found = libmpq_conf_parse_line(temp, "MPQ_BUFFER", temp, LIBMPQ_CONF_BUFSIZE); - - if (found == 1) { - libmpq_conf_delete_char(temp, "\"\\"); - - /* set the next filelist entry to a copy of the file */ - (*filelist)[fl_count++] = _strdup(temp); - - /* increase the array size */ - if (fl_count == fl_size) { - (*filelist) = (char **)realloc((*filelist), (fl_size + LIBMPQ_CONF_FL_INCREMENT) * sizeof(char *)); - fl_size += LIBMPQ_CONF_FL_INCREMENT; - } - - /* increase number of entries */ - (*entries)++; - } - } - - /* process the line and search array start */ - //if (!strncasecmp(line, search_value, strlen(search_value))) { - if (!strcmp(line, search_value)) { - - /* search value */ - while (*(++line)) { - - /* check for array start ( */ - if (*line == '(' && level == 1) { - - /* we found our value so break */ - array_start = 1; - break; - } - - /* check for '=' so the value follows as next parameter */ - if (*line == '=' && level == 0) { - level = 1; - } - } - } - } - - /* we got all files, so rewind stream */ - fseek(fp, 0L, SEEK_SET); - - (*filelist)[fl_count] = NULL; - - return found; -} diff --git a/contrib/extractor/libmpq/wave.cpp b/contrib/extractor/libmpq/wave.cpp deleted file mode 100644 index d8907611d..000000000 --- a/contrib/extractor/libmpq/wave.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * wave.c -- this file contains decompression methods used by Storm.dll - * to decompress wave files. - * - * Copyright (C) 2003 Maik Broemme - * - * This source was adepted from the C++ version of wave.cpp included - * in stormlib. The C++ version belongs to the following authors, - * - * Ladislav Zezula - * Tom Amigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "wave.h" - -/* Tables necessary dor decompression */ -static unsigned long wave_table_1503f120[] = { - 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 -}; - -static unsigned long wave_table_1503f1a0[] = { - 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, - 0x00000010, 0x00000011, 0x00000013, 0x00000015, 0x00000017, 0x00000019, 0x0000001C, 0x0000001F, - 0x00000022, 0x00000025, 0x00000029, 0x0000002D, 0x00000032, 0x00000037, 0x0000003C, 0x00000042, - 0x00000049, 0x00000050, 0x00000058, 0x00000061, 0x0000006B, 0x00000076, 0x00000082, 0x0000008F, - 0x0000009D, 0x000000AD, 0x000000BE, 0x000000D1, 0x000000E6, 0x000000FD, 0x00000117, 0x00000133, - 0x00000151, 0x00000173, 0x00000198, 0x000001C1, 0x000001EE, 0x00000220, 0x00000256, 0x00000292, - 0x000002D4, 0x0000031C, 0x0000036C, 0x000003C3, 0x00000424, 0x0000048E, 0x00000502, 0x00000583, - 0x00000610, 0x000006AB, 0x00000756, 0x00000812, 0x000008E0, 0x000009C3, 0x00000ABD, 0x00000BD0, - 0x00000CFF, 0x00000E4C, 0x00000FBA, 0x0000114C, 0x00001307, 0x000014EE, 0x00001706, 0x00001954, - 0x00001BDC, 0x00001EA5, 0x000021B6, 0x00002515, 0x000028CA, 0x00002CDF, 0x0000315B, 0x0000364B, - 0x00003BB9, 0x000041B2, 0x00004844, 0x00004F7E, 0x00005771, 0x0000602F, 0x000069CE, 0x00007462, - 0x00007FFF -}; - -/* - * Decompress a wave file, mono or stereo - * - * Offset: 1500F230 - */ -int libmpq_wave_decompress(unsigned char *out_buf, int out_length, unsigned char *in_buf, int in_length, int channels) { - byte_and_short out; - byte_and_short in; - unsigned char *in_end = in_buf + in_length; /* End on input buffer */ - unsigned long index; - long nr_array1[2]; - long nr_array2[2]; - int count = 0; - - out.pb = out_buf; - in.pb = in_buf; - nr_array1[0] = 0x2C; - nr_array1[1] = 0x2C; - in.pw++; - - /* 15007AD7 */ - for (count = 0; count < channels; count++) { - long temp; - temp = *(short *)in.pw++; - nr_array2[count] = temp; - if (out_length < 2) { - return out.pb - out_buf; - } - *out.pw++ = (unsigned short)temp; - out_length -= 2; - } - index = channels - 1; - while (in.pb < in_end) { - unsigned char one_byte = *in.pb++; - if (channels == 2) { - index = (index == 0) ? 1 : 0; - } - - /* - * Get one byte from input buffer - * 15007B25 - */ - if (one_byte & 0x80) { - /* 15007B32 */ - switch(one_byte & 0x7F) { - case 0: /* 15007B8E */ - if (nr_array1[index] != 0) { - nr_array1[index]--; - } - if (out_length < 2) { - break; - } - *out.pw++ = (unsigned short)nr_array2[index]; - out_length -= 2; - continue; - case 1: /* 15007B72 */ - nr_array1[index] += 8; /* EBX also */ - if (nr_array1[index] > 0x58) { - nr_array1[index] = 0x58; - } - if (channels == 2) { - index = (index == 0) ? 1 : 0; - } - continue; - case 2: - continue; - default: - nr_array1[index] -= 8; - if (nr_array1[index] < 0) { - nr_array1[index] = 0; - } - if (channels != 2) { - continue; - } - index = (index == 0) ? 1 : 0; - continue; - } - } else { - unsigned long temp1 = wave_table_1503f1a0[nr_array1[index]]; /* EDI */ - unsigned long temp2 = temp1 >> in_buf[1]; /* ESI */ - long temp3 = nr_array2[index]; /* ECX */ - if (one_byte & 0x01) { /* EBX = one_byte */ - temp2 += (temp1 >> 0); - } - if (one_byte & 0x02) { - temp2 += (temp1 >> 1); - } - if (one_byte & 0x04) { - temp2 += (temp1 >> 2); - } - if (one_byte & 0x08) { - temp2 += (temp1 >> 3); - } - if (one_byte & 0x10) { - temp2 += (temp1 >> 4); - } - if (one_byte & 0x20) { - temp2 += (temp1 >> 5); - } - if(one_byte & 0x40) { - temp3 -= temp2; - if (temp3 <= (long)0xFFFF8000) { - temp3 = (long)0xFFFF8000; - } - } else { - temp3 += temp2; - if (temp3 >= 0x7FFF) { - temp3 = 0x7FFF; - } - } - nr_array2[index] = temp3; - if (out_length < 2) { - break; - } - - temp2 = nr_array1[index]; - one_byte &= 0x1F; - *out.pw++ = (unsigned short)temp3; - out_length -= 2; - temp2 += wave_table_1503f120[one_byte]; - nr_array1[index] = temp2; - - if (nr_array1[index] < 0) { - nr_array1[index] = 0; - } else { - if (nr_array1[index] > 0x58) { - nr_array1[index] = 0x58; - } - } - } - } - return (out.pb - out_buf); -} diff --git a/contrib/extractor/libmpq/wave.h b/contrib/extractor/libmpq/wave.h deleted file mode 100644 index 5beb97a72..000000000 --- a/contrib/extractor/libmpq/wave.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * wave.h -- header file for WAVe unplode functions used by mpq-tools. - * - * Copyright (C) 2003 Maik Broemme - * - * This source was adepted from the C++ version of wave.h included - * in stormlib. The C++ version belongs to the following authors, - * - * Ladislav Zezula - * Tom Amigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _WAVE_H -#define _WAVE_H - -typedef union { - unsigned short *pw; - unsigned char *pb; -} byte_and_short; - -int libmpq_wave_decompress(unsigned char *out_buf, int out_length, unsigned char *in_buf, int in_length, int channels); - -#endif /* _WAVE_H */ diff --git a/contrib/extractor/loadlib/adt.cpp b/contrib/extractor/loadlib/adt.cpp index fde706811..bb1e3bfcc 100644 --- a/contrib/extractor/loadlib/adt.cpp +++ b/contrib/extractor/loadlib/adt.cpp @@ -48,6 +48,27 @@ bool ADT_file::prepareLoadedData() if (!a_grid->prepareLoadedData()) return false; + // funny offsets calculations because there is no mapping for them and they have variable lengths + uint8* ptr = (uint8*)a_grid + a_grid->size + 8; + uint32 mcnk_count = 0; + memset(cells, 0, ADT_CELLS_PER_GRID * ADT_CELLS_PER_GRID * sizeof(adt_MCNK*)); + while (ptr < GetData() + GetDataSize()) + { + uint32 header = *(uint32*)ptr; + uint32 size = *(uint32*)(ptr + 4); + if (header == 'MCNK') + { + cells[mcnk_count / ADT_CELLS_PER_GRID][mcnk_count % ADT_CELLS_PER_GRID] = (adt_MCNK*)ptr; + ++mcnk_count; + } + + // move to next chunk + ptr += size + 8; + } + + if (mcnk_count != ADT_CELLS_PER_GRID * ADT_CELLS_PER_GRID) + return false; + return true; } diff --git a/contrib/extractor/loadlib/adt.h b/contrib/extractor/loadlib/adt.h index 9c9167376..84d68c795 100644 --- a/contrib/extractor/loadlib/adt.h +++ b/contrib/extractor/loadlib/adt.h @@ -25,6 +25,7 @@ enum LiquidType // // Adt file height map chunk // +class ADT_file; class adt_MCVT { union{ @@ -252,9 +253,11 @@ class adt_MHDR uint32 fcc; char fcc_txt[4]; }; + +public: uint32 size; - uint32 pad; + uint32 flags; uint32 offsMCIN; // MCIN uint32 offsTex; // MTEX uint32 offsModels; // MMDX @@ -272,8 +275,8 @@ class adt_MHDR uint32 data5; public: bool prepareLoadedData(); - adt_MCIN *getMCIN(){ return (adt_MCIN *)((uint8 *)&pad+offsMCIN);} - adt_MH2O *getMH2O(){ return offsMH2O ? (adt_MH2O *)((uint8 *)&pad+offsMH2O) : 0;} + adt_MCIN* getMCIN() { return offsMCIN ? (adt_MCIN *)((uint8 *)&flags+offsMCIN) : 0; } + adt_MH2O* getMH2O() { return offsMH2O ? (adt_MH2O *)((uint8 *)&flags+offsMH2O) : 0; } }; @@ -284,7 +287,8 @@ public: ~ADT_file(); void free(); - adt_MHDR *a_grid; + adt_MHDR* a_grid; + adt_MCNK* cells[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]; }; bool isHole(int holes, int i, int j); diff --git a/contrib/extractor/loadlib/loadlib.cpp b/contrib/extractor/loadlib/loadlib.cpp index c8a76b7dc..1ec13b6c2 100644 --- a/contrib/extractor/loadlib/loadlib.cpp +++ b/contrib/extractor/loadlib/loadlib.cpp @@ -1,11 +1,78 @@ #define _CRT_SECURE_NO_DEPRECATE #include "loadlib.h" -#include "../mpq_libmpq.h" -#include +// list of mpq files for lookup most recent file version +ArchiveSet gOpenArchives; -class MPQFile; +ArchiveSetBounds GetArchivesBounds() +{ + return ArchiveSetBounds(gOpenArchives.begin(), gOpenArchives.end()); +} + +bool OpenArchive(char const* mpqFileName, HANDLE* mpqHandlePtr /*= NULL*/) +{ + HANDLE mpqHandle; + + if (!SFileOpenArchive(mpqFileName, 0, MPQ_OPEN_READ_ONLY, &mpqHandle)) + return false; + + gOpenArchives.push_back(mpqHandle); + + if (mpqHandlePtr) + *mpqHandlePtr = mpqHandle; + + return true; +} + +bool OpenNewestFile(char const* filename, HANDLE* fileHandlerPtr) +{ + for(ArchiveSet::const_reverse_iterator i=gOpenArchives.rbegin(); i!=gOpenArchives.rend();++i) + { + // always prefer get updated file version + if (SFileOpenFileEx(*i, filename, SFILE_OPEN_PATCHED_FILE, fileHandlerPtr)) + return true; + } + + return false; +} + +bool ExtractFile( char const* mpq_name, std::string const& filename ) +{ + for(ArchiveSet::const_reverse_iterator i=gOpenArchives.rbegin(); i!=gOpenArchives.rend();++i) + { + HANDLE fileHandle; + if (!SFileOpenFileEx(*i, mpq_name, SFILE_OPEN_PATCHED_FILE, &fileHandle)) + continue; + + if (SFileGetFileSize(fileHandle, NULL) == 0) // some files removed in next updates and its reported size 0 + { + SFileCloseFile(fileHandle); + return true; + } + + SFileCloseFile(fileHandle); + + if (!SFileExtractFile(*i, mpq_name, filename.c_str(), SFILE_OPEN_PATCHED_FILE)) + { + printf("Can't extract file: %s\n", mpq_name); + return false; + } + + return true; + } + + printf("Extracting file not found: %s\n", filename.c_str()); + return false; +} + + +void CloseArchives() +{ + for(ArchiveSet::const_iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) + SFileCloseArchive(*i); + gOpenArchives.clear(); +} FileLoader::FileLoader() { @@ -22,36 +89,54 @@ FileLoader::~FileLoader() bool FileLoader::loadFile(char *filename, bool log) { free(); - MPQFile mf(filename); - if(mf.isEof()) + + HANDLE fileHandle = 0; + + if (!OpenNewestFile(filename, &fileHandle)) { if (log) printf("No such file %s\n", filename); return false; } - data_size = mf.getSize(); + data_size = SFileGetFileSize(fileHandle, NULL); data = new uint8 [data_size]; - if (data) + if (!data) { - mf.read(data, data_size); - mf.close(); - if (prepareLoadedData()) - return true; + SFileCloseFile(fileHandle); + return false; } - printf("Error loading %s", filename); - mf.close(); - free(); - return false; + + if (!SFileReadFile(fileHandle, data, data_size, NULL, NULL)) + { + if (log) + printf("Can't read file %s\n", filename); + SFileCloseFile(fileHandle); + return false; + } + + SFileCloseFile(fileHandle); + + // ToDo: Fix WDT errors... + if (!prepareLoadedData()) + { + //printf("Error loading %s\n\n", filename); + //free(); + return true; + } + + return true; } bool FileLoader::prepareLoadedData() { // Check version version = (file_MVER *) data; + if (version->fcc != 'MVER') return false; + if (version->ver != FILE_FORMAT_VERSION) return false; return true; diff --git a/contrib/extractor/loadlib/loadlib.h b/contrib/extractor/loadlib/loadlib.h index 96cd25ced..006a2ed7a 100644 --- a/contrib/extractor/loadlib/loadlib.h +++ b/contrib/extractor/loadlib/loadlib.h @@ -1,6 +1,13 @@ #ifndef LOAD_LIB_H #define LOAD_LIB_H +#ifdef _DLL +#undef _DLL +#endif + +#include "StormLib.h" +#include + #ifdef WIN32 typedef __int64 int64; typedef __int32 int32; @@ -27,6 +34,15 @@ typedef uint16_t uint16; typedef uint8_t uint8; #endif +typedef std::deque ArchiveSet; +typedef std::pair ArchiveSetBounds; + +bool OpenArchive(char const* mpqFileName, HANDLE* mpqHandlePtr = NULL); +bool OpenNewestFile(char const* filename, HANDLE* fileHandlerPtr); +ArchiveSetBounds GetArchivesBounds(); +bool ExtractFile( char const* mpq_name, std::string const& filename ); +void CloseArchives(); + #define FILE_FORMAT_VERSION 18 // diff --git a/contrib/extractor/mpq_libmpq.cpp b/contrib/extractor/mpq_libmpq.cpp deleted file mode 100644 index 65facbff3..000000000 --- a/contrib/extractor/mpq_libmpq.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "mpq_libmpq.h" -#include -#include - -ArchiveSet gOpenArchives; - -MPQArchive::MPQArchive(const char* filename) -{ - int result = libmpq_archive_open(&mpq_a, (unsigned char*)filename); - printf("Opening %s\n", filename); - if(result) { - switch(result) { - case LIBMPQ_EFILE : /* error on file operation */ - printf("Error opening archive '%s': File operation Error\n", filename); - break; - case LIBMPQ_EFILE_FORMAT : /* bad file format */ - printf("Error opening archive '%s': Bad file format\n", filename); - break; - case LIBMPQ_EFILE_CORRUPT : /* file corrupt */ - printf("Error opening archive '%s': File corrupt\n", filename); - break; - case LIBMPQ_EFILE_NOT_FOUND : /* file in archive not found */ - printf("Error opening archive '%s': File in archive not found\n", filename); - break; - case LIBMPQ_EFILE_READ : /* Read error in archive */ - printf("Error opening archive '%s': Read error in archive\n", filename); - break; - case LIBMPQ_EALLOCMEM : /* maybe not enough memory? :) */ - printf("Error opening archive '%s': Maybe not enough memory\n", filename); - break; - case LIBMPQ_EFREEMEM : /* can not free memory */ - printf("Error opening archive '%s': Cannot free memory\n", filename); - break; - case LIBMPQ_EINV_RANGE : /* Given filenumber is out of range */ - printf("Error opening archive '%s': Given filenumber is out of range\n", filename); - break; - case LIBMPQ_EHASHTABLE : /* error in reading hashtable */ - printf("Error opening archive '%s': Error in reading hashtable\n", filename); - break; - case LIBMPQ_EBLOCKTABLE : /* error in reading blocktable */ - printf("Error opening archive '%s': Error in reading blocktable\n", filename); - break; - default: - printf("Error opening archive '%s': Unknown error\n", filename); - break; - } - return; - } - gOpenArchives.push_front(this); -} - -void MPQArchive::close() -{ - //gOpenArchives.erase(erase(&mpq_a); - libmpq_archive_close(&mpq_a); -} - -MPQFile::MPQFile(const char* filename): - eof(false), - buffer(0), - pointer(0), - size(0) -{ - for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i) - { - mpq_archive &mpq_a = (*i)->mpq_a; - - mpq_hash hash = (*i)->GetHashEntry(filename); - uint32 blockindex = hash.blockindex; - - if (blockindex == 0xFFFFFFFF) - continue; //file not found - - uint32 fileno = blockindex; - - //int fileno = libmpq_file_number(&mpq_a, filename); - //if(fileno == LIBMPQ_EFILE_NOT_FOUND) - // continue; - - // Found! - size = libmpq_file_info(&mpq_a, LIBMPQ_FILE_UNCOMPRESSED_SIZE, fileno); - // HACK: in patch.mpq some files don't want to open and give 1 for filesize - if (size<=1) { - eof = true; - buffer = 0; - return; - } - buffer = new char[size]; - - //libmpq_file_getdata - libmpq_file_getdata(&mpq_a, hash, fileno, (unsigned char*)buffer); - return; - - } - eof = true; - buffer = 0; -} - -size_t MPQFile::read(void* dest, size_t bytes) -{ - if (eof) return 0; - - size_t rpos = pointer + bytes; - if (rpos > size) { - bytes = size - pointer; - eof = true; - } - - memcpy(dest, &(buffer[pointer]), bytes); - - pointer = rpos; - - return bytes; -} - -void MPQFile::seek(int offset) -{ - pointer = offset; - eof = (pointer >= size); -} - -void MPQFile::seekRelative(int offset) -{ - pointer += offset; - eof = (pointer >= size); -} - -void MPQFile::close() -{ - if (buffer) delete[] buffer; - buffer = 0; - eof = true; -} diff --git a/contrib/extractor/mpq_libmpq.h b/contrib/extractor/mpq_libmpq.h deleted file mode 100644 index 7b5258e6a..000000000 --- a/contrib/extractor/mpq_libmpq.h +++ /dev/null @@ -1,121 +0,0 @@ -#define _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_WARNINGS - -#ifndef MPQ_H -#define MPQ_H - -#include "loadlib/loadlib.h" -#include "libmpq/mpq.h" -#include -#include -#include -#include -#include - -using namespace std; - -class MPQArchive -{ - -public: - mpq_archive mpq_a; - - MPQArchive(const char* filename); - void close(); - - uint32 HashString(const char* Input, uint32 Offset) { - uint32 seed1 = 0x7fed7fed; - uint32 seed2 = 0xeeeeeeee; - - for (uint32 i = 0; i < strlen(Input); i++) { - uint32 val = toupper(Input[i]); - seed1 = mpq_a.buf[Offset + val] ^ (seed1 + seed2); - seed2 = val + seed1 + seed2 + (seed2 << 5) + 3; - } - - return seed1; - } - mpq_hash GetHashEntry(const char* Filename) { - uint32 index = HashString(Filename, 0); - index &= mpq_a.header->hashtablesize - 1; - uint32 name1 = HashString(Filename, 0x100); - uint32 name2 = HashString(Filename, 0x200); - - for(uint32 i = index; i < mpq_a.header->hashtablesize; ++i) { - mpq_hash hash = mpq_a.hashtable[i]; - if (hash.name1 == name1 && hash.name2 == name2) return hash; - } - - mpq_hash nullhash; - nullhash.blockindex = 0xFFFFFFFF; - return nullhash; - } - - void GetFileListTo(vector& filelist) { - mpq_hash hash = GetHashEntry("(listfile)"); - uint32 blockindex = hash.blockindex; - - if ((blockindex == 0xFFFFFFFF) || (blockindex == 0)) - return; - - uint32 size = libmpq_file_info(&mpq_a, LIBMPQ_FILE_UNCOMPRESSED_SIZE, blockindex); - char *buffer = new char[size]; - - libmpq_file_getdata(&mpq_a, hash, blockindex, (unsigned char*)buffer); - - char seps[] = "\n"; - char *token; - - token = strtok( buffer, seps ); - uint32 counter = 0; - while ((token != NULL) && (counter < size)) { - //cout << token << endl; - token[strlen(token) - 1] = 0; - string s = token; - filelist.push_back(s); - counter += strlen(token) + 2; - token = strtok(NULL, seps); - } - - delete[] buffer; - } -}; -typedef std::deque ArchiveSet; - -class MPQFile -{ - //MPQHANDLE handle; - bool eof; - char *buffer; - size_t pointer,size; - - // disable copying - MPQFile(const MPQFile &f) {} - void operator=(const MPQFile &f) {} - -public: - MPQFile(const char* filename); // filenames are not case sensitive - ~MPQFile() { close(); } - size_t read(void* dest, size_t bytes); - size_t getSize() { return size; } - size_t getPos() { return pointer; } - char* getBuffer() { return buffer; } - char* getPointer() { return buffer + pointer; } - bool isEof() { return eof; } - void seek(int offset); - void seekRelative(int offset); - void close(); -}; - -inline void flipcc(char *fcc) -{ - char t; - t=fcc[0]; - fcc[0]=fcc[3]; - fcc[3]=t; - t=fcc[1]; - fcc[1]=fcc[2]; - fcc[2]=t; -} - -#endif diff --git a/contrib/extractor/release/zlib.lib b/contrib/extractor/release/zlib.lib deleted file mode 100644 index 42dded3ce..000000000 Binary files a/contrib/extractor/release/zlib.lib and /dev/null differ diff --git a/dep/ACE_Notes.md b/dep/ACE_Notes.md new file mode 100644 index 000000000..57a3c69ea --- /dev/null +++ b/dep/ACE_Notes.md @@ -0,0 +1,25 @@ +The default files for ACE_LITE were amended in this commit: https://github.com/mangos/mangosDeps/commit/52e4c984dbca474f7a4353b444339067a95ea277 + +The same changes need to be reapplied if a new version is added. + +The following two lines were amended to fix a connection bottleneck (especially on Linux): +- ACE_DEFAULT_BACKLOG - Change 5 to 128 https://github.com/mangos/mangosDeps/blob/Rel21/acelite/ace/Default_Constants.h#L81 +- ACE_DEFAULT_ASYNCH_BACKLOG - Change 5 to 128 https://github.com/mangos/mangosDeps/blob/Rel21/acelite/ace/Default_Constants.h#L85 + +For MacOS X, the ACE_UINT64_TYPE should be defined as follows in `ace/config-macosx-leopard.h` +``` +#define ACE_UINT64_TYPE unsigned long long +``` + +To get Travis CI working with `macos10.12` and `xcode8.3`, the following changes should be made to `ace/config-macosx-yosemite.h` +```diff + #include "ace/config-macosx-mavericks.h" ++#undef ACE_LACKS_CLOCKID_T ++#undef ACE_LACKS_CLOCK_MONOTONIC ++#undef ACE_LACKS_CLOCK_REALTIME +``` + +March 7th, 2018 - To build ACE as static library, one has to add the following line to the global CMakeLists.txt +``` +add_definitions(-DACE_AS_STATIC_LIBS) +``` diff --git a/dep/ACE_wrappers/ACE_vc10.sln b/dep/ACE_wrappers/ACE_vc10.sln index 347575b7a..27234c788 100644 --- a/dep/ACE_wrappers/ACE_vc10.sln +++ b/dep/ACE_wrappers/ACE_vc10.sln @@ -1,111 +1,111 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc10.vcxproj", "{47BC56ED-FECA-1BAD-6757-8A6300006755}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ace\ETCL\ACE_ETCL_Parser_vc10.vcxproj", "{42B1A787-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ace\ETCL\ACE_ETCL_vc10.vcxproj", "{17692659-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "ace\Monitor_Control\Monitor_Control_vc10.vcxproj", "{7153B6F4-FECA-1BAD-D619-74620E01B14C}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} - {42B1A787-FECA-1BAD-007E-8A67757B007A} = {42B1A787-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "ace\QoS\QoS_vc10.vcxproj", "{6ADC56EC-FECA-1BAD-7781-8A636757A7A3}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "bin\PerlACE\PerlACE_vc10.vcxproj", "{47B934A1-FECA-1BAD-A757-FC47A624E189}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin\bin_vc10.vcxproj", "{5F0C56EF-FECA-1BAD-64FC-8A63000064FE}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc10.vcxproj", "{47BC56ED-FECA-1BAD-6757-8A6300006755}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ace\ETCL\ACE_ETCL_Parser_vc10.vcxproj", "{42B1A787-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ace\ETCL\ACE_ETCL_vc10.vcxproj", "{17692659-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "ace\Monitor_Control\Monitor_Control_vc10.vcxproj", "{7153B6F4-FECA-1BAD-D619-74620E01B14C}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} + {42B1A787-FECA-1BAD-007E-8A67757B007A} = {42B1A787-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "ace\QoS\QoS_vc10.vcxproj", "{6ADC56EC-FECA-1BAD-7781-8A636757A7A3}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "bin\PerlACE\PerlACE_vc10.vcxproj", "{47B934A1-FECA-1BAD-A757-FC47A624E189}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin\bin_vc10.vcxproj", "{5F0C56EF-FECA-1BAD-64FC-8A63000064FE}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ACE_vc8.sln b/dep/ACE_wrappers/ACE_vc8.sln index efa8af456..363acffce 100644 --- a/dep/ACE_wrappers/ACE_vc8.sln +++ b/dep/ACE_wrappers/ACE_vc8.sln @@ -1,111 +1,111 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6300006755}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ace\ETCL\ACE_ETCL_Parser_vc8.vcproj", "{C756716B-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ace\ETCL\ACE_ETCL_vc8.vcproj", "{1903A9EA-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "ace\Monitor_Control\Monitor_Control_vc8.vcproj", "{B465937A-FECA-1BAD-D619-74620E01B14C}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} - {C756716B-FECA-1BAD-007E-8A67757B007A} = {C756716B-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "ace\QoS\QoS_vc8.vcproj", "{AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "bin\PerlACE\PerlACE_vc8.vcproj", "{E15379F8-FECA-1BAD-A757-FC47A624E189}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin\bin_vc8.vcproj", "{AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6300006755}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ace\ETCL\ACE_ETCL_Parser_vc8.vcproj", "{C756716B-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ace\ETCL\ACE_ETCL_vc8.vcproj", "{1903A9EA-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "ace\Monitor_Control\Monitor_Control_vc8.vcproj", "{B465937A-FECA-1BAD-D619-74620E01B14C}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} + {C756716B-FECA-1BAD-007E-8A67757B007A} = {C756716B-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "ace\QoS\QoS_vc8.vcproj", "{AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "bin\PerlACE\PerlACE_vc8.vcproj", "{E15379F8-FECA-1BAD-A757-FC47A624E189}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin\bin_vc8.vcproj", "{AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ACE_vc9.sln b/dep/ACE_wrappers/ACE_vc9.sln index 28c6ff64b..b592f0cf0 100644 --- a/dep/ACE_wrappers/ACE_vc9.sln +++ b/dep/ACE_wrappers/ACE_vc9.sln @@ -1,111 +1,111 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6300006755}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ace\ETCL\ACE_ETCL_Parser_vc9.vcproj", "{D756716B-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ace\ETCL\ACE_ETCL_vc9.vcproj", "{0903A9EA-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "ace\Monitor_Control\Monitor_Control_vc9.vcproj", "{A465937A-FECA-1BAD-D619-74620E01B14C}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} - {D756716B-FECA-1BAD-007E-8A67757B007A} = {D756716B-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "ace\QoS\QoS_vc9.vcproj", "{BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "bin\PerlACE\PerlACE_vc9.vcproj", "{F15379F8-FECA-1BAD-A757-FC47A624E189}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin\bin_vc9.vcproj", "{BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6300006755}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ace\ETCL\ACE_ETCL_Parser_vc9.vcproj", "{D756716B-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ace\ETCL\ACE_ETCL_vc9.vcproj", "{0903A9EA-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "ace\Monitor_Control\Monitor_Control_vc9.vcproj", "{A465937A-FECA-1BAD-D619-74620E01B14C}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} + {D756716B-FECA-1BAD-007E-8A67757B007A} = {D756716B-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "ace\QoS\QoS_vc9.vcproj", "{BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "bin\PerlACE\PerlACE_vc9.vcproj", "{F15379F8-FECA-1BAD-A757-FC47A624E189}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin\bin_vc9.vcproj", "{BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ACE_wrappers_vc10.sln b/dep/ACE_wrappers/ACE_wrappers_vc10.sln index 10c68317d..e962b0f2f 100644 --- a/dep/ACE_wrappers/ACE_wrappers_vc10.sln +++ b/dep/ACE_wrappers/ACE_wrappers_vc10.sln @@ -1,41 +1,41 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc10.vcxproj", "{47BC56ED-FECA-1BAD-6757-8A6300006755}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.ActiveCfg = Debug|Win32 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.Build.0 = Debug|Win32 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.ActiveCfg = Debug|x64 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.Build.0 = Debug|x64 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.ActiveCfg = Release|Win32 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.Build.0 = Release|Win32 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|x64.ActiveCfg = Release|x64 - {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc10.vcxproj", "{47BC56ED-FECA-1BAD-6757-8A6300006755}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.Build.0 = Debug|Win32 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.ActiveCfg = Debug|x64 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.Build.0 = Debug|x64 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.ActiveCfg = Release|Win32 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.Build.0 = Release|Win32 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|x64.ActiveCfg = Release|x64 + {348C50EF-FECA-1BAD-6244-8A036423F5D3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ACE_wrappers_vc8.sln b/dep/ACE_wrappers/ACE_wrappers_vc8.sln index 8114f7761..0f106553e 100644 --- a/dep/ACE_wrappers/ACE_wrappers_vc8.sln +++ b/dep/ACE_wrappers/ACE_wrappers_vc8.sln @@ -1,41 +1,41 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6300006755}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.ActiveCfg = Debug|Win32 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.Build.0 = Debug|Win32 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.ActiveCfg = Debug|x64 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.Build.0 = Debug|x64 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.ActiveCfg = Release|Win32 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.Build.0 = Release|Win32 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.ActiveCfg = Release|x64 - {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6300006755}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.Build.0 = Debug|Win32 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.ActiveCfg = Debug|x64 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.Build.0 = Debug|x64 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.ActiveCfg = Release|Win32 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.Build.0 = Release|Win32 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.ActiveCfg = Release|x64 + {AF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ACE_wrappers_vc9.sln b/dep/ACE_wrappers/ACE_wrappers_vc9.sln index 9b4f08592..34828a286 100644 --- a/dep/ACE_wrappers/ACE_wrappers_vc9.sln +++ b/dep/ACE_wrappers/ACE_wrappers_vc9.sln @@ -1,41 +1,41 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6300006755}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.ActiveCfg = Debug|Win32 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.Build.0 = Debug|Win32 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.ActiveCfg = Debug|x64 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.Build.0 = Debug|x64 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.ActiveCfg = Release|Win32 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.Build.0 = Release|Win32 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.ActiveCfg = Release|x64 - {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ace\ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6300006755}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|Win32.Build.0 = Debug|Win32 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.ActiveCfg = Debug|x64 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Debug|x64.Build.0 = Debug|x64 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.ActiveCfg = Release|Win32 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|Win32.Build.0 = Release|Win32 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.ActiveCfg = Release|x64 + {BF204C9C-FECA-1BAD-6244-8A036423F5D3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/ACE_vc10.vcxproj b/dep/ACE_wrappers/ace/ACE_vc10.vcxproj index 5aa629637..14b728e99 100644 --- a/dep/ACE_wrappers/ace/ACE_vc10.vcxproj +++ b/dep/ACE_wrappers/ace/ACE_vc10.vcxproj @@ -1,2455 +1,2455 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - ACE - {47BC56ED-FECA-1BAD-6757-8A6300006755} - ACE - Win32Proj - - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\lib\ - Debug\ACE_vc10\I386\ - true - ACEd - AllRules.ruleset - - - ..\lib\ - Release\ACE_vc10\I386\ - false - ACE - AllRules.ruleset - - - ..\lib\ - Debug\ACE_vc10\AMD64\ - true - ACEd - AllRules.ruleset - - - ..\lib\ - Release\ACE_vc10\AMD64\ - false - ACE - AllRules.ruleset - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..;%(AdditionalIncludeDirectories) - ACE_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - $(OutDir)ACEd.dll - .;..\lib;%(AdditionalLibraryDirectories) - ..\lib\ACEd.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..;%(AdditionalIncludeDirectories) - ACE_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - $(OutDir)ACE.dll - .;..\lib;%(AdditionalLibraryDirectories) - true - true - ..\lib\ACE.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..;%(AdditionalIncludeDirectories) - ACE_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - $(OutDir)ACEd.dll - .;..\lib;%(AdditionalLibraryDirectories) - ..\lib\ACEd.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..;%(AdditionalIncludeDirectories) - ACE_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - $(OutDir)ACE.dll - .;..\lib;%(AdditionalLibraryDirectories) - true - true - ..\lib\ACE.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - - - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - true - true - true - true - - - Document - true - true - true - true - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + ACE + {47BC56ED-FECA-1BAD-6757-8A6300006755} + ACE + Win32Proj + + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\lib\ + Debug\ACE_vc10\I386\ + true + ACEd + AllRules.ruleset + + + ..\lib\ + Release\ACE_vc10\I386\ + false + ACE + AllRules.ruleset + + + ..\lib\ + Debug\ACE_vc10\AMD64\ + true + ACEd + AllRules.ruleset + + + ..\lib\ + Release\ACE_vc10\AMD64\ + false + ACE + AllRules.ruleset + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..;%(AdditionalIncludeDirectories) + ACE_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + $(OutDir)ACEd.dll + .;..\lib;%(AdditionalLibraryDirectories) + ..\lib\ACEd.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..;%(AdditionalIncludeDirectories) + ACE_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + $(OutDir)ACE.dll + .;..\lib;%(AdditionalLibraryDirectories) + true + true + ..\lib\ACE.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..;%(AdditionalIncludeDirectories) + ACE_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + $(OutDir)ACEd.dll + .;..\lib;%(AdditionalLibraryDirectories) + ..\lib\ACEd.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..;%(AdditionalIncludeDirectories) + ACE_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + $(OutDir)ACE.dll + .;..\lib;%(AdditionalLibraryDirectories) + true + true + ..\lib\ACE.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + true + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Document + true + true + true + true + + + Document + true + true + true + true + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ACE_vc10.vcxproj.filters b/dep/ACE_wrappers/ace/ACE_vc10.vcxproj.filters index 6ae8d1c67..fa85e12c2 100644 --- a/dep/ACE_wrappers/ace/ACE_vc10.vcxproj.filters +++ b/dep/ACE_wrappers/ace/ACE_vc10.vcxproj.filters @@ -1,3944 +1,3944 @@ - - - - - {B1F27843-FECA-1BAD-6757-8A6300006755} - cpp;cxx;cc;c;C - - - {06319535-FECA-1BAD-6757-8A6300006755} - h;hpp;hxx;hh - - - {A1909F1C-FECA-1BAD-6757-8A6300006755} - mpc;mpb;mwc - - - {B0B7506A-FECA-1BAD-6757-8A6300006755} - - - {8441A3A3-FECA-1BAD-6757-8A6300006755} - pcin - - - {763028EF-FECA-1BAD-6757-8A6300006755} - i;ipp;inl - - - {5635C877-FECA-1BAD-6757-8A6300006755} - - - {B14BBA74-FECA-1BAD-6757-8A6300006755} - - - {502A2050-FECA-1BAD-6757-8A6300006755} - rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Build Files - - - Build Files - - - Build Files - - - Build Files - - - Build Files - - - Build Files - - - Build Files - - - Build Files - - - Build Files - - - Build Files - - - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - Installdata Files - - - - - Pkgconfig Files - - - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - Inline Files - - - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - Template Files - - - - - Documentation - - - Documentation - - - - - Resource Files - - - + + + + + {B1F27843-FECA-1BAD-6757-8A6300006755} + cpp;cxx;cc;c;C + + + {06319535-FECA-1BAD-6757-8A6300006755} + h;hpp;hxx;hh + + + {A1909F1C-FECA-1BAD-6757-8A6300006755} + mpc;mpb;mwc + + + {B0B7506A-FECA-1BAD-6757-8A6300006755} + + + {8441A3A3-FECA-1BAD-6757-8A6300006755} + pcin + + + {763028EF-FECA-1BAD-6757-8A6300006755} + i;ipp;inl + + + {5635C877-FECA-1BAD-6757-8A6300006755} + + + {B14BBA74-FECA-1BAD-6757-8A6300006755} + + + {502A2050-FECA-1BAD-6757-8A6300006755} + rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Build Files + + + Build Files + + + Build Files + + + Build Files + + + Build Files + + + Build Files + + + Build Files + + + Build Files + + + Build Files + + + Build Files + + + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + Installdata Files + + + + + Pkgconfig Files + + + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + Inline Files + + + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + Template Files + + + + + Documentation + + + Documentation + + + + + Resource Files + + + diff --git a/dep/ACE_wrappers/ace/ACE_vc9.vcproj b/dep/ACE_wrappers/ace/ACE_vc9.vcproj index d81104001..e563e20a8 100644 --- a/dep/ACE_wrappers/ace/ACE_vc9.vcproj +++ b/dep/ACE_wrappers/ace/ACE_vc9.vcproj @@ -1,6869 +1,6869 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj index 0202c3464..05947d96d 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj @@ -1,301 +1,301 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - ACE_ETCL_Parser - {42B1A787-FECA-1BAD-007E-8A67757B007A} - ACE_ETCL_Parser - Win32Proj - - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\lib\ - Debug\ACE_ETCL_Parser_vc10\I386\ - true - ACE_ETCL_Parserd - AllRules.ruleset - - - ..\..\lib\ - Release\ACE_ETCL_Parser_vc10\I386\ - false - ACE_ETCL_Parser - AllRules.ruleset - - - ..\..\lib\ - Debug\ACE_ETCL_Parser_vc10\AMD64\ - true - ACE_ETCL_Parserd - AllRules.ruleset - - - ..\..\lib\ - Release\ACE_ETCL_Parser_vc10\AMD64\ - false - ACE_ETCL_Parser - AllRules.ruleset - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - ETCL_PARSER_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;ACE_ETCLd.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCL_Parserd.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_ETCL_Parserd.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - ETCL_PARSER_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;ACE_ETCL.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCL_Parser.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_ETCL_Parser.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - ETCL_PARSER_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;ACE_ETCLd.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCL_Parserd.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_ETCL_Parserd.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - ETCL_PARSER_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;ACE_ETCL.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCL_Parser.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_ETCL_Parser.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - - - true - true - true - true - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + ACE_ETCL_Parser + {42B1A787-FECA-1BAD-007E-8A67757B007A} + ACE_ETCL_Parser + Win32Proj + + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\lib\ + Debug\ACE_ETCL_Parser_vc10\I386\ + true + ACE_ETCL_Parserd + AllRules.ruleset + + + ..\..\lib\ + Release\ACE_ETCL_Parser_vc10\I386\ + false + ACE_ETCL_Parser + AllRules.ruleset + + + ..\..\lib\ + Debug\ACE_ETCL_Parser_vc10\AMD64\ + true + ACE_ETCL_Parserd + AllRules.ruleset + + + ..\..\lib\ + Release\ACE_ETCL_Parser_vc10\AMD64\ + false + ACE_ETCL_Parser + AllRules.ruleset + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + ETCL_PARSER_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;ACE_ETCLd.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCL_Parserd.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_ETCL_Parserd.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + ETCL_PARSER_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;ACE_ETCL.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCL_Parser.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_ETCL_Parser.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + ETCL_PARSER_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;ACE_ETCLd.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCL_Parserd.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_ETCL_Parserd.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + ETCL_PARSER_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;ACE_ETCL.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCL_Parser.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_ETCL_Parser.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + + + true + true + true + true + + + + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj.filters b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj.filters index 84f32bc87..b57554692 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj.filters +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc10.vcxproj.filters @@ -1,53 +1,53 @@ - - - - - {B1F27843-FECA-1BAD-007E-8A67757B007A} - cpp;cxx;cc;c;C - - - {06319535-FECA-1BAD-007E-8A67757B007A} - h;hpp;hxx;hh - - - {A1909F1C-FECA-1BAD-007E-8A67757B007A} - mpc;mpb;mwc - - - {8441A3A3-FECA-1BAD-007E-8A67757B007A} - pcin - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Build Files - - - - - Pkgconfig Files - - - + + + + + {B1F27843-FECA-1BAD-007E-8A67757B007A} + cpp;cxx;cc;c;C + + + {06319535-FECA-1BAD-007E-8A67757B007A} + h;hpp;hxx;hh + + + {A1909F1C-FECA-1BAD-007E-8A67757B007A} + mpc;mpb;mwc + + + {8441A3A3-FECA-1BAD-007E-8A67757B007A} + pcin + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + Build Files + + + + + Pkgconfig Files + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc8.vcproj b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc8.vcproj index d7b39c6b7..91690144b 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc8.vcproj +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc8.vcproj @@ -1,441 +1,441 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc9.vcproj b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc9.vcproj index 8b1b32a28..14ce1b72c 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc9.vcproj +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_Parser_vc9.vcproj @@ -1,441 +1,441 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj index 0955341e6..5130a6063 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj @@ -1,302 +1,302 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - ACE_ETCL - {17692659-FECA-1BAD-007E-8A67757B007A} - ACE_ETCL - Win32Proj - - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\lib\ - Debug\ACE_ETCL_vc10\I386\ - true - ACE_ETCLd - AllRules.ruleset - - - ..\..\lib\ - Release\ACE_ETCL_vc10\I386\ - false - ACE_ETCL - AllRules.ruleset - - - ..\..\lib\ - Debug\ACE_ETCL_vc10\AMD64\ - true - ACE_ETCLd - AllRules.ruleset - - - ..\..\lib\ - Release\ACE_ETCL_vc10\AMD64\ - false - ACE_ETCL - AllRules.ruleset - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - ACE_ETCL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCLd.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_ETCLd.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - ACE_ETCL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCL.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_ETCL.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - ACE_ETCL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCLd.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_ETCLd.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - ACE_ETCL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;%(AdditionalDependencies) - $(OutDir)ACE_ETCL.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_ETCL.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - - - true - true - true - true - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + ACE_ETCL + {17692659-FECA-1BAD-007E-8A67757B007A} + ACE_ETCL + Win32Proj + + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\lib\ + Debug\ACE_ETCL_vc10\I386\ + true + ACE_ETCLd + AllRules.ruleset + + + ..\..\lib\ + Release\ACE_ETCL_vc10\I386\ + false + ACE_ETCL + AllRules.ruleset + + + ..\..\lib\ + Debug\ACE_ETCL_vc10\AMD64\ + true + ACE_ETCLd + AllRules.ruleset + + + ..\..\lib\ + Release\ACE_ETCL_vc10\AMD64\ + false + ACE_ETCL + AllRules.ruleset + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + ACE_ETCL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCLd.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_ETCLd.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + ACE_ETCL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCL.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_ETCL.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + ACE_ETCL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCLd.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_ETCLd.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + ACE_ETCL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;%(AdditionalDependencies) + $(OutDir)ACE_ETCL.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_ETCL.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + + + true + true + true + true + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj.filters b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj.filters index fc8071525..556b24677 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj.filters +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc10.vcxproj.filters @@ -1,59 +1,59 @@ - - - - - {B1F27843-FECA-1BAD-007E-8A67757B007A} - cpp;cxx;cc;c;C - - - {06319535-FECA-1BAD-007E-8A67757B007A} - h;hpp;hxx;hh - - - {A1909F1C-FECA-1BAD-007E-8A67757B007A} - mpc;mpb;mwc - - - {8441A3A3-FECA-1BAD-007E-8A67757B007A} - pcin - - - {763028EF-FECA-1BAD-007E-8A67757B007A} - i;ipp;inl - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Build Files - - - - - Pkgconfig Files - - - - - Inline Files - - - + + + + + {B1F27843-FECA-1BAD-007E-8A67757B007A} + cpp;cxx;cc;c;C + + + {06319535-FECA-1BAD-007E-8A67757B007A} + h;hpp;hxx;hh + + + {A1909F1C-FECA-1BAD-007E-8A67757B007A} + mpc;mpb;mwc + + + {8441A3A3-FECA-1BAD-007E-8A67757B007A} + pcin + + + {763028EF-FECA-1BAD-007E-8A67757B007A} + i;ipp;inl + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + Build Files + + + + + Pkgconfig Files + + + + + Inline Files + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc8.vcproj b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc8.vcproj index d01e4a17b..02b9f3157 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc8.vcproj +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc8.vcproj @@ -1,445 +1,445 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc9.vcproj b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc9.vcproj index 3c3883c44..83522bc36 100644 --- a/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc9.vcproj +++ b/dep/ACE_wrappers/ace/ETCL/ACE_ETCL_vc9.vcproj @@ -1,445 +1,445 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ETCL/ETCL_vc10.sln b/dep/ACE_wrappers/ace/ETCL/ETCL_vc10.sln index 1fde2cdb4..db153b910 100644 --- a/dep/ACE_wrappers/ace/ETCL/ETCL_vc10.sln +++ b/dep/ACE_wrappers/ace/ETCL/ETCL_vc10.sln @@ -1,46 +1,46 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ACE_ETCL_Parser_vc10.vcxproj", "{42B1A787-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ACE_ETCL_vc10.vcxproj", "{17692659-FECA-1BAD-007E-8A67757B007A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ACE_ETCL_Parser_vc10.vcxproj", "{42B1A787-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ACE_ETCL_vc10.vcxproj", "{17692659-FECA-1BAD-007E-8A67757B007A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/ETCL/ETCL_vc8.sln b/dep/ACE_wrappers/ace/ETCL/ETCL_vc8.sln index 97ed802b1..51ec7804b 100644 --- a/dep/ACE_wrappers/ace/ETCL/ETCL_vc8.sln +++ b/dep/ACE_wrappers/ace/ETCL/ETCL_vc8.sln @@ -1,46 +1,46 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ACE_ETCL_Parser_vc8.vcproj", "{C756716B-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ACE_ETCL_vc8.vcproj", "{1903A9EA-FECA-1BAD-007E-8A67757B007A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ACE_ETCL_Parser_vc8.vcproj", "{C756716B-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ACE_ETCL_vc8.vcproj", "{1903A9EA-FECA-1BAD-007E-8A67757B007A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/ETCL/ETCL_vc9.sln b/dep/ACE_wrappers/ace/ETCL/ETCL_vc9.sln index a46f24ca6..9b375a726 100644 --- a/dep/ACE_wrappers/ace/ETCL/ETCL_vc9.sln +++ b/dep/ACE_wrappers/ace/ETCL/ETCL_vc9.sln @@ -1,46 +1,46 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ACE_ETCL_Parser_vc9.vcproj", "{D756716B-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ACE_ETCL_vc9.vcproj", "{0903A9EA-FECA-1BAD-007E-8A67757B007A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ACE_ETCL_Parser_vc9.vcproj", "{D756716B-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ACE_ETCL_vc9.vcproj", "{0903A9EA-FECA-1BAD-007E-8A67757B007A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.sln b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.sln index b292a2866..70469a1df 100644 --- a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.sln +++ b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control_vc10.vcxproj", "{7153B6F4-FECA-1BAD-D619-74620E01B14C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control_vc10.vcxproj", "{7153B6F4-FECA-1BAD-D619-74620E01B14C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj index efd7f654e..c986c6e1f 100644 --- a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj +++ b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj @@ -1,344 +1,344 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - Monitor_Control - {7153B6F4-FECA-1BAD-D619-74620E01B14C} - Monitor_Control - Win32Proj - - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\lib\ - Debug\Monitor_Control_vc10\I386\ - true - ACE_Monitor_Controld - AllRules.ruleset - - - ..\..\lib\ - Release\Monitor_Control_vc10\I386\ - false - ACE_Monitor_Control - AllRules.ruleset - - - ..\..\lib\ - Debug\Monitor_Control_vc10\AMD64\ - true - ACE_Monitor_Controld - AllRules.ruleset - - - ..\..\lib\ - Release\Monitor_Control_vc10\AMD64\ - false - ACE_Monitor_Control - AllRules.ruleset - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - MONITOR_CONTROL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;ACE_ETCLd.lib;ACE_ETCL_Parserd.lib;pdh.lib;%(AdditionalDependencies) - $(OutDir)ACE_Monitor_Controld.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_Monitor_Controld.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - MONITOR_CONTROL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;ACE_ETCL.lib;ACE_ETCL_Parser.lib;pdh.lib;%(AdditionalDependencies) - $(OutDir)ACE_Monitor_Control.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_Monitor_Control.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - MONITOR_CONTROL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;ACE_ETCLd.lib;ACE_ETCL_Parserd.lib;pdh.lib;%(AdditionalDependencies) - $(OutDir)ACE_Monitor_Controld.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_Monitor_Controld.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - MONITOR_CONTROL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;ACE_ETCL.lib;ACE_ETCL_Parser.lib;pdh.lib;%(AdditionalDependencies) - $(OutDir)ACE_Monitor_Control.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_Monitor_Control.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + Monitor_Control + {7153B6F4-FECA-1BAD-D619-74620E01B14C} + Monitor_Control + Win32Proj + + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\lib\ + Debug\Monitor_Control_vc10\I386\ + true + ACE_Monitor_Controld + AllRules.ruleset + + + ..\..\lib\ + Release\Monitor_Control_vc10\I386\ + false + ACE_Monitor_Control + AllRules.ruleset + + + ..\..\lib\ + Debug\Monitor_Control_vc10\AMD64\ + true + ACE_Monitor_Controld + AllRules.ruleset + + + ..\..\lib\ + Release\Monitor_Control_vc10\AMD64\ + false + ACE_Monitor_Control + AllRules.ruleset + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + MONITOR_CONTROL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;ACE_ETCLd.lib;ACE_ETCL_Parserd.lib;pdh.lib;%(AdditionalDependencies) + $(OutDir)ACE_Monitor_Controld.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_Monitor_Controld.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + MONITOR_CONTROL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;ACE_ETCL.lib;ACE_ETCL_Parser.lib;pdh.lib;%(AdditionalDependencies) + $(OutDir)ACE_Monitor_Control.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_Monitor_Control.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + MONITOR_CONTROL_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;ACE_ETCLd.lib;ACE_ETCL_Parserd.lib;pdh.lib;%(AdditionalDependencies) + $(OutDir)ACE_Monitor_Controld.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_Monitor_Controld.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + MONITOR_CONTROL_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;ACE_ETCL.lib;ACE_ETCL_Parser.lib;pdh.lib;%(AdditionalDependencies) + $(OutDir)ACE_Monitor_Control.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_Monitor_Control.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + + + + diff --git a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj.filters b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj.filters index fce01e762..8bdc921d4 100644 --- a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj.filters +++ b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc10.vcxproj.filters @@ -1,149 +1,149 @@ - - - - - {B1F27843-FECA-1BAD-D619-74620E01B14C} - cpp;cxx;cc;c;C - - - {06319535-FECA-1BAD-D619-74620E01B14C} - h;hpp;hxx;hh - - - {A1909F1C-FECA-1BAD-D619-74620E01B14C} - mpc;mpb;mwc - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Build Files - - - + + + + + {B1F27843-FECA-1BAD-D619-74620E01B14C} + cpp;cxx;cc;c;C + + + {06319535-FECA-1BAD-D619-74620E01B14C} + h;hpp;hxx;hh + + + {A1909F1C-FECA-1BAD-D619-74620E01B14C} + mpc;mpb;mwc + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Build Files + + + diff --git a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.sln b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.sln index 2717d6b06..3019e0448 100644 --- a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.sln +++ b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control_vc8.vcproj", "{B465937A-FECA-1BAD-D619-74620E01B14C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control_vc8.vcproj", "{B465937A-FECA-1BAD-D619-74620E01B14C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.vcproj b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.vcproj index 6e0c1bc66..846e99d46 100644 --- a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.vcproj +++ b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc8.vcproj @@ -1,519 +1,519 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.sln b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.sln index 7f440e015..c4cdc7c9a 100644 --- a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.sln +++ b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control_vc9.vcproj", "{A465937A-FECA-1BAD-D619-74620E01B14C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control_vc9.vcproj", "{A465937A-FECA-1BAD-D619-74620E01B14C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.vcproj b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.vcproj index 97b97e00f..e5dffdf56 100644 --- a/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.vcproj +++ b/dep/ACE_wrappers/ace/Monitor_Control/Monitor_Control_vc9.vcproj @@ -1,519 +1,519 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/QoS/QoS_vc10.sln b/dep/ACE_wrappers/ace/QoS/QoS_vc10.sln index 6f04edfb7..b86d73531 100644 --- a/dep/ACE_wrappers/ace/QoS/QoS_vc10.sln +++ b/dep/ACE_wrappers/ace/QoS/QoS_vc10.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS_vc10.vcxproj", "{6ADC56EC-FECA-1BAD-7781-8A636757A7A3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS_vc10.vcxproj", "{6ADC56EC-FECA-1BAD-7781-8A636757A7A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj b/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj index 6b897677c..305c9c2c4 100644 --- a/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj +++ b/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj @@ -1,322 +1,322 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - QoS - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3} - QoS - Win32Proj - - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - DynamicLibrary - true - NotSet - - - DynamicLibrary - false - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\lib\ - Debug\QoS_vc10\I386\ - true - ACE_QoSd - AllRules.ruleset - - - ..\..\lib\ - Release\QoS_vc10\I386\ - false - ACE_QoS - AllRules.ruleset - - - ..\..\lib\ - Debug\QoS_vc10\AMD64\ - true - ACE_QoSd - AllRules.ruleset - - - ..\..\lib\ - Release\QoS_vc10\AMD64\ - false - ACE_QoS - AllRules.ruleset - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - ACE_QoS_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;%(AdditionalDependencies) - $(OutDir)ACE_QoSd.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_QoSd.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - ACE_QoS_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;%(AdditionalDependencies) - $(OutDir)ACE_QoS.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_QoS.lib - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..\..;%(AdditionalIncludeDirectories) - ACE_QoS_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACEd.lib;%(AdditionalDependencies) - $(OutDir)ACE_QoSd.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - ..\..\lib\ACE_QoSd.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..\..;%(AdditionalIncludeDirectories) - ACE_QoS_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;_WIN64;%(PreprocessorDefinitions) - 1033 - ..\..;%(AdditionalIncludeDirectories) - - - true - ACE.lib;%(AdditionalDependencies) - $(OutDir)ACE_QoS.dll - .;..\..\lib;%(AdditionalLibraryDirectories) - true - true - ..\..\lib\ACE_QoS.lib - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - - - true - true - true - true - - - - - - - - - Document - true - true - true - true - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + QoS + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3} + QoS + Win32Proj + + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + DynamicLibrary + true + NotSet + + + DynamicLibrary + false + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\lib\ + Debug\QoS_vc10\I386\ + true + ACE_QoSd + AllRules.ruleset + + + ..\..\lib\ + Release\QoS_vc10\I386\ + false + ACE_QoS + AllRules.ruleset + + + ..\..\lib\ + Debug\QoS_vc10\AMD64\ + true + ACE_QoSd + AllRules.ruleset + + + ..\..\lib\ + Release\QoS_vc10\AMD64\ + false + ACE_QoS + AllRules.ruleset + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + ACE_QoS_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;%(AdditionalDependencies) + $(OutDir)ACE_QoSd.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_QoSd.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + ACE_QoS_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;%(AdditionalDependencies) + $(OutDir)ACE_QoS.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_QoS.lib + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..\..;%(AdditionalIncludeDirectories) + ACE_QoS_BUILD_DLL;_DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACEd.lib;%(AdditionalDependencies) + $(OutDir)ACE_QoSd.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + ..\..\lib\ACE_QoSd.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..\..;%(AdditionalIncludeDirectories) + ACE_QoS_BUILD_DLL;NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ACE_HAS_QOS;ACE_HAS_WINSOCK2_GQOS;_WIN64;%(PreprocessorDefinitions) + 1033 + ..\..;%(AdditionalIncludeDirectories) + + + true + ACE.lib;%(AdditionalDependencies) + $(OutDir)ACE_QoS.dll + .;..\..\lib;%(AdditionalLibraryDirectories) + true + true + ..\..\lib\ACE_QoS.lib + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + + + true + true + true + true + + + + + + + + + Document + true + true + true + true + + + + + + diff --git a/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj.filters b/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj.filters index 19cc34fe1..c1c59aa3b 100644 --- a/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj.filters +++ b/dep/ACE_wrappers/ace/QoS/QoS_vc10.vcxproj.filters @@ -1,91 +1,91 @@ - - - - - {B1F27843-FECA-1BAD-7781-8A636757A7A3} - cpp;cxx;cc;c;C - - - {06319535-FECA-1BAD-7781-8A636757A7A3} - h;hpp;hxx;hh - - - {A1909F1C-FECA-1BAD-7781-8A636757A7A3} - mpc;mpb;mwc - - - {8441A3A3-FECA-1BAD-7781-8A636757A7A3} - pcin - - - {763028EF-FECA-1BAD-7781-8A636757A7A3} - i;ipp;inl - - - {B14BBA74-FECA-1BAD-7781-8A636757A7A3} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Build Files - - - - - Pkgconfig Files - - - - - Inline Files - - - Inline Files - - - - - Documentation - - - + + + + + {B1F27843-FECA-1BAD-7781-8A636757A7A3} + cpp;cxx;cc;c;C + + + {06319535-FECA-1BAD-7781-8A636757A7A3} + h;hpp;hxx;hh + + + {A1909F1C-FECA-1BAD-7781-8A636757A7A3} + mpc;mpb;mwc + + + {8441A3A3-FECA-1BAD-7781-8A636757A7A3} + pcin + + + {763028EF-FECA-1BAD-7781-8A636757A7A3} + i;ipp;inl + + + {B14BBA74-FECA-1BAD-7781-8A636757A7A3} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Build Files + + + + + Pkgconfig Files + + + + + Inline Files + + + Inline Files + + + + + Documentation + + + diff --git a/dep/ACE_wrappers/ace/QoS/QoS_vc8.sln b/dep/ACE_wrappers/ace/QoS/QoS_vc8.sln index 17be0c113..0371161ba 100644 --- a/dep/ACE_wrappers/ace/QoS/QoS_vc8.sln +++ b/dep/ACE_wrappers/ace/QoS/QoS_vc8.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS_vc8.vcproj", "{AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS_vc8.vcproj", "{AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/QoS/QoS_vc8.vcproj b/dep/ACE_wrappers/ace/QoS/QoS_vc8.vcproj index 7a7bf0637..83f1ee4d9 100644 --- a/dep/ACE_wrappers/ace/QoS/QoS_vc8.vcproj +++ b/dep/ACE_wrappers/ace/QoS/QoS_vc8.vcproj @@ -1,500 +1,500 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/QoS/QoS_vc9.sln b/dep/ACE_wrappers/ace/QoS/QoS_vc9.sln index 0c2470faa..a88abfef8 100644 --- a/dep/ACE_wrappers/ace/QoS/QoS_vc9.sln +++ b/dep/ACE_wrappers/ace/QoS/QoS_vc9.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS_vc9.vcproj", "{BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS_vc9.vcproj", "{BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/QoS/QoS_vc9.vcproj b/dep/ACE_wrappers/ace/QoS/QoS_vc9.vcproj index 8cb2291c8..7d354a109 100644 --- a/dep/ACE_wrappers/ace/QoS/QoS_vc9.vcproj +++ b/dep/ACE_wrappers/ace/QoS/QoS_vc9.vcproj @@ -1,500 +1,500 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ace_vc10.sln b/dep/ACE_wrappers/ace/ace_vc10.sln index 1c64a6d55..d127b48d3 100644 --- a/dep/ACE_wrappers/ace/ace_vc10.sln +++ b/dep/ACE_wrappers/ace/ace_vc10.sln @@ -1,88 +1,88 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ACE_vc10.vcxproj", "{47BC56ED-FECA-1BAD-6757-8A6300006755}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ETCL\ACE_ETCL_Parser_vc10.vcxproj", "{42B1A787-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ETCL\ACE_ETCL_vc10.vcxproj", "{17692659-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control\Monitor_Control_vc10.vcxproj", "{7153B6F4-FECA-1BAD-D619-74620E01B14C}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} - {42B1A787-FECA-1BAD-007E-8A67757B007A} = {42B1A787-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS\QoS_vc10.vcxproj", "{6ADC56EC-FECA-1BAD-7781-8A636757A7A3}" - ProjectSection(ProjectDependencies) = postProject - {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ACE_vc10.vcxproj", "{47BC56ED-FECA-1BAD-6757-8A6300006755}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ETCL\ACE_ETCL_Parser_vc10.vcxproj", "{42B1A787-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ETCL\ACE_ETCL_vc10.vcxproj", "{17692659-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control\Monitor_Control_vc10.vcxproj", "{7153B6F4-FECA-1BAD-D619-74620E01B14C}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + {17692659-FECA-1BAD-007E-8A67757B007A} = {17692659-FECA-1BAD-007E-8A67757B007A} + {42B1A787-FECA-1BAD-007E-8A67757B007A} = {42B1A787-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS\QoS_vc10.vcxproj", "{6ADC56EC-FECA-1BAD-7781-8A636757A7A3}" + ProjectSection(ProjectDependencies) = postProject + {47BC56ED-FECA-1BAD-6757-8A6300006755} = {47BC56ED-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {47BC56ED-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {42B1A787-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {17692659-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {7153B6F4-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {6ADC56EC-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/ace_vc8.sln b/dep/ACE_wrappers/ace/ace_vc8.sln index 73be7a484..43bd2beae 100644 --- a/dep/ACE_wrappers/ace/ace_vc8.sln +++ b/dep/ACE_wrappers/ace/ace_vc8.sln @@ -1,88 +1,88 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6300006755}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ETCL\ACE_ETCL_Parser_vc8.vcproj", "{C756716B-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ETCL\ACE_ETCL_vc8.vcproj", "{1903A9EA-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control\Monitor_Control_vc8.vcproj", "{B465937A-FECA-1BAD-D619-74620E01B14C}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} - {C756716B-FECA-1BAD-007E-8A67757B007A} = {C756716B-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS\QoS_vc8.vcproj", "{AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" - ProjectSection(ProjectDependencies) = postProject - {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6300006755}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ETCL\ACE_ETCL_Parser_vc8.vcproj", "{C756716B-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ETCL\ACE_ETCL_vc8.vcproj", "{1903A9EA-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control\Monitor_Control_vc8.vcproj", "{B465937A-FECA-1BAD-D619-74620E01B14C}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + {1903A9EA-FECA-1BAD-007E-8A67757B007A} = {1903A9EA-FECA-1BAD-007E-8A67757B007A} + {C756716B-FECA-1BAD-007E-8A67757B007A} = {C756716B-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS\QoS_vc8.vcproj", "{AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" + ProjectSection(ProjectDependencies) = postProject + {AD537C9A-FECA-1BAD-6757-8A6300006755} = {AD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {AD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {C756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {1903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {B465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {AC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/ace/ace_vc9.sln b/dep/ACE_wrappers/ace/ace_vc9.sln index d40a609e0..42b292236 100644 --- a/dep/ACE_wrappers/ace/ace_vc9.sln +++ b/dep/ACE_wrappers/ace/ace_vc9.sln @@ -1,88 +1,88 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6300006755}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ETCL\ACE_ETCL_Parser_vc9.vcproj", "{D756716B-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ETCL\ACE_ETCL_vc9.vcproj", "{0903A9EA-FECA-1BAD-007E-8A67757B007A}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control\Monitor_Control_vc9.vcproj", "{A465937A-FECA-1BAD-D619-74620E01B14C}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} - {D756716B-FECA-1BAD-007E-8A67757B007A} = {D756716B-FECA-1BAD-007E-8A67757B007A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS\QoS_vc9.vcproj", "{BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" - ProjectSection(ProjectDependencies) = postProject - {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 - {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 - {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 - {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 - {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE", "ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6300006755}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL_Parser", "ETCL\ACE_ETCL_Parser_vc9.vcproj", "{D756716B-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_ETCL", "ETCL\ACE_ETCL_vc9.vcproj", "{0903A9EA-FECA-1BAD-007E-8A67757B007A}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Monitor_Control", "Monitor_Control\Monitor_Control_vc9.vcproj", "{A465937A-FECA-1BAD-D619-74620E01B14C}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + {0903A9EA-FECA-1BAD-007E-8A67757B007A} = {0903A9EA-FECA-1BAD-007E-8A67757B007A} + {D756716B-FECA-1BAD-007E-8A67757B007A} = {D756716B-FECA-1BAD-007E-8A67757B007A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoS", "QoS\QoS_vc9.vcproj", "{BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}" + ProjectSection(ProjectDependencies) = postProject + {BD537C9A-FECA-1BAD-6757-8A6300006755} = {BD537C9A-FECA-1BAD-6757-8A6300006755} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.ActiveCfg = Debug|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|Win32.Build.0 = Debug|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.ActiveCfg = Debug|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Debug|x64.Build.0 = Debug|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.ActiveCfg = Release|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|Win32.Build.0 = Release|Win32 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.ActiveCfg = Release|x64 + {BD537C9A-FECA-1BAD-6757-8A6300006755}.Release|x64.Build.0 = Release|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {D756716B-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.ActiveCfg = Debug|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|Win32.Build.0 = Debug|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.ActiveCfg = Debug|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Debug|x64.Build.0 = Debug|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.ActiveCfg = Release|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|Win32.Build.0 = Release|Win32 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.ActiveCfg = Release|x64 + {0903A9EA-FECA-1BAD-007E-8A67757B007A}.Release|x64.Build.0 = Release|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.ActiveCfg = Debug|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|Win32.Build.0 = Debug|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.ActiveCfg = Debug|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Debug|x64.Build.0 = Debug|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.ActiveCfg = Release|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|Win32.Build.0 = Release|Win32 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.ActiveCfg = Release|x64 + {A465937A-FECA-1BAD-D619-74620E01B14C}.Release|x64.Build.0 = Release|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|Win32.Build.0 = Debug|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.ActiveCfg = Debug|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Debug|x64.Build.0 = Debug|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.ActiveCfg = Release|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|Win32.Build.0 = Release|Win32 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.ActiveCfg = Release|x64 + {BC7E1C9A-FECA-1BAD-7781-8A636757A7A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.sln b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.sln index d89b26da4..223094cef 100644 --- a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.sln +++ b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE_vc10.vcxproj", "{47B934A1-FECA-1BAD-A757-FC47A624E189}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE_vc10.vcxproj", "{47B934A1-FECA-1BAD-A757-FC47A624E189}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj index ec0e51e41..6a25cf2b5 100644 --- a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj +++ b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj @@ -1,290 +1,290 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - PerlACE - {47B934A1-FECA-1BAD-A757-FC47A624E189} - PerlACE - Win32Proj - - - - Utility - true - NotSet - - - Utility - false - NotSet - true - - - Utility - true - NotSet - - - Utility - false - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\ - Debug\PerlACE_vc10\I386\ - true - - AllRules.ruleset - - - Release\ - Release\PerlACE_vc10\I386\ - false - - AllRules.ruleset - - - .\ - Debug\PerlACE_vc10\AMD64\ - true - - AllRules.ruleset - - - Release\ - Release\PerlACE_vc10\AMD64\ - false - - AllRules.ruleset - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - _DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - - - _DEBUG;%(PreprocessorDefinitions) - 1033 - %(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - .;%(AdditionalLibraryDirectories) - /noentry %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - - - NDEBUG;%(PreprocessorDefinitions) - 1033 - %(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - .;%(AdditionalLibraryDirectories) - true - true - /noentry %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - _DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - - - _DEBUG;_WIN64;%(PreprocessorDefinitions) - 1033 - %(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - .;%(AdditionalLibraryDirectories) - - - /noentry /machine:AMD64 %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - - - NDEBUG;_WIN64;%(PreprocessorDefinitions) - 1033 - %(AdditionalIncludeDirectories) - - - true - %(AdditionalDependencies) - .;%(AdditionalLibraryDirectories) - true - true - - - /noentry /machine:AMD64 %(AdditionalOptions) - - - - - - - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + PerlACE + {47B934A1-FECA-1BAD-A757-FC47A624E189} + PerlACE + Win32Proj + + + + Utility + true + NotSet + + + Utility + false + NotSet + true + + + Utility + true + NotSet + + + Utility + false + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + .\ + Debug\PerlACE_vc10\I386\ + true + + AllRules.ruleset + + + Release\ + Release\PerlACE_vc10\I386\ + false + + AllRules.ruleset + + + .\ + Debug\PerlACE_vc10\AMD64\ + true + + AllRules.ruleset + + + Release\ + Release\PerlACE_vc10\AMD64\ + false + + AllRules.ruleset + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + _DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + + + _DEBUG;%(PreprocessorDefinitions) + 1033 + %(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + .;%(AdditionalLibraryDirectories) + /noentry %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 1033 + %(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + .;%(AdditionalLibraryDirectories) + true + true + /noentry %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + _DEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + + + _DEBUG;_WIN64;%(PreprocessorDefinitions) + 1033 + %(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + .;%(AdditionalLibraryDirectories) + + + /noentry /machine:AMD64 %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + NDEBUG;WIN32;_WINDOWS;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + + + NDEBUG;_WIN64;%(PreprocessorDefinitions) + 1033 + %(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + .;%(AdditionalLibraryDirectories) + true + true + + + /noentry /machine:AMD64 %(AdditionalOptions) + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + + diff --git a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj.filters b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj.filters index 3efae1616..8265ba23d 100644 --- a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj.filters +++ b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc10.vcxproj.filters @@ -1,26 +1,26 @@ - - - - - {7197AE6D-FECA-1BAD-A757-FC47A624E189} - sh - - - - - Script Files - - - Script Files - - - Script Files - - - Script Files - - - Script Files - - - + + + + + {7197AE6D-FECA-1BAD-A757-FC47A624E189} + sh + + + + + Script Files + + + Script Files + + + Script Files + + + Script Files + + + Script Files + + + diff --git a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.sln b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.sln index 2c5cd5db7..567cc426e 100644 --- a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.sln +++ b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE_vc8.vcproj", "{E15379F8-FECA-1BAD-A757-FC47A624E189}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE_vc8.vcproj", "{E15379F8-FECA-1BAD-A757-FC47A624E189}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.vcproj b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.vcproj index e4c600b4e..6f485033a 100644 --- a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.vcproj +++ b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc8.vcproj @@ -1,220 +1,220 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.sln b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.sln index 9ca462ee5..932e766b5 100644 --- a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.sln +++ b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.sln @@ -1,33 +1,33 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE_vc9.vcproj", "{F15379F8-FECA-1BAD-A757-FC47A624E189}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE_vc9.vcproj", "{F15379F8-FECA-1BAD-A757-FC47A624E189}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.vcproj b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.vcproj index a7c485660..a6bb1cc39 100644 --- a/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.vcproj +++ b/dep/ACE_wrappers/bin/PerlACE/PerlACE_vc9.vcproj @@ -1,220 +1,220 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/bin/bin_vc10.sln b/dep/ACE_wrappers/bin/bin_vc10.sln index 214bbe0ea..a6d88593b 100644 --- a/dep/ACE_wrappers/bin/bin_vc10.sln +++ b/dep/ACE_wrappers/bin/bin_vc10.sln @@ -1,43 +1,43 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE\PerlACE_vc10.vcxproj", "{47B934A1-FECA-1BAD-A757-FC47A624E189}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin_vc10.vcxproj", "{5F0C56EF-FECA-1BAD-64FC-8A63000064FE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# $Id: VC10WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc10 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc10" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE\PerlACE_vc10.vcxproj", "{47B934A1-FECA-1BAD-A757-FC47A624E189}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin_vc10.vcxproj", "{5F0C56EF-FECA-1BAD-64FC-8A63000064FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {47B934A1-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/bin/bin_vc10.vcxproj b/dep/ACE_wrappers/bin/bin_vc10.vcxproj index e92289426..d6fb87318 100644 --- a/dep/ACE_wrappers/bin/bin_vc10.vcxproj +++ b/dep/ACE_wrappers/bin/bin_vc10.vcxproj @@ -1,298 +1,298 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - bin - {5F0C56EF-FECA-1BAD-64FC-8A63000064FE} - bin - Win32Proj - - - - Application - true - NotSet - - - Application - false - NotSet - true - - - Application - true - NotSet - - - Application - false - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\ - Debug\bin_vc10\I386\ - true - envinfo - AllRules.ruleset - - - Release\ - Release\bin_vc10\I386\ - false - envinfo - AllRules.ruleset - - - .\ - Debug\bin_vc10\AMD64\ - true - envinfo - AllRules.ruleset - - - Release\ - Release\bin_vc10\AMD64\ - false - envinfo - AllRules.ruleset - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..;%(AdditionalIncludeDirectories) - _DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - Console - true - ACEd.lib;%(AdditionalDependencies) - $(OutDir)envinfo.exe - .;..\lib;%(AdditionalLibraryDirectories) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - Win32 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..;%(AdditionalIncludeDirectories) - NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - Console - true - ACE.lib;%(AdditionalDependencies) - $(OutDir)envinfo.exe - .;..\lib;%(AdditionalLibraryDirectories) - true - true - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - Disabled - ..;%(AdditionalIncludeDirectories) - _DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - Console - true - ACEd.lib;%(AdditionalDependencies) - $(OutDir)envinfo.exe - .;..\lib;%(AdditionalLibraryDirectories) - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - x64 - %(Filename).tlb - %(Filename).h - %(Filename)_i.c - %(Filename)_p.c - - - MaxSpeed - true - ..;%(AdditionalIncludeDirectories) - NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Level3 - 4355;%(DisableSpecificWarnings) - - - NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) - 1033 - ..;%(AdditionalIncludeDirectories) - - - Console - true - ACE.lib;%(AdditionalDependencies) - $(OutDir)envinfo.exe - .;..\lib;%(AdditionalLibraryDirectories) - true - true - - - /machine:AMD64 %(AdditionalOptions) - - - - - - - - - - - - - true - true - true - true - - - - - true - true - true - true - - - true - true - true - true - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + bin + {5F0C56EF-FECA-1BAD-64FC-8A63000064FE} + bin + Win32Proj + + + + Application + true + NotSet + + + Application + false + NotSet + true + + + Application + true + NotSet + + + Application + false + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + .\ + Debug\bin_vc10\I386\ + true + envinfo + AllRules.ruleset + + + Release\ + Release\bin_vc10\I386\ + false + envinfo + AllRules.ruleset + + + .\ + Debug\bin_vc10\AMD64\ + true + envinfo + AllRules.ruleset + + + Release\ + Release\bin_vc10\AMD64\ + false + envinfo + AllRules.ruleset + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..;%(AdditionalIncludeDirectories) + _DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + Console + true + ACEd.lib;%(AdditionalDependencies) + $(OutDir)envinfo.exe + .;..\lib;%(AdditionalLibraryDirectories) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + Win32 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..;%(AdditionalIncludeDirectories) + NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + Console + true + ACE.lib;%(AdditionalDependencies) + $(OutDir)envinfo.exe + .;..\lib;%(AdditionalLibraryDirectories) + true + true + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + Disabled + ..;%(AdditionalIncludeDirectories) + _DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MPC_LIB_MODIFIER="d";%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + _DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + Console + true + ACEd.lib;%(AdditionalDependencies) + $(OutDir)envinfo.exe + .;..\lib;%(AdditionalLibraryDirectories) + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + x64 + %(Filename).tlb + %(Filename).h + %(Filename)_i.c + %(Filename)_p.c + + + MaxSpeed + true + ..;%(AdditionalIncludeDirectories) + NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Level3 + 4355;%(DisableSpecificWarnings) + + + NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN64;%(PreprocessorDefinitions) + 1033 + ..;%(AdditionalIncludeDirectories) + + + Console + true + ACE.lib;%(AdditionalDependencies) + $(OutDir)envinfo.exe + .;..\lib;%(AdditionalLibraryDirectories) + true + true + + + /machine:AMD64 %(AdditionalOptions) + + + + + + + + + + + + + true + true + true + true + + + + + true + true + true + true + + + true + true + true + true + + + + + + diff --git a/dep/ACE_wrappers/bin/bin_vc10.vcxproj.filters b/dep/ACE_wrappers/bin/bin_vc10.vcxproj.filters index fc98ca18a..a16f69489 100644 --- a/dep/ACE_wrappers/bin/bin_vc10.vcxproj.filters +++ b/dep/ACE_wrappers/bin/bin_vc10.vcxproj.filters @@ -1,35 +1,35 @@ - - - - - {B1F27843-FECA-1BAD-64FC-8A63000064FE} - cpp;cxx;cc;c;C - - - {A1909F1C-FECA-1BAD-64FC-8A63000064FE} - mpc;mpb;mwc - - - {7197AE6D-FECA-1BAD-64FC-8A63000064FE} - sh - - - - - Source Files - - - - - Build Files - - - - - Script Files - - - Script Files - - - + + + + + {B1F27843-FECA-1BAD-64FC-8A63000064FE} + cpp;cxx;cc;c;C + + + {A1909F1C-FECA-1BAD-64FC-8A63000064FE} + mpc;mpb;mwc + + + {7197AE6D-FECA-1BAD-64FC-8A63000064FE} + sh + + + + + Source Files + + + + + Build Files + + + + + Script Files + + + Script Files + + + diff --git a/dep/ACE_wrappers/bin/bin_vc8.sln b/dep/ACE_wrappers/bin/bin_vc8.sln index ad5e0ab61..ac4e71867 100644 --- a/dep/ACE_wrappers/bin/bin_vc8.sln +++ b/dep/ACE_wrappers/bin/bin_vc8.sln @@ -1,43 +1,43 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE\PerlACE_vc8.vcproj", "{E15379F8-FECA-1BAD-A757-FC47A624E189}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin_vc8.vcproj", "{AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 - {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# $Id: VC8WorkspaceCreator.pm 1893 2010-08-26 15:06:15Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc8 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc8" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE\PerlACE_vc8.vcproj", "{E15379F8-FECA-1BAD-A757-FC47A624E189}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin_vc8.vcproj", "{AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {E15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 + {AF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/bin/bin_vc8.vcproj b/dep/ACE_wrappers/bin/bin_vc8.vcproj index ead581623..a791787d6 100644 --- a/dep/ACE_wrappers/bin/bin_vc8.vcproj +++ b/dep/ACE_wrappers/bin/bin_vc8.vcproj @@ -1,441 +1,441 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/bin/bin_vc9.sln b/dep/ACE_wrappers/bin/bin_vc9.sln index fd9e164e3..9ae40270a 100644 --- a/dep/ACE_wrappers/bin/bin_vc9.sln +++ b/dep/ACE_wrappers/bin/bin_vc9.sln @@ -1,43 +1,43 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ -# -# This file was generated by MPC. Any changes made directly to -# this file will be lost the next time it is generated. -# -# MPC Command: -# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE\PerlACE_vc9.vcproj", "{F15379F8-FECA-1BAD-A757-FC47A624E189}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin_vc9.vcproj", "{BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 - {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 - {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# $Id: VC9WorkspaceCreator.pm 1890 2010-08-24 19:48:23Z mitza $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /tmp/DOC_ROOT/stage-1367/ACE_wrappers/bin/mwc.pl -type vc9 -recurse -hierarchy -relative ACE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers -relative TAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO -relative CIAO_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/CIAO -relative DANCE_ROOT=/tmp/DOC_ROOT/stage-1367/ACE_wrappers/TAO/DAnCE -name_modifier "*_vc9" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerlACE", "PerlACE\PerlACE_vc9.vcproj", "{F15379F8-FECA-1BAD-A757-FC47A624E189}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin", "bin_vc9.vcproj", "{BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.ActiveCfg = Debug|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|Win32.Build.0 = Debug|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.ActiveCfg = Debug|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Debug|x64.Build.0 = Debug|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.ActiveCfg = Release|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|Win32.Build.0 = Release|Win32 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.ActiveCfg = Release|x64 + {F15379F8-FECA-1BAD-A757-FC47A624E189}.Release|x64.Build.0 = Release|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|Win32.Build.0 = Debug|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.ActiveCfg = Debug|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Debug|x64.Build.0 = Debug|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.ActiveCfg = Release|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|Win32.Build.0 = Release|Win32 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.ActiveCfg = Release|x64 + {BF4BCC9A-FECA-1BAD-64FC-8A63000064FE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/ACE_wrappers/bin/bin_vc9.vcproj b/dep/ACE_wrappers/bin/bin_vc9.vcproj index da500fde4..df43a425c 100644 --- a/dep/ACE_wrappers/bin/bin_vc9.vcproj +++ b/dep/ACE_wrappers/bin/bin_vc9.vcproj @@ -1,441 +1,441 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/StormLib/.gitignore b/dep/StormLib/.gitignore new file mode 100644 index 000000000..ee7b95b83 --- /dev/null +++ b/dep/StormLib/.gitignore @@ -0,0 +1,13 @@ +# +# NOTE! Don't add files that are generated in specific +# subdirectories here. Add them in the ".gitignore" file +# in that subdirectory instead. +# +# NOTE! Please use 'git-ls-files -i --exclude-standard' +# command after changing this file, to see if there are +# any tracked files which get ignored after the change. +# +# MaNGOS generated files at Windows build +# + +bin diff --git a/dep/StormLib/CMakeLists.txt b/dep/StormLib/CMakeLists.txt index 3c3b3c818..e4bd1b16f 100644 --- a/dep/StormLib/CMakeLists.txt +++ b/dep/StormLib/CMakeLists.txt @@ -1,54 +1,305 @@ -project(StormLib VERSION 9.22.0) +project(StormLib) +cmake_minimum_required(VERSION 2.6) -add_library(stormlib STATIC - src/adpcm/adpcm.cpp - src/huffman/huff.cpp - src/jenkins/lookup3.c - src/lzma/C/LzFind.c - src/lzma/C/LzmaDec.c - src/lzma/C/LzmaEnc.c - src/pklib/explode.c - src/pklib/implode.c - src/sparse/sparse.cpp - src/rsa/rsa_verify_simple.c - src/FileStream.cpp - src/SBaseCommon.cpp - src/SBaseDumpData.cpp - src/SBaseFileTable.cpp - src/SBaseSubTypes.cpp - src/SCompression.cpp - src/SFileAddFile.cpp - src/SFileAttributes.cpp - src/SFileCompactArchive.cpp - src/SFileCreateArchive.cpp - src/SFileExtractFile.cpp - src/SFileFindFile.cpp - src/SFileGetFileInfo.cpp - src/SFileListFile.cpp - src/SFileOpenArchive.cpp - src/SFileOpenFileEx.cpp - src/SFilePatchArchives.cpp - src/SFileReadFile.cpp - src/SFileVerify.cpp +set(SRC_FILES + src/adpcm/adpcm.cpp + src/huffman/huff.cpp + src/jenkins/lookup3.c + src/lzma/C/LzFind.c + src/lzma/C/LzmaDec.c + src/lzma/C/LzmaEnc.c + src/pklib/explode.c + src/pklib/implode.c + src/sparse/sparse.cpp + src/FileStream.cpp + src/SBaseCommon.cpp + src/SBaseDumpData.cpp + src/SBaseFileTable.cpp + src/SCompression.cpp + src/SFileAddFile.cpp + src/SFileAttributes.cpp + src/SFileCompactArchive.cpp + src/SFileCreateArchive.cpp + src/SFileExtractFile.cpp + src/SFileFindFile.cpp + src/SFileListFile.cpp + src/SFileOpenArchive.cpp + src/SFileOpenFileEx.cpp + src/SFilePatchArchives.cpp + src/SFileReadFile.cpp + src/SFileVerify.cpp ) -target_include_directories(stormlib - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) - -target_compile_definitions(stormlib - PUBLIC - _7ZIP_ST - __SYS_BZLIB - __SYS_ZLIB - LTM_DESC - INTERFACE - STORMLIB_NO_AUTO_LINK +set(TOMCRYPT_FILES + src/libtomcrypt/src/hashes/hash_memory.c + src/libtomcrypt/src/hashes/md5.c + src/libtomcrypt/src/hashes/sha1.c + src/libtomcrypt/src/math/ltm_desc.c + src/libtomcrypt/src/math/multi.c + src/libtomcrypt/src/math/rand_prime.c + src/libtomcrypt/src/misc/base64_decode.c + src/libtomcrypt/src/misc/crypt_argchk.c + src/libtomcrypt/src/misc/crypt_find_hash.c + src/libtomcrypt/src/misc/crypt_find_prng.c + src/libtomcrypt/src/misc/crypt_hash_descriptor.c + src/libtomcrypt/src/misc/crypt_hash_is_valid.c + src/libtomcrypt/src/misc/crypt_libc.c + src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c + src/libtomcrypt/src/misc/crypt_prng_descriptor.c + src/libtomcrypt/src/misc/crypt_prng_is_valid.c + src/libtomcrypt/src/misc/crypt_register_hash.c + src/libtomcrypt/src/misc/crypt_register_prng.c + src/libtomcrypt/src/misc/zeromem.c + src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c + src/libtomcrypt/src/pk/asn1/der_decode_boolean.c + src/libtomcrypt/src/pk/asn1/der_decode_choice.c + src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c + src/libtomcrypt/src/pk/asn1/der_decode_integer.c + src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c + src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c + src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c + src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c + src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c + src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c + src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c + src/libtomcrypt/src/pk/asn1/der_decode_utctime.c + src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c + src/libtomcrypt/src/pk/asn1/der_length_bit_string.c + src/libtomcrypt/src/pk/asn1/der_length_boolean.c + src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c + src/libtomcrypt/src/pk/asn1/der_length_integer.c + src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c + src/libtomcrypt/src/pk/asn1/der_length_octet_string.c + src/libtomcrypt/src/pk/asn1/der_length_printable_string.c + src/libtomcrypt/src/pk/asn1/der_length_sequence.c + src/libtomcrypt/src/pk/asn1/der_length_utctime.c + src/libtomcrypt/src/pk/asn1/der_sequence_free.c + src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c + src/libtomcrypt/src/pk/asn1/der_length_short_integer.c + src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c + src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c + src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c + src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c + src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c + src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c + src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c + src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c + src/libtomcrypt/src/pk/rsa/rsa_exptmod.c + src/libtomcrypt/src/pk/rsa/rsa_free.c + src/libtomcrypt/src/pk/rsa/rsa_import.c + src/libtomcrypt/src/pk/rsa/rsa_make_key.c + src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c + src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c ) -target_link_libraries(stormlib - PRIVATE - ZLIB::ZLIB - BZip2::BZip2 - TomLib::Crypt - TomLib::Math -) \ No newline at end of file +set(TOMMATH_FILES + src/libtommath/bncore.c + src/libtommath/bn_fast_mp_invmod.c + src/libtommath/bn_fast_mp_montgomery_reduce.c + src/libtommath/bn_fast_s_mp_mul_digs.c + src/libtommath/bn_fast_s_mp_mul_high_digs.c + src/libtommath/bn_fast_s_mp_sqr.c + src/libtommath/bn_mp_2expt.c + src/libtommath/bn_mp_abs.c + src/libtommath/bn_mp_add.c + src/libtommath/bn_mp_addmod.c + src/libtommath/bn_mp_add_d.c + src/libtommath/bn_mp_and.c + src/libtommath/bn_mp_clamp.c + src/libtommath/bn_mp_clear.c + src/libtommath/bn_mp_clear_multi.c + src/libtommath/bn_mp_cmp.c + src/libtommath/bn_mp_cmp_d.c + src/libtommath/bn_mp_cmp_mag.c + src/libtommath/bn_mp_cnt_lsb.c + src/libtommath/bn_mp_copy.c + src/libtommath/bn_mp_count_bits.c + src/libtommath/bn_mp_div.c + src/libtommath/bn_mp_div_2.c + src/libtommath/bn_mp_div_2d.c + src/libtommath/bn_mp_div_3.c + src/libtommath/bn_mp_div_d.c + src/libtommath/bn_mp_dr_is_modulus.c + src/libtommath/bn_mp_dr_reduce.c + src/libtommath/bn_mp_dr_setup.c + src/libtommath/bn_mp_exch.c + src/libtommath/bn_mp_exptmod.c + src/libtommath/bn_mp_exptmod_fast.c + src/libtommath/bn_mp_expt_d.c + src/libtommath/bn_mp_exteuclid.c + src/libtommath/bn_mp_fread.c + src/libtommath/bn_mp_fwrite.c + src/libtommath/bn_mp_gcd.c + src/libtommath/bn_mp_get_int.c + src/libtommath/bn_mp_grow.c + src/libtommath/bn_mp_init.c + src/libtommath/bn_mp_init_copy.c + src/libtommath/bn_mp_init_multi.c + src/libtommath/bn_mp_init_set.c + src/libtommath/bn_mp_init_set_int.c + src/libtommath/bn_mp_init_size.c + src/libtommath/bn_mp_invmod.c + src/libtommath/bn_mp_invmod_slow.c + src/libtommath/bn_mp_is_square.c + src/libtommath/bn_mp_jacobi.c + src/libtommath/bn_mp_karatsuba_mul.c + src/libtommath/bn_mp_karatsuba_sqr.c + src/libtommath/bn_mp_lcm.c + src/libtommath/bn_mp_lshd.c + src/libtommath/bn_mp_mod.c + src/libtommath/bn_mp_mod_2d.c + src/libtommath/bn_mp_mod_d.c + src/libtommath/bn_mp_montgomery_calc_normalization.c + src/libtommath/bn_mp_montgomery_reduce.c + src/libtommath/bn_mp_montgomery_setup.c + src/libtommath/bn_mp_mul.c + src/libtommath/bn_mp_mulmod.c + src/libtommath/bn_mp_mul_2.c + src/libtommath/bn_mp_mul_2d.c + src/libtommath/bn_mp_mul_d.c + src/libtommath/bn_mp_neg.c + src/libtommath/bn_mp_n_root.c + src/libtommath/bn_mp_or.c + src/libtommath/bn_mp_prime_fermat.c + src/libtommath/bn_mp_prime_is_divisible.c + src/libtommath/bn_mp_prime_is_prime.c + src/libtommath/bn_mp_prime_miller_rabin.c + src/libtommath/bn_mp_prime_next_prime.c + src/libtommath/bn_mp_prime_rabin_miller_trials.c + src/libtommath/bn_mp_prime_random_ex.c + src/libtommath/bn_mp_radix_size.c + src/libtommath/bn_mp_radix_smap.c + src/libtommath/bn_mp_rand.c + src/libtommath/bn_mp_read_radix.c + src/libtommath/bn_mp_read_signed_bin.c + src/libtommath/bn_mp_read_unsigned_bin.c + src/libtommath/bn_mp_reduce.c + src/libtommath/bn_mp_reduce_2k.c + src/libtommath/bn_mp_reduce_2k_l.c + src/libtommath/bn_mp_reduce_2k_setup.c + src/libtommath/bn_mp_reduce_2k_setup_l.c + src/libtommath/bn_mp_reduce_is_2k.c + src/libtommath/bn_mp_reduce_is_2k_l.c + src/libtommath/bn_mp_reduce_setup.c + src/libtommath/bn_mp_rshd.c + src/libtommath/bn_mp_set.c + src/libtommath/bn_mp_set_int.c + src/libtommath/bn_mp_shrink.c + src/libtommath/bn_mp_signed_bin_size.c + src/libtommath/bn_mp_sqr.c + src/libtommath/bn_mp_sqrmod.c + src/libtommath/bn_mp_sqrt.c + src/libtommath/bn_mp_sub.c + src/libtommath/bn_mp_submod.c + src/libtommath/bn_mp_sub_d.c + src/libtommath/bn_mp_toom_mul.c + src/libtommath/bn_mp_toom_sqr.c + src/libtommath/bn_mp_toradix.c + src/libtommath/bn_mp_toradix_n.c + src/libtommath/bn_mp_to_signed_bin.c + src/libtommath/bn_mp_to_signed_bin_n.c + src/libtommath/bn_mp_to_unsigned_bin.c + src/libtommath/bn_mp_to_unsigned_bin_n.c + src/libtommath/bn_mp_unsigned_bin_size.c + src/libtommath/bn_mp_xor.c + src/libtommath/bn_mp_zero.c + src/libtommath/bn_prime_tab.c + src/libtommath/bn_reverse.c + src/libtommath/bn_s_mp_add.c + src/libtommath/bn_s_mp_exptmod.c + src/libtommath/bn_s_mp_mul_digs.c + src/libtommath/bn_s_mp_mul_high_digs.c + src/libtommath/bn_s_mp_sqr.c + src/libtommath/bn_s_mp_sub.c +) + +set(ZLIB_BZIP2_FILES + src/bzip2/blocksort.c + src/bzip2/bzlib.c + src/bzip2/compress.c + src/bzip2/crctable.c + src/bzip2/decompress.c + src/bzip2/huffman.c + src/bzip2/randtable.c + src/zlib/adler32.c + src/zlib/compress2.c + src/zlib/crc32.c + src/zlib/deflate.c + src/zlib/inffast.c + src/zlib/inflate.c + src/zlib/inftrees.c + src/zlib/trees.c + src/zlib/zutil.c +) + +# set(TEST_SRC_FILES +# test/Test.cpp +# ) + +add_definitions(-D_7ZIP_ST -DBZ_STRICT_ANSI) + +if(WIN32) + if(MSVC) + message(STATUS "Using MSVC") + add_definitions(-D_7ZIP_ST -DWIN32) + else() + message(STATUS "Using mingw") + endif() + set(SRC_ADDITIONAL_FILES ${ZLIB_BZIP2_FILES} ${TOMCRYPT_FILES} ${TOMMATH_FILES}) + set(LINK_LIBS wininet) +endif() + +if(APPLE) + message(STATUS "Using Mac OS X port") + set(LINK_LIBS z bz2) + set(SRC_ADDITIONAL_FILES ${TOMCRYPT_FILES} ${TOMMATH_FILES}) +endif() + +if (${CMAKE_SYSTEM_NAME} STREQUAL Linux) + message(STATUS "Using Linux port") + option(WITH_LIBTOMCRYPT "Use system LibTomCrypt library" OFF) + if(WITH_LIBTOMCRYPT) + set(LINK_LIBS z bz2 tomcrypt) + else() + set(LINK_LIBS z bz2) + set(SRC_ADDITIONAL_FILES ${TOMCRYPT_FILES} ${TOMMATH_FILES}) + endif() +endif() + +add_library(storm SHARED ${SRC_FILES} ${SRC_ADDITIONAL_FILES}) +target_link_libraries(storm ${LINK_LIBS}) + +# option(WITH_TEST "Compile Test application" OFF) +# if(WITH_TEST) +# add_executable(storm_test ${TEST_SRC_FILES}) +# target_link_libraries(storm_test storm) +# endif() + +# option(WITH_STATIC "Compile static linked library" OFF) +# if(WITH_STATIC) +# add_library(StormLib_static STATIC ${SRC_FILES} ${SRC_ADDITIONAL_FILES}) +# target_link_libraries(StormLib_static ${LINK_LIBS}) +# set_target_properties(StormLib_static PROPERTIES OUTPUT_NAME StormLib) +# endif() + +if(APPLE) + set_target_properties(storm PROPERTIES FRAMEWORK true) + set_target_properties(storm PROPERTIES PUBLIC_HEADER "src/StormLib.h src/StormPort.h") + set_target_properties(storm PROPERTIES LINK_FLAGS "-framework Carbon") +endif() + +if(UNIX) + set_target_properties(storm PROPERTIES VERSION 8.20.0) + set_target_properties(storm PROPERTIES SOVERSION 8.20) +endif() + +# On Win32, build StormLib.dll since we don't want to clash with Storm.dll +if(WIN32) + set_target_properties(storm PROPERTIES OUTPUT_NAME StormLib) +endif() + +install(TARGETS storm RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib FRAMEWORK DESTINATION /Library/Frameworks) +install(FILES src/StormLib.h src/StormPort.h DESTINATION include) + diff --git a/dep/StormLib/Info.plist b/dep/StormLib/Info.plist new file mode 100644 index 000000000..0e1ae014f --- /dev/null +++ b/dep/StormLib/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + net.zezula.${PRODUCT_NAME:rfc1034Identifier} + CFBundleName + ${PRODUCT_NAME} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 8.01 + + diff --git a/dep/StormLib/Makefile.linux b/dep/StormLib/Makefile.linux new file mode 100644 index 000000000..e9d89c7d9 --- /dev/null +++ b/dep/StormLib/Makefile.linux @@ -0,0 +1,275 @@ +##################################################################### +### +# +# Makefile for compiling StormLib under linux +# +# Author: Marko Friedemann +# Created at: Mon Jan 29 18:26:01 CEST 2001 +# Computer: whiplash.flachland-chemnitz.de +# System: Linux 2.4.0 on i686 +# +# Copyright (c) 2001 BMX-Chemnitz.DE All rights reserved. +# +##################################################################### +### + +############################################################## +# updated on Monday 3, 2010 by Christopher Chedeau aka vjeux # +# updated on April 24, 2010 by Ivan Komissarov aka Nevermore # +############################################################## + +C++ = g++ +CC = gcc +AR = ar +DFLAGS = -D__SYS_ZLIB +OFLAGS = +LFLAGS = -lbz2 -lz +CFLAGS = -fPIC -D_7ZIP_ST +CFLAGS += $(OFLAGS) $(DFLAGS) + +OBJS = src/adpcm/adpcm.o \ + src/FileStream.o \ + src/huffman/huff.o \ + src/SBaseCommon.o \ + src/SBaseFileTable.o \ + src/SCompression.o \ + src/SFileAddFile.o \ + src/SFileAttributes.o \ + src/SFileCompactArchive.o \ + src/SFileCreateArchive.o \ + src/SFileExtractFile.o \ + src/SFileFindFile.o \ + src/SFileListFile.o \ + src/SFileOpenArchive.o \ + src/SFileOpenFileEx.o \ + src/SFilePatchArchives.o \ + src/SFileReadFile.o \ + src/SFileVerify.o \ + src/sparse/sparse.o + +COBJS = src/libtomcrypt/src/hashes/sha1.o \ + src/libtomcrypt/src/hashes/hash_memory.o \ + src/libtomcrypt/src/hashes/md5.o \ + src/libtomcrypt/src/misc/crypt_hash_is_valid.o \ + src/libtomcrypt/src/misc/crypt_prng_descriptor.o \ + src/libtomcrypt/src/misc/crypt_register_prng.o \ + src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.o \ + src/libtomcrypt/src/misc/crypt_find_hash.o \ + src/libtomcrypt/src/misc/zeromem.o \ + src/libtomcrypt/src/misc/base64_decode.o \ + src/libtomcrypt/src/misc/crypt_register_hash.o \ + src/libtomcrypt/src/misc/crypt_find_prng.o \ + src/libtomcrypt/src/misc/crypt_prng_is_valid.o \ + src/libtomcrypt/src/misc/crypt_hash_descriptor.o \ + src/libtomcrypt/src/misc/crypt_libc.o \ + src/libtomcrypt/src/misc/crypt_argchk.o \ + src/libtomcrypt/src/math/multi.o \ + src/libtomcrypt/src/math/ltm_desc.o \ + src/libtomcrypt/src/math/rand_prime.o \ + src/libtomcrypt/src/pk/asn1/der_length_ia5_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_utctime.o \ + src/libtomcrypt/src/pk/asn1/der_length_boolean.o \ + src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.o \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.o \ + src/libtomcrypt/src/pk/asn1/der_decode_octet_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_object_identifier.o \ + src/libtomcrypt/src/pk/asn1/der_length_bit_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_integer.o \ + src/libtomcrypt/src/pk/asn1/der_length_sequence.o \ + src/libtomcrypt/src/pk/asn1/der_decode_choice.o \ + src/libtomcrypt/src/pk/asn1/der_length_octet_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.o \ + src/libtomcrypt/src/pk/asn1/der_decode_printable_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_bit_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_short_integer.o \ + src/libtomcrypt/src/pk/asn1/der_length_utctime.o \ + src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_integer.o \ + src/libtomcrypt/src/pk/asn1/der_decode_boolean.o \ + src/libtomcrypt/src/pk/asn1/der_sequence_free.o \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.o \ + src/libtomcrypt/src/pk/asn1/der_length_short_integer.o \ + src/libtomcrypt/src/pk/asn1/der_length_printable_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_utf8_string.o \ + src/libtomcrypt/src/pk/rsa/rsa_make_key.o \ + src/libtomcrypt/src/pk/rsa/rsa_free.o \ + src/libtomcrypt/src/pk/rsa/rsa_verify_simple.o \ + src/libtomcrypt/src/pk/rsa/rsa_import.o \ + src/libtomcrypt/src/pk/rsa/rsa_verify_hash.o \ + src/libtomcrypt/src/pk/rsa/rsa_exptmod.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_map.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_points.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.o \ + src/libtommath/bn_mp_exptmod_fast.o \ + src/libtommath/bn_mp_jacobi.o \ + src/libtommath/bn_mp_mod.o \ + src/libtommath/bn_mp_signed_bin_size.o \ + src/libtommath/bn_mp_invmod.o \ + src/libtommath/bn_mp_is_square.o \ + src/libtommath/bn_mp_neg.o \ + src/libtommath/bn_mp_reduce_2k.o \ + src/libtommath/bn_mp_xor.o \ + src/libtommath/bn_mp_karatsuba_mul.o \ + src/libtommath/bn_mp_dr_setup.o \ + src/libtommath/bn_mp_mul.o \ + src/libtommath/bn_mp_init_multi.o \ + src/libtommath/bn_mp_clear.o \ + src/libtommath/bn_s_mp_sqr.o \ + src/libtommath/bn_mp_rshd.o \ + src/libtommath/bn_s_mp_sub.o \ + src/libtommath/bn_mp_sub.o \ + src/libtommath/bn_mp_toradix.o \ + src/libtommath/bn_mp_reduce.o \ + src/libtommath/bn_mp_prime_is_prime.o \ + src/libtommath/bn_mp_prime_next_prime.o \ + src/libtommath/bn_mp_exptmod.o \ + src/libtommath/bn_mp_mod_2d.o \ + src/libtommath/bn_reverse.o \ + src/libtommath/bn_mp_init.o \ + src/libtommath/bn_fast_s_mp_sqr.o \ + src/libtommath/bn_mp_sqr.o \ + src/libtommath/bn_mp_cnt_lsb.o \ + src/libtommath/bn_mp_clear_multi.o \ + src/libtommath/bn_mp_exch.o \ + src/libtommath/bn_fast_s_mp_mul_digs.o \ + src/libtommath/bn_mp_grow.o \ + src/libtommath/bn_mp_read_radix.o \ + src/libtommath/bn_mp_mul_2.o \ + src/libtommath/bn_mp_shrink.o \ + src/libtommath/bn_mp_div_2.o \ + src/libtommath/bn_fast_mp_invmod.o \ + src/libtommath/bn_mp_prime_miller_rabin.o \ + src/libtommath/bn_mp_to_unsigned_bin.o \ + src/libtommath/bn_mp_prime_rabin_miller_trials.o \ + src/libtommath/bn_mp_2expt.o \ + src/libtommath/bn_mp_cmp_mag.o \ + src/libtommath/bn_mp_to_signed_bin.o \ + src/libtommath/bn_mp_get_int.o \ + src/libtommath/bn_mp_montgomery_reduce.o \ + src/libtommath/bn_mp_dr_reduce.o \ + src/libtommath/bn_mp_fwrite.o \ + src/libtommath/bn_mp_and.o \ + src/libtommath/bn_mp_exteuclid.o \ + src/libtommath/bn_fast_mp_montgomery_reduce.o \ + src/libtommath/bn_s_mp_mul_high_digs.o \ + src/libtommath/bn_mp_reduce_setup.o \ + src/libtommath/bn_mp_lcm.o \ + src/libtommath/bn_mp_abs.o \ + src/libtommath/bn_mp_cmp.o \ + src/libtommath/bn_mp_submod.o \ + src/libtommath/bn_mp_div_d.o \ + src/libtommath/bn_s_mp_mul_digs.o \ + src/libtommath/bn_mp_mul_d.o \ + src/libtommath/bn_mp_to_unsigned_bin_n.o \ + src/libtommath/bn_mp_prime_random_ex.o \ + src/libtommath/bn_mp_rand.o \ + src/libtommath/bn_mp_div_2d.o \ + src/libtommath/bn_mp_addmod.o \ + src/libtommath/bn_mp_init_copy.o \ + src/libtommath/bn_mp_read_unsigned_bin.o \ + src/libtommath/bn_mp_toradix_n.o \ + src/libtommath/bn_fast_s_mp_mul_high_digs.o \ + src/libtommath/bn_mp_toom_sqr.o \ + src/libtommath/bn_mp_to_signed_bin_n.o \ + src/libtommath/bn_mp_reduce_2k_setup_l.o \ + src/libtommath/bn_mp_div.o \ + src/libtommath/bn_prime_tab.o \ + src/libtommath/bn_mp_karatsuba_sqr.o \ + src/libtommath/bn_mp_gcd.o \ + src/libtommath/bn_mp_prime_is_divisible.o \ + src/libtommath/bn_mp_set_int.o \ + src/libtommath/bn_mp_prime_fermat.o \ + src/libtommath/bn_mp_cmp_d.o \ + src/libtommath/bn_mp_add.o \ + src/libtommath/bn_mp_sub_d.o \ + src/libtommath/bn_s_mp_exptmod.o \ + src/libtommath/bn_mp_init_size.o \ + src/libtommath/bncore.o \ + src/libtommath/bn_mp_radix_smap.o \ + src/libtommath/bn_mp_reduce_2k_l.o \ + src/libtommath/bn_mp_montgomery_calc_normalization.o \ + src/libtommath/bn_mp_mod_d.o \ + src/libtommath/bn_mp_set.o \ + src/libtommath/bn_mp_or.o \ + src/libtommath/bn_mp_sqrt.o \ + src/libtommath/bn_mp_invmod_slow.o \ + src/libtommath/bn_mp_count_bits.o \ + src/libtommath/bn_mp_read_signed_bin.o \ + src/libtommath/bn_mp_div_3.o \ + src/libtommath/bn_mp_unsigned_bin_size.o \ + src/libtommath/bn_mp_mulmod.o \ + src/libtommath/bn_mp_clamp.o \ + src/libtommath/bn_mp_reduce_2k_setup.o \ + src/libtommath/bn_mp_toom_mul.o \ + src/libtommath/bn_mp_montgomery_setup.o \ + src/libtommath/bn_mp_expt_d.o \ + src/libtommath/bn_mp_copy.o \ + src/libtommath/bn_mp_dr_is_modulus.o \ + src/libtommath/bn_mp_sqrmod.o \ + src/libtommath/bn_mp_reduce_is_2k_l.o \ + src/libtommath/bn_mp_mul_2d.o \ + src/libtommath/bn_mp_fread.o \ + src/libtommath/bn_mp_init_set.o \ + src/libtommath/bn_mp_add_d.o \ + src/libtommath/bn_mp_zero.o \ + src/libtommath/bn_s_mp_add.o \ + src/libtommath/bn_mp_radix_size.o \ + src/libtommath/bn_mp_init_set_int.o \ + src/libtommath/bn_mp_n_root.o \ + src/libtommath/bn_mp_lshd.o \ + src/libtommath/bn_mp_reduce_is_2k.o \ + src/pklib/implode.o \ + src/pklib/crc32.o \ + src/pklib/explode.o \ + src/zlib/crc32.o \ + src/zlib/trees.o \ + src/zlib/compress2.o \ + src/zlib/adler32.o \ + src/zlib/inftrees.o \ + src/zlib/inffast.o \ + src/zlib/deflate.o \ + src/zlib/inflate.o \ + src/zlib/zutil.o \ + src/lzma/C/LzFind.o \ + src/lzma/C/LzmaEnc.o \ + src/lzma/C/LzmaDec.o \ + src/jenkins/lookup3.o + +LIB = libStorm.so +SLIB = libStorm.a + +all: $(OBJS) $(COBJS) $(LIB) $(SLIB) + +$(LIB): $(OBJS) $(COBJS) + $(C++) $(ARCH) -shared -o $(LIB) $(OBJS) $(COBJS) $(LFLAGS) + +$(SLIB): $(OBJS) $(COBJS) + $(AR) rcs $(SLIB) $(OBJS) $(COBJS) + +clean: + rm -f $(OBJS) $(COBJS) $(LIB) + +$(OBJS): %.o: %.cpp + $(C++) -o $@ $(CFLAGS) -c $< + +$(COBJS): %.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + +$(LIB): $(OBJS) $(COBJS) + +all: $(LIB) + +install: $(LIB) + install $(LIB) /usr/local/lib + mkdir -p /usr/local/include/StormLib + cp src/StormLib.h /usr/local/include/StormLib + cp src/StormPort.h /usr/local/include/StormLib + ldconfig diff --git a/dep/StormLib/Makefile.mac b/dep/StormLib/Makefile.mac new file mode 100644 index 000000000..0ca783426 --- /dev/null +++ b/dep/StormLib/Makefile.mac @@ -0,0 +1,253 @@ +##################################################################### +# +# Makefile for compiling StormLib with g++ on Mac +# +# Author: Ladislav Zezula +# Created: Mon May 10 14:13:00 CEST 2010 +# System: Mac OS X (64bit) +# +##################################################################### + +CPP = g++ +CC = gcc +CFLAGS = -Wall +LFLAGS = -lbz2 -lz -framework Carbon +ARCH = -arch x86_64 +DFLAGS = -D__SYS_BZLIB -D__SYS_ZLIB -D_7ZIP_ST +AR = ar +ARFLAGS= rcs + +LIBRARY = libStorm.dylib + +OBJS_CPP = src/adpcm/adpcm.obj \ + src/huffman/huff.obj \ + src/sparse/sparse.obj \ + src/FileStream.obj \ + src/SBaseCommon.o \ + src/SBaseFileTable.o \ + src/SCompression.obj \ + src/SFileAddFile.obj \ + src/SFileAttributes.obj \ + src/SFileCompactArchive.obj \ + src/SFileCreateArchive.obj \ + src/SFileExtractFile.obj \ + src/SFileFindFile.obj \ + src/SFileListFile.obj \ + src/SFileOpenArchive.obj \ + src/SFileOpenFileEx.obj \ + src/SFilePatchArchives.obj \ + src/SFileReadFile.obj \ + src/SFileVerify.obj + + +OBJS_C = src/jenkins/lookup3.o \ + src/libtomcrypt/src/hashes/hash_memory.obj \ + src/libtomcrypt/src/hashes/md5.obj \ + src/libtomcrypt/src/hashes/sha1.obj\ + src/libtomcrypt/src/math/ltm_desc.obj \ + src/libtomcrypt/src/math/multi.obj \ + src/libtomcrypt/src/math/rand_prime.obj \ + src/libtomcrypt/src/misc/base64_decode.obj \ + src/libtomcrypt/src/misc/crypt_argchk.obj \ + src/libtomcrypt/src/misc/crypt_find_hash.obj \ + src/libtomcrypt/src/misc/crypt_find_prng.obj \ + src/libtomcrypt/src/misc/crypt_hash_descriptor.obj \ + src/libtomcrypt/src/misc/crypt_hash_is_valid.obj \ + src/libtomcrypt/src/misc/crypt_libc.obj \ + src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.obj \ + src/libtomcrypt/src/misc/crypt_prng_descriptor.obj \ + src/libtomcrypt/src/misc/crypt_prng_is_valid.obj \ + src/libtomcrypt/src/misc/crypt_register_hash.obj \ + src/libtomcrypt/src/misc/crypt_register_prng.obj \ + src/libtomcrypt/src/misc/zeromem.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_bit_string.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_boolean.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_choice.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_integer.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_octet_string.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_printable_string.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_short_integer.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_utctime.obj \ + src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.obj \ + src/libtomcrypt/src/pk/asn1/der_length_bit_string.obj \ + src/libtomcrypt/src/pk/asn1/der_length_boolean.obj \ + src/libtomcrypt/src/pk/asn1/der_length_ia5_string.obj \ + src/libtomcrypt/src/pk/asn1/der_length_integer.obj \ + src/libtomcrypt/src/pk/asn1/der_length_object_identifier.obj \ + src/libtomcrypt/src/pk/asn1/der_length_octet_string.obj \ + src/libtomcrypt/src/pk/asn1/der_length_printable_string.obj \ + src/libtomcrypt/src/pk/asn1/der_length_sequence.obj \ + src/libtomcrypt/src/pk/asn1/der_length_short_integer.obj \ + + src/libtomcrypt/src/pk/asn1/der_length_utctime.obj \ + + src/libtomcrypt/src/pk/asn1/der_length_utf8_string.obj \ + + src/libtomcrypt/src/pk/asn1/der_sequence_free.obj \ + + src/libtomcrypt/src/pk/ecc/ltc_ecc_map.obj \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.obj \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.obj \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_points.obj \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.obj \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.obj \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.obj \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.obj \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.obj \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.obj \ + src/libtomcrypt/src/pk/rsa/rsa_exptmod.obj \ + src/libtomcrypt/src/pk/rsa/rsa_free.obj \ + src/libtomcrypt/src/pk/rsa/rsa_import.obj \ + src/libtomcrypt/src/pk/rsa/rsa_make_key.obj \ + src/libtomcrypt/src/pk/rsa/rsa_verify_hash.obj \ + src/libtomcrypt/src/pk/rsa/rsa_verify_simple.obj \ + src/libtommath/bncore.obj \ + src/libtommath/bn_fast_mp_invmod.obj \ + src/libtommath/bn_fast_mp_montgomery_reduce.obj \ + src/libtommath/bn_fast_s_mp_mul_digs.obj \ + src/libtommath/bn_fast_s_mp_mul_high_digs.obj \ + src/libtommath/bn_fast_s_mp_sqr.obj \ + src/libtommath/bn_mp_2expt.obj \ + src/libtommath/bn_mp_abs.obj \ + src/libtommath/bn_mp_add.obj \ + src/libtommath/bn_mp_addmod.obj \ + src/libtommath/bn_mp_add_d.obj \ + src/libtommath/bn_mp_and.obj \ + src/libtommath/bn_mp_clamp.obj \ + src/libtommath/bn_mp_clear.obj \ + src/libtommath/bn_mp_clear_multi.obj \ + src/libtommath/bn_mp_cmp.obj \ + src/libtommath/bn_mp_cmp_d.obj \ + src/libtommath/bn_mp_cmp_mag.obj \ + src/libtommath/bn_mp_cnt_lsb.obj \ + src/libtommath/bn_mp_copy.obj \ + src/libtommath/bn_mp_count_bits.obj \ + src/libtommath/bn_mp_div.obj \ + src/libtommath/bn_mp_div_2.obj \ + src/libtommath/bn_mp_div_2d.obj \ + src/libtommath/bn_mp_div_3.obj \ + src/libtommath/bn_mp_div_d.obj \ + src/libtommath/bn_mp_dr_is_modulus.obj \ + src/libtommath/bn_mp_dr_reduce.obj \ + src/libtommath/bn_mp_dr_setup.obj \ + src/libtommath/bn_mp_exch.obj \ + src/libtommath/bn_mp_exptmod.obj \ + src/libtommath/bn_mp_exptmod_fast.obj \ + src/libtommath/bn_mp_expt_d.obj \ + src/libtommath/bn_mp_exteuclid.obj \ + src/libtommath/bn_mp_fread.obj \ + src/libtommath/bn_mp_fwrite.obj \ + src/libtommath/bn_mp_gcd.obj \ + src/libtommath/bn_mp_get_int.obj \ + src/libtommath/bn_mp_grow.obj \ + src/libtommath/bn_mp_init.obj \ + src/libtommath/bn_mp_init_copy.obj \ + src/libtommath/bn_mp_init_multi.obj \ + src/libtommath/bn_mp_init_set.obj \ + src/libtommath/bn_mp_init_set_int.obj \ + src/libtommath/bn_mp_init_size.obj \ + src/libtommath/bn_mp_invmod.obj \ + src/libtommath/bn_mp_invmod_slow.obj \ + src/libtommath/bn_mp_is_square.obj \ + src/libtommath/bn_mp_jacobi.obj \ + src/libtommath/bn_mp_karatsuba_mul.obj \ + src/libtommath/bn_mp_karatsuba_sqr.obj \ + src/libtommath/bn_mp_lcm.obj \ + src/libtommath/bn_mp_lshd.obj \ + src/libtommath/bn_mp_mod.obj \ + src/libtommath/bn_mp_mod_2d.obj \ + src/libtommath/bn_mp_mod_d.obj \ + src/libtommath/bn_mp_montgomery_calc_normalization.obj \ + src/libtommath/bn_mp_montgomery_reduce.obj \ + src/libtommath/bn_mp_montgomery_setup.obj \ + src/libtommath/bn_mp_mul.obj \ + src/libtommath/bn_mp_mulmod.obj \ + src/libtommath/bn_mp_mul_2.obj \ + src/libtommath/bn_mp_mul_2d.obj \ + src/libtommath/bn_mp_mul_d.obj \ + src/libtommath/bn_mp_neg.obj \ + src/libtommath/bn_mp_n_root.obj \ + src/libtommath/bn_mp_or.obj \ + src/libtommath/bn_mp_prime_fermat.obj \ + src/libtommath/bn_mp_prime_is_divisible.obj \ + src/libtommath/bn_mp_prime_is_prime.obj \ + src/libtommath/bn_mp_prime_miller_rabin.obj \ + src/libtommath/bn_mp_prime_next_prime.obj \ + src/libtommath/bn_mp_prime_rabin_miller_trials.obj \ + src/libtommath/bn_mp_prime_random_ex.obj \ + src/libtommath/bn_mp_radix_size.obj \ + src/libtommath/bn_mp_radix_smap.obj \ + src/libtommath/bn_mp_rand.obj \ + src/libtommath/bn_mp_read_radix.obj \ + src/libtommath/bn_mp_read_signed_bin.obj \ + src/libtommath/bn_mp_read_unsigned_bin.obj \ + src/libtommath/bn_mp_reduce.obj \ + src/libtommath/bn_mp_reduce_2k.obj \ + src/libtommath/bn_mp_reduce_2k_l.obj \ + src/libtommath/bn_mp_reduce_2k_setup.obj \ + src/libtommath/bn_mp_reduce_2k_setup_l.obj \ + src/libtommath/bn_mp_reduce_is_2k.obj \ + src/libtommath/bn_mp_reduce_is_2k_l.obj \ + src/libtommath/bn_mp_reduce_setup.obj \ + src/libtommath/bn_mp_rshd.obj \ + src/libtommath/bn_mp_set.obj \ + src/libtommath/bn_mp_set_int.obj \ + src/libtommath/bn_mp_shrink.obj \ + src/libtommath/bn_mp_signed_bin_size.obj \ + src/libtommath/bn_mp_sqr.obj \ + src/libtommath/bn_mp_sqrmod.obj \ + src/libtommath/bn_mp_sqrt.obj \ + src/libtommath/bn_mp_sub.obj \ + src/libtommath/bn_mp_submod.obj \ + src/libtommath/bn_mp_sub_d.obj \ + src/libtommath/bn_mp_toom_mul.obj \ + src/libtommath/bn_mp_toom_sqr.obj \ + src/libtommath/bn_mp_toradix.obj \ + src/libtommath/bn_mp_toradix_n.obj \ + src/libtommath/bn_mp_to_signed_bin.obj \ + src/libtommath/bn_mp_to_signed_bin_n.obj \ + src/libtommath/bn_mp_to_unsigned_bin.obj \ + src/libtommath/bn_mp_to_unsigned_bin_n.obj \ + src/libtommath/bn_mp_unsigned_bin_size.obj \ + src/libtommath/bn_mp_xor.obj \ + src/libtommath/bn_mp_zero.obj \ + src/libtommath/bn_prime_tab.obj \ + src/libtommath/bn_reverse.obj \ + src/libtommath/bn_s_mp_add.obj \ + src/libtommath/bn_s_mp_exptmod.obj \ + src/libtommath/bn_s_mp_mul_digs.obj \ + src/libtommath/bn_s_mp_mul_high_digs.obj \ + src/libtommath/bn_s_mp_sqr.obj \ + src/libtommath/bn_s_mp_sub.obj \ + src/lzma/C/LzFind.obj \ + src/lzma/C/LzmaDec.obj \ + src/lzma/C/LzmaEnc.obj \ + src/pklib/explode.obj \ + src/pklib/implode.obj + +all: $(LIBRARY) + +#clean: +# rm -f $(OBJS) $(LIBRARY) + +#install: $(LIBRARY) +# install $(LIBRARY) /usr/local/lib +# mkdir -p /usr/local/include/StormLib +# cp StormLib.h /usr/local/include/StormLib +# cp StormPort.h /usr/local/include/StormLib + +$(LIBRARY): $(OBJS_C) $(OBJS_CPP) + $(CPP) $(CFLAGS) $(DFLAGS) $(ARCH) $(LFLAGS) -shared -o $(LIBRARY) $(OBJS_C) $(OBJS_CPP) +# $(AR) $(ARFLAGS) $(LIBRARY) $(OBJS_C) $(OBJS_CPP) + +$(OBJS_C): %.obj: %.c + $(CC) -o $@ $(CFLAGS) $(DFLAGS) -c $< + +$(OBJS_CPP): %.obj: %.cpp + $(CC) -o $@ $(CFLAGS) $(DFLAGS) -c $< + diff --git a/dep/StormLib/Publish.bat b/dep/StormLib/Publish.bat new file mode 100644 index 000000000..59db0b1e3 --- /dev/null +++ b/dep/StormLib/Publish.bat @@ -0,0 +1,22 @@ +@echo off +rem This BAT file updates the ZIP file that is to be uploaded to web +rem Only use when both 32-bit and 64-bit are properly compiled + +echo Creating stormlib.zip ... +cd \Ladik\Appdir +zip.exe -ur9 ..\WWW\web\download\stormlib.zip StormLib\doc\* +zip.exe -ur9 ..\WWW\web\download\stormlib.zip StormLib\src\* +zip.exe -ur9 ..\WWW\web\download\stormlib.zip StormLib\storm_dll\* +zip.exe -ur9 ..\WWW\web\download\stormlib.zip StormLib\StormLib.xcodeproj\* +zip.exe -ur9 ..\WWW\web\download\stormlib.zip StormLib\stormlib_dll\* +zip.exe -ur9 ..\WWW\web\download\stormlib.zip StormLib\test\* +zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\CMakeLists.txt +zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\makefile.* +zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\Info.plist +zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\*.bat +zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\*.sln +zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\*.vcproj +echo. + +echo Press any key to exit ... +pause >nul diff --git a/dep/StormLib/Publish_beta.bat b/dep/StormLib/Publish_beta.bat new file mode 100644 index 000000000..380ea1c84 --- /dev/null +++ b/dep/StormLib/Publish_beta.bat @@ -0,0 +1,22 @@ +@echo off +rem This BAT file updates the ZIP file that is to be uploaded to web +rem Only use when both 32-bit and 64-bit are properly compiled + +echo Creating stormlib_beta.zip ... +cd \Ladik\Appdir +zip.exe -ur9 ..\WWW\web\download\stormlib_beta.zip StormLib\doc\* +zip.exe -ur9 ..\WWW\web\download\stormlib_beta.zip StormLib\src\* +zip.exe -ur9 ..\WWW\web\download\stormlib_beta.zip StormLib\storm_dll\* +zip.exe -ur9 ..\WWW\web\download\stormlib_beta.zip StormLib\StormLib.xcodeproj\* +zip.exe -ur9 ..\WWW\web\download\stormlib_beta.zip StormLib\stormlib_dll\* +zip.exe -ur9 ..\WWW\web\download\stormlib_beta.zip StormLib\test\* +zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\CMakeLists.txt +zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\makefile.* +zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\Info.plist +zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\*.bat +zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\*.sln +zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\*.vcproj +echo. + +echo Press any key to exit ... +pause >nul diff --git a/dep/StormLib/README.md b/dep/StormLib/README.md new file mode 100644 index 000000000..b8737e15d --- /dev/null +++ b/dep/StormLib/README.md @@ -0,0 +1,23 @@ +stormlib ![Project status](http://getmangos.com/assets/img/repository-status-maintained.png) +======== + +The StormLib library is a pack of modules, written in C++, which are able to +read and also to write files from/to the MPQ archives. + +MPQ (MoPaQ) is an archive format developed by Blizzard Entertainment, +purposed for storing data files, images, sounds, music and videos for their +games. + +*Notice*: this repository is meant to track the development of the original +[stormlib][1], developed by [Ladislav Zezula][2]. + +Usage +----- +This library is used inside of [mangos-zero][3] to access data inside of MPQ +archives included in the [World of Warcraft][4] game client. + + +[1]: http://www.zezula.net/en/mpq/stormlib.html "StormLib" +[2]: http://www.zezula.net/ "Ladislav Zezula" +[3]: http://github.com/mangos-zero "mangos-zero" +[4]: http://eu.blizzard.com/en-gb/games/wow/ "World of Warcraft" diff --git a/dep/StormLib/StormLib.bat b/dep/StormLib/StormLib.bat new file mode 100644 index 000000000..5228a26b2 --- /dev/null +++ b/dep/StormLib/StormLib.bat @@ -0,0 +1,22 @@ +@echo off +rem Post-build batch for StormLib project +rem Called as StormLib.bat $(PlatformName) $(ConfigurationName) +rem Example: StormLib.bat x64 Debug + +copy src\StormPort.h ..\aaa\inc +copy src\StormLib.h ..\aaa\inc + +if x%1 == xWin32 goto PlatformWin32 +if x%1 == xx64 goto PlatformWin64 +goto exit + +:PlatformWin32 +copy .\bin\Stormlib\%1\%2\*.lib ..\aaa\lib32 +goto exit + +:PlatformWin64 +copy .\bin\Stormlib\%1\%2\*.lib ..\aaa\lib64 +goto exit + +:exit + diff --git a/dep/StormLib/StormLib.sln b/dep/StormLib/StormLib.sln new file mode 100644 index 000000000..758f29c30 --- /dev/null +++ b/dep/StormLib/StormLib.sln @@ -0,0 +1,140 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib", "StormLib.vcproj", "{78424708-1F6E-4D4B-920C-FB6D26847055}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib_dll", "StormLib_dll.vcproj", "{CB385198-50B1-4CF4-883B-11F042DED6AA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib_test", "StormLib_test.vcproj", "{AA561A7B-26EA-49AF-90E8-C53C1FA2965D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + DebugAD|Win32 = DebugAD|Win32 + DebugAD|x64 = DebugAD|x64 + DebugAS|Win32 = DebugAS|Win32 + DebugAS|x64 = DebugAS|x64 + DebugUD|Win32 = DebugUD|Win32 + DebugUD|x64 = DebugUD|x64 + DebugUS|Win32 = DebugUS|Win32 + DebugUS|x64 = DebugUS|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseAD|Win32 = ReleaseAD|Win32 + ReleaseAD|x64 = ReleaseAD|x64 + ReleaseAS|Win32 = ReleaseAS|Win32 + ReleaseAS|x64 = ReleaseAS|x64 + ReleaseUD|Win32 = ReleaseUD|Win32 + ReleaseUD|x64 = ReleaseUD|x64 + ReleaseUS|Win32 = ReleaseUS|Win32 + ReleaseUS|x64 = ReleaseUS|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Debug|Win32.Build.0 = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Debug|x64.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Debug|x64.Build.0 = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAD|Win32.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAD|x64.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAD|x64.Build.0 = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAS|Win32.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAS|x64.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAS|x64.Build.0 = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugUD|Win32.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugUD|x64.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugUD|x64.Build.0 = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugUS|Win32.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugUS|x64.ActiveCfg = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugUS|x64.Build.0 = Debug|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Release|Win32.ActiveCfg = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Release|Win32.Build.0 = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Release|x64.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Release|x64.Build.0 = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAD|Win32.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAD|x64.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAD|x64.Build.0 = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAS|Win32.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAS|x64.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAS|x64.Build.0 = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseUD|Win32.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseUD|x64.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseUD|x64.Build.0 = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseUS|Win32.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseUS|x64.ActiveCfg = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseUS|x64.Build.0 = Release|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.ActiveCfg = DebugUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.ActiveCfg = DebugUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.Build.0 = DebugUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|Win32.ActiveCfg = DebugAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|Win32.Build.0 = DebugAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|x64.ActiveCfg = DebugAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|x64.Build.0 = DebugAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|Win32.ActiveCfg = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|Win32.Build.0 = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|x64.ActiveCfg = DebugAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|x64.Build.0 = DebugAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUD|Win32.ActiveCfg = DebugUD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUD|Win32.Build.0 = DebugUD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUD|x64.ActiveCfg = DebugUD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUD|x64.Build.0 = DebugUD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUS|Win32.ActiveCfg = DebugUS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUS|Win32.Build.0 = DebugUS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUS|x64.ActiveCfg = DebugUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugUS|x64.Build.0 = DebugUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.ActiveCfg = ReleaseUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.ActiveCfg = ReleaseUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.Build.0 = ReleaseUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|Win32.ActiveCfg = ReleaseAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|Win32.Build.0 = ReleaseAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|x64.ActiveCfg = ReleaseAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|x64.Build.0 = ReleaseAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|Win32.ActiveCfg = ReleaseAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|Win32.Build.0 = ReleaseAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|x64.ActiveCfg = ReleaseAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|x64.Build.0 = ReleaseAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUD|Win32.ActiveCfg = ReleaseUD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUD|Win32.Build.0 = ReleaseUD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUD|x64.ActiveCfg = ReleaseUD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUD|x64.Build.0 = ReleaseUD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUS|Win32.ActiveCfg = ReleaseUS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUS|Win32.Build.0 = ReleaseUS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUS|x64.ActiveCfg = ReleaseUS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseUS|x64.Build.0 = ReleaseUS|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|Win32.ActiveCfg = Debug|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|Win32.Build.0 = Debug|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAD|Win32.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAD|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAD|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAS|Win32.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAS|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAS|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugUD|Win32.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugUD|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugUD|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugUS|Win32.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugUS|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugUS|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|Win32.ActiveCfg = Release|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|Win32.Build.0 = Release|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|x64.Build.0 = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAD|Win32.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAD|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAD|x64.Build.0 = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAS|Win32.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAS|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAS|x64.Build.0 = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseUD|Win32.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseUD|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseUD|x64.Build.0 = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseUS|Win32.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseUS|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseUS|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/StormLib/StormLib.vcproj b/dep/StormLib/StormLib.vcproj new file mode 100644 index 000000000..cccd638d3 --- /dev/null +++ b/dep/StormLib/StormLib.vcproj @@ -0,0 +1,21605 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/StormLib/StormLib.vcxproj b/dep/StormLib/StormLib.vcxproj new file mode 100644 index 000000000..328b47398 --- /dev/null +++ b/dep/StormLib/StormLib.vcxproj @@ -0,0 +1,688 @@ + + + + + DebugAD + Win32 + + + DebugAD + x64 + + + DebugAS + Win32 + + + DebugAS + x64 + + + ReleaseAD + Win32 + + + ReleaseAD + x64 + + + ReleaseAS + Win32 + + + ReleaseAS + x64 + + + + StormLib + {78424708-1F6E-4D4B-920C-FB6D26847055} + StormLib + Win32Proj + + + + StaticLibrary + MultiByte + true + + + StaticLibrary + MultiByte + true + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + true + + + StaticLibrary + MultiByte + true + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + $(ProjectName)RAS + $(ProjectName)DAD + $(ProjectName)DAS + $(ProjectName)RAD + $(ProjectName)DAD + $(ProjectName)DAS + $(ProjectName)RAD + $(ProjectName)RAS + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebugDLL + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)DAD.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + X64 + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebugDLL + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)DAD.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebug + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)DAS.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + X64 + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebug + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)DAS.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)RAD.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + X64 + + + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)RAD.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)RAS.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + X64 + + + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level1 + ProgramDatabase + + + $(OutDir)$(ProjectName)RAS.lib + + + StormLib.bat $(Platform) $(Configuration) + + + + + + + + + + + + + + + + + + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + Level4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dep/StormLib/StormLib.vcxproj.filters b/dep/StormLib/StormLib.vcxproj.filters new file mode 100644 index 000000000..ef66e8266 --- /dev/null +++ b/dep/StormLib/StormLib.vcxproj.filters @@ -0,0 +1,773 @@ + + + + + {effa28bb-96bc-4993-9585-b693f1b43fed} + + + {7286f457-bd1b-48bb-a3db-f0578efc1599} + + + {d600e869-3d0d-4e8c-a7a1-3d8e197a2221} + + + {ebdeaea5-c32f-45d5-8f90-3eaa095c6718} + + + {7dec5e6c-4b3a-4b2e-a101-be989834099d} + + + {1bfbfc3e-5dc4-4b0c-854b-e89d6640a2fc} + + + {47adf465-3887-4876-bf83-d37b4a985aaa} + + + {790545bb-38f9-4912-bbe3-12df58f4baa5} + + + {94bebdeb-9e41-4035-86f0-7f6ae11e2554} + + + {ede5853a-1e68-4ece-a685-92c8332c3f14} + + + {a51db59f-9173-4695-a630-f0cd4a681a01} + + + {c031a94e-2744-4a55-8816-ace1bf00100b} + + + {2f21719f-6b7b-4030-8ecf-3d78c206aeed} + + + {78e6bf7d-7caf-4e0f-a6fb-6b47a29829e2} + + + {cc4ee160-f0fc-4b20-b407-321a736eef53} + + + {6e6e1703-0f73-4c7f-8ec7-43e54dc41686} + + + {1ca211be-0681-4c87-a79f-a0d642e712b4} + + + {528999a0-8a83-4e92-8464-def8777926e9} + + + {13b274dc-aaf6-464c-ab6a-ce8043d293d7} + + + {4e915cd1-6776-4950-af15-16692935d179} + + + {9e077595-7d70-423c-90ce-aa5ec68eac06} + + + + + Doc Files + + + Doc Files + + + Doc Files + + + + + Header Files + + + Header Files + + + Header Files + + + Source Files\adpcm + + + Source Files\huffman + + + Source Files\pklib + + + Source Files\sparse + + + Source Files\jenkins + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\adpcm + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\huffman + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\pklib + + + Source Files\pklib + + + Source Files\sparse + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\jenkins + + + \ No newline at end of file diff --git a/dep/StormLib/StormLib.xcodeproj/project.pbxproj b/dep/StormLib/StormLib.xcodeproj/project.pbxproj new file mode 100644 index 000000000..319e26313 --- /dev/null +++ b/dep/StormLib/StormLib.xcodeproj/project.pbxproj @@ -0,0 +1,1992 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 221F6A741168529C0026C852 /* LzmaDec.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6A721168529C0026C852 /* LzmaDec.h */; }; + 221F6A751168529C0026C852 /* LzmaEnc.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6A731168529C0026C852 /* LzmaEnc.h */; }; + 221F6A761168529C0026C852 /* LzmaDec.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6A721168529C0026C852 /* LzmaDec.h */; }; + 221F6A771168529C0026C852 /* LzmaEnc.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6A731168529C0026C852 /* LzmaEnc.h */; }; + 221F6A7B116852AA0026C852 /* LzmaEnc.c in Sources */ = {isa = PBXBuildFile; fileRef = 221F6A7A116852AA0026C852 /* LzmaEnc.c */; }; + 221F6A7C116852AA0026C852 /* LzmaEnc.c in Sources */ = {isa = PBXBuildFile; fileRef = 221F6A7A116852AA0026C852 /* LzmaEnc.c */; }; + 221F6A7E116852B20026C852 /* LzmaDec.c in Sources */ = {isa = PBXBuildFile; fileRef = 221F6A7D116852B20026C852 /* LzmaDec.c */; }; + 221F6A7F116852B20026C852 /* LzmaDec.c in Sources */ = {isa = PBXBuildFile; fileRef = 221F6A7D116852B20026C852 /* LzmaDec.c */; }; + 221F6AB51168545B0026C852 /* LzFind.c in Sources */ = {isa = PBXBuildFile; fileRef = 221F6AB31168545B0026C852 /* LzFind.c */; }; + 221F6AB61168545B0026C852 /* LzFind.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6AB41168545B0026C852 /* LzFind.h */; }; + 221F6AB71168545B0026C852 /* LzFind.c in Sources */ = {isa = PBXBuildFile; fileRef = 221F6AB31168545B0026C852 /* LzFind.c */; }; + 221F6AB81168545B0026C852 /* LzFind.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6AB41168545B0026C852 /* LzFind.h */; }; + 221F6ABA116854730026C852 /* LzHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6AB9116854730026C852 /* LzHash.h */; }; + 221F6ABB116854730026C852 /* LzHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6AB9116854730026C852 /* LzHash.h */; }; + 221F6ABD116854870026C852 /* Types.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6ABC116854870026C852 /* Types.h */; }; + 221F6ABE116854870026C852 /* Types.h in Headers */ = {isa = PBXBuildFile; fileRef = 221F6ABC116854870026C852 /* Types.h */; }; + 2254917B11948CE70044424D /* crypt_ltc_mp_descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184811933FCF0083AC69 /* crypt_ltc_mp_descriptor.c */; settings = {COMPILER_FLAGS = "-fno-common"; }; }; + 225530DB1056BC7900FA646A /* huff.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED009D0D03542A00AB0B4E /* huff.h */; }; + 225530DE1056BC7900FA646A /* pklib.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00A80D03542A00AB0B4E /* pklib.h */; }; + 225530DF1056BC7900FA646A /* StormCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00AB0D03542A00AB0B4E /* StormCommon.h */; }; + 225530E01056BC7900FA646A /* StormLib.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00B60D03542A00AB0B4E /* StormLib.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 225530E11056BC7900FA646A /* StormPort.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00B70D03542A00AB0B4E /* StormPort.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 225530E31056BC8700FA646A /* huff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED009C0D03542A00AB0B4E /* huff.cpp */; }; + 225530E61056BC8700FA646A /* explode.c in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00A60D03542A00AB0B4E /* explode.c */; }; + 225530E71056BC8700FA646A /* implode.c in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00A70D03542A00AB0B4E /* implode.c */; }; + 225530E81056BC8700FA646A /* SFileAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00A90D03542A00AB0B4E /* SFileAttributes.cpp */; }; + 225530E91056BC8700FA646A /* SBaseCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AA0D03542A00AB0B4E /* SBaseCommon.cpp */; }; + 225530EA1056BC8700FA646A /* SCompression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AC0D03542A00AB0B4E /* SCompression.cpp */; }; + 225530EB1056BC8700FA646A /* SFileCompactArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AD0D03542A00AB0B4E /* SFileCompactArchive.cpp */; }; + 225530EC1056BC8700FA646A /* SFileCreateArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AE0D03542A00AB0B4E /* SFileCreateArchive.cpp */; }; + 225530ED1056BC8700FA646A /* SFileExtractFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AF0D03542A00AB0B4E /* SFileExtractFile.cpp */; }; + 225530EE1056BC8700FA646A /* SFileFindFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B00D03542A00AB0B4E /* SFileFindFile.cpp */; }; + 225530EF1056BC8700FA646A /* SFileOpenArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B10D03542A00AB0B4E /* SFileOpenArchive.cpp */; }; + 225530F01056BC8700FA646A /* SFileOpenFileEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B20D03542A00AB0B4E /* SFileOpenFileEx.cpp */; }; + 225530F11056BC8700FA646A /* SFileReadFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B30D03542A00AB0B4E /* SFileReadFile.cpp */; }; + 225530F21056BC8700FA646A /* SFileListFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B40D03542A00AB0B4E /* SFileListFile.cpp */; }; + 225C734D1257CCC70009E8DA /* lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 225C734B1257CCC70009E8DA /* lookup.h */; }; + 225C734F1257CCC70009E8DA /* lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 225C734B1257CCC70009E8DA /* lookup.h */; }; + 225C73501257CCC70009E8DA /* lookup3.c in Sources */ = {isa = PBXBuildFile; fileRef = 225C734C1257CCC70009E8DA /* lookup3.c */; }; + 225C73541257CD0C0009E8DA /* SBaseFileTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 225C73531257CD0C0009E8DA /* SBaseFileTable.cpp */; }; + 225C73551257CD0C0009E8DA /* SBaseFileTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 225C73531257CD0C0009E8DA /* SBaseFileTable.cpp */; }; + 225C735A1257CD1F0009E8DA /* lookup3.c in Sources */ = {isa = PBXBuildFile; fileRef = 225C734C1257CCC70009E8DA /* lookup3.c */; }; + 225FAC9C0E53BAA100DA2CAE /* huff.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED009D0D03542A00AB0B4E /* huff.h */; }; + 225FAC9F0E53BAA100DA2CAE /* pklib.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00A80D03542A00AB0B4E /* pklib.h */; }; + 225FACA00E53BAA100DA2CAE /* StormCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00AB0D03542A00AB0B4E /* StormCommon.h */; }; + 225FACA10E53BAA100DA2CAE /* StormLib.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00B60D03542A00AB0B4E /* StormLib.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 225FACA20E53BAA100DA2CAE /* StormPort.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED00B70D03542A00AB0B4E /* StormPort.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 225FACA50E53BAB400DA2CAE /* huff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED009C0D03542A00AB0B4E /* huff.cpp */; }; + 225FACA90E53BAB400DA2CAE /* explode.c in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00A60D03542A00AB0B4E /* explode.c */; }; + 225FACAA0E53BAB400DA2CAE /* implode.c in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00A70D03542A00AB0B4E /* implode.c */; }; + 225FACAB0E53BAB400DA2CAE /* SFileAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00A90D03542A00AB0B4E /* SFileAttributes.cpp */; }; + 225FACAC0E53BAB400DA2CAE /* SBaseCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AA0D03542A00AB0B4E /* SBaseCommon.cpp */; }; + 225FACAD0E53BAB400DA2CAE /* SCompression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AC0D03542A00AB0B4E /* SCompression.cpp */; }; + 225FACAE0E53BAB400DA2CAE /* SFileCompactArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AD0D03542A00AB0B4E /* SFileCompactArchive.cpp */; }; + 225FACAF0E53BAB400DA2CAE /* SFileCreateArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AE0D03542A00AB0B4E /* SFileCreateArchive.cpp */; }; + 225FACB00E53BAB400DA2CAE /* SFileExtractFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00AF0D03542A00AB0B4E /* SFileExtractFile.cpp */; }; + 225FACB10E53BAB400DA2CAE /* SFileFindFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B00D03542A00AB0B4E /* SFileFindFile.cpp */; }; + 225FACB20E53BAB400DA2CAE /* SFileOpenArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B10D03542A00AB0B4E /* SFileOpenArchive.cpp */; }; + 225FACB30E53BAB400DA2CAE /* SFileOpenFileEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B20D03542A00AB0B4E /* SFileOpenFileEx.cpp */; }; + 225FACB40E53BAB400DA2CAE /* SFileReadFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B30D03542A00AB0B4E /* SFileReadFile.cpp */; }; + 225FACB50E53BAB400DA2CAE /* SFileListFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32ED00B40D03542A00AB0B4E /* SFileListFile.cpp */; }; + 225FADD40E53C06600DA2CAE /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 32D20A8A0CF3902D00230E7A /* libbz2.dylib */; settings = {ATTRIBUTES = (Required, ); }; }; + 225FADD50E53C06600DA2CAE /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 32D20A8B0CF3902D00230E7A /* libz.dylib */; settings = {ATTRIBUTES = (Required, ); }; }; + 228B538411BF7D0D001A58DA /* FileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 228B538311BF7D0D001A58DA /* FileStream.cpp */; }; + 228B538511BF7D0D001A58DA /* FileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 228B538311BF7D0D001A58DA /* FileStream.cpp */; }; + 22954AD211D463AB0064B264 /* Test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2295488911D45A820064B264 /* Test.cpp */; }; + 22954AD311D463B50064B264 /* libStormLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 225530D41056BAC800FA646A /* libStormLib.a */; }; + 22954AD611D463BE0064B264 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 32D20A8A0CF3902D00230E7A /* libbz2.dylib */; }; + 22954AD711D463BE0064B264 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 32D20A8B0CF3902D00230E7A /* libz.dylib */; }; + 2299D9D71167EFA8005C19BF /* adpcm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2299D9D51167EFA8005C19BF /* adpcm.cpp */; }; + 2299D9D81167EFA8005C19BF /* adpcm.h in Headers */ = {isa = PBXBuildFile; fileRef = 2299D9D61167EFA8005C19BF /* adpcm.h */; }; + 2299D9D91167EFA8005C19BF /* adpcm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2299D9D51167EFA8005C19BF /* adpcm.cpp */; }; + 2299D9DA1167EFA8005C19BF /* adpcm.h in Headers */ = {isa = PBXBuildFile; fileRef = 2299D9D61167EFA8005C19BF /* adpcm.h */; }; + 2299D9DE1167EFC6005C19BF /* sparse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2299D9DC1167EFC6005C19BF /* sparse.cpp */; }; + 2299D9DF1167EFC6005C19BF /* sparse.h in Headers */ = {isa = PBXBuildFile; fileRef = 2299D9DD1167EFC6005C19BF /* sparse.h */; }; + 2299D9E01167EFC6005C19BF /* sparse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2299D9DC1167EFC6005C19BF /* sparse.cpp */; }; + 2299D9E11167EFC6005C19BF /* sparse.h in Headers */ = {isa = PBXBuildFile; fileRef = 2299D9DD1167EFC6005C19BF /* sparse.h */; }; + 2299DA4E1167FD16005C19BF /* SFileAddFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2299DA4D1167FD16005C19BF /* SFileAddFile.cpp */; }; + 2299DA4F1167FD16005C19BF /* SFileAddFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2299DA4D1167FD16005C19BF /* SFileAddFile.cpp */; }; + 22AEA122123125D800359B16 /* SFilePatchArchives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22AEA121123125D800359B16 /* SFilePatchArchives.cpp */; }; + 22AEA123123125D800359B16 /* SFilePatchArchives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22AEA121123125D800359B16 /* SFilePatchArchives.cpp */; }; + 22C9187D11933FCF0083AC69 /* hash_memory.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9182B11933FCF0083AC69 /* hash_memory.c */; }; + 22C9187E11933FCF0083AC69 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9182C11933FCF0083AC69 /* md5.c */; }; + 22C9187F11933FCF0083AC69 /* sha1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9182D11933FCF0083AC69 /* sha1.c */; }; + 22C9188011933FCF0083AC69 /* tomcrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9182F11933FCF0083AC69 /* tomcrypt.h */; }; + 22C9188111933FCF0083AC69 /* tomcrypt_argchk.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183011933FCF0083AC69 /* tomcrypt_argchk.h */; }; + 22C9188211933FCF0083AC69 /* tomcrypt_cfg.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183111933FCF0083AC69 /* tomcrypt_cfg.h */; }; + 22C9188311933FCF0083AC69 /* tomcrypt_cipher.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183211933FCF0083AC69 /* tomcrypt_cipher.h */; }; + 22C9188411933FCF0083AC69 /* tomcrypt_custom.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183311933FCF0083AC69 /* tomcrypt_custom.h */; }; + 22C9188511933FCF0083AC69 /* tomcrypt_hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183411933FCF0083AC69 /* tomcrypt_hash.h */; }; + 22C9188611933FCF0083AC69 /* tomcrypt_mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183511933FCF0083AC69 /* tomcrypt_mac.h */; }; + 22C9188711933FCF0083AC69 /* tomcrypt_macros.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183611933FCF0083AC69 /* tomcrypt_macros.h */; }; + 22C9188811933FCF0083AC69 /* tomcrypt_math.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183711933FCF0083AC69 /* tomcrypt_math.h */; }; + 22C9188911933FCF0083AC69 /* tomcrypt_misc.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183811933FCF0083AC69 /* tomcrypt_misc.h */; }; + 22C9188A11933FCF0083AC69 /* tomcrypt_pk.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183911933FCF0083AC69 /* tomcrypt_pk.h */; }; + 22C9188B11933FCF0083AC69 /* tomcrypt_pkcs.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183A11933FCF0083AC69 /* tomcrypt_pkcs.h */; }; + 22C9188C11933FCF0083AC69 /* tomcrypt_prng.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183B11933FCF0083AC69 /* tomcrypt_prng.h */; }; + 22C9188D11933FCF0083AC69 /* ltm_desc.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9183D11933FCF0083AC69 /* ltm_desc.c */; }; + 22C9188E11933FCF0083AC69 /* multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9183E11933FCF0083AC69 /* multi.c */; }; + 22C9188F11933FCF0083AC69 /* rand_prime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9183F11933FCF0083AC69 /* rand_prime.c */; }; + 22C9189011933FCF0083AC69 /* base64_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184111933FCF0083AC69 /* base64_decode.c */; }; + 22C9189111933FCF0083AC69 /* crypt_argchk.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184211933FCF0083AC69 /* crypt_argchk.c */; }; + 22C9189211933FCF0083AC69 /* crypt_find_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184311933FCF0083AC69 /* crypt_find_hash.c */; }; + 22C9189311933FCF0083AC69 /* crypt_find_prng.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184411933FCF0083AC69 /* crypt_find_prng.c */; }; + 22C9189411933FCF0083AC69 /* crypt_hash_descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184511933FCF0083AC69 /* crypt_hash_descriptor.c */; }; + 22C9189511933FCF0083AC69 /* crypt_hash_is_valid.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184611933FCF0083AC69 /* crypt_hash_is_valid.c */; }; + 22C9189611933FCF0083AC69 /* crypt_libc.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184711933FCF0083AC69 /* crypt_libc.c */; }; + 22C9189811933FCF0083AC69 /* crypt_prng_descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184911933FCF0083AC69 /* crypt_prng_descriptor.c */; }; + 22C9189911933FCF0083AC69 /* crypt_prng_is_valid.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184A11933FCF0083AC69 /* crypt_prng_is_valid.c */; }; + 22C9189A11933FCF0083AC69 /* crypt_register_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184B11933FCF0083AC69 /* crypt_register_hash.c */; }; + 22C9189B11933FCF0083AC69 /* crypt_register_prng.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184C11933FCF0083AC69 /* crypt_register_prng.c */; }; + 22C9189C11933FCF0083AC69 /* zeromem.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184D11933FCF0083AC69 /* zeromem.c */; }; + 22C9189D11933FCF0083AC69 /* der_decode_bit_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185011933FCF0083AC69 /* der_decode_bit_string.c */; }; + 22C9189E11933FCF0083AC69 /* der_decode_boolean.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185111933FCF0083AC69 /* der_decode_boolean.c */; }; + 22C9189F11933FCF0083AC69 /* der_decode_choice.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185211933FCF0083AC69 /* der_decode_choice.c */; }; + 22C918A011933FCF0083AC69 /* der_decode_ia5_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185311933FCF0083AC69 /* der_decode_ia5_string.c */; }; + 22C918A111933FCF0083AC69 /* der_decode_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185411933FCF0083AC69 /* der_decode_integer.c */; }; + 22C918A211933FCF0083AC69 /* der_decode_object_identifier.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185511933FCF0083AC69 /* der_decode_object_identifier.c */; }; + 22C918A311933FCF0083AC69 /* der_decode_octet_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185611933FCF0083AC69 /* der_decode_octet_string.c */; }; + 22C918A411933FCF0083AC69 /* der_decode_printable_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185711933FCF0083AC69 /* der_decode_printable_string.c */; }; + 22C918A511933FCF0083AC69 /* der_decode_sequence_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185811933FCF0083AC69 /* der_decode_sequence_ex.c */; }; + 22C918A611933FCF0083AC69 /* der_decode_sequence_flexi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185911933FCF0083AC69 /* der_decode_sequence_flexi.c */; }; + 22C918A711933FCF0083AC69 /* der_decode_sequence_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185A11933FCF0083AC69 /* der_decode_sequence_multi.c */; }; + 22C918A811933FCF0083AC69 /* der_decode_short_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185B11933FCF0083AC69 /* der_decode_short_integer.c */; }; + 22C918A911933FCF0083AC69 /* der_decode_utctime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185C11933FCF0083AC69 /* der_decode_utctime.c */; }; + 22C918AA11933FCF0083AC69 /* der_decode_utf8_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185D11933FCF0083AC69 /* der_decode_utf8_string.c */; }; + 22C918AB11933FCF0083AC69 /* der_length_bit_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185E11933FCF0083AC69 /* der_length_bit_string.c */; }; + 22C918AC11933FCF0083AC69 /* der_length_boolean.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185F11933FCF0083AC69 /* der_length_boolean.c */; }; + 22C918AD11933FCF0083AC69 /* der_length_ia5_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186011933FCF0083AC69 /* der_length_ia5_string.c */; }; + 22C918AE11933FCF0083AC69 /* der_length_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186111933FCF0083AC69 /* der_length_integer.c */; }; + 22C918AF11933FCF0083AC69 /* der_length_object_identifier.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186211933FCF0083AC69 /* der_length_object_identifier.c */; }; + 22C918B011933FCF0083AC69 /* der_length_octet_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186311933FCF0083AC69 /* der_length_octet_string.c */; }; + 22C918B111933FCF0083AC69 /* der_length_printable_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186411933FCF0083AC69 /* der_length_printable_string.c */; }; + 22C918B211933FCF0083AC69 /* der_length_sequence.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186511933FCF0083AC69 /* der_length_sequence.c */; }; + 22C918B311933FCF0083AC69 /* der_length_short_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186611933FCF0083AC69 /* der_length_short_integer.c */; }; + 22C918B411933FCF0083AC69 /* der_length_utctime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186711933FCF0083AC69 /* der_length_utctime.c */; }; + 22C918B511933FCF0083AC69 /* der_length_utf8_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186811933FCF0083AC69 /* der_length_utf8_string.c */; }; + 22C918B611933FCF0083AC69 /* der_sequence_free.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186911933FCF0083AC69 /* der_sequence_free.c */; }; + 22C918B711933FCF0083AC69 /* ltc_ecc_map.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186B11933FCF0083AC69 /* ltc_ecc_map.c */; }; + 22C918B811933FCF0083AC69 /* ltc_ecc_mul2add.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186C11933FCF0083AC69 /* ltc_ecc_mul2add.c */; }; + 22C918B911933FCF0083AC69 /* ltc_ecc_mulmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186D11933FCF0083AC69 /* ltc_ecc_mulmod.c */; }; + 22C918BA11933FCF0083AC69 /* ltc_ecc_points.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186E11933FCF0083AC69 /* ltc_ecc_points.c */; }; + 22C918BB11933FCF0083AC69 /* ltc_ecc_projective_add_point.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186F11933FCF0083AC69 /* ltc_ecc_projective_add_point.c */; }; + 22C918BC11933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187011933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c */; }; + 22C918BD11933FCF0083AC69 /* pkcs_1_mgf1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187211933FCF0083AC69 /* pkcs_1_mgf1.c */; }; + 22C918BE11933FCF0083AC69 /* pkcs_1_oaep_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187311933FCF0083AC69 /* pkcs_1_oaep_decode.c */; }; + 22C918BF11933FCF0083AC69 /* pkcs_1_pss_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187411933FCF0083AC69 /* pkcs_1_pss_decode.c */; }; + 22C918C011933FCF0083AC69 /* pkcs_1_v1_5_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187511933FCF0083AC69 /* pkcs_1_v1_5_decode.c */; }; + 22C918C111933FCF0083AC69 /* rsa_exptmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187711933FCF0083AC69 /* rsa_exptmod.c */; }; + 22C918C211933FCF0083AC69 /* rsa_free.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187811933FCF0083AC69 /* rsa_free.c */; }; + 22C918C311933FCF0083AC69 /* rsa_import.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187911933FCF0083AC69 /* rsa_import.c */; }; + 22C918C411933FCF0083AC69 /* rsa_make_key.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187A11933FCF0083AC69 /* rsa_make_key.c */; }; + 22C918C511933FCF0083AC69 /* rsa_verify_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187B11933FCF0083AC69 /* rsa_verify_hash.c */; }; + 22C918C611933FCF0083AC69 /* rsa_verify_simple.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187C11933FCF0083AC69 /* rsa_verify_simple.c */; }; + 22C918C711933FCF0083AC69 /* hash_memory.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9182B11933FCF0083AC69 /* hash_memory.c */; }; + 22C918C811933FCF0083AC69 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9182C11933FCF0083AC69 /* md5.c */; }; + 22C918C911933FCF0083AC69 /* sha1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9182D11933FCF0083AC69 /* sha1.c */; }; + 22C918CA11933FCF0083AC69 /* tomcrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9182F11933FCF0083AC69 /* tomcrypt.h */; }; + 22C918CB11933FCF0083AC69 /* tomcrypt_argchk.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183011933FCF0083AC69 /* tomcrypt_argchk.h */; }; + 22C918CC11933FCF0083AC69 /* tomcrypt_cfg.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183111933FCF0083AC69 /* tomcrypt_cfg.h */; }; + 22C918CD11933FCF0083AC69 /* tomcrypt_cipher.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183211933FCF0083AC69 /* tomcrypt_cipher.h */; }; + 22C918CE11933FCF0083AC69 /* tomcrypt_custom.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183311933FCF0083AC69 /* tomcrypt_custom.h */; }; + 22C918CF11933FCF0083AC69 /* tomcrypt_hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183411933FCF0083AC69 /* tomcrypt_hash.h */; }; + 22C918D011933FCF0083AC69 /* tomcrypt_mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183511933FCF0083AC69 /* tomcrypt_mac.h */; }; + 22C918D111933FCF0083AC69 /* tomcrypt_macros.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183611933FCF0083AC69 /* tomcrypt_macros.h */; }; + 22C918D211933FCF0083AC69 /* tomcrypt_math.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183711933FCF0083AC69 /* tomcrypt_math.h */; }; + 22C918D311933FCF0083AC69 /* tomcrypt_misc.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183811933FCF0083AC69 /* tomcrypt_misc.h */; }; + 22C918D411933FCF0083AC69 /* tomcrypt_pk.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183911933FCF0083AC69 /* tomcrypt_pk.h */; }; + 22C918D511933FCF0083AC69 /* tomcrypt_pkcs.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183A11933FCF0083AC69 /* tomcrypt_pkcs.h */; }; + 22C918D611933FCF0083AC69 /* tomcrypt_prng.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C9183B11933FCF0083AC69 /* tomcrypt_prng.h */; }; + 22C918D711933FCF0083AC69 /* ltm_desc.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9183D11933FCF0083AC69 /* ltm_desc.c */; }; + 22C918D811933FCF0083AC69 /* multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9183E11933FCF0083AC69 /* multi.c */; }; + 22C918D911933FCF0083AC69 /* rand_prime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9183F11933FCF0083AC69 /* rand_prime.c */; }; + 22C918DA11933FCF0083AC69 /* base64_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184111933FCF0083AC69 /* base64_decode.c */; }; + 22C918DB11933FCF0083AC69 /* crypt_argchk.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184211933FCF0083AC69 /* crypt_argchk.c */; }; + 22C918DC11933FCF0083AC69 /* crypt_find_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184311933FCF0083AC69 /* crypt_find_hash.c */; }; + 22C918DD11933FCF0083AC69 /* crypt_find_prng.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184411933FCF0083AC69 /* crypt_find_prng.c */; }; + 22C918DE11933FCF0083AC69 /* crypt_hash_descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184511933FCF0083AC69 /* crypt_hash_descriptor.c */; }; + 22C918DF11933FCF0083AC69 /* crypt_hash_is_valid.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184611933FCF0083AC69 /* crypt_hash_is_valid.c */; }; + 22C918E011933FCF0083AC69 /* crypt_libc.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184711933FCF0083AC69 /* crypt_libc.c */; }; + 22C918E111933FCF0083AC69 /* crypt_ltc_mp_descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184811933FCF0083AC69 /* crypt_ltc_mp_descriptor.c */; }; + 22C918E211933FCF0083AC69 /* crypt_prng_descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184911933FCF0083AC69 /* crypt_prng_descriptor.c */; }; + 22C918E311933FCF0083AC69 /* crypt_prng_is_valid.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184A11933FCF0083AC69 /* crypt_prng_is_valid.c */; }; + 22C918E411933FCF0083AC69 /* crypt_register_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184B11933FCF0083AC69 /* crypt_register_hash.c */; }; + 22C918E511933FCF0083AC69 /* crypt_register_prng.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184C11933FCF0083AC69 /* crypt_register_prng.c */; }; + 22C918E611933FCF0083AC69 /* zeromem.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9184D11933FCF0083AC69 /* zeromem.c */; }; + 22C918E711933FCF0083AC69 /* der_decode_bit_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185011933FCF0083AC69 /* der_decode_bit_string.c */; }; + 22C918E811933FCF0083AC69 /* der_decode_boolean.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185111933FCF0083AC69 /* der_decode_boolean.c */; }; + 22C918E911933FCF0083AC69 /* der_decode_choice.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185211933FCF0083AC69 /* der_decode_choice.c */; }; + 22C918EA11933FCF0083AC69 /* der_decode_ia5_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185311933FCF0083AC69 /* der_decode_ia5_string.c */; }; + 22C918EB11933FCF0083AC69 /* der_decode_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185411933FCF0083AC69 /* der_decode_integer.c */; }; + 22C918EC11933FCF0083AC69 /* der_decode_object_identifier.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185511933FCF0083AC69 /* der_decode_object_identifier.c */; }; + 22C918ED11933FCF0083AC69 /* der_decode_octet_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185611933FCF0083AC69 /* der_decode_octet_string.c */; }; + 22C918EE11933FCF0083AC69 /* der_decode_printable_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185711933FCF0083AC69 /* der_decode_printable_string.c */; }; + 22C918EF11933FCF0083AC69 /* der_decode_sequence_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185811933FCF0083AC69 /* der_decode_sequence_ex.c */; }; + 22C918F011933FCF0083AC69 /* der_decode_sequence_flexi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185911933FCF0083AC69 /* der_decode_sequence_flexi.c */; }; + 22C918F111933FCF0083AC69 /* der_decode_sequence_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185A11933FCF0083AC69 /* der_decode_sequence_multi.c */; }; + 22C918F211933FCF0083AC69 /* der_decode_short_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185B11933FCF0083AC69 /* der_decode_short_integer.c */; }; + 22C918F311933FCF0083AC69 /* der_decode_utctime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185C11933FCF0083AC69 /* der_decode_utctime.c */; }; + 22C918F411933FCF0083AC69 /* der_decode_utf8_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185D11933FCF0083AC69 /* der_decode_utf8_string.c */; }; + 22C918F511933FCF0083AC69 /* der_length_bit_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185E11933FCF0083AC69 /* der_length_bit_string.c */; }; + 22C918F611933FCF0083AC69 /* der_length_boolean.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9185F11933FCF0083AC69 /* der_length_boolean.c */; }; + 22C918F711933FCF0083AC69 /* der_length_ia5_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186011933FCF0083AC69 /* der_length_ia5_string.c */; }; + 22C918F811933FCF0083AC69 /* der_length_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186111933FCF0083AC69 /* der_length_integer.c */; }; + 22C918F911933FCF0083AC69 /* der_length_object_identifier.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186211933FCF0083AC69 /* der_length_object_identifier.c */; }; + 22C918FA11933FCF0083AC69 /* der_length_octet_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186311933FCF0083AC69 /* der_length_octet_string.c */; }; + 22C918FB11933FCF0083AC69 /* der_length_printable_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186411933FCF0083AC69 /* der_length_printable_string.c */; }; + 22C918FC11933FCF0083AC69 /* der_length_sequence.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186511933FCF0083AC69 /* der_length_sequence.c */; }; + 22C918FD11933FCF0083AC69 /* der_length_short_integer.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186611933FCF0083AC69 /* der_length_short_integer.c */; }; + 22C918FE11933FCF0083AC69 /* der_length_utctime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186711933FCF0083AC69 /* der_length_utctime.c */; }; + 22C918FF11933FCF0083AC69 /* der_length_utf8_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186811933FCF0083AC69 /* der_length_utf8_string.c */; }; + 22C9190011933FCF0083AC69 /* der_sequence_free.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186911933FCF0083AC69 /* der_sequence_free.c */; }; + 22C9190111933FCF0083AC69 /* ltc_ecc_map.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186B11933FCF0083AC69 /* ltc_ecc_map.c */; }; + 22C9190211933FCF0083AC69 /* ltc_ecc_mul2add.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186C11933FCF0083AC69 /* ltc_ecc_mul2add.c */; }; + 22C9190311933FCF0083AC69 /* ltc_ecc_mulmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186D11933FCF0083AC69 /* ltc_ecc_mulmod.c */; }; + 22C9190411933FCF0083AC69 /* ltc_ecc_points.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186E11933FCF0083AC69 /* ltc_ecc_points.c */; }; + 22C9190511933FCF0083AC69 /* ltc_ecc_projective_add_point.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9186F11933FCF0083AC69 /* ltc_ecc_projective_add_point.c */; }; + 22C9190611933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187011933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c */; }; + 22C9190711933FCF0083AC69 /* pkcs_1_mgf1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187211933FCF0083AC69 /* pkcs_1_mgf1.c */; }; + 22C9190811933FCF0083AC69 /* pkcs_1_oaep_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187311933FCF0083AC69 /* pkcs_1_oaep_decode.c */; }; + 22C9190911933FCF0083AC69 /* pkcs_1_pss_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187411933FCF0083AC69 /* pkcs_1_pss_decode.c */; }; + 22C9190A11933FCF0083AC69 /* pkcs_1_v1_5_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187511933FCF0083AC69 /* pkcs_1_v1_5_decode.c */; }; + 22C9190B11933FCF0083AC69 /* rsa_exptmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187711933FCF0083AC69 /* rsa_exptmod.c */; }; + 22C9190C11933FCF0083AC69 /* rsa_free.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187811933FCF0083AC69 /* rsa_free.c */; }; + 22C9190D11933FCF0083AC69 /* rsa_import.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187911933FCF0083AC69 /* rsa_import.c */; }; + 22C9190E11933FCF0083AC69 /* rsa_make_key.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187A11933FCF0083AC69 /* rsa_make_key.c */; }; + 22C9190F11933FCF0083AC69 /* rsa_verify_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187B11933FCF0083AC69 /* rsa_verify_hash.c */; }; + 22C9191011933FCF0083AC69 /* rsa_verify_simple.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9187C11933FCF0083AC69 /* rsa_verify_simple.c */; }; + 22C9198A1193400A0083AC69 /* bn_fast_mp_invmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919111193400A0083AC69 /* bn_fast_mp_invmod.c */; }; + 22C9198B1193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919121193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c */; }; + 22C9198C1193400A0083AC69 /* bn_fast_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919131193400A0083AC69 /* bn_fast_s_mp_mul_digs.c */; }; + 22C9198D1193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919141193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c */; }; + 22C9198E1193400A0083AC69 /* bn_fast_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919151193400A0083AC69 /* bn_fast_s_mp_sqr.c */; }; + 22C9198F1193400A0083AC69 /* bn_mp_2expt.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919161193400A0083AC69 /* bn_mp_2expt.c */; }; + 22C919901193400A0083AC69 /* bn_mp_abs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919171193400A0083AC69 /* bn_mp_abs.c */; }; + 22C919911193400A0083AC69 /* bn_mp_add_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919181193400A0083AC69 /* bn_mp_add_d.c */; }; + 22C919921193400A0083AC69 /* bn_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919191193400A0083AC69 /* bn_mp_add.c */; }; + 22C919931193400A0083AC69 /* bn_mp_addmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191A1193400A0083AC69 /* bn_mp_addmod.c */; }; + 22C919941193400A0083AC69 /* bn_mp_and.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191B1193400A0083AC69 /* bn_mp_and.c */; }; + 22C919951193400A0083AC69 /* bn_mp_clamp.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191C1193400A0083AC69 /* bn_mp_clamp.c */; }; + 22C919961193400A0083AC69 /* bn_mp_clear_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191D1193400A0083AC69 /* bn_mp_clear_multi.c */; }; + 22C919971193400A0083AC69 /* bn_mp_clear.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191E1193400A0083AC69 /* bn_mp_clear.c */; }; + 22C919981193400A0083AC69 /* bn_mp_cmp_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191F1193400A0083AC69 /* bn_mp_cmp_d.c */; }; + 22C919991193400A0083AC69 /* bn_mp_cmp_mag.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919201193400A0083AC69 /* bn_mp_cmp_mag.c */; }; + 22C9199A1193400A0083AC69 /* bn_mp_cmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919211193400A0083AC69 /* bn_mp_cmp.c */; }; + 22C9199B1193400A0083AC69 /* bn_mp_cnt_lsb.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919221193400A0083AC69 /* bn_mp_cnt_lsb.c */; }; + 22C9199C1193400A0083AC69 /* bn_mp_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919231193400A0083AC69 /* bn_mp_copy.c */; }; + 22C9199D1193400A0083AC69 /* bn_mp_count_bits.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919241193400A0083AC69 /* bn_mp_count_bits.c */; }; + 22C9199E1193400A0083AC69 /* bn_mp_div_2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919251193400A0083AC69 /* bn_mp_div_2.c */; }; + 22C9199F1193400A0083AC69 /* bn_mp_div_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919261193400A0083AC69 /* bn_mp_div_2d.c */; }; + 22C919A01193400A0083AC69 /* bn_mp_div_3.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919271193400A0083AC69 /* bn_mp_div_3.c */; }; + 22C919A11193400A0083AC69 /* bn_mp_div_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919281193400A0083AC69 /* bn_mp_div_d.c */; }; + 22C919A21193400A0083AC69 /* bn_mp_div.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919291193400A0083AC69 /* bn_mp_div.c */; }; + 22C919A31193400A0083AC69 /* bn_mp_dr_is_modulus.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192A1193400A0083AC69 /* bn_mp_dr_is_modulus.c */; }; + 22C919A41193400A0083AC69 /* bn_mp_dr_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192B1193400A0083AC69 /* bn_mp_dr_reduce.c */; }; + 22C919A51193400A0083AC69 /* bn_mp_dr_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192C1193400A0083AC69 /* bn_mp_dr_setup.c */; }; + 22C919A61193400A0083AC69 /* bn_mp_exch.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192D1193400A0083AC69 /* bn_mp_exch.c */; }; + 22C919A71193400A0083AC69 /* bn_mp_expt_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192E1193400A0083AC69 /* bn_mp_expt_d.c */; }; + 22C919A81193400A0083AC69 /* bn_mp_exptmod_fast.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192F1193400A0083AC69 /* bn_mp_exptmod_fast.c */; }; + 22C919A91193400A0083AC69 /* bn_mp_exptmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919301193400A0083AC69 /* bn_mp_exptmod.c */; }; + 22C919AA1193400A0083AC69 /* bn_mp_exteuclid.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919311193400A0083AC69 /* bn_mp_exteuclid.c */; }; + 22C919AB1193400A0083AC69 /* bn_mp_fread.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919321193400A0083AC69 /* bn_mp_fread.c */; }; + 22C919AC1193400A0083AC69 /* bn_mp_fwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919331193400A0083AC69 /* bn_mp_fwrite.c */; }; + 22C919AD1193400A0083AC69 /* bn_mp_gcd.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919341193400A0083AC69 /* bn_mp_gcd.c */; }; + 22C919AE1193400A0083AC69 /* bn_mp_get_int.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919351193400A0083AC69 /* bn_mp_get_int.c */; }; + 22C919AF1193400A0083AC69 /* bn_mp_grow.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919361193400A0083AC69 /* bn_mp_grow.c */; }; + 22C919B01193400A0083AC69 /* bn_mp_init_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919371193400A0083AC69 /* bn_mp_init_copy.c */; }; + 22C919B11193400A0083AC69 /* bn_mp_init_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919381193400A0083AC69 /* bn_mp_init_multi.c */; }; + 22C919B21193400A0083AC69 /* bn_mp_init_set_int.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919391193400A0083AC69 /* bn_mp_init_set_int.c */; }; + 22C919B31193400A0083AC69 /* bn_mp_init_set.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193A1193400A0083AC69 /* bn_mp_init_set.c */; }; + 22C919B41193400A0083AC69 /* bn_mp_init_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193B1193400A0083AC69 /* bn_mp_init_size.c */; }; + 22C919B51193400A0083AC69 /* bn_mp_init.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193C1193400A0083AC69 /* bn_mp_init.c */; }; + 22C919B61193400A0083AC69 /* bn_mp_invmod_slow.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193D1193400A0083AC69 /* bn_mp_invmod_slow.c */; }; + 22C919B71193400A0083AC69 /* bn_mp_invmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193E1193400A0083AC69 /* bn_mp_invmod.c */; }; + 22C919B81193400A0083AC69 /* bn_mp_is_square.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193F1193400A0083AC69 /* bn_mp_is_square.c */; }; + 22C919B91193400A0083AC69 /* bn_mp_jacobi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919401193400A0083AC69 /* bn_mp_jacobi.c */; }; + 22C919BA1193400A0083AC69 /* bn_mp_karatsuba_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919411193400A0083AC69 /* bn_mp_karatsuba_mul.c */; }; + 22C919BB1193400A0083AC69 /* bn_mp_karatsuba_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919421193400A0083AC69 /* bn_mp_karatsuba_sqr.c */; }; + 22C919BC1193400A0083AC69 /* bn_mp_lcm.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919431193400A0083AC69 /* bn_mp_lcm.c */; }; + 22C919BD1193400A0083AC69 /* bn_mp_lshd.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919441193400A0083AC69 /* bn_mp_lshd.c */; }; + 22C919BE1193400A0083AC69 /* bn_mp_mod_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919451193400A0083AC69 /* bn_mp_mod_2d.c */; }; + 22C919BF1193400A0083AC69 /* bn_mp_mod_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919461193400A0083AC69 /* bn_mp_mod_d.c */; }; + 22C919C01193400A0083AC69 /* bn_mp_mod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919471193400A0083AC69 /* bn_mp_mod.c */; }; + 22C919C11193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919481193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c */; }; + 22C919C21193400A0083AC69 /* bn_mp_montgomery_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919491193400A0083AC69 /* bn_mp_montgomery_reduce.c */; }; + 22C919C31193400A0083AC69 /* bn_mp_montgomery_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194A1193400A0083AC69 /* bn_mp_montgomery_setup.c */; }; + 22C919C41193400A0083AC69 /* bn_mp_mul_2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194B1193400A0083AC69 /* bn_mp_mul_2.c */; }; + 22C919C51193400A0083AC69 /* bn_mp_mul_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194C1193400A0083AC69 /* bn_mp_mul_2d.c */; }; + 22C919C61193400A0083AC69 /* bn_mp_mul_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194D1193400A0083AC69 /* bn_mp_mul_d.c */; }; + 22C919C71193400A0083AC69 /* bn_mp_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194E1193400A0083AC69 /* bn_mp_mul.c */; }; + 22C919C81193400A0083AC69 /* bn_mp_mulmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194F1193400A0083AC69 /* bn_mp_mulmod.c */; }; + 22C919C91193400A0083AC69 /* bn_mp_n_root.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919501193400A0083AC69 /* bn_mp_n_root.c */; }; + 22C919CA1193400A0083AC69 /* bn_mp_neg.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919511193400A0083AC69 /* bn_mp_neg.c */; }; + 22C919CB1193400A0083AC69 /* bn_mp_or.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919521193400A0083AC69 /* bn_mp_or.c */; }; + 22C919CC1193400A0083AC69 /* bn_mp_prime_fermat.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919531193400A0083AC69 /* bn_mp_prime_fermat.c */; }; + 22C919CD1193400A0083AC69 /* bn_mp_prime_is_divisible.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919541193400A0083AC69 /* bn_mp_prime_is_divisible.c */; }; + 22C919CE1193400A0083AC69 /* bn_mp_prime_is_prime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919551193400A0083AC69 /* bn_mp_prime_is_prime.c */; }; + 22C919CF1193400A0083AC69 /* bn_mp_prime_miller_rabin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919561193400A0083AC69 /* bn_mp_prime_miller_rabin.c */; }; + 22C919D01193400A0083AC69 /* bn_mp_prime_next_prime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919571193400A0083AC69 /* bn_mp_prime_next_prime.c */; }; + 22C919D11193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919581193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c */; }; + 22C919D21193400A0083AC69 /* bn_mp_prime_random_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919591193400A0083AC69 /* bn_mp_prime_random_ex.c */; }; + 22C919D31193400A0083AC69 /* bn_mp_radix_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195A1193400A0083AC69 /* bn_mp_radix_size.c */; }; + 22C919D41193400A0083AC69 /* bn_mp_radix_smap.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195B1193400A0083AC69 /* bn_mp_radix_smap.c */; }; + 22C919D51193400A0083AC69 /* bn_mp_rand.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195C1193400A0083AC69 /* bn_mp_rand.c */; }; + 22C919D61193400A0083AC69 /* bn_mp_read_radix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195D1193400A0083AC69 /* bn_mp_read_radix.c */; }; + 22C919D71193400A0083AC69 /* bn_mp_read_signed_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195E1193400A0083AC69 /* bn_mp_read_signed_bin.c */; }; + 22C919D81193400A0083AC69 /* bn_mp_read_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195F1193400A0083AC69 /* bn_mp_read_unsigned_bin.c */; }; + 22C919D91193400A0083AC69 /* bn_mp_reduce_2k_l.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919601193400A0083AC69 /* bn_mp_reduce_2k_l.c */; }; + 22C919DA1193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919611193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c */; }; + 22C919DB1193400A0083AC69 /* bn_mp_reduce_2k_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919621193400A0083AC69 /* bn_mp_reduce_2k_setup.c */; }; + 22C919DC1193400A0083AC69 /* bn_mp_reduce_2k.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919631193400A0083AC69 /* bn_mp_reduce_2k.c */; }; + 22C919DD1193400A0083AC69 /* bn_mp_reduce_is_2k_l.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919641193400A0083AC69 /* bn_mp_reduce_is_2k_l.c */; }; + 22C919DE1193400A0083AC69 /* bn_mp_reduce_is_2k.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919651193400A0083AC69 /* bn_mp_reduce_is_2k.c */; }; + 22C919DF1193400A0083AC69 /* bn_mp_reduce_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919661193400A0083AC69 /* bn_mp_reduce_setup.c */; }; + 22C919E01193400A0083AC69 /* bn_mp_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919671193400A0083AC69 /* bn_mp_reduce.c */; }; + 22C919E11193400A0083AC69 /* bn_mp_rshd.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919681193400A0083AC69 /* bn_mp_rshd.c */; }; + 22C919E21193400A0083AC69 /* bn_mp_set_int.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919691193400A0083AC69 /* bn_mp_set_int.c */; }; + 22C919E31193400A0083AC69 /* bn_mp_set.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196A1193400A0083AC69 /* bn_mp_set.c */; }; + 22C919E41193400A0083AC69 /* bn_mp_shrink.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196B1193400A0083AC69 /* bn_mp_shrink.c */; }; + 22C919E51193400A0083AC69 /* bn_mp_signed_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196C1193400A0083AC69 /* bn_mp_signed_bin_size.c */; }; + 22C919E61193400A0083AC69 /* bn_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196D1193400A0083AC69 /* bn_mp_sqr.c */; }; + 22C919E71193400A0083AC69 /* bn_mp_sqrmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196E1193400A0083AC69 /* bn_mp_sqrmod.c */; }; + 22C919E81193400A0083AC69 /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196F1193400A0083AC69 /* bn_mp_sqrt.c */; }; + 22C919E91193400A0083AC69 /* bn_mp_sub_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919701193400A0083AC69 /* bn_mp_sub_d.c */; }; + 22C919EA1193400A0083AC69 /* bn_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919711193400A0083AC69 /* bn_mp_sub.c */; }; + 22C919EB1193400A0083AC69 /* bn_mp_submod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919721193400A0083AC69 /* bn_mp_submod.c */; }; + 22C919EC1193400A0083AC69 /* bn_mp_to_signed_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919731193400A0083AC69 /* bn_mp_to_signed_bin_n.c */; }; + 22C919ED1193400A0083AC69 /* bn_mp_to_signed_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919741193400A0083AC69 /* bn_mp_to_signed_bin.c */; }; + 22C919EE1193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919751193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c */; }; + 22C919EF1193400A0083AC69 /* bn_mp_to_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919761193400A0083AC69 /* bn_mp_to_unsigned_bin.c */; }; + 22C919F01193400A0083AC69 /* bn_mp_toom_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919771193400A0083AC69 /* bn_mp_toom_mul.c */; }; + 22C919F11193400A0083AC69 /* bn_mp_toom_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919781193400A0083AC69 /* bn_mp_toom_sqr.c */; }; + 22C919F21193400A0083AC69 /* bn_mp_toradix_n.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919791193400A0083AC69 /* bn_mp_toradix_n.c */; }; + 22C919F31193400A0083AC69 /* bn_mp_toradix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197A1193400A0083AC69 /* bn_mp_toradix.c */; }; + 22C919F41193400A0083AC69 /* bn_mp_unsigned_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197B1193400A0083AC69 /* bn_mp_unsigned_bin_size.c */; }; + 22C919F51193400A0083AC69 /* bn_mp_xor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197C1193400A0083AC69 /* bn_mp_xor.c */; }; + 22C919F61193400A0083AC69 /* bn_mp_zero.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197D1193400A0083AC69 /* bn_mp_zero.c */; }; + 22C919F71193400A0083AC69 /* bn_prime_tab.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197E1193400A0083AC69 /* bn_prime_tab.c */; }; + 22C919F81193400A0083AC69 /* bn_reverse.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197F1193400A0083AC69 /* bn_reverse.c */; }; + 22C919F91193400A0083AC69 /* bn_s_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919801193400A0083AC69 /* bn_s_mp_add.c */; }; + 22C919FA1193400A0083AC69 /* bn_s_mp_exptmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919811193400A0083AC69 /* bn_s_mp_exptmod.c */; }; + 22C919FB1193400A0083AC69 /* bn_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919821193400A0083AC69 /* bn_s_mp_mul_digs.c */; }; + 22C919FC1193400A0083AC69 /* bn_s_mp_mul_high_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919831193400A0083AC69 /* bn_s_mp_mul_high_digs.c */; }; + 22C919FD1193400A0083AC69 /* bn_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919841193400A0083AC69 /* bn_s_mp_sqr.c */; }; + 22C919FE1193400A0083AC69 /* bn_s_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919851193400A0083AC69 /* bn_s_mp_sub.c */; }; + 22C919FF1193400A0083AC69 /* bncore.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919861193400A0083AC69 /* bncore.c */; }; + 22C91A001193400A0083AC69 /* tommath_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C919871193400A0083AC69 /* tommath_class.h */; }; + 22C91A011193400A0083AC69 /* tommath_superclass.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C919881193400A0083AC69 /* tommath_superclass.h */; }; + 22C91A021193400A0083AC69 /* tommath.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C919891193400A0083AC69 /* tommath.h */; }; + 22C91A031193400A0083AC69 /* bn_fast_mp_invmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919111193400A0083AC69 /* bn_fast_mp_invmod.c */; }; + 22C91A041193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919121193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c */; }; + 22C91A051193400A0083AC69 /* bn_fast_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919131193400A0083AC69 /* bn_fast_s_mp_mul_digs.c */; }; + 22C91A061193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919141193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c */; }; + 22C91A071193400A0083AC69 /* bn_fast_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919151193400A0083AC69 /* bn_fast_s_mp_sqr.c */; }; + 22C91A081193400A0083AC69 /* bn_mp_2expt.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919161193400A0083AC69 /* bn_mp_2expt.c */; }; + 22C91A091193400A0083AC69 /* bn_mp_abs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919171193400A0083AC69 /* bn_mp_abs.c */; }; + 22C91A0A1193400A0083AC69 /* bn_mp_add_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919181193400A0083AC69 /* bn_mp_add_d.c */; }; + 22C91A0B1193400A0083AC69 /* bn_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919191193400A0083AC69 /* bn_mp_add.c */; }; + 22C91A0C1193400A0083AC69 /* bn_mp_addmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191A1193400A0083AC69 /* bn_mp_addmod.c */; }; + 22C91A0D1193400A0083AC69 /* bn_mp_and.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191B1193400A0083AC69 /* bn_mp_and.c */; }; + 22C91A0E1193400A0083AC69 /* bn_mp_clamp.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191C1193400A0083AC69 /* bn_mp_clamp.c */; }; + 22C91A0F1193400A0083AC69 /* bn_mp_clear_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191D1193400A0083AC69 /* bn_mp_clear_multi.c */; }; + 22C91A101193400A0083AC69 /* bn_mp_clear.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191E1193400A0083AC69 /* bn_mp_clear.c */; }; + 22C91A111193400A0083AC69 /* bn_mp_cmp_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9191F1193400A0083AC69 /* bn_mp_cmp_d.c */; }; + 22C91A121193400A0083AC69 /* bn_mp_cmp_mag.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919201193400A0083AC69 /* bn_mp_cmp_mag.c */; }; + 22C91A131193400A0083AC69 /* bn_mp_cmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919211193400A0083AC69 /* bn_mp_cmp.c */; }; + 22C91A141193400A0083AC69 /* bn_mp_cnt_lsb.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919221193400A0083AC69 /* bn_mp_cnt_lsb.c */; }; + 22C91A151193400A0083AC69 /* bn_mp_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919231193400A0083AC69 /* bn_mp_copy.c */; }; + 22C91A161193400A0083AC69 /* bn_mp_count_bits.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919241193400A0083AC69 /* bn_mp_count_bits.c */; }; + 22C91A171193400A0083AC69 /* bn_mp_div_2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919251193400A0083AC69 /* bn_mp_div_2.c */; }; + 22C91A181193400A0083AC69 /* bn_mp_div_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919261193400A0083AC69 /* bn_mp_div_2d.c */; }; + 22C91A191193400A0083AC69 /* bn_mp_div_3.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919271193400A0083AC69 /* bn_mp_div_3.c */; }; + 22C91A1A1193400A0083AC69 /* bn_mp_div_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919281193400A0083AC69 /* bn_mp_div_d.c */; }; + 22C91A1B1193400A0083AC69 /* bn_mp_div.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919291193400A0083AC69 /* bn_mp_div.c */; }; + 22C91A1C1193400A0083AC69 /* bn_mp_dr_is_modulus.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192A1193400A0083AC69 /* bn_mp_dr_is_modulus.c */; }; + 22C91A1D1193400A0083AC69 /* bn_mp_dr_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192B1193400A0083AC69 /* bn_mp_dr_reduce.c */; }; + 22C91A1E1193400A0083AC69 /* bn_mp_dr_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192C1193400A0083AC69 /* bn_mp_dr_setup.c */; }; + 22C91A1F1193400A0083AC69 /* bn_mp_exch.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192D1193400A0083AC69 /* bn_mp_exch.c */; }; + 22C91A201193400A0083AC69 /* bn_mp_expt_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192E1193400A0083AC69 /* bn_mp_expt_d.c */; }; + 22C91A211193400A0083AC69 /* bn_mp_exptmod_fast.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9192F1193400A0083AC69 /* bn_mp_exptmod_fast.c */; }; + 22C91A221193400A0083AC69 /* bn_mp_exptmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919301193400A0083AC69 /* bn_mp_exptmod.c */; }; + 22C91A231193400A0083AC69 /* bn_mp_exteuclid.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919311193400A0083AC69 /* bn_mp_exteuclid.c */; }; + 22C91A241193400A0083AC69 /* bn_mp_fread.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919321193400A0083AC69 /* bn_mp_fread.c */; }; + 22C91A251193400A0083AC69 /* bn_mp_fwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919331193400A0083AC69 /* bn_mp_fwrite.c */; }; + 22C91A261193400A0083AC69 /* bn_mp_gcd.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919341193400A0083AC69 /* bn_mp_gcd.c */; }; + 22C91A271193400A0083AC69 /* bn_mp_get_int.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919351193400A0083AC69 /* bn_mp_get_int.c */; }; + 22C91A281193400A0083AC69 /* bn_mp_grow.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919361193400A0083AC69 /* bn_mp_grow.c */; }; + 22C91A291193400A0083AC69 /* bn_mp_init_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919371193400A0083AC69 /* bn_mp_init_copy.c */; }; + 22C91A2A1193400A0083AC69 /* bn_mp_init_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919381193400A0083AC69 /* bn_mp_init_multi.c */; }; + 22C91A2B1193400A0083AC69 /* bn_mp_init_set_int.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919391193400A0083AC69 /* bn_mp_init_set_int.c */; }; + 22C91A2C1193400A0083AC69 /* bn_mp_init_set.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193A1193400A0083AC69 /* bn_mp_init_set.c */; }; + 22C91A2D1193400A0083AC69 /* bn_mp_init_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193B1193400A0083AC69 /* bn_mp_init_size.c */; }; + 22C91A2E1193400A0083AC69 /* bn_mp_init.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193C1193400A0083AC69 /* bn_mp_init.c */; }; + 22C91A2F1193400A0083AC69 /* bn_mp_invmod_slow.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193D1193400A0083AC69 /* bn_mp_invmod_slow.c */; }; + 22C91A301193400A0083AC69 /* bn_mp_invmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193E1193400A0083AC69 /* bn_mp_invmod.c */; }; + 22C91A311193400A0083AC69 /* bn_mp_is_square.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9193F1193400A0083AC69 /* bn_mp_is_square.c */; }; + 22C91A321193400A0083AC69 /* bn_mp_jacobi.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919401193400A0083AC69 /* bn_mp_jacobi.c */; }; + 22C91A331193400A0083AC69 /* bn_mp_karatsuba_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919411193400A0083AC69 /* bn_mp_karatsuba_mul.c */; }; + 22C91A341193400A0083AC69 /* bn_mp_karatsuba_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919421193400A0083AC69 /* bn_mp_karatsuba_sqr.c */; }; + 22C91A351193400A0083AC69 /* bn_mp_lcm.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919431193400A0083AC69 /* bn_mp_lcm.c */; }; + 22C91A361193400A0083AC69 /* bn_mp_lshd.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919441193400A0083AC69 /* bn_mp_lshd.c */; }; + 22C91A371193400A0083AC69 /* bn_mp_mod_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919451193400A0083AC69 /* bn_mp_mod_2d.c */; }; + 22C91A381193400A0083AC69 /* bn_mp_mod_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919461193400A0083AC69 /* bn_mp_mod_d.c */; }; + 22C91A391193400A0083AC69 /* bn_mp_mod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919471193400A0083AC69 /* bn_mp_mod.c */; }; + 22C91A3A1193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919481193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c */; }; + 22C91A3B1193400A0083AC69 /* bn_mp_montgomery_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919491193400A0083AC69 /* bn_mp_montgomery_reduce.c */; }; + 22C91A3C1193400A0083AC69 /* bn_mp_montgomery_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194A1193400A0083AC69 /* bn_mp_montgomery_setup.c */; }; + 22C91A3D1193400A0083AC69 /* bn_mp_mul_2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194B1193400A0083AC69 /* bn_mp_mul_2.c */; }; + 22C91A3E1193400A0083AC69 /* bn_mp_mul_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194C1193400A0083AC69 /* bn_mp_mul_2d.c */; }; + 22C91A3F1193400A0083AC69 /* bn_mp_mul_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194D1193400A0083AC69 /* bn_mp_mul_d.c */; }; + 22C91A401193400A0083AC69 /* bn_mp_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194E1193400A0083AC69 /* bn_mp_mul.c */; }; + 22C91A411193400A0083AC69 /* bn_mp_mulmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9194F1193400A0083AC69 /* bn_mp_mulmod.c */; }; + 22C91A421193400A0083AC69 /* bn_mp_n_root.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919501193400A0083AC69 /* bn_mp_n_root.c */; }; + 22C91A431193400A0083AC69 /* bn_mp_neg.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919511193400A0083AC69 /* bn_mp_neg.c */; }; + 22C91A441193400A0083AC69 /* bn_mp_or.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919521193400A0083AC69 /* bn_mp_or.c */; }; + 22C91A451193400A0083AC69 /* bn_mp_prime_fermat.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919531193400A0083AC69 /* bn_mp_prime_fermat.c */; }; + 22C91A461193400A0083AC69 /* bn_mp_prime_is_divisible.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919541193400A0083AC69 /* bn_mp_prime_is_divisible.c */; }; + 22C91A471193400A0083AC69 /* bn_mp_prime_is_prime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919551193400A0083AC69 /* bn_mp_prime_is_prime.c */; }; + 22C91A481193400A0083AC69 /* bn_mp_prime_miller_rabin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919561193400A0083AC69 /* bn_mp_prime_miller_rabin.c */; }; + 22C91A491193400A0083AC69 /* bn_mp_prime_next_prime.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919571193400A0083AC69 /* bn_mp_prime_next_prime.c */; }; + 22C91A4A1193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919581193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c */; }; + 22C91A4B1193400A0083AC69 /* bn_mp_prime_random_ex.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919591193400A0083AC69 /* bn_mp_prime_random_ex.c */; }; + 22C91A4C1193400A0083AC69 /* bn_mp_radix_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195A1193400A0083AC69 /* bn_mp_radix_size.c */; }; + 22C91A4D1193400A0083AC69 /* bn_mp_radix_smap.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195B1193400A0083AC69 /* bn_mp_radix_smap.c */; }; + 22C91A4E1193400A0083AC69 /* bn_mp_rand.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195C1193400A0083AC69 /* bn_mp_rand.c */; }; + 22C91A4F1193400A0083AC69 /* bn_mp_read_radix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195D1193400A0083AC69 /* bn_mp_read_radix.c */; }; + 22C91A501193400A0083AC69 /* bn_mp_read_signed_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195E1193400A0083AC69 /* bn_mp_read_signed_bin.c */; }; + 22C91A511193400A0083AC69 /* bn_mp_read_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9195F1193400A0083AC69 /* bn_mp_read_unsigned_bin.c */; }; + 22C91A521193400A0083AC69 /* bn_mp_reduce_2k_l.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919601193400A0083AC69 /* bn_mp_reduce_2k_l.c */; }; + 22C91A531193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919611193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c */; }; + 22C91A541193400A0083AC69 /* bn_mp_reduce_2k_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919621193400A0083AC69 /* bn_mp_reduce_2k_setup.c */; }; + 22C91A551193400A0083AC69 /* bn_mp_reduce_2k.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919631193400A0083AC69 /* bn_mp_reduce_2k.c */; }; + 22C91A561193400A0083AC69 /* bn_mp_reduce_is_2k_l.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919641193400A0083AC69 /* bn_mp_reduce_is_2k_l.c */; }; + 22C91A571193400A0083AC69 /* bn_mp_reduce_is_2k.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919651193400A0083AC69 /* bn_mp_reduce_is_2k.c */; }; + 22C91A581193400A0083AC69 /* bn_mp_reduce_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919661193400A0083AC69 /* bn_mp_reduce_setup.c */; }; + 22C91A591193400A0083AC69 /* bn_mp_reduce.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919671193400A0083AC69 /* bn_mp_reduce.c */; }; + 22C91A5A1193400A0083AC69 /* bn_mp_rshd.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919681193400A0083AC69 /* bn_mp_rshd.c */; }; + 22C91A5B1193400A0083AC69 /* bn_mp_set_int.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919691193400A0083AC69 /* bn_mp_set_int.c */; }; + 22C91A5C1193400A0083AC69 /* bn_mp_set.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196A1193400A0083AC69 /* bn_mp_set.c */; }; + 22C91A5D1193400A0083AC69 /* bn_mp_shrink.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196B1193400A0083AC69 /* bn_mp_shrink.c */; }; + 22C91A5E1193400A0083AC69 /* bn_mp_signed_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196C1193400A0083AC69 /* bn_mp_signed_bin_size.c */; }; + 22C91A5F1193400A0083AC69 /* bn_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196D1193400A0083AC69 /* bn_mp_sqr.c */; }; + 22C91A601193400A0083AC69 /* bn_mp_sqrmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196E1193400A0083AC69 /* bn_mp_sqrmod.c */; }; + 22C91A611193400A0083AC69 /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9196F1193400A0083AC69 /* bn_mp_sqrt.c */; }; + 22C91A621193400A0083AC69 /* bn_mp_sub_d.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919701193400A0083AC69 /* bn_mp_sub_d.c */; }; + 22C91A631193400A0083AC69 /* bn_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919711193400A0083AC69 /* bn_mp_sub.c */; }; + 22C91A641193400A0083AC69 /* bn_mp_submod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919721193400A0083AC69 /* bn_mp_submod.c */; }; + 22C91A651193400A0083AC69 /* bn_mp_to_signed_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919731193400A0083AC69 /* bn_mp_to_signed_bin_n.c */; }; + 22C91A661193400A0083AC69 /* bn_mp_to_signed_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919741193400A0083AC69 /* bn_mp_to_signed_bin.c */; }; + 22C91A671193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919751193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c */; }; + 22C91A681193400A0083AC69 /* bn_mp_to_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919761193400A0083AC69 /* bn_mp_to_unsigned_bin.c */; }; + 22C91A691193400A0083AC69 /* bn_mp_toom_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919771193400A0083AC69 /* bn_mp_toom_mul.c */; }; + 22C91A6A1193400A0083AC69 /* bn_mp_toom_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919781193400A0083AC69 /* bn_mp_toom_sqr.c */; }; + 22C91A6B1193400A0083AC69 /* bn_mp_toradix_n.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919791193400A0083AC69 /* bn_mp_toradix_n.c */; }; + 22C91A6C1193400A0083AC69 /* bn_mp_toradix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197A1193400A0083AC69 /* bn_mp_toradix.c */; }; + 22C91A6D1193400A0083AC69 /* bn_mp_unsigned_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197B1193400A0083AC69 /* bn_mp_unsigned_bin_size.c */; }; + 22C91A6E1193400A0083AC69 /* bn_mp_xor.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197C1193400A0083AC69 /* bn_mp_xor.c */; }; + 22C91A6F1193400A0083AC69 /* bn_mp_zero.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197D1193400A0083AC69 /* bn_mp_zero.c */; }; + 22C91A701193400A0083AC69 /* bn_prime_tab.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197E1193400A0083AC69 /* bn_prime_tab.c */; }; + 22C91A711193400A0083AC69 /* bn_reverse.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C9197F1193400A0083AC69 /* bn_reverse.c */; }; + 22C91A721193400A0083AC69 /* bn_s_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919801193400A0083AC69 /* bn_s_mp_add.c */; }; + 22C91A731193400A0083AC69 /* bn_s_mp_exptmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919811193400A0083AC69 /* bn_s_mp_exptmod.c */; }; + 22C91A741193400A0083AC69 /* bn_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919821193400A0083AC69 /* bn_s_mp_mul_digs.c */; }; + 22C91A751193400A0083AC69 /* bn_s_mp_mul_high_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919831193400A0083AC69 /* bn_s_mp_mul_high_digs.c */; }; + 22C91A761193400A0083AC69 /* bn_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919841193400A0083AC69 /* bn_s_mp_sqr.c */; }; + 22C91A771193400A0083AC69 /* bn_s_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919851193400A0083AC69 /* bn_s_mp_sub.c */; }; + 22C91A781193400A0083AC69 /* bncore.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C919861193400A0083AC69 /* bncore.c */; }; + 22C91A791193400A0083AC69 /* tommath_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C919871193400A0083AC69 /* tommath_class.h */; }; + 22C91A7A1193400A0083AC69 /* tommath_superclass.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C919881193400A0083AC69 /* tommath_superclass.h */; }; + 22C91A7B1193400A0083AC69 /* tommath.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C919891193400A0083AC69 /* tommath.h */; }; + 22EC6044154B28A000679228 /* FileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 22EC6043154B28A000679228 /* FileStream.h */; }; + 22EC6045154B28A000679228 /* FileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 22EC6043154B28A000679228 /* FileStream.h */; }; + 22F5A9C51193DFBA00F8B121 /* SFileVerify.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22F5A9C41193DFBA00F8B121 /* SFileVerify.cpp */; }; + 22F5A9C61193DFBA00F8B121 /* SFileVerify.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22F5A9C41193DFBA00F8B121 /* SFileVerify.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 2229F62E11D4653600118914 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 225530D31056BAC800FA646A; + remoteInfo = StormLib; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 221F6A721168529C0026C852 /* LzmaDec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LzmaDec.h; path = C/LzmaDec.h; sourceTree = ""; }; + 221F6A731168529C0026C852 /* LzmaEnc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LzmaEnc.h; path = C/LzmaEnc.h; sourceTree = ""; }; + 221F6A7A116852AA0026C852 /* LzmaEnc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = LzmaEnc.c; path = C/LzmaEnc.c; sourceTree = ""; }; + 221F6A7D116852B20026C852 /* LzmaDec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = LzmaDec.c; path = C/LzmaDec.c; sourceTree = ""; }; + 221F6AB31168545B0026C852 /* LzFind.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = LzFind.c; path = C/LzFind.c; sourceTree = ""; }; + 221F6AB41168545B0026C852 /* LzFind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LzFind.h; path = C/LzFind.h; sourceTree = ""; }; + 221F6AB9116854730026C852 /* LzHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LzHash.h; path = C/LzHash.h; sourceTree = ""; }; + 221F6ABC116854870026C852 /* Types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Types.h; path = C/Types.h; sourceTree = ""; }; + 2253A19F10568A83001909F9 /* StormLib.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; name = StormLib.exp; path = stormlib_dll/StormLib.exp; sourceTree = ""; }; + 225530D41056BAC800FA646A /* libStormLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libStormLib.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 225C734B1257CCC70009E8DA /* lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lookup.h; sourceTree = ""; }; + 225C734C1257CCC70009E8DA /* lookup3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lookup3.c; sourceTree = ""; }; + 225C73531257CD0C0009E8DA /* SBaseFileTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBaseFileTable.cpp; path = src/SBaseFileTable.cpp; sourceTree = ""; }; + 225FAC940E53B7F800DA2CAE /* StormLib.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = StormLib.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 225FAC950E53B7F800DA2CAE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 228B538311BF7D0D001A58DA /* FileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileStream.cpp; path = src/FileStream.cpp; sourceTree = ""; }; + 2295488911D45A820064B264 /* Test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Test.cpp; path = test/Test.cpp; sourceTree = ""; }; + 22954ACE11D463A30064B264 /* StormLib_Test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = StormLib_Test; sourceTree = BUILT_PRODUCTS_DIR; }; + 2299D9D51167EFA8005C19BF /* adpcm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = adpcm.cpp; sourceTree = ""; }; + 2299D9D61167EFA8005C19BF /* adpcm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = adpcm.h; sourceTree = ""; }; + 2299D9DC1167EFC6005C19BF /* sparse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sparse.cpp; sourceTree = ""; }; + 2299D9DD1167EFC6005C19BF /* sparse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sparse.h; sourceTree = ""; }; + 2299DA4D1167FD16005C19BF /* SFileAddFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileAddFile.cpp; path = src/SFileAddFile.cpp; sourceTree = ""; }; + 22AEA121123125D800359B16 /* SFilePatchArchives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFilePatchArchives.cpp; path = src/SFilePatchArchives.cpp; sourceTree = ""; }; + 22C9182B11933FCF0083AC69 /* hash_memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hash_memory.c; sourceTree = ""; }; + 22C9182C11933FCF0083AC69 /* md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5.c; sourceTree = ""; }; + 22C9182D11933FCF0083AC69 /* sha1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sha1.c; sourceTree = ""; }; + 22C9182F11933FCF0083AC69 /* tomcrypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt.h; sourceTree = ""; }; + 22C9183011933FCF0083AC69 /* tomcrypt_argchk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_argchk.h; sourceTree = ""; }; + 22C9183111933FCF0083AC69 /* tomcrypt_cfg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_cfg.h; sourceTree = ""; }; + 22C9183211933FCF0083AC69 /* tomcrypt_cipher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_cipher.h; sourceTree = ""; }; + 22C9183311933FCF0083AC69 /* tomcrypt_custom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_custom.h; sourceTree = ""; }; + 22C9183411933FCF0083AC69 /* tomcrypt_hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_hash.h; sourceTree = ""; }; + 22C9183511933FCF0083AC69 /* tomcrypt_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_mac.h; sourceTree = ""; }; + 22C9183611933FCF0083AC69 /* tomcrypt_macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_macros.h; sourceTree = ""; }; + 22C9183711933FCF0083AC69 /* tomcrypt_math.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_math.h; sourceTree = ""; }; + 22C9183811933FCF0083AC69 /* tomcrypt_misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_misc.h; sourceTree = ""; }; + 22C9183911933FCF0083AC69 /* tomcrypt_pk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_pk.h; sourceTree = ""; }; + 22C9183A11933FCF0083AC69 /* tomcrypt_pkcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_pkcs.h; sourceTree = ""; }; + 22C9183B11933FCF0083AC69 /* tomcrypt_prng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tomcrypt_prng.h; sourceTree = ""; }; + 22C9183D11933FCF0083AC69 /* ltm_desc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltm_desc.c; sourceTree = ""; }; + 22C9183E11933FCF0083AC69 /* multi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = multi.c; sourceTree = ""; }; + 22C9183F11933FCF0083AC69 /* rand_prime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rand_prime.c; sourceTree = ""; }; + 22C9184111933FCF0083AC69 /* base64_decode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = base64_decode.c; sourceTree = ""; }; + 22C9184211933FCF0083AC69 /* crypt_argchk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_argchk.c; sourceTree = ""; }; + 22C9184311933FCF0083AC69 /* crypt_find_hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_find_hash.c; sourceTree = ""; }; + 22C9184411933FCF0083AC69 /* crypt_find_prng.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_find_prng.c; sourceTree = ""; }; + 22C9184511933FCF0083AC69 /* crypt_hash_descriptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_hash_descriptor.c; sourceTree = ""; }; + 22C9184611933FCF0083AC69 /* crypt_hash_is_valid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_hash_is_valid.c; sourceTree = ""; }; + 22C9184711933FCF0083AC69 /* crypt_libc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_libc.c; sourceTree = ""; }; + 22C9184811933FCF0083AC69 /* crypt_ltc_mp_descriptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_ltc_mp_descriptor.c; sourceTree = ""; }; + 22C9184911933FCF0083AC69 /* crypt_prng_descriptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_prng_descriptor.c; sourceTree = ""; }; + 22C9184A11933FCF0083AC69 /* crypt_prng_is_valid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_prng_is_valid.c; sourceTree = ""; }; + 22C9184B11933FCF0083AC69 /* crypt_register_hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_register_hash.c; sourceTree = ""; }; + 22C9184C11933FCF0083AC69 /* crypt_register_prng.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crypt_register_prng.c; sourceTree = ""; }; + 22C9184D11933FCF0083AC69 /* zeromem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zeromem.c; sourceTree = ""; }; + 22C9185011933FCF0083AC69 /* der_decode_bit_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_bit_string.c; sourceTree = ""; }; + 22C9185111933FCF0083AC69 /* der_decode_boolean.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_boolean.c; sourceTree = ""; }; + 22C9185211933FCF0083AC69 /* der_decode_choice.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_choice.c; sourceTree = ""; }; + 22C9185311933FCF0083AC69 /* der_decode_ia5_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_ia5_string.c; sourceTree = ""; }; + 22C9185411933FCF0083AC69 /* der_decode_integer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_integer.c; sourceTree = ""; }; + 22C9185511933FCF0083AC69 /* der_decode_object_identifier.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_object_identifier.c; sourceTree = ""; }; + 22C9185611933FCF0083AC69 /* der_decode_octet_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_octet_string.c; sourceTree = ""; }; + 22C9185711933FCF0083AC69 /* der_decode_printable_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_printable_string.c; sourceTree = ""; }; + 22C9185811933FCF0083AC69 /* der_decode_sequence_ex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_sequence_ex.c; sourceTree = ""; }; + 22C9185911933FCF0083AC69 /* der_decode_sequence_flexi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_sequence_flexi.c; sourceTree = ""; }; + 22C9185A11933FCF0083AC69 /* der_decode_sequence_multi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_sequence_multi.c; sourceTree = ""; }; + 22C9185B11933FCF0083AC69 /* der_decode_short_integer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_short_integer.c; sourceTree = ""; }; + 22C9185C11933FCF0083AC69 /* der_decode_utctime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_utctime.c; sourceTree = ""; }; + 22C9185D11933FCF0083AC69 /* der_decode_utf8_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_decode_utf8_string.c; sourceTree = ""; }; + 22C9185E11933FCF0083AC69 /* der_length_bit_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_bit_string.c; sourceTree = ""; }; + 22C9185F11933FCF0083AC69 /* der_length_boolean.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_boolean.c; sourceTree = ""; }; + 22C9186011933FCF0083AC69 /* der_length_ia5_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_ia5_string.c; sourceTree = ""; }; + 22C9186111933FCF0083AC69 /* der_length_integer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_integer.c; sourceTree = ""; }; + 22C9186211933FCF0083AC69 /* der_length_object_identifier.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_object_identifier.c; sourceTree = ""; }; + 22C9186311933FCF0083AC69 /* der_length_octet_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_octet_string.c; sourceTree = ""; }; + 22C9186411933FCF0083AC69 /* der_length_printable_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_printable_string.c; sourceTree = ""; }; + 22C9186511933FCF0083AC69 /* der_length_sequence.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_sequence.c; sourceTree = ""; }; + 22C9186611933FCF0083AC69 /* der_length_short_integer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_short_integer.c; sourceTree = ""; }; + 22C9186711933FCF0083AC69 /* der_length_utctime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_utctime.c; sourceTree = ""; }; + 22C9186811933FCF0083AC69 /* der_length_utf8_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_length_utf8_string.c; sourceTree = ""; }; + 22C9186911933FCF0083AC69 /* der_sequence_free.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = der_sequence_free.c; sourceTree = ""; }; + 22C9186B11933FCF0083AC69 /* ltc_ecc_map.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltc_ecc_map.c; sourceTree = ""; }; + 22C9186C11933FCF0083AC69 /* ltc_ecc_mul2add.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltc_ecc_mul2add.c; sourceTree = ""; }; + 22C9186D11933FCF0083AC69 /* ltc_ecc_mulmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltc_ecc_mulmod.c; sourceTree = ""; }; + 22C9186E11933FCF0083AC69 /* ltc_ecc_points.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltc_ecc_points.c; sourceTree = ""; }; + 22C9186F11933FCF0083AC69 /* ltc_ecc_projective_add_point.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltc_ecc_projective_add_point.c; sourceTree = ""; }; + 22C9187011933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltc_ecc_projective_dbl_point.c; sourceTree = ""; }; + 22C9187211933FCF0083AC69 /* pkcs_1_mgf1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkcs_1_mgf1.c; sourceTree = ""; }; + 22C9187311933FCF0083AC69 /* pkcs_1_oaep_decode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkcs_1_oaep_decode.c; sourceTree = ""; }; + 22C9187411933FCF0083AC69 /* pkcs_1_pss_decode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkcs_1_pss_decode.c; sourceTree = ""; }; + 22C9187511933FCF0083AC69 /* pkcs_1_v1_5_decode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkcs_1_v1_5_decode.c; sourceTree = ""; }; + 22C9187711933FCF0083AC69 /* rsa_exptmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rsa_exptmod.c; sourceTree = ""; }; + 22C9187811933FCF0083AC69 /* rsa_free.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rsa_free.c; sourceTree = ""; }; + 22C9187911933FCF0083AC69 /* rsa_import.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rsa_import.c; sourceTree = ""; }; + 22C9187A11933FCF0083AC69 /* rsa_make_key.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rsa_make_key.c; sourceTree = ""; }; + 22C9187B11933FCF0083AC69 /* rsa_verify_hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rsa_verify_hash.c; sourceTree = ""; }; + 22C9187C11933FCF0083AC69 /* rsa_verify_simple.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rsa_verify_simple.c; sourceTree = ""; }; + 22C919111193400A0083AC69 /* bn_fast_mp_invmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_fast_mp_invmod.c; sourceTree = ""; }; + 22C919121193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_fast_mp_montgomery_reduce.c; sourceTree = ""; }; + 22C919131193400A0083AC69 /* bn_fast_s_mp_mul_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_fast_s_mp_mul_digs.c; sourceTree = ""; }; + 22C919141193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_fast_s_mp_mul_high_digs.c; sourceTree = ""; }; + 22C919151193400A0083AC69 /* bn_fast_s_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_fast_s_mp_sqr.c; sourceTree = ""; }; + 22C919161193400A0083AC69 /* bn_mp_2expt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_2expt.c; sourceTree = ""; }; + 22C919171193400A0083AC69 /* bn_mp_abs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_abs.c; sourceTree = ""; }; + 22C919181193400A0083AC69 /* bn_mp_add_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_add_d.c; sourceTree = ""; }; + 22C919191193400A0083AC69 /* bn_mp_add.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_add.c; sourceTree = ""; }; + 22C9191A1193400A0083AC69 /* bn_mp_addmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_addmod.c; sourceTree = ""; }; + 22C9191B1193400A0083AC69 /* bn_mp_and.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_and.c; sourceTree = ""; }; + 22C9191C1193400A0083AC69 /* bn_mp_clamp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_clamp.c; sourceTree = ""; }; + 22C9191D1193400A0083AC69 /* bn_mp_clear_multi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_clear_multi.c; sourceTree = ""; }; + 22C9191E1193400A0083AC69 /* bn_mp_clear.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_clear.c; sourceTree = ""; }; + 22C9191F1193400A0083AC69 /* bn_mp_cmp_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_cmp_d.c; sourceTree = ""; }; + 22C919201193400A0083AC69 /* bn_mp_cmp_mag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_cmp_mag.c; sourceTree = ""; }; + 22C919211193400A0083AC69 /* bn_mp_cmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_cmp.c; sourceTree = ""; }; + 22C919221193400A0083AC69 /* bn_mp_cnt_lsb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_cnt_lsb.c; sourceTree = ""; }; + 22C919231193400A0083AC69 /* bn_mp_copy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_copy.c; sourceTree = ""; }; + 22C919241193400A0083AC69 /* bn_mp_count_bits.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_count_bits.c; sourceTree = ""; }; + 22C919251193400A0083AC69 /* bn_mp_div_2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_2.c; sourceTree = ""; }; + 22C919261193400A0083AC69 /* bn_mp_div_2d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_2d.c; sourceTree = ""; }; + 22C919271193400A0083AC69 /* bn_mp_div_3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_3.c; sourceTree = ""; }; + 22C919281193400A0083AC69 /* bn_mp_div_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_d.c; sourceTree = ""; }; + 22C919291193400A0083AC69 /* bn_mp_div.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div.c; sourceTree = ""; }; + 22C9192A1193400A0083AC69 /* bn_mp_dr_is_modulus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_dr_is_modulus.c; sourceTree = ""; }; + 22C9192B1193400A0083AC69 /* bn_mp_dr_reduce.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_dr_reduce.c; sourceTree = ""; }; + 22C9192C1193400A0083AC69 /* bn_mp_dr_setup.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_dr_setup.c; sourceTree = ""; }; + 22C9192D1193400A0083AC69 /* bn_mp_exch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_exch.c; sourceTree = ""; }; + 22C9192E1193400A0083AC69 /* bn_mp_expt_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_expt_d.c; sourceTree = ""; }; + 22C9192F1193400A0083AC69 /* bn_mp_exptmod_fast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_exptmod_fast.c; sourceTree = ""; }; + 22C919301193400A0083AC69 /* bn_mp_exptmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_exptmod.c; sourceTree = ""; }; + 22C919311193400A0083AC69 /* bn_mp_exteuclid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_exteuclid.c; sourceTree = ""; }; + 22C919321193400A0083AC69 /* bn_mp_fread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_fread.c; sourceTree = ""; }; + 22C919331193400A0083AC69 /* bn_mp_fwrite.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_fwrite.c; sourceTree = ""; }; + 22C919341193400A0083AC69 /* bn_mp_gcd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_gcd.c; sourceTree = ""; }; + 22C919351193400A0083AC69 /* bn_mp_get_int.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_get_int.c; sourceTree = ""; }; + 22C919361193400A0083AC69 /* bn_mp_grow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_grow.c; sourceTree = ""; }; + 22C919371193400A0083AC69 /* bn_mp_init_copy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_copy.c; sourceTree = ""; }; + 22C919381193400A0083AC69 /* bn_mp_init_multi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_multi.c; sourceTree = ""; }; + 22C919391193400A0083AC69 /* bn_mp_init_set_int.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_set_int.c; sourceTree = ""; }; + 22C9193A1193400A0083AC69 /* bn_mp_init_set.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_set.c; sourceTree = ""; }; + 22C9193B1193400A0083AC69 /* bn_mp_init_size.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_size.c; sourceTree = ""; }; + 22C9193C1193400A0083AC69 /* bn_mp_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init.c; sourceTree = ""; }; + 22C9193D1193400A0083AC69 /* bn_mp_invmod_slow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_invmod_slow.c; sourceTree = ""; }; + 22C9193E1193400A0083AC69 /* bn_mp_invmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_invmod.c; sourceTree = ""; }; + 22C9193F1193400A0083AC69 /* bn_mp_is_square.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_is_square.c; sourceTree = ""; }; + 22C919401193400A0083AC69 /* bn_mp_jacobi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_jacobi.c; sourceTree = ""; }; + 22C919411193400A0083AC69 /* bn_mp_karatsuba_mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_karatsuba_mul.c; sourceTree = ""; }; + 22C919421193400A0083AC69 /* bn_mp_karatsuba_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_karatsuba_sqr.c; sourceTree = ""; }; + 22C919431193400A0083AC69 /* bn_mp_lcm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_lcm.c; sourceTree = ""; }; + 22C919441193400A0083AC69 /* bn_mp_lshd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_lshd.c; sourceTree = ""; }; + 22C919451193400A0083AC69 /* bn_mp_mod_2d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mod_2d.c; sourceTree = ""; }; + 22C919461193400A0083AC69 /* bn_mp_mod_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mod_d.c; sourceTree = ""; }; + 22C919471193400A0083AC69 /* bn_mp_mod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mod.c; sourceTree = ""; }; + 22C919481193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_montgomery_calc_normalization.c; sourceTree = ""; }; + 22C919491193400A0083AC69 /* bn_mp_montgomery_reduce.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_montgomery_reduce.c; sourceTree = ""; }; + 22C9194A1193400A0083AC69 /* bn_mp_montgomery_setup.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_montgomery_setup.c; sourceTree = ""; }; + 22C9194B1193400A0083AC69 /* bn_mp_mul_2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul_2.c; sourceTree = ""; }; + 22C9194C1193400A0083AC69 /* bn_mp_mul_2d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul_2d.c; sourceTree = ""; }; + 22C9194D1193400A0083AC69 /* bn_mp_mul_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul_d.c; sourceTree = ""; }; + 22C9194E1193400A0083AC69 /* bn_mp_mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul.c; sourceTree = ""; }; + 22C9194F1193400A0083AC69 /* bn_mp_mulmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mulmod.c; sourceTree = ""; }; + 22C919501193400A0083AC69 /* bn_mp_n_root.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_n_root.c; sourceTree = ""; }; + 22C919511193400A0083AC69 /* bn_mp_neg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_neg.c; sourceTree = ""; }; + 22C919521193400A0083AC69 /* bn_mp_or.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_or.c; sourceTree = ""; }; + 22C919531193400A0083AC69 /* bn_mp_prime_fermat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_prime_fermat.c; sourceTree = ""; }; + 22C919541193400A0083AC69 /* bn_mp_prime_is_divisible.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_prime_is_divisible.c; sourceTree = ""; }; + 22C919551193400A0083AC69 /* bn_mp_prime_is_prime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_prime_is_prime.c; sourceTree = ""; }; + 22C919561193400A0083AC69 /* bn_mp_prime_miller_rabin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_prime_miller_rabin.c; sourceTree = ""; }; + 22C919571193400A0083AC69 /* bn_mp_prime_next_prime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_prime_next_prime.c; sourceTree = ""; }; + 22C919581193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_prime_rabin_miller_trials.c; sourceTree = ""; }; + 22C919591193400A0083AC69 /* bn_mp_prime_random_ex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_prime_random_ex.c; sourceTree = ""; }; + 22C9195A1193400A0083AC69 /* bn_mp_radix_size.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_radix_size.c; sourceTree = ""; }; + 22C9195B1193400A0083AC69 /* bn_mp_radix_smap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_radix_smap.c; sourceTree = ""; }; + 22C9195C1193400A0083AC69 /* bn_mp_rand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_rand.c; sourceTree = ""; }; + 22C9195D1193400A0083AC69 /* bn_mp_read_radix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_read_radix.c; sourceTree = ""; }; + 22C9195E1193400A0083AC69 /* bn_mp_read_signed_bin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_read_signed_bin.c; sourceTree = ""; }; + 22C9195F1193400A0083AC69 /* bn_mp_read_unsigned_bin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_read_unsigned_bin.c; sourceTree = ""; }; + 22C919601193400A0083AC69 /* bn_mp_reduce_2k_l.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce_2k_l.c; sourceTree = ""; }; + 22C919611193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce_2k_setup_l.c; sourceTree = ""; }; + 22C919621193400A0083AC69 /* bn_mp_reduce_2k_setup.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce_2k_setup.c; sourceTree = ""; }; + 22C919631193400A0083AC69 /* bn_mp_reduce_2k.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce_2k.c; sourceTree = ""; }; + 22C919641193400A0083AC69 /* bn_mp_reduce_is_2k_l.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce_is_2k_l.c; sourceTree = ""; }; + 22C919651193400A0083AC69 /* bn_mp_reduce_is_2k.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce_is_2k.c; sourceTree = ""; }; + 22C919661193400A0083AC69 /* bn_mp_reduce_setup.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce_setup.c; sourceTree = ""; }; + 22C919671193400A0083AC69 /* bn_mp_reduce.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_reduce.c; sourceTree = ""; }; + 22C919681193400A0083AC69 /* bn_mp_rshd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_rshd.c; sourceTree = ""; }; + 22C919691193400A0083AC69 /* bn_mp_set_int.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_set_int.c; sourceTree = ""; }; + 22C9196A1193400A0083AC69 /* bn_mp_set.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_set.c; sourceTree = ""; }; + 22C9196B1193400A0083AC69 /* bn_mp_shrink.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_shrink.c; sourceTree = ""; }; + 22C9196C1193400A0083AC69 /* bn_mp_signed_bin_size.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_signed_bin_size.c; sourceTree = ""; }; + 22C9196D1193400A0083AC69 /* bn_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sqr.c; sourceTree = ""; }; + 22C9196E1193400A0083AC69 /* bn_mp_sqrmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sqrmod.c; sourceTree = ""; }; + 22C9196F1193400A0083AC69 /* bn_mp_sqrt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sqrt.c; sourceTree = ""; }; + 22C919701193400A0083AC69 /* bn_mp_sub_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sub_d.c; sourceTree = ""; }; + 22C919711193400A0083AC69 /* bn_mp_sub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sub.c; sourceTree = ""; }; + 22C919721193400A0083AC69 /* bn_mp_submod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_submod.c; sourceTree = ""; }; + 22C919731193400A0083AC69 /* bn_mp_to_signed_bin_n.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_to_signed_bin_n.c; sourceTree = ""; }; + 22C919741193400A0083AC69 /* bn_mp_to_signed_bin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_to_signed_bin.c; sourceTree = ""; }; + 22C919751193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_to_unsigned_bin_n.c; sourceTree = ""; }; + 22C919761193400A0083AC69 /* bn_mp_to_unsigned_bin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_to_unsigned_bin.c; sourceTree = ""; }; + 22C919771193400A0083AC69 /* bn_mp_toom_mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_toom_mul.c; sourceTree = ""; }; + 22C919781193400A0083AC69 /* bn_mp_toom_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_toom_sqr.c; sourceTree = ""; }; + 22C919791193400A0083AC69 /* bn_mp_toradix_n.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_toradix_n.c; sourceTree = ""; }; + 22C9197A1193400A0083AC69 /* bn_mp_toradix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_toradix.c; sourceTree = ""; }; + 22C9197B1193400A0083AC69 /* bn_mp_unsigned_bin_size.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_unsigned_bin_size.c; sourceTree = ""; }; + 22C9197C1193400A0083AC69 /* bn_mp_xor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_xor.c; sourceTree = ""; }; + 22C9197D1193400A0083AC69 /* bn_mp_zero.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_zero.c; sourceTree = ""; }; + 22C9197E1193400A0083AC69 /* bn_prime_tab.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_prime_tab.c; sourceTree = ""; }; + 22C9197F1193400A0083AC69 /* bn_reverse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_reverse.c; sourceTree = ""; }; + 22C919801193400A0083AC69 /* bn_s_mp_add.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_add.c; sourceTree = ""; }; + 22C919811193400A0083AC69 /* bn_s_mp_exptmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_exptmod.c; sourceTree = ""; }; + 22C919821193400A0083AC69 /* bn_s_mp_mul_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_mul_digs.c; sourceTree = ""; }; + 22C919831193400A0083AC69 /* bn_s_mp_mul_high_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_mul_high_digs.c; sourceTree = ""; }; + 22C919841193400A0083AC69 /* bn_s_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sqr.c; sourceTree = ""; }; + 22C919851193400A0083AC69 /* bn_s_mp_sub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sub.c; sourceTree = ""; }; + 22C919861193400A0083AC69 /* bncore.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bncore.c; sourceTree = ""; }; + 22C919871193400A0083AC69 /* tommath_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_class.h; sourceTree = ""; }; + 22C919881193400A0083AC69 /* tommath_superclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_superclass.h; sourceTree = ""; }; + 22C919891193400A0083AC69 /* tommath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath.h; sourceTree = ""; }; + 22EC6043154B28A000679228 /* FileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileStream.h; path = src/FileStream.h; sourceTree = ""; }; + 22F5A9C41193DFBA00F8B121 /* SFileVerify.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileVerify.cpp; path = src/SFileVerify.cpp; sourceTree = ""; }; + 32D20A8A0CF3902D00230E7A /* libbz2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbz2.dylib; path = /usr/lib/libbz2.dylib; sourceTree = ""; }; + 32D20A8B0CF3902D00230E7A /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = ""; }; + 32ED009C0D03542A00AB0B4E /* huff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = huff.cpp; sourceTree = ""; }; + 32ED009D0D03542A00AB0B4E /* huff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = huff.h; sourceTree = ""; }; + 32ED00A60D03542A00AB0B4E /* explode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = explode.c; sourceTree = ""; }; + 32ED00A70D03542A00AB0B4E /* implode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = implode.c; sourceTree = ""; }; + 32ED00A80D03542A00AB0B4E /* pklib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pklib.h; sourceTree = ""; }; + 32ED00A90D03542A00AB0B4E /* SFileAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileAttributes.cpp; path = src/SFileAttributes.cpp; sourceTree = ""; }; + 32ED00AA0D03542A00AB0B4E /* SBaseCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBaseCommon.cpp; path = src/SBaseCommon.cpp; sourceTree = ""; }; + 32ED00AB0D03542A00AB0B4E /* StormCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StormCommon.h; path = src/StormCommon.h; sourceTree = ""; }; + 32ED00AC0D03542A00AB0B4E /* SCompression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SCompression.cpp; path = src/SCompression.cpp; sourceTree = ""; }; + 32ED00AD0D03542A00AB0B4E /* SFileCompactArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileCompactArchive.cpp; path = src/SFileCompactArchive.cpp; sourceTree = ""; }; + 32ED00AE0D03542A00AB0B4E /* SFileCreateArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileCreateArchive.cpp; path = src/SFileCreateArchive.cpp; sourceTree = ""; }; + 32ED00AF0D03542A00AB0B4E /* SFileExtractFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileExtractFile.cpp; path = src/SFileExtractFile.cpp; sourceTree = ""; }; + 32ED00B00D03542A00AB0B4E /* SFileFindFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileFindFile.cpp; path = src/SFileFindFile.cpp; sourceTree = ""; }; + 32ED00B10D03542A00AB0B4E /* SFileOpenArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileOpenArchive.cpp; path = src/SFileOpenArchive.cpp; sourceTree = ""; }; + 32ED00B20D03542A00AB0B4E /* SFileOpenFileEx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileOpenFileEx.cpp; path = src/SFileOpenFileEx.cpp; sourceTree = ""; }; + 32ED00B30D03542A00AB0B4E /* SFileReadFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileReadFile.cpp; path = src/SFileReadFile.cpp; sourceTree = ""; }; + 32ED00B40D03542A00AB0B4E /* SFileListFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileListFile.cpp; path = src/SFileListFile.cpp; sourceTree = ""; }; + 32ED00B60D03542A00AB0B4E /* StormLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StormLib.h; path = src/StormLib.h; sourceTree = ""; }; + 32ED00B70D03542A00AB0B4E /* StormPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StormPort.h; path = src/StormPort.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 225530D21056BAC800FA646A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 225FAC920E53B7F800DA2CAE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 225FADD40E53C06600DA2CAE /* libbz2.dylib in Frameworks */, + 225FADD50E53C06600DA2CAE /* libz.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 22954ACC11D463A30064B264 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 22954AD611D463BE0064B264 /* libbz2.dylib in Frameworks */, + 22954AD711D463BE0064B264 /* libz.dylib in Frameworks */, + 22954AD311D463B50064B264 /* libStormLib.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 034768DDFF38A45A11DB9C8B /* Products */ = { + isa = PBXGroup; + children = ( + 225FAC940E53B7F800DA2CAE /* StormLib.framework */, + 225530D41056BAC800FA646A /* libStormLib.a */, + 22954ACE11D463A30064B264 /* StormLib_Test */, + ); + name = Products; + sourceTree = ""; + }; + 0867D691FE84028FC02AAC07 /* stormlib */ = { + isa = PBXGroup; + children = ( + 32DBEE830D00E58F00DB1E81 /* Source */, + 2295488711D45A520064B264 /* Test */, + 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */, + 22B54B321054B287001D6436 /* Resources */, + 034768DDFF38A45A11DB9C8B /* Products */, + 2253A19F10568A83001909F9 /* StormLib.exp */, + ); + name = stormlib; + sourceTree = ""; + }; + 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 32D20A8A0CF3902D00230E7A /* libbz2.dylib */, + 32D20A8B0CF3902D00230E7A /* libz.dylib */, + ); + name = "External Frameworks and Libraries"; + sourceTree = ""; + }; + 221F652D116851D70026C852 /* lzma */ = { + isa = PBXGroup; + children = ( + 221F6AB31168545B0026C852 /* LzFind.c */, + 221F6AB41168545B0026C852 /* LzFind.h */, + 221F6AB9116854730026C852 /* LzHash.h */, + 221F6A7D116852B20026C852 /* LzmaDec.c */, + 221F6A721168529C0026C852 /* LzmaDec.h */, + 221F6A7A116852AA0026C852 /* LzmaEnc.c */, + 221F6A731168529C0026C852 /* LzmaEnc.h */, + 221F6ABC116854870026C852 /* Types.h */, + ); + name = lzma; + path = src/lzma; + sourceTree = ""; + }; + 225C734A1257CCC70009E8DA /* jenkins */ = { + isa = PBXGroup; + children = ( + 225C734B1257CCC70009E8DA /* lookup.h */, + 225C734C1257CCC70009E8DA /* lookup3.c */, + ); + name = jenkins; + path = src/jenkins; + sourceTree = ""; + }; + 2295488711D45A520064B264 /* Test */ = { + isa = PBXGroup; + children = ( + 2295488911D45A820064B264 /* Test.cpp */, + ); + name = Test; + sourceTree = ""; + }; + 2299D9D41167EFA8005C19BF /* adpcm */ = { + isa = PBXGroup; + children = ( + 2299D9D51167EFA8005C19BF /* adpcm.cpp */, + 2299D9D61167EFA8005C19BF /* adpcm.h */, + ); + name = adpcm; + path = src/adpcm; + sourceTree = ""; + }; + 2299D9DB1167EFC6005C19BF /* sparse */ = { + isa = PBXGroup; + children = ( + 2299D9DC1167EFC6005C19BF /* sparse.cpp */, + 2299D9DD1167EFC6005C19BF /* sparse.h */, + ); + name = sparse; + path = src/sparse; + sourceTree = ""; + }; + 22B54B321054B287001D6436 /* Resources */ = { + isa = PBXGroup; + children = ( + 225FAC950E53B7F800DA2CAE /* Info.plist */, + ); + name = Resources; + sourceTree = ""; + }; + 22C9181D11933E3A0083AC69 /* libtomcrypt */ = { + isa = PBXGroup; + children = ( + 22C9182A11933FCF0083AC69 /* hashes */, + 22C9182E11933FCF0083AC69 /* headers */, + 22C9183C11933FCF0083AC69 /* math */, + 22C9184011933FCF0083AC69 /* misc */, + 22C9184E11933FCF0083AC69 /* pk */, + ); + name = libtomcrypt; + path = src/libtomcrypt; + sourceTree = ""; + }; + 22C9181E11933E470083AC69 /* libtommath */ = { + isa = PBXGroup; + children = ( + 22C919111193400A0083AC69 /* bn_fast_mp_invmod.c */, + 22C919121193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c */, + 22C919131193400A0083AC69 /* bn_fast_s_mp_mul_digs.c */, + 22C919141193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c */, + 22C919151193400A0083AC69 /* bn_fast_s_mp_sqr.c */, + 22C919161193400A0083AC69 /* bn_mp_2expt.c */, + 22C919171193400A0083AC69 /* bn_mp_abs.c */, + 22C919181193400A0083AC69 /* bn_mp_add_d.c */, + 22C919191193400A0083AC69 /* bn_mp_add.c */, + 22C9191A1193400A0083AC69 /* bn_mp_addmod.c */, + 22C9191B1193400A0083AC69 /* bn_mp_and.c */, + 22C9191C1193400A0083AC69 /* bn_mp_clamp.c */, + 22C9191D1193400A0083AC69 /* bn_mp_clear_multi.c */, + 22C9191E1193400A0083AC69 /* bn_mp_clear.c */, + 22C9191F1193400A0083AC69 /* bn_mp_cmp_d.c */, + 22C919201193400A0083AC69 /* bn_mp_cmp_mag.c */, + 22C919211193400A0083AC69 /* bn_mp_cmp.c */, + 22C919221193400A0083AC69 /* bn_mp_cnt_lsb.c */, + 22C919231193400A0083AC69 /* bn_mp_copy.c */, + 22C919241193400A0083AC69 /* bn_mp_count_bits.c */, + 22C919251193400A0083AC69 /* bn_mp_div_2.c */, + 22C919261193400A0083AC69 /* bn_mp_div_2d.c */, + 22C919271193400A0083AC69 /* bn_mp_div_3.c */, + 22C919281193400A0083AC69 /* bn_mp_div_d.c */, + 22C919291193400A0083AC69 /* bn_mp_div.c */, + 22C9192A1193400A0083AC69 /* bn_mp_dr_is_modulus.c */, + 22C9192B1193400A0083AC69 /* bn_mp_dr_reduce.c */, + 22C9192C1193400A0083AC69 /* bn_mp_dr_setup.c */, + 22C9192D1193400A0083AC69 /* bn_mp_exch.c */, + 22C9192E1193400A0083AC69 /* bn_mp_expt_d.c */, + 22C9192F1193400A0083AC69 /* bn_mp_exptmod_fast.c */, + 22C919301193400A0083AC69 /* bn_mp_exptmod.c */, + 22C919311193400A0083AC69 /* bn_mp_exteuclid.c */, + 22C919321193400A0083AC69 /* bn_mp_fread.c */, + 22C919331193400A0083AC69 /* bn_mp_fwrite.c */, + 22C919341193400A0083AC69 /* bn_mp_gcd.c */, + 22C919351193400A0083AC69 /* bn_mp_get_int.c */, + 22C919361193400A0083AC69 /* bn_mp_grow.c */, + 22C919371193400A0083AC69 /* bn_mp_init_copy.c */, + 22C919381193400A0083AC69 /* bn_mp_init_multi.c */, + 22C919391193400A0083AC69 /* bn_mp_init_set_int.c */, + 22C9193A1193400A0083AC69 /* bn_mp_init_set.c */, + 22C9193B1193400A0083AC69 /* bn_mp_init_size.c */, + 22C9193C1193400A0083AC69 /* bn_mp_init.c */, + 22C9193D1193400A0083AC69 /* bn_mp_invmod_slow.c */, + 22C9193E1193400A0083AC69 /* bn_mp_invmod.c */, + 22C9193F1193400A0083AC69 /* bn_mp_is_square.c */, + 22C919401193400A0083AC69 /* bn_mp_jacobi.c */, + 22C919411193400A0083AC69 /* bn_mp_karatsuba_mul.c */, + 22C919421193400A0083AC69 /* bn_mp_karatsuba_sqr.c */, + 22C919431193400A0083AC69 /* bn_mp_lcm.c */, + 22C919441193400A0083AC69 /* bn_mp_lshd.c */, + 22C919451193400A0083AC69 /* bn_mp_mod_2d.c */, + 22C919461193400A0083AC69 /* bn_mp_mod_d.c */, + 22C919471193400A0083AC69 /* bn_mp_mod.c */, + 22C919481193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c */, + 22C919491193400A0083AC69 /* bn_mp_montgomery_reduce.c */, + 22C9194A1193400A0083AC69 /* bn_mp_montgomery_setup.c */, + 22C9194B1193400A0083AC69 /* bn_mp_mul_2.c */, + 22C9194C1193400A0083AC69 /* bn_mp_mul_2d.c */, + 22C9194D1193400A0083AC69 /* bn_mp_mul_d.c */, + 22C9194E1193400A0083AC69 /* bn_mp_mul.c */, + 22C9194F1193400A0083AC69 /* bn_mp_mulmod.c */, + 22C919501193400A0083AC69 /* bn_mp_n_root.c */, + 22C919511193400A0083AC69 /* bn_mp_neg.c */, + 22C919521193400A0083AC69 /* bn_mp_or.c */, + 22C919531193400A0083AC69 /* bn_mp_prime_fermat.c */, + 22C919541193400A0083AC69 /* bn_mp_prime_is_divisible.c */, + 22C919551193400A0083AC69 /* bn_mp_prime_is_prime.c */, + 22C919561193400A0083AC69 /* bn_mp_prime_miller_rabin.c */, + 22C919571193400A0083AC69 /* bn_mp_prime_next_prime.c */, + 22C919581193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c */, + 22C919591193400A0083AC69 /* bn_mp_prime_random_ex.c */, + 22C9195A1193400A0083AC69 /* bn_mp_radix_size.c */, + 22C9195B1193400A0083AC69 /* bn_mp_radix_smap.c */, + 22C9195C1193400A0083AC69 /* bn_mp_rand.c */, + 22C9195D1193400A0083AC69 /* bn_mp_read_radix.c */, + 22C9195E1193400A0083AC69 /* bn_mp_read_signed_bin.c */, + 22C9195F1193400A0083AC69 /* bn_mp_read_unsigned_bin.c */, + 22C919601193400A0083AC69 /* bn_mp_reduce_2k_l.c */, + 22C919611193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c */, + 22C919621193400A0083AC69 /* bn_mp_reduce_2k_setup.c */, + 22C919631193400A0083AC69 /* bn_mp_reduce_2k.c */, + 22C919641193400A0083AC69 /* bn_mp_reduce_is_2k_l.c */, + 22C919651193400A0083AC69 /* bn_mp_reduce_is_2k.c */, + 22C919661193400A0083AC69 /* bn_mp_reduce_setup.c */, + 22C919671193400A0083AC69 /* bn_mp_reduce.c */, + 22C919681193400A0083AC69 /* bn_mp_rshd.c */, + 22C919691193400A0083AC69 /* bn_mp_set_int.c */, + 22C9196A1193400A0083AC69 /* bn_mp_set.c */, + 22C9196B1193400A0083AC69 /* bn_mp_shrink.c */, + 22C9196C1193400A0083AC69 /* bn_mp_signed_bin_size.c */, + 22C9196D1193400A0083AC69 /* bn_mp_sqr.c */, + 22C9196E1193400A0083AC69 /* bn_mp_sqrmod.c */, + 22C9196F1193400A0083AC69 /* bn_mp_sqrt.c */, + 22C919701193400A0083AC69 /* bn_mp_sub_d.c */, + 22C919711193400A0083AC69 /* bn_mp_sub.c */, + 22C919721193400A0083AC69 /* bn_mp_submod.c */, + 22C919731193400A0083AC69 /* bn_mp_to_signed_bin_n.c */, + 22C919741193400A0083AC69 /* bn_mp_to_signed_bin.c */, + 22C919751193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c */, + 22C919761193400A0083AC69 /* bn_mp_to_unsigned_bin.c */, + 22C919771193400A0083AC69 /* bn_mp_toom_mul.c */, + 22C919781193400A0083AC69 /* bn_mp_toom_sqr.c */, + 22C919791193400A0083AC69 /* bn_mp_toradix_n.c */, + 22C9197A1193400A0083AC69 /* bn_mp_toradix.c */, + 22C9197B1193400A0083AC69 /* bn_mp_unsigned_bin_size.c */, + 22C9197C1193400A0083AC69 /* bn_mp_xor.c */, + 22C9197D1193400A0083AC69 /* bn_mp_zero.c */, + 22C9197E1193400A0083AC69 /* bn_prime_tab.c */, + 22C9197F1193400A0083AC69 /* bn_reverse.c */, + 22C919801193400A0083AC69 /* bn_s_mp_add.c */, + 22C919811193400A0083AC69 /* bn_s_mp_exptmod.c */, + 22C919821193400A0083AC69 /* bn_s_mp_mul_digs.c */, + 22C919831193400A0083AC69 /* bn_s_mp_mul_high_digs.c */, + 22C919841193400A0083AC69 /* bn_s_mp_sqr.c */, + 22C919851193400A0083AC69 /* bn_s_mp_sub.c */, + 22C919861193400A0083AC69 /* bncore.c */, + 22C919871193400A0083AC69 /* tommath_class.h */, + 22C919881193400A0083AC69 /* tommath_superclass.h */, + 22C919891193400A0083AC69 /* tommath.h */, + ); + name = libtommath; + path = src/libtommath; + sourceTree = ""; + }; + 22C9182A11933FCF0083AC69 /* hashes */ = { + isa = PBXGroup; + children = ( + 22C9182B11933FCF0083AC69 /* hash_memory.c */, + 22C9182C11933FCF0083AC69 /* md5.c */, + 22C9182D11933FCF0083AC69 /* sha1.c */, + ); + name = hashes; + path = src/hashes; + sourceTree = ""; + }; + 22C9182E11933FCF0083AC69 /* headers */ = { + isa = PBXGroup; + children = ( + 22C9182F11933FCF0083AC69 /* tomcrypt.h */, + 22C9183011933FCF0083AC69 /* tomcrypt_argchk.h */, + 22C9183111933FCF0083AC69 /* tomcrypt_cfg.h */, + 22C9183211933FCF0083AC69 /* tomcrypt_cipher.h */, + 22C9183311933FCF0083AC69 /* tomcrypt_custom.h */, + 22C9183411933FCF0083AC69 /* tomcrypt_hash.h */, + 22C9183511933FCF0083AC69 /* tomcrypt_mac.h */, + 22C9183611933FCF0083AC69 /* tomcrypt_macros.h */, + 22C9183711933FCF0083AC69 /* tomcrypt_math.h */, + 22C9183811933FCF0083AC69 /* tomcrypt_misc.h */, + 22C9183911933FCF0083AC69 /* tomcrypt_pk.h */, + 22C9183A11933FCF0083AC69 /* tomcrypt_pkcs.h */, + 22C9183B11933FCF0083AC69 /* tomcrypt_prng.h */, + ); + name = headers; + path = src/headers; + sourceTree = ""; + }; + 22C9183C11933FCF0083AC69 /* math */ = { + isa = PBXGroup; + children = ( + 22C9183D11933FCF0083AC69 /* ltm_desc.c */, + 22C9183E11933FCF0083AC69 /* multi.c */, + 22C9183F11933FCF0083AC69 /* rand_prime.c */, + ); + name = math; + path = src/math; + sourceTree = ""; + }; + 22C9184011933FCF0083AC69 /* misc */ = { + isa = PBXGroup; + children = ( + 22C9184111933FCF0083AC69 /* base64_decode.c */, + 22C9184211933FCF0083AC69 /* crypt_argchk.c */, + 22C9184311933FCF0083AC69 /* crypt_find_hash.c */, + 22C9184411933FCF0083AC69 /* crypt_find_prng.c */, + 22C9184511933FCF0083AC69 /* crypt_hash_descriptor.c */, + 22C9184611933FCF0083AC69 /* crypt_hash_is_valid.c */, + 22C9184711933FCF0083AC69 /* crypt_libc.c */, + 22C9184811933FCF0083AC69 /* crypt_ltc_mp_descriptor.c */, + 22C9184911933FCF0083AC69 /* crypt_prng_descriptor.c */, + 22C9184A11933FCF0083AC69 /* crypt_prng_is_valid.c */, + 22C9184B11933FCF0083AC69 /* crypt_register_hash.c */, + 22C9184C11933FCF0083AC69 /* crypt_register_prng.c */, + 22C9184D11933FCF0083AC69 /* zeromem.c */, + ); + name = misc; + path = src/misc; + sourceTree = ""; + }; + 22C9184E11933FCF0083AC69 /* pk */ = { + isa = PBXGroup; + children = ( + 22C9184F11933FCF0083AC69 /* asn1 */, + 22C9186A11933FCF0083AC69 /* ecc */, + 22C9187111933FCF0083AC69 /* pkcs1 */, + 22C9187611933FCF0083AC69 /* rsa */, + ); + name = pk; + path = src/pk; + sourceTree = ""; + }; + 22C9184F11933FCF0083AC69 /* asn1 */ = { + isa = PBXGroup; + children = ( + 22C9185011933FCF0083AC69 /* der_decode_bit_string.c */, + 22C9185111933FCF0083AC69 /* der_decode_boolean.c */, + 22C9185211933FCF0083AC69 /* der_decode_choice.c */, + 22C9185311933FCF0083AC69 /* der_decode_ia5_string.c */, + 22C9185411933FCF0083AC69 /* der_decode_integer.c */, + 22C9185511933FCF0083AC69 /* der_decode_object_identifier.c */, + 22C9185611933FCF0083AC69 /* der_decode_octet_string.c */, + 22C9185711933FCF0083AC69 /* der_decode_printable_string.c */, + 22C9185811933FCF0083AC69 /* der_decode_sequence_ex.c */, + 22C9185911933FCF0083AC69 /* der_decode_sequence_flexi.c */, + 22C9185A11933FCF0083AC69 /* der_decode_sequence_multi.c */, + 22C9185B11933FCF0083AC69 /* der_decode_short_integer.c */, + 22C9185C11933FCF0083AC69 /* der_decode_utctime.c */, + 22C9185D11933FCF0083AC69 /* der_decode_utf8_string.c */, + 22C9185E11933FCF0083AC69 /* der_length_bit_string.c */, + 22C9185F11933FCF0083AC69 /* der_length_boolean.c */, + 22C9186011933FCF0083AC69 /* der_length_ia5_string.c */, + 22C9186111933FCF0083AC69 /* der_length_integer.c */, + 22C9186211933FCF0083AC69 /* der_length_object_identifier.c */, + 22C9186311933FCF0083AC69 /* der_length_octet_string.c */, + 22C9186411933FCF0083AC69 /* der_length_printable_string.c */, + 22C9186511933FCF0083AC69 /* der_length_sequence.c */, + 22C9186611933FCF0083AC69 /* der_length_short_integer.c */, + 22C9186711933FCF0083AC69 /* der_length_utctime.c */, + 22C9186811933FCF0083AC69 /* der_length_utf8_string.c */, + 22C9186911933FCF0083AC69 /* der_sequence_free.c */, + ); + path = asn1; + sourceTree = ""; + }; + 22C9186A11933FCF0083AC69 /* ecc */ = { + isa = PBXGroup; + children = ( + 22C9186B11933FCF0083AC69 /* ltc_ecc_map.c */, + 22C9186C11933FCF0083AC69 /* ltc_ecc_mul2add.c */, + 22C9186D11933FCF0083AC69 /* ltc_ecc_mulmod.c */, + 22C9186E11933FCF0083AC69 /* ltc_ecc_points.c */, + 22C9186F11933FCF0083AC69 /* ltc_ecc_projective_add_point.c */, + 22C9187011933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c */, + ); + path = ecc; + sourceTree = ""; + }; + 22C9187111933FCF0083AC69 /* pkcs1 */ = { + isa = PBXGroup; + children = ( + 22C9187211933FCF0083AC69 /* pkcs_1_mgf1.c */, + 22C9187311933FCF0083AC69 /* pkcs_1_oaep_decode.c */, + 22C9187411933FCF0083AC69 /* pkcs_1_pss_decode.c */, + 22C9187511933FCF0083AC69 /* pkcs_1_v1_5_decode.c */, + ); + path = pkcs1; + sourceTree = ""; + }; + 22C9187611933FCF0083AC69 /* rsa */ = { + isa = PBXGroup; + children = ( + 22C9187711933FCF0083AC69 /* rsa_exptmod.c */, + 22C9187811933FCF0083AC69 /* rsa_free.c */, + 22C9187911933FCF0083AC69 /* rsa_import.c */, + 22C9187A11933FCF0083AC69 /* rsa_make_key.c */, + 22C9187B11933FCF0083AC69 /* rsa_verify_hash.c */, + 22C9187C11933FCF0083AC69 /* rsa_verify_simple.c */, + ); + path = rsa; + sourceTree = ""; + }; + 32DBEE830D00E58F00DB1E81 /* Source */ = { + isa = PBXGroup; + children = ( + 2299D9D41167EFA8005C19BF /* adpcm */, + 32ED009B0D03542A00AB0B4E /* huffman */, + 225C734A1257CCC70009E8DA /* jenkins */, + 22C9181D11933E3A0083AC69 /* libtomcrypt */, + 22C9181E11933E470083AC69 /* libtommath */, + 221F652D116851D70026C852 /* lzma */, + 32ED00A40D03542A00AB0B4E /* pklib */, + 2299D9DB1167EFC6005C19BF /* sparse */, + 228B538311BF7D0D001A58DA /* FileStream.cpp */, + 22EC6043154B28A000679228 /* FileStream.h */, + 32ED00AA0D03542A00AB0B4E /* SBaseCommon.cpp */, + 225C73531257CD0C0009E8DA /* SBaseFileTable.cpp */, + 32ED00AC0D03542A00AB0B4E /* SCompression.cpp */, + 2299DA4D1167FD16005C19BF /* SFileAddFile.cpp */, + 32ED00A90D03542A00AB0B4E /* SFileAttributes.cpp */, + 32ED00AD0D03542A00AB0B4E /* SFileCompactArchive.cpp */, + 32ED00AE0D03542A00AB0B4E /* SFileCreateArchive.cpp */, + 32ED00AF0D03542A00AB0B4E /* SFileExtractFile.cpp */, + 32ED00B00D03542A00AB0B4E /* SFileFindFile.cpp */, + 32ED00B40D03542A00AB0B4E /* SFileListFile.cpp */, + 32ED00B10D03542A00AB0B4E /* SFileOpenArchive.cpp */, + 32ED00B20D03542A00AB0B4E /* SFileOpenFileEx.cpp */, + 22AEA121123125D800359B16 /* SFilePatchArchives.cpp */, + 32ED00B30D03542A00AB0B4E /* SFileReadFile.cpp */, + 22F5A9C41193DFBA00F8B121 /* SFileVerify.cpp */, + 32ED00AB0D03542A00AB0B4E /* StormCommon.h */, + 32ED00B60D03542A00AB0B4E /* StormLib.h */, + 32ED00B70D03542A00AB0B4E /* StormPort.h */, + ); + name = Source; + sourceTree = ""; + }; + 32ED009B0D03542A00AB0B4E /* huffman */ = { + isa = PBXGroup; + children = ( + 32ED009C0D03542A00AB0B4E /* huff.cpp */, + 32ED009D0D03542A00AB0B4E /* huff.h */, + ); + name = huffman; + path = src/huffman; + sourceTree = ""; + }; + 32ED00A40D03542A00AB0B4E /* pklib */ = { + isa = PBXGroup; + children = ( + 32ED00A60D03542A00AB0B4E /* explode.c */, + 32ED00A70D03542A00AB0B4E /* implode.c */, + 32ED00A80D03542A00AB0B4E /* pklib.h */, + ); + name = pklib; + path = src/pklib; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 225530D01056BAC800FA646A /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 225530DB1056BC7900FA646A /* huff.h in Headers */, + 225530DE1056BC7900FA646A /* pklib.h in Headers */, + 225530DF1056BC7900FA646A /* StormCommon.h in Headers */, + 225530E01056BC7900FA646A /* StormLib.h in Headers */, + 225530E11056BC7900FA646A /* StormPort.h in Headers */, + 2299D9DA1167EFA8005C19BF /* adpcm.h in Headers */, + 2299D9E11167EFC6005C19BF /* sparse.h in Headers */, + 221F6A761168529C0026C852 /* LzmaDec.h in Headers */, + 221F6A771168529C0026C852 /* LzmaEnc.h in Headers */, + 221F6AB81168545B0026C852 /* LzFind.h in Headers */, + 221F6ABB116854730026C852 /* LzHash.h in Headers */, + 221F6ABE116854870026C852 /* Types.h in Headers */, + 22C9188011933FCF0083AC69 /* tomcrypt.h in Headers */, + 22C9188111933FCF0083AC69 /* tomcrypt_argchk.h in Headers */, + 22C9188211933FCF0083AC69 /* tomcrypt_cfg.h in Headers */, + 22C9188311933FCF0083AC69 /* tomcrypt_cipher.h in Headers */, + 22C9188411933FCF0083AC69 /* tomcrypt_custom.h in Headers */, + 22C9188511933FCF0083AC69 /* tomcrypt_hash.h in Headers */, + 22C9188611933FCF0083AC69 /* tomcrypt_mac.h in Headers */, + 22C9188711933FCF0083AC69 /* tomcrypt_macros.h in Headers */, + 22C9188811933FCF0083AC69 /* tomcrypt_math.h in Headers */, + 22C9188911933FCF0083AC69 /* tomcrypt_misc.h in Headers */, + 22C9188A11933FCF0083AC69 /* tomcrypt_pk.h in Headers */, + 22C9188B11933FCF0083AC69 /* tomcrypt_pkcs.h in Headers */, + 22C9188C11933FCF0083AC69 /* tomcrypt_prng.h in Headers */, + 22C91A001193400A0083AC69 /* tommath_class.h in Headers */, + 22C91A011193400A0083AC69 /* tommath_superclass.h in Headers */, + 22C91A021193400A0083AC69 /* tommath.h in Headers */, + 225C734F1257CCC70009E8DA /* lookup.h in Headers */, + 22EC6044154B28A000679228 /* FileStream.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 225FAC8F0E53B7F800DA2CAE /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 225FAC9C0E53BAA100DA2CAE /* huff.h in Headers */, + 225FAC9F0E53BAA100DA2CAE /* pklib.h in Headers */, + 225FACA00E53BAA100DA2CAE /* StormCommon.h in Headers */, + 225FACA10E53BAA100DA2CAE /* StormLib.h in Headers */, + 225FACA20E53BAA100DA2CAE /* StormPort.h in Headers */, + 2299D9D81167EFA8005C19BF /* adpcm.h in Headers */, + 2299D9DF1167EFC6005C19BF /* sparse.h in Headers */, + 221F6A741168529C0026C852 /* LzmaDec.h in Headers */, + 221F6A751168529C0026C852 /* LzmaEnc.h in Headers */, + 221F6AB61168545B0026C852 /* LzFind.h in Headers */, + 221F6ABA116854730026C852 /* LzHash.h in Headers */, + 221F6ABD116854870026C852 /* Types.h in Headers */, + 22C918CA11933FCF0083AC69 /* tomcrypt.h in Headers */, + 22C918CB11933FCF0083AC69 /* tomcrypt_argchk.h in Headers */, + 22C918CC11933FCF0083AC69 /* tomcrypt_cfg.h in Headers */, + 22C918CD11933FCF0083AC69 /* tomcrypt_cipher.h in Headers */, + 22C918CE11933FCF0083AC69 /* tomcrypt_custom.h in Headers */, + 22C918CF11933FCF0083AC69 /* tomcrypt_hash.h in Headers */, + 22C918D011933FCF0083AC69 /* tomcrypt_mac.h in Headers */, + 22C918D111933FCF0083AC69 /* tomcrypt_macros.h in Headers */, + 22C918D211933FCF0083AC69 /* tomcrypt_math.h in Headers */, + 22C918D311933FCF0083AC69 /* tomcrypt_misc.h in Headers */, + 22C918D411933FCF0083AC69 /* tomcrypt_pk.h in Headers */, + 22C918D511933FCF0083AC69 /* tomcrypt_pkcs.h in Headers */, + 22C918D611933FCF0083AC69 /* tomcrypt_prng.h in Headers */, + 22C91A791193400A0083AC69 /* tommath_class.h in Headers */, + 22C91A7A1193400A0083AC69 /* tommath_superclass.h in Headers */, + 22C91A7B1193400A0083AC69 /* tommath.h in Headers */, + 225C734D1257CCC70009E8DA /* lookup.h in Headers */, + 22EC6045154B28A000679228 /* FileStream.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 225530D31056BAC800FA646A /* StormLib */ = { + isa = PBXNativeTarget; + buildConfigurationList = 225530D71056BB1600FA646A /* Build configuration list for PBXNativeTarget "StormLib" */; + buildPhases = ( + 225530D01056BAC800FA646A /* Headers */, + 225530D11056BAC800FA646A /* Sources */, + 225530D21056BAC800FA646A /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = StormLib; + productName = StormLib; + productReference = 225530D41056BAC800FA646A /* libStormLib.a */; + productType = "com.apple.product-type.library.static"; + }; + 225FAC930E53B7F800DA2CAE /* StormLibFramework */ = { + isa = PBXNativeTarget; + buildConfigurationList = 225FAC980E53B7F900DA2CAE /* Build configuration list for PBXNativeTarget "StormLibFramework" */; + buildPhases = ( + 225FAC8F0E53B7F800DA2CAE /* Headers */, + 225FAC900E53B7F800DA2CAE /* Resources */, + 225FAC910E53B7F800DA2CAE /* Sources */, + 225FAC920E53B7F800DA2CAE /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = StormLibFramework; + productName = StormLib; + productReference = 225FAC940E53B7F800DA2CAE /* StormLib.framework */; + productType = "com.apple.product-type.framework"; + }; + 22954ACD11D463A30064B264 /* StormLib_Test */ = { + isa = PBXNativeTarget; + buildConfigurationList = 22954AD911D463E00064B264 /* Build configuration list for PBXNativeTarget "StormLib_Test" */; + buildPhases = ( + 22954ACB11D463A30064B264 /* Sources */, + 22954ACC11D463A30064B264 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 2229F62F11D4653600118914 /* PBXTargetDependency */, + ); + name = StormLib_Test; + productName = StormLib_Test; + productReference = 22954ACE11D463A30064B264 /* StormLib_Test */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0867D690FE84028FC02AAC07 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; + buildConfigurationList = 1DEB916408733D950010E9CD /* Build configuration list for PBXProject "StormLib" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + en, + ); + mainGroup = 0867D691FE84028FC02AAC07 /* stormlib */; + productRefGroup = 034768DDFF38A45A11DB9C8B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 225530D31056BAC800FA646A /* StormLib */, + 225FAC930E53B7F800DA2CAE /* StormLibFramework */, + 22954ACD11D463A30064B264 /* StormLib_Test */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 225FAC900E53B7F800DA2CAE /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 225530D11056BAC800FA646A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 225530E31056BC8700FA646A /* huff.cpp in Sources */, + 225530E61056BC8700FA646A /* explode.c in Sources */, + 225530E71056BC8700FA646A /* implode.c in Sources */, + 225530E81056BC8700FA646A /* SFileAttributes.cpp in Sources */, + 225530E91056BC8700FA646A /* SBaseCommon.cpp in Sources */, + 225530EA1056BC8700FA646A /* SCompression.cpp in Sources */, + 225530EB1056BC8700FA646A /* SFileCompactArchive.cpp in Sources */, + 225530EC1056BC8700FA646A /* SFileCreateArchive.cpp in Sources */, + 225530ED1056BC8700FA646A /* SFileExtractFile.cpp in Sources */, + 225530EE1056BC8700FA646A /* SFileFindFile.cpp in Sources */, + 225530EF1056BC8700FA646A /* SFileOpenArchive.cpp in Sources */, + 225530F01056BC8700FA646A /* SFileOpenFileEx.cpp in Sources */, + 225530F11056BC8700FA646A /* SFileReadFile.cpp in Sources */, + 225530F21056BC8700FA646A /* SFileListFile.cpp in Sources */, + 2299D9D91167EFA8005C19BF /* adpcm.cpp in Sources */, + 2299D9E01167EFC6005C19BF /* sparse.cpp in Sources */, + 2299DA4F1167FD16005C19BF /* SFileAddFile.cpp in Sources */, + 221F6A7C116852AA0026C852 /* LzmaEnc.c in Sources */, + 221F6A7F116852B20026C852 /* LzmaDec.c in Sources */, + 221F6AB71168545B0026C852 /* LzFind.c in Sources */, + 22C9187D11933FCF0083AC69 /* hash_memory.c in Sources */, + 22C9187E11933FCF0083AC69 /* md5.c in Sources */, + 22C9187F11933FCF0083AC69 /* sha1.c in Sources */, + 22C9188D11933FCF0083AC69 /* ltm_desc.c in Sources */, + 22C9188E11933FCF0083AC69 /* multi.c in Sources */, + 22C9188F11933FCF0083AC69 /* rand_prime.c in Sources */, + 22C9189011933FCF0083AC69 /* base64_decode.c in Sources */, + 22C9189111933FCF0083AC69 /* crypt_argchk.c in Sources */, + 22C9189211933FCF0083AC69 /* crypt_find_hash.c in Sources */, + 22C9189311933FCF0083AC69 /* crypt_find_prng.c in Sources */, + 22C9189411933FCF0083AC69 /* crypt_hash_descriptor.c in Sources */, + 22C9189511933FCF0083AC69 /* crypt_hash_is_valid.c in Sources */, + 22C9189611933FCF0083AC69 /* crypt_libc.c in Sources */, + 2254917B11948CE70044424D /* crypt_ltc_mp_descriptor.c in Sources */, + 22C9189811933FCF0083AC69 /* crypt_prng_descriptor.c in Sources */, + 22C9189911933FCF0083AC69 /* crypt_prng_is_valid.c in Sources */, + 22C9189A11933FCF0083AC69 /* crypt_register_hash.c in Sources */, + 22C9189B11933FCF0083AC69 /* crypt_register_prng.c in Sources */, + 22C9189C11933FCF0083AC69 /* zeromem.c in Sources */, + 22C9189D11933FCF0083AC69 /* der_decode_bit_string.c in Sources */, + 22C9189E11933FCF0083AC69 /* der_decode_boolean.c in Sources */, + 22C9189F11933FCF0083AC69 /* der_decode_choice.c in Sources */, + 22C918A011933FCF0083AC69 /* der_decode_ia5_string.c in Sources */, + 22C918A111933FCF0083AC69 /* der_decode_integer.c in Sources */, + 22C918A211933FCF0083AC69 /* der_decode_object_identifier.c in Sources */, + 22C918A311933FCF0083AC69 /* der_decode_octet_string.c in Sources */, + 22C918A411933FCF0083AC69 /* der_decode_printable_string.c in Sources */, + 22C918A511933FCF0083AC69 /* der_decode_sequence_ex.c in Sources */, + 22C918A611933FCF0083AC69 /* der_decode_sequence_flexi.c in Sources */, + 22C918A711933FCF0083AC69 /* der_decode_sequence_multi.c in Sources */, + 22C918A811933FCF0083AC69 /* der_decode_short_integer.c in Sources */, + 22C918A911933FCF0083AC69 /* der_decode_utctime.c in Sources */, + 22C918AA11933FCF0083AC69 /* der_decode_utf8_string.c in Sources */, + 22C918AB11933FCF0083AC69 /* der_length_bit_string.c in Sources */, + 22C918AC11933FCF0083AC69 /* der_length_boolean.c in Sources */, + 22C918AD11933FCF0083AC69 /* der_length_ia5_string.c in Sources */, + 22C918AE11933FCF0083AC69 /* der_length_integer.c in Sources */, + 22C918AF11933FCF0083AC69 /* der_length_object_identifier.c in Sources */, + 22C918B011933FCF0083AC69 /* der_length_octet_string.c in Sources */, + 22C918B111933FCF0083AC69 /* der_length_printable_string.c in Sources */, + 22C918B211933FCF0083AC69 /* der_length_sequence.c in Sources */, + 22C918B311933FCF0083AC69 /* der_length_short_integer.c in Sources */, + 22C918B411933FCF0083AC69 /* der_length_utctime.c in Sources */, + 22C918B511933FCF0083AC69 /* der_length_utf8_string.c in Sources */, + 22C918B611933FCF0083AC69 /* der_sequence_free.c in Sources */, + 22C918B711933FCF0083AC69 /* ltc_ecc_map.c in Sources */, + 22C918B811933FCF0083AC69 /* ltc_ecc_mul2add.c in Sources */, + 22C918B911933FCF0083AC69 /* ltc_ecc_mulmod.c in Sources */, + 22C918BA11933FCF0083AC69 /* ltc_ecc_points.c in Sources */, + 22C918BB11933FCF0083AC69 /* ltc_ecc_projective_add_point.c in Sources */, + 22C918BC11933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c in Sources */, + 22C918BD11933FCF0083AC69 /* pkcs_1_mgf1.c in Sources */, + 22C918BE11933FCF0083AC69 /* pkcs_1_oaep_decode.c in Sources */, + 22C918BF11933FCF0083AC69 /* pkcs_1_pss_decode.c in Sources */, + 22C918C011933FCF0083AC69 /* pkcs_1_v1_5_decode.c in Sources */, + 22C918C111933FCF0083AC69 /* rsa_exptmod.c in Sources */, + 22C918C211933FCF0083AC69 /* rsa_free.c in Sources */, + 22C918C311933FCF0083AC69 /* rsa_import.c in Sources */, + 22C918C411933FCF0083AC69 /* rsa_make_key.c in Sources */, + 22C918C511933FCF0083AC69 /* rsa_verify_hash.c in Sources */, + 22C918C611933FCF0083AC69 /* rsa_verify_simple.c in Sources */, + 22C9198A1193400A0083AC69 /* bn_fast_mp_invmod.c in Sources */, + 22C9198B1193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c in Sources */, + 22C9198C1193400A0083AC69 /* bn_fast_s_mp_mul_digs.c in Sources */, + 22C9198D1193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c in Sources */, + 22C9198E1193400A0083AC69 /* bn_fast_s_mp_sqr.c in Sources */, + 22C9198F1193400A0083AC69 /* bn_mp_2expt.c in Sources */, + 22C919901193400A0083AC69 /* bn_mp_abs.c in Sources */, + 22C919911193400A0083AC69 /* bn_mp_add_d.c in Sources */, + 22C919921193400A0083AC69 /* bn_mp_add.c in Sources */, + 22C919931193400A0083AC69 /* bn_mp_addmod.c in Sources */, + 22C919941193400A0083AC69 /* bn_mp_and.c in Sources */, + 22C919951193400A0083AC69 /* bn_mp_clamp.c in Sources */, + 22C919961193400A0083AC69 /* bn_mp_clear_multi.c in Sources */, + 22C919971193400A0083AC69 /* bn_mp_clear.c in Sources */, + 22C919981193400A0083AC69 /* bn_mp_cmp_d.c in Sources */, + 22C919991193400A0083AC69 /* bn_mp_cmp_mag.c in Sources */, + 22C9199A1193400A0083AC69 /* bn_mp_cmp.c in Sources */, + 22C9199B1193400A0083AC69 /* bn_mp_cnt_lsb.c in Sources */, + 22C9199C1193400A0083AC69 /* bn_mp_copy.c in Sources */, + 22C9199D1193400A0083AC69 /* bn_mp_count_bits.c in Sources */, + 22C9199E1193400A0083AC69 /* bn_mp_div_2.c in Sources */, + 22C9199F1193400A0083AC69 /* bn_mp_div_2d.c in Sources */, + 22C919A01193400A0083AC69 /* bn_mp_div_3.c in Sources */, + 22C919A11193400A0083AC69 /* bn_mp_div_d.c in Sources */, + 22C919A21193400A0083AC69 /* bn_mp_div.c in Sources */, + 22C919A31193400A0083AC69 /* bn_mp_dr_is_modulus.c in Sources */, + 22C919A41193400A0083AC69 /* bn_mp_dr_reduce.c in Sources */, + 22C919A51193400A0083AC69 /* bn_mp_dr_setup.c in Sources */, + 22C919A61193400A0083AC69 /* bn_mp_exch.c in Sources */, + 22C919A71193400A0083AC69 /* bn_mp_expt_d.c in Sources */, + 22C919A81193400A0083AC69 /* bn_mp_exptmod_fast.c in Sources */, + 22C919A91193400A0083AC69 /* bn_mp_exptmod.c in Sources */, + 22C919AA1193400A0083AC69 /* bn_mp_exteuclid.c in Sources */, + 22C919AB1193400A0083AC69 /* bn_mp_fread.c in Sources */, + 22C919AC1193400A0083AC69 /* bn_mp_fwrite.c in Sources */, + 22C919AD1193400A0083AC69 /* bn_mp_gcd.c in Sources */, + 22C919AE1193400A0083AC69 /* bn_mp_get_int.c in Sources */, + 22C919AF1193400A0083AC69 /* bn_mp_grow.c in Sources */, + 22C919B01193400A0083AC69 /* bn_mp_init_copy.c in Sources */, + 22C919B11193400A0083AC69 /* bn_mp_init_multi.c in Sources */, + 22C919B21193400A0083AC69 /* bn_mp_init_set_int.c in Sources */, + 22C919B31193400A0083AC69 /* bn_mp_init_set.c in Sources */, + 22C919B41193400A0083AC69 /* bn_mp_init_size.c in Sources */, + 22C919B51193400A0083AC69 /* bn_mp_init.c in Sources */, + 22C919B61193400A0083AC69 /* bn_mp_invmod_slow.c in Sources */, + 22C919B71193400A0083AC69 /* bn_mp_invmod.c in Sources */, + 22C919B81193400A0083AC69 /* bn_mp_is_square.c in Sources */, + 22C919B91193400A0083AC69 /* bn_mp_jacobi.c in Sources */, + 22C919BA1193400A0083AC69 /* bn_mp_karatsuba_mul.c in Sources */, + 22C919BB1193400A0083AC69 /* bn_mp_karatsuba_sqr.c in Sources */, + 22C919BC1193400A0083AC69 /* bn_mp_lcm.c in Sources */, + 22C919BD1193400A0083AC69 /* bn_mp_lshd.c in Sources */, + 22C919BE1193400A0083AC69 /* bn_mp_mod_2d.c in Sources */, + 22C919BF1193400A0083AC69 /* bn_mp_mod_d.c in Sources */, + 22C919C01193400A0083AC69 /* bn_mp_mod.c in Sources */, + 22C919C11193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c in Sources */, + 22C919C21193400A0083AC69 /* bn_mp_montgomery_reduce.c in Sources */, + 22C919C31193400A0083AC69 /* bn_mp_montgomery_setup.c in Sources */, + 22C919C41193400A0083AC69 /* bn_mp_mul_2.c in Sources */, + 22C919C51193400A0083AC69 /* bn_mp_mul_2d.c in Sources */, + 22C919C61193400A0083AC69 /* bn_mp_mul_d.c in Sources */, + 22C919C71193400A0083AC69 /* bn_mp_mul.c in Sources */, + 22C919C81193400A0083AC69 /* bn_mp_mulmod.c in Sources */, + 22C919C91193400A0083AC69 /* bn_mp_n_root.c in Sources */, + 22C919CA1193400A0083AC69 /* bn_mp_neg.c in Sources */, + 22C919CB1193400A0083AC69 /* bn_mp_or.c in Sources */, + 22C919CC1193400A0083AC69 /* bn_mp_prime_fermat.c in Sources */, + 22C919CD1193400A0083AC69 /* bn_mp_prime_is_divisible.c in Sources */, + 22C919CE1193400A0083AC69 /* bn_mp_prime_is_prime.c in Sources */, + 22C919CF1193400A0083AC69 /* bn_mp_prime_miller_rabin.c in Sources */, + 22C919D01193400A0083AC69 /* bn_mp_prime_next_prime.c in Sources */, + 22C919D11193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c in Sources */, + 22C919D21193400A0083AC69 /* bn_mp_prime_random_ex.c in Sources */, + 22C919D31193400A0083AC69 /* bn_mp_radix_size.c in Sources */, + 22C919D41193400A0083AC69 /* bn_mp_radix_smap.c in Sources */, + 22C919D51193400A0083AC69 /* bn_mp_rand.c in Sources */, + 22C919D61193400A0083AC69 /* bn_mp_read_radix.c in Sources */, + 22C919D71193400A0083AC69 /* bn_mp_read_signed_bin.c in Sources */, + 22C919D81193400A0083AC69 /* bn_mp_read_unsigned_bin.c in Sources */, + 22C919D91193400A0083AC69 /* bn_mp_reduce_2k_l.c in Sources */, + 22C919DA1193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c in Sources */, + 22C919DB1193400A0083AC69 /* bn_mp_reduce_2k_setup.c in Sources */, + 22C919DC1193400A0083AC69 /* bn_mp_reduce_2k.c in Sources */, + 22C919DD1193400A0083AC69 /* bn_mp_reduce_is_2k_l.c in Sources */, + 22C919DE1193400A0083AC69 /* bn_mp_reduce_is_2k.c in Sources */, + 22C919DF1193400A0083AC69 /* bn_mp_reduce_setup.c in Sources */, + 22C919E01193400A0083AC69 /* bn_mp_reduce.c in Sources */, + 22C919E11193400A0083AC69 /* bn_mp_rshd.c in Sources */, + 22C919E21193400A0083AC69 /* bn_mp_set_int.c in Sources */, + 22C919E31193400A0083AC69 /* bn_mp_set.c in Sources */, + 22C919E41193400A0083AC69 /* bn_mp_shrink.c in Sources */, + 22C919E51193400A0083AC69 /* bn_mp_signed_bin_size.c in Sources */, + 22C919E61193400A0083AC69 /* bn_mp_sqr.c in Sources */, + 22C919E71193400A0083AC69 /* bn_mp_sqrmod.c in Sources */, + 22C919E81193400A0083AC69 /* bn_mp_sqrt.c in Sources */, + 22C919E91193400A0083AC69 /* bn_mp_sub_d.c in Sources */, + 22C919EA1193400A0083AC69 /* bn_mp_sub.c in Sources */, + 22C919EB1193400A0083AC69 /* bn_mp_submod.c in Sources */, + 22C919EC1193400A0083AC69 /* bn_mp_to_signed_bin_n.c in Sources */, + 22C919ED1193400A0083AC69 /* bn_mp_to_signed_bin.c in Sources */, + 22C919EE1193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c in Sources */, + 22C919EF1193400A0083AC69 /* bn_mp_to_unsigned_bin.c in Sources */, + 22C919F01193400A0083AC69 /* bn_mp_toom_mul.c in Sources */, + 22C919F11193400A0083AC69 /* bn_mp_toom_sqr.c in Sources */, + 22C919F21193400A0083AC69 /* bn_mp_toradix_n.c in Sources */, + 22C919F31193400A0083AC69 /* bn_mp_toradix.c in Sources */, + 22C919F41193400A0083AC69 /* bn_mp_unsigned_bin_size.c in Sources */, + 22C919F51193400A0083AC69 /* bn_mp_xor.c in Sources */, + 22C919F61193400A0083AC69 /* bn_mp_zero.c in Sources */, + 22C919F71193400A0083AC69 /* bn_prime_tab.c in Sources */, + 22C919F81193400A0083AC69 /* bn_reverse.c in Sources */, + 22C919F91193400A0083AC69 /* bn_s_mp_add.c in Sources */, + 22C919FA1193400A0083AC69 /* bn_s_mp_exptmod.c in Sources */, + 22C919FB1193400A0083AC69 /* bn_s_mp_mul_digs.c in Sources */, + 22C919FC1193400A0083AC69 /* bn_s_mp_mul_high_digs.c in Sources */, + 22C919FD1193400A0083AC69 /* bn_s_mp_sqr.c in Sources */, + 22C919FE1193400A0083AC69 /* bn_s_mp_sub.c in Sources */, + 22C919FF1193400A0083AC69 /* bncore.c in Sources */, + 22F5A9C51193DFBA00F8B121 /* SFileVerify.cpp in Sources */, + 228B538511BF7D0D001A58DA /* FileStream.cpp in Sources */, + 22AEA123123125D800359B16 /* SFilePatchArchives.cpp in Sources */, + 225C73501257CCC70009E8DA /* lookup3.c in Sources */, + 225C73551257CD0C0009E8DA /* SBaseFileTable.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 225FAC910E53B7F800DA2CAE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 225FACA50E53BAB400DA2CAE /* huff.cpp in Sources */, + 225FACA90E53BAB400DA2CAE /* explode.c in Sources */, + 225FACAA0E53BAB400DA2CAE /* implode.c in Sources */, + 225FACAB0E53BAB400DA2CAE /* SFileAttributes.cpp in Sources */, + 225FACAC0E53BAB400DA2CAE /* SBaseCommon.cpp in Sources */, + 225FACAD0E53BAB400DA2CAE /* SCompression.cpp in Sources */, + 225FACAE0E53BAB400DA2CAE /* SFileCompactArchive.cpp in Sources */, + 225FACAF0E53BAB400DA2CAE /* SFileCreateArchive.cpp in Sources */, + 225FACB00E53BAB400DA2CAE /* SFileExtractFile.cpp in Sources */, + 225FACB10E53BAB400DA2CAE /* SFileFindFile.cpp in Sources */, + 225FACB20E53BAB400DA2CAE /* SFileOpenArchive.cpp in Sources */, + 225FACB30E53BAB400DA2CAE /* SFileOpenFileEx.cpp in Sources */, + 225FACB40E53BAB400DA2CAE /* SFileReadFile.cpp in Sources */, + 225FACB50E53BAB400DA2CAE /* SFileListFile.cpp in Sources */, + 2299D9D71167EFA8005C19BF /* adpcm.cpp in Sources */, + 2299D9DE1167EFC6005C19BF /* sparse.cpp in Sources */, + 2299DA4E1167FD16005C19BF /* SFileAddFile.cpp in Sources */, + 221F6A7B116852AA0026C852 /* LzmaEnc.c in Sources */, + 221F6A7E116852B20026C852 /* LzmaDec.c in Sources */, + 221F6AB51168545B0026C852 /* LzFind.c in Sources */, + 22C918C711933FCF0083AC69 /* hash_memory.c in Sources */, + 22C918C811933FCF0083AC69 /* md5.c in Sources */, + 22C918C911933FCF0083AC69 /* sha1.c in Sources */, + 22C918D711933FCF0083AC69 /* ltm_desc.c in Sources */, + 22C918D811933FCF0083AC69 /* multi.c in Sources */, + 22C918D911933FCF0083AC69 /* rand_prime.c in Sources */, + 22C918DA11933FCF0083AC69 /* base64_decode.c in Sources */, + 22C918DB11933FCF0083AC69 /* crypt_argchk.c in Sources */, + 22C918DC11933FCF0083AC69 /* crypt_find_hash.c in Sources */, + 22C918DD11933FCF0083AC69 /* crypt_find_prng.c in Sources */, + 22C918DE11933FCF0083AC69 /* crypt_hash_descriptor.c in Sources */, + 22C918DF11933FCF0083AC69 /* crypt_hash_is_valid.c in Sources */, + 22C918E011933FCF0083AC69 /* crypt_libc.c in Sources */, + 22C918E111933FCF0083AC69 /* crypt_ltc_mp_descriptor.c in Sources */, + 22C918E211933FCF0083AC69 /* crypt_prng_descriptor.c in Sources */, + 22C918E311933FCF0083AC69 /* crypt_prng_is_valid.c in Sources */, + 22C918E411933FCF0083AC69 /* crypt_register_hash.c in Sources */, + 22C918E511933FCF0083AC69 /* crypt_register_prng.c in Sources */, + 22C918E611933FCF0083AC69 /* zeromem.c in Sources */, + 22C918E711933FCF0083AC69 /* der_decode_bit_string.c in Sources */, + 22C918E811933FCF0083AC69 /* der_decode_boolean.c in Sources */, + 22C918E911933FCF0083AC69 /* der_decode_choice.c in Sources */, + 22C918EA11933FCF0083AC69 /* der_decode_ia5_string.c in Sources */, + 22C918EB11933FCF0083AC69 /* der_decode_integer.c in Sources */, + 22C918EC11933FCF0083AC69 /* der_decode_object_identifier.c in Sources */, + 22C918ED11933FCF0083AC69 /* der_decode_octet_string.c in Sources */, + 22C918EE11933FCF0083AC69 /* der_decode_printable_string.c in Sources */, + 22C918EF11933FCF0083AC69 /* der_decode_sequence_ex.c in Sources */, + 22C918F011933FCF0083AC69 /* der_decode_sequence_flexi.c in Sources */, + 22C918F111933FCF0083AC69 /* der_decode_sequence_multi.c in Sources */, + 22C918F211933FCF0083AC69 /* der_decode_short_integer.c in Sources */, + 22C918F311933FCF0083AC69 /* der_decode_utctime.c in Sources */, + 22C918F411933FCF0083AC69 /* der_decode_utf8_string.c in Sources */, + 22C918F511933FCF0083AC69 /* der_length_bit_string.c in Sources */, + 22C918F611933FCF0083AC69 /* der_length_boolean.c in Sources */, + 22C918F711933FCF0083AC69 /* der_length_ia5_string.c in Sources */, + 22C918F811933FCF0083AC69 /* der_length_integer.c in Sources */, + 22C918F911933FCF0083AC69 /* der_length_object_identifier.c in Sources */, + 22C918FA11933FCF0083AC69 /* der_length_octet_string.c in Sources */, + 22C918FB11933FCF0083AC69 /* der_length_printable_string.c in Sources */, + 22C918FC11933FCF0083AC69 /* der_length_sequence.c in Sources */, + 22C918FD11933FCF0083AC69 /* der_length_short_integer.c in Sources */, + 22C918FE11933FCF0083AC69 /* der_length_utctime.c in Sources */, + 22C918FF11933FCF0083AC69 /* der_length_utf8_string.c in Sources */, + 22C9190011933FCF0083AC69 /* der_sequence_free.c in Sources */, + 22C9190111933FCF0083AC69 /* ltc_ecc_map.c in Sources */, + 22C9190211933FCF0083AC69 /* ltc_ecc_mul2add.c in Sources */, + 22C9190311933FCF0083AC69 /* ltc_ecc_mulmod.c in Sources */, + 22C9190411933FCF0083AC69 /* ltc_ecc_points.c in Sources */, + 22C9190511933FCF0083AC69 /* ltc_ecc_projective_add_point.c in Sources */, + 22C9190611933FCF0083AC69 /* ltc_ecc_projective_dbl_point.c in Sources */, + 22C9190711933FCF0083AC69 /* pkcs_1_mgf1.c in Sources */, + 22C9190811933FCF0083AC69 /* pkcs_1_oaep_decode.c in Sources */, + 22C9190911933FCF0083AC69 /* pkcs_1_pss_decode.c in Sources */, + 22C9190A11933FCF0083AC69 /* pkcs_1_v1_5_decode.c in Sources */, + 22C9190B11933FCF0083AC69 /* rsa_exptmod.c in Sources */, + 22C9190C11933FCF0083AC69 /* rsa_free.c in Sources */, + 22C9190D11933FCF0083AC69 /* rsa_import.c in Sources */, + 22C9190E11933FCF0083AC69 /* rsa_make_key.c in Sources */, + 22C9190F11933FCF0083AC69 /* rsa_verify_hash.c in Sources */, + 22C9191011933FCF0083AC69 /* rsa_verify_simple.c in Sources */, + 22C91A031193400A0083AC69 /* bn_fast_mp_invmod.c in Sources */, + 22C91A041193400A0083AC69 /* bn_fast_mp_montgomery_reduce.c in Sources */, + 22C91A051193400A0083AC69 /* bn_fast_s_mp_mul_digs.c in Sources */, + 22C91A061193400A0083AC69 /* bn_fast_s_mp_mul_high_digs.c in Sources */, + 22C91A071193400A0083AC69 /* bn_fast_s_mp_sqr.c in Sources */, + 22C91A081193400A0083AC69 /* bn_mp_2expt.c in Sources */, + 22C91A091193400A0083AC69 /* bn_mp_abs.c in Sources */, + 22C91A0A1193400A0083AC69 /* bn_mp_add_d.c in Sources */, + 22C91A0B1193400A0083AC69 /* bn_mp_add.c in Sources */, + 22C91A0C1193400A0083AC69 /* bn_mp_addmod.c in Sources */, + 22C91A0D1193400A0083AC69 /* bn_mp_and.c in Sources */, + 22C91A0E1193400A0083AC69 /* bn_mp_clamp.c in Sources */, + 22C91A0F1193400A0083AC69 /* bn_mp_clear_multi.c in Sources */, + 22C91A101193400A0083AC69 /* bn_mp_clear.c in Sources */, + 22C91A111193400A0083AC69 /* bn_mp_cmp_d.c in Sources */, + 22C91A121193400A0083AC69 /* bn_mp_cmp_mag.c in Sources */, + 22C91A131193400A0083AC69 /* bn_mp_cmp.c in Sources */, + 22C91A141193400A0083AC69 /* bn_mp_cnt_lsb.c in Sources */, + 22C91A151193400A0083AC69 /* bn_mp_copy.c in Sources */, + 22C91A161193400A0083AC69 /* bn_mp_count_bits.c in Sources */, + 22C91A171193400A0083AC69 /* bn_mp_div_2.c in Sources */, + 22C91A181193400A0083AC69 /* bn_mp_div_2d.c in Sources */, + 22C91A191193400A0083AC69 /* bn_mp_div_3.c in Sources */, + 22C91A1A1193400A0083AC69 /* bn_mp_div_d.c in Sources */, + 22C91A1B1193400A0083AC69 /* bn_mp_div.c in Sources */, + 22C91A1C1193400A0083AC69 /* bn_mp_dr_is_modulus.c in Sources */, + 22C91A1D1193400A0083AC69 /* bn_mp_dr_reduce.c in Sources */, + 22C91A1E1193400A0083AC69 /* bn_mp_dr_setup.c in Sources */, + 22C91A1F1193400A0083AC69 /* bn_mp_exch.c in Sources */, + 22C91A201193400A0083AC69 /* bn_mp_expt_d.c in Sources */, + 22C91A211193400A0083AC69 /* bn_mp_exptmod_fast.c in Sources */, + 22C91A221193400A0083AC69 /* bn_mp_exptmod.c in Sources */, + 22C91A231193400A0083AC69 /* bn_mp_exteuclid.c in Sources */, + 22C91A241193400A0083AC69 /* bn_mp_fread.c in Sources */, + 22C91A251193400A0083AC69 /* bn_mp_fwrite.c in Sources */, + 22C91A261193400A0083AC69 /* bn_mp_gcd.c in Sources */, + 22C91A271193400A0083AC69 /* bn_mp_get_int.c in Sources */, + 22C91A281193400A0083AC69 /* bn_mp_grow.c in Sources */, + 22C91A291193400A0083AC69 /* bn_mp_init_copy.c in Sources */, + 22C91A2A1193400A0083AC69 /* bn_mp_init_multi.c in Sources */, + 22C91A2B1193400A0083AC69 /* bn_mp_init_set_int.c in Sources */, + 22C91A2C1193400A0083AC69 /* bn_mp_init_set.c in Sources */, + 22C91A2D1193400A0083AC69 /* bn_mp_init_size.c in Sources */, + 22C91A2E1193400A0083AC69 /* bn_mp_init.c in Sources */, + 22C91A2F1193400A0083AC69 /* bn_mp_invmod_slow.c in Sources */, + 22C91A301193400A0083AC69 /* bn_mp_invmod.c in Sources */, + 22C91A311193400A0083AC69 /* bn_mp_is_square.c in Sources */, + 22C91A321193400A0083AC69 /* bn_mp_jacobi.c in Sources */, + 22C91A331193400A0083AC69 /* bn_mp_karatsuba_mul.c in Sources */, + 22C91A341193400A0083AC69 /* bn_mp_karatsuba_sqr.c in Sources */, + 22C91A351193400A0083AC69 /* bn_mp_lcm.c in Sources */, + 22C91A361193400A0083AC69 /* bn_mp_lshd.c in Sources */, + 22C91A371193400A0083AC69 /* bn_mp_mod_2d.c in Sources */, + 22C91A381193400A0083AC69 /* bn_mp_mod_d.c in Sources */, + 22C91A391193400A0083AC69 /* bn_mp_mod.c in Sources */, + 22C91A3A1193400A0083AC69 /* bn_mp_montgomery_calc_normalization.c in Sources */, + 22C91A3B1193400A0083AC69 /* bn_mp_montgomery_reduce.c in Sources */, + 22C91A3C1193400A0083AC69 /* bn_mp_montgomery_setup.c in Sources */, + 22C91A3D1193400A0083AC69 /* bn_mp_mul_2.c in Sources */, + 22C91A3E1193400A0083AC69 /* bn_mp_mul_2d.c in Sources */, + 22C91A3F1193400A0083AC69 /* bn_mp_mul_d.c in Sources */, + 22C91A401193400A0083AC69 /* bn_mp_mul.c in Sources */, + 22C91A411193400A0083AC69 /* bn_mp_mulmod.c in Sources */, + 22C91A421193400A0083AC69 /* bn_mp_n_root.c in Sources */, + 22C91A431193400A0083AC69 /* bn_mp_neg.c in Sources */, + 22C91A441193400A0083AC69 /* bn_mp_or.c in Sources */, + 22C91A451193400A0083AC69 /* bn_mp_prime_fermat.c in Sources */, + 22C91A461193400A0083AC69 /* bn_mp_prime_is_divisible.c in Sources */, + 22C91A471193400A0083AC69 /* bn_mp_prime_is_prime.c in Sources */, + 22C91A481193400A0083AC69 /* bn_mp_prime_miller_rabin.c in Sources */, + 22C91A491193400A0083AC69 /* bn_mp_prime_next_prime.c in Sources */, + 22C91A4A1193400A0083AC69 /* bn_mp_prime_rabin_miller_trials.c in Sources */, + 22C91A4B1193400A0083AC69 /* bn_mp_prime_random_ex.c in Sources */, + 22C91A4C1193400A0083AC69 /* bn_mp_radix_size.c in Sources */, + 22C91A4D1193400A0083AC69 /* bn_mp_radix_smap.c in Sources */, + 22C91A4E1193400A0083AC69 /* bn_mp_rand.c in Sources */, + 22C91A4F1193400A0083AC69 /* bn_mp_read_radix.c in Sources */, + 22C91A501193400A0083AC69 /* bn_mp_read_signed_bin.c in Sources */, + 22C91A511193400A0083AC69 /* bn_mp_read_unsigned_bin.c in Sources */, + 22C91A521193400A0083AC69 /* bn_mp_reduce_2k_l.c in Sources */, + 22C91A531193400A0083AC69 /* bn_mp_reduce_2k_setup_l.c in Sources */, + 22C91A541193400A0083AC69 /* bn_mp_reduce_2k_setup.c in Sources */, + 22C91A551193400A0083AC69 /* bn_mp_reduce_2k.c in Sources */, + 22C91A561193400A0083AC69 /* bn_mp_reduce_is_2k_l.c in Sources */, + 22C91A571193400A0083AC69 /* bn_mp_reduce_is_2k.c in Sources */, + 22C91A581193400A0083AC69 /* bn_mp_reduce_setup.c in Sources */, + 22C91A591193400A0083AC69 /* bn_mp_reduce.c in Sources */, + 22C91A5A1193400A0083AC69 /* bn_mp_rshd.c in Sources */, + 22C91A5B1193400A0083AC69 /* bn_mp_set_int.c in Sources */, + 22C91A5C1193400A0083AC69 /* bn_mp_set.c in Sources */, + 22C91A5D1193400A0083AC69 /* bn_mp_shrink.c in Sources */, + 22C91A5E1193400A0083AC69 /* bn_mp_signed_bin_size.c in Sources */, + 22C91A5F1193400A0083AC69 /* bn_mp_sqr.c in Sources */, + 22C91A601193400A0083AC69 /* bn_mp_sqrmod.c in Sources */, + 22C91A611193400A0083AC69 /* bn_mp_sqrt.c in Sources */, + 22C91A621193400A0083AC69 /* bn_mp_sub_d.c in Sources */, + 22C91A631193400A0083AC69 /* bn_mp_sub.c in Sources */, + 22C91A641193400A0083AC69 /* bn_mp_submod.c in Sources */, + 22C91A651193400A0083AC69 /* bn_mp_to_signed_bin_n.c in Sources */, + 22C91A661193400A0083AC69 /* bn_mp_to_signed_bin.c in Sources */, + 22C91A671193400A0083AC69 /* bn_mp_to_unsigned_bin_n.c in Sources */, + 22C91A681193400A0083AC69 /* bn_mp_to_unsigned_bin.c in Sources */, + 22C91A691193400A0083AC69 /* bn_mp_toom_mul.c in Sources */, + 22C91A6A1193400A0083AC69 /* bn_mp_toom_sqr.c in Sources */, + 22C91A6B1193400A0083AC69 /* bn_mp_toradix_n.c in Sources */, + 22C91A6C1193400A0083AC69 /* bn_mp_toradix.c in Sources */, + 22C91A6D1193400A0083AC69 /* bn_mp_unsigned_bin_size.c in Sources */, + 22C91A6E1193400A0083AC69 /* bn_mp_xor.c in Sources */, + 22C91A6F1193400A0083AC69 /* bn_mp_zero.c in Sources */, + 22C91A701193400A0083AC69 /* bn_prime_tab.c in Sources */, + 22C91A711193400A0083AC69 /* bn_reverse.c in Sources */, + 22C91A721193400A0083AC69 /* bn_s_mp_add.c in Sources */, + 22C91A731193400A0083AC69 /* bn_s_mp_exptmod.c in Sources */, + 22C91A741193400A0083AC69 /* bn_s_mp_mul_digs.c in Sources */, + 22C91A751193400A0083AC69 /* bn_s_mp_mul_high_digs.c in Sources */, + 22C91A761193400A0083AC69 /* bn_s_mp_sqr.c in Sources */, + 22C91A771193400A0083AC69 /* bn_s_mp_sub.c in Sources */, + 22C91A781193400A0083AC69 /* bncore.c in Sources */, + 22F5A9C61193DFBA00F8B121 /* SFileVerify.cpp in Sources */, + 228B538411BF7D0D001A58DA /* FileStream.cpp in Sources */, + 22AEA122123125D800359B16 /* SFilePatchArchives.cpp in Sources */, + 225C73541257CD0C0009E8DA /* SBaseFileTable.cpp in Sources */, + 225C735A1257CD1F0009E8DA /* lookup3.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 22954ACB11D463A30064B264 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 22954AD211D463AB0064B264 /* Test.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 2229F62F11D4653600118914 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 225530D31056BAC800FA646A /* StormLib */; + targetProxy = 2229F62E11D4653600118914 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 1DEB916508733D950010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ( + _7ZIP_ST, + _DEBUG, + ); + GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = NO; + }; + name = Debug; + }; + 1DEB916608733D950010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = _7ZIP_ST; + GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + SDKROOT = macosx; + SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = YES; + }; + name = Release; + }; + 225530D51056BAC900FA646A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = StormLib; + }; + name = Debug; + }; + 225530D61056BAC900FA646A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = StormLib; + }; + name = Release; + }; + 225FAC960E53B7F900DA2CAE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXPORTED_SYMBOLS_FILE = "$(PROJECT_DIR)/stormlib_dll/StormLib.exp"; + FRAMEWORK_VERSION = A; + GCC_DYNAMIC_NO_PIC = NO; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /usr/lib/clang/3.1/lib/darwin, + ); + PRODUCT_NAME = StormLib; + }; + name = Debug; + }; + 225FAC970E53B7F900DA2CAE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXPORTED_SYMBOLS_FILE = "$(PROJECT_DIR)/stormlib_dll/StormLib.exp"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /usr/lib/clang/3.1/lib/darwin, + ); + PRODUCT_NAME = StormLib; + }; + name = Release; + }; + 22954AD011D463A40064B264 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ( + _7ZIP_ST, + _DEBUG, + __STORMLIB_TEST__, + ); + INSTALL_PATH = /usr/local/bin; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /usr/lib/clang/3.1/lib/darwin, + ); + PRODUCT_NAME = StormLib_Test; + }; + name = Debug; + }; + 22954AD111D463A40064B264 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + INSTALL_PATH = /usr/local/bin; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /usr/lib/clang/3.1/lib/darwin, + ); + PRODUCT_NAME = StormLib_Test; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB916408733D950010E9CD /* Build configuration list for PBXProject "StormLib" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB916508733D950010E9CD /* Debug */, + 1DEB916608733D950010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 225530D71056BB1600FA646A /* Build configuration list for PBXNativeTarget "StormLib" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 225530D51056BAC900FA646A /* Debug */, + 225530D61056BAC900FA646A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 225FAC980E53B7F900DA2CAE /* Build configuration list for PBXNativeTarget "StormLibFramework" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 225FAC960E53B7F900DA2CAE /* Debug */, + 225FAC970E53B7F900DA2CAE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 22954AD911D463E00064B264 /* Build configuration list for PBXNativeTarget "StormLib_Test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 22954AD011D463A40064B264 /* Debug */, + 22954AD111D463A40064B264 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0867D690FE84028FC02AAC07 /* Project object */; +} diff --git a/dep/StormLib/StormLib_dll.vcproj b/dep/StormLib/StormLib_dll.vcproj new file mode 100644 index 000000000..f56cd8477 --- /dev/null +++ b/dep/StormLib/StormLib_dll.vcproj @@ -0,0 +1,2499 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/StormLib/StormLib_dll.vcxproj b/dep/StormLib/StormLib_dll.vcxproj new file mode 100644 index 000000000..740f5af25 --- /dev/null +++ b/dep/StormLib/StormLib_dll.vcxproj @@ -0,0 +1,511 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + StormLib_dll + {CB385198-50B1-4CF4-883B-11F042DED6AA} + StormLib_dll + Win32Proj + + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + true + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + true + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + false + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level1 + ProgramDatabase + + + $(OutDir)StormLib.dll + .\StormLib_dll\StormLib.def + true + Windows + false + + + MachineX86 + + + + + X64 + + + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level1 + ProgramDatabase + + + $(OutDir)StormLib.dll + .\StormLib_dll\StormLib.def + true + Windows + false + + + MachineX64 + + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreaded + + + Level1 + ProgramDatabase + + + $(OutDir)StormLib.dll + .\StormLib_dll\StormLib.def + true + Windows + true + true + false + + + MachineX86 + + + + + X64 + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreaded + + + Level1 + ProgramDatabase + + + $(OutDir)StormLib.dll + .\StormLib_dll\StormLib.def + true + Windows + true + true + false + + + MachineX64 + + + + + + + + + + + + + + + + + + + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + Level4 + Level4 + Level4 + Level4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dep/StormLib/StormLib_dll.vcxproj.filters b/dep/StormLib/StormLib_dll.vcxproj.filters new file mode 100644 index 000000000..3b818268a --- /dev/null +++ b/dep/StormLib/StormLib_dll.vcxproj.filters @@ -0,0 +1,779 @@ + + + + + {4c9205db-fd84-4138-bf99-9762053fad24} + + + {c46bb1be-e2ee-44ed-8ccf-277792e674a5} + + + {f14302d2-8c36-4dd9-aa65-ada246a32592} + + + {0402bd47-a1d1-47d5-b192-c30d6c9fc00f} + + + {821a4034-910a-4ee0-beda-3716d7e0d4e7} + + + {ac0040f0-0b8f-477a-928d-b159162ddabc} + + + {490bdd04-2b51-4cd9-a48a-804a6c5c2e66} + + + {f26bb75a-155e-4230-aefb-bc9797199ff2} + + + {76f65750-18e0-40d9-ba7b-7fd6e864abd9} + + + {9f4ea0eb-a4cc-4425-8762-1530b05002a8} + + + {7345615c-9ea6-4f79-ad9d-bfba3678e2df} + + + {d100666f-35f0-4465-b5f0-48614229b2b7} + + + {a08914e6-844f-4dcc-8867-b38b8f55df64} + + + {e2ea2efd-8853-40e6-aeee-af7a67e1dbec} + + + {5a8af9f4-dc43-4d8d-8fea-1d24f9615100} + + + {1e741e95-ab82-47d4-8faa-47e03780c4ee} + + + {261ff9dd-b1eb-4662-99b1-9a18d82c644a} + + + {d6033939-9a98-4c26-a158-8226dbbbc1a6} + + + {e36b055a-1636-4850-b7c8-4170a94fb162} + + + {65341005-077a-4f02-a4af-0bb63fad4c30} + + + {c33670da-5145-4e1d-b7a5-762b85b9e63a} + + + + + Doc Files + + + Doc Files + + + Doc Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Source Files\adpcm + + + Source Files\huffman + + + Source Files\pklib + + + Source Files\sparse + + + Source Files\jenkins + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\adpcm + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\huffman + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\pklib + + + Source Files\pklib + + + Source Files\sparse + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\jenkins + + + \ No newline at end of file diff --git a/dep/StormLib/StormLib_test.kdev4 b/dep/StormLib/StormLib_test.kdev4 new file mode 100644 index 000000000..5bea3f80c --- /dev/null +++ b/dep/StormLib/StormLib_test.kdev4 @@ -0,0 +1,4 @@ +[Project] +Name=StormLib_test +Manager=KDevCMakeManager +VersionControl= diff --git a/dep/StormLib/StormLib_test.vcproj b/dep/StormLib/StormLib_test.vcproj new file mode 100644 index 000000000..6386d5317 --- /dev/null +++ b/dep/StormLib/StormLib_test.vcproj @@ -0,0 +1,1984 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/StormLib/StormLib_test.vcxproj b/dep/StormLib/StormLib_test.vcxproj new file mode 100644 index 000000000..cb554fe2c --- /dev/null +++ b/dep/StormLib/StormLib_test.vcxproj @@ -0,0 +1,385 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + StormLib_test + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D} + StormLib_test + Win32Proj + + + + Application + MultiByte + true + + + Application + MultiByte + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + true + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + ./bin/$(ProjectName)/$(Platform)/$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ./src/libtomcrypt/src/headers;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;__STORMLIB_TEST__;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level1 + EditAndContinue + + + true + Console + false + + + MachineX86 + + + + + ./src/libtomcrypt/src/headers;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;__STORMLIB_TEST__;%(PreprocessorDefinitions) + MultiThreaded + + + Level1 + ProgramDatabase + + + true + Console + true + true + false + + + MachineX86 + + + + + + + + + + + + + + + + + + + + Level4 + + + Level4 + + + + Level4 + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + Level4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + + + + + \ No newline at end of file diff --git a/dep/StormLib/StormLib_test.vcxproj.filters b/dep/StormLib/StormLib_test.vcxproj.filters new file mode 100644 index 000000000..09d1b7dcb --- /dev/null +++ b/dep/StormLib/StormLib_test.vcxproj.filters @@ -0,0 +1,787 @@ + + + + + {0521b37a-df0c-4809-92ee-5c21b80735f5} + + + {3f337e66-2467-48f8-a358-c81ed372f252} + + + {6babe236-18ee-471b-8a62-d03a22e90198} + + + {f0a0e8e3-b2c2-4d1c-879d-a43f03ea5a61} + + + {2aaefdc1-9d77-4a38-9f4c-5e870ec44945} + + + {4e9f5c7f-af4c-4fd4-830f-3a2da5d7206c} + + + {4d3becbb-eec3-45b8-a125-02d94d150a33} + + + {0ab926c1-a33f-4c11-8c1a-101256e167f0} + + + {5085a0e7-4e7e-4676-91d5-7b4e2fbb0664} + + + {8a3caff1-3400-424c-807f-2ed016789093} + + + {bea80b25-7db8-4811-a8e6-8032eb386539} + + + {ffe3f691-7640-4d6d-a972-62b8885c7b1a} + + + {213deedd-9a1e-400d-b023-68e8fba78e18} + + + {816de789-6cb1-4be0-864d-e1171bc8e138} + + + {20df7a5a-581d-4f4c-b676-6698f2ff15f1} + + + {a385691f-2a7f-4e22-93ab-7d46e356a858} + + + {0f30053a-90ce-4d0c-bbd8-f209eba9bd42} + + + {16f73278-7a0c-44ce-9e4a-1d82fa474f10} + + + {a7380b86-f5f2-4f08-97e8-80d9be6aa833} + + + {efee3853-4625-4137-b32a-ff3a14b3ad38} + + + {248420f6-1bae-41ff-9f20-6bf0cf804ef8} + + + + + Doc Files + + + Doc Files + + + Doc Files + + + + + Header Files + + + Header Files + + + Header Files + + + Source Files\adpcm + + + Source Files\huffman + + + Source Files\pklib + + + Source Files\sparse + + + Source Files\jenkins + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\adpcm + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\bzip2 + + + Source Files\huffman + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\hashes + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\math + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\misc + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\asn1 + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\ecc + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\pkcs1 + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtomcrypt\pk\rsa + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\libtommath + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\lzma + + + Source Files\pklib + + + Source Files\pklib + + + Source Files\sparse + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\jenkins + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/dep/StormLib/StormLib_vc100.sln b/dep/StormLib/StormLib_vc100.sln new file mode 100644 index 000000000..dbe7e4a72 --- /dev/null +++ b/dep/StormLib/StormLib_vc100.sln @@ -0,0 +1,110 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib_dll", "StormLib_dll.vcxproj", "{CB385198-50B1-4CF4-883B-11F042DED6AA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib_test", "StormLib_test.vcxproj", "{AA561A7B-26EA-49AF-90E8-C53C1FA2965D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Storm_dll", "Storm_dll.vcxproj", "{BD600973-C6FA-4CE3-8821-67F6418B7F9C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib", "StormLib.vcxproj", "{78424708-1F6E-4D4B-920C-FB6D26847055}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + DebugAD|Win32 = DebugAD|Win32 + DebugAD|x64 = DebugAD|x64 + DebugAS|Win32 = DebugAS|Win32 + DebugAS|x64 = DebugAS|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseAD|Win32 = ReleaseAD|Win32 + ReleaseAD|x64 = ReleaseAD|x64 + ReleaseAS|Win32 = ReleaseAS|Win32 + ReleaseAS|x64 = ReleaseAS|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|Win32.ActiveCfg = Debug|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|Win32.Build.0 = Debug|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Debug|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAD|Win32.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAD|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAD|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAS|Win32.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAS|x64.ActiveCfg = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.DebugAS|x64.Build.0 = Debug|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|Win32.ActiveCfg = Release|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|Win32.Build.0 = Release|Win32 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.Release|x64.Build.0 = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAD|Win32.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAD|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAD|x64.Build.0 = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAS|Win32.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAS|x64.ActiveCfg = Release|x64 + {CB385198-50B1-4CF4-883B-11F042DED6AA}.ReleaseAS|x64.Build.0 = Release|x64 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Debug|Win32.Build.0 = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Debug|x64.ActiveCfg = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAD|Win32.ActiveCfg = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAD|Win32.Build.0 = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAD|x64.ActiveCfg = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAS|Win32.ActiveCfg = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAS|Win32.Build.0 = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.DebugAS|x64.ActiveCfg = Debug|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Release|Win32.ActiveCfg = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Release|Win32.Build.0 = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.Release|x64.ActiveCfg = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAD|Win32.ActiveCfg = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAD|Win32.Build.0 = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAD|x64.ActiveCfg = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAS|Win32.ActiveCfg = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAS|Win32.Build.0 = Release|Win32 + {AA561A7B-26EA-49AF-90E8-C53C1FA2965D}.ReleaseAS|x64.ActiveCfg = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.Debug|Win32.ActiveCfg = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.Debug|Win32.Build.0 = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.Debug|x64.ActiveCfg = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.DebugAD|Win32.ActiveCfg = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.DebugAD|Win32.Build.0 = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.DebugAD|x64.ActiveCfg = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.DebugAS|Win32.ActiveCfg = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.DebugAS|Win32.Build.0 = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.DebugAS|x64.ActiveCfg = Debug|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.Release|Win32.ActiveCfg = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.Release|Win32.Build.0 = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.Release|x64.ActiveCfg = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.ReleaseAD|Win32.ActiveCfg = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.ReleaseAD|Win32.Build.0 = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.ReleaseAD|x64.ActiveCfg = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.ReleaseAS|Win32.ActiveCfg = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.ReleaseAS|Win32.Build.0 = Release|Win32 + {BD600973-C6FA-4CE3-8821-67F6418B7F9C}.ReleaseAS|x64.ActiveCfg = Release|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.ActiveCfg = DebugAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.ActiveCfg = DebugAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.Build.0 = DebugAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|Win32.ActiveCfg = DebugAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|Win32.Build.0 = DebugAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|x64.ActiveCfg = DebugAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|x64.Build.0 = DebugAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|Win32.ActiveCfg = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|Win32.Build.0 = DebugAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|x64.ActiveCfg = DebugAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|x64.Build.0 = DebugAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.ActiveCfg = ReleaseAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.ActiveCfg = ReleaseAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.Build.0 = ReleaseAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|Win32.ActiveCfg = ReleaseAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|Win32.Build.0 = ReleaseAD|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|x64.ActiveCfg = ReleaseAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|x64.Build.0 = ReleaseAD|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|Win32.ActiveCfg = ReleaseAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|Win32.Build.0 = ReleaseAS|Win32 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|x64.ActiveCfg = ReleaseAS|x64 + {78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|x64.Build.0 = ReleaseAS|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/StormLib/Storm_dll.bat b/dep/StormLib/Storm_dll.bat new file mode 100644 index 000000000..466a3d33f --- /dev/null +++ b/dep/StormLib/Storm_dll.bat @@ -0,0 +1,18 @@ +@echo off +rem Post-build batch for StormDll project +rem Called as StormDll.bat $(PlatformName) $(ConfigurationName) +rem Example: StormDll.bat x64 Debug + +if x%1 == xWin32 goto PlatformWin32 +if x%1 == xx64 goto PlatformWin64 +goto exit + +:PlatformWin32 +copy .\bin\Storm_dll\%1\%2\*.lib . +goto exit + +:PlatformWin64 +copy .\bin\Storm_dll\%1\%2\*.lib . +goto exit + +:exit diff --git a/dep/StormLib/Storm_dll.lib b/dep/StormLib/Storm_dll.lib new file mode 100644 index 000000000..cb6e65c9c Binary files /dev/null and b/dep/StormLib/Storm_dll.lib differ diff --git a/dep/StormLib/Storm_dll.vcproj b/dep/StormLib/Storm_dll.vcproj new file mode 100644 index 000000000..4eb8902ac --- /dev/null +++ b/dep/StormLib/Storm_dll.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/StormLib/Storm_dll.vcxproj b/dep/StormLib/Storm_dll.vcxproj new file mode 100644 index 000000000..df10c4700 --- /dev/null +++ b/dep/StormLib/Storm_dll.vcxproj @@ -0,0 +1,121 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + Storm_dll + {BD600973-C6FA-4CE3-8821-67F6418B7F9C} + Storm_dll + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + .\bin\Storm_dll\$(Platform)\$(Configuration)\ + .\bin\Storm_dll\$(Platform)\$(Configuration)\ + true + false + .\bin\Storm_dll\$(Platform)\$(Configuration)\ + .\bin\Storm_dll\$(Platform)\$(Configuration)\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;Storm_dll_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + + + $(OutDir)storm.dll + .\Storm_dll\Storm_dll.def + true + Windows + 0x15000000 + false + + + MachineX86 + + + Storm_dll.bat $(Platform) $(Configuration) + + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;Storm_dll_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + $(OutDir)storm.dll + .\Storm_dll\storm_dll.def + true + Windows + true + true + 0x15000000 + false + + + MachineX86 + + + Storm_dll.bat $(Platform) $(Configuration) + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dep/StormLib/Storm_dll.vcxproj.filters b/dep/StormLib/Storm_dll.vcxproj.filters new file mode 100644 index 000000000..48e14f060 --- /dev/null +++ b/dep/StormLib/Storm_dll.vcxproj.filters @@ -0,0 +1,28 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/dep/StormLib/doc/History.txt b/dep/StormLib/doc/History.txt new file mode 100644 index 000000000..e7ef388ef --- /dev/null +++ b/dep/StormLib/doc/History.txt @@ -0,0 +1,62 @@ + + StormLib history + ================ + + Version 8.02 + + - Support for UNICODE encoding for on-disk files + - Optimized file deleting + + Version 8.01 + + - SFileFindFirstFile and SFileFindNextFile no longer find files that have + patch file in the oldest MPQ in the patch chain + - Write support for MPQs version 4 + + Version 8.00 + + - Updated support for protected maps from Warcraft III + + Version 7.11 + + - Support for MPQs v 3.0 (WOW-Cataclysm BETA) + - StormLib now deals properly with files that have MPQ_SECTOR_CHECKSUM missing, + but have sector checksum entry present in the sector offset table + + Version 7.10 + + - Support for partial MPQs ("interface.MPQ.part") + - The only operation that is externally allowed to do with internal files + ("(listfile)", "(attributes)" and "(signature)") is reading. Attempt to modify any of the file + fails and GetLastError returns ERROR_INTERNAL_FILE + - Fixed memory leak that has occured when writing more than one sector to the file at once + + Version 7.01 + + - Support for adding files from memory + - Fixed improper validation of handles to MPQ file and MPQ archive + - Fixed bug where StormLib didn't save CRC32 of the file when added to archive + + Version 7.00 + + - Properly deals with MPQs protected by w3xMaster + - Major rewrite + - Fixed support for (attributes) + - Added file verification + - Added MPQ signature verification + + Version 6.22 + + - Properly deals with MPQs protected by w3xMaster + + Version 6.21 + + - SFileRenameFile now properly re-crypts the file if necessary. + - SFileFindFirstFile correctly deals with deleted files + + Version 6.20 + + - Fixed lots of bugs when processing files with same names but different locales + - Fixed bugs when repeately extracts the same file with MPQ_FILE_SINGLE_UNIT flag + - Added SFileFlushArchive + - Fixed issue opening AVI files renamed to MPQ using SFileCreateArchiveEx diff --git a/dep/StormLib/doc/Sector Offset MD5.txt b/dep/StormLib/doc/Sector Offset MD5.txt new file mode 100644 index 000000000..12829ca34 --- /dev/null +++ b/dep/StormLib/doc/Sector Offset MD5.txt @@ -0,0 +1,25 @@ + + After sector offset table + ========================= + +FileSize CmpSize DWORDs +00007588 000075A4 0x01 +0000A9EA 000095EC 0x01 +0000E51D 0000E20D 0x02 +00015C00 00015C40 0x02 +0001C578 000186C4 0x02 +0002A9D4 0002A9EA 0x04 +00037BAC 00037A42 0x06 +0003C3C1 00034084 0x06 +0003D224 0003B30F 0x06 +00045105 0004195A 0x07 +00045D9C 0003D87D 0x07 +0004AAB8 0004860A 0x08 +0004D18E 00048E0C 0x07 +00056B4C 00056BDD 0x09 +0005DC08 00059426 0x09 +00061EC0 00057711 0x0A +0006CEC4 00062561 0x0B +000778EE 00066736 0x0C +000AD0CB 0007F32E 0x11 +00327EAC 00303395 0x53 diff --git a/dep/StormLib/doc/The MoPaQ File Format 0.9.txt b/dep/StormLib/doc/The MoPaQ File Format 0.9.txt new file mode 100644 index 000000000..410a0e5de --- /dev/null +++ b/dep/StormLib/doc/The MoPaQ File Format 0.9.txt @@ -0,0 +1,318 @@ +THE MOPAQ ARCHIVE FORMAT +v0.9 (Thursday, June 30, 2005) +by Justin Olbrantz(Quantam) + +Distribution and reproduction of this specification are allowed without limitation, as long as it is not altered. Quoting +in other works is freely allowed, as long as the source and author of the quote is stated. + +TABLE OF CONTENTS +1. Introduction to the MoPaQ Format +2. The MoPaQ Format + 2.1 General Archive Layout + 2.2 Archive Header + 2.3 Block Table + 2.4 Hash Table + 2.5 File Data + 2.6 Listfile + 2.7 Extended Attributes + 2.8 Weak (Old) Digital Signature + 2.9 Strong (New) Digital Signature +3. Algorithm Source Code + 3.1 Encryption/Decryption + 3.2 Hashing + 3.3 Conversion of FILETIME and time_t + +1. INTRODUCTION TO THE MOPAQ FORMAT +The MoPaQ (or MPQ) format is an archive file format designed by Mike O'Brien (hence the name Mike O'brien PaCK) at Blizzard +Entertainment. The format has been used in all Blizzard games since (and including) Diablo. It is heavily optimized to be +a read-only game archive format, and excels at this role. + +The Blizzard MoPaQ-reading functions are contained in the Storm module, which my be either statically or dynamically linked. +The Blizzard MoPaQ-writing functions are contained in the MPQAPI module, which is always statically linked. + +2. THE MOPAQ FORMAT +All numbers in the MoPaQ format are in little endian. Data types are listed either as int (integer, the number of bits specified), +byte (8 bits), and char (bytes which contain ASCII characters). All sizes and offsets are in bytes, unless specified otherwise. +Structure members are listed in the following general form: +offset from the beginning of the structure: data type(array size) member name : member description + +2.1 GENERAL ARCHIVE LAYOUT +- Archive Header +- File Data +- File Data - Special Files +- Hash Table +- Block Table +- Strong Digital signature + +This is the usual archive format, and is not absolutely essential. Some archives have been observed placing the hash table +and file table after the archive header, and before the file data. + +2.2 ARCHIVE HEADER +00h: char(4) Magic : Indicates that the file is a MoPaQ archive. Must be ASCII "MPQ" 1Ah. +04h: int32 HeaderSize : Size of the archive header. Should be 32. +08h: int32 ArchiveSize : Size of the whole archive, including the header. Does not include the strong digital signature, if present. +This size is used, among other things, for determining the region to hash in computing the digital signature. +0Ch: int16 Unknown : Unknown +0Eh: int8 SectorSizeShift : Power of two exponent specifying the number of 512-byte disk sectors in each logical sector +in the archive. The size of each logical sector the archive is 512 * 2^SectorSizeShift. Bugs in the Storm library dictate +that this should always be 3 (4096 byte sectors). +10h: int32 HashTableOffset : Offset to the beginning of the hash table, relative to the beginning of the archive. +14h: int32 BlockTableOffset : Offset to the beginning of the block table, relative to the beginning of the archive. +18h: int32 HashTableEntries : Number of entries in the hash table. Must be a power of two, and must be less than 2^16. +1Ch: int32 BlockTableEntries : Number of entries in the block table. + +The archive header is the first structure in the archive, at archive offset 0, but the archive does not need to be at offset +0 of the containing file. The offset of the archive in the file is referred to here as ArchiveOffset. If the archive is not +at the beginning of the file, it must begin at a disk sector boundary (512 bytes). Early versions of Storm require that the +archive be at the end of the containing file (ArchiveOffset + ArchiveSize = file size), but this is not required in newer +versions (due to the strong digital signature not being considered a part of the archive). + +2.3 BLOCK TABLE +The block table contains entries for each region in the archive. Regions may be either files or empty space, which may be +overwritten by new files (typically this space is from deleted file data). The block table is encrypted, using the hash +of "(block table)" as the key. Each entry is structured as follows: + +00h: int32 BlockOffset : Offset of the beginning of the block, relative to the beginning of the archive. Meaningless if the block size is 0. +04h: int32 BlockSize : Size of the block in the archive. +08h: int32 FileSize : Size of the file data stored in the block. Only valid if the block is a file, otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data. +0Ch: int32 Flags : Bit mask of the flags for the block. The following values are conclusively identified: + 80000000h: Block is a file, and follows the file data format; otherwise, block is free space, and may be overwritten. If the block is not a file, all other flags should be cleared. + 01000000h: File is stored as a single unit, rather than split into sectors. + 00020000h: The file's encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted. + 00010000h: File is encrypted. + 00000200h: File is compressed. Mutually exclusive to file imploded. + 00000100h: File is imploded. Mutually exclusive to file compressed. + +2.4 HASH TABLE +Instead of storing file names, for quick access MoPaQs use a fixed, power of two-size hash table of files in the archive. A file is uniquely identified by its file path, its language, and its platform. The home entry for a file in the hash table is computed as a hash of the file path. In the event of a collision (the home entry is occupied by another file), progressive overflow is used, and the file is placed in the next available hash table entry. Searches for a desired file in the hash table proceed from the home entry for the file until either the file is found, the entire hash table is searched, or an empty hash table entry (FileBlockIndex of FFFFFFFFh) is encountered. The hash table is encrypted using the hash of "(hash table)" as the key. Each entry is structured as follows: + +00h: int32 FilePathHashA : The hash of the file path, using method A. +04h: int32 FilePathHashB : The hash of the file path, using method B. +08h: int16 Language : The language of the file. This is a Windows LANGID data type, and uses the same values. 0 indicates the default language (American English), or that the file is language-neutral. +0Ah: int8 Platform : The platform the file is used for. 0 indicates the default platform. No other values have been observed. +0Ch: int32 FileBlockIndex : If the hash table entry is valid, this is the index into the block table of the file. Otherwise, one of the following two values: + FFFFFFFFh: Hash table entry is empty, and has always been empty. Terminates searches for a given file. + FFFFFFFEh: Hash table entry is empty, but was valid at some point (in other words, the file was deleted). Does not terminate searches for a given file. + +2.5 FILE DATA +00h: int32(SectorsInFile + 1) SectorOffsetTable : Offsets to the start of each sector's data, relative to the beginning of the file data. Not present if this information is calculatable (see details below). +immediately following SectorOffsetTable: SectorData : Data of each sector in the file, packed end to end (see details below). + +Normally, file data is split up into sectors, for simple streaming. All sectors, save for the last, will contain as many bytes of file data as specified in the archive header's SectorSizeShift; the last sector may be smaller than this, depending on the size of the file data. This sector size is the size of the raw file data; if the file is compressed, the compressed sector will be smaller or the same size as the uncompressed sector size. Individual sectors in a compressed file may be stored uncompressed; this occurs if and only if the sector could not be compressed by the algorithm used (if the compressed sector size was greater than or equal to the size of the raw data), and is indicated by the sector's compressed size in SectorOffsetTable being equal to the uncompressed size of the sector (which may be calculated from the FileSize). + +If the sector is compressed (but not imploded), a bit mask byte of the compression algorithm(s) used to compress the sector is appended to the beginning of the compressed sector data. This additional byte counts towards the total size of the sector; if the size of the sector (including this byte) exceeds or matches the uncompressed size of the sector data, the sector will be stored uncompressed, and this byte omitted. Multiple compression algorithms may be used on the same sector; in this case, successive compression occurs in the order the algorithms are listed below, and decompression occurs in the opposite order. For implimentations of all of these algorithms, see StormLib. + 40h: IMA ADPCM mono + 80h: IMA ADPCM stereo + 01h: Huffman encoded + 02h: Deflated (see ZLib) + 08h: Imploded (see PKWare Data Compression Library) + 10h: BZip2 compressed (see BZip2) + +If the file is stored as a single unit (indicated in the file's Flags), there is effectively only a single sector, which +contains the entire file. + +If the file is encrypted, each sector (after compression and appendage of the compression type byte, if applicable) +is encrypted with the file's key. The base key for a file is determined by a hash of the file name stripped of the +directory (i.e. the key for a file named "directory\file" would be computed as the hash of "file"). If this key is +adjusted, as indicated in the file's Flags, the final key is calculated as ((base key + BlockOffset - ArchiveOffset) +XOR FileSize) (StormLib - an open-source implementation of the MoPaQ reading and writing functions, +by Ladislav Zezula - incorrectly uses an AND in place of the XOR). Each sector is encrypted using the key + the +0-based index of the sector in the file. The SectorOffsetTable, if present, is encrypted using the key - 1. + +The SectorOffsetTable is omitted when the sizes and offsets of all sectors in the file are calculatable from the FileSize. +This can happen in several circumstances. If the file is not compressed/imploded, then the size and offset of all sectors +is known, based on the archive's SectorSizeShift. If the file is stored as a single unit compressed/imploded, then the +SectorOffsetTable is omitted, as the single file "sector" corresponds to BlockSize and FileSize, as mentioned previously. +Note that the SectorOffsetTable will always be present if the file is compressed/imploded and the file is not stored as +a single unit, even if there is only a single sector in the file (the size of the file is less than or equal to the +archive's sector size). + +2.6 LISTFILE +The listfile is a very simple extension to the MoPaQ format that contains the file paths of (most) files in the archive. +The languages and platforms of the files are not stored in the listfile. The listfile is contained in the file "(listfile)", +and is simply a non-Unix-style text file with one file path on each line, lines terminated with the bytes 0Dh 0Ah. The file +"(listfile)" may not be listed in the listfile. + +2.7 EXTENDED ATTRIBUTES +The extended attributes are optional file attributes for files in the block table. These attributes were added at times after +the MoPaQ format was already finalized, and it is not necessary for every archive to have all (or any) of the extended attributes. +If an archive contains a given attribute, there will be an instance of that attribute for every block in the block table, although +the attribute will be meaningless if the block is not a file. The order of the attributes for blocks correspond to the order of the +blocks in the block table, and are of the same number. The attributes are stored in parallel arrays in the "(attributes)" file, +in the archive. The attributes corresponding to this file need not be valid (and logically cannot be). Unlike all the other +structures in the MoPaQ format, entries in the extended attributes are NOT guaranteed to be aligned. Also note that in some +archives, malicious zeroing of the attributes has been observed, perhaps with the intent of breaking archive viewers. This +file is structured as follows: + +00h: int32 Version : Specifies the extended attributes format version. For now, must be 100. +04h: int32 AttributesPresent : Bit mask of the extended attributes present in the archive: + 00000001h: File CRC32s. + 00000002h: File timestamps. + 00000004h: File MD5s. +08h: int32(BlockTableEntries) CRC32s : CRC32s of the (uncompressed) file data for each block in the archive. Omitted if the +archive does not have CRC32s. immediately after CRC32s: FILETIME(BlockTableEntries) Timestamps : Timestamps for each block +in the archive. The format is that of the Windows FILETIME structure. Omitted if the archive does not have timestamps. +immediately after Timestamps: MD5(BlockTableEntries) MD5s : MD5s of the (uncompressed) file data for each block in the archive. +Omitted if the archive does not have MD5s. + +2.8 WEAK DIGITAL SIGNATURE +The weak digital signature is a digital signature using Microsoft CryptoAPI. It is an implimentation of the RSASSA-PKCS1-v1_5 +digital signature protocol, using the MD5 hashing algorithm and a 512-bit (weak) RSA key (for more information about this +protocol, see the RSA Labs PKCS1 specification). The public key and exponent are stored in a resource in Storm. The signature +is stored uncompressed, unencrypted in the file "(signature)" in the archive. The archive is hashed from the beginning of the +archive (ArchiveOffset in the containing file) to the end of the archive (the length indicated by ArchiveSize); the signature +file is added to the archive before signing, and the space occupied by the file is considered to be all binary 0s during +signing/verification. This file is structured as follows: + +00h: int32 Unknown : Must be 0. +04h: int32 Unknown : must be 0. +08h: int512 Signature : The digital signature. Like all other numbers in the MoPaQ format, this is stored in little-endian order. + +2.9 STRONG DIGITAL SIGNATURE +The strong digital signature uses a simple proprietary implementation of RSA signing, using the SHA-1 hashing algorithm and +a 2048-bit (strong) RSA key. The default public key and exponent are stored in Storm, but other keys may be used as well. +The strong digital signature is stored immediately after the archive, in the containing file; the entire archive (ArchiveSize +bytes, starting at ArchiveOffset in the containing file) is hashed as a single block. The signature has the following format: + +00h: char(4) Magic : Indicates the presence of a digital signature. Must be "NGIS" ("SIGN" backwards). +04h: int2048 Signature : The digital signature, stored in little-endian format. + +When the Signature field is decrypted with the public key and exponent, and the result stored in little-endian order, it is structured as follows: + +00h: byte Padding : Must be 0Bh. +01h: byte(235) Padding : Must be BBh. +ECh: byte(20) SHA-1 : SHA-1 hash of the archive, in standard SHA-1 format. + +3. ALGORITHM SOURCE CODE +3.1 ENCRYPTION/DECRYPTION +I believe this was derived at some point from code in StormLib. Assumes the long type to be 32 bits, and the machine to be little endian order. + +unsigned long dwCryptTable[0x500]; + +void InitializeCryptTable() +{ + unsigned long seed = 0x00100001; + unsigned long index1 = 0; + unsigned long index2 = 0; + int i; + + for (index1 = 0; index1 < 0x100; index1++) + { + for (index2 = index1, i = 0; i < 5; i++, index2 += 0x100) + { + unsigned long temp1, temp2; + + seed = (seed * 125 + 3) % 0x2AAAAB; + temp1 = (seed & 0xFFFF) << 0x10; + + seed = (seed * 125 + 3) % 0x2AAAAB; + temp2 = (seed & 0xFFFF); + + dwCryptTable[index2] = (temp1 | temp2); + } + } +} + +void EncryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) +{ + unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; + unsigned long seed = 0xEEEEEEEE; + unsigned long ch; + + assert(lpbyBuffer); + + dwLength /= sizeof(unsigned long); + + while(dwLength-- > 0) + { + seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; + ch = *lpdwBuffer ^ (dwKey + seed); + + dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B); + seed = *lpdwBuffer + seed + (seed << 5) + 3; + + *lpdwBuffer++ = ch; + } +} + +void DecryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) +{ + unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; + unsigned long seed = 0xEEEEEEEE; + unsigned long ch; + + assert(lpbyBuffer); + + dwLength /= sizeof(unsigned long); + + while(dwLength-- > 0) + { + seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; + ch = *lpdwBuffer ^ (dwKey + seed); + + dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B); + seed = ch + seed + (seed << 5) + 3; + + *lpdwBuffer++ = ch; + } +} + +3.2 HASHING +Based on code from StormLib. + +// Different types of hashes to make with HashString +#define MPQ_HASH_TABLE_OFFSET 0 +#define MPQ_HASH_NAME_A 1 +#define MPQ_HASH_NAME_B 2 +#define MPQ_HASH_FILE_KEY 3 + +unsigned long HashString(const char *lpszString, unsigned long dwHashType) +{ + unsigned long seed1 = 0x7FED7FED; + unsigned long seed2 = 0xEEEEEEEE; + int ch; + + while (*lpszString != 0) + { + ch = toupper(*lpszString++); + + seed1 = dwCryptTable[(dwHashType * 0xFF) + ch] ^ (seed1 + seed2); + seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3; + } + return seed1; +} + +3.3 CONVERSION OF FILETIME AND time_t + +#define EPOCH_OFFSET 116444736000000000ULL // Number of 100 ns units between 01/01/1601 and 01/01/1970 + +bool GetTimeFromFileTime(FILETIME &fileTime, time_t &time) +{ + // The FILETIME represents a 64-bit integer: the number of 100 ns units since January 1, 1601 + unsigned long long nTime = ((unsigned long long)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime; + + if (nTime < EPOCH_OFFSET) + return false; + + nTime -= EPOCH_OFFSET; // Convert the time base from 01/01/1601 to 01/01/1970 + nTime /= 10000000ULL; // Convert 100 ns to sec + + time = (time_t)nTime; + + // Test for overflow (FILETIME is 64 bits, time_t is 32 bits) + if ((nTime - (unsigned long long)time) > 0) + return false; + + return true; +} + +void GetFileTimeFromTime(time_t &time, FILETIME &fileTime) +{ + unsigned long long nTime = (unsigned long long)time; + + nTime *= 10000000ULL; + nTime += EPOCH_OFFSET; + + fileTime.dwLowDateTime = (DWORD)nTime; + fileTime.dwHighDateTime = (DWORD)(nTime >> 32); +} diff --git a/dep/StormLib/doc/The MoPaQ File Format 1.0.txt b/dep/StormLib/doc/The MoPaQ File Format 1.0.txt new file mode 100644 index 000000000..026d80c0b --- /dev/null +++ b/dep/StormLib/doc/The MoPaQ File Format 1.0.txt @@ -0,0 +1,433 @@ +THE MOPAQ ARCHIVE FORMAT +v1.0 (Friday, September 1, 2006) +by Justin Olbrantz(Quantam) + +Distribution and reproduction of this specification are allowed without limitation, as long as it is not altered. Quotation in other works is freely allowed, as long as the source and author of the quote are stated. + +TABLE OF CONTENTS +1. Introduction to the MoPaQ Format +2. The MoPaQ Format + 2.1 General Archive Layout + 2.2 Archive Header + 2.3 Block Table + 2.4 Extended Block Table + 2.5 Hash Table + 2.6 File Data + 2.7 Listfile + 2.8 Extended Attributes + 2.9 Weak (Old) Digital Signature + 2.10 Strong (New) Digital Signature +3. Algorithm Source Code + 3.1 Encryption/Decryption + 3.2 Hashing and File Key Computation + 3.3 Finding Files + 3.4 Deleting Files + 3.5 Conversion of FILETIME and time_t + 3.6 Forming a 64-bit Large Archive Offset from 32-bit and 16-bit Components +4. Revision History + +1. INTRODUCTION TO THE MOPAQ FORMAT +The MoPaQ (or MPQ) format is an archive file format designed by Mike O'Brien (hence the name Mike O'brien PaCK) at Blizzard Entertainment. The format has been used in all Blizzard games since (and including) Diablo. It is heavily optimized to be a read-only game archive format, and excels at this role. + +The Blizzard MoPaQ-reading functions are contained in the Storm module, which my be either statically or dynamically linked. The Blizzard MoPaQ-writing functions are contained in the MPQAPI module, which is always statically linked. + +StormLib - mentioned several times in this specification - is an open-source MoPaQ reading and writing library written by Ladislav Zezula (no affiliation with Blizzard Entertainment). While it's a bit dated, and does not support all of the newer MoPaQ features, it contains source code to the more exotic compression methods used by MoPaQ, such as the PKWare implode algorithm, MoPaQ's huffman compression algorithm, and the IMA ADPCM compression used by MoPaQ. + +2. THE MOPAQ FORMAT +All numbers in the MoPaQ format are in little endian byte order; signed numbers use the two's complement system. Data types are listed either as int (integer, the number of bits specified), byte (8 bits), or char (bytes which contain ASCII characters). All sizes and offsets are in bytes, unless specified otherwise. Structure members are listed in the following general form: +offset from the beginning of the structure: data type(array size) member name : member description + +2.1 GENERAL ARCHIVE LAYOUT +- Archive Header +- File Data +- File Data - Special Files +- Hash Table +- Block Table +- Extended Block Table +- Strong Digital signature + +This is the usual archive format, but it is not mandatory. Some archives have been observed placing the hash table and file table after the archive header, and before the file data. + +2.2 ARCHIVE HEADER +00h: char(4) Magic : Indicates that the file is a MoPaQ archive. Must be ASCII "MPQ" 1Ah. +04h: int32 HeaderSize : Size of the archive header. +08h: int32 ArchiveSize : Size of the whole archive, including the header. Does not include the strong digital signature, if present. This size is used, among other things, for determining the region to hash in computing the digital signature. This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive is calculated as the size from the beginning of the archive to the end of the hash table, block table, or extended block table (whichever is largest). +0Ch: int16 FormatVersion : MoPaQ format version. MPQAPI will not open archives where this is negative. Known versions: + 0000h: Original format. HeaderSize should be 20h, and large archives are not supported. + 0001h: Burning Crusade format. Header size should be 2Ch, and large archives are supported. +0Eh: int8 SectorSizeShift : Power of two exponent specifying the number of 512-byte disk sectors in each logical sector in the archive. The size of each logical sector in the archive is 512 * 2^SectorSizeShift. Bugs in the Storm library dictate that this should always be 3 (4096 byte sectors). +10h: int32 HashTableOffset : Offset to the beginning of the hash table, relative to the beginning of the archive. +14h: int32 BlockTableOffset : Offset to the beginning of the block table, relative to the beginning of the archive. +18h: int32 HashTableEntries : Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for the original MoPaQ format, or less than 2^20 for the Burning Crusade format. +1Ch: int32 BlockTableEntries : Number of entries in the block table. +Fields only present in the Burning Crusade format and later: +20h: int64 ExtendedBlockTableOffset : Offset to the beginning of the extended block table, relative to the beginning of the archive. +28h: int16 HashTableOffsetHigh : High 16 bits of the hash table offset for large archives. +2Ah: int16 BlockTableOffsetHigh : High 16 bits of the block table offset for large archives. + +The archive header is the first structure in the archive, at archive offset 0; however, the archive does not need to be at offset 0 of the containing file. The offset of the archive in the file is referred to here as ArchiveOffset. If the archive is not at the beginning of the file, it must begin at a disk sector boundary (512 bytes). Early versions of Storm require that the archive be at the end of the containing file (ArchiveOffset + ArchiveSize = file size), but this is not required in newer versions (due to the strong digital signature not being considered a part of the archive). + +2.3 BLOCK TABLE +The block table contains entries for each region in the archive. Regions may be either files, empty space, which may be overwritten by new files (typically this space is from deleted file data), or unused block table entries. Empty space entries should have BlockOffset and BlockSize nonzero, and FileSize and Flags zero; unused block table entries should have BlockSize, FileSize, and Flags zero. The block table is encrypted, using the hash of "(block table)" as the key. Each entry is structured as follows: + +00h: int32 BlockOffset : Offset of the beginning of the block, relative to the beginning of the archive. +04h: int32 BlockSize : Size of the block in the archive. +08h: int32 FileSize : Size of the file data stored in the block. Only valid if the block is a file; otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data. +0Ch: int32 Flags : Bit mask of the flags for the block. The following values are conclusively identified: + 80000000h: Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0. + 01000000h: File is stored as a single unit, rather than split into sectors. + 00020000h: The file's encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted. + 00010000h: File is encrypted. + 00000200h: File is compressed. File cannot be imploded. + 00000100h: File is imploded. File cannot be compressed. + +2.4 EXTENDED BLOCK TABLE +The extended block table was added to support archives larger than 4 gigabytes (2^32 bytes). The table contains the upper bits of the archive offsets for each block in the block table. It is simply an array of int16s, which become bits 32-47 of the archive offsets for each block, with bits 48-63 being zero. Individual blocks in the archive are still limited to 4 gigabytes in size. This table is only present in Burning Crusade format archives that exceed 4 gigabytes size. + +As of the Burning Crusade Friends and Family beta, this table is not encrypted. + +2.5 HASH TABLE +Instead of storing file names, for quick access MoPaQs use a fixed, power of two-size hash table of files in the archive. A file is uniquely identified by its file path, its language, and its platform. The home entry for a file in the hash table is computed as a hash of the file path. In the event of a collision (the home entry is occupied by another file), progressive overflow is used, and the file is placed in the next available hash table entry. Searches for a desired file in the hash table proceed from the home entry for the file until either the file is found, the entire hash table is searched, or an empty hash table entry (FileBlockIndex of FFFFFFFFh) is encountered. The hash table is encrypted using the hash of "(hash table)" as the key. Each entry is structured as follows: + +00h: int32 FilePathHashA : The hash of the file path, using method A. +04h: int32 FilePathHashB : The hash of the file path, using method B. +08h: int16 Language : The language of the file. This is a Windows LANGID data type, and uses the same values. 0 indicates the default language (American English), or that the file is language-neutral. +0Ah: int8 Platform : The platform the file is used for. 0 indicates the default platform. No other values have been observed. +0Ch: int32 FileBlockIndex : If the hash table entry is valid, this is the index into the block table of the file. Otherwise, one of the following two values: + FFFFFFFFh: Hash table entry is empty, and has always been empty. Terminates searches for a given file. + FFFFFFFEh: Hash table entry is empty, but was valid at some point (in other words, the file was deleted). Does not terminate searches for a given file. + +2.6 FILE DATA +The data for each file is composed of the following structure: +00h: int32(SectorsInFile + 1) SectorOffsetTable : Offsets to the start of each sector, relative to the beginning of the file data. The last entry contains the file size, making it possible to easily calculate the size of any given sector. This table is not present if this information can be calculated (see details below). +immediately following SectorOffsetTable: SECTOR Sectors(SectorsInFile) : Data of each sector in the file, packed end to end (see details below). + +Normally, file data is split up into sectors, for simple streaming. All sectors, save for the last, will contain as many bytes of file data as specified in the archive header's SectorSizeShift; the last sector may contain less than this, depending on the size of the entire file's data. If the file is compressed or imploded, the sector will be smaller or the same size as the file data it contains. Individual sectors in a compressed or imploded file may be stored uncompressed; this occurs if and only if the file data the sector contains could not be compressed by the algorithm(s) used (if the compressed sector size was greater than or equal to the size of the file data), and is indicated by the sector's size in SectorOffsetTable being equal to the size of the file data in the sector (which may be calculated from the FileSize). + +The format of each sector depends on the kind of sector it is. Uncompressed sectors are simply the the raw file data contained in the sector. Imploded sectors are the raw compressed data following compression with the implode algorithm (these sectors can only be in imploded files). Compressed sectors (only found in compressed - not imploded - files) are compressed with one or more compression algorithms, and have the following structure: +00h: byte CompressionMask : Mask of the compression types applied to this sector. If multiple compression types are used, they are applied in the order listed below, and decompression is performed in the opposite order. This byte counts towards the total sector size, meaning that the sector will be stored uncompressed if the data cannot be compressed by at least two bytes; as well, this byte is encrypted with the sector data, if applicable. The following compression types are defined (for implementations of these algorithms, see StormLib): + 40h: IMA ADPCM mono + 80h: IMA ADPCM stereo + 01h: Huffman encoded + 02h: Deflated (see ZLib) + 08h: Imploded (see PKWare Data Compression Library) + 10h: BZip2 compressed (see BZip2) +01h: byte(SectorSize - 1) SectorData : The compressed data for the sector. + +If the file is stored as a single unit (indicated in the file's Flags), there is effectively only a single sector, which contains the entire file data. + +If the file is encrypted, each sector (after compression/implosion, if applicable) is encrypted with the file's key. The base key for a file is determined by a hash of the file name stripped of the directory (i.e. the key for a file named "directory\file" would be computed as the hash of "file"). If this key is adjusted, as indicated in the file's Flags, the final key is calculated as ((base key + BlockOffset - ArchiveOffset) XOR FileSize) (StormLib incorrectly uses an AND in place of the XOR). Each sector is encrypted using the key + the 0-based index of the sector in the file. The SectorOffsetTable, if present, is encrypted using the key - 1. + +The SectorOffsetTable is omitted when the sizes and offsets of all sectors in the file are calculatable from the FileSize. This can happen in several circumstances. If the file is not compressed/imploded, then the size and offset of all sectors is known, based on the archive's SectorSizeShift. If the file is stored as a single unit compressed/imploded, then the SectorOffsetTable is omitted, as the single file "sector" corresponds to BlockSize and FileSize, as mentioned previously. However, the SectorOffsetTable will be present if the file is compressed/imploded and the file is not stored as a single unit, even if there is only a single sector in the file (the size of the file is less than or equal to the archive's sector size). + +2.7 LISTFILE +The listfile is a very simple extension to the MoPaQ format that contains the file paths of (most) files in the archive. The languages and platforms of the files are not stored in the listfile. The listfile is contained in the file "(listfile)" (default language and platform), and is simply a text file with file paths separated by ';', 0Dh, 0Ah, or some combination of these. The file "(listfile)" may not be listed in the listfile. + +2.8 EXTENDED ATTRIBUTES +The extended attributes are optional file attributes for files in the block table. These attributes were added at times after the MoPaQ format was already finalized, and it is not necessary for every archive to have all (or any) of the extended attributes. If an archive contains a given attribute, there will be an instance of that attribute for every block in the block table, although the attribute will be meaningless if the block is not a file. The order of the attributes for blocks correspond to the order of the blocks in the block table, and are of the same number. The attributes are stored in parallel arrays in the "(attributes)" file (default language and platform), in the archive. The attributes corresponding to this file need not be valid (and logically cannot be). Unlike all the other structures in the MoPaQ format, entries in the extended attributes are NOT guaranteed to be aligned. Also note that in some archives, malicious zeroing of the attributes has been observed, perhaps with the intent of breaking archive viewers. This file is structured as follows: + +00h: int32 Version : Specifies the extended attributes format version. For now, must be 100. +04h: int32 AttributesPresent : Bit mask of the extended attributes present in the archive: + 00000001h: File CRC32s. + 00000002h: File timestamps. + 00000004h: File MD5s. +08h: int32(BlockTableEntries) CRC32s : CRC32s of the (uncompressed) file data for each block in the archive. Omitted if the archive does not have CRC32s. +immediately after CRC32s: FILETIME(BlockTableEntries) Timestamps : Timestamps for each block in the archive. The format is that of the Windows FILETIME structure. Omitted if the archive does not have timestamps. +immediately after Timestamps: MD5(BlockTableEntries) MD5s : MD5s of the (uncompressed) file data for each block in the archive. Omitted if the archive does not have MD5s. + +2.9 WEAK DIGITAL SIGNATURE +The weak digital signature is a digital signature using Microsoft CryptoAPI. It is an implimentation +of the RSASSA-PKCS1-v1_5 digital signature protocol, using the MD5 hashing algorithm and a 512-bit (weak) +RSA key (for more information about this protocol, see the RSA Labs PKCS1 specification). The public key +and exponent are stored in a resource in Storm, the private key is stored in a separate file, whose filename +is passed to MPQAPI (the private key is not stored in MPQAPI). The signature is stored uncompressed, +unencrypted in the file "(signature)" (default language and platform) in the archive. The archive +is hashed from the beginning of the archive (ArchiveOffset in the containing file) to the end of +the archive (the length indicated by ArchiveSize, or calculated in the Burning Crusade MoPaQ format); +the signature file is added to the archive before signing, and the space occupied by the file is considered +to be all binary 0s during signing/verification. This file is structured as follows: + +00h: int32 Unknown : Must be 0. +04h: int32 Unknown : Must be 0. +08h: int512 Signature : The digital signature. Like all other numbers in the MoPaQ format, this is stored +in little-endian order. The structure of this, when decrypted, follows the RSASSA-PKCS1-v1_5 specification; +this format is rather icky to work with (I wrote a program to verify this signature using nothing but an MD5 +function and huge integer functions; it wasn't pleasant), and best left to an encryption library such as Cryto++. + +2.10 STRONG DIGITAL SIGNATURE +The strong digital signature uses a simple proprietary implementation of RSA signing, using the SHA-1 hashing algorithm and a 2048-bit (strong) RSA key. The default public key and exponent are stored in Storm, but other keys may be used as well. The strong digital signature is stored immediately after the archive, in the containing file; the entire archive (ArchiveSize bytes, starting at ArchiveOffset in the containing file) is hashed as a single block. The signature has the following format: + +00h: char(4) Magic : Indicates the presence of a digital signature. Must be "NGIS" ("SIGN" backwards). +04h: int2048 Signature : The digital signature, stored in little-endian format. + +When the Signature field is decrypted with the public key and exponent, and the resulting large integer is stored in little-endian order, it is structured as follows: + +00h: byte Padding : Must be 0Bh. +01h: byte(235) Padding : Must be BBh. +ECh: byte(20) SHA-1 : SHA-1 hash of the archive, in standard SHA-1 byte order. + +3. ALGORITHM SOURCE CODE +All of the sample code here assumes little endian machine byte order, that the short type is 16 bits, that the long type is 32 bits, and that the long long type is 64 bits. Adjustments must be made if these assumptions are not correct on a given platform. All code not credited otherwise was written by myself in the writing of this specification. + +3.1 ENCRYPTION/DECRYPTION +Based on code from StormLib. + +unsigned long dwCryptTable[0x500]; + +// The encryption and hashing functions use a number table in their procedures. This table must be initialized before the functions are called the first time. +void InitializeCryptTable() +{ + unsigned long seed = 0x00100001; + unsigned long index1 = 0; + unsigned long index2 = 0; + int i; + + for (index1 = 0; index1 < 0x100; index1++) + { + for (index2 = index1, i = 0; i < 5; i++, index2 += 0x100) + { + unsigned long temp1, temp2; + + seed = (seed * 125 + 3) % 0x2AAAAB; + temp1 = (seed & 0xFFFF) << 0x10; + + seed = (seed * 125 + 3) % 0x2AAAAB; + temp2 = (seed & 0xFFFF); + + dwCryptTable[index2] = (temp1 | temp2); + } + } +} + +void EncryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) +{ + assert(lpbyBuffer); + + unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; + unsigned long seed = 0xEEEEEEEE; + unsigned long ch; + + dwLength /= sizeof(unsigned long); + + while(dwLength-- > 0) + { + seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; + ch = *lpdwBuffer ^ (dwKey + seed); + + dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B); + seed = *lpdwBuffer + seed + (seed << 5) + 3; + + *lpdwBuffer++ = ch; + } +} + +void DecryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) +{ + assert(lpbyBuffer); + + unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; + unsigned long seed = 0xEEEEEEEEL; + unsigned long ch; + + dwLength /= sizeof(unsigned long); + + while(dwLength-- > 0) + { + seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; + ch = *lpdwBuffer ^ (dwKey + seed); + + dwKey = ((~dwKey << 0x15) + 0x11111111L) | (dwKey >> 0x0B); + seed = ch + seed + (seed << 5) + 3; + + *lpdwBuffer++ = ch; + } +} + +3.2 HASHING AND FILE KEY COMPUTATION +These functions may have been derived from StormLib code at some point in the very distant past. It was so long ago that I don't remember for certain. + +// Different types of hashes to make with HashString +#define MPQ_HASH_TABLE_OFFSET 0 +#define MPQ_HASH_NAME_A 1 +#define MPQ_HASH_NAME_B 2 +#define MPQ_HASH_FILE_KEY 3 + +// Based on code from StormLib. +unsigned long HashString(const char *lpszString, unsigned long dwHashType) +{ + assert(lpszString); + assert(dwHashType <= MPQ_HASH_FILE_KEY); + + unsigned long seed1 = 0x7FED7FEDL; + unsigned long seed2 = 0xEEEEEEEEL; + int ch; + + while (*lpszString != 0) + { + ch = toupper(*lpszString++); + + seed1 = dwCryptTable[(dwHashType * 0x100) + ch] ^ (seed1 + seed2); + seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3; + } + return seed1; +} + +#define BLOCK_OFFSET_ADJUSTED_KEY 0x00020000L + +unsigned long ComputeFileKey(const char *lpszFilePath, const BlockTableEntry &blockEntry, unsigned long nArchiveOffset) +{ + assert(lpszFilePath); + + // Find the file name part of the path + const char *lpszFileName = strrchr(lpszFilePath, '\\'); + if (lpszFileName) + lpszFileName++; // Skip the \ + else + lpszFileName = lpszFilePath; + + // Hash the name to get the base key + unsigned long nFileKey = HashString(lpszFileName, MPQ_HASH_FILE_KEY); + + // Offset-adjust the key if necessary + if (blockEntry.Flags & BLOCK_OFFSET_ADJUSTED_KEY) + nFileKey = (nFileKey + blockEntry.BlockOffset) ^ blockEntry.FileSize; + + return nFileKey; +} + +3.3 FINDING FILES + +#define MPQ_HASH_ENTRY_EMPTY 0xFFFFFFFFL +#define MPQ_HASH_ENTRY_DELETED 0xFFFFFFFEL + +bool FindFileInHashTable(const HashTableEntry *lpHashTable, unsigned long nHashTableSize, const char *lpszFilePath, unsigned short nLang, unsigned char nPlatform, unsigned long &iFileHashEntry) +{ + assert(lpHashTable); + assert(nHashTableSize); + assert(lpszFilePath); + + // Find the home entry in the hash table for the file + unsigned long iInitEntry = HashString(lpszFilePath, MPQ_HASH_TABLE_OFFSET) & (nHashTableSize - 1); + + // Is there anything there at all? + if (lpHashTable[iInitEntry].FileBlockIndex == MPQ_HASH_ENTRY_EMPTY) + return false; + + // Compute the hashes to compare the hash table entry against + unsigned long nNameHashA = HashString(lpszFilePath, MPQ_HASH_NAME_A), + nNameHashB = HashString(lpszFilePath, MPQ_HASH_NAME_B), + iCurEntry = iInitEntry; + + // Check each entry in the hash table till a termination point is reached + do + { + if (lpHashTable[iCurEntry].FileBlockIndex != MPQ_HASH_ENTRY_DELETED) + { + if (lpHashTable[iCurEntry].FilePathHashA == nNameHashA + && lpHashTable[iCurEntry].FilePathHashB == nNameHashB + && lpHashTable[iCurEntry].Language == nLang + && lpHashTable[iCurEntry].Platform == nPlatform) + { + iFileHashEntry = iCurEntry; + + return true; + } + } + + iCurEntry = (iCurEntry + 1) & (nHashTableSize - 1); + } while (iCurEntry != iInitEntry && lpHashTable[iCurEntry].FileBlockIndex != MPQ_HASH_ENTRY_EMPTY); + + return false; +} + +3.4 DELETING FILES + +bool DeleteFile(HashTableEntry *lpHashTable, unsigned long nHashTableSize, BlockTableEntry *lpBlockTable, const char *lpszFilePath, unsigned short nLang, unsigned char nPlatform) +{ + assert(lpHashTable); + assert(nHashTableSize); + assert(lpBlockTable); + + // Find the file in the hash table + unsigned long iFileHashEntry; + + if (!FindFileInHashTable(lpHashTable, nHashTableSize, lpszFilePath, nLang, nPlatform, iFileHashEntry)) + return false; + + // Get the block table index before we nuke the hash table entry + unsigned long iFileBlockEntry = lpHashTable[iFileHashEntry].FileBlockIndex; + + // Delete the file's entry in the hash table + memset(&lpHashTable[iFileHashEntry], 0xFF, sizeof(HashTableEntry)); + + // If the next entry is empty, mark this one as empty; otherwise, mark this as deleted. + if (lpHashTable[(iFileHashEntry + 1) & (nHashTableSize - 1)].FileBlockIndex == MPQ_HASH_ENTRY_EMPTY) + lpHashTable[iFileHashEntry].FileBlockIndex = MPQ_HASH_ENTRY_EMPTY; + else + lpHashTable[iFileHashEntry].FileBlockIndex = MPQ_HASH_ENTRY_DELETED; + + // If the block occupies space, mark the block as free space; otherwise, clear the block table entry. + if (lpBlockTable[iFileBlockEntry].BlockSize > 0) + { + lpBlockTable[iFileBlockEntry].FileSize = 0; + lpBlockTable[iFileBlockEntry].Flags = 0; + } + else + memset(&lpBlockTable[iFileBlockEntry], 0, sizeof(BlockTableEntry); + + return true; +} + +3.5 CONVERSION OF FILETIME AND time_t +This code assumes that the base ("zero") date for time_t is 01/01/1970. This is true on Windows, Unix System V systems, and Mac OS X. It is unknown whether this is true on all other platforms. You'll need to research this yourself, if you plan on porting it somewhere else. + +#define EPOCH_OFFSET 116444736000000000ULL // Number of 100 ns units between 01/01/1601 and 01/01/1970 + +bool GetTimeFromFileTime(const FILETIME &fileTime, time_t &time) +{ + // The FILETIME represents a 64-bit integer: the number of 100 ns units since January 1, 1601 + unsigned long long nTime = ((unsigned long long)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime; + + if (nTime < EPOCH_OFFSET) + return false; + + nTime -= EPOCH_OFFSET; // Convert the time base from 01/01/1601 to 01/01/1970 + nTime /= 10000000ULL; // Convert 100 ns to sec + + time = (time_t)nTime; + + // Test for overflow (FILETIME is 64 bits, time_t is 32 bits) + if ((nTime - (unsigned long long)time) > 0) + return false; + + return true; +} + +void GetFileTimeFromTime(const time_t &time, FILETIME &fileTime) +{ + unsigned long long nTime = (unsigned long long)time; + + nTime *= 10000000ULL; + nTime += EPOCH_OFFSET; + + fileTime.dwLowDateTime = (DWORD)nTime; + fileTime.dwHighDateTime = (DWORD)(nTime >> 32); +} + +3.6 FORMING A 64-BIT LARGE ARCHIVE OFFSET FROM 32-BIT AND 16-BIT COMPONENTS +unsigned long long MakeLargeArchiveOffset(unsigned long nOffsetLow, unsigned short nOffsetHigh) +{ + return ((unsigned long long)nOffsetHigh << 32) + (unsigned long long)nOffsetLow; +} + +4. REVISION HISTORY +1.0 + - Updated to include most of the changes found in the Burning Crusade Friends and Family beta + +0.91. + - Updated several structure member descriptions + - Listed the full set of characters that can separate list file entries + - Noted that (attributes), (listfile), and (signature) use the default language and platform codes + - Redid part of the file data specs to clarify the format of sectors + - Enhanced descriptions of the different kinds of block table entries + - Added ComputeFileKey, FindFileInHashTable, and DeleteFile source \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-deDE.txt b/dep/StormLib/doc/d3-authenticationcode-deDE.txt new file mode 100644 index 000000000..cac66712a --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-deDE.txt @@ -0,0 +1 @@ +UCMXF6EJY352EFH4XFRXCFH2XC9MQRZK \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-enGB.txt b/dep/StormLib/doc/d3-authenticationcode-enGB.txt new file mode 100644 index 000000000..2bc9c8385 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-enGB.txt @@ -0,0 +1 @@ +MMKVHY48RP7WXP4GHYBQ7SL9J9UNPHBP \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-enSG.txt b/dep/StormLib/doc/d3-authenticationcode-enSG.txt new file mode 100644 index 000000000..e6f1ec296 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-enSG.txt @@ -0,0 +1 @@ +8MXLWHQ7VGGLTZ9MQZQSFDCLJYET3CPP \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-enUS.txt b/dep/StormLib/doc/d3-authenticationcode-enUS.txt new file mode 100644 index 000000000..8d73e61de --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-enUS.txt @@ -0,0 +1 @@ +EJ2R5TM6XFE2GUNG5QDGHKQ9UAKPWZSZ \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-esES.txt b/dep/StormLib/doc/d3-authenticationcode-esES.txt new file mode 100644 index 000000000..6b1b0a1b8 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-esES.txt @@ -0,0 +1 @@ +PBGFBE42Z6LNK65UGJQ3WZVMCLP4HQQT \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-esMX.txt b/dep/StormLib/doc/d3-authenticationcode-esMX.txt new file mode 100644 index 000000000..504759e8d --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-esMX.txt @@ -0,0 +1 @@ +X7SEJJS9TSGCW5P28EBSC47AJPEY8VU2 \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-frFR.txt b/dep/StormLib/doc/d3-authenticationcode-frFR.txt new file mode 100644 index 000000000..bb35a2bfd --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-frFR.txt @@ -0,0 +1 @@ +5KVBQA8VYE6XRY3DLGC5ZDE4XS4P7YA2 \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-itIT.txt b/dep/StormLib/doc/d3-authenticationcode-itIT.txt new file mode 100644 index 000000000..a62031d38 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-itIT.txt @@ -0,0 +1 @@ +478JD2K56EVNVVY4XX8TDWYT5B8KB254 \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-koKR.txt b/dep/StormLib/doc/d3-authenticationcode-koKR.txt new file mode 100644 index 000000000..296ffcc94 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-koKR.txt @@ -0,0 +1 @@ +8TS4VNFQRZTN6YWHE9CHVDH9NVWD474A \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-plPL.txt b/dep/StormLib/doc/d3-authenticationcode-plPL.txt new file mode 100644 index 000000000..a92563c18 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-plPL.txt @@ -0,0 +1 @@ +LJ52Z32DF4LZ4ZJJXVKK3AZQA6GABLJB \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-ptBR.txt b/dep/StormLib/doc/d3-authenticationcode-ptBR.txt new file mode 100644 index 000000000..e6e5c3568 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-ptBR.txt @@ -0,0 +1 @@ +K6BDHY2ECUE2545YKNLBJPVYWHE7XYAG \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode-zhTW.txt b/dep/StormLib/doc/d3-authenticationcode-zhTW.txt new file mode 100644 index 000000000..138a5449c --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode-zhTW.txt @@ -0,0 +1 @@ +6VWCQTN8V3ZZMRUCZXV8A8CGUX2TAA8H \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-deDE.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-deDE.txt new file mode 100644 index 000000000..cac66712a --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-deDE.txt @@ -0,0 +1 @@ +UCMXF6EJY352EFH4XFRXCFH2XC9MQRZK \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enGB.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enGB.txt new file mode 100644 index 000000000..2bc9c8385 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enGB.txt @@ -0,0 +1 @@ +MMKVHY48RP7WXP4GHYBQ7SL9J9UNPHBP \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enSG.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enSG.txt new file mode 100644 index 000000000..e6f1ec296 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enSG.txt @@ -0,0 +1 @@ +8MXLWHQ7VGGLTZ9MQZQSFDCLJYET3CPP \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enUS.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enUS.txt new file mode 100644 index 000000000..8d73e61de --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-enUS.txt @@ -0,0 +1 @@ +EJ2R5TM6XFE2GUNG5QDGHKQ9UAKPWZSZ \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-esES.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-esES.txt new file mode 100644 index 000000000..6b1b0a1b8 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-esES.txt @@ -0,0 +1 @@ +PBGFBE42Z6LNK65UGJQ3WZVMCLP4HQQT \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-esMX.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-esMX.txt new file mode 100644 index 000000000..504759e8d --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-esMX.txt @@ -0,0 +1 @@ +X7SEJJS9TSGCW5P28EBSC47AJPEY8VU2 \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-frFR.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-frFR.txt new file mode 100644 index 000000000..bb35a2bfd --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-frFR.txt @@ -0,0 +1 @@ +5KVBQA8VYE6XRY3DLGC5ZDE4XS4P7YA2 \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-itIT.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-itIT.txt new file mode 100644 index 000000000..a62031d38 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-itIT.txt @@ -0,0 +1 @@ +478JD2K56EVNVVY4XX8TDWYT5B8KB254 \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-koKR.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-koKR.txt new file mode 100644 index 000000000..296ffcc94 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-koKR.txt @@ -0,0 +1 @@ +8TS4VNFQRZTN6YWHE9CHVDH9NVWD474A \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-plPL.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-plPL.txt new file mode 100644 index 000000000..a92563c18 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-plPL.txt @@ -0,0 +1 @@ +LJ52Z32DF4LZ4ZJJXVKK3AZQA6GABLJB \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-ptBR.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-ptBR.txt new file mode 100644 index 000000000..e6e5c3568 --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-ptBR.txt @@ -0,0 +1 @@ +K6BDHY2ECUE2545YKNLBJPVYWHE7XYAG \ No newline at end of file diff --git a/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-zhTW.txt b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-zhTW.txt new file mode 100644 index 000000000..138a5449c --- /dev/null +++ b/dep/StormLib/doc/d3-authenticationcode/d3-authenticationcode-zhTW.txt @@ -0,0 +1 @@ +6VWCQTN8V3ZZMRUCZXV8A8CGUX2TAA8H \ No newline at end of file diff --git a/dep/StormLib/doc/diablo3_ruru_disk_encrypted_win.blob b/dep/StormLib/doc/diablo3_ruru_disk_encrypted_win.blob new file mode 100644 index 000000000..7972b2d76 --- /dev/null +++ b/dep/StormLib/doc/diablo3_ruru_disk_encrypted_win.blob @@ -0,0 +1,49 @@ +{ +"config":{ + "product": "D3", + "install_progress_percent": 70.0, + "install_progress_info": [8000000000.0, 0.0, 0.0], + "download_progress_info": [10000000.0, 500000000.0, 500000000.0], + "install_progress_speed": 5000000.0, + "tome_download_progress_percent": 0.0, + "updater_product": "d3_patch", + "expansion_level": 0, + "ptr": false, + "beta": false, + "update_method": "patch on demand", + "supports_multibox": false, + "data_dir": "Data_D3/PC/MPQs/", + "patch_url": "http://ruRU.patch.battle.net:1119/patch", + "update_regex": "(?Pd3-update-(?P\\w+))-(?P\\d+)\\.mpq$", + "update_identifier": "d3-update-", + "torrent_file_path": "Diablo III.tfil", + "manifest_file_path": "Diablo III.mfil", + "priority_file_path": "Diablo III.pfil", + "priority_file_layout": "Retail", + "binary_version_path": "Diablo III.exe", + "binary_launch_path": "Diablo III.exe", + "display_locales":["ruRU"], + "supported_locales" : ["enUS", "esMX", "ptBR", "enGB", "deDE", "esES", "frFR", "itIT", "plPL", "enSG", "ptPT", "ruRU", "koKR", "zhTW", "zhCN"], + "launch_arguments":["-launch","-uid","diablo3_ruru"], + "form": { + "eula": { + "eula":false + }, + "game_dir": { + "default": "Program Files", + "dirname": "Diablo III", + "required_space": 15032385536 + }, + "language": { + "default":["ruRU"], + "list":["ruRU"] + }, + "authentication_key": { + "url": [ + "http://ruru.nydus.battle.net/D3/ruRU/setup/mediakey", + "http://dist.blizzard.com/mediakey/d3-authenticationcode-ruRU.txt" + ] + } + } + } +} \ No newline at end of file diff --git a/dep/StormLib/doc/diablo3_urls.txt b/dep/StormLib/doc/diablo3_urls.txt new file mode 100644 index 000000000..1fbb6e0b5 --- /dev/null +++ b/dep/StormLib/doc/diablo3_urls.txt @@ -0,0 +1,14 @@ +shttp://dist.blizzard.com/mediakey/d3-authenticationcode-deDE.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-enGB.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-enSG.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-enUS.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-esES.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-esMX.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-frFR.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-itIT.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-koKR.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-plPL.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-ptBR.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-ruRU.txt <==== +http://dist.blizzard.com/mediakey/d3-authenticationcode-zhTW.txt +http://dist.blizzard.com/mediakey/d3-authenticationcode-zhCN.txt <==== diff --git a/dep/StormLib/doc/hots-authenticationcode/hots-authenticationcode-bgdl.txt b/dep/StormLib/doc/hots-authenticationcode/hots-authenticationcode-bgdl.txt new file mode 100644 index 000000000..6dfe0ee60 --- /dev/null +++ b/dep/StormLib/doc/hots-authenticationcode/hots-authenticationcode-bgdl.txt @@ -0,0 +1 @@ +S48B6CDTN5XEQAKQDJNDLJBJ73FDFM3U \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-deDE.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-deDE.txt new file mode 100644 index 000000000..029d733ea --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-deDE.txt @@ -0,0 +1 @@ +Y45MD3CAK4KXSSXHYD9VY64Z8EKJ4XFX \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-enGB.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-enGB.txt new file mode 100644 index 000000000..7f66f8bba --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-enGB.txt @@ -0,0 +1 @@ +G8MN8UDG6NA2ANGY6A3DNY82HRGF29ZH \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-enUS.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-enUS.txt new file mode 100644 index 000000000..0a4f5b8f6 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-enUS.txt @@ -0,0 +1 @@ +3DH5RE5NVM5GTFD85LXGWT6FK859ETR5 \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-esES.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-esES.txt new file mode 100644 index 000000000..fba8c8dc8 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-esES.txt @@ -0,0 +1 @@ +8WLKUAXE94PFQU4Y249PAZ24N4R4XKTQ \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-esMX.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-esMX.txt new file mode 100644 index 000000000..bb020c65e --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-esMX.txt @@ -0,0 +1 @@ +A34DXX3VHGGXSQBRFE5UFFDXMF9G4G54 \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-frFR.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-frFR.txt new file mode 100644 index 000000000..37bcc4a41 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-frFR.txt @@ -0,0 +1 @@ +ZG7J9K938HJEFWPQUA768MA2PFER6EAJ \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-itIT.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-itIT.txt new file mode 100644 index 000000000..a665f6913 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-itIT.txt @@ -0,0 +1 @@ +NE7CUNNNTVAPXV7E3G2BSVBWGVMW8BL2 \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-koKR.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-koKR.txt new file mode 100644 index 000000000..e6346df30 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-koKR.txt @@ -0,0 +1 @@ +3V9E2FTMBM9QQWK7U6MAMWAZWQDB838F \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-plPL.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-plPL.txt new file mode 100644 index 000000000..564efc489 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-plPL.txt @@ -0,0 +1 @@ +2NSFB8MELULJ83U6YHA3UP6K4MQD48L6 \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-ptBR.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-ptBR.txt new file mode 100644 index 000000000..e8f8172d1 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-ptBR.txt @@ -0,0 +1 @@ +QA2TZ9EWZ4CUU8BMB5WXCTY65F9CSW4E \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-ruRU.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-ruRU.txt new file mode 100644 index 000000000..1b93b5be2 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-ruRU.txt @@ -0,0 +1 @@ +VHB378W64BAT9SH7D68VV9NLQDK9YEGT \ No newline at end of file diff --git a/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-zhTW.txt b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-zhTW.txt new file mode 100644 index 000000000..409a8c142 --- /dev/null +++ b/dep/StormLib/doc/sc2-authenticationcode/sc2-authenticationcode-zhTW.txt @@ -0,0 +1 @@ +U3NFQJV4M6GC7KBN9XQJ3BRDN3PLD9NE \ No newline at end of file diff --git a/dep/StormLib/makefile.w32 b/dep/StormLib/makefile.w32 new file mode 100644 index 000000000..8826ccd32 --- /dev/null +++ b/dep/StormLib/makefile.w32 @@ -0,0 +1,268 @@ +##################################################################### +# +# Makefile for compiling StormLib with MINGW +# +# Author: Ladislav Zezula +# Created: Mon May 10 14:13:00 CEST 2010 +# System: Windows Seven +# +##################################################################### + +PATH = C:\TOOLS32\MINGW\bin +CPP = g++ +CC = gcc +CFLAGS = -Wall +DFLAGS = -D_7ZIP_ST +LFLAGS = -shared +#LFLAGS = -lbz2 -lz +AR = ar +ARFLAGS= rcs + +LIBRARY = StormLib.dll +#LIBRARY = StormLib.lib + +OBJS_CPP = src/adpcm/adpcm.o \ + src/huffman/huff.o \ + src/sparse/sparse.o \ + src/FileStream.o \ + src/SBaseCommon.o \ + src/SBaseFileTable.o \ + src/SCompression.o \ + src/SFileAddFile.o \ + src/SFileAttributes.o \ + src/SFileCompactArchive.o \ + src/SFileCreateArchive.o \ + src/SFileExtractFile.o \ + src/SFileFindFile.o \ + src/SFileListFile.o \ + src/SFileOpenArchive.o \ + src/SFileOpenFileEx.o \ + src/SFilePatchArchives.o \ + src/SFileReadFile.o \ + src/SFileVerify.o + + +OBJS_C = src/bzip2/blocksort.o \ + src/bzip2/bzlib.o \ + src/bzip2/compress.o \ + src/bzip2/crctable.o \ + src/bzip2/decompress.o \ + src/bzip2/huffman.o \ + src/bzip2/randtable.o \ + src/jenkins/lookup3.o \ + src/libtomcrypt/src/hashes/hash_memory.o \ + src/libtomcrypt/src/hashes/md5.o \ + src/libtomcrypt/src/hashes/sha1.o\ + src/libtomcrypt/src/math/ltm_desc.o \ + src/libtomcrypt/src/math/multi.o \ + src/libtomcrypt/src/math/rand_prime.o \ + src/libtomcrypt/src/misc/base64_decode.o \ + src/libtomcrypt/src/misc/crypt_argchk.o \ + src/libtomcrypt/src/misc/crypt_find_hash.o \ + src/libtomcrypt/src/misc/crypt_find_prng.o \ + src/libtomcrypt/src/misc/crypt_hash_descriptor.o \ + src/libtomcrypt/src/misc/crypt_hash_is_valid.o \ + src/libtomcrypt/src/misc/crypt_libc.o \ + src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.o \ + src/libtomcrypt/src/misc/crypt_prng_descriptor.o \ + src/libtomcrypt/src/misc/crypt_prng_is_valid.o \ + src/libtomcrypt/src/misc/crypt_register_hash.o \ + src/libtomcrypt/src/misc/crypt_register_prng.o \ + src/libtomcrypt/src/misc/zeromem.o \ + src/libtomcrypt/src/pk/asn1/der_decode_bit_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_boolean.o \ + src/libtomcrypt/src/pk/asn1/der_decode_choice.o \ + src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_integer.o \ + src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.o \ + src/libtomcrypt/src/pk/asn1/der_decode_octet_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_printable_string.o \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.o \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.o \ + src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.o \ + src/libtomcrypt/src/pk/asn1/der_decode_short_integer.o \ + src/libtomcrypt/src/pk/asn1/der_decode_utctime.o \ + src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_bit_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_boolean.o \ + src/libtomcrypt/src/pk/asn1/der_length_ia5_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_integer.o \ + src/libtomcrypt/src/pk/asn1/der_length_object_identifier.o \ + src/libtomcrypt/src/pk/asn1/der_length_octet_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_printable_string.o \ + src/libtomcrypt/src/pk/asn1/der_length_sequence.o \ + src/libtomcrypt/src/pk/asn1/der_length_short_integer.o \ + src/libtomcrypt/src/pk/asn1/der_length_utctime.o \ + src/libtomcrypt/src/pk/asn1/der_length_utf8_string.o \ + src/libtomcrypt/src/pk/asn1/der_sequence_free.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_map.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_points.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.o \ + src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.o \ + src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.o \ + src/libtomcrypt/src/pk/rsa/rsa_exptmod.o \ + src/libtomcrypt/src/pk/rsa/rsa_free.o \ + src/libtomcrypt/src/pk/rsa/rsa_import.o \ + src/libtomcrypt/src/pk/rsa/rsa_make_key.o \ + src/libtomcrypt/src/pk/rsa/rsa_verify_hash.o \ + src/libtomcrypt/src/pk/rsa/rsa_verify_simple.o \ + src/libtommath/bncore.o \ + src/libtommath/bn_fast_mp_invmod.o \ + src/libtommath/bn_fast_mp_montgomery_reduce.o \ + src/libtommath/bn_fast_s_mp_mul_digs.o \ + src/libtommath/bn_fast_s_mp_mul_high_digs.o \ + src/libtommath/bn_fast_s_mp_sqr.o \ + src/libtommath/bn_mp_2expt.o \ + src/libtommath/bn_mp_abs.o \ + src/libtommath/bn_mp_add.o \ + src/libtommath/bn_mp_addmod.o \ + src/libtommath/bn_mp_add_d.o \ + src/libtommath/bn_mp_and.o \ + src/libtommath/bn_mp_clamp.o \ + src/libtommath/bn_mp_clear.o \ + src/libtommath/bn_mp_clear_multi.o \ + src/libtommath/bn_mp_cmp.o \ + src/libtommath/bn_mp_cmp_d.o \ + src/libtommath/bn_mp_cmp_mag.o \ + src/libtommath/bn_mp_cnt_lsb.o \ + src/libtommath/bn_mp_copy.o \ + src/libtommath/bn_mp_count_bits.o \ + src/libtommath/bn_mp_div.o \ + src/libtommath/bn_mp_div_2.o \ + src/libtommath/bn_mp_div_2d.o \ + src/libtommath/bn_mp_div_3.o \ + src/libtommath/bn_mp_div_d.o \ + src/libtommath/bn_mp_dr_is_modulus.o \ + src/libtommath/bn_mp_dr_reduce.o \ + src/libtommath/bn_mp_dr_setup.o \ + src/libtommath/bn_mp_exch.o \ + src/libtommath/bn_mp_exptmod.o \ + src/libtommath/bn_mp_exptmod_fast.o \ + src/libtommath/bn_mp_expt_d.o \ + src/libtommath/bn_mp_exteuclid.o \ + src/libtommath/bn_mp_fread.o \ + src/libtommath/bn_mp_fwrite.o \ + src/libtommath/bn_mp_gcd.o \ + src/libtommath/bn_mp_get_int.o \ + src/libtommath/bn_mp_grow.o \ + src/libtommath/bn_mp_init.o \ + src/libtommath/bn_mp_init_copy.o \ + src/libtommath/bn_mp_init_multi.o \ + src/libtommath/bn_mp_init_set.o \ + src/libtommath/bn_mp_init_set_int.o \ + src/libtommath/bn_mp_init_size.o \ + src/libtommath/bn_mp_invmod.o \ + src/libtommath/bn_mp_invmod_slow.o \ + src/libtommath/bn_mp_is_square.o \ + src/libtommath/bn_mp_jacobi.o \ + src/libtommath/bn_mp_karatsuba_mul.o \ + src/libtommath/bn_mp_karatsuba_sqr.o \ + src/libtommath/bn_mp_lcm.o \ + src/libtommath/bn_mp_lshd.o \ + src/libtommath/bn_mp_mod.o \ + src/libtommath/bn_mp_mod_2d.o \ + src/libtommath/bn_mp_mod_d.o \ + src/libtommath/bn_mp_montgomery_calc_normalization.o \ + src/libtommath/bn_mp_montgomery_reduce.o \ + src/libtommath/bn_mp_montgomery_setup.o \ + src/libtommath/bn_mp_mul.o \ + src/libtommath/bn_mp_mulmod.o \ + src/libtommath/bn_mp_mul_2.o \ + src/libtommath/bn_mp_mul_2d.o \ + src/libtommath/bn_mp_mul_d.o \ + src/libtommath/bn_mp_neg.o \ + src/libtommath/bn_mp_n_root.o \ + src/libtommath/bn_mp_or.o \ + src/libtommath/bn_mp_prime_fermat.o \ + src/libtommath/bn_mp_prime_is_divisible.o \ + src/libtommath/bn_mp_prime_is_prime.o \ + src/libtommath/bn_mp_prime_miller_rabin.o \ + src/libtommath/bn_mp_prime_next_prime.o \ + src/libtommath/bn_mp_prime_rabin_miller_trials.o \ + src/libtommath/bn_mp_prime_random_ex.o \ + src/libtommath/bn_mp_radix_size.o \ + src/libtommath/bn_mp_radix_smap.o \ + src/libtommath/bn_mp_rand.o \ + src/libtommath/bn_mp_read_radix.o \ + src/libtommath/bn_mp_read_signed_bin.o \ + src/libtommath/bn_mp_read_unsigned_bin.o \ + src/libtommath/bn_mp_reduce.o \ + src/libtommath/bn_mp_reduce_2k.o \ + src/libtommath/bn_mp_reduce_2k_l.o \ + src/libtommath/bn_mp_reduce_2k_setup.o \ + src/libtommath/bn_mp_reduce_2k_setup_l.o \ + src/libtommath/bn_mp_reduce_is_2k.o \ + src/libtommath/bn_mp_reduce_is_2k_l.o \ + src/libtommath/bn_mp_reduce_setup.o \ + src/libtommath/bn_mp_rshd.o \ + src/libtommath/bn_mp_set.o \ + src/libtommath/bn_mp_set_int.o \ + src/libtommath/bn_mp_shrink.o \ + src/libtommath/bn_mp_signed_bin_size.o \ + src/libtommath/bn_mp_sqr.o \ + src/libtommath/bn_mp_sqrmod.o \ + src/libtommath/bn_mp_sqrt.o \ + src/libtommath/bn_mp_sub.o \ + src/libtommath/bn_mp_submod.o \ + src/libtommath/bn_mp_sub_d.o \ + src/libtommath/bn_mp_toom_mul.o \ + src/libtommath/bn_mp_toom_sqr.o \ + src/libtommath/bn_mp_toradix.o \ + src/libtommath/bn_mp_toradix_n.o \ + src/libtommath/bn_mp_to_signed_bin.o \ + src/libtommath/bn_mp_to_signed_bin_n.o \ + src/libtommath/bn_mp_to_unsigned_bin.o \ + src/libtommath/bn_mp_to_unsigned_bin_n.o \ + src/libtommath/bn_mp_unsigned_bin_size.o \ + src/libtommath/bn_mp_xor.o \ + src/libtommath/bn_mp_zero.o \ + src/libtommath/bn_prime_tab.o \ + src/libtommath/bn_reverse.o \ + src/libtommath/bn_s_mp_add.o \ + src/libtommath/bn_s_mp_exptmod.o \ + src/libtommath/bn_s_mp_mul_digs.o \ + src/libtommath/bn_s_mp_mul_high_digs.o \ + src/libtommath/bn_s_mp_sqr.o \ + src/libtommath/bn_s_mp_sub.o \ + src/lzma/C/LzFind.o \ + src/lzma/C/LzmaDec.o \ + src/lzma/C/LzmaEnc.o \ + src/pklib/explode.o \ + src/pklib/implode.o \ + src/zlib/adler32.o \ + src/zlib/compress2.o \ + src/zlib/crc32.o \ + src/zlib/deflate.o \ + src/zlib/inffast.o \ + src/zlib/inflate.o \ + src/zlib/inftrees.o \ + src/zlib/trees.o \ + src/zlib/zutil.o \ + stormlib_dll/DllMain.o + +all: $(LIBRARY) + +#clean: +# rm -f $(OBJS) $(LIBRARY) + +#install: $(LIBRARY) +# install $(LIBRARY) /usr/local/lib +# mkdir -p /usr/local/include/StormLib +# cp StormLib.h /usr/local/include/StormLib +# cp StormPort.h /usr/local/include/StormLib + +$(LIBRARY): $(OBJS_C) $(OBJS_CPP) + $(CPP) $(CFLAGS) $(DFLAGS) -o $(LIBRARY) $(OBJS_C) $(OBJS_CPP) $(LFLAGS) + $(AR) $(ARFLAGS) $(LIBRARY) $(OBJS_C) $(OBJS_CPP) + +$(OBJS_C): %.o: %.c + $(CC) -o $@ $(CFLAGS) $(DFLAGS) -c $< + +$(OBJS_CPP): %.o: %.cpp + $(CC) -o $@ $(CFLAGS) $(DFLAGS) -c $< + diff --git a/dep/StormLib/src/FileStream.cpp b/dep/StormLib/src/FileStream.cpp index 55324ecb3..620373d9e 100644 --- a/dep/StormLib/src/FileStream.cpp +++ b/dep/StormLib/src/FileStream.cpp @@ -19,8 +19,7 @@ #include "FileStream.h" #ifdef _MSC_VER -#pragma comment(lib, "wininet.lib") // Internet functions for HTTP stream -#pragma warning(disable: 4800) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning) +#pragma comment(lib, "wininet.lib") #endif //----------------------------------------------------------------------------- @@ -30,155 +29,108 @@ #define INVALID_HANDLE_VALUE ((HANDLE)-1) #endif +#ifdef _MSC_VER +#pragma warning(disable: 4800) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning) +#endif + //----------------------------------------------------------------------------- // Local functions - platform-specific functions #ifndef PLATFORM_WINDOWS -static DWORD nLastError = ERROR_SUCCESS; +static int nLastError = ERROR_SUCCESS; -DWORD GetLastError() +int GetLastError() { return nLastError; } -void SetLastError(DWORD dwErrCode) +void SetLastError(int nError) { - nLastError = dwErrCode; + nLastError = nError; } #endif -static DWORD StringToInt(const char * szString) +#ifndef PLATFORM_LITTLE_ENDIAN +void ConvertPartHeader(void * partHeader) { - DWORD dwValue = 0; + PPART_FILE_HEADER theHeader = (PPART_FILE_HEADER)partHeader; - while('0' <= szString[0] && szString[0] <= '9') - { - dwValue = (dwValue * 10) + (szString[0] - '9'); - szString++; - } - - return dwValue; + theHeader->PartialVersion = SwapUInt32(theHeader->PartialVersion); + theHeader->Flags = SwapUInt32(theHeader->Flags); + theHeader->FileSizeLo = SwapUInt32(theHeader->FileSizeLo); + theHeader->FileSizeHi = SwapUInt32(theHeader->FileSizeHi); + theHeader->BlockSize = SwapUInt32(theHeader->BlockSize); } +#endif //----------------------------------------------------------------------------- -// Dummy init function +// Preparing file bitmap for a complete file of a given size -static void BaseNone_Init(TFileStream *) +#define DEFAULT_BLOCK_SIZE 0x4000 + +static bool Dummy_GetBitmap( + TFileStream * pStream, + TFileBitmap * pBitmap, + DWORD Length, + LPDWORD LengthNeeded) { - // Nothing here + ULONGLONG FileSize = 0; + DWORD TotalLength; + DWORD BlockCount; + DWORD BitmapSize; + DWORD LastByte; + bool bResult = false; + + // Get file size and calculate bitmap length + FileStream_GetSize(pStream, &FileSize); + BlockCount = (DWORD)(((FileSize - 1) / DEFAULT_BLOCK_SIZE) + 1); + BitmapSize = (DWORD)(((BlockCount - 1) / 8) + 1); + + // Calculate and give the total length + TotalLength = sizeof(TFileBitmap) + BitmapSize; + if(LengthNeeded != NULL) + *LengthNeeded = TotalLength; + + // Has the caller given enough space for storing the structure? + if(Length >= sizeof(TFileBitmap)) + { + memset(pBitmap, 0, sizeof(TFileBitmap)); + pBitmap->EndOffset = FileSize; + pBitmap->IsComplete = 1; + pBitmap->BitmapSize = BitmapSize; + pBitmap->BlockSize = DEFAULT_BLOCK_SIZE; + bResult = true; + } + + // Do we have enough space to fill the bitmap as well? + if(Length >= TotalLength) + { + LPBYTE pbBitmap = (LPBYTE)(pBitmap + 1); + + // Fill the full blocks + memset(pbBitmap, 0xFF, (BlockCount / 8)); + pbBitmap += (BlockCount / 8); + bResult = true; + + // Supply the last block + if(BlockCount & 7) + { + LastByte = (1 << (BlockCount & 7)) - 1; + pbBitmap[0] = (BYTE)LastByte; + } + } + + return bResult; } //----------------------------------------------------------------------------- // Local functions - base file support -static bool BaseFile_Create(TFileStream * pStream) -{ -#ifdef PLATFORM_WINDOWS - { - DWORD dwWriteShare = (pStream->dwFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0; - - pStream->Base.File.hFile = CreateFile(pStream->szFileName, - GENERIC_READ | GENERIC_WRITE, - dwWriteShare | FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - 0, - NULL); - if(pStream->Base.File.hFile == INVALID_HANDLE_VALUE) - return false; - } -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - { - intptr_t handle; - - handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if(handle == -1) - { - nLastError = errno; - return false; - } - - pStream->Base.File.hFile = (HANDLE)handle; - } -#endif - - // Reset the file size and position - pStream->Base.File.FileSize = 0; - pStream->Base.File.FilePos = 0; - return true; -} - -static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags) -{ -#ifdef PLATFORM_WINDOWS - { - ULARGE_INTEGER FileSize; - DWORD dwWriteAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? 0 : FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES; - DWORD dwWriteShare = (dwStreamFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0; - - // Open the file - pStream->Base.File.hFile = CreateFile(szFileName, - FILE_READ_DATA | FILE_READ_ATTRIBUTES | dwWriteAccess, - FILE_SHARE_READ | dwWriteShare, - NULL, - OPEN_EXISTING, - 0, - NULL); - if(pStream->Base.File.hFile == INVALID_HANDLE_VALUE) - return false; - - // Query the file size - FileSize.LowPart = GetFileSize(pStream->Base.File.hFile, &FileSize.HighPart); - pStream->Base.File.FileSize = FileSize.QuadPart; - - // Query last write time - GetFileTime(pStream->Base.File.hFile, NULL, NULL, (LPFILETIME)&pStream->Base.File.FileTime); - } -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - { - struct stat64 fileinfo; - int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR; - intptr_t handle; - - // Open the file - handle = open(szFileName, oflag | O_LARGEFILE); - if(handle == -1) - { - nLastError = errno; - return false; - } - - // Get the file size - if(fstat64(handle, &fileinfo) == -1) - { - nLastError = errno; - close(handle); - return false; - } - - // time_t is number of seconds since 1.1.1970, UTC. - // 1 second = 10000000 (decimal) in FILETIME - // Set the start to 1.1.1970 00:00:00 - pStream->Base.File.FileTime = 0x019DB1DED53E8000ULL + (10000000 * fileinfo.st_mtime); - pStream->Base.File.FileSize = (ULONGLONG)fileinfo.st_size; - pStream->Base.File.hFile = (HANDLE)handle; - } -#endif - - // Reset the file position - pStream->Base.File.FilePos = 0; - return true; -} - static bool BaseFile_Read( - TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position + void * pvBuffer, // Pointer to data to be read + DWORD dwBytesToRead) // Number of bytes to read from the file { ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.File.FilePos; DWORD dwBytesRead = 0; // Must be set by platform-specific code @@ -204,6 +156,24 @@ static bool BaseFile_Read( if(!ReadFile(pStream->Base.File.hFile, pvBuffer, dwBytesToRead, &dwBytesRead, &Overlapped)) return false; } + /* + // If the byte offset is different from the current file position, + // we have to update the file position + if(ByteOffset != pStream->Base.File.FilePos) + { + LONG ByteOffsetHi = (LONG)(ByteOffset >> 32); + + SetFilePointer(pStream->Base.File.hFile, (LONG)ByteOffset, &ByteOffsetHi, FILE_BEGIN); + pStream->Base.File.FilePos = ByteOffset; + } + + // Read the data + if(dwBytesToRead != 0) + { + if(!ReadFile(pStream->Base.File.hFile, pvBuffer, dwBytesToRead, &dwBytesRead, NULL)) + return false; + } +*/ } #endif @@ -212,10 +182,10 @@ static bool BaseFile_Read( ssize_t bytes_read; // If the byte offset is different from the current file position, - // we have to update the file position xxx + // we have to update the file position if(ByteOffset != pStream->Base.File.FilePos) { - lseek64((intptr_t)pStream->Base.File.hFile, (off64_t)(ByteOffset), SEEK_SET); + lseek((intptr_t)pStream->Base.File.hFile, (off_t)(ByteOffset), SEEK_SET); pStream->Base.File.FilePos = ByteOffset; } @@ -228,7 +198,7 @@ static bool BaseFile_Read( nLastError = errno; return false; } - + dwBytesRead = (DWORD)(size_t)bytes_read; } } @@ -275,6 +245,24 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const if(!WriteFile(pStream->Base.File.hFile, pvBuffer, dwBytesToWrite, &dwBytesWritten, &Overlapped)) return false; } + /* + // If the byte offset is different from the current file position, + // we have to update the file position + if(ByteOffset != pStream->Base.File.FilePos) + { + LONG ByteOffsetHi = (LONG)(ByteOffset >> 32); + + SetFilePointer(pStream->Base.File.hFile, (LONG)ByteOffset, &ByteOffsetHi, FILE_BEGIN); + pStream->Base.File.FilePos = ByteOffset; + } + + // Read the data + if(dwBytesToWrite != 0) + { + if(!WriteFile(pStream->Base.File.hFile, pvBuffer, dwBytesToWrite, &dwBytesWritten, NULL)) + return false; + } +*/ } #endif @@ -286,7 +274,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const // we have to update the file position if(ByteOffset != pStream->Base.File.FilePos) { - lseek64((intptr_t)pStream->Base.File.hFile, (off64_t)(ByteOffset), SEEK_SET); + lseek((intptr_t)pStream->Base.File.hFile, (off_t)(ByteOffset), SEEK_SET); pStream->Base.File.FilePos = ByteOffset; } @@ -297,7 +285,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const nLastError = errno; return false; } - + dwBytesWritten = (DWORD)(size_t)bytes_written; } #endif @@ -314,11 +302,27 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const return (dwBytesWritten == dwBytesToWrite); } +static bool BaseFile_GetPos( + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset) // Pointer to file byte offset +{ + *pByteOffset = pStream->Base.File.FilePos; + return true; +} + +static bool BaseFile_GetSize( + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pFileSize) // Pointer where to store file size +{ + *pFileSize = pStream->Base.File.FileSize; + return true; +} + /** * \a pStream Pointer to an open stream * \a NewFileSize New size of the file */ -static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) +static bool BaseFile_SetSize(TFileStream * pStream, ULONGLONG NewFileSize) { #ifdef PLATFORM_WINDOWS { @@ -334,8 +338,6 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) // Set the current file pointer as the end of the file bResult = (bool)SetEndOfFile(pStream->Base.File.hFile); - if(bResult) - pStream->Base.File.FileSize = NewFileSize; // Restore the file position FileSizeHi = (LONG)(pStream->Base.File.FilePos >> 32); @@ -344,41 +346,28 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) return bResult; } #endif - + #if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) { - if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1) + if(ftruncate((intptr_t)pStream->Base.File.hFile, (off_t)NewFileSize) == -1) { nLastError = errno; return false; } - - pStream->Base.File.FileSize = NewFileSize; + return true; } #endif } -// Gives the current file size -static bool BaseFile_GetSize(TFileStream * pStream, ULONGLONG * pFileSize) +static bool BaseFile_GetTime(TFileStream * pStream, ULONGLONG * pFileTime) { - // Note: Used by all thre base providers. - // Requires the TBaseData union to have the same layout for all three base providers - *pFileSize = pStream->Base.File.FileSize; - return true; -} - -// Gives the current file position -static bool BaseFile_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) -{ - // Note: Used by all thre base providers. - // Requires the TBaseData union to have the same layout for all three base providers - *pByteOffset = pStream->Base.File.FilePos; + *pFileTime = pStream->Base.File.FileTime; return true; } // Renames the file pointed by pStream so that it contains data from pNewStream -static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream) +static bool BaseFile_Switch(TFileStream * pStream, TFileStream * pNewStream) { #ifdef PLATFORM_WINDOWS // Delete the original stream file. Don't check the result value, @@ -396,7 +385,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream) nLastError = errno; return false; } - + return true; #endif } @@ -418,23 +407,203 @@ static void BaseFile_Close(TFileStream * pStream) pStream->Base.File.hFile = INVALID_HANDLE_VALUE; } -// Initializes base functions for the disk file -static void BaseFile_Init(TFileStream * pStream) +static bool BaseFile_Create( + TFileStream * pStream, + const TCHAR * szFileName, + DWORD dwStreamFlags) { - pStream->BaseCreate = BaseFile_Create; - pStream->BaseOpen = BaseFile_Open; +#ifdef PLATFORM_WINDOWS + { + DWORD dwWriteShare = (dwStreamFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0; + + pStream->Base.File.hFile = CreateFile(szFileName, + GENERIC_READ | GENERIC_WRITE, + dwWriteShare | FILE_SHARE_READ, + NULL, + CREATE_ALWAYS, + 0, + NULL); + if(pStream->Base.File.hFile == INVALID_HANDLE_VALUE) + return false; + } +#endif + +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) + { + intptr_t handle; + + handle = open(szFileName, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if(handle == -1) + { + nLastError = errno; + return false; + } + + pStream->Base.File.hFile = (HANDLE)handle; + } +#endif + + // Fill-in the entry points pStream->BaseRead = BaseFile_Read; pStream->BaseWrite = BaseFile_Write; - pStream->BaseResize = BaseFile_Resize; - pStream->BaseGetSize = BaseFile_GetSize; pStream->BaseGetPos = BaseFile_GetPos; + pStream->BaseGetSize = BaseFile_GetSize; + pStream->BaseSetSize = BaseFile_SetSize; + pStream->BaseSetSize = BaseFile_SetSize; + pStream->BaseGetTime = BaseFile_GetTime; pStream->BaseClose = BaseFile_Close; + + // Reset the file position + pStream->Base.File.FileSize = 0; + pStream->Base.File.FilePos = 0; + pStream->dwFlags = dwStreamFlags; + return true; +} + +static bool BaseFile_Open( + TFileStream * pStream, + const TCHAR * szFileName, + DWORD dwStreamFlags) +{ +#ifdef PLATFORM_WINDOWS + { + ULARGE_INTEGER FileSize; + DWORD dwDesiredAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? GENERIC_READ : GENERIC_ALL; + DWORD dwWriteShare = (dwStreamFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0; + + // Open the file + pStream->Base.File.hFile = CreateFile(szFileName, + dwDesiredAccess, + dwWriteShare | FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + 0, + NULL); + if(pStream->Base.File.hFile == INVALID_HANDLE_VALUE) + return false; + + // Query the file size + FileSize.LowPart = GetFileSize(pStream->Base.File.hFile, &FileSize.HighPart); + pStream->Base.File.FileSize = FileSize.QuadPart; + + // Query last write time + GetFileTime(pStream->Base.File.hFile, NULL, NULL, (LPFILETIME)&pStream->Base.File.FileTime); + } +#endif + +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) + { + struct stat fileinfo; + int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR; + intptr_t handle; + + // Open the file + handle = open(szFileName, oflag); + if(handle == -1) + { + nLastError = errno; + return false; + } + + // Get the file size + if(fstat(handle, &fileinfo) == -1) + { + nLastError = errno; + return false; + } + + // time_t is number of seconds since 1.1.1970, UTC. + // 1 second = 10000000 (decimal) in FILETIME + // Set the start to 1.1.1970 00:00:00 + pStream->Base.File.FileTime = 0x019DB1DED53E8000ULL + (10000000 * fileinfo.st_mtime); + pStream->Base.File.FileSize = (ULONGLONG)fileinfo.st_size; + pStream->Base.File.hFile = (HANDLE)handle; + } +#endif + + // Fill-in the entry points + pStream->BaseRead = BaseFile_Read; + pStream->BaseWrite = BaseFile_Write; + pStream->BaseGetPos = BaseFile_GetPos; + pStream->BaseGetSize = BaseFile_GetSize; + pStream->BaseSetSize = BaseFile_SetSize; + pStream->BaseGetTime = BaseFile_GetTime; + pStream->BaseClose = BaseFile_Close; + + // Reset the file position + pStream->Base.File.FilePos = 0; + pStream->dwFlags = dwStreamFlags; + return true; } //----------------------------------------------------------------------------- // Local functions - base memory-mapped file support -static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags) +static bool BaseMap_Read( + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position + void * pvBuffer, // Pointer to data to be read + DWORD dwBytesToRead) // Number of bytes to read from the file +{ + ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.Map.FilePos; + + // Do we have to read anything at all? + if(dwBytesToRead != 0) + { + // Don't allow reading past file size + if((ByteOffset + dwBytesToRead) > pStream->Base.Map.FileSize) + return false; + + // Copy the required data + memcpy(pvBuffer, pStream->Base.Map.pbFile + (size_t)ByteOffset, dwBytesToRead); + } + + // Move the current file position + pStream->Base.Map.FilePos += dwBytesToRead; + return true; +} + +static bool BaseMap_GetPos( + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset) // Pointer to file byte offset +{ + *pByteOffset = pStream->Base.Map.FilePos; + return true; +} + +static bool BaseMap_GetSize( + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pFileSize) // Pointer where to store file size +{ + *pFileSize = pStream->Base.Map.FileSize; + return true; +} + +static bool BaseMap_GetTime(TFileStream * pStream, ULONGLONG * pFileTime) +{ + *pFileTime = pStream->Base.Map.FileTime; + return true; +} + +static void BaseMap_Close(TFileStream * pStream) +{ +#ifdef PLATFORM_WINDOWS + if(pStream->Base.Map.pbFile != NULL) + UnmapViewOfFile(pStream->Base.Map.pbFile); +#endif + +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) + if(pStream->Base.Map.pbFile != NULL) + munmap(pStream->Base.Map.pbFile, (size_t )pStream->Base.Map.FileSize); +#endif + + pStream->Base.Map.pbFile = NULL; +} + +static bool BaseMap_Open( + TFileStream * pStream, + const TCHAR * szFileName, + DWORD dwStreamFlags) { #ifdef PLATFORM_WINDOWS @@ -443,17 +612,17 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD HANDLE hMap; bool bResult = false; - // Keep compiler happy - dwStreamFlags = dwStreamFlags; - // Open the file for read access - hFile = CreateFile(szFileName, FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(hFile != INVALID_HANDLE_VALUE) + hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if(hFile != NULL) { // Retrieve file size. Don't allow mapping file of a zero size. FileSize.LowPart = GetFileSize(hFile, &FileSize.HighPart); if(FileSize.QuadPart != 0) { + // Retrieve file time + GetFileTime(hFile, NULL, NULL, (LPFILETIME)&pStream->Base.Map.FileTime); + // Now create mapping object hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); if(hMap != NULL) @@ -464,10 +633,6 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD pStream->Base.Map.pbFile = (LPBYTE)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0); if(pStream->Base.Map.pbFile != NULL) { - // Retrieve file time - GetFileTime(hFile, NULL, NULL, (LPFILETIME)&pStream->Base.Map.FileTime); - - // Retrieve file size and position pStream->Base.Map.FileSize = FileSize.QuadPart; pStream->Base.Map.FilePos = 0; bResult = true; @@ -489,7 +654,7 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD #endif #if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - struct stat64 fileinfo; + struct stat fileinfo; intptr_t handle; bool bResult = false; @@ -498,7 +663,7 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD if(handle != -1) { // Get the file size - if(fstat64(handle, &fileinfo) != -1) + if(fstat(handle, &fileinfo) != -1) { pStream->Base.Map.pbFile = (LPBYTE)mmap(NULL, (size_t)fileinfo.st_size, PROT_READ, MAP_PRIVATE, handle, 0); if(pStream->Base.Map.pbFile != NULL) @@ -523,60 +688,14 @@ static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD } #endif - return true; -} - -static bool BaseMap_Read( - TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file -{ - ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.Map.FilePos; - - // Do we have to read anything at all? - if(dwBytesToRead != 0) - { - // Don't allow reading past file size - if((ByteOffset + dwBytesToRead) > pStream->Base.Map.FileSize) - return false; - - // Copy the required data - memcpy(pvBuffer, pStream->Base.Map.pbFile + (size_t)ByteOffset, dwBytesToRead); - } - - // Move the current file position - pStream->Base.Map.FilePos += dwBytesToRead; - return true; -} - -static void BaseMap_Close(TFileStream * pStream) -{ -#ifdef PLATFORM_WINDOWS - if(pStream->Base.Map.pbFile != NULL) - UnmapViewOfFile(pStream->Base.Map.pbFile); -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - if(pStream->Base.Map.pbFile != NULL) - munmap(pStream->Base.Map.pbFile, (size_t )pStream->Base.Map.FileSize); -#endif - - pStream->Base.Map.pbFile = NULL; -} - -// Initializes base functions for the mapped file -static void BaseMap_Init(TFileStream * pStream) -{ - // Supply the file stream functions - pStream->BaseOpen = BaseMap_Open; + // Fill-in entry points pStream->BaseRead = BaseMap_Read; - pStream->BaseGetSize = BaseFile_GetSize; // Reuse BaseFile function - pStream->BaseGetPos = BaseFile_GetPos; // Reuse BaseFile function + pStream->BaseGetPos = BaseMap_GetPos; + pStream->BaseGetSize = BaseMap_GetSize; + pStream->BaseGetTime = BaseMap_GetTime; pStream->BaseClose = BaseMap_Close; - - // Mapped files are read-only - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; + pStream->dwFlags = dwStreamFlags; + return true; } //----------------------------------------------------------------------------- @@ -598,126 +717,18 @@ static const TCHAR * BaseHttp_ExtractServerName(const TCHAR * szFileName, TCHAR else { while(szFileName[0] != 0 && szFileName[0] != _T('/')) - szFileName++; + *szFileName++; } // Return the remainder return szFileName; } -static bool BaseHttp_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags) -{ -#ifdef PLATFORM_WINDOWS - - HINTERNET hRequest; - DWORD dwTemp = 0; - - // Keep compiler happy - dwStreamFlags = dwStreamFlags; - - // Don't connect to the internet - if(!InternetGetConnectedState(&dwTemp, 0)) - return false; - - // Initiate the connection to the internet - pStream->Base.Http.hInternet = InternetOpen(_T("StormLib HTTP MPQ reader"), - INTERNET_OPEN_TYPE_PRECONFIG, - NULL, - NULL, - 0); - if(pStream->Base.Http.hInternet != NULL) - { - TCHAR szServerName[MAX_PATH]; - DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_UI | INTERNET_FLAG_NO_CACHE_WRITE; - - // Initiate connection with the server - szFileName = BaseHttp_ExtractServerName(szFileName, szServerName); - pStream->Base.Http.hConnect = InternetConnect(pStream->Base.Http.hInternet, - szServerName, - INTERNET_DEFAULT_HTTP_PORT, - NULL, - NULL, - INTERNET_SERVICE_HTTP, - dwFlags, - 0); - if(pStream->Base.Http.hConnect != NULL) - { - // Open HTTP request to the file - hRequest = HttpOpenRequest(pStream->Base.Http.hConnect, _T("GET"), szFileName, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0); - if(hRequest != NULL) - { - if(HttpSendRequest(hRequest, NULL, 0, NULL, 0)) - { - ULONGLONG FileTime = 0; - DWORD dwFileSize = 0; - DWORD dwDataSize; - DWORD dwIndex = 0; - TCHAR StatusCode[0x08]; - - // Check if the file succeeded to open - dwDataSize = sizeof(StatusCode); - if(HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE, StatusCode, &dwDataSize, &dwIndex)) - { - if(_tcscmp(StatusCode, _T("200"))) - { - InternetCloseHandle(hRequest); - SetLastError(ERROR_FILE_NOT_FOUND); - return false; - } - } - - // Check if the MPQ has Last Modified field - dwDataSize = sizeof(ULONGLONG); - if(HttpQueryInfo(hRequest, HTTP_QUERY_LAST_MODIFIED | HTTP_QUERY_FLAG_SYSTEMTIME, &FileTime, &dwDataSize, &dwIndex)) - pStream->Base.Http.FileTime = FileTime; - - // Verify if the server supports random access - dwDataSize = sizeof(DWORD); - if(HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &dwFileSize, &dwDataSize, &dwIndex)) - { - if(dwFileSize != 0) - { - InternetCloseHandle(hRequest); - pStream->Base.Http.FileSize = dwFileSize; - pStream->Base.Http.FilePos = 0; - return true; - } - } - } - - // Close the request - InternetCloseHandle(hRequest); - } - - // Close the connection handle - InternetCloseHandle(pStream->Base.Http.hConnect); - pStream->Base.Http.hConnect = NULL; - } - - // Close the internet handle - InternetCloseHandle(pStream->Base.Http.hInternet); - pStream->Base.Http.hInternet = NULL; - } - - // If the file is not there or is not available for random access, report error - pStream->BaseClose(pStream); - return false; - -#else - - // Not supported - SetLastError(ERROR_NOT_SUPPORTED); - pStream = pStream; - return false; - -#endif -} - static bool BaseHttp_Read( - TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position + void * pvBuffer, // Pointer to data to be read + DWORD dwBytesToRead) // Number of bytes to read from the file { #ifdef PLATFORM_WINDOWS ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.Http.FilePos; @@ -732,6 +743,7 @@ static bool BaseHttp_Read( TCHAR szRangeRequest[0x80]; DWORD dwStartOffset = (DWORD)ByteOffset; DWORD dwEndOffset = dwStartOffset + dwBytesToRead; + BYTE Buffer[0x200]; // Open HTTP request to the file szFileName = BaseHttp_ExtractServerName(pStream->szFileName, NULL); @@ -740,8 +752,8 @@ static bool BaseHttp_Read( { // Add range request to the HTTP headers // http://www.clevercomponents.com/articles/article015/resuming.asp - _stprintf(szRangeRequest, _T("Range: bytes=%u-%u"), (unsigned int)dwStartOffset, (unsigned int)dwEndOffset); - HttpAddRequestHeaders(hRequest, szRangeRequest, 0xFFFFFFFF, HTTP_ADDREQ_FLAG_ADD_IF_NEW); + _stprintf(szRangeRequest, _T("Range: bytes=%d-%d"), dwStartOffset, dwEndOffset); + HttpAddRequestHeaders(hRequest, szRangeRequest, 0xFFFFFFFF, HTTP_ADDREQ_FLAG_ADD_IF_NEW); // Send the request to the server if(HttpSendRequest(hRequest, NULL, 0, NULL, 0)) @@ -752,8 +764,8 @@ static bool BaseHttp_Read( DWORD dwBlockBytesRead = 0; // Read the block from the file - if(dwBlockBytesToRead > 0x200) - dwBlockBytesToRead = 0x200; + if(dwBlockBytesToRead > sizeof(Buffer)) + dwBlockBytesToRead = sizeof(Buffer); InternetReadFile(hRequest, pbBuffer, dwBlockBytesToRead, &dwBlockBytesRead); // Check for end @@ -790,6 +802,28 @@ static bool BaseHttp_Read( #endif } +static bool BaseHttp_GetPos( + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset) // Pointer to file byte offset +{ + *pByteOffset = pStream->Base.Http.FilePos; + return true; +} + +static bool BaseHttp_GetSize( + TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pFileSize) // Pointer where to store file size +{ + *pFileSize = pStream->Base.Http.FileSize; + return true; +} + +static bool BaseHttp_GetTime(TFileStream * pStream, ULONGLONG * pFileTime) +{ + *pFileTime = pStream->Base.Http.FileTime; + return true; +} + static void BaseHttp_Close(TFileStream * pStream) { #ifdef PLATFORM_WINDOWS @@ -805,626 +839,271 @@ static void BaseHttp_Close(TFileStream * pStream) #endif } -// Initializes base functions for the mapped file -static void BaseHttp_Init(TFileStream * pStream) +static bool BaseHttp_Open( + TFileStream * pStream, + const TCHAR * szFileName, + DWORD dwStreamFlags) { - // Supply the stream functions - pStream->BaseOpen = BaseHttp_Open; - pStream->BaseRead = BaseHttp_Read; - pStream->BaseGetSize = BaseFile_GetSize; // Reuse BaseFile function - pStream->BaseGetPos = BaseFile_GetPos; // Reuse BaseFile function - pStream->BaseClose = BaseHttp_Close; +#ifdef PLATFORM_WINDOWS - // HTTP files are read-only - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; -} + HINTERNET hRequest; + DWORD dwTemp = 0; + bool bFileAvailable = false; + int nError = ERROR_SUCCESS; -//----------------------------------------------------------------------------- -// Local functions - base block-based support + // Don't connect to the internet + if(!InternetGetConnectedState(&dwTemp, 0)) + nError = GetLastError(); -// Generic function that loads blocks from the file -// The function groups the block with the same availability, -// so the called BlockRead can finish the request in a single system call -static bool BlockStream_Read( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file -{ - ULONGLONG BlockOffset0; - ULONGLONG BlockOffset; - ULONGLONG ByteOffset; - ULONGLONG EndOffset; - LPBYTE TransferBuffer; - LPBYTE BlockBuffer; - DWORD BlockBufferOffset; // Offset of the desired data in the block buffer - DWORD BytesNeeded; // Number of bytes that really need to be read - DWORD BlockSize = pStream->BlockSize; - DWORD BlockCount; - bool bPrevBlockAvailable; - bool bCallbackCalled = false; - bool bBlockAvailable; - bool bResult = true; - - // The base block read function must be present - assert(pStream->BlockRead != NULL); - - // NOP reading of zero bytes - if(dwBytesToRead == 0) - return true; - - // Get the current position in the stream - ByteOffset = (pByteOffset != NULL) ? pByteOffset[0] : pStream->StreamPos; - EndOffset = ByteOffset + dwBytesToRead; - if(EndOffset > pStream->StreamSize) + // Initiate the connection to the internet + if(nError == ERROR_SUCCESS) { - SetLastError(ERROR_HANDLE_EOF); - return false; + pStream->Base.Http.hInternet = InternetOpen(_T("StormLib HTTP MPQ reader"), + INTERNET_OPEN_TYPE_PRECONFIG, + NULL, + NULL, + 0); + if(pStream->Base.Http.hInternet == NULL) + nError = GetLastError(); } - // Calculate the block parameters - BlockOffset0 = BlockOffset = ByteOffset & ~((ULONGLONG)BlockSize - 1); - BlockCount = (DWORD)(((EndOffset - BlockOffset) + (BlockSize - 1)) / BlockSize); - BytesNeeded = (DWORD)(EndOffset - BlockOffset); - - // Remember where we have our data - assert((BlockSize & (BlockSize - 1)) == 0); - BlockBufferOffset = (DWORD)(ByteOffset & (BlockSize - 1)); - - // Allocate buffer for reading blocks - TransferBuffer = BlockBuffer = STORM_ALLOC(BYTE, (BlockCount * BlockSize)); - if(TransferBuffer == NULL) + // Connect to the server + if(nError == ERROR_SUCCESS) { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return false; + TCHAR szServerName[MAX_PATH]; + DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_UI | INTERNET_FLAG_NO_CACHE_WRITE; + + // Initiate connection with the server + szFileName = BaseHttp_ExtractServerName(szFileName, szServerName); + pStream->Base.Http.hConnect = InternetConnect(pStream->Base.Http.hInternet, + szServerName, + INTERNET_DEFAULT_HTTP_PORT, + NULL, + NULL, + INTERNET_SERVICE_HTTP, + dwFlags, + 0); + if(pStream->Base.Http.hConnect == NULL) + nError = GetLastError(); } - // If all blocks are available, just read all blocks at once - if(pStream->IsComplete == 0) + // Now try to query the file size + if(nError == ERROR_SUCCESS) { - // Now parse the blocks and send the block read request - // to all blocks with the same availability - assert(pStream->BlockCheck != NULL); - bPrevBlockAvailable = pStream->BlockCheck(pStream, BlockOffset); - - // Loop as long as we have something to read - while(BlockOffset < EndOffset) + // Open HTTP request to the file + hRequest = HttpOpenRequest(pStream->Base.Http.hConnect, _T("GET"), szFileName, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0); + if(hRequest != NULL) { - // Determine availability of the next block - bBlockAvailable = pStream->BlockCheck(pStream, BlockOffset); - - // If the availability has changed, read all blocks up to this one - if(bBlockAvailable != bPrevBlockAvailable) + if(HttpSendRequest(hRequest, NULL, 0, NULL, 0)) { - // Call the file stream callback, if the block is not available - if(pStream->pMaster && pStream->pfnCallback && bPrevBlockAvailable == false) + ULONGLONG FileTime = 0; + DWORD dwFileSize = 0; + DWORD dwDataSize; + DWORD dwIndex = 0; + + // Check if the MPQ has Last Modified field + dwDataSize = sizeof(ULONGLONG); + if(HttpQueryInfo(hRequest, HTTP_QUERY_LAST_MODIFIED | HTTP_QUERY_FLAG_SYSTEMTIME, &FileTime, &dwDataSize, &dwIndex)) + pStream->Base.Http.FileTime = FileTime; + + // Verify if the server supports random access + dwDataSize = sizeof(DWORD); + if(HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &dwFileSize, &dwDataSize, &dwIndex)) { - pStream->pfnCallback(pStream->UserData, BlockOffset0, (DWORD)(BlockOffset - BlockOffset0)); - bCallbackCalled = true; - } - - // Load the continuous blocks with the same availability - assert(BlockOffset > BlockOffset0); - bResult = pStream->BlockRead(pStream, BlockOffset0, BlockOffset, BlockBuffer, BytesNeeded, bPrevBlockAvailable); - if(!bResult) - break; - - // Move the block offset - BlockBuffer += (DWORD)(BlockOffset - BlockOffset0); - BytesNeeded -= (DWORD)(BlockOffset - BlockOffset0); - bPrevBlockAvailable = bBlockAvailable; - BlockOffset0 = BlockOffset; - } - - // Move to the block offset in the stream - BlockOffset += BlockSize; - } - - // If there is a block(s) remaining to be read, do it - if(BlockOffset > BlockOffset0) - { - // Call the file stream callback, if the block is not available - if(pStream->pMaster && pStream->pfnCallback && bPrevBlockAvailable == false) - { - pStream->pfnCallback(pStream->UserData, BlockOffset0, (DWORD)(BlockOffset - BlockOffset0)); - bCallbackCalled = true; - } - - // Read the complete blocks from the file - if(BlockOffset > pStream->StreamSize) - BlockOffset = pStream->StreamSize; - bResult = pStream->BlockRead(pStream, BlockOffset0, BlockOffset, BlockBuffer, BytesNeeded, bPrevBlockAvailable); - } - } - else - { - // Read the complete blocks from the file - if(EndOffset > pStream->StreamSize) - EndOffset = pStream->StreamSize; - bResult = pStream->BlockRead(pStream, BlockOffset, EndOffset, BlockBuffer, BytesNeeded, true); - } - - // Now copy the data to the user buffer - if(bResult) - { - memcpy(pvBuffer, TransferBuffer + BlockBufferOffset, dwBytesToRead); - pStream->StreamPos = ByteOffset + dwBytesToRead; - } - else - { - // If the block read failed, set the last error - SetLastError(ERROR_FILE_INCOMPLETE); - } - - // Call the callback to indicate we are done - if(bCallbackCalled) - pStream->pfnCallback(pStream->UserData, 0, 0); - - // Free the block buffer and return - STORM_FREE(TransferBuffer); - return bResult; -} - -static bool BlockStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize) -{ - *pFileSize = pStream->StreamSize; - return true; -} - -static bool BlockStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) -{ - *pByteOffset = pStream->StreamPos; - return true; -} - -static void BlockStream_Close(TBlockStream * pStream) -{ - // Free the data map, if any - if(pStream->FileBitmap != NULL) - STORM_FREE(pStream->FileBitmap); - pStream->FileBitmap = NULL; - - // Call the base class for closing the stream - pStream->BaseClose(pStream); -} - -//----------------------------------------------------------------------------- -// File stream allocation function - -static STREAM_INIT StreamBaseInit[4] = -{ - BaseFile_Init, - BaseMap_Init, - BaseHttp_Init, - BaseNone_Init -}; - -// This function allocates an empty structure for the file stream -// The stream structure is created as flat block, variable length -// The file name is placed after the end of the stream structure data -static TFileStream * AllocateFileStream( - const TCHAR * szFileName, - size_t StreamSize, - DWORD dwStreamFlags) -{ - TFileStream * pMaster = NULL; - TFileStream * pStream; - const TCHAR * szNextFile = szFileName; - size_t FileNameSize; - - // Sanity check - assert(StreamSize != 0); - - // The caller can specify chain of files in the following form: - // C:\archive.MPQ*http://www.server.com/MPQs/archive-server.MPQ - // In that case, we use the part after "*" as master file name - while(szNextFile[0] != 0 && szNextFile[0] != _T('*')) - szNextFile++; - FileNameSize = (size_t)((szNextFile - szFileName) * sizeof(TCHAR)); - - // If we have a next file, we need to open it as master stream - // Note that we don't care if the master stream exists or not, - // If it doesn't, later attempts to read missing file block will fail - if(szNextFile[0] == _T('*')) - { - // Don't allow another master file in the string - if(_tcschr(szNextFile + 1, _T('*')) != NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - // Open the master file - pMaster = FileStream_OpenFile(szNextFile + 1, STREAM_FLAG_READ_ONLY); - } - - // Allocate the stream structure for the given stream type - pStream = (TFileStream *)STORM_ALLOC(BYTE, StreamSize + FileNameSize + sizeof(TCHAR)); - if(pStream != NULL) - { - // Zero the entire structure - memset(pStream, 0, StreamSize); - pStream->pMaster = pMaster; - pStream->dwFlags = dwStreamFlags; - - // Initialize the file name - pStream->szFileName = (TCHAR *)((BYTE *)pStream + StreamSize); - memcpy(pStream->szFileName, szFileName, FileNameSize); - pStream->szFileName[FileNameSize / sizeof(TCHAR)] = 0; - - // Initialize the stream functions - StreamBaseInit[dwStreamFlags & 0x03](pStream); - } - - return pStream; -} - -//----------------------------------------------------------------------------- -// Local functions - flat stream support - -static DWORD FlatStream_CheckFile(TBlockStream * pStream) -{ - LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap; - DWORD WholeByteCount = (pStream->BlockCount / 8); - DWORD ExtraBitsCount = (pStream->BlockCount & 7); - BYTE ExpectedValue; - - // Verify the whole bytes - their value must be 0xFF - for(DWORD i = 0; i < WholeByteCount; i++) - { - if(FileBitmap[i] != 0xFF) - return 0; - } - - // If there are extra bits, calculate the mask - if(ExtraBitsCount != 0) - { - ExpectedValue = (BYTE)((1 << ExtraBitsCount) - 1); - if(FileBitmap[WholeByteCount] != ExpectedValue) - return 0; - } - - // Yes, the file is complete - return 1; -} - -static bool FlatStream_LoadBitmap(TBlockStream * pStream) -{ - FILE_BITMAP_FOOTER Footer; - ULONGLONG ByteOffset; - LPBYTE FileBitmap; - DWORD BlockCount; - DWORD BitmapSize; - - // Do not load the bitmap if we should not have to - if(!(pStream->dwFlags & STREAM_FLAG_USE_BITMAP)) - return false; - - // Only if the size is greater than size of bitmap footer - if(pStream->Base.File.FileSize > sizeof(FILE_BITMAP_FOOTER)) - { - // Load the bitmap footer - ByteOffset = pStream->Base.File.FileSize - sizeof(FILE_BITMAP_FOOTER); - if(pStream->BaseRead(pStream, &ByteOffset, &Footer, sizeof(FILE_BITMAP_FOOTER))) - { - // Make sure that the array is properly BSWAP-ed - BSWAP_ARRAY32_UNSIGNED((LPDWORD)(&Footer), sizeof(FILE_BITMAP_FOOTER)); - - // Verify if there is actually a footer - if(Footer.Signature == ID_FILE_BITMAP_FOOTER && Footer.Version == 0x03) - { - // Get the offset of the bitmap, number of blocks and size of the bitmap - ByteOffset = MAKE_OFFSET64(Footer.MapOffsetHi, Footer.MapOffsetLo); - BlockCount = (DWORD)(((ByteOffset - 1) / Footer.BlockSize) + 1); - BitmapSize = ((BlockCount + 7) / 8); - - // Check if the sizes match - if(ByteOffset + BitmapSize + sizeof(FILE_BITMAP_FOOTER) == pStream->Base.File.FileSize) - { - // Allocate space for the bitmap - FileBitmap = STORM_ALLOC(BYTE, BitmapSize); - if(FileBitmap != NULL) + if(dwFileSize != 0) { - // Load the bitmap bits - if(!pStream->BaseRead(pStream, &ByteOffset, FileBitmap, BitmapSize)) - { - STORM_FREE(FileBitmap); - return false; - } - - // Update the stream size - pStream->BuildNumber = Footer.BuildNumber; - pStream->StreamSize = ByteOffset; - - // Fill the bitmap information - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = BitmapSize; - pStream->BlockSize = Footer.BlockSize; - pStream->BlockCount = BlockCount; - pStream->IsComplete = FlatStream_CheckFile(pStream); - return true; + pStream->Base.Http.FileSize = dwFileSize; + pStream->Base.Http.FilePos = 0; + bFileAvailable = true; } } } + InternetCloseHandle(hRequest); } } + // If the file is not there and is not available for random access, + // report error + if(bFileAvailable == false) + { + BaseHttp_Close(pStream); + return false; + } + + // Fill-in entry points + pStream->BaseRead = BaseHttp_Read; + pStream->BaseGetPos = BaseHttp_GetPos; + pStream->BaseGetSize = BaseHttp_GetSize; + pStream->BaseGetTime = BaseHttp_GetTime; + pStream->BaseClose = BaseHttp_Close; + pStream->dwFlags = dwStreamFlags; + return true; + +#else + + // Not supported + pStream = pStream; + szFileName = szFileName; + SetLastError(ERROR_NOT_SUPPORTED); return false; + +#endif } -static void FlatStream_UpdateBitmap( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset) +//----------------------------------------------------------------------------- +// Local functions - linear stream support + +static bool LinearStream_Read( + TLinearStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position + void * pvBuffer, // Pointer to data to be read + DWORD dwBytesToRead) // Number of bytes to read from the file { - LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap; + ULONGLONG ByteOffset; + ULONGLONG EndOffset; + LPBYTE pbBitmap; DWORD BlockIndex; - DWORD BlockSize = pStream->BlockSize; DWORD ByteIndex; - BYTE BitMask; + DWORD BitMask; - // Sanity checks - assert((StartOffset & (BlockSize - 1)) == 0); - assert(FileBitmap != NULL); + // At this point, we must have a bitmap set + assert(pStream->pBitmap != NULL); - // Calculate the index of the block - BlockIndex = (DWORD)(StartOffset / BlockSize); - ByteIndex = (BlockIndex / 0x08); - BitMask = (BYTE)(1 << (BlockIndex & 0x07)); - - // Set all bits for the specified range - while(StartOffset < EndOffset) + // If we have data map, we must check if the data block is present in the MPQ + if(dwBytesToRead != 0) { - // Set the bit - FileBitmap[ByteIndex] |= BitMask; + DWORD BlockSize = pStream->pBitmap->BlockSize; - // Move all - StartOffset += BlockSize; - ByteIndex += (BitMask >> 0x07); - BitMask = (BitMask >> 0x07) | (BitMask << 0x01); - } + // Get the offset where we read it from + if(pByteOffset == NULL) + pStream->BaseGetPos(pStream, &ByteOffset); + else + ByteOffset = *pByteOffset; + EndOffset = ByteOffset + dwBytesToRead; - // Increment the bitmap update count - pStream->IsModified = 1; -} - -static bool FlatStream_BlockCheck( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG BlockOffset) -{ - LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap; - DWORD BlockIndex; - BYTE BitMask; - - // Sanity checks - assert((BlockOffset & (pStream->BlockSize - 1)) == 0); - assert(FileBitmap != NULL); - - // Calculate the index of the block - BlockIndex = (DWORD)(BlockOffset / pStream->BlockSize); - BitMask = (BYTE)(1 << (BlockIndex & 0x07)); - - // Check if the bit is present - return (FileBitmap[BlockIndex / 0x08] & BitMask) ? true : false; -} - -static bool FlatStream_BlockRead( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) -{ - DWORD BytesToRead = (DWORD)(EndOffset - StartOffset); - - // The starting offset must be aligned to size of the block - assert(pStream->FileBitmap != NULL); - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - - // If the blocks are not available, we need to load them from the master - // and then save to the mirror - if(bAvailable == false) - { - // If we have no master, we cannot satisfy read request - if(pStream->pMaster == NULL) - return false; - - // Load the blocks from the master stream - // Note that we always have to read complete blocks - // so they get properly stored to the mirror stream - if(!FileStream_Read(pStream->pMaster, &StartOffset, BlockBuffer, BytesToRead)) - return false; - - // Store the loaded blocks to the mirror file. - // Note that this operation is not required to succeed - if(pStream->BaseWrite(pStream, &StartOffset, BlockBuffer, BytesToRead)) - FlatStream_UpdateBitmap(pStream, StartOffset, EndOffset); - - return true; - } - else - { - if(BytesToRead > BytesNeeded) - BytesToRead = BytesNeeded; - return pStream->BaseRead(pStream, &StartOffset, BlockBuffer, BytesToRead); - } -} - -static void FlatStream_Close(TBlockStream * pStream) -{ - FILE_BITMAP_FOOTER Footer; - - if(pStream->FileBitmap && pStream->IsModified) - { - // Write the file bitmap - pStream->BaseWrite(pStream, &pStream->StreamSize, pStream->FileBitmap, pStream->BitmapSize); - - // Prepare and write the file footer - Footer.Signature = ID_FILE_BITMAP_FOOTER; - Footer.Version = 3; - Footer.BuildNumber = pStream->BuildNumber; - Footer.MapOffsetLo = (DWORD)(pStream->StreamSize & 0xFFFFFFFF); - Footer.MapOffsetHi = (DWORD)(pStream->StreamSize >> 0x20); - Footer.BlockSize = pStream->BlockSize; - BSWAP_ARRAY32_UNSIGNED(&Footer, sizeof(FILE_BITMAP_FOOTER)); - pStream->BaseWrite(pStream, NULL, &Footer, sizeof(FILE_BITMAP_FOOTER)); - } - - // Close the base class - BlockStream_Close(pStream); -} - -static bool FlatStream_CreateMirror(TBlockStream * pStream) -{ - ULONGLONG MasterSize = 0; - ULONGLONG MirrorSize = 0; - LPBYTE FileBitmap = NULL; - DWORD dwBitmapSize; - DWORD dwBlockCount; - bool bNeedCreateMirrorStream = true; - bool bNeedResizeMirrorStream = true; - - // Do we have master function and base creation function? - if(pStream->pMaster == NULL || pStream->BaseCreate == NULL) - return false; - - // Retrieve the master file size, block count and bitmap size - FileStream_GetSize(pStream->pMaster, &MasterSize); - dwBlockCount = (DWORD)((MasterSize + DEFAULT_BLOCK_SIZE - 1) / DEFAULT_BLOCK_SIZE); - dwBitmapSize = (DWORD)((dwBlockCount + 7) / 8); - - // Setup stream size and position - pStream->BuildNumber = DEFAULT_BUILD_NUMBER; // BUGBUG: Really??? - pStream->StreamSize = MasterSize; - pStream->StreamPos = 0; - - // Open the base stream for write access - if(pStream->BaseOpen(pStream, pStream->szFileName, 0)) - { - // If the file open succeeded, check if the file size matches required size - pStream->BaseGetSize(pStream, &MirrorSize); - if(MirrorSize == MasterSize + dwBitmapSize + sizeof(FILE_BITMAP_FOOTER)) + // If the start of the area is within the region + // protected by data map, check each block + if(ByteOffset < pStream->pBitmap->EndOffset) { - // Attempt to load an existing file bitmap - if(FlatStream_LoadBitmap(pStream)) - return true; + // Cut the end of the stream protected by the data map + EndOffset = STORMLIB_MIN(EndOffset, pStream->pBitmap->EndOffset); - // We need to create new file bitmap - bNeedResizeMirrorStream = false; + // Calculate the initial block index + BlockIndex = (DWORD)(ByteOffset / BlockSize); + pbBitmap = (LPBYTE)(pStream->pBitmap + 1); + + // Parse each block + while(ByteOffset < EndOffset) + { + // Prepare byte index and bit mask + ByteIndex = BlockIndex / 8; + BitMask = 1 << (BlockIndex & 0x07); + + // If that bit is not set, it means that the block is not present + if((pbBitmap[ByteIndex] & BitMask) == 0) + { + SetLastError(ERROR_FILE_CORRUPT); + return false; + } + + // Move to tne next block + ByteOffset += BlockSize; + BlockIndex++; + } } - - // We need to create mirror stream - bNeedCreateMirrorStream = false; } - // Create a new stream, if needed - if(bNeedCreateMirrorStream) - { - if(!pStream->BaseCreate(pStream)) - return false; - } + // Now if all tests passed, we can call the base read function + return pStream->BaseRead(pStream, pByteOffset, pvBuffer, dwBytesToRead); +} - // If we need to, then resize the mirror stream - if(bNeedResizeMirrorStream) - { - if(!pStream->BaseResize(pStream, MasterSize + dwBitmapSize + sizeof(FILE_BITMAP_FOOTER))) - return false; - } +static bool LinearStream_Switch(TLinearStream * pStream, TLinearStream * pNewStream) +{ + // Sanity checks + assert((pNewStream->dwFlags & STREAM_PROVIDER_MASK) == STREAM_PROVIDER_LINEAR); + assert((pNewStream->dwFlags & BASE_PROVIDER_MASK) == BASE_PROVIDER_FILE); + assert((pStream->dwFlags & STREAM_PROVIDER_MASK) == STREAM_PROVIDER_LINEAR); + assert((pStream->dwFlags & BASE_PROVIDER_MASK) == BASE_PROVIDER_FILE); - // Allocate the bitmap array - FileBitmap = STORM_ALLOC(BYTE, dwBitmapSize); - if(FileBitmap == NULL) + // Close the new stream + pNewStream->BaseClose(pNewStream); + + // Close the source stream + pStream->BaseClose(pStream); + + // Rename the new data source file to the existing file + if(!BaseFile_Switch(pStream, pNewStream)) return false; - // Initialize the bitmap - memset(FileBitmap, 0, dwBitmapSize); - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = dwBitmapSize; - pStream->BlockSize = DEFAULT_BLOCK_SIZE; - pStream->BlockCount = dwBlockCount; - pStream->IsComplete = 0; - pStream->IsModified = 1; + // Now we have to open the "pStream" again + if(!BaseFile_Open(pStream, pStream->szFileName, pNewStream->dwFlags)) + return false; - // Note: Don't write the stream bitmap right away. - // Doing so would cause sparse file resize on NTFS, - // which would take long time on larger files. + // We need to cleanup the new data stream + FileStream_Close(pNewStream); return true; } -static TFileStream * FlatStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) +static bool LinearStream_GetBitmap( + TLinearStream * pStream, + TFileBitmap * pBitmap, + DWORD Length, + LPDWORD LengthNeeded) { - TBlockStream * pStream; - ULONGLONG ByteOffset = 0; + DWORD TotalLength; + bool bResult = false; - // Create new empty stream - pStream = (TBlockStream *)AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); - if(pStream == NULL) - return NULL; + // Assumed that we have bitmap now + assert(pStream->pBitmap != NULL); - // Do we have a master stream? - if(pStream->pMaster != NULL) + // Give the bitmap length + TotalLength = sizeof(TFileBitmap) + pStream->pBitmap->BitmapSize; + if(LengthNeeded != NULL) + *LengthNeeded = TotalLength; + + // Do we have enough space to fill at least the bitmap structure? + if(Length >= sizeof(TFileBitmap)) { - if(!FlatStream_CreateMirror(pStream)) + // Enough space for complete bitmap? + if(Length >= TotalLength) { - FileStream_Close(pStream); - SetLastError(ERROR_FILE_NOT_FOUND); - return NULL; + memcpy(pBitmap, pStream->pBitmap, TotalLength); + bResult = true; + } + else + { + memcpy(pBitmap, pStream->pBitmap, sizeof(TFileBitmap)); + bResult = true; } } - else - { - // Attempt to open the base stream - if(!pStream->BaseOpen(pStream, pStream->szFileName, dwStreamFlags)) - { - FileStream_Close(pStream); - return NULL; - } - // Load the bitmap, if required to - if(dwStreamFlags & STREAM_FLAG_USE_BITMAP) - FlatStream_LoadBitmap(pStream); - } + return bResult; +} - // If we have a stream bitmap, set the reading functions - // which check presence of each file block - if(pStream->FileBitmap != NULL) - { - // Set the stream position to zero. Stream size is already set - assert(pStream->StreamSize != 0); - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; +static void LinearStream_Close(TLinearStream * pStream) +{ + // Free the data map, if any + if(pStream->pBitmap != NULL) + STORM_FREE(pStream->pBitmap); + pStream->pBitmap = NULL; - // Supply the stream functions - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamClose = (STREAM_CLOSE)FlatStream_Close; + // Call the base class for closing the stream + return pStream->BaseClose(pStream); +} - // Supply the block functions - pStream->BlockCheck = (BLOCK_CHECK)FlatStream_BlockCheck; - pStream->BlockRead = (BLOCK_READ)FlatStream_BlockRead; - } - else - { - // Reset the base position to zero - pStream->BaseRead(pStream, &ByteOffset, NULL, 0); - - // Setup stream size and position - pStream->StreamSize = pStream->Base.File.FileSize; - pStream->StreamPos = 0; - - // Set the base functions - pStream->StreamRead = pStream->BaseRead; - pStream->StreamWrite = pStream->BaseWrite; - pStream->StreamResize = pStream->BaseResize; - pStream->StreamGetSize = pStream->BaseGetSize; - pStream->StreamGetPos = pStream->BaseGetPos; - pStream->StreamClose = pStream->BaseClose; - } - - return pStream; +static bool LinearStream_Open(TLinearStream * pStream) +{ + // No extra work here really; just set entry points + pStream->StreamRead = pStream->BaseRead; + pStream->StreamWrite = pStream->BaseWrite; + pStream->StreamGetPos = pStream->BaseGetPos; + pStream->StreamGetSize = pStream->BaseGetSize; + pStream->StreamSetSize = pStream->BaseSetSize; + pStream->StreamGetTime = pStream->BaseGetTime; + pStream->StreamGetBmp = (STREAM_GETBMP)Dummy_GetBitmap; + pStream->StreamSwitch = (STREAM_SWITCH)LinearStream_Switch; + pStream->StreamClose = (STREAM_CLOSE)LinearStream_Close; + return true; } //----------------------------------------------------------------------------- @@ -1447,400 +1126,276 @@ static bool IsPartHeader(PPART_FILE_HEADER pPartHdr) return false; } -static DWORD PartStream_CheckFile(TBlockStream * pStream) +static bool PartialStream_Read( + TPartialStream * pStream, + ULONGLONG * pByteOffset, + void * pvBuffer, + DWORD dwBytesToRead) { - PPART_FILE_MAP_ENTRY FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap; - DWORD dwBlockCount; + ULONGLONG RawByteOffset; + LPBYTE pbBuffer = (LPBYTE)pvBuffer; + DWORD dwBytesRemaining = dwBytesToRead; + DWORD dwPartOffset; + DWORD dwPartIndex; + DWORD dwBytesRead = 0; + DWORD dwBlockSize = pStream->BlockSize; + bool bResult = false; + int nFailReason = ERROR_HANDLE_EOF; // Why it failed if not enough bytes was read - // Get the number of blocks - dwBlockCount = (DWORD)((pStream->StreamSize + pStream->BlockSize - 1) / pStream->BlockSize); + // If the byte offset is not entered, use the current position + if(pByteOffset == NULL) + pByteOffset = &pStream->VirtualPos; - // Check all blocks - for(DWORD i = 0; i < dwBlockCount; i++, FileBitmap++) + // Check if the file position is not at or beyond end of the file + if(*pByteOffset >= pStream->VirtualSize) { - // Few sanity checks - assert(FileBitmap->LargeValueHi == 0); - assert(FileBitmap->LargeValueLo == 0); - assert(FileBitmap->Flags == 0 || FileBitmap->Flags == 3); - - // Check if this block is present - if(FileBitmap->Flags != 3) - return 0; + SetLastError(ERROR_HANDLE_EOF); + return false; } - // Yes, the file is complete - return 1; + // Get the part index where the read offset is + // Note that the part index should now be within the range, + // as read requests beyond-EOF are handled by the previous test + dwPartIndex = (DWORD)(*pByteOffset / pStream->BlockSize); + assert(dwPartIndex < pStream->BlockCount); + + // If the number of bytes remaining goes past + // the end of the file, cut them + if((*pByteOffset + dwBytesRemaining) > pStream->VirtualSize) + dwBytesRemaining = (DWORD)(pStream->VirtualSize - *pByteOffset); + + // Calculate the offset in the current part + dwPartOffset = (DWORD)(*pByteOffset) & (pStream->BlockSize - 1); + + // Read all data, one part at a time + while(dwBytesRemaining != 0) + { + PPART_FILE_MAP_ENTRY PartMap = pStream->PartMap + dwPartIndex; + DWORD dwBytesInPart; + + // If the part is not present in the file, we fail the read + if((PartMap->Flags & 3) == 0) + { + nFailReason = ERROR_FILE_CORRUPT; + bResult = false; + break; + } + + // If we are in the last part, we have to cut the number of bytes in the last part + if(dwPartIndex == pStream->BlockCount - 1) + dwBlockSize = (DWORD)pStream->VirtualSize & (pStream->BlockSize - 1); + + // Get the number of bytes reamining in the current part + dwBytesInPart = dwBlockSize - dwPartOffset; + + // Compute the raw file offset of the file part + RawByteOffset = MAKE_OFFSET64(PartMap->BlockOffsHi, PartMap->BlockOffsLo); + if(RawByteOffset == 0) + { + nFailReason = ERROR_FILE_CORRUPT; + bResult = false; + break; + } + + // If the number of bytes in part is too big, cut it + if(dwBytesInPart > dwBytesRemaining) + dwBytesInPart = dwBytesRemaining; + + // Append the offset within the part + RawByteOffset += dwPartOffset; + if(!pStream->BaseRead(pStream, &RawByteOffset, pbBuffer, dwBytesInPart)) + { + nFailReason = ERROR_FILE_CORRUPT; + bResult = false; + break; + } + + // Increment the file position + dwBytesRemaining -= dwBytesInPart; + dwBytesRead += dwBytesInPart; + pbBuffer += dwBytesInPart; + + // Move to the next file part + dwPartOffset = 0; + dwPartIndex++; + } + + // Move the file position by the number of bytes read + pStream->VirtualPos = *pByteOffset + dwBytesRead; + if(dwBytesRead != dwBytesToRead) + SetLastError(nFailReason); + return (dwBytesRead == dwBytesToRead); } -static bool PartStream_LoadBitmap(TBlockStream * pStream) +static bool PartialStream_GetPos( + TPartialStream * pStream, + ULONGLONG & ByteOffset) { - PPART_FILE_MAP_ENTRY FileBitmap; - PART_FILE_HEADER PartHdr; - ULONGLONG ByteOffset = 0; - ULONGLONG StreamSize = 0; - DWORD BlockCount; - DWORD BitmapSize; + ByteOffset = pStream->VirtualPos; + return true; +} - // Only if the size is greater than size of the bitmap header - if(pStream->Base.File.FileSize > sizeof(PART_FILE_HEADER)) +static bool PartialStream_GetSize( + TPartialStream * pStream, // Pointer to an open stream + ULONGLONG & FileSize) // Pointer where to store file size +{ + FileSize = pStream->VirtualSize; + return true; +} + +static bool PartialStream_GetBitmap( + TPartialStream * pStream, + TFileBitmap * pBitmap, + DWORD Length, + LPDWORD LengthNeeded) +{ + LPBYTE pbBitmap; + DWORD TotalLength; + DWORD BitmapSize = 0; + DWORD ByteOffset; + DWORD BitMask; + bool bResult = false; + + // Do we have stream bitmap? + BitmapSize = ((pStream->BlockCount - 1) / 8) + 1; + + // Give the bitmap length + TotalLength = sizeof(TFileBitmap) + BitmapSize; + if(LengthNeeded != NULL) + *LengthNeeded = TotalLength; + + // Do we have enough to fill at least the header? + if(Length >= sizeof(TFileBitmap)) { - // Attempt to read PART file header - if(pStream->BaseRead(pStream, &ByteOffset, &PartHdr, sizeof(PART_FILE_HEADER))) + // Fill the bitmap header + pBitmap->StartOffset = 0; + pBitmap->EndOffset = pStream->VirtualSize; + pBitmap->IsComplete = 1; + pBitmap->BitmapSize = BitmapSize; + pBitmap->BlockSize = pStream->BlockSize; + pBitmap->Reserved = 0; + + // Is there at least one incomplete block? + for(DWORD i = 0; i < pStream->BlockCount; i++) { - // We need to swap PART file header on big-endian platforms - BSWAP_ARRAY32_UNSIGNED(&PartHdr, sizeof(PART_FILE_HEADER)); - - // Verify the PART file header - if(IsPartHeader(&PartHdr)) + if(pStream->PartMap[i].Flags != 3) { - // Get the number of blocks and size of one block - StreamSize = MAKE_OFFSET64(PartHdr.FileSizeHi, PartHdr.FileSizeLo); - ByteOffset = sizeof(PART_FILE_HEADER); - BlockCount = (DWORD)((StreamSize + PartHdr.BlockSize - 1) / PartHdr.BlockSize); - BitmapSize = BlockCount * sizeof(PART_FILE_MAP_ENTRY); + pBitmap->IsComplete = 0; + break; + } + } - // Check if sizes match - if((ByteOffset + BitmapSize) < pStream->Base.File.FileSize) + bResult = true; + } + + // Do we have enough space for supplying the bitmap? + if(Length >= TotalLength) + { + // Fill the file bitmap + pbBitmap = (LPBYTE)(pBitmap + 1); + for(DWORD i = 0; i < pStream->BlockCount; i++) + { + // Is the block there? + if(pStream->PartMap[i].Flags == 3) + { + ByteOffset = i / 8; + BitMask = 1 << (i & 7); + pbBitmap[ByteOffset] |= BitMask; + } + } + bResult = true; + } + + return bResult; +} + +static void PartialStream_Close(TPartialStream * pStream) +{ + // Free the part map + if(pStream->PartMap != NULL) + STORM_FREE(pStream->PartMap); + pStream->PartMap = NULL; + + // Clear variables + pStream->VirtualSize = 0; + pStream->VirtualPos = 0; + + // Close the base stream + assert(pStream->BaseClose != NULL); + pStream->BaseClose(pStream); +} + +static bool PartialStream_Open(TPartialStream * pStream) +{ + PART_FILE_HEADER PartHdr; + ULONGLONG VirtualSize; // Size of the file stored in part file + ULONGLONG ByteOffset = {0}; + DWORD BlockCount; + + // Sanity check + assert(pStream->BaseRead != NULL); + + // Attempt to read PART file header + if(pStream->BaseRead(pStream, &ByteOffset, &PartHdr, sizeof(PART_FILE_HEADER))) + { + // We need to swap PART file header on big-endian platforms + BSWAP_PART_HEADER(&PartHdr); + + // Verify the PART file header + if(IsPartHeader(&PartHdr)) + { + // Calculate the number of parts in the file + VirtualSize = MAKE_OFFSET64(PartHdr.FileSizeHi, PartHdr.FileSizeLo); + assert(VirtualSize != 0); + BlockCount = (DWORD)((VirtualSize + PartHdr.BlockSize - 1) / PartHdr.BlockSize); + + // Allocate the map entry array + pStream->PartMap = STORM_ALLOC(PART_FILE_MAP_ENTRY, BlockCount); + if(pStream->PartMap != NULL) + { + // Load the block map + if(pStream->BaseRead(pStream, NULL, pStream->PartMap, BlockCount * sizeof(PART_FILE_MAP_ENTRY))) { - // Allocate space for the array of PART_FILE_MAP_ENTRY - FileBitmap = STORM_ALLOC(PART_FILE_MAP_ENTRY, BlockCount); - if(FileBitmap != NULL) - { - // Load the block map - if(!pStream->BaseRead(pStream, &ByteOffset, FileBitmap, BitmapSize)) - { - STORM_FREE(FileBitmap); - return false; - } + // Swap the array of file map entries + BSWAP_ARRAY32_UNSIGNED(pStream->PartMap, BlockCount * sizeof(PART_FILE_MAP_ENTRY)); - // Make sure that the byte order is correct - BSWAP_ARRAY32_UNSIGNED(FileBitmap, BitmapSize); + // Fill the members of PART file stream + pStream->VirtualSize = ((ULONGLONG)PartHdr.FileSizeHi) + PartHdr.FileSizeLo; + pStream->VirtualPos = 0; + pStream->BlockCount = BlockCount; + pStream->BlockSize = PartHdr.BlockSize; - // Update the stream size - pStream->BuildNumber = StringToInt(PartHdr.GameBuildNumber); - pStream->StreamSize = StreamSize; - - // Fill the bitmap information - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = BitmapSize; - pStream->BlockSize = PartHdr.BlockSize; - pStream->BlockCount = BlockCount; - pStream->IsComplete = PartStream_CheckFile(pStream); - return true; - } + // Set new function pointers + pStream->StreamRead = (STREAM_READ)PartialStream_Read; + pStream->StreamGetPos = (STREAM_GETPOS)PartialStream_GetPos; + pStream->StreamGetSize = (STREAM_GETSIZE)PartialStream_GetSize; + pStream->StreamGetTime = pStream->BaseGetTime; + pStream->StreamGetTime = pStream->BaseGetTime; + pStream->StreamGetBmp = (STREAM_GETBMP)PartialStream_GetBitmap; + pStream->StreamClose = (STREAM_CLOSE)PartialStream_Close; + return true; } + + // Free the part map + STORM_FREE(pStream->PartMap); + pStream->PartMap = NULL; } } } + SetLastError(ERROR_BAD_FORMAT); return false; } -static void PartStream_UpdateBitmap( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset, - ULONGLONG RealOffset) -{ - PPART_FILE_MAP_ENTRY FileBitmap; - DWORD BlockSize = pStream->BlockSize; - - // Sanity checks - assert((StartOffset & (BlockSize - 1)) == 0); - assert(pStream->FileBitmap != NULL); - - // Calculate the first entry in the block map - FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + (StartOffset / BlockSize); - - // Set all bits for the specified range - while(StartOffset < EndOffset) - { - // Set the bit - FileBitmap->BlockOffsHi = (DWORD)(RealOffset >> 0x20); - FileBitmap->BlockOffsLo = (DWORD)(RealOffset & 0xFFFFFFFF); - FileBitmap->Flags = 3; - - // Move all - StartOffset += BlockSize; - RealOffset += BlockSize; - FileBitmap++; - } - - // Increment the bitmap update count - pStream->IsModified = 1; -} - -static bool PartStream_BlockCheck( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG BlockOffset) -{ - PPART_FILE_MAP_ENTRY FileBitmap; - - // Sanity checks - assert((BlockOffset & (pStream->BlockSize - 1)) == 0); - assert(pStream->FileBitmap != NULL); - - // Calculate the block map entry - FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + (BlockOffset / pStream->BlockSize); - - // Check if the flags are present - return (FileBitmap->Flags & 0x03) ? true : false; -} - -static bool PartStream_BlockRead( - TBlockStream * pStream, - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) -{ - PPART_FILE_MAP_ENTRY FileBitmap; - ULONGLONG ByteOffset; - DWORD BytesToRead; - DWORD BlockIndex = (DWORD)(StartOffset / pStream->BlockSize); - - // The starting offset must be aligned to size of the block - assert(pStream->FileBitmap != NULL); - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - - // If the blocks are not available, we need to load them from the master - // and then save to the mirror - if(bAvailable == false) - { - // If we have no master, we cannot satisfy read request - if(pStream->pMaster == NULL) - return false; - - // Load the blocks from the master stream - // Note that we always have to read complete blocks - // so they get properly stored to the mirror stream - BytesToRead = (DWORD)(EndOffset - StartOffset); - if(!FileStream_Read(pStream->pMaster, &StartOffset, BlockBuffer, BytesToRead)) - return false; - - // The loaded blocks are going to be stored to the end of the file - // Note that this operation is not required to succeed - if(pStream->BaseGetSize(pStream, &ByteOffset)) - { - // Store the loaded blocks to the mirror file. - if(pStream->BaseWrite(pStream, &ByteOffset, BlockBuffer, BytesToRead)) - { - PartStream_UpdateBitmap(pStream, StartOffset, EndOffset, ByteOffset); - } - } - } - else - { - // Get the file map entry - FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + BlockIndex; - - // Read all blocks - while(StartOffset < EndOffset) - { - // Get the number of bytes to be read - BytesToRead = (DWORD)(EndOffset - StartOffset); - if(BytesToRead > pStream->BlockSize) - BytesToRead = pStream->BlockSize; - if(BytesToRead > BytesNeeded) - BytesToRead = BytesNeeded; - - // Read the block - ByteOffset = MAKE_OFFSET64(FileBitmap->BlockOffsHi, FileBitmap->BlockOffsLo); - if(!pStream->BaseRead(pStream, &ByteOffset, BlockBuffer, BytesToRead)) - return false; - - // Move the pointers - StartOffset += pStream->BlockSize; - BlockBuffer += pStream->BlockSize; - BytesNeeded -= pStream->BlockSize; - FileBitmap++; - } - } - - return true; -} - -static void PartStream_Close(TBlockStream * pStream) -{ - PART_FILE_HEADER PartHeader; - ULONGLONG ByteOffset = 0; - - if(pStream->FileBitmap && pStream->IsModified) - { - // Prepare the part file header - memset(&PartHeader, 0, sizeof(PART_FILE_HEADER)); - PartHeader.PartialVersion = 2; - PartHeader.FileSizeHi = (DWORD)(pStream->StreamSize >> 0x20); - PartHeader.FileSizeLo = (DWORD)(pStream->StreamSize & 0xFFFFFFFF); - PartHeader.BlockSize = pStream->BlockSize; - - // Make sure that the header is properly BSWAPed - BSWAP_ARRAY32_UNSIGNED(&PartHeader, sizeof(PART_FILE_HEADER)); - sprintf(PartHeader.GameBuildNumber, "%u", (unsigned int)pStream->BuildNumber); - - // Write the part header - pStream->BaseWrite(pStream, &ByteOffset, &PartHeader, sizeof(PART_FILE_HEADER)); - - // Write the block bitmap - BSWAP_ARRAY32_UNSIGNED(pStream->FileBitmap, pStream->BitmapSize); - pStream->BaseWrite(pStream, NULL, pStream->FileBitmap, pStream->BitmapSize); - } - - // Close the base class - BlockStream_Close(pStream); -} - -static bool PartStream_CreateMirror(TBlockStream * pStream) -{ - ULONGLONG RemainingSize; - ULONGLONG MasterSize = 0; - ULONGLONG MirrorSize = 0; - LPBYTE FileBitmap = NULL; - DWORD dwBitmapSize; - DWORD dwBlockCount; - bool bNeedCreateMirrorStream = true; - bool bNeedResizeMirrorStream = true; - - // Do we have master function and base creation function? - if(pStream->pMaster == NULL || pStream->BaseCreate == NULL) - return false; - - // Retrieve the master file size, block count and bitmap size - FileStream_GetSize(pStream->pMaster, &MasterSize); - dwBlockCount = (DWORD)((MasterSize + DEFAULT_BLOCK_SIZE - 1) / DEFAULT_BLOCK_SIZE); - dwBitmapSize = (DWORD)(dwBlockCount * sizeof(PART_FILE_MAP_ENTRY)); - - // Setup stream size and position - pStream->BuildNumber = DEFAULT_BUILD_NUMBER; // BUGBUG: Really??? - pStream->StreamSize = MasterSize; - pStream->StreamPos = 0; - - // Open the base stream for write access - if(pStream->BaseOpen(pStream, pStream->szFileName, 0)) - { - // If the file open succeeded, check if the file size matches required size - pStream->BaseGetSize(pStream, &MirrorSize); - if(MirrorSize >= sizeof(PART_FILE_HEADER) + dwBitmapSize) - { - // Check if the remaining size is aligned to block - RemainingSize = MirrorSize - sizeof(PART_FILE_HEADER) - dwBitmapSize; - if((RemainingSize & (DEFAULT_BLOCK_SIZE - 1)) == 0 || RemainingSize == MasterSize) - { - // Attempt to load an existing file bitmap - if(PartStream_LoadBitmap(pStream)) - return true; - } - } - - // We need to create mirror stream - bNeedCreateMirrorStream = false; - } - - // Create a new stream, if needed - if(bNeedCreateMirrorStream) - { - if(!pStream->BaseCreate(pStream)) - return false; - } - - // If we need to, then resize the mirror stream - if(bNeedResizeMirrorStream) - { - if(!pStream->BaseResize(pStream, sizeof(PART_FILE_HEADER) + dwBitmapSize)) - return false; - } - - // Allocate the bitmap array - FileBitmap = STORM_ALLOC(BYTE, dwBitmapSize); - if(FileBitmap == NULL) - return false; - - // Initialize the bitmap - memset(FileBitmap, 0, dwBitmapSize); - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = dwBitmapSize; - pStream->BlockSize = DEFAULT_BLOCK_SIZE; - pStream->BlockCount = dwBlockCount; - pStream->IsComplete = 0; - pStream->IsModified = 1; - - // Note: Don't write the stream bitmap right away. - // Doing so would cause sparse file resize on NTFS, - // which would take long time on larger files. - return true; -} - - -static TFileStream * PartStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) -{ - TBlockStream * pStream; - - // Create new empty stream - pStream = (TBlockStream *)AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); - if(pStream == NULL) - return NULL; - - // Do we have a master stream? - if(pStream->pMaster != NULL) - { - if(!PartStream_CreateMirror(pStream)) - { - FileStream_Close(pStream); - SetLastError(ERROR_FILE_NOT_FOUND); - return NULL; - } - } - else - { - // Attempt to open the base stream - if(!pStream->BaseOpen(pStream, pStream->szFileName, dwStreamFlags)) - { - FileStream_Close(pStream); - return NULL; - } - - // Load the part stream block map - if(!PartStream_LoadBitmap(pStream)) - { - FileStream_Close(pStream); - SetLastError(ERROR_BAD_FORMAT); - return NULL; - } - } - - // Set the stream position to zero. Stream size is already set - assert(pStream->StreamSize != 0); - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; - - // Set new function pointers - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamClose = (STREAM_CLOSE)PartStream_Close; - - // Supply the block functions - pStream->BlockCheck = (BLOCK_CHECK)PartStream_BlockCheck; - pStream->BlockRead = (BLOCK_READ)PartStream_BlockRead; - return pStream; -} - //----------------------------------------------------------------------------- -// Local functions - MPQE stream support +// Local functions - encrypted stream support static const char * szKeyTemplate = "expand 32-byte k000000000000000000000000000000000000000000000000"; static const char * AuthCodeArray[] = { - // Starcraft II (Heart of the Swarm) - // Authentication code URL: http://dist.blizzard.com/mediakey/hots-authenticationcode-bgdl.txt - // -0C- -1C--08- -18--04- -14--00- -10- - "S48B6CDTN5XEQAKQDJNDLJBJ73FDFM3U", // SC2 Heart of the Swarm-all : "expand 32-byte kQAKQ0000FM3UN5XE000073FD6CDT0000LJBJS48B0000DJND" - // Diablo III: Agent.exe (1.0.0.954) - // Address of decryption routine: 00502b00 + // Address of decryption routine: 00502b00 // Pointer to decryptor object: ECX // Pointer to key: ECX+0x5C // Authentication code URL: http://dist.blizzard.com/mediakey/d3-authenticationcode-enGB.txt @@ -1860,7 +1415,7 @@ static const char * AuthCodeArray[] = "6VWCQTN8V3ZZMRUCZXV8A8CGUX2TAA8H", // Diablo III Installer (zhTW): "expand 32-byte kMRUC0000AA8HV3ZZ0000UX2TQTN80000A8CG6VWC0000ZXV8" // "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // Diablo III Installer (zhCN): "expand 32-byte kXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - // Starcraft II (Wings of Liberty): Installer.exe (4.1.1.4219) + // Note: Starcraft II (Wings of Liberty): Installer.exe (4.1.1.4219) // Address of decryption routine: 0053A3D0 // Pointer to decryptor object: ECX // Pointer to key: ECX+0x5C @@ -1910,10 +1465,10 @@ static void CreateKeyFromAuthCode( } static void DecryptFileChunk( - DWORD * MpqData, - LPBYTE pbKey, - ULONGLONG ByteOffset, - DWORD dwLength) + DWORD * MpqData, + LPBYTE pbKey, + ULONGLONG ByteOffset, + DWORD dwLength) { ULONGLONG ChunkOffset; DWORD KeyShuffled[0x10]; @@ -1946,7 +1501,7 @@ static void DecryptFileChunk( KeyShuffled[0x04] = KeyMirror[0x0D]; KeyShuffled[0x01] = KeyMirror[0x0E]; KeyShuffled[0x00] = KeyMirror[0x0F]; - + // Shuffle the key - part 2 for(DWORD i = 0; i < RoundCount; i += 2) { @@ -2022,315 +1577,123 @@ static void DecryptFileChunk( } } -static bool MpqeStream_DetectFileKey(TEncryptedStream * pStream) +static bool DetectFileKey(LPBYTE pbKeyBuffer, LPBYTE pbEncryptedHeader) { ULONGLONG ByteOffset = 0; - BYTE EncryptedHeader[MPQE_CHUNK_SIZE]; BYTE FileHeader[MPQE_CHUNK_SIZE]; - // Read the first file chunk - if(pStream->BaseRead(pStream, &ByteOffset, EncryptedHeader, sizeof(EncryptedHeader))) + // We just try all known keys one by one + for(int i = 0; AuthCodeArray[i] != NULL; i++) { - // We just try all known keys one by one - for(int i = 0; AuthCodeArray[i] != NULL; i++) - { - // Prepare they decryption key from game serial number - CreateKeyFromAuthCode(pStream->Key, AuthCodeArray[i]); + // Prepare they decryption key from game serial number + CreateKeyFromAuthCode(pbKeyBuffer, AuthCodeArray[i]); - // Try to decrypt with the given key - memcpy(FileHeader, EncryptedHeader, MPQE_CHUNK_SIZE); - DecryptFileChunk((LPDWORD)FileHeader, pStream->Key, ByteOffset, MPQE_CHUNK_SIZE); + // Try to decrypt with the given key + memcpy(FileHeader, pbEncryptedHeader, MPQE_CHUNK_SIZE); + DecryptFileChunk((LPDWORD)FileHeader, pbKeyBuffer, ByteOffset, MPQE_CHUNK_SIZE); - // We check the decrypted data - // All known encrypted MPQs have header at the begin of the file, - // so we check for MPQ signature there. - if(FileHeader[0] == 'M' && FileHeader[1] == 'P' && FileHeader[2] == 'Q') - { - // Update the stream size - pStream->StreamSize = pStream->Base.File.FileSize; - - // Fill the block information - pStream->BlockSize = MPQE_CHUNK_SIZE; - pStream->BlockCount = (DWORD)(pStream->Base.File.FileSize + MPQE_CHUNK_SIZE - 1) / MPQE_CHUNK_SIZE; - pStream->IsComplete = 1; - return true; - } - } + // We check the decrypted data + // All known encrypted MPQs have header at the begin of the file, + // so we check for MPQ signature there. + if(FileHeader[0] == 'M' && FileHeader[1] == 'P' && FileHeader[2] == 'Q') + return true; } // Key not found, sorry return false; } -static bool MpqeStream_BlockRead( - TEncryptedStream * pStream, - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) +static bool EncryptedStream_Read( + TEncryptedStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position + void * pvBuffer, // Pointer to data to be read + DWORD dwBytesToRead) // Number of bytes to read from the file { - DWORD dwBytesToRead; + ULONGLONG StartOffset; // Offset of the first byte to be read from the file + ULONGLONG ByteOffset; // Offset that the caller wants + ULONGLONG EndOffset; // End offset that is to be read from the file + DWORD dwBytesToAllocate; + DWORD dwBytesToDecrypt; + DWORD dwOffsetInCache; + LPBYTE pbMpqData = NULL; + bool bResult = false; - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - assert(bAvailable != false); - BytesNeeded = BytesNeeded; - bAvailable = bAvailable; + // Get the byte offset + if(pByteOffset == NULL) + pStream->BaseGetPos(pStream, &ByteOffset); + else + ByteOffset = *pByteOffset; - // Read the file from the stream as-is - // Limit the reading to number of blocks really needed - dwBytesToRead = (DWORD)(EndOffset - StartOffset); - if(!pStream->BaseRead(pStream, &StartOffset, BlockBuffer, dwBytesToRead)) - return false; + // Cut it down to MPQE chunk size + StartOffset = ByteOffset; + StartOffset = StartOffset & ~(MPQE_CHUNK_SIZE - 1); + EndOffset = ByteOffset + dwBytesToRead; - // Decrypt the data - dwBytesToRead = (dwBytesToRead + MPQE_CHUNK_SIZE - 1) & ~(MPQE_CHUNK_SIZE - 1); - DecryptFileChunk((LPDWORD)BlockBuffer, pStream->Key, StartOffset, dwBytesToRead); - return true; -} + // Calculate number of bytes to decrypt + dwBytesToDecrypt = (DWORD)(EndOffset - StartOffset); + dwBytesToAllocate = (dwBytesToDecrypt + (MPQE_CHUNK_SIZE - 1)) & ~(MPQE_CHUNK_SIZE - 1); -static TFileStream * MpqeStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) -{ - TEncryptedStream * pStream; - - // Create new empty stream - pStream = (TEncryptedStream *)AllocateFileStream(szFileName, sizeof(TEncryptedStream), dwStreamFlags); - if(pStream == NULL) - return NULL; - - // Attempt to open the base stream - assert(pStream->BaseOpen != NULL); - if(!pStream->BaseOpen(pStream, pStream->szFileName, dwStreamFlags)) - return NULL; - - // Determine the encryption key for the MPQ - if(MpqeStream_DetectFileKey(pStream)) + // Allocate buffers for encrypted and decrypted data + pbMpqData = STORM_ALLOC(BYTE, dwBytesToAllocate); + if(pbMpqData) { - // Set the stream position and size - assert(pStream->StreamSize != 0); - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; + // Get the offset of the desired data in the cache + dwOffsetInCache = (DWORD)(ByteOffset - StartOffset); - // Set new function pointers - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamClose = pStream->BaseClose; - - // Supply the block functions - pStream->BlockRead = (BLOCK_READ)MpqeStream_BlockRead; - return pStream; - } - - // Cleanup the stream and return - FileStream_Close(pStream); - SetLastError(ERROR_UNKNOWN_FILE_KEY); - return NULL; -} - -//----------------------------------------------------------------------------- -// Local functions - Block4 stream support - -#define BLOCK4_BLOCK_SIZE 0x4000 // Size of one block -#define BLOCK4_HASH_SIZE 0x20 // Size of MD5 hash that is after each block -#define BLOCK4_MAX_BLOCKS 0x00002000 // Maximum amount of blocks per file -#define BLOCK4_MAX_FSIZE 0x08040000 // Max size of one file - -static bool Block4Stream_BlockRead( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) -{ - TBaseProviderData * BaseArray = (TBaseProviderData *)pStream->FileBitmap; - ULONGLONG ByteOffset; - DWORD BytesToRead; - DWORD StreamIndex; - DWORD BlockIndex; - bool bResult; - - // The starting offset must be aligned to size of the block - assert(pStream->FileBitmap != NULL); - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - assert(bAvailable == true); - - // Keep compiler happy - bAvailable = bAvailable; - EndOffset = EndOffset; - - while(BytesNeeded != 0) - { - // Calculate the block index and the file index - StreamIndex = (DWORD)((StartOffset / pStream->BlockSize) / BLOCK4_MAX_BLOCKS); - BlockIndex = (DWORD)((StartOffset / pStream->BlockSize) % BLOCK4_MAX_BLOCKS); - if(StreamIndex > pStream->BitmapSize) - return false; - - // Calculate the block offset - ByteOffset = ((ULONGLONG)BlockIndex * (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE)); - BytesToRead = STORMLIB_MIN(BytesNeeded, BLOCK4_BLOCK_SIZE); - - // Read from the base stream - pStream->Base = BaseArray[StreamIndex]; - bResult = pStream->BaseRead(pStream, &ByteOffset, BlockBuffer, BytesToRead); - BaseArray[StreamIndex] = pStream->Base; - - // Did the result succeed? - if(bResult == false) - return false; - - // Move pointers - StartOffset += BytesToRead; - BlockBuffer += BytesToRead; - BytesNeeded -= BytesToRead; - } - - return true; -} - - -static void Block4Stream_Close(TBlockStream * pStream) -{ - TBaseProviderData * BaseArray = (TBaseProviderData *)pStream->FileBitmap; - - // If we have a non-zero count of base streams, - // we have to close them all - if(BaseArray != NULL) - { - // Close all base streams - for(DWORD i = 0; i < pStream->BitmapSize; i++) + // Read the file from the stream as-is + if(pStream->BaseRead(pStream, &StartOffset, pbMpqData, dwBytesToDecrypt)) { - memcpy(&pStream->Base, BaseArray + i, sizeof(TBaseProviderData)); - pStream->BaseClose(pStream); + // Decrypt the data + DecryptFileChunk((LPDWORD)pbMpqData, pStream->Key, StartOffset, dwBytesToAllocate); + + // Copy the decrypted data + memcpy(pvBuffer, pbMpqData + dwOffsetInCache, dwBytesToRead); + bResult = true; } + else + { + assert(false); + } + + // Free decryption buffer + STORM_FREE(pbMpqData); } - // Free the data map, if any - if(pStream->FileBitmap != NULL) - STORM_FREE(pStream->FileBitmap); - pStream->FileBitmap = NULL; - - // Do not call the BaseClose function, - // we closed all handles already - return; + // Free buffers and exit + return bResult; } -static TFileStream * Block4Stream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) +static bool EncryptedStream_Open(TEncryptedStream * pStream) { - TBaseProviderData * NewBaseArray = NULL; - ULONGLONG RemainderBlock; - ULONGLONG BlockCount; - ULONGLONG FileSize; - TBlockStream * pStream; - TCHAR * szNameBuff; - size_t nNameLength; - DWORD dwBaseFiles = 0; - DWORD dwBaseFlags; - - // Create new empty stream - pStream = (TBlockStream *)AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); - if(pStream == NULL) - return NULL; + ULONGLONG ByteOffset = 0; + BYTE EncryptedHeader[MPQE_CHUNK_SIZE]; // Sanity check - assert(pStream->BaseOpen != NULL); + assert(pStream->BaseRead != NULL); - // Get the length of the file name without numeric suffix - nNameLength = _tcslen(pStream->szFileName); - if(pStream->szFileName[nNameLength - 2] == '.' && pStream->szFileName[nNameLength - 1] == '0') - nNameLength -= 2; - pStream->szFileName[nNameLength] = 0; - - // Supply the stream functions - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamClose = (STREAM_CLOSE)Block4Stream_Close; - pStream->BlockRead = (BLOCK_READ)Block4Stream_BlockRead; - - // Allocate work space for numeric names - szNameBuff = STORM_ALLOC(TCHAR, nNameLength + 4); - if(szNameBuff != NULL) + // Load one MPQE chunk and try to detect the file key + if(pStream->BaseRead(pStream, &ByteOffset, EncryptedHeader, sizeof(EncryptedHeader))) { - // Set the base flags - dwBaseFlags = (dwStreamFlags & STREAM_PROVIDERS_MASK) | STREAM_FLAG_READ_ONLY; - - // Go all suffixes from 0 to 30 - for(int nSuffix = 0; nSuffix < 30; nSuffix++) + // Attempt to decrypt the MPQ header with all known keys + if(DetectFileKey(pStream->Key, EncryptedHeader)) { - // Open the n-th file - _stprintf(szNameBuff, _T("%s.%u"), pStream->szFileName, nSuffix); - if(!pStream->BaseOpen(pStream, szNameBuff, dwBaseFlags)) - break; + // Assign functions + pStream->StreamRead = (STREAM_READ)EncryptedStream_Read; + pStream->StreamGetPos = pStream->BaseGetPos; + pStream->StreamGetSize = pStream->BaseGetSize; + pStream->StreamGetTime = pStream->BaseGetTime; + pStream->StreamGetBmp = (STREAM_GETBMP)Dummy_GetBitmap; + pStream->StreamClose = pStream->BaseClose; - // If the open succeeded, we re-allocate the base provider array - NewBaseArray = STORM_ALLOC(TBaseProviderData, dwBaseFiles + 1); - if(NewBaseArray == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return NULL; - } - - // Copy the old base data array to the new base data array - if(pStream->FileBitmap != NULL) - { - memcpy(NewBaseArray, pStream->FileBitmap, sizeof(TBaseProviderData) * dwBaseFiles); - STORM_FREE(pStream->FileBitmap); - } - - // Also copy the opened base array - memcpy(NewBaseArray + dwBaseFiles, &pStream->Base, sizeof(TBaseProviderData)); - pStream->FileBitmap = NewBaseArray; - dwBaseFiles++; - - // Get the size of the base stream - pStream->BaseGetSize(pStream, &FileSize); - assert(FileSize <= BLOCK4_MAX_FSIZE); - RemainderBlock = FileSize % (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE); - BlockCount = FileSize / (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE); - - // Increment the stream size and number of blocks - pStream->StreamSize += (BlockCount * BLOCK4_BLOCK_SIZE); - pStream->BlockCount += (DWORD)BlockCount; - - // Is this the last file? - if(FileSize < BLOCK4_MAX_FSIZE) - { - if(RemainderBlock) - { - pStream->StreamSize += (RemainderBlock - BLOCK4_HASH_SIZE); - pStream->BlockCount++; - } - break; - } + // We need to reset the position back to the begin of the file + pStream->BaseRead(pStream, &ByteOffset, EncryptedHeader, 0); + return true; } - // Fill the remainining block stream variables - pStream->BitmapSize = dwBaseFiles; - pStream->BlockSize = BLOCK4_BLOCK_SIZE; - pStream->IsComplete = 1; - pStream->IsModified = 0; - - // Fill the remaining stream variables - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; - - STORM_FREE(szNameBuff); + // An unknown key + SetLastError(ERROR_UNKNOWN_FILE_KEY); } - - // If we opened something, return success - if(dwBaseFiles == 0) - { - FileStream_Close(pStream); - SetLastError(ERROR_FILE_NOT_FOUND); - pStream = NULL; - } - - return pStream; + return false; } //----------------------------------------------------------------------------- @@ -2354,31 +1717,38 @@ static TFileStream * Block4Stream_Open(const TCHAR * szFileName, DWORD dwStreamF */ TFileStream * FileStream_CreateFile( - const TCHAR * szFileName, - DWORD dwStreamFlags) + const TCHAR * szFileName, + DWORD dwStreamFlags) { TFileStream * pStream; - // We only support creation of flat, local file - if((dwStreamFlags & (STREAM_PROVIDERS_MASK)) != (STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE)) + // We only support creation of linear, local file + if((dwStreamFlags & (STREAM_PROVIDER_MASK | BASE_PROVIDER_MASK)) != (STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE)) { SetLastError(ERROR_NOT_SUPPORTED); return NULL; } - // Allocate file stream structure for flat stream - pStream = AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); + // Allocate file stream structure for linear stream + pStream = STORM_ALLOC(TFileStream, 1); if(pStream != NULL) { + // Reset entire structure to zero + memset(pStream, 0, sizeof(TFileStream)); + _tcscpy(pStream->szFileName, szFileName); + // Attempt to create the disk file - if(BaseFile_Create(pStream)) + if(BaseFile_Create(pStream, szFileName, dwStreamFlags)) { // Fill the stream provider functions pStream->StreamRead = pStream->BaseRead; pStream->StreamWrite = pStream->BaseWrite; - pStream->StreamResize = pStream->BaseResize; - pStream->StreamGetSize = pStream->BaseGetSize; pStream->StreamGetPos = pStream->BaseGetPos; + pStream->StreamGetSize = pStream->BaseGetSize; + pStream->StreamSetSize = pStream->BaseSetSize; + pStream->StreamGetTime = pStream->BaseGetTime; + pStream->StreamGetBmp = (STREAM_GETBMP)Dummy_GetBitmap;; + pStream->StreamSwitch = (STREAM_SWITCH)LinearStream_Switch; pStream->StreamClose = pStream->BaseClose; return pStream; } @@ -2400,6 +1770,8 @@ TFileStream * FileStream_CreateFile( * - If the file does not exist, the function must return NULL * - If the file exists but cannot be open, then function must return NULL * - The parameters of the function must be validate by the caller + * - The function must check if the file is a PART file, + * and create TPartialStream object if so. * - The function must initialize all stream function pointers in TFileStream * - If the function fails from any reason, it must close all handles * and free all memory that has been allocated in the process of stream creation, @@ -2410,244 +1782,95 @@ TFileStream * FileStream_CreateFile( */ TFileStream * FileStream_OpenFile( - const TCHAR * szFileName, - DWORD dwStreamFlags) + const TCHAR * szFileName, + DWORD dwStreamFlags) { - DWORD dwProvider = dwStreamFlags & STREAM_PROVIDERS_MASK; - size_t nPrefixLength = FileStream_Prefix(szFileName, &dwProvider); + TFileStream * pStream = NULL; + size_t StreamSize = 0; + bool bStreamResult = false; + bool bBaseResult = false; - // Re-assemble the stream flags - dwStreamFlags = (dwStreamFlags & STREAM_OPTIONS_MASK) | dwProvider; - szFileName += nPrefixLength; - - // Perform provider-specific open + // Allocate file stream for each stream provider switch(dwStreamFlags & STREAM_PROVIDER_MASK) { - case STREAM_PROVIDER_FLAT: - return FlatStream_Open(szFileName, dwStreamFlags); + case STREAM_PROVIDER_LINEAR: // Allocate structure for linear stream + StreamSize = sizeof(TLinearStream); + break; - case STREAM_PROVIDER_PARTIAL: - return PartStream_Open(szFileName, dwStreamFlags); + case STREAM_PROVIDER_PARTIAL: + dwStreamFlags |= STREAM_FLAG_READ_ONLY; + StreamSize = sizeof(TPartialStream); + break; - case STREAM_PROVIDER_MPQE: - return MpqeStream_Open(szFileName, dwStreamFlags); + case STREAM_PROVIDER_ENCRYPTED: + dwStreamFlags |= STREAM_FLAG_READ_ONLY; + StreamSize = sizeof(TEncryptedStream); + break; - case STREAM_PROVIDER_BLOCK4: - return Block4Stream_Open(szFileName, dwStreamFlags); - - default: - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; + default: + return NULL; } -} -/** - * Returns the file name of the stream - * - * \a pStream Pointer to an open stream - */ -const TCHAR * FileStream_GetFileName(TFileStream * pStream) -{ - assert(pStream != NULL); - return pStream->szFileName; -} + // Allocate the stream for each type + pStream = (TFileStream *)STORM_ALLOC(BYTE, StreamSize); + if(pStream == NULL) + return NULL; -/** - * Returns the length of the provider prefix. Returns zero if no prefix - * - * \a szFileName Pointer to a stream name (file, mapped file, URL) - * \a pdwStreamProvider Pointer to a DWORD variable that receives stream provider (STREAM_PROVIDER_XXX) - */ + // Fill the stream structure with zeros + memset(pStream, 0, StreamSize); + _tcscpy(pStream->szFileName, szFileName); -size_t FileStream_Prefix(const TCHAR * szFileName, DWORD * pdwProvider) -{ - size_t nPrefixLength1 = 0; - size_t nPrefixLength2 = 0; - DWORD dwProvider = 0; - - if(szFileName != NULL) + // Now initialize the respective base provider + switch(dwStreamFlags & BASE_PROVIDER_MASK) { - // - // Determine the stream provider - // + case BASE_PROVIDER_FILE: + bBaseResult = BaseFile_Open(pStream, szFileName, dwStreamFlags); + break; - if(!_tcsnicmp(szFileName, _T("flat-"), 5)) - { - dwProvider |= STREAM_PROVIDER_FLAT; - nPrefixLength1 = 5; - } + case BASE_PROVIDER_MAP: + dwStreamFlags |= STREAM_FLAG_READ_ONLY; + bBaseResult = BaseMap_Open(pStream, szFileName, dwStreamFlags); + break; - else if(!_tcsnicmp(szFileName, _T("part-"), 5)) - { - dwProvider |= STREAM_PROVIDER_PARTIAL; - nPrefixLength1 = 5; - } - - else if(!_tcsnicmp(szFileName, _T("mpqe-"), 5)) - { - dwProvider |= STREAM_PROVIDER_MPQE; - nPrefixLength1 = 5; - } - - else if(!_tcsnicmp(szFileName, _T("blk4-"), 5)) - { - dwProvider |= STREAM_PROVIDER_BLOCK4; - nPrefixLength1 = 5; - } - - // - // Determine the base provider - // - - if(!_tcsnicmp(szFileName+nPrefixLength1, _T("file:"), 5)) - { - dwProvider |= BASE_PROVIDER_FILE; - nPrefixLength2 = 5; - } - - else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("map:"), 4)) - { - dwProvider |= BASE_PROVIDER_MAP; - nPrefixLength2 = 4; - } - - else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("http:"), 5)) - { - dwProvider |= BASE_PROVIDER_HTTP; - nPrefixLength2 = 5; - } - - // Only accept stream provider if we recognized the base provider - if(nPrefixLength2 != 0) - { - // It is also allowed to put "//" after the base provider, e.g. "file://", "http://" - if(szFileName[nPrefixLength1+nPrefixLength2] == '/' && szFileName[nPrefixLength1+nPrefixLength2+1] == '/') - nPrefixLength2 += 2; - - if(pdwProvider != NULL) - *pdwProvider = dwProvider; - return nPrefixLength1 + nPrefixLength2; - } + case BASE_PROVIDER_HTTP: + dwStreamFlags |= STREAM_FLAG_READ_ONLY; + bBaseResult = BaseHttp_Open(pStream, szFileName, dwStreamFlags); + break; } - return 0; -} - -/** - * Sets a download callback. Whenever the stream needs to download one or more blocks - * from the server, the callback is called - * - * \a pStream Pointer to an open stream - * \a pfnCallback Pointer to callback function - * \a pvUserData Arbitrary user pointer passed to the download callback - */ - -bool FileStream_SetCallback(TFileStream * pStream, SFILE_DOWNLOAD_CALLBACK pfnCallback, void * pvUserData) -{ - TBlockStream * pBlockStream = (TBlockStream *)pStream; - - if(pStream->BlockRead == NULL) + // If we failed to open the base storage, fail the operation + if(bBaseResult == false) { - SetLastError(ERROR_NOT_SUPPORTED); - return false; + STORM_FREE(pStream); + return NULL; } - pBlockStream->pfnCallback = pfnCallback; - pBlockStream->UserData = pvUserData; - return true; -} - -/** - * This function gives the block map. The 'pvBitmap' pointer must point to a buffer - * of at least sizeof(STREAM_BLOCK_MAP) size. It can also have size of the complete - * block map (i.e. sizeof(STREAM_BLOCK_MAP) + BitmapSize). In that case, the function - * also copies the bit-based block map. - * - * \a pStream Pointer to an open stream - * \a pvBitmap Pointer to buffer where the block map will be stored - * \a cbBitmap Length of the buffer, of the block map - * \a cbLengthNeeded Length of the bitmap, in bytes - */ - -bool FileStream_GetBitmap(TFileStream * pStream, void * pvBitmap, DWORD cbBitmap, DWORD * pcbLengthNeeded) -{ - TStreamBitmap * pBitmap = (TStreamBitmap *)pvBitmap; - TBlockStream * pBlockStream = (TBlockStream *)pStream; - ULONGLONG BlockOffset; - LPBYTE Bitmap = (LPBYTE)(pBitmap + 1); - DWORD BitmapSize; - DWORD BlockCount; - DWORD BlockSize; - bool bResult = false; - - // Retrieve the size of one block - if(pStream->BlockCheck != NULL) + // Now initialize the stream provider + switch(dwStreamFlags & STREAM_PROVIDER_MASK) { - BlockCount = pBlockStream->BlockCount; - BlockSize = pBlockStream->BlockSize; + case STREAM_PROVIDER_LINEAR: + bStreamResult = LinearStream_Open((TLinearStream *)pStream); + break; + + case STREAM_PROVIDER_PARTIAL: + bStreamResult = PartialStream_Open((TPartialStream *)pStream); + break; + + case STREAM_PROVIDER_ENCRYPTED: + bStreamResult = EncryptedStream_Open((TEncryptedStream *)pStream); + break; } - else + + // If the operation failed, free the stream and set it to NULL + if(bStreamResult == false) { - BlockCount = (DWORD)((pStream->StreamSize + DEFAULT_BLOCK_SIZE - 1) / DEFAULT_BLOCK_SIZE); - BlockSize = DEFAULT_BLOCK_SIZE; + // Only close the base stream + pStream->BaseClose(pStream); + STORM_FREE(pStream); + pStream = NULL; } - // Fill-in the variables - BitmapSize = (BlockCount + 7) / 8; - - // Give the number of blocks - if(pcbLengthNeeded != NULL) - pcbLengthNeeded[0] = sizeof(TStreamBitmap) + BitmapSize; - - // If the length of the buffer is not enough - if(pvBitmap != NULL && cbBitmap != 0) - { - // Give the STREAM_BLOCK_MAP structure - if(cbBitmap >= sizeof(TStreamBitmap)) - { - pBitmap->StreamSize = pStream->StreamSize; - pBitmap->BitmapSize = BitmapSize; - pBitmap->BlockCount = BlockCount; - pBitmap->BlockSize = BlockSize; - pBitmap->IsComplete = (pStream->BlockCheck != NULL) ? pBlockStream->IsComplete : 1; - bResult = true; - } - - // Give the block bitmap, if enough space - if(cbBitmap >= sizeof(TStreamBitmap) + BitmapSize) - { - // Version with bitmap present - if(pStream->BlockCheck != NULL) - { - DWORD ByteIndex = 0; - BYTE BitMask = 0x01; - - // Initialize the map with zeros - memset(Bitmap, 0, BitmapSize); - - // Fill the map - for(BlockOffset = 0; BlockOffset < pStream->StreamSize; BlockOffset += BlockSize) - { - // Set the bit if the block is present - if(pBlockStream->BlockCheck(pStream, BlockOffset)) - Bitmap[ByteIndex] |= BitMask; - - // Move bit position - ByteIndex += (BitMask >> 0x07); - BitMask = (BitMask >> 0x07) | (BitMask << 0x01); - } - } - else - { - memset(Bitmap, 0xFF, BitmapSize); - } - } - } - - // Set last error value and return - if(bResult == false) - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return bResult; + return pStream; } /** @@ -2690,15 +1913,23 @@ bool FileStream_Read(TFileStream * pStream, ULONGLONG * pByteOffset, void * pvBu bool FileStream_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const void * pvBuffer, DWORD dwBytesToWrite) { if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); return false; - } assert(pStream->StreamWrite != NULL); return pStream->StreamWrite(pStream, pByteOffset, pvBuffer, dwBytesToWrite); } +/** + * This function returns the current file position + * \a pStream + * \a ByteOffset + */ +bool FileStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) +{ + assert(pStream->StreamGetPos != NULL); + return pStream->StreamGetPos(pStream, pByteOffset); +} + /** * Returns the size of a file * @@ -2718,26 +1949,12 @@ bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize) * \a NewFileSize File size to set */ bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize) -{ - if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - assert(pStream->StreamResize != NULL); - return pStream->StreamResize(pStream, NewFileSize); -} - -/** - * This function returns the current file position - * \a pStream - * \a pByteOffset - */ -bool FileStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) { - assert(pStream->StreamGetPos != NULL); - return pStream->StreamGetPos(pStream, pByteOffset); + if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) + return false; + + assert(pStream->StreamSetSize != NULL); + return pStream->StreamSetSize(pStream, NewFileSize); } /** @@ -2748,9 +1965,8 @@ bool FileStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) */ bool FileStream_GetTime(TFileStream * pStream, ULONGLONG * pFileTime) { - // Just use the saved filetime value - *pFileTime = pStream->Base.File.FileTime; - return true; + assert(pStream->StreamGetTime != NULL); + return pStream->StreamGetTime(pStream, pFileTime); } /** @@ -2774,41 +1990,87 @@ bool FileStream_GetFlags(TFileStream * pStream, LPDWORD pdwStreamFlags) * 3) Opens the MPQ stores the handle and stream position to the new stream structure * * \a pStream Pointer to an open stream - * \a pNewStream Temporary ("working") stream (created during archive compacting) + * \a pTempStream Temporary ("working") stream (created during archive compacting) */ -bool FileStream_Replace(TFileStream * pStream, TFileStream * pNewStream) +bool FileStream_Switch(TFileStream * pStream, TFileStream * pNewStream) { - // Only supported on flat files - if((pStream->dwFlags & STREAM_PROVIDERS_MASK) != (STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE)) - { - SetLastError(ERROR_NOT_SUPPORTED); - return false; - } - - // Not supported on read-only streams if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - // Close both stream's base providers - pNewStream->BaseClose(pNewStream); - pStream->BaseClose(pStream); - - // Now we have to delete the (now closed) old file and rename the new file - if(!BaseFile_Replace(pStream, pNewStream)) return false; - // Now open the base file again - if(!BaseFile_Open(pStream, pStream->szFileName, pStream->dwFlags)) + assert(pStream->StreamSwitch != NULL); + return pStream->StreamSwitch(pStream, pNewStream); +} + +/** + * Returns the file name of the stream + * + * \a pStream Pointer to an open stream + */ +TCHAR * FileStream_GetFileName(TFileStream * pStream) +{ + assert(pStream != NULL); + return pStream->szFileName; +} + +/** + * Returns true if the stream is read-only + * + * \a pStream Pointer to an open stream + */ +bool FileStream_IsReadOnly(TFileStream * pStream) +{ + return (pStream->dwFlags & STREAM_FLAG_READ_ONLY) ? true : false; +} + +/** + * This function enabled a linear stream to include data bitmap. + * Used by MPQs v 4.0 from WoW. Each file block is represented by + * a bit in the bitmap. 1 means the block is present, 0 means it's not. + * + * \a pStream Pointer to an open stream + * \a pBitmap Pointer to file bitmap + */ + +bool FileStream_SetBitmap(TFileStream * pStream, TFileBitmap * pBitmap) +{ + TLinearStream * pLinearStream; + + // It must be a linear stream. + if((pStream->dwFlags & STREAM_PROVIDER_MASK) != STREAM_PROVIDER_LINEAR) + return false; + pLinearStream = (TLinearStream *)pStream; + + // Two bitmaps are not allowed + if(pLinearStream->pBitmap != NULL) return false; - // Cleanup the new stream - FileStream_Close(pNewStream); + // We need to change some entry points + pLinearStream->StreamRead = (STREAM_READ)LinearStream_Read; + pLinearStream->StreamGetBmp = (STREAM_GETBMP)LinearStream_GetBitmap; + + // Using data bitmap renders the stream to be read only. + pLinearStream->dwFlags |= STREAM_FLAG_READ_ONLY; + pLinearStream->pBitmap = pBitmap; return true; } +/** + * This function retrieves the file bitmap. A file bitmap is an array + * of bits, each bit representing one file block. A value of 1 means + * that the block is present in the file, a value of 0 means that the + * block is not present. + * + * \a pStream Pointer to an open stream + * \a pBitmap Pointer to buffer where to store the file bitmap + * \a Length Size of buffer pointed by pBitmap, in bytes + * \a LengthNeeded If non-NULL, the function supplies the necessary byte size of the buffer + */ +bool FileStream_GetBitmap(TFileStream * pStream, TFileBitmap * pBitmap, DWORD Length, LPDWORD LengthNeeded) +{ + assert(pStream->StreamGetBmp != NULL); + return pStream->StreamGetBmp(pStream, pBitmap, Length, LengthNeeded); +} + /** * This function closes an archive file and frees any data buffers * that have been allocated for stream management. The function must also @@ -2822,20 +2084,211 @@ void FileStream_Close(TFileStream * pStream) // Check if the stream structure is allocated at all if(pStream != NULL) { - // Free the master stream, if any - if(pStream->pMaster != NULL) - FileStream_Close(pStream->pMaster); - pStream->pMaster = NULL; - - // Close the stream provider ... - if(pStream->StreamClose != NULL) - pStream->StreamClose(pStream); - - // ... or close base stream, if any - else if(pStream->BaseClose != NULL) - pStream->BaseClose(pStream); + // Close the stream provider. + // This will also close the base stream + assert(pStream->StreamClose != NULL); + pStream->StreamClose(pStream); // Free the stream itself STORM_FREE(pStream); } } + +//----------------------------------------------------------------------------- +// main - for testing purposes + +#ifdef __STORMLIB_TEST__ +int FileStream_Test(const TCHAR * szFileName, DWORD dwStreamFlags) +{ + TFileStream * pStream; + TMPQHeader MpqHeader; + ULONGLONG FilePos; + TMPQBlock * pBlock; + TMPQHash * pHash; + + InitializeMpqCryptography(); + + pStream = FileStream_OpenFile(szFileName, dwStreamFlags); + if(pStream == NULL) + return GetLastError(); + + // Read the MPQ header + FileStream_Read(pStream, NULL, &MpqHeader, MPQ_HEADER_SIZE_V2); + if(MpqHeader.dwID != ID_MPQ) + return ERROR_FILE_CORRUPT; + + // Read the hash table + pHash = STORM_ALLOC(TMPQHash, MpqHeader.dwHashTableSize); + if(pHash != NULL) + { + FilePos = MpqHeader.dwHashTablePos; + FileStream_Read(pStream, &FilePos, pHash, MpqHeader.dwHashTableSize * sizeof(TMPQHash)); + DecryptMpqBlock(pHash, MpqHeader.dwHashTableSize * sizeof(TMPQHash), MPQ_KEY_HASH_TABLE); + STORM_FREE(pHash); + } + + // Read the block table + pBlock = STORM_ALLOC(TMPQBlock, MpqHeader.dwBlockTableSize); + if(pBlock != NULL) + { + FilePos = MpqHeader.dwBlockTablePos; + FileStream_Read(pStream, &FilePos, pBlock, MpqHeader.dwBlockTableSize * sizeof(TMPQBlock)); + DecryptMpqBlock(pBlock, MpqHeader.dwBlockTableSize * sizeof(TMPQBlock), MPQ_KEY_BLOCK_TABLE); + STORM_FREE(pBlock); + } + + FileStream_Close(pStream); + return ERROR_SUCCESS; +} +#endif + +/* +int FileStream_Test() +{ + TFileStream * pStream; + + InitializeMpqCryptography(); + + // + // Test 1: Write to a stream + // + + pStream = FileStream_CreateFile("E:\\Stream.bin", 0); + if(pStream != NULL) + { + char szString1[100] = "This is a single line\n\r"; + DWORD dwLength = strlen(szString1); + + for(int i = 0; i < 10; i++) + { + if(!FileStream_Write(pStream, NULL, szString1, dwLength)) + { + printf("Failed to write to the stream\n"); + return ERROR_CAN_NOT_COMPLETE; + } + } + FileStream_Close(pStream); + } + + // + // Test2: Read from the stream + // + + pStream = FileStream_OpenFile("E:\\Stream.bin", STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + if(pStream != NULL) + { + char szString1[100] = "This is a single line\n\r"; + char szString2[100]; + DWORD dwLength = strlen(szString1); + + // This call must end with an error + if(FileStream_Write(pStream, NULL, "aaa", 3)) + { + printf("Write succeeded while it should fail\n"); + return -1; + } + + for(int i = 0; i < 10; i++) + { + if(!FileStream_Read(pStream, NULL, szString2, dwLength)) + { + printf("Failed to read from the stream\n"); + return -1; + } + + szString2[dwLength] = 0; + if(strcmp(szString1, szString2)) + { + printf("Data read from file are different from data written\n"); + return -1; + } + } + FileStream_Close(pStream); + } + + // + // Test3: Open the temp stream, write some data and switch it to the original stream + // + + pStream = FileStream_OpenFile("E:\\Stream.bin", STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + if(pStream != NULL) + { + TFileStream * pTempStream; + ULONGLONG FileSize; + + pTempStream = FileStream_CreateFile("E:\\TempStream.bin", 0); + if(pTempStream == NULL) + { + printf("Failed to create temp stream\n"); + return -1; + } + + // Copy the original stream to the temp + if(!FileStream_GetSize(pStream, FileSize)) + { + printf("Failed to get the file size\n"); + return -1; + } + + while(FileSize != 0) + { + DWORD dwBytesToRead = (DWORD)FileSize; + char Buffer[0x80]; + + if(dwBytesToRead > sizeof(Buffer)) + dwBytesToRead = sizeof(Buffer); + + if(!FileStream_Read(pStream, NULL, Buffer, dwBytesToRead)) + { + printf("CopyStream: Read source file failed\n"); + return -1; + } + + if(!FileStream_Write(pTempStream, NULL, Buffer, dwBytesToRead)) + { + printf("CopyStream: Write target file failed\n"); + return -1; + } + + FileSize -= dwBytesToRead; + } + + // Switch the streams + // Note that the pTempStream is closed by the operation + FileStream_Switch(pStream, pTempStream); + FileStream_Close(pStream); + } + + // + // Test4: Read from the stream again + // + + pStream = FileStream_OpenFile("E:\\Stream.bin", STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + if(pStream != NULL) + { + char szString1[100] = "This is a single line\n\r"; + char szString2[100]; + DWORD dwLength = strlen(szString1); + + for(int i = 0; i < 10; i++) + { + if(!FileStream_Read(pStream, NULL, szString2, dwLength)) + { + printf("Failed to read from the stream\n"); + return -1; + } + + szString2[dwLength] = 0; + if(strcmp(szString1, szString2)) + { + printf("Data read from file are different from data written\n"); + return -1; + } + } + FileStream_Close(pStream); + } + + return 0; +} +*/ + diff --git a/dep/StormLib/src/FileStream.h b/dep/StormLib/src/FileStream.h index 44beeed91..5c50a0d2a 100644 --- a/dep/StormLib/src/FileStream.h +++ b/dep/StormLib/src/FileStream.h @@ -14,77 +14,58 @@ //----------------------------------------------------------------------------- // Function prototypes -typedef void (*STREAM_INIT)( - struct TFileStream * pStream // Pointer to an unopened stream -); - -typedef bool (*STREAM_CREATE)( - struct TFileStream * pStream // Pointer to an unopened stream - ); - -typedef bool (*STREAM_OPEN)( - struct TFileStream * pStream, // Pointer to an unopened stream - const TCHAR * szFileName, // Pointer to file name to be open - DWORD dwStreamFlags // Stream flags - ); - typedef bool (*STREAM_READ)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead // Number of bytes to read from the file - ); + struct TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position + void * pvBuffer, // Pointer to data to be read + DWORD dwBytesToRead // Number of bytes to read from the file + ); typedef bool (*STREAM_WRITE)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it writes to the current position - const void * pvBuffer, // Pointer to data to be written - DWORD dwBytesToWrite // Number of bytes to read from the file - ); - -typedef bool (*STREAM_RESIZE)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG FileSize // New size for the file, in bytes - ); - -typedef bool (*STREAM_GETSIZE)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pFileSize // Receives the file size, in bytes - ); + struct TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it writes to the current position + const void * pvBuffer, // Pointer to data to be written + DWORD dwBytesToWrite // Number of bytes to read from the file + ); typedef bool (*STREAM_GETPOS)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset // Pointer to store current file position - ); + struct TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pByteOffset // Pointer to store current file position + ); + +typedef bool (*STREAM_GETSIZE)( + struct TFileStream * pStream, // Pointer to an open stream + ULONGLONG * pFileSize // Receives the file size, in bytes + ); + +typedef bool (*STREAM_SETSIZE)( + struct TFileStream * pStream, // Pointer to an open stream + ULONGLONG FileSize // New size for the file, in bytes + ); + +typedef bool (*STREAM_GETTIME)( + struct TFileStream * pStream, + ULONGLONG * pFT + ); + +typedef bool (*STREAM_SWITCH)( + struct TFileStream * pStream, + struct TFileStream * pNewStream + ); + +typedef bool (*STREAM_GETBMP)( + TFileStream * pStream, + TFileBitmap * pBitmap, + DWORD Length, + LPDWORD LengthNeeded + ); typedef void (*STREAM_CLOSE)( - struct TFileStream * pStream // Pointer to an open stream - ); - -typedef bool (*BLOCK_READ)( - struct TFileStream * pStream, // Pointer to a block-oriented stream - ULONGLONG StartOffset, // Byte offset of start of the block array - ULONGLONG EndOffset, // End offset (either end of the block or end of the file) - LPBYTE BlockBuffer, // Pointer to block-aligned buffer - DWORD BytesNeeded, // Number of bytes that are really needed - bool bAvailable // true if the block is available - ); - -typedef bool (*BLOCK_CHECK)( - struct TFileStream * pStream, // Pointer to a block-oriented stream - ULONGLONG BlockOffset // Offset of the file to check - ); - -typedef void (*BLOCK_SAVEMAP)( - struct TFileStream * pStream // Pointer to a block-oriented stream - ); + struct TFileStream * pStream + ); //----------------------------------------------------------------------------- -// Local structures - partial file structure and bitmap footer - -#define ID_FILE_BITMAP_FOOTER 0x33767470 // Signature of the file bitmap footer ('ptv3') -#define DEFAULT_BLOCK_SIZE 0x00004000 // Default size of the stream block -#define DEFAULT_BUILD_NUMBER 10958 // Build number for newly created partial MPQs +// Local structures - part file structure typedef struct _PART_FILE_HEADER { @@ -108,108 +89,99 @@ typedef struct _PART_FILE_MAP_ENTRY } PART_FILE_MAP_ENTRY, *PPART_FILE_MAP_ENTRY; -typedef struct _FILE_BITMAP_FOOTER -{ - DWORD Signature; // 'ptv3' (ID_FILE_BITMAP_FOOTER) - DWORD Version; // Unknown, seems to always have value of 3 (version?) - DWORD BuildNumber; // Game build number for that MPQ - DWORD MapOffsetLo; // Low 32-bits of the offset of the bit map - DWORD MapOffsetHi; // High 32-bits of the offset of the bit map - DWORD BlockSize; // Size of one block (usually 0x4000 bytes) - -} FILE_BITMAP_FOOTER, *PFILE_BITMAP_FOOTER; - //----------------------------------------------------------------------------- -// Structure for file stream +// Local structures -union TBaseProviderData +union TBaseData { struct { ULONGLONG FileSize; // Size of the file ULONGLONG FilePos; // Current file position - ULONGLONG FileTime; // Last write time + ULONGLONG FileTime; // Date/time of last modification of the file HANDLE hFile; // File handle } File; struct { - ULONGLONG FileSize; // Size of the file - ULONGLONG FilePos; // Current file position - ULONGLONG FileTime; // Last write time + ULONGLONG FileSize; // Mapped file size + ULONGLONG FilePos; // Current stream position + ULONGLONG FileTime; // Date/time of last modification of the file LPBYTE pbFile; // Pointer to mapped view } Map; struct { - ULONGLONG FileSize; // Size of the file - ULONGLONG FilePos; // Current file position - ULONGLONG FileTime; // Last write time + ULONGLONG FileSize; // Size of the internet file + ULONGLONG FilePos; // Current position in the file + ULONGLONG FileTime; // Date/time of last modification of the file HANDLE hInternet; // Internet handle HANDLE hConnect; // Connection to the internet server } Http; }; +//----------------------------------------------------------------------------- +// Structure for linear stream + struct TFileStream { // Stream provider functions STREAM_READ StreamRead; // Pointer to stream read function for this archive. Do not use directly. STREAM_WRITE StreamWrite; // Pointer to stream write function for this archive. Do not use directly. - STREAM_RESIZE StreamResize; // Pointer to function changing file size - STREAM_GETSIZE StreamGetSize; // Pointer to function returning file size STREAM_GETPOS StreamGetPos; // Pointer to function that returns current file position + STREAM_GETSIZE StreamGetSize; // Pointer to function returning file size + STREAM_SETSIZE StreamSetSize; // Pointer to function changing file size + STREAM_GETTIME StreamGetTime; // Pointer to function retrieving the file time + STREAM_GETBMP StreamGetBmp; // Pointer to function that retrieves the file bitmap + STREAM_SWITCH StreamSwitch; // Pointer to function changing the stream to another file STREAM_CLOSE StreamClose; // Pointer to function closing the stream - // Block-oriented functions - BLOCK_READ BlockRead; // Pointer to function reading one or more blocks - BLOCK_CHECK BlockCheck; // Pointer to function checking whether the block is present + // Stream provider data members + TCHAR szFileName[MAX_PATH]; // File name + DWORD dwFlags; // Stream flags // Base provider functions - STREAM_CREATE BaseCreate; // Pointer to base create function - STREAM_OPEN BaseOpen; // Pointer to base open function - STREAM_READ BaseRead; // Read from the stream - STREAM_WRITE BaseWrite; // Write to the stream - STREAM_RESIZE BaseResize; // Pointer to function changing file size - STREAM_GETSIZE BaseGetSize; // Pointer to function returning file size + STREAM_READ BaseRead; + STREAM_WRITE BaseWrite; STREAM_GETPOS BaseGetPos; // Pointer to function that returns current file position + STREAM_GETSIZE BaseGetSize; // Pointer to function returning file size + STREAM_SETSIZE BaseSetSize; // Pointer to function changing file size + STREAM_GETTIME BaseGetTime; // Pointer to function retrieving the file time STREAM_CLOSE BaseClose; // Pointer to function closing the stream - // Base provider data (file size, file position) - TBaseProviderData Base; - - // Stream provider data - TFileStream * pMaster; // Master stream (e.g. MPQ on a web server) - TCHAR * szFileName; // File name (self-relative pointer) - - ULONGLONG StreamSize; // Stream size (can be less than file size) - ULONGLONG StreamPos; // Stream position - DWORD BuildNumber; // Game build number - DWORD dwFlags; // Stream flags + // Base provider data members + TBaseData Base; // Base provider data // Followed by stream provider data, with variable length }; //----------------------------------------------------------------------------- -// Structures for block-oriented stream +// Structure for linear stream -struct TBlockStream : public TFileStream +struct TLinearStream : public TFileStream { - SFILE_DOWNLOAD_CALLBACK pfnCallback; // Callback for downloading - void * FileBitmap; // Array of bits for file blocks - void * UserData; // User data to be passed to the download callback - DWORD BitmapSize; // Size of the file bitmap (in bytes) - DWORD BlockSize; // Size of one block, in bytes - DWORD BlockCount; // Number of data blocks in the file - DWORD IsComplete; // If nonzero, no blocks are missing - DWORD IsModified; // nonzero if the bitmap has been modified -}; + TFileBitmap * pBitmap; // Pointer to the stream bitmap +}; + +//----------------------------------------------------------------------------- +// Structure for partial stream + +struct TPartialStream : public TFileStream +{ + ULONGLONG VirtualSize; // Virtual size of the file + ULONGLONG VirtualPos; // Virtual position in the file + DWORD BlockCount; // Number of file blocks. Used by partial file stream + DWORD BlockSize; // Size of one block. Used by partial file stream + + PPART_FILE_MAP_ENTRY PartMap; // File map, variable length +}; //----------------------------------------------------------------------------- // Structure for encrypted stream #define MPQE_CHUNK_SIZE 0x40 // Size of one chunk to be decrypted -struct TEncryptedStream : public TBlockStream +struct TEncryptedStream : public TFileStream { BYTE Key[MPQE_CHUNK_SIZE]; // File key }; diff --git a/dep/StormLib/src/SBaseCommon.cpp b/dep/StormLib/src/SBaseCommon.cpp index 782e154a3..82a7f5d7e 100644 --- a/dep/StormLib/src/SBaseCommon.cpp +++ b/dep/StormLib/src/SBaseCommon.cpp @@ -15,181 +15,40 @@ #include "StormLib.h" #include "StormCommon.h" -char StormLibCopyright[] = "StormLib v " STORMLIB_VERSION_STRING " Copyright Ladislav Zezula 1998-2014"; +char StormLibCopyright[] = "StormLib v " STORMLIB_VERSION_STRING " Copyright Ladislav Zezula 1998-2012"; //----------------------------------------------------------------------------- -// Local variables +// The buffer for decryption engine. LCID lcFileLocale = LANG_NEUTRAL; // File locale USHORT wPlatform = 0; // File platform //----------------------------------------------------------------------------- -// Conversion to uppercase/lowercase - -// Converts ASCII characters to lowercase -// Converts slash (0x2F) to backslash (0x5C) -unsigned char AsciiToLowerTable[256] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x5C, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -// Converts ASCII characters to uppercase -// Converts slash (0x2F) to backslash (0x5C) -unsigned char AsciiToUpperTable[256] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x5C, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -// Converts ASCII characters to uppercase -// Does NOT convert slash (0x2F) to backslash (0x5C) -unsigned char AsciiToUpperTable_Slash[256] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -//----------------------------------------------------------------------------- -// Safe string functions (for ANSI builds) - -void StringCopy(char * szTarget, size_t cchTarget, const char * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = strlen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - memcpy(szTarget, szSource, cchSource); - szTarget[cchSource] = 0; - } -} - -void StringCat(char * szTarget, size_t cchTargetMax, const char * szSource) -{ - // Get the current length of the target - size_t cchTarget = strlen(szTarget); - - // Copy the string to the target - if(cchTarget < cchTargetMax) - { - StringCopy(szTarget + cchTarget, (cchTargetMax - cchTarget), szSource); - } -} - -//----------------------------------------------------------------------------- -// Utility functions (UNICODE) only exist in the ANSI version of the library -// In ANSI builds, TCHAR = char, so we don't need these functions implemented - -#ifdef _UNICODE -void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = strlen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - mbstowcs(szTarget, szSource, cchSource); - szTarget[cchSource] = 0; - } -} - -void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = _tcslen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - wcstombs(szTarget, szSource, cchSource); - szTarget[cchSource] = 0; - } -} - -void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = _tcslen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - memcpy(szTarget, szSource, cchSource * sizeof(TCHAR)); - szTarget[cchSource] = 0; - } -} - -void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource) -{ - // Get the current length of the target - size_t cchTarget = _tcslen(szTarget); - - // Copy the string to the target - if(cchTarget < cchTargetMax) - { - StringCopy(szTarget + cchTarget, (cchTargetMax - cchTarget), szSource); - } -} -#endif - -//----------------------------------------------------------------------------- -// Storm hashing functions +// Storm buffer functions #define STORM_BUFFER_SIZE 0x500 -#define HASH_INDEX_MASK(ha) (ha->pHeader->dwHashTableSize ? (ha->pHeader->dwHashTableSize - 1) : 0) static DWORD StormBuffer[STORM_BUFFER_SIZE]; // Buffer for the decryption engine static bool bMpqCryptographyInitialized = false; +DWORD HashString(const char * szFileName, DWORD dwHashType) +{ + LPBYTE pbKey = (BYTE *)szFileName; + DWORD dwSeed1 = 0x7FED7FED; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; + + while(*pbKey != 0) + { + ch = toupper(*pbKey++); + + dwSeed1 = StormBuffer[dwHashType + ch] ^ (dwSeed1 + dwSeed2); + dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; + } + + return dwSeed1; +} + void InitializeMpqCryptography() { DWORD dwSeed = 0x00100001; @@ -222,161 +81,249 @@ void InitializeMpqCryptography() register_hash(&sha1_desc); // Use LibTomMath as support math library for LibTomCrypt - ltc_mp = ltm_desc; + ltc_mp = ltm_desc; // Don't do that again bMpqCryptographyInitialized = true; } } -// -// Note: Implementation of this function in WorldEdit.exe and storm.dll -// incorrectly treats the character as signed, which leads to the -// a buffer underflow if the character in the file name >= 0x80: -// The following steps happen when *pbKey == 0xBF and dwHashType == 0x0000 -// (calculating hash index) -// -// 1) Result of AsciiToUpperTable_Slash[*pbKey++] is sign-extended to 0xffffffbf -// 2) The "ch" is added to dwHashType (0xffffffbf + 0x0000 => 0xffffffbf) -// 3) The result is used as index to the StormBuffer table, -// thus dereferences a random value BEFORE the begin of StormBuffer. -// -// As result, MPQs containing files with non-ANSI characters will not work between -// various game versions and localizations. Even WorldEdit, after importing a file -// with Korean characters in the name, cannot open the file back. -// -DWORD HashString(const char * szFileName, DWORD dwHashType) -{ - LPBYTE pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - // Convert the input character to uppercase - // Convert slash (0x2F) to backslash (0x5C) - ch = AsciiToUpperTable[*pbKey++]; - - dwSeed1 = StormBuffer[dwHashType + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - return dwSeed1; -} - -DWORD HashStringSlash(const char * szFileName, DWORD dwHashType) -{ - LPBYTE pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - // Convert the input character to uppercase - // DON'T convert slash (0x2F) to backslash (0x5C) - ch = AsciiToUpperTable_Slash[*pbKey++]; - - dwSeed1 = StormBuffer[dwHashType + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - return dwSeed1; -} - -DWORD HashStringLower(const char * szFileName, DWORD dwHashType) -{ - LPBYTE pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - // Convert the input character to lower - // DON'T convert slash (0x2F) to backslash (0x5C) - ch = AsciiToLowerTable[*pbKey++]; - - dwSeed1 = StormBuffer[dwHashType + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - return dwSeed1; -} - //----------------------------------------------------------------------------- // Calculates the hash table size for a given amount of files -// Returns the nearest higher power of two. -// If the value is already a power of two, returns the same value -DWORD GetNearestPowerOfTwo(DWORD dwFileCount) +DWORD GetHashTableSizeForFileCount(DWORD dwFileCount) { - dwFileCount --; - - dwFileCount |= dwFileCount >> 1; - dwFileCount |= dwFileCount >> 2; - dwFileCount |= dwFileCount >> 4; - dwFileCount |= dwFileCount >> 8; - dwFileCount |= dwFileCount >> 16; - - return dwFileCount + 1; -} -/* -DWORD GetNearestPowerOfTwo(DWORD dwFileCount) -{ - DWORD dwPowerOfTwo = HASH_TABLE_SIZE_MIN; - - // For zero files, there is no hash table needed - if(dwFileCount == 0) - return 0; + DWORD dwPowerOfTwo; // Round the hash table size up to the nearest power of two + for(dwPowerOfTwo = HASH_TABLE_SIZE_MIN; dwPowerOfTwo < HASH_TABLE_SIZE_MAX; dwPowerOfTwo <<= 1) + { + if(dwPowerOfTwo >= dwFileCount) + { + return dwPowerOfTwo; + } + } + // Don't allow the hash table size go over allowed maximum - while(dwPowerOfTwo < HASH_TABLE_SIZE_MAX && dwPowerOfTwo < dwFileCount) - dwPowerOfTwo <<= 1; - return dwPowerOfTwo; + return HASH_TABLE_SIZE_MAX; } -*/ + //----------------------------------------------------------------------------- // Calculates a Jenkin's Encrypting and decrypting MPQ file data ULONGLONG HashStringJenkins(const char * szFileName) { - LPBYTE pbFileName = (LPBYTE)szFileName; - char szNameBuff[0x108]; + char * szTemp; + char szLocFileName[0x108]; + char chOneChar; size_t nLength = 0; unsigned int primary_hash = 1; unsigned int secondary_hash = 2; - // Normalize the file name - convert to uppercase, and convert "/" to "\\". - if(pbFileName != NULL) - { - char * szNamePtr = szNameBuff; - char * szNameEnd = szNamePtr + sizeof(szNameBuff); + // This is required to produce defined results + assert(szFileName != NULL); - // Normalize the file name. Doesn't have to be zero terminated for hashing - while(szNamePtr < szNameEnd && pbFileName[0] != 0) - *szNamePtr++ = (char)AsciiToLowerTable[*pbFileName++]; - nLength = szNamePtr - szNameBuff; + // Normalize the file name - convert to uppercase, and convert "/" to "\\". + if(szFileName != NULL) + { + szTemp = szLocFileName; + while(*szFileName != 0) + { + chOneChar = (char)tolower(*szFileName++); + if(chOneChar == '/') + chOneChar = '\\'; + + *szTemp++ = chOneChar; + } + + nLength = szTemp - szLocFileName; + *szTemp = 0; } // Thanks Quantam for finding out what the algorithm is. // I am really getting old for reversing large chunks of assembly // that does hashing :-) - hashlittle2(szNameBuff, nLength, &secondary_hash, &primary_hash); + hashlittle2(szLocFileName, nLength, &secondary_hash, &primary_hash); // Combine those 2 together - return ((ULONGLONG)primary_hash << 0x20) | (ULONGLONG)secondary_hash; + return (ULONGLONG)primary_hash * (ULONGLONG)0x100000000ULL + (ULONGLONG)secondary_hash; +} + +//----------------------------------------------------------------------------- +// This function converts the MPQ header so it always looks like version 4 + +int ConvertMpqHeaderToFormat4( + TMPQArchive * ha, + ULONGLONG FileSize, + DWORD dwFlags) +{ + ULONGLONG ByteOffset; + TMPQHeader * pHeader = ha->pHeader; + DWORD dwExpectedArchiveSize; + USHORT wFormatVersion = pHeader->wFormatVersion; + int nError = ERROR_SUCCESS; + + // If version 1.0 is forced, then the format version is forced to be 1.0 + // Reason: Storm.dll in Warcraft III ignores format version value + if(dwFlags & MPQ_OPEN_FORCE_MPQ_V1) + wFormatVersion = MPQ_FORMAT_VERSION_1; + + // Format-specific fixes + switch(wFormatVersion) + { + case MPQ_FORMAT_VERSION_1: + + // Check for malformed MPQ header version 1.0 + if(pHeader->dwHeaderSize != MPQ_HEADER_SIZE_V1) + { + pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; + ha->dwFlags |= MPQ_FLAG_PROTECTED; + } + + // + // The value of "dwArchiveSize" member in the MPQ header + // is ignored by Storm.dll and can contain garbage value + // ("w3xmaster" protector). + // + + dwExpectedArchiveSize = (DWORD)(FileSize - ha->MpqPos); + if(pHeader->dwArchiveSize != dwExpectedArchiveSize) + { + // Note: dwExpectedArchiveSize might be incorrect at this point. + // MPQs version 1.0 can have strong digital signature appended at the end, + // or they might just have arbitrary data there. + // In either case, we recalculate the archive size later when + // block table is loaded and positions of all files is known. + pHeader->dwArchiveSize = dwExpectedArchiveSize; + ha->dwFlags |= MPQ_FLAG_NEED_FIX_SIZE; + } + + // Zero the fields in 2.0 part of the MPQ header + pHeader->HiBlockTablePos64 = 0; + pHeader->wHashTablePosHi = 0; + pHeader->wBlockTablePosHi = 0; + // No break here !!! + + case MPQ_FORMAT_VERSION_2: + case MPQ_FORMAT_VERSION_3: + + // In MPQ format 3.0, the entire header is optional + // and the size of the header can actually be identical + // to size of header 2.0 + if(pHeader->dwHeaderSize < MPQ_HEADER_SIZE_V3) + { + ULONGLONG ArchiveSize64 = pHeader->dwArchiveSize; + + // In format 2.0, the archive size is obsolete and is calculated + // as the highest offset of hash table, block table or hi-block table. + // However, we can still rely on it, if the size of the archive is under 4 GB + if((FileSize - ha->MpqPos) >> 32) + { + ByteOffset = MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos) + (pHeader->dwHashTableSize * sizeof(TMPQHash)); + if(ByteOffset > ArchiveSize64) + ArchiveSize64 = ByteOffset; + + ByteOffset = MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos) + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)); + if(ByteOffset > ArchiveSize64) + ArchiveSize64 = ByteOffset; + + // Only if we actually have a hi-block table + if(pHeader->HiBlockTablePos64) + { + ByteOffset = pHeader->HiBlockTablePos64 + (pHeader->dwBlockTableSize * sizeof(USHORT)); + if(ByteOffset > ArchiveSize64) + ArchiveSize64 = ByteOffset; + } + + // We need to recalculate archive size later, + // when block table is loaded and the position of files is known + ha->dwFlags |= MPQ_FLAG_NEED_FIX_SIZE; + } + + // Initialize the rest of the 3.0 header + pHeader->ArchiveSize64 = ArchiveSize64; + pHeader->HetTablePos64 = 0; + pHeader->BetTablePos64 = 0; + } + + // + // Calculate compressed size of each table. We assume the following order: + // 1) HET table + // 2) BET table + // 3) Classic hash table + // 4) Classic block table + // 5) Hi-block table + // + + // Set all sizes to zero + pHeader->HetTableSize64 = 0; + pHeader->BetTableSize64 = 0; + + // Either both HET and BET table exist or none of them does. + if(pHeader->HetTablePos64) + { + // Compressed size of the HET and BET tables + pHeader->HetTableSize64 = pHeader->BetTablePos64 - pHeader->HetTablePos64; + pHeader->BetTableSize64 = MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos) - pHeader->HetTablePos64; + } + + // Compressed size of hash and block table + if(wFormatVersion >= MPQ_FORMAT_VERSION_2) + { + // Compressed size of the hash table + pHeader->HashTableSize64 = MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos) - MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos); + + // Block and hi-block table + if(pHeader->HiBlockTablePos64) + { + pHeader->BlockTableSize64 = pHeader->HiBlockTablePos64 - MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); + pHeader->HiBlockTableSize64 = pHeader->ArchiveSize64 - pHeader->HiBlockTablePos64; + } + else + { + pHeader->BlockTableSize64 = pHeader->ArchiveSize64 - MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); + pHeader->HiBlockTableSize64 = 0; + } + } + else + { + // No known MPQ in format 1.0 has any of the tables compressed + pHeader->HashTableSize64 = pHeader->dwHashTableSize * sizeof(TMPQHash); + pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock); + pHeader->HiBlockTableSize64 = 0; + } + + // Set the data chunk size for MD5 to zero + pHeader->dwRawChunkSize = 0; + + // Fill the MD5's + memset(pHeader->MD5_BlockTable, 0, MD5_DIGEST_SIZE); + memset(pHeader->MD5_HashTable, 0, MD5_DIGEST_SIZE); + memset(pHeader->MD5_HiBlockTable, 0, MD5_DIGEST_SIZE); + memset(pHeader->MD5_BetTable, 0, MD5_DIGEST_SIZE); + memset(pHeader->MD5_HetTable, 0, MD5_DIGEST_SIZE); + memset(pHeader->MD5_MpqHeader, 0, MD5_DIGEST_SIZE); + // No break here !!!! + + case MPQ_FORMAT_VERSION_4: + + // Verify header MD5. Header MD5 is calculated from the MPQ header since the 'MPQ\x1A' + // signature until the position of header MD5 at offset 0xC0 + if(!VerifyDataBlockHash(ha->pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, ha->pHeader->MD5_MpqHeader)) + nError = ERROR_FILE_CORRUPT; + break; + } + + return nError; } //----------------------------------------------------------------------------- // Default flags for (attributes) and (listfile) -DWORD GetDefaultSpecialFileFlags(DWORD dwFileSize, USHORT wFormatVersion) +DWORD GetDefaultSpecialFileFlags(TMPQArchive * ha, DWORD dwFileSize) { // Fixed for format 1.0 - if(wFormatVersion == MPQ_FORMAT_VERSION_1) + if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) return MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY; // Size-dependent for formats 2.0-4.0 @@ -385,191 +332,186 @@ DWORD GetDefaultSpecialFileFlags(DWORD dwFileSize, USHORT wFormatVersion) //----------------------------------------------------------------------------- -// Encrypting/Decrypting MPQ data block +// Encrypting and decrypting MPQ file data -void EncryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1) +void EncryptMpqBlock(void * pvFileBlock, DWORD dwLength, DWORD dwSeed1) { - LPDWORD DataBlock = (LPDWORD)pvDataBlock; - DWORD dwValue32; - DWORD dwKey2 = 0xEEEEEEEE; + LPDWORD block = (LPDWORD)pvFileBlock; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; // Round to DWORDs dwLength >>= 2; - // Encrypt the data block at array of DWORDs - for(DWORD i = 0; i < dwLength; i++) + while(dwLength-- > 0) { - // Modify the second key - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *block; + *block++ = ch ^ (dwSeed1 + dwSeed2); - dwValue32 = DataBlock[i]; - DataBlock[i] = DataBlock[i] ^ (dwKey1 + dwKey2); - - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = dwValue32 + dwKey2 + (dwKey2 << 5) + 3; + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; } } -void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1) +void DecryptMpqBlock(void * pvFileBlock, DWORD dwLength, DWORD dwSeed1) { - LPDWORD DataBlock = (LPDWORD)pvDataBlock; - DWORD dwValue32; - DWORD dwKey2 = 0xEEEEEEEE; + LPDWORD block = (LPDWORD)pvFileBlock; + DWORD dwSeed2 = 0xEEEEEEEE; + DWORD ch; // Round to DWORDs dwLength >>= 2; - // Decrypt the data block at array of DWORDs - for(DWORD i = 0; i < dwLength; i++) + while(dwLength-- > 0) { - // Modify the second key - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - - DataBlock[i] = DataBlock[i] ^ (dwKey1 + dwKey2); - dwValue32 = DataBlock[i]; + dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; + ch = *block ^ (dwSeed1 + dwSeed2); - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = dwValue32 + dwKey2 + (dwKey2 << 5) + 3; + dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); + dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; + *block++ = ch; } } +/* +void EncryptMpqTable(void * pvMpqTable, DWORD dwLength, const char * szKey) +{ + EncryptMpqBlock(pvMpqTable, dwLength, HashString(szKey, MPQ_HASH_FILE_KEY)); +} + +void DecryptMpqTable(void * pvMpqTable, DWORD dwLength, const char * szKey) +{ + DecryptMpqBlock(pvMpqTable, dwLength, HashString(szKey, MPQ_HASH_FILE_KEY)); +} +*/ + /** - * Functions tries to get file decryption key. This comes from these facts - * - * - We know the decrypted value of the first DWORD in the encrypted data - * - We know the decrypted value of the second DWORD (at least aproximately) - * - There is only 256 variants of how the second key is modified - * - * The first iteration of dwKey1 and dwKey2 is this: - * - * dwKey2 = 0xEEEEEEEE + StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)] - * dwDecrypted0 = DataBlock[0] ^ (dwKey1 + dwKey2); - * - * This means: - * - * (dwKey1 + dwKey2) = DataBlock[0] ^ dwDecrypted0; + * Functions tries to get file decryption key. The trick comes from sector + * positions which are stored at the begin of each compressed file. We know the + * file size, that means we know number of sectors that means we know the first + * DWORD value in sector position. And if we know encrypted and decrypted value, + * we can find the decryption key !!! * + * hf - MPQ file handle + * SectorOffsets - DWORD array of sector positions + * ch - Decrypted value of the first sector pos */ -DWORD DetectFileKeyBySectorSize(LPDWORD EncryptedData, DWORD dwSectorSize, DWORD dwDecrypted0) +DWORD DetectFileKeyBySectorSize(LPDWORD SectorOffsets, DWORD decrypted) { - DWORD dwDecrypted1Max = dwSectorSize + dwDecrypted0; - DWORD dwKey1PlusKey2; - DWORD DataBlock[2]; + DWORD saveKey1; + DWORD temp = *SectorOffsets ^ decrypted; // temp = seed1 + seed2 + temp -= 0xEEEEEEEE; // temp = seed1 + StormBuffer[0x400 + (seed1 & 0xFF)] - // We must have at least 2 DWORDs there to be able to decrypt something - if(dwSectorSize < 0x08) + for(int i = 0; i < 0x100; i++) // Try all 255 possibilities + { + DWORD seed1; + DWORD seed2 = 0xEEEEEEEE; + DWORD ch; + + // Try the first DWORD (We exactly know the value) + seed1 = temp - StormBuffer[0x400 + i]; + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = SectorOffsets[0] ^ (seed1 + seed2); + + if(ch != decrypted) + continue; + + // Add 1 because we are decrypting sector positions + saveKey1 = seed1 + 1; + + // If OK, continue and test the second value. We don't know exactly the value, + // but we know that the second one has lower 16 bits set to zero + // (no compressed sector is larger than 0xFFFF bytes) + seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); + seed2 = ch + seed2 + (seed2 << 5) + 3; + + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = SectorOffsets[1] ^ (seed1 + seed2); + + if((ch & 0xFFFF0000) == 0) + return saveKey1; + } + return 0; +} + +// Function tries to detect file encryption key. It expectes at least two uncompressed bytes +DWORD DetectFileKeyByKnownContent(void * pvFileContent, DWORD nDwords, ...) +{ + LPDWORD pdwContent = (LPDWORD)pvFileContent; + va_list argList; + DWORD dwDecrypted[0x10]; + DWORD saveKey1; + DWORD dwTemp; + DWORD i, j; + + // We need at least two DWORDS to detect the file key + if(nDwords < 0x02 || nDwords > 0x10) return 0; - // Get the value of the combined encryption key - dwKey1PlusKey2 = (EncryptedData[0] ^ dwDecrypted0) - 0xEEEEEEEE; + va_start(argList, nDwords); + for(i = 0; i < nDwords; i++) + dwDecrypted[i] = va_arg(argList, DWORD); + va_end(argList); - // Try all 256 combinations of dwKey1 - for(DWORD i = 0; i < 0x100; i++) + dwTemp = (*pdwContent ^ dwDecrypted[0]) - 0xEEEEEEEE; + for(i = 0; i < 0x100; i++) // Try all 256 possibilities { - DWORD dwSaveKey1; - DWORD dwKey1 = dwKey1PlusKey2 - StormBuffer[MPQ_HASH_KEY2_MIX + i]; - DWORD dwKey2 = 0xEEEEEEEE; + DWORD seed1; + DWORD seed2 = 0xEEEEEEEE; + DWORD ch; - // Modify the second key and decrypt the first DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[0] = EncryptedData[0] ^ (dwKey1 + dwKey2); + // Try the first DWORD + seed1 = dwTemp - StormBuffer[0x400 + i]; + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = pdwContent[0] ^ (seed1 + seed2); - // Did we obtain the same value like dwDecrypted0? - if(DataBlock[0] == dwDecrypted0) + if(ch != dwDecrypted[0]) + continue; + + saveKey1 = seed1; + + // If OK, continue and test all bytes. + for(j = 1; j < nDwords; j++) { - // Save this key value. Increment by one because - // we are decrypting sector offset table - dwSaveKey1 = dwKey1 + 1; + seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); + seed2 = ch + seed2 + (seed2 << 5) + 3; - // Rotate both keys - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = DataBlock[0] + dwKey2 + (dwKey2 << 5) + 3; + seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; + ch = pdwContent[j] ^ (seed1 + seed2); - // Modify the second key again and decrypt the second DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[1] = EncryptedData[1] ^ (dwKey1 + dwKey2); - - // Now compare the results - if(DataBlock[1] <= dwDecrypted1Max) - return dwSaveKey1; + if(ch == dwDecrypted[j] && j == nDwords - 1) + return saveKey1; } } - - // Key not found return 0; } -// Function tries to detect file encryption key based on expected file content -// It is the same function like before, except that we know the value of the second DWORD -DWORD DetectFileKeyByKnownContent(void * pvEncryptedData, DWORD dwDecrypted0, DWORD dwDecrypted1) -{ - LPDWORD EncryptedData = (LPDWORD)pvEncryptedData; - DWORD dwKey1PlusKey2; - DWORD DataBlock[2]; - - // Get the value of the combined encryption key - dwKey1PlusKey2 = (EncryptedData[0] ^ dwDecrypted0) - 0xEEEEEEEE; - - // Try all 256 combinations of dwKey1 - for(DWORD i = 0; i < 0x100; i++) - { - DWORD dwSaveKey1; - DWORD dwKey1 = dwKey1PlusKey2 - StormBuffer[MPQ_HASH_KEY2_MIX + i]; - DWORD dwKey2 = 0xEEEEEEEE; - - // Modify the second key and decrypt the first DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[0] = EncryptedData[0] ^ (dwKey1 + dwKey2); - - // Did we obtain the same value like dwDecrypted0? - if(DataBlock[0] == dwDecrypted0) - { - // Save this key value - dwSaveKey1 = dwKey1; - - // Rotate both keys - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = DataBlock[0] + dwKey2 + (dwKey2 << 5) + 3; - - // Modify the second key again and decrypt the second DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[1] = EncryptedData[1] ^ (dwKey1 + dwKey2); - - // Now compare the results - if(DataBlock[1] == dwDecrypted1) - return dwSaveKey1; - } - } - - // Key not found - return 0; -} - -DWORD DetectFileKeyByContent(void * pvEncryptedData, DWORD dwSectorSize, DWORD dwFileSize) +DWORD DetectFileKeyByContent(void * pvFileContent, DWORD dwFileSize) { DWORD dwFileKey; // Try to break the file encryption key as if it was a WAVE file - if(dwSectorSize >= 0x0C) + if(dwFileSize >= 0x0C) { - dwFileKey = DetectFileKeyByKnownContent(pvEncryptedData, 0x46464952, dwFileSize - 8); + dwFileKey = DetectFileKeyByKnownContent(pvFileContent, 3, 0x46464952, dwFileSize - 8, 0x45564157); if(dwFileKey != 0) return dwFileKey; } // Try to break the encryption key as if it was an EXE file - if(dwSectorSize > 0x40) + if(dwFileSize > 0x40) { - dwFileKey = DetectFileKeyByKnownContent(pvEncryptedData, 0x00905A4D, 0x00000003); + dwFileKey = DetectFileKeyByKnownContent(pvFileContent, 2, 0x00905A4D, 0x00000003); if(dwFileKey != 0) return dwFileKey; } // Try to break the encryption key as if it was a XML file - if(dwSectorSize > 0x04) + if(dwFileSize > 0x04) { - dwFileKey = DetectFileKeyByKnownContent(pvEncryptedData, 0x6D783F3C, 0x6576206C); + dwFileKey = DetectFileKeyByKnownContent(pvFileContent, 2, 0x6D783F3C, 0x6576206C); if(dwFileKey != 0) return dwFileKey; } @@ -579,16 +521,16 @@ DWORD DetectFileKeyByContent(void * pvEncryptedData, DWORD dwSectorSize, DWORD d } DWORD DecryptFileKey( - const char * szFileName, - ULONGLONG MpqPos, - DWORD dwFileSize, - DWORD dwFlags) + const char * szFileName, + ULONGLONG MpqPos, + DWORD dwFileSize, + DWORD dwFlags) { DWORD dwFileKey; DWORD dwMpqPos = (DWORD)MpqPos; // File key is calculated from plain name - szFileName = GetPlainFileName(szFileName); + szFileName = GetPlainFileNameA(szFileName); dwFileKey = HashString(szFileName, MPQ_HASH_FILE_KEY); // Fix the key, if needed @@ -602,192 +544,160 @@ DWORD DecryptFileKey( //----------------------------------------------------------------------------- // Handle validation functions -TMPQArchive * IsValidMpqHandle(HANDLE hMpq) +bool IsValidMpqHandle(TMPQArchive * ha) { - TMPQArchive * ha = (TMPQArchive *)hMpq; - - return (ha != NULL && ha->pHeader != NULL && ha->pHeader->dwID == ID_MPQ) ? ha : NULL; + if(ha == NULL) + return false; + if(ha->pHeader == NULL || ha->pHeader->dwID != ID_MPQ) + return false; + + return (bool)(ha->pHeader->dwID == ID_MPQ); } -TMPQFile * IsValidFileHandle(HANDLE hFile) +bool IsValidFileHandle(TMPQFile * hf) { - TMPQFile * hf = (TMPQFile *)hFile; + if(hf == NULL) + return false; - // Must not be NULL - if(hf != NULL && hf->dwMagic == ID_MPQ_FILE) - { - // Local file handle? - if(hf->pStream != NULL) - return hf; + if(hf->dwMagic != ID_MPQ_FILE) + return false; - // Also verify the MPQ handle within the file handle - if(IsValidMpqHandle(hf->ha)) - return hf; - } + if(hf->pStream != NULL) + return true; - return NULL; + return IsValidMpqHandle(hf->ha); } //----------------------------------------------------------------------------- // Hash table and block table manipulation -// Attempts to search a free hash entry, or an entry whose names and locale matches -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1, DWORD dwName2, LCID lcLocale) -{ - TMPQHash * pDeletedEntry = NULL; // If a deleted entry was found in the continuous hash range - TMPQHash * pFreeEntry = NULL; // If a free entry was found in the continuous hash range - DWORD dwHashIndexMask = HASH_INDEX_MASK(ha); - DWORD dwIndex; - - // Set the initial index - dwStartIndex = dwIndex = (dwStartIndex & dwHashIndexMask); - - // Search the hash table and return the found entries in the following priority: - // 1) - // 2) - // 3) - // 4) NULL - for(;;) - { - TMPQHash * pHash = ha->pHashTable + dwIndex; - - // If we found a matching entry, return that one - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->lcLocale == lcLocale) - return pHash; - - // If we found a deleted entry, remember it but keep searching - if(pHash->dwBlockIndex == HASH_ENTRY_DELETED && pDeletedEntry == NULL) - pDeletedEntry = pHash; - - // If we found a free entry, we need to stop searching - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - { - pFreeEntry = pHash; - break; - } - - // Move to the next hash entry. - // If we reached the starting entry, it's failure. - dwIndex = (dwIndex + 1) & dwHashIndexMask; - if(dwIndex == dwStartIndex) - break; - } - - // If we found a deleted entry, return that one preferentially - return (pDeletedEntry != NULL) ? pDeletedEntry : pFreeEntry; -} - // Retrieves the first hash entry for the given file. // Every locale version of a file has its own hash entry TMPQHash * GetFirstHashEntry(TMPQArchive * ha, const char * szFileName) { - DWORD dwHashIndexMask = HASH_INDEX_MASK(ha); - DWORD dwStartIndex = ha->pfnHashString(szFileName, MPQ_HASH_TABLE_INDEX); - DWORD dwName1 = ha->pfnHashString(szFileName, MPQ_HASH_NAME_A); - DWORD dwName2 = ha->pfnHashString(szFileName, MPQ_HASH_NAME_B); - DWORD dwIndex; + TMPQHash * pStartHash; // File hash entry (start) + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash; // File hash entry (current) + DWORD dwHashTableSizeMask; + DWORD dwIndex = HashString(szFileName, MPQ_HASH_TABLE_INDEX); + DWORD dwName1 = HashString(szFileName, MPQ_HASH_NAME_A); + DWORD dwName2 = HashString(szFileName, MPQ_HASH_NAME_B); - // Set the initial index - dwStartIndex = dwIndex = (dwStartIndex & dwHashIndexMask); + // Get the first possible has entry that might be the one + dwHashTableSizeMask = ha->pHeader->dwHashTableSize ? (ha->pHeader->dwHashTableSize - 1) : 0; + pStartHash = pHash = ha->pHashTable + (dwIndex & dwHashTableSizeMask); - // Search the hash table - for(;;) + // There might be deleted entries in the hash table prior to our desired entry. + while(pHash->dwBlockIndex != HASH_ENTRY_FREE) { - TMPQHash * pHash = ha->pHashTable + dwIndex; - - // If the entry matches, we found it. - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) + // If the entry agrees, we found it. + if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->dwBlockIndex < ha->dwFileTableSize) return pHash; - // If that hash entry is a free entry, it means we haven't found the file - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - return NULL; - // Move to the next hash entry. Stop searching // if we got reached the original hash entry - dwIndex = (dwIndex + 1) & dwHashIndexMask; - if(dwIndex == dwStartIndex) - return NULL; + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pStartHash) + break; } + + // The apropriate hash entry was not found + return NULL; } -TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash * pHash) +TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash * pPrevHash) { - DWORD dwHashIndexMask = HASH_INDEX_MASK(ha); - DWORD dwStartIndex = (DWORD)(pFirstHash - ha->pHashTable); - DWORD dwName1 = pHash->dwName1; - DWORD dwName2 = pHash->dwName2; - DWORD dwIndex = (DWORD)(pHash - ha->pHashTable); + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash = pPrevHash; + DWORD dwName1 = pPrevHash->dwName1; + DWORD dwName2 = pPrevHash->dwName2; - // Now go for any next entry that follows the pHash, + // Now go for any next entry that follows the pPrevHash, // until either free hash entry was found, or the start entry was reached for(;;) { // Move to the next hash entry. Stop searching // if we got reached the original hash entry - dwIndex = (dwIndex + 1) & dwHashIndexMask; - if(dwIndex == dwStartIndex) - return NULL; - pHash = ha->pHashTable + dwIndex; + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pFirstHash) + break; - // If the entry matches, we found it. - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - return pHash; - - // If that hash entry is a free entry, it means we haven't found the file + // If the entry is a free entry, stop search if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - return NULL; + break; + + // If the entry is not free and the name agrees, we found it + if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->dwBlockIndex < ha->pHeader->dwBlockTableSize) + return pHash; } + + // No next entry + return NULL; } // Allocates an entry in the hash table -TMPQHash * AllocateHashEntry( - TMPQArchive * ha, - TFileEntry * pFileEntry, - LCID lcLocale) +DWORD AllocateHashEntry( + TMPQArchive * ha, + TFileEntry * pFileEntry) { - TMPQHash * pHash; - DWORD dwStartIndex = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_TABLE_INDEX); - DWORD dwName1 = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_NAME_A); - DWORD dwName2 = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_NAME_B); + TMPQHash * pStartHash; // File hash entry (start) + TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; + TMPQHash * pHash; // File hash entry (current) + DWORD dwHashTableSizeMask; + DWORD dwIndex = HashString(pFileEntry->szFileName, MPQ_HASH_TABLE_INDEX); + DWORD dwName1 = HashString(pFileEntry->szFileName, MPQ_HASH_NAME_A); + DWORD dwName2 = HashString(pFileEntry->szFileName, MPQ_HASH_NAME_B); - // Attempt to find a free hash entry - pHash = FindFreeHashEntry(ha, dwStartIndex, dwName1, dwName2, lcLocale); - if(pHash != NULL) + // Get the first possible has entry that might be the one + dwHashTableSizeMask = ha->pHeader->dwHashTableSize ? (ha->pHeader->dwHashTableSize - 1) : 0; + pStartHash = pHash = ha->pHashTable + (dwIndex & dwHashTableSizeMask); + + // There might be deleted entries in the hash table prior to our desired entry. + while(pHash->dwBlockIndex < HASH_ENTRY_DELETED) { - // Fill the free hash entry - pHash->dwName1 = dwName1; - pHash->dwName2 = dwName2; - pHash->lcLocale = (USHORT)lcLocale; - pHash->Platform = 0; - pHash->dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable); + // If there already is an existing entry, reuse it. + if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->lcLocale == pFileEntry->lcLocale) + break; + + // Move to the next hash entry. + // If we reached the starting entry, it's failure. + if(++pHash >= pHashEnd) + pHash = ha->pHashTable; + if(pHash == pStartHash) + return HASH_ENTRY_FREE; } - return pHash; + // Fill the free hash entry + pHash->dwName1 = dwName1; + pHash->dwName2 = dwName2; + pHash->lcLocale = pFileEntry->lcLocale; + pHash->wPlatform = pFileEntry->wPlatform; + pHash->dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable); + + // Fill the hash index in the file entry + pFileEntry->dwHashIndex = (DWORD)(pHash - ha->pHashTable); + return pFileEntry->dwHashIndex; } // Finds a free space in the MPQ where to store next data // The free space begins beyond the file that is stored at the fuhrtest -// position in the MPQ. (listfile), (attributes) and (signature) are ignored, -// unless the MPQ is being flushed. -ULONGLONG FindFreeMpqSpace(TMPQArchive * ha) +// position in the MPQ. +void FindFreeMpqSpace(TMPQArchive * ha, ULONGLONG * pFreeSpacePos) { TMPQHeader * pHeader = ha->pHeader; TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; + TFileEntry * pFileEntry = ha->pFileTable; ULONGLONG FreeSpacePos = ha->pHeader->dwHeaderSize; DWORD dwChunkCount; // Parse the entire block table for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) { - // Only take existing files with nonzero size - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && (pFileEntry->dwCmpSize != 0)) + // Only take existing files + if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) { - // If we are not saving MPQ tables, ignore internal MPQ files - if((ha->dwFlags & MPQ_FLAG_SAVING_TABLES) == 0 && IsInternalMpqFileName(pFileEntry->szFileName)) - continue; - // If the end of the file is bigger than current MPQ table pos, update it if((pFileEntry->ByteOffset + pFileEntry->dwCmpSize) > FreeSpacePos) { @@ -805,13 +715,14 @@ ULONGLONG FindFreeMpqSpace(TMPQArchive * ha) } // Give the free space position to the caller - return FreeSpacePos; + if(pFreeSpacePos != NULL) + *pFreeSpacePos = FreeSpacePos; } //----------------------------------------------------------------------------- // Common functions - MPQ File -TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry) +TMPQFile * CreateMpqFile(TMPQArchive * ha) { TMPQFile * hf; @@ -821,171 +732,108 @@ TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry) { // Fill the file structure memset(hf, 0, sizeof(TMPQFile)); - hf->dwMagic = ID_MPQ_FILE; - hf->pStream = NULL; hf->ha = ha; - - // If the called entered a file entry, we also copy informations from the file entry - if(ha != NULL && pFileEntry != NULL) - { - // Set the raw position and MPQ position - hf->RawFilePos = FileOffsetFromMpqOffset(ha, pFileEntry->ByteOffset); - hf->MpqFilePos = pFileEntry->ByteOffset; - - // Set the data size - hf->dwDataSize = pFileEntry->dwFileSize; - hf->pFileEntry = pFileEntry; - } + hf->pStream = NULL; + hf->dwMagic = ID_MPQ_FILE; } return hf; } -TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize) -{ - ULONGLONG FreeMpqSpace; - ULONGLONG TempPos; - TMPQFile * hf; - - // We need to find the position in the MPQ where we save the file data - FreeMpqSpace = FindFreeMpqSpace(ha); - - // When format V1, the size of the archive cannot exceed 4 GB - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - TempPos = FreeMpqSpace + - dwFileSize + - (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)) + - (ha->dwFileTableSize * sizeof(TMPQBlock)); - if((TempPos >> 32) != 0) - { - SetLastError(ERROR_DISK_FULL); - return NULL; - } - } - - // Allocate the file handle - hf = CreateFileHandle(ha, NULL); - if(hf == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return NULL; - } - - // We need to find the position in the MPQ where we save the file data - hf->MpqFilePos = FreeMpqSpace; - hf->bIsWriteHandle = true; - return hf; -} - // Loads a table from MPQ. // Can be used for hash table, block table, sector offset table or sector checksum table -void * LoadMpqTable( - TMPQArchive * ha, - ULONGLONG ByteOffset, - DWORD dwCompressedSize, - DWORD dwTableSize, - DWORD dwKey, - bool * pbTableIsCut) +int LoadMpqTable( + TMPQArchive * ha, + ULONGLONG ByteOffset, + void * pvTable, + DWORD dwCompressedSize, + DWORD dwRealSize, + DWORD dwKey) { - ULONGLONG FileSize = 0; LPBYTE pbCompressed = NULL; - LPBYTE pbMpqTable; - LPBYTE pbToRead; - DWORD dwBytesToRead = dwCompressedSize; + LPBYTE pbToRead = (LPBYTE)pvTable; int nError = ERROR_SUCCESS; - // Allocate the MPQ table - pbMpqTable = pbToRead = STORM_ALLOC(BYTE, dwTableSize); - if(pbMpqTable != NULL) + // "interface.MPQ.part" in trial version of World of Warcraft + // has block table and hash table compressed. + if(dwCompressedSize < dwRealSize) { - // Check if the MPQ table is encrypted - if(dwCompressedSize < dwTableSize) - { - // Allocate temporary buffer for holding compressed data - pbCompressed = pbToRead = STORM_ALLOC(BYTE, dwCompressedSize); - if(pbCompressed == NULL) - { - STORM_FREE(pbMpqTable); - return NULL; - } - } + // Allocate temporary buffer for holding compressed data + pbCompressed = STORM_ALLOC(BYTE, dwCompressedSize); + if(pbCompressed == NULL) + return ERROR_NOT_ENOUGH_MEMORY; - // Get the file offset from which we will read the table - // Note: According to Storm.dll from Warcraft III (version 2002), - // if the hash table position is 0xFFFFFFFF, no SetFilePointer call is done - // and the table is loaded from the current file offset - if(ByteOffset == SFILE_INVALID_POS) - FileStream_GetPos(ha->pStream, &ByteOffset); - - // On archives v 1.0, hash table and block table can go beyond EOF. - // Storm.dll reads as much as possible, then fills the missing part with zeros. - // Abused by Spazzler map protector which sets hash table size to 0x00100000 - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - // Cut the table size - FileStream_GetSize(ha->pStream, &FileSize); - if((ByteOffset + dwBytesToRead) > FileSize) - { - // Fill the extra data with zeros - dwBytesToRead = (DWORD)(FileSize - ByteOffset); - memset(pbMpqTable + dwBytesToRead, 0, (dwTableSize - dwBytesToRead)); - - // Give the caller information that the table was cut - if(pbTableIsCut != NULL) - pbTableIsCut[0] = true; - } - } - - // If everything succeeded, read the raw table form the MPQ - if(FileStream_Read(ha->pStream, &ByteOffset, pbToRead, dwBytesToRead)) - { - // First of all, decrypt the table - if(dwKey != 0) - { - BSWAP_ARRAY32_UNSIGNED(pbToRead, dwCompressedSize); - DecryptMpqBlock(pbToRead, dwCompressedSize, dwKey); - BSWAP_ARRAY32_UNSIGNED(pbToRead, dwCompressedSize); - } - - // If the table is compressed, decompress it - if(dwCompressedSize < dwTableSize) - { - int cbOutBuffer = (int)dwTableSize; - int cbInBuffer = (int)dwCompressedSize; - - if(!SCompDecompress2(pbMpqTable, &cbOutBuffer, pbCompressed, cbInBuffer)) - nError = GetLastError(); - } - - // Make sure that the table is properly byte-swapped - BSWAP_ARRAY32_UNSIGNED(pbMpqTable, dwTableSize); - } - else - { - nError = GetLastError(); - } - - // If read failed, free the table and return - if(nError != ERROR_SUCCESS) - { - STORM_FREE(pbMpqTable); - pbMpqTable = NULL; - } - - // Free the compression buffer, if any - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); + // Assign the temporary buffer as target for read operation + pbToRead = pbCompressed; } - // Return the MPQ table - return pbMpqTable; + // Read the table + if(FileStream_Read(ha->pStream, &ByteOffset, pbToRead, dwCompressedSize)) + { + // First of all, decrypt the table + if(dwKey != 0) + { + BSWAP_ARRAY32_UNSIGNED(pbToRead, dwCompressedSize); + DecryptMpqBlock(pbToRead, dwCompressedSize, dwKey); + BSWAP_ARRAY32_UNSIGNED(pbToRead, dwCompressedSize); + } + + // If the table is compressed, decompress it + if(dwCompressedSize < dwRealSize) + { + int cbOutBuffer = (int)dwRealSize; + int cbInBuffer = (int)dwCompressedSize; + + if(!SCompDecompress2((char *)pvTable, &cbOutBuffer, (char *)pbCompressed, cbInBuffer)) + nError = GetLastError(); + + // Free the temporary buffer + STORM_FREE(pbCompressed); + } + } + else + { + nError = GetLastError(); + } + + BSWAP_ARRAY32_UNSIGNED(pvTable, dwRealSize); + return nError; +} + +void CalculateRawSectorOffset( + ULONGLONG & RawFilePos, + TMPQFile * hf, + DWORD dwSectorOffset) +{ + // + // Some MPQ protectors place the sector offset table after the actual file data. + // Sector offsets in the sector offset table are negative. When added + // to MPQ file offset from the block table entry, the result is a correct + // position of the file data in the MPQ. + // + // The position of sector table must be always within the MPQ, however. + // When a negative sector offset is found, we make sure that we make the addition + // just in 32-bits, and then add the MPQ offset. + // + + if(dwSectorOffset & 0x80000000) + { + RawFilePos = hf->ha->MpqPos + ((DWORD)hf->pFileEntry->ByteOffset + dwSectorOffset); + } + else + { + RawFilePos = hf->RawFilePos + dwSectorOffset; + } + + // We also have to add patch header size, if patch header is present + if(hf->pPatchInfo != NULL) + RawFilePos += hf->pPatchInfo->dwLength; } unsigned char * AllocateMd5Buffer( - DWORD dwRawDataSize, - DWORD dwChunkSize, - LPDWORD pcbMd5Size) + DWORD dwRawDataSize, + DWORD dwChunkSize, + LPDWORD pcbMd5Size) { unsigned char * md5_array; DWORD cbMd5Size; @@ -1043,7 +891,7 @@ __AllocateAndLoadPatchInfo: // Allocate space for patch header. Start with default size, // and if its size if bigger, then we reload them - hf->pPatchInfo = STORM_ALLOC(TPatchInfo, 1); + hf->pPatchInfo = (TPatchInfo *)STORM_ALLOC(BYTE, dwLength); if(hf->pPatchInfo == NULL) return ERROR_NOT_ENOUGH_MEMORY; @@ -1120,7 +968,7 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile) // Calculate the number of file sectors dwSectorOffsLen = (hf->dwSectorCount + 1) * sizeof(DWORD); - + // If MPQ_FILE_SECTOR_CRC flag is set, there will either be extra DWORD // or an array of MD5's. Either way, we read at least 4 bytes more // in order to save additional read from the file. @@ -1128,12 +976,12 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile) dwSectorOffsLen += sizeof(DWORD); // Only allocate and load the table if the file is compressed - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) + if(pFileEntry->dwFlags & MPQ_FILE_COMPRESSED) { - __LoadSectorOffsets: +__LoadSectorOffsets: // Allocate the sector offset table - hf->SectorOffsets = STORM_ALLOC(DWORD, (dwSectorOffsLen / sizeof(DWORD))); + hf->SectorOffsets = (DWORD *)STORM_ALLOC(BYTE, dwSectorOffsLen); if(hf->SectorOffsets == NULL) return ERROR_NOT_ENOUGH_MEMORY; @@ -1142,13 +990,8 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile) { ULONGLONG RawFilePos = hf->RawFilePos; - // Append the length of the patch info, if any if(hf->pPatchInfo != NULL) - { - if((RawFilePos + hf->pPatchInfo->dwLength) < RawFilePos) - return ERROR_FILE_CORRUPT; RawFilePos += hf->pPatchInfo->dwLength; - } // Load the sector offsets from the file if(!FileStream_Read(ha->pStream, &RawFilePos, hf->SectorOffsets, dwSectorOffsLen)) @@ -1168,7 +1011,7 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile) // If we don't know the file key, try to find it. if(hf->dwFileKey == 0) { - hf->dwFileKey = DetectFileKeyBySectorSize(hf->SectorOffsets, ha->dwSectorSize, dwSectorOffsLen); + hf->dwFileKey = DetectFileKeyBySectorSize(hf->SectorOffsets, dwSectorOffsLen); if(hf->dwFileKey == 0) { STORM_FREE(hf->SectorOffsets); @@ -1201,10 +1044,7 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile) } // The sector size must not be bigger than compressed file size - // Edit: Yes, but apparently, in original Storm.dll, the compressed - // size is not checked anywhere. However, we need to do this check - // in order to sector offset table malformed by MPQ protectors - if((dwSectorOffset1 - dwSectorOffset0) > ha->dwSectorSize) + if((dwSectorOffset1 - dwSectorOffset0) > pFileEntry->dwCmpSize) { bSectorOffsetTableCorrupt = true; break; @@ -1226,17 +1066,13 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile) // // These extra values are, however, include in the dwCmpSize in the file // table. We cannot ignore them, because compacting archive would fail - // + // if(hf->SectorOffsets[0] > dwSectorOffsLen) { - // MPQ protectors put some ridiculous values there. We must limit the extra bytes - if(hf->SectorOffsets[0] > (dwSectorOffsLen + 0x400)) - return ERROR_FILE_CORRUPT; - - // Free the old sector offset table dwSectorOffsLen = hf->SectorOffsets[0]; STORM_FREE(hf->SectorOffsets); + hf->SectorOffsets = NULL; goto __LoadSectorOffsets; } } @@ -1273,7 +1109,7 @@ int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile) // Caller must ensure that we are only called when we have sector checksums assert(pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC); - // + // // Older MPQs store an array of CRC32's after // the raw file data in the MPQ. // @@ -1286,44 +1122,39 @@ int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile) // Does the size of the file table match with the CRC32-based checksums? dwExpectedSize = (hf->dwSectorCount + 2) * sizeof(DWORD); - if(hf->SectorOffsets[0] != 0 && hf->SectorOffsets[0] == dwExpectedSize) + if(hf->SectorOffsets[0] == dwExpectedSize) { - // If we are not loading from the MPQ file, we just allocate the sector table - // In that case, do not check any sizes + // Is there valid size of the sector checksums? + if(hf->SectorOffsets[hf->dwSectorCount + 1] >= hf->SectorOffsets[hf->dwSectorCount]) + dwCompressedSize = hf->SectorOffsets[hf->dwSectorCount + 1] - hf->SectorOffsets[hf->dwSectorCount]; + + // Ignore cases when the length is too small or too big. + if(dwCompressedSize < sizeof(DWORD) || dwCompressedSize > hf->dwSectorSize) + return ERROR_SUCCESS; + + // Allocate the array for the sector checksums + hf->SectorChksums = STORM_ALLOC(DWORD, hf->dwSectorCount); + if(hf->SectorChksums == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + + // If we are not supposed to load it from the file, allocate empty buffer if(bLoadFromFile == false) { - hf->SectorChksums = STORM_ALLOC(DWORD, hf->dwSectorCount); - if(hf->SectorChksums == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Fill the checksum table with zeros memset(hf->SectorChksums, 0, hf->dwSectorCount * sizeof(DWORD)); return ERROR_SUCCESS; } - else - { - // Is there valid size of the sector checksums? - if(hf->SectorOffsets[hf->dwSectorCount + 1] >= hf->SectorOffsets[hf->dwSectorCount]) - dwCompressedSize = hf->SectorOffsets[hf->dwSectorCount + 1] - hf->SectorOffsets[hf->dwSectorCount]; - // Ignore cases when the length is too small or too big. - if(dwCompressedSize < sizeof(DWORD) || dwCompressedSize > hf->dwSectorSize) - return ERROR_SUCCESS; + // Calculate offset of the CRC table + dwCrcSize = hf->dwSectorCount * sizeof(DWORD); + dwCrcOffset = hf->SectorOffsets[hf->dwSectorCount]; + CalculateRawSectorOffset(RawFilePos, hf, dwCrcOffset); - // Calculate offset of the CRC table - dwCrcSize = hf->dwSectorCount * sizeof(DWORD); - dwCrcOffset = hf->SectorOffsets[hf->dwSectorCount]; - RawFilePos = CalculateRawSectorOffset(hf, dwCrcOffset); - - // Now read the table from the MPQ - hf->SectorChksums = (DWORD *)LoadMpqTable(ha, RawFilePos, dwCompressedSize, dwCrcSize, 0, NULL); - if(hf->SectorChksums == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - } + // Now read the table from the MPQ + return LoadMpqTable(ha, RawFilePos, hf->SectorChksums, dwCompressedSize, dwCrcSize, 0); } // If the size doesn't match, we ignore sector checksums -// assert(false); + // assert(false); return ERROR_SUCCESS; } @@ -1353,7 +1184,7 @@ int WriteSectorOffsets(TMPQFile * hf) // The caller must make sure that this function is only called // when the following is true. - assert(hf->pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK); + assert(hf->pFileEntry->dwFlags & MPQ_FILE_COMPRESSED); assert(hf->SectorOffsets != NULL); dwSectorOffsLen = hf->SectorOffsets[0]; @@ -1369,10 +1200,10 @@ int WriteSectorOffsets(TMPQFile * hf) // Write sector offsets to the archive if(!FileStream_Write(ha->pStream, &RawFilePos, hf->SectorOffsets, dwSectorOffsLen)) return GetLastError(); - + // Not necessary, as the sector checksums // are going to be freed when this is done. -// BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen); + // BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen); return ERROR_SUCCESS; } @@ -1414,7 +1245,7 @@ int WriteSectorChecksums(TMPQFile * hf) BSWAP_ARRAY32_UNSIGNED(hf->SectorChksums, dwCrcSize); nOutSize = (int)dwCrcSize; - SCompCompress(pbCompressed, &nOutSize, hf->SectorChksums, (int)dwCrcSize, MPQ_COMPRESSION_ZLIB, 0, 0); + SCompCompress((char *)pbCompressed, &nOutSize, (char *)hf->SectorChksums, (int)dwCrcSize, MPQ_COMPRESSION_ZLIB, 0, 0); dwCompressedSize = (DWORD)nOutSize; // Write the sector CRCs to the archive @@ -1426,9 +1257,9 @@ int WriteSectorChecksums(TMPQFile * hf) // Not necessary, as the sector checksums // are going to be freed when this is done. -// BSWAP_ARRAY32_UNSIGNED(hf->SectorChksums, dwCrcSize); + // BSWAP_ARRAY32_UNSIGNED(hf->SectorChksums, dwCrcSize); - // Store the sector CRCs + // Store the sector CRCs hf->SectorOffsets[hf->dwSectorCount + 1] = hf->SectorOffsets[hf->dwSectorCount] + dwCompressedSize; pFileEntry->dwCmpSize += dwCompressedSize; STORM_FREE(pbCompressed); @@ -1436,12 +1267,12 @@ int WriteSectorChecksums(TMPQFile * hf) } int WriteMemDataMD5( - TFileStream * pStream, - ULONGLONG RawDataOffs, - void * pvRawData, - DWORD dwRawDataSize, - DWORD dwChunkSize, - LPDWORD pcbTotalSize) + TFileStream * pStream, + ULONGLONG RawDataOffs, + void * pvRawData, + DWORD dwRawDataSize, + DWORD dwChunkSize, + LPDWORD pcbTotalSize) { unsigned char * md5_array; unsigned char * md5; @@ -1487,10 +1318,10 @@ int WriteMemDataMD5( // Writes the MD5 for each chunk of the raw file data int WriteMpqDataMD5( - TFileStream * pStream, - ULONGLONG RawDataOffs, - DWORD dwRawDataSize, - DWORD dwChunkSize) + TFileStream * pStream, + ULONGLONG RawDataOffs, + DWORD dwRawDataSize, + DWORD dwChunkSize) { unsigned char * md5_array; unsigned char * md5; @@ -1548,15 +1379,17 @@ int WriteMpqDataMD5( } // Frees the structure for MPQ file -void FreeFileHandle(TMPQFile *& hf) +void FreeMPQFile(TMPQFile *& hf) { if(hf != NULL) { // If we have patch file attached to this one, free it first - if(hf->hfPatch != NULL) - FreeFileHandle(hf->hfPatch); + if(hf->hfPatchFile != NULL) + FreeMPQFile(hf->hfPatchFile); // Then free all buffers allocated in the file structure + if(hf->pPatchHeader != NULL) + STORM_FREE(hf->pPatchHeader); if(hf->pbFileData != NULL) STORM_FREE(hf->pbFileData); if(hf->pPatchInfo != NULL) @@ -1567,25 +1400,20 @@ void FreeFileHandle(TMPQFile *& hf) STORM_FREE(hf->SectorChksums); if(hf->pbFileSector != NULL) STORM_FREE(hf->pbFileSector); - if(hf->pStream != NULL) - FileStream_Close(hf->pStream); + FileStream_Close(hf->pStream); STORM_FREE(hf); hf = NULL; } } // Frees the MPQ archive -void FreeArchiveHandle(TMPQArchive *& ha) +void FreeMPQArchive(TMPQArchive *& ha) { if(ha != NULL) { // First of all, free the patch archive, if any if(ha->haPatch != NULL) - FreeArchiveHandle(ha->haPatch); - - // Free the patch prefix, if any - if(ha->pPatchPrefix != NULL) - STORM_FREE(ha->pPatchPrefix); + FreeMPQArchive(ha->haPatch); // Close the file stream FileStream_Close(ha->pStream); @@ -1605,6 +1433,8 @@ void FreeArchiveHandle(TMPQArchive *& ha) STORM_FREE(ha->pFileTable); } + if(ha->pBitmap != NULL) + STORM_FREE(ha->pBitmap); if(ha->pHashTable != NULL) STORM_FREE(ha->pHashTable); if(ha->pHetTable != NULL) @@ -1614,13 +1444,41 @@ void FreeArchiveHandle(TMPQArchive *& ha) } } +const char * GetPlainFileNameA(const char * szFileName) +{ + const char * szPlainName = szFileName; + + while(*szFileName != 0) + { + if(*szFileName == '\\' || *szFileName == '/') + szPlainName = szFileName + 1; + szFileName++; + } + + return szPlainName; +} + +const TCHAR * GetPlainFileNameT(const TCHAR * szFileName) +{ + const TCHAR * szPlainName = szFileName; + + while(*szFileName != 0) + { + if(*szFileName == '\\' || *szFileName == '/') + szPlainName = szFileName + 1; + szFileName++; + } + + return szPlainName; +} + bool IsInternalMpqFileName(const char * szFileName) { if(szFileName != NULL && szFileName[0] == '(') { if(!_stricmp(szFileName, LISTFILE_NAME) || - !_stricmp(szFileName, ATTRIBUTES_NAME) || - !_stricmp(szFileName, SIGNATURE_NAME)) + !_stricmp(szFileName, ATTRIBUTES_NAME) || + !_stricmp(szFileName, SIGNATURE_NAME)) { return true; } @@ -1666,23 +1524,14 @@ bool IsPseudoFileName(const char * szFileName, DWORD * pdwFileIndex) bool IsValidMD5(LPBYTE pbMd5) { - LPDWORD Md5 = (LPDWORD)pbMd5; + BYTE BitSummary = 0; - return (Md5[0] | Md5[1] | Md5[2] | Md5[3]) ? true : false; + // The MD5 is considered invalid of it is zeroed + BitSummary |= pbMd5[0x00] | pbMd5[0x01] | pbMd5[0x02] | pbMd5[0x03] | pbMd5[0x04] | pbMd5[0x05] | pbMd5[0x06] | pbMd5[0x07]; + BitSummary |= pbMd5[0x08] | pbMd5[0x09] | pbMd5[0x0A] | pbMd5[0x0B] | pbMd5[0x0C] | pbMd5[0x0D] | pbMd5[0x0E] | pbMd5[0x0F]; + return (BitSummary != 0); } -bool IsValidSignature(LPBYTE pbSignature) -{ - LPDWORD Signature = (LPDWORD)pbSignature; - DWORD SigValid = 0; - - for(int i = 0; i < MPQ_WEAK_SIGNATURE_SIZE / sizeof(DWORD); i++) - SigValid |= Signature[i]; - - return (SigValid != 0) ? true : false; -} - - bool VerifyDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE expected_md5) { hash_state md5_state; @@ -1724,37 +1573,37 @@ void CalculateDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE md5_ha // Swaps a signed 16-bit integer int16_t SwapInt16(uint16_t data) { - return (int16_t)CFSwapInt16(data); + return (int16_t)CFSwapInt16(data); } // Swaps an unsigned 16-bit integer uint16_t SwapUInt16(uint16_t data) { - return CFSwapInt16(data); + return CFSwapInt16(data); } // Swaps signed 32-bit integer int32_t SwapInt32(uint32_t data) { - return (int32_t)CFSwapInt32(data); + return (int32_t)CFSwapInt32(data); } // Swaps an unsigned 32-bit integer uint32_t SwapUInt32(uint32_t data) { - return CFSwapInt32(data); + return CFSwapInt32(data); } // Swaps signed 64-bit integer int64_t SwapInt64(int64_t data) { - return (int64_t)CFSwapInt64(data); + return (int64_t)CFSwapInt64(data); } // Swaps an unsigned 64-bit integer uint64_t SwapUInt64(uint64_t data) { - return CFSwapInt64(data); + return CFSwapInt64(data); } // Swaps array of unsigned 16-bit integers @@ -1764,10 +1613,10 @@ void ConvertUInt16Buffer(void * ptr, size_t length) uint32_t nElements = (uint32_t)(length / sizeof(uint16_t)); while(nElements-- > 0) - { - *buffer = SwapUInt16(*buffer); - buffer++; - } + { + *buffer = SwapUInt16(*buffer); + buffer++; + } } // Swaps array of unsigned 32-bit integers @@ -1776,11 +1625,11 @@ void ConvertUInt32Buffer(void * ptr, size_t length) uint32_t * buffer = (uint32_t *)ptr; uint32_t nElements = (uint32_t)(length / sizeof(uint32_t)); - while(nElements-- > 0) - { - *buffer = SwapUInt32(*buffer); - buffer++; - } + while(nElements-- > 0) + { + *buffer = SwapUInt32(*buffer); + buffer++; + } } // Swaps array of unsigned 64-bit integers @@ -1789,53 +1638,62 @@ void ConvertUInt64Buffer(void * ptr, size_t length) uint64_t * buffer = (uint64_t *)ptr; uint32_t nElements = (uint32_t)(length / sizeof(uint64_t)); - while(nElements-- > 0) - { - *buffer = SwapUInt64(*buffer); - buffer++; - } + while(nElements-- > 0) + { + *buffer = SwapUInt64(*buffer); + buffer++; + } +} + +// Swaps the TMPQUserData structure +void ConvertTMPQUserData(void *userData) +{ + TMPQUserData * theData = (TMPQUserData *)userData; + + theData->dwID = SwapUInt32(theData->dwID); + theData->cbUserDataSize = SwapUInt32(theData->cbUserDataSize); + theData->dwHeaderOffs = SwapUInt32(theData->dwHeaderOffs); + theData->cbUserDataHeader = SwapUInt32(theData->cbUserDataHeader); } // Swaps the TMPQHeader structure -void ConvertTMPQHeader(void *header, uint16_t version) +void ConvertTMPQHeader(void *header) { - TMPQHeader * theHeader = (TMPQHeader *)header; + TMPQHeader * theHeader = (TMPQHeader *)header; - // Swap header part version 1 - if(version == MPQ_FORMAT_VERSION_1) + theHeader->dwID = SwapUInt32(theHeader->dwID); + theHeader->dwHeaderSize = SwapUInt32(theHeader->dwHeaderSize); + theHeader->dwArchiveSize = SwapUInt32(theHeader->dwArchiveSize); + theHeader->wFormatVersion = SwapUInt16(theHeader->wFormatVersion); + theHeader->wSectorSize = SwapUInt16(theHeader->wSectorSize); + theHeader->dwHashTablePos = SwapUInt32(theHeader->dwHashTablePos); + theHeader->dwBlockTablePos = SwapUInt32(theHeader->dwBlockTablePos); + theHeader->dwHashTableSize = SwapUInt32(theHeader->dwHashTableSize); + theHeader->dwBlockTableSize = SwapUInt32(theHeader->dwBlockTableSize); + + if(theHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) { - theHeader->dwID = SwapUInt32(theHeader->dwID); - theHeader->dwHeaderSize = SwapUInt32(theHeader->dwHeaderSize); - theHeader->dwArchiveSize = SwapUInt32(theHeader->dwArchiveSize); - theHeader->wFormatVersion = SwapUInt16(theHeader->wFormatVersion); - theHeader->wSectorSize = SwapUInt16(theHeader->wSectorSize); - theHeader->dwHashTablePos = SwapUInt32(theHeader->dwHashTablePos); - theHeader->dwBlockTablePos = SwapUInt32(theHeader->dwBlockTablePos); - theHeader->dwHashTableSize = SwapUInt32(theHeader->dwHashTableSize); - theHeader->dwBlockTableSize = SwapUInt32(theHeader->dwBlockTableSize); - } + // Swap the hi-block table position + theHeader->HiBlockTablePos64 = SwapUInt64(theHeader->HiBlockTablePos64); - if(version == MPQ_FORMAT_VERSION_2) - { - theHeader->HiBlockTablePos64 = SwapUInt64(theHeader->HiBlockTablePos64); theHeader->wHashTablePosHi = SwapUInt16(theHeader->wHashTablePosHi); - theHeader->wBlockTablePosHi = SwapUInt16(theHeader->wBlockTablePosHi); - } + theHeader->wBlockTablePosHi = SwapUInt16(theHeader->wBlockTablePosHi); - if(version == MPQ_FORMAT_VERSION_3) - { - theHeader->ArchiveSize64 = SwapUInt64(theHeader->ArchiveSize64); - theHeader->BetTablePos64 = SwapUInt64(theHeader->BetTablePos64); - theHeader->HetTablePos64 = SwapUInt64(theHeader->HetTablePos64); - } + if(theHeader->wFormatVersion >= MPQ_FORMAT_VERSION_3) + { + theHeader->ArchiveSize64 = SwapUInt64(theHeader->ArchiveSize64); + theHeader->BetTablePos64 = SwapUInt64(theHeader->BetTablePos64); + theHeader->HetTablePos64 = SwapUInt64(theHeader->HetTablePos64); - if(version == MPQ_FORMAT_VERSION_4) - { - theHeader->HashTableSize64 = SwapUInt64(theHeader->HashTableSize64); - theHeader->BlockTableSize64 = SwapUInt64(theHeader->BlockTableSize64); - theHeader->HiBlockTableSize64 = SwapUInt64(theHeader->HiBlockTableSize64); - theHeader->HetTableSize64 = SwapUInt64(theHeader->HetTableSize64); - theHeader->BetTableSize64 = SwapUInt64(theHeader->BetTableSize64); + if(theHeader->wFormatVersion >= MPQ_FORMAT_VERSION_4) + { + theHeader->HashTableSize64 = SwapUInt64(theHeader->HashTableSize64); + theHeader->BlockTableSize64 = SwapUInt64(theHeader->BlockTableSize64); + theHeader->HiBlockTableSize64 = SwapUInt64(theHeader->HiBlockTableSize64); + theHeader->HetTableSize64 = SwapUInt64(theHeader->HetTableSize64); + theHeader->BetTableSize64 = SwapUInt64(theHeader->BetTableSize64); + } + } } } diff --git a/dep/StormLib/src/SBaseDumpData.cpp b/dep/StormLib/src/SBaseDumpData.cpp index 334561b85..9b6537bd3 100644 --- a/dep/StormLib/src/SBaseDumpData.cpp +++ b/dep/StormLib/src/SBaseDumpData.cpp @@ -41,26 +41,6 @@ void DumpMpqHeader(TMPQHeader * pHeader) printf("-----------------------------------------------\n\n"); } -void DumpHashTable(TMPQHash * pHashTable, DWORD dwHashTableSize) -{ - DWORD i; - - if(pHashTable == NULL || dwHashTableSize == 0) - return; - - printf("== Hash Table =================================\n"); - for(i = 0; i < dwHashTableSize; i++) - { - printf("[%08x] %08X %08X %04X %02X %08X\n", i, - pHashTable[i].dwName1, - pHashTable[i].dwName2, - pHashTable[i].lcLocale, - pHashTable[i].Platform, - pHashTable[i].dwBlockIndex); - } - printf("-----------------------------------------------\n\n"); -} - void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable) { DWORD i; @@ -69,14 +49,14 @@ void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable) return; printf("== HET Header =================================\n"); - printf("ULONGLONG AndMask64 = %016llX\n", pHetTable->AndMask64); - printf("ULONGLONG OrMask64 = %016llX\n", pHetTable->OrMask64); - printf("DWORD dwEntryCount = %08X\n", pHetTable->dwEntryCount); - printf("DWORD dwTotalCount = %08X\n", pHetTable->dwTotalCount); - printf("DWORD dwNameHashBitSize = %08X\n", pHetTable->dwNameHashBitSize); + printf("ULONGLONG AndMask64 = %016llX\n", pHetTable->AndMask64); + printf("ULONGLONG OrMask64 = %016llX\n", pHetTable->OrMask64); printf("DWORD dwIndexSizeTotal = %08X\n", pHetTable->dwIndexSizeTotal); printf("DWORD dwIndexSizeExtra = %08X\n", pHetTable->dwIndexSizeExtra); - printf("DWORD dwIndexSize = %08X\n", pHetTable->dwIndexSize); + printf("DWORD dwIndexSize = %08X\n", pHetTable->dwIndexSize); + printf("DWORD dwMaxFileCount = %08X\n", pHetTable->dwMaxFileCount); + printf("DWORD dwHashTableSize = %08X\n", pHetTable->dwHashTableSize); + printf("DWORD dwHashBitSize = %08X\n", pHetTable->dwHashBitSize); printf("-----------------------------------------------\n\n"); printf("== BET Header =================================\n"); @@ -89,19 +69,19 @@ void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable) printf("DWORD dwBitCount_FilePos = %08X\n", pBetTable->dwBitCount_FilePos); printf("DWORD dwBitCount_FileSize = %08X\n", pBetTable->dwBitCount_FileSize); printf("DWORD dwBitCount_CmpSize = %08X\n", pBetTable->dwBitCount_CmpSize); - printf("DWORD dwBitCount_FlagIndex = %08X\n", pBetTable->dwBitCount_FlagIndex); + printf("DWORD dwBitCount_FlagIndex = %08X\n", pBetTable->dwBitCount_FlagIndex); printf("DWORD dwBitCount_Unknown = %08X\n", pBetTable->dwBitCount_Unknown); - printf("DWORD dwBitTotal_NameHash2 = %08X\n", pBetTable->dwBitTotal_NameHash2); - printf("DWORD dwBitExtra_NameHash2 = %08X\n", pBetTable->dwBitExtra_NameHash2); - printf("DWORD dwBitCount_NameHash2 = %08X\n", pBetTable->dwBitCount_NameHash2); - printf("DWORD dwEntryCount = %08X\n", pBetTable->dwEntryCount); + printf("DWORD dwBetHashSizeTotal = %08X\n", pBetTable->dwBetHashSizeTotal); + printf("DWORD dwBetHashSizeExtra = %08X\n", pBetTable->dwBetHashSizeExtra); + printf("DWORD dwBetHashSize = %08X\n", pBetTable->dwBetHashSize); + printf("DWORD dwMaxFileCount = %08X\n", pBetTable->dwMaxFileCount); printf("DWORD dwFlagCount = %08X\n", pBetTable->dwFlagCount); printf("-----------------------------------------------\n\n"); printf("== HET & Bet Table ======================================================================\n\n"); printf("HetIdx HetHash BetIdx BetHash ByteOffset FileSize CmpSize FlgIdx Flags \n"); printf("------ ------- ------ ---------------- ---------------- -------- -------- ------ --------\n"); - for(i = 0; i < pHetTable->dwTotalCount; i++) + for(i = 0; i < pHetTable->dwHashTableSize; i++) { ULONGLONG ByteOffset = 0; ULONGLONG BetHash = 0; @@ -113,77 +93,52 @@ void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable) GetBits(pHetTable->pBetIndexes, i * pHetTable->dwIndexSizeTotal, pHetTable->dwIndexSize, - &dwBetIndex, + &dwBetIndex, 4); - - if(dwBetIndex < pHetTable->dwTotalCount) + + if(dwBetIndex < pHetTable->dwMaxFileCount) { DWORD dwEntryIndex = pBetTable->dwTableEntrySize * dwBetIndex; - GetBits(pBetTable->pNameHashes, dwBetIndex * pBetTable->dwBitTotal_NameHash2, - pBetTable->dwBitCount_NameHash2, + GetBits(pBetTable->pBetHashes, dwBetIndex * pBetTable->dwBetHashSizeTotal, + pBetTable->dwBetHashSize, &BetHash, - 8); - - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_FilePos, - pBetTable->dwBitCount_FilePos, - &ByteOffset, 8); - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_FileSize, + GetBits(dwEntryIndex + pBetTable->dwBitIndex_FilePos, + pBetTable->dwBitCount_FilePos, + &ByteOffset, + 8); + + GetBits(dwEntryIndex + pBetTable->dwBitIndex_FileSize, pBetTable->dwBitCount_FileSize, - &dwFileSize, + &dwFileSize, 4); - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_CmpSize, + GetBits(dwEntryIndex + pBetTable->dwBitIndex_CmpSize, pBetTable->dwBitCount_CmpSize, - &dwCmpSize, + &dwCmpSize, 4); - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_FlagIndex, + GetBits(dwEntryIndex + pBetTable->dwBitIndex_FlagIndex, pBetTable->dwBitCount_FlagIndex, - &dwFlagIndex, + &dwFlagIndex, 4); dwFlags = pBetTable->pFileFlags[dwFlagIndex]; } printf(" %04X %02lX %04X %016llX %016llX %08X %08X %04X %08X\n", i, - pHetTable->pNameHashes[i], - dwBetIndex, - BetHash, - ByteOffset, - dwFileSize, - dwCmpSize, - dwFlagIndex, - dwFlags); + pHetTable->pHetHashes[i], + dwBetIndex, + BetHash, + ByteOffset, + dwFileSize, + dwCmpSize, + dwFlagIndex, + dwFlags); } printf("-----------------------------------------------------------------------------------------\n"); } -void DumpFileTable(TFileEntry * pFileTable, DWORD dwFileTableSize) -{ - DWORD i; - - if(pFileTable == NULL || dwFileTableSize == 0) - return; - - printf("== File Table =================================\n"); - for(i = 0; i < dwFileTableSize; i++, pFileTable++) - { - printf("[%04u] %08X-%08X %08X-%08X %08X-%08X 0x%08X 0x%08X 0x%08X %s\n", i, - (DWORD)(pFileTable->FileNameHash >> 0x20), - (DWORD)(pFileTable->FileNameHash & 0xFFFFFFFF), - (DWORD)(pFileTable->ByteOffset >> 0x20), - (DWORD)(pFileTable->ByteOffset & 0xFFFFFFFF), - (DWORD)(pFileTable->FileTime >> 0x20), - (DWORD)(pFileTable->FileTime & 0xFFFFFFFF), - pFileTable->dwFileSize, - pFileTable->dwCmpSize, - pFileTable->dwFlags, - pFileTable->szFileName != NULL ? pFileTable->szFileName : ""); - } - printf("-----------------------------------------------\n\n"); -} - #endif // __STORMLIB_DUMP_DATA__ diff --git a/dep/StormLib/src/SBaseFileTable.cpp b/dep/StormLib/src/SBaseFileTable.cpp index e66536d7c..0e25101ed 100644 --- a/dep/StormLib/src/SBaseFileTable.cpp +++ b/dep/StormLib/src/SBaseFileTable.cpp @@ -18,12 +18,55 @@ #define INVALID_FLAG_VALUE 0xCCCCCCCC #define MAX_FLAG_INDEX 512 +//----------------------------------------------------------------------------- +// Local structures + +// Structure for HET table header +typedef struct _HET_TABLE_HEADER +{ + DWORD dwTableSize; // Size of the entire HET table, including HET_TABLE_HEADER (in bytes) + DWORD dwMaxFileCount; // Maximum number of files in the MPQ + DWORD dwHashTableSize; // Size of the hash table (in bytes) + DWORD dwHashEntrySize; // Effective size of the hash entry (in bits) + DWORD dwIndexSizeTotal; // Total size of file index (in bits) + DWORD dwIndexSizeExtra; // Extra bits in the file index + DWORD dwIndexSize; // Effective size of the file index (in bits) + DWORD dwIndexTableSize; // Size of the block index subtable (in bytes) + +} HET_TABLE_HEADER, *PHET_TABLE_HEADER; + +// Structure for BET table header +typedef struct _BET_TABLE_HEADER +{ + DWORD dwTableSize; // Size of the entire BET table, including the header (in bytes) + DWORD dwFileCount; // Number of files in the BET table + DWORD dwUnknown08; + DWORD dwTableEntrySize; // Size of one table entry (in bits) + DWORD dwBitIndex_FilePos; // Bit index of the file position (within the entry record) + DWORD dwBitIndex_FileSize; // Bit index of the file size (within the entry record) + DWORD dwBitIndex_CmpSize; // Bit index of the compressed size (within the entry record) + DWORD dwBitIndex_FlagIndex; // Bit index of the flag index (within the entry record) + DWORD dwBitIndex_Unknown; // Bit index of the ??? (within the entry record) + DWORD dwBitCount_FilePos; // Bit size of file position (in the entry record) + DWORD dwBitCount_FileSize; // Bit size of file size (in the entry record) + DWORD dwBitCount_CmpSize; // Bit size of compressed file size (in the entry record) + DWORD dwBitCount_FlagIndex; // Bit size of flags index (in the entry record) + DWORD dwBitCount_Unknown; // Bit size of ??? (in the entry record) + DWORD dwBetHashSizeTotal; // Total size of the BET hash + DWORD dwBetHashSizeExtra; // Extra bits in the BET hash + DWORD dwBetHashSize; // Effective size of BET hash (in bits) + DWORD dwBetHashArraySize; // Size of BET hashes array, in bytes + DWORD dwFlagCount; // Number of flags in the following array + +} BET_TABLE_HEADER, *PBET_TABLE_HEADER; + //----------------------------------------------------------------------------- // Support for calculating bit sizes static void InitFileFlagArray(LPDWORD FlagArray) { - memset(FlagArray, 0xCC, MAX_FLAG_INDEX * sizeof(DWORD)); + for(DWORD dwFlagIndex = 0; dwFlagIndex < MAX_FLAG_INDEX; dwFlagIndex++) + FlagArray[dwFlagIndex] = INVALID_FLAG_VALUE; } static DWORD GetFileFlagIndex(LPDWORD FlagArray, DWORD dwFlags) @@ -52,7 +95,7 @@ static DWORD GetNecessaryBitCount(ULONGLONG MaxValue) MaxValue >>= 1; dwBitCount++; } - + return dwBitCount; } @@ -62,8 +105,8 @@ static DWORD GetNecessaryBitCount(ULONGLONG MaxValue) static USHORT SetBitsMask[] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF}; static TBitArray * CreateBitArray( - DWORD NumberOfBits, - BYTE FillValue) + DWORD NumberOfBits, + BYTE FillValue) { TBitArray * pBitArray; size_t nSize = sizeof(TBitArray) + (NumberOfBits + 7) / 8; @@ -73,7 +116,6 @@ static TBitArray * CreateBitArray( if(pBitArray != NULL) { memset(pBitArray, FillValue, nSize); - pBitArray->NumberOfBytes = (NumberOfBits + 7) / 8; pBitArray->NumberOfBits = NumberOfBits; } @@ -81,11 +123,11 @@ static TBitArray * CreateBitArray( } void GetBits( - TBitArray * pArray, - unsigned int nBitPosition, - unsigned int nBitLength, - void * pvBuffer, - int nResultByteSize) + TBitArray * pArray, + unsigned int nBitPosition, + unsigned int nBitLength, + void * pvBuffer, + int nResultByteSize) { unsigned char * pbBuffer = (unsigned char *)pvBuffer; unsigned int nBytePosition0 = (nBitPosition / 8); @@ -106,7 +148,7 @@ void GetBits( #ifndef PLATFORM_LITTLE_ENDIAN // Adjust the buffer pointer for big endian platforms pbBuffer += (nResultByteSize - 1); -#endif +#endif // Copy whole bytes, if any while(nByteLength > 0) @@ -147,11 +189,11 @@ void GetBits( } void SetBits( - TBitArray * pArray, - unsigned int nBitPosition, - unsigned int nBitLength, - void * pvBuffer, - int nResultByteSize) + TBitArray * pArray, + unsigned int nBitPosition, + unsigned int nBitLength, + void * pvBuffer, + int nResultByteSize) { unsigned char * pbBuffer = (unsigned char *)pvBuffer; unsigned int nBytePosition = (nBitPosition / 8); @@ -166,7 +208,7 @@ void SetBits( #ifndef PLATFORM_LITTLE_ENDIAN // Adjust the buffer pointer for big endian platforms pbBuffer += (nResultByteSize - 1); -#endif +#endif // Copy whole bytes, if any while(nBitLength > 8) @@ -213,450 +255,65 @@ void SetBits( } } -//----------------------------------------------------------------------------- -// Support for MPQ header - -static ULONGLONG DetermineArchiveSize_V1( - TMPQArchive * ha, - TMPQHeader * pHeader, - ULONGLONG MpqOffset, - ULONGLONG FileSize) -{ - ULONGLONG ByteOffset; - ULONGLONG EndOfMpq = FileSize; - DWORD SignatureHeader = 0; - DWORD dwArchiveSize32; - - // This could only be called for MPQs version 1.0 - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1); - - // Check if we can rely on the archive size in the header - if(pHeader->dwBlockTablePos < pHeader->dwArchiveSize) - { - // The block table cannot be compressed, so the sizes must match - if((pHeader->dwArchiveSize - pHeader->dwBlockTablePos) == (pHeader->dwBlockTableSize * sizeof(TMPQBlock))) - return pHeader->dwArchiveSize; - - // If the archive size in the header is less than real file size - dwArchiveSize32 = (DWORD)(FileSize - MpqOffset); - if(pHeader->dwArchiveSize == dwArchiveSize32) - return pHeader->dwArchiveSize; - } - - // Check if there is a signature header - if((EndOfMpq - MpqOffset) > (MPQ_STRONG_SIGNATURE_SIZE + 4)) - { - ByteOffset = EndOfMpq - MPQ_STRONG_SIGNATURE_SIZE - 4; - if(FileStream_Read(ha->pStream, &ByteOffset, &SignatureHeader, sizeof(DWORD))) - { - if(BSWAP_INT32_UNSIGNED(SignatureHeader) == MPQ_STRONG_SIGNATURE_ID) - EndOfMpq = EndOfMpq - MPQ_STRONG_SIGNATURE_SIZE - 4; - } - } - - // Return the returned archive size - return (EndOfMpq - MpqOffset); -} - -static ULONGLONG DetermineArchiveSize_V2( - TMPQHeader * pHeader, - ULONGLONG MpqOffset, - ULONGLONG FileSize) -{ - ULONGLONG EndOfMpq = FileSize; - DWORD dwArchiveSize32; - - // This could only be called for MPQs version 2.0 - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_2); - - // Check if we can rely on the archive size in the header - if((FileSize >> 0x20) == 0) - { - if(pHeader->dwBlockTablePos < pHeader->dwArchiveSize) - { - if((pHeader->dwArchiveSize - pHeader->dwBlockTablePos) <= (pHeader->dwBlockTableSize * sizeof(TMPQBlock))) - return pHeader->dwArchiveSize; - - // If the archive size in the header is less than real file size - dwArchiveSize32 = (DWORD)(FileSize - MpqOffset); - if(pHeader->dwArchiveSize <= dwArchiveSize32) - return pHeader->dwArchiveSize; - } - } - - // Return the calculated archive size - return (EndOfMpq - MpqOffset); -} - -ULONGLONG FileOffsetFromMpqOffset(TMPQArchive * ha, ULONGLONG MpqOffset) -{ - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - // For MPQ archive v1, any file offset is only 32-bit - return (ULONGLONG)((DWORD)ha->MpqPos + (DWORD)MpqOffset); - } - else - { - // For MPQ archive v2+, file offsets are full 64-bit - return ha->MpqPos + MpqOffset; - } -} - -ULONGLONG CalculateRawSectorOffset( - TMPQFile * hf, - DWORD dwSectorOffset) -{ - ULONGLONG RawFilePos; - - // Must be used for files within a MPQ - assert(hf->ha != NULL); - assert(hf->ha->pHeader != NULL); - - // - // Some MPQ protectors place the sector offset table after the actual file data. - // Sector offsets in the sector offset table are negative. When added - // to MPQ file offset from the block table entry, the result is a correct - // position of the file data in the MPQ. - // - // For MPQs version 1.0, the offset is purely 32-bit - // - - RawFilePos = hf->RawFilePos + dwSectorOffset; - if(hf->ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - RawFilePos = (DWORD)hf->ha->MpqPos + (DWORD)hf->pFileEntry->ByteOffset + dwSectorOffset; - - // We also have to add patch header size, if patch header is present - if(hf->pPatchInfo != NULL) - RawFilePos += hf->pPatchInfo->dwLength; - - // Return the result offset - return RawFilePos; -} - -// This function converts the MPQ header so it always looks like version 4 -int ConvertMpqHeaderToFormat4( - TMPQArchive * ha, - ULONGLONG MpqOffset, - ULONGLONG FileSize, - DWORD dwFlags, - bool bIsWarcraft3Map) -{ - TMPQHeader * pHeader = (TMPQHeader *)ha->HeaderData; - ULONGLONG BlockTablePos64 = 0; - ULONGLONG HashTablePos64 = 0; - ULONGLONG BlockTableMask = (ULONGLONG)-1; - ULONGLONG ByteOffset; - USHORT wFormatVersion = BSWAP_INT16_UNSIGNED(pHeader->wFormatVersion); - int nError = ERROR_SUCCESS; - - // If version 1.0 is forced, then the format version is forced to be 1.0 - // Reason: Storm.dll in Warcraft III ignores format version value - if((dwFlags & MPQ_OPEN_FORCE_MPQ_V1) || bIsWarcraft3Map) - wFormatVersion = MPQ_FORMAT_VERSION_1; - - // Format-specific fixes - switch(wFormatVersion) - { - case MPQ_FORMAT_VERSION_1: - - // Check for malformed MPQ header version 1.0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_1); - if(pHeader->wFormatVersion != MPQ_FORMAT_VERSION_1 || pHeader->dwHeaderSize != MPQ_HEADER_SIZE_V1) - { - pHeader->wFormatVersion = MPQ_FORMAT_VERSION_1; - pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - } - - // - // Note: The value of "dwArchiveSize" member in the MPQ header - // is ignored by Storm.dll and can contain garbage value - // ("w3xmaster" protector). - // - - Label_ArchiveVersion1: - if(pHeader->dwBlockTableSize > 1) // Prevent empty MPQs being marked as malformed - { - if(pHeader->dwHashTablePos <= pHeader->dwHeaderSize || (pHeader->dwHashTablePos & 0x80000000)) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - if(pHeader->dwBlockTablePos <= pHeader->dwHeaderSize || (pHeader->dwBlockTablePos & 0x80000000)) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - } - - // Only low byte of sector size is really used - if(pHeader->wSectorSize & 0xFF00) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - pHeader->wSectorSize = pHeader->wSectorSize & 0xFF; - - // Fill the rest of the header - memset((LPBYTE)pHeader + MPQ_HEADER_SIZE_V1, 0, sizeof(TMPQHeader) - MPQ_HEADER_SIZE_V1); - pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock); - pHeader->HashTableSize64 = pHeader->dwHashTableSize * sizeof(TMPQHash); - pHeader->ArchiveSize64 = pHeader->dwArchiveSize; - - // Block table position must be calculated as 32-bit value - // Note: BOBA protector puts block table before the MPQ header, so it is negative - BlockTablePos64 = (ULONGLONG)((DWORD)MpqOffset + pHeader->dwBlockTablePos); - BlockTableMask = 0xFFFFFFF0; - - // Determine the archive size on malformed MPQs - if(ha->dwFlags & MPQ_FLAG_MALFORMED) - { - // Calculate the archive size - pHeader->ArchiveSize64 = DetermineArchiveSize_V1(ha, pHeader, MpqOffset, FileSize); - pHeader->dwArchiveSize = (DWORD)pHeader->ArchiveSize64; - } - - // EWIX_v8_7.w3x: TMPQHeader::dwBlockTableSize = 0x00319601 - // Size of TFileTable goes to ~200MB, so we artificially cut it - if(BlockTablePos64 + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)) > FileSize) - { - pHeader->dwBlockTableSize = (DWORD)((FileSize - BlockTablePos64) / sizeof(TMPQBlock)); - pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock); - } - break; - - case MPQ_FORMAT_VERSION_2: - - // Check for malformed MPQ header version 1.0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_2); - if(pHeader->wFormatVersion != MPQ_FORMAT_VERSION_2 || pHeader->dwHeaderSize != MPQ_HEADER_SIZE_V2) - { - pHeader->wFormatVersion = MPQ_FORMAT_VERSION_1; - pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - goto Label_ArchiveVersion1; - } - - // Fill the rest of the header with zeros - memset((LPBYTE)pHeader + MPQ_HEADER_SIZE_V2, 0, sizeof(TMPQHeader) - MPQ_HEADER_SIZE_V2); - - // Calculate the expected hash table size - pHeader->HashTableSize64 = (pHeader->dwHashTableSize * sizeof(TMPQHash)); - HashTablePos64 = MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos); - - // Calculate the expected block table size - pHeader->BlockTableSize64 = (pHeader->dwBlockTableSize * sizeof(TMPQBlock)); - BlockTablePos64 = MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - - // We require the block table to follow hash table - if(BlockTablePos64 >= HashTablePos64) - { - // HashTableSize64 may be less than TblSize * sizeof(TMPQHash). - // That means that the hash table is compressed. - pHeader->HashTableSize64 = BlockTablePos64 - HashTablePos64; - - // Calculate the compressed block table size - if(pHeader->HiBlockTablePos64 != 0) - { - // BlockTableSize64 may be less than TblSize * sizeof(TMPQBlock). - // That means that the block table is compressed. - pHeader->BlockTableSize64 = pHeader->HiBlockTablePos64 - BlockTablePos64; - assert(pHeader->BlockTableSize64 <= (pHeader->dwBlockTableSize * sizeof(TMPQBlock))); - - // Determine real archive size - pHeader->ArchiveSize64 = DetermineArchiveSize_V2(pHeader, MpqOffset, FileSize); - - // Calculate the size of the hi-block table - pHeader->HiBlockTableSize64 = pHeader->ArchiveSize64 - pHeader->HiBlockTablePos64; - assert(pHeader->HiBlockTableSize64 == (pHeader->dwBlockTableSize * sizeof(USHORT))); - } - else - { - // Determine real archive size - pHeader->ArchiveSize64 = DetermineArchiveSize_V2(pHeader, MpqOffset, FileSize); - - // Calculate size of the block table - pHeader->BlockTableSize64 = pHeader->ArchiveSize64 - BlockTablePos64; - assert(pHeader->BlockTableSize64 <= (pHeader->dwBlockTableSize * sizeof(TMPQBlock))); - } - } - else - { - pHeader->ArchiveSize64 = pHeader->dwArchiveSize; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - } - - // Add the MPQ Offset - BlockTablePos64 += MpqOffset; - break; - - case MPQ_FORMAT_VERSION_3: - - // In MPQ format 3.0, the entire header is optional - // and the size of the header can actually be identical - // to size of header 2.0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_3); - if(pHeader->dwHeaderSize < MPQ_HEADER_SIZE_V3) - { - pHeader->ArchiveSize64 = pHeader->dwArchiveSize; - pHeader->HetTablePos64 = 0; - pHeader->BetTablePos64 = 0; - } - - // - // We need to calculate the compressed size of each table. We assume the following order: - // 1) HET table - // 2) BET table - // 3) Classic hash table - // 4) Classic block table - // 5) Hi-block table - // - - // Fill the rest of the header with zeros - memset((LPBYTE)pHeader + MPQ_HEADER_SIZE_V3, 0, sizeof(TMPQHeader) - MPQ_HEADER_SIZE_V3); - BlockTablePos64 = MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - HashTablePos64 = MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos); - ByteOffset = pHeader->ArchiveSize64; - - // Size of the hi-block table - if(pHeader->HiBlockTablePos64) - { - pHeader->HiBlockTableSize64 = ByteOffset - pHeader->HiBlockTablePos64; - ByteOffset = pHeader->HiBlockTablePos64; - } - - // Size of the block table - if(BlockTablePos64) - { - pHeader->BlockTableSize64 = ByteOffset - BlockTablePos64; - ByteOffset = BlockTablePos64; - } - - // Size of the hash table - if(HashTablePos64) - { - pHeader->HashTableSize64 = ByteOffset - HashTablePos64; - ByteOffset = HashTablePos64; - } - - // Size of the BET table - if(pHeader->BetTablePos64) - { - pHeader->BetTableSize64 = ByteOffset - pHeader->BetTablePos64; - ByteOffset = pHeader->BetTablePos64; - } - - // Size of the HET table - if(pHeader->HetTablePos64) - { - pHeader->HetTableSize64 = ByteOffset - pHeader->HetTablePos64; -// ByteOffset = pHeader->HetTablePos64; - } - - // Add the MPQ Offset - BlockTablePos64 += MpqOffset; - break; - - case MPQ_FORMAT_VERSION_4: - - // Verify header MD5. Header MD5 is calculated from the MPQ header since the 'MPQ\x1A' - // signature until the position of header MD5 at offset 0xC0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_4); - if(!VerifyDataBlockHash(pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, pHeader->MD5_MpqHeader)) - nError = ERROR_FILE_CORRUPT; - - // Calculate the block table position - BlockTablePos64 = MpqOffset + MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - break; - - default: - - // Check if it's a War of the Immortal data file (SQP) - // If not, we treat it as malformed MPQ version 1.0 - if(ConvertSqpHeaderToFormat4(ha, FileSize, dwFlags) != ERROR_SUCCESS) - { - pHeader->wFormatVersion = MPQ_FORMAT_VERSION_1; - pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - goto Label_ArchiveVersion1; - } - - // Calculate the block table position - BlockTablePos64 = MpqOffset + MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - break; - } - - // Handle case when block table is placed before the MPQ header - // Used by BOBA protector - if(BlockTablePos64 < MpqOffset) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - return nError; -} //----------------------------------------------------------------------------- // Support for hash table -// Hash entry verification when the file table does not exist yet -bool IsValidHashEntry(TMPQArchive * ha, TMPQHash * pHash) -{ - TFileEntry * pFileEntry = ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - - return ((MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) && (pFileEntry->dwFlags & MPQ_FILE_EXISTS)) ? true : false; -} - -// Hash entry verification when the file table does not exist yet -static bool IsValidHashEntry1(TMPQArchive * ha, TMPQHash * pHash, TMPQBlock * pBlockTable) -{ - ULONGLONG ByteOffset; - TMPQBlock * pBlock; - - // The block index is considered valid if it's less than block table size - if(MPQ_BLOCK_INDEX(pHash) < ha->pHeader->dwBlockTableSize) - { - // Calculate the block table position - pBlock = pBlockTable + MPQ_BLOCK_INDEX(pHash); - - // Check whether this is an existing file - // Also we do not allow to be file size greater than 2GB - if((pBlock->dwFlags & MPQ_FILE_EXISTS) && (pBlock->dwFSize & 0x80000000) == 0) - { - // The begin of the file must be within the archive - ByteOffset = FileOffsetFromMpqOffset(ha, pBlock->dwFilePos); - return (ByteOffset < ha->FileSize); - } - } - - return false; -} - // Returns a hash table entry in the following order: -// 1) A hash table entry with the preferred locale and platform -// 2) A hash table entry with the neutral|matching locale and neutral|matching platform +// 1) A hash table entry with the neutral locale +// 2) A hash table entry with any other locale // 3) NULL -// Storm_2016.dll: 15020940 -static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale, BYTE Platform) +static TMPQHash * GetHashEntryAny(TMPQArchive * ha, const char * szFileName) { + TMPQHash * pHashNeutral = NULL; TMPQHash * pFirstHash = GetFirstHashEntry(ha, szFileName); - TMPQHash * pBestEntry = NULL; + TMPQHash * pHashAny = NULL; TMPQHash * pHash = pFirstHash; // Parse the found hashes while(pHash != NULL) { - // Storm_2016.dll: 150209CB - // If the hash entry matches both locale and platform, return it immediately - // Note: We only succeed this check if the locale is non-neutral, because - // some Warcraft III maps have several items with neutral locale&platform, which leads - // to wrong item being returned - if((lcLocale || Platform) && pHash->lcLocale == lcLocale && pHash->Platform == Platform) - return pHash; - - // Storm_2016.dll: 150209D9 - // If (locale matches or is neutral) OR (platform matches or is neutral) - // remember this as the best entry - if(pHash->lcLocale == 0 || pHash->lcLocale == lcLocale) - { - if(pHash->Platform == 0 || pHash->Platform == Platform) - pBestEntry = pHash; - } + // If we found neutral hash, remember it + if(pHash->lcLocale == 0) + pHashNeutral = pHash; + if(pHashAny == NULL) + pHashAny = pHash; // Get the next hash entry for that file - pHash = GetNextHashEntry(ha, pFirstHash, pHash); + pHash = GetNextHashEntry(ha, pFirstHash, pHash); } // At the end, return neutral hash (if found), otherwise NULL - return pBestEntry; + return (pHashNeutral != NULL) ? pHashNeutral : pHashAny; +} + +// Returns a hash table entry in the following order: +// 1) A hash table entry with the preferred locale +// 2) A hash table entry with the neutral locale +// 3) NULL +static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale) +{ + TMPQHash * pHashNeutral = NULL; + TMPQHash * pFirstHash = GetFirstHashEntry(ha, szFileName); + TMPQHash * pHash = pFirstHash; + + // Parse the found hashes + while(pHash != NULL) + { + // If the locales match, return it + if(pHash->lcLocale == lcLocale) + return pHash; + + // If we found neutral hash, remember it + if(pHash->lcLocale == 0) + pHashNeutral = pHash; + + // Get the next hash entry for that file + pHash = GetNextHashEntry(ha, pFirstHash, pHash); + } + + // At the end, return neutral hash (if found), otherwise NULL + return pHashNeutral; } // Returns a hash table entry in the following order: @@ -673,201 +330,18 @@ static TMPQHash * GetHashEntryExact(TMPQArchive * ha, const char * szFileName, L // If the locales match, return it if(pHash->lcLocale == lcLocale) return pHash; - + // Get the next hash entry for that file - pHash = GetNextHashEntry(ha, pFirstHash, pHash); + pHash = GetNextHashEntry(ha, pFirstHash, pHash); } // Not found return NULL; } -// Defragment the file table so it does not contain any gaps -// Note: As long as all values of all TMPQHash::dwBlockIndex -// are not HASH_ENTRY_FREE, the startup search index does not matter. -// Hash table is circular, so as long as there is no terminator, -// all entries will be found. -static TMPQHash * DefragmentHashTable( - TMPQArchive * ha, - TMPQHash * pHashTable, - TMPQBlock * pBlockTable) -{ - TMPQHeader * pHeader = ha->pHeader; - TMPQHash * pHashTableEnd = pHashTable + pHeader->dwHashTableSize; - TMPQHash * pSource = pHashTable; - TMPQHash * pTarget = pHashTable; - DWORD dwFirstFreeEntry; - DWORD dwNewTableSize; - - // Sanity checks - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1); - assert(pHeader->HiBlockTablePos64 == 0); - - // Parse the hash table and move the entries to the begin of it - for(pSource = pHashTable; pSource < pHashTableEnd; pSource++) - { - // Check whether this is a valid hash table entry - if(IsValidHashEntry1(ha, pSource, pBlockTable)) - { - // Copy the hash table entry back - if(pSource > pTarget) - pTarget[0] = pSource[0]; - - // Move the target - pTarget++; - } - } - - // Calculate how many entries in the hash table we really need - dwFirstFreeEntry = (DWORD)(pTarget - pHashTable); - dwNewTableSize = GetNearestPowerOfTwo(dwFirstFreeEntry); - - // Fill the rest with entries that look like deleted - pHashTableEnd = pHashTable + dwNewTableSize; - pSource = pHashTable + dwFirstFreeEntry; - memset(pSource, 0xFF, (dwNewTableSize - dwFirstFreeEntry) * sizeof(TMPQHash)); - - // Mark the block indexes as deleted - for(; pSource < pHashTableEnd; pSource++) - pSource->dwBlockIndex = HASH_ENTRY_DELETED; - - // Free some of the space occupied by the hash table - if(dwNewTableSize < pHeader->dwHashTableSize) - { - pHashTable = STORM_REALLOC(TMPQHash, pHashTable, dwNewTableSize); - ha->pHeader->BlockTableSize64 = dwNewTableSize * sizeof(TMPQHash); - ha->pHeader->dwHashTableSize = dwNewTableSize; - } - - return pHashTable; -} - -static int BuildFileTableFromBlockTable( - TMPQArchive * ha, - TMPQBlock * pBlockTable) -{ - TFileEntry * pFileEntry; - TMPQHeader * pHeader = ha->pHeader; - TMPQBlock * pBlock; - TMPQHash * pHashTableEnd; - TMPQHash * pHash; - LPDWORD DefragmentTable = NULL; - DWORD dwItemCount = 0; - DWORD dwFlagMask; - - // Sanity checks - assert(ha->pFileTable != NULL); - assert(ha->dwFileTableSize >= ha->dwMaxFileCount); - - // MPQs for Warcraft III doesn't know some flags, namely MPQ_FILE_SINGLE_UNIT and MPQ_FILE_PATCH_FILE - dwFlagMask = (ha->dwFlags & MPQ_FLAG_WAR3_MAP) ? MPQ_FILE_VALID_FLAGS_W3X : MPQ_FILE_VALID_FLAGS; - - // Defragment the hash table, if needed - if(ha->dwFlags & MPQ_FLAG_HASH_TABLE_CUT) - { - ha->pHashTable = DefragmentHashTable(ha, ha->pHashTable, pBlockTable); - ha->dwMaxFileCount = pHeader->dwHashTableSize; - } - - // If the hash table or block table is cut, - // we will defragment the block table - if(ha->dwFlags & (MPQ_FLAG_HASH_TABLE_CUT | MPQ_FLAG_BLOCK_TABLE_CUT)) - { - // Sanity checks - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1); - assert(pHeader->HiBlockTablePos64 == 0); - - // Allocate the translation table - DefragmentTable = STORM_ALLOC(DWORD, pHeader->dwBlockTableSize); - if(DefragmentTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Fill the translation table - memset(DefragmentTable, 0xFF, pHeader->dwBlockTableSize * sizeof(DWORD)); - } - - // Parse the entire hash table - pHashTableEnd = ha->pHashTable + pHeader->dwHashTableSize; - for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++) - { - // - // We need to properly handle these cases: - // - Multiple hash entries (same file name) point to the same block entry - // - Multiple hash entries (different file name) point to the same block entry - // - // Ignore all hash table entries where: - // - Block Index >= BlockTableSize - // - Flags of the appropriate block table entry - // - - if(IsValidHashEntry1(ha, pHash, pBlockTable)) - { - DWORD dwOldIndex = MPQ_BLOCK_INDEX(pHash); - DWORD dwNewIndex = MPQ_BLOCK_INDEX(pHash); - - // Determine the new block index - if(DefragmentTable != NULL) - { - // Need to handle case when multiple hash - // entries point to the same block entry - if(DefragmentTable[dwOldIndex] == HASH_ENTRY_FREE) - { - DefragmentTable[dwOldIndex] = dwItemCount; - dwNewIndex = dwItemCount++; - } - else - { - dwNewIndex = DefragmentTable[dwOldIndex]; - } - - // Fix the pointer in the hash entry - pHash->dwBlockIndex = dwNewIndex; - - // Dump the relocation entry -// printf("Relocating hash entry %08X-%08X: %08X -> %08X\n", pHash->dwName1, pHash->dwName2, dwBlockIndex, dwNewIndex); - } - - // Get the pointer to the file entry and the block entry - pFileEntry = ha->pFileTable + dwNewIndex; - pBlock = pBlockTable + dwOldIndex; - - // ByteOffset is only valid if file size is not zero - pFileEntry->ByteOffset = pBlock->dwFilePos; - if(pFileEntry->ByteOffset == 0 && pBlock->dwFSize == 0) - pFileEntry->ByteOffset = ha->pHeader->dwHeaderSize; - - // Fill the rest of the file entry - pFileEntry->dwFileSize = pBlock->dwFSize; - pFileEntry->dwCmpSize = pBlock->dwCSize; - pFileEntry->dwFlags = pBlock->dwFlags & dwFlagMask; - } - } - - // Free the translation table - if(DefragmentTable != NULL) - { - // If we defragmented the block table in the process, - // free some memory by shrinking the file table - if(ha->dwFileTableSize > ha->dwMaxFileCount) - { - ha->pFileTable = STORM_REALLOC(TFileEntry, ha->pFileTable, ha->dwMaxFileCount); - ha->pHeader->BlockTableSize64 = ha->dwMaxFileCount * sizeof(TMPQBlock); - ha->pHeader->dwBlockTableSize = ha->dwMaxFileCount; - ha->dwFileTableSize = ha->dwMaxFileCount; - } - -// DumpFileTable(ha->pFileTable, ha->dwFileTableSize); - - // Free the translation table - STORM_FREE(DefragmentTable); - } - - return ERROR_SUCCESS; -} - static TMPQHash * TranslateHashTable( - TMPQArchive * ha, - ULONGLONG * pcbTableSize) + TMPQArchive * ha, + ULONGLONG * pcbTableSize) { TMPQHash * pHashTable; size_t HashTableSize; @@ -890,26 +364,26 @@ static TMPQHash * TranslateHashTable( return pHashTable; } -// Also used in SFileGetFileInfo -TMPQBlock * TranslateBlockTable( - TMPQArchive * ha, - ULONGLONG * pcbTableSize, - bool * pbNeedHiBlockTable) +static TMPQBlock * TranslateBlockTable( + TMPQArchive * ha, + ULONGLONG * pcbTableSize, + bool * pbNeedHiBlockTable) { TFileEntry * pFileEntry = ha->pFileTable; TMPQBlock * pBlockTable; TMPQBlock * pBlock; - DWORD NeedHiBlockTable = 0; - DWORD dwBlockTableSize = ha->pHeader->dwBlockTableSize; + size_t BlockTableSize; + bool bNeedHiBlockTable = false; // Allocate copy of the hash table - pBlockTable = pBlock = STORM_ALLOC(TMPQBlock, dwBlockTableSize); + pBlockTable = pBlock = STORM_ALLOC(TMPQBlock, ha->dwFileTableSize); if(pBlockTable != NULL) { - // Convert the block table - for(DWORD i = 0; i < dwBlockTableSize; i++) + // Copy the block table + BlockTableSize = sizeof(TMPQBlock) * ha->dwFileTableSize; + for(DWORD i = 0; i < ha->dwFileTableSize; i++) { - NeedHiBlockTable |= (DWORD)(pFileEntry->ByteOffset >> 32); + bNeedHiBlockTable = (pFileEntry->ByteOffset >> 32) ? true : false; pBlock->dwFilePos = (DWORD)pFileEntry->ByteOffset; pBlock->dwFSize = pFileEntry->dwFileSize; pBlock->dwCSize = pFileEntry->dwCmpSize; @@ -921,35 +395,36 @@ TMPQBlock * TranslateBlockTable( // Give the size to the caller if(pcbTableSize != NULL) - *pcbTableSize = (ULONGLONG)dwBlockTableSize * sizeof(TMPQBlock); + *pcbTableSize = (ULONGLONG)BlockTableSize; if(pbNeedHiBlockTable != NULL) - *pbNeedHiBlockTable = NeedHiBlockTable ? true : false; + *pbNeedHiBlockTable = bNeedHiBlockTable; } return pBlockTable; } static USHORT * TranslateHiBlockTable( - TMPQArchive * ha, - ULONGLONG * pcbTableSize) + TMPQArchive * ha, + ULONGLONG * pcbTableSize) { TFileEntry * pFileEntry = ha->pFileTable; USHORT * pHiBlockTable; USHORT * pHiBlock; - DWORD dwBlockTableSize = ha->pHeader->dwBlockTableSize; + size_t HiBlockTableSize; // Allocate copy of the hash table - pHiBlockTable = pHiBlock = STORM_ALLOC(USHORT, dwBlockTableSize); + pHiBlockTable = pHiBlock = STORM_ALLOC(USHORT, ha->dwFileTableSize); if(pHiBlockTable != NULL) { // Copy the block table - for(DWORD i = 0; i < dwBlockTableSize; i++) + HiBlockTableSize = sizeof(USHORT) * ha->dwFileTableSize; + for(DWORD i = 0; i < ha->dwFileTableSize; i++) pHiBlock[i] = (USHORT)(pFileEntry[i].ByteOffset >> 0x20); // Give the size to the caller if(pcbTableSize != NULL) - *pcbTableSize = (ULONGLONG)dwBlockTableSize * sizeof(USHORT); + *pcbTableSize = (ULONGLONG)HiBlockTableSize; } return pHiBlockTable; @@ -958,21 +433,21 @@ static USHORT * TranslateHiBlockTable( //----------------------------------------------------------------------------- // General EXT table functions -TMPQExtHeader * LoadExtTable( - TMPQArchive * ha, - ULONGLONG ByteOffset, - size_t Size, - DWORD dwSignature, - DWORD dwKey) +TMPQExtTable * LoadExtTable( + TMPQArchive * ha, + ULONGLONG ByteOffset, + size_t Size, + DWORD dwSignature, + DWORD dwKey) { - TMPQExtHeader * pCompressed = NULL; // Compressed table - TMPQExtHeader * pExtTable = NULL; // Uncompressed table + TMPQExtTable * pCompressed = NULL; // Compressed table + TMPQExtTable * pExtTable = NULL; // Uncompressed table // Do nothing if the size is zero if(ByteOffset != 0 && Size != 0) { // Allocate size for the compressed table - pExtTable = (TMPQExtHeader *)STORM_ALLOC(BYTE, Size); + pExtTable = (TMPQExtTable *)STORM_ALLOC(BYTE, Size); if(pExtTable != NULL) { // Load the table from the MPQ @@ -984,7 +459,7 @@ TMPQExtHeader * LoadExtTable( } // Swap the ext table header - BSWAP_ARRAY32_UNSIGNED(pExtTable, sizeof(TMPQExtHeader)); + BSWAP_ARRAY32_UNSIGNED(pExtTable, sizeof(TMPQExtTable)); if(pExtTable->dwSignature != dwSignature) { STORM_FREE(pExtTable); @@ -993,14 +468,14 @@ TMPQExtHeader * LoadExtTable( // Decrypt the block BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); - DecryptMpqBlock(pExtTable + 1, (DWORD)(Size - sizeof(TMPQExtHeader)), dwKey); + DecryptMpqBlock(pExtTable + 1, (DWORD)(Size - sizeof(TMPQExtTable)), dwKey); BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); // If the table is compressed, decompress it - if((pExtTable->dwDataSize + sizeof(TMPQExtHeader)) > Size) + if((pExtTable->dwDataSize + sizeof(TMPQExtTable)) > Size) { pCompressed = pExtTable; - pExtTable = (TMPQExtHeader *)STORM_ALLOC(BYTE, sizeof(TMPQExtHeader) + pCompressed->dwDataSize); + pExtTable = (TMPQExtTable *)STORM_ALLOC(BYTE, sizeof(TMPQExtTable) + pCompressed->dwDataSize); if(pExtTable != NULL) { int cbOutBuffer = (int)pCompressed->dwDataSize; @@ -1010,7 +485,7 @@ TMPQExtHeader * LoadExtTable( pExtTable->dwSignature = pCompressed->dwSignature; pExtTable->dwVersion = pCompressed->dwVersion; pExtTable->dwDataSize = pCompressed->dwDataSize; - if(!SCompDecompress2(pExtTable + 1, &cbOutBuffer, pCompressed + 1, cbInBuffer)) + if(!SCompDecompress2((char *)(pExtTable + 1), &cbOutBuffer, (char *)(pCompressed + 1), cbInBuffer)) { STORM_FREE(pExtTable); pExtTable = NULL; @@ -1027,14 +502,20 @@ TMPQExtHeader * LoadExtTable( return pExtTable; } +// Used in MPQ Editor +void FreeMpqBuffer(void * pvBuffer) +{ + STORM_FREE(pvBuffer); +} + static int SaveMpqTable( - TMPQArchive * ha, - void * pMpqTable, - ULONGLONG ByteOffset, - size_t Size, - unsigned char * md5, - DWORD dwKey, - bool bCompress) + TMPQArchive * ha, + void * pMpqTable, + ULONGLONG ByteOffset, + size_t Size, + unsigned char * md5, + DWORD dwKey, + bool bCompress) { ULONGLONG FileOffset; void * pCompressed = NULL; @@ -1052,7 +533,7 @@ static int SaveMpqTable( return ERROR_NOT_ENOUGH_MEMORY; // Compress the table - SCompCompress(pCompressed, &cbOutBuffer, pMpqTable, cbInBuffer, MPQ_COMPRESSION_ZLIB, 0, 0); + SCompCompress((char *)pCompressed, &cbOutBuffer, (char *)pMpqTable, cbInBuffer, MPQ_COMPRESSION_ZLIB, 0, 0); // If the compression failed, revert it. Otherwise, swap the tables if(cbOutBuffer >= cbInBuffer) @@ -1093,17 +574,17 @@ static int SaveMpqTable( } static int SaveExtTable( - TMPQArchive * ha, - TMPQExtHeader * pExtTable, - ULONGLONG ByteOffset, - DWORD dwTableSize, - unsigned char * md5, - DWORD dwKey, - bool bCompress, - LPDWORD pcbTotalSize) + TMPQArchive * ha, + TMPQExtTable * pExtTable, + ULONGLONG ByteOffset, + DWORD dwTableSize, + unsigned char * md5, + DWORD dwKey, + bool bCompress, + LPDWORD pcbTotalSize) { ULONGLONG FileOffset; - TMPQExtHeader * pCompressed = NULL; + TMPQExtTable * pCompressed = NULL; DWORD cbTotalSize = 0; int nError = ERROR_SUCCESS; @@ -1114,7 +595,7 @@ static int SaveExtTable( int cbInBuffer = (int)dwTableSize; // Allocate extra space for compressed table - pCompressed = (TMPQExtHeader *)STORM_ALLOC(BYTE, dwTableSize); + pCompressed = (TMPQExtTable *)STORM_ALLOC(BYTE, dwTableSize); if(pCompressed == NULL) return ERROR_NOT_ENOUGH_MEMORY; @@ -1122,7 +603,7 @@ static int SaveExtTable( pCompressed->dwSignature = pExtTable->dwSignature; pCompressed->dwVersion = pExtTable->dwVersion; pCompressed->dwDataSize = pExtTable->dwDataSize; - SCompCompress((pCompressed + 1), &cbOutBuffer, (pExtTable + 1), cbInBuffer, MPQ_COMPRESSION_ZLIB, 0, 0); + SCompCompress((char *)(pCompressed + 1), &cbOutBuffer, (char *)(pExtTable + 1), cbInBuffer, MPQ_COMPRESSION_ZLIB, 0, 0); // If the compression failed, revert it. Otherwise, swap the tables if(cbOutBuffer >= cbInBuffer) @@ -1140,7 +621,7 @@ static int SaveExtTable( if(dwKey != 0) { BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); - EncryptMpqBlock(pExtTable + 1, (DWORD)(dwTableSize - sizeof(TMPQExtHeader)), dwKey); + EncryptMpqBlock(pExtTable + 1, (DWORD)(dwTableSize - sizeof(TMPQExtTable)), dwKey); BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); } @@ -1165,7 +646,7 @@ static int SaveExtTable( pExtTable, dwTableSize, ha->pHeader->dwRawChunkSize, - &cbTotalSize); + &cbTotalSize); } // Give the total written size, if needed @@ -1182,176 +663,103 @@ static int SaveExtTable( // Support for HET table static void CreateHetHeader( - TMPQHetTable * pHetTable, - TMPQHetHeader * pHetHeader) + TMPQHetTable * pHetTable, + PHET_TABLE_HEADER pHetHeader) { - // Fill the common header - pHetHeader->ExtHdr.dwSignature = HET_TABLE_SIGNATURE; - pHetHeader->ExtHdr.dwVersion = 1; - pHetHeader->ExtHdr.dwDataSize = 0; - - // Fill the HET header - pHetHeader->dwEntryCount = pHetTable->dwEntryCount; - pHetHeader->dwTotalCount = pHetTable->dwTotalCount; - pHetHeader->dwNameHashBitSize = pHetTable->dwNameHashBitSize; - pHetHeader->dwIndexSizeTotal = pHetTable->dwIndexSizeTotal; - pHetHeader->dwIndexSizeExtra = pHetTable->dwIndexSizeExtra; - pHetHeader->dwIndexSize = pHetTable->dwIndexSize; - pHetHeader->dwIndexTableSize = ((pHetHeader->dwIndexSizeTotal * pHetTable->dwTotalCount) + 7) / 8; + // Fill the BET header + pHetHeader->dwMaxFileCount = pHetTable->dwMaxFileCount; + pHetHeader->dwHashTableSize = pHetTable->dwHashTableSize; + pHetHeader->dwHashEntrySize = pHetTable->dwHashBitSize; + pHetHeader->dwIndexSizeTotal = GetNecessaryBitCount(pHetTable->dwMaxFileCount); + pHetHeader->dwIndexSizeExtra = 0; + pHetHeader->dwIndexSize = pHetHeader->dwIndexSizeTotal; + pHetHeader->dwIndexTableSize = ((pHetHeader->dwIndexSizeTotal * pHetTable->dwHashTableSize) + 7) / 8; // Calculate the total size needed for holding HET table - pHetHeader->ExtHdr.dwDataSize = - pHetHeader->dwTableSize = sizeof(TMPQHetHeader) - sizeof(TMPQExtHeader) + - pHetHeader->dwTotalCount + - pHetHeader->dwIndexTableSize; + pHetHeader->dwTableSize = sizeof(HET_TABLE_HEADER) + + pHetHeader->dwHashTableSize + + pHetHeader->dwIndexTableSize; } -TMPQHetTable * CreateHetTable(DWORD dwEntryCount, DWORD dwTotalCount, DWORD dwNameHashBitSize, LPBYTE pbSrcData) +TMPQHetTable * CreateHetTable(DWORD dwMaxFileCount, DWORD dwHashBitSize, bool bCreateEmpty) { TMPQHetTable * pHetTable; pHetTable = STORM_ALLOC(TMPQHetTable, 1); if(pHetTable != NULL) { - // Zero the HET table - memset(pHetTable, 0, sizeof(TMPQHetTable)); + pHetTable->dwIndexSizeTotal = 0; + pHetTable->dwIndexSizeExtra = 0; + pHetTable->dwIndexSize = pHetTable->dwIndexSizeTotal; + pHetTable->dwMaxFileCount = dwMaxFileCount; + pHetTable->dwHashTableSize = (dwMaxFileCount * 4 / 3); + pHetTable->dwHashBitSize = dwHashBitSize; - // Hash sizes less than 0x40 bits are not tested - assert(dwNameHashBitSize == 0x40); + // Size of one index is calculated from max file count + pHetTable->dwIndexSizeTotal = GetNecessaryBitCount(dwMaxFileCount); + pHetTable->dwIndexSizeExtra = 0; + pHetTable->dwIndexSize = pHetTable->dwIndexSizeTotal; + + // Allocate hash table + pHetTable->pHetHashes = STORM_ALLOC(BYTE, pHetTable->dwHashTableSize); + memset(pHetTable->pHetHashes, 0, pHetTable->dwHashTableSize); + + // If we shall create empty HET table, we have to allocate empty block index table as well + if(bCreateEmpty) + pHetTable->pBetIndexes = CreateBitArray(pHetTable->dwHashTableSize * pHetTable->dwIndexSizeTotal, 0xFF); // Calculate masks - pHetTable->AndMask64 = ((dwNameHashBitSize != 0x40) ? ((ULONGLONG)1 << dwNameHashBitSize) : 0) - 1; - pHetTable->OrMask64 = (ULONGLONG)1 << (dwNameHashBitSize - 1); + pHetTable->AndMask64 = 0; + if(dwHashBitSize != 0x40) + pHetTable->AndMask64 = (ULONGLONG)1 << dwHashBitSize; + pHetTable->AndMask64--; - // If the total count is not entered, use default - if(dwTotalCount == 0) - dwTotalCount = (dwEntryCount * 4) / 3; - - // Store the HET table parameters - pHetTable->dwEntryCount = dwEntryCount; - pHetTable->dwTotalCount = dwTotalCount; - pHetTable->dwNameHashBitSize = dwNameHashBitSize; - pHetTable->dwIndexSizeTotal = GetNecessaryBitCount(dwEntryCount); - pHetTable->dwIndexSizeExtra = 0; - pHetTable->dwIndexSize = pHetTable->dwIndexSizeTotal; - - // Allocate array of hashes - pHetTable->pNameHashes = STORM_ALLOC(BYTE, dwTotalCount); - if(pHetTable->pNameHashes != NULL) - { - // Make sure the data are initialized - memset(pHetTable->pNameHashes, 0, dwTotalCount); - - // Allocate the bit array for file indexes - pHetTable->pBetIndexes = CreateBitArray(dwTotalCount * pHetTable->dwIndexSizeTotal, 0xFF); - if(pHetTable->pBetIndexes != NULL) - { - // Initialize the HET table from the source data (if given) - if(pbSrcData != NULL) - { - // Copy the name hashes - memcpy(pHetTable->pNameHashes, pbSrcData, dwTotalCount); - - // Copy the file indexes - memcpy(pHetTable->pBetIndexes->Elements, pbSrcData + dwTotalCount, pHetTable->pBetIndexes->NumberOfBytes); - } - - // Return the result HET table - return pHetTable; - } - - // Free the name hashes - STORM_FREE(pHetTable->pNameHashes); - } - - STORM_FREE(pHetTable); + pHetTable->OrMask64 = (ULONGLONG)1 << (dwHashBitSize - 1); } - // Failed - return NULL; + return pHetTable; } -static int InsertHetEntry(TMPQHetTable * pHetTable, ULONGLONG FileNameHash, DWORD dwFileIndex) -{ - DWORD StartIndex; - DWORD Index; - BYTE NameHash1; - - // Get the start index and the high 8 bits of the name hash - StartIndex = Index = (DWORD)(FileNameHash % pHetTable->dwTotalCount); - NameHash1 = (BYTE)(FileNameHash >> (pHetTable->dwNameHashBitSize - 8)); - - // Find a place where to put it - for(;;) - { - // Did we find a free HET entry? - if(pHetTable->pNameHashes[Index] == HET_ENTRY_FREE) - { - // Set the entry in the name hash table - pHetTable->pNameHashes[Index] = NameHash1; - - // Set the entry in the file index table - SetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * Index, - pHetTable->dwIndexSize, - &dwFileIndex, - 4); - return ERROR_SUCCESS; - } - - // Move to the next entry in the HET table - // If we came to the start index again, we are done - Index = (Index + 1) % pHetTable->dwTotalCount; - if(Index == StartIndex) - break; - } - - // No space in the HET table. Should never happen, - // because the HET table is created according to the number of files - assert(false); - return ERROR_DISK_FULL; -} - -static TMPQHetTable * TranslateHetTable(TMPQHetHeader * pHetHeader) +static TMPQHetTable * TranslateHetTable(TMPQExtTable * pExtTable) { + HET_TABLE_HEADER HetHeader; TMPQHetTable * pHetTable = NULL; - LPBYTE pbSrcData = (LPBYTE)(pHetHeader + 1); + LPBYTE pbSrcData = (LPBYTE)(pExtTable + 1); // Sanity check - assert(pHetHeader->ExtHdr.dwSignature == HET_TABLE_SIGNATURE); - assert(pHetHeader->ExtHdr.dwVersion == 1); + assert(pExtTable->dwSignature == HET_TABLE_SIGNATURE); + assert(pExtTable->dwVersion == 1); // Verify size of the HET table - if(pHetHeader->ExtHdr.dwDataSize >= (sizeof(TMPQHetHeader) - sizeof(TMPQExtHeader))) + if(pExtTable != NULL && pExtTable->dwDataSize >= sizeof(HET_TABLE_HEADER)) { + // Copy the table header in order to have it aligned and swapped + memcpy(&HetHeader, pbSrcData, sizeof(HET_TABLE_HEADER)); + BSWAP_ARRAY32_UNSIGNED(&HetHeader, sizeof(HET_TABLE_HEADER)); + pbSrcData += sizeof(HET_TABLE_HEADER); + // Verify the size of the table in the header - if(pHetHeader->dwTableSize == pHetHeader->ExtHdr.dwDataSize) + if(HetHeader.dwTableSize == pExtTable->dwDataSize) { - // The size of the HET table must be sum of header, hash and index table size - assert((sizeof(TMPQHetHeader) - sizeof(TMPQExtHeader) + pHetHeader->dwTotalCount + pHetHeader->dwIndexTableSize) == pHetHeader->dwTableSize); - - // So far, all MPQs with HET Table have had total number of entries equal to 4/3 of file count - // Exception: "2010 - Starcraft II\!maps\Tya's Zerg Defense (unprotected).SC2Map" -// assert(((pHetHeader->dwEntryCount * 4) / 3) == pHetHeader->dwTotalCount); - - // The size of one index is predictable as well - assert(GetNecessaryBitCount(pHetHeader->dwEntryCount) == pHetHeader->dwIndexSizeTotal); - - // The size of index table (in entries) is expected - // to be the same like the hash table size (in bytes) - assert(((pHetHeader->dwTotalCount * pHetHeader->dwIndexSizeTotal) + 7) / 8 == pHetHeader->dwIndexTableSize); - // Create translated table - pHetTable = CreateHetTable(pHetHeader->dwEntryCount, pHetHeader->dwTotalCount, pHetHeader->dwNameHashBitSize, pbSrcData); + pHetTable = CreateHetTable(HetHeader.dwMaxFileCount, HetHeader.dwHashEntrySize, false); if(pHetTable != NULL) { - // Now the sizes in the hash table should be already set - assert(pHetTable->dwEntryCount == pHetHeader->dwEntryCount); - assert(pHetTable->dwTotalCount == pHetHeader->dwTotalCount); - assert(pHetTable->dwIndexSizeTotal == pHetHeader->dwIndexSizeTotal); + // Copy the hash table size, index size and extra bits from the HET header + pHetTable->dwHashTableSize = HetHeader.dwHashTableSize; + pHetTable->dwIndexSizeTotal = HetHeader.dwIndexSizeTotal; + pHetTable->dwIndexSizeExtra = HetHeader.dwIndexSizeExtra; - // Copy the missing variables - pHetTable->dwIndexSizeExtra = pHetHeader->dwIndexSizeExtra; - pHetTable->dwIndexSize = pHetHeader->dwIndexSize; + // Fill the hash table + if(pHetTable->pHetHashes != NULL) + memcpy(pHetTable->pHetHashes, pbSrcData, pHetTable->dwHashTableSize); + pbSrcData += pHetTable->dwHashTableSize; + + // Copy the block index table + pHetTable->pBetIndexes = CreateBitArray(HetHeader.dwIndexTableSize * 8, 0xFF); + if(pHetTable->pBetIndexes != NULL) + memcpy(pHetTable->pBetIndexes->Elements, pbSrcData, HetHeader.dwIndexTableSize); + pbSrcData += HetHeader.dwIndexTableSize; } } } @@ -1359,95 +767,110 @@ static TMPQHetTable * TranslateHetTable(TMPQHetHeader * pHetHeader) return pHetTable; } -static TMPQExtHeader * TranslateHetTable(TMPQHetTable * pHetTable, ULONGLONG * pcbHetTable) +static TMPQExtTable * TranslateHetTable(TMPQHetTable * pHetTable, ULONGLONG * pcbHetTable) { - TMPQHetHeader * pHetHeader = NULL; - TMPQHetHeader HetHeader; + TMPQExtTable * pExtTable = NULL; + HET_TABLE_HEADER HetHeader; LPBYTE pbLinearTable = NULL; LPBYTE pbTrgData; + size_t HetTableSize; // Prepare header of the HET table CreateHetHeader(pHetTable, &HetHeader); + // Calculate the total size needed for holding the encrypted HET table + HetTableSize = HetHeader.dwTableSize; + // Allocate space for the linear table - pbLinearTable = STORM_ALLOC(BYTE, sizeof(TMPQExtHeader) + HetHeader.dwTableSize); + pbLinearTable = STORM_ALLOC(BYTE, sizeof(TMPQExtTable) + HetTableSize); if(pbLinearTable != NULL) { - // Copy the table header - pHetHeader = (TMPQHetHeader *)pbLinearTable; - memcpy(pHetHeader, &HetHeader, sizeof(TMPQHetHeader)); - pbTrgData = (LPBYTE)(pHetHeader + 1); + // Create the common ext table header + pExtTable = (TMPQExtTable *)pbLinearTable; + pExtTable->dwSignature = HET_TABLE_SIGNATURE; + pExtTable->dwVersion = 1; + pExtTable->dwDataSize = (DWORD)HetTableSize; + pbTrgData = (LPBYTE)(pExtTable + 1); - // Copy the array of name hashes - memcpy(pbTrgData, pHetTable->pNameHashes, pHetTable->dwTotalCount); - pbTrgData += pHetTable->dwTotalCount; + // Copy the HET table header + memcpy(pbTrgData, &HetHeader, sizeof(HET_TABLE_HEADER)); + BSWAP_ARRAY32_UNSIGNED(pbTrgData, sizeof(HET_TABLE_HEADER)); + pbTrgData += sizeof(HET_TABLE_HEADER); + + // Copy the array of HET hashes + memcpy(pbTrgData, pHetTable->pHetHashes, pHetTable->dwHashTableSize); + pbTrgData += pHetTable->dwHashTableSize; // Copy the bit array of BET indexes memcpy(pbTrgData, pHetTable->pBetIndexes->Elements, HetHeader.dwIndexTableSize); - // Calculate the total size of the table, including the TMPQExtHeader + // Calculate the total size of the table, including the TMPQExtTable if(pcbHetTable != NULL) { - *pcbHetTable = (ULONGLONG)(sizeof(TMPQExtHeader) + HetHeader.dwTableSize); + *pcbHetTable = (ULONGLONG)(sizeof(TMPQExtTable) + HetTableSize); } } - // Keep Coverity happy - assert((TMPQExtHeader *)&pHetHeader->ExtHdr == (TMPQExtHeader *)pbLinearTable); - return (TMPQExtHeader *)pbLinearTable; + return pExtTable; } -static DWORD GetFileIndex_Het(TMPQArchive * ha, const char * szFileName) +DWORD GetFileIndex_Het(TMPQArchive * ha, const char * szFileName) { TMPQHetTable * pHetTable = ha->pHetTable; ULONGLONG FileNameHash; + ULONGLONG AndMask64; + ULONGLONG OrMask64; + ULONGLONG BetHash; DWORD StartIndex; DWORD Index; - BYTE NameHash1; // Upper 8 bits of the masked file name hash - - // If there are no entries in the HET table, do nothing - if(pHetTable->dwEntryCount == 0) - return HASH_ENTRY_FREE; + BYTE HetHash; // Upper 8 bits of the masked file name hash // Do nothing if the MPQ has no HET table assert(ha->pHetTable != NULL); // Calculate 64-bit hash of the file name - FileNameHash = (HashStringJenkins(szFileName) & pHetTable->AndMask64) | pHetTable->OrMask64; + AndMask64 = pHetTable->AndMask64; + OrMask64 = pHetTable->OrMask64; + FileNameHash = (HashStringJenkins(szFileName) & AndMask64) | OrMask64; // Split the file name hash into two parts: - // NameHash1: The highest 8 bits of the name hash - // NameHash2: File name hash limited to hash size - // Note: Our file table contains full name hash, no need to cut the high 8 bits before comparison - NameHash1 = (BYTE)(FileNameHash >> (pHetTable->dwNameHashBitSize - 8)); + // Part 1: The highest 8 bits of the name hash + // Part 2: The rest of the name hash (without the highest 8 bits) + HetHash = (BYTE)(FileNameHash >> (pHetTable->dwHashBitSize - 8)); + BetHash = FileNameHash & (AndMask64 >> 0x08); // Calculate the starting index to the hash table - StartIndex = Index = (DWORD)(FileNameHash % pHetTable->dwTotalCount); + StartIndex = Index = (DWORD)(FileNameHash % pHetTable->dwHashTableSize); // Go through HET table until we find a terminator - while(pHetTable->pNameHashes[Index] != HET_ENTRY_FREE) + while(pHetTable->pHetHashes[Index] != HET_ENTRY_FREE) { - // Did we find a match ? - if(pHetTable->pNameHashes[Index] == NameHash1) + // Did we find match ? + if(pHetTable->pHetHashes[Index] == HetHash) { DWORD dwFileIndex = 0; - // Get the file index + // Get the index of the BetHash GetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * Index, pHetTable->dwIndexSize, - &dwFileIndex, - sizeof(DWORD)); + &dwFileIndex, + 4); - // Verify the FileNameHash against the entry in the table of name hashes - if(dwFileIndex <= ha->dwFileTableSize && ha->pFileTable[dwFileIndex].FileNameHash == FileNameHash) - { + // + // TODO: This condition only happens when we are opening a MPQ + // where some files were deleted by StormLib. Perhaps + // we should not allow shrinking of the file table in MPQs v 4.0? + // assert(dwFileIndex <= ha->dwFileTableSize); + // + + // Verify the BetHash against the entry in the table of BET hashes + if(dwFileIndex <= ha->dwFileTableSize && ha->pFileTable[dwFileIndex].BetHash == BetHash) return dwFileIndex; - } } - // Move to the next entry in the HET table + // Move to the next entry in the primary search table // If we came to the start index again, we are done - Index = (Index + 1) % pHetTable->dwTotalCount; + Index = (Index + 1) % pHetTable->dwHashTableSize; if(Index == StartIndex) break; } @@ -1456,12 +879,94 @@ static DWORD GetFileIndex_Het(TMPQArchive * ha, const char * szFileName) return HASH_ENTRY_FREE; } +DWORD AllocateHetEntry( + TMPQArchive * ha, + TFileEntry * pFileEntry) +{ + TMPQHetTable * pHetTable = ha->pHetTable; + ULONGLONG FileNameHash; + ULONGLONG AndMask64; + ULONGLONG OrMask64; + ULONGLONG BetHash; + DWORD FreeHetIndex = HASH_ENTRY_FREE; + DWORD dwFileIndex; + DWORD StartIndex; + DWORD Index; + BYTE HetHash; // Upper 8 bits of the masked file name hash + + // Do nothing if the MPQ has no HET table + assert(ha->pHetTable != NULL); + + // Calculate 64-bit hash of the file name + AndMask64 = pHetTable->AndMask64; + OrMask64 = pHetTable->OrMask64; + FileNameHash = (HashStringJenkins(pFileEntry->szFileName) & AndMask64) | OrMask64; + + // Calculate the starting index to the hash table + StartIndex = Index = (DWORD)(FileNameHash % pHetTable->dwHashTableSize); + + // Split the file name hash into two parts: + // Part 1: The highest 8 bits of the name hash + // Part 2: The rest of the name hash (without the highest 8 bits) + HetHash = (BYTE)(FileNameHash >> (pHetTable->dwHashBitSize - 8)); + BetHash = FileNameHash & (AndMask64 >> 0x08); + + // Go through HET table until we find a terminator + for(;;) + { + // Check for entries that might have been deleted + if(pHetTable->pHetHashes[Index] == HET_ENTRY_DELETED) + { + DWORD dwInvalidBetIndex = (1 << pHetTable->dwIndexSizeTotal) - 1; + DWORD dwBetIndex = 0; + + // Verify the BET index. If it's really free, we can use it + dwFileIndex = (DWORD)(pFileEntry - ha->pFileTable); + GetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * Index, + pHetTable->dwIndexSize, + &dwBetIndex, + 4); + + if(dwBetIndex == dwInvalidBetIndex) + { + FreeHetIndex = Index; + break; + } + } + + // Is that entry free ? + if(pHetTable->pHetHashes[Index] == HET_ENTRY_FREE) + { + FreeHetIndex = Index; + break; + } + + // Move to the next entry in the primary search table + // If we came to the start index again, we are done + Index = (Index + 1) % pHetTable->dwHashTableSize; + if(Index == StartIndex) + return HASH_ENTRY_FREE; + } + + // Fill the HET table entry + dwFileIndex = (DWORD)(pFileEntry - ha->pFileTable); + pHetTable->pHetHashes[FreeHetIndex] = HetHash; + SetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * FreeHetIndex, + pHetTable->dwIndexSize, + &dwFileIndex, + 4); + // Fill the file entry + pFileEntry->BetHash = BetHash; + pFileEntry->dwHetIndex = FreeHetIndex; + return FreeHetIndex; +} + void FreeHetTable(TMPQHetTable * pHetTable) { if(pHetTable != NULL) { - if(pHetTable->pNameHashes != NULL) - STORM_FREE(pHetTable->pNameHashes); + if(pHetTable->pHetHashes != NULL) + STORM_FREE(pHetTable->pHetHashes); if(pHetTable->pBetIndexes != NULL) STORM_FREE(pHetTable->pBetIndexes); @@ -1473,8 +978,8 @@ void FreeHetTable(TMPQHetTable * pHetTable) // Support for BET table static void CreateBetHeader( - TMPQArchive * ha, - TMPQBetHeader * pBetHeader) + TMPQArchive * ha, + PBET_TABLE_HEADER pBetHeader) { TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; TFileEntry * pFileEntry; @@ -1488,19 +993,9 @@ static void CreateBetHeader( // Initialize array of flag combinations InitFileFlagArray(FlagArray); - // Fill the common header - pBetHeader->ExtHdr.dwSignature = BET_TABLE_SIGNATURE; - pBetHeader->ExtHdr.dwVersion = 1; - pBetHeader->ExtHdr.dwDataSize = 0; - // Get the maximum values for the BET table - pFileTableEnd = ha->pFileTable + ha->pHeader->dwBlockTableSize; for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) { - // - // Note: Deleted files must be counted as well - // - // Highest file position in the MPQ if(pFileEntry->ByteOffset > MaxByteOffset) MaxByteOffset = pFileEntry->ByteOffset; @@ -1537,31 +1032,30 @@ static void CreateBetHeader( // Calculate the total size of one entry pBetHeader->dwTableEntrySize = pBetHeader->dwBitCount_FilePos + - pBetHeader->dwBitCount_FileSize + - pBetHeader->dwBitCount_CmpSize + - pBetHeader->dwBitCount_FlagIndex + - pBetHeader->dwBitCount_Unknown; + pBetHeader->dwBitCount_FileSize + + pBetHeader->dwBitCount_CmpSize + + pBetHeader->dwBitCount_FlagIndex + + pBetHeader->dwBitCount_Unknown; // Save the file count and flag count - pBetHeader->dwEntryCount = ha->pHeader->dwBlockTableSize; + pBetHeader->dwFileCount = ha->dwFileTableSize; pBetHeader->dwFlagCount = dwMaxFlagIndex + 1; pBetHeader->dwUnknown08 = 0x10; // Save the total size of the BET hash - pBetHeader->dwBitTotal_NameHash2 = ha->pHetTable->dwNameHashBitSize - 0x08; - pBetHeader->dwBitExtra_NameHash2 = 0; - pBetHeader->dwBitCount_NameHash2 = pBetHeader->dwBitTotal_NameHash2; - pBetHeader->dwNameHashArraySize = ((pBetHeader->dwBitTotal_NameHash2 * pBetHeader->dwEntryCount) + 7) / 8; + pBetHeader->dwBetHashSizeTotal = ha->pHetTable->dwHashBitSize - 0x08; + pBetHeader->dwBetHashSizeExtra = 0; + pBetHeader->dwBetHashSize = pBetHeader->dwBetHashSizeTotal; + pBetHeader->dwBetHashArraySize = ((pBetHeader->dwBetHashSizeTotal * pBetHeader->dwFileCount) + 7) / 8; // Save the total table size - pBetHeader->ExtHdr.dwDataSize = - pBetHeader->dwTableSize = sizeof(TMPQBetHeader) - sizeof(TMPQExtHeader) + - pBetHeader->dwFlagCount * sizeof(DWORD) + - ((pBetHeader->dwTableEntrySize * pBetHeader->dwEntryCount) + 7) / 8 + - pBetHeader->dwNameHashArraySize; + pBetHeader->dwTableSize = sizeof(BET_TABLE_HEADER) + + pBetHeader->dwFlagCount * sizeof(DWORD) + + ((pBetHeader->dwTableEntrySize * pBetHeader->dwFileCount) + 7) / 8 + + pBetHeader->dwBetHashArraySize; } -TMPQBetTable * CreateBetTable(DWORD dwEntryCount) +TMPQBetTable * CreateBetTable(DWORD dwFileCount) { TMPQBetTable * pBetTable; @@ -1570,102 +1064,101 @@ TMPQBetTable * CreateBetTable(DWORD dwEntryCount) if(pBetTable != NULL) { memset(pBetTable, 0, sizeof(TMPQBetTable)); - pBetTable->dwEntryCount = dwEntryCount; + pBetTable->dwFileCount = dwFileCount; } return pBetTable; } static TMPQBetTable * TranslateBetTable( - TMPQArchive * ha, - TMPQBetHeader * pBetHeader) + TMPQArchive * ha, + TMPQExtTable * pExtTable) { + BET_TABLE_HEADER BetHeader; TMPQBetTable * pBetTable = NULL; - LPBYTE pbSrcData = (LPBYTE)(pBetHeader + 1); - DWORD LengthInBytes = 0; + LPBYTE pbSrcData = (LPBYTE)(pExtTable + 1); + DWORD LengthInBytes; // Sanity check - assert(pBetHeader->ExtHdr.dwSignature == BET_TABLE_SIGNATURE); - assert(pBetHeader->ExtHdr.dwVersion == 1); + assert(pExtTable->dwSignature == BET_TABLE_SIGNATURE); + assert(pExtTable->dwVersion == 1); assert(ha->pHetTable != NULL); ha = ha; // Verify size of the HET table - if(pBetHeader->ExtHdr.dwDataSize >= (sizeof(TMPQBetHeader) - sizeof(TMPQExtHeader))) + if(pExtTable != NULL && pExtTable->dwDataSize >= sizeof(BET_TABLE_HEADER)) { + // Copy the table header in order to have it aligned and swapped + memcpy(&BetHeader, pbSrcData, sizeof(BET_TABLE_HEADER)); + BSWAP_ARRAY32_UNSIGNED(&BetHeader, sizeof(BET_TABLE_HEADER)); + pbSrcData += sizeof(BET_TABLE_HEADER); + + // Some MPQs affected by a bug in StormLib have pBetTable->dwFileCount + // greater than ha->dwMaxFileCount + if(BetHeader.dwFileCount > ha->dwMaxFileCount) + return NULL; + // Verify the size of the table in the header - if(pBetHeader->dwTableSize == pBetHeader->ExtHdr.dwDataSize) + if(BetHeader.dwTableSize == pExtTable->dwDataSize) { - // The number of entries in the BET table must be the same like number of entries in the block table - assert(pBetHeader->dwEntryCount == ha->pHeader->dwBlockTableSize); - assert(pBetHeader->dwEntryCount <= ha->dwMaxFileCount); - - // The number of entries in the BET table must be the same like number of entries in the HET table - // Note that if it's not, it is not a problem - //assert(pBetHeader->dwEntryCount == ha->pHetTable->dwEntryCount); - // Create translated table - pBetTable = CreateBetTable(pBetHeader->dwEntryCount); + pBetTable = CreateBetTable(BetHeader.dwFileCount); if(pBetTable != NULL) { // Copy the variables from the header to the BetTable - pBetTable->dwTableEntrySize = pBetHeader->dwTableEntrySize; - pBetTable->dwBitIndex_FilePos = pBetHeader->dwBitIndex_FilePos; - pBetTable->dwBitIndex_FileSize = pBetHeader->dwBitIndex_FileSize; - pBetTable->dwBitIndex_CmpSize = pBetHeader->dwBitIndex_CmpSize; - pBetTable->dwBitIndex_FlagIndex = pBetHeader->dwBitIndex_FlagIndex; - pBetTable->dwBitIndex_Unknown = pBetHeader->dwBitIndex_Unknown; - pBetTable->dwBitCount_FilePos = pBetHeader->dwBitCount_FilePos; - pBetTable->dwBitCount_FileSize = pBetHeader->dwBitCount_FileSize; - pBetTable->dwBitCount_CmpSize = pBetHeader->dwBitCount_CmpSize; - pBetTable->dwBitCount_FlagIndex = pBetHeader->dwBitCount_FlagIndex; - pBetTable->dwBitCount_Unknown = pBetHeader->dwBitCount_Unknown; + pBetTable->dwTableEntrySize = BetHeader.dwTableEntrySize; + pBetTable->dwBitIndex_FilePos = BetHeader.dwBitIndex_FilePos; + pBetTable->dwBitIndex_FileSize = BetHeader.dwBitIndex_FileSize; + pBetTable->dwBitIndex_CmpSize = BetHeader.dwBitIndex_CmpSize; + pBetTable->dwBitIndex_FlagIndex = BetHeader.dwBitIndex_FlagIndex; + pBetTable->dwBitIndex_Unknown = BetHeader.dwBitIndex_Unknown; + pBetTable->dwBitCount_FilePos = BetHeader.dwBitCount_FilePos; + pBetTable->dwBitCount_FileSize = BetHeader.dwBitCount_FileSize; + pBetTable->dwBitCount_CmpSize = BetHeader.dwBitCount_CmpSize; + pBetTable->dwBitCount_FlagIndex = BetHeader.dwBitCount_FlagIndex; + pBetTable->dwBitCount_Unknown = BetHeader.dwBitCount_Unknown; - // Since we don't know what the "unknown" is, we'll assert when it's zero + // Since we don't know what the "unknown" is, we'll assert when it's nonzero assert(pBetTable->dwBitCount_Unknown == 0); // Allocate array for flags - if(pBetHeader->dwFlagCount != 0) + if(BetHeader.dwFlagCount != 0) { // Allocate array for file flags and load it - pBetTable->pFileFlags = STORM_ALLOC(DWORD, pBetHeader->dwFlagCount); + pBetTable->pFileFlags = STORM_ALLOC(DWORD, BetHeader.dwFlagCount); if(pBetTable->pFileFlags != NULL) { - LengthInBytes = pBetHeader->dwFlagCount * sizeof(DWORD); + LengthInBytes = BetHeader.dwFlagCount * sizeof(DWORD); memcpy(pBetTable->pFileFlags, pbSrcData, LengthInBytes); BSWAP_ARRAY32_UNSIGNED(pBetTable->pFileFlags, LengthInBytes); pbSrcData += LengthInBytes; } // Save the number of flags - pBetTable->dwFlagCount = pBetHeader->dwFlagCount; + pBetTable->dwFlagCount = BetHeader.dwFlagCount; } // Load the bit-based file table - pBetTable->pFileTable = CreateBitArray(pBetTable->dwTableEntrySize * pBetHeader->dwEntryCount, 0); + pBetTable->pFileTable = CreateBitArray(pBetTable->dwTableEntrySize * BetHeader.dwFileCount, 0); + LengthInBytes = (pBetTable->pFileTable->NumberOfBits + 7) / 8; if(pBetTable->pFileTable != NULL) - { - LengthInBytes = (pBetTable->pFileTable->NumberOfBits + 7) / 8; memcpy(pBetTable->pFileTable->Elements, pbSrcData, LengthInBytes); - pbSrcData += LengthInBytes; - } + pbSrcData += LengthInBytes; // Fill the sizes of BET hash - pBetTable->dwBitTotal_NameHash2 = pBetHeader->dwBitTotal_NameHash2; - pBetTable->dwBitExtra_NameHash2 = pBetHeader->dwBitExtra_NameHash2; - pBetTable->dwBitCount_NameHash2 = pBetHeader->dwBitCount_NameHash2; - + pBetTable->dwBetHashSizeTotal = BetHeader.dwBetHashSizeTotal; + pBetTable->dwBetHashSizeExtra = BetHeader.dwBetHashSizeExtra; + pBetTable->dwBetHashSize = BetHeader.dwBetHashSize; + // Create and load the array of BET hashes - pBetTable->pNameHashes = CreateBitArray(pBetTable->dwBitTotal_NameHash2 * pBetHeader->dwEntryCount, 0); - if(pBetTable->pNameHashes != NULL) - { - LengthInBytes = (pBetTable->pNameHashes->NumberOfBits + 7) / 8; - memcpy(pBetTable->pNameHashes->Elements, pbSrcData, LengthInBytes); -// pbSrcData += LengthInBytes; - } + pBetTable->pBetHashes = CreateBitArray(pBetTable->dwBetHashSizeTotal * BetHeader.dwFileCount, 0); + LengthInBytes = (pBetTable->pBetHashes->NumberOfBits + 7) / 8; + if(pBetTable->pBetHashes != NULL) + memcpy(pBetTable->pBetHashes->Elements, pbSrcData, LengthInBytes); + pbSrcData += BetHeader.dwBetHashArraySize; // Dump both tables -// DumpHetAndBetTable(ha->pHetTable, pBetTable); + // DumpHetAndBetTable(ha->pHetTable, pBetTable); } } } @@ -1673,67 +1166,82 @@ static TMPQBetTable * TranslateBetTable( return pBetTable; } -TMPQExtHeader * TranslateBetTable( - TMPQArchive * ha, - ULONGLONG * pcbBetTable) +TMPQExtTable * TranslateBetTable( + TMPQArchive * ha, + ULONGLONG * pcbBetTable) { - TMPQBetHeader * pBetHeader = NULL; - TMPQBetHeader BetHeader; - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; + TMPQExtTable * pExtTable = NULL; + BET_TABLE_HEADER BetHeader; TBitArray * pBitArray = NULL; LPBYTE pbLinearTable = NULL; LPBYTE pbTrgData; + size_t BetTableSize; DWORD LengthInBytes; DWORD FlagArray[MAX_FLAG_INDEX]; + DWORD i; // Calculate the bit sizes of various entries InitFileFlagArray(FlagArray); CreateBetHeader(ha, &BetHeader); + // Calculate the size of the BET table + BetTableSize = sizeof(BET_TABLE_HEADER) + + BetHeader.dwFlagCount * sizeof(DWORD) + + ((BetHeader.dwTableEntrySize * BetHeader.dwFileCount) + 7) / 8 + + BetHeader.dwBetHashArraySize; + // Allocate space - pbLinearTable = STORM_ALLOC(BYTE, sizeof(TMPQExtHeader) + BetHeader.dwTableSize); + pbLinearTable = STORM_ALLOC(BYTE, sizeof(TMPQExtTable) + BetTableSize); if(pbLinearTable != NULL) { - // Copy the BET header to the linear buffer - pBetHeader = (TMPQBetHeader *)pbLinearTable; - memcpy(pBetHeader, &BetHeader, sizeof(TMPQBetHeader)); - pbTrgData = (LPBYTE)(pBetHeader + 1); + // Create the common ext table header + pExtTable = (TMPQExtTable *)pbLinearTable; + pExtTable->dwSignature = BET_TABLE_SIGNATURE; + pExtTable->dwVersion = 1; + pExtTable->dwDataSize = (DWORD)BetTableSize; + pbTrgData = (LPBYTE)(pExtTable + 1); + + // Copy the BET table header + memcpy(pbTrgData, &BetHeader, sizeof(BET_TABLE_HEADER)); + BSWAP_ARRAY32_UNSIGNED(pbTrgData, sizeof(BET_TABLE_HEADER)); + pbTrgData += sizeof(BET_TABLE_HEADER); // Save the bit-based block table - pBitArray = CreateBitArray(BetHeader.dwEntryCount * BetHeader.dwTableEntrySize, 0); + pBitArray = CreateBitArray(BetHeader.dwFileCount * BetHeader.dwTableEntrySize, 0); if(pBitArray != NULL) { + TFileEntry * pFileEntry = ha->pFileTable; DWORD dwFlagIndex = 0; DWORD nBitOffset = 0; - // Construct the bit-based file table - pFileTableEnd = ha->pFileTable + BetHeader.dwEntryCount; - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) + // Construct the array of flag values and bit-based file table + for(i = 0; i < BetHeader.dwFileCount; i++, pFileEntry++) { // - // Note: Missing files must be included as well + // Note: Blizzard MPQs contain valid values even for non-existant files + // (FilePos, FileSize, CmpSize and FlagIndex) + // Note: If flags is zero, it must be in the flag table too !!! // // Save the byte offset SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_FilePos, BetHeader.dwBitCount_FilePos, - &pFileEntry->ByteOffset, + &pFileEntry->ByteOffset, 8); SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_FileSize, BetHeader.dwBitCount_FileSize, - &pFileEntry->dwFileSize, + &pFileEntry->dwFileSize, 4); SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_CmpSize, BetHeader.dwBitCount_CmpSize, - &pFileEntry->dwCmpSize, + &pFileEntry->dwCmpSize, 4); // Save the flag index dwFlagIndex = GetFileFlagIndex(FlagArray, pFileEntry->dwFlags); SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_FlagIndex, BetHeader.dwBitCount_FlagIndex, - &dwFlagIndex, + &dwFlagIndex, 4); // Move the bit offset @@ -1755,28 +1263,39 @@ TMPQExtHeader * TranslateBetTable( STORM_FREE(pBitArray); } - // Create bit array for name hashes - pBitArray = CreateBitArray(BetHeader.dwBitTotal_NameHash2 * BetHeader.dwEntryCount, 0); + // Create bit array for BET hashes + pBitArray = CreateBitArray(BetHeader.dwBetHashSizeTotal * BetHeader.dwFileCount, 0); if(pBitArray != NULL) { - DWORD dwFileIndex = 0; + TFileEntry * pFileEntry = ha->pFileTable; + ULONGLONG AndMask64 = ha->pHetTable->AndMask64; + ULONGLONG OrMask64 = ha->pHetTable->OrMask64; - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) + for(i = 0; i < BetHeader.dwFileCount; i++) { + ULONGLONG FileNameHash = 0; + + // Calculate 64-bit hash of the file name + if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && pFileEntry->szFileName != NULL) + { + FileNameHash = (HashStringJenkins(pFileEntry->szFileName) & AndMask64) | OrMask64; + FileNameHash = FileNameHash & (AndMask64 >> 0x08); + } + // Insert the name hash to the bit array - SetBits(pBitArray, BetHeader.dwBitTotal_NameHash2 * dwFileIndex, - BetHeader.dwBitCount_NameHash2, - &pFileEntry->FileNameHash, + SetBits(pBitArray, BetHeader.dwBetHashSizeTotal * i, + BetHeader.dwBetHashSize, + &FileNameHash, 8); - - assert(dwFileIndex < BetHeader.dwEntryCount); - dwFileIndex++; + + // Move to the next file entry + pFileEntry++; } // Write the array of BET hashes LengthInBytes = (pBitArray->NumberOfBits + 7) / 8; memcpy(pbTrgData, pBitArray->Elements, LengthInBytes); -// pbTrgData += LengthInBytes; + pbTrgData += LengthInBytes; // Free the bit array STORM_FREE(pBitArray); @@ -1785,13 +1304,11 @@ TMPQExtHeader * TranslateBetTable( // Write the size of the BET table in the MPQ if(pcbBetTable != NULL) { - *pcbBetTable = (ULONGLONG)(sizeof(TMPQExtHeader) + BetHeader.dwTableSize); + *pcbBetTable = (ULONGLONG)(sizeof(TMPQExtTable) + BetTableSize); } } - // Keep Coverity happy - assert((TMPQExtHeader *)&pBetHeader->ExtHdr == (TMPQExtHeader *)pbLinearTable); - return (TMPQExtHeader *)pbLinearTable; + return pExtTable; } void FreeBetTable(TMPQBetTable * pBetTable) @@ -1802,8 +1319,8 @@ void FreeBetTable(TMPQBetTable * pBetTable) STORM_FREE(pBetTable->pFileTable); if(pBetTable->pFileFlags != NULL) STORM_FREE(pBetTable->pFileFlags); - if(pBetTable->pNameHashes != NULL) - STORM_FREE(pBetTable->pNameHashes); + if(pBetTable->pBetHashes != NULL) + STORM_FREE(pBetTable->pBetHashes); STORM_FREE(pBetTable); } @@ -1812,25 +1329,11 @@ void FreeBetTable(TMPQBetTable * pBetTable) //----------------------------------------------------------------------------- // Support for file table -TFileEntry * GetFileEntryLocale2(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex) +TFileEntry * GetFileEntryAny(TMPQArchive * ha, const char * szFileName) { TMPQHash * pHash; DWORD dwFileIndex; - // First, we have to search the classic hash table - // This is because on renaming, deleting, or changing locale, - // we will need the pointer to hash table entry - if(ha->pHashTable != NULL) - { - pHash = GetHashEntryLocale(ha, szFileName, lcLocale, 0); - if(pHash != NULL && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - { - if(PtrHashIndex != NULL) - PtrHashIndex[0] = (DWORD)(pHash - ha->pHashTable); - return ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - } - } - // If we have HET table in the MPQ, try to find the file in HET table if(ha->pHetTable != NULL) { @@ -1839,49 +1342,77 @@ TFileEntry * GetFileEntryLocale2(TMPQArchive * ha, const char * szFileName, LCID return ha->pFileTable + dwFileIndex; } + // Otherwise, perform the file search in the classic hash table + if(ha->pHashTable != NULL) + { + pHash = GetHashEntryAny(ha, szFileName); + if(pHash != NULL && pHash->dwBlockIndex < ha->dwFileTableSize) + return ha->pFileTable + pHash->dwBlockIndex; + } + // Not found return NULL; } TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale) -{ - return GetFileEntryLocale2(ha, szFileName, lcLocale, NULL); -} - -TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex) { TMPQHash * pHash; DWORD dwFileIndex; - // If the hash table is present, find the entry from hash table - if(ha->pHashTable != NULL) - { - pHash = GetHashEntryExact(ha, szFileName, lcLocale); - if(pHash != NULL && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - { - if(PtrHashIndex != NULL) - PtrHashIndex[0] = (DWORD)(pHash - ha->pHashTable); - return ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - } - } - // If we have HET table in the MPQ, try to find the file in HET table if(ha->pHetTable != NULL) { dwFileIndex = GetFileIndex_Het(ha, szFileName); if(dwFileIndex != HASH_ENTRY_FREE) - { - if(PtrHashIndex != NULL) - PtrHashIndex[0] = HASH_ENTRY_FREE; return ha->pFileTable + dwFileIndex; - } } - + + // Otherwise, perform the file search in the classic hash table + if(ha->pHashTable != NULL) + { + pHash = GetHashEntryLocale(ha, szFileName, lcLocale); + if(pHash != NULL && pHash->dwBlockIndex < ha->dwFileTableSize) + return ha->pFileTable + pHash->dwBlockIndex; + } + // Not found return NULL; } -void AllocateFileName(TMPQArchive * ha, TFileEntry * pFileEntry, const char * szFileName) +TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale) +{ + TMPQHash * pHash; + DWORD dwFileIndex; + + // If we have HET table in the MPQ, try to find the file in HET table + if(ha->pHetTable != NULL) + { + dwFileIndex = GetFileIndex_Het(ha, szFileName); + if(dwFileIndex != HASH_ENTRY_FREE) + return ha->pFileTable + dwFileIndex; + } + + // Otherwise, perform the file search in the classic hash table + if(ha->pHashTable != NULL) + { + pHash = GetHashEntryExact(ha, szFileName, lcLocale); + if(pHash != NULL && pHash->dwBlockIndex < ha->dwFileTableSize) + return ha->pFileTable + pHash->dwBlockIndex; + } + + // Not found + return NULL; +} + +TFileEntry * GetFileEntryByIndex(TMPQArchive * ha, DWORD dwIndex) +{ + // For MPQs with classic hash table + if(dwIndex < ha->dwFileTableSize) + return ha->pFileTable + dwIndex; + return NULL; +} + +void AllocateFileName(TFileEntry * pFileEntry, const char * szFileName) { // Sanity check assert(pFileEntry != NULL); @@ -1901,114 +1432,170 @@ void AllocateFileName(TMPQArchive * ha, TFileEntry * pFileEntry, const char * sz if(pFileEntry->szFileName != NULL) strcpy(pFileEntry->szFileName, szFileName); } - - // We also need to create the file name hash - if(ha->pHetTable != NULL) - { - ULONGLONG AndMask64 = ha->pHetTable->AndMask64; - ULONGLONG OrMask64 = ha->pHetTable->OrMask64; - - pFileEntry->FileNameHash = (HashStringJenkins(szFileName) & AndMask64) | OrMask64; - } } -TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex) + +// Finds a free file entry. Does NOT increment table size. +TFileEntry * FindFreeFileEntry(TMPQArchive * ha) { TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; TFileEntry * pFreeEntry = NULL; TFileEntry * pFileEntry; - TMPQHash * pHash = NULL; - DWORD dwReservedFiles = ha->dwReservedFiles; - DWORD dwFreeCount = 0; - // Sanity check: File table size must be greater or equal to max file count - assert(ha->dwFileTableSize >= ha->dwMaxFileCount); - - // If we are saving MPQ tables, we don't tale number of reserved files into account - dwReservedFiles = (ha->dwFlags & MPQ_FLAG_SAVING_TABLES) ? 0 : ha->dwReservedFiles; - - // Now find a free entry in the file table. - // Note that in the case when free entries are in the middle, - // we need to use these + // Try to find a free entry for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) { + // If that entry is free, we reuse it if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0) { - // Remember the first free entry - if(pFreeEntry == NULL) - pFreeEntry = pFileEntry; - dwFreeCount++; - - // If the number of free items is greater than number - // of reserved items, We can add the file - if(dwFreeCount > dwReservedFiles) - break; + pFreeEntry = pFileEntry; + break; + } + + // + // Note: Files with "delete marker" are not deleted. + // Don't consider them free entries + // + } + + // Do we have a deleted entry? + if(pFreeEntry != NULL) + { + ClearFileEntry(ha, pFreeEntry); + return pFreeEntry; + } + + // If no file entry within the existing file table is free, + // we try the reserve space after current file table + if(ha->dwFileTableSize < ha->dwMaxFileCount) + return ha->pFileTable + ha->dwFileTableSize; + + // If we reached maximum file count, we cannot add more files to the MPQ + assert(ha->dwFileTableSize == ha->dwMaxFileCount); + return NULL; +} + + +TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale) +{ + TFileEntry * pFileEntry = NULL; + TMPQHash * pHash; + DWORD dwHashIndex; + DWORD dwFileIndex; + bool bHashEntryExists = false; + bool bHetEntryExists = false; + + // If the archive has classic hash table, we try to + // find the file in the hash table + if(ha->pHashTable != NULL) + { + // If the hash entry is already there, we reuse the file entry + pHash = GetHashEntryExact(ha, szFileName, lcLocale); + if(pHash != NULL) + { + pFileEntry = ha->pFileTable + pHash->dwBlockIndex; + bHashEntryExists = true; } } - // If the total number of free entries is less than number of reserved files, - // we cannot add the file to the archive - if(pFreeEntry == NULL || dwFreeCount <= dwReservedFiles) - return NULL; - - // Initialize the file entry and set its file name - memset(pFreeEntry, 0, sizeof(TFileEntry)); - AllocateFileName(ha, pFreeEntry, szFileName); - - // If the archive has a hash table, we need to first free entry there - if(ha->pHashTable != NULL) - { - // Make sure that the entry is not there yet - assert(GetHashEntryExact(ha, szFileName, lcLocale) == NULL); - - // Find a free hash table entry for the name - pHash = AllocateHashEntry(ha, pFreeEntry, lcLocale); - if(pHash == NULL) - return NULL; - - // Set the file index to the hash table - pHash->dwBlockIndex = (DWORD)(pFreeEntry - ha->pFileTable); - PtrHashIndex[0] = (DWORD)(pHash - ha->pHashTable); - } - - // If the archive has a HET table, just do some checks - // Note: Don't bother modifying the HET table. It will be rebuilt from scratch after, anyway + // If the archive has HET table, try to use it for + // finding the file if(ha->pHetTable != NULL) { - assert(GetFileIndex_Het(ha, szFileName) == HASH_ENTRY_FREE); + dwFileIndex = GetFileIndex_Het(ha, szFileName); + if(dwFileIndex != HASH_ENTRY_FREE) + { + pFileEntry = ha->pFileTable + dwFileIndex; + bHetEntryExists = true; + } } - // Return the free table entry - return pFreeEntry; + // If still haven't found the file entry, we allocate new one + if(pFileEntry == NULL) + { + pFileEntry = FindFreeFileEntry(ha); + if(pFileEntry == NULL) + return NULL; + } + + // Fill the rest of the file entry + pFileEntry->ByteOffset = 0; + pFileEntry->FileTime = 0; + pFileEntry->dwFileSize = 0; + pFileEntry->dwCmpSize = 0; + pFileEntry->dwFlags = 0; + pFileEntry->lcLocale = (USHORT)lcLocale; + pFileEntry->wPlatform = 0; + pFileEntry->dwCrc32 = 0; + memset(pFileEntry->md5, 0, MD5_DIGEST_SIZE); + + // Allocate space for file name, if it's not there yet + AllocateFileName(pFileEntry, szFileName); + + // If the free file entry is at the end of the file table, + // we have to increment file table size + if(pFileEntry == ha->pFileTable + ha->dwFileTableSize) + { + assert(ha->dwFileTableSize < ha->dwMaxFileCount); + ha->pHeader->dwBlockTableSize++; + ha->dwFileTableSize++; + } + + // If the MPQ has hash table, we have to insert the new entry into the hash table + if(ha->pHashTable != NULL && bHashEntryExists == false) + { + dwHashIndex = AllocateHashEntry(ha, pFileEntry); + assert(dwHashIndex != HASH_ENTRY_FREE); + } + + // If the MPQ has HET table, we have to insert it to the HET table as well + if(ha->pHetTable != NULL && bHetEntryExists == false) + { + // TODO: Does HET table even support locales? + // Most probably, Blizzard gave up that silly idea long ago. + dwHashIndex = AllocateHetEntry(ha, pFileEntry); + assert(dwHashIndex != HASH_ENTRY_FREE); + } + + // Return the file entry + return pFileEntry; } int RenameFileEntry( - TMPQArchive * ha, - TMPQFile * hf, - const char * szNewFileName) + TMPQArchive * ha, + TFileEntry * pFileEntry, + const char * szNewFileName) { - TFileEntry * pFileEntry = hf->pFileEntry; - TMPQHash * pHashEntry = hf->pHashEntry; - LCID lcLocale = 0; + TMPQHash * pHash; + DWORD dwFileIndex; + int nError = ERROR_SUCCESS; - // If the archive hash hash table, we need to free the hash table entry + // If the MPQ has classic hash table, clear the entry there if(ha->pHashTable != NULL) { - // The file must have hash table entry assigned - // Will exit if there are multiple HASH entries pointing to the same file entry - if(pHashEntry == NULL) - return ERROR_NOT_SUPPORTED; + assert(pFileEntry->dwHashIndex < ha->pHeader->dwHashTableSize); - // Save the locale - lcLocale = pHashEntry->lcLocale; + pHash = ha->pHashTable + pFileEntry->dwHashIndex; + memset(pHash, 0xFF, sizeof(TMPQHash)); + pHash->dwBlockIndex = HASH_ENTRY_DELETED; + } - // Mark the hash table entry as deleted - pHashEntry->dwName1 = 0xFFFFFFFF; - pHashEntry->dwName2 = 0xFFFFFFFF; - pHashEntry->lcLocale = 0xFFFF; - pHashEntry->Platform = 0xFF; - pHashEntry->Reserved = 0xFF; - pHashEntry->dwBlockIndex = HASH_ENTRY_DELETED; + // If the MPQ has HET table, clear the entry there as well + if(ha->pHetTable != NULL) + { + TMPQHetTable * pHetTable = ha->pHetTable; + DWORD dwInvalidFileIndex = (1 << pHetTable->dwIndexSizeTotal) - 1; + + assert(pFileEntry->dwHetIndex < pHetTable->dwHashTableSize); + + // Clear the entry in the HET hash array + pHetTable->pHetHashes[pFileEntry->dwHetIndex] = HET_ENTRY_DELETED; + + // Set the BET index to invalid index + SetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * pFileEntry->dwHetIndex, + pHetTable->dwIndexSize, + &dwInvalidFileIndex, + 4); } // Free the old file name @@ -2017,127 +1604,241 @@ int RenameFileEntry( pFileEntry->szFileName = NULL; // Allocate new file name - AllocateFileName(ha, pFileEntry, szNewFileName); + AllocateFileName(pFileEntry, szNewFileName); - // Allocate new hash entry + // Now find a hash entry for the new file name if(ha->pHashTable != NULL) { - // Since we freed one hash entry before, this must succeed - hf->pHashEntry = AllocateHashEntry(ha, pFileEntry, lcLocale); - assert(hf->pHashEntry != NULL); + // Try to find the hash table entry for the new file name + // Note: If this fails, we leave the MPQ in a corrupt state + dwFileIndex = AllocateHashEntry(ha, pFileEntry); + if(dwFileIndex == HASH_ENTRY_FREE) + nError = ERROR_FILE_CORRUPT; } - return ERROR_SUCCESS; + // If the archive has HET table, we have to allocate HET table for the file as well + // finding the file + if(ha->pHetTable != NULL) + { + dwFileIndex = AllocateHetEntry(ha, pFileEntry); + if(dwFileIndex == HASH_ENTRY_FREE) + nError = ERROR_FILE_CORRUPT; + } + + // Invalidate the entries for (listfile) and (attributes) + // After we are done with MPQ changes, we need to re-create them + InvalidateInternalFiles(ha); + return nError; } -int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf) +void ClearFileEntry( + TMPQArchive * ha, + TFileEntry * pFileEntry) { - TFileEntry * pFileEntry = hf->pFileEntry; - TMPQHash * pHashEntry = hf->pHashEntry; + TMPQHash * pHash = NULL; - // If the archive hash hash table, we need to free the hash table entry + // If the MPQ has classic hash table, clear the entry there if(ha->pHashTable != NULL) { - // The file must have hash table entry assigned - // Will exit if there are multiple HASH entries pointing to the same file entry - if(pHashEntry == NULL) - return ERROR_NOT_SUPPORTED; + assert(pFileEntry->dwHashIndex < ha->pHeader->dwHashTableSize); - // Mark the hash table entry as deleted - pHashEntry->dwName1 = 0xFFFFFFFF; - pHashEntry->dwName2 = 0xFFFFFFFF; - pHashEntry->lcLocale = 0xFFFF; - pHashEntry->Platform = 0xFF; - pHashEntry->Reserved = 0xFF; - pHashEntry->dwBlockIndex = HASH_ENTRY_DELETED; + pHash = ha->pHashTable + pFileEntry->dwHashIndex; + memset(pHash, 0xFF, sizeof(TMPQHash)); + pHash->dwBlockIndex = HASH_ENTRY_DELETED; + } + + // If the MPQ has HET table, clear the entry there as well + if(ha->pHetTable != NULL) + { + TMPQHetTable * pHetTable = ha->pHetTable; + DWORD dwInvalidFileIndex = (1 << pHetTable->dwIndexSizeTotal) - 1; + + assert(pFileEntry->dwHetIndex < pHetTable->dwHashTableSize); + + // Clear the entry in the HET hash array + pHetTable->pHetHashes[pFileEntry->dwHetIndex] = HET_ENTRY_DELETED; + + // Set the BET index to invalid index + SetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * pFileEntry->dwHetIndex, + pHetTable->dwIndexSize, + &dwInvalidFileIndex, + 4); } // Free the file name, and set the file entry as deleted if(pFileEntry->szFileName != NULL) STORM_FREE(pFileEntry->szFileName); - pFileEntry->szFileName = NULL; - // - // Don't modify the HET table, because it gets recreated by the caller - // Don't decrement the number of entries in the file table - // Keep Byte Offset, file size, compressed size, CRC32 and MD5 - // Clear the file name hash and the MPQ_FILE_EXISTS bit - // - - pFileEntry->dwFlags &= ~MPQ_FILE_EXISTS; - pFileEntry->FileNameHash = 0; - return ERROR_SUCCESS; + // Invalidate the file entry + memset(pFileEntry, 0, sizeof(TFileEntry)); } -DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dwFlagNone, DWORD dwFlagNew, DWORD dwForceAddTheFile = 0) +int FreeFileEntry( + TMPQArchive * ha, + TFileEntry * pFileEntry) { - TMPQFile * hf = NULL; - DWORD dwFileFlags = MPQ_FILE_DEFAULT_INTERNAL; - int nError = ERROR_FILE_NOT_FOUND; + TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; + TFileEntry * pTempEntry; + int nError = ERROR_SUCCESS; - // Open the file from the MPQ - if(SFileOpenFileEx((HANDLE)ha, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf)) + // + // If we have HET table, we cannot just get rid of the file + // Doing so would lead to empty gaps in the HET table + // We have to keep BET hash, hash index, HET index, locale, platform and file name + // + + if(ha->pHetTable == NULL) { - // Remember the file flags - dwFileFlags = hf->pFileEntry->dwFlags; + TFileEntry * pLastFileEntry = ha->pFileTable + ha->dwFileTableSize - 1; + TFileEntry * pLastUsedEntry = pLastFileEntry; - // Delete the file entry - nError = DeleteFileEntry(ha, hf); - if(nError == ERROR_SUCCESS) - dwForceAddTheFile = 1; + // Zero the file entry + ClearFileEntry(ha, pFileEntry); - // Close the file - FreeFileHandle(hf); - } + // Now there is a chance that we created a chunk of free + // file entries at the end of the file table. We check this + // and eventually free all deleted file entries at the end + for(pTempEntry = ha->pFileTable; pTempEntry < pFileTableEnd; pTempEntry++) + { + // Is that an occupied file entry? + if(pTempEntry->dwFlags & MPQ_FILE_EXISTS) + pLastUsedEntry = pTempEntry; + } - // Are we going to add the file? - if(dwForceAddTheFile) - { - ha->dwFlags |= dwFlagNew; - ha->dwReservedFiles++; + // Can we free some entries at the end? + if(pLastUsedEntry < pLastFileEntry) + { + // Fix the size of the file table entry + ha->dwFileTableSize = (DWORD)(pLastUsedEntry - ha->pFileTable) + 1; + ha->pHeader->dwBlockTableSize = ha->dwFileTableSize; + } } else { - ha->dwFlags |= dwFlagNone; - dwFileFlags = 0; + // Note: Deleted entries in Blizzard MPQs version 4.0 + // normally contain valid byte offset and length + pFileEntry->dwFlags &= ~MPQ_FILE_EXISTS; + nError = ERROR_SUCCESS; } - // Return the intended file flags - return dwFileFlags; + return nError; } void InvalidateInternalFiles(TMPQArchive * ha) { - // Do nothing if we are in the middle of saving internal files - if(!(ha->dwFlags & MPQ_FLAG_SAVING_TABLES)) + TFileEntry * pFileEntry; + + // Invalidate the (listfile), if not done yet + if(!(ha->dwFlags & MPQ_FLAG_INV_LISTFILE)) { - // - // We clear the file entries for (listfile), (attributes) and (signature) - // For each internal file cleared, we increment the number - // of reserved entries in the file table. - // - - // Invalidate the (listfile), if not done yet - if((ha->dwFlags & (MPQ_FLAG_LISTFILE_NONE | MPQ_FLAG_LISTFILE_NEW)) == 0) - { - ha->dwFileFlags1 = InvalidateInternalFile(ha, LISTFILE_NAME, MPQ_FLAG_LISTFILE_NONE, MPQ_FLAG_LISTFILE_NEW, (ha->dwFlags & MPQ_FLAG_LISTFILE_FORCE)); - } - - // Invalidate the (attributes), if not done yet - if((ha->dwFlags & (MPQ_FLAG_ATTRIBUTES_NONE | MPQ_FLAG_ATTRIBUTES_NEW)) == 0) - { - ha->dwFileFlags2 = InvalidateInternalFile(ha, ATTRIBUTES_NAME, MPQ_FLAG_ATTRIBUTES_NONE, MPQ_FLAG_ATTRIBUTES_NEW); - } - - // Invalidate the (signature), if not done yet - if((ha->dwFlags & (MPQ_FLAG_SIGNATURE_NONE | MPQ_FLAG_SIGNATURE_NEW)) == 0) - { - ha->dwFileFlags3 = InvalidateInternalFile(ha, SIGNATURE_NAME, MPQ_FLAG_SIGNATURE_NONE, MPQ_FLAG_SIGNATURE_NEW); - } - - // Remember that the MPQ has been changed - ha->dwFlags |= MPQ_FLAG_CHANGED; + pFileEntry = GetFileEntryExact(ha, LISTFILE_NAME, LANG_NEUTRAL); + if(pFileEntry != NULL) + FreeFileEntry(ha, pFileEntry); + ha->dwFlags |= MPQ_FLAG_INV_LISTFILE; } + + // Invalidate the (attributes), if not done yet + if(!(ha->dwFlags & MPQ_FLAG_INV_ATTRIBUTES)) + { + pFileEntry = GetFileEntryExact(ha, ATTRIBUTES_NAME, LANG_NEUTRAL); + if(pFileEntry != NULL) + FreeFileEntry(ha, pFileEntry); + ha->dwFlags |= MPQ_FLAG_INV_ATTRIBUTES; + } + + // Remember that the MPQ has been changed and it will be necessary + // to update the tables + ha->dwFlags |= MPQ_FLAG_CHANGED; +} + +//----------------------------------------------------------------------------- +// Functions that loads and verify MPQ data bitmap + +int LoadMpqDataBitmap(TMPQArchive * ha, ULONGLONG FileSize, bool * pbFileIsComplete) +{ + TMPQBitmap * pBitmap = NULL; + TMPQBitmap DataBitmap; + ULONGLONG BitmapOffset; + ULONGLONG EndOfMpq; + DWORD DataBlockCount = 0; + DWORD BitmapByteSize; + DWORD WholeByteCount; + DWORD ExtraBitsCount; + + // Is there enough space for a MPQ bitmap? + EndOfMpq = ha->MpqPos + ha->pHeader->ArchiveSize64; + FileSize = FileSize - sizeof(TMPQBitmap); + if(FileSize > EndOfMpq) + { + // Try to load the data bitmap from the end of the file + if(FileStream_Read(ha->pStream, &FileSize, &DataBitmap, sizeof(TMPQBitmap))) + { + // Is it a valid data bitmap? + BSWAP_ARRAY32_UNSIGNED((LPDWORD)(&DataBitmap), sizeof(TMPQBitmap)); + if(DataBitmap.dwSignature == MPQ_DATA_BITMAP_SIGNATURE) + { + // We assume that MPQs with data bitmap begin at position 0 + assert(ha->MpqPos == 0); + + // Calculate the number of extra bytes for data bitmap + DataBlockCount = (DWORD)(((ha->pHeader->ArchiveSize64 - 1) / DataBitmap.dwBlockSize) + 1); + BitmapByteSize = ((DataBlockCount - 1) / 8) + 1; + + // Verify the data block size + BitmapOffset = ((ULONGLONG)DataBitmap.dwMapOffsetHi << 32) | DataBitmap.dwMapOffsetLo; + assert((DWORD)(FileSize - BitmapOffset) == BitmapByteSize); + + // Allocate space for the data bitmap + pBitmap = (TMPQBitmap *)STORM_ALLOC(BYTE, sizeof(TMPQBitmap) + BitmapByteSize); + if(pBitmap != NULL) + { + // Copy the bitmap header + memcpy(pBitmap, &DataBitmap, sizeof(TMPQBitmap)); + + // Read the remaining part + if(!FileStream_Read(ha->pStream, &BitmapOffset, (pBitmap + 1), BitmapByteSize)) + { + STORM_FREE(pBitmap); + pBitmap = NULL; + } + } + } + } + } + + // If the caller asks for file completeness, check it + if(pBitmap != NULL && pbFileIsComplete != NULL) + { + LPBYTE pbBitmap = (LPBYTE)(pBitmap + 1); + DWORD i; + bool bFileIsComplete = true; + + // Calculate the number of whole bytes and extra bits of the bitmap + WholeByteCount = (DataBlockCount / 8); + ExtraBitsCount = (DataBlockCount & 7); + + // Verify the whole bytes - their value must be 0xFF + for(i = 0; i < WholeByteCount; i++) + { + if(pbBitmap[i] != 0xFF) + bFileIsComplete = false; + } + + // If there are extra bits, calculate the mask + if(ExtraBitsCount != 0) + { + BYTE ExpectedValue = (BYTE)((1 << ExtraBitsCount) - 1); + + if(pbBitmap[i] != ExpectedValue) + bFileIsComplete = false; + } + + // Give the result to the caller + *pbFileIsComplete = bFileIsComplete; + } + + ha->pBitmap = pBitmap; + return ERROR_SUCCESS; } //----------------------------------------------------------------------------- @@ -2151,10 +1852,6 @@ int CreateHashTable(TMPQArchive * ha, DWORD dwHashTableSize) assert((dwHashTableSize & (dwHashTableSize - 1)) == 0); assert(ha->pHashTable == NULL); - // If the required hash table size is zero, don't create anything - if(dwHashTableSize == 0) - dwHashTableSize = HASH_TABLE_SIZE_DEFAULT; - // Create the hash table pHashTable = STORM_ALLOC(TMPQHash, dwHashTableSize); if(pHashTable == NULL) @@ -2162,153 +1859,199 @@ int CreateHashTable(TMPQArchive * ha, DWORD dwHashTableSize) // Fill it memset(pHashTable, 0xFF, dwHashTableSize * sizeof(TMPQHash)); - ha->pHeader->dwHashTableSize = dwHashTableSize; - ha->dwMaxFileCount = dwHashTableSize; ha->pHashTable = pHashTable; + + // Set the max file count, if needed + if(ha->pHetTable == NULL) + ha->dwMaxFileCount = dwHashTableSize; return ERROR_SUCCESS; } -static TMPQHash * LoadHashTable(TMPQArchive * ha) +TMPQHash * LoadHashTable(TMPQArchive * ha) { TMPQHeader * pHeader = ha->pHeader; ULONGLONG ByteOffset; - TMPQHash * pHashTable = NULL; + TMPQHash * pHashTable; DWORD dwTableSize; DWORD dwCmpSize; - bool bHashTableIsCut = false; + int nError; - // Note: It is allowed to load hash table if it is at offset 0. - // Example: MPQ_2016_v1_ProtectedMap_HashOffsIsZero.w3x -// if(pHeader->dwHashTablePos == 0 && pHeader->wHashTablePosHi == 0) -// return NULL; + // If the MPQ has no hash table, do nothing + if(pHeader->dwHashTablePos == 0 && pHeader->wHashTablePosHi == 0) + return NULL; // If the hash table size is zero, do nothing if(pHeader->dwHashTableSize == 0) return NULL; - // Load the hash table for MPQ variations - switch(ha->dwSubType) + // Allocate buffer for the hash table + dwTableSize = pHeader->dwHashTableSize * sizeof(TMPQHash); + pHashTable = STORM_ALLOC(TMPQHash, pHeader->dwHashTableSize); + if(pHashTable == NULL) + return NULL; + + // Compressed size of the hash table + dwCmpSize = (DWORD)pHeader->HashTableSize64; + + // + // Load the table from the MPQ, with decompression + // + // Note: We will NOT check if the hash table is properly decrypted. + // Some MPQ protectors corrupt the hash table by rewriting part of it. + // Hash table, the way how it works, allows arbitrary values for unused entries. + // + + ByteOffset = ha->MpqPos + MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos); + nError = LoadMpqTable(ha, ByteOffset, pHashTable, dwCmpSize, dwTableSize, MPQ_KEY_HASH_TABLE); + if(nError != ERROR_SUCCESS) { - case MPQ_SUBTYPE_MPQ: - - // Calculate the position and size of the hash table - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos)); - dwTableSize = pHeader->dwHashTableSize * sizeof(TMPQHash); - dwCmpSize = (DWORD)pHeader->HashTableSize64; - - // Read, decrypt and uncompress the hash table - pHashTable = (TMPQHash *)LoadMpqTable(ha, ByteOffset, dwCmpSize, dwTableSize, MPQ_KEY_HASH_TABLE, &bHashTableIsCut); -// DumpHashTable(pHashTable, pHeader->dwHashTableSize); - - // If the hash table was cut, we can/have to defragment it - if(pHashTable != NULL && bHashTableIsCut) - ha->dwFlags |= (MPQ_FLAG_MALFORMED | MPQ_FLAG_HASH_TABLE_CUT); - break; - - case MPQ_SUBTYPE_SQP: - pHashTable = LoadSqpHashTable(ha); - break; - - case MPQ_SUBTYPE_MPK: - pHashTable = LoadMpkHashTable(ha); - break; + STORM_FREE(pHashTable); + pHashTable = NULL; } - // Remember the size of the hash table + // Return the hash table return pHashTable; } -int CreateFileTable(TMPQArchive * ha, DWORD dwFileTableSize) -{ - ha->pFileTable = STORM_ALLOC(TFileEntry, dwFileTableSize); - if(ha->pFileTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - memset(ha->pFileTable, 0x00, sizeof(TFileEntry) * dwFileTableSize); - ha->dwFileTableSize = dwFileTableSize; - return ERROR_SUCCESS; -} - -TMPQBlock * LoadBlockTable(TMPQArchive * ha, bool /* bDontFixEntries */) +static void FixBlockTableSize( + TMPQArchive * ha, + TMPQBlock * pBlockTable, + DWORD dwClaimedSize) { TMPQHeader * pHeader = ha->pHeader; - TMPQBlock * pBlockTable = NULL; + ULONGLONG BlockTableStart; + ULONGLONG BlockTableEnd; + ULONGLONG FileDataStart; + + // Only perform this check on MPQs version 1.0 + if(pHeader->dwHeaderSize == MPQ_HEADER_SIZE_V1) + { + // Calculate claimed block table begin and end + BlockTableStart = ha->MpqPos + MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); + BlockTableEnd = BlockTableStart + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)); + + for(DWORD i = 0; i < dwClaimedSize; i++) + { + // If the block table end goes into that file, fix the block table end + FileDataStart = ha->MpqPos + pBlockTable[i].dwFilePos; + if(BlockTableStart < FileDataStart && BlockTableEnd > FileDataStart) + { + dwClaimedSize = (DWORD)((FileDataStart - BlockTableStart) / sizeof(TMPQBlock)); + BlockTableEnd = FileDataStart; + } + } + } + + // Fix the block table size + pHeader->BlockTableSize64 = dwClaimedSize * sizeof(TMPQBlock); + pHeader->dwBlockTableSize = dwClaimedSize; +} + +TMPQBlock * LoadBlockTable(TMPQArchive * ha, ULONGLONG FileSize) +{ + TMPQHeader * pHeader = ha->pHeader; + TMPQBlock * pBlockTable; ULONGLONG ByteOffset; DWORD dwTableSize; DWORD dwCmpSize; - bool bBlockTableIsCut = false; + int nError; - // Note: It is possible that the block table starts at offset 0 - // Example: MPQ_2016_v1_ProtectedMap_HashOffsIsZero.w3x -// if(pHeader->dwBlockTablePos == 0 && pHeader->wBlockTablePosHi == 0) -// return NULL; + // Do nothing if the block table position is zero + if(pHeader->dwBlockTablePos == 0 && pHeader->wBlockTablePosHi == 0) + return NULL; // Do nothing if the block table size is zero if(pHeader->dwBlockTableSize == 0) return NULL; - // Load the block table for MPQ variations - switch(ha->dwSubType) + // Sanity check, enforced by LoadAnyHashTable + assert(ha->dwMaxFileCount >= pHeader->dwBlockTableSize); + + // Calculate sizes of both tables + ByteOffset = ha->MpqPos + MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); + dwTableSize = pHeader->dwBlockTableSize * sizeof(TMPQBlock); + dwCmpSize = (DWORD)pHeader->BlockTableSize64; + + // Allocate space for the block table + // Note: pHeader->dwBlockTableSize can be zero !!! + pBlockTable = STORM_ALLOC(TMPQBlock, ha->dwMaxFileCount); + if(pBlockTable == NULL) + return NULL; + + // Fill the block table with zeros + memset(pBlockTable, 0, dwTableSize); + + // I found a MPQ which claimed 0x200 entries in the block table, + // but the file was cut and there was only 0x1A0 entries. + // We will handle this case properly. + if(dwTableSize == dwCmpSize && (ByteOffset + dwTableSize) > FileSize) { - case MPQ_SUBTYPE_MPQ: - - // Calculate byte position of the block table - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos)); - dwTableSize = pHeader->dwBlockTableSize * sizeof(TMPQBlock); - dwCmpSize = (DWORD)pHeader->BlockTableSize64; - - // Read, decrypt and uncompress the block table - pBlockTable = (TMPQBlock * )LoadMpqTable(ha, ByteOffset, dwCmpSize, dwTableSize, MPQ_KEY_BLOCK_TABLE, &bBlockTableIsCut); - - // If the block table was cut, we need to remember it - if(pBlockTable != NULL && bBlockTableIsCut) - ha->dwFlags |= (MPQ_FLAG_MALFORMED | MPQ_FLAG_BLOCK_TABLE_CUT); - break; - - case MPQ_SUBTYPE_SQP: - - pBlockTable = LoadSqpBlockTable(ha); - break; - - case MPQ_SUBTYPE_MPK: - - pBlockTable = LoadMpkBlockTable(ha); - break; + pHeader->dwBlockTableSize = (DWORD)((FileSize - ByteOffset) / sizeof(TMPQBlock)); + pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock); + dwTableSize = dwCmpSize = pHeader->dwBlockTableSize * sizeof(TMPQBlock); } + // + // One of the first cracked versions of Diablo I had block table unencrypted + // StormLib does NOT support such MPQs anymore, as they are incompatible + // with compressed block table feature + // + + // Load the block table + nError = LoadMpqTable(ha, ByteOffset, pBlockTable, dwCmpSize, dwTableSize, MPQ_KEY_BLOCK_TABLE); + if(nError != ERROR_SUCCESS) + { + // Failed, sorry + STORM_FREE(pBlockTable); + return NULL; + } + + // Defense against MPQs that claim block table to be bigger than it really is + FixBlockTableSize(ha, pBlockTable, pHeader->dwBlockTableSize); return pBlockTable; } -TMPQHetTable * LoadHetTable(TMPQArchive * ha) +int LoadHetTable(TMPQArchive * ha) { - TMPQExtHeader * pExtTable; - TMPQHetTable * pHetTable = NULL; + TMPQExtTable * pExtTable; TMPQHeader * pHeader = ha->pHeader; + int nError = ERROR_SUCCESS; - // If the HET table position is not 0, we expect the table to be present - if(pHeader->HetTablePos64 != 0 && pHeader->HetTableSize64 != 0) + // If the HET table position is not NULL, we expect + // both HET and BET tables to be present. + if(pHeader->HetTablePos64 != 0) { // Attempt to load the HET table (Hash Extended Table) pExtTable = LoadExtTable(ha, pHeader->HetTablePos64, (size_t)pHeader->HetTableSize64, HET_TABLE_SIGNATURE, MPQ_KEY_HASH_TABLE); if(pExtTable != NULL) { + // If succeeded, we have to limit the maximum file count + // to the values saved in the HET table // If loading HET table fails, we ignore the result. - pHetTable = TranslateHetTable((TMPQHetHeader *)pExtTable); + ha->pHetTable = TranslateHetTable(pExtTable); + if(ha->pHetTable != NULL) + ha->dwMaxFileCount = ha->pHetTable->dwMaxFileCount; + STORM_FREE(pExtTable); } + + // If the HET hable failed to load, it's corrupt. + if(ha->pHetTable == NULL) + nError = ERROR_FILE_CORRUPT; } - return pHetTable; + return nError; } TMPQBetTable * LoadBetTable(TMPQArchive * ha) { - TMPQExtHeader * pExtTable; + TMPQExtTable * pExtTable; TMPQBetTable * pBetTable = NULL; TMPQHeader * pHeader = ha->pHeader; - // If the BET table position is not 0, we expect the table to be present - if(pHeader->BetTablePos64 != 0 && pHeader->BetTableSize64 != 0) + // If the HET table position is not NULL, we expect + // both HET and BET tables to be present. + if(pHeader->BetTablePos64 != 0) { // Attempt to load the HET table (Hash Extended Table) pExtTable = LoadExtTable(ha, pHeader->BetTablePos64, (size_t)pHeader->BetTableSize64, BET_TABLE_SIGNATURE, MPQ_KEY_BLOCK_TABLE); @@ -2316,7 +2059,7 @@ TMPQBetTable * LoadBetTable(TMPQArchive * ha) { // If succeeded, we translate the BET table // to more readable form - pBetTable = TranslateBetTable(ha, (TMPQBetHeader *)pExtTable); + pBetTable = TranslateBetTable(ha, pExtTable); STORM_FREE(pExtTable); } } @@ -2332,46 +2075,114 @@ int LoadAnyHashTable(TMPQArchive * ha) if(pHeader->dwHashTableSize == 0 && pHeader->HetTableSize64 == 0) return CreateHashTable(ha, HASH_TABLE_SIZE_DEFAULT); - // Try to load HET table - if(pHeader->HetTablePos64 != 0) - ha->pHetTable = LoadHetTable(ha); + // Try to load HET and/or classic hash table + LoadHetTable(ha); - // Try to load classic hash table - if(pHeader->dwHashTableSize) - ha->pHashTable = LoadHashTable(ha); + // Load the HASH table + ha->pHashTable = LoadHashTable(ha); - // At least one of the tables must be present + // Set the maximum file count to the size of the hash table + // In case there is HET table, we have to keep the file limit + if(ha->pHetTable == NULL) + ha->dwMaxFileCount = pHeader->dwHashTableSize; + + // Did at least one succeed? if(ha->pHetTable == NULL && ha->pHashTable == NULL) return ERROR_FILE_CORRUPT; - // Set the maximum file count to the size of the hash table. - // Note: We don't care about HET table limits, because HET table is rebuilt - // after each file add/rename/delete. - ha->dwMaxFileCount = (ha->pHashTable != NULL) ? pHeader->dwHashTableSize : HASH_TABLE_SIZE_MAX; + // In theory, a MPQ could have bigger block table than hash table + if(ha->pHeader->dwBlockTableSize > ha->dwMaxFileCount) + { + ha->dwMaxFileCount = ha->pHeader->dwBlockTableSize; + ha->dwFlags |= MPQ_FLAG_READ_ONLY; + } + return ERROR_SUCCESS; } -static int BuildFileTable_Classic(TMPQArchive * ha) +int BuildFileTable_Classic( + TMPQArchive * ha, + TFileEntry * pFileTable, + ULONGLONG FileSize) { + TFileEntry * pFileEntry; TMPQHeader * pHeader = ha->pHeader; TMPQBlock * pBlockTable; + TMPQBlock * pBlock; int nError = ERROR_SUCCESS; // Sanity checks assert(ha->pHashTable != NULL); - assert(ha->pFileTable != NULL); - - // If the MPQ has no block table, do nothing - if(pHeader->dwBlockTableSize == 0) - return ERROR_SUCCESS; - assert(ha->dwFileTableSize >= pHeader->dwBlockTableSize); // Load the block table - // WARNING! ha->pFileTable can change in the process!! - pBlockTable = (TMPQBlock *)LoadBlockTable(ha); + pBlockTable = LoadBlockTable(ha, FileSize); if(pBlockTable != NULL) { - nError = BuildFileTableFromBlockTable(ha, pBlockTable); + TMPQHash * pHashEnd = ha->pHashTable + pHeader->dwHashTableSize; + TMPQHash * pHash; + + // If we don't have HET table, we build the file entries from the hash&block tables + if(ha->pHetTable == NULL) + { + for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) + { + if(pHash->dwBlockIndex < pHeader->dwBlockTableSize) + { + pFileEntry = pFileTable + pHash->dwBlockIndex; + pBlock = pBlockTable + pHash->dwBlockIndex; + + // + // Yet another silly map protector: For each valid file, + // there are 4 items in the hash table, that appears to be valid: + // + // a6d79af0 e61a0932 001e0000 0000770b <== Fake valid + // a6d79af0 e61a0932 0000d761 0000dacb <== Fake valid + // a6d79af0 e61a0932 00000000 0000002f <== Real file entry + // a6d79af0 e61a0932 00005a4f 000093bc <== Fake valid + // + + if(!(pBlock->dwFlags & ~MPQ_FILE_VALID_FLAGS) && (pBlock->dwFlags & MPQ_FILE_EXISTS)) + { + // Fill the entry + pFileEntry->ByteOffset = pBlock->dwFilePos; + pFileEntry->dwHashIndex = (DWORD)(pHash - ha->pHashTable); + pFileEntry->dwFileSize = pBlock->dwFSize; + pFileEntry->dwCmpSize = pBlock->dwCSize; + pFileEntry->dwFlags = pBlock->dwFlags; + pFileEntry->lcLocale = pHash->lcLocale; + pFileEntry->wPlatform = pHash->wPlatform; + } + else + { + // If the hash table entry doesn't point to the valid file item, + // we invalidate the entire hash table entry + pHash->dwName1 = 0xFFFFFFFF; + pHash->dwName2 = 0xFFFFFFFF; + pHash->lcLocale = 0xFFFF; + pHash->wPlatform = 0xFFFF; + pHash->dwBlockIndex = HASH_ENTRY_DELETED; + } + } + } + } + else + { + for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) + { + if(pHash->dwBlockIndex < ha->dwFileTableSize) + { + pFileEntry = pFileTable + pHash->dwBlockIndex; + if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) + { + pFileEntry->dwHashIndex = (DWORD)(pHash - ha->pHashTable); + pFileEntry->lcLocale = pHash->lcLocale; + pFileEntry->wPlatform = pHash->wPlatform; + } + } + } + } + + // Free the block table STORM_FREE(pBlockTable); } else @@ -2399,14 +2210,15 @@ static int BuildFileTable_Classic(TMPQArchive * ha) // Now merge the hi-block table to the file table if(nError == ERROR_SUCCESS) { - TFileEntry * pFileEntry = ha->pFileTable; - - // Swap the hi-block table - BSWAP_ARRAY16_UNSIGNED(pHiBlockTable, dwTableSize); + pFileEntry = pFileTable; // Add the high file offset to the base file offset. - for(DWORD i = 0; i < pHeader->dwBlockTableSize; i++, pFileEntry++) - pFileEntry->ByteOffset = MAKE_OFFSET64(pHiBlockTable[i], pFileEntry->ByteOffset); + // We also need to swap it during the process. + for(DWORD i = 0; i < pHeader->dwBlockTableSize; i++) + { + pFileEntry->ByteOffset |= ((ULONGLONG)BSWAP_INT16_UNSIGNED(pHiBlockTable[i]) << 32); + pFileEntry++; + } } // Free the hi-block table @@ -2418,14 +2230,18 @@ static int BuildFileTable_Classic(TMPQArchive * ha) } } + // Set the current size of the file table + ha->dwFileTableSize = pHeader->dwBlockTableSize; return nError; } -static int BuildFileTable_HetBet(TMPQArchive * ha) +int BuildFileTable_HetBet( + TMPQArchive * ha, + TFileEntry * pFileTable) { TMPQHetTable * pHetTable = ha->pHetTable; TMPQBetTable * pBetTable; - TFileEntry * pFileEntry = ha->pFileTable; + TFileEntry * pFileEntry = pFileTable; TBitArray * pBitArray; DWORD dwBitPosition = 0; DWORD i; @@ -2435,69 +2251,58 @@ static int BuildFileTable_HetBet(TMPQArchive * ha) pBetTable = LoadBetTable(ha); if(pBetTable != NULL) { - // Verify the size of NameHash2 in the BET table. - // It has to be 8 bits less than the information in HET table - if((pBetTable->dwBitCount_NameHash2 + 8) != pHetTable->dwNameHashBitSize) - { - FreeBetTable(pBetTable); - return ERROR_FILE_CORRUPT; - } - - // Step one: Fill the name indexes - for(i = 0; i < pHetTable->dwTotalCount; i++) + // Step one: Fill the indexes to the HET table + for(i = 0; i < pHetTable->dwHashTableSize; i++) { DWORD dwFileIndex = 0; // Is the entry in the HET table occupied? - if(pHetTable->pNameHashes[i] != HET_ENTRY_FREE) + if(pHetTable->pHetHashes[i] != 0) { // Load the index to the BET table GetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * i, pHetTable->dwIndexSize, - &dwFileIndex, + &dwFileIndex, 4); // Overflow test - if(dwFileIndex < pBetTable->dwEntryCount) + if(dwFileIndex < pBetTable->dwFileCount) { - ULONGLONG NameHash1 = pHetTable->pNameHashes[i]; - ULONGLONG NameHash2 = 0; + // Get the file entry and save HET index + pFileEntry = pFileTable + dwFileIndex; + pFileEntry->dwHetIndex = i; // Load the BET hash - GetBits(pBetTable->pNameHashes, pBetTable->dwBitTotal_NameHash2 * dwFileIndex, - pBetTable->dwBitCount_NameHash2, - &NameHash2, - 8); - - // Combine both part of the name hash and put it to the file table - pFileEntry = ha->pFileTable + dwFileIndex; - pFileEntry->FileNameHash = (NameHash1 << pBetTable->dwBitCount_NameHash2) | NameHash2; + GetBits(pBetTable->pBetHashes, pBetTable->dwBetHashSizeTotal * dwFileIndex, + pBetTable->dwBetHashSize, + &pFileEntry->BetHash, + 8); } } } // Go through the entire BET table and convert it to the file table. - pFileEntry = ha->pFileTable; - pBitArray = pBetTable->pFileTable; - for(i = 0; i < pBetTable->dwEntryCount; i++) + pFileEntry = pFileTable; + pBitArray = pBetTable->pFileTable; + for(i = 0; i < pBetTable->dwFileCount; i++) { DWORD dwFlagIndex = 0; // Read the file position GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_FilePos, pBetTable->dwBitCount_FilePos, - &pFileEntry->ByteOffset, + &pFileEntry->ByteOffset, 8); // Read the file size GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_FileSize, pBetTable->dwBitCount_FileSize, - &pFileEntry->dwFileSize, + &pFileEntry->dwFileSize, 4); // Read the compressed size GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_CmpSize, pBetTable->dwBitCount_CmpSize, - &pFileEntry->dwCmpSize, + &pFileEntry->dwCmpSize, 4); @@ -2506,8 +2311,9 @@ static int BuildFileTable_HetBet(TMPQArchive * ha) { GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_FlagIndex, pBetTable->dwBitCount_FlagIndex, - &dwFlagIndex, + &dwFlagIndex, 4); + pFileEntry->dwFlags = pBetTable->pFileFlags[dwFlagIndex]; } @@ -2521,6 +2327,7 @@ static int BuildFileTable_HetBet(TMPQArchive * ha) } // Set the current size of the file table + ha->dwFileTableSize = pBetTable->dwFileCount; FreeBetTable(pBetTable); nError = ERROR_SUCCESS; } @@ -2532,33 +2339,28 @@ static int BuildFileTable_HetBet(TMPQArchive * ha) return nError; } -int BuildFileTable(TMPQArchive * ha) +int BuildFileTable(TMPQArchive * ha, ULONGLONG FileSize) { - DWORD dwFileTableSize; + TFileEntry * pFileTable; bool bFileTableCreated = false; // Sanity checks - assert(ha->pFileTable == NULL); assert(ha->dwFileTableSize == 0); assert(ha->dwMaxFileCount != 0); - // Determine the allocation size for the file table - dwFileTableSize = STORMLIB_MAX(ha->pHeader->dwBlockTableSize, ha->dwMaxFileCount); - // Allocate the file table with size determined before - ha->pFileTable = STORM_ALLOC(TFileEntry, dwFileTableSize); - if(ha->pFileTable == NULL) + pFileTable = STORM_ALLOC(TFileEntry, ha->dwMaxFileCount); + if(pFileTable == NULL) return ERROR_NOT_ENOUGH_MEMORY; // Fill the table with zeros - memset(ha->pFileTable, 0, dwFileTableSize * sizeof(TFileEntry)); - ha->dwFileTableSize = dwFileTableSize; + memset(pFileTable, 0, ha->dwMaxFileCount * sizeof(TFileEntry)); // If we have HET table, we load file table from the BET table // Note: If BET table is corrupt or missing, we set the archive as read only if(ha->pHetTable != NULL) { - if(BuildFileTable_HetBet(ha) != ERROR_SUCCESS) + if(BuildFileTable_HetBet(ha, pFileTable) != ERROR_SUCCESS) ha->dwFlags |= MPQ_FLAG_READ_ONLY; else bFileTableCreated = true; @@ -2568,232 +2370,29 @@ int BuildFileTable(TMPQArchive * ha) // Note: If block table is corrupt or missing, we set the archive as read only if(ha->pHashTable != NULL) { - if(BuildFileTable_Classic(ha) != ERROR_SUCCESS) + if(BuildFileTable_Classic(ha, pFileTable, FileSize) != ERROR_SUCCESS) ha->dwFlags |= MPQ_FLAG_READ_ONLY; else bFileTableCreated = true; } - // Return result - return bFileTableCreated ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; -} - -/* -void UpdateBlockTableSize(TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - DWORD dwBlockTableSize = 0; - - // Calculate the number of files - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) + // If something failed, we free the file table entry + if(bFileTableCreated == false) { - // If the source table entry is valid, - if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) - dwBlockTableSize = (DWORD)(pFileEntry - ha->pFileTable) + 1; - } - - // Save the block table size to the MPQ header - ha->pHeader->dwBlockTableSize = ha->dwReservedFiles + dwBlockTableSize; -} -*/ - -// Defragment the file table so it does not contain any gaps -int DefragmentFileTable(TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pSource = ha->pFileTable; - TFileEntry * pTarget = ha->pFileTable; - LPDWORD DefragmentTable; - DWORD dwBlockTableSize = 0; - DWORD dwSrcIndex; - DWORD dwTrgIndex; - - // Allocate brand new file table - DefragmentTable = STORM_ALLOC(DWORD, ha->dwFileTableSize); - if(DefragmentTable != NULL) - { - // Clear the file table - memset(DefragmentTable, 0xFF, sizeof(DWORD) * ha->dwFileTableSize); - - // Parse the entire file table and defragment it - for(; pSource < pFileTableEnd; pSource++) - { - // If the source table entry is valid, - if(pSource->dwFlags & MPQ_FILE_EXISTS) - { - // Remember the index conversion - dwSrcIndex = (DWORD)(pSource - ha->pFileTable); - dwTrgIndex = (DWORD)(pTarget - ha->pFileTable); - DefragmentTable[dwSrcIndex] = dwTrgIndex; - - // Move the entry, if needed - if(pTarget != pSource) - pTarget[0] = pSource[0]; - pTarget++; - - // Update the block table size - dwBlockTableSize = (DWORD)(pTarget - ha->pFileTable); - } - else - { - // If there is file name left, free it - if(pSource->szFileName != NULL) - STORM_FREE(pSource->szFileName); - pSource->szFileName = NULL; - } - } - - // Did we defragment something? - if(pTarget < pFileTableEnd) - { - // Clear the remaining file entries - memset(pTarget, 0, (pFileTableEnd - pTarget) * sizeof(TFileEntry)); - - // Go through the hash table and relocate the block indexes - if(ha->pHashTable != NULL) - { - TMPQHash * pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash; - DWORD dwNewBlockIndex; - - for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++) - { - if(MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - { - // If that block entry is there, set it to the hash entry - // If not, set it as DELETED - dwNewBlockIndex = DefragmentTable[MPQ_BLOCK_INDEX(pHash)]; - pHash->dwBlockIndex = (dwNewBlockIndex != HASH_ENTRY_FREE) ? dwNewBlockIndex : HASH_ENTRY_DELETED; - } - } - } - } - - // Save the block table size - ha->pHeader->dwBlockTableSize = ha->dwReservedFiles + dwBlockTableSize; - - // Free the defragment table - STORM_FREE(DefragmentTable); + STORM_FREE(pFileTable); + return ERROR_FILE_CORRUPT; } + // Assign it to the archive structure + ha->pFileTable = pFileTable; return ERROR_SUCCESS; } -// Rebuilds the HET table from scratch based on the file table -// Used after a modifying operation (add, rename, delete) -int RebuildHetTable(TMPQArchive * ha) -{ - TMPQHetTable * pOldHetTable = ha->pHetTable; - TFileEntry * pFileTableEnd; - TFileEntry * pFileEntry; - DWORD dwBlockTableSize = ha->dwFileTableSize; - int nError = ERROR_SUCCESS; - - // If we are in the state of saving MPQ tables, the real size of block table - // must already have been calculated. Use that value instead - if(ha->dwFlags & MPQ_FLAG_SAVING_TABLES) - { - assert(ha->pHeader->dwBlockTableSize != 0); - dwBlockTableSize = ha->pHeader->dwBlockTableSize; - } - - // Create new HET table based on the total number of entries in the file table - // Note that if we fail to create it, we just stop using HET table - ha->pHetTable = CreateHetTable(dwBlockTableSize, 0, 0x40, NULL); - if(ha->pHetTable != NULL) - { - // Go through the file table again and insert all existing files - pFileTableEnd = ha->pFileTable + dwBlockTableSize; - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) - { - // Get the high - nError = InsertHetEntry(ha->pHetTable, pFileEntry->FileNameHash, (DWORD)(pFileEntry - ha->pFileTable)); - if(nError != ERROR_SUCCESS) - break; - } - } - } - - // Free the old HET table - FreeHetTable(pOldHetTable); - return nError; -} - -// Rebuilds the file table, removing all deleted file entries. -// Used when compacting the archive -int RebuildFileTable(TMPQArchive * ha, DWORD dwNewHashTableSize) -{ - TFileEntry * pFileEntry; - TMPQHash * pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pOldHashTable = ha->pHashTable; - TMPQHash * pHashTable = NULL; - TMPQHash * pHash; - int nError = ERROR_SUCCESS; - - // The new hash table size must be greater or equal to the current hash table size - assert(dwNewHashTableSize >= ha->pHeader->dwHashTableSize); - assert(dwNewHashTableSize >= ha->dwMaxFileCount); - assert((dwNewHashTableSize & (dwNewHashTableSize - 1)) == 0); - assert(ha->pHashTable != NULL); - - // Reallocate the new file table, if needed - if(dwNewHashTableSize > ha->dwFileTableSize) - { - ha->pFileTable = STORM_REALLOC(TFileEntry, ha->pFileTable, dwNewHashTableSize); - if(ha->pFileTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - memset(ha->pFileTable + ha->dwFileTableSize, 0, (dwNewHashTableSize - ha->dwFileTableSize) * sizeof(TFileEntry)); - } - - // Allocate new hash table - if(nError == ERROR_SUCCESS) - { - pHashTable = STORM_ALLOC(TMPQHash, dwNewHashTableSize); - if(pHashTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // If both succeeded, we need to rebuild the file table - if(nError == ERROR_SUCCESS) - { - // Make sure that the hash table is properly filled - memset(pHashTable, 0xFF, sizeof(TMPQHash) * dwNewHashTableSize); - ha->pHashTable = pHashTable; - - // Set the new limits to the MPQ archive - ha->pHeader->dwHashTableSize = dwNewHashTableSize; - - // Parse the old hash table and copy all entries to the new table - for(pHash = pOldHashTable; pHash < pHashTableEnd; pHash++) - { - if(IsValidHashEntry(ha, pHash)) - { - pFileEntry = ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - AllocateHashEntry(ha, pFileEntry, pHash->lcLocale); - } - } - - // Increment the max file count for the file - ha->dwFileTableSize = dwNewHashTableSize; - ha->dwMaxFileCount = dwNewHashTableSize; - ha->dwFlags |= MPQ_FLAG_CHANGED; - } - - // Now free the remaining entries - if(pOldHashTable != NULL) - STORM_FREE(pOldHashTable); - return nError; -} - // Saves MPQ header, hash table, block table and hi-block table. int SaveMPQTables(TMPQArchive * ha) { - TMPQExtHeader * pHetTable = NULL; - TMPQExtHeader * pBetTable = NULL; + TMPQExtTable * pHetTable = NULL; + TMPQExtTable * pBetTable = NULL; TMPQHeader * pHeader = ha->pHeader; TMPQBlock * pBlockTable = NULL; TMPQHash * pHashTable = NULL; @@ -2811,8 +2410,8 @@ int SaveMPQTables(TMPQArchive * ha) // We expect this function to be called only when tables have been changed assert(ha->dwFlags & MPQ_FLAG_CHANGED); - // Find the space where the MPQ tables will be saved - TablePos = FindFreeMpqSpace(ha); + // Find the space where the MPQ tables will be saved + FindFreeMpqSpace(ha, &TablePos); // If the MPQ has HET table, we prepare a ready-to-save version if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) @@ -2839,7 +2438,7 @@ int SaveMPQTables(TMPQArchive * ha) } // Create block table - if(nError == ERROR_SUCCESS && ha->pFileTable != NULL) + if(nError == ERROR_SUCCESS && ha->pHashTable != NULL) { pBlockTable = TranslateBlockTable(ha, &BlockTableSize64, &bNeedHiBlockTable); if(pBlockTable == NULL) @@ -2902,7 +2501,7 @@ int SaveMPQTables(TMPQArchive * ha) pHeader->HiBlockTableSize64 = HiBlockTableSize64; pHeader->HiBlockTablePos64 = TablePos; BSWAP_ARRAY16_UNSIGNED(pHiBlockTable, HiBlockTableSize64); - + if(!FileStream_Write(ha->pStream, &ByteOffset, pHiBlockTable, (DWORD)HiBlockTableSize64)) nError = GetLastError(); TablePos += HiBlockTableSize64; @@ -2920,23 +2519,18 @@ int SaveMPQTables(TMPQArchive * ha) // Write the MPQ header if(nError == ERROR_SUCCESS) { - TMPQHeader SaveMpqHeader; - // Update the size of the archive pHeader->ArchiveSize64 = TablePos; pHeader->dwArchiveSize = (DWORD)TablePos; - + // Update the MD5 of the archive header CalculateDataBlockHash(pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, pHeader->MD5_MpqHeader); // Write the MPQ header to the file - memcpy(&SaveMpqHeader, pHeader, pHeader->dwHeaderSize); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_1); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_2); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_3); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_4); - if(!FileStream_Write(ha->pStream, &ha->MpqPos, &SaveMpqHeader, pHeader->dwHeaderSize)) + BSWAP_TMPQHEADER(pHeader); + if(!FileStream_Write(ha->pStream, &ha->MpqPos, pHeader, pHeader->dwHeaderSize)) nError = GetLastError(); + BSWAP_TMPQHEADER(pHeader); } // Clear the changed flag diff --git a/dep/StormLib/src/SCompression.cpp b/dep/StormLib/src/SCompression.cpp index d706a6f37..19ef5940f 100644 --- a/dep/StormLib/src/SCompression.cpp +++ b/dep/StormLib/src/SCompression.cpp @@ -2,7 +2,7 @@ /* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */ /*---------------------------------------------------------------------------*/ /* This module serves as a bridge between StormLib code and (de)compression */ -/* functions. All (de)compression calls go (and should only go) through this */ +/* functions. All (de)compression calls go (and should only go) through this */ /* module. No system headers should be included in this module to prevent */ /* compile-time problems. */ /*---------------------------------------------------------------------------*/ @@ -22,34 +22,35 @@ // Information about the input and output buffers for pklib typedef struct { - unsigned char * pbInBuff; // Pointer to input data buffer - unsigned char * pbInBuffEnd; // End of the input buffer - unsigned char * pbOutBuff; // Pointer to output data buffer - unsigned char * pbOutBuffEnd; // Pointer to output data buffer + char * pbInBuff; // Pointer to input data buffer + char * pbInBuffEnd; // End of the input buffer + char * pbOutBuff; // Pointer to output data buffer + char * pbOutBuffEnd; // Pointer to output data buffer } TDataInfo; // Prototype of the compression function // Function doesn't return an error. A success means that the size of compressed buffer // is lower than size of uncompressed buffer. typedef void (*COMPRESS)( - void * pvOutBuffer, // [out] Pointer to the buffer where the compressed data will be stored - int * pcbOutBuffer, // [in] Pointer to length of the buffer pointed by pvOutBuffer - void * pvInBuffer, // [in] Pointer to the buffer with data to compress - int cbInBuffer, // [in] Length of the buffer pointer by pvInBuffer - int * pCmpType, // [in] Compression-method specific value. ADPCM Setups this for the following Huffman compression - int nCmpLevel); // [in] Compression specific value. ADPCM uses this. Should be set to zero. + char * pbOutBuffer, // [out] Pointer to the buffer where the compressed data will be stored + int * pcbOutBuffer, // [in] Pointer to length of the buffer pointed by pbOutBuffer + // [out] Contains length of the compressed data + char * pbInBuffer, // [in] Pointer to the buffer with data to compress + int cbInBuffer, // [in] Length of the buffer pointer by pbInBuffer + int * pCmpType, // [in] Compression-method specific value. ADPCM Setups this for the following Huffman compression + int nCmpLevel); // [in] Compression specific value. ADPCM uses this. Should be set to zero. // Prototype of the decompression function // Returns 1 if success, 0 if failure typedef int (*DECOMPRESS)( - void * pvOutBuffer, // [out] Pointer to the buffer where to store decompressed data - int * pcbOutBuffer, // [in] Pointer to total size of the buffer pointed by pvOutBuffer - // [out] Contains length of the decompressed data - void * pvInBuffer, // [in] Pointer to data to be decompressed - int cbInBuffer); // [in] Length of the data to be decompressed + char * pbOutBuffer, // [out] Pointer to the buffer where to store decompressed data + int * pcbOutBuffer, // [in] Pointer to total size of the buffer pointed by pbOutBuffer + // [out] Contains length of the decompressed data + char * pbInBuffer, // [in] Pointer to data to be decompressed + int cbInBuffer); // [in] Length of the data to be decompressed // Table of compression functions -typedef struct +typedef struct { unsigned long uMask; // Compression mask COMPRESS Compress; // Compression function @@ -69,22 +70,59 @@ typedef struct /* */ /*****************************************************************************/ -void Compress_huff(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +// 1500F4C0 +void Compress_huff( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * pCmpType, + int /* nCmpLevel */) { - THuffmannTree ht(true); - TOutputStream os(pvOutBuffer, *pcbOutBuffer); + THuffmannTree ht; // Huffmann tree for compression + TOutputStream os; // Output stream - STORMLIB_UNUSED(nCmpLevel); - *pcbOutBuffer = ht.Compress(&os, pvInBuffer, cbInBuffer, *pCmpType); -} + // Initialize output stream + os.pbOutBuffer = (unsigned char *)pbOutBuffer; + os.cbOutSize = *pcbOutBuffer; + os.pbOutPos = (unsigned char *)pbOutBuffer; + os.dwBitBuff = 0; + os.nBits = 0; -int Decompress_huff(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) + // Initialize the Huffmann tree for compression + ht.InitTree(true); + + *pcbOutBuffer = ht.DoCompression(&os, (unsigned char *)pbInBuffer, cbInBuffer, *pCmpType); + + // The following code is not necessary to run, because it has no + // effect on the output data. It only clears the huffmann tree, but when + // the tree is on the stack, who cares ? + // ht.UninitTree(); +} + +// 1500F5F0 +int Decompress_huff(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { - THuffmannTree ht(false); - TInputStream is(pvInBuffer, cbInBuffer); + THuffmannTree ht; + TInputStream is; - *pcbOutBuffer = ht.Decompress(pvOutBuffer, *pcbOutBuffer, &is); - return (*pcbOutBuffer == 0) ? 0 : 1; + // Initialize input stream + is.pbInBufferEnd = (unsigned char *)pbInBuffer + cbInBuffer; + is.pbInBuffer = (unsigned char *)pbInBuffer; + is.BitBuffer = 0; + is.BitCount = 0; + + // Initialize the Huffmann tree for compression + ht.InitTree(false); + *pcbOutBuffer = ht.DoDecompression((unsigned char *)pbOutBuffer, *pcbOutBuffer, &is); + if(*pcbOutBuffer == 0) + return 0; + + // The following code is not necessary to run, because it has no + // effect on the output data. It only clears the huffmann tree, but when + // the tree is on the stack, who cares ? + // ht.UninitTree(); + return 1; } /******************************************************************************/ @@ -93,21 +131,23 @@ int Decompress_huff(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i /* */ /******************************************************************************/ -void Compress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +void Compress_ZLIB( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * /* pCmpType */, + int /* nCmpLevel */) { z_stream z; // Stream information for zlib int windowBits; int nResult; - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - // Fill the stream structure for zlib - z.next_in = (Bytef *)pvInBuffer; + z.next_in = (Bytef *)pbInBuffer; z.avail_in = (uInt)cbInBuffer; z.total_in = cbInBuffer; - z.next_out = (Bytef *)pvOutBuffer; + z.next_out = (Bytef *)pbOutBuffer; z.avail_out = *pcbOutBuffer; z.total_out = 0; z.zalloc = NULL; @@ -135,16 +175,16 @@ void Compress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, in // Storm.dll uses zlib version 1.1.3 // Wow.exe uses zlib version 1.2.3 nResult = deflateInit2(&z, - 6, // Compression level used by WoW MPQs - Z_DEFLATED, - windowBits, - 8, - Z_DEFAULT_STRATEGY); + 6, // Compression level used by WoW MPQs + Z_DEFLATED, + windowBits, + 8, + Z_DEFAULT_STRATEGY); if(nResult == Z_OK) { // Call zlib to compress the data nResult = deflate(&z, Z_FINISH); - + if(nResult == Z_OK || nResult == Z_STREAM_END) *pcbOutBuffer = z.total_out; @@ -152,16 +192,16 @@ void Compress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, in } } -int Decompress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +int Decompress_ZLIB(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { z_stream z; // Stream information for zlib int nResult; // Fill the stream structure for zlib - z.next_in = (Bytef *)pvInBuffer; + z.next_in = (Bytef *)pbInBuffer; z.avail_in = (uInt)cbInBuffer; z.total_in = cbInBuffer; - z.next_out = (Bytef *)pvOutBuffer; + z.next_out = (Bytef *)pbOutBuffer; z.avail_out = *pcbOutBuffer; z.total_out = 0; z.zalloc = NULL; @@ -187,7 +227,7 @@ int Decompress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i // Function loads data from the input buffer. Used by Pklib's "implode" // and "explode" function as user-defined callback // Returns number of bytes loaded -// +// // char * buf - Pointer to a buffer where to store loaded data // unsigned int * size - Max. number of bytes to read // void * param - Custom pointer, parameter of implode/explode @@ -201,7 +241,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) // Check the case when not enough data available if(nToRead > nMaxAvail) nToRead = nMaxAvail; - + // Load data and increment offsets memcpy(buf, pInfo->pbInBuff, nToRead); pInfo->pbInBuff += nToRead; @@ -211,7 +251,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) // Function for store output data. Used by Pklib's "implode" and "explode" // as user-defined callback -// +// // char * buf - Pointer to data to be written // unsigned int * size - Number of bytes to write // void * param - Custom pointer, parameter of implode/explode @@ -232,77 +272,68 @@ static void WriteOutputData(char * buf, unsigned int * size, void * param) assert(pInfo->pbOutBuff <= pInfo->pbOutBuffEnd); } -static void Compress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +static void Compress_PKLIB( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * /* pCmpType */, + int /* nCmpLevel */) { TDataInfo Info; // Data information char * work_buf = STORM_ALLOC(char, CMP_BUFFER_SIZE);// Pklib's work buffer unsigned int dict_size; // Dictionary size unsigned int ctype = CMP_BINARY; // Compression type - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); + // Fill data information structure + memset(work_buf, 0, CMP_BUFFER_SIZE); + Info.pbInBuff = pbInBuffer; + Info.pbInBuffEnd = pbInBuffer + cbInBuffer; + Info.pbOutBuff = pbOutBuffer; + Info.pbOutBuffEnd = pbOutBuffer + *pcbOutBuffer; - // Handle no-memory condition - if(work_buf != NULL) - { - // Fill data information structure - memset(work_buf, 0, CMP_BUFFER_SIZE); - Info.pbInBuff = (unsigned char *)pvInBuffer; - Info.pbInBuffEnd = (unsigned char *)pvInBuffer + cbInBuffer; - Info.pbOutBuff = (unsigned char *)pvOutBuffer; - Info.pbOutBuffEnd = (unsigned char *)pvOutBuffer + *pcbOutBuffer; + // + // Set the dictionary size + // + // Diablo I ues fixed dictionary size of CMP_IMPLODE_DICT_SIZE3 + // Starcraft uses the variable dictionary size based on algorithm below + // - // - // Set the dictionary size - // - // Diablo I uses fixed dictionary size of CMP_IMPLODE_DICT_SIZE3 - // Starcraft I uses the variable dictionary size based on algorithm below - // + if (cbInBuffer < 0x600) + dict_size = CMP_IMPLODE_DICT_SIZE1; + else if(0x600 <= cbInBuffer && cbInBuffer < 0xC00) + dict_size = CMP_IMPLODE_DICT_SIZE2; + else + dict_size = CMP_IMPLODE_DICT_SIZE3; - if (cbInBuffer < 0x600) - dict_size = CMP_IMPLODE_DICT_SIZE1; - else if(0x600 <= cbInBuffer && cbInBuffer < 0xC00) - dict_size = CMP_IMPLODE_DICT_SIZE2; - else - dict_size = CMP_IMPLODE_DICT_SIZE3; + // Do the compression + if(implode(ReadInputData, WriteOutputData, work_buf, &Info, &ctype, &dict_size) == CMP_NO_ERROR) + *pcbOutBuffer = (int)(Info.pbOutBuff - pbOutBuffer); - // Do the compression - if(implode(ReadInputData, WriteOutputData, work_buf, &Info, &ctype, &dict_size) == CMP_NO_ERROR) - *pcbOutBuffer = (int)(Info.pbOutBuff - (unsigned char *)pvOutBuffer); - - STORM_FREE(work_buf); - } + STORM_FREE(work_buf); } -static int Decompress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +static int Decompress_PKLIB(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { TDataInfo Info; // Data information char * work_buf = STORM_ALLOC(char, EXP_BUFFER_SIZE);// Pklib's work buffer - // Handle no-memory condition - if(work_buf == NULL) - return 0; - // Fill data information structure memset(work_buf, 0, EXP_BUFFER_SIZE); - Info.pbInBuff = (unsigned char *)pvInBuffer; - Info.pbInBuffEnd = (unsigned char *)pvInBuffer + cbInBuffer; - Info.pbOutBuff = (unsigned char *)pvOutBuffer; - Info.pbOutBuffEnd = (unsigned char *)pvOutBuffer + *pcbOutBuffer; + Info.pbInBuff = pbInBuffer; + Info.pbInBuffEnd = pbInBuffer + cbInBuffer; + Info.pbOutBuff = pbOutBuffer; + Info.pbOutBuffEnd = pbOutBuffer + *pcbOutBuffer; // Do the decompression explode(ReadInputData, WriteOutputData, work_buf, &Info); - + // If PKLIB is unable to decompress the data, return 0; - if(Info.pbOutBuff == pvOutBuffer) - { - STORM_FREE(work_buf); + if(Info.pbOutBuff == pbOutBuffer) return 0; - } // Give away the number of decompressed bytes - *pcbOutBuffer = (int)(Info.pbOutBuff - (unsigned char *)pvOutBuffer); + *pcbOutBuffer = (int)(Info.pbOutBuff - pbOutBuffer); STORM_FREE(work_buf); return 1; } @@ -313,29 +344,30 @@ static int Decompress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB /* */ /******************************************************************************/ -static void Compress_BZIP2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +static void Compress_BZIP2( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * /* pCmpType */, + int /* nCmpLevel */) { bz_stream strm; int blockSize100k = 9; int workFactor = 30; int bzError; - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - // Initialize the BZIP2 compression strm.bzalloc = NULL; strm.bzfree = NULL; - strm.opaque = NULL; // Blizzard uses 9 as blockSize100k, (0x30 as workFactor) // Last checked on Starcraft II if(BZ2_bzCompressInit(&strm, blockSize100k, 0, workFactor) == BZ_OK) { - strm.next_in = (char *)pvInBuffer; + strm.next_in = pbInBuffer; strm.avail_in = cbInBuffer; - strm.next_out = (char *)pvOutBuffer; + strm.next_out = pbOutBuffer; strm.avail_out = *pcbOutBuffer; // Perform the compression @@ -354,7 +386,7 @@ static void Compress_BZIP2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu } } -static int Decompress_BZIP2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +static int Decompress_BZIP2(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { bz_stream strm; int nResult = BZ_OK; @@ -362,22 +394,19 @@ static int Decompress_BZIP2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB // Initialize the BZIP2 decompression strm.bzalloc = NULL; strm.bzfree = NULL; - strm.opaque = NULL; - - // Initialize decompression if(BZ2_bzDecompressInit(&strm, 0, 0) == BZ_OK) { - strm.next_in = (char *)pvInBuffer; + strm.next_in = pbInBuffer; strm.avail_in = cbInBuffer; - strm.next_out = (char *)pvOutBuffer; + strm.next_out = pbOutBuffer; strm.avail_out = *pcbOutBuffer; // Perform the decompression while(nResult != BZ_STREAM_END) { nResult = BZ2_bzDecompress(&strm); - - // If any error there, break the loop + + // If any error there, break the loop if(nResult < BZ_OK) break; } @@ -432,12 +461,17 @@ static void LZMA_Callback_Free(void *p, void *address) // the data compressed by StormLib. // -static void Compress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +/*static */ void Compress_LZMA( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * /* pCmpType */, + int /* nCmpLevel */) { ICompressProgress Progress; CLzmaEncProps props; ISzAlloc SzAlloc; - Byte * pbOutBuffer = (Byte *)pvOutBuffer; Byte * destBuffer; SizeT destLen = *pcbOutBuffer; SizeT srcLen = cbInBuffer; @@ -445,10 +479,6 @@ static void Compress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuf size_t encodedPropsSize = LZMA_PROPS_SIZE; SRes nResult; - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - // Fill the callbacks in structures Progress.Progress = LZMA_Callback_Progress; SzAlloc.Alloc = LZMA_Callback_Alloc; @@ -458,19 +488,19 @@ static void Compress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuf LzmaEncProps_Init(&props); // Perform compression - destBuffer = (Byte *)pvOutBuffer + LZMA_HEADER_SIZE; + destBuffer = (Byte *)pbOutBuffer + LZMA_HEADER_SIZE; destLen = *pcbOutBuffer - LZMA_HEADER_SIZE; nResult = LzmaEncode(destBuffer, - &destLen, - (Byte *)pvInBuffer, + &destLen, + (Byte *)pbInBuffer, srcLen, - &props, + &props, encodedProps, - &encodedPropsSize, + &encodedPropsSize, 0, - &Progress, - &SzAlloc, - &SzAlloc); + &Progress, + &SzAlloc, + &SzAlloc); if(nResult != SZ_OK) return; @@ -482,7 +512,7 @@ static void Compress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuf *pbOutBuffer++ = 0; // Copy the encoded properties to the output buffer - memcpy(pvOutBuffer, encodedProps, encodedPropsSize); + memcpy(pbOutBuffer, encodedProps, encodedPropsSize); pbOutBuffer += encodedPropsSize; // Copy the size of the data @@ -499,18 +529,18 @@ static void Compress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuf *pcbOutBuffer = (unsigned int)(destLen + LZMA_HEADER_SIZE); } -static int Decompress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +static int Decompress_LZMA(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { ELzmaStatus LzmaStatus; ISzAlloc SzAlloc; - Byte * destBuffer = (Byte *)pvOutBuffer; - Byte * srcBuffer = (Byte *)pvInBuffer; + Byte * destBuffer = (Byte *)pbOutBuffer; + Byte * srcBuffer = (Byte *)pbInBuffer; SizeT destLen = *pcbOutBuffer; SizeT srcLen = cbInBuffer; SRes nResult; // There must be at least 0x0E bytes in the buffer - if(srcLen <= LZMA_HEADER_SIZE) + if(srcLen <= LZMA_HEADER_SIZE) return 0; // We only accept blocks that have no filter used @@ -524,55 +554,14 @@ static int Decompress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu // Perform compression srcLen = cbInBuffer - LZMA_HEADER_SIZE; nResult = LzmaDecode(destBuffer, - &destLen, + &destLen, srcBuffer + LZMA_HEADER_SIZE, - &srcLen, - srcBuffer + 1, + &srcLen, + srcBuffer + 1, LZMA_PROPS_SIZE, LZMA_FINISH_END, - &LzmaStatus, - &SzAlloc); - if(nResult != SZ_OK) - return 0; - - *pcbOutBuffer = (unsigned int)destLen; - return 1; -} - -static int Decompress_LZMA_MPK(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - ELzmaStatus LzmaStatus; - ISzAlloc SzAlloc; - Byte * destBuffer = (Byte *)pvOutBuffer; - Byte * srcBuffer = (Byte *)pvInBuffer; - SizeT destLen = *pcbOutBuffer; - SizeT srcLen = cbInBuffer; - SRes nResult; - BYTE LZMA_Props[] = {0x5D, 0x00, 0x00, 0x00, 0x01}; - - // There must be at least 0x0E bytes in the buffer - if(srcLen <= sizeof(LZMA_Props)) - return 0; - - // Verify the props header - if(memcmp(pvInBuffer, LZMA_Props, sizeof(LZMA_Props))) - return 0; - - // Fill the callbacks in structures - SzAlloc.Alloc = LZMA_Callback_Alloc; - SzAlloc.Free = LZMA_Callback_Free; - - // Perform compression - srcLen = cbInBuffer - sizeof(LZMA_Props); - nResult = LzmaDecode(destBuffer, - &destLen, - srcBuffer + sizeof(LZMA_Props), - &srcLen, - srcBuffer, - sizeof(LZMA_Props), - LZMA_FINISH_END, - &LzmaStatus, - &SzAlloc); + &LzmaStatus, + &SzAlloc); if(nResult != SZ_OK) return 0; @@ -586,18 +575,20 @@ static int Decompress_LZMA_MPK(void * pvOutBuffer, int * pcbOutBuffer, void * pv /* */ /******************************************************************************/ -void Compress_SPARSE(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +void Compress_SPARSE( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * /* pCmpType */, + int /* nCmpLevel */) { - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - - CompressSparse(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer); + CompressSparse((unsigned char *)pbOutBuffer, pcbOutBuffer, (unsigned char *)pbInBuffer, cbInBuffer); } -int Decompress_SPARSE(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +int Decompress_SPARSE(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { - return DecompressSparse(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer); + return DecompressSparse((unsigned char *)pbOutBuffer, pcbOutBuffer, (unsigned char *)pbInBuffer, cbInBuffer); } /******************************************************************************/ @@ -606,7 +597,13 @@ int Decompress_SPARSE(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, /* */ /******************************************************************************/ -static void Compress_ADPCM_mono(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +static void Compress_ADPCM_mono( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * pCmpType, + int nCmpLevel) { // Prepare the compression level for Huffmann compression, // which will be called as next step @@ -625,12 +622,12 @@ static void Compress_ADPCM_mono(void * pvOutBuffer, int * pcbOutBuffer, void * p nCmpLevel = 5; *pCmpType = 7; } - *pcbOutBuffer = CompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 1, nCmpLevel); + *pcbOutBuffer = CompressADPCM((unsigned char *)pbOutBuffer, *pcbOutBuffer, (short *)pbInBuffer, cbInBuffer, 1, nCmpLevel); } -static int Decompress_ADPCM_mono(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +static int Decompress_ADPCM_mono(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { - *pcbOutBuffer = DecompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 1); + *pcbOutBuffer = DecompressADPCM((unsigned char *)pbOutBuffer, *pcbOutBuffer, (unsigned char *)pbInBuffer, cbInBuffer, 1); return 1; } @@ -640,7 +637,13 @@ static int Decompress_ADPCM_mono(void * pvOutBuffer, int * pcbOutBuffer, void * /* */ /******************************************************************************/ -static void Compress_ADPCM_stereo(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) +static void Compress_ADPCM_stereo( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + int * pCmpType, + int nCmpLevel) { // Prepare the compression level for Huffmann compression, // which will be called as next step @@ -659,12 +662,12 @@ static void Compress_ADPCM_stereo(void * pvOutBuffer, int * pcbOutBuffer, void * nCmpLevel = 5; *pCmpType = 7; } - *pcbOutBuffer = CompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 2, nCmpLevel); + *pcbOutBuffer = CompressADPCM((unsigned char *)pbOutBuffer, *pcbOutBuffer, (short *)pbInBuffer, cbInBuffer, 2, nCmpLevel); } -static int Decompress_ADPCM_stereo(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +static int Decompress_ADPCM_stereo(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { - *pcbOutBuffer = DecompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 2); + *pcbOutBuffer = DecompressADPCM((unsigned char *)pbOutBuffer, *pcbOutBuffer, (unsigned char *)pbInBuffer, cbInBuffer, 2); return 1; } @@ -674,25 +677,24 @@ static int Decompress_ADPCM_stereo(void * pvOutBuffer, int * pcbOutBuffer, void /* */ /*****************************************************************************/ -int WINAPI SCompImplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +int WINAPI SCompImplode(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { - int cbOutBuffer; + int cbOutBuffer = *pcbOutBuffer; // Check for valid parameters - if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer) + if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pbOutBuffer || !pbInBuffer) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } // Perform the compression - cbOutBuffer = *pcbOutBuffer; - Compress_PKLIB(pvOutBuffer, &cbOutBuffer, pvInBuffer, cbInBuffer, NULL, 0); + Compress_PKLIB(pbOutBuffer, &cbOutBuffer, pbInBuffer, cbInBuffer, NULL, 0); // If the compression was unsuccessful, copy the data as-is if(cbOutBuffer >= *pcbOutBuffer) { - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); + memcpy(pbOutBuffer, pbInBuffer, cbInBuffer); cbOutBuffer = *pcbOutBuffer; } @@ -706,34 +708,33 @@ int WINAPI SCompImplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffe /* */ /*****************************************************************************/ -int WINAPI SCompExplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +int WINAPI SCompExplode(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) { - int cbOutBuffer; + int cbOutBuffer = *pcbOutBuffer; // Check for valid parameters - if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer) + if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pbOutBuffer || !pbInBuffer) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } // If the input length is the same as output length, do nothing. - cbOutBuffer = *pcbOutBuffer; if(cbInBuffer == cbOutBuffer) { // If the buffers are equal, don't copy anything. - if(pvInBuffer == pvOutBuffer) + if(pbInBuffer == pbOutBuffer) return 1; - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); + memcpy(pbOutBuffer, pbInBuffer, cbInBuffer); return 1; } - + // Perform decompression - if(!Decompress_PKLIB(pvOutBuffer, &cbOutBuffer, pvInBuffer, cbInBuffer)) + if(!Decompress_PKLIB(pbOutBuffer, &cbOutBuffer, pbInBuffer, cbInBuffer)) { SetLastError(ERROR_FILE_CORRUPT); - return 0; + return false; } *pcbOutBuffer = cbOutBuffer; @@ -757,23 +758,29 @@ int WINAPI SCompExplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffe static TCompressTable cmp_table[] = { - {MPQ_COMPRESSION_SPARSE, Compress_SPARSE}, // Sparse compression - {MPQ_COMPRESSION_ADPCM_MONO, Compress_ADPCM_mono}, // IMA ADPCM mono compression - {MPQ_COMPRESSION_ADPCM_STEREO, Compress_ADPCM_stereo}, // IMA ADPCM stereo compression - {MPQ_COMPRESSION_HUFFMANN, Compress_huff}, // Huffmann compression - {MPQ_COMPRESSION_ZLIB, Compress_ZLIB}, // Compression with the "zlib" library - {MPQ_COMPRESSION_PKWARE, Compress_PKLIB}, // Compression with Pkware DCL - {MPQ_COMPRESSION_BZIP2, Compress_BZIP2} // Compression Bzip2 library + {MPQ_COMPRESSION_SPARSE, Compress_SPARSE}, // Sparse compression + {MPQ_COMPRESSION_ADPCM_MONO, Compress_ADPCM_mono}, // IMA ADPCM mono compression + {MPQ_COMPRESSION_ADPCM_STEREO, Compress_ADPCM_stereo}, // IMA ADPCM stereo compression + {MPQ_COMPRESSION_HUFFMANN, Compress_huff}, // Huffmann compression + {MPQ_COMPRESSION_ZLIB, Compress_ZLIB}, // Compression with the "zlib" library + {MPQ_COMPRESSION_PKWARE, Compress_PKLIB}, // Compression with Pkware DCL + {MPQ_COMPRESSION_BZIP2, Compress_BZIP2} // Compression Bzip2 library }; -int WINAPI SCompCompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel) +int WINAPI SCompCompress( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer, + unsigned uCompressionMask, + int nCmpType, + int nCmpLevel) { - COMPRESS CompressFuncArray[0x10]; // Array of compression functions, applied sequentially - unsigned char CompressByte[0x10]; // CompressByte for each method in the CompressFuncArray array - unsigned char * pbWorkBuffer = NULL; // Temporary storage for decompressed data - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbOutput = (unsigned char *)pvOutBuffer;// Current output buffer - unsigned char * pbInput = (unsigned char *)pvInBuffer; // Current input buffer + COMPRESS CompressFuncArray[0x10]; // Array of compression functions, applied sequentially + unsigned char CompressByte[0x10]; // CompressByte for each method in the CompressFuncArray array + char * pbWorkBuffer = NULL; // Temporary storage for decompressed data + char * pbOutput = pbOutBuffer; // Current output buffer + char * pbInput = pbInBuffer; // Current input buffer int nCompressCount = 0; int nCompressIndex = 0; int nAtLeastOneCompressionDone = 0; @@ -782,7 +789,7 @@ int WINAPI SCompCompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuff int nResult = 1; // Check for valid parameters - if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer) + if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pbOutBuffer || !pbInBuffer) { SetLastError(ERROR_INVALID_PARAMETER); return 0; @@ -831,7 +838,7 @@ int WINAPI SCompCompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuff // If we need to do more than 1 compression, allocate intermediate buffer if(nCompressCount > 1) { - pbWorkBuffer = STORM_ALLOC(unsigned char, *pcbOutBuffer); + pbWorkBuffer = STORM_ALLOC(char, *pcbOutBuffer); if(pbWorkBuffer == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -877,12 +884,12 @@ int WINAPI SCompCompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuff // If at least one compression succeeded, put the compression // mask to the begin of the output buffer if(nAtLeastOneCompressionDone) - *pbOutBuffer = (unsigned char)uCompressionMask; + *pbOutBuffer = (char)uCompressionMask; *pcbOutBuffer = cbOutBuffer + nAtLeastOneCompressionDone; } else { - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); + memcpy(pbOutBuffer, pbInBuffer, cbInBuffer); *pcbOutBuffer = cbInBuffer; } @@ -912,13 +919,15 @@ static TDecompressTable dcmp_table[] = {MPQ_COMPRESSION_SPARSE, Decompress_SPARSE} // Sparse decompression }; -int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +int WINAPI SCompDecompress( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer) { - unsigned char * pbWorkBuffer = NULL; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; - unsigned char * pbOutput = (unsigned char *)pvOutBuffer; - unsigned char * pbInput; + char * pbWorkBuffer = NULL; // Temporary storage for decompressed data + char * pbOutput = pbOutBuffer; // Where to store decompressed data + char * pbInput; // Where to store decompressed data unsigned uCompressionMask; // Decompressions applied to the data unsigned uCompressionCopy; // Decompressions applied to the data int cbOutBuffer = *pcbOutBuffer; // Current size of the output buffer @@ -935,8 +944,8 @@ int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu if(cbOutBuffer == cbInBuffer) { // If the buffers are equal, don't copy anything. - if(pvInBuffer != pvOutBuffer) - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); + if(pbInBuffer != pbOutBuffer) + memcpy(pbOutBuffer, pbInBuffer, cbInBuffer); return 1; } @@ -972,7 +981,7 @@ int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu // If there is more than one compression, we have to allocate extra buffer if(nCompressCount > 1) { - pbWorkBuffer = STORM_ALLOC(unsigned char, cbOutBuffer); + pbWorkBuffer = STORM_ALLOC(char, cbOutBuffer); if(pbWorkBuffer == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -992,7 +1001,7 @@ int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu // Get the correct output buffer pbOutput = (nCompressIndex & 1) ? pbWorkBuffer : pbOutBuffer; nCompressIndex--; - + // Perform the decompression cbOutBuffer = *pcbOutBuffer; nResult = dcmp_table[i].Decompress(pbOutput, &cbOutBuffer, pbInput, cbInLength); @@ -1018,12 +1027,15 @@ int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu return nResult; } -int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +int WINAPI SCompDecompress2( + char * pbOutBuffer, + int * pcbOutBuffer, + char * pbInBuffer, + int cbInBuffer) { DECOMPRESS pfnDecompress1 = NULL; DECOMPRESS pfnDecompress2 = NULL; - unsigned char * pbWorkBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; + char * pbWorkBuffer = pbOutBuffer; int cbWorkBuffer = *pcbOutBuffer; int nResult; char CompressionMethod; @@ -1035,8 +1047,8 @@ int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB // If the outputbuffer is as big as input buffer, just copy the block if(*pcbOutBuffer == cbInBuffer) { - if(pvOutBuffer != pvInBuffer) - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); + if(pbOutBuffer != pbInBuffer) + memcpy(pbOutBuffer, pbInBuffer, cbInBuffer); return 1; } @@ -1047,35 +1059,35 @@ int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB // We only recognize a fixed set of compression methods switch((unsigned char)CompressionMethod) { - case MPQ_COMPRESSION_ZLIB: - pfnDecompress1 = Decompress_ZLIB; - break; + case MPQ_COMPRESSION_ZLIB: + pfnDecompress1 = Decompress_ZLIB; + break; - case MPQ_COMPRESSION_PKWARE: - pfnDecompress1 = Decompress_PKLIB; - break; + case MPQ_COMPRESSION_PKWARE: + pfnDecompress1 = Decompress_PKLIB; + break; - case MPQ_COMPRESSION_BZIP2: - pfnDecompress1 = Decompress_BZIP2; - break; + case MPQ_COMPRESSION_BZIP2: + pfnDecompress1 = Decompress_BZIP2; + break; - case MPQ_COMPRESSION_LZMA: - pfnDecompress1 = Decompress_LZMA; - break; + case MPQ_COMPRESSION_LZMA: + pfnDecompress1 = Decompress_LZMA; + break; - case MPQ_COMPRESSION_SPARSE: - pfnDecompress1 = Decompress_SPARSE; - break; + case MPQ_COMPRESSION_SPARSE: + pfnDecompress1 = Decompress_SPARSE; + break; - case (MPQ_COMPRESSION_SPARSE | MPQ_COMPRESSION_ZLIB): - pfnDecompress1 = Decompress_ZLIB; - pfnDecompress2 = Decompress_SPARSE; - break; + case (MPQ_COMPRESSION_SPARSE | MPQ_COMPRESSION_ZLIB): + pfnDecompress1 = Decompress_ZLIB; + pfnDecompress2 = Decompress_SPARSE; + break; - case (MPQ_COMPRESSION_SPARSE | MPQ_COMPRESSION_BZIP2): - pfnDecompress1 = Decompress_BZIP2; - pfnDecompress2 = Decompress_SPARSE; - break; + case (MPQ_COMPRESSION_SPARSE | MPQ_COMPRESSION_BZIP2): + pfnDecompress1 = Decompress_BZIP2; + pfnDecompress2 = Decompress_SPARSE; + break; // // Note: Any combination including MPQ_COMPRESSION_ADPCM_MONO, @@ -1083,25 +1095,15 @@ int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB // is not supported by newer MPQs. // - case (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_HUFFMANN): - pfnDecompress1 = Decompress_huff; - pfnDecompress2 = Decompress_ADPCM_mono; - break; - - case (MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN): - pfnDecompress1 = Decompress_huff; - pfnDecompress2 = Decompress_ADPCM_stereo; - break; - - default: - SetLastError(ERROR_FILE_CORRUPT); - return 0; + default: + SetLastError(ERROR_FILE_CORRUPT); + return 0; } // If we have to use two decompressions, allocate temporary buffer if(pfnDecompress2 != NULL) { - pbWorkBuffer = STORM_ALLOC(unsigned char, *pcbOutBuffer); + pbWorkBuffer = STORM_ALLOC(char, *pcbOutBuffer); if(pbWorkBuffer == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -1117,29 +1119,17 @@ int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB { cbInBuffer = cbWorkBuffer; cbWorkBuffer = *pcbOutBuffer; - nResult = pfnDecompress2(pvOutBuffer, &cbWorkBuffer, pbWorkBuffer, cbInBuffer); + nResult = pfnDecompress2(pbOutBuffer, &cbWorkBuffer, pbWorkBuffer, cbInBuffer); } // Supply the output buffer size *pcbOutBuffer = cbWorkBuffer; // Free temporary buffer - if(pbWorkBuffer != pvOutBuffer) + if(pbWorkBuffer != pbOutBuffer) STORM_FREE(pbWorkBuffer); if(nResult == 0) SetLastError(ERROR_FILE_CORRUPT); return nResult; } - -/*****************************************************************************/ -/* */ -/* File decompression for MPK archives */ -/* */ -/*****************************************************************************/ - -int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - return Decompress_LZMA_MPK(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer); -} - diff --git a/dep/StormLib/src/SFileAddFile.cpp b/dep/StormLib/src/SFileAddFile.cpp index 4572d89b8..3f12e697f 100644 --- a/dep/StormLib/src/SFileAddFile.cpp +++ b/dep/StormLib/src/SFileAddFile.cpp @@ -6,7 +6,6 @@ /* Date Ver Who Comment */ /* -------- ---- --- ------- */ /* 27.03.10 1.00 Lad Splitted from SFileCreateArchiveEx.cpp */ -/* 21.04.13 1.01 Dea AddFile callback now part of TMPQArchive */ /*****************************************************************************/ #define __STORMLIB_SELF__ @@ -14,17 +13,7 @@ #include "StormCommon.h" //----------------------------------------------------------------------------- -// Local variables - -// Mask for lossy compressions -#define MPQ_LOSSY_COMPRESSION_MASK (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN) - -// Data compression for SFileAddFile -// Kept here for compatibility with code that was created with StormLib version < 6.50 -static DWORD DefaultDataCompression = MPQ_COMPRESSION_PKWARE; - -//----------------------------------------------------------------------------- -// WAVE verification +// Local structures #define FILE_SIGNATURE_RIFF 0x46464952 #define FILE_SIGNATURE_WAVE 0x45564157 @@ -36,8 +25,8 @@ typedef struct _WAVE_FILE_HEADER DWORD dwChunkId; // 0x52494646 ("RIFF") DWORD dwChunkSize; // Size of that chunk, in bytes DWORD dwFormat; // Must be 0x57415645 ("WAVE") - - // Format sub-chunk + + // Format sub-chunk DWORD dwSubChunk1Id; // 0x666d7420 ("fmt ") DWORD dwSubChunk1Size; // 0x16 for PCM USHORT wAudioFormat; // 1 = PCM. Other value means some sort of compression @@ -50,29 +39,36 @@ typedef struct _WAVE_FILE_HEADER // Followed by "data" sub-chunk (we don't care) } WAVE_FILE_HEADER, *PWAVE_FILE_HEADER; -static bool IsWaveFile_16BitsPerAdpcmSample( - LPBYTE pbFileData, - DWORD cbFileData, - LPDWORD pdwChannels) +//----------------------------------------------------------------------------- +// Local variables + +// Data compression for SFileAddFile +// Kept here for compatibility with code that was created with StormLib version < 6.50 +static DWORD DefaultDataCompression = MPQ_COMPRESSION_PKWARE; + +static SFILE_ADDFILE_CALLBACK AddFileCB = NULL; +static void * pvUserData = NULL; + +//----------------------------------------------------------------------------- +// MPQ write data functions + +#define LOSSY_COMPRESSION_MASK (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN) + +static int IsWaveFile( + LPBYTE pbFileData, + DWORD cbFileData, + LPDWORD pdwChannels) { PWAVE_FILE_HEADER pWaveHdr = (PWAVE_FILE_HEADER)pbFileData; - // The amount of file data must be at least size of WAVE header if(cbFileData > sizeof(WAVE_FILE_HEADER)) { - // Check for the RIFF header if(pWaveHdr->dwChunkId == FILE_SIGNATURE_RIFF && pWaveHdr->dwFormat == FILE_SIGNATURE_WAVE) { - // Check for ADPCM format if(pWaveHdr->dwSubChunk1Id == FILE_SIGNATURE_FMT && pWaveHdr->wAudioFormat == AUDIO_FORMAT_PCM) { - // Now the number of bits per sample must be at least 16. - // If not, the WAVE file gets corrupted by the ADPCM compression - if(pWaveHdr->wBitsPerSample >= 0x10) - { - *pdwChannels = pWaveHdr->wChannels; - return true; - } + *pdwChannels = pWaveHdr->wChannels; + return true; } } } @@ -80,68 +76,33 @@ static bool IsWaveFile_16BitsPerAdpcmSample( return false; } -static int FillWritableHandle( - TMPQArchive * ha, - TMPQFile * hf, - ULONGLONG FileTime, - DWORD dwFileSize, - DWORD dwFlags) -{ - TFileEntry * pFileEntry = hf->pFileEntry; - - // Initialize the hash entry for the file - hf->RawFilePos = ha->MpqPos + hf->MpqFilePos; - hf->dwDataSize = dwFileSize; - - // Initialize the block table entry for the file - pFileEntry->ByteOffset = hf->MpqFilePos; - pFileEntry->dwFileSize = dwFileSize; - pFileEntry->dwCmpSize = 0; - pFileEntry->dwFlags = dwFlags | MPQ_FILE_EXISTS; - - // Initialize the file time, CRC32 and MD5 - assert(sizeof(hf->hctx) >= sizeof(hash_state)); - memset(pFileEntry->md5, 0, MD5_DIGEST_SIZE); - md5_init((hash_state *)hf->hctx); - pFileEntry->dwCrc32 = crc32(0, Z_NULL, 0); - - // If the caller gave us a file time, use it. - pFileEntry->FileTime = FileTime; - - // Mark the archive as modified - ha->dwFlags |= MPQ_FLAG_CHANGED; - - // Call the callback, if needed - if(ha->pfnAddFileCB != NULL) - ha->pfnAddFileCB(ha->pvAddFileUserData, 0, hf->dwDataSize, false); - hf->nAddFileError = ERROR_SUCCESS; - - return ERROR_SUCCESS; -} - -//----------------------------------------------------------------------------- -// MPQ write data functions static int WriteDataToMpqFile( - TMPQArchive * ha, - TMPQFile * hf, - LPBYTE pbFileData, - DWORD dwDataSize, - DWORD dwCompression) + TMPQArchive * ha, + TMPQFile * hf, + LPBYTE pbFileData, + DWORD dwDataSize, + DWORD dwCompression) { TFileEntry * pFileEntry = hf->pFileEntry; ULONGLONG ByteOffset; - LPBYTE pbCompressed = NULL; // Compressed (target) data - LPBYTE pbToWrite = hf->pbFileSector; // Data to write to the file - int nCompressionLevel; // ADPCM compression level (only used for wave files) + LPBYTE pbCompressed = NULL; // Compressed (target) data + LPBYTE pbToWrite = NULL; // Data to write to the file + int nCompressionLevel = -1; // ADPCM compression level (only used for wave files) int nError = ERROR_SUCCESS; + // If the caller wants ADPCM compression, we will set wave compression level to 4, + // which corresponds to medium quality + if(dwCompression & LOSSY_COMPRESSION_MASK) + nCompressionLevel = 4; + // Make sure that the caller won't overrun the previously initiated file size assert(hf->dwFilePos + dwDataSize <= pFileEntry->dwFileSize); assert(hf->dwSectorCount != 0); assert(hf->pbFileSector != NULL); if((hf->dwFilePos + dwDataSize) > pFileEntry->dwFileSize) return ERROR_DISK_FULL; + pbToWrite = hf->pbFileSector; // Now write all data to the file sector buffer if(nError == ERROR_SUCCESS) @@ -150,11 +111,11 @@ static int WriteDataToMpqFile( DWORD dwSectorIndex = hf->dwFilePos / hf->dwSectorSize; DWORD dwBytesToCopy; - // Process all data. + // Process all data. while(dwDataSize != 0) { dwBytesToCopy = dwDataSize; - + // Check for sector overflow if(dwBytesToCopy > (hf->dwSectorSize - dwBytesInSector)) dwBytesToCopy = (hf->dwSectorSize - dwBytesInSector); @@ -180,7 +141,7 @@ static int WriteDataToMpqFile( hf->dwCrc32 = crc32(hf->dwCrc32, hf->pbFileSector, dwBytesInSector); // Compress the file sector, if needed - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) + if(pFileEntry->dwFlags & MPQ_FILE_COMPRESSED) { int nOutBuffer = (int)dwBytesInSector; int nInBuffer = (int)dwBytesInSector; @@ -199,33 +160,27 @@ static int WriteDataToMpqFile( } // - // Note that both SCompImplode and SCompCompress copy data as-is, - // if they are unable to compress the data. + // Note that both SCompImplode and SCompCompress give original buffer, + // if they are unable to comperss the data. // if(pFileEntry->dwFlags & MPQ_FILE_IMPLODE) { - SCompImplode(pbCompressed, &nOutBuffer, hf->pbFileSector, nInBuffer); + SCompImplode((char *)pbCompressed, + &nOutBuffer, + (char *)hf->pbFileSector, + nInBuffer); } if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS) { - // If this is the first sector, we need to override the given compression - // by the first sector compression. This is because the entire sector must - // be compressed by the same compression. - // - // Test case: - // - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_PKWARE) // Write 0x10 bytes (sector 0) - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_ADPCM_MONO) // Write 0x10 bytes (still sector 0) - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_ADPCM_MONO) // Write 0x10 bytes (still sector 0) - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_ADPCM_MONO) // Write 0x10 bytes (still sector 0) - dwCompression = (dwSectorIndex == 0) ? hf->dwCompression0 : dwCompression; - - // If the caller wants ADPCM compression, we will set wave compression level to 4, - // which corresponds to medium quality - nCompressionLevel = (dwCompression & MPQ_LOSSY_COMPRESSION_MASK) ? 4 : -1; - SCompCompress(pbCompressed, &nOutBuffer, hf->pbFileSector, nInBuffer, (unsigned)dwCompression, 0, nCompressionLevel); + SCompCompress((char *)pbCompressed, + &nOutBuffer, + (char *)hf->pbFileSector, + nInBuffer, + (unsigned)dwCompression, + 0, + nCompressionLevel); } // Update sector positions @@ -236,7 +191,7 @@ static int WriteDataToMpqFile( // We have to calculate sector CRC, if enabled if(hf->SectorChksums != NULL) hf->SectorChksums[dwSectorIndex] = adler32(0, pbCompressed, nOutBuffer); - } + } // Encrypt the sector, if necessary if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) @@ -254,8 +209,8 @@ static int WriteDataToMpqFile( } // Call the compact callback, if any - if(ha->pfnAddFileCB != NULL) - ha->pfnAddFileCB(ha->pvAddFileUserData, hf->dwFilePos, hf->dwDataSize, false); + if(AddFileCB != NULL) + AddFileCB(pvUserData, hf->dwFilePos, hf->dwDataSize, false); // Update the compressed file size pFileEntry->dwCmpSize += dwBytesInSector; @@ -275,10 +230,10 @@ static int WriteDataToMpqFile( // Recrypts file data for file renaming static int RecryptFileData( - TMPQArchive * ha, - TMPQFile * hf, - const char * szFileName, - const char * szNewFileName) + TMPQArchive * ha, + TMPQFile * hf, + const char * szFileName, + const char * szNewFileName) { ULONGLONG RawFilePos; TFileEntry * pFileEntry = hf->pFileEntry; @@ -291,8 +246,8 @@ static int RecryptFileData( assert(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED); // File decryption key is calculated from the plain name - szNewFileName = GetPlainFileName(szNewFileName); - szFileName = GetPlainFileName(szFileName); + szNewFileName = GetPlainFileNameA(szNewFileName); + szFileName = GetPlainFileNameA(szFileName); // Calculate both file keys dwOldKey = DecryptFileKey(szFileName, pFileEntry->ByteOffset, pFileEntry->dwFileSize, pFileEntry->dwFlags); @@ -322,7 +277,7 @@ static int RecryptFileData( if(hf->SectorOffsets != NULL) { // Allocate secondary buffer for sectors copy - DWORD * SectorOffsetsCopy = STORM_ALLOC(DWORD, hf->SectorOffsets[0] / sizeof(DWORD)); + DWORD * SectorOffsetsCopy = (DWORD *)STORM_ALLOC(BYTE, hf->SectorOffsets[0]); DWORD dwSectorOffsLen = hf->SectorOffsets[0]; if(SectorOffsetsCopy == NULL) @@ -360,7 +315,7 @@ static int RecryptFileData( } // Calculate the raw file offset of the file sector - RawFilePos = CalculateRawSectorOffset(hf, dwRawByteOffset); + CalculateRawSectorOffset(RawFilePos, hf, dwRawByteOffset); // Read the file sector if(!FileStream_Read(ha->pStream, &RawFilePos, hf->pbFileSector, dwRawDataInSector)) @@ -370,7 +325,7 @@ static int RecryptFileData( } // If necessary, re-encrypt the sector - // Note: Recompression is not necessary here. Unlike encryption, + // Note: Recompression is not necessary here. Unlike encryption, // the compression does not depend on the position of the file in MPQ. BSWAP_ARRAY32_UNSIGNED(hf->pbFileSector, dwRawDataInSector); DecryptMpqBlock(hf->pbFileSector, dwRawDataInSector, dwOldKey + dwSector); @@ -393,20 +348,20 @@ static int RecryptFileData( } //----------------------------------------------------------------------------- -// Internal support for MPQ modifications +// Support functions for adding files to the MPQ int SFileAddFile_Init( - TMPQArchive * ha, - const char * szFileName, - ULONGLONG FileTime, - DWORD dwFileSize, - LCID lcLocale, - DWORD dwFlags, - TMPQFile ** phf) + TMPQArchive * ha, + const char * szFileName, + ULONGLONG FileTime, + DWORD dwFileSize, + LCID lcLocale, + DWORD dwFlags, + TMPQFile ** phf) { TFileEntry * pFileEntry = NULL; + ULONGLONG TempPos; // For various file offset calculations TMPQFile * hf = NULL; // File structure for newly added file - DWORD dwHashIndex = HASH_ENTRY_FREE; int nError = ERROR_SUCCESS; // @@ -420,9 +375,9 @@ int SFileAddFile_Init( dwFlags &= ~MPQ_FILE_SECTOR_CRC; // Sector CRC is not allowed if the file is not compressed - if(!(dwFlags & MPQ_FILE_COMPRESS_MASK)) + if(!(dwFlags & MPQ_FILE_COMPRESSED)) dwFlags &= ~MPQ_FILE_SECTOR_CRC; - + // Fix Key is not allowed if the file is not enrypted if(!(dwFlags & MPQ_FILE_ENCRYPTED)) dwFlags &= ~MPQ_FILE_FIX_KEY; @@ -433,133 +388,99 @@ int SFileAddFile_Init( lcLocale = 0; // Allocate the TMPQFile entry for newly added file - hf = CreateWritableHandle(ha, dwFileSize); + hf = CreateMpqFile(ha); if(hf == NULL) - return false; + nError = ERROR_NOT_ENOUGH_MEMORY; + + // Find a free space in the MPQ, as well as free block table entry + if(nError == ERROR_SUCCESS) + { + // Find the position where the file will be stored + FindFreeMpqSpace(ha, &hf->MpqFilePos); + hf->RawFilePos = ha->MpqPos + hf->MpqFilePos; + hf->bIsWriteHandle = true; + + // Sanity check: The MPQ must be marked as changed at this point + assert((ha->dwFlags & MPQ_FLAG_CHANGED) != 0); + + // When format V1, the size of the archive cannot exceed 4 GB + if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) + { + TempPos = hf->MpqFilePos + dwFileSize; + TempPos += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); + TempPos += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); + TempPos += ha->pHeader->dwBlockTableSize * sizeof(USHORT); + if((TempPos >> 32) != 0) + nError = ERROR_DISK_FULL; + } + } // Allocate file entry in the MPQ if(nError == ERROR_SUCCESS) { // Check if the file already exists in the archive - pFileEntry = GetFileEntryExact(ha, szFileName, lcLocale, &dwHashIndex); - if(pFileEntry != NULL) + pFileEntry = GetFileEntryExact(ha, szFileName, lcLocale); + if(pFileEntry == NULL) { - if(dwFlags & MPQ_FILE_REPLACEEXISTING) - InvalidateInternalFiles(ha); - else - nError = ERROR_ALREADY_EXISTS; + pFileEntry = AllocateFileEntry(ha, szFileName, lcLocale); + if(pFileEntry == NULL) + nError = ERROR_DISK_FULL; } else { - // Attempt to allocate new file entry - pFileEntry = AllocateFileEntry(ha, szFileName, lcLocale, &dwHashIndex); - if(pFileEntry != NULL) - InvalidateInternalFiles(ha); - else - nError = ERROR_DISK_FULL; + // If the file exists and "replace existing" is not set, fail it + if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0) + nError = ERROR_ALREADY_EXISTS; + + // If the file entry already contains a file + // and it is a pseudo-name, replace it + if(nError == ERROR_SUCCESS) + { + AllocateFileName(pFileEntry, szFileName); + } } - - // Set the file entry to the file structure - hf->pFileEntry = pFileEntry; } - // Prepare the pointer to hash table entry - if(nError == ERROR_SUCCESS && ha->pHashTable != NULL && dwHashIndex < ha->pHeader->dwHashTableSize) - { - hf->pHashEntry = ha->pHashTable + dwHashIndex; - hf->pHashEntry->lcLocale = (USHORT)lcLocale; - } + // + // At this point, the file name in file entry must be non-NULL + // - // Prepare the file key + // Create key for file encryption if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_ENCRYPTED)) { hf->dwFileKey = DecryptFileKey(szFileName, hf->MpqFilePos, dwFileSize, dwFlags); - if(hf->dwFileKey == 0) - nError = ERROR_UNKNOWN_FILE_KEY; } - // Fill the file entry and TMPQFile structure if(nError == ERROR_SUCCESS) { - // At this point, the file name in the file entry must be set - assert(pFileEntry->szFileName != NULL); - assert(_stricmp(pFileEntry->szFileName, szFileName) == 0); - - nError = FillWritableHandle(ha, hf, FileTime, dwFileSize, dwFlags); - } - - // Free the file handle if failed - if(nError != ERROR_SUCCESS && hf != NULL) - FreeFileHandle(hf); - - // Give the handle to the caller - *phf = hf; - return nError; -} - -int SFileAddFile_Init( - TMPQArchive * ha, - TMPQFile * hfSrc, - TMPQFile ** phf) -{ - TFileEntry * pFileEntry = NULL; - TMPQFile * hf = NULL; // File structure for newly added file - ULONGLONG FileTime = hfSrc->pFileEntry->FileTime; - DWORD dwFileSize = hfSrc->pFileEntry->dwFileSize; - DWORD dwFlags = hfSrc->pFileEntry->dwFlags; - int nError = ERROR_SUCCESS; - - // Allocate the TMPQFile entry for newly added file - hf = CreateWritableHandle(ha, dwFileSize); - if(hf == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - - // We need to keep the file entry index the same like in the source archive - // This is because multiple hash table entries can point to the same file entry - if(nError == ERROR_SUCCESS) - { - // Retrieve the file entry for the target file - pFileEntry = ha->pFileTable + (hfSrc->pFileEntry - hfSrc->ha->pFileTable); - - // Copy all variables except file name - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0) - { - pFileEntry[0] = hfSrc->pFileEntry[0]; - pFileEntry->szFileName = NULL; - } - else - nError = ERROR_ALREADY_EXISTS; - - // Set the file entry to the file structure + // Initialize the hash entry for the file hf->pFileEntry = pFileEntry; + hf->dwDataSize = dwFileSize; + + // Initialize the block table entry for the file + pFileEntry->ByteOffset = hf->MpqFilePos; + pFileEntry->dwFileSize = dwFileSize; + pFileEntry->dwCmpSize = 0; + pFileEntry->dwFlags = dwFlags | MPQ_FILE_EXISTS; + pFileEntry->lcLocale = (USHORT)lcLocale; + + // Initialize the file time, CRC32 and MD5 + assert(sizeof(hf->hctx) >= sizeof(hash_state)); + memset(pFileEntry->md5, 0, MD5_DIGEST_SIZE); + md5_init((hash_state *)hf->hctx); + pFileEntry->dwCrc32 = crc32(0, Z_NULL, 0); + + // If the caller gave us a file time, use it. + pFileEntry->FileTime = FileTime; + + // Call the callback, if needed + if(AddFileCB != NULL) + AddFileCB(pvUserData, 0, hf->dwDataSize, false); } - // Prepare the pointer to hash table entry - if(nError == ERROR_SUCCESS && ha->pHashTable != NULL && hfSrc->pHashEntry != NULL) - { - hf->dwHashIndex = (DWORD)(hfSrc->pHashEntry - hfSrc->ha->pHashTable); - hf->pHashEntry = ha->pHashTable + hf->dwHashIndex; - } - - // Prepare the file key (copy from source file) - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_ENCRYPTED)) - { - hf->dwFileKey = hfSrc->dwFileKey; - if(hf->dwFileKey == 0) - nError = ERROR_UNKNOWN_FILE_KEY; - } - - // Fill the file entry and TMPQFile structure - if(nError == ERROR_SUCCESS) - { - nError = FillWritableHandle(ha, hf, FileTime, dwFileSize, dwFlags); - } - - // Free the file handle if failed - if(nError != ERROR_SUCCESS && hf != NULL) - FreeFileHandle(hf); - - // Give the handle to the caller + // If an error occured, remember it + if(nError != ERROR_SUCCESS) + hf->bErrorOccured = true; *phf = hf; return nError; } @@ -584,9 +505,12 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d ULONGLONG RawFilePos = hf->RawFilePos; // Allocate buffer for file sector - hf->nAddFileError = nError = AllocateSectorBuffer(hf); + nError = AllocateSectorBuffer(hf); if(nError != ERROR_SUCCESS) + { + hf->bErrorOccured = true; return nError; + } // Allocate patch info, if the data is patch if(hf->pPatchInfo == NULL && IsIncrementalPatchFile(pvData, dwSize, &hf->dwPatchedFileSize)) @@ -595,25 +519,34 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d hf->pFileEntry->dwFlags |= MPQ_FILE_PATCH_FILE; // Allocate the patch info - hf->nAddFileError = nError = AllocatePatchInfo(hf, false); + nError = AllocatePatchInfo(hf, false); if(nError != ERROR_SUCCESS) + { + hf->bErrorOccured = true; return nError; + } } // Allocate sector offsets if(hf->SectorOffsets == NULL) { - hf->nAddFileError = nError = AllocateSectorOffsets(hf, false); + nError = AllocateSectorOffsets(hf, false); if(nError != ERROR_SUCCESS) + { + hf->bErrorOccured = true; return nError; + } } // Create array of sector checksums if(hf->SectorChksums == NULL && (pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC)) { - hf->nAddFileError = nError = AllocateSectorChecksums(hf, false); + nError = AllocateSectorChecksums(hf, false); if(nError != ERROR_SUCCESS) + { + hf->bErrorOccured = true; return nError; + } } // Pre-save the patch info, if any @@ -621,7 +554,7 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d { if(!FileStream_Write(ha->pStream, &RawFilePos, hf->pPatchInfo, hf->pPatchInfo->dwLength)) nError = GetLastError(); - + pFileEntry->dwCmpSize += hf->pPatchInfo->dwLength; RawFilePos += hf->pPatchInfo->dwLength; } @@ -641,16 +574,7 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d // Write the MPQ data to the file if(nError == ERROR_SUCCESS) - { - // Save the first sector compression to the file structure - // Note that the entire first file sector will be compressed - // by compression that was passed to the first call of SFileAddFile_Write - if(hf->dwFilePos == 0) - hf->dwCompression0 = dwCompression; - - // Write the data to the MPQ nError = WriteDataToMpqFile(ha, hf, (LPBYTE)pvData, dwSize, dwCompression); - } // If it succeeded and we wrote all the file data, // we need to re-save sector offset table @@ -668,6 +592,8 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d if(hf->SectorChksums != NULL) { nError = WriteSectorChecksums(hf); + if(nError != ERROR_SUCCESS) + hf->bErrorOccured = true; } // Now write patch info @@ -677,12 +603,16 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d hf->pPatchInfo->dwDataSize = hf->pFileEntry->dwFileSize; hf->pFileEntry->dwFileSize = hf->dwPatchedFileSize; nError = WritePatchInfo(hf); + if(nError != ERROR_SUCCESS) + hf->bErrorOccured = true; } // Now write sector offsets to the file if(hf->SectorOffsets != NULL) { nError = WriteSectorOffsets(hf); + if(nError != ERROR_SUCCESS) + hf->bErrorOccured = true; } // Write the MD5 hashes of each file chunk, if required @@ -692,12 +622,16 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d ha->MpqPos + hf->pFileEntry->ByteOffset, hf->pFileEntry->dwCmpSize, ha->pHeader->dwRawChunkSize); + if(nError != ERROR_SUCCESS) + hf->bErrorOccured = true; } } } + else + { + hf->bErrorOccured = true; + } - // Store the error code from the Write File operation - hf->nAddFileError = nError; return nError; } @@ -705,102 +639,110 @@ int SFileAddFile_Finish(TMPQFile * hf) { TMPQArchive * ha = hf->ha; TFileEntry * pFileEntry = hf->pFileEntry; - int nError = hf->nAddFileError; + int nError = ERROR_SUCCESS; // If all previous operations succeeded, we can update the MPQ - if(nError == ERROR_SUCCESS) + if(!hf->bErrorOccured) { // Verify if the caller wrote the file properly if(hf->pPatchInfo == NULL) { assert(pFileEntry != NULL); if(hf->dwFilePos != pFileEntry->dwFileSize) + { nError = ERROR_CAN_NOT_COMPLETE; + hf->bErrorOccured = true; + } } else { if(hf->dwFilePos != hf->pPatchInfo->dwDataSize) + { nError = ERROR_CAN_NOT_COMPLETE; + hf->bErrorOccured = true; + } } } - // Now we need to recreate the HET table, if exists - if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) - { - nError = RebuildHetTable(ha); - } - - // Update the block table size - if(nError == ERROR_SUCCESS) + if(!hf->bErrorOccured) { // Call the user callback, if any - if(ha->pfnAddFileCB != NULL) - ha->pfnAddFileCB(ha->pvAddFileUserData, hf->dwDataSize, hf->dwDataSize, true); + if(AddFileCB != NULL) + AddFileCB(pvUserData, hf->dwDataSize, hf->dwDataSize, true); + + // Update the size of the block table + ha->pHeader->dwBlockTableSize = ha->dwFileTableSize; } else { // Free the file entry in MPQ tables if(pFileEntry != NULL) - DeleteFileEntry(ha, hf); + FreeFileEntry(ha, pFileEntry); } // Clear the add file callback - FreeFileHandle(hf); + FreeMPQFile(hf); + pvUserData = NULL; + AddFileCB = NULL; return nError; } //----------------------------------------------------------------------------- -// Adds data as file to the archive +// Adds data as file to the archive bool WINAPI SFileCreateFile( - HANDLE hMpq, - const char * szArchivedName, - ULONGLONG FileTime, - DWORD dwFileSize, - LCID lcLocale, - DWORD dwFlags, - HANDLE * phFile) + HANDLE hMpq, + const char * szArchivedName, + ULONGLONG FileTime, + DWORD dwFileSize, + LCID lcLocale, + DWORD dwFlags, + HANDLE * phFile) { TMPQArchive * ha = (TMPQArchive *)hMpq; int nError = ERROR_SUCCESS; // Check valid parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) nError = ERROR_INVALID_HANDLE; if(szArchivedName == NULL || *szArchivedName == 0) nError = ERROR_INVALID_PARAMETER; if(phFile == NULL) nError = ERROR_INVALID_PARAMETER; - + // Don't allow to add file if the MPQ is open for read only - if(nError == ERROR_SUCCESS) - { - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - nError = ERROR_ACCESS_DENIED; + if(ha->dwFlags & MPQ_FLAG_READ_ONLY) + nError = ERROR_ACCESS_DENIED; - // Don't allow to add a file under pseudo-file name - if(IsPseudoFileName(szArchivedName, NULL)) - nError = ERROR_INVALID_PARAMETER; + // Don't allow to add a file under pseudo-file name + if(IsPseudoFileName(szArchivedName, NULL)) + nError = ERROR_INVALID_PARAMETER; - // Don't allow to add any of the internal files - if(IsInternalMpqFileName(szArchivedName)) - nError = ERROR_INTERNAL_FILE; - } + // Don't allow to add any of the internal files + if(IsInternalMpqFileName(szArchivedName)) + nError = ERROR_INTERNAL_FILE; // Perform validity check of the MPQ flags if(nError == ERROR_SUCCESS) { // Mask all unsupported flags out - dwFlags &= (ha->dwFlags & MPQ_FLAG_WAR3_MAP) ? MPQ_FILE_VALID_FLAGS_W3X : MPQ_FILE_VALID_FLAGS; + dwFlags &= MPQ_FILE_VALID_FLAGS; // Check for valid flag combinations if((dwFlags & (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS)) == (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS)) nError = ERROR_INVALID_PARAMETER; } - // Initiate the add file operation + // Create the file in MPQ if(nError == ERROR_SUCCESS) + { + // Invalidate the entries for (listfile) and (attributes) + // After we are done with MPQ changes, we need to re-create them anyway + InvalidateInternalFiles(ha); + + // Initiate the add file operation nError = SFileAddFile_Init(ha, szArchivedName, FileTime, dwFileSize, lcLocale, dwFlags, (TMPQFile **)phFile); + } // Deal with the errors if(nError != ERROR_SUCCESS) @@ -809,16 +751,16 @@ bool WINAPI SFileCreateFile( } bool WINAPI SFileWriteFile( - HANDLE hFile, - const void * pvData, - DWORD dwSize, - DWORD dwCompression) + HANDLE hFile, + const void * pvData, + DWORD dwSize, + DWORD dwCompression) { TMPQFile * hf = (TMPQFile *)hFile; int nError = ERROR_SUCCESS; // Check the proper parameters - if(!IsValidFileHandle(hFile)) + if(!IsValidFileHandle(hf)) nError = ERROR_INVALID_HANDLE; if(hf->bIsWriteHandle == false) nError = ERROR_INVALID_HANDLE; @@ -832,14 +774,14 @@ bool WINAPI SFileWriteFile( // the calling application must ensure that such flag combination doesn't get here // -// if(dwFlags & MPQ_FILE_IMPLODE) -// nError = ERROR_INVALID_PARAMETER; -// -// if(dwFlags & MPQ_FILE_ENCRYPTED) -// nError = ERROR_INVALID_PARAMETER; - + // if(dwFlags & MPQ_FILE_IMPLODE) + // nError = ERROR_INVALID_PARAMETER; + // + // if(dwFlags & MPQ_FILE_ENCRYPTED) + // nError = ERROR_INVALID_PARAMETER; + // Lossy compression is not allowed on single unit files - if(dwCompression & MPQ_LOSSY_COMPRESSION_MASK) + if(dwCompression & LOSSY_COMPRESSION_MASK) nError = ERROR_INVALID_PARAMETER; } @@ -847,7 +789,7 @@ bool WINAPI SFileWriteFile( // Write the data to the file if(nError == ERROR_SUCCESS) nError = SFileAddFile_Write(hf, pvData, dwSize, dwCompression); - + // Deal with errors if(nError != ERROR_SUCCESS) SetLastError(nError); @@ -860,7 +802,7 @@ bool WINAPI SFileFinishFile(HANDLE hFile) int nError = ERROR_SUCCESS; // Check the proper parameters - if(!IsValidFileHandle(hFile)) + if(!IsValidFileHandle(hf)) nError = ERROR_INVALID_HANDLE; if(hf->bIsWriteHandle == false) nError = ERROR_INVALID_HANDLE; @@ -868,7 +810,7 @@ bool WINAPI SFileFinishFile(HANDLE hFile) // Finish the file if(nError == ERROR_SUCCESS) nError = SFileAddFile_Finish(hf); - + // Deal with errors if(nError != ERROR_SUCCESS) SetLastError(nError); @@ -876,15 +818,15 @@ bool WINAPI SFileFinishFile(HANDLE hFile) } //----------------------------------------------------------------------------- -// Adds a file to the archive +// Adds a file to the archive bool WINAPI SFileAddFileEx( - HANDLE hMpq, - const TCHAR * szFileName, - const char * szArchivedName, - DWORD dwFlags, - DWORD dwCompression, // Compression of the first sector - DWORD dwCompressionNext) // Compression of next sectors + HANDLE hMpq, + const TCHAR * szFileName, + const char * szArchivedName, + DWORD dwFlags, + DWORD dwCompression, // Compression of the first sector + DWORD dwCompressionNext) // Compression of next sectors { ULONGLONG FileSize = 0; ULONGLONG FileTime = 0; @@ -900,22 +842,27 @@ bool WINAPI SFileAddFileEx( int nError = ERROR_SUCCESS; // Check parameters - if(hMpq == NULL || szFileName == NULL || *szFileName == 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } + if(szFileName == NULL || *szFileName == 0) + nError = ERROR_INVALID_PARAMETER; // Open added file - pStream = FileStream_OpenFile(szFileName, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE); - if(pStream == NULL) - return false; + if(nError == ERROR_SUCCESS) + { + pStream = FileStream_OpenFile(szFileName, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + if(pStream == NULL) + nError = GetLastError(); + } - // Files bigger than 4GB cannot be added to MPQ - FileStream_GetTime(pStream, &FileTime); - FileStream_GetSize(pStream, &FileSize); - if(FileSize >> 32) - nError = ERROR_DISK_FULL; + // Get the file size and file time + if(nError == ERROR_SUCCESS) + { + FileStream_GetTime(pStream, &FileTime); + FileStream_GetSize(pStream, &FileSize); + + // Files bigger than 4GB cannot be added to MPQ + if(FileSize >> 32) + nError = ERROR_DISK_FULL; + } // Allocate data buffer for reading from the source file if(nError == ERROR_SUCCESS) @@ -933,18 +880,15 @@ bool WINAPI SFileAddFileEx( // we will copy the compression for the first sector if(dwCompressionNext == MPQ_COMPRESSION_NEXT_SAME) dwCompressionNext = dwCompression; - + // If the caller wants ADPCM compression, we make sure // that the first sector is not compressed with lossy compression if(dwCompressionNext & (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO)) { - // The compression of the first file sector must not be ADPCM - // in order not to corrupt the headers + // The first compression must not be WAVE if(dwCompression & (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO)) dwCompression = MPQ_COMPRESSION_PKWARE; - - // Remove both flag mono and stereo flags. - // They will be re-added according to WAVE type + dwCompressionNext &= ~(MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO); bIsAdpcmCompression = true; } @@ -972,19 +916,15 @@ bool WINAPI SFileAddFileEx( // If the file being added is a WAVE file, we check number of channels if(bIsFirstSector && bIsAdpcmCompression) { - // The file must really be a WAVE file with at least 16 bits per sample, - // otherwise the ADPCM compression will corrupt it - if(IsWaveFile_16BitsPerAdpcmSample(pbFileData, dwBytesToRead, &dwChannels)) + // The file must really be a wave file, otherwise it's data corruption + if(!IsWaveFile(pbFileData, dwBytesToRead, &dwChannels)) { - // Setup the compression of next sectors according to number of channels - dwCompressionNext |= (dwChannels == 1) ? MPQ_COMPRESSION_ADPCM_MONO : MPQ_COMPRESSION_ADPCM_STEREO; - } - else - { - // Setup the compression of next sectors to a lossless compression - dwCompressionNext = (dwCompression & MPQ_LOSSY_COMPRESSION_MASK) ? MPQ_COMPRESSION_PKWARE : dwCompression; + nError = ERROR_BAD_FORMAT; + break; } + // Setup the compression according to number of channels + dwCompressionNext |= (dwChannels == 1) ? MPQ_COMPRESSION_ADPCM_MONO : MPQ_COMPRESSION_ADPCM_STEREO; bIsFirstSector = false; } @@ -1016,7 +956,7 @@ bool WINAPI SFileAddFileEx( SetLastError(nError); return (nError == ERROR_SUCCESS); } - + // Adds a data file into the archive bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags) { @@ -1043,25 +983,25 @@ bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szA // Starcraft files are packed as Mono (0x41) on medium quality. // Because this compression is not used anymore, our compression functions // will default to WaveCompressionLevel = 4 when using ADPCM compression - // + // // Convert quality to data compression switch(dwQuality) { - case MPQ_WAVE_QUALITY_HIGH: -// WaveCompressionLevel = -1; - dwCompression = MPQ_COMPRESSION_PKWARE; - break; + case MPQ_WAVE_QUALITY_HIGH: + // WaveCompressionLevel = -1; + dwCompression = MPQ_COMPRESSION_PKWARE; + break; - case MPQ_WAVE_QUALITY_MEDIUM: -// WaveCompressionLevel = 4; - dwCompression = MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN; - break; + case MPQ_WAVE_QUALITY_MEDIUM: + // WaveCompressionLevel = 4; + dwCompression = MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN; + break; - case MPQ_WAVE_QUALITY_LOW: -// WaveCompressionLevel = 2; - dwCompression = MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN; - break; + case MPQ_WAVE_QUALITY_LOW: + // WaveCompressionLevel = 2; + dwCompression = MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN; + break; } return SFileAddFileEx(hMpq, @@ -1075,59 +1015,68 @@ bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szA //----------------------------------------------------------------------------- // bool SFileRemoveFile(HANDLE hMpq, char * szFileName) // -// This function removes a file from the archive. -// +// This function removes a file from the archive. The file content +// remains there, only the entries in the hash table and in the block +// table are updated. bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope) { - TMPQArchive * ha = IsValidMpqHandle(hMpq); - TMPQFile * hf = NULL; + TMPQArchive * ha = (TMPQArchive *)hMpq; + TFileEntry * pFileEntry = NULL; // File entry of the file to be deleted + DWORD dwFileIndex = 0; int nError = ERROR_SUCCESS; // Keep compiler happy dwSearchScope = dwSearchScope; // Check the parameters - if(ha == NULL) - nError = ERROR_INVALID_HANDLE; - if(szFileName == NULL || *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - if(IsInternalMpqFileName(szFileName)) - nError = ERROR_INTERNAL_FILE; - - // Do not allow to remove files from read-only or patched MPQs if(nError == ERROR_SUCCESS) { - if((ha->dwFlags & MPQ_FLAG_READ_ONLY) || (ha->haPatch != NULL)) + if(!IsValidMpqHandle(ha)) + nError = ERROR_INVALID_HANDLE; + if(szFileName == NULL || *szFileName == 0) + nError = ERROR_INVALID_PARAMETER; + if(IsInternalMpqFileName(szFileName)) + nError = ERROR_INTERNAL_FILE; + } + + if(nError == ERROR_SUCCESS) + { + // Do not allow to remove files from MPQ open for read only + if(ha->dwFlags & MPQ_FLAG_READ_ONLY) nError = ERROR_ACCESS_DENIED; } - // If all checks have passed, we can delete the file from the MPQ + // Get hash entry belonging to this file if(nError == ERROR_SUCCESS) { - // Open the file from the MPQ - if(SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf)) + if(!IsPseudoFileName(szFileName, &dwFileIndex)) { - // Delete the file entry - nError = DeleteFileEntry(ha, hf); - FreeFileHandle(hf); + if((pFileEntry = GetFileEntryExact(ha, (char *)szFileName, lcFileLocale)) == NULL) + nError = ERROR_FILE_NOT_FOUND; } else - nError = GetLastError(); + { + if((pFileEntry = GetFileEntryByIndex(ha, dwFileIndex)) == NULL) + nError = ERROR_FILE_NOT_FOUND; + } } - // If the file has been deleted, we need to invalidate - // the internal files and recreate HET table + // Test if the file is not already deleted if(nError == ERROR_SUCCESS) { - // Invalidate the entries for internal files + if(!(pFileEntry->dwFlags & MPQ_FILE_EXISTS)) + nError = ERROR_FILE_NOT_FOUND; + } + + if(nError == ERROR_SUCCESS) + { + // Invalidate the entries for (listfile) and (attributes) // After we are done with MPQ changes, we need to re-create them anyway InvalidateInternalFiles(ha); - // - // Don't rebuild HET table now; the file's flags indicate - // that it's been deleted, which is enough - // + // Mark the file entry as free + nError = FreeFileEntry(ha, pFileEntry); } // Resolve error and exit @@ -1139,56 +1088,79 @@ bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearch // Renames the file within the archive. bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szFileName, const char * szNewFileName) { - TMPQArchive * ha = IsValidMpqHandle(hMpq); + TMPQArchive * ha = (TMPQArchive *)hMpq; + TFileEntry * pFileEntry = NULL; + ULONGLONG RawDataOffs; TMPQFile * hf; int nError = ERROR_SUCCESS; // Test the valid parameters - if(ha == NULL) - nError = ERROR_INVALID_HANDLE; - if(szFileName == NULL || *szFileName == 0 || szNewFileName == NULL || *szNewFileName == 0) - nError = ERROR_INVALID_PARAMETER; - if(IsInternalMpqFileName(szFileName) || IsInternalMpqFileName(szNewFileName)) - nError = ERROR_INTERNAL_FILE; - - // Do not allow to rename files in MPQ open for read only if(nError == ERROR_SUCCESS) { - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - nError = ERROR_ACCESS_DENIED; + if(!IsValidMpqHandle(ha)) + nError = ERROR_INVALID_HANDLE; + if(szFileName == NULL || *szFileName == 0 || szNewFileName == NULL || *szNewFileName == 0) + nError = ERROR_INVALID_PARAMETER; } - // Open the new file. If exists, we don't allow rename operation if(nError == ERROR_SUCCESS) { - if(GetFileEntryLocale(ha, szNewFileName, lcFileLocale) != NULL) + // Do not allow to rename files in MPQ open for read only + if(ha->dwFlags & MPQ_FLAG_READ_ONLY) + nError = ERROR_ACCESS_DENIED; + + // Do not allow renaming anything to a pseudo-file name + if(IsPseudoFileName(szFileName, NULL) || IsPseudoFileName(szNewFileName, NULL)) + nError = ERROR_INVALID_PARAMETER; + + // Do not allow to rename any of the internal files + // Also do not allow to rename any of files to an internal file + if(IsInternalMpqFileName(szFileName) || IsInternalMpqFileName(szNewFileName)) + nError = ERROR_INTERNAL_FILE; + } + + // Find the current file entry. + if(nError == ERROR_SUCCESS) + { + // Get the file entry + pFileEntry = GetFileEntryLocale(ha, szFileName, lcFileLocale); + if(pFileEntry == NULL) + nError = ERROR_FILE_NOT_FOUND; + } + + // Also try to find file entry for the new file. + // This verifies if we are not overwriting an existing file + // (whose name we perhaps don't know) + if(nError == ERROR_SUCCESS) + { + if(GetFileEntryLocale(ha, szNewFileName, pFileEntry->lcLocale) != NULL) nError = ERROR_ALREADY_EXISTS; } - // Open the file from the MPQ + // Now we rename the existing file entry. if(nError == ERROR_SUCCESS) { - // Attempt to open the file - if(SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf)) + // Rename the file entry + nError = RenameFileEntry(ha, pFileEntry, szNewFileName); + } + + // Now we copy the existing file entry to the new one + if(nError == ERROR_SUCCESS) + { + // If the file is encrypted, we have to re-crypt the file content + // with the new decryption key + if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) { - ULONGLONG RawDataOffs; - TFileEntry * pFileEntry = hf->pFileEntry; - - // Invalidate the entries for internal files - InvalidateInternalFiles(ha); - - // Rename the file entry in the table - nError = RenameFileEntry(ha, hf, szNewFileName); - - // If the file is encrypted, we have to re-crypt the file content - // with the new decryption key - if((nError == ERROR_SUCCESS) && (pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED)) + hf = CreateMpqFile(ha); + if(hf != NULL) { // Recrypt the file data in the MPQ + hf->pFileEntry = pFileEntry; + hf->dwDataSize = pFileEntry->dwFileSize; nError = RecryptFileData(ha, hf, szFileName, szNewFileName); - - // Update the MD5 of the raw block - if(nError == ERROR_SUCCESS && ha->pHeader->dwRawChunkSize != 0) + + // Update the MD5 + if(ha->pHeader->dwRawChunkSize != 0) { RawDataOffs = ha->MpqPos + pFileEntry->ByteOffset; WriteMpqDataMD5(ha->pStream, @@ -1196,22 +1168,21 @@ bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szFileName, const char * s pFileEntry->dwCmpSize, ha->pHeader->dwRawChunkSize); } - } - // Free the file handle - FreeFileHandle(hf); - } - else - { - nError = GetLastError(); + FreeMPQFile(hf); + } + else + { + nError = ERROR_NOT_ENOUGH_MEMORY; + } } } - // We also need to rebuild the HET table, if present - if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) - nError = RebuildHetTable(ha); + // + // Note: MPQ_FLAG_CHANGED is set by RenameFileEntry + // - // Resolve error and exit + // Resolve error and return if(nError != ERROR_SUCCESS) SetLastError(nError); return (nError == ERROR_SUCCESS); @@ -1241,23 +1212,15 @@ bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale) { TMPQArchive * ha; TFileEntry * pFileEntry; - TMPQFile * hf = IsValidFileHandle(hFile); + TMPQFile * hf = (TMPQFile *)hFile; // Invalid handle => do nothing - if(hf == NULL) + if(!IsValidFileHandle(hf)) { SetLastError(ERROR_INVALID_HANDLE); return false; } - // Do not allow to rename files in MPQ open for read only - ha = hf->ha; - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - // Do not allow unnamed access if(hf->pFileEntry->szFileName == NULL) { @@ -1272,23 +1235,42 @@ bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale) return false; } - // Do not allow changing file locales if there is no hash table - if(hf->pHashEntry == NULL) + // Do not allow changing file locales in MPQs version 3 or higher + ha = hf->ha; + if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_3) { SetLastError(ERROR_NOT_SUPPORTED); return false; } + // Do not allow to rename files in MPQ open for read only + if(ha->dwFlags & MPQ_FLAG_READ_ONLY) + { + SetLastError(ERROR_ACCESS_DENIED); + return false; + } + + // If the file already has that locale, return OK + if(hf->pFileEntry->lcLocale == lcNewLocale) + return true; + // We have to check if the file+locale is not already there - pFileEntry = GetFileEntryExact(ha, hf->pFileEntry->szFileName, lcNewLocale, NULL); + pFileEntry = GetFileEntryExact(ha, hf->pFileEntry->szFileName, lcNewLocale); if(pFileEntry != NULL) { SetLastError(ERROR_ALREADY_EXISTS); return false; } - // Update the locale in the hash table entry - hf->pHashEntry->lcLocale = (USHORT)lcNewLocale; + // Set the locale and return success + pFileEntry = hf->pFileEntry; + pFileEntry->lcLocale = (USHORT)lcNewLocale; + + // Save the new locale to the hash table, if any + if(ha->pHashTable != NULL) + ha->pHashTable[pFileEntry->dwHashIndex].lcLocale = (USHORT)lcNewLocale; + + // Remember that the MPQ tables have been changed ha->dwFlags |= MPQ_FLAG_CHANGED; return true; } @@ -1296,17 +1278,9 @@ bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale) //----------------------------------------------------------------------------- // Sets add file callback -bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData) +bool WINAPI SFileSetAddFileCallback(HANDLE /* hMpq */, SFILE_ADDFILE_CALLBACK aAddFileCB, void * pvData) { - TMPQArchive * ha = (TMPQArchive *) hMpq; - - if(!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - ha->pvAddFileUserData = pvUserData; - ha->pfnAddFileCB = AddFileCB; + pvUserData = pvData; + AddFileCB = aAddFileCB; return true; } diff --git a/dep/StormLib/src/SFileAttributes.cpp b/dep/StormLib/src/SFileAttributes.cpp index d565be738..e3659bfdc 100644 --- a/dep/StormLib/src/SFileAttributes.cpp +++ b/dep/StormLib/src/SFileAttributes.cpp @@ -24,444 +24,346 @@ typedef struct _MPQ_ATTRIBUTES_HEADER // Followed by an array of file times // Followed by an array of MD5 // Followed by an array of patch bits - - // Note: The MD5 in (attributes), if present, is a hash of the entire file. - // In case the file is an incremental patch, it contains MD5 of the file - // after being patched. - } MPQ_ATTRIBUTES_HEADER, *PMPQ_ATTRIBUTES_HEADER; -//----------------------------------------------------------------------------- -// Local functions - -static DWORD GetSizeOfAttributesFile(DWORD dwAttrFlags, DWORD dwBlockTableSize) -{ - DWORD cbAttrFile = sizeof(MPQ_ATTRIBUTES_HEADER); - - // Calculate size of the (attributes) file - if(dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - cbAttrFile += dwBlockTableSize * sizeof(DWORD); - if(dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - cbAttrFile += dwBlockTableSize * sizeof(ULONGLONG); - if(dwAttrFlags & MPQ_ATTRIBUTE_MD5) - cbAttrFile += dwBlockTableSize * MD5_DIGEST_SIZE; - - // The bit array has been created without the last bit belonging to (attributes) - // When the number of files is a multiplier of 8 plus one, then the size of (attributes) - // if 1 byte less than expected. - // Example: wow-update-13164.MPQ: BlockTableSize = 0x62E1, but there's only 0xC5C bytes - if(dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - cbAttrFile += (dwBlockTableSize + 6) / 8; - - return cbAttrFile; -} - -static DWORD CheckSizeOfAttributesFile(DWORD cbAttrFile, DWORD dwAttrFlags, DWORD dwBlockTableSize) -{ - DWORD cbHeaderSize = sizeof(MPQ_ATTRIBUTES_HEADER); - DWORD cbChecksumSize1 = 0; - DWORD cbChecksumSize2 = 0; - DWORD cbFileTimeSize1 = 0; - DWORD cbFileTimeSize2 = 0; - DWORD cbFileHashSize1 = 0; - DWORD cbFileHashSize2 = 0; - DWORD cbPatchBitSize1 = 0; - DWORD cbPatchBitSize2 = 0; - DWORD cbPatchBitSize3 = 0; - - // - // Various variants with the patch bit - // - // interface.MPQ.part from WoW build 10958 has - // the MPQ_ATTRIBUTE_PATCH_BIT set, but there's an array of DWORDs instead. - // The array is filled with zeros, so we don't know what it should contain - // - // Zenith.SC2MAP has the MPQ_ATTRIBUTE_PATCH_BIT set, but the bit array is missing - // - // Elimination Tournament 2.w3x's (attributes) have one entry less - // - // There may be two variants: Either the (attributes) file has full - // number of entries, or has one entry less - // - - // Get the expected size of CRC32 array - if(dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - { - cbChecksumSize1 += dwBlockTableSize * sizeof(DWORD); - cbChecksumSize2 += cbChecksumSize1 - sizeof(DWORD); - } - - // Get the expected size of FILETIME array - if(dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - { - cbFileTimeSize1 += dwBlockTableSize * sizeof(ULONGLONG); - cbFileTimeSize2 += cbFileTimeSize1 - sizeof(ULONGLONG); - } - - // Get the expected size of MD5 array - if(dwAttrFlags & MPQ_ATTRIBUTE_MD5) - { - cbFileHashSize1 += dwBlockTableSize * MD5_DIGEST_SIZE; - cbFileHashSize2 += cbFileHashSize1 - MD5_DIGEST_SIZE; - } - - // Get the expected size of patch bit array - if(dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - { - cbPatchBitSize1 = - cbPatchBitSize2 = ((dwBlockTableSize + 6) / 8); - cbPatchBitSize3 = dwBlockTableSize * sizeof(DWORD); - } - - // Check if the (attributes) file entry count is equal to our file table size - if(cbAttrFile == (cbHeaderSize + cbChecksumSize1 + cbFileTimeSize1 + cbFileHashSize1 + cbPatchBitSize1)) - return dwBlockTableSize; - - // Check if the (attributes) file entry count is equal to our file table size minus one - if(cbAttrFile == (cbHeaderSize + cbChecksumSize2 + cbFileTimeSize2 + cbFileHashSize2 + cbPatchBitSize2)) - return dwBlockTableSize - 1; - - // Zenith.SC2MAP has the MPQ_ATTRIBUTE_PATCH_BIT set, but the bit array is missing - if(cbAttrFile == (cbHeaderSize + cbChecksumSize1 + cbFileTimeSize1 + cbFileHashSize1)) - return dwBlockTableSize; - - // interface.MPQ.part (WoW build 10958) has the MPQ_ATTRIBUTE_PATCH_BIT set - // but there's an array of DWORDs (filled with zeros) instead of array of bits - if(cbAttrFile == (cbHeaderSize + cbChecksumSize1 + cbFileTimeSize1 + cbFileHashSize1 + cbPatchBitSize3)) - return dwBlockTableSize; - -#ifdef __STORMLIB_TEST__ - // Invalid size of the (attributes) file - // Note that many MPQs, especially Warcraft III maps have the size of (attributes) invalid. - // We only perform this check if this is the STORMLIB testprogram itself -// assert(false); -#endif - - return 0; -} - -static int LoadAttributesFile(TMPQArchive * ha, LPBYTE pbAttrFile, DWORD cbAttrFile) -{ - LPBYTE pbAttrFileEnd = pbAttrFile + cbAttrFile; - LPBYTE pbAttrPtr = pbAttrFile; - DWORD dwAttributesEntries = 0; - DWORD i; - - // Load and verify the header - if((pbAttrPtr + sizeof(MPQ_ATTRIBUTES_HEADER)) <= pbAttrFileEnd) - { - PMPQ_ATTRIBUTES_HEADER pAttrHeader = (PMPQ_ATTRIBUTES_HEADER)pbAttrPtr; - - // Verify the header version - BSWAP_ARRAY32_UNSIGNED(pAttrHeader, sizeof(MPQ_ATTRIBUTES_HEADER)); - if(pAttrHeader->dwVersion != MPQ_ATTRIBUTES_V1) - return ERROR_BAD_FORMAT; - - // Verify the flags - if(pAttrHeader->dwFlags & ~MPQ_ATTRIBUTE_ALL) - return ERROR_BAD_FORMAT; - - // Verify whether file size of (attributes) is expected - dwAttributesEntries = CheckSizeOfAttributesFile(cbAttrFile, pAttrHeader->dwFlags, ha->pHeader->dwBlockTableSize); - if(dwAttributesEntries == 0) - return ERROR_BAD_FORMAT; - - ha->dwAttrFlags = pAttrHeader->dwFlags; - pbAttrPtr = (LPBYTE)(pAttrHeader + 1); - } - - // Load the CRC32 (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - { - LPDWORD ArrayCRC32 = (LPDWORD)pbAttrPtr; - DWORD cbArraySize = dwAttributesEntries * sizeof(DWORD); - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) > pbAttrFileEnd) - return ERROR_FILE_CORRUPT; - - BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbCRC32Size); - for(i = 0; i < dwAttributesEntries; i++) - ha->pFileTable[i].dwCrc32 = ArrayCRC32[i]; - pbAttrPtr += cbArraySize; - } - - // Load the FILETIME (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - { - ULONGLONG * ArrayFileTime = (ULONGLONG *)pbAttrPtr; - DWORD cbArraySize = dwAttributesEntries * sizeof(ULONGLONG); - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) > pbAttrFileEnd) - return ERROR_FILE_CORRUPT; - - BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbFileTimeSize); - for(i = 0; i < dwAttributesEntries; i++) - ha->pFileTable[i].FileTime = ArrayFileTime[i]; - pbAttrPtr += cbArraySize; - } - - // Load the MD5 (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_MD5) - { - LPBYTE ArrayMd5 = pbAttrPtr; - DWORD cbArraySize = dwAttributesEntries * MD5_DIGEST_SIZE; - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) > pbAttrFileEnd) - return ERROR_FILE_CORRUPT; - - for(i = 0; i < dwAttributesEntries; i++) - { - memcpy(ha->pFileTable[i].md5, ArrayMd5, MD5_DIGEST_SIZE); - ArrayMd5 += MD5_DIGEST_SIZE; - } - pbAttrPtr += cbArraySize; - } - - // Read the patch bit for each file (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - { - LPBYTE pbBitArray = pbAttrPtr; - DWORD cbArraySize = (dwAttributesEntries + 7) / 8; - DWORD dwByteIndex = 0; - DWORD dwBitMask = 0x80; - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) == pbAttrFileEnd) - { - for(i = 0; i < dwAttributesEntries; i++) - { - ha->pFileTable[i].dwFlags |= (pbBitArray[dwByteIndex] & dwBitMask) ? MPQ_FILE_PATCH_FILE : 0; - dwByteIndex += (dwBitMask & 0x01); - dwBitMask = (dwBitMask << 0x07) | (dwBitMask >> 0x01); - } - } - } - - return ERROR_SUCCESS; -} - -static LPBYTE CreateAttributesFile(TMPQArchive * ha, DWORD * pcbAttrFile) -{ - PMPQ_ATTRIBUTES_HEADER pAttrHeader; - TFileEntry * pFileTableEnd = ha->pFileTable + ha->pHeader->dwBlockTableSize; - TFileEntry * pFileEntry; - LPBYTE pbAttrFile; - LPBYTE pbAttrPtr; - size_t cbAttrFile; - - // Check if we need patch bits in the (attributes) file - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) - { - ha->dwAttrFlags |= MPQ_ATTRIBUTE_PATCH_BIT; - break; - } - } - - // Allocate the buffer for holding the entire (attributes) - // Allocate 1 byte more (See GetSizeOfAttributesFile for more info) - cbAttrFile = GetSizeOfAttributesFile(ha->dwAttrFlags, ha->pHeader->dwBlockTableSize); - pbAttrFile = pbAttrPtr = STORM_ALLOC(BYTE, cbAttrFile + 1); - if(pbAttrFile != NULL) - { - // Make sure it's all zeroed - memset(pbAttrFile, 0, cbAttrFile + 1); - - // Write the header of the (attributes) file - pAttrHeader = (PMPQ_ATTRIBUTES_HEADER)pbAttrPtr; - pAttrHeader->dwVersion = BSWAP_INT32_UNSIGNED(100); - pAttrHeader->dwFlags = BSWAP_INT32_UNSIGNED((ha->dwAttrFlags & MPQ_ATTRIBUTE_ALL)); - pbAttrPtr = (LPBYTE)(pAttrHeader + 1); - - // Write the array of CRC32, if present - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - { - LPDWORD pArrayCRC32 = (LPDWORD)pbAttrPtr; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - *pArrayCRC32++ = BSWAP_INT32_UNSIGNED(pFileEntry->dwCrc32); - - // Update pointer - pbAttrPtr = (LPBYTE)pArrayCRC32; - } - - // Write the array of file time - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - { - ULONGLONG * pArrayFileTime = (ULONGLONG *)pbAttrPtr; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - *pArrayFileTime++ = BSWAP_INT64_UNSIGNED(pFileEntry->FileTime); - - // Update pointer - pbAttrPtr = (LPBYTE)pArrayFileTime; - } - - // Write the array of MD5s - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_MD5) - { - LPBYTE pbArrayMD5 = pbAttrPtr; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - memcpy(pbArrayMD5, pFileEntry->md5, MD5_DIGEST_SIZE); - pbArrayMD5 += MD5_DIGEST_SIZE; - } - - // Update pointer - pbAttrPtr = pbArrayMD5; - } - - // Write the array of patch bits - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - { - LPBYTE pbBitArray = pbAttrPtr; - DWORD dwByteIndex = 0; - BYTE dwBitMask = 0x80; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Set the bit, if needed - if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) - pbBitArray[dwByteIndex] |= dwBitMask; - - // Update bit index and bit mask - dwByteIndex += (dwBitMask & 0x01); - dwBitMask = (dwBitMask << 0x07) | (dwBitMask >> 0x01); - } - - // Move past the bit array - pbAttrPtr += (ha->pHeader->dwBlockTableSize + 6) / 8; - } - - // Now we expect that current position matches the estimated size - // Note that if there is 1 extra bit above the byte size, - // the table is actually 1 byte shorter in Blizzard MPQs. See GetSizeOfAttributesFile - assert((size_t)(pbAttrPtr - pbAttrFile) == cbAttrFile); - } - - // Give away the attributes file - if(pcbAttrFile != NULL) - *pcbAttrFile = (DWORD)cbAttrFile; - return pbAttrFile; -} - //----------------------------------------------------------------------------- // Public functions (internal use by StormLib) int SAttrLoadAttributes(TMPQArchive * ha) { + MPQ_ATTRIBUTES_HEADER AttrHeader; HANDLE hFile = NULL; - LPBYTE pbAttrFile; + DWORD dwBlockTableSize = ha->pHeader->dwBlockTableSize; + DWORD dwArraySize; DWORD dwBytesRead; - DWORD cbAttrFile = 0; - int nError = ERROR_FILE_CORRUPT; + DWORD i; + int nError = ERROR_SUCCESS; // File table must be initialized assert(ha->pFileTable != NULL); - assert((ha->dwFlags & MPQ_FLAG_BLOCK_TABLE_CUT) == 0); - - // Don't load the attributes file from malformed Warcraft III maps - if(ha->dwFlags & MPQ_FLAG_MALFORMED) - return ERROR_FILE_CORRUPT; // Attempt to open the "(attributes)" file. + // If it's not there, then the archive doesn't support attributes if(SFileOpenFileEx((HANDLE)ha, ATTRIBUTES_NAME, SFILE_OPEN_ANY_LOCALE, &hFile)) { - // Retrieve and check size of the (attributes) file - cbAttrFile = SFileGetFileSize(hFile, NULL); - - // Integer overflow check - if((cbAttrFile + 1) > cbAttrFile) + // Load the content of the attributes file + SFileReadFile(hFile, &AttrHeader, sizeof(MPQ_ATTRIBUTES_HEADER), &dwBytesRead, NULL); + if(dwBytesRead != sizeof(MPQ_ATTRIBUTES_HEADER)) + nError = ERROR_FILE_CORRUPT; + + // Verify the header of the (attributes) file + if(nError == ERROR_SUCCESS) { - // Size of the (attributes) might be 1 byte less than expected - // See GetSizeOfAttributesFile for more info - pbAttrFile = STORM_ALLOC(BYTE, cbAttrFile + 1); - if(pbAttrFile != NULL) + AttrHeader.dwVersion = BSWAP_INT32_UNSIGNED(AttrHeader.dwVersion); + AttrHeader.dwFlags = BSWAP_INT32_UNSIGNED(AttrHeader.dwFlags); + ha->dwAttrFlags = AttrHeader.dwFlags; + if(dwBytesRead != sizeof(MPQ_ATTRIBUTES_HEADER)) + nError = ERROR_FILE_CORRUPT; + } + + // Verify format of the attributes + if(nError == ERROR_SUCCESS) + { + if(AttrHeader.dwVersion > MPQ_ATTRIBUTES_V1) + nError = ERROR_BAD_FORMAT; + } + + // Load the CRC32 (if any) + if(nError == ERROR_SUCCESS && (AttrHeader.dwFlags & MPQ_ATTRIBUTE_CRC32)) + { + LPDWORD pArrayCRC32 = STORM_ALLOC(DWORD, dwBlockTableSize); + + if(pArrayCRC32 != NULL) { - // Set the last byte to 0 in case the size should be 1 byte greater - pbAttrFile[cbAttrFile] = 0; + dwArraySize = dwBlockTableSize * sizeof(DWORD); + SFileReadFile(hFile, pArrayCRC32, dwArraySize, &dwBytesRead, NULL); + if(dwBytesRead == dwArraySize) + { + for(i = 0; i < dwBlockTableSize; i++) + ha->pFileTable[i].dwCrc32 = BSWAP_INT32_UNSIGNED(pArrayCRC32[i]); + } + else + nError = ERROR_FILE_CORRUPT; - // Load the entire file to memory - SFileReadFile(hFile, pbAttrFile, cbAttrFile, &dwBytesRead, NULL); - if(dwBytesRead == cbAttrFile) - nError = LoadAttributesFile(ha, pbAttrFile, cbAttrFile); + STORM_FREE(pArrayCRC32); + } + else + nError = ERROR_NOT_ENOUGH_MEMORY; + } - // Free the buffer - STORM_FREE(pbAttrFile); + // Read the array of file times + if(nError == ERROR_SUCCESS && (AttrHeader.dwFlags & MPQ_ATTRIBUTE_FILETIME)) + { + ULONGLONG * pArrayFileTime = STORM_ALLOC(ULONGLONG, dwBlockTableSize); + + if(pArrayFileTime != NULL) + { + dwArraySize = dwBlockTableSize * sizeof(ULONGLONG); + SFileReadFile(hFile, pArrayFileTime, dwArraySize, &dwBytesRead, NULL); + if(dwBytesRead == dwArraySize) + { + for(i = 0; i < dwBlockTableSize; i++) + ha->pFileTable[i].FileTime = BSWAP_INT64_UNSIGNED(pArrayFileTime[i]); + } + else + nError = ERROR_FILE_CORRUPT; + + STORM_FREE(pArrayFileTime); + } + else + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Read the MD5 (if any) + // Note: MD5 array can be incomplete, if it's the last array in the (attributes) + if(nError == ERROR_SUCCESS && (AttrHeader.dwFlags & MPQ_ATTRIBUTE_MD5)) + { + unsigned char * pArrayMD5 = STORM_ALLOC(unsigned char, (dwBlockTableSize * MD5_DIGEST_SIZE)); + unsigned char * md5; + + if(pArrayMD5 != NULL) + { + dwArraySize = dwBlockTableSize * MD5_DIGEST_SIZE; + SFileReadFile(hFile, pArrayMD5, dwArraySize, &dwBytesRead, NULL); + if(dwBytesRead == dwArraySize) + { + md5 = pArrayMD5; + for(i = 0; i < dwBlockTableSize; i++) + { + memcpy(ha->pFileTable[i].md5, md5, MD5_DIGEST_SIZE); + md5 += MD5_DIGEST_SIZE; + } + } + else + nError = ERROR_FILE_CORRUPT; + + STORM_FREE(pArrayMD5); + } + else + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Read the patch bit for each file + if(nError == ERROR_SUCCESS && (AttrHeader.dwFlags & MPQ_ATTRIBUTE_PATCH_BIT)) + { + LPBYTE pbBitArray; + DWORD dwByteSize = ((dwBlockTableSize - 1) / 8) + 1; + + pbBitArray = STORM_ALLOC(BYTE, dwByteSize); + if(pbBitArray != NULL) + { + SFileReadFile(hFile, pbBitArray, dwByteSize, &dwBytesRead, NULL); + if(dwBytesRead == dwByteSize) + { + for(i = 0; i < dwBlockTableSize; i++) + { + DWORD dwByteIndex = i / 8; + DWORD dwBitMask = 0x80 >> (i & 7); + + // Is the appropriate bit set? + if(pbBitArray[dwByteIndex] & dwBitMask) + { + // At the moment, we assume that the patch bit is present + // in both file table and (attributes) + assert((ha->pFileTable[i].dwFlags & MPQ_FILE_PATCH_FILE) != 0); + ha->pFileTable[i].dwFlags |= MPQ_FILE_PATCH_FILE; + } + } + } + else + nError = ERROR_FILE_CORRUPT; + + STORM_FREE(pbBitArray); } } - // Close the attributes file + // + // Note: Version 7.00 of StormLib saved the (attributes) incorrectly. + // Sometimes, number of entries in the (attributes) was 1 item less + // than block table size. + // If we encounter such table, we will zero all three arrays + // + + if(nError != ERROR_SUCCESS) + ha->dwAttrFlags = 0; + + // Cleanup & exit SFileCloseFile(hFile); } - return nError; } -// Saves the (attributes) to the MPQ int SAttrFileSaveToMpq(TMPQArchive * ha) { + MPQ_ATTRIBUTES_HEADER AttrHeader; + TFileEntry * pFileEntry; TMPQFile * hf = NULL; - LPBYTE pbAttrFile; - DWORD cbAttrFile = 0; + DWORD dwFinalBlockTableSize = ha->dwFileTableSize; + DWORD dwFileSize = 0; + DWORD dwToWrite; + DWORD i; int nError = ERROR_SUCCESS; - // Only save the attributes if we should do so - if(ha->dwFileFlags2 != 0) + // Now we have to check if we need patch bits in the (attributes) + if(nError == ERROR_SUCCESS) { - // At this point, we expect to have at least one reserved entry in the file table - assert(ha->dwFlags & MPQ_FLAG_ATTRIBUTES_NEW); - assert(ha->dwReservedFiles > 0); - - // Create the raw data that is to be written to (attributes) - // Note: Blizzard MPQs have entries for (listfile) and (attributes), - // but they are filled empty - pbAttrFile = CreateAttributesFile(ha, &cbAttrFile); - if(pbAttrFile != NULL) + for(i = 0; i < ha->dwFileTableSize; i++) { - // Determine the real flags for (attributes) - if(ha->dwFileFlags2 == MPQ_FILE_DEFAULT_INTERNAL) - ha->dwFileFlags2 = GetDefaultSpecialFileFlags(cbAttrFile, ha->pHeader->wFormatVersion); - - // Create the attributes file in the MPQ - nError = SFileAddFile_Init(ha, ATTRIBUTES_NAME, - 0, - cbAttrFile, - LANG_NEUTRAL, - ha->dwFileFlags2 | MPQ_FILE_REPLACEEXISTING, - &hf); - - // Write the attributes file raw data to it - if(nError == ERROR_SUCCESS) + if(ha->pFileTable[i].dwFlags & MPQ_FILE_PATCH_FILE) { - // Write the content of the attributes file to the MPQ - nError = SFileAddFile_Write(hf, pbAttrFile, cbAttrFile, MPQ_COMPRESSION_ZLIB); - SFileAddFile_Finish(hf); + ha->dwAttrFlags |= MPQ_ATTRIBUTE_PATCH_BIT; + break; } - - // Clear the number of reserved files - ha->dwFlags &= ~(MPQ_FLAG_ATTRIBUTES_NEW | MPQ_FLAG_ATTRIBUTES_NONE); - ha->dwReservedFiles--; - - // Free the attributes buffer - STORM_FREE(pbAttrFile); - } - else - { - // If the (attributes) file would be empty, its OK - nError = (cbAttrFile == 0) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY; } } - + + // If the (attributes) is not in the file table yet, + // we have to increase the final block table size + pFileEntry = GetFileEntryExact(ha, ATTRIBUTES_NAME, LANG_NEUTRAL); + if(pFileEntry != NULL) + { + // If "(attributes)" file exists, and it's set to 0, then remove it + if(ha->dwAttrFlags == 0) + { + FreeFileEntry(ha, pFileEntry); + return ERROR_SUCCESS; + } + } + else + { + // If we don't want to create file atributes, do nothing + if(ha->dwAttrFlags == 0) + return ERROR_SUCCESS; + + // Check where the file entry is going to be allocated. + // If at the end of the file table, we have to increment + // the expected size of the (attributes) file. + pFileEntry = FindFreeFileEntry(ha); + if(pFileEntry == ha->pFileTable + ha->dwFileTableSize) + dwFinalBlockTableSize++; + } + + // Calculate the size of the attributes file + if(nError == ERROR_SUCCESS) + { + dwFileSize = sizeof(MPQ_ATTRIBUTES_HEADER); // Header + if(ha->dwAttrFlags & MPQ_ATTRIBUTE_CRC32) + dwFileSize += dwFinalBlockTableSize * sizeof(DWORD); + if(ha->dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) + dwFileSize += dwFinalBlockTableSize * sizeof(ULONGLONG); + if(ha->dwAttrFlags & MPQ_ATTRIBUTE_MD5) + dwFileSize += dwFinalBlockTableSize * MD5_DIGEST_SIZE; + if(ha->dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) + dwFileSize += ((dwFinalBlockTableSize - 1)) / 8 + 1; + } + + // Determine the flags for (attributes) + if(ha->dwFileFlags2 == 0) + ha->dwFileFlags2 = GetDefaultSpecialFileFlags(ha, dwFileSize); + + // Create the attributes file in the MPQ + nError = SFileAddFile_Init(ha, ATTRIBUTES_NAME, + 0, + dwFileSize, + LANG_NEUTRAL, + ha->dwFileFlags2 | MPQ_FILE_REPLACEEXISTING, + &hf); + + // Write all parts of the (attributes) file + if(nError == ERROR_SUCCESS) + { + assert(ha->dwFileTableSize == dwFinalBlockTableSize); + + // Note that we don't know what the new bit (0x08) means. + AttrHeader.dwVersion = BSWAP_INT32_UNSIGNED(100); + AttrHeader.dwFlags = BSWAP_INT32_UNSIGNED((ha->dwAttrFlags & MPQ_ATTRIBUTE_ALL)); + dwToWrite = sizeof(MPQ_ATTRIBUTES_HEADER); + nError = SFileAddFile_Write(hf, &AttrHeader, dwToWrite, MPQ_COMPRESSION_ZLIB); + } + + // Write the array of CRC32 + if(nError == ERROR_SUCCESS && (ha->dwAttrFlags & MPQ_ATTRIBUTE_CRC32)) + { + LPDWORD pArrayCRC32 = STORM_ALLOC(DWORD, dwFinalBlockTableSize); + + if(pArrayCRC32 != NULL) + { + // Copy from file table + for(i = 0; i < ha->dwFileTableSize; i++) + pArrayCRC32[i] = BSWAP_INT32_UNSIGNED(ha->pFileTable[i].dwCrc32); + + dwToWrite = ha->dwFileTableSize * sizeof(DWORD); + nError = SFileAddFile_Write(hf, pArrayCRC32, dwToWrite, MPQ_COMPRESSION_ZLIB); + STORM_FREE(pArrayCRC32); + } + } + + // Write the array of file time + if(nError == ERROR_SUCCESS && (ha->dwAttrFlags & MPQ_ATTRIBUTE_FILETIME)) + { + ULONGLONG * pArrayFileTime = STORM_ALLOC(ULONGLONG, ha->dwFileTableSize); + + if(pArrayFileTime != NULL) + { + // Copy from file table + for(i = 0; i < ha->dwFileTableSize; i++) + pArrayFileTime[i] = BSWAP_INT64_UNSIGNED(ha->pFileTable[i].FileTime); + + dwToWrite = ha->dwFileTableSize * sizeof(ULONGLONG); + nError = SFileAddFile_Write(hf, pArrayFileTime, dwToWrite, MPQ_COMPRESSION_ZLIB); + STORM_FREE(pArrayFileTime); + } + } + + // Write the array of MD5s + if(nError == ERROR_SUCCESS && (ha->dwAttrFlags & MPQ_ATTRIBUTE_MD5)) + { + char * pArrayMD5 = STORM_ALLOC(char, ha->dwFileTableSize * MD5_DIGEST_SIZE); + + if(pArrayMD5 != NULL) + { + // Copy from file table + for(i = 0; i < ha->dwFileTableSize; i++) + memcpy(&pArrayMD5[i * MD5_DIGEST_SIZE], ha->pFileTable[i].md5, MD5_DIGEST_SIZE); + + dwToWrite = ha->dwFileTableSize * MD5_DIGEST_SIZE; + nError = SFileAddFile_Write(hf, pArrayMD5, dwToWrite, MPQ_COMPRESSION_ZLIB); + STORM_FREE(pArrayMD5); + } + } + + // Write the array of patch bits + if(nError == ERROR_SUCCESS && (ha->dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT)) + { + LPBYTE pbBitArray; + DWORD dwByteSize = ((ha->dwFileTableSize - 1) / 8) + 1; + + pbBitArray = STORM_ALLOC(BYTE, dwByteSize); + if(pbBitArray != NULL) + { + memset(pbBitArray, 0, dwByteSize); + for(i = 0; i < ha->dwFileTableSize; i++) + { + DWORD dwByteIndex = i / 8; + DWORD dwBitMask = 0x80 >> (i & 7); + + if(ha->pFileTable[i].dwFlags & MPQ_FILE_PATCH_FILE) + pbBitArray[dwByteIndex] |= dwBitMask; + } + + nError = SFileAddFile_Write(hf, pbBitArray, dwByteSize, MPQ_COMPRESSION_ZLIB); + STORM_FREE(pbBitArray); + } + } + + // Finalize the file in the archive + if(hf != NULL) + { + SFileAddFile_Finish(hf); + } + + if(nError == ERROR_SUCCESS) + ha->dwFlags &= ~MPQ_FLAG_INV_ATTRIBUTES; return nError; } @@ -473,7 +375,7 @@ DWORD WINAPI SFileGetAttributes(HANDLE hMpq) TMPQArchive * ha = (TMPQArchive *)hMpq; // Verify the parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) { SetLastError(ERROR_INVALID_PARAMETER); return SFILE_INVALID_ATTRIBUTES; @@ -487,7 +389,7 @@ bool WINAPI SFileSetAttributes(HANDLE hMpq, DWORD dwFlags) TMPQArchive * ha = (TMPQArchive *)hMpq; // Verify the parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) { SetLastError(ERROR_INVALID_PARAMETER); return false; @@ -532,12 +434,12 @@ bool WINAPI SFileUpdateFileAttributes(HANDLE hMpq, const char * szFileName) } // Attempt to open the file - if(!SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_BASE_FILE, &hFile)) + if(!SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_FROM_MPQ, &hFile)) return false; // Get the file size hf = (TMPQFile *)hFile; - dwTotalBytes = hf->pFileEntry->dwFileSize; + SFileGetFileInfo(hFile, SFILE_INFO_FILE_SIZE, &dwTotalBytes, sizeof(DWORD), NULL); // Initialize the CRC32 and MD5 contexts md5_init(&md5_state); diff --git a/dep/StormLib/src/SFileCompactArchive.cpp b/dep/StormLib/src/SFileCompactArchive.cpp index 7b3fcd6f4..46ae8be83 100644 --- a/dep/StormLib/src/SFileCompactArchive.cpp +++ b/dep/StormLib/src/SFileCompactArchive.cpp @@ -7,36 +7,70 @@ /* -------- ---- --- ------- */ /* 14.04.03 1.00 Lad Splitted from SFileCreateArchiveEx.cpp */ /* 19.11.03 1.01 Dan Big endian handling */ -/* 21.04.13 1.02 Dea Compact callback now part of TMPQArchive */ /*****************************************************************************/ #define __STORMLIB_SELF__ #include "StormLib.h" #include "StormCommon.h" +/*****************************************************************************/ +/* Local variables */ +/*****************************************************************************/ + +static SFILE_COMPACT_CALLBACK CompactCB = NULL; +static ULONGLONG CompactBytesProcessed = 0; +static ULONGLONG CompactTotalBytes = 0; +static void * pvUserData = NULL; + /*****************************************************************************/ /* Local functions */ /*****************************************************************************/ -static int CheckIfAllFilesKnown(TMPQArchive * ha) +static int CheckIfAllFilesKnown(TMPQArchive * ha, const char * szListFile, LPDWORD pFileKeys) { - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; + TFileEntry * pFileTableEnd; TFileEntry * pFileEntry; DWORD dwBlockIndex = 0; int nError = ERROR_SUCCESS; + // Add the listfile to the MPQ + if(nError == ERROR_SUCCESS && szListFile != NULL) + { + // Notify the user + if(CompactCB != NULL) + CompactCB(pvUserData, CCB_CHECKING_FILES, CompactBytesProcessed, CompactTotalBytes); + + nError = SFileAddListFile((HANDLE)ha, szListFile); + } + // Verify the file table if(nError == ERROR_SUCCESS) { + pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++, dwBlockIndex++) { - // If there is an existing entry in the file table, check its name if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) { - // The name must be valid and must not be a pseudo-name - if(pFileEntry->szFileName == NULL || IsPseudoFileName(pFileEntry->szFileName, NULL)) + if(pFileEntry->szFileName != NULL && !IsPseudoFileName(pFileEntry->szFileName, NULL)) { - nError = ERROR_UNKNOWN_FILE_NAMES; + DWORD dwFileKey = 0; + + // Resolve the file key. Use plain file name for it + if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) + { + dwFileKey = DecryptFileKey(pFileEntry->szFileName, + pFileEntry->ByteOffset, + pFileEntry->dwFileSize, + pFileEntry->dwFlags); + } + + // Give the key to the caller + if(pFileKeys != NULL) + pFileKeys[dwBlockIndex] = dwFileKey; + } + else + { + nError = ERROR_CAN_NOT_COMPLETE; break; } } @@ -46,59 +80,11 @@ static int CheckIfAllFilesKnown(TMPQArchive * ha) return nError; } -static int CheckIfAllKeysKnown(TMPQArchive * ha, const TCHAR * szListFile, LPDWORD pFileKeys) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - DWORD dwBlockIndex = 0; - int nError = ERROR_SUCCESS; - - // Add the listfile to the MPQ - if(szListFile != NULL) - { - // Notify the user - if(ha->pfnCompactCB != NULL) - ha->pfnCompactCB(ha->pvCompactUserData, CCB_CHECKING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); - - nError = SFileAddListFile((HANDLE)ha, szListFile); - } - - // Verify the file table - if(nError == ERROR_SUCCESS) - { - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++, dwBlockIndex++) - { - // If the file exists and it's encrypted - if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) - { - // If we know the name, we decrypt the file key from the file name - if(pFileEntry->szFileName != NULL && !IsPseudoFileName(pFileEntry->szFileName, NULL)) - { - // Give the key to the caller - pFileKeys[dwBlockIndex] = DecryptFileKey(pFileEntry->szFileName, - pFileEntry->ByteOffset, - pFileEntry->dwFileSize, - pFileEntry->dwFlags); - continue; - } - - // We don't know the encryption key of this file, - // thus we cannot compact the file - nError = ERROR_UNKNOWN_FILE_NAMES; - break; - } - } - } - - return nError; -} - static int CopyNonMpqData( - TMPQArchive * ha, - TFileStream * pSrcStream, - TFileStream * pTrgStream, - ULONGLONG & ByteOffset, - ULONGLONG & ByteCount) + TFileStream * pSrcStream, + TFileStream * pTrgStream, + ULONGLONG & ByteOffset, + ULONGLONG & ByteCount) { ULONGLONG DataSize = ByteCount; DWORD dwToRead; @@ -128,10 +114,10 @@ static int CopyNonMpqData( } // Update the progress - if(ha->pfnCompactCB != NULL) + if(CompactCB != NULL) { - ha->CompactBytesProcessed += dwToRead; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COPYING_NON_MPQ_DATA, ha->CompactBytesProcessed, ha->CompactTotalBytes); + CompactBytesProcessed += dwToRead; + CompactCB(pvUserData, CCB_COPYING_NON_MPQ_DATA, CompactBytesProcessed, CompactTotalBytes); } // Decrement the number of data to be copied @@ -139,18 +125,18 @@ static int CopyNonMpqData( DataSize -= dwToRead; } - return nError; + return ERROR_SUCCESS; } // Copies all file sectors into another archive. static int CopyMpqFileSectors( - TMPQArchive * ha, - TMPQFile * hf, - TFileStream * pNewStream, - ULONGLONG MpqFilePos) // MPQ file position in the new archive + TMPQArchive * ha, + TMPQFile * hf, + TFileStream * pNewStream) { TFileEntry * pFileEntry = hf->pFileEntry; ULONGLONG RawFilePos; // Used for calculating sector offset in the old MPQ archive + ULONGLONG MpqFilePos; // MPQ file position in the new archive DWORD dwBytesToCopy = pFileEntry->dwCmpSize; DWORD dwPatchSize = 0; // Size of patch header DWORD dwFileKey1 = 0; // File key used for decryption @@ -158,7 +144,11 @@ static int CopyMpqFileSectors( DWORD dwCmpSize = 0; // Compressed file size, including patch header int nError = ERROR_SUCCESS; - // Resolve decryption keys. Note that the file key given + // Remember the position in the destination file + FileStream_GetPos(pNewStream, &MpqFilePos); + MpqFilePos -= ha->MpqPos; + + // Resolve decryption keys. Note that the file key given // in the TMPQFile structure also includes the key adjustment if(nError == ERROR_SUCCESS && (pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED)) { @@ -184,11 +174,11 @@ static int CopyMpqFileSectors( // If we have to save sector offset table, do it. if(nError == ERROR_SUCCESS && hf->SectorOffsets != NULL) { - DWORD * SectorOffsetsCopy = STORM_ALLOC(DWORD, hf->SectorOffsets[0] / sizeof(DWORD)); + DWORD * SectorOffsetsCopy = (DWORD *)STORM_ALLOC(BYTE, hf->SectorOffsets[0]); DWORD dwSectorOffsLen = hf->SectorOffsets[0]; assert((pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) == 0); - assert(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK); + assert(pFileEntry->dwFlags & MPQ_FILE_COMPRESSED); if(SectorOffsetsCopy == NULL) nError = ERROR_NOT_ENOUGH_MEMORY; @@ -209,10 +199,10 @@ static int CopyMpqFileSectors( } // Update compact progress - if(ha->pfnCompactCB != NULL) + if(CompactCB != NULL) { - ha->CompactBytesProcessed += dwSectorOffsLen; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COMPACTING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); + CompactBytesProcessed += dwSectorOffsLen; + CompactCB(pvUserData, CCB_COMPACTING_FILES, CompactBytesProcessed, CompactTotalBytes); } STORM_FREE(SectorOffsetsCopy); @@ -239,8 +229,8 @@ static int CopyMpqFileSectors( dwRawDataInSector = dwBytesToCopy; // Calculate the raw file offset of the file sector - RawFilePos = CalculateRawSectorOffset(hf, dwRawByteOffset); - + CalculateRawSectorOffset(RawFilePos, hf, dwRawByteOffset); + // Read the file sector if(!FileStream_Read(ha->pStream, &RawFilePos, hf->pbFileSector, dwRawDataInSector)) { @@ -249,7 +239,7 @@ static int CopyMpqFileSectors( } // If necessary, re-encrypt the sector - // Note: Recompression is not necessary here. Unlike encryption, + // Note: Recompression is not necessary here. Unlike encryption, // the compression does not depend on the position of the file in MPQ. if((pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) && dwFileKey1 != dwFileKey2) { @@ -267,10 +257,10 @@ static int CopyMpqFileSectors( } // Update compact progress - if(ha->pfnCompactCB != NULL) + if(CompactCB != NULL) { - ha->CompactBytesProcessed += dwRawDataInSector; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COMPACTING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); + CompactBytesProcessed += dwRawDataInSector; + CompactCB(pvUserData, CCB_COMPACTING_FILES, CompactBytesProcessed, CompactTotalBytes); } // Adjust byte counts @@ -295,10 +285,10 @@ static int CopyMpqFileSectors( nError = GetLastError(); // Update compact progress - if(ha->pfnCompactCB != NULL) + if(CompactCB != NULL) { - ha->CompactBytesProcessed += dwCrcLength; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COMPACTING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); + CompactBytesProcessed += dwCrcLength; + CompactCB(pvUserData, CCB_COMPACTING_FILES, CompactBytesProcessed, CompactTotalBytes); } // Size of the CRC block is also included in the compressed file size @@ -328,6 +318,7 @@ static int CopyMpqFileSectors( // Include these extra data in the compressed size dwCmpSize += dwBytesToCopy; + dwBytesToCopy = 0; STORM_FREE(pbExtraData); } else @@ -337,30 +328,36 @@ static int CopyMpqFileSectors( // Write the MD5's of the raw file data, if needed if(nError == ERROR_SUCCESS && ha->pHeader->dwRawChunkSize != 0) { - nError = WriteMpqDataMD5(pNewStream, + nError = WriteMpqDataMD5(pNewStream, ha->MpqPos + MpqFilePos, pFileEntry->dwCmpSize, ha->pHeader->dwRawChunkSize); } - // Verify the number of bytes written + // Update file position in the block table if(nError == ERROR_SUCCESS) { // At this point, number of bytes written should be exactly // the same like the compressed file size. If it isn't, - // there's something wrong (an unknown archive version, MPQ malformation, ...) - // + // there's something wrong (an unknown archive version, MPQ protection, ...) + // // Note: Diablo savegames have very weird layout, and the file "hero" // seems to have improper compressed size. Instead of real compressed size, // the "dwCmpSize" member of the block table entry contains // uncompressed size of file data + size of the sector table. // If we compact the archive, Diablo will refuse to load the game + // Seems like some sort of protection to me. // // Note: Some patch files in WOW patches don't count the patch header // into compressed size // - if(!(dwCmpSize <= pFileEntry->dwCmpSize && pFileEntry->dwCmpSize <= dwCmpSize + dwPatchSize)) + if(dwCmpSize <= pFileEntry->dwCmpSize && pFileEntry->dwCmpSize <= dwCmpSize + dwPatchSize) + { + // Note: DO NOT update the compressed size in the file entry, no matter how bad it is. + pFileEntry->ByteOffset = MpqFilePos; + } + else { nError = ERROR_FILE_CORRUPT; assert(false); @@ -375,7 +372,6 @@ static int CopyMpqFiles(TMPQArchive * ha, LPDWORD pFileKeys, TFileStream * pNewS TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; TFileEntry * pFileEntry; TMPQFile * hf = NULL; - ULONGLONG MpqFilePos; int nError = ERROR_SUCCESS; // Walk through all files and write them to the destination MPQ archive @@ -383,158 +379,94 @@ static int CopyMpqFiles(TMPQArchive * ha, LPDWORD pFileKeys, TFileStream * pNewS { // Copy all the file sectors // Only do that when the file has nonzero size - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS)) + if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && pFileEntry->dwFileSize != 0) { - // Query the position where the destination file will be - FileStream_GetPos(pNewStream, &MpqFilePos); - MpqFilePos = MpqFilePos - ha->MpqPos; + // Allocate structure for the MPQ file + hf = CreateMpqFile(ha); + if(hf == NULL) + return ERROR_NOT_ENOUGH_MEMORY; - // Perform file copy ONLY if the file has nonzero size - if(pFileEntry->dwFileSize != 0) + // Store file entry + hf->pFileEntry = pFileEntry; + + // Set the raw file position + hf->MpqFilePos = pFileEntry->ByteOffset; + hf->RawFilePos = ha->MpqPos + hf->MpqFilePos; + + // Set the file decryption key + hf->dwFileKey = pFileKeys[pFileEntry - ha->pFileTable]; + hf->dwDataSize = pFileEntry->dwFileSize; + + // If the file is a patch file, load the patch header + if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) { - // Allocate structure for the MPQ file - hf = CreateFileHandle(ha, pFileEntry); - if(hf == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Set the file decryption key - hf->dwFileKey = pFileKeys[pFileEntry - ha->pFileTable]; - - // If the file is a patch file, load the patch header - if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) - { - nError = AllocatePatchInfo(hf, true); - if(nError != ERROR_SUCCESS) - break; - } - - // Allocate buffers for file sector and sector offset table - nError = AllocateSectorBuffer(hf); + nError = AllocatePatchInfo(hf, true); if(nError != ERROR_SUCCESS) break; - - // Also allocate sector offset table and sector checksum table - nError = AllocateSectorOffsets(hf, true); - if(nError != ERROR_SUCCESS) - break; - - // Also load sector checksums, if any - if(pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC) - { - nError = AllocateSectorChecksums(hf, false); - if(nError != ERROR_SUCCESS) - break; - } - - // Copy all file sectors - nError = CopyMpqFileSectors(ha, hf, pNewStream, MpqFilePos); - if(nError != ERROR_SUCCESS) - break; - - // Free buffers. This also sets "hf" to NULL. - FreeFileHandle(hf); } - // Note: DO NOT update the compressed size in the file entry, no matter how bad it is. - pFileEntry->ByteOffset = MpqFilePos; + // Allocate buffers for file sector and sector offset table + nError = AllocateSectorBuffer(hf); + if(nError != ERROR_SUCCESS) + break; + + // Also allocate sector offset table and sector checksum table + nError = AllocateSectorOffsets(hf, true); + if(nError != ERROR_SUCCESS) + break; + + // Also load sector checksums, if any + if(pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC) + { + nError = AllocateSectorChecksums(hf, false); + if(nError != ERROR_SUCCESS) + break; + } + + // Copy all file sectors + nError = CopyMpqFileSectors(ha, hf, pNewStream); + if(nError != ERROR_SUCCESS) + break; + + // Free buffers. This also sets "hf" to NULL. + FreeMPQFile(hf); } } // Cleanup and exit if(hf != NULL) - FreeFileHandle(hf); + FreeMPQFile(hf); return nError; } + /*****************************************************************************/ /* Public functions */ /*****************************************************************************/ -//----------------------------------------------------------------------------- -// Changing hash table size - -DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq) +bool WINAPI SFileSetCompactCallback(HANDLE /* hMpq */, SFILE_COMPACT_CALLBACK aCompactCB, void * pvData) { - TMPQArchive * ha = (TMPQArchive *)hMpq; - - return ha->dwMaxFileCount; -} - -bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - DWORD dwNewHashTableSize = 0; - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(!IsValidMpqHandle(hMpq)) - nError = ERROR_INVALID_HANDLE; - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - nError = ERROR_ACCESS_DENIED; - if(dwMaxFileCount < ha->dwFileTableSize) - nError = ERROR_DISK_FULL; - - // ALL file names must be known in order to be able to rebuild hash table - if(nError == ERROR_SUCCESS && ha->pHashTable != NULL) - { - nError = CheckIfAllFilesKnown(ha); - if(nError == ERROR_SUCCESS) - { - // Calculate the hash table size for the new file limit - dwNewHashTableSize = GetNearestPowerOfTwo(dwMaxFileCount); - - // Rebuild both file tables - nError = RebuildFileTable(ha, dwNewHashTableSize); - } - } - - // We always have to rebuild the (attributes) file due to file table change - if(nError == ERROR_SUCCESS) - { - // Invalidate (listfile) and (attributes) - InvalidateInternalFiles(ha); - - // Rebuild the HET table, if we have any - if(ha->pHetTable != NULL) - nError = RebuildHetTable(ha); - } - - // Return the error - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); + CompactCB = aCompactCB; + pvUserData = pvData; + return true; } //----------------------------------------------------------------------------- // Archive compacting -bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK pfnCompactCB, void * pvUserData) -{ - TMPQArchive * ha = (TMPQArchive *) hMpq; - - if (!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - ha->pfnCompactCB = pfnCompactCB; - ha->pvCompactUserData = pvUserData; - return true; -} - -bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool /* bReserved */) +bool WINAPI SFileCompactArchive(HANDLE hMpq, const char * szListFile, bool /* bReserved */) { TFileStream * pTempStream = NULL; TMPQArchive * ha = (TMPQArchive *)hMpq; ULONGLONG ByteOffset; ULONGLONG ByteCount; LPDWORD pFileKeys = NULL; - TCHAR szTempFile[MAX_PATH+1] = _T(""); + TCHAR szTempFile[MAX_PATH] = _T(""); + TCHAR * szTemp = NULL; int nError = ERROR_SUCCESS; // Test the valid parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) nError = ERROR_INVALID_HANDLE; if(ha->dwFlags & MPQ_FLAG_READ_ONLY) nError = ERROR_ACCESS_DENIED; @@ -559,20 +491,21 @@ bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool /* b if(nError == ERROR_SUCCESS) { // Initialize the progress variables for compact callback - FileStream_GetSize(ha->pStream, &(ha->CompactTotalBytes)); - ha->CompactBytesProcessed = 0; - nError = CheckIfAllKeysKnown(ha, szListFile, pFileKeys); + FileStream_GetSize(ha->pStream, &CompactTotalBytes); + CompactBytesProcessed = 0; + nError = CheckIfAllFilesKnown(ha, szListFile, pFileKeys); } // Get the temporary file name and create it if(nError == ERROR_SUCCESS) { - // Create temporary file name. Prevent buffer overflow - StringCopy(szTempFile, _countof(szTempFile), FileStream_GetFileName(ha->pStream)); - StringCat(szTempFile, _countof(szTempFile), _T(".tmp")); + _tcscpy(szTempFile, FileStream_GetFileName(ha->pStream)); + if((szTemp = _tcsrchr(szTempFile, '.')) != NULL) + _tcscpy(szTemp + 1, _T("mp_")); + else + _tcscat(szTempFile, _T("_")); - // Create temporary file - pTempStream = FileStream_CreateFile(szTempFile, STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE); + pTempStream = FileStream_CreateFile(szTempFile, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); if(pTempStream == NULL) nError = GetLastError(); } @@ -581,12 +514,12 @@ bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool /* b if(nError == ERROR_SUCCESS && ha->UserDataPos != 0) { // Inform the application about the progress - if(ha->pfnCompactCB != NULL) - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COPYING_NON_MPQ_DATA, ha->CompactBytesProcessed, ha->CompactTotalBytes); + if(CompactCB != NULL) + CompactCB(pvUserData, CCB_COPYING_NON_MPQ_DATA, CompactBytesProcessed, CompactTotalBytes); ByteOffset = 0; ByteCount = ha->UserDataPos; - nError = CopyNonMpqData(ha, ha->pStream, pTempStream, ByteOffset, ByteCount); + nError = CopyNonMpqData(ha->pStream, pTempStream, ByteOffset, ByteCount); } // Write the MPQ user data (if any) @@ -600,49 +533,61 @@ bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool /* b assert(ha->pUserData != NULL); assert(ha->pUserData->dwHeaderOffs == ByteCount); - nError = CopyNonMpqData(ha, ha->pStream, pTempStream, ByteOffset, ByteCount); + nError = CopyNonMpqData(ha->pStream, pTempStream, ByteOffset, ByteCount); } // Write the MPQ header if(nError == ERROR_SUCCESS) { - TMPQHeader SaveMpqHeader; + // Remember the header size before swapping + DWORD dwBytesToWrite = ha->pHeader->dwHeaderSize; - // Write the MPQ header to the file - memcpy(&SaveMpqHeader, ha->pHeader, ha->pHeader->dwHeaderSize); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_1); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_2); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_3); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_4); - if(!FileStream_Write(pTempStream, NULL, &SaveMpqHeader, ha->pHeader->dwHeaderSize)) + BSWAP_TMPQHEADER(ha->pHeader); + if(!FileStream_Write(pTempStream, NULL, ha->pHeader, dwBytesToWrite)) nError = GetLastError(); + BSWAP_TMPQHEADER(ha->pHeader); // Update the progress - ha->CompactBytesProcessed += ha->pHeader->dwHeaderSize; + CompactBytesProcessed += ha->pHeader->dwHeaderSize; } // Now copy all files if(nError == ERROR_SUCCESS) + { nError = CopyMpqFiles(ha, pFileKeys, pTempStream); + ha->dwFlags |= MPQ_FLAG_CHANGED; + } // If succeeded, switch the streams if(nError == ERROR_SUCCESS) { - ha->dwFlags |= MPQ_FLAG_CHANGED; - if(FileStream_Replace(ha->pStream, pTempStream)) + if(FileStream_Switch(ha->pStream, pTempStream)) pTempStream = NULL; else nError = ERROR_CAN_NOT_COMPLETE; } - // Final user notification - if(nError == ERROR_SUCCESS && ha->pfnCompactCB != NULL) + // If all succeeded, save the MPQ tables + if(nError == ERROR_SUCCESS) { - ha->CompactBytesProcessed += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); - ha->CompactBytesProcessed += (ha->dwFileTableSize * sizeof(TMPQBlock)); - ha->pfnCompactCB(ha->pvCompactUserData, CCB_CLOSING_ARCHIVE, ha->CompactBytesProcessed, ha->CompactTotalBytes); + // + // Note: We don't recalculate position of the MPQ tables at this point. + // SaveMPQTables does it automatically. + // + + nError = SaveMPQTables(ha); + if(nError == ERROR_SUCCESS && CompactCB != NULL) + { + CompactBytesProcessed += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); + CompactBytesProcessed += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock)); + CompactCB(pvUserData, CCB_CLOSING_ARCHIVE, CompactBytesProcessed, CompactTotalBytes); + } } + // Invalidate the compact callback + pvUserData = NULL; + CompactCB = NULL; + // Cleanup and return if(pTempStream != NULL) FileStream_Close(pTempStream); @@ -652,3 +597,169 @@ bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool /* b SetLastError(nError); return (nError == ERROR_SUCCESS); } + +//----------------------------------------------------------------------------- +// Changing hash table size + +DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq) +{ + TMPQArchive * ha = (TMPQArchive *)hMpq; + + return ha->dwMaxFileCount; +} + +bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount) +{ + TMPQHetTable * pOldHetTable = NULL; + TMPQArchive * ha = (TMPQArchive *)hMpq; + TFileEntry * pOldFileTableEnd = ha->pFileTable + ha->dwFileTableSize; + TFileEntry * pOldFileTable = NULL; + TFileEntry * pOldFileEntry; + TFileEntry * pFileEntry; + TMPQHash * pOldHashTable = NULL; + DWORD dwOldHashTableSize = 0; + DWORD dwOldFileTableSize = 0; + int nError = ERROR_SUCCESS; + + // Test the valid parameters + if(!IsValidMpqHandle(ha)) + nError = ERROR_INVALID_HANDLE; + if(ha->dwFlags & MPQ_FLAG_READ_ONLY) + nError = ERROR_ACCESS_DENIED; + + // The new limit must not be lower than the index of the last file entry in the table + if(nError == ERROR_SUCCESS && ha->dwFileTableSize > dwMaxFileCount) + nError = ERROR_DISK_FULL; + + // ALL file names must be known in order to be able + // to rebuild hash table size + if(nError == ERROR_SUCCESS) + { + nError = CheckIfAllFilesKnown(ha, NULL, NULL); + } + + // If the MPQ has a hash table, then we relocate the hash table + if(nError == ERROR_SUCCESS && ha->pHashTable != NULL) + { + // Save parameters for the current hash table + dwOldHashTableSize = ha->pHeader->dwHashTableSize; + pOldHashTable = ha->pHashTable; + + // Allocate new hash table + ha->pHeader->dwHashTableSize = GetHashTableSizeForFileCount(dwMaxFileCount); + ha->pHashTable = STORM_ALLOC(TMPQHash, ha->pHeader->dwHashTableSize); + if(ha->pHashTable != NULL) + memset(ha->pHashTable, 0xFF, ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); + else + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // If the MPQ has HET table, allocate new one as well + if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) + { + // Save the original HET table + pOldHetTable = ha->pHetTable; + + // Create new one + ha->pHetTable = CreateHetTable(dwMaxFileCount, 0x40, true); + if(ha->pHetTable == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Now reallocate the file table + if(nError == ERROR_SUCCESS) + { + // Save the current file table + dwOldFileTableSize = ha->dwFileTableSize; + pOldFileTable = ha->pFileTable; + + // Create new one + ha->pFileTable = STORM_ALLOC(TFileEntry, dwMaxFileCount); + if(ha->pFileTable != NULL) + memset(ha->pFileTable, 0, dwMaxFileCount * sizeof(TFileEntry)); + else + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Now we have to build both classic hash table and HET table. + if(nError == ERROR_SUCCESS) + { + DWORD dwFileIndex = 0; + DWORD dwHashIndex = 0; + + // Create new hash and HET entry for each file + pFileEntry = ha->pFileTable; + for(pOldFileEntry = pOldFileTable; pOldFileEntry < pOldFileTableEnd; pOldFileEntry++) + { + if(pOldFileEntry->dwFlags & MPQ_FILE_EXISTS) + { + // Copy the old file entry to the new one + memcpy(pFileEntry, pOldFileEntry, sizeof(TFileEntry)); + assert(pFileEntry->szFileName != NULL); + + // Create new entry in the hash table + if(ha->pHashTable != NULL) + { + dwHashIndex = AllocateHashEntry(ha, pFileEntry); + if(dwHashIndex == HASH_ENTRY_FREE) + { + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + } + + // Create new entry in the HET table, if needed + if(ha->pHetTable != NULL) + { + dwHashIndex = AllocateHetEntry(ha, pFileEntry); + if(dwHashIndex == HASH_ENTRY_FREE) + { + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + } + + // Move to the next file entry in the new table + pFileEntry++; + dwFileIndex++; + } + } + } + + // Mark the archive as changed + // Note: We always have to rebuild the (attributes) file due to file table change + if(nError == ERROR_SUCCESS) + { + ha->dwMaxFileCount = dwMaxFileCount; + InvalidateInternalFiles(ha); + } + else + { + // Revert the hash table + if(ha->pHashTable != NULL && pOldHashTable != NULL) + { + STORM_FREE(ha->pHashTable); + ha->pHeader->dwHashTableSize = dwOldHashTableSize; + ha->pHashTable = pOldHashTable; + } + + // Revert the HET table + if(ha->pHetTable != NULL && pOldHetTable != NULL) + { + FreeHetTable(ha->pHetTable); + ha->pHetTable = pOldHetTable; + } + + // Revert the file table + if(pOldFileTable != NULL) + { + STORM_FREE(ha->pFileTable); + ha->pFileTable = pOldFileTable; + } + + SetLastError(nError); + } + + // Return the result + return (nError == ERROR_SUCCESS); +} diff --git a/dep/StormLib/src/SFileCreateArchive.cpp b/dep/StormLib/src/SFileCreateArchive.cpp index de4ab36f9..3ce0c02b5 100644 --- a/dep/StormLib/src/SFileCreateArchive.cpp +++ b/dep/StormLib/src/SFileCreateArchive.cpp @@ -56,10 +56,7 @@ static int WriteNakedMPQHeader(TMPQArchive * ha) Header.wSectorSize = pHeader->wSectorSize; // Write it to the file - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_1); - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_2); - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_3); - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_4); + BSWAP_TMPQHEADER(&Header); if(!FileStream_Write(ha->pStream, &ha->MpqPos, &Header, dwBytesToWrite)) nError = GetLastError(); @@ -69,32 +66,19 @@ static int WriteNakedMPQHeader(TMPQArchive * ha) //----------------------------------------------------------------------------- // Creates a new MPQ archive. -bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWORD dwMaxFileCount, HANDLE * phMpq) +bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwFlags, DWORD dwMaxFileCount, HANDLE * phMpq) { SFILE_CREATE_MPQ CreateInfo; // Fill the create structure memset(&CreateInfo, 0, sizeof(SFILE_CREATE_MPQ)); CreateInfo.cbSize = sizeof(SFILE_CREATE_MPQ); - CreateInfo.dwMpqVersion = (dwCreateFlags & MPQ_CREATE_ARCHIVE_VMASK) >> FLAGS_TO_FORMAT_SHIFT; - CreateInfo.dwStreamFlags = STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE; - CreateInfo.dwFileFlags1 = (dwCreateFlags & MPQ_CREATE_LISTFILE) ? MPQ_FILE_DEFAULT_INTERNAL : 0; - CreateInfo.dwFileFlags2 = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_FILE_DEFAULT_INTERNAL : 0; - CreateInfo.dwFileFlags3 = (dwCreateFlags & MPQ_CREATE_SIGNATURE) ? MPQ_FILE_DEFAULT_INTERNAL : 0; - CreateInfo.dwAttrFlags = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? (MPQ_ATTRIBUTE_CRC32 | MPQ_ATTRIBUTE_FILETIME | MPQ_ATTRIBUTE_MD5) : 0; + CreateInfo.dwMpqVersion = (dwFlags & MPQ_CREATE_ARCHIVE_VMASK) >> FLAGS_TO_FORMAT_SHIFT; + CreateInfo.dwStreamFlags = STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE; + CreateInfo.dwAttrFlags = (dwFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_ATTRIBUTE_ALL : 0; CreateInfo.dwSectorSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_3) ? 0x4000 : 0x1000; CreateInfo.dwRawChunkSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_4) ? 0x4000 : 0; CreateInfo.dwMaxFileCount = dwMaxFileCount; - - // Set the proper attribute parts - if((CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_3) && (dwCreateFlags & MPQ_CREATE_ATTRIBUTES)) - CreateInfo.dwAttrFlags |= MPQ_ATTRIBUTE_PATCH_BIT; - - // Backward compatibility: SFileCreateArchive always used to add (listfile) - // We would break loads of applications if we change that - CreateInfo.dwFileFlags1 = MPQ_FILE_DEFAULT_INTERNAL; - - // Let the main function create the archive return SFileCreateArchive2(szMpqName, &CreateInfo, phMpq); } @@ -102,13 +86,11 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea { TFileStream * pStream = NULL; // File stream TMPQArchive * ha = NULL; // MPQ archive handle - TMPQHeader * pHeader; ULONGLONG MpqPos = 0; // Position of MPQ header in the file HANDLE hMpq = NULL; DWORD dwBlockTableSize = 0; // Initial block table size DWORD dwHashTableSize = 0; - DWORD dwReservedFiles = 0; // Number of reserved file entries - DWORD dwMpqFlags = 0; + DWORD dwMaxFileCount; int nError = ERROR_SUCCESS; // Check the parameters, if they are valid @@ -119,12 +101,13 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea } // Verify if all variables in SFILE_CREATE_MPQ are correct - if((pCreateInfo->cbSize == 0 || pCreateInfo->cbSize > sizeof(SFILE_CREATE_MPQ)) || - (pCreateInfo->dwMpqVersion > MPQ_FORMAT_VERSION_4) || - (pCreateInfo->pvUserData != NULL || pCreateInfo->cbUserData != 0) || - (pCreateInfo->dwAttrFlags & ~MPQ_ATTRIBUTE_ALL) || - (pCreateInfo->dwSectorSize & (pCreateInfo->dwSectorSize - 1)) || - (pCreateInfo->dwRawChunkSize & (pCreateInfo->dwRawChunkSize - 1))) + if((pCreateInfo->cbSize == 0 || pCreateInfo->cbSize > sizeof(SFILE_CREATE_MPQ)) || + (pCreateInfo->dwMpqVersion > MPQ_FORMAT_VERSION_4) || + (pCreateInfo->pvUserData != NULL || pCreateInfo->cbUserData != 0) || + (pCreateInfo->dwAttrFlags & ~MPQ_ATTRIBUTE_ALL) || + (pCreateInfo->dwSectorSize & (pCreateInfo->dwSectorSize - 1)) || + (pCreateInfo->dwRawChunkSize & (pCreateInfo->dwRawChunkSize - 1)) || + (pCreateInfo->dwMaxFileCount < 4)) { SetLastError(ERROR_INVALID_PARAMETER); return false; @@ -135,7 +118,7 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea // We verify if the file already exists and if it's a MPQ archive. // If yes, we won't allow to overwrite it. - if(SFileOpenArchive(szMpqName, 0, STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE | MPQ_OPEN_NO_ATTRIBUTES | MPQ_OPEN_NO_LISTFILE, &hMpq)) + if(SFileOpenArchive(szMpqName, 0, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE | MPQ_OPEN_NO_ATTRIBUTES | MPQ_OPEN_NO_LISTFILE, &hMpq)) { SFileCloseArchive(hMpq); SetLastError(ERROR_ALREADY_EXISTS); @@ -156,29 +139,15 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea return false; } - // Increment the maximum amount of files to have space for (listfile) - if(pCreateInfo->dwMaxFileCount && pCreateInfo->dwFileFlags1) - { - dwMpqFlags |= MPQ_FLAG_LISTFILE_NEW; - dwReservedFiles++; - } - - // Increment the maximum amount of files to have space for (attributes) - if(pCreateInfo->dwMaxFileCount && pCreateInfo->dwFileFlags2 && pCreateInfo->dwAttrFlags) - { - dwMpqFlags |= MPQ_FLAG_ATTRIBUTES_NEW; - dwReservedFiles++; - } - - // Increment the maximum amount of files to have space for (signature) - if(pCreateInfo->dwMaxFileCount && pCreateInfo->dwFileFlags3) - { - dwMpqFlags |= MPQ_FLAG_SIGNATURE_NEW; - dwReservedFiles++; - } + // Increment the maximum amount of files to have space + // for listfile and attributes file + dwMaxFileCount = pCreateInfo->dwMaxFileCount; + if(pCreateInfo->dwAttrFlags != 0) + dwMaxFileCount++; + dwMaxFileCount++; // If file count is not zero, initialize the hash table size - dwHashTableSize = GetNearestPowerOfTwo(pCreateInfo->dwMaxFileCount + dwReservedFiles); + dwHashTableSize = GetHashTableSizeForFileCount(dwMaxFileCount); // Retrieve the file size and round it up to 0x200 bytes FileStream_GetSize(pStream, &MpqPos); @@ -186,9 +155,9 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea if(!FileStream_SetSize(pStream, MpqPos)) nError = GetLastError(); -#ifdef _DEBUG +#ifdef _DEBUG // Debug code, used for testing StormLib -// dwBlockTableSize = dwHashTableSize * 2; + // dwBlockTableSize = dwHashTableSize * 2; #endif // Create the archive handle @@ -202,21 +171,26 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea if(nError == ERROR_SUCCESS) { memset(ha, 0, sizeof(TMPQArchive)); - ha->pfnHashString = HashStringSlash; ha->pStream = pStream; ha->dwSectorSize = pCreateInfo->dwSectorSize; ha->UserDataPos = MpqPos; ha->MpqPos = MpqPos; - ha->pHeader = pHeader = (TMPQHeader *)ha->HeaderData; - ha->dwMaxFileCount = dwHashTableSize; + ha->pHeader = (TMPQHeader *)ha->HeaderData; + ha->dwMaxFileCount = dwMaxFileCount; ha->dwFileTableSize = 0; - ha->dwReservedFiles = dwReservedFiles; ha->dwFileFlags1 = pCreateInfo->dwFileFlags1; ha->dwFileFlags2 = pCreateInfo->dwFileFlags2; - ha->dwFileFlags3 = pCreateInfo->dwFileFlags3 ? MPQ_FILE_EXISTS : 0; + ha->dwFlags = 0; + + // Setup the attributes ha->dwAttrFlags = pCreateInfo->dwAttrFlags; - ha->dwFlags = dwMpqFlags | MPQ_FLAG_CHANGED; pStream = NULL; + } + + // Fill the MPQ header + if(nError == ERROR_SUCCESS) + { + TMPQHeader * pHeader = ha->pHeader; // Fill the MPQ header memset(pHeader, 0, sizeof(ha->HeaderData)); @@ -237,37 +211,44 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea // Write the naked MPQ header nError = WriteNakedMPQHeader(ha); + + // Remember that the (listfile) and (attributes) need to be saved + ha->dwFlags |= MPQ_FLAG_CHANGED | MPQ_FLAG_INV_LISTFILE | MPQ_FLAG_INV_ATTRIBUTES; } // Create initial HET table, if the caller required an MPQ format 3.0 or newer - if(nError == ERROR_SUCCESS && pCreateInfo->dwMpqVersion >= MPQ_FORMAT_VERSION_3 && pCreateInfo->dwMaxFileCount != 0) + if(nError == ERROR_SUCCESS && pCreateInfo->dwMpqVersion >= MPQ_FORMAT_VERSION_3) { - ha->pHetTable = CreateHetTable(ha->dwFileTableSize, 0, 0x40, NULL); + ha->pHetTable = CreateHetTable(ha->dwMaxFileCount, 0x40, true); if(ha->pHetTable == NULL) nError = ERROR_NOT_ENOUGH_MEMORY; } // Create initial hash table - if(nError == ERROR_SUCCESS && dwHashTableSize != 0) + if(nError == ERROR_SUCCESS) { nError = CreateHashTable(ha, dwHashTableSize); } // Create initial file table - if(nError == ERROR_SUCCESS && ha->dwMaxFileCount != 0) + if(nError == ERROR_SUCCESS) { - nError = CreateFileTable(ha, ha->dwMaxFileCount); + ha->pFileTable = STORM_ALLOC(TFileEntry, ha->dwMaxFileCount); + if(ha->pFileTable != NULL) + memset(ha->pFileTable, 0x00, sizeof(TFileEntry) * ha->dwMaxFileCount); + else + nError = ERROR_NOT_ENOUGH_MEMORY; } // Cleanup : If an error, delete all buffers and return if(nError != ERROR_SUCCESS) { FileStream_Close(pStream); - FreeArchiveHandle(ha); + FreeMPQArchive(ha); SetLastError(nError); ha = NULL; } - + // Return the values *phMpq = (HANDLE)ha; return (nError == ERROR_SUCCESS); diff --git a/dep/StormLib/src/SFileExtractFile.cpp b/dep/StormLib/src/SFileExtractFile.cpp index cabde4927..c8053ed4e 100644 --- a/dep/StormLib/src/SFileExtractFile.cpp +++ b/dep/StormLib/src/SFileExtractFile.cpp @@ -28,29 +28,32 @@ bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR // Create the local file if(nError == ERROR_SUCCESS) { - pLocalFile = FileStream_CreateFile(szExtracted, 0); + pLocalFile = FileStream_CreateFile(szExtracted, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); if(pLocalFile == NULL) nError = GetLastError(); } // Copy the file's content - while(nError == ERROR_SUCCESS) + if(nError == ERROR_SUCCESS) { char szBuffer[0x1000]; - DWORD dwTransferred = 0; + DWORD dwTransferred; - // dwTransferred is only set to nonzero if something has been read. - // nError can be ERROR_SUCCESS or ERROR_HANDLE_EOF - if(!SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL)) - nError = GetLastError(); - if(nError == ERROR_HANDLE_EOF) - nError = ERROR_SUCCESS; - if(dwTransferred == 0) - break; + for(;;) + { + // dwTransferred is only set to nonzero if something has been read. + // nError can be ERROR_SUCCESS or ERROR_HANDLE_EOF + if(!SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL)) + nError = GetLastError(); + if(nError == ERROR_HANDLE_EOF) + nError = ERROR_SUCCESS; + if(dwTransferred == 0) + break; - // If something has been actually read, write it - if(!FileStream_Write(pLocalFile, NULL, szBuffer, dwTransferred)) - nError = GetLastError(); + // If something has been actually read, write it + if(!FileStream_Write(pLocalFile, NULL, szBuffer, dwTransferred)) + nError = GetLastError(); + } } // Close the files diff --git a/dep/StormLib/src/SFileFindFile.cpp b/dep/StormLib/src/SFileFindFile.cpp index a27cf02f7..952d4d016 100644 --- a/dep/StormLib/src/SFileFindFile.cpp +++ b/dep/StormLib/src/SFileFindFile.cpp @@ -12,9 +12,17 @@ #include "StormLib.h" #include "StormCommon.h" +//----------------------------------------------------------------------------- +// Defines + +#define LISTFILE_CACHE_SIZE 0x1000 + //----------------------------------------------------------------------------- // Private structure used for file search (search handle) +struct TMPQSearch; +typedef int (*MPQSEARCH)(TMPQSearch *, SFILE_FIND_DATA *); + // Used by searching in MPQ archives struct TMPQSearch { @@ -29,67 +37,97 @@ struct TMPQSearch //----------------------------------------------------------------------------- // Local functions -static TMPQSearch * IsValidSearchHandle(HANDLE hFind) +static bool IsValidSearchHandle(TMPQSearch * hs) { - TMPQSearch * hs = (TMPQSearch *)hFind; + if(hs == NULL) + return false; - if(hs != NULL && IsValidMpqHandle(hs->ha)) - return hs; - - return NULL; + return IsValidMpqHandle(hs->ha); } bool CheckWildCard(const char * szString, const char * szWildCard) { - const char * szWildCardPtr; + const char * szSubString; + int nSubStringLength; + int nMatchCount = 0; + // When the mask is empty, it never matches + if(szWildCard == NULL || *szWildCard == 0) + return false; + + // If the wildcard contains just "*", then it always matches + if(szWildCard[0] == '*' && szWildCard[1] == 0) + return true; + + // Do normal test for(;;) { // If there is '?' in the wildcard, we skip one char - while(szWildCard[0] == '?') + while(*szWildCard == '?') { - if(szString[0] == 0) - return false; - szWildCard++; szString++; } - // Handle '*' - szWildCardPtr = szWildCard; - if(szWildCardPtr[0] != 0) + // If there is '*', means zero or more chars. We have to + // find the sequence after '*' + if(*szWildCard == '*') { - if(szWildCardPtr[0] == '*') + // More stars is equal to one star + while(*szWildCard == '*' || *szWildCard == '?') + szWildCard++; + + // If we found end of the wildcard, it's a match + if(*szWildCard == 0) + return true; + + // Determine the length of the substring in szWildCard + szSubString = szWildCard; + while(*szSubString != 0 && *szSubString != '?' && *szSubString != '*') + szSubString++; + nSubStringLength = (int)(szSubString - szWildCard); + nMatchCount = 0; + + // Now we have to find a substring in szString, + // that matches the substring in szWildCard + while(*szString != 0) { - szWildCardPtr++; - - if(szWildCardPtr[0] == '*') - continue; - - if(szWildCardPtr[0] == 0) - return true; - - if(AsciiToUpperTable[szWildCardPtr[0]] == AsciiToUpperTable[szString[0]]) + // Calculate match count + while(nMatchCount < nSubStringLength) { - if(CheckWildCard(szString, szWildCardPtr)) - return true; + if(toupper(szString[nMatchCount]) != toupper(szWildCard[nMatchCount])) + break; + if(szString[nMatchCount] == 0) + break; + nMatchCount++; } - } - else - { - if(AsciiToUpperTable[szWildCardPtr[0]] != AsciiToUpperTable[szString[0]]) - return false; - szWildCard = szWildCardPtr + 1; - } + // If the match count has reached substring length, we found a match + if(nMatchCount == nSubStringLength) + { + szWildCard += nMatchCount; + szString += nMatchCount; + break; + } - if(szString[0] == 0) - return false; - szString++; + // No match, move to the next char in szString + nMatchCount = 0; + szString++; + } } else { - return (szString[0] == 0) ? true : false; + // If we came to the end of the string, compare it to the wildcard + if(toupper(*szString) != toupper(*szWildCard)) + return false; + + // If we arrived to the end of the string, it's a match + if(*szString == 0) + return true; + + // Otherwise, continue in comparing + szWildCard++; + szString++; } } } @@ -102,7 +140,7 @@ static DWORD GetSearchTableItems(TMPQArchive * ha) while(ha != NULL) { // Append the number of files - dwMergeItems += (ha->pHetTable != NULL) ? ha->pHetTable->dwEntryCount + dwMergeItems += (ha->pHetTable != NULL) ? ha->pHetTable->dwMaxFileCount : ha->pHeader->dwBlockTableSize; // Move to the patched archive ha = ha->haPatch; @@ -113,9 +151,9 @@ static DWORD GetSearchTableItems(TMPQArchive * ha) } static bool FileWasFoundBefore( - TMPQArchive * ha, - TMPQSearch * hs, - TFileEntry * pFileEntry) + TMPQArchive * ha, + TMPQSearch * hs, + TFileEntry * pFileEntry) { TFileEntry * pEntry; char * szRealFileName = pFileEntry->szFileName; @@ -127,18 +165,18 @@ static bool FileWasFoundBefore( { // If we are in patch MPQ, we check if patch prefix matches // and then trim the patch prefix - if(ha->pPatchPrefix != NULL) + if(ha->cchPatchPrefix != 0) { // If the patch prefix doesn't fit, we pretend that the file // was there before and it will be skipped - if(_strnicmp(szRealFileName, ha->pPatchPrefix->szPatchPrefix, ha->pPatchPrefix->nLength)) + if(_strnicmp(szRealFileName, ha->szPatchPrefix, ha->cchPatchPrefix)) return true; - szRealFileName += ha->pPatchPrefix->nLength; + szRealFileName += ha->cchPatchPrefix; } // Calculate the hash to the table - dwNameHash = ha->pfnHashString(szRealFileName, MPQ_HASH_NAME_A); + dwNameHash = HashString(szRealFileName, MPQ_HASH_NAME_A); dwStartIndex = dwIndex = (dwNameHash % hs->dwSearchTableItems); // The file might have been found before @@ -175,185 +213,114 @@ static bool FileWasFoundBefore( static TFileEntry * FindPatchEntry(TMPQArchive * ha, TFileEntry * pFileEntry) { - TFileEntry * pPatchEntry = pFileEntry; + TFileEntry * pPatchEntry = NULL; TFileEntry * pTempEntry; - char szFileName[MAX_PATH+1]; + char szFileName[MAX_PATH]; + LCID lcLocale = pFileEntry->lcLocale; - // Can't find patch entry for a file that doesn't have name - if(pFileEntry->szFileName != NULL && pFileEntry->szFileName[0] != 0) + // Go while there are patches + while(ha->haPatch != NULL) { - // Go while there are patches - while(ha->haPatch != NULL) - { - // Move to the patch archive - ha = ha->haPatch; - szFileName[0] = 0; + // Move to the patch archive + ha = ha->haPatch; - // Prepare the prefix for the file name - if(ha->pPatchPrefix && ha->pPatchPrefix->nLength) - StringCopy(szFileName, _countof(szFileName), ha->pPatchPrefix->szPatchPrefix); - StringCat(szFileName, _countof(szFileName), pFileEntry->szFileName); + // Prepare the prefix for the file name + strcpy(szFileName, ha->szPatchPrefix); + strcat(szFileName, pFileEntry->szFileName); - // Try to find the file there - pTempEntry = GetFileEntryExact(ha, szFileName, 0, NULL); - if(pTempEntry != NULL) - pPatchEntry = pTempEntry; - } + // Try to find the file there + pTempEntry = GetFileEntryExact(ha, szFileName, lcLocale); + if(pTempEntry != NULL) + pPatchEntry = pTempEntry; } // Return the found patch entry return pPatchEntry; } -static bool DoMPQSearch_FileEntry( - TMPQSearch * hs, - SFILE_FIND_DATA * lpFindFileData, - TMPQArchive * ha, - TMPQHash * pHashEntry, - TFileEntry * pFileEntry) -{ - TFileEntry * pPatchEntry; - HANDLE hFile = NULL; - const char * szFileName; - size_t nPrefixLength = (ha->pPatchPrefix != NULL) ? ha->pPatchPrefix->nLength : 0; - DWORD dwBlockIndex; - char szNameBuff[MAX_PATH]; - - // Is it a file but not a patch file? - if((pFileEntry->dwFlags & hs->dwFlagMask) == MPQ_FILE_EXISTS) - { - // Now we have to check if this file was not enumerated before - if(!FileWasFoundBefore(ha, hs, pFileEntry)) - { -// if(pFileEntry != NULL && !_stricmp(pFileEntry->szFileName, "TriggerLibs\\NativeLib.galaxy")) -// DebugBreak(); - - // Find a patch to this file - // Note: This either succeeds or returns pFileEntry - pPatchEntry = FindPatchEntry(ha, pFileEntry); - - // Prepare the block index - dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable); - - // Get the file name. If it's not known, we will create pseudo-name - szFileName = pFileEntry->szFileName; - if(szFileName == NULL) - { - // Open the file by its pseudo-name. - sprintf(szNameBuff, "File%08u.xxx", (unsigned int)dwBlockIndex); - if(SFileOpenFileEx((HANDLE)hs->ha, szNameBuff, SFILE_OPEN_BASE_FILE, &hFile)) - { - SFileGetFileName(hFile, szNameBuff); - szFileName = szNameBuff; - SFileCloseFile(hFile); - } - } - - // If the file name is still NULL, we cannot include the file to search results - if(szFileName != NULL) - { - // Check the file name against the wildcard - if(CheckWildCard(szFileName + nPrefixLength, hs->szSearchMask)) - { - // Fill the found entry. hash entry and block index are taken from the base MPQ - lpFindFileData->dwHashIndex = HASH_ENTRY_FREE; - lpFindFileData->dwBlockIndex = dwBlockIndex; - lpFindFileData->dwFileSize = pPatchEntry->dwFileSize; - lpFindFileData->dwFileFlags = pPatchEntry->dwFlags; - lpFindFileData->dwCompSize = pPatchEntry->dwCmpSize; - lpFindFileData->lcLocale = 0; // pPatchEntry->lcLocale; - - // Fill the filetime - lpFindFileData->dwFileTimeHi = (DWORD)(pPatchEntry->FileTime >> 32); - lpFindFileData->dwFileTimeLo = (DWORD)(pPatchEntry->FileTime); - - // Fill-in the entries from hash table entry, if given - if(pHashEntry != NULL) - { - lpFindFileData->dwHashIndex = (DWORD)(pHashEntry - ha->pHashTable); - lpFindFileData->lcLocale = pHashEntry->lcLocale; - } - - // Fill the file name and plain file name - StringCopy(lpFindFileData->cFileName, _countof(lpFindFileData->cFileName), szFileName + nPrefixLength); - lpFindFileData->szPlainName = (char *)GetPlainFileName(lpFindFileData->cFileName); - return true; - } - } - } - } - - // Either not a valid item or was found before - return false; -} - -static int DoMPQSearch_HashTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha) -{ - TMPQHash * pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash; - - // Parse the file table - for(pHash = ha->pHashTable + hs->dwNextIndex; pHash < pHashTableEnd; pHash++) - { - // Increment the next index for subsequent search - hs->dwNextIndex++; - - // Does this hash table entry point to a proper block table entry? - if(IsValidHashEntry(ha, pHash)) - { - // Check if this file entry should be included in the search result - if(DoMPQSearch_FileEntry(hs, lpFindFileData, ha, pHash, ha->pFileTable + MPQ_BLOCK_INDEX(pHash))) - return ERROR_SUCCESS; - } - } - - // No more files - return ERROR_NO_MORE_FILES; -} - -static int DoMPQSearch_FileTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - - // Parse the file table - for(pFileEntry = ha->pFileTable + hs->dwNextIndex; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Increment the next index for subsequent search - hs->dwNextIndex++; - - // Check if this file entry should be included in the search result - if(DoMPQSearch_FileEntry(hs, lpFindFileData, ha, NULL, pFileEntry)) - return ERROR_SUCCESS; - } - - // No more files - return ERROR_NO_MORE_FILES; -} - // Performs one MPQ search static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData) { TMPQArchive * ha = hs->ha; - int nError; + TFileEntry * pFileTableEnd; + TFileEntry * pPatchEntry; + TFileEntry * pFileEntry; + const char * szFileName; + HANDLE hFile; + char szPseudoName[20]; + DWORD dwBlockIndex; + size_t nPrefixLength; // Start searching with base MPQ while(ha != NULL) - { - // If the archive has hash table, we need to use hash table - // in order to catch hash table index and file locale. - // Note: If multiple hash table entries, point to the same block entry, - // we need, to report them all - nError = (ha->pHashTable != NULL) ? DoMPQSearch_HashTable(hs, lpFindFileData, ha) - : DoMPQSearch_FileTable(hs, lpFindFileData, ha); - if(nError == ERROR_SUCCESS) - return nError; + { + // Now parse the file entry table in order to get all files. + pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; + pFileEntry = ha->pFileTable + hs->dwNextIndex; - // If there is no more patches in the chain, stop it. - // This also keeps hs->ha non-NULL, which is required - // for freeing the handle later - if(ha->haPatch == NULL) - break; + // Get the length of the patch prefix (0 if none) + nPrefixLength = strlen(ha->szPatchPrefix); + + // Parse the file table + while(pFileEntry < pFileTableEnd) + { + // Increment the next index for subsequent search + hs->dwNextIndex++; + + // Is it a file and not a patch file? + if((pFileEntry->dwFlags & hs->dwFlagMask) == MPQ_FILE_EXISTS) + { + // Now we have to check if this file was not enumerated before + if(!FileWasFoundBefore(ha, hs, pFileEntry)) + { + // Find a patch to this file + pPatchEntry = FindPatchEntry(ha, pFileEntry); + if(pPatchEntry == NULL) + pPatchEntry = pFileEntry; + + // Prepare the block index + dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable); + + // Get the file name. If it's not known, we will create pseudo-name + szFileName = pFileEntry->szFileName; + if(szFileName == NULL) + { + // Open the file by its pseudo-name. + // This also generates the file name with a proper extension + sprintf(szPseudoName, "File%08u.xxx", dwBlockIndex); + if(SFileOpenFileEx((HANDLE)hs->ha, szPseudoName, SFILE_OPEN_FROM_MPQ, &hFile)) + { + szFileName = (pFileEntry->szFileName != NULL) ? pFileEntry->szFileName : szPseudoName; + SFileCloseFile(hFile); + } + } + + // Check the file name against the wildcard + if(CheckWildCard(szFileName + nPrefixLength, hs->szSearchMask)) + { + // Fill the found entry + lpFindFileData->dwHashIndex = pPatchEntry->dwHashIndex; + lpFindFileData->dwBlockIndex = dwBlockIndex; + lpFindFileData->dwFileSize = pPatchEntry->dwFileSize; + lpFindFileData->dwFileFlags = pPatchEntry->dwFlags; + lpFindFileData->dwCompSize = pPatchEntry->dwCmpSize; + lpFindFileData->lcLocale = pPatchEntry->lcLocale; + + // Fill the filetime + lpFindFileData->dwFileTimeHi = (DWORD)(pPatchEntry->FileTime >> 32); + lpFindFileData->dwFileTimeLo = (DWORD)(pPatchEntry->FileTime); + + // Fill the file name and plain file name + strcpy(lpFindFileData->cFileName, szFileName + nPrefixLength); + lpFindFileData->szPlainName = (char *)GetPlainFileNameA(lpFindFileData->cFileName); + return ERROR_SUCCESS; + } + + } + } + + pFileEntry++; + } // Move to the next patch in the patch chain hs->ha = ha = ha->haPatch; @@ -378,7 +345,7 @@ static void FreeMPQSearch(TMPQSearch *& hs) //----------------------------------------------------------------------------- // Public functions -HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile) +HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile) { TMPQArchive * ha = (TMPQArchive *)hMpq; TMPQSearch * hs = NULL; @@ -386,7 +353,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA int nError = ERROR_SUCCESS; // Check for the valid parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) nError = ERROR_INVALID_HANDLE; if(szMask == NULL || lpFindFileData == NULL) nError = ERROR_INVALID_PARAMETER; @@ -439,18 +406,18 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA FreeMPQSearch(hs); SetLastError(nError); } - + // Return the result value return (HANDLE)hs; } bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) { - TMPQSearch * hs = IsValidSearchHandle(hFind); + TMPQSearch * hs = (TMPQSearch *)hFind; int nError = ERROR_SUCCESS; // Check the parameters - if(hs == NULL) + if(!IsValidSearchHandle(hs)) nError = ERROR_INVALID_HANDLE; if(lpFindFileData == NULL) nError = ERROR_INVALID_PARAMETER; @@ -465,10 +432,10 @@ bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) bool WINAPI SFileFindClose(HANDLE hFind) { - TMPQSearch * hs = IsValidSearchHandle(hFind); + TMPQSearch * hs = (TMPQSearch *)hFind; // Check the parameters - if(hs == NULL) + if(!IsValidSearchHandle(hs)) { SetLastError(ERROR_INVALID_HANDLE); return false; diff --git a/dep/StormLib/src/SFileListFile.cpp b/dep/StormLib/src/SFileListFile.cpp index 777bba3cf..a575c581a 100644 --- a/dep/StormLib/src/SFileListFile.cpp +++ b/dep/StormLib/src/SFileListFile.cpp @@ -17,279 +17,202 @@ // Listfile entry structure #define CACHE_BUFFER_SIZE 0x1000 // Size of the cache buffer -#define MAX_LISTFILE_SIZE 0x04000000 // Maximum accepted listfile size is about 68 MB - -union TListFileHandle -{ - TFileStream * pStream; // Opened local file - HANDLE hFile; // Opened MPQ file -}; struct TListFileCache { - char * szWildCard; // Self-relative pointer to file mask - LPBYTE pBegin; // The begin of the listfile cache - LPBYTE pPos; // Current position in the cache - LPBYTE pEnd; // The last character in the file cache - DWORD dwFlags; // Flags from TMPQArchive + HANDLE hFile; // Stormlib file handle + char * szMask; // File mask + DWORD dwFileSize; // Total size of the cached file + DWORD dwFilePos; // Position of the cache in the file + BYTE * pBegin; // The begin of the listfile cache + BYTE * pPos; + BYTE * pEnd; // The last character in the file cache -// char szWildCard[wildcard_length]; // Followed by the name mask (if any) -// char szListFile[listfile_length]; // Followed by the listfile (if any) + BYTE Buffer[CACHE_BUFFER_SIZE]; // Listfile cache itself }; -typedef bool (*LOAD_LISTFILE)(TListFileHandle * pHandle, void * pvBuffer, DWORD cbBuffer, LPDWORD pdwBytesRead); - //----------------------------------------------------------------------------- // Local functions (cache) -static char * CopyListLine(char * szListLine, const char * szFileName) -{ - // Copy the string - while(szFileName[0] != 0) - *szListLine++ = *szFileName++; - - // Append the end-of-line - *szListLine++ = 0x0D; - *szListLine++ = 0x0A; - return szListLine; -} - -static bool LoadListFile_Stream(TListFileHandle * pHandle, void * pvBuffer, DWORD cbBuffer, LPDWORD pdwBytesRead) -{ - ULONGLONG ByteOffset = 0; - bool bResult; - - bResult = FileStream_Read(pHandle->pStream, &ByteOffset, pvBuffer, cbBuffer); - if(bResult) - *pdwBytesRead = cbBuffer; - return bResult; -} - -static bool LoadListFile_MPQ(TListFileHandle * pHandle, void * pvBuffer, DWORD cbBuffer, LPDWORD pdwBytesRead) -{ - return SFileReadFile(pHandle->hFile, pvBuffer, cbBuffer, pdwBytesRead, NULL); -} - static bool FreeListFileCache(TListFileCache * pCache) { // Valid parameter check - if(pCache != NULL) - STORM_FREE(pCache); + if(pCache == NULL) + return false; + + // Free all allocated buffers + if(pCache->hFile != NULL) + SFileCloseFile(pCache->hFile); + if(pCache->szMask != NULL) + STORM_FREE(pCache->szMask); + STORM_FREE(pCache); return true; } -static TListFileCache * CreateListFileCache( - LOAD_LISTFILE PfnLoadFile, - TListFileHandle * pHandle, - const char * szWildCard, - DWORD dwFileSize, - DWORD dwMaxSize, - DWORD dwFlags) +static TListFileCache * CreateListFileCache(HANDLE hListFile, const char * szMask) { TListFileCache * pCache = NULL; - size_t cchWildCard = 0; DWORD dwBytesRead = 0; - - // Get the amount of bytes that need to be allocated - if(dwFileSize == 0 || dwFileSize > dwMaxSize) - return NULL; - - // Append buffer for name mask, if any - if(szWildCard != NULL) - cchWildCard = strlen(szWildCard) + 1; + int nError = ERROR_SUCCESS; // Allocate cache for one file block - pCache = (TListFileCache *)STORM_ALLOC(BYTE, sizeof(TListFileCache) + cchWildCard + dwFileSize + 1); - if(pCache != NULL) + pCache = (TListFileCache *)STORM_ALLOC(TListFileCache, 1); + if(pCache == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + + // Clear the entire structure + if(nError == ERROR_SUCCESS) { - // Clear the entire structure - memset(pCache, 0, sizeof(TListFileCache) + cchWildCard); - pCache->dwFlags = dwFlags; + memset(pCache, 0, sizeof(TListFileCache)); + pCache->hFile = hListFile; - // Shall we copy the mask? - if(cchWildCard != 0) + // Shall we allocate a mask? + if(szMask != NULL) { - pCache->szWildCard = (char *)(pCache + 1); - memcpy(pCache->szWildCard, szWildCard, cchWildCard); + pCache->szMask = STORM_ALLOC(char, strlen(szMask) + 1); + if(pCache->szMask != NULL) + strcpy(pCache->szMask, szMask); + else + nError = ERROR_NOT_ENOUGH_MEMORY; } - - // Fill-in the rest of the cache pointers - pCache->pBegin = (LPBYTE)(pCache + 1) + cchWildCard; + } - // Load the entire listfile to the cache - PfnLoadFile(pHandle, pCache->pBegin, dwFileSize, &dwBytesRead); - if(dwBytesRead != 0) - { - // Allocate pointers - pCache->pPos = pCache->pBegin; - pCache->pEnd = pCache->pBegin + dwBytesRead; - } - else - { - FreeListFileCache(pCache); - pCache = NULL; - } + // Initialize the file cache + if(nError == ERROR_SUCCESS) + { + pCache->dwFileSize = SFileGetFileSize(pCache->hFile, NULL); + + // Fill the cache + SFileReadFile(pCache->hFile, pCache->Buffer, CACHE_BUFFER_SIZE, &dwBytesRead, NULL); + if(dwBytesRead == 0) + nError = GetLastError(); + } + + // Allocate pointers + if(nError == ERROR_SUCCESS) + { + pCache->pBegin = + pCache->pPos = &pCache->Buffer[0]; + pCache->pEnd = pCache->pBegin + dwBytesRead; + } + else + { + FreeListFileCache(pCache); + SetLastError(nError); + pCache = NULL; } // Return the cache return pCache; } -static TListFileCache * CreateListFileCache( - HANDLE hMpq, - const TCHAR * szListFile, - const char * szWildCard, - DWORD dwMaxSize, - DWORD dwFlags) +// Reloads the cache. Returns number of characters +// that has been loaded into the cache. +static DWORD ReloadListFileCache(TListFileCache * pCache) { - TListFileCache * pCache = NULL; - TListFileHandle ListHandle = {NULL}; - - // Internal listfile: hMPQ must be non NULL and szListFile must be NULL. - // We load the MPQ::(listfile) file - if(hMpq != NULL && szListFile == NULL) - { - DWORD dwFileSize = 0; - - // Open the file from the MPQ - if(SFileOpenFileEx(hMpq, LISTFILE_NAME, 0, &ListHandle.hFile)) - { - // Get the file size and create the listfile cache - dwFileSize = SFileGetFileSize(ListHandle.hFile, NULL); - pCache = CreateListFileCache(LoadListFile_MPQ, &ListHandle, szWildCard, dwFileSize, dwMaxSize, dwFlags); - - // Close the MPQ file - SFileCloseFile(ListHandle.hFile); - } - - // Return the loaded cache - return pCache; - } - - // External listfile: hMpq must be NULL and szListFile must be non-NULL. - // We load the file using TFileStream - if(hMpq == NULL && szListFile != NULL) - { - ULONGLONG FileSize = 0; - - // Open the local file - ListHandle.pStream = FileStream_OpenFile(szListFile, STREAM_FLAG_READ_ONLY); - if(ListHandle.pStream != NULL) - { - // Verify the file size - FileStream_GetSize(ListHandle.pStream, &FileSize); - if(0 < FileSize && FileSize < MAX_LISTFILE_SIZE) - { - pCache = CreateListFileCache(LoadListFile_Stream, &ListHandle, szWildCard, (DWORD)FileSize, dwMaxSize, dwFlags); - } - - // Close the stream - FileStream_Close(ListHandle.pStream); - } - - // Return the loaded cache - return pCache; - } - - // This combination should never happen - SetLastError(ERROR_INVALID_PARAMETER); - assert(false); - return NULL; -} - -#ifdef _DEBUG -/* -TMPQNameCache * CreateNameCache(HANDLE hListFile, const char * szSearchMask) -{ - TMPQNameCache * pNameCache; - char * szCachePointer; - size_t cbToAllocate; - size_t nMaskLength = 1; + DWORD dwBytesToRead; DWORD dwBytesRead = 0; - DWORD dwFileSize; - // Get the size of the listfile. Ignore zero or too long ones - dwFileSize = SFileGetFileSize(hListFile, NULL); - if(dwFileSize == 0 || dwFileSize > MAX_LISTFILE_SIZE) - return NULL; - - // Get the length of the search mask - if(szSearchMask == NULL) - szSearchMask = "*"; - nMaskLength = strlen(szSearchMask) + 1; - - // Allocate the name cache - cbToAllocate = sizeof(TMPQNameCache) + nMaskLength + dwFileSize + 1; - pNameCache = (TMPQNameCache *)STORM_ALLOC(BYTE, cbToAllocate); - if(pNameCache != NULL) + // Only do something if the cache is empty + if(pCache->pPos >= pCache->pEnd) { - // Initialize the name cache - memset(pNameCache, 0, sizeof(TMPQNameCache)); - pNameCache->TotalCacheSize = (DWORD)(nMaskLength + dwFileSize + 1); - szCachePointer = (char *)(pNameCache + 1); + // __TryReadBlock: - // Copy the search mask, if any - memcpy(szCachePointer, szSearchMask, nMaskLength); - pNameCache->FirstNameOffset = (DWORD)nMaskLength; - pNameCache->FreeSpaceOffset = (DWORD)nMaskLength; + // Move the file position forward + pCache->dwFilePos += CACHE_BUFFER_SIZE; + if(pCache->dwFilePos >= pCache->dwFileSize) + return 0; - // Read the listfile itself - SFileSetFilePointer(hListFile, 0, NULL, FILE_BEGIN); - SFileReadFile(hListFile, szCachePointer + nMaskLength, dwFileSize, &dwBytesRead, NULL); + // Get the number of bytes remaining + dwBytesToRead = pCache->dwFileSize - pCache->dwFilePos; + if(dwBytesToRead > CACHE_BUFFER_SIZE) + dwBytesToRead = CACHE_BUFFER_SIZE; - // If nothing has been read from the listfile, clear the cache + // Load the next data chunk to the cache + SFileSetFilePointer(pCache->hFile, pCache->dwFilePos, NULL, FILE_BEGIN); + SFileReadFile(pCache->hFile, pCache->Buffer, CACHE_BUFFER_SIZE, &dwBytesRead, NULL); + + // If we didn't read anything, it might mean that the block + // of the file is not available (in case of partial MPQs). + // We stop reading the file at this point, because the rest + // of the listfile is unreliable if(dwBytesRead == 0) - { - STORM_FREE(pNameCache); - return NULL; - } + return 0; - // Move the free space offset - pNameCache->FreeSpaceOffset = pNameCache->FirstNameOffset + dwBytesRead + 1; - szCachePointer[nMaskLength + dwBytesRead] = 0; + // Set the buffer pointers + pCache->pBegin = + pCache->pPos = &pCache->Buffer[0]; + pCache->pEnd = pCache->pBegin + dwBytesRead; } - return pNameCache; + return dwBytesRead; } -static void FreeNameCache(TMPQNameCache * pNameCache) +static size_t ReadListFileLine(TListFileCache * pCache, char * szLine, int nMaxChars) { - if(pNameCache != NULL) - STORM_FREE(pNameCache); - pNameCache = NULL; -} -*/ -#endif // _DEBUG + char * szLineBegin = szLine; + char * szLineEnd = szLine + nMaxChars - 1; + char * szExtraString = NULL; -static char * ReadListFileLine(TListFileCache * pCache, size_t * PtrLength) -{ - LPBYTE pbLineBegin; - LPBYTE pbLineEnd; - - // Skip newlines. Keep spaces and tabs, as they can be a legal part of the file name - while(pCache->pPos < pCache->pEnd && (pCache->pPos[0] == 0x0A || pCache->pPos[0] == 0x0D)) + // Skip newlines, spaces, tabs and another non-printable stuff + for(;;) + { + // If we need to reload the cache, do it + if(pCache->pPos == pCache->pEnd) + { + if(ReloadListFileCache(pCache) == 0) + break; + } + + // If we found a non-whitespace character, stop + if(*pCache->pPos > 0x20) + break; + + // Skip the character pCache->pPos++; - - // Set the line begin and end - if(pCache->pPos >= pCache->pEnd) - return NULL; - pbLineBegin = pbLineEnd = pCache->pPos; + } - // Find the end of the line - while(pCache->pPos < pCache->pEnd && pCache->pPos[0] != 0x0A && pCache->pPos[0] != 0x0D) - pCache->pPos++; + // Copy the remaining characters + while(szLine < szLineEnd) + { + // If we need to reload the cache, do it now and resume copying + if(pCache->pPos == pCache->pEnd) + { + if(ReloadListFileCache(pCache) == 0) + break; + } - // Remember the end of the line - pbLineEnd = pCache->pPos++; - pbLineEnd[0] = 0; + // If we have found a newline, stop loading + if(*pCache->pPos == 0x0D || *pCache->pPos == 0x0A) + break; - // Give the line to the caller - if(PtrLength != NULL) - PtrLength[0] = (size_t)(pbLineEnd - pbLineBegin); - return (char *)pbLineBegin; + // Blizzard listfiles can also contain information about patch: + // Pass1\Files\MacOS\unconditional\user\Background Downloader.app\Contents\Info.plist~Patch(Data#frFR#base-frFR,1326) + if(*pCache->pPos == '~') + szExtraString = szLine; + + // Copy the character + *szLine++ = *pCache->pPos++; + } + + // Terminate line with zero + *szLine = 0; + + // If there was extra string after the file name, clear it + if(szExtraString != NULL) + { + if(szExtraString[0] == '~' && szExtraString[1] == 'P') + { + szLine = szExtraString; + *szExtraString = 0; + } + } + + // Return the length of the line + return (szLine - szLineBegin); } -static int CompareFileNodes(const void * p1, const void * p2) +static int CompareFileNodes(const void * p1, const void * p2) { char * szFileName1 = *(char **)p1; char * szFileName2 = *(char **)p2; @@ -297,96 +220,19 @@ static int CompareFileNodes(const void * p1, const void * p2) return _stricmp(szFileName1, szFileName2); } -static LPBYTE CreateListFile(TMPQArchive * ha, DWORD * pcbListFile) +static int WriteListFileLine( + TMPQFile * hf, + const char * szLine) { - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - char ** SortTable = NULL; - char * szListFile = NULL; - char * szListLine; - size_t nFileNodes = 0; - size_t cbListFile = 0; - size_t nIndex0; - size_t nIndex1; + char szNewLine[2] = {0x0D, 0x0A}; + size_t nLength = strlen(szLine); + int nError; - // Allocate the table for sorting listfile - SortTable = STORM_ALLOC(char*, ha->dwFileTableSize); - if(SortTable == NULL) - return NULL; + nError = SFileAddFile_Write(hf, szLine, (DWORD)nLength, MPQ_COMPRESSION_ZLIB); + if(nError != ERROR_SUCCESS) + return nError; - // Construct the sort table - // Note: in MPQs with multiple locale versions of the same file, - // this code causes adding multiple listfile entries. - // They will get removed after the listfile sorting - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Only take existing items - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && pFileEntry->szFileName != NULL) - { - // Ignore pseudo-names and internal names - if(!IsPseudoFileName(pFileEntry->szFileName, NULL) && !IsInternalMpqFileName(pFileEntry->szFileName)) - { - SortTable[nFileNodes++] = pFileEntry->szFileName; - } - } - } - - // Remove duplicities - if(nFileNodes > 0) - { - // Sort the table - qsort(SortTable, nFileNodes, sizeof(char *), CompareFileNodes); - - // Count the 0-th item - cbListFile += strlen(SortTable[0]) + 2; - - // Walk through the items and only use the ones that are not duplicated - for(nIndex0 = 0, nIndex1 = 1; nIndex1 < nFileNodes; nIndex1++) - { - // If the next file node is different, we will include it to the result listfile - if(_stricmp(SortTable[nIndex1], SortTable[nIndex0]) != 0) - { - cbListFile += strlen(SortTable[nIndex1]) + 2; - nIndex0 = nIndex1; - } - } - - // Now allocate buffer for the entire listfile - szListFile = szListLine = STORM_ALLOC(char, cbListFile + 1); - if(szListFile != NULL) - { - // Copy the 0-th item - szListLine = CopyListLine(szListLine, SortTable[0]); - - // Walk through the items and only use the ones that are not duplicated - for(nIndex0 = 0, nIndex1 = 1; nIndex1 < nFileNodes; nIndex1++) - { - // If the next file node is different, we will include it to the result listfile - if(_stricmp(SortTable[nIndex1], SortTable[nIndex0]) != 0) - { - // Copy the listfile line - szListLine = CopyListLine(szListLine, SortTable[nIndex1]); - nIndex0 = nIndex1; - } - } - - // Sanity check - does the size match? - assert((size_t)(szListLine - szListFile) == cbListFile); - } - } - else - { - szListFile = STORM_ALLOC(char, 1); - cbListFile = 0; - } - - // Free the sort table - STORM_FREE(SortTable); - - // Give away the listfile - if(pcbListFile != NULL) - *pcbListFile = (DWORD)cbListFile; - return (LPBYTE)szListFile; + return SFileAddFile_Write(hf, szNewLine, sizeof(szNewLine), MPQ_COMPRESSION_ZLIB); } //----------------------------------------------------------------------------- @@ -397,211 +243,272 @@ static LPBYTE CreateListFile(TMPQArchive * ha, DWORD * pcbListFile) // If the file name is already there, does nothing. static int SListFileCreateNodeForAllLocales(TMPQArchive * ha, const char * szFileName) { + TMPQHeader * pHeader = ha->pHeader; TFileEntry * pFileEntry; TMPQHash * pFirstHash; TMPQHash * pHash; + bool bNameEntryCreated = false; // If we have HET table, use that one if(ha->pHetTable != NULL) { - pFileEntry = GetFileEntryLocale(ha, szFileName, 0); + pFileEntry = GetFileEntryAny(ha, szFileName); if(pFileEntry != NULL) { // Allocate file name for the file entry - AllocateFileName(ha, pFileEntry, szFileName); + AllocateFileName(pFileEntry, szFileName); + bNameEntryCreated = true; } return ERROR_SUCCESS; } // If we have hash table, we use it - if(ha->pHashTable != NULL) + if(bNameEntryCreated == false && ha->pHashTable != NULL) { - // Go while we found something + // Look for the first hash table entry for the file pFirstHash = pHash = GetFirstHashEntry(ha, szFileName); + + // Go while we found something while(pHash != NULL) { - // Allocate file name for the file entry - AllocateFileName(ha, ha->pFileTable + MPQ_BLOCK_INDEX(pHash), szFileName); + // Is it a valid file table index ? + if(pHash->dwBlockIndex < pHeader->dwBlockTableSize) + { + // Allocate file name for the file entry + AllocateFileName(ha->pFileTable + pHash->dwBlockIndex, szFileName); + bNameEntryCreated = true; + } // Now find the next language version of the file pHash = GetNextHashEntry(ha, pFirstHash, pHash); } - - return ERROR_SUCCESS; } return ERROR_CAN_NOT_COMPLETE; } -// Saves the whole listfile to the MPQ +// Saves the whole listfile into the MPQ. int SListFileSaveToMpq(TMPQArchive * ha) { + TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; + TFileEntry * pFileEntry; TMPQFile * hf = NULL; - LPBYTE pbListFile; - DWORD cbListFile = 0; + char * szPrevItem; + char ** SortTable = NULL; + DWORD dwFileSize = 0; + size_t nFileNodes = 0; + size_t i; int nError = ERROR_SUCCESS; - // Only save the listfile if we should do so - if(ha->dwFileFlags1 != 0) + // Allocate the table for sorting listfile + SortTable = STORM_ALLOC(char*, ha->dwFileTableSize); + if(SortTable == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + + // Construct the sort table + // Note: in MPQs with multiple locale versions of the same file, + // this code causes adding multiple listfile entries. + // Since those MPQs were last time used in Starcraft, + // we leave it as it is. + for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) { - // At this point, we expect to have at least one reserved entry in the file table - assert(ha->dwFlags & MPQ_FLAG_LISTFILE_NEW); - assert(ha->dwReservedFiles > 0); - - // Create the raw data that is to be written to (listfile) - // Note: Creating the raw data before the (listfile) has been created in the MPQ - // causes that the name of the listfile will not be included in the listfile itself. - // That is OK, because (listfile) in Blizzard MPQs does not contain it either. - pbListFile = CreateListFile(ha, &cbListFile); - if(pbListFile != NULL) + // Only take existing items + if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && pFileEntry->szFileName != NULL) { - // Determine the real flags for (listfile) - if(ha->dwFileFlags1 == MPQ_FILE_DEFAULT_INTERNAL) - ha->dwFileFlags1 = GetDefaultSpecialFileFlags(cbListFile, ha->pHeader->wFormatVersion); - - // Create the listfile in the MPQ - nError = SFileAddFile_Init(ha, LISTFILE_NAME, - 0, - cbListFile, - LANG_NEUTRAL, - ha->dwFileFlags1 | MPQ_FILE_REPLACEEXISTING, - &hf); - - // Write the listfile raw data to it - if(nError == ERROR_SUCCESS) + // Ignore pseudo-names + if(!IsPseudoFileName(pFileEntry->szFileName, NULL) && !IsInternalMpqFileName(pFileEntry->szFileName)) { - // Write the content of the listfile to the MPQ - nError = SFileAddFile_Write(hf, pbListFile, cbListFile, MPQ_COMPRESSION_ZLIB); - SFileAddFile_Finish(hf); + SortTable[nFileNodes++] = pFileEntry->szFileName; } - - // Clear the listfile flags - ha->dwFlags &= ~(MPQ_FLAG_LISTFILE_NEW | MPQ_FLAG_LISTFILE_NONE); - ha->dwReservedFiles--; - - // Free the listfile buffer - STORM_FREE(pbListFile); - } - else - { - // If the (listfile) file would be empty, its OK - nError = (cbListFile == 0) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY; } } + // Sort the table + qsort(SortTable, nFileNodes, sizeof(char *), CompareFileNodes); + + // Now parse the table of file names again - remove duplicates + // and count file size. + if(nFileNodes != 0) + { + // Count the 0-th item + dwFileSize += (DWORD)strlen(SortTable[0]) + 2; + szPrevItem = SortTable[0]; + + // Count all next items + for(i = 1; i < nFileNodes; i++) + { + // If the item is the same like the last one, skip it + if(_stricmp(SortTable[i], szPrevItem)) + { + dwFileSize += (DWORD)strlen(SortTable[i]) + 2; + szPrevItem = SortTable[i]; + } + } + + // Determine the flags for (listfile) + if(ha->dwFileFlags1 == 0) + ha->dwFileFlags1 = GetDefaultSpecialFileFlags(ha, dwFileSize); + + // Create the listfile in the MPQ + nError = SFileAddFile_Init(ha, LISTFILE_NAME, + 0, + dwFileSize, + LANG_NEUTRAL, + ha->dwFileFlags1 | MPQ_FILE_REPLACEEXISTING, + &hf); + // Add all file names + if(nError == ERROR_SUCCESS) + { + // Each name is followed by newline ("\x0D\x0A") + szPrevItem = SortTable[0]; + nError = WriteListFileLine(hf, SortTable[0]); + + // Count all next items + for(i = 1; i < nFileNodes; i++) + { + // If the item is the same like the last one, skip it + if(_stricmp(SortTable[i], szPrevItem)) + { + WriteListFileLine(hf, SortTable[i]); + szPrevItem = SortTable[i]; + } + } + } + } + else + { + // Create the listfile in the MPQ + dwFileSize = (DWORD)strlen(LISTFILE_NAME) + 2; + nError = SFileAddFile_Init(ha, LISTFILE_NAME, + 0, + dwFileSize, + LANG_NEUTRAL, + MPQ_FILE_ENCRYPTED | MPQ_FILE_COMPRESS | MPQ_FILE_REPLACEEXISTING, + &hf); + + // Just add "(listfile)" there + if(nError == ERROR_SUCCESS) + { + WriteListFileLine(hf, LISTFILE_NAME); + } + } + + // Finalize the file in the MPQ + if(hf != NULL) + { + SFileAddFile_Finish(hf); + } + + // Free buffers + if(nError == ERROR_SUCCESS) + ha->dwFlags &= ~MPQ_FLAG_INV_LISTFILE; + if(SortTable != NULL) + STORM_FREE(SortTable); return nError; } static int SFileAddArbitraryListFile( TMPQArchive * ha, - HANDLE hMpq, - const TCHAR * szListFile, - DWORD dwMaxSize) + HANDLE hListFile) { TListFileCache * pCache = NULL; + size_t nLength; + char szFileName[MAX_PATH]; + int nError = ERROR_SUCCESS; // Create the listfile cache for that file - pCache = CreateListFileCache(hMpq, szListFile, NULL, dwMaxSize, ha->dwFlags); - if(pCache != NULL) + pCache = CreateListFileCache(hListFile, NULL); + if(pCache == NULL) + nError = GetLastError(); + + // Load the node list. Add the node for every locale in the archive + if(nError == ERROR_SUCCESS) { - char * szFileName; - size_t nLength = 0; - - // Get the next line - while((szFileName = ReadListFileLine(pCache, &nLength)) != NULL) - { - // Add the line to the MPQ - if(nLength != 0) - SListFileCreateNodeForAllLocales(ha, szFileName); - } - - // Delete the cache - FreeListFileCache(pCache); + while((nLength = ReadListFileLine(pCache, szFileName, sizeof(szFileName))) > 0) + SListFileCreateNodeForAllLocales(ha, szFileName); + pCache->hFile = NULL; } - - return (pCache != NULL) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; + + // Delete the cache + if(pCache != NULL) + FreeListFileCache(pCache); + return nError; +} + +static int SFileAddExternalListFile( + TMPQArchive * ha, + HANDLE hMpq, + const char * szListFile) +{ + HANDLE hListFile; + int nError = ERROR_SUCCESS; + + // Open the external list file + if(SFileOpenFileEx(hMpq, szListFile, SFILE_OPEN_LOCAL_FILE, &hListFile)) + { + // Add the data from the listfile to MPQ + nError = SFileAddArbitraryListFile(ha, hListFile); + SFileCloseFile(hListFile); + } + return nError; } static int SFileAddInternalListFile( TMPQArchive * ha, HANDLE hMpq) { + TMPQArchive * haMpq = (TMPQArchive *)hMpq; TMPQHash * pFirstHash; TMPQHash * pHash; + HANDLE hListFile; LCID lcSaveLocale = lcFileLocale; - DWORD dwMaxSize = MAX_LISTFILE_SIZE; int nError = ERROR_SUCCESS; // If there is hash table, we need to support multiple listfiles // with different locales (BrooDat.mpq) - if(ha->pHashTable != NULL) + if(haMpq->pHashTable != NULL) { - // If the archive is a malformed map, ignore too large listfiles - if(ha->dwFlags & MPQ_FLAG_MALFORMED) - dwMaxSize = 0x40000; - - pFirstHash = pHash = GetFirstHashEntry(ha, LISTFILE_NAME); + pFirstHash = pHash = GetFirstHashEntry(haMpq, LISTFILE_NAME); while(nError == ERROR_SUCCESS && pHash != NULL) - { + { // Set the prefered locale to that from list file SFileSetLocale(pHash->lcLocale); + if(SFileOpenFileEx(hMpq, LISTFILE_NAME, 0, &hListFile)) + { + // Add the data from the listfile to MPQ + nError = SFileAddArbitraryListFile(ha, hListFile); + SFileCloseFile(hListFile); + } - // Add that listfile - nError = SFileAddArbitraryListFile(ha, hMpq, NULL, dwMaxSize); + // Restore the original locale + SFileSetLocale(lcSaveLocale); // Move to the next hash - pHash = GetNextHashEntry(ha, pFirstHash, pHash); + pHash = GetNextHashEntry(haMpq, pFirstHash, pHash); } - - // Restore the original locale - SFileSetLocale(lcSaveLocale); } else { - // Add the single listfile - nError = SFileAddArbitraryListFile(ha, hMpq, NULL, dwMaxSize); + // Open the external list file + if(SFileOpenFileEx(hMpq, LISTFILE_NAME, 0, &hListFile)) + { + // Add the data from the listfile to MPQ + // The function also closes the listfile handle + nError = SFileAddArbitraryListFile(ha, hListFile); + SFileCloseFile(hListFile); + } } // Return the result of the operation return nError; } -static bool DoListFileSearch(TListFileCache * pCache, SFILE_FIND_DATA * lpFindFileData) -{ - // Check for the valid search handle - if(pCache != NULL) - { - char * szFileName; - size_t nLength = 0; - - // Get the next line - while((szFileName = ReadListFileLine(pCache, &nLength)) != NULL) - { - // Check search mask - if(nLength != 0 && CheckWildCard(szFileName, pCache->szWildCard)) - { - if(nLength >= sizeof(lpFindFileData->cFileName)) - nLength = sizeof(lpFindFileData->cFileName) - 1; - - memcpy(lpFindFileData->cFileName, szFileName, nLength); - lpFindFileData->cFileName[nLength] = 0; - return true; - } - } - } - - // No more files - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - SetLastError(ERROR_NO_MORE_FILES); - return false; -} - //----------------------------------------------------------------------------- // File functions // Adds a listfile into the MPQ archive. -int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile) +int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile) { TMPQArchive * ha = (TMPQArchive *)hMpq; int nError = ERROR_SUCCESS; @@ -610,9 +517,9 @@ int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile) while(ha != NULL) { if(szListFile != NULL) - nError = SFileAddArbitraryListFile(ha, NULL, szListFile, MAX_LISTFILE_SIZE); + SFileAddExternalListFile(ha, hMpq, szListFile); else - nError = SFileAddInternalListFile(ha, hMpq); + SFileAddInternalListFile(ha, hMpq); // Also, add three special files to the listfile: // (listfile) itself, (attributes) and (signature) @@ -630,39 +537,101 @@ int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile) //----------------------------------------------------------------------------- // Enumerating files in listfile -HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const TCHAR * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData) +HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData) { TListFileCache * pCache = NULL; + HANDLE hListFile; + size_t nLength = 0; + DWORD dwSearchScope = SFILE_OPEN_LOCAL_FILE; + int nError = ERROR_SUCCESS; // Initialize the structure with zeros memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - // Open the local/internal listfile - pCache = CreateListFileCache(hMpq, szListFile, szMask, 0, 0); - if(pCache != NULL) + // If the szListFile is NULL, it means we have to open internal listfile + if(szListFile == NULL) { - if(!DoListFileSearch(pCache, lpFindFileData)) + // Use SFILE_OPEN_ANY_LOCALE for listfile. This will allow us to load + // the listfile even if there is only non-neutral version of the listfile in the MPQ + dwSearchScope = SFILE_OPEN_ANY_LOCALE; + szListFile = LISTFILE_NAME; + } + + // Open the local/internal listfile + if(!SFileOpenFileEx(hMpq, szListFile, dwSearchScope, &hListFile)) + nError = GetLastError(); + + // Load the listfile to cache + if(nError == ERROR_SUCCESS) + { + pCache = CreateListFileCache(hListFile, szMask); + if(pCache == NULL) + nError = GetLastError(); + } + + // Perform file search + if(nError == ERROR_SUCCESS) + { + for(;;) { - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - SetLastError(ERROR_NO_MORE_FILES); - FreeListFileCache(pCache); - pCache = NULL; + // Read the (next) line + nLength = ReadListFileLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); + if(nLength == 0) + { + nError = ERROR_NO_MORE_FILES; + break; + } + + // If some mask entered, check it + if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) + break; } } - // Return the listfile cache as handle + // Cleanup & exit + if(nError != ERROR_SUCCESS) + { + memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); + FreeListFileCache(pCache); + + SetLastError(nError); + pCache = NULL; + } return (HANDLE)pCache; } bool WINAPI SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) { - return DoListFileSearch((TListFileCache *)hFind, lpFindFileData); + TListFileCache * pCache = (TListFileCache *)hFind; + size_t nLength; + bool bResult = false; + int nError = ERROR_SUCCESS; + + for(;;) + { + // Read the (next) line + nLength = ReadListFileLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); + if(nLength == 0) + { + nError = ERROR_NO_MORE_FILES; + break; + } + + // If some mask entered, check it + if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) + { + bResult = true; + break; + } + } + + if(nError != ERROR_SUCCESS) + SetLastError(nError); + return bResult; } bool WINAPI SListFileFindClose(HANDLE hFind) { - TListFileCache * pCache = (TListFileCache *)hFind; - - return FreeListFileCache(pCache); + return FreeListFileCache((TListFileCache *)hFind); } diff --git a/dep/StormLib/src/SFileOpenArchive.cpp b/dep/StormLib/src/SFileOpenArchive.cpp index bba0aad95..b44c9909c 100644 --- a/dep/StormLib/src/SFileOpenArchive.cpp +++ b/dep/StormLib/src/SFileOpenArchive.cpp @@ -17,55 +17,47 @@ #include "StormLib.h" #include "StormCommon.h" -#define HEADER_SEARCH_BUFFER_SIZE 0x1000 - /*****************************************************************************/ /* Local functions */ /*****************************************************************************/ -static bool IsAviFile(DWORD * HeaderData) +static bool IsAviFile(void * pvFileBegin) { - DWORD DwordValue0 = BSWAP_INT32_UNSIGNED(HeaderData[0]); - DWORD DwordValue2 = BSWAP_INT32_UNSIGNED(HeaderData[2]); - DWORD DwordValue3 = BSWAP_INT32_UNSIGNED(HeaderData[3]); + LPDWORD AviHeader = (DWORD *)pvFileBegin; + DWORD DwordValue0 = BSWAP_INT32_UNSIGNED(AviHeader[0]); + DWORD DwordValue2 = BSWAP_INT32_UNSIGNED(AviHeader[2]); + DWORD DwordValue3 = BSWAP_INT32_UNSIGNED(AviHeader[3]); // Test for 'RIFF', 'AVI ' or 'LIST' return (DwordValue0 == 0x46464952 && DwordValue2 == 0x20495641 && DwordValue3 == 0x5453494C); } -static bool IsWarcraft3Map(DWORD * HeaderData) +static TFileBitmap * CreateFileBitmap(TMPQArchive * ha, TMPQBitmap * pMpqBitmap, bool bFileIsComplete) { - DWORD DwordValue0 = BSWAP_INT32_UNSIGNED(HeaderData[0]); - DWORD DwordValue1 = BSWAP_INT32_UNSIGNED(HeaderData[1]); + TFileBitmap * pBitmap; + size_t nLength; - return (DwordValue0 == 0x57334D48 && DwordValue1 == 0x00000000); -} + // Calculate the length of the bitmap in blocks and in bytes + nLength = (size_t)(((ha->pHeader->ArchiveSize64 - 1) / pMpqBitmap->dwBlockSize) + 1); + nLength = (size_t)(((nLength - 1) / 8) + 1); -static TMPQUserData * IsValidMpqUserData(ULONGLONG ByteOffset, ULONGLONG FileSize, void * pvUserData) -{ - TMPQUserData * pUserData; - - // BSWAP the source data and copy them to our buffer - BSWAP_ARRAY32_UNSIGNED(&pvUserData, sizeof(TMPQUserData)); - pUserData = (TMPQUserData *)pvUserData; - - // Check the sizes - if(pUserData->cbUserDataHeader <= pUserData->cbUserDataSize && pUserData->cbUserDataSize <= pUserData->dwHeaderOffs) + // Allocate the file bitmap + pBitmap = (TFileBitmap *)STORM_ALLOC(BYTE, sizeof(TFileBitmap) + nLength); + if(pBitmap != NULL) { - // Move to the position given by the userdata - ByteOffset += pUserData->dwHeaderOffs; + // Fill the structure + pBitmap->StartOffset = ha->MpqPos; + pBitmap->EndOffset = ha->MpqPos + ha->pHeader->ArchiveSize64; + pBitmap->IsComplete = bFileIsComplete ? 1 : 0; + pBitmap->BitmapSize = (DWORD)nLength; + pBitmap->BlockSize = pMpqBitmap->dwBlockSize; + pBitmap->Reserved = 0; - // The MPQ header should be within range of the file size - if((ByteOffset + MPQ_HEADER_SIZE_V1) < FileSize) - { - // Note: We should verify if there is the MPQ header. - // However, the header could be at any position below that - // that is multiplier of 0x200 - return (TMPQUserData *)pvUserData; - } + // Copy the file bitmap + memcpy((pBitmap + 1), (pMpqBitmap + 1), nLength); } - return NULL; + return pBitmap; } // This function gets the right positions of the hash table and the block table. @@ -93,7 +85,7 @@ static int VerifyMpqTablePositions(TMPQArchive * ha, ULONGLONG FileSize) // Check the begin of hash table if(pHeader->wHashTablePosHi || pHeader->dwHashTablePos) { - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos)); + ByteOffset = ha->MpqPos + MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos); if(ByteOffset > FileSize) return ERROR_BAD_FORMAT; } @@ -101,7 +93,7 @@ static int VerifyMpqTablePositions(TMPQArchive * ha, ULONGLONG FileSize) // Check the begin of block table if(pHeader->wBlockTablePosHi || pHeader->dwBlockTablePos) { - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos)); + ByteOffset = ha->MpqPos + MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); if(ByteOffset > FileSize) return ERROR_BAD_FORMAT; } @@ -118,6 +110,7 @@ static int VerifyMpqTablePositions(TMPQArchive * ha, ULONGLONG FileSize) return ERROR_SUCCESS; } + /*****************************************************************************/ /* Public functions */ /*****************************************************************************/ @@ -146,213 +139,137 @@ LCID WINAPI SFileSetLocale(LCID lcNewLocale) // phMpq - Pointer to store open archive handle bool WINAPI SFileOpenArchive( - const TCHAR * szMpqName, - DWORD dwPriority, - DWORD dwFlags, - HANDLE * phMpq) + const TCHAR * szMpqName, + DWORD dwPriority, + DWORD dwFlags, + HANDLE * phMpq) { - TMPQUserData * pUserData; TFileStream * pStream = NULL; // Open file stream TMPQArchive * ha = NULL; // Archive handle TFileEntry * pFileEntry; ULONGLONG FileSize = 0; // Size of the file - LPBYTE pbHeaderBuffer = NULL; // Buffer for searching MPQ header - DWORD dwStreamFlags = (dwFlags & STREAM_FLAGS_MASK); - bool bIsWarcraft3Map = false; - int nError = ERROR_SUCCESS; + int nError = ERROR_SUCCESS; // Verify the parameters if(szMpqName == NULL || *szMpqName == 0 || phMpq == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } + nError = ERROR_INVALID_PARAMETER; // One time initialization of MPQ cryptography InitializeMpqCryptography(); - - // If not forcing MPQ v 1.0, also use file bitmap - dwStreamFlags |= (dwFlags & MPQ_OPEN_FORCE_MPQ_V1) ? 0 : STREAM_FLAG_USE_BITMAP; + dwPriority = dwPriority; // Open the MPQ archive file - pStream = FileStream_OpenFile(szMpqName, dwStreamFlags); - if(pStream == NULL) - return false; - - // Check the file size. There must be at least 0x20 bytes if(nError == ERROR_SUCCESS) { - FileStream_GetSize(pStream, &FileSize); - if(FileSize < MPQ_HEADER_SIZE_V1) - nError = ERROR_BAD_FORMAT; + // Initialize the stream + pStream = FileStream_OpenFile(szMpqName, (dwFlags & STREAM_OPTIONS_MASK)); + if(pStream == NULL) + nError = GetLastError(); } // Allocate the MPQhandle if(nError == ERROR_SUCCESS) { + FileStream_GetSize(pStream, &FileSize); if((ha = STORM_ALLOC(TMPQArchive, 1)) == NULL) nError = ERROR_NOT_ENOUGH_MEMORY; } - // Allocate buffer for searching MPQ header + // Initialize handle structure and allocate structure for MPQ header if(nError == ERROR_SUCCESS) { - pbHeaderBuffer = STORM_ALLOC(BYTE, HEADER_SEARCH_BUFFER_SIZE); - if(pbHeaderBuffer == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Find the position of MPQ header - if(nError == ERROR_SUCCESS) - { - ULONGLONG SearchOffset = 0; - ULONGLONG EndOfSearch = FileSize; - DWORD dwStrmFlags = 0; - DWORD dwHeaderSize; - DWORD dwHeaderID; - bool bSearchComplete = false; - memset(ha, 0, sizeof(TMPQArchive)); - ha->pfnHashString = HashStringSlash; ha->pStream = pStream; pStream = NULL; - // Set the archive read only if the stream is read-only - FileStream_GetFlags(ha->pStream, &dwStrmFlags); - ha->dwFlags |= (dwStrmFlags & STREAM_FLAG_READ_ONLY) ? MPQ_FLAG_READ_ONLY : 0; + // Remember if the archive is open for write + if(FileStream_IsReadOnly(ha->pStream)) + ha->dwFlags |= MPQ_FLAG_READ_ONLY; // Also remember if we shall check sector CRCs when reading file - ha->dwFlags |= (dwFlags & MPQ_OPEN_CHECK_SECTOR_CRC) ? MPQ_FLAG_CHECK_SECTOR_CRC : 0; + if(dwFlags & MPQ_OPEN_CHECK_SECTOR_CRC) + ha->dwFlags |= MPQ_FLAG_CHECK_SECTOR_CRC; + } - // Also remember if this MPQ is a patch - ha->dwFlags |= (dwFlags & MPQ_OPEN_PATCH) ? MPQ_FLAG_PATCH : 0; - - // Limit the header searching to about 130 MB of data - if(EndOfSearch > 0x08000000) - EndOfSearch = 0x08000000; + // Find the offset of MPQ header within the file + if(nError == ERROR_SUCCESS) + { + ULONGLONG SearchPos = 0; + DWORD dwHeaderID; - // Find the offset of MPQ header within the file - while(bSearchComplete == false && SearchOffset < EndOfSearch) + while(SearchPos < FileSize) { - // Always read at least 0x1000 bytes for performance. - // This is what Storm.dll (2002) does. - DWORD dwBytesAvailable = HEADER_SEARCH_BUFFER_SIZE; - DWORD dwInBufferOffset = 0; + DWORD dwBytesAvailable = MPQ_HEADER_SIZE_V4; // Cut the bytes available, if needed - if((FileSize - SearchOffset) < HEADER_SEARCH_BUFFER_SIZE) - dwBytesAvailable = (DWORD)(FileSize - SearchOffset); + if((FileSize - SearchPos) < MPQ_HEADER_SIZE_V4) + dwBytesAvailable = (DWORD)(FileSize - SearchPos); // Read the eventual MPQ header - if(!FileStream_Read(ha->pStream, &SearchOffset, pbHeaderBuffer, dwBytesAvailable)) + if(!FileStream_Read(ha->pStream, &SearchPos, ha->HeaderData, dwBytesAvailable)) { nError = GetLastError(); break; } // There are AVI files from Warcraft III with 'MPQ' extension. - if(SearchOffset == 0) + if(SearchPos == 0 && IsAviFile(ha->HeaderData)) { - if(IsAviFile((DWORD *)pbHeaderBuffer)) - { - nError = ERROR_AVI_FILE; - break; - } - - bIsWarcraft3Map = IsWarcraft3Map((DWORD *)pbHeaderBuffer); + nError = ERROR_AVI_FILE; + break; } - // Search the header buffer - while(dwInBufferOffset < dwBytesAvailable) + // If there is the MPQ user data signature, process it + dwHeaderID = BSWAP_INT32_UNSIGNED(*(LPDWORD)ha->HeaderData); + if(dwHeaderID == ID_MPQ_USERDATA && ha->pUserData == NULL) { - // Copy the data from the potential header buffer to the MPQ header - memcpy(ha->HeaderData, pbHeaderBuffer + dwInBufferOffset, sizeof(ha->HeaderData)); - - // If there is the MPQ user data, process it - // Note that Warcraft III does not check for user data, which is abused by many map protectors - dwHeaderID = BSWAP_INT32_UNSIGNED(ha->HeaderData[0]); - if(bIsWarcraft3Map == false && (dwFlags & MPQ_OPEN_FORCE_MPQ_V1) == 0) + // Ignore the MPQ user data completely if the caller wants to open the MPQ as V1.0 + if((dwFlags & MPQ_OPEN_FORCE_MPQ_V1) == 0) { - if(ha->pUserData == NULL && dwHeaderID == ID_MPQ_USERDATA) - { - // Verify if this looks like a valid user data - pUserData = IsValidMpqUserData(SearchOffset, FileSize, ha->HeaderData); - if(pUserData != NULL) - { - // Fill the user data header - ha->UserDataPos = SearchOffset; - ha->pUserData = &ha->UserData; - memcpy(ha->pUserData, pUserData, sizeof(TMPQUserData)); + // Fill the user data header + ha->pUserData = &ha->UserData; + memcpy(ha->pUserData, ha->HeaderData, sizeof(TMPQUserData)); + BSWAP_TMPQUSERDATA(ha->pUserData); - // Continue searching from that position - SearchOffset += ha->pUserData->dwHeaderOffs; - break; - } - } + // Remember the position of the user data and continue search + ha->UserDataPos = SearchPos; + SearchPos += ha->pUserData->dwHeaderOffs; + continue; } - - // There must be MPQ header signature. Note that STORM.dll from Warcraft III actually - // tests the MPQ header size. It must be at least 0x20 bytes in order to load it - // Abused by Spazzler Map protector. Note that the size check is not present - // in Storm.dll v 1.00, so Diablo I code would load the MPQ anyway. - dwHeaderSize = BSWAP_INT32_UNSIGNED(ha->HeaderData[1]); - if(dwHeaderID == ID_MPQ && dwHeaderSize >= MPQ_HEADER_SIZE_V1) - { - // Now convert the header to version 4 - nError = ConvertMpqHeaderToFormat4(ha, SearchOffset, FileSize, dwFlags, bIsWarcraft3Map); - bSearchComplete = true; - break; - } - - // Check for MPK archives (Longwu Online - MPQ fork) - if(bIsWarcraft3Map == false && dwHeaderID == ID_MPK) - { - // Now convert the MPK header to MPQ Header version 4 - nError = ConvertMpkHeaderToFormat4(ha, FileSize, dwFlags); - bSearchComplete = true; - break; - } - - // If searching for the MPQ header is disabled, return an error - if(dwFlags & MPQ_OPEN_NO_HEADER_SEARCH) - { - nError = ERROR_NOT_SUPPORTED; - bSearchComplete = true; - break; - } - - // Move the pointers - SearchOffset += 0x200; - dwInBufferOffset += 0x200; } + + // There must be MPQ header signature + if(dwHeaderID == ID_MPQ) + { + // Save the position where the MPQ header has been found + if(ha->pUserData == NULL) + ha->UserDataPos = SearchPos; + ha->pHeader = (TMPQHeader *)ha->HeaderData; + ha->MpqPos = SearchPos; + + // Now convert the header to version 4 + BSWAP_TMPQHEADER(ha->pHeader); + nError = ConvertMpqHeaderToFormat4(ha, FileSize, dwFlags); + break; + } + + // Move to the next possible offset + SearchPos += 0x200; } - // Did we identify one of the supported headers? - if(nError == ERROR_SUCCESS) - { - // Set the user data position to the MPQ header, if none - if(ha->pUserData == NULL) - ha->UserDataPos = SearchOffset; - - // Set the position of the MPQ header - ha->pHeader = (TMPQHeader *)ha->HeaderData; - ha->MpqPos = SearchOffset; - ha->FileSize = FileSize; - - // Sector size must be nonzero. - if(SearchOffset >= FileSize || ha->pHeader->wSectorSize == 0) - nError = ERROR_BAD_FORMAT; - } + // If we haven't found MPQ header in the file, it's an error + if(ha->pHeader == NULL) + nError = ERROR_BAD_FORMAT; } // Fix table positions according to format if(nError == ERROR_SUCCESS) { // Dump the header -// DumpMpqHeader(ha->pHeader); + // DumpMpqHeader(ha->pHeader); // W3x Map Protectors use the fact that War3's Storm.dll ignores the MPQ user data, - // and ignores the MPQ format version as well. The trick is to + // and probably ignores the MPQ format version as well. The trick is to // fake MPQ format 2, with an improper hi-word position of hash table and block table // We can overcome such protectors by forcing opening the archive as MPQ v 1.0 if(dwFlags & MPQ_OPEN_FORCE_MPQ_V1) @@ -363,25 +280,10 @@ bool WINAPI SFileOpenArchive( ha->pUserData = NULL; } - // Anti-overflow. If the hash table size in the header is - // higher than 0x10000000, it would overflow in 32-bit version - // Observed in the malformed Warcraft III maps - // Example map: MPQ_2016_v1_ProtectedMap_TableSizeOverflow.w3x - ha->pHeader->dwBlockTableSize = (ha->pHeader->dwBlockTableSize & BLOCK_INDEX_MASK); - ha->pHeader->dwHashTableSize = (ha->pHeader->dwHashTableSize & BLOCK_INDEX_MASK); - // Both MPQ_OPEN_NO_LISTFILE or MPQ_OPEN_NO_ATTRIBUTES trigger read only mode if(dwFlags & (MPQ_OPEN_NO_LISTFILE | MPQ_OPEN_NO_ATTRIBUTES)) ha->dwFlags |= MPQ_FLAG_READ_ONLY; - // Check if the caller wants to force adding listfile - if(dwFlags & MPQ_OPEN_FORCE_LISTFILE) - ha->dwFlags |= MPQ_FLAG_LISTFILE_FORCE; - - // Remember whether whis is a map for Warcraft III - if(bIsWarcraft3Map) - ha->dwFlags |= MPQ_FLAG_WAR3_MAP; - // Set the size of file sector ha->dwSectorSize = (0x200 << ha->pHeader->wSectorSize); @@ -389,6 +291,24 @@ bool WINAPI SFileOpenArchive( nError = VerifyMpqTablePositions(ha, FileSize); } + // Check if the MPQ has data bitmap. If yes, we can verify if the MPQ is complete + if(nError == ERROR_SUCCESS && ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_4) + { + TFileBitmap * pBitmap; + bool bFileIsComplete = true; + + LoadMpqDataBitmap(ha, FileSize, &bFileIsComplete); + if(ha->pBitmap != NULL && bFileIsComplete == false) + { + // Convert the MPQ bitmap to the file bitmap + pBitmap = CreateFileBitmap(ha, ha->pBitmap, bFileIsComplete); + + // Set the data bitmap into the file stream for additional checks + FileStream_SetBitmap(ha->pStream, pBitmap); + ha->dwFlags |= MPQ_FLAG_READ_ONLY; + } + } + // Read the hash table. Ignore the result, as hash table is no longer required // Read HET table. Ignore the result, as HET table is no longer required if(nError == ERROR_SUCCESS) @@ -400,86 +320,93 @@ bool WINAPI SFileOpenArchive( // the block table, BET table, hi-block table, (attributes) and (listfile). if(nError == ERROR_SUCCESS) { - nError = BuildFileTable(ha); + nError = BuildFileTable(ha, FileSize); + } + + // Verify the file table, if no kind of protection was detected + if(nError == ERROR_SUCCESS && (ha->dwFlags & MPQ_FLAG_PROTECTED) == 0) + { + TFileEntry * pFileTableEnd = ha->pFileTable + ha->pHeader->dwBlockTableSize; +// ULONGLONG ArchiveSize = 0; + ULONGLONG RawFilePos; + + // Parse all file entries + for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) + { + // If that file entry is valid, check the file position + if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) + { + // Get the 64-bit file position, + // relative to the begin of the file + RawFilePos = ha->MpqPos + pFileEntry->ByteOffset; + + // Begin of the file must be within range + if(RawFilePos > FileSize) + { + nError = ERROR_FILE_CORRUPT; + break; + } + + // End of the file must be within range + RawFilePos += pFileEntry->dwCmpSize; + if(RawFilePos > FileSize) + { + nError = ERROR_FILE_CORRUPT; + break; + } + + // Also, we remember end of the file + // if(RawFilePos > ArchiveSize) + // ArchiveSize = RawFilePos; + } + } } // Load the internal listfile and include it to the file table if(nError == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_LISTFILE) == 0) { - // Quick check for (listfile) + // Save the flags for (listfile) pFileEntry = GetFileEntryLocale(ha, LISTFILE_NAME, LANG_NEUTRAL); if(pFileEntry != NULL) - { - // Ignore result of the operation. (listfile) is optional. - SFileAddListFile((HANDLE)ha, NULL); ha->dwFileFlags1 = pFileEntry->dwFlags; - } + + // Ignore result of the operation. (listfile) is optional. + SFileAddListFile((HANDLE)ha, NULL); } // Load the "(attributes)" file and merge it to the file table - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_ATTRIBUTES) == 0 && (ha->dwFlags & MPQ_FLAG_BLOCK_TABLE_CUT) == 0) + if(nError == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_ATTRIBUTES) == 0) { - // Quick check for (attributes) + // Save the flags for (attributes) pFileEntry = GetFileEntryLocale(ha, ATTRIBUTES_NAME, LANG_NEUTRAL); if(pFileEntry != NULL) - { - // Ignore result of the operation. (attributes) is optional. - SAttrLoadAttributes(ha); ha->dwFileFlags2 = pFileEntry->dwFlags; - } - } - // Remember whether the archive has weak signature. Only for MPQs format 1.0. - if(nError == ERROR_SUCCESS) - { - // Quick check for (signature) - pFileEntry = GetFileEntryLocale(ha, SIGNATURE_NAME, LANG_NEUTRAL); - if(pFileEntry != NULL) - { - // Just remember that the archive is weak-signed - assert((pFileEntry->dwFlags & MPQ_FILE_EXISTS) != 0); - ha->dwFileFlags3 = pFileEntry->dwFlags; - } - - // Finally, set the MPQ_FLAG_READ_ONLY if the MPQ was found malformed - ha->dwFlags |= (ha->dwFlags & MPQ_FLAG_MALFORMED) ? MPQ_FLAG_READ_ONLY : 0; + // Ignore result of the operation. (attributes) is optional. + SAttrLoadAttributes(ha); } // Cleanup and exit if(nError != ERROR_SUCCESS) { FileStream_Close(pStream); - FreeArchiveHandle(ha); + FreeMPQArchive(ha); SetLastError(nError); ha = NULL; } - // Free the header buffer - if(pbHeaderBuffer != NULL) - STORM_FREE(pbHeaderBuffer); - if(phMpq != NULL) - *phMpq = ha; + *phMpq = ha; return (nError == ERROR_SUCCESS); } //----------------------------------------------------------------------------- -// bool WINAPI SFileSetDownloadCallback(HANDLE, SFILE_DOWNLOAD_CALLBACK, void *); -// -// Sets a callback that is called when content is downloaded from the master MPQ -// +// SFileGetArchiveBitmap -bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData) +bool WINAPI SFileGetArchiveBitmap(HANDLE hMpq, TFileBitmap * pBitmap, DWORD Length, LPDWORD LengthNeeded) { TMPQArchive * ha = (TMPQArchive *)hMpq; - // Do nothing if 'hMpq' is bad parameter - if(!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - return FileStream_SetCallback(ha->pStream, DownloadCB, pvUserData); + return FileStream_GetBitmap(ha->pStream, pBitmap, Length, LengthNeeded); } //----------------------------------------------------------------------------- @@ -493,75 +420,39 @@ bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK Downlo bool WINAPI SFileFlushArchive(HANDLE hMpq) { - TMPQArchive * ha; + TMPQArchive * ha = (TMPQArchive *)hMpq; int nResultError = ERROR_SUCCESS; int nError; // Do nothing if 'hMpq' is bad parameter - if((ha = IsValidMpqHandle(hMpq)) == NULL) + if(!IsValidMpqHandle(ha)) { SetLastError(ERROR_INVALID_HANDLE); return false; } - // Only if the MPQ was changed + // If the (listfile) has been invalidated, save it + if(ha->dwFlags & MPQ_FLAG_INV_LISTFILE) + { + nError = SListFileSaveToMpq(ha); + if(nError != ERROR_SUCCESS) + nResultError = nError; + } + + // If the (attributes) has been invalidated, save it + if(ha->dwFlags & MPQ_FLAG_INV_ATTRIBUTES) + { + nError = SAttrFileSaveToMpq(ha); + if(nError != ERROR_SUCCESS) + nResultError = nError; + } + + // Save HET table, BET table, hash table, block table, hi-block table if(ha->dwFlags & MPQ_FLAG_CHANGED) { - // Indicate that we are saving MPQ internal structures - ha->dwFlags |= MPQ_FLAG_SAVING_TABLES; - - // Defragment the file table. This will allow us to put the internal files to the end - DefragmentFileTable(ha); - - // - // Create each internal file - // Note that the (signature) file is usually before (listfile) in the file table - // - - if(ha->dwFlags & MPQ_FLAG_SIGNATURE_NEW) - { - nError = SSignFileCreate(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - - if(ha->dwFlags & (MPQ_FLAG_LISTFILE_NEW | MPQ_FLAG_LISTFILE_FORCE)) - { - nError = SListFileSaveToMpq(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - - if(ha->dwFlags & MPQ_FLAG_ATTRIBUTES_NEW) - { - nError = SAttrFileSaveToMpq(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - - // Save HET table, BET table, hash table, block table, hi-block table - if(ha->dwFlags & MPQ_FLAG_CHANGED) - { - // Rebuild the HET table - if(ha->pHetTable != NULL) - RebuildHetTable(ha); - - // Save all MPQ tables first - nError = SaveMPQTables(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - - // If the archive has weak signature, we need to finish it - if(ha->dwFileFlags3 != 0) - { - nError = SSignFileFinish(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - } - - // We are no longer saving internal MPQ structures - ha->dwFlags &= ~MPQ_FLAG_SAVING_TABLES; + nError = SaveMPQTables(ha); + if(nError != ERROR_SUCCESS) + nResultError = nError; } // Return the error @@ -576,25 +467,14 @@ bool WINAPI SFileFlushArchive(HANDLE hMpq) bool WINAPI SFileCloseArchive(HANDLE hMpq) { - TMPQArchive * ha = IsValidMpqHandle(hMpq); - bool bResult = false; - - // Only if the handle is valid - if(ha == NULL) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - // Invalidate the add file callback so it won't be called - // when saving (listfile) and (attributes) - ha->pfnAddFileCB = NULL; - ha->pvAddFileUserData = NULL; + TMPQArchive * ha = (TMPQArchive *)hMpq; + bool bResult; // Flush all unsaved data to the storage bResult = SFileFlushArchive(hMpq); // Free all memory used by MPQ archive - FreeArchiveHandle(ha); + FreeMPQArchive(ha); return bResult; } + diff --git a/dep/StormLib/src/SFileOpenFileEx.cpp b/dep/StormLib/src/SFileOpenFileEx.cpp index 72eb15d9f..4d2516af4 100644 --- a/dep/StormLib/src/SFileOpenFileEx.cpp +++ b/dep/StormLib/src/SFileOpenFileEx.cpp @@ -16,77 +16,33 @@ /* Local functions */ /*****************************************************************************/ -static DWORD FindHashIndex(TMPQArchive * ha, DWORD dwFileIndex) -{ - TMPQHash * pHashTableEnd; - TMPQHash * pHash; - DWORD dwFirstIndex = HASH_ENTRY_FREE; - - // Should only be called if the archive has hash table - assert(ha->pHashTable != NULL); - - // Multiple hash table entries can point to the file table entry. - // We need to search all of them - pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++) - { - if(MPQ_BLOCK_INDEX(pHash) == dwFileIndex) - { - // Duplicate hash entry found - if(dwFirstIndex != HASH_ENTRY_FREE) - return HASH_ENTRY_FREE; - dwFirstIndex = (DWORD)(pHash - ha->pHashTable); - } - } - - // Return the hash table entry index - return dwFirstIndex; -} - -static const char * GetPatchFileName(TMPQArchive * ha, const char * szFileName, char * szBuffer) -{ - TMPQNamePrefix * pPrefix; - - // Are there patches in the current MPQ? - if(ha->dwFlags & MPQ_FLAG_PATCH) - { - // The patch prefix must be already known here - assert(ha->pPatchPrefix != NULL); - pPrefix = ha->pPatchPrefix; - - // The patch name for "OldWorld\\XXX\\YYY" is "Base\\XXX\YYY" - // We need to remove the "OldWorld\\" prefix - if(!_strnicmp(szFileName, "OldWorld\\", 9)) - szFileName += 9; - - // Create the file name from the known patch entry - memcpy(szBuffer, pPrefix->szPatchPrefix, pPrefix->nLength); - strcpy(szBuffer + pPrefix->nLength, szFileName); - szFileName = szBuffer; - } - - return szFileName; -} - -static bool OpenLocalFile(const char * szFileName, HANDLE * PtrFile) +static bool OpenLocalFile(const char * szFileName, HANDLE * phFile) { TFileStream * pStream; TMPQFile * hf = NULL; + + // We have to convert the local file name to UNICODE, if needed +#ifdef _UNICODE TCHAR szFileNameT[MAX_PATH]; + int i; - // Convert the file name to UNICODE (if needed) - StringCopy(szFileNameT, _countof(szFileNameT), szFileName); + for(i = 0; szFileName[i] != 0; i++) + szFileNameT[i] = szFileName[i]; + szFileNameT[i] = 0; + pStream = FileStream_OpenFile(szFileNameT, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + +#else + pStream = FileStream_OpenFile(szFileName, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); +#endif - // Open the file and create the TMPQFile structure - pStream = FileStream_OpenFile(szFileNameT, STREAM_FLAG_READ_ONLY); if(pStream != NULL) { // Allocate and initialize file handle - hf = CreateFileHandle(NULL, NULL); + hf = CreateMpqFile(NULL); if(hf != NULL) { hf->pStream = pStream; - *PtrFile = hf; + *phFile = hf; return true; } else @@ -95,71 +51,91 @@ static bool OpenLocalFile(const char * szFileName, HANDLE * PtrFile) SetLastError(ERROR_NOT_ENOUGH_MEMORY); } } - *PtrFile = NULL; + *phFile = NULL; return false; } -bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, HANDLE * PtrFile) +bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, DWORD dwReserved, HANDLE * phFile) { - TMPQArchive * haBase = NULL; TMPQArchive * ha = (TMPQArchive *)hMpq; - TFileEntry * pFileEntry; TMPQFile * hfPatch; // Pointer to patch file TMPQFile * hfBase = NULL; // Pointer to base open file + TMPQFile * hfLast = NULL; // The highest file in the chain that is not patch file TMPQFile * hf = NULL; HANDLE hPatchFile; - char szNameBuffer[MAX_PATH]; + char szPatchFileName[MAX_PATH]; - // First of all, find the latest archive where the file is in base version - // (i.e. where the original, unpatched version of the file exists) + // Keep this flag here for future updates + dwReserved = dwReserved; + + // First of all, try to open the original version of the file in any of the patch chain while(ha != NULL) { - // If the file is there, then we remember the archive - pFileEntry = GetFileEntryExact(ha, GetPatchFileName(ha, szFileName, szNameBuffer), 0, NULL); - if(pFileEntry != NULL && (pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) - haBase = ha; + // Construct the name of the patch file + strcpy(szPatchFileName, ha->szPatchPrefix); + strcpy(&szPatchFileName[ha->cchPatchPrefix], szFileName); + if(SFileOpenFileEx((HANDLE)ha, szPatchFileName, SFILE_OPEN_FROM_MPQ, (HANDLE *)&hfBase)) + { + // The file must be a base file, i.e. without MPQ_FILE_PATCH_FILE + if((hfBase->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) + { + hf = hfLast = hfBase; + break; + } - // Move to the patch archive + SFileCloseFile((HANDLE)hfBase); + } + + // Move to the next file in the patch chain ha = ha->haPatch; } - // If we couldn't find the base file in any of the patches, it doesn't exist - if((ha = haBase) == NULL) + // If we couldn't find the file in any of the patches, it doesn't exist + if(hf == NULL) { SetLastError(ERROR_FILE_NOT_FOUND); return false; } - // Now open the base file - if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, (HANDLE *)&hfBase)) + // Now keep going in the patch chain and open every patch file that is there + for(ha = ha->haPatch; ha != NULL; ha = ha->haPatch) { - // The file must be a base file, i.e. without MPQ_FILE_PATCH_FILE - assert((hfBase->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0); - hf = hfBase; - - // Now open all patches and attach them on top of the base file - for(ha = ha->haPatch; ha != NULL; ha = ha->haPatch) + // Construct patch file name + strcpy(szPatchFileName, ha->szPatchPrefix); + strcpy(&szPatchFileName[ha->cchPatchPrefix], szFileName); + if(SFileOpenFileEx((HANDLE)ha, szPatchFileName, SFILE_OPEN_FROM_MPQ, &hPatchFile)) { - // Prepare the file name with a correct prefix - if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, &hPatchFile)) - { - // Remember the new version - hfPatch = (TMPQFile *)hPatchFile; + // Remember the new version + hfPatch = (TMPQFile *)hPatchFile; - // We should not find patch file - assert((hfPatch->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) != 0); + // If we encountered a full replacement of the file, + // we have to remember the highest full file + if((hfPatch->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) + hfLast = hfPatch; - // Attach the patch to the base file - hf->hfPatch = hfPatch; - hf = hfPatch; - } + // Set current patch to base file and move on + hf->hfPatchFile = hfPatch; + hf = hfPatch; } } + // Now we need to free all files that are below the highest unpatched version + while(hfBase != hfLast) + { + TMPQFile * hfNext = hfBase->hfPatchFile; + + // Free the file below + hfBase->hfPatchFile = NULL; + FreeMPQFile(hfBase); + + // Move the base to the next file + hfBase = hfNext; + } + // Give the updated base MPQ - if(PtrFile != NULL) - *PtrFile = (HANDLE)hfBase; - return (hfBase != NULL); + if(phFile != NULL) + *phFile = (HANDLE)hfBase; + return true; } /*****************************************************************************/ @@ -167,205 +143,81 @@ bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, HANDLE * PtrFile) /*****************************************************************************/ //----------------------------------------------------------------------------- -// SFileEnumLocales enums all locale versions within MPQ. +// SFileEnumLocales enums all locale versions within MPQ. // Functions fills all available language identifiers on a file into the buffer // pointed by plcLocales. There must be enough entries to copy the localed, // otherwise the function returns ERROR_INSUFFICIENT_BUFFER. int WINAPI SFileEnumLocales( - HANDLE hMpq, - const char * szFileName, - LCID * PtrLocales, - LPDWORD PtrMaxLocales, - DWORD dwSearchScope) + HANDLE hMpq, + const char * szFileName, + LCID * plcLocales, + LPDWORD pdwMaxLocales, + DWORD dwSearchScope) { TMPQArchive * ha = (TMPQArchive *)hMpq; + TFileEntry * pFileEntry; TMPQHash * pFirstHash; TMPQHash * pHash; DWORD dwFileIndex = 0; - DWORD dwMaxLocales; DWORD dwLocales = 0; // Test the parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) return ERROR_INVALID_HANDLE; if(szFileName == NULL || *szFileName == 0) return ERROR_INVALID_PARAMETER; - if(ha->pHashTable == NULL) - return ERROR_NOT_SUPPORTED; - if(PtrMaxLocales == NULL) + if(pdwMaxLocales == NULL) return ERROR_INVALID_PARAMETER; - if(IsPseudoFileName(szFileName, &dwFileIndex)) - return ERROR_INVALID_PARAMETER; - + // Keep compiler happy - dwMaxLocales = PtrMaxLocales[0]; + dwSearchScope = dwSearchScope; - // Parse all files with that name - pFirstHash = pHash = GetFirstHashEntry(ha, szFileName); - while(pHash != NULL) + // Parse hash table entries for all locales + if(!IsPseudoFileName(szFileName, &dwFileIndex)) { - // Put the locales to the buffer - if(PtrLocales != NULL && dwLocales < dwMaxLocales) - *PtrLocales++ = pHash->lcLocale; - dwLocales++; - - // Get the next locale - pHash = GetNextHashEntry(ha, pFirstHash, pHash); - } - - // Give the caller the number of locales and return - PtrMaxLocales[0] = dwLocales; - return (dwLocales <= dwMaxLocales) ? ERROR_SUCCESS : ERROR_INSUFFICIENT_BUFFER; -} - -//----------------------------------------------------------------------------- -// SFileOpenFileEx -// -// hMpq - Handle of opened MPQ archive -// szFileName - Name of file to open -// dwSearchScope - Where to search -// PtrFile - Pointer to store opened file handle - -bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * PtrFile) -{ - TMPQArchive * ha = IsValidMpqHandle(hMpq); - TFileEntry * pFileEntry = NULL; - TMPQFile * hf = NULL; - DWORD dwHashIndex = HASH_ENTRY_FREE; - DWORD dwFileIndex = 0; - bool bOpenByIndex = false; - int nError = ERROR_SUCCESS; - - // Don't accept NULL pointer to file handle - if(szFileName == NULL || *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - - // When opening a file from MPQ, the handle must be valid - if(dwSearchScope != SFILE_OPEN_LOCAL_FILE && ha == NULL) - nError = ERROR_INVALID_HANDLE; - - // When not checking for existence, the pointer to file handle must be valid - if(dwSearchScope != SFILE_OPEN_CHECK_EXISTS && PtrFile == NULL) - nError = ERROR_INVALID_PARAMETER; - - // Prepare the file opening - if(nError == ERROR_SUCCESS) - { - switch(dwSearchScope) + // Calculate the number of locales + pFirstHash = pHash = GetFirstHashEntry(ha, szFileName); + while(pHash != NULL) { - case SFILE_OPEN_FROM_MPQ: - case SFILE_OPEN_BASE_FILE: - case SFILE_OPEN_CHECK_EXISTS: - - // If this MPQ has no patches, open the file from this MPQ directly - if(ha->haPatch == NULL || dwSearchScope == SFILE_OPEN_BASE_FILE) - { - pFileEntry = GetFileEntryLocale2(ha, szFileName, lcFileLocale, &dwHashIndex); - } - - // If this MPQ is a patched archive, open the file as patched - else - { - return OpenPatchedFile(hMpq, szFileName, PtrFile); - } - break; - - case SFILE_OPEN_ANY_LOCALE: - - // This open option is reserved for opening MPQ internal listfile. - // No argument validation. Tries to open file with neutral locale first, - // then any other available. - pFileEntry = GetFileEntryLocale2(ha, szFileName, 0, &dwHashIndex); - break; - - case SFILE_OPEN_LOCAL_FILE: - - // Open a local file - return OpenLocalFile(szFileName, PtrFile); - - default: - - // Don't accept any other value - nError = ERROR_INVALID_PARAMETER; - break; - } - } - - // Check whether the file really exists in the MPQ - if(nError == ERROR_SUCCESS) - { - if(pFileEntry == NULL || (pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0) - { - // Check the pseudo-file name - if((bOpenByIndex = IsPseudoFileName(szFileName, &dwFileIndex)) == true) - { - // Get the file entry for the file - if(dwFileIndex < ha->dwFileTableSize) - { - pFileEntry = ha->pFileTable + dwFileIndex; - } - } - - if(pFileEntry == NULL) - { - nError = ERROR_FILE_NOT_FOUND; - } + dwLocales++; + pHash = GetNextHashEntry(ha, pFirstHash, pHash); } - // Ignore unknown loading flags (example: MPQ_2016_v1_WME4_4.w3x) -// if(pFileEntry != NULL && pFileEntry->dwFlags & ~MPQ_FILE_VALID_FLAGS) -// nError = ERROR_NOT_SUPPORTED; - } + // Test if there is enough space to copy the locales + if(*pdwMaxLocales < dwLocales) + { + *pdwMaxLocales = dwLocales; + return ERROR_INSUFFICIENT_BUFFER; + } - // Did the caller just wanted to know if the file exists? - if(nError == ERROR_SUCCESS && dwSearchScope != SFILE_OPEN_CHECK_EXISTS) + // Enum the locales + pFirstHash = pHash = GetFirstHashEntry(ha, szFileName); + while(pHash != NULL) + { + *plcLocales++ = pHash->lcLocale; + pHash = GetNextHashEntry(ha, pFirstHash, pHash); + } + } + else { - // Allocate file handle - hf = CreateFileHandle(ha, pFileEntry); - if(hf != NULL) + // There must be space for 1 locale + if(*pdwMaxLocales < 1) { - // Get the hash index for the file - if(ha->pHashTable != NULL && dwHashIndex == HASH_ENTRY_FREE) - dwHashIndex = FindHashIndex(ha, dwFileIndex); - if(dwHashIndex != HASH_ENTRY_FREE) - hf->pHashEntry = ha->pHashTable + dwHashIndex; - hf->dwHashIndex = dwHashIndex; - - // If the MPQ has sector CRC enabled, enable if for the file - if(ha->dwFlags & MPQ_FLAG_CHECK_SECTOR_CRC) - hf->bCheckSectorCRCs = true; - - // If we know the real file name, copy it to the file entry - if(bOpenByIndex == false) - { - // If there is no file name yet, allocate it - AllocateFileName(ha, pFileEntry, szFileName); - - // If the file is encrypted, we should detect the file key - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - hf->dwFileKey = DecryptFileKey(szFileName, - pFileEntry->ByteOffset, - pFileEntry->dwFileSize, - pFileEntry->dwFlags); - } - } - } - else - { - nError = ERROR_NOT_ENOUGH_MEMORY; + *pdwMaxLocales = 1; + return ERROR_INSUFFICIENT_BUFFER; } + + // For nameless access, always return 1 locale + pFileEntry = GetFileEntryByIndex(ha, dwFileIndex); + pHash = ha->pHashTable + pFileEntry->dwHashIndex; + *plcLocales = pHash->lcLocale; + dwLocales = 1; } - // Give the file entry - if(PtrFile != NULL) - PtrFile[0] = hf; - - // Return error code - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); + // Give the caller the total number of found locales + *pdwMaxLocales = dwLocales; + return ERROR_SUCCESS; } //----------------------------------------------------------------------------- @@ -376,7 +228,226 @@ bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearch bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName) { - return SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_CHECK_EXISTS, NULL); + TMPQArchive * ha = (TMPQArchive *)hMpq; + TFileEntry * pFileEntry; + DWORD dwFlagsToCheck = MPQ_FILE_EXISTS; + DWORD dwFileIndex = 0; + char szPatchFileName[MAX_PATH]; + bool bIsPseudoName; + int nError = ERROR_SUCCESS; + + if(!IsValidMpqHandle(ha)) + nError = ERROR_INVALID_HANDLE; + if(szFileName == NULL || *szFileName == 0) + nError = ERROR_INVALID_PARAMETER; + + // Prepare the file opening + if(nError == ERROR_SUCCESS) + { + // Different processing for pseudo-names + bIsPseudoName = IsPseudoFileName(szFileName, &dwFileIndex); + + // Walk through the MPQ and all patches + while(ha != NULL) + { + // Verify presence of the file + pFileEntry = (bIsPseudoName == false) ? GetFileEntryLocale(ha, szFileName, lcFileLocale) + : GetFileEntryByIndex(ha, dwFileIndex); + // Verify the file flags + if(pFileEntry != NULL && (pFileEntry->dwFlags & dwFlagsToCheck) == MPQ_FILE_EXISTS) + return true; + + // If this is patched archive, go to the patch + dwFlagsToCheck = MPQ_FILE_EXISTS | MPQ_FILE_PATCH_FILE; + ha = ha->haPatch; + + // Prepare the patched file name + if(ha != NULL) + { + strcpy(szPatchFileName, ha->szPatchPrefix); + strcat(szPatchFileName, szFileName); + szFileName = szPatchFileName; + } + } + + // Not found, sorry + nError = ERROR_FILE_NOT_FOUND; + } + + // Cleanup + SetLastError(nError); + return false; +} + + +//----------------------------------------------------------------------------- +// SFileOpenFileEx +// +// hMpq - Handle of opened MPQ archive +// szFileName - Name of file to open +// dwSearchScope - Where to search +// phFile - Pointer to store opened file handle + +bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile) +{ + TMPQArchive * ha = (TMPQArchive *)hMpq; + TFileEntry * pFileEntry = NULL; + TMPQFile * hf = NULL; + DWORD dwFileIndex = 0; + bool bOpenByIndex = false; + int nError = ERROR_SUCCESS; + + // Don't accept NULL pointer to file handle + if(phFile == NULL) + nError = ERROR_INVALID_PARAMETER; + + // Prepare the file opening + if(nError == ERROR_SUCCESS) + { + switch(dwSearchScope) + { + case SFILE_OPEN_PATCHED_FILE: + + // We want to open the updated version of the file + return OpenPatchedFile(hMpq, szFileName, 0, phFile); + + case SFILE_OPEN_FROM_MPQ: + + if(!IsValidMpqHandle(ha)) + { + nError = ERROR_INVALID_HANDLE; + break; + } + + if(szFileName == NULL || *szFileName == 0) + { + nError = ERROR_INVALID_PARAMETER; + break; + } + + // First of all, check the name as-is + if(!IsPseudoFileName(szFileName, &dwFileIndex)) + { + pFileEntry = GetFileEntryLocale(ha, szFileName, lcFileLocale); + if(pFileEntry == NULL) + nError = ERROR_FILE_NOT_FOUND; + } + else + { + bOpenByIndex = true; + pFileEntry = GetFileEntryByIndex(ha, dwFileIndex); + if(pFileEntry == NULL) + nError = ERROR_FILE_NOT_FOUND; + } + break; + + case SFILE_OPEN_ANY_LOCALE: + + // This open option is reserved for opening MPQ internal listfile. + // No argument validation. Tries to open file with neutral locale first, + // then any other available. + dwSearchScope = SFILE_OPEN_FROM_MPQ; + pFileEntry = GetFileEntryAny(ha, szFileName); + if(pFileEntry == NULL) + nError = ERROR_FILE_NOT_FOUND; + break; + + case SFILE_OPEN_LOCAL_FILE: + + if(szFileName == NULL || *szFileName == 0) + { + nError = ERROR_INVALID_PARAMETER; + break; + } + + return OpenLocalFile(szFileName, phFile); + + default: + + // Don't accept any other value + nError = ERROR_INVALID_PARAMETER; + break; + } + + // Quick return if something failed + if(nError != ERROR_SUCCESS) + { + SetLastError(nError); + return false; + } + } + + // Test if the file was not already deleted. + if(nError == ERROR_SUCCESS) + { + if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0) + nError = ERROR_FILE_NOT_FOUND; + if(pFileEntry->dwFlags & ~MPQ_FILE_VALID_FLAGS) + nError = ERROR_NOT_SUPPORTED; + } + + // Allocate file handle + if(nError == ERROR_SUCCESS) + { + if((hf = STORM_ALLOC(TMPQFile, 1)) == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Initialize file handle + if(nError == ERROR_SUCCESS) + { + memset(hf, 0, sizeof(TMPQFile)); + hf->pFileEntry = pFileEntry; + hf->dwMagic = ID_MPQ_FILE; + hf->ha = ha; + + hf->MpqFilePos = pFileEntry->ByteOffset; + hf->RawFilePos = ha->MpqPos + hf->MpqFilePos; + hf->dwDataSize = pFileEntry->dwFileSize; + + // If the MPQ has sector CRC enabled, enable if for the file + if(ha->dwFlags & MPQ_FLAG_CHECK_SECTOR_CRC) + hf->bCheckSectorCRCs = true; + + // If we know the real file name, copy it to the file entry + if(bOpenByIndex == false) + { + // If there is no file name yet, allocate it + AllocateFileName(pFileEntry, szFileName); + + // If the file is encrypted, we should detect the file key + if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) + { + hf->dwFileKey = DecryptFileKey(szFileName, + pFileEntry->ByteOffset, + pFileEntry->dwFileSize, + pFileEntry->dwFlags); + } + } + else + { + // Try to auto-detect the file name + if(!SFileGetFileName(hf, NULL)) + nError = GetLastError(); + } + } + + // If the file is actually a patch file, we have to load the patch file header + if(nError == ERROR_SUCCESS && pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) + { + assert(hf->pPatchInfo == NULL); + nError = AllocatePatchInfo(hf, true); + } + + // Cleanup + if(nError != ERROR_SUCCESS) + { + SetLastError(nError); + FreeMPQFile(hf); + } + + *phFile = hf; + return (nError == ERROR_SUCCESS); } //----------------------------------------------------------------------------- @@ -385,14 +456,14 @@ bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName) bool WINAPI SFileCloseFile(HANDLE hFile) { TMPQFile * hf = (TMPQFile *)hFile; - - if(!IsValidFileHandle(hFile)) + + if(!IsValidFileHandle(hf)) { SetLastError(ERROR_INVALID_HANDLE); return false; } // Free the structure - FreeFileHandle(hf); + FreeMPQFile(hf); return true; } diff --git a/dep/StormLib/src/SFilePatchArchives.cpp b/dep/StormLib/src/SFilePatchArchives.cpp index dc16631bc..fe900486c 100644 --- a/dep/StormLib/src/SFilePatchArchives.cpp +++ b/dep/StormLib/src/SFilePatchArchives.cpp @@ -15,37 +15,6 @@ //----------------------------------------------------------------------------- // Local structures -#define MAX_SC2_PATCH_PREFIX 0x80 - -#define PATCH_SIGNATURE_HEADER 0x48435450 -#define PATCH_SIGNATURE_MD5 0x5f35444d -#define PATCH_SIGNATURE_XFRM 0x4d524658 - -#define SIZE_OF_XFRM_HEADER 0x0C - -// Header for incremental patch files -typedef struct _MPQ_PATCH_HEADER -{ - //-- PATCH header ----------------------------------- - DWORD dwSignature; // 'PTCH' - DWORD dwSizeOfPatchData; // Size of the entire patch (decompressed) - DWORD dwSizeBeforePatch; // Size of the file before patch - DWORD dwSizeAfterPatch; // Size of file after patch - - //-- MD5 block -------------------------------------- - DWORD dwMD5; // 'MD5_' - DWORD dwMd5BlockSize; // Size of the MD5 block, including the signature and size itself - BYTE md5_before_patch[0x10]; // MD5 of the original (unpached) file - BYTE md5_after_patch[0x10]; // MD5 of the patched file - - //-- XFRM block ------------------------------------- - DWORD dwXFRM; // 'XFRM' - DWORD dwXfrmBlockSize; // Size of the XFRM block, includes XFRM header and patch data - DWORD dwPatchType; // Type of patch ('BSD0' or 'COPY') - - // Followed by the patch data -} MPQ_PATCH_HEADER, *PMPQ_PATCH_HEADER; - typedef struct _BLIZZARD_BSDIFF40_FILE { ULONGLONG Signature; @@ -54,70 +23,49 @@ typedef struct _BLIZZARD_BSDIFF40_FILE ULONGLONG NewFileSize; } BLIZZARD_BSDIFF40_FILE, *PBLIZZARD_BSDIFF40_FILE; -typedef struct _BSDIFF_CTRL_BLOCK -{ - DWORD dwAddDataLength; - DWORD dwMovDataLength; - DWORD dwOldMoveLength; - -} BSDIFF_CTRL_BLOCK, *PBSDIFF_CTRL_BLOCK; - -typedef struct _LOCALIZED_MPQ_INFO -{ - const char * szNameTemplate; // Name template - size_t nLangOffset; // Offset of the language - size_t nLength; // Length of the name template -} LOCALIZED_MPQ_INFO, *PLOCALIZED_MPQ_INFO; - -//----------------------------------------------------------------------------- -// Local variables - -// 4-byte groups for all languages -static const char * LanguageList = "baseteenenUSenGBenCNenTWdeDEesESesMXfrFRitITkoKRptBRptPTruRUzhCNzhTW"; - -// List of localized MPQs for World of Warcraft -static LOCALIZED_MPQ_INFO LocaleMpqs_WoW[] = -{ - {"expansion1-locale-####", 18, 22}, - {"expansion1-speech-####", 18, 22}, - {"expansion2-locale-####", 18, 22}, - {"expansion2-speech-####", 18, 22}, - {"expansion3-locale-####", 18, 22}, - {"expansion3-speech-####", 18, 22}, - {"locale-####", 7, 11}, - {"speech-####", 7, 11}, - {NULL, 0, 0} -}; - //----------------------------------------------------------------------------- // Local functions -static inline bool IsPatchMetadataFile(TFileEntry * pFileEntry) +static bool GetDefaultPatchPrefix( + const TCHAR * szBaseMpqName, + char * szBuffer) { - // The file must ave a name - if(pFileEntry->szFileName != NULL && (pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) + const TCHAR * szExtension; + const TCHAR * szDash; + + // Ensure that both names are plain names + szBaseMpqName = GetPlainFileNameT(szBaseMpqName); + + // Patch prefix is for the Cataclysm MPQs, whose names + // are like "locale-enGB.MPQ" or "speech-enGB.MPQ" + szExtension = _tcsrchr(szBaseMpqName, _T('.')); + szDash = _tcsrchr(szBaseMpqName, _T('-')); + strcpy(szBuffer, "Base"); + + // If the length of the prefix doesn't match, use default one + if(szExtension != NULL && szDash != NULL && (szExtension - szDash) == 5) { - // The file must be small - if(0 < pFileEntry->dwFileSize && pFileEntry->dwFileSize < 0x40) - { - // Compare the plain name - return (_stricmp(GetPlainFileName(pFileEntry->szFileName), PATCH_METADATA_NAME) == 0); - } + // Copy the prefix + szBuffer[0] = (char)szDash[1]; + szBuffer[1] = (char)szDash[2]; + szBuffer[2] = (char)szDash[3]; + szBuffer[3] = (char)szDash[4]; + szBuffer[4] = 0; } - // Not a patch_metadata - return false; + return true; } static void Decompress_RLE(LPBYTE pbDecompressed, DWORD cbDecompressed, LPBYTE pbCompressed, DWORD cbCompressed) { LPBYTE pbDecompressedEnd = pbDecompressed + cbDecompressed; LPBYTE pbCompressedEnd = pbCompressed + cbCompressed; - BYTE RepeatCount; + BYTE RepeatCount; BYTE OneByte; // Cut the initial DWORD from the compressed chunk pbCompressed += sizeof(DWORD); + cbCompressed -= sizeof(DWORD); // Pre-fill decompressed buffer with zeros memset(pbDecompressed, 0, cbDecompressed); @@ -126,7 +74,7 @@ static void Decompress_RLE(LPBYTE pbDecompressed, DWORD cbDecompressed, LPBYTE p while(pbCompressed < pbCompressedEnd && pbDecompressed < pbDecompressedEnd) { OneByte = *pbCompressed++; - + // Is it a repetition byte ? if(OneByte & 0x80) { @@ -146,94 +94,130 @@ static void Decompress_RLE(LPBYTE pbDecompressed, DWORD cbDecompressed, LPBYTE p } } -static int LoadFilePatch_COPY(TMPQFile * hf, PMPQ_PATCH_HEADER pFullPatch) +static int LoadMpqPatch_COPY(TMPQFile * hf, TPatchHeader * pPatchHeader) { - DWORD cbBytesToRead = pFullPatch->dwSizeOfPatchData - sizeof(MPQ_PATCH_HEADER); - DWORD cbBytesRead = 0; + int nError = ERROR_SUCCESS; - // Simply load the rest of the patch - SFileReadFile((HANDLE)hf, (pFullPatch + 1), cbBytesToRead, &cbBytesRead, NULL); - return (cbBytesRead == cbBytesToRead) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; + // Allocate space for patch header and compressed data + hf->pPatchHeader = (TPatchHeader *)STORM_ALLOC(BYTE, pPatchHeader->dwSizeOfPatchData); + if(hf->pPatchHeader == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + + // Load the patch data and decide if they are compressed or not + if(nError == ERROR_SUCCESS) + { + LPBYTE pbPatchFile = (LPBYTE)hf->pPatchHeader; + + // Copy the patch header itself + memcpy(pbPatchFile, pPatchHeader, sizeof(TPatchHeader)); + pbPatchFile += sizeof(TPatchHeader); + + // Load the rest of the patch + if(!SFileReadFile((HANDLE)hf, pbPatchFile, pPatchHeader->dwSizeOfPatchData - sizeof(TPatchHeader), NULL, NULL)) + nError = GetLastError(); + } + + return nError; } -static int LoadFilePatch_BSD0(TMPQFile * hf, PMPQ_PATCH_HEADER pFullPatch) +static int LoadMpqPatch_BSD0(TMPQFile * hf, TPatchHeader * pPatchHeader) { - LPBYTE pbDecompressed = (LPBYTE)(pFullPatch + 1); + LPBYTE pbDecompressed = NULL; LPBYTE pbCompressed = NULL; DWORD cbDecompressed = 0; DWORD cbCompressed = 0; DWORD dwBytesRead = 0; int nError = ERROR_SUCCESS; - // Calculate the size of compressed data - cbDecompressed = pFullPatch->dwSizeOfPatchData - sizeof(MPQ_PATCH_HEADER); - cbCompressed = pFullPatch->dwXfrmBlockSize - SIZE_OF_XFRM_HEADER; + // Allocate space for compressed data + cbCompressed = pPatchHeader->dwXfrmBlockSize - SIZE_OF_XFRM_HEADER; + pbCompressed = STORM_ALLOC(BYTE, cbCompressed); + if(pbCompressed == NULL) + nError = ERROR_SUCCESS; - // Is that file compressed? - if(cbCompressed < cbDecompressed) + // Read the compressed patch data + if(nError == ERROR_SUCCESS) { - pbCompressed = STORM_ALLOC(BYTE, cbCompressed); - if(pbCompressed == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - - // Read the compressed patch data - if(nError == ERROR_SUCCESS) - { - SFileReadFile((HANDLE)hf, pbCompressed, cbCompressed, &dwBytesRead, NULL); - if(dwBytesRead != cbCompressed) - nError = ERROR_FILE_CORRUPT; - } - - // Decompress the data - if(nError == ERROR_SUCCESS) - Decompress_RLE(pbDecompressed, cbDecompressed, pbCompressed, cbCompressed); - - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); - } - else - { - SFileReadFile((HANDLE)hf, pbDecompressed, cbDecompressed, &dwBytesRead, NULL); - if(dwBytesRead != cbDecompressed) + // Load the rest of the header + SFileReadFile((HANDLE)hf, pbCompressed, cbCompressed, &dwBytesRead, NULL); + if(dwBytesRead != cbCompressed) nError = ERROR_FILE_CORRUPT; } + // Get the uncompressed size of the patch + if(nError == ERROR_SUCCESS) + { + cbDecompressed = pPatchHeader->dwSizeOfPatchData - sizeof(TPatchHeader); + hf->pPatchHeader = (TPatchHeader *)STORM_ALLOC(BYTE, pPatchHeader->dwSizeOfPatchData); + if(hf->pPatchHeader == NULL) + nError = ERROR_NOT_ENOUGH_MEMORY; + } + + // Now decompress the patch data + if(nError == ERROR_SUCCESS) + { + // Copy the patch header + memcpy(hf->pPatchHeader, pPatchHeader, sizeof(TPatchHeader)); + pbDecompressed = (LPBYTE)hf->pPatchHeader + sizeof(TPatchHeader); + + // Uncompress or copy the patch data + if(cbCompressed < cbDecompressed) + { + Decompress_RLE(pbDecompressed, cbDecompressed, pbCompressed, cbCompressed); + } + else + { + assert(cbCompressed == cbDecompressed); + memcpy(pbDecompressed, pbCompressed, cbCompressed); + } + } + + // Free buffers and exit + if(pbCompressed != NULL) + STORM_FREE(pbCompressed); return nError; } -static int ApplyFilePatch_COPY( - TMPQPatcher * pPatcher, - PMPQ_PATCH_HEADER pFullPatch, - LPBYTE pbTarget, - LPBYTE pbSource) +static int ApplyMpqPatch_COPY( + TMPQFile * hf, + TPatchHeader * pPatchHeader) { - // Sanity checks - assert(pPatcher->cbMaxFileData >= pPatcher->cbFileData); - pFullPatch = pFullPatch; + LPBYTE pbNewFileData; + DWORD cbNewFileData; + + // Allocate space for new file data + cbNewFileData = pPatchHeader->dwXfrmBlockSize - SIZE_OF_XFRM_HEADER; + pbNewFileData = STORM_ALLOC(BYTE, cbNewFileData); + if(pbNewFileData == NULL) + return ERROR_NOT_ENOUGH_MEMORY; // Copy the patch data as-is - memcpy(pbTarget, pbSource, pPatcher->cbFileData); + memcpy(pbNewFileData, (LPBYTE)pPatchHeader + sizeof(TPatchHeader), cbNewFileData); + + // Free the old file data + STORM_FREE(hf->pbFileData); + + // Put the new file data there + hf->pbFileData = pbNewFileData; + hf->cbFileData = cbNewFileData; return ERROR_SUCCESS; } -static int ApplyFilePatch_BSD0( - TMPQPatcher * pPatcher, - PMPQ_PATCH_HEADER pFullPatch, - LPBYTE pbTarget, - LPBYTE pbSource) +static int ApplyMpqPatch_BSD0( + TMPQFile * hf, + TPatchHeader * pPatchHeader) { PBLIZZARD_BSDIFF40_FILE pBsdiff; - PBSDIFF_CTRL_BLOCK pCtrlBlock; - LPBYTE pbPatchData = (LPBYTE)(pFullPatch + 1); + LPDWORD pCtrlBlock; + LPBYTE pbPatchData = (LPBYTE)pPatchHeader + sizeof(TPatchHeader); LPBYTE pDataBlock; LPBYTE pExtraBlock; - LPBYTE pbOldData = pbSource; - LPBYTE pbNewData = pbTarget; - DWORD dwCombineSize; + LPBYTE pbNewData = NULL; + LPBYTE pbOldData = (LPBYTE)hf->pbFileData; DWORD dwNewOffset = 0; // Current position to patch DWORD dwOldOffset = 0; // Current source position DWORD dwNewSize; // Patched file size - DWORD dwOldSize = pPatcher->cbFileData; // File size before patch + DWORD dwOldSize = hf->cbFileData; // File size before patch // Get pointer to the patch header // Format of BSDIFF header corresponds to original BSDIFF, which is: @@ -250,7 +234,7 @@ static int ApplyFilePatch_BSD0( // 0000 4 bytes Length to copy from the BSDIFF data block the new file // 0004 4 bytes Length to copy from the BSDIFF extra block // 0008 4 bytes Size to increment source file offset - pCtrlBlock = (PBSDIFF_CTRL_BLOCK)pbPatchData; + pCtrlBlock = (LPDWORD)pbPatchData; pbPatchData += (size_t)BSWAP_INT64_UNSIGNED(pBsdiff->CtrlBlockSize); // Get the pointer to the data block @@ -261,38 +245,46 @@ static int ApplyFilePatch_BSD0( pExtraBlock = (LPBYTE)pbPatchData; dwNewSize = (DWORD)BSWAP_INT64_UNSIGNED(pBsdiff->NewFileSize); + // Allocate new buffer + pbNewData = STORM_ALLOC(BYTE, dwNewSize); + if(pbNewData == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + // Now patch the file while(dwNewOffset < dwNewSize) { - DWORD dwAddDataLength = BSWAP_INT32_UNSIGNED(pCtrlBlock->dwAddDataLength); - DWORD dwMovDataLength = BSWAP_INT32_UNSIGNED(pCtrlBlock->dwMovDataLength); - DWORD dwOldMoveLength = BSWAP_INT32_UNSIGNED(pCtrlBlock->dwOldMoveLength); + DWORD dwAddDataLength = BSWAP_INT32_UNSIGNED(pCtrlBlock[0]); + DWORD dwMovDataLength = BSWAP_INT32_UNSIGNED(pCtrlBlock[1]); + DWORD dwOldMoveLength = BSWAP_INT32_UNSIGNED(pCtrlBlock[2]); DWORD i; // Sanity check if((dwNewOffset + dwAddDataLength) > dwNewSize) + { + STORM_FREE(pbNewData); return ERROR_FILE_CORRUPT; + } // Read the diff string to the target buffer memcpy(pbNewData + dwNewOffset, pDataBlock, dwAddDataLength); pDataBlock += dwAddDataLength; - // Get the longest block that we can combine - dwCombineSize = ((dwOldOffset + dwAddDataLength) >= dwOldSize) ? (dwOldSize - dwOldOffset) : dwAddDataLength; - if((dwNewOffset + dwCombineSize) > dwNewSize || (dwNewOffset + dwCombineSize) < dwNewOffset) - return ERROR_FILE_CORRUPT; - // Now combine the patch data with the original file - for(i = 0; i < dwCombineSize; i++) - pbNewData[dwNewOffset + i] = pbNewData[dwNewOffset + i] + pbOldData[dwOldOffset + i]; - - // Move the offsets - dwNewOffset += dwAddDataLength; - dwOldOffset += dwAddDataLength; + for(i = 0; i < dwAddDataLength; i++) + { + if(dwOldOffset < dwOldSize) + pbNewData[dwNewOffset] = pbNewData[dwNewOffset] + pbOldData[dwOldOffset]; + + dwNewOffset++; + dwOldOffset++; + } // Sanity check if((dwNewOffset + dwMovDataLength) > dwNewSize) + { + STORM_FREE(pbNewData); return ERROR_FILE_CORRUPT; + } // Copy the data from the extra block in BSDIFF patch memcpy(pbNewData + dwNewOffset, pExtraBlock, dwMovDataLength); @@ -303,607 +295,106 @@ static int ApplyFilePatch_BSD0( if(dwOldMoveLength & 0x80000000) dwOldMoveLength = 0x80000000 - dwOldMoveLength; dwOldOffset += dwOldMoveLength; - pCtrlBlock++; + pCtrlBlock += 3; } - // The size after patch must match - if(dwNewOffset != pFullPatch->dwSizeAfterPatch) - return ERROR_FILE_CORRUPT; + // Free the old file data + STORM_FREE(hf->pbFileData); - // Update the new data size - pPatcher->cbFileData = dwNewOffset; + // Put the new data to the fil structure + hf->pbFileData = pbNewData; + hf->cbFileData = dwNewSize; return ERROR_SUCCESS; } -static PMPQ_PATCH_HEADER LoadFullFilePatch(TMPQFile * hf, MPQ_PATCH_HEADER & PatchHeader) + +static int LoadMpqPatch(TMPQFile * hf) { - PMPQ_PATCH_HEADER pFullPatch; + TPatchHeader PatchHeader; + DWORD dwBytesRead; int nError = ERROR_SUCCESS; - // BSWAP the entire header, if needed - BSWAP_ARRAY32_UNSIGNED(&PatchHeader, sizeof(DWORD) * 6); - BSWAP_ARRAY32_UNSIGNED(&PatchHeader.dwXFRM, sizeof(DWORD) * 3); + // Read the patch header + SFileReadFile((HANDLE)hf, &PatchHeader, sizeof(TPatchHeader), &dwBytesRead, NULL); + if(dwBytesRead != sizeof(TPatchHeader)) + nError = ERROR_FILE_CORRUPT; // Verify the signatures in the patch header - if(PatchHeader.dwSignature != PATCH_SIGNATURE_HEADER || PatchHeader.dwMD5 != PATCH_SIGNATURE_MD5 || PatchHeader.dwXFRM != PATCH_SIGNATURE_XFRM) - return NULL; - - // Allocate space for patch header and compressed data - pFullPatch = (PMPQ_PATCH_HEADER)STORM_ALLOC(BYTE, PatchHeader.dwSizeOfPatchData); - if(pFullPatch != NULL) + if(nError == ERROR_SUCCESS) { - // Copy the patch header - memcpy(pFullPatch, &PatchHeader, sizeof(MPQ_PATCH_HEADER)); + // BSWAP the entire header, if needed + BSWAP_ARRAY32_UNSIGNED(&PatchHeader, sizeof(DWORD) * 6); + PatchHeader.dwXFRM = BSWAP_INT32_UNSIGNED(PatchHeader.dwXFRM); + PatchHeader.dwXfrmBlockSize = BSWAP_INT32_UNSIGNED(PatchHeader.dwXfrmBlockSize); + PatchHeader.dwPatchType = BSWAP_INT32_UNSIGNED(PatchHeader.dwPatchType); - // Read the patch, depending on patch type - if(nError == ERROR_SUCCESS) - { - switch(PatchHeader.dwPatchType) - { - case 0x59504f43: // 'COPY' - nError = LoadFilePatch_COPY(hf, pFullPatch); - break; - - case 0x30445342: // 'BSD0' - nError = LoadFilePatch_BSD0(hf, pFullPatch); - break; - - default: - nError = ERROR_FILE_CORRUPT; - break; - } - } - - // If something failed, free the patch buffer - if(nError != ERROR_SUCCESS) - { - STORM_FREE(pFullPatch); - pFullPatch = NULL; - } + if(PatchHeader.dwSignature != 0x48435450 || PatchHeader.dwMD5 != 0x5f35444d || PatchHeader.dwXFRM != 0x4d524658) + nError = ERROR_FILE_CORRUPT; } - // Give the result to the caller - return pFullPatch; -} - -static int ApplyFilePatch( - TMPQPatcher * pPatcher, - PMPQ_PATCH_HEADER pFullPatch) -{ - LPBYTE pbSource = (pPatcher->nCounter & 0x1) ? pPatcher->pbFileData2 : pPatcher->pbFileData1; - LPBYTE pbTarget = (pPatcher->nCounter & 0x1) ? pPatcher->pbFileData1 : pPatcher->pbFileData2; - int nError; - - // Sanity checks - assert(pFullPatch->dwSizeAfterPatch <= pPatcher->cbMaxFileData); - - // Apply the patch according to the type - switch(pFullPatch->dwPatchType) + // Read the patch, depending on patch type + if(nError == ERROR_SUCCESS) { + switch(PatchHeader.dwPatchType) + { case 0x59504f43: // 'COPY' - nError = ApplyFilePatch_COPY(pPatcher, pFullPatch, pbTarget, pbSource); + nError = LoadMpqPatch_COPY(hf, &PatchHeader); break; case 0x30445342: // 'BSD0' - nError = ApplyFilePatch_BSD0(pPatcher, pFullPatch, pbTarget, pbSource); + nError = LoadMpqPatch_BSD0(hf, &PatchHeader); break; default: nError = ERROR_FILE_CORRUPT; break; - } - - // Verify MD5 after patch - if(nError == ERROR_SUCCESS && pFullPatch->dwSizeAfterPatch != 0) - { - // Verify the patched file - if(!VerifyDataBlockHash(pbTarget, pFullPatch->dwSizeAfterPatch, pFullPatch->md5_after_patch)) - nError = ERROR_FILE_CORRUPT; - - // Copy the MD5 of the new block - memcpy(pPatcher->this_md5, pFullPatch->md5_after_patch, MD5_DIGEST_SIZE); + } } return nError; } -//----------------------------------------------------------------------------- -// Local functions (patch prefix matching) - -static bool CreatePatchPrefix(TMPQArchive * ha, const char * szFileName, size_t nLength) +static int ApplyMpqPatch( + TMPQFile * hf, + TPatchHeader * pPatchHeader) { - TMPQNamePrefix * pNewPrefix; + int nError = ERROR_SUCCESS; - // If the length of the patch prefix was not entered, find it - // Not that the patch prefix must always begin with backslash - if(szFileName != NULL && nLength == 0) - nLength = strlen(szFileName); - - // Create the patch prefix - pNewPrefix = (TMPQNamePrefix *)STORM_ALLOC(BYTE, sizeof(TMPQNamePrefix) + nLength + 1); - if(pNewPrefix != NULL) + // Verify the original file before patching + if(pPatchHeader->dwSizeBeforePatch != 0) { - // Fill the name prefix. Also add the backslash - if(szFileName && nLength) - { - memcpy(pNewPrefix->szPatchPrefix, szFileName, nLength); - if(pNewPrefix->szPatchPrefix[nLength - 1] != '\\') - pNewPrefix->szPatchPrefix[nLength++] = '\\'; - } - - // Terminate the string and fill the length - pNewPrefix->szPatchPrefix[nLength] = 0; - pNewPrefix->nLength = nLength; + if(!VerifyDataBlockHash(hf->pbFileData, hf->cbFileData, pPatchHeader->md5_before_patch)) + nError = ERROR_FILE_CORRUPT; } - ha->pPatchPrefix = pNewPrefix; - return (pNewPrefix != NULL); -} - -static bool CheckAndCreatePatchPrefix(TMPQArchive * ha, const char * szPatchPrefix, size_t nLength) -{ - char szTempName[MAX_SC2_PATCH_PREFIX + 0x41]; - bool bResult = false; - - // Prepare the patch file name - if(nLength > MAX_SC2_PATCH_PREFIX) - return false; - - // Prepare the patched file name - memcpy(szTempName, szPatchPrefix, nLength); - memcpy(&szTempName[nLength], "\\(patch_metadata)", 18); - - // Verifywhether that file exists - if(GetFileEntryLocale(ha, szTempName, 0) != NULL) - bResult = CreatePatchPrefix(ha, szPatchPrefix, nLength); - - return bResult; -} - -static bool IsMatchingPatchFile( - TMPQArchive * ha, - const char * szFileName, - LPBYTE pbBaseFileMd5) -{ - MPQ_PATCH_HEADER PatchHeader = {0}; - HANDLE hFile = NULL; - DWORD dwTransferred = 0; - DWORD dwFlags = 0; - bool bResult = false; - - // Open the file and load the patch header - if(SFileOpenFileEx((HANDLE)ha, szFileName, SFILE_OPEN_BASE_FILE, &hFile)) + // Apply the patch + if(nError == ERROR_SUCCESS) { - // Retrieve the flags. We need to know whether the file is a patch or not - SFileGetFileInfo(hFile, SFileInfoFlags, &dwFlags, sizeof(DWORD), &dwTransferred); - if(dwFlags & MPQ_FILE_PATCH_FILE) + switch(pPatchHeader->dwPatchType) { - // Load the patch header - SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL); - BSWAP_ARRAY32_UNSIGNED(pPatchHeader, sizeof(DWORD) * 6); + case 0x59504f43: // 'COPY' + nError = ApplyMpqPatch_COPY(hf, pPatchHeader); + break; - // If the file contains an incremental patch, - // compare the "MD5 before patching" with the base file MD5 - if(dwTransferred == sizeof(MPQ_PATCH_HEADER) && PatchHeader.dwSignature == PATCH_SIGNATURE_HEADER) - bResult = (!memcmp(PatchHeader.md5_before_patch, pbBaseFileMd5, MD5_DIGEST_SIZE)); - } - else - { - // TODO: How to match it if it's not an incremental patch? - // Example: StarCraft II\Updates\enGB\s2-update-enGB-23258.MPQ: - // Mods\Core.SC2Mod\enGB.SC2Assets\StreamingBuckets.txt" - bResult = false; - } + case 0x30445342: // 'BSD0' + nError = ApplyMpqPatch_BSD0(hf, pPatchHeader); + break; - // Close the file - SFileCloseFile(hFile); - } - - return bResult; -} - -static const char * FindArchiveLanguage(TMPQArchive * ha, PLOCALIZED_MPQ_INFO pMpqInfo) -{ - TFileEntry * pFileEntry; - const char * szLanguage = LanguageList; - char szFileName[0x40]; - - // Iterate through all localized languages - while(pMpqInfo->szNameTemplate != NULL) - { - // Iterate through all languages - for(szLanguage = LanguageList; szLanguage[0] != 0; szLanguage += 4) - { - // Construct the file name - memcpy(szFileName, pMpqInfo->szNameTemplate, pMpqInfo->nLength); - szFileName[pMpqInfo->nLangOffset + 0] = szLanguage[0]; - szFileName[pMpqInfo->nLangOffset + 1] = szLanguage[1]; - szFileName[pMpqInfo->nLangOffset + 2] = szLanguage[2]; - szFileName[pMpqInfo->nLangOffset + 3] = szLanguage[3]; - - // Append the suffix - memcpy(szFileName + pMpqInfo->nLength, "-md5.lst", 9); - - // Check whether the name exists - pFileEntry = GetFileEntryLocale(ha, szFileName, 0); - if(pFileEntry != NULL) - return szLanguage; - } - - // Move to the next language name - pMpqInfo++; - } - - // Not found - return NULL; -} - -//----------------------------------------------------------------------------- -// Finding ratch prefix for an temporary build of WoW (Pre-Cataclysm) - -static bool FindPatchPrefix_WoW_13164_13623(TMPQArchive * haBase, TMPQArchive * haPatch) -{ - const char * szPatchPrefix; - char szNamePrefix[0x08]; - - // Try to find the language of the MPQ archive - szPatchPrefix = FindArchiveLanguage(haBase, LocaleMpqs_WoW); - if(szPatchPrefix == NULL) - szPatchPrefix = "Base"; - - // Format the patch prefix - szNamePrefix[0] = szPatchPrefix[0]; - szNamePrefix[1] = szPatchPrefix[1]; - szNamePrefix[2] = szPatchPrefix[2]; - szNamePrefix[3] = szPatchPrefix[3]; - szNamePrefix[4] = '\\'; - szNamePrefix[5] = 0; - return CreatePatchPrefix(haPatch, szNamePrefix, 5); -} - -//----------------------------------------------------------------------------- -// Finding patch prefix for Starcraft II (Pre-Legacy of the Void) - -// -// This method tries to match the patch by placement of the archive (in the game subdirectory) -// -// Archive Path: %GAME_DIR%\Mods\SwarmMulti.SC2Mod\Base.SC2Data -// Patch Prefix: Mods\SwarmMulti.SC2Mod\Base.SC2Data -// -// Archive Path: %ANY_DIR%\MPQ_2013_v4_Mods#Liberty.SC2Mod#enGB.SC2Data -// Patch Prefix: Mods\Liberty.SC2Mod\enGB.SC2Data -// - -static bool CheckPatchPrefix_SC2_ArchiveName( - TMPQArchive * haPatch, - const TCHAR * szPathPtr, - const TCHAR * szSeparator, - const TCHAR * szPathEnd, - const TCHAR * szExpectedString, - size_t cchExpectedString) -{ - char szPatchPrefix[MAX_SC2_PATCH_PREFIX+0x41]; - size_t nLength = 0; - bool bResult = false; - - // Check whether the length is equal to the length of the expected string - if((size_t)(szSeparator - szPathPtr) == cchExpectedString) - { - // Now check the string itself - if(!_tcsnicmp(szPathPtr, szExpectedString, szSeparator - szPathPtr)) - { - // Copy the name string - for(; szPathPtr < szPathEnd; szPathPtr++) - { - if(szPathPtr[0] != _T('/') && szPathPtr[0] != _T('#')) - szPatchPrefix[nLength++] = (char)szPathPtr[0]; - else - szPatchPrefix[nLength++] = '\\'; - } - - // Check and create the patch prefix - bResult = CheckAndCreatePatchPrefix(haPatch, szPatchPrefix, nLength); - } - } - - return bResult; -} - -static bool FindPatchPrefix_SC2_ArchiveName(TMPQArchive * haBase, TMPQArchive * haPatch) -{ - const TCHAR * szPathBegin = FileStream_GetFileName(haBase->pStream); - const TCHAR * szSeparator = NULL; - const TCHAR * szPathEnd = szPathBegin + _tcslen(szPathBegin); - const TCHAR * szPathPtr; - int nSlashCount = 0; - int nDotCount = 0; - - // Skip the part where the patch prefix would be too long - if((szPathEnd - szPathBegin) > MAX_SC2_PATCH_PREFIX) - szPathBegin = szPathEnd - MAX_SC2_PATCH_PREFIX; - - // Search for the file extension - for(szPathPtr = szPathEnd; szPathPtr > szPathBegin; szPathPtr--) - { - if(szPathPtr[0] == _T('.')) - { - nDotCount++; + default: + nError = ERROR_FILE_CORRUPT; break; } } - // Search for the possible begin of the prefix name - for(/* NOTHING */; szPathPtr > szPathBegin; szPathPtr--) + // Verify MD5 after patch + if(nError == ERROR_SUCCESS && pPatchHeader->dwSizeAfterPatch != 0) { - // Check the slashes, backslashes and hashes - if(szPathPtr[0] == _T('\\') || szPathPtr[0] == _T('/') || szPathPtr[0] == _T('#')) - { - if(nDotCount == 0) - return false; - szSeparator = szPathPtr; - nSlashCount++; - } - - // Check the path parts - if(szSeparator != NULL && nSlashCount >= nDotCount) - { - if(CheckPatchPrefix_SC2_ArchiveName(haPatch, szPathPtr, szSeparator, szPathEnd, _T("Battle.net"), 10)) - return true; - if(CheckPatchPrefix_SC2_ArchiveName(haPatch, szPathPtr, szSeparator, szPathEnd, _T("Campaigns"), 9)) - return true; - if(CheckPatchPrefix_SC2_ArchiveName(haPatch, szPathPtr, szSeparator, szPathEnd, _T("Mods"), 4)) - return true; - } + // Verify the patched file + if(!VerifyDataBlockHash(hf->pbFileData, hf->cbFileData, pPatchHeader->md5_after_patch)) + nError = ERROR_FILE_CORRUPT; } - // Not matched, sorry - return false; -} - -// -// This method tries to read the patch prefix from a helper file -// -// Example -// ========================================================= -// MPQ File Name: MPQ_2013_v4_Base1.SC2Data -// Helper File : MPQ_2013_v4_Base1.SC2Data-PATCH -// File Contains: PatchPrefix=Mods\Core.SC2Mod\Base.SC2Data -// Patch Prefix : Mods\Core.SC2Mod\Base.SC2Data -// - -static bool ExtractPatchPrefixFromFile(const TCHAR * szHelperFile, char * szPatchPrefix, size_t nMaxChars, size_t * PtrLength) -{ - TFileStream * pStream; - ULONGLONG FileSize = 0; - size_t nLength; - char szFileData[MAX_PATH+1]; - bool bResult = false; - - pStream = FileStream_OpenFile(szHelperFile, STREAM_FLAG_READ_ONLY); - if(pStream != NULL) - { - // Retrieve and check the file size - FileStream_GetSize(pStream, &FileSize); - if(12 <= FileSize && FileSize < MAX_PATH) - { - // Read the entire file to memory - if(FileStream_Read(pStream, NULL, szFileData, (DWORD)FileSize)) - { - // Terminate the buffer with zero - szFileData[(DWORD)FileSize] = 0; - - // The file data must begin with the "PatchPrefix" variable - if(!_strnicmp(szFileData, "PatchPrefix", 11)) - { - char * szLinePtr = szFileData + 11; - char * szLineEnd; - - // Skip spaces or '=' - while(szLinePtr[0] == ' ' || szLinePtr[0] == '=') - szLinePtr++; - szLineEnd = szLinePtr; - - // Find the end - while(szLineEnd[0] != 0 && szLineEnd[0] != 0x0A && szLineEnd[0] != 0x0D) - szLineEnd++; - nLength = (size_t)(szLineEnd - szLinePtr); - - // Copy the variable - if(szLineEnd > szLinePtr && nLength <= nMaxChars) - { - memcpy(szPatchPrefix, szLinePtr, nLength); - szPatchPrefix[nLength] = 0; - PtrLength[0] = nLength; - bResult = true; - } - } - } - } - - // Close the stream - FileStream_Close(pStream); - } - - return bResult; -} - - -static bool FindPatchPrefix_SC2_HelperFile(TMPQArchive * haBase, TMPQArchive * haPatch) -{ - TCHAR szHelperFile[MAX_PATH+1]; - char szPatchPrefix[MAX_SC2_PATCH_PREFIX+0x41]; - size_t nLength = 0; - bool bResult = false; - - // Create the name of the patch helper file - _tcscpy(szHelperFile, FileStream_GetFileName(haBase->pStream)); - if(_tcslen(szHelperFile) + 6 > MAX_PATH) - return false; - _tcscat(szHelperFile, _T("-PATCH")); - - // Open the patch helper file and read the line - if(ExtractPatchPrefixFromFile(szHelperFile, szPatchPrefix, MAX_SC2_PATCH_PREFIX, &nLength)) - bResult = CheckAndCreatePatchPrefix(haPatch, szPatchPrefix, nLength); - - return bResult; -} - -// -// Find match in Starcraft II patch MPQs -// Match a LST file in the root directory if the MPQ with any of the file in subdirectories -// -// The problem: -// File in the base MPQ: enGB-md5.lst -// File in the patch MPQ: Campaigns\Liberty.SC2Campaign\enGB.SC2Assets\enGB-md5.lst -// Campaigns\Liberty.SC2Campaign\enGB.SC2Data\enGB-md5.lst -// Campaigns\LibertyStory.SC2Campaign\enGB.SC2Data\enGB-md5.lst -// Campaigns\LibertyStory.SC2Campaign\enGB.SC2Data\enGB-md5.lst Mods\Core.SC2Mod\enGB.SC2Assets\enGB-md5.lst -// Mods\Core.SC2Mod\enGB.SC2Data\enGB-md5.lst -// Mods\Liberty.SC2Mod\enGB.SC2Assets\enGB-md5.lst -// Mods\Liberty.SC2Mod\enGB.SC2Data\enGB-md5.lst -// Mods\LibertyMulti.SC2Mod\enGB.SC2Data\enGB-md5.lst -// -// Solution: -// We need to match the file by its MD5 -// - -static bool FindPatchPrefix_SC2_MatchFiles(TMPQArchive * haBase, TMPQArchive * haPatch, TFileEntry * pBaseEntry) -{ - TMPQNamePrefix * pPatchPrefix; - char * szPatchFileName; - char * szPlainName; - size_t cchWorkBuffer = 0x400; - bool bResult = false; - - // First-level patches: Find the same file within the patch archive - // and verify by MD5-before-patch - if(haBase->haPatch == NULL) - { - TFileEntry * pFileTableEnd = haPatch->pFileTable + haPatch->dwFileTableSize; - TFileEntry * pFileEntry; - - // Allocate working buffer for merging LST file - szPatchFileName = STORM_ALLOC(char, cchWorkBuffer); - if(szPatchFileName != NULL) - { - // Parse the entire file table - for(pFileEntry = haPatch->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Look for "patch_metadata" file - if(IsPatchMetadataFile(pFileEntry)) - { - // Construct the name of the MD5 file - strcpy(szPatchFileName, pFileEntry->szFileName); - szPlainName = (char *)GetPlainFileName(szPatchFileName); - strcpy(szPlainName, pBaseEntry->szFileName); - - // Check for matching MD5 file - if(IsMatchingPatchFile(haPatch, szPatchFileName, pBaseEntry->md5)) - { - bResult = CreatePatchPrefix(haPatch, szPatchFileName, (size_t)(szPlainName - szPatchFileName)); - break; - } - } - } - - // Delete the merge buffer - STORM_FREE(szPatchFileName); - } - } - - // For second-level patches, just take the patch prefix from the lower level patch - else - { - // There must be at least two patches in the chain - assert(haBase->haPatch->pPatchPrefix != NULL); - pPatchPrefix = haBase->haPatch->pPatchPrefix; - - // Copy the patch prefix - bResult = CreatePatchPrefix(haPatch, - pPatchPrefix->szPatchPrefix, - pPatchPrefix->nLength); - } - - return bResult; -} - -// Note: pBaseEntry is the file entry of the base version of "StreamingBuckets.txt" -static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch, TFileEntry * pBaseEntry) -{ - // Method 1: Try it by the placement of the archive. - // Works when someone is opening an archive in the game (sub)directory - if(FindPatchPrefix_SC2_ArchiveName(haBase, haPatch)) - return true; - - // Method 2: Try to locate the Name.Ext-PATCH file and read the patch prefix from it - if(FindPatchPrefix_SC2_HelperFile(haBase, haPatch)) - return true; - - // Method 3: Try to pair any version of "StreamingBuckets.txt" from the patch MPQ - // with the "StreamingBuckets.txt" in the base MPQ. Does not always work - if(FindPatchPrefix_SC2_MatchFiles(haBase, haPatch, pBaseEntry)) - return true; - - return false; -} - -// -// Patch prefix is the path subdirectory where the patched files are within MPQ. -// -// Example 1: -// Main MPQ: locale-enGB.MPQ -// Patch MPQ: wow-update-12694.MPQ -// File in main MPQ: DBFilesClient\Achievement.dbc -// File in patch MPQ: enGB\DBFilesClient\Achievement.dbc -// Path prefix: enGB -// -// Example 2: -// Main MPQ: expansion1.MPQ -// Patch MPQ: wow-update-12694.MPQ -// File in main MPQ: DBFilesClient\Achievement.dbc -// File in patch MPQ: Base\DBFilesClient\Achievement.dbc -// Path prefix: Base -// -// Example 3: -// Main MPQ: %GAME%\Battle.net\Battle.net.MPQ -// Patch MPQ: s2-update-base-26147.MPQ -// File in main MPQ: Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml -// File in patch MPQ: Battle.net\Battle.net.MPQ\Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml -// Path prefix: Battle.net\Battle.net.MPQ -// -// Example 4: -// Main MPQ: %GAME%\Campaigns\Liberty.SC2Campaign\enGB.SC2Data -// *OR* %ANY_DIR%\%ANY_NAME%Campaigns#Liberty.SC2Campaign#enGB.SC2Data -// Patch MPQ: s2-update-enGB-23258.MPQ -// File in main MPQ: LocalizedData\GameHotkeys.txt -// File in patch MPQ: Campaigns\Liberty.SC2Campaign\enGB.SC2Data\LocalizedData\GameHotkeys.txt -// Patch Prefix: Campaigns\Liberty.SC2Campaign\enGB.SC2Data -// - -static bool FindPatchPrefix(TMPQArchive * haBase, TMPQArchive * haPatch, const char * szPatchPathPrefix) -{ - TFileEntry * pFileEntry; - - // If the patch prefix was explicitly entered, we use that one - if(szPatchPathPrefix != NULL) - return CreatePatchPrefix(haPatch, szPatchPathPrefix, 0); - - // Patches for World of Warcraft - they mostly do not use prefix. - // All patches that use patch prefix have the "base\\(patch_metadata) file present - if(GetFileEntryLocale(haPatch, "base\\" PATCH_METADATA_NAME, 0)) - return FindPatchPrefix_WoW_13164_13623(haBase, haPatch); - - // Updates for Starcraft II - // Match: LocalizedData\GameHotkeys.txt <==> Campaigns\Liberty.SC2Campaign\enGB.SC2Data\LocalizedData\GameHotkeys.txt - // All Starcraft II base archives seem to have the file "StreamingBuckets.txt" present - pFileEntry = GetFileEntryLocale(haBase, "StreamingBuckets.txt", 0); - if(pFileEntry != NULL) - return FindPatchPrefix_SC2(haBase, haPatch, pFileEntry); - - // Diablo III patch MPQs don't use patch prefix - // Hearthstone MPQs don't use patch prefix - CreatePatchPrefix(haPatch, NULL, 0); - return true; + return nError; } //----------------------------------------------------------------------------- @@ -911,11 +402,11 @@ static bool FindPatchPrefix(TMPQArchive * haBase, TMPQArchive * haPatch, const c bool IsIncrementalPatchFile(const void * pvData, DWORD cbData, LPDWORD pdwPatchedFileSize) { - PMPQ_PATCH_HEADER pPatchHeader = (PMPQ_PATCH_HEADER)pvData; + TPatchHeader * pPatchHeader = (TPatchHeader *)pvData; BLIZZARD_BSDIFF40_FILE DiffFile; DWORD dwPatchType; - if(cbData >= sizeof(MPQ_PATCH_HEADER) + sizeof(BLIZZARD_BSDIFF40_FILE)) + if(cbData >= sizeof(TPatchHeader) + sizeof(BLIZZARD_BSDIFF40_FILE)) { dwPatchType = BSWAP_INT32_UNSIGNED(pPatchHeader->dwPatchType); if(dwPatchType == 0x30445342) @@ -934,177 +425,87 @@ bool IsIncrementalPatchFile(const void * pvData, DWORD cbData, LPDWORD pdwPatche return false; } -int Patch_InitPatcher(TMPQPatcher * pPatcher, TMPQFile * hf) +int PatchFileData(TMPQFile * hf) { - DWORD cbMaxFileData = 0; - - // Overflow check - if((cbMaxFileData + (DWORD)sizeof(MPQ_PATCH_HEADER)) < cbMaxFileData) - return ERROR_NOT_ENOUGH_MEMORY; - if(hf->hfPatch == NULL) - return ERROR_INVALID_PARAMETER; - - // Initialize the entire structure with zeros - memset(pPatcher, 0, sizeof(TMPQPatcher)); - - // Copy the MD5 of the current file - memcpy(pPatcher->this_md5, hf->pFileEntry->md5, MD5_DIGEST_SIZE); - - // Find out the biggest data size needed during the patching process - while(hf != NULL) - { - if(hf->pFileEntry->dwFileSize > cbMaxFileData) - cbMaxFileData = hf->pFileEntry->dwFileSize; - hf = hf->hfPatch; - } - - // Allocate primary and secondary buffer - pPatcher->pbFileData1 = STORM_ALLOC(BYTE, cbMaxFileData); - pPatcher->pbFileData2 = STORM_ALLOC(BYTE, cbMaxFileData); - if(!pPatcher->pbFileData1 || !pPatcher->pbFileData2) - return ERROR_NOT_ENOUGH_MEMORY; - - pPatcher->cbMaxFileData = cbMaxFileData; - return ERROR_SUCCESS; -} - -// -// Note: The patch may either be applied to the base file or to the previous version -// In Starcraft II, Mods\Core.SC2Mod\Base.SC2Data, file StreamingBuckets.txt: -// -// Base file MD5: 31376b0344b6df59ad009d4296125539 -// -// s2-update-base-23258: from 31376b0344b6df59ad009d4296125539 to 941a82683452e54bf024a8d491501824 -// s2-update-base-24540: from 31376b0344b6df59ad009d4296125539 to 941a82683452e54bf024a8d491501824 -// s2-update-base-26147: from 31376b0344b6df59ad009d4296125539 to d5d5253c762fac6b9761240288a0771a -// s2-update-base-28522: from 31376b0344b6df59ad009d4296125539 to 5a76c4b356920aab7afd22e0e1913d7a -// s2-update-base-30508: from 31376b0344b6df59ad009d4296125539 to 8cb0d4799893fe801cc78ae4488a3671 -// s2-update-base-32283: from 31376b0344b6df59ad009d4296125539 to 8cb0d4799893fe801cc78ae4488a3671 -// -// We don't keep all intermediate versions in memory, as it would cause massive -// memory usage during patching process. A prime example is the file -// DBFilesClient\\Item-Sparse.db2 from locale-enGB.MPQ (WoW 16965), which has -// 9 patches in a row, each requiring 70 MB memory (35 MB patch data + 35 MB work buffer) -// - -int Patch_Process(TMPQPatcher * pPatcher, TMPQFile * hf) -{ - PMPQ_PATCH_HEADER pFullPatch; - MPQ_PATCH_HEADER PatchHeader1; - MPQ_PATCH_HEADER PatchHeader2 = {0}; TMPQFile * hfBase = hf; - DWORD cbBytesRead = 0; int nError = ERROR_SUCCESS; // Move to the first patch - assert(hfBase->pbFileData == NULL); - assert(hfBase->cbFileData == 0); - hf = hf->hfPatch; + hf = hf->hfPatchFile; - // Read the header of the current patch - SFileReadFile((HANDLE)hf, &PatchHeader1, sizeof(MPQ_PATCH_HEADER), &cbBytesRead, NULL); - if(cbBytesRead != sizeof(MPQ_PATCH_HEADER)) - return ERROR_FILE_CORRUPT; - - // Perform the patching process - while(nError == ERROR_SUCCESS && hf != NULL) + // Now go through all patches and patch the original data + while(hf != NULL) { - // Try to read the next patch header. If the md5_before_patch - // still matches we go directly to the next one and repeat - while(hf->hfPatch != NULL) - { - // Attempt to read the patch header - SFileReadFile((HANDLE)hf->hfPatch, &PatchHeader2, sizeof(MPQ_PATCH_HEADER), &cbBytesRead, NULL); - if(cbBytesRead != sizeof(MPQ_PATCH_HEADER)) - return ERROR_FILE_CORRUPT; + // This must be true + assert(hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE); - // Compare the md5_before_patch - if(memcmp(PatchHeader2.md5_before_patch, pPatcher->this_md5, MD5_DIGEST_SIZE)) - break; + // Make sure that the patch data is loaded + nError = LoadMpqPatch(hf); + if(nError != ERROR_SUCCESS) + break; - // Move one patch fuhrter - PatchHeader1 = PatchHeader2; - hf = hf->hfPatch; - } - - // Allocate memory for the patch data - pFullPatch = LoadFullFilePatch(hf, PatchHeader1); - if(pFullPatch != NULL) - { - // Apply the patch - nError = ApplyFilePatch(pPatcher, pFullPatch); - STORM_FREE(pFullPatch); - } - else - { - nError = ERROR_FILE_CORRUPT; - } + // Apply the patch + nError = ApplyMpqPatch(hfBase, hf->pPatchHeader); + if(nError != ERROR_SUCCESS) + break; // Move to the next patch - PatchHeader1 = PatchHeader2; - pPatcher->nCounter++; - hf = hf->hfPatch; + hf = hf->hfPatchFile; } - // Put the result data to the file structure - if(nError == ERROR_SUCCESS) - { - // Swap the pointer to the file data structure - if(pPatcher->nCounter & 0x01) - { - hfBase->pbFileData = pPatcher->pbFileData2; - pPatcher->pbFileData2 = NULL; - } - else - { - hfBase->pbFileData = pPatcher->pbFileData1; - pPatcher->pbFileData1 = NULL; - } - - // Also supply the data size - hfBase->cbFileData = pPatcher->cbFileData; - } - - return ERROR_SUCCESS; + return nError; } -void Patch_Finalize(TMPQPatcher * pPatcher) -{ - if(pPatcher != NULL) - { - if(pPatcher->pbFileData1 != NULL) - STORM_FREE(pPatcher->pbFileData1); - if(pPatcher->pbFileData2 != NULL) - STORM_FREE(pPatcher->pbFileData2); - - memset(pPatcher, 0, sizeof(TMPQPatcher)); - } -} - - //----------------------------------------------------------------------------- // Public functions +// +// Patch prefix is the path subdirectory where the patched files are within MPQ. +// +// Example 1: +// Main MPQ: locale-enGB.MPQ +// Patch MPQ: wow-update-12694.MPQ +// File in main MPQ: DBFilesClient\Achievement.dbc +// File in patch MPQ: enGB\DBFilesClient\Achievement.dbc +// Path prefix: enGB +// +// Example 2: +// Main MPQ: expansion1.MPQ +// Patch MPQ: wow-update-12694.MPQ +// File in main MPQ: DBFilesClient\Achievement.dbc +// File in patch MPQ: Base\DBFilesClient\Achievement.dbc +// Path prefix: Base +// + bool WINAPI SFileOpenPatchArchive( - HANDLE hMpq, - const TCHAR * szPatchMpqName, - const char * szPatchPathPrefix, - DWORD dwFlags) + HANDLE hMpq, + const TCHAR * szPatchMpqName, + const char * szPatchPathPrefix, + DWORD dwFlags) { TMPQArchive * haPatch; TMPQArchive * ha = (TMPQArchive *)hMpq; HANDLE hPatchMpq = NULL; + char szPatchPrefixBuff[MPQ_PATCH_PREFIX_LEN]; int nError = ERROR_SUCCESS; // Keep compiler happy dwFlags = dwFlags; // Verify input parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) nError = ERROR_INVALID_HANDLE; if(szPatchMpqName == NULL || *szPatchMpqName == 0) nError = ERROR_INVALID_PARAMETER; + // If the user didn't give the patch prefix, get default one + if(szPatchPathPrefix != NULL) + { + // Save length of the patch prefix + if(strlen(szPatchPathPrefix) > MPQ_PATCH_PREFIX_LEN - 2) + nError = ERROR_INVALID_PARAMETER; + } + // // We don't allow adding patches to archives that have been open for write // @@ -1119,44 +520,55 @@ bool WINAPI SFileOpenPatchArchive( if(nError == ERROR_SUCCESS) { - if(!(ha->dwFlags & MPQ_FLAG_READ_ONLY)) + if(!FileStream_IsReadOnly(ha->pStream)) nError = ERROR_ACCESS_DENIED; } // Open the archive like it is normal archive if(nError == ERROR_SUCCESS) { - if(SFileOpenArchive(szPatchMpqName, 0, MPQ_OPEN_READ_ONLY | MPQ_OPEN_PATCH, &hPatchMpq)) + if(!SFileOpenArchive(szPatchMpqName, 0, MPQ_OPEN_READ_ONLY, &hPatchMpq)) + return false; + haPatch = (TMPQArchive *)hPatchMpq; + + // Older WoW patches (build 13914) used to have + // several language versions in one patch file + // Those patches needed to have a path prefix + // We can distinguish such patches by not having the (patch_metadata) file + if(szPatchPathPrefix == NULL) { - // Cast the archive handle to structure pointer - haPatch = (TMPQArchive *)hPatchMpq; - - // We need to remember the proper patch prefix to match names of patched files - if(FindPatchPrefix(ha, (TMPQArchive *)hPatchMpq, szPatchPathPrefix)) + if(!SFileHasFile(hPatchMpq, PATCH_METADATA_NAME)) { - // Now add the patch archive to the list of patches to the original MPQ - while(ha != NULL) - { - if(ha->haPatch == NULL) - { - haPatch->haBase = ha; - ha->haPatch = haPatch; - return true; - } + GetDefaultPatchPrefix(FileStream_GetFileName(ha->pStream), szPatchPrefixBuff); + szPatchPathPrefix = szPatchPrefixBuff; + } + } - // Move to the next archive - ha = ha->haPatch; - } + // Save the prefix for patch file names. + // Make sure that there is backslash after it + if(szPatchPathPrefix != NULL && *szPatchPathPrefix != 0) + { + strcpy(haPatch->szPatchPrefix, szPatchPathPrefix); + strcat(haPatch->szPatchPrefix, "\\"); + haPatch->cchPatchPrefix = strlen(haPatch->szPatchPrefix); + } + + // Now add the patch archive to the list of patches to the original MPQ + while(ha != NULL) + { + if(ha->haPatch == NULL) + { + haPatch->haBase = ha; + ha->haPatch = haPatch; + return true; } - // Close the archive - SFileCloseArchive(hPatchMpq); - nError = ERROR_CANT_FIND_PATCH_PREFIX; - } - else - { - nError = GetLastError(); + // Move to the next archive + ha = ha->haPatch; } + + // Should never happen + nError = ERROR_CAN_NOT_COMPLETE; } SetLastError(nError); @@ -1168,7 +580,7 @@ bool WINAPI SFileIsPatchedArchive(HANDLE hMpq) TMPQArchive * ha = (TMPQArchive *)hMpq; // Verify input parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) return false; return (ha->haPatch != NULL); diff --git a/dep/StormLib/src/SFileReadFile.cpp b/dep/StormLib/src/SFileReadFile.cpp index 719064b0a..741352c2c 100644 --- a/dep/StormLib/src/SFileReadFile.cpp +++ b/dep/StormLib/src/SFileReadFile.cpp @@ -13,9 +13,111 @@ #include "StormLib.h" #include "StormCommon.h" +//----------------------------------------------------------------------------- +// Local structures + +struct TFileHeader2Ext +{ + DWORD dwOffset00Data; // Required data at offset 00 (32-bits) + DWORD dwOffset00Mask; // Mask for data at offset 00 (32 bits). 0 = data are ignored + DWORD dwOffset04Data; // Required data at offset 04 (32-bits) + DWORD dwOffset04Mask; // Mask for data at offset 04 (32 bits). 0 = data are ignored + const char * szExt; // Supplied extension, if the condition is true +}; + //----------------------------------------------------------------------------- // Local functions +static void CopyFileName(char * szTarget, const TCHAR * szSource) +{ + while(*szSource != 0) + *szTarget++ = (char)*szSource++; + *szTarget = 0; +} + +static DWORD GetMpqFileCount(TMPQArchive * ha) +{ + TFileEntry * pFileTableEnd; + TFileEntry * pFileEntry; + DWORD dwFileCount = 0; + + // Go through all open MPQs, including patches + while(ha != NULL) + { + // Only count files that are not patch files + pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; + for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) + { + // If the file is patch file and this is not primary archive, skip it + // BUGBUG: This errorneously counts non-patch files that are in both + // base MPQ and in patches, and increases the number of files by cca 50% + if((pFileEntry->dwFlags & (MPQ_FILE_EXISTS | MPQ_FILE_PATCH_FILE)) == MPQ_FILE_EXISTS) + dwFileCount++; + } + + // Move to the next patch archive + ha = ha->haPatch; + } + + return dwFileCount; +} + +static bool GetFilePatchChain(TMPQFile * hf, void * pvFileInfo, DWORD cbFileInfo, LPDWORD pcbLengthNeeded) +{ + TMPQFile * hfTemp; + TCHAR * szPatchChain = (TCHAR *)pvFileInfo; + TCHAR * szFileName; + size_t cchCharsNeeded = 1; + size_t nLength; + DWORD cbLengthNeeded; + + // Check if the "hf" is a MPQ file + if(hf->pStream != NULL) + { + // Calculate the length needed + szFileName = FileStream_GetFileName(hf->pStream); + cchCharsNeeded += _tcslen(szFileName) + 1; + cbLengthNeeded = (DWORD)(cchCharsNeeded * sizeof(TCHAR)); + + // If we have enough space, copy the file name + if(cbFileInfo >= cbLengthNeeded) + { + nLength = _tcslen(szFileName) + 1; + memcpy(szPatchChain, szFileName, nLength * sizeof(TCHAR)); + szPatchChain += nLength; + + // Terminate the multi-string + *szPatchChain = 0; + } + } + else + { + // Calculate number of characters needed + for(hfTemp = hf; hfTemp != NULL; hfTemp = hfTemp->hfPatchFile) + cchCharsNeeded += _tcslen(FileStream_GetFileName(hfTemp->ha->pStream)) + 1; + cbLengthNeeded = (DWORD)(cchCharsNeeded * sizeof(TCHAR)); + + // If we have enough space, the copy the patch chain + if(cbFileInfo >= cbLengthNeeded) + { + for(hfTemp = hf; hfTemp != NULL; hfTemp = hfTemp->hfPatchFile) + { + szFileName = FileStream_GetFileName(hfTemp->ha->pStream); + nLength = _tcslen(szFileName) + 1; + memcpy(szPatchChain, szFileName, nLength * sizeof(TCHAR)); + szPatchChain += nLength; + } + + // Terminate the multi-string + *szPatchChain = 0; + } + } + + // Give result length, terminate multi-string and return + *pcbLengthNeeded = cbLengthNeeded; + return true; +} + // hf - MPQ File handle. // pbBuffer - Pointer to target buffer to store sectors. // dwByteOffset - Position of sector in the file (relative to file begin) @@ -48,13 +150,13 @@ static int ReadMpqSectors(TMPQFile * hf, LPBYTE pbBuffer, DWORD dwByteOffset, DW dwRawBytesToRead = dwBytesToRead; // Perform all necessary work to do with compressed files - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) + if(pFileEntry->dwFlags & MPQ_FILE_COMPRESSED) { // If the sector positions are not loaded yet, do it if(hf->SectorOffsets == NULL) { nError = AllocateSectorOffsets(hf, true); - if(nError != ERROR_SUCCESS || hf->SectorOffsets == NULL) + if(nError != ERROR_SUCCESS) return nError; } @@ -74,148 +176,141 @@ static int ReadMpqSectors(TMPQFile * hf, LPBYTE pbBuffer, DWORD dwByteOffset, DW // TODO: If the raw data MD5s are not loaded yet, load them now // Only do it if the MPQ is of format 4.0 -// if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_4 && ha->pHeader->dwRawChunkSize != 0) -// { -// nError = AllocateRawMD5s(hf, true); -// if(nError != ERROR_SUCCESS) -// return nError; -// } + // if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_4 && ha->pHeader->dwRawChunkSize != 0) + // { + // nError = AllocateRawMD5s(hf, true); + // if(nError != ERROR_SUCCESS) + // return nError; + // } + + // If the file is compressed, also allocate secondary buffer + pbInSector = pbRawSector = STORM_ALLOC(BYTE, dwBytesToRead); + if(pbRawSector == NULL) + return ERROR_NOT_ENOUGH_MEMORY; // Assign the temporary buffer as target for read operation dwRawSectorOffset = hf->SectorOffsets[dwSectorIndex]; dwRawBytesToRead = hf->SectorOffsets[dwSectorIndex + dwSectorsToRead] - dwRawSectorOffset; - - // If the file is compressed, also allocate secondary buffer - pbInSector = pbRawSector = STORM_ALLOC(BYTE, dwRawBytesToRead); - if(pbRawSector == NULL) - return ERROR_NOT_ENOUGH_MEMORY; } // Calculate raw file offset where the sector(s) are stored. - RawFilePos = CalculateRawSectorOffset(hf, dwRawSectorOffset); + CalculateRawSectorOffset(RawFilePos, hf, dwRawSectorOffset); // Set file pointer and read all required sectors - if(FileStream_Read(ha->pStream, &RawFilePos, pbInSector, dwRawBytesToRead)) + if(!FileStream_Read(ha->pStream, &RawFilePos, pbInSector, dwRawBytesToRead)) + return GetLastError(); + dwBytesRead = 0; + + // Now we have to decrypt and decompress all file sectors that have been loaded + for(DWORD i = 0; i < dwSectorsToRead; i++) { - // Now we have to decrypt and decompress all file sectors that have been loaded - for(DWORD i = 0; i < dwSectorsToRead; i++) + DWORD dwRawBytesInThisSector = ha->dwSectorSize; + DWORD dwBytesInThisSector = ha->dwSectorSize; + DWORD dwIndex = dwSectorIndex + i; + + // If there is not enough bytes in the last sector, + // cut the number of bytes in this sector + if(dwRawBytesInThisSector > dwBytesToRead) + dwRawBytesInThisSector = dwBytesToRead; + if(dwBytesInThisSector > dwBytesToRead) + dwBytesInThisSector = dwBytesToRead; + + // If the file is compressed, we have to adjust the raw sector size + if(pFileEntry->dwFlags & MPQ_FILE_COMPRESSED) + dwRawBytesInThisSector = hf->SectorOffsets[dwIndex + 1] - hf->SectorOffsets[dwIndex]; + + // If the file is encrypted, we have to decrypt the sector + if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) { - DWORD dwRawBytesInThisSector = ha->dwSectorSize; - DWORD dwBytesInThisSector = ha->dwSectorSize; - DWORD dwIndex = dwSectorIndex + i; + BSWAP_ARRAY32_UNSIGNED(pbInSector, dwRawBytesInThisSector); - // If there is not enough bytes in the last sector, - // cut the number of bytes in this sector - if(dwRawBytesInThisSector > dwBytesToRead) - dwRawBytesInThisSector = dwBytesToRead; - if(dwBytesInThisSector > dwBytesToRead) - dwBytesInThisSector = dwBytesToRead; - - // If the file is compressed, we have to adjust the raw sector size - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - dwRawBytesInThisSector = hf->SectorOffsets[dwIndex + 1] - hf->SectorOffsets[dwIndex]; - - // If the file is encrypted, we have to decrypt the sector - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) + // If we don't know the key, try to detect it by file content + if(hf->dwFileKey == 0) { - BSWAP_ARRAY32_UNSIGNED(pbInSector, dwRawBytesInThisSector); - - // If we don't know the key, try to detect it by file content + hf->dwFileKey = DetectFileKeyByContent(pbInSector, dwBytesInThisSector); if(hf->dwFileKey == 0) { - hf->dwFileKey = DetectFileKeyByContent(pbInSector, dwBytesInThisSector, hf->dwDataSize); - if(hf->dwFileKey == 0) - { - nError = ERROR_UNKNOWN_FILE_KEY; - break; - } - } - - DecryptMpqBlock(pbInSector, dwRawBytesInThisSector, hf->dwFileKey + dwIndex); - BSWAP_ARRAY32_UNSIGNED(pbInSector, dwRawBytesInThisSector); - } - - // If the file has sector CRC check turned on, perform it - if(hf->bCheckSectorCRCs && hf->SectorChksums != NULL) - { - DWORD dwAdlerExpected = hf->SectorChksums[dwIndex]; - DWORD dwAdlerValue = 0; - - // We can only check sector CRC when it's not zero - // Neither can we check it if it's 0xFFFFFFFF. - if(dwAdlerExpected != 0 && dwAdlerExpected != 0xFFFFFFFF) - { - dwAdlerValue = adler32(0, pbInSector, dwRawBytesInThisSector); - if(dwAdlerValue != dwAdlerExpected) - { - nError = ERROR_CHECKSUM_ERROR; - break; - } - } - } - - // If the sector is really compressed, decompress it. - // WARNING : Some sectors may not be compressed, it can be determined only - // by comparing uncompressed and compressed size !!! - if(dwRawBytesInThisSector < dwBytesInThisSector) - { - int cbOutSector = dwBytesInThisSector; - int cbInSector = dwRawBytesInThisSector; - int nResult = 0; - - // Is the file compressed by Blizzard's multiple compression ? - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS) - { - // Remember the last used compression - hf->dwCompression0 = pbInSector[0]; - - // Decompress the data - if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) - nResult = SCompDecompress2(pbOutSector, &cbOutSector, pbInSector, cbInSector); - else - nResult = SCompDecompress(pbOutSector, &cbOutSector, pbInSector, cbInSector); - } - - // Is the file compressed by PKWARE Data Compression Library ? - else if(pFileEntry->dwFlags & MPQ_FILE_IMPLODE) - { - nResult = SCompExplode(pbOutSector, &cbOutSector, pbInSector, cbInSector); - } - - // Did the decompression fail ? - if(nResult == 0) - { - nError = ERROR_FILE_CORRUPT; + nError = ERROR_UNKNOWN_FILE_KEY; break; } } - else + + DecryptMpqBlock(pbInSector, dwRawBytesInThisSector, hf->dwFileKey + dwIndex); + BSWAP_ARRAY32_UNSIGNED(pbInSector, dwRawBytesInThisSector); + } + + // If the file has sector CRC check turned on, perform it + if(hf->bCheckSectorCRCs && hf->SectorChksums != NULL) + { + DWORD dwAdlerExpected = hf->SectorChksums[dwIndex]; + DWORD dwAdlerValue = 0; + + // We can only check sector CRC when it's not zero + // Neither can we check it if it's 0xFFFFFFFF. + if(dwAdlerExpected != 0 && dwAdlerExpected != 0xFFFFFFFF) { - if(pbOutSector != pbInSector) - memcpy(pbOutSector, pbInSector, dwBytesInThisSector); + dwAdlerValue = adler32(0, pbInSector, dwRawBytesInThisSector); + if(dwAdlerValue != dwAdlerExpected) + { + nError = ERROR_CHECKSUM_ERROR; + break; + } + } + } + + // If the sector is really compressed, decompress it. + // WARNING : Some sectors may not be compressed, it can be determined only + // by comparing uncompressed and compressed size !!! + if(dwRawBytesInThisSector < dwBytesInThisSector) + { + int cbOutSector = dwBytesInThisSector; + int cbInSector = dwRawBytesInThisSector; + int nResult = 0; + + // Is the file compressed by Blizzard's multiple compression ? + if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS) + { + if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) + nResult = SCompDecompress2((char *)pbOutSector, &cbOutSector, (char *)pbInSector, cbInSector); + else + nResult = SCompDecompress((char *)pbOutSector, &cbOutSector, (char *)pbInSector, cbInSector); } - // Move pointers - dwBytesToRead -= dwBytesInThisSector; - dwByteOffset += dwBytesInThisSector; - dwBytesRead += dwBytesInThisSector; - pbOutSector += dwBytesInThisSector; - pbInSector += dwRawBytesInThisSector; - dwSectorsDone++; + // Is the file compressed by PKWARE Data Compression Library ? + else if(pFileEntry->dwFlags & MPQ_FILE_IMPLODE) + { + nResult = SCompExplode((char *)pbOutSector, &cbOutSector, (char *)pbInSector, cbInSector); + } + + // Did the decompression fail ? + if(nResult == 0) + { + nError = ERROR_FILE_CORRUPT; + break; + } } - } - else - { - nError = GetLastError(); + else + { + if(pbOutSector != pbInSector) + memcpy(pbOutSector, pbInSector, dwBytesInThisSector); + } + + // Move pointers + dwBytesToRead -= dwBytesInThisSector; + dwByteOffset += dwBytesInThisSector; + dwBytesRead += dwBytesInThisSector; + pbOutSector += dwBytesInThisSector; + pbInSector += dwRawBytesInThisSector; + dwSectorsDone++; } // Free all used buffers if(pbRawSector != NULL) STORM_FREE(pbRawSector); - + // Give the caller thenumber of bytes read *pdwBytesRead = dwBytesRead; - return nError; + return nError; } static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) @@ -224,27 +319,27 @@ static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos TMPQArchive * ha = hf->ha; TFileEntry * pFileEntry = hf->pFileEntry; LPBYTE pbCompressed = NULL; - LPBYTE pbRawData; + LPBYTE pbRawData = NULL; int nError = ERROR_SUCCESS; // If the file buffer is not allocated yet, do it. if(hf->pbFileSector == NULL) { nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS || hf->pbFileSector == NULL) + if(nError != ERROR_SUCCESS) return nError; + pbRawData = hf->pbFileSector; } // If the file is a patch file, adjust raw data offset if(hf->pPatchInfo != NULL) RawFilePos += hf->pPatchInfo->dwLength; - pbRawData = hf->pbFileSector; // If the file sector is not loaded yet, do it if(hf->dwSectorOffs != 0) { // Is the file compressed? - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) + if(pFileEntry->dwFlags & MPQ_FILE_COMPRESSED) { // Allocate space for compressed data pbCompressed = STORM_ALLOC(BYTE, pFileEntry->dwCmpSize); @@ -252,7 +347,7 @@ static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos return ERROR_NOT_ENOUGH_MEMORY; pbRawData = pbCompressed; } - + // Load the raw (compressed, encrypted) data if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, pFileEntry->dwCmpSize)) { @@ -269,7 +364,7 @@ static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos } // If the file is compressed, we have to decompress it now - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) + if(pFileEntry->dwFlags & MPQ_FILE_COMPRESSED) { int cbOutBuffer = (int)hf->dwDataSize; int cbInBuffer = (int)pFileEntry->dwCmpSize; @@ -285,7 +380,7 @@ static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos // -------------------------------------- ---------- -------- -------- --------------- // esES\DBFilesClient\LightSkyBox.dbc 0xBE->0xA2 0xBC 0xBC Yes // deDE\DBFilesClient\MountCapability.dbc 0x93->0x77 0x77 0x77 No - // + // if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) cbInBuffer = cbInBuffer - sizeof(TPatchInfo); @@ -293,121 +388,20 @@ static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos // Is the file compressed by Blizzard's multiple compression ? if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS) { - // Remember the last used compression - hf->dwCompression0 = pbRawData[0]; - - // Decompress the file if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) - nResult = SCompDecompress2(hf->pbFileSector, &cbOutBuffer, pbRawData, cbInBuffer); + nResult = SCompDecompress2((char *)hf->pbFileSector, &cbOutBuffer, (char *)pbRawData, cbInBuffer); else - nResult = SCompDecompress(hf->pbFileSector, &cbOutBuffer, pbRawData, cbInBuffer); + nResult = SCompDecompress((char *)hf->pbFileSector, &cbOutBuffer, (char *)pbRawData, cbInBuffer); } // Is the file compressed by PKWARE Data Compression Library ? // Note: Single unit files compressed with IMPLODE are not supported by Blizzard else if(pFileEntry->dwFlags & MPQ_FILE_IMPLODE) - nResult = SCompExplode(hf->pbFileSector, &cbOutBuffer, pbRawData, cbInBuffer); + nResult = SCompExplode((char *)hf->pbFileSector, &cbOutBuffer, (char *)pbRawData, cbInBuffer); nError = (nResult != 0) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; } else - { - if(hf->pbFileSector != NULL && pbRawData != hf->pbFileSector) - memcpy(hf->pbFileSector, pbRawData, hf->dwDataSize); - } - - // Free the decompression buffer. - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); - - // The file sector is now properly loaded - hf->dwSectorOffs = 0; - } - - // At this moment, we have the file loaded into the file buffer. - // Copy as much as the caller wants - if(nError == ERROR_SUCCESS && hf->dwSectorOffs == 0) - { - // File position is greater or equal to file size ? - if(dwFilePos >= hf->dwDataSize) - { - *pdwBytesRead = 0; - return ERROR_SUCCESS; - } - - // If not enough bytes remaining in the file, cut them - if((hf->dwDataSize - dwFilePos) < dwToRead) - dwToRead = (hf->dwDataSize - dwFilePos); - - // Copy the bytes - memcpy(pvBuffer, hf->pbFileSector + dwFilePos, dwToRead); - - // Give the number of bytes read - *pdwBytesRead = dwToRead; - return ERROR_SUCCESS; - } - - // An error, sorry - return ERROR_CAN_NOT_COMPLETE; -} - -static int ReadMpkFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) -{ - ULONGLONG RawFilePos = hf->RawFilePos + 0x0C; // For some reason, MPK files start at position (hf->RawFilePos + 0x0C) - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - LPBYTE pbCompressed = NULL; - LPBYTE pbRawData = hf->pbFileSector; - int nError = ERROR_SUCCESS; - - // We do not support patch files in MPK archives - assert(hf->pPatchInfo == NULL); - - // If the file buffer is not allocated yet, do it. - if(hf->pbFileSector == NULL) - { - nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS || hf->pbFileSector == NULL) - return nError; - pbRawData = hf->pbFileSector; - } - - // If the file sector is not loaded yet, do it - if(hf->dwSectorOffs != 0) - { - // Is the file compressed? - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - // Allocate space for compressed data - pbCompressed = STORM_ALLOC(BYTE, pFileEntry->dwCmpSize); - if(pbCompressed == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - pbRawData = pbCompressed; - } - - // Load the raw (compressed, encrypted) data - if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, pFileEntry->dwCmpSize)) - { - STORM_FREE(pbCompressed); - return GetLastError(); - } - - // If the file is encrypted, we have to decrypt the data first - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - DecryptMpkTable(pbRawData, pFileEntry->dwCmpSize); - } - - // If the file is compressed, we have to decompress it now - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - int cbOutBuffer = (int)hf->dwDataSize; - - hf->dwCompression0 = pbRawData[0]; - if(!SCompDecompressMpk(hf->pbFileSector, &cbOutBuffer, pbRawData, (int)pFileEntry->dwCmpSize)) - nError = ERROR_FILE_CORRUPT; - } - else { if(pbRawData != hf->pbFileSector) memcpy(hf->pbFileSector, pbRawData, hf->dwDataSize); @@ -448,8 +442,7 @@ static int ReadMpkFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos return ERROR_CAN_NOT_COMPLETE; } - -static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwBytesToRead, LPDWORD pdwBytesRead) +static int ReadMpqFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwBytesToRead, LPDWORD pdwBytesRead) { TMPQArchive * ha = hf->ha; LPBYTE pbBuffer = (BYTE *)pvBuffer; @@ -477,7 +470,7 @@ static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos if(hf->pbFileSector == NULL) { nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS || hf->pbFileSector == NULL) + if(nError != ERROR_SUCCESS) return nError; } @@ -486,7 +479,7 @@ static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos { DWORD dwBytesInSector = ha->dwSectorSize; DWORD dwBufferOffs = dwFilePos & dwSectorSizeMask; - DWORD dwToCopy; + DWORD dwToCopy; // Is the file sector already loaded ? if(hf->dwSectorOffs != dwFileSectorPos) @@ -560,7 +553,7 @@ static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos // Copy the data from the cached last sector to the caller's buffer memcpy(pbBuffer, hf->pbFileSector, dwToCopy); - + // Update pointers dwTotalBytesRead += dwToCopy; } @@ -572,34 +565,34 @@ static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos static int ReadMpqFilePatchFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) { - TMPQPatcher Patcher; DWORD dwBytesToRead = dwToRead; DWORD dwBytesRead = 0; int nError = ERROR_SUCCESS; // Make sure that the patch file is loaded completely - if(nError == ERROR_SUCCESS && hf->pbFileData == NULL) + if(hf->pbFileData == NULL) { - // Initialize patching process and allocate data - nError = Patch_InitPatcher(&Patcher, hf); - if(nError != ERROR_SUCCESS) - return nError; + // Load the original file and store its content to "pbOldData" + hf->pbFileData = STORM_ALLOC(BYTE, hf->pFileEntry->dwFileSize); + hf->cbFileData = hf->pFileEntry->dwFileSize; + if(hf->pbFileData == NULL) + return ERROR_NOT_ENOUGH_MEMORY; - // Set the current data size - Patcher.cbFileData = hf->pFileEntry->dwFileSize; - - // Initialize the patcher object with initial file data + // Read the file data if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) - nError = ReadMpqFileSingleUnit(hf, Patcher.pbFileData1, 0, Patcher.cbFileData, &dwBytesRead); + nError = ReadMpqFileSingleUnit(hf, hf->pbFileData, 0, hf->cbFileData, &dwBytesRead); else - nError = ReadMpqFileSectorFile(hf, Patcher.pbFileData1, 0, Patcher.cbFileData, &dwBytesRead); + nError = ReadMpqFile(hf, hf->pbFileData, 0, hf->cbFileData, &dwBytesRead); - // Perform the patching process + // Fix error code + if(nError == ERROR_SUCCESS && dwBytesRead != hf->cbFileData) + nError = ERROR_FILE_CORRUPT; + + // Patch the file data if(nError == ERROR_SUCCESS) - nError = Patch_Process(&Patcher, hf); + nError = PatchFileData(hf); - // Finalize the patcher structure - Patch_Finalize(&Patcher); + // Reset number of bytes read to zero dwBytesRead = 0; } @@ -627,38 +620,6 @@ static int ReadMpqFilePatchFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, return nError; } -static int ReadMpqFileLocalFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) -{ - ULONGLONG FilePosition1 = dwFilePos; - ULONGLONG FilePosition2; - DWORD dwBytesRead = 0; - int nError = ERROR_SUCCESS; - - assert(hf->pStream != NULL); - - // Because stream I/O functions are designed to read - // "all or nothing", we compare file position before and after, - // and if they differ, we assume that number of bytes read - // is the difference between them - - if(!FileStream_Read(hf->pStream, &FilePosition1, pvBuffer, dwToRead)) - { - // If not all bytes have been read, then return the number of bytes read - if((nError = GetLastError()) == ERROR_HANDLE_EOF) - { - FileStream_GetPos(hf->pStream, &FilePosition2); - dwBytesRead = (DWORD)(FilePosition2 - FilePosition1); - } - } - else - { - dwBytesRead = dwToRead; - } - - *pdwBytesRead = dwBytesRead; - return nError; -} - //----------------------------------------------------------------------------- // SFileReadFile @@ -668,12 +629,11 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD DWORD dwBytesRead = 0; // Number of bytes read int nError = ERROR_SUCCESS; - // Always zero the result - if(pdwRead != NULL) - *pdwRead = 0; + // Keep compilers happy + lpOverlapped = lpOverlapped; // Check valid parameters - if(!IsValidFileHandle(hFile)) + if(!IsValidFileHandle(hf)) { SetLastError(ERROR_INVALID_HANDLE); return false; @@ -685,52 +645,60 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD return false; } - // If we didn't load the patch info yet, do it now - if(hf->pFileEntry != NULL && (hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) && hf->pPatchInfo == NULL) - { - nError = AllocatePatchInfo(hf, true); - if(nError != ERROR_SUCCESS || hf->pPatchInfo == NULL) - { - SetLastError(nError); - return false; - } - } - - // Clear the last used compression - hf->dwCompression0 = 0; - // If the file is local file, read the data directly from the stream if(hf->pStream != NULL) { - nError = ReadMpqFileLocalFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } + ULONGLONG FilePosition1; + ULONGLONG FilePosition2; - // If the file is a patch file, we have to read it special way - else if(hf->hfPatch != NULL && (hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) - { - nError = ReadMpqFilePatchFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } + // Because stream I/O functions are designed to read + // "all or nothing", we compare file position before and after, + // and if they differ, we assume that number of bytes read + // is the difference between them - // If the archive is a MPK archive, we need special way to read the file - else if(hf->ha->dwSubType == MPQ_SUBTYPE_MPK) - { - nError = ReadMpkFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); + FileStream_GetPos(hf->pStream, &FilePosition1); + if(!FileStream_Read(hf->pStream, NULL, pvBuffer, dwToRead)) + { + // If not all bytes have been read, then return the number + // of bytes read + if((nError = GetLastError()) == ERROR_HANDLE_EOF) + { + FileStream_GetPos(hf->pStream, &FilePosition2); + dwBytesRead = (DWORD)(FilePosition2 - FilePosition1); + } + else + { + nError = GetLastError(); + } + } + else + { + dwBytesRead = dwToRead; + } } - - // If the file is single unit file, redirect it to read file - else if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) - { - nError = ReadMpqFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } - - // Otherwise read it as sector based MPQ file else - { - nError = ReadMpqFileSectorFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } + { + // If the file is a patch file, we have to read it special way + if(hf->hfPatchFile != NULL && (hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) + { + nError = ReadMpqFilePatchFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); + } - // Increment the file position - hf->dwFilePos += dwBytesRead; + // If the file is single unit file, redirect it to read file + else if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) + { + nError = ReadMpqFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); + } + + // Otherwise read it as sector based MPQ file + else + { + nError = ReadMpqFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); + } + + // Increment the file position + hf->dwFilePos += dwBytesRead; + } // Give the caller the number of bytes read if(pdwRead != NULL) @@ -756,13 +724,13 @@ DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh) TMPQFile * hf = (TMPQFile *)hFile; // Validate the file handle before we go on - if(IsValidFileHandle(hFile)) + if(IsValidFileHandle(hf)) { // Make sure that the variable is initialized FileSize = 0; // If the file is patched file, we have to get the size of the last version - if(hf->hfPatch != NULL) + if(hf->hfPatchFile != NULL) { // Walk through the entire patch chain, take the last version while(hf != NULL) @@ -771,7 +739,7 @@ DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh) FileSize = hf->pFileEntry->dwFileSize; // Move to the next patch file in the hierarchy - hf = hf->hfPatch; + hf = hf->hfPatchFile; } } else @@ -800,99 +768,419 @@ DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh) DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod) { TMPQFile * hf = (TMPQFile *)hFile; - ULONGLONG OldPosition; - ULONGLONG NewPosition; - ULONGLONG FileSize; - ULONGLONG DeltaPos; + ULONGLONG FilePosition; + ULONGLONG MoveOffset; + DWORD dwFilePosHi; // If the hFile is not a valid file handle, return an error. - if(!IsValidFileHandle(hFile)) + if(!IsValidFileHandle(hf)) { SetLastError(ERROR_INVALID_HANDLE); return SFILE_INVALID_POS; } - // Retrieve the file size for handling the limits - if(hf->pStream != NULL) - { - FileStream_GetSize(hf->pStream, &FileSize); - } - else - { - FileSize = SFileGetFileSize(hFile, NULL); - } - - // Handle the NULL and non-NULL values of plFilePosHigh - // Non-NULL: The DeltaPos is combined from lFilePos and *lpFilePosHigh - // NULL: The DeltaPos is sign-extended value of lFilePos - DeltaPos = (plFilePosHigh != NULL) ? MAKE_OFFSET64(plFilePosHigh[0], lFilePos) : (ULONGLONG)(LONGLONG)lFilePos; - // Get the relative point where to move from switch(dwMoveMethod) { - case FILE_BEGIN: + case FILE_BEGIN: + FilePosition = 0; + break; - // Move relative to the file begin. - OldPosition = 0; - break; - - case FILE_CURRENT: - - // Retrieve the current file position - if(hf->pStream != NULL) - { - FileStream_GetPos(hf->pStream, &OldPosition); - } - else - { - OldPosition = hf->dwFilePos; - } - break; - - case FILE_END: - - // Move relative to the end of the file - OldPosition = FileSize; - break; - - default: - SetLastError(ERROR_INVALID_PARAMETER); - return SFILE_INVALID_POS; - } - - // Calculate the new position - NewPosition = OldPosition + DeltaPos; - - // If moving backward, don't allow the new position go negative - if((LONGLONG)DeltaPos < 0) - { - if(NewPosition > FileSize) // Position is negative + case FILE_CURRENT: + if(hf->pStream != NULL) { - SetLastError(ERROR_NEGATIVE_SEEK); - return SFILE_INVALID_POS; + FileStream_GetPos(hf->pStream, &FilePosition); } + else + { + FilePosition = hf->dwFilePos; + } + break; + + case FILE_END: + if(hf->pStream != NULL) + { + FileStream_GetSize(hf->pStream, &FilePosition); + } + else + { + FilePosition = SFileGetFileSize(hFile, NULL); + } + break; + + default: + SetLastError(ERROR_INVALID_PARAMETER); + return SFILE_INVALID_POS; } - // If moving forward, don't allow the new position go past the end of the file + // Now get the move offset. Note that both values form + // a signed 64-bit value (a file pointer can be moved backwards) + if(plFilePosHigh != NULL) + dwFilePosHi = *plFilePosHigh; else - { - if(NewPosition > FileSize) - NewPosition = FileSize; - } + dwFilePosHi = (lFilePos & 0x80000000) ? 0xFFFFFFFF : 0; + MoveOffset = MAKE_OFFSET64(dwFilePosHi, lFilePos); + + // Now calculate the new file pointer + // Do not allow the file pointer to go before the begin of the file + FilePosition += MoveOffset; + if(FilePosition < 0) + FilePosition = 0; // Now apply the file pointer to the file if(hf->pStream != NULL) { - if(!FileStream_Read(hf->pStream, &NewPosition, NULL, 0)) + // Apply the new file position + if(!FileStream_Read(hf->pStream, &FilePosition, NULL, 0)) return SFILE_INVALID_POS; + + // Return the new file position + if(plFilePosHigh != NULL) + *plFilePosHigh = (LONG)(FilePosition >> 32); + return (DWORD)FilePosition; } else { - hf->dwFilePos = (DWORD)NewPosition; + // Files in MPQ can't be bigger than 4 GB. + // We don't allow to go past 4 GB + if(FilePosition >> 32) + { + SetLastError(ERROR_INVALID_PARAMETER); + return SFILE_INVALID_POS; + } + + // Change the file position + hf->dwFilePos = (DWORD)FilePosition; + + // Return the new file position + if(plFilePosHigh != NULL) + *plFilePosHigh = 0; + return (DWORD)FilePosition; + } +} + +//----------------------------------------------------------------------------- +// Tries to retrieve the file name + +static TFileHeader2Ext data2ext[] = +{ + {0x00005A4D, 0x0000FFFF, 0x00000000, 0x00000000, "exe"}, // EXE files + {0x00000006, 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, "dc6"}, // EXE files + {0x1A51504D, 0xFFFFFFFF, 0x00000000, 0x00000000, "mpq"}, // MPQ archive header ID ('MPQ\x1A') + {0x46464952, 0xFFFFFFFF, 0x00000000, 0x00000000, "wav"}, // WAVE header 'RIFF' + {0x324B4D53, 0xFFFFFFFF, 0x00000000, 0x00000000, "smk"}, // Old "Smacker Video" files 'SMK2' + {0x694B4942, 0xFFFFFFFF, 0x00000000, 0x00000000, "bik"}, // Bink video files (new) + {0x0801050A, 0xFFFFFFFF, 0x00000000, 0x00000000, "pcx"}, // PCX images used in Diablo I + {0x544E4F46, 0xFFFFFFFF, 0x00000000, 0x00000000, "fnt"}, // Font files used in Diablo II + {0x6D74683C, 0xFFFFFFFF, 0x00000000, 0x00000000, "html"}, // HTML 'pFileEntry; + + // Only do something if the file name is not filled + if(nError == ERROR_SUCCESS && pFileEntry != NULL && pFileEntry->szFileName == NULL) + { + // Read the first 2 DWORDs bytes from the file + FirstBytes[0] = FirstBytes[1] = 0; + dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT); + SFileReadFile(hFile, FirstBytes, sizeof(FirstBytes), NULL, NULL); + BSWAP_ARRAY32_UNSIGNED(FirstBytes, sizeof(FirstBytes)); + SFileSetFilePointer(hf, dwFilePos, NULL, FILE_BEGIN); + + // Try to guess file extension from those 2 DWORDs + for(i = 0; data2ext[i].szExt != NULL; i++) + { + if((FirstBytes[0] & data2ext[i].dwOffset00Mask) == data2ext[i].dwOffset00Data && + (FirstBytes[1] & data2ext[i].dwOffset04Mask) == data2ext[i].dwOffset04Data) + { + sprintf(szPseudoName, "File%08u.%s", (unsigned int)(pFileEntry - hf->ha->pFileTable), data2ext[i].szExt); + break; + } + } + + // Put the file name to the file table + AllocateFileName(pFileEntry, szPseudoName); } - // Return the new file position - if(plFilePosHigh != NULL) - *plFilePosHigh = (LONG)(NewPosition >> 32); - return (DWORD)NewPosition; + // Now put the file name to the file structure + if(nError == ERROR_SUCCESS && szFileName != NULL) + { + if(pFileEntry != NULL && pFileEntry->szFileName != NULL) + strcpy(szFileName, pFileEntry->szFileName); + else if(hf->pStream != NULL) + CopyFileName(szFileName, FileStream_GetFileName(hf->pStream)); + } + return (nError == ERROR_SUCCESS); +} + +//----------------------------------------------------------------------------- +// Retrieves an information about an archive or about a file within the archive +// +// hMpqOrFile - Handle to an MPQ archive or to a file +// dwInfoType - Information to obtain + +#define VERIFY_MPQ_HANDLE(h) \ + if(!IsValidMpqHandle(h)) \ +{ \ + nError = ERROR_INVALID_HANDLE; \ + break; \ + } + +#define VERIFY_FILE_HANDLE(h) \ + if(!IsValidFileHandle(h)) \ +{ \ + nError = ERROR_INVALID_HANDLE; \ + break; \ + } + +bool WINAPI SFileGetFileInfo( + HANDLE hMpqOrFile, + DWORD dwInfoType, + void * pvFileInfo, + DWORD cbFileInfo, + LPDWORD pcbLengthNeeded) +{ + TMPQArchive * ha = (TMPQArchive *)hMpqOrFile; + TMPQBlock * pBlock; + TMPQFile * hf = (TMPQFile *)hMpqOrFile; + void * pvSrcFileInfo = NULL; + DWORD cbLengthNeeded = 0; + DWORD dwIsReadOnly; + DWORD dwFileCount = 0; + DWORD dwFileIndex; + DWORD dwFileKey; + DWORD i; + int nError = ERROR_SUCCESS; + + switch(dwInfoType) + { + case SFILE_INFO_ARCHIVE_NAME: + VERIFY_MPQ_HANDLE(ha); + + // pvFileInfo receives the name of the archive, terminated by 0 + pvSrcFileInfo = FileStream_GetFileName(ha->pStream); + cbLengthNeeded = (DWORD)(_tcslen((TCHAR *)pvSrcFileInfo) + 1) * sizeof(TCHAR); + break; + + case SFILE_INFO_ARCHIVE_SIZE: // Size of the archive + VERIFY_MPQ_HANDLE(ha); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &ha->pHeader->dwArchiveSize; + break; + + case SFILE_INFO_MAX_FILE_COUNT: // Max. number of files in the MPQ + VERIFY_MPQ_HANDLE(ha); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &ha->dwMaxFileCount; + break; + + case SFILE_INFO_HASH_TABLE_SIZE: // Size of the hash table + VERIFY_MPQ_HANDLE(ha); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &ha->pHeader->dwHashTableSize; + break; + + case SFILE_INFO_BLOCK_TABLE_SIZE: // Size of the block table + VERIFY_MPQ_HANDLE(ha); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &ha->pHeader->dwBlockTableSize; + break; + + case SFILE_INFO_SECTOR_SIZE: + VERIFY_MPQ_HANDLE(ha); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &ha->dwSectorSize; + break; + + case SFILE_INFO_HASH_TABLE: + VERIFY_MPQ_HANDLE(ha); + cbLengthNeeded = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); + pvSrcFileInfo = ha->pHashTable; + break; + + case SFILE_INFO_BLOCK_TABLE: + VERIFY_MPQ_HANDLE(ha); + cbLengthNeeded = ha->dwFileTableSize * sizeof(TMPQBlock); + if(cbFileInfo < cbLengthNeeded) + { + nError = ERROR_INSUFFICIENT_BUFFER; + break; + } + + // Construct block table from file table size + pBlock = (TMPQBlock *)pvFileInfo; + for(i = 0; i < ha->dwFileTableSize; i++) + { + pBlock->dwFilePos = (DWORD)ha->pFileTable[i].ByteOffset; + pBlock->dwFSize = ha->pFileTable[i].dwFileSize; + pBlock->dwCSize = ha->pFileTable[i].dwCmpSize; + pBlock->dwFlags = ha->pFileTable[i].dwFlags; + pBlock++; + } + break; + + case SFILE_INFO_NUM_FILES: + VERIFY_MPQ_HANDLE(ha); + dwFileCount = GetMpqFileCount(ha); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &dwFileCount; + break; + + case SFILE_INFO_STREAM_FLAGS: + VERIFY_MPQ_HANDLE(ha); + FileStream_GetFlags(ha->pStream, &dwFileKey); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &dwFileKey; + break; + + case SFILE_INFO_IS_READ_ONLY: + VERIFY_MPQ_HANDLE(ha); + dwIsReadOnly = (FileStream_IsReadOnly(ha->pStream) || (ha->dwFlags & MPQ_FLAG_READ_ONLY)); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &dwIsReadOnly; + break; + + case SFILE_INFO_HASH_INDEX: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &hf->pFileEntry->dwHashIndex; + break; + + case SFILE_INFO_CODENAME1: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &hf->pFileEntry->dwHashIndex; + if(ha->pHashTable != NULL) + pvSrcFileInfo = &ha->pHashTable[hf->pFileEntry->dwHashIndex].dwName1; + break; + + case SFILE_INFO_CODENAME2: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + if(ha->pHashTable != NULL) + pvSrcFileInfo = &ha->pHashTable[hf->pFileEntry->dwHashIndex].dwName2; + break; + + case SFILE_INFO_LOCALEID: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &hf->pFileEntry->lcLocale; + break; + + case SFILE_INFO_BLOCKINDEX: + VERIFY_FILE_HANDLE(hf); + dwFileIndex = (DWORD)(hf->pFileEntry - hf->ha->pFileTable); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &dwFileIndex; + break; + + case SFILE_INFO_FILE_SIZE: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &hf->pFileEntry->dwFileSize; + break; + + case SFILE_INFO_COMPRESSED_SIZE: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &hf->pFileEntry->dwCmpSize; + break; + + case SFILE_INFO_FLAGS: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &hf->pFileEntry->dwFlags; + break; + + case SFILE_INFO_POSITION: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(ULONGLONG); + pvSrcFileInfo = &hf->pFileEntry->ByteOffset; + break; + + case SFILE_INFO_KEY: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &hf->dwFileKey; + break; + + case SFILE_INFO_KEY_UNFIXED: + VERIFY_FILE_HANDLE(hf); + dwFileKey = hf->dwFileKey; + if(hf->pFileEntry->dwFlags & MPQ_FILE_FIX_KEY) + dwFileKey = (dwFileKey ^ hf->pFileEntry->dwFileSize) - (DWORD)hf->MpqFilePos; + cbLengthNeeded = sizeof(DWORD); + pvSrcFileInfo = &dwFileKey; + break; + + case SFILE_INFO_FILETIME: + VERIFY_FILE_HANDLE(hf); + cbLengthNeeded = sizeof(ULONGLONG); + pvSrcFileInfo = &hf->pFileEntry->FileTime; + break; + + case SFILE_INFO_PATCH_CHAIN: + VERIFY_FILE_HANDLE(hf); + GetFilePatchChain(hf, pvFileInfo, cbFileInfo, &cbLengthNeeded); + break; + + default: + nError = ERROR_INVALID_PARAMETER; + break; + } + + // If everything is OK so far, copy the information + if(nError == ERROR_SUCCESS) + { + // Is the output buffer large enough? + if(cbFileInfo >= cbLengthNeeded) + { + // Copy the data + if(pvSrcFileInfo != NULL) + memcpy(pvFileInfo, pvSrcFileInfo, cbLengthNeeded); + } + else + { + nError = ERROR_INSUFFICIENT_BUFFER; + } + + // Give the size to the caller + if(pcbLengthNeeded != NULL) + *pcbLengthNeeded = cbLengthNeeded; + } + + // Set the last error value, if needed + if(nError != ERROR_SUCCESS) + SetLastError(nError); + return (nError == ERROR_SUCCESS); } diff --git a/dep/StormLib/src/SFileVerify.cpp b/dep/StormLib/src/SFileVerify.cpp index 0248b9136..8344480ef 100644 --- a/dep/StormLib/src/SFileVerify.cpp +++ b/dep/StormLib/src/SFileVerify.cpp @@ -20,83 +20,89 @@ //----------------------------------------------------------------------------- // Local defines +#define SIGNATURE_TYPE_NONE 0 +#define SIGNATURE_TYPE_WEAK 1 +#define SIGNATURE_TYPE_STRONG 2 + #define MPQ_DIGEST_UNIT_SIZE 0x10000 +typedef struct _MPQ_SIGNATURE_INFO +{ + ULONGLONG BeginMpqData; // File offset where the hashing starts + ULONGLONG BeginExclude; // Begin of the excluded area (used for (signature) file) + ULONGLONG EndExclude; // End of the excluded area (used for (signature) file) + ULONGLONG EndMpqData; // File offset where the hashing ends + ULONGLONG EndOfFile; // Size of the entire file + BYTE Signature[MPQ_STRONG_SIGNATURE_SIZE + 0x10]; + DWORD cbSignatureSize; // Length of the signature + int nSignatureType; // See SIGNATURE_TYPE_XXX + +} MPQ_SIGNATURE_INFO, *PMPQ_SIGNATURE_INFO; + //----------------------------------------------------------------------------- // Known Blizzard public keys // Created by Jean-Francois Roy using OpenSSL -static const char * szBlizzardWeakPrivateKey = - "-----BEGIN PRIVATE KEY-----" - "MIIBOQIBAAJBAJJidwS/uILMBSO5DLGsBFknIXWWjQJe2kfdfEk3G/j66w4KkhZ1" - "V61Rt4zLaMVCYpDun7FLwRjkMDSepO1q2DcCAwEAAQJANtiztVDMJh2hE1hjPDKy" - "UmEJ9U/aN3gomuKOjbQbQ/bWWcM/WfhSVHmPqtqh/bQI2UXFr0rnXngeteZHLr/b" - "8QIhAMuWriSKGMACw18/rVVfUrThs915odKBH1Alr3vMVVzZAiEAuBHPSQkgwcb6" - "L4MWaiKuOzq08mSyNqPeN8oSy18q848CIHeMn+3s+eOmu7su1UYQl6yH7OrdBd1q" - "3UxfFNEJiAbhAiAqxdCyOxHGlbM7aS3DOg3cq5ayoN2cvtV7h1R4t8OmVwIgF+5z" - "/6vkzBUsZhd8Nwyis+MeQYH0rpFpMKdTlqmPF2Q=" - "-----END PRIVATE KEY-----"; - static const char * szBlizzardWeakPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJJidwS/uILMBSO5DLGsBFknIXWWjQJe" - "2kfdfEk3G/j66w4KkhZ1V61Rt4zLaMVCYpDun7FLwRjkMDSepO1q2DcCAwEAAQ==" - "-----END PUBLIC KEY-----"; + "-----BEGIN PUBLIC KEY-----" + "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJJidwS/uILMBSO5DLGsBFknIXWWjQJe" + "2kfdfEk3G/j66w4KkhZ1V61Rt4zLaMVCYpDun7FLwRjkMDSepO1q2DcCAwEAAQ==" + "-----END PUBLIC KEY-----"; static const char * szBlizzardStrongPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsQZ+ziT2h8h+J/iMQpgd" - "tH1HaJzOBE3agjU4yMPcrixaPOZoA4t8bwfey7qczfWywocYo3pleytFF+IuD4HD" - "Fl9OXN1SFyupSgMx1EGZlgbFAomnbq9MQJyMqQtMhRAjFgg4TndS7YNb+JMSAEKp" - "kXNqY28n/EVBHD5TsMuVCL579gIenbr61dI92DDEdy790IzIG0VKWLh/KOTcTJfm" - "Ds/7HQTkGouVW+WUsfekuqNQo7ND9DBnhLjLjptxeFE2AZqYcA1ao3S9LN3GL1tW" - "lVXFIX9c7fWqaVTQlZ2oNsI/ARVApOK3grNgqvwH6YoVYVXjNJEo5sQJsPsdV/hk" - "dwIDAQAB" - "-----END PUBLIC KEY-----"; + "-----BEGIN PUBLIC KEY-----" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsQZ+ziT2h8h+J/iMQpgd" + "tH1HaJzOBE3agjU4yMPcrixaPOZoA4t8bwfey7qczfWywocYo3pleytFF+IuD4HD" + "Fl9OXN1SFyupSgMx1EGZlgbFAomnbq9MQJyMqQtMhRAjFgg4TndS7YNb+JMSAEKp" + "kXNqY28n/EVBHD5TsMuVCL579gIenbr61dI92DDEdy790IzIG0VKWLh/KOTcTJfm" + "Ds/7HQTkGouVW+WUsfekuqNQo7ND9DBnhLjLjptxeFE2AZqYcA1ao3S9LN3GL1tW" + "lVXFIX9c7fWqaVTQlZ2oNsI/ARVApOK3grNgqvwH6YoVYVXjNJEo5sQJsPsdV/hk" + "dwIDAQAB" + "-----END PUBLIC KEY-----"; static const char * szWarcraft3MapPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1BwklUUQ3UvjizOBRoF5" - "yyOVc7KD+oGOQH5i6eUk1yfs0luCC70kNucNrfqhmviywVtahRse1JtXCPrx2bd3" - "iN8Dx91fbkxjYIOGTsjYoHKTp0BbaFkJih776fcHgnFSb+7mJcDuJVvJOXxEH6w0" - "1vo6VtujCqj1arqbyoal+xtAaczF3us5cOEp45sR1zAWTn1+7omN7VWV4QqJPaDS" - "gBSESc0l1grO0i1VUSumayk7yBKIkb+LBvcG6WnYZHCi7VdLmaxER5m8oZfER66b" - "heHoiSQIZf9PAY6Guw2DT5BTc54j/AaLQAKf2qcRSgQLVo5kQaddF3rCpsXoB/74" - "6QIDAQAB" - "-----END PUBLIC KEY-----"; + "-----BEGIN PUBLIC KEY-----" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1BwklUUQ3UvjizOBRoF5" + "yyOVc7KD+oGOQH5i6eUk1yfs0luCC70kNucNrfqhmviywVtahRse1JtXCPrx2bd3" + "iN8Dx91fbkxjYIOGTsjYoHKTp0BbaFkJih776fcHgnFSb+7mJcDuJVvJOXxEH6w0" + "1vo6VtujCqj1arqbyoal+xtAaczF3us5cOEp45sR1zAWTn1+7omN7VWV4QqJPaDS" + "gBSESc0l1grO0i1VUSumayk7yBKIkb+LBvcG6WnYZHCi7VdLmaxER5m8oZfER66b" + "heHoiSQIZf9PAY6Guw2DT5BTc54j/AaLQAKf2qcRSgQLVo5kQaddF3rCpsXoB/74" + "6QIDAQAB" + "-----END PUBLIC KEY-----"; static const char * szWowPatchPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwOsMV0LagAWPEtEQM6b9" - "6FHFkUyGbbyda2/Dfc9dyl21E9QvX+Yw7qKRMAKPzA2TlQQLZKvXpnKXF/YIK5xa" - "5uwg9CEHCEAYolLG4xn0FUOE0E/0PuuytI0p0ICe6rk00PifZzTr8na2wI/l/GnQ" - "bvnIVF1ck6cslATpQJ5JJVMXzoFlUABS19WESw4MXuJAS3AbMhxNWdEhVv7eO51c" - "yGjRLy9QjogZODZTY0fSEksgBqQxNCoYVJYI/sF5K2flDsGqrIp0OdJ6teJlzg1Y" - "UjYnb6bKjlidXoHEXI2TgA/mD6O3XFIt08I9s3crOCTgICq7cgX35qrZiIVWZdRv" - "TwIDAQAB" - "-----END PUBLIC KEY-----"; + "-----BEGIN PUBLIC KEY-----" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwOsMV0LagAWPEtEQM6b9" + "6FHFkUyGbbyda2/Dfc9dyl21E9QvX+Yw7qKRMAKPzA2TlQQLZKvXpnKXF/YIK5xa" + "5uwg9CEHCEAYolLG4xn0FUOE0E/0PuuytI0p0ICe6rk00PifZzTr8na2wI/l/GnQ" + "bvnIVF1ck6cslATpQJ5JJVMXzoFlUABS19WESw4MXuJAS3AbMhxNWdEhVv7eO51c" + "yGjRLy9QjogZODZTY0fSEksgBqQxNCoYVJYI/sF5K2flDsGqrIp0OdJ6teJlzg1Y" + "UjYnb6bKjlidXoHEXI2TgA/mD6O3XFIt08I9s3crOCTgICq7cgX35qrZiIVWZdRv" + "TwIDAQAB" + "-----END PUBLIC KEY-----"; static const char * szWowSurveyPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnIt1DR6nRyyKsy2qahHe" - "MKLtacatn/KxieHcwH87wLBxKy+jZ0gycTmJ7SaTdBAEMDs/V5IPIXEtoqYnid2c" - "63TmfGDU92oc3Ph1PWUZ2PWxBhT06HYxRdbrgHw9/I29pNPi/607x+lzPORITOgU" - "BR6MR8au8HsQP4bn4vkJNgnSgojh48/XQOB/cAln7As1neP61NmVimoLR4Bwi3zt" - "zfgrZaUpyeNCUrOYJmH09YIjbBySTtXOUidoPHjFrMsCWpr6xs8xbETbs7MJFL6a" - "vcUfTT67qfIZ9RsuKfnXJTIrV0kwDSjjuNXiPTmWAehSsiHIsrUXX5RNcwsSjClr" - "nQIDAQAB" - "-----END PUBLIC KEY-----"; + "-----BEGIN PUBLIC KEY-----" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnIt1DR6nRyyKsy2qahHe" + "MKLtacatn/KxieHcwH87wLBxKy+jZ0gycTmJ7SaTdBAEMDs/V5IPIXEtoqYnid2c" + "63TmfGDU92oc3Ph1PWUZ2PWxBhT06HYxRdbrgHw9/I29pNPi/607x+lzPORITOgU" + "BR6MR8au8HsQP4bn4vkJNgnSgojh48/XQOB/cAln7As1neP61NmVimoLR4Bwi3zt" + "zfgrZaUpyeNCUrOYJmH09YIjbBySTtXOUidoPHjFrMsCWpr6xs8xbETbs7MJFL6a" + "vcUfTT67qfIZ9RsuKfnXJTIrV0kwDSjjuNXiPTmWAehSsiHIsrUXX5RNcwsSjClr" + "nQIDAQAB" + "-----END PUBLIC KEY-----"; static const char * szStarcraft2MapPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmk4GT8zb+ICC25a17KZB" - "q/ygKGJ2VSO6IT5PGHJlm1KfnHBA4B6SH3xMlJ4c6eG2k7QevZv+FOhjsAHubyWq" - "2VKqWbrIFKv2ILc2RfMn8J9EDVRxvcxh6slRrVL69D0w1tfVGjMiKq2Fym5yGoRT" - "E7CRgDqbAbXP9LBsCNWHiJLwfxMGzHbk8pIl9oia5pvM7ofZamSHchxlpy6xa4GJ" - "7xKN01YCNvklTL1D7uol3wkwcHc7vrF8QwuJizuA5bSg4poEGtH62BZOYi+UL/z0" - "31YK+k9CbQyM0X0pJoJoYz1TK+Y5J7vBnXCZtfcTYQ/ZzN6UcxTa57dJaiOlCh9z" - "nQIDAQAB" - "-----END PUBLIC KEY-----"; + "-----BEGIN PUBLIC KEY-----" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmk4GT8zb+ICC25a17KZB" + "q/ygKGJ2VSO6IT5PGHJlm1KfnHBA4B6SH3xMlJ4c6eG2k7QevZv+FOhjsAHubyWq" + "2VKqWbrIFKv2ILc2RfMn8J9EDVRxvcxh6slRrVL69D0w1tfVGjMiKq2Fym5yGoRT" + "E7CRgDqbAbXP9LBsCNWHiJLwfxMGzHbk8pIl9oia5pvM7ofZamSHchxlpy6xa4GJ" + "7xKN01YCNvklTL1D7uol3wkwcHc7vrF8QwuJizuA5bSg4poEGtH62BZOYi+UL/z0" + "31YK+k9CbQyM0X0pJoJoYz1TK+Y5J7vBnXCZtfcTYQ/ZzN6UcxTa57dJaiOlCh9z" + "nQIDAQAB" + "-----END PUBLIC KEY-----"; //----------------------------------------------------------------------------- // Local functions @@ -113,6 +119,13 @@ static void memrev(unsigned char *buf, size_t count) } } +static bool is_valid_md5(void * pvMd5) +{ + LPDWORD Md5 = (LPDWORD)pvMd5; + + return (Md5[0] | Md5[1] | Md5[2] | Md5[3]) ? true : false; +} + static bool decode_base64_key(const char * szKeyBase64, rsa_key * key) { unsigned char decoded_key[0x200]; @@ -129,7 +142,7 @@ static bool decode_base64_key(const char * szKeyBase64, rsa_key * key) // decode the base64 string length = (unsigned long)(szBase64End - szBase64Begin); - if(base64_decode(szBase64Begin, length, decoded_key, &decoded_length) != CRYPT_OK) + if(base64_decode((unsigned char *)szBase64Begin, length, decoded_key, &decoded_length) != CRYPT_OK) return false; // Create RSA key @@ -140,10 +153,10 @@ static bool decode_base64_key(const char * szKeyBase64, rsa_key * key) } static void GetPlainAnsiFileName( - const TCHAR * szFileName, - char * szPlainName) + const TCHAR * szFileName, + char * szPlainName) { - const TCHAR * szPlainNameT = GetPlainFileName(szFileName); + const TCHAR * szPlainNameT = GetPlainFileNameT(szFileName); // Convert the plain name to ANSI while(*szPlainNameT != 0) @@ -153,8 +166,8 @@ static void GetPlainAnsiFileName( // Calculate begin and end of the MPQ archive static void CalculateArchiveRange( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) + TMPQArchive * ha, + PMPQ_SIGNATURE_INFO pSI) { ULONGLONG TempPos = 0; char szMapHeader[0x200]; @@ -173,17 +186,71 @@ static void CalculateArchiveRange( } } - // Get the MPQ data end. This is stored in the MPQ header + // Get the MPQ data end. This is stored in our MPQ header, + // and it's been already prepared by SFileOpenArchive, pSI->EndMpqData = ha->MpqPos + ha->pHeader->ArchiveSize64; // Get the size of the entire file FileStream_GetSize(ha->pStream, &pSI->EndOfFile); } +static bool QueryMpqSignatureInfo( + TMPQArchive * ha, + PMPQ_SIGNATURE_INFO pSI) +{ + ULONGLONG ExtraBytes; + TMPQFile * hf; + HANDLE hFile; + DWORD dwFileSize; + + // Calculate the range of the MPQ + CalculateArchiveRange(ha, pSI); + + // If there is "(signature)" file in the MPQ, it has a weak signature + if(SFileOpenFileEx((HANDLE)ha, SIGNATURE_NAME, SFILE_OPEN_FROM_MPQ, &hFile)) + { + // Get the content of the signature + SFileReadFile(hFile, pSI->Signature, sizeof(pSI->Signature), &pSI->cbSignatureSize, NULL); + + // Verify the size of the signature + hf = (TMPQFile *)hFile; + + // We have to exclude the signature file from the digest + pSI->BeginExclude = ha->MpqPos + hf->pFileEntry->ByteOffset; + pSI->EndExclude = pSI->BeginExclude + hf->pFileEntry->dwCmpSize; + dwFileSize = hf->dwDataSize; + + // Close the file + SFileCloseFile(hFile); + pSI->nSignatureType = SIGNATURE_TYPE_WEAK; + return (dwFileSize == (MPQ_WEAK_SIGNATURE_SIZE + 8)) ? true : false; + } + + // If there is extra bytes beyond the end of the archive, + // it's the strong signature + ExtraBytes = pSI->EndOfFile - pSI->EndMpqData; + if(ExtraBytes >= (MPQ_STRONG_SIGNATURE_SIZE + 4)) + { + // Read the strong signature + if(!FileStream_Read(ha->pStream, &pSI->EndMpqData, pSI->Signature, (MPQ_STRONG_SIGNATURE_SIZE + 4))) + return false; + + // Check the signature header "NGIS" + if(pSI->Signature[0] != 'N' || pSI->Signature[1] != 'G' || pSI->Signature[2] != 'I' || pSI->Signature[3] != 'S') + return false; + + pSI->nSignatureType = SIGNATURE_TYPE_STRONG; + return true; + } + + // Succeeded, but no known signature found + return true; +} + static bool CalculateMpqHashMd5( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI, - LPBYTE pMd5Digest) + TMPQArchive * ha, + PMPQ_SIGNATURE_INFO pSI, + LPBYTE pMd5Digest) { hash_state md5_state; ULONGLONG BeginBuffer; @@ -216,7 +283,7 @@ static bool CalculateMpqHashMd5( if(dwToRead == 0) break; - // Read the next chunk + // Read the next chunk if(!FileStream_Read(ha->pStream, &BeginBuffer, pbDigestBuffer, dwToRead)) { STORM_FREE(pbDigestBuffer); @@ -257,18 +324,17 @@ static bool CalculateMpqHashMd5( } static void AddTailToSha1( - hash_state * psha1_state, - const char * szTail) + hash_state * psha1_state, + const char * szTail) { - unsigned char * pbTail = (unsigned char *)szTail; unsigned char szUpperCase[0x200]; unsigned long nLength = 0; // Convert the tail to uppercase // Note that we don't need to terminate the string with zero - while(*pbTail != 0) + while(*szTail != 0) { - szUpperCase[nLength++] = AsciiToUpperTable[*pbTail++]; + szUpperCase[nLength++] = (unsigned char)toupper(*szTail++); } // Append the tail to the SHA1 @@ -276,11 +342,11 @@ static void AddTailToSha1( } static bool CalculateMpqHashSha1( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI, - unsigned char * sha1_tail0, - unsigned char * sha1_tail1, - unsigned char * sha1_tail2) + TMPQArchive * ha, + PMPQ_SIGNATURE_INFO pSI, + unsigned char * sha1_tail0, + unsigned char * sha1_tail1, + unsigned char * sha1_tail2) { ULONGLONG BeginBuffer; hash_state sha1_state_temp; @@ -312,7 +378,7 @@ static bool CalculateMpqHashSha1( if(dwToRead == 0) break; - // Read the next chunk + // Read the next chunk if(!FileStream_Read(ha->pStream, &BeginBuffer, pbDigestBuffer, dwToRead)) { STORM_FREE(pbDigestBuffer); @@ -345,9 +411,9 @@ static bool CalculateMpqHashSha1( } static int VerifyRawMpqData( - TMPQArchive * ha, - ULONGLONG ByteOffset, - DWORD dwDataSize) + TMPQArchive * ha, + ULONGLONG ByteOffset, + DWORD dwDataSize) { ULONGLONG DataOffset = ha->MpqPos + ByteOffset; LPBYTE pbDataChunk; @@ -433,8 +499,8 @@ static int VerifyRawMpqData( } static DWORD VerifyWeakSignature( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) + TMPQArchive * ha, + PMPQ_SIGNATURE_INFO pSI) { BYTE RevSignature[MPQ_WEAK_SIGNATURE_SIZE]; BYTE Md5Digest[MD5_DIGEST_SIZE]; @@ -442,10 +508,6 @@ static DWORD VerifyWeakSignature( int hash_idx = find_hash("md5"); int result = 0; - // The signature might be zeroed out. In that case, we ignore it - if(!IsValidSignature(pSI->Signature)) - return ERROR_WEAK_SIGNATURE_OK; - // Calculate hash of the entire archive, skipping the (signature) file if(!CalculateMpqHashMd5(ha, pSI, Md5Digest)) return ERROR_VERIFY_FAILED; @@ -457,7 +519,7 @@ static DWORD VerifyWeakSignature( // Verify the signature memcpy(RevSignature, &pSI->Signature[8], MPQ_WEAK_SIGNATURE_SIZE); memrev(RevSignature, MPQ_WEAK_SIGNATURE_SIZE); - rsa_verify_hash_ex(RevSignature, MPQ_WEAK_SIGNATURE_SIZE, Md5Digest, sizeof(Md5Digest), LTC_PKCS_1_V1_5, hash_idx, 0, &result, &key); + rsa_verify_hash_ex(RevSignature, MPQ_WEAK_SIGNATURE_SIZE, Md5Digest, sizeof(Md5Digest), LTC_LTC_PKCS_1_V1_5, hash_idx, 0, &result, &key); rsa_free(&key); // Return the result @@ -465,9 +527,9 @@ static DWORD VerifyWeakSignature( } static DWORD VerifyStrongSignatureWithKey( - unsigned char * reversed_signature, - unsigned char * padded_digest, - const char * szPublicKey) + unsigned char * reversed_signature, + unsigned char * padded_digest, + const char * szPublicKey) { rsa_key key; int result = 0; @@ -482,15 +544,15 @@ static DWORD VerifyStrongSignatureWithKey( // Verify the signature if(rsa_verify_simple(reversed_signature, MPQ_STRONG_SIGNATURE_SIZE, padded_digest, MPQ_STRONG_SIGNATURE_SIZE, &result, &key) != CRYPT_OK) return ERROR_VERIFY_FAILED; - + // Free the key and return result rsa_free(&key); return result ? ERROR_STRONG_SIGNATURE_OK : ERROR_STRONG_SIGNATURE_ERROR; } static DWORD VerifyStrongSignature( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) + TMPQArchive * ha, + PMPQ_SIGNATURE_INFO pSI) { unsigned char reversed_signature[MPQ_STRONG_SIGNATURE_SIZE]; unsigned char Sha1Digest_tail0[SHA1_DIGEST_SIZE]; @@ -552,11 +614,11 @@ static DWORD VerifyStrongSignature( } static DWORD VerifyFile( - HANDLE hMpq, - const char * szFileName, - LPDWORD pdwCrc32, - char * pMD5, - DWORD dwFlags) + HANDLE hMpq, + const char * szFileName, + LPDWORD pdwCrc32, + char * pMD5, + DWORD dwFlags) { hash_state md5_state; unsigned char * pFileMd5; @@ -566,16 +628,14 @@ static DWORD VerifyFile( BYTE Buffer[0x1000]; HANDLE hFile = NULL; DWORD dwVerifyResult = 0; + DWORD dwSearchScope = SFILE_OPEN_FROM_MPQ; DWORD dwTotalBytes = 0; + DWORD dwBytesRead; DWORD dwCrc32 = 0; - // - // Note: When the MPQ is patched, it will - // automatically check the patched version of the file - // - - // Make sure the md5 is initialized - memset(md5, 0, sizeof(md5)); + // Fix the open type for patched archives + if(SFileIsPatchedArchive(hMpq)) + dwSearchScope = SFILE_OPEN_PATCHED_FILE; // If we have to verify raw data MD5, do it before file open if(dwFlags & SFILE_VERIFY_RAW_MD5) @@ -607,7 +667,7 @@ static DWORD VerifyFile( } // Attempt to open the file - if(SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_FROM_MPQ, &hFile)) + if(SFileOpenFileEx(hMpq, szFileName, dwSearchScope, &hFile)) { // Get the file size hf = (TMPQFile *)hFile; @@ -625,8 +685,6 @@ static DWORD VerifyFile( // Go through entire file and update both CRC32 and MD5 for(;;) { - DWORD dwBytesRead = 0; - // Read data from file SFileReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL); if(dwBytesRead == 0) @@ -639,7 +697,7 @@ static DWORD VerifyFile( // Update CRC32 value if(dwFlags & SFILE_VERIFY_FILE_CRC) dwCrc32 = crc32(dwCrc32, Buffer, dwBytesRead); - + // Update MD5 value if(dwFlags & SFILE_VERIFY_FILE_MD5) md5_process(&md5_state, Buffer, dwBytesRead); @@ -661,7 +719,7 @@ static DWORD VerifyFile( if(dwTotalBytes == 0) { // Check CRC32 and MD5 only if there is no patches - if(hf->hfPatch == NULL) + if(hf->hfPatchFile == NULL) { // Check if the CRC32 matches. if(dwFlags & SFILE_VERIFY_FILE_CRC) @@ -683,7 +741,7 @@ static DWORD VerifyFile( md5_done(&md5_state, md5); // Only check the MD5 if it is valid - if(IsValidMD5(pFileMd5)) + if(is_valid_md5(pFileMd5)) { dwVerifyResult |= VERIFY_FILE_HAS_MD5; if(memcmp(md5, pFileMd5, MD5_DIGEST_SIZE)) @@ -714,155 +772,11 @@ static DWORD VerifyFile( if(pdwCrc32 != NULL) *pdwCrc32 = dwCrc32; if(pMD5 != NULL) - memcpy(pMD5, md5, MD5_DIGEST_SIZE); + memcpy(pMD5, md5, MD5_DIGEST_SIZE); return dwVerifyResult; } -// Used in SFileGetFileInfo -bool QueryMpqSignatureInfo( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) -{ - TFileEntry * pFileEntry; - ULONGLONG ExtraBytes; - DWORD dwFileSize; - - // Make sure it's all zeroed - memset(pSI, 0, sizeof(MPQ_SIGNATURE_INFO)); - - // Calculate the range of the MPQ - CalculateArchiveRange(ha, pSI); - - // If there is "(signature)" file in the MPQ, it has a weak signature - pFileEntry = GetFileEntryLocale(ha, SIGNATURE_NAME, LANG_NEUTRAL); - if(pFileEntry != NULL) - { - // Calculate the begin and end of the signature file itself - pSI->BeginExclude = ha->MpqPos + pFileEntry->ByteOffset; - pSI->EndExclude = pSI->BeginExclude + pFileEntry->dwCmpSize; - dwFileSize = (DWORD)(pSI->EndExclude - pSI->BeginExclude); - - // Does the signature have proper size? - if(dwFileSize == MPQ_SIGNATURE_FILE_SIZE) - { - // Read the weak signature - if(!FileStream_Read(ha->pStream, &pSI->BeginExclude, pSI->Signature, dwFileSize)) - return false; - - pSI->SignatureTypes |= SIGNATURE_TYPE_WEAK; - pSI->cbSignatureSize = dwFileSize; - return true; - } - } - - // If there is extra bytes beyond the end of the archive, - // it's the strong signature - ExtraBytes = pSI->EndOfFile - pSI->EndMpqData; - if(ExtraBytes >= (MPQ_STRONG_SIGNATURE_SIZE + 4)) - { - // Read the strong signature - if(!FileStream_Read(ha->pStream, &pSI->EndMpqData, pSI->Signature, (MPQ_STRONG_SIGNATURE_SIZE + 4))) - return false; - - // Check the signature header "NGIS" - if(pSI->Signature[0] != 'N' || pSI->Signature[1] != 'G' || pSI->Signature[2] != 'I' || pSI->Signature[3] != 'S') - return false; - - pSI->SignatureTypes |= SIGNATURE_TYPE_STRONG; - return true; - } - - // Succeeded, but no known signature found - return true; -} - -//----------------------------------------------------------------------------- -// Support for weak signature - -int SSignFileCreate(TMPQArchive * ha) -{ - TMPQFile * hf = NULL; - BYTE EmptySignature[MPQ_SIGNATURE_FILE_SIZE]; - int nError = ERROR_SUCCESS; - - // Only save the signature if we should do so - if(ha->dwFileFlags3 != 0) - { - // The (signature) file must be non-encrypted and non-compressed - assert(ha->dwFlags & MPQ_FLAG_SIGNATURE_NEW); - assert(ha->dwFileFlags3 == MPQ_FILE_EXISTS); - assert(ha->dwReservedFiles > 0); - - // Create the (signature) file file in the MPQ - // Note that the file must not be compressed or encrypted - nError = SFileAddFile_Init(ha, SIGNATURE_NAME, - 0, - sizeof(EmptySignature), - LANG_NEUTRAL, - ha->dwFileFlags3 | MPQ_FILE_REPLACEEXISTING, - &hf); - - // Write the empty signature file to the archive - if(nError == ERROR_SUCCESS) - { - // Write the empty zeroed file to the MPQ - memset(EmptySignature, 0, sizeof(EmptySignature)); - nError = SFileAddFile_Write(hf, EmptySignature, (DWORD)sizeof(EmptySignature), 0); - SFileAddFile_Finish(hf); - - // Clear the invalid mark - ha->dwFlags &= ~(MPQ_FLAG_SIGNATURE_NEW | MPQ_FLAG_SIGNATURE_NONE); - ha->dwReservedFiles--; - } - } - - return nError; -} - -int SSignFileFinish(TMPQArchive * ha) -{ - MPQ_SIGNATURE_INFO si; - unsigned long signature_len = MPQ_WEAK_SIGNATURE_SIZE; - BYTE WeakSignature[MPQ_SIGNATURE_FILE_SIZE]; - BYTE Md5Digest[MD5_DIGEST_SIZE]; - rsa_key key; - int hash_idx = find_hash("md5"); - - // Sanity checks - assert((ha->dwFlags & MPQ_FLAG_CHANGED) == 0); - assert(ha->dwFileFlags3 == MPQ_FILE_EXISTS); - - // Query the weak signature info - memset(&si, 0, sizeof(MPQ_SIGNATURE_INFO)); - if(!QueryMpqSignatureInfo(ha, &si)) - return ERROR_FILE_CORRUPT; - - // There must be exactly one signature - if(si.SignatureTypes != SIGNATURE_TYPE_WEAK) - return ERROR_FILE_CORRUPT; - - // Calculate MD5 of the entire archive - if(!CalculateMpqHashMd5(ha, &si, Md5Digest)) - return ERROR_VERIFY_FAILED; - - // Decode the private key - if(!decode_base64_key(szBlizzardWeakPrivateKey, &key)) - return ERROR_VERIFY_FAILED; - - // Sign the hash - memset(WeakSignature, 0, sizeof(WeakSignature)); - rsa_sign_hash_ex(Md5Digest, sizeof(Md5Digest), WeakSignature + 8, &signature_len, LTC_PKCS_1_V1_5, 0, 0, hash_idx, 0, &key); - memrev(WeakSignature + 8, MPQ_WEAK_SIGNATURE_SIZE); - rsa_free(&key); - - // Write the signature to the MPQ. Don't use SFile* functions, but write the hash directly - if(!FileStream_Write(ha->pStream, &si.BeginExclude, WeakSignature, MPQ_SIGNATURE_FILE_SIZE)) - return GetLastError(); - - return ERROR_SUCCESS; -} - //----------------------------------------------------------------------------- // Public (exported) functions @@ -910,7 +824,7 @@ int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * sz TMPQHeader * pHeader; // Verify input parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) return ERROR_INVALID_PARAMETER; pHeader = ha->pHeader; @@ -921,54 +835,54 @@ int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * sz // If we have to verify MPQ header, do it switch(dwWhatToVerify) { - case SFILE_VERIFY_MPQ_HEADER: - - // Only if the header is of version 4 or newer - if(pHeader->dwHeaderSize >= (MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE)) - return VerifyRawMpqData(ha, 0, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE); - return ERROR_SUCCESS; + case SFILE_VERIFY_MPQ_HEADER: - case SFILE_VERIFY_HET_TABLE: + // Only if the header is of version 4 or newer + if(pHeader->dwHeaderSize >= (MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE)) + return VerifyRawMpqData(ha, 0, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE); + return ERROR_SUCCESS; - // Only if we have HET table - if(pHeader->HetTablePos64 && pHeader->HetTableSize64) - return VerifyRawMpqData(ha, pHeader->HetTablePos64, (DWORD)pHeader->HetTableSize64); - return ERROR_SUCCESS; + case SFILE_VERIFY_HET_TABLE: - case SFILE_VERIFY_BET_TABLE: + // Only if we have HET table + if(pHeader->HetTablePos64 && pHeader->HetTableSize64) + return VerifyRawMpqData(ha, pHeader->HetTablePos64, (DWORD)pHeader->HetTableSize64); + return ERROR_SUCCESS; - // Only if we have BET table - if(pHeader->BetTablePos64 && pHeader->BetTableSize64) - return VerifyRawMpqData(ha, pHeader->BetTablePos64, (DWORD)pHeader->BetTableSize64); - return ERROR_SUCCESS; + case SFILE_VERIFY_BET_TABLE: - case SFILE_VERIFY_HASH_TABLE: + // Only if we have BET table + if(pHeader->BetTablePos64 && pHeader->BetTableSize64) + return VerifyRawMpqData(ha, pHeader->BetTablePos64, (DWORD)pHeader->BetTableSize64); + return ERROR_SUCCESS; - // Hash table is not protected by MD5 - return ERROR_SUCCESS; + case SFILE_VERIFY_HASH_TABLE: - case SFILE_VERIFY_BLOCK_TABLE: + // Hash table is not protected by MD5 + return ERROR_SUCCESS; - // Block table is not protected by MD5 - return ERROR_SUCCESS; + case SFILE_VERIFY_BLOCK_TABLE: - case SFILE_VERIFY_HIBLOCK_TABLE: + // Block table is not protected by MD5 + return ERROR_SUCCESS; - // It is unknown if the hi-block table is protected my MD5 or not. - return ERROR_SUCCESS; + case SFILE_VERIFY_HIBLOCK_TABLE: - case SFILE_VERIFY_FILE: + // It is unknown if the hi-block table is protected my MD5 or not. + return ERROR_SUCCESS; - // Verify parameters - if(szFileName == NULL || *szFileName == 0) - return ERROR_INVALID_PARAMETER; + case SFILE_VERIFY_FILE: - // Get the offset of a file - pFileEntry = GetFileEntryLocale(ha, szFileName, lcFileLocale); - if(pFileEntry == NULL) - return ERROR_FILE_NOT_FOUND; + // Verify parameters + if(szFileName == NULL || *szFileName == 0) + return ERROR_INVALID_PARAMETER; - return VerifyRawMpqData(ha, pFileEntry->ByteOffset, pFileEntry->dwCmpSize); + // Get the offset of a file + pFileEntry = GetFileEntryLocale(ha, szFileName, lcFileLocale); + if(pFileEntry == NULL) + return ERROR_FILE_NOT_FOUND; + + return VerifyRawMpqData(ha, pFileEntry->ByteOffset, pFileEntry->dwCmpSize); } return ERROR_INVALID_PARAMETER; @@ -982,73 +896,26 @@ DWORD WINAPI SFileVerifyArchive(HANDLE hMpq) TMPQArchive * ha = (TMPQArchive *)hMpq; // Verify input parameters - if(!IsValidMpqHandle(hMpq)) + if(!IsValidMpqHandle(ha)) return ERROR_VERIFY_FAILED; - // If the archive was modified, we need to flush it - if(ha->dwFlags & MPQ_FLAG_CHANGED) - SFileFlushArchive(hMpq); - // Get the MPQ signature and signature type memset(&si, 0, sizeof(MPQ_SIGNATURE_INFO)); if(!QueryMpqSignatureInfo(ha, &si)) return ERROR_VERIFY_FAILED; - // If there is no signature - if(si.SignatureTypes == 0) + // Verify the signature + switch(si.nSignatureType) + { + case SIGNATURE_TYPE_NONE: return ERROR_NO_SIGNATURE; - // We haven't seen a MPQ with both signatures - assert(si.SignatureTypes == SIGNATURE_TYPE_WEAK || si.SignatureTypes == SIGNATURE_TYPE_STRONG); - - // Verify the strong signature, if present - if(si.SignatureTypes & SIGNATURE_TYPE_STRONG) - return VerifyStrongSignature(ha, &si); - - // Verify the weak signature, if present - if(si.SignatureTypes & SIGNATURE_TYPE_WEAK) + case SIGNATURE_TYPE_WEAK: return VerifyWeakSignature(ha, &si); - return ERROR_NO_SIGNATURE; + case SIGNATURE_TYPE_STRONG: + return VerifyStrongSignature(ha, &si); + } + + return ERROR_VERIFY_FAILED; } - -// Verifies the archive against the signature -bool WINAPI SFileSignArchive(HANDLE hMpq, DWORD dwSignatureType) -{ - TMPQArchive * ha; - - // Verify the archive handle - ha = IsValidMpqHandle(hMpq); - if(ha == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // We only support weak signature, and only for MPQs version 1.0 - if(dwSignatureType != SIGNATURE_TYPE_WEAK) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // The archive must not be malformed and must not be read-only - if(ha->dwFlags & (MPQ_FLAG_READ_ONLY | MPQ_FLAG_MALFORMED)) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - // If the signature is not there yet - if(ha->dwFileFlags3 == 0) - { - // Turn the signature on. The signature will - // be applied when the archive is closed - ha->dwFlags |= MPQ_FLAG_SIGNATURE_NEW | MPQ_FLAG_CHANGED; - ha->dwFileFlags3 = MPQ_FILE_EXISTS; - ha->dwReservedFiles++; - } - - return true; -} - diff --git a/dep/StormLib/src/StormCommon.h b/dep/StormLib/src/StormCommon.h index 4a016c6da..57a890667 100644 --- a/dep/StormLib/src/StormCommon.h +++ b/dep/StormLib/src/StormCommon.h @@ -35,25 +35,23 @@ // Include functions from zlib #ifndef __SYS_ZLIB - #include "zlib/zlib.h" +#include "zlib/zlib.h" #else - #include +#include #endif // Include functions from bzlib #ifndef __SYS_BZLIB - #include "bzip2/bzlib.h" +#include "bzip2/bzlib.h" #else - #include +#include #endif //----------------------------------------------------------------------------- // Cryptography support // Headers from LibTomCrypt -#include "tomcrypt.h" - -#include "rsa/rsa_verify_simple.h" +#include "libtomcrypt/src/headers/tomcrypt.h" // For HashStringJenkins #include "jenkins/lookup.h" @@ -63,88 +61,56 @@ #define ID_MPQ_FILE 0x46494c45 // Used internally for checking TMPQFile ('FILE') +#define MPQ_WEAK_SIGNATURE_SIZE 64 +#define MPQ_STRONG_SIGNATURE_SIZE 256 + // Prevent problems with CRT "min" and "max" functions, // as they are not defined on all platforms #define STORMLIB_MIN(a, b) ((a < b) ? a : b) #define STORMLIB_MAX(a, b) ((a > b) ? a : b) -#define STORMLIB_UNUSED(p) ((void)(p)) // Macro for building 64-bit file offset from two 32-bit -#define MAKE_OFFSET64(hi, lo) (((ULONGLONG)hi << 32) | (ULONGLONG)lo) - -//----------------------------------------------------------------------------- -// MPQ signature information - -// Size of each signature type -#define MPQ_WEAK_SIGNATURE_SIZE 64 -#define MPQ_STRONG_SIGNATURE_SIZE 256 -#define MPQ_STRONG_SIGNATURE_ID 0x5349474E // ID of the strong signature ("NGIS") -#define MPQ_SIGNATURE_FILE_SIZE (MPQ_WEAK_SIGNATURE_SIZE + 8) - -// MPQ signature info -typedef struct _MPQ_SIGNATURE_INFO -{ - ULONGLONG BeginMpqData; // File offset where the hashing starts - ULONGLONG BeginExclude; // Begin of the excluded area (used for (signature) file) - ULONGLONG EndExclude; // End of the excluded area (used for (signature) file) - ULONGLONG EndMpqData; // File offset where the hashing ends - ULONGLONG EndOfFile; // Size of the entire file - BYTE Signature[MPQ_STRONG_SIGNATURE_SIZE + 0x10]; - DWORD cbSignatureSize; // Length of the signature - DWORD SignatureTypes; // See SIGNATURE_TYPE_XXX - -} MPQ_SIGNATURE_INFO, *PMPQ_SIGNATURE_INFO; +#define MAKE_OFFSET64(hi, lo) (((ULONGLONG)hi << 32) | lo) //----------------------------------------------------------------------------- // Memory management // // We use our own macros for allocating/freeing memory. If you want -// to redefine them, please keep the following rules: +// to redefine them, please keep the following rules // // - The memory allocation must return NULL if not enough memory // (i.e not to throw exception) -// - The allocating function does not need to fill the allocated buffer with zeros -// - Memory freeing function doesn't have to test the pointer to NULL +// - It is not necessary to fill the allocated buffer with zeros +// - Memory freeing function doesn't have to test the pointer to NULL. // -//#if defined(_MSC_VER) && defined(_DEBUG) -// -//#define STORM_ALLOC(type, nitems) (type *)HeapAlloc(GetProcessHeap(), 0, ((nitems) * sizeof(type))) -//#define STORM_REALLOC(type, ptr, nitems) (type *)HeapReAlloc(GetProcessHeap(), 0, ptr, ((nitems) * sizeof(type))) -//#define STORM_FREE(ptr) HeapFree(GetProcessHeap(), 0, ptr) -// -//#else +#if defined(_MSC_VER) && defined(_DEBUG) +__inline void * DebugMalloc(char * /* szFile */, int /* nLine */, size_t nSize) +{ + // return new BYTE[nSize]; + return HeapAlloc(GetProcessHeap(), 0, nSize); +} -#define STORM_ALLOC(type, nitems) (type *)malloc((nitems) * sizeof(type)) -#define STORM_REALLOC(type, ptr, nitems) (type *)realloc(ptr, ((nitems) * sizeof(type))) -#define STORM_FREE(ptr) free(ptr) +__inline void DebugFree(void * ptr) +{ + // delete [] ptr; + HeapFree(GetProcessHeap(), 0, ptr); +} -//#endif +#define STORM_ALLOC(type, nitems) (type *)DebugMalloc(__FILE__, __LINE__, (nitems) * sizeof(type)) +#define STORM_FREE(ptr) DebugFree(ptr) +#else + +#define STORM_ALLOC(type, nitems) (type *)malloc((nitems) * sizeof(type)) +#define STORM_FREE(ptr) free(ptr) + +#endif //----------------------------------------------------------------------------- // StormLib internal global variables extern LCID lcFileLocale; // Preferred file locale -//----------------------------------------------------------------------------- -// Conversion to uppercase/lowercase (and "/" to "\") - -extern unsigned char AsciiToLowerTable[256]; -extern unsigned char AsciiToUpperTable[256]; - -//----------------------------------------------------------------------------- -// Safe string functions - -void StringCopy(char * szTarget, size_t cchTarget, const char * szSource); -void StringCat(char * szTarget, size_t cchTargetMax, const char * szSource); - -#ifdef _UNICODE -void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource); -void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource); -void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource); -void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource); -#endif - //----------------------------------------------------------------------------- // Encryption and decryption functions @@ -152,200 +118,134 @@ void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource); #define MPQ_HASH_NAME_A 0x100 #define MPQ_HASH_NAME_B 0x200 #define MPQ_HASH_FILE_KEY 0x300 -#define MPQ_HASH_KEY2_MIX 0x400 DWORD HashString(const char * szFileName, DWORD dwHashType); -DWORD HashStringSlash(const char * szFileName, DWORD dwHashType); -DWORD HashStringLower(const char * szFileName, DWORD dwHashType); void InitializeMpqCryptography(); -DWORD GetNearestPowerOfTwo(DWORD dwFileCount); +DWORD GetHashTableSizeForFileCount(DWORD dwFileCount); bool IsPseudoFileName(const char * szFileName, LPDWORD pdwFileIndex); ULONGLONG HashStringJenkins(const char * szFileName); -DWORD GetDefaultSpecialFileFlags(DWORD dwFileSize, USHORT wFormatVersion); +int ConvertMpqHeaderToFormat4(TMPQArchive * ha, ULONGLONG FileSize, DWORD dwFlags); -void EncryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); -void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); +DWORD GetDefaultSpecialFileFlags(TMPQArchive * ha, DWORD dwFileSize); -DWORD DetectFileKeyBySectorSize(LPDWORD EncryptedData, DWORD dwSectorSize, DWORD dwSectorOffsLen); -DWORD DetectFileKeyByContent(void * pvEncryptedData, DWORD dwSectorSize, DWORD dwFileSize); +void EncryptMpqBlock(void * pvFileBlock, DWORD dwLength, DWORD dwKey); +void DecryptMpqBlock(void * pvFileBlock, DWORD dwLength, DWORD dwKey); + +DWORD DetectFileKeyBySectorSize(LPDWORD SectorOffsets, DWORD decrypted); +DWORD DetectFileKeyByContent(void * pvFileContent, DWORD dwFileSize); DWORD DecryptFileKey(const char * szFileName, ULONGLONG MpqPos, DWORD dwFileSize, DWORD dwFlags); bool IsValidMD5(LPBYTE pbMd5); -bool IsValidSignature(LPBYTE pbSignature); bool VerifyDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE expected_md5); void CalculateDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE md5_hash); //----------------------------------------------------------------------------- // Handle validation functions -TMPQArchive * IsValidMpqHandle(HANDLE hMpq); -TMPQFile * IsValidFileHandle(HANDLE hFile); +bool IsValidMpqHandle(TMPQArchive * ha); +bool IsValidFileHandle(TMPQFile * hf); //----------------------------------------------------------------------------- -// Support for MPQ file tables +// Hash table and block table manipulation -ULONGLONG FileOffsetFromMpqOffset(TMPQArchive * ha, ULONGLONG MpqOffset); -ULONGLONG CalculateRawSectorOffset(TMPQFile * hf, DWORD dwSectorOffset); - -int ConvertMpqHeaderToFormat4(TMPQArchive * ha, ULONGLONG MpqOffset, ULONGLONG FileSize, DWORD dwFlags, bool bIsWarcraft3Map); - -bool IsValidHashEntry(TMPQArchive * ha, TMPQHash * pHash); - -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1, DWORD dwName2, LCID lcLocale); TMPQHash * GetFirstHashEntry(TMPQArchive * ha, const char * szFileName); TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash * pPrevHash); -TMPQHash * AllocateHashEntry(TMPQArchive * ha, TFileEntry * pFileEntry, LCID lcLocale); +DWORD AllocateHashEntry(TMPQArchive * ha, TFileEntry * pFileEntry); +DWORD AllocateHetEntry(TMPQArchive * ha, TFileEntry * pFileEntry); -TMPQExtHeader * LoadExtTable(TMPQArchive * ha, ULONGLONG ByteOffset, size_t Size, DWORD dwSignature, DWORD dwKey); -TMPQHetTable * LoadHetTable(TMPQArchive * ha); -TMPQBetTable * LoadBetTable(TMPQArchive * ha); +void FindFreeMpqSpace(TMPQArchive * ha, ULONGLONG * pFreeSpacePos); -TMPQBlock * LoadBlockTable(TMPQArchive * ha, bool bDontFixEntries = false); -TMPQBlock * TranslateBlockTable(TMPQArchive * ha, ULONGLONG * pcbTableSize, bool * pbNeedHiBlockTable); - -ULONGLONG FindFreeMpqSpace(TMPQArchive * ha); +// Functions that loads and verifies MPQ data bitmap +int LoadMpqDataBitmap(TMPQArchive * ha, ULONGLONG FileSize, bool * pbFileIsComplete); // Functions that load the HET and BET tables int CreateHashTable(TMPQArchive * ha, DWORD dwHashTableSize); int LoadAnyHashTable(TMPQArchive * ha); -int BuildFileTable(TMPQArchive * ha); -int DefragmentFileTable(TMPQArchive * ha); - -int CreateFileTable(TMPQArchive * ha, DWORD dwFileTableSize); -int RebuildHetTable(TMPQArchive * ha); -int RebuildFileTable(TMPQArchive * ha, DWORD dwNewHashTableSize); +int BuildFileTable(TMPQArchive * ha, ULONGLONG FileSize); int SaveMPQTables(TMPQArchive * ha); -TMPQHetTable * CreateHetTable(DWORD dwEntryCount, DWORD dwTotalCount, DWORD dwHashBitSize, LPBYTE pbSrcData); +TMPQHetTable * CreateHetTable(DWORD dwMaxFileCount, DWORD dwHashBitSize, bool bCreateEmpty); void FreeHetTable(TMPQHetTable * pHetTable); TMPQBetTable * CreateBetTable(DWORD dwMaxFileCount); void FreeBetTable(TMPQBetTable * pBetTable); // Functions for finding files in the file table -TFileEntry * GetFileEntryLocale2(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); +TFileEntry * GetFileEntryAny(TMPQArchive * ha, const char * szFileName); TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale); -TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); +TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale); +TFileEntry * GetFileEntryByIndex(TMPQArchive * ha, DWORD dwIndex); // Allocates file name in the file entry -void AllocateFileName(TMPQArchive * ha, TFileEntry * pFileEntry, const char * szFileName); +void AllocateFileName(TFileEntry * pFileEntry, const char * szFileName); // Allocates new file entry in the MPQ tables. Reuses existing, if possible -TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); -int RenameFileEntry(TMPQArchive * ha, TMPQFile * hf, const char * szNewFileName); -int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf); +TFileEntry * FindFreeFileEntry(TMPQArchive * ha); +TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale); +int RenameFileEntry(TMPQArchive * ha, TFileEntry * pFileEntry, const char * szNewFileName); +void ClearFileEntry(TMPQArchive * ha, TFileEntry * pFileEntry); +int FreeFileEntry(TMPQArchive * ha, TFileEntry * pFileEntry); // Invalidates entries for (listfile) and (attributes) void InvalidateInternalFiles(TMPQArchive * ha); -// Retrieves information about the strong signature -bool QueryMpqSignatureInfo(TMPQArchive * ha, PMPQ_SIGNATURE_INFO pSignatureInfo); - -//----------------------------------------------------------------------------- -// Support for alternate file formats (SBaseSubTypes.cpp) - -int ConvertSqpHeaderToFormat4(TMPQArchive * ha, ULONGLONG FileSize, DWORD dwFlags); -TMPQHash * LoadSqpHashTable(TMPQArchive * ha); -TMPQBlock * LoadSqpBlockTable(TMPQArchive * ha); - -int ConvertMpkHeaderToFormat4(TMPQArchive * ha, ULONGLONG FileSize, DWORD dwFlags); -void DecryptMpkTable(void * pvMpkTable, size_t cbSize); -TMPQHash * LoadMpkHashTable(TMPQArchive * ha); -TMPQBlock * LoadMpkBlockTable(TMPQArchive * ha); -int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); - //----------------------------------------------------------------------------- // Common functions - MPQ File -TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry); -TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize); -void * LoadMpqTable(TMPQArchive * ha, ULONGLONG ByteOffset, DWORD dwCompressedSize, DWORD dwRealSize, DWORD dwKey, bool * pbTableIsCut); +TMPQFile * CreateMpqFile(TMPQArchive * ha); +int LoadMpqTable(TMPQArchive * ha, ULONGLONG ByteOffset, void * pvTable, DWORD dwCompressedSize, DWORD dwRealSize, DWORD dwKey); int AllocateSectorBuffer(TMPQFile * hf); int AllocatePatchInfo(TMPQFile * hf, bool bLoadFromFile); int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile); int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile); +void CalculateRawSectorOffset(ULONGLONG & RawFilePos, TMPQFile * hf, DWORD dwSectorOffset); int WritePatchInfo(TMPQFile * hf); int WriteSectorOffsets(TMPQFile * hf); int WriteSectorChecksums(TMPQFile * hf); int WriteMemDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, void * pvRawData, DWORD dwRawDataSize, DWORD dwChunkSize, LPDWORD pcbTotalSize); int WriteMpqDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, DWORD dwRawDataSize, DWORD dwChunkSize); -void FreeFileHandle(TMPQFile *& hf); -void FreeArchiveHandle(TMPQArchive *& ha); - -//----------------------------------------------------------------------------- -// Patch functions - -// Structure used for the patching process -typedef struct _TMPQPatcher -{ - BYTE this_md5[MD5_DIGEST_SIZE]; // MD5 of the current file state - LPBYTE pbFileData1; // Primary working buffer - LPBYTE pbFileData2; // Secondary working buffer - DWORD cbMaxFileData; // Maximum allowed size of the patch data - DWORD cbFileData; // Current size of the result data - DWORD nCounter; // Counter of the patch process - -} TMPQPatcher; +void FreeMPQFile(TMPQFile *& hf); bool IsIncrementalPatchFile(const void * pvData, DWORD cbData, LPDWORD pdwPatchedFileSize); -int Patch_InitPatcher(TMPQPatcher * pPatcher, TMPQFile * hf); -int Patch_Process(TMPQPatcher * pPatcher, TMPQFile * hf); -void Patch_Finalize(TMPQPatcher * pPatcher); +int PatchFileData(TMPQFile * hf); + +void FreeMPQArchive(TMPQArchive *& ha); //----------------------------------------------------------------------------- // Utility functions bool CheckWildCard(const char * szString, const char * szWildCard); +const char * GetPlainFileNameA(const char * szFileName); +const TCHAR * GetPlainFileNameT(const TCHAR * szFileName); bool IsInternalMpqFileName(const char * szFileName); -template -const XCHAR * GetPlainFileName(const XCHAR * szFileName) -{ - const XCHAR * szPlainName = szFileName; - - while(*szFileName != 0) - { - if(*szFileName == '\\' || *szFileName == '/') - szPlainName = szFileName + 1; - szFileName++; - } - - return szPlainName; -} - //----------------------------------------------------------------------------- -// Internal support for MPQ modifications +// Support for adding files to the MPQ int SFileAddFile_Init( - TMPQArchive * ha, - const char * szArchivedName, - ULONGLONG ft, - DWORD dwFileSize, - LCID lcLocale, - DWORD dwFlags, - TMPQFile ** phf - ); - -int SFileAddFile_Init( - TMPQArchive * ha, - TMPQFile * hfSrc, - TMPQFile ** phf - ); + TMPQArchive * ha, + const char * szArchivedName, + ULONGLONG ft, + DWORD dwFileSize, + LCID lcLocale, + DWORD dwFlags, + TMPQFile ** phf + ); int SFileAddFile_Write( - TMPQFile * hf, - const void * pvData, - DWORD dwSize, - DWORD dwCompression - ); + TMPQFile * hf, + const void * pvData, + DWORD dwSize, + DWORD dwCompression + ); int SFileAddFile_Finish( - TMPQFile * hf - ); + TMPQFile * hf + ); //----------------------------------------------------------------------------- // Attributes support @@ -358,29 +258,16 @@ int SAttrFileSaveToMpq(TMPQArchive * ha); int SListFileSaveToMpq(TMPQArchive * ha); -//----------------------------------------------------------------------------- -// Weak signature support - -int SSignFileCreate(TMPQArchive * ha); -int SSignFileFinish(TMPQArchive * ha); - //----------------------------------------------------------------------------- // Dump data support #ifdef __STORMLIB_DUMP_DATA__ - void DumpMpqHeader(TMPQHeader * pHeader); -void DumpHashTable(TMPQHash * pHashTable, DWORD dwHashTableSize); void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable); -void DumpFileTable(TFileEntry * pFileTable, DWORD dwFileTableSize); #else - -#define DumpMpqHeader(h) /* */ -#define DumpHashTable(t, s) /* */ -#define DumpHetAndBetTable(t, s) /* */ -#define DumpFileTable(t, s) /* */ - +#define DumpMpqHeader(h) /* */ +#define DumpHetAndBetTable(h, b) /* */ #endif #endif // __STORMCOMMON_H__ diff --git a/dep/StormLib/src/StormLib.h b/dep/StormLib/src/StormLib.h index 31f6edae9..e5e153697 100644 --- a/dep/StormLib/src/StormLib.h +++ b/dep/StormLib/src/StormLib.h @@ -1,7 +1,7 @@ /*****************************************************************************/ -/* StormLib.h Copyright (c) Ladislav Zezula 1999-2017 */ +/* StormLib.h Copyright (c) Ladislav Zezula 1999-2010 */ /*---------------------------------------------------------------------------*/ -/* StormLib library v 9.22 */ +/* StormLib library v 7.02 */ /* */ /* Author : Ladislav Zezula */ /* E-mail : ladik@zezula.net */ @@ -66,22 +66,15 @@ /* 15.09.11 8.04 Lad Bug fixes, testing for Diablo III MPQs */ /* 26.04.12 8.10 Lad Support for data map, added SFileGetArchiveBitmap */ /* 29.05.12 8.20 Lad C-only interface */ -/* 14.01.13 8.21 Lad ADPCM and Huffmann (de)compression refactored */ -/* 04.12.13 9.00 Lad Unit tests, bug fixes */ -/* 27.08.14 9.10 Lad Signing archives with weak digital signature */ -/* 25.11.14 9.11 Lad Fixed bug reading & creating HET table */ -/* 18.09.15 9.20 Lad Release 9.20 */ -/* 12.12.16 9.21 Lad Release 9.21 */ -/* 10.11.17 9.22 Lad Release 9.22 */ /*****************************************************************************/ #ifndef __STORMLIB_H__ #define __STORMLIB_H__ #ifdef _MSC_VER -#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' +#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' #pragma warning(disable:4820) // 'XXX' : '2' bytes padding added after data member 'XXX::yyy' -#endif +#endif #include "StormPort.h" @@ -94,115 +87,92 @@ extern "C" { // // The library type is encoded in the library name as the following // StormLibXYZ.lib -// +// // X - D for Debug version, R for Release version // Y - A for ANSI version, U for Unicode version // Z - S for static-linked CRT library, D for multithreaded DLL CRT library // -#if defined(__STORMLIB_SELF__) && !defined(STORMLIB_NO_AUTO_LINK) -#define STORMLIB_NO_AUTO_LINK // Define this if you don't want to link using pragmas when using msvc -#endif +#if defined(_MSC_VER) && !defined(__STORMLIB_SELF__) -#if defined(_MSC_VER) && !defined(STORMLIB_NO_AUTO_LINK) - #ifdef _DEBUG // DEBUG VERSIONS - #ifndef _UNICODE - #ifdef _DLL - #pragma comment(lib, "StormLibDAD.lib") // Debug Ansi CRT-DLL version - #else - #pragma comment(lib, "StormLibDAS.lib") // Debug Ansi CRT-LIB version - #endif - #else - #ifdef _DLL - #pragma comment(lib, "StormLibDUD.lib") // Debug Unicode CRT-DLL version - #else - #pragma comment(lib, "StormLibDUS.lib") // Debug Unicode CRT-LIB version - #endif - #endif - #else // RELEASE VERSIONS - #ifndef _UNICODE - #ifdef _DLL - #pragma comment(lib, "StormLibRAD.lib") // Release Ansi CRT-DLL version - #else - #pragma comment(lib, "StormLibRAS.lib") // Release Ansi CRT-LIB version - #endif - #else - #ifdef _DLL - #pragma comment(lib, "StormLibRUD.lib") // Release Unicode CRT-DLL version - #else - #pragma comment(lib, "StormLibRUS.lib") // Release Unicode CRT-LIB version - #endif - #endif - #endif +#ifdef _DEBUG // DEBUG VERSIONS +#ifndef _UNICODE +#ifdef _DLL +#pragma comment(lib, "StormLibDAD.lib") // Debug Ansi CRT-DLL version +#else +#pragma comment(lib, "StormLibDAS.lib") // Debug Ansi CRT-LIB version +#endif +#else +#ifdef _DLL +#pragma comment(lib, "StormLibDUD.lib") // Debug Unicode CRT-DLL version +#else +#pragma comment(lib, "StormLibDUS.lib") // Debug Unicode CRT-LIB version +#endif +#endif +#else // RELEASE VERSIONS +#ifndef _UNICODE +#ifdef _DLL +#pragma comment(lib, "StormLibRAD.lib") // Release Ansi CRT-DLL version +#else +#pragma comment(lib, "StormLibRAS.lib") // Release Ansi CRT-LIB version +#endif +#else +#ifdef _DLL +#pragma comment(lib, "StormLibRUD.lib") // Release Unicode CRT-DLL version +#else +#pragma comment(lib, "StormLibRUS.lib") // Release Unicode CRT-LIB version +#endif +#endif +#endif #endif //----------------------------------------------------------------------------- // Defines -#define STORMLIB_VERSION 0x0916 // Current version of StormLib (9.21) -#define STORMLIB_VERSION_STRING "9.22" // String version of StormLib version - #define ID_MPQ 0x1A51504D // MPQ archive header ID ('MPQ\x1A') #define ID_MPQ_USERDATA 0x1B51504D // MPQ userdata entry ('MPQ\x1B') -#define ID_MPK 0x1A4B504D // MPK archive header ID ('MPK\x1A') -#define ERROR_AVI_FILE 10000 // Not a MPQ file, but an AVI file. +#define ERROR_AVI_FILE 10000 // No MPQ file, but AVI file. #define ERROR_UNKNOWN_FILE_KEY 10001 // Returned by SFileReadFile when can't find file key #define ERROR_CHECKSUM_ERROR 10002 // Returned by SFileReadFile when sector CRC doesn't match #define ERROR_INTERNAL_FILE 10003 // The given operation is not allowed on internal file #define ERROR_BASE_FILE_MISSING 10004 // The file is present as incremental patch file, but base file is missing #define ERROR_MARKED_FOR_DELETE 10005 // The file was marked as "deleted" in the MPQ -#define ERROR_FILE_INCOMPLETE 10006 // The required file part is missing -#define ERROR_UNKNOWN_FILE_NAMES 10007 // A name of at least one file is unknown -#define ERROR_CANT_FIND_PATCH_PREFIX 10008 // StormLib was unable to find patch prefix for the patches // Values for SFileCreateArchive -#define HASH_TABLE_SIZE_MIN 0x00000004 // Verified: If there is 1 file, hash table size is 4 +#define HASH_TABLE_SIZE_MIN 0x00000004 // Minimum acceptable hash table size #define HASH_TABLE_SIZE_DEFAULT 0x00001000 // Default hash table size for empty MPQs #define HASH_TABLE_SIZE_MAX 0x00080000 // Maximum acceptable hash table size #define HASH_ENTRY_DELETED 0xFFFFFFFE // Block index for deleted entry in the hash table #define HASH_ENTRY_FREE 0xFFFFFFFF // Block index for free entry in the hash table -#define HET_ENTRY_DELETED 0x80 // NameHash1 value for a deleted entry -#define HET_ENTRY_FREE 0x00 // NameHash1 value for free entry +#define HET_ENTRY_DELETED 0x80 // HET hash value for a deleted entry +#define HET_ENTRY_FREE 0x00 // HET hash value for free entry #define HASH_STATE_SIZE 0x60 // Size of LibTomCrypt's hash_state structure +#define MPQ_PATCH_PREFIX_LEN 0x20 // Maximum length of the patch prefix + // Values for SFileOpenArchive #define SFILE_OPEN_HARD_DISK_FILE 2 // Open the archive on HDD #define SFILE_OPEN_CDROM_FILE 3 // Open the archive only if it is on CDROM // Values for SFileOpenFile #define SFILE_OPEN_FROM_MPQ 0x00000000 // Open the file from the MPQ archive -#define SFILE_OPEN_CHECK_EXISTS 0xFFFFFFFC // Only check whether the file exists -#define SFILE_OPEN_BASE_FILE 0xFFFFFFFD // Reserved for StormLib internal use +#define SFILE_OPEN_PATCHED_FILE 0x00000001 // Open the file from the MPQ archive #define SFILE_OPEN_ANY_LOCALE 0xFFFFFFFE // Reserved for StormLib internal use #define SFILE_OPEN_LOCAL_FILE 0xFFFFFFFF // Open a local file -// Flags for TMPQArchive::dwFlags. Used internally +// Flags for TMPQArchive::dwFlags #define MPQ_FLAG_READ_ONLY 0x00000001 // If set, the MPQ has been open for read-only access #define MPQ_FLAG_CHANGED 0x00000002 // If set, the MPQ tables have been changed -#define MPQ_FLAG_MALFORMED 0x00000004 // Malformed data structure detected (W3M map protectors) -#define MPQ_FLAG_HASH_TABLE_CUT 0x00000008 // The hash table goes beyond EOF -#define MPQ_FLAG_BLOCK_TABLE_CUT 0x00000010 // The hash table goes beyond EOF -#define MPQ_FLAG_CHECK_SECTOR_CRC 0x00000020 // Checking sector CRC when reading files -#define MPQ_FLAG_SAVING_TABLES 0x00000040 // If set, we are saving MPQ internal files and MPQ tables -#define MPQ_FLAG_PATCH 0x00000080 // If set, this MPQ is a patch archive -#define MPQ_FLAG_WAR3_MAP 0x00000100 // If set, this MPQ is a map for Warcraft III -#define MPQ_FLAG_LISTFILE_NONE 0x00000200 // Set when no (listfile) was found in InvalidateInternalFiles -#define MPQ_FLAG_LISTFILE_NEW 0x00000400 // Set when (listfile) invalidated by InvalidateInternalFiles -#define MPQ_FLAG_LISTFILE_FORCE 0x00000800 // Save updated listfile on exit -#define MPQ_FLAG_ATTRIBUTES_NONE 0x00001000 // Set when no (attributes) was found in InvalidateInternalFiles -#define MPQ_FLAG_ATTRIBUTES_NEW 0x00002000 // Set when (attributes) invalidated by InvalidateInternalFiles -#define MPQ_FLAG_SIGNATURE_NONE 0x00004000 // Set when no (signature) was found in InvalidateInternalFiles -#define MPQ_FLAG_SIGNATURE_NEW 0x00008000 // Set when (signature) invalidated by InvalidateInternalFiles - -// Values for TMPQArchive::dwSubType -#define MPQ_SUBTYPE_MPQ 0x00000000 // The file is a MPQ file (Blizzard games) -#define MPQ_SUBTYPE_SQP 0x00000001 // The file is a SQP file (War of the Immortals) -#define MPQ_SUBTYPE_MPK 0x00000002 // The file is a MPK file (Longwu Online) +#define MPQ_FLAG_PROTECTED 0x00000004 // Set on protected MPQs (like W3M maps) +#define MPQ_FLAG_CHECK_SECTOR_CRC 0x00000008 // Checking sector CRC when reading files +#define MPQ_FLAG_NEED_FIX_SIZE 0x00000010 // Used during opening the archive +#define MPQ_FLAG_INV_LISTFILE 0x00000020 // If set, it means that the (listfile) has been invalidated +#define MPQ_FLAG_INV_ATTRIBUTES 0x00000040 // If set, it means that the (attributes) has been invalidated // Return value for SFileGetFileSize and SFileSetFilePointer #define SFILE_INVALID_SIZE 0xFFFFFFFF @@ -212,47 +182,26 @@ extern "C" { // Flags for SFileAddFile #define MPQ_FILE_IMPLODE 0x00000100 // Implode method (By PKWARE Data Compression Library) #define MPQ_FILE_COMPRESS 0x00000200 // Compress methods (By multiple methods) -#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted +#define MPQ_FILE_COMPRESSED 0x0000FF00 // File is compressed +#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted #define MPQ_FILE_FIX_KEY 0x00020000 // File decryption key has to be fixed #define MPQ_FILE_PATCH_FILE 0x00100000 // The file is a patch file. Raw file data begin with TPatchInfo structure #define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) #define MPQ_FILE_DELETE_MARKER 0x02000000 // File is a deletion marker. Used in MPQ patches, indicating that the file no longer exists. #define MPQ_FILE_SECTOR_CRC 0x04000000 // File has checksums for each sector. - // Ignored if file is not compressed or imploded. -#define MPQ_FILE_SIGNATURE 0x10000000 // Present on STANDARD.SNP\(signature). The only occurence ever observed +// Ignored if file is not compressed or imploded. #define MPQ_FILE_EXISTS 0x80000000 // Set if file exists, reset when the file was deleted #define MPQ_FILE_REPLACEEXISTING 0x80000000 // Replace when the file exist (SFileAddFile) -#define MPQ_FILE_COMPRESS_MASK 0x0000FF00 // Mask for a file being compressed - -#define MPQ_FILE_DEFAULT_INTERNAL 0xFFFFFFFF // Use default flags for internal files - #define MPQ_FILE_VALID_FLAGS (MPQ_FILE_IMPLODE | \ - MPQ_FILE_COMPRESS | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIX_KEY | \ - MPQ_FILE_PATCH_FILE | \ - MPQ_FILE_SINGLE_UNIT | \ - MPQ_FILE_DELETE_MARKER | \ - MPQ_FILE_SECTOR_CRC | \ - MPQ_FILE_SIGNATURE | \ - MPQ_FILE_EXISTS) - -#define MPQ_FILE_VALID_FLAGS_W3X (MPQ_FILE_IMPLODE | \ - MPQ_FILE_COMPRESS | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIX_KEY | \ - MPQ_FILE_DELETE_MARKER | \ - MPQ_FILE_SECTOR_CRC | \ - MPQ_FILE_SIGNATURE | \ - MPQ_FILE_EXISTS) - -// We need to mask out the upper 4 bits of the block table index. -// This is because it gets shifted out when calculating block table offset -// BlockTableOffset = pHash->dwBlockIndex << 0x04 -// Malformed MPQ maps may contain block indexes like 0x40000001 or 0xF0000023 -#define BLOCK_INDEX_MASK 0x0FFFFFFF -#define MPQ_BLOCK_INDEX(pHash) (pHash->dwBlockIndex & BLOCK_INDEX_MASK) + MPQ_FILE_COMPRESS | \ + MPQ_FILE_ENCRYPTED | \ + MPQ_FILE_FIX_KEY | \ + MPQ_FILE_PATCH_FILE | \ + MPQ_FILE_SINGLE_UNIT | \ + MPQ_FILE_DELETE_MARKER | \ + MPQ_FILE_SECTOR_CRC | \ + MPQ_FILE_EXISTS) // Compression types for multiple compressions #define MPQ_COMPRESSION_HUFFMANN 0x01 // Huffmann compression (used on WAVE files only) @@ -278,13 +227,46 @@ extern "C" { #define MPQ_KEY_HASH_TABLE 0xC3AF3770 // Obtained by HashString("(hash table)", MPQ_HASH_FILE_KEY) #define MPQ_KEY_BLOCK_TABLE 0xEC83B3A3 // Obtained by HashString("(block table)", MPQ_HASH_FILE_KEY) +// Block map defines +#define MPQ_DATA_BITMAP_SIGNATURE 0x33767470 // Signature of the MPQ data bitmap ('ptv3') + +// Constants for SFileGetFileInfo +#define SFILE_INFO_ARCHIVE_NAME 1 // MPQ size (value from header) +#define SFILE_INFO_ARCHIVE_SIZE 2 // MPQ size (value from header) +#define SFILE_INFO_MAX_FILE_COUNT 3 // Max number of files in the MPQ +#define SFILE_INFO_HASH_TABLE_SIZE 4 // Size of hash table, in entries +#define SFILE_INFO_BLOCK_TABLE_SIZE 5 // Number of entries in the block table +#define SFILE_INFO_SECTOR_SIZE 6 // Size of file sector (in bytes) +#define SFILE_INFO_HASH_TABLE 7 // Pointer to Hash table (TMPQHash *) +#define SFILE_INFO_BLOCK_TABLE 8 // Pointer to Block Table (TMPQBlock *) +#define SFILE_INFO_NUM_FILES 9 // Real number of files within archive +#define SFILE_INFO_STREAM_FLAGS 10 // Stream flags for the MPQ. See STREAM_FLAG_XXX +#define SFILE_INFO_IS_READ_ONLY 11 // TRUE of the MPQ was open as read only +//------ +#define SFILE_INFO_HASH_INDEX 100 // Hash index of file in MPQ +#define SFILE_INFO_CODENAME1 101 // The first codename of the file +#define SFILE_INFO_CODENAME2 102 // The second codename of the file +#define SFILE_INFO_LOCALEID 103 // Locale ID of file in MPQ +#define SFILE_INFO_BLOCKINDEX 104 // Index to Block Table +#define SFILE_INFO_FILE_SIZE 105 // Original file size (from the block table) +#define SFILE_INFO_COMPRESSED_SIZE 106 // Compressed file size (from the block table) +#define SFILE_INFO_FLAGS 107 // File flags +#define SFILE_INFO_POSITION 108 // File position within archive +#define SFILE_INFO_KEY 109 // File decryption key +#define SFILE_INFO_KEY_UNFIXED 110 // Decryption key not fixed to file pos and size +#define SFILE_INFO_FILETIME 111 // TMPQFileTime +#define SFILE_INFO_PATCH_CHAIN 112 // Chain of patches + #define LISTFILE_NAME "(listfile)" // Name of internal listfile #define SIGNATURE_NAME "(signature)" // Name of internal signature #define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file #define PATCH_METADATA_NAME "(patch_metadata)" +#define STORMLIB_VERSION 0x0814 // Current version of StormLib (8.10) +#define STORMLIB_VERSION_STRING "8.20" + #define MPQ_FORMAT_VERSION_1 0 // Up to The Burning Crusade -#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer +#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer #define MPQ_FORMAT_VERSION_3 2 // WoW Cataclysm Beta #define MPQ_FORMAT_VERSION_4 3 // WoW Cataclysm and newer @@ -303,33 +285,27 @@ extern "C" { #define BASE_PROVIDER_HTTP 0x00000002 // Base data source is a file on web server #define BASE_PROVIDER_MASK 0x0000000F // Mask for base provider value -#define STREAM_PROVIDER_FLAT 0x00000000 // Stream is linear with no offset mapping +#define STREAM_PROVIDER_LINEAR 0x00000000 // Stream is linear with no offset mapping #define STREAM_PROVIDER_PARTIAL 0x00000010 // Stream is partial file (.part) -#define STREAM_PROVIDER_MPQE 0x00000020 // Stream is an encrypted MPQ -#define STREAM_PROVIDER_BLOCK4 0x00000030 // 0x4000 per block, text MD5 after each block, max 0x2000 blocks per file +#define STREAM_PROVIDER_ENCRYPTED 0x00000020 // Stream is an encrypted MPQ #define STREAM_PROVIDER_MASK 0x000000F0 // Mask for stream provider value #define STREAM_FLAG_READ_ONLY 0x00000100 // Stream is read only #define STREAM_FLAG_WRITE_SHARE 0x00000200 // Allow write sharing when open for write -#define STREAM_FLAG_USE_BITMAP 0x00000400 // If the file has a file bitmap, load it and use it -#define STREAM_OPTIONS_MASK 0x0000FF00 // Mask for stream options - -#define STREAM_PROVIDERS_MASK 0x000000FF // Mask to get stream providers -#define STREAM_FLAGS_MASK 0x0000FFFF // Mask for all stream flags (providers+options) +#define STREAM_FLAG_MASK 0x0000FF00 // Mask for stream flags +#define STREAM_OPTIONS_MASK 0x0000FFFF // Mask for all stream options #define MPQ_OPEN_NO_LISTFILE 0x00010000 // Don't load the internal listfile #define MPQ_OPEN_NO_ATTRIBUTES 0x00020000 // Don't open the attributes -#define MPQ_OPEN_NO_HEADER_SEARCH 0x00040000 // Don't search for the MPQ header past the begin of the file -#define MPQ_OPEN_FORCE_MPQ_V1 0x00080000 // Always open the archive as MPQ v 1.00, ignore the "wFormatVersion" variable in the header -#define MPQ_OPEN_CHECK_SECTOR_CRC 0x00100000 // On files with MPQ_FILE_SECTOR_CRC, the CRC will be checked when reading file -#define MPQ_OPEN_PATCH 0x00200000 // This archive is a patch MPQ. Used internally. -#define MPQ_OPEN_FORCE_LISTFILE 0x00400000 // Force add listfile even if there is none at the moment of opening +#define MPQ_OPEN_FORCE_MPQ_V1 0x00040000 // Always open the archive as MPQ v 1.00, ignore the "wFormatVersion" variable in the header +#define MPQ_OPEN_CHECK_SECTOR_CRC 0x00080000 // On files with MPQ_FILE_SECTOR_CRC, the CRC will be checked when reading file + +// Deprecated #define MPQ_OPEN_READ_ONLY STREAM_FLAG_READ_ONLY +#define MPQ_OPEN_ENCRYPTED STREAM_PROVIDER_ENCRYPTED // Flags for SFileCreateArchive -#define MPQ_CREATE_LISTFILE 0x00100000 // Also add the (listfile) file -#define MPQ_CREATE_ATTRIBUTES 0x00200000 // Also add the (attributes) file -#define MPQ_CREATE_SIGNATURE 0x00400000 // Also add the (signature) file +#define MPQ_CREATE_ATTRIBUTES 0x00100000 // Also add the (attributes) file #define MPQ_CREATE_ARCHIVE_V1 0x00000000 // Creates archive of version 1 (size up to 4GB) #define MPQ_CREATE_ARCHIVE_V2 0x01000000 // Creates archive of version 2 (larger than 4 GB) #define MPQ_CREATE_ARCHIVE_V3 0x02000000 // Creates archive of version 3 @@ -367,11 +343,6 @@ extern "C" { #define SFILE_VERIFY_HIBLOCK_TABLE 0x0006 // Verify raw data of the hi-block table #define SFILE_VERIFY_FILE 0x0007 // Verify raw data of a file -// Signature types -#define SIGNATURE_TYPE_NONE 0x0000 // The archive has no signature in it -#define SIGNATURE_TYPE_WEAK 0x0001 // The archive has weak signature -#define SIGNATURE_TYPE_STRONG 0x0002 // The archive has strong signature - // Return values for SFileVerifyArchive #define ERROR_NO_SIGNATURE 0 // There is no signature in the MPQ #define ERROR_VERIFY_FAILED 1 // There was an error during verifying signature (like no memory) @@ -379,7 +350,7 @@ extern "C" { #define ERROR_WEAK_SIGNATURE_ERROR 3 // There is a weak signature but sign check failed #define ERROR_STRONG_SIGNATURE_OK 4 // There is a strong signature and sign check passed #define ERROR_STRONG_SIGNATURE_ERROR 5 // There is a strong signature but sign check failed - + #ifndef MD5_DIGEST_SIZE #define MD5_DIGEST_SIZE 0x10 #endif @@ -392,87 +363,16 @@ extern "C" { #define LANG_NEUTRAL 0x00 // Neutral locale #endif -// Pointer to hashing function -typedef DWORD (*HASH_STRING)(const char * szFileName, DWORD dwHashType); - -//----------------------------------------------------------------------------- -// File information classes for SFileGetFileInfo and SFileFreeFileInfo - -typedef enum _SFileInfoClass -{ - // Info classes for archives - SFileMpqFileName, // Name of the archive file (TCHAR []) - SFileMpqStreamBitmap, // Array of bits, each bit means availability of one block (BYTE []) - SFileMpqUserDataOffset, // Offset of the user data header (ULONGLONG) - SFileMpqUserDataHeader, // Raw (unfixed) user data header (TMPQUserData) - SFileMpqUserData, // MPQ USer data, without the header (BYTE []) - SFileMpqHeaderOffset, // Offset of the MPQ header (ULONGLONG) - SFileMpqHeaderSize, // Fixed size of the MPQ header - SFileMpqHeader, // Raw (unfixed) archive header (TMPQHeader) - SFileMpqHetTableOffset, // Offset of the HET table, relative to MPQ header (ULONGLONG) - SFileMpqHetTableSize, // Compressed size of the HET table (ULONGLONG) - SFileMpqHetHeader, // HET table header (TMPQHetHeader) - SFileMpqHetTable, // HET table as pointer. Must be freed using SFileFreeFileInfo - SFileMpqBetTableOffset, // Offset of the BET table, relative to MPQ header (ULONGLONG) - SFileMpqBetTableSize, // Compressed size of the BET table (ULONGLONG) - SFileMpqBetHeader, // BET table header, followed by the flags (TMPQBetHeader + DWORD[]) - SFileMpqBetTable, // BET table as pointer. Must be freed using SFileFreeFileInfo - SFileMpqHashTableOffset, // Hash table offset, relative to MPQ header (ULONGLONG) - SFileMpqHashTableSize64, // Compressed size of the hash table (ULONGLONG) - SFileMpqHashTableSize, // Size of the hash table, in entries (DWORD) - SFileMpqHashTable, // Raw (unfixed) hash table (TMPQBlock []) - SFileMpqBlockTableOffset, // Block table offset, relative to MPQ header (ULONGLONG) - SFileMpqBlockTableSize64, // Compressed size of the block table (ULONGLONG) - SFileMpqBlockTableSize, // Size of the block table, in entries (DWORD) - SFileMpqBlockTable, // Raw (unfixed) block table (TMPQBlock []) - SFileMpqHiBlockTableOffset, // Hi-block table offset, relative to MPQ header (ULONGLONG) - SFileMpqHiBlockTableSize64, // Compressed size of the hi-block table (ULONGLONG) - SFileMpqHiBlockTable, // The hi-block table (USHORT []) - SFileMpqSignatures, // Signatures present in the MPQ (DWORD) - SFileMpqStrongSignatureOffset, // Byte offset of the strong signature, relative to begin of the file (ULONGLONG) - SFileMpqStrongSignatureSize, // Size of the strong signature (DWORD) - SFileMpqStrongSignature, // The strong signature (BYTE []) - SFileMpqArchiveSize64, // Archive size from the header (ULONGLONG) - SFileMpqArchiveSize, // Archive size from the header (DWORD) - SFileMpqMaxFileCount, // Max number of files in the archive (DWORD) - SFileMpqFileTableSize, // Number of entries in the file table (DWORD) - SFileMpqSectorSize, // Sector size (DWORD) - SFileMpqNumberOfFiles, // Number of files (DWORD) - SFileMpqRawChunkSize, // Size of the raw data chunk for MD5 - SFileMpqStreamFlags, // Stream flags (DWORD) - SFileMpqFlags, // Nonzero if the MPQ is read only (DWORD) - - // Info classes for files - SFileInfoPatchChain, // Chain of patches where the file is (TCHAR []) - SFileInfoFileEntry, // The file entry for the file (TFileEntry) - SFileInfoHashEntry, // Hash table entry for the file (TMPQHash) - SFileInfoHashIndex, // Index of the hash table entry (DWORD) - SFileInfoNameHash1, // The first name hash in the hash table (DWORD) - SFileInfoNameHash2, // The second name hash in the hash table (DWORD) - SFileInfoNameHash3, // 64-bit file name hash for the HET/BET tables (ULONGLONG) - SFileInfoLocale, // File locale (DWORD) - SFileInfoFileIndex, // Block index (DWORD) - SFileInfoByteOffset, // File position in the archive (ULONGLONG) - SFileInfoFileTime, // File time (ULONGLONG) - SFileInfoFileSize, // Size of the file (DWORD) - SFileInfoCompressedSize, // Compressed file size (DWORD) - SFileInfoFlags, // File flags from (DWORD) - SFileInfoEncryptionKey, // File encryption key - SFileInfoEncryptionKeyRaw, // Unfixed value of the file key - SFileInfoCRC32, // CRC32 of the file -} SFileInfoClass; - //----------------------------------------------------------------------------- // Callback functions // Values for compact callback -#define CCB_CHECKING_FILES 1 // Checking archive (dwParam1 = current, dwParam2 = total) -#define CCB_CHECKING_HASH_TABLE 2 // Checking hash table (dwParam1 = current, dwParam2 = total) -#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used -#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) -#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used - -typedef void (WINAPI * SFILE_DOWNLOAD_CALLBACK)(void * pvUserData, ULONGLONG ByteOffset, DWORD dwTotalBytes); +#define CCB_CHECKING_FILES 1 // Checking archive (dwParam1 = current, dwParam2 = total) +#define CCB_CHECKING_HASH_TABLE 2 // Checking hash table (dwParam1 = current, dwParam2 = total) +#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used +#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) +#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used + typedef void (WINAPI * SFILE_ADDFILE_CALLBACK)(void * pvUserData, DWORD dwBytesWritten, DWORD dwTotalBytes, bool bFinalCall); typedef void (WINAPI * SFILE_COMPACT_CALLBACK)(void * pvUserData, DWORD dwWorkType, ULONGLONG BytesProcessed, ULONGLONG TotalBytes); @@ -483,7 +383,7 @@ typedef struct TFileStream TFileStream; typedef struct _TBitArray { - DWORD NumberOfBytes; // Total number of bytes in "Elements" + DWORD NumberOfBits; // Total number of bits that are available BYTE Elements[1]; // Array of elements (variable length) } TBitArray; @@ -491,6 +391,19 @@ typedef struct _TBitArray void GetBits(TBitArray * array, unsigned int nBitPosition, unsigned int nBitLength, void * pvBuffer, int nResultSize); void SetBits(TBitArray * array, unsigned int nBitPosition, unsigned int nBitLength, void * pvBuffer, int nResultSize); +// Structure for file bitmap. Used by SFileGetArchiveBitmap +typedef struct _TFileBitmap +{ + ULONGLONG StartOffset; // Starting offset of the file, covered by bitmap + ULONGLONG EndOffset; // Ending offset of the file, covered by bitmap + DWORD IsComplete; // If nonzero, no blocks are missing + DWORD BitmapSize; // Size of the file bitmap (in bytes) + DWORD BlockSize; // Size of one block, in bytes + DWORD Reserved; // Alignment + + // Followed by file bitmap (variable length), array of BYTEs) +} TFileBitmap; + //----------------------------------------------------------------------------- // Structures related to MPQ format // @@ -505,7 +418,6 @@ void SetBits(TBitArray * array, unsigned int nBitPosition, unsigned int nBitLeng #define MPQ_HEADER_SIZE_V2 0x2C #define MPQ_HEADER_SIZE_V3 0x44 #define MPQ_HEADER_SIZE_V4 0xD0 -#define MPQ_HEADER_DWORDS (MPQ_HEADER_SIZE_V4 / 0x04) typedef struct _TMPQUserData { @@ -554,14 +466,14 @@ typedef struct _TMPQHeader // Offset to the beginning of the hash table, relative to the beginning of the archive. DWORD dwHashTablePos; - + // Offset to the beginning of the block table, relative to the beginning of the archive. DWORD dwBlockTablePos; - + // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. DWORD dwHashTableSize; - + // Number of entries in the block table DWORD dwBlockTableSize; @@ -606,7 +518,7 @@ typedef struct _TMPQHeader // Size of raw data chunk to calculate MD5. // MD5 of each data chunk follows the raw file data. - DWORD dwRawChunkSize; + DWORD dwRawChunkSize; // MD5 of MPQ tables unsigned char MD5_BlockTable[MD5_DIGEST_SIZE]; // MD5 of the block table before decryption @@ -618,12 +530,13 @@ typedef struct _TMPQHeader } TMPQHeader; #pragma pack(pop) -// Hash table entry. All files in the archive are searched by their hashes. + +// Hash entry. All files in the archive are searched by their hashes. typedef struct _TMPQHash { // The hash of the file path, using method A. DWORD dwName1; - + // The hash of the file path, using method B. DWORD dwName2; @@ -635,13 +548,12 @@ typedef struct _TMPQHash // The platform the file is used for. 0 indicates the default platform. // No other values have been observed. - BYTE Platform; - BYTE Reserved; + // Note: wPlatform is actually just BYTE, but since it has never been used, we don't care. + USHORT wPlatform; #else - BYTE Platform; - BYTE Reserved; + USHORT wPlatform; USHORT lcLocale; #endif @@ -655,317 +567,270 @@ typedef struct _TMPQHash DWORD dwBlockIndex; } TMPQHash; + // File description block contains informations about the file typedef struct _TMPQBlock { // Offset of the beginning of the file, relative to the beginning of the archive. DWORD dwFilePos; - + // Compressed file size DWORD dwCSize; - + // Only valid if the block is a file; otherwise meaningless, and should be 0. // If the file is compressed, this is the size of the uncompressed file data. - DWORD dwFSize; - + DWORD dwFSize; + // Flags for the file. See MPQ_FILE_XXXX constants - DWORD dwFlags; + DWORD dwFlags; } TMPQBlock; // Patch file information, preceding the sector offset table typedef struct _TPatchInfo { - DWORD dwLength; // Length of patch info header, in bytes - DWORD dwFlags; // Flags. 0x80000000 = MD5 (?) - DWORD dwDataSize; // Uncompressed size of the patch file - BYTE md5[0x10]; // MD5 of the entire patch file after decompression + DWORD dwLength; // Length of patch info header, in bytes + DWORD dwFlags; // Flags. 0x80000000 = MD5 (?) + DWORD dwDataSize; // Uncompressed size of the patch file + BYTE md5[0x10]; // MD5 of the entire patch file after decompression // Followed by the sector table (variable length) } TPatchInfo; +// Header for PTCH files +typedef struct _TPatchHeader +{ + //-- PATCH header ----------------------------------- + DWORD dwSignature; // 'PTCH' + DWORD dwSizeOfPatchData; // Size of the entire patch (decompressed) + DWORD dwSizeBeforePatch; // Size of the file before patch + DWORD dwSizeAfterPatch; // Size of file after patch + + //-- MD5 block -------------------------------------- + DWORD dwMD5; // 'MD5_' + DWORD dwMd5BlockSize; // Size of the MD5 block, including the signature and size itself + BYTE md5_before_patch[0x10]; // MD5 of the original (unpached) file + BYTE md5_after_patch[0x10]; // MD5 of the patched file + + //-- XFRM block ------------------------------------- + DWORD dwXFRM; // 'XFRM' + DWORD dwXfrmBlockSize; // Size of the XFRM block, includes XFRM header and patch data + DWORD dwPatchType; // Type of patch ('BSD0' or 'COPY') + + // Followed by the patch data +} TPatchHeader; + +#define SIZE_OF_XFRM_HEADER 0x0C + // This is the combined file entry for maintaining file list in the MPQ. // This structure is combined from block table, hi-block table, // (attributes) file and from (listfile). typedef struct _TFileEntry { - ULONGLONG FileNameHash; // Jenkins hash of the file name. Only used when the MPQ has BET table. - ULONGLONG ByteOffset; // Position of the file content in the MPQ, relative to the MPQ header - ULONGLONG FileTime; // FileTime from the (attributes) file. 0 if not present. - DWORD dwFileSize; // Decompressed size of the file - DWORD dwCmpSize; // Compressed size of the file (i.e., size of the file data in the MPQ) - DWORD dwFlags; // File flags (from block table) - DWORD dwCrc32; // CRC32 from (attributes) file. 0 if not present. - BYTE md5[MD5_DIGEST_SIZE]; // File MD5 from the (attributes) file. 0 if not present. - char * szFileName; // File name. NULL if not known. + ULONGLONG ByteOffset; // Position of the file content in the MPQ, relative to the MPQ header + ULONGLONG FileTime; // FileTime from the (attributes) file. 0 if not present. + ULONGLONG BetHash; // Lower part of the file name hash. Only used when the MPQ has BET table. + DWORD dwHashIndex; // Index to the hash table. Only used when the MPQ has classic hash table + DWORD dwHetIndex; // Index to the HET table. Only used when the MPQ has HET table + DWORD dwFileSize; // Decompressed size of the file + DWORD dwCmpSize; // Compressed size of the file (i.e., size of the file data in the MPQ) + DWORD dwFlags; // File flags (from block table) + USHORT lcLocale; // Locale ID for the file + USHORT wPlatform; // Platform ID for the file + DWORD dwCrc32; // CRC32 from (attributes) file. 0 if not present. + unsigned char md5[MD5_DIGEST_SIZE]; // File MD5 from the (attributes) file. 0 if not present. + char * szFileName; // File name. NULL if not known. } TFileEntry; // Common header for HET and BET tables -typedef struct _TMPQExtHeader +typedef struct _TMPQExtTable { - DWORD dwSignature; // 'HET\x1A' or 'BET\x1A' - DWORD dwVersion; // Version. Seems to be always 1 - DWORD dwDataSize; // Size of the contained table + DWORD dwSignature; // 'HET\x1A' or 'BET\x1A' + DWORD dwVersion; // Version. Seems to be always 1 + DWORD dwDataSize; // Size of the contained table // Followed by the table header // Followed by the table data -} TMPQExtHeader; +} TMPQExtTable; -// Structure for HET table header -typedef struct _TMPQHetHeader +// +// MPQ data bitmap, can be found at (FileSize - sizeof(TMPQBlockMap)) +// +// There is bit map of the entire MPQ before TMPQBitmap. Each 0x4000-byte +// block is represented by one bit (including the last, eventually incomplete block). +// +typedef struct _TMPQBitmap { - TMPQExtHeader ExtHdr; - - DWORD dwTableSize; // Size of the entire HET table, including HET_TABLE_HEADER (in bytes) - DWORD dwEntryCount; // Number of occupied entries in the HET table - DWORD dwTotalCount; // Total number of entries in the HET table - DWORD dwNameHashBitSize; // Size of the name hash entry (in bits) - DWORD dwIndexSizeTotal; // Total size of file index (in bits) - DWORD dwIndexSizeExtra; // Extra bits in the file index - DWORD dwIndexSize; // Effective size of the file index (in bits) - DWORD dwIndexTableSize; // Size of the block index subtable (in bytes) - -} TMPQHetHeader; - -// Structure for BET table header -typedef struct _TMPQBetHeader -{ - TMPQExtHeader ExtHdr; - - DWORD dwTableSize; // Size of the entire BET table, including the header (in bytes) - DWORD dwEntryCount; // Number of entries in the BET table. Must match HET_TABLE_HEADER::dwEntryCount - DWORD dwUnknown08; - DWORD dwTableEntrySize; // Size of one table entry (in bits) - DWORD dwBitIndex_FilePos; // Bit index of the file position (within the entry record) - DWORD dwBitIndex_FileSize; // Bit index of the file size (within the entry record) - DWORD dwBitIndex_CmpSize; // Bit index of the compressed size (within the entry record) - DWORD dwBitIndex_FlagIndex; // Bit index of the flag index (within the entry record) - DWORD dwBitIndex_Unknown; // Bit index of the ??? (within the entry record) - DWORD dwBitCount_FilePos; // Bit size of file position (in the entry record) - DWORD dwBitCount_FileSize; // Bit size of file size (in the entry record) - DWORD dwBitCount_CmpSize; // Bit size of compressed file size (in the entry record) - DWORD dwBitCount_FlagIndex; // Bit size of flags index (in the entry record) - DWORD dwBitCount_Unknown; // Bit size of ??? (in the entry record) - DWORD dwBitTotal_NameHash2; // Total bit size of the NameHash2 - DWORD dwBitExtra_NameHash2; // Extra bits in the NameHash2 - DWORD dwBitCount_NameHash2; // Effective size of NameHash2 (in bits) - DWORD dwNameHashArraySize; // Size of NameHash2 table, in bytes - DWORD dwFlagCount; // Number of flags in the following array - -} TMPQBetHeader; + DWORD dwSignature; // 'ptv3' (MPQ_BLOCK_MAP_SIGNATURE) + DWORD dwAlways3; // Unknown, seems to always have value of 3 + DWORD dwBuildNumber; // Game build number for that MPQ + DWORD dwMapOffsetLo; // Low 32-bits of the offset of the bit map + DWORD dwMapOffsetHi; // High 32-bits of the offset of the bit map + DWORD dwBlockSize; // Size of one block (usually 0x4000 bytes) +} TMPQBitmap; // Structure for parsed HET table typedef struct _TMPQHetTable { - TBitArray * pBetIndexes; // Bit array of FileIndex values - LPBYTE pNameHashes; // Array of NameHash1 values (NameHash1 = upper 8 bits of FileName hashe) - ULONGLONG AndMask64; // AND mask used for calculating file name hash - ULONGLONG OrMask64; // OR mask used for setting the highest bit of the file name hash + TBitArray * pBetIndexes; // Bit array of indexes to BET tables + LPBYTE pHetHashes; // Array of HET hashes. Each entry has size of 1 byte + ULONGLONG AndMask64; // AND mask used for calculating file name hash + ULONGLONG OrMask64; // OR mask used for setting the highest bit of the file name hash - DWORD dwEntryCount; // Number of occupied entries in the HET table - DWORD dwTotalCount; // Number of entries in both NameHash and FileIndex table - DWORD dwNameHashBitSize; // Size of the name hash entry (in bits) - DWORD dwIndexSizeTotal; // Total size of one entry in pBetIndexes (in bits) - DWORD dwIndexSizeExtra; // Extra bits in the entry in pBetIndexes - DWORD dwIndexSize; // Effective size of one entry in pBetIndexes (in bits) + DWORD dwIndexSizeTotal; // Total size of one entry in pBetIndexes (in bits) + DWORD dwIndexSizeExtra; // Extra bits in the entry in pBetIndexes + DWORD dwIndexSize; // Effective size of one entry in pBetIndexes (in bits) + DWORD dwMaxFileCount; // Maximum number of files in the MPQ + DWORD dwHashTableSize; // Number of entries in pBetHashes + DWORD dwHashBitSize; // Effective number of bits in the hash } TMPQHetTable; // Structure for parsed BET table typedef struct _TMPQBetTable { - TBitArray * pNameHashes; // Array of NameHash2 entries (lower 24 bits of FileName hash) - TBitArray * pFileTable; // Bit-based file table - LPDWORD pFileFlags; // Array of file flags + TBitArray * pBetHashes; // Array of BET hashes + TBitArray * pFileTable; // Bit-based file table + LPDWORD pFileFlags; // Array of file flags - DWORD dwTableEntrySize; // Size of one table entry, in bits - DWORD dwBitIndex_FilePos; // Bit index of the file position in the table entry - DWORD dwBitIndex_FileSize; // Bit index of the file size in the table entry - DWORD dwBitIndex_CmpSize; // Bit index of the compressed size in the table entry - DWORD dwBitIndex_FlagIndex; // Bit index of the flag index in the table entry - DWORD dwBitIndex_Unknown; // Bit index of ??? in the table entry - DWORD dwBitCount_FilePos; // Size of file offset (in bits) within table entry - DWORD dwBitCount_FileSize; // Size of file size (in bits) within table entry - DWORD dwBitCount_CmpSize; // Size of compressed file size (in bits) within table entry - DWORD dwBitCount_FlagIndex; // Size of flag index (in bits) within table entry - DWORD dwBitCount_Unknown; // Size of ??? (in bits) within table entry - DWORD dwBitTotal_NameHash2; // Total size of the NameHash2 - DWORD dwBitExtra_NameHash2; // Extra bits in the NameHash2 - DWORD dwBitCount_NameHash2; // Effective size of the NameHash2 - DWORD dwEntryCount; // Number of entries - DWORD dwFlagCount; // Number of file flags in pFileFlags + DWORD dwTableEntrySize; // Size of one table entry, in bits + DWORD dwBitIndex_FilePos; // Bit index of the file position in the table entry + DWORD dwBitIndex_FileSize; // Bit index of the file size in the table entry + DWORD dwBitIndex_CmpSize; // Bit index of the compressed size in the table entry + DWORD dwBitIndex_FlagIndex; // Bit index of the flag index in the table entry + DWORD dwBitIndex_Unknown; // Bit index of ??? in the table entry + DWORD dwBitCount_FilePos; // Size of file offset (in bits) within table entry + DWORD dwBitCount_FileSize; // Size of file size (in bits) within table entry + DWORD dwBitCount_CmpSize; // Size of compressed file size (in bits) within table entry + DWORD dwBitCount_FlagIndex; // Size of flag index (in bits) within table entry + DWORD dwBitCount_Unknown; // Size of ??? (in bits) within table entry + DWORD dwBetHashSizeTotal; // Total size of bet hash + DWORD dwBetHashSizeExtra; // Extra bits in the bet hash + DWORD dwBetHashSize; // Effective size of the bet hash + DWORD dwFileCount; // Number of files (usually equal to maximum number of files) + DWORD dwFlagCount; // Number of entries in pFileFlags } TMPQBetTable; -// Structure for patch prefix -typedef struct _TMPQNamePrefix -{ - size_t nLength; // Length of this patch prefix. Can be 0 - char szPatchPrefix[1]; // Patch name prefix (variable length). If not empty, it always starts with backslash. -} TMPQNamePrefix; - -// Structure for name cache -typedef struct _TMPQNameCache -{ - DWORD FirstNameOffset; // Offset of the first name in the name list (in bytes) - DWORD FreeSpaceOffset; // Offset of the first free byte in the name cache (in bytes) - DWORD TotalCacheSize; // Size, in bytes, of the cache. Includes wildcard - DWORD SearchOffset; // Used by SListFileFindFirstFile - - // Followed by search mask (ASCIIZ, '\0' if none) - // Followed by name cache (ANSI multistring) - -} TMPQNameCache; - // Archive handle structure typedef struct _TMPQArchive { - TFileStream * pStream; // Open stream for the MPQ + TFileStream * pStream; // Open stream for the MPQ - ULONGLONG UserDataPos; // Position of user data (relative to the begin of the file) - ULONGLONG MpqPos; // MPQ header offset (relative to the begin of the file) - ULONGLONG FileSize; // Size of the file at the moment of file open + ULONGLONG UserDataPos; // Position of user data (relative to the begin of the file) + ULONGLONG MpqPos; // MPQ header offset (relative to the begin of the file) - struct _TMPQArchive * haPatch; // Pointer to patch archive, if any - struct _TMPQArchive * haBase; // Pointer to base ("previous version") archive, if any - TMPQNamePrefix * pPatchPrefix; // Patch prefix to precede names of patch files + struct _TMPQArchive * haPatch; // Pointer to patch archive, if any + struct _TMPQArchive * haBase; // Pointer to base ("previous version") archive, if any + char szPatchPrefix[MPQ_PATCH_PREFIX_LEN]; // Prefix for file names in patch MPQs + size_t cchPatchPrefix; // Length of the patch prefix, in characters - TMPQUserData * pUserData; // MPQ user data (NULL if not present in the file) - TMPQHeader * pHeader; // MPQ file header - TMPQHash * pHashTable; // Hash table - TMPQHetTable * pHetTable; // HET table - TFileEntry * pFileTable; // File table - HASH_STRING pfnHashString; // Hashing function that will convert the file name into hash - - TMPQUserData UserData; // MPQ user data. Valid only when ID_MPQ_USERDATA has been found - DWORD HeaderData[MPQ_HEADER_DWORDS]; // Storage for MPQ header + TMPQUserData * pUserData; // MPQ user data (NULL if not present in the file) + TMPQHeader * pHeader; // MPQ file header + TMPQBitmap * pBitmap; // MPQ bitmap + TMPQHash * pHashTable; // Hash table + TMPQHetTable * pHetTable; // Het table + TFileEntry * pFileTable; // File table + + TMPQUserData UserData; // MPQ user data. Valid only when ID_MPQ_USERDATA has been found + BYTE HeaderData[MPQ_HEADER_SIZE_V4]; // Storage for MPQ header DWORD dwHETBlockSize; DWORD dwBETBlockSize; - DWORD dwMaxFileCount; // Maximum number of files in the MPQ. Also total size of the file table. - DWORD dwFileTableSize; // Current size of the file table, e.g. index of the entry past the last occupied one - DWORD dwReservedFiles; // Number of entries reserved for internal MPQ files (listfile, attributes) - DWORD dwSectorSize; // Default size of one file sector - DWORD dwFileFlags1; // Flags for (listfile) - DWORD dwFileFlags2; // Flags for (attributes) - DWORD dwFileFlags3; // Flags for (signature) - DWORD dwAttrFlags; // Flags for the (attributes) file, see MPQ_ATTRIBUTE_XXX - DWORD dwFlags; // See MPQ_FLAG_XXXXX - DWORD dwSubType; // See MPQ_SUBTYPE_XXX - - SFILE_ADDFILE_CALLBACK pfnAddFileCB; // Callback function for adding files - void * pvAddFileUserData; // User data thats passed to the callback - - SFILE_COMPACT_CALLBACK pfnCompactCB; // Callback function for compacting the archive - ULONGLONG CompactBytesProcessed; // Amount of bytes that have been processed during a particular compact call - ULONGLONG CompactTotalBytes; // Total amount of bytes to be compacted - void * pvCompactUserData; // User data thats passed to the callback -} TMPQArchive; + DWORD dwFileTableSize; // Current size of the file table, e.g. index of the entry past the last occupied one + DWORD dwMaxFileCount; // Maximum number of files in the MPQ + DWORD dwSectorSize; // Default size of one file sector + DWORD dwFileFlags1; // Flags for (listfile) + DWORD dwFileFlags2; // Flags for (attributes) + DWORD dwAttrFlags; // Flags for the (attributes) file, see MPQ_ATTRIBUTE_XXX + DWORD dwFlags; // See MPQ_FLAG_XXXXX +} TMPQArchive; // File handle structure typedef struct _TMPQFile { - TFileStream * pStream; // File stream. Only used on local files - TMPQArchive * ha; // Archive handle - TMPQHash * pHashEntry; // Pointer to hash table entry, if the file was open using hash table - TFileEntry * pFileEntry; // File entry for the file - ULONGLONG RawFilePos; // Offset in MPQ archive (relative to file begin) - ULONGLONG MpqFilePos; // Offset in MPQ archive (relative to MPQ header) - DWORD dwHashIndex; // Hash table index (0xFFFFFFFF if not used) - DWORD dwFileKey; // Decryption key - DWORD dwFilePos; // Current file position - DWORD dwMagic; // 'FILE' + TFileStream * pStream; // File stream. Only used on local files + TMPQArchive * ha; // Archive handle + TFileEntry * pFileEntry; // File entry for the file + DWORD dwFileKey; // Decryption key + DWORD dwFilePos; // Current file position + ULONGLONG RawFilePos; // Offset in MPQ archive (relative to file begin) + ULONGLONG MpqFilePos; // Offset in MPQ archive (relative to MPQ header) + DWORD dwMagic; // 'FILE' - struct _TMPQFile * hfPatch; // Pointer to opened patch file + struct _TMPQFile * hfPatchFile; // Pointer to opened patch file + TPatchHeader * pPatchHeader; // Patch header. Only used if the file is a patch file + LPBYTE pbFileData; // Loaded and patched file data. Only used if the file is a patch file + DWORD cbFileData; // Size of loaded patched data - TPatchInfo * pPatchInfo; // Patch info block, preceding the sector table - LPDWORD SectorOffsets; // Position of each file sector, relative to the begin of the file. Only for compressed files. - LPDWORD SectorChksums; // Array of sector checksums (either ADLER32 or MD5) values for each file sector - LPBYTE pbFileData; // Data of the file (single unit files, patched files) - DWORD cbFileData; // Size of file data - DWORD dwCompression0; // Compression that will be used on the first file sector - DWORD dwSectorCount; // Number of sectors in the file - DWORD dwPatchedFileSize; // Size of patched file. Used when saving patch file to the MPQ - DWORD dwDataSize; // Size of data in the file (on patch files, this differs from file size in block table entry) + TPatchInfo * pPatchInfo; // Patch info block, preceding the sector table + DWORD * SectorOffsets; // Position of each file sector, relative to the begin of the file. Only for compressed files. + DWORD * SectorChksums; // Array of sector checksums (either ADLER32 or MD5) values for each file sector + DWORD dwSectorCount; // Number of sectors in the file + DWORD dwPatchedFileSize; // Size of patched file. Used when saving patch file to the MPQ + DWORD dwDataSize; // Size of data in the file (on patch files, this differs from file size in block table entry) - LPBYTE pbFileSector; // Last loaded file sector. For single unit files, entire file content - DWORD dwSectorOffs; // File position of currently loaded file sector - DWORD dwSectorSize; // Size of the file sector. For single unit files, this is equal to the file size + LPBYTE pbFileSector; // Last loaded file sector. For single unit files, entire file content + DWORD dwSectorOffs; // File position of currently loaded file sector + DWORD dwSectorSize; // Size of the file sector. For single unit files, this is equal to the file size - unsigned char hctx[HASH_STATE_SIZE]; // Hash state for MD5. Used when saving file to MPQ - DWORD dwCrc32; // CRC32 value, used when saving file to MPQ + unsigned char hctx[HASH_STATE_SIZE];// Hash state for MD5. Used when saving file to MPQ + DWORD dwCrc32; // CRC32 value, used when saving file to MPQ - int nAddFileError; // Result of the "Add File" operations - - bool bLoadedSectorCRCs; // If true, we already tried to load sector CRCs - bool bCheckSectorCRCs; // If true, then SFileReadFile will check sector CRCs when reading the file - bool bIsWriteHandle; // If true, this handle has been created by SFileCreateFile + bool bLoadedSectorCRCs; // If true, we already tried to load sector CRCs + bool bCheckSectorCRCs; // If true, then SFileReadFile will check sector CRCs when reading the file + bool bIsWriteHandle; // If true, this handle has been created by SFileCreateFile + bool bErrorOccured; // If true, then at least one error occured during saving the file to the archive } TMPQFile; // Structure for SFileFindFirstFile and SFileFindNextFile typedef struct _SFILE_FIND_DATA { - char cFileName[MAX_PATH]; // Full name of the found file - char * szPlainName; // Plain name of the found file - DWORD dwHashIndex; // Hash table index for the file (HAH_ENTRY_FREE if no hash table) - DWORD dwBlockIndex; // Block table index for the file - DWORD dwFileSize; // File size in bytes - DWORD dwFileFlags; // MPQ file flags - DWORD dwCompSize; // Compressed file size - DWORD dwFileTimeLo; // Low 32-bits of the file time (0 if not present) - DWORD dwFileTimeHi; // High 32-bits of the file time (0 if not present) - LCID lcLocale; // Locale version + char cFileName[MAX_PATH]; // Full name of the found file + char * szPlainName; // Plain name of the found file + DWORD dwHashIndex; // Hash table index for the file + DWORD dwBlockIndex; // Block table index for the file + DWORD dwFileSize; // File size in bytes + DWORD dwFileFlags; // MPQ file flags + DWORD dwCompSize; // Compressed file size + DWORD dwFileTimeLo; // Low 32-bits of the file time (0 if not present) + DWORD dwFileTimeHi; // High 32-bits of the file time (0 if not present) + LCID lcLocale; // Locale version } SFILE_FIND_DATA, *PSFILE_FIND_DATA; typedef struct _SFILE_CREATE_MPQ { - DWORD cbSize; // Size of this structure, in bytes - DWORD dwMpqVersion; // Version of the MPQ to be created - void *pvUserData; // Reserved, must be NULL - DWORD cbUserData; // Reserved, must be 0 - DWORD dwStreamFlags; // Stream flags for creating the MPQ - DWORD dwFileFlags1; // File flags for (listfile). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwFileFlags2; // File flags for (attributes). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwFileFlags3; // File flags for (signature). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwAttrFlags; // Flags for the (attributes) file. If 0, no attributes will be created - DWORD dwSectorSize; // Sector size for compressed files - DWORD dwRawChunkSize; // Size of raw data chunk - DWORD dwMaxFileCount; // File limit for the MPQ + DWORD cbSize; // Size of this structure, in bytes + DWORD dwMpqVersion; // Version of the MPQ to be created + void *pvUserData; // Reserved, must be NULL + DWORD cbUserData; // Reserved, must be 0 + DWORD dwStreamFlags; // Stream flags for creating the MPQ + DWORD dwFileFlags1; // File flags for (listfile). 0 = default + DWORD dwFileFlags2; // File flags for (attributes). 0 = default + DWORD dwAttrFlags; // Flags for the (attributes) file. If 0, no attributes will be created + DWORD dwSectorSize; // Sector size for compressed files + DWORD dwRawChunkSize; // Size of raw data chunk + DWORD dwMaxFileCount; // File limit for the MPQ } SFILE_CREATE_MPQ, *PSFILE_CREATE_MPQ; //----------------------------------------------------------------------------- // Stream support - functions -// Structure used by FileStream_GetBitmap -typedef struct _TStreamBitmap -{ - ULONGLONG StreamSize; // Size of the stream, in bytes - DWORD BitmapSize; // Size of the block map, in bytes - DWORD BlockCount; // Number of blocks in the stream - DWORD BlockSize; // Size of one block - DWORD IsComplete; // Nonzero if the file is complete - - // Followed by the BYTE array, each bit means availability of one block - -} TStreamBitmap; - -// UNICODE versions of the file access functions TFileStream * FileStream_CreateFile(const TCHAR * szFileName, DWORD dwStreamFlags); TFileStream * FileStream_OpenFile(const TCHAR * szFileName, DWORD dwStreamFlags); -const TCHAR * FileStream_GetFileName(TFileStream * pStream); -size_t FileStream_Prefix(const TCHAR * szFileName, DWORD * pdwProvider); - -bool FileStream_SetCallback(TFileStream * pStream, SFILE_DOWNLOAD_CALLBACK pfnCallback, void * pvUserData); - -bool FileStream_GetBitmap(TFileStream * pStream, void * pvBitmap, DWORD cbBitmap, LPDWORD pcbLengthNeeded); +TCHAR * FileStream_GetFileName(TFileStream * pStream); +bool FileStream_IsReadOnly(TFileStream * pStream); bool FileStream_Read(TFileStream * pStream, ULONGLONG * pByteOffset, void * pvBuffer, DWORD dwBytesToRead); bool FileStream_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const void * pvBuffer, DWORD dwBytesToWrite); -bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize); -bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize); bool FileStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset); +bool FileStream_SetPos(TFileStream * pStream, ULONGLONG ByteOffset); +bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize); +bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize); bool FileStream_GetTime(TFileStream * pStream, ULONGLONG * pFT); bool FileStream_GetFlags(TFileStream * pStream, LPDWORD pdwStreamFlags); -bool FileStream_Replace(TFileStream * pStream, TFileStream * pNewStream); +bool FileStream_Switch(TFileStream * pStream, TFileStream * pTempStream); +bool FileStream_SetBitmap(TFileStream * pStream, TFileBitmap * pBitmap); +bool FileStream_GetBitmap(TFileStream * pStream, TFileBitmap * pBitmap, DWORD Length, LPDWORD LengthNeeded); void FileStream_Close(TFileStream * pStream); //----------------------------------------------------------------------------- @@ -991,21 +856,21 @@ LCID WINAPI SFileSetLocale(LCID lcNewLocale); // Functions for archive manipulation bool WINAPI SFileOpenArchive(const TCHAR * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMpq); -bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWORD dwMaxFileCount, HANDLE * phMpq); +bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwFlags, DWORD dwMaxFileCount, HANDLE * phMpq); bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCreateInfo, HANDLE * phMpq); -bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData); +bool WINAPI SFileGetArchiveBitmap(HANDLE hMpq, TFileBitmap * pBitmap, DWORD Length, LPDWORD LengthNeeded); bool WINAPI SFileFlushArchive(HANDLE hMpq); bool WINAPI SFileCloseArchive(HANDLE hMpq); // Adds another listfile into MPQ. The currently added listfile(s) remain, // so you can use this API to combining more listfiles. // Note that this function is internally called by SFileFindFirstFile -int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile); +int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile); // Archive compacting -bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK CompactCB, void * pvUserData); -bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool bReserved); +bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK CompactCB, void * pvData); +bool WINAPI SFileCompactArchive(HANDLE hMpq, const char * szListFile, bool bReserved); // Changing the maximum file count DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq); @@ -1026,17 +891,16 @@ bool WINAPI SFileIsPatchedArchive(HANDLE hMpq); // Functions for file manipulation // Reading from MPQ file -bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName); bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile); DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh); DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod); bool WINAPI SFileReadFile(HANDLE hFile, void * lpBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped); bool WINAPI SFileCloseFile(HANDLE hFile); -// Retrieving info about a file in the archive -bool WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, SFileInfoClass InfoClass, void * pvFileInfo, DWORD cbFileInfo, LPDWORD pcbLengthNeeded); +// Retrieving info about the file +bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName); bool WINAPI SFileGetFileName(HANDLE hFile, char * szFileName); -bool WINAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass); +bool WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType, void * pvFileInfo, DWORD cbFileInfo, LPDWORD pcbLengthNeeded); // High-level extract function bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope); @@ -1055,17 +919,16 @@ DWORD WINAPI SFileVerifyFile(HANDLE hMpq, const char * szFileName, DWORD dwFlag int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * szFileName); // Verifies the signature, if present -bool WINAPI SFileSignArchive(HANDLE hMpq, DWORD dwSignatureType); DWORD WINAPI SFileVerifyArchive(HANDLE hMpq); //----------------------------------------------------------------------------- // Functions for file searching -HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile); +HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile); bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); bool WINAPI SFileFindClose(HANDLE hFind); -HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const TCHAR * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); +HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); bool WINAPI SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); bool WINAPI SListFileFindClose(HANDLE hFind); @@ -1079,32 +942,32 @@ bool WINAPI SFileCreateFile(HANDLE hMpq, const char * szArchivedName, ULONGLON bool WINAPI SFileWriteFile(HANDLE hFile, const void * pvData, DWORD dwSize, DWORD dwCompression); bool WINAPI SFileFinishFile(HANDLE hFile); -bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext = MPQ_COMPRESSION_NEXT_SAME); -bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags); -bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); +bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext); +bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags); +bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope); bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szOldFileName, const char * szNewFileName); bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); bool WINAPI SFileSetDataCompression(DWORD DataCompression); -bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData); +bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvData); //----------------------------------------------------------------------------- // Compression and decompression -int WINAPI SCompImplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompExplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompCompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel); -int WINAPI SCompDecompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); +int WINAPI SCompImplode (char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer); +int WINAPI SCompExplode (char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer); +int WINAPI SCompCompress (char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel); +int WINAPI SCompDecompress (char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer); +int WINAPI SCompDecompress2(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer); //----------------------------------------------------------------------------- // Non-Windows support for SetLastError/GetLastError #ifndef PLATFORM_WINDOWS -void SetLastError(DWORD dwErrCode); -DWORD GetLastError(); +void SetLastError(int err); +int GetLastError(); #endif @@ -1113,8 +976,8 @@ DWORD GetLastError(); // possibility to use them together with StormLib (StormXXX instead of SFileXXX) #ifdef __LINK_STORM_DLL__ - #define STORM_ALTERNATE_NAMES // Force storm_dll.h to use alternate fnc names - #include "..\storm_dll\storm_dll.h" +#define STORM_ALTERNATE_NAMES // Force storm_dll.h to use alternate fnc names +#include "..\storm_dll\storm_dll.h" #endif // __LINK_STORM_DLL__ #ifdef __cplusplus diff --git a/dep/StormLib/src/StormPort.h b/dep/StormLib/src/StormPort.h index 34151edf4..5673516c1 100644 --- a/dep/StormLib/src/StormPort.h +++ b/dep/StormLib/src/StormPort.h @@ -21,313 +21,221 @@ /* 24.07.04 1.03 Sam Mac OS X compatibility */ /* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */ /* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ -/* 17.10.12 1.05 Lad Moved error codes so they don't overlap with errno.h */ /*****************************************************************************/ #ifndef __STORMPORT_H__ #define __STORMPORT_H__ #ifndef __cplusplus - #define bool char - #define true 1 - #define false 0 +#define bool char +#define true 1 +#define false 0 #endif -//----------------------------------------------------------------------------- // Defines for Windows +#if !defined(PLATFORM_DEFINED) && (defined(WIN32) || defined(WIN64)) -#if !defined(PLATFORM_DEFINED) && defined(_WIN32) +// In MSVC 8.0, there are some functions declared as deprecated. +#if _MSC_VER >= 1400 +#define _CRT_SECURE_NO_DEPRECATE +#define _CRT_NON_CONFORMING_SWPRINTFS +#endif - // In MSVC 8.0, there are some functions declared as deprecated. - #if _MSC_VER >= 1400 - #define _CRT_SECURE_NO_DEPRECATE - #define _CRT_NON_CONFORMING_SWPRINTFS - #endif +#include +#include +#include +#include +#include +#include +#define PLATFORM_LITTLE_ENDIAN - #include - #include - #include - #include - #include - #include - #define PLATFORM_LITTLE_ENDIAN +#ifdef WIN64 +#define PLATFORM_64BIT +#else +#define PLATFORM_32BIT +#endif - #ifdef _WIN64 - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif - - #define PLATFORM_WINDOWS - #define PLATFORM_DEFINED // The platform is known now +#define PLATFORM_WINDOWS +#define PLATFORM_DEFINED // The platform is known now #endif -//----------------------------------------------------------------------------- // Defines for Mac - #if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac BSD API - // Macintosh - #include - #include - #include - #include - #include - #include - #include +// Macintosh +#include +#include +#include +#include +#include +#include +#include - // Support for PowerPC on Max OS X - #if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1) - #include - #include - #endif +#define PKEXPORT +#define __SYS_ZLIB +#define __SYS_BZLIB - #define PKEXPORT - #define __SYS_ZLIB - #define __SYS_BZLIB +#ifndef __BIG_ENDIAN__ +#define PLATFORM_LITTLE_ENDIAN +#endif - #ifndef __BIG_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN - #endif - - #define PLATFORM_MAC - #define PLATFORM_DEFINED // The platform is known now +#define PLATFORM_MAC +#define PLATFORM_DEFINED // The platform is known now #endif -#if !defined(PLATFORM_DEFINED) && defined(__HAIKU__) - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #ifndef __BIG_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN - #endif - - #define PLATFORM_HAIKU - #define PLATFORM_DEFINED // The platform is known now - -#endif - -//----------------------------------------------------------------------------- // Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* - #if !defined(PLATFORM_DEFINED) - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include - #define PLATFORM_LITTLE_ENDIAN - #define PLATFORM_LINUX - # if defined (__FreeBSD__) - # define PLATFORM_FREEBSD - # endif - #define PLATFORM_DEFINED +#define PLATFORM_LITTLE_ENDIAN +#define PLATFORM_LINUX +#define PLATFORM_DEFINED #endif -//----------------------------------------------------------------------------- -// Definition of Windows-specific types for non-Windows platforms - +// Definition of Windows-specific structures for non-Windows platforms #ifndef PLATFORM_WINDOWS - #if __LP64__ - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif +#if __LP64__ +#define PLATFORM_64BIT +#else +#define PLATFORM_32BIT +#endif - // Typedefs for ANSI C - typedef unsigned char BYTE; - typedef unsigned short USHORT; - typedef int LONG; - typedef unsigned int DWORD; - typedef unsigned long DWORD_PTR; - typedef long LONG_PTR; - typedef long INT_PTR; - typedef long long LONGLONG; - typedef unsigned long long ULONGLONG; - typedef void * HANDLE; - typedef void * LPOVERLAPPED; // Unsupported on Linux and Mac - typedef char TCHAR; - typedef unsigned int LCID; - typedef LONG * PLONG; - typedef DWORD * LPDWORD; - typedef BYTE * LPBYTE; - typedef const char * LPCTSTR; - typedef const char * LPCSTR; - typedef char * LPTSTR; - typedef char * LPSTR; +// Typedefs for ANSI C +typedef unsigned char BYTE; +typedef unsigned short USHORT; +typedef int LONG; +typedef unsigned int DWORD; +typedef unsigned long DWORD_PTR; +typedef long LONG_PTR; +typedef long INT_PTR; +typedef long long LONGLONG; +typedef unsigned long long ULONGLONG; +typedef void * HANDLE; +typedef void * LPOVERLAPPED; // Unsupported on Linux and Mac +typedef char TCHAR; +typedef unsigned int LCID; +typedef LONG * PLONG; +typedef DWORD * LPDWORD; +typedef BYTE * LPBYTE; - #ifdef PLATFORM_32BIT - #define _LZMA_UINT32_IS_ULONG - #endif +#ifdef PLATFORM_32BIT +#define _LZMA_UINT32_IS_ULONG +#endif - // Some Windows-specific defines - #ifndef MAX_PATH - #define MAX_PATH 1024 - #endif +// Some Windows-specific defines +#ifndef MAX_PATH +#define MAX_PATH 1024 +#endif - #ifndef _countof - #define _countof(x) (sizeof(x) / sizeof(x[0])) - #endif +#define WINAPI - #define WINAPI +#define FILE_BEGIN SEEK_SET +#define FILE_CURRENT SEEK_CUR +#define FILE_END SEEK_END - #define FILE_BEGIN SEEK_SET - #define FILE_CURRENT SEEK_CUR - #define FILE_END SEEK_END +#define _T(x) x +#define _tcslen strlen +#define _tcscpy strcpy +#define _tcscat strcat +#define _tcsrchr strrchr +#define _tprintf printf +#define _stprintf sprintf +#define _tremove remove - #define _T(x) x - #define _tcslen strlen - #define _tcscpy strcpy - #define _tcscat strcat - #define _tcschr strchr - #define _tcsrchr strrchr - #define _tcsstr strstr - #define _tcsnicmp strncasecmp - #define _tprintf printf - #define _stprintf sprintf - #define _tremove remove - #define _tmain main +#define _stricmp strcasecmp +#define _strnicmp strncasecmp +#define _tcsnicmp strncasecmp - #define _stricmp strcasecmp - #define _strnicmp strncasecmp - #define _tcsicmp strcasecmp - #define _tcsnicmp strncasecmp - -#endif // !PLATFORM_WINDOWS +#endif // !WIN32 // 64-bit calls are supplied by "normal" calls on Mac -#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU) || defined(PLATFORM_FREEBSD) - #define stat64 stat - #define fstat64 fstat - #define lseek64 lseek - #define ftruncate64 ftruncate - #define off64_t off_t - #define O_LARGEFILE 0 -#endif - -#if defined(PLATFORM_FREEBSD) - #define lstat64 lstat +#if defined(PLATFORM_MAC) +#define stat64 stat +#define fstat64 fstat +#define lseek64 lseek +#define off64_t off_t +#define O_LARGEFILE 0 #endif // Platform-specific error codes for UNIX-based platforms -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU) - #define ERROR_SUCCESS 0 - #define ERROR_FILE_NOT_FOUND ENOENT - #define ERROR_ACCESS_DENIED EPERM - #define ERROR_INVALID_HANDLE EBADF - #define ERROR_NOT_ENOUGH_MEMORY ENOMEM - #define ERROR_NOT_SUPPORTED ENOTSUP - #define ERROR_INVALID_PARAMETER EINVAL - #define ERROR_NEGATIVE_SEEK EINVAL - #define ERROR_DISK_FULL ENOSPC - #define ERROR_ALREADY_EXISTS EEXIST - #define ERROR_INSUFFICIENT_BUFFER ENOBUFS - #define ERROR_BAD_FORMAT 1000 // No such error code under Linux - #define ERROR_NO_MORE_FILES 1001 // No such error code under Linux - #define ERROR_HANDLE_EOF 1002 // No such error code under Linux - #define ERROR_CAN_NOT_COMPLETE 1003 // No such error code under Linux - #define ERROR_FILE_CORRUPT 1004 // No such error code under Linux +#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) +#define ERROR_SUCCESS 0 +#define ERROR_FILE_NOT_FOUND ENOENT +#define ERROR_ACCESS_DENIED EPERM +#define ERROR_INVALID_HANDLE EBADF +#define ERROR_NOT_ENOUGH_MEMORY ENOMEM +#define ERROR_BAD_FORMAT 105 // No such error code under Linux +#define ERROR_NO_MORE_FILES 106 +#define ERROR_HANDLE_EOF 107 // No such error code under Linux +#define ERROR_NOT_SUPPORTED ENOTSUP +#define ERROR_INVALID_PARAMETER EINVAL +#define ERROR_DISK_FULL ENOSPC +#define ERROR_ALREADY_EXISTS EEXIST +#define ERROR_CAN_NOT_COMPLETE 108 // No such error code under Linux +#define ERROR_FILE_CORRUPT 109 // No such error code under Linux +#define ERROR_INSUFFICIENT_BUFFER ENOBUFS #endif -//----------------------------------------------------------------------------- -// Swapping functions - #ifdef PLATFORM_LITTLE_ENDIAN - #define BSWAP_INT16_UNSIGNED(a) (a) - #define BSWAP_INT16_SIGNED(a) (a) - #define BSWAP_INT32_UNSIGNED(a) (a) - #define BSWAP_INT32_SIGNED(a) (a) - #define BSWAP_INT64_SIGNED(a) (a) - #define BSWAP_INT64_UNSIGNED(a) (a) - #define BSWAP_ARRAY16_UNSIGNED(a,b) {} - #define BSWAP_ARRAY32_UNSIGNED(a,b) {} - #define BSWAP_ARRAY64_UNSIGNED(a,b) {} - #define BSWAP_PART_HEADER(a) {} - #define BSWAP_TMPQHEADER(a,b) {} - #define BSWAP_TMPKHEADER(a) {} +#define BSWAP_INT16_UNSIGNED(a) (a) +#define BSWAP_INT16_SIGNED(a) (a) +#define BSWAP_INT32_UNSIGNED(a) (a) +#define BSWAP_INT32_SIGNED(a) (a) +#define BSWAP_INT64_SIGNED(a) (a) +#define BSWAP_INT64_UNSIGNED(a) (a) +#define BSWAP_ARRAY16_UNSIGNED(a,b) {} +#define BSWAP_ARRAY32_UNSIGNED(a,b) {} +#define BSWAP_ARRAY64_UNSIGNED(a,b) {} +#define BSWAP_PART_HEADER(a) {} +#define BSWAP_TMPQUSERDATA(a) {} +#define BSWAP_TMPQHEADER(a) {} #else - #ifdef __cplusplus extern "C" { #endif - int16_t SwapInt16(uint16_t); - uint16_t SwapUInt16(uint16_t); - int32_t SwapInt32(uint32_t); - uint32_t SwapUInt32(uint32_t); - int64_t SwapInt64(uint64_t); - uint64_t SwapUInt64(uint64_t); - void ConvertUInt16Buffer(void * ptr, size_t length); - void ConvertUInt32Buffer(void * ptr, size_t length); - void ConvertUInt64Buffer(void * ptr, size_t length); - void ConvertTMPQUserData(void *userData); - void ConvertTMPQHeader(void *header, uint16_t wPart); - void ConvertTMPKHeader(void *header); +int16_t SwapInt16(uint16_t); +uint16_t SwapUInt16(uint16_t); +int32_t SwapInt32(uint32_t); +uint32_t SwapUInt32(uint32_t); +int64_t SwapInt64(uint64_t); +uint64_t SwapUInt64(uint64_t); +void ConvertUInt16Buffer(void * ptr, size_t length); +void ConvertUInt32Buffer(void * ptr, size_t length); +void ConvertUInt64Buffer(void * ptr, size_t length); +void ConvertPartHeader(void * partHeader); +void ConvertTMPQUserData(void *userData); +void ConvertTMPQHeader(void *header); #ifdef __cplusplus } #endif - #define BSWAP_INT16_SIGNED(a) SwapInt16((a)) - #define BSWAP_INT16_UNSIGNED(a) SwapUInt16((a)) - #define BSWAP_INT32_SIGNED(a) SwapInt32((a)) - #define BSWAP_INT32_UNSIGNED(a) SwapUInt32((a)) - #define BSWAP_INT64_SIGNED(a) SwapInt64((a)) - #define BSWAP_INT64_UNSIGNED(a) SwapUInt64((a)) - #define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUInt16Buffer((a),(b)) - #define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUInt32Buffer((a),(b)) - #define BSWAP_ARRAY64_UNSIGNED(a,b) ConvertUInt64Buffer((a),(b)) - #define BSWAP_TMPQHEADER(a,b) ConvertTMPQHeader((a),(b)) - #define BSWAP_TMPKHEADER(a) ConvertTMPKHeader((a)) +#define BSWAP_INT16_SIGNED(a) SwapInt16((a)) +#define BSWAP_INT16_UNSIGNED(a) SwapUInt16((a)) +#define BSWAP_INT32_SIGNED(a) SwapInt32((a)) +#define BSWAP_INT32_UNSIGNED(a) SwapUInt32((a)) +#define BSWAP_INT64_SIGNED(a) SwapInt64((a)) +#define BSWAP_INT64_UNSIGNED(a) SwapUInt64((a)) +#define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUInt16Buffer((a),(b)) +#define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUInt32Buffer((a),(b)) +#define BSWAP_ARRAY64_UNSIGNED(a,b) ConvertUInt64Buffer((a),(b)) +#define BSWAP_PART_HEADER(a) ConvertPartHeader(a) +#define BSWAP_TMPQUSERDATA(a) ConvertTMPQUserData((a)) +#define BSWAP_TMPQHEADER(a) ConvertTMPQHeader((a)) #endif -//----------------------------------------------------------------------------- -// Macro for deprecated symbols - -/* -#ifdef _MSC_VER - #if _MSC_FULL_VER >= 140050320 - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated(_Text)) - #else - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated) - #endif -#else - #ifdef __GNUC__ - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated)) - #else - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated(_Text))) - #endif -#endif - -// When a flag is deprecated, use this macro -#ifndef _STORMLIB_NO_DEPRECATE - #define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) \ - const STORMLIB_DEPRECATED(#oldflag " is deprecated. Use " #newflag ". To supress this warning, define _STORMLIB_NO_DEPRECATE") static type oldflag = (type)newflag; -#else -#define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) static type oldflag = (type)newflag; -#endif -*/ - #endif // __STORMPORT_H__ diff --git a/dep/StormLib/src/adpcm/adpcm.cpp b/dep/StormLib/src/adpcm/adpcm.cpp index c8086ab6b..783cf10bf 100644 --- a/dep/StormLib/src/adpcm/adpcm.cpp +++ b/dep/StormLib/src/adpcm/adpcm.cpp @@ -10,392 +10,349 @@ /* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ /* 20.05.03 2.00 Lad Added compression */ /* 19.11.03 2.01 Dan Big endian handling */ -/* 10.01.13 3.00 Lad Refactored, beautified, documented :-) */ /*****************************************************************************/ -#include - #include "adpcm.h" +//------------------------------------------------------------------------------ +// Structures + +typedef union _BYTE_AND_WORD_PTR +{ + short * pw; + unsigned char * pb; +} BYTE_AND_WORD_PTR; + +typedef union _WORD_AND_BYTE_ARRAY +{ + short w; + unsigned char b[2]; +} WORD_AND_BYTE_ARRAY; + //----------------------------------------------------------------------------- // Tables necessary dor decompression -static int NextStepTable[] = +static long Table1503F120[] = { - -1, 0, -1, 4, -1, 2, -1, 6, - -1, 1, -1, 5, -1, 3, -1, 7, - -1, 1, -1, 5, -1, 3, -1, 7, - -1, 2, -1, 4, -1, 6, -1, 8 + 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006, + 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, + 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, + 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 }; -static int StepSizeTable[] = +static long step_table[] = { - 7, 8, 9, 10, 11, 12, 13, 14, - 16, 17, 19, 21, 23, 25, 28, 31, - 34, 37, 41, 45, 50, 55, 60, 66, - 73, 80, 88, 97, 107, 118, 130, 143, - 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, - 724, 796, 876, 963, 1060, 1166, 1282, 1411, - 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, - 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, - 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, - 32767 + 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, + 0x00000010, 0x00000011, 0x00000013, 0x00000015, 0x00000017, 0x00000019, 0x0000001C, 0x0000001F, + 0x00000022, 0x00000025, 0x00000029, 0x0000002D, 0x00000032, 0x00000037, 0x0000003C, 0x00000042, + 0x00000049, 0x00000050, 0x00000058, 0x00000061, 0x0000006B, 0x00000076, 0x00000082, 0x0000008F, + 0x0000009D, 0x000000AD, 0x000000BE, 0x000000D1, 0x000000E6, 0x000000FD, 0x00000117, 0x00000133, + 0x00000151, 0x00000173, 0x00000198, 0x000001C1, 0x000001EE, 0x00000220, 0x00000256, 0x00000292, + 0x000002D4, 0x0000031C, 0x0000036C, 0x000003C3, 0x00000424, 0x0000048E, 0x00000502, 0x00000583, + 0x00000610, 0x000006AB, 0x00000756, 0x00000812, 0x000008E0, 0x000009C3, 0x00000ABD, 0x00000BD0, + 0x00000CFF, 0x00000E4C, 0x00000FBA, 0x0000114C, 0x00001307, 0x000014EE, 0x00001706, 0x00001954, + 0x00001BDC, 0x00001EA5, 0x000021B6, 0x00002515, 0x000028CA, 0x00002CDF, 0x0000315B, 0x0000364B, + 0x00003BB9, 0x000041B2, 0x00004844, 0x00004F7E, 0x00005771, 0x0000602F, 0x000069CE, 0x00007462, + 0x00007FFF }; -//----------------------------------------------------------------------------- -// Helper class for writing output ADPCM data - -class TADPCMStream -{ - public: - - TADPCMStream(void * pvBuffer, size_t cbBuffer) - { - pbBufferEnd = (unsigned char *)pvBuffer + cbBuffer; - pbBuffer = (unsigned char *)pvBuffer; - } - - bool ReadByteSample(unsigned char & ByteSample) - { - // Check if there is enough space in the buffer - if(pbBuffer >= pbBufferEnd) - return false; - - ByteSample = *pbBuffer++; - return true; - } - - bool WriteByteSample(unsigned char ByteSample) - { - // Check if there is enough space in the buffer - if(pbBuffer >= pbBufferEnd) - return false; - - *pbBuffer++ = ByteSample; - return true; - } - - bool ReadWordSample(short & OneSample) - { - // Check if we have enough space in the output buffer - if((size_t)(pbBufferEnd - pbBuffer) < sizeof(short)) - return false; - - // Write the sample - OneSample = pbBuffer[0] + (((short)pbBuffer[1]) << 0x08); - pbBuffer += sizeof(short); - return true; - } - - bool WriteWordSample(short OneSample) - { - // Check if we have enough space in the output buffer - if((size_t)(pbBufferEnd - pbBuffer) < sizeof(short)) - return false; - - // Write the sample - *pbBuffer++ = (unsigned char)(OneSample & 0xFF); - *pbBuffer++ = (unsigned char)(OneSample >> 0x08); - return true; - } - - int LengthProcessed(void * pvOutBuffer) - { - return (int)((unsigned char *)pbBuffer - (unsigned char *)pvOutBuffer); - } - - unsigned char * pbBufferEnd; - unsigned char * pbBuffer; -}; - //---------------------------------------------------------------------------- -// Local functions +// CompressWave -static inline short GetNextStepIndex(int StepIndex, unsigned int EncodedSample) +// 1500EF70 +int CompressADPCM(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nChannels, int nCmpLevel) +// ECX EDX { - // Get the next step index - StepIndex = StepIndex + NextStepTable[EncodedSample & 0x1F]; + WORD_AND_BYTE_ARRAY Wcmp; + BYTE_AND_WORD_PTR out; // Pointer to the output buffer + long SInt32Array1[2]; + long SInt32Array2[2]; + long SInt32Array3[2]; + long nBytesRemains = dwOutLength; // Number of bytes remaining + long nWordsRemains; // Number of words remaining +// unsigned char * pbSaveOutBuffer; // Copy of output buffer (actually not used) + unsigned long dwBitBuff; + unsigned long dwStopBit; + unsigned long dwBit; + unsigned long ebx; + unsigned long esi; + long nTableValue; + long nOneWord; + long var_1C; + long var_2C; + int nLength; + int nIndex; + int nValue; + int i, chnl; - // Don't make the step index overflow - if(StepIndex < 0) - StepIndex = 0; - else if(StepIndex > 88) - StepIndex = 88; - - return (short)StepIndex; -} - -static inline int UpdatePredictedSample(int PredictedSample, int EncodedSample, int Difference) -{ - // Is the sign bit set? - if(EncodedSample & 0x40) - { - PredictedSample -= Difference; - if(PredictedSample <= -32768) - PredictedSample = -32768; - } - else - { - PredictedSample += Difference; - if(PredictedSample >= 32767) - PredictedSample = 32767; - } - - return PredictedSample; -} - -static inline int DecodeSample(int PredictedSample, int EncodedSample, int StepSize, int Difference) -{ - if(EncodedSample & 0x01) - Difference += (StepSize >> 0); - - if(EncodedSample & 0x02) - Difference += (StepSize >> 1); - - if(EncodedSample & 0x04) - Difference += (StepSize >> 2); - - if(EncodedSample & 0x08) - Difference += (StepSize >> 3); - - if(EncodedSample & 0x10) - Difference += (StepSize >> 4); - - if(EncodedSample & 0x20) - Difference += (StepSize >> 5); - - return UpdatePredictedSample(PredictedSample, EncodedSample, Difference); -} - -//---------------------------------------------------------------------------- -// Compression routine - -int CompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int cbInBuffer, int ChannelCount, int CompressionLevel) -{ - TADPCMStream os(pvOutBuffer, cbOutBuffer); // The output stream - TADPCMStream is(pvInBuffer, cbInBuffer); // The input stream - unsigned char BitShift = (unsigned char)(CompressionLevel - 1); - short PredictedSamples[MAX_ADPCM_CHANNEL_COUNT];// Predicted samples for each channel - short StepIndexes[MAX_ADPCM_CHANNEL_COUNT]; // Step indexes for each channel - short InputSample; // Input sample for the current channel - int TotalStepSize; - int ChannelIndex; - int AbsDifference; - int Difference; - int MaxBitMask; - int StepSize; - -// _tprintf(_T("== CMPR Started ==============\n")); - - // First byte in the output stream contains zero. The second one contains the compression level - os.WriteByteSample(0); - if(!os.WriteByteSample(BitShift)) + // If less than 2 bytes remain, don't decompress anything +// pbSaveOutBuffer = pbOutBuffer; + out.pb = pbOutBuffer; + if(nBytesRemains < 2) return 2; - // Set the initial step index for each channel - PredictedSamples[0] = PredictedSamples[1] = 0; - StepIndexes[0] = StepIndexes[1] = INITIAL_ADPCM_STEP_INDEX; + Wcmp.b[1] = (unsigned char)(nCmpLevel - 1); + Wcmp.b[0] = (unsigned char)0; - // Next, InitialSample value for each channel follows - for(int i = 0; i < ChannelCount; i++) + *out.pw++ = BSWAP_INT16_SIGNED(Wcmp.w); + if((out.pb - pbOutBuffer + (nChannels * 2)) > nBytesRemains) + return (int)(out.pb - pbOutBuffer + (nChannels * 2)); + + SInt32Array1[0] = SInt32Array1[1] = 0x2C; + + for(i = 0; i < nChannels; i++) { - // Get the initial sample from the input stream - if(!is.ReadWordSample(InputSample)) - return os.LengthProcessed(pvOutBuffer); - - // Store the initial sample to our sample array - PredictedSamples[i] = InputSample; - - // Also store the loaded sample to the output stream - if(!os.WriteWordSample(InputSample)) - return os.LengthProcessed(pvOutBuffer); + nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); + *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); + SInt32Array2[i] = nOneWord; } - // Get the initial index - ChannelIndex = ChannelCount - 1; - - // Now keep reading the input data as long as there is something in the input buffer - while(is.ReadWordSample(InputSample)) + // Weird. But it's there + nLength = dwInLength; + if(nLength < 0) // mov eax, dwInLength; cdq; sub eax, edx; + nLength++; + + nLength = (nLength / 2) - (int)(out.pb - pbOutBuffer); + nLength = (nLength < 0) ? 0 : nLength; + + nIndex = nChannels - 1; // edi + nWordsRemains = dwInLength / 2; // eax + + // ebx - nChannels + // ecx - pwOutPos + for(chnl = nChannels; chnl < nWordsRemains; chnl++) { - int EncodedSample = 0; + // 1500F030 + if((out.pb - pbOutBuffer + 2) > nBytesRemains) + return (int)(out.pb - pbOutBuffer + 2); - // If we have two channels, we need to flip the channel index - ChannelIndex = (ChannelIndex + 1) % ChannelCount; + // Switch index + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; - // Get the difference from the previous sample. - // If the difference is negative, set the sign bit to the encoded sample - AbsDifference = InputSample - PredictedSamples[ChannelIndex]; - if(AbsDifference < 0) + // Load one word from the input stream + nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); // ecx - nOneWord + SInt32Array3[nIndex] = nOneWord; + + // esi - SInt32Array2[nIndex] + // eax - nValue + nValue = nOneWord - SInt32Array2[nIndex]; + nValue = (nValue < 0) ? ((nValue ^ 0xFFFFFFFF) + 1) : nValue; + + ebx = (nOneWord >= SInt32Array2[nIndex]) ? 0 : 0x40; + + // esi - SInt32Array2[nIndex] + // edx - step_table[SInt32Array2[nIndex]] + // edi - (step_table[SInt32Array1[nIndex]] >> nCmpLevel) + nTableValue = step_table[SInt32Array1[nIndex]]; + dwStopBit = (unsigned long)nCmpLevel; + + // edi - nIndex; + if(nValue < (nTableValue >> nCmpLevel)) { - AbsDifference = -AbsDifference; - EncodedSample |= 0x40; - } - - // If the difference is too low (higher that difference treshold), - // write a step index modifier marker - StepSize = StepSizeTable[StepIndexes[ChannelIndex]]; - if(AbsDifference < (StepSize >> CompressionLevel)) - { - if(StepIndexes[ChannelIndex] != 0) - StepIndexes[ChannelIndex]--; - - os.WriteByteSample(0x80); + if(SInt32Array1[nIndex] != 0) + SInt32Array1[nIndex]--; + *out.pb++ = 0x80; } else { - // If the difference is too high, write marker that - // indicates increase in step size - while(AbsDifference > (StepSize << 1)) + while(nValue > nTableValue * 2) { - if(StepIndexes[ChannelIndex] >= 0x58) + if(SInt32Array1[nIndex] >= 0x58 || nLength == 0) break; - // Modify the step index - StepIndexes[ChannelIndex] += 8; - if(StepIndexes[ChannelIndex] > 0x58) - StepIndexes[ChannelIndex] = 0x58; + SInt32Array1[nIndex] += 8; + if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; - // Write the "modify step index" marker - StepSize = StepSizeTable[StepIndexes[ChannelIndex]]; - os.WriteByteSample(0x81); + nTableValue = step_table[SInt32Array1[nIndex]]; + *out.pb++ = 0x81; + nLength--; } - // Get the limit bit value - MaxBitMask = (1 << (BitShift - 1)); - MaxBitMask = (MaxBitMask > 0x20) ? 0x20 : MaxBitMask; - Difference = StepSize >> BitShift; - TotalStepSize = 0; + var_2C = nTableValue >> Wcmp.b[1]; + dwBitBuff = 0; - for(int BitVal = 0x01; BitVal <= MaxBitMask; BitVal <<= 1) + esi = (1 << (dwStopBit - 2)); + dwStopBit = (esi <= 0x20) ? esi : 0x20; + + for(var_1C = 0, dwBit = 1; ; dwBit <<= 1) { - if((TotalStepSize + StepSize) <= AbsDifference) +// esi = var_1C + nTableValue; + if((var_1C + nTableValue) <= nValue) { - TotalStepSize += StepSize; - EncodedSample |= BitVal; + var_1C += nTableValue; + dwBitBuff |= dwBit; } - StepSize >>= 1; + if(dwBit == dwStopBit) + break; + + nTableValue >>= 1; } - PredictedSamples[ChannelIndex] = (short)UpdatePredictedSample(PredictedSamples[ChannelIndex], - EncodedSample, - Difference + TotalStepSize); - // Write the encoded sample to the output stream - if(!os.WriteByteSample((unsigned char)EncodedSample)) - break; - - // Calculates the step index to use for the next encode - StepIndexes[ChannelIndex] = GetNextStepIndex(StepIndexes[ChannelIndex], EncodedSample); + nValue = SInt32Array2[nIndex]; + if(ebx != 0) + { + nValue -= (var_1C + var_2C); + if(nValue < -32768) + nValue = -32768; + } + else + { + nValue += (var_1C + var_2C); + if(nValue > 32767) + nValue = 32767; + } + + SInt32Array2[nIndex] = nValue; + *out.pb++ = (unsigned char)(dwBitBuff | ebx); + nTableValue = Table1503F120[dwBitBuff & 0x1F]; + SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue; + if(SInt32Array1[nIndex] < 0) + SInt32Array1[nIndex] = 0; + else if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; } } -// _tprintf(_T("== CMPR Ended ================\n")); - return os.LengthProcessed(pvOutBuffer); + return (int)(out.pb - pbOutBuffer); } //---------------------------------------------------------------------------- -// Decompression routine +// DecompressADPCM -int DecompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int cbInBuffer, int ChannelCount) +// 1500F230 +int DecompressADPCM(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels) { - TADPCMStream os(pvOutBuffer, cbOutBuffer); // Output stream - TADPCMStream is(pvInBuffer, cbInBuffer); // Input stream - unsigned char EncodedSample; - unsigned char BitShift; - short PredictedSamples[MAX_ADPCM_CHANNEL_COUNT]; // Predicted sample for each channel - short StepIndexes[MAX_ADPCM_CHANNEL_COUNT]; // Predicted step index for each channel - int ChannelIndex; // Current channel index + BYTE_AND_WORD_PTR out; // Output buffer + BYTE_AND_WORD_PTR in; + unsigned char * pbInBufferEnd = (pbInBuffer + dwInLength); + long SInt32Array1[2]; + long SInt32Array2[2]; + long nOneWord; + int nIndex; + int i; - // Initialize the StepIndex for each channel - PredictedSamples[0] = PredictedSamples[1] = 0; - StepIndexes[0] = StepIndexes[1] = INITIAL_ADPCM_STEP_INDEX; + SInt32Array1[0] = SInt32Array1[1] = 0x2C; + out.pb = pbOutBuffer; + in.pb = pbInBuffer; + in.pw++; -// _tprintf(_T("== DCMP Started ==============\n")); - - // The first byte is always zero, the second one contains bit shift (compression level - 1) - is.ReadByteSample(BitShift); - is.ReadByteSample(BitShift); -// _tprintf(_T("DCMP: BitShift = %u\n"), (unsigned int)(unsigned char)BitShift); - - // Next, InitialSample value for each channel follows - for(int i = 0; i < ChannelCount; i++) + // Fill the Uint32Array2 array by channel values. + for(i = 0; i < nChannels; i++) { - // Get the initial sample from the input stream - short InitialSample; + nOneWord = BSWAP_INT16_SIGNED(*in.pw++); + SInt32Array2[i] = nOneWord; + if(dwOutLength < 2) + return (int)(out.pb - pbOutBuffer); - // Attempt to read the initial sample - if(!is.ReadWordSample(InitialSample)) - return os.LengthProcessed(pvOutBuffer); - -// _tprintf(_T("DCMP: Loaded InitialSample[%u]: %04X\n"), i, (unsigned int)(unsigned short)InitialSample); - - // Store the initial sample to our sample array - PredictedSamples[i] = InitialSample; - - // Also store the loaded sample to the output stream - if(!os.WriteWordSample(InitialSample)) - return os.LengthProcessed(pvOutBuffer); + *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); + dwOutLength -= sizeof(short); } // Get the initial index - ChannelIndex = ChannelCount - 1; + nIndex = nChannels - 1; - // Keep reading as long as there is something in the input buffer - while(is.ReadByteSample(EncodedSample)) + // Perform the decompression + while(in.pb < pbInBufferEnd) { -// _tprintf(_T("DCMP: Loaded Encoded Sample: %02X\n"), (unsigned int)(unsigned char)EncodedSample); + unsigned char nOneByte = *in.pb++; - // If we have two channels, we need to flip the channel index - ChannelIndex = (ChannelIndex + 1) % ChannelCount; + // Switch index + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; - if(EncodedSample == 0x80) + // 1500F2A2: Get one byte from input buffer + if(nOneByte & 0x80) { - if(StepIndexes[ChannelIndex] != 0) - StepIndexes[ChannelIndex]--; + switch(nOneByte & 0x7F) + { + case 0: // 1500F315 + if(SInt32Array1[nIndex] != 0) + SInt32Array1[nIndex]--; -// _tprintf(_T("DCMP: Writing Decoded Sample: %04lX\n"), (unsigned int)(unsigned short)PredictedSamples[ChannelIndex]); - if(!os.WriteWordSample(PredictedSamples[ChannelIndex])) - return os.LengthProcessed(pvOutBuffer); - } - else if(EncodedSample == 0x81) - { - // Modify the step index - StepIndexes[ChannelIndex] += 8; - if(StepIndexes[ChannelIndex] > 0x58) - StepIndexes[ChannelIndex] = 0x58; + if(dwOutLength < 2) + return (int)(out.pb - pbOutBuffer); -// _tprintf(_T("DCMP: New value of StepIndex: %04lX\n"), (unsigned int)(unsigned short)StepIndexes[ChannelIndex]); + *out.pw++ = BSWAP_INT16_SIGNED((unsigned short)SInt32Array2[nIndex]); + dwOutLength -= sizeof(unsigned short); + break; - // Next pass, keep going on the same channel - ChannelIndex = (ChannelIndex + 1) % ChannelCount; + case 1: // 1500F2E8 + SInt32Array1[nIndex] += 8; + if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; + + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; + break; + + case 2: // 1500F41E + break; + + default: // 1500F2C4 + SInt32Array1[nIndex] -= 8; + if(SInt32Array1[nIndex] < 0) + SInt32Array1[nIndex] = 0; + + if(nChannels == 2) + nIndex = (nIndex == 0) ? 1 : 0; + break; + } } else { - int StepIndex = StepIndexes[ChannelIndex]; - int StepSize = StepSizeTable[StepIndex]; + // 1500F349 + long temp1 = step_table[SInt32Array1[nIndex]]; // EDI + long temp2 = temp1 >> pbInBuffer[1]; // ESI + long temp3 = SInt32Array2[nIndex]; // ECX - // Encode one sample - PredictedSamples[ChannelIndex] = (short)DecodeSample(PredictedSamples[ChannelIndex], - EncodedSample, - StepSize, - StepSize >> BitShift); + if(nOneByte & 0x01) // EBX = nOneByte + temp2 += (temp1 >> 0); -// _tprintf(_T("DCMP: Writing decoded sample: %04X\n"), (unsigned int)(unsigned short)PredictedSamples[ChannelIndex]); + if(nOneByte & 0x02) + temp2 += (temp1 >> 1); - // Write the decoded sample to the output stream - if(!os.WriteWordSample(PredictedSamples[ChannelIndex])) + if(nOneByte & 0x04) + temp2 += (temp1 >> 2); + + if(nOneByte & 0x08) + temp2 += (temp1 >> 3); + + if(nOneByte & 0x10) + temp2 += (temp1 >> 4); + + if(nOneByte & 0x20) + temp2 += (temp1 >> 5); + + if(nOneByte & 0x40) + { + temp3 = temp3 - temp2; + if(temp3 <= -32768) + temp3 = -32768; + } + else + { + temp3 = temp3 + temp2; + if(temp3 >= 32767) + temp3 = 32767; + } + + SInt32Array2[nIndex] = temp3; + if(dwOutLength < 2) break; - // Calculates the step index to use for the next encode - StepIndexes[ChannelIndex] = GetNextStepIndex(StepIndex, EncodedSample); -// _tprintf(_T("DCMP: New step index: %04X\n"), (unsigned int)(unsigned short)StepIndexes[ChannelIndex]); + // Store the output 16-bit value + *out.pw++ = BSWAP_INT16_SIGNED((short)SInt32Array2[nIndex]); + dwOutLength -= 2; + + SInt32Array1[nIndex] += Table1503F120[nOneByte & 0x1F]; + + if(SInt32Array1[nIndex] < 0) + SInt32Array1[nIndex] = 0; + else if(SInt32Array1[nIndex] > 0x58) + SInt32Array1[nIndex] = 0x58; } } - -// _tprintf(_T("DCMP: Total length written: %u\n"), (unsigned int)os.LengthProcessed(pvOutBuffer)); -// _tprintf(_T("== DCMP Ended ================\n")); - - // Return total bytes written since beginning of the output buffer - return os.LengthProcessed(pvOutBuffer); + return (int)(out.pb - pbOutBuffer); } diff --git a/dep/StormLib/src/adpcm/adpcm.h b/dep/StormLib/src/adpcm/adpcm.h index b1bf36143..beb961597 100644 --- a/dep/StormLib/src/adpcm/adpcm.h +++ b/dep/StormLib/src/adpcm/adpcm.h @@ -12,15 +12,11 @@ #define __ADPCM_H__ //----------------------------------------------------------------------------- -// Defines +// Functions -#define MAX_ADPCM_CHANNEL_COUNT 2 -#define INITIAL_ADPCM_STEP_INDEX 0x2C +#include "../StormPort.h" -//----------------------------------------------------------------------------- -// Public functions - -int CompressADPCM (void * pvOutBuffer, int dwOutLength, void * pvInBuffer, int dwInLength, int nCmpType, int ChannelCount); -int DecompressADPCM(void * pvOutBuffer, int dwOutLength, void * pvInBuffer, int dwInLength, int ChannelCount); +int CompressADPCM (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nCmpType, int nChannels); +int DecompressADPCM(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels); #endif // __ADPCM_H__ diff --git a/dep/StormLib/src/bzip2/blocksort.c b/dep/StormLib/src/bzip2/blocksort.c new file mode 100644 index 000000000..bd2dec157 --- /dev/null +++ b/dep/StormLib/src/bzip2/blocksort.c @@ -0,0 +1,1094 @@ + +/*-------------------------------------------------------------*/ +/*--- Block sorting machinery ---*/ +/*--- blocksort.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + +/*---------------------------------------------*/ +/*--- Fallback O(N log(N)^2) sorting ---*/ +/*--- algorithm, for repetitive blocks ---*/ +/*---------------------------------------------*/ + +/*---------------------------------------------*/ +static +__inline__ +void fallbackSimpleSort ( UInt32* fmap, + UInt32* eclass, + Int32 lo, + Int32 hi ) +{ + Int32 i, j, tmp; + UInt32 ec_tmp; + + if (lo == hi) return; + + if (hi - lo > 3) { + for ( i = hi-4; i >= lo; i-- ) { + tmp = fmap[i]; + ec_tmp = eclass[tmp]; + for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 ) + fmap[j-4] = fmap[j]; + fmap[j-4] = tmp; + } + } + + for ( i = hi-1; i >= lo; i-- ) { + tmp = fmap[i]; + ec_tmp = eclass[tmp]; + for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ ) + fmap[j-1] = fmap[j]; + fmap[j-1] = tmp; + } +} + + +/*---------------------------------------------*/ +#define fswap(zz1, zz2) \ + { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } + +#define fvswap(zzp1, zzp2, zzn) \ +{ \ + Int32 yyp1 = (zzp1); \ + Int32 yyp2 = (zzp2); \ + Int32 yyn = (zzn); \ + while (yyn > 0) { \ + fswap(fmap[yyp1], fmap[yyp2]); \ + yyp1++; yyp2++; yyn--; \ + } \ +} + + +#define fmin(a,b) ((a) < (b)) ? (a) : (b) + +#define fpush(lz,hz) { stackLo[sp] = lz; \ + stackHi[sp] = hz; \ + sp++; } + +#define fpop(lz,hz) { sp--; \ + lz = stackLo[sp]; \ + hz = stackHi[sp]; } + +#define FALLBACK_QSORT_SMALL_THRESH 10 +#define FALLBACK_QSORT_STACK_SIZE 100 + + +static +void fallbackQSort3 ( UInt32* fmap, + UInt32* eclass, + Int32 loSt, + Int32 hiSt ) +{ + Int32 unLo, unHi, ltLo, gtHi, n, m; + Int32 sp, lo, hi; + UInt32 med, r, r3; + Int32 stackLo[FALLBACK_QSORT_STACK_SIZE]; + Int32 stackHi[FALLBACK_QSORT_STACK_SIZE]; + + r = 0; + + sp = 0; + fpush ( loSt, hiSt ); + + while (sp > 0) { + + AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 ); + + fpop ( lo, hi ); + if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) { + fallbackSimpleSort ( fmap, eclass, lo, hi ); + continue; + } + + /* Random partitioning. Median of 3 sometimes fails to + avoid bad cases. Median of 9 seems to help but + looks rather expensive. This too seems to work but + is cheaper. Guidance for the magic constants + 7621 and 32768 is taken from Sedgewick's algorithms + book, chapter 35. + */ + r = ((r * 7621) + 1) % 32768; + r3 = r % 3; + if (r3 == 0) med = eclass[fmap[lo]]; else + if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else + med = eclass[fmap[hi]]; + + unLo = ltLo = lo; + unHi = gtHi = hi; + + while (1) { + while (1) { + if (unLo > unHi) break; + n = (Int32)eclass[fmap[unLo]] - (Int32)med; + if (n == 0) { + fswap(fmap[unLo], fmap[ltLo]); + ltLo++; unLo++; + continue; + }; + if (n > 0) break; + unLo++; + } + while (1) { + if (unLo > unHi) break; + n = (Int32)eclass[fmap[unHi]] - (Int32)med; + if (n == 0) { + fswap(fmap[unHi], fmap[gtHi]); + gtHi--; unHi--; + continue; + }; + if (n < 0) break; + unHi--; + } + if (unLo > unHi) break; + fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--; + } + + AssertD ( unHi == unLo-1, "fallbackQSort3(2)" ); + + if (gtHi < ltLo) continue; + + n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n); + m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m); + + n = lo + unLo - ltLo - 1; + m = hi - (gtHi - unHi) + 1; + + if (n - lo > hi - m) { + fpush ( lo, n ); + fpush ( m, hi ); + } else { + fpush ( m, hi ); + fpush ( lo, n ); + } + } +} + +#undef fmin +#undef fpush +#undef fpop +#undef fswap +#undef fvswap +#undef FALLBACK_QSORT_SMALL_THRESH +#undef FALLBACK_QSORT_STACK_SIZE + + +/*---------------------------------------------*/ +/* Pre: + nblock > 0 + eclass exists for [0 .. nblock-1] + ((UChar*)eclass) [0 .. nblock-1] holds block + ptr exists for [0 .. nblock-1] + + Post: + ((UChar*)eclass) [0 .. nblock-1] holds block + All other areas of eclass destroyed + fmap [0 .. nblock-1] holds sorted order + bhtab [ 0 .. 2+(nblock/32) ] destroyed +*/ + +#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31)) +#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31)) +#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31))) +#define WORD_BH(zz) bhtab[(zz) >> 5] +#define UNALIGNED_BH(zz) ((zz) & 0x01f) + +static +void fallbackSort ( UInt32* fmap, + UInt32* eclass, + UInt32* bhtab, + Int32 nblock, + Int32 verb ) +{ + Int32 ftab[257]; + Int32 ftabCopy[256]; + Int32 H, i, j, k, l, r, cc, cc1; + Int32 nNotDone; + Int32 nBhtab; + UChar* eclass8 = (UChar*)eclass; + + /*-- + Initial 1-char radix sort to generate + initial fmap and initial BH bits. + --*/ + if (verb >= 4) + VPrintf0 ( " bucket sorting ...\n" ); + for (i = 0; i < 257; i++) ftab[i] = 0; + for (i = 0; i < nblock; i++) ftab[eclass8[i]]++; + for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i]; + for (i = 1; i < 257; i++) ftab[i] += ftab[i-1]; + + for (i = 0; i < nblock; i++) { + j = eclass8[i]; + k = ftab[j] - 1; + ftab[j] = k; + fmap[k] = i; + } + + nBhtab = 2 + (nblock / 32); + for (i = 0; i < nBhtab; i++) bhtab[i] = 0; + for (i = 0; i < 256; i++) SET_BH(ftab[i]); + + /*-- + Inductively refine the buckets. Kind-of an + "exponential radix sort" (!), inspired by the + Manber-Myers suffix array construction algorithm. + --*/ + + /*-- set sentinel bits for block-end detection --*/ + for (i = 0; i < 32; i++) { + SET_BH(nblock + 2*i); + CLEAR_BH(nblock + 2*i + 1); + } + + /*-- the log(N) loop --*/ + H = 1; + while (1) { + + if (verb >= 4) + VPrintf1 ( " depth %6d has ", H ); + + j = 0; + for (i = 0; i < nblock; i++) { + if (ISSET_BH(i)) j = i; + k = fmap[i] - H; if (k < 0) k += nblock; + eclass[k] = j; + } + + nNotDone = 0; + r = -1; + while (1) { + + /*-- find the next non-singleton bucket --*/ + k = r + 1; + while (ISSET_BH(k) && UNALIGNED_BH(k)) k++; + if (ISSET_BH(k)) { + while (WORD_BH(k) == 0xffffffff) k += 32; + while (ISSET_BH(k)) k++; + } + l = k - 1; + if (l >= nblock) break; + while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++; + if (!ISSET_BH(k)) { + while (WORD_BH(k) == 0x00000000) k += 32; + while (!ISSET_BH(k)) k++; + } + r = k - 1; + if (r >= nblock) break; + + /*-- now [l, r] bracket current bucket --*/ + if (r > l) { + nNotDone += (r - l + 1); + fallbackQSort3 ( fmap, eclass, l, r ); + + /*-- scan bucket and generate header bits-- */ + cc = -1; + for (i = l; i <= r; i++) { + cc1 = eclass[fmap[i]]; + if (cc != cc1) { SET_BH(i); cc = cc1; }; + } + } + } + + if (verb >= 4) + VPrintf1 ( "%6d unresolved strings\n", nNotDone ); + + H *= 2; + if (H > nblock || nNotDone == 0) break; + } + + /*-- + Reconstruct the original block in + eclass8 [0 .. nblock-1], since the + previous phase destroyed it. + --*/ + if (verb >= 4) + VPrintf0 ( " reconstructing block ...\n" ); + j = 0; + for (i = 0; i < nblock; i++) { + while (ftabCopy[j] == 0) j++; + ftabCopy[j]--; + eclass8[fmap[i]] = (UChar)j; + } + AssertH ( j < 256, 1005 ); +} + +#undef SET_BH +#undef CLEAR_BH +#undef ISSET_BH +#undef WORD_BH +#undef UNALIGNED_BH + + +/*---------------------------------------------*/ +/*--- The main, O(N^2 log(N)) sorting ---*/ +/*--- algorithm. Faster for "normal" ---*/ +/*--- non-repetitive blocks. ---*/ +/*---------------------------------------------*/ + +/*---------------------------------------------*/ +static +__inline__ +Bool mainGtU ( UInt32 i1, + UInt32 i2, + UChar* block, + UInt16* quadrant, + UInt32 nblock, + Int32* budget ) +{ + Int32 k; + UChar c1, c2; + UInt16 s1, s2; + + AssertD ( i1 != i2, "mainGtU" ); + /* 1 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 2 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 3 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 4 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 5 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 6 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 7 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 8 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 9 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 10 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 11 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + /* 12 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + i1++; i2++; + + k = nblock + 8; + + do { + /* 1 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 2 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 3 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 4 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 5 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 6 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 7 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + /* 8 */ + c1 = block[i1]; c2 = block[i2]; + if (c1 != c2) return (c1 > c2); + s1 = quadrant[i1]; s2 = quadrant[i2]; + if (s1 != s2) return (s1 > s2); + i1++; i2++; + + if (i1 >= nblock) i1 -= nblock; + if (i2 >= nblock) i2 -= nblock; + + k -= 8; + (*budget)--; + } + while (k >= 0); + + return False; +} + + +/*---------------------------------------------*/ +/*-- + Knuth's increments seem to work better + than Incerpi-Sedgewick here. Possibly + because the number of elems to sort is + usually small, typically <= 20. +--*/ +static +Int32 incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280, + 9841, 29524, 88573, 265720, + 797161, 2391484 }; + +static +void mainSimpleSort ( UInt32* ptr, + UChar* block, + UInt16* quadrant, + Int32 nblock, + Int32 lo, + Int32 hi, + Int32 d, + Int32* budget ) +{ + Int32 i, j, h, bigN, hp; + UInt32 v; + + bigN = hi - lo + 1; + if (bigN < 2) return; + + hp = 0; + while (incs[hp] < bigN) hp++; + hp--; + + for (; hp >= 0; hp--) { + h = incs[hp]; + + i = lo + h; + while (True) { + + /*-- copy 1 --*/ + if (i > hi) break; + v = ptr[i]; + j = i; + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget + ) ) { + ptr[j] = ptr[j-h]; + j = j - h; + if (j <= (lo + h - 1)) break; + } + ptr[j] = v; + i++; + + /*-- copy 2 --*/ + if (i > hi) break; + v = ptr[i]; + j = i; + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget + ) ) { + ptr[j] = ptr[j-h]; + j = j - h; + if (j <= (lo + h - 1)) break; + } + ptr[j] = v; + i++; + + /*-- copy 3 --*/ + if (i > hi) break; + v = ptr[i]; + j = i; + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget + ) ) { + ptr[j] = ptr[j-h]; + j = j - h; + if (j <= (lo + h - 1)) break; + } + ptr[j] = v; + i++; + + if (*budget < 0) return; + } + } +} + + +/*---------------------------------------------*/ +/*-- + The following is an implementation of + an elegant 3-way quicksort for strings, + described in a paper "Fast Algorithms for + Sorting and Searching Strings", by Robert + Sedgewick and Jon L. Bentley. +--*/ + +#define mswap(zz1, zz2) \ + { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } + +#define mvswap(zzp1, zzp2, zzn) \ +{ \ + Int32 yyp1 = (zzp1); \ + Int32 yyp2 = (zzp2); \ + Int32 yyn = (zzn); \ + while (yyn > 0) { \ + mswap(ptr[yyp1], ptr[yyp2]); \ + yyp1++; yyp2++; yyn--; \ + } \ +} + +static +__inline__ +UChar mmed3 ( UChar a, UChar b, UChar c ) +{ + UChar t; + if (a > b) { t = a; a = b; b = t; }; + if (b > c) { + b = c; + if (a > b) b = a; + } + return b; +} + +#define mmin(a,b) ((a) < (b)) ? (a) : (b) + +#define mpush(lz,hz,dz) { stackLo[sp] = lz; \ + stackHi[sp] = hz; \ + stackD [sp] = dz; \ + sp++; } + +#define mpop(lz,hz,dz) { sp--; \ + lz = stackLo[sp]; \ + hz = stackHi[sp]; \ + dz = stackD [sp]; } + + +#define mnextsize(az) (nextHi[az]-nextLo[az]) + +#define mnextswap(az,bz) \ + { Int32 tz; \ + tz = nextLo[az]; nextLo[az] = nextLo[bz]; nextLo[bz] = tz; \ + tz = nextHi[az]; nextHi[az] = nextHi[bz]; nextHi[bz] = tz; \ + tz = nextD [az]; nextD [az] = nextD [bz]; nextD [bz] = tz; } + + +#define MAIN_QSORT_SMALL_THRESH 20 +#define MAIN_QSORT_DEPTH_THRESH (BZ_N_RADIX + BZ_N_QSORT) +#define MAIN_QSORT_STACK_SIZE 100 + +static +void mainQSort3 ( UInt32* ptr, + UChar* block, + UInt16* quadrant, + Int32 nblock, + Int32 loSt, + Int32 hiSt, + Int32 dSt, + Int32* budget ) +{ + Int32 unLo, unHi, ltLo, gtHi, n, m, med; + Int32 sp, lo, hi, d; + + Int32 stackLo[MAIN_QSORT_STACK_SIZE]; + Int32 stackHi[MAIN_QSORT_STACK_SIZE]; + Int32 stackD [MAIN_QSORT_STACK_SIZE]; + + Int32 nextLo[3]; + Int32 nextHi[3]; + Int32 nextD [3]; + + sp = 0; + mpush ( loSt, hiSt, dSt ); + + while (sp > 0) { + + AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 ); + + mpop ( lo, hi, d ); + if (hi - lo < MAIN_QSORT_SMALL_THRESH || + d > MAIN_QSORT_DEPTH_THRESH) { + mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); + if (*budget < 0) return; + continue; + } + + med = (Int32) + mmed3 ( block[ptr[ lo ]+d], + block[ptr[ hi ]+d], + block[ptr[ (lo+hi)>>1 ]+d] ); + + unLo = ltLo = lo; + unHi = gtHi = hi; + + while (True) { + while (True) { + if (unLo > unHi) break; + n = ((Int32)block[ptr[unLo]+d]) - med; + if (n == 0) { + mswap(ptr[unLo], ptr[ltLo]); + ltLo++; unLo++; continue; + }; + if (n > 0) break; + unLo++; + } + while (True) { + if (unLo > unHi) break; + n = ((Int32)block[ptr[unHi]+d]) - med; + if (n == 0) { + mswap(ptr[unHi], ptr[gtHi]); + gtHi--; unHi--; continue; + }; + if (n < 0) break; + unHi--; + } + if (unLo > unHi) break; + mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--; + } + + AssertD ( unHi == unLo-1, "mainQSort3(2)" ); + + if (gtHi < ltLo) { + mpush(lo, hi, d+1 ); + continue; + } + + n = mmin(ltLo-lo, unLo-ltLo); mvswap(lo, unLo-n, n); + m = mmin(hi-gtHi, gtHi-unHi); mvswap(unLo, hi-m+1, m); + + n = lo + unLo - ltLo - 1; + m = hi - (gtHi - unHi) + 1; + + nextLo[0] = lo; nextHi[0] = n; nextD[0] = d; + nextLo[1] = m; nextHi[1] = hi; nextD[1] = d; + nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1; + + if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); + if (mnextsize(1) < mnextsize(2)) mnextswap(1,2); + if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); + + AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" ); + AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" ); + + mpush (nextLo[0], nextHi[0], nextD[0]); + mpush (nextLo[1], nextHi[1], nextD[1]); + mpush (nextLo[2], nextHi[2], nextD[2]); + } +} + +#undef mswap +#undef mvswap +#undef mpush +#undef mpop +#undef mmin +#undef mnextsize +#undef mnextswap +#undef MAIN_QSORT_SMALL_THRESH +#undef MAIN_QSORT_DEPTH_THRESH +#undef MAIN_QSORT_STACK_SIZE + + +/*---------------------------------------------*/ +/* Pre: + nblock > N_OVERSHOOT + block32 exists for [0 .. nblock-1 +N_OVERSHOOT] + ((UChar*)block32) [0 .. nblock-1] holds block + ptr exists for [0 .. nblock-1] + + Post: + ((UChar*)block32) [0 .. nblock-1] holds block + All other areas of block32 destroyed + ftab [0 .. 65536 ] destroyed + ptr [0 .. nblock-1] holds sorted order + if (*budget < 0), sorting was abandoned +*/ + +#define BIGFREQ(b) (ftab[((b)+1) << 8] - ftab[(b) << 8]) +#define SETMASK (1 << 21) +#define CLEARMASK (~(SETMASK)) + +static +void mainSort ( UInt32* ptr, + UChar* block, + UInt16* quadrant, + UInt32* ftab, + Int32 nblock, + Int32 verb, + Int32* budget ) +{ + Int32 i, j, k, ss, sb; + Int32 runningOrder[256]; + Bool bigDone[256]; + Int32 copyStart[256]; + Int32 copyEnd [256]; + UChar c1; + Int32 numQSorted; + UInt16 s; + if (verb >= 4) VPrintf0 ( " main sort initialise ...\n" ); + + /*-- set up the 2-byte frequency table --*/ + for (i = 65536; i >= 0; i--) ftab[i] = 0; + + j = block[0] << 8; + i = nblock-1; + for (; i >= 3; i -= 4) { + quadrant[i] = 0; + j = (j >> 8) | ( ((UInt16)block[i]) << 8); + ftab[j]++; + quadrant[i-1] = 0; + j = (j >> 8) | ( ((UInt16)block[i-1]) << 8); + ftab[j]++; + quadrant[i-2] = 0; + j = (j >> 8) | ( ((UInt16)block[i-2]) << 8); + ftab[j]++; + quadrant[i-3] = 0; + j = (j >> 8) | ( ((UInt16)block[i-3]) << 8); + ftab[j]++; + } + for (; i >= 0; i--) { + quadrant[i] = 0; + j = (j >> 8) | ( ((UInt16)block[i]) << 8); + ftab[j]++; + } + + /*-- (emphasises close relationship of block & quadrant) --*/ + for (i = 0; i < BZ_N_OVERSHOOT; i++) { + block [nblock+i] = block[i]; + quadrant[nblock+i] = 0; + } + + if (verb >= 4) VPrintf0 ( " bucket sorting ...\n" ); + + /*-- Complete the initial radix sort --*/ + for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1]; + + s = block[0] << 8; + i = nblock-1; + for (; i >= 3; i -= 4) { + s = (s >> 8) | (block[i] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i; + s = (s >> 8) | (block[i-1] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i-1; + s = (s >> 8) | (block[i-2] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i-2; + s = (s >> 8) | (block[i-3] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i-3; + } + for (; i >= 0; i--) { + s = (s >> 8) | (block[i] << 8); + j = ftab[s] -1; + ftab[s] = j; + ptr[j] = i; + } + + /*-- + Now ftab contains the first loc of every small bucket. + Calculate the running order, from smallest to largest + big bucket. + --*/ + for (i = 0; i <= 255; i++) { + bigDone [i] = False; + runningOrder[i] = i; + } + + { + Int32 vv; + Int32 h = 1; + do h = 3 * h + 1; while (h <= 256); + do { + h = h / 3; + for (i = h; i <= 255; i++) { + vv = runningOrder[i]; + j = i; + while ( BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv) ) { + runningOrder[j] = runningOrder[j-h]; + j = j - h; + if (j <= (h - 1)) goto zero; + } + zero: + runningOrder[j] = vv; + } + } while (h != 1); + } + + /*-- + The main sorting loop. + --*/ + + numQSorted = 0; + + for (i = 0; i <= 255; i++) { + + /*-- + Process big buckets, starting with the least full. + Basically this is a 3-step process in which we call + mainQSort3 to sort the small buckets [ss, j], but + also make a big effort to avoid the calls if we can. + --*/ + ss = runningOrder[i]; + + /*-- + Step 1: + Complete the big bucket [ss] by quicksorting + any unsorted small buckets [ss, j], for j != ss. + Hopefully previous pointer-scanning phases have already + completed many of the small buckets [ss, j], so + we don't have to sort them at all. + --*/ + for (j = 0; j <= 255; j++) { + if (j != ss) { + sb = (ss << 8) + j; + if ( ! (ftab[sb] & SETMASK) ) { + Int32 lo = ftab[sb] & CLEARMASK; + Int32 hi = (ftab[sb+1] & CLEARMASK) - 1; + if (hi > lo) { + if (verb >= 4) + VPrintf4 ( " qsort [0x%x, 0x%x] " + "done %d this %d\n", + ss, j, numQSorted, hi - lo + 1 ); + mainQSort3 ( + ptr, block, quadrant, nblock, + lo, hi, BZ_N_RADIX, budget + ); + numQSorted += (hi - lo + 1); + if (*budget < 0) return; + } + } + ftab[sb] |= SETMASK; + } + } + + AssertH ( !bigDone[ss], 1006 ); + + /*-- + Step 2: + Now scan this big bucket [ss] so as to synthesise the + sorted order for small buckets [t, ss] for all t, + including, magically, the bucket [ss,ss] too. + This will avoid doing Real Work in subsequent Step 1's. + --*/ + { + for (j = 0; j <= 255; j++) { + copyStart[j] = ftab[(j << 8) + ss] & CLEARMASK; + copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1; + } + for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) { + k = ptr[j]-1; if (k < 0) k += nblock; + c1 = block[k]; + if (!bigDone[c1]) + ptr[ copyStart[c1]++ ] = k; + } + for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { + k = ptr[j]-1; if (k < 0) k += nblock; + c1 = block[k]; + if (!bigDone[c1]) + ptr[ copyEnd[c1]-- ] = k; + } + } + + AssertH ( (copyStart[ss]-1 == copyEnd[ss]) + || + /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1. + Necessity for this case is demonstrated by compressing + a sequence of approximately 48.5 million of character + 251; 1.0.0/1.0.1 will then die here. */ + (copyStart[ss] == 0 && copyEnd[ss] == nblock-1), + 1007 ) + + for (j = 0; j <= 255; j++) ftab[(j << 8) + ss] |= SETMASK; + + /*-- + Step 3: + The [ss] big bucket is now done. Record this fact, + and update the quadrant descriptors. Remember to + update quadrants in the overshoot area too, if + necessary. The "if (i < 255)" test merely skips + this updating for the last bucket processed, since + updating for the last bucket is pointless. + + The quadrant array provides a way to incrementally + cache sort orderings, as they appear, so as to + make subsequent comparisons in fullGtU() complete + faster. For repetitive blocks this makes a big + difference (but not big enough to be able to avoid + the fallback sorting mechanism, exponential radix sort). + + The precise meaning is: at all times: + + for 0 <= i < nblock and 0 <= j <= nblock + + if block[i] != block[j], + + then the relative values of quadrant[i] and + quadrant[j] are meaningless. + + else { + if quadrant[i] < quadrant[j] + then the string starting at i lexicographically + precedes the string starting at j + + else if quadrant[i] > quadrant[j] + then the string starting at j lexicographically + precedes the string starting at i + + else + the relative ordering of the strings starting + at i and j has not yet been determined. + } + --*/ + bigDone[ss] = True; + + if (i < 255) { + Int32 bbStart = ftab[ss << 8] & CLEARMASK; + Int32 bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart; + Int32 shifts = 0; + + while ((bbSize >> shifts) > 65534) shifts++; + + for (j = bbSize-1; j >= 0; j--) { + Int32 a2update = ptr[bbStart + j]; + UInt16 qVal = (UInt16)(j >> shifts); + quadrant[a2update] = qVal; + if (a2update < BZ_N_OVERSHOOT) + quadrant[a2update + nblock] = qVal; + } + AssertH ( ((bbSize-1) >> shifts) <= 65535, 1002 ); + } + + } + + if (verb >= 4) + VPrintf3 ( " %d pointers, %d sorted, %d scanned\n", + nblock, numQSorted, nblock - numQSorted ); +} + +#undef BIGFREQ +#undef SETMASK +#undef CLEARMASK + + +/*---------------------------------------------*/ +/* Pre: + nblock > 0 + arr2 exists for [0 .. nblock-1 +N_OVERSHOOT] + ((UChar*)arr2) [0 .. nblock-1] holds block + arr1 exists for [0 .. nblock-1] + + Post: + ((UChar*)arr2) [0 .. nblock-1] holds block + All other areas of block destroyed + ftab [ 0 .. 65536 ] destroyed + arr1 [0 .. nblock-1] holds sorted order +*/ +void BZ2_blockSort ( EState* s ) +{ + UInt32* ptr = s->ptr; + UChar* block = s->block; + UInt32* ftab = s->ftab; + Int32 nblock = s->nblock; + Int32 verb = s->verbosity; + Int32 wfact = s->workFactor; + UInt16* quadrant; + Int32 budget; + Int32 budgetInit; + Int32 i; + + if (nblock < 10000) { + fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); + } else { + /* Calculate the location for quadrant, remembering to get + the alignment right. Assumes that &(block[0]) is at least + 2-byte aligned -- this should be ok since block is really + the first section of arr2. + */ + i = nblock+BZ_N_OVERSHOOT; + if (i & 1) i++; + quadrant = (UInt16*)(&(block[i])); + + /* (wfact-1) / 3 puts the default-factor-30 + transition point at very roughly the same place as + with v0.1 and v0.9.0. + Not that it particularly matters any more, since the + resulting compressed stream is now the same regardless + of whether or not we use the main sort or fallback sort. + */ + if (wfact < 1 ) wfact = 1; + if (wfact > 100) wfact = 100; + budgetInit = nblock * ((wfact-1) / 3); + budget = budgetInit; + + mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); + if (verb >= 3) + VPrintf3 ( " %d work, %d block, ratio %5.2f\n", + budgetInit - budget, + nblock, + (float)(budgetInit - budget) / + (float)(nblock==0 ? 1 : nblock) ); + if (budget < 0) { + if (verb >= 2) + VPrintf0 ( " too repetitive; using fallback" + " sorting algorithm\n" ); + fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); + } + } + + s->origPtr = -1; + for (i = 0; i < s->nblock; i++) + if (ptr[i] == 0) + { s->origPtr = i; break; }; + + AssertH( s->origPtr != -1, 1003 ); +} + + +/*-------------------------------------------------------------*/ +/*--- end blocksort.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/bzlib.c b/dep/StormLib/src/bzip2/bzlib.c new file mode 100644 index 000000000..b98f3e586 --- /dev/null +++ b/dep/StormLib/src/bzip2/bzlib.c @@ -0,0 +1,1573 @@ + +/*-------------------------------------------------------------*/ +/*--- Library top-level functions. ---*/ +/*--- bzlib.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + +/* CHANGES + 0.9.0 -- original version. + 0.9.0a/b -- no changes in this file. + 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress(). + fixed bzWrite/bzRead to ignore zero-length requests. + fixed bzread to correctly handle read requests after EOF. + wrong parameter order in call to bzDecompressInit in + bzBuffToBuffDecompress. Fixed. +*/ + +#define _CRT_SECURE_NO_WARNINGS +#include "bzlib_private.h" + + +/*---------------------------------------------------*/ +/*--- Compression stuff ---*/ +/*---------------------------------------------------*/ + + +/*---------------------------------------------------*/ +#ifndef BZ_NO_STDIO +void BZ2_bz__AssertH__fail ( int errcode ) +{ + fprintf(stderr, + "\n\nbzip2/libbzip2: internal error number %d.\n" + "This is a bug in bzip2/libbzip2, %s.\n" + "Please report it to me at: jseward@bzip.org. If this happened\n" + "when you were using some program which uses libbzip2 as a\n" + "component, you should also report this bug to the author(s)\n" + "of that program. Please make an effort to report this bug;\n" + "timely and accurate bug reports eventually lead to higher\n" + "quality software. Thanks. Julian Seward, 10 December 2007.\n\n", + errcode, + BZ2_bzlibVersion() + ); + + if (errcode == 1007) { + fprintf(stderr, + "\n*** A special note about internal error number 1007 ***\n" + "\n" + "Experience suggests that a common cause of i.e. 1007\n" + "is unreliable memory or other hardware. The 1007 assertion\n" + "just happens to cross-check the results of huge numbers of\n" + "memory reads/writes, and so acts (unintendedly) as a stress\n" + "test of your memory system.\n" + "\n" + "I suggest the following: try compressing the file again,\n" + "possibly monitoring progress in detail with the -vv flag.\n" + "\n" + "* If the error cannot be reproduced, and/or happens at different\n" + " points in compression, you may have a flaky memory system.\n" + " Try a memory-test program. I have used Memtest86\n" + " (www.memtest86.com). At the time of writing it is free (GPLd).\n" + " Memtest86 tests memory much more thorougly than your BIOSs\n" + " power-on test, and may find failures that the BIOS doesn't.\n" + "\n" + "* If the error can be repeatably reproduced, this is a bug in\n" + " bzip2, and I would very much like to hear about it. Please\n" + " let me know, and, ideally, save a copy of the file causing the\n" + " problem -- without which I will be unable to investigate it.\n" + "\n" + ); + } + + exit(3); +} +#endif + + +/*---------------------------------------------------*/ +static +int bz_config_ok ( void ) +{ + if (sizeof(int) != 4) return 0; + if (sizeof(short) != 2) return 0; + if (sizeof(char) != 1) return 0; + return 1; +} + + +/*---------------------------------------------------*/ +static +void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) +{ + void* v = malloc ( items * size ); + return v; +} + +static +void default_bzfree ( void* opaque, void* addr ) +{ + if (addr != NULL) free ( addr ); +} + + +/*---------------------------------------------------*/ +static +void prepare_new_block ( EState* s ) +{ + Int32 i; + s->nblock = 0; + s->numZ = 0; + s->state_out_pos = 0; + BZ_INITIALISE_CRC ( s->blockCRC ); + for (i = 0; i < 256; i++) s->inUse[i] = False; + s->blockNo++; +} + + +/*---------------------------------------------------*/ +static +void init_RL ( EState* s ) +{ + s->state_in_ch = 256; + s->state_in_len = 0; +} + + +static +Bool isempty_RL ( EState* s ) +{ + if (s->state_in_ch < 256 && s->state_in_len > 0) + return False; else + return True; +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzCompressInit) + ( bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor ) +{ + Int32 n; + EState* s; + + if (!bz_config_ok()) return BZ_CONFIG_ERROR; + + if (strm == NULL || + blockSize100k < 1 || blockSize100k > 9 || + workFactor < 0 || workFactor > 250) + return BZ_PARAM_ERROR; + + if (workFactor == 0) workFactor = 30; + if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; + if (strm->bzfree == NULL) strm->bzfree = default_bzfree; + + s = BZALLOC( sizeof(EState) ); + if (s == NULL) return BZ_MEM_ERROR; + s->strm = strm; + + s->arr1 = NULL; + s->arr2 = NULL; + s->ftab = NULL; + + n = 100000 * blockSize100k; + s->arr1 = BZALLOC( n * sizeof(UInt32) ); + s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) ); + s->ftab = BZALLOC( 65537 * sizeof(UInt32) ); + + if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) { + if (s->arr1 != NULL) BZFREE(s->arr1); + if (s->arr2 != NULL) BZFREE(s->arr2); + if (s->ftab != NULL) BZFREE(s->ftab); + if (s != NULL) BZFREE(s); + return BZ_MEM_ERROR; + } + + s->blockNo = 0; + s->state = BZ_S_INPUT; + s->mode = BZ_M_RUNNING; + s->combinedCRC = 0; + s->blockSize100k = blockSize100k; + s->nblockMAX = 100000 * blockSize100k - 19; + s->verbosity = verbosity; + s->workFactor = workFactor; + + s->block = (UChar*)s->arr2; + s->mtfv = (UInt16*)s->arr1; + s->zbits = NULL; + s->ptr = (UInt32*)s->arr1; + + strm->state = s; + strm->total_in_lo32 = 0; + strm->total_in_hi32 = 0; + strm->total_out_lo32 = 0; + strm->total_out_hi32 = 0; + init_RL ( s ); + prepare_new_block ( s ); + return BZ_OK; +} + + +/*---------------------------------------------------*/ +static +void add_pair_to_block ( EState* s ) +{ + Int32 i; + UChar ch = (UChar)(s->state_in_ch); + for (i = 0; i < s->state_in_len; i++) { + BZ_UPDATE_CRC( s->blockCRC, ch ); + } + s->inUse[s->state_in_ch] = True; + switch (s->state_in_len) { + case 1: + s->block[s->nblock] = (UChar)ch; s->nblock++; + break; + case 2: + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + break; + case 3: + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + break; + default: + s->inUse[s->state_in_len-4] = True; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = (UChar)ch; s->nblock++; + s->block[s->nblock] = ((UChar)(s->state_in_len-4)); + s->nblock++; + break; + } +} + + +/*---------------------------------------------------*/ +static +void flush_RL ( EState* s ) +{ + if (s->state_in_ch < 256) add_pair_to_block ( s ); + init_RL ( s ); +} + + +/*---------------------------------------------------*/ +#define ADD_CHAR_TO_BLOCK(zs,zchh0) \ +{ \ + UInt32 zchh = (UInt32)(zchh0); \ + /*-- fast track the common case --*/ \ + if (zchh != zs->state_in_ch && \ + zs->state_in_len == 1) { \ + UChar ch = (UChar)(zs->state_in_ch); \ + BZ_UPDATE_CRC( zs->blockCRC, ch ); \ + zs->inUse[zs->state_in_ch] = True; \ + zs->block[zs->nblock] = (UChar)ch; \ + zs->nblock++; \ + zs->state_in_ch = zchh; \ + } \ + else \ + /*-- general, uncommon cases --*/ \ + if (zchh != zs->state_in_ch || \ + zs->state_in_len == 255) { \ + if (zs->state_in_ch < 256) \ + add_pair_to_block ( zs ); \ + zs->state_in_ch = zchh; \ + zs->state_in_len = 1; \ + } else { \ + zs->state_in_len++; \ + } \ +} + + +/*---------------------------------------------------*/ +static +Bool copy_input_until_stop ( EState* s ) +{ + Bool progress_in = False; + + if (s->mode == BZ_M_RUNNING) { + + /*-- fast track the common case --*/ + while (True) { + /*-- block full? --*/ + if (s->nblock >= s->nblockMAX) break; + /*-- no input? --*/ + if (s->strm->avail_in == 0) break; + progress_in = True; + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + s->strm->next_in++; + s->strm->avail_in--; + s->strm->total_in_lo32++; + if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; + } + + } else { + + /*-- general, uncommon case --*/ + while (True) { + /*-- block full? --*/ + if (s->nblock >= s->nblockMAX) break; + /*-- no input? --*/ + if (s->strm->avail_in == 0) break; + /*-- flush/finish end? --*/ + if (s->avail_in_expect == 0) break; + progress_in = True; + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + s->strm->next_in++; + s->strm->avail_in--; + s->strm->total_in_lo32++; + if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; + s->avail_in_expect--; + } + } + return progress_in; +} + + +/*---------------------------------------------------*/ +static +Bool copy_output_until_stop ( EState* s ) +{ + Bool progress_out = False; + + while (True) { + + /*-- no output space? --*/ + if (s->strm->avail_out == 0) break; + + /*-- block done? --*/ + if (s->state_out_pos >= s->numZ) break; + + progress_out = True; + *(s->strm->next_out) = s->zbits[s->state_out_pos]; + s->state_out_pos++; + s->strm->avail_out--; + s->strm->next_out++; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + return progress_out; +} + + +/*---------------------------------------------------*/ +static +Bool handle_compress ( bz_stream* strm ) +{ + Bool progress_in = False; + Bool progress_out = False; + EState* s = strm->state; + + while (True) { + + if (s->state == BZ_S_OUTPUT) { + progress_out |= copy_output_until_stop ( s ); + if (s->state_out_pos < s->numZ) break; + if (s->mode == BZ_M_FINISHING && + s->avail_in_expect == 0 && + isempty_RL(s)) break; + prepare_new_block ( s ); + s->state = BZ_S_INPUT; + if (s->mode == BZ_M_FLUSHING && + s->avail_in_expect == 0 && + isempty_RL(s)) break; + } + + if (s->state == BZ_S_INPUT) { + progress_in |= copy_input_until_stop ( s ); + if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) { + flush_RL ( s ); + BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) ); + s->state = BZ_S_OUTPUT; + } + else + if (s->nblock >= s->nblockMAX) { + BZ2_compressBlock ( s, False ); + s->state = BZ_S_OUTPUT; + } + else + if (s->strm->avail_in == 0) { + break; + } + } + + } + + return progress_in || progress_out; +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) +{ + Bool progress; + EState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + preswitch: + switch (s->mode) { + + case BZ_M_IDLE: + return BZ_SEQUENCE_ERROR; + + case BZ_M_RUNNING: + if (action == BZ_RUN) { + progress = handle_compress ( strm ); + return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; + } + else + if (action == BZ_FLUSH) { + s->avail_in_expect = strm->avail_in; + s->mode = BZ_M_FLUSHING; + goto preswitch; + } + else + if (action == BZ_FINISH) { + s->avail_in_expect = strm->avail_in; + s->mode = BZ_M_FINISHING; + goto preswitch; + } + else + return BZ_PARAM_ERROR; + + case BZ_M_FLUSHING: + if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; + if (s->avail_in_expect != s->strm->avail_in) + return BZ_SEQUENCE_ERROR; + progress = handle_compress ( strm ); + if (s->avail_in_expect > 0 || !isempty_RL(s) || + s->state_out_pos < s->numZ) return BZ_FLUSH_OK; + s->mode = BZ_M_RUNNING; + return BZ_RUN_OK; + + case BZ_M_FINISHING: + if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; + if (s->avail_in_expect != s->strm->avail_in) + return BZ_SEQUENCE_ERROR; + progress = handle_compress ( strm ); + if (!progress) return BZ_SEQUENCE_ERROR; + if (s->avail_in_expect > 0 || !isempty_RL(s) || + s->state_out_pos < s->numZ) return BZ_FINISH_OK; + s->mode = BZ_M_IDLE; + return BZ_STREAM_END; + } + return BZ_OK; /*--not reached--*/ +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) +{ + EState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + if (s->arr1 != NULL) BZFREE(s->arr1); + if (s->arr2 != NULL) BZFREE(s->arr2); + if (s->ftab != NULL) BZFREE(s->ftab); + BZFREE(strm->state); + + strm->state = NULL; + + return BZ_OK; +} + + +/*---------------------------------------------------*/ +/*--- Decompression stuff ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzDecompressInit) + ( bz_stream* strm, + int verbosity, + int small ) +{ + DState* s; + + if (!bz_config_ok()) return BZ_CONFIG_ERROR; + + if (strm == NULL) return BZ_PARAM_ERROR; + if (small != 0 && small != 1) return BZ_PARAM_ERROR; + if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; + + if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; + if (strm->bzfree == NULL) strm->bzfree = default_bzfree; + + s = BZALLOC( sizeof(DState) ); + if (s == NULL) return BZ_MEM_ERROR; + s->strm = strm; + strm->state = s; + s->state = BZ_X_MAGIC_1; + s->bsLive = 0; + s->bsBuff = 0; + s->calculatedCombinedCRC = 0; + strm->total_in_lo32 = 0; + strm->total_in_hi32 = 0; + strm->total_out_lo32 = 0; + strm->total_out_hi32 = 0; + s->smallDecompress = (Bool)small; + s->ll4 = NULL; + s->ll16 = NULL; + s->tt = NULL; + s->currBlockNo = 0; + s->verbosity = verbosity; + + return BZ_OK; +} + + +/*---------------------------------------------------*/ +/* Return True iff data corruption is discovered. + Returns False if there is no problem. +*/ +static +Bool unRLE_obuf_to_output_FAST ( DState* s ) +{ + UChar k1; + + if (s->blockRandomised) { + + while (True) { + /* try to finish existing run */ + while (True) { + if (s->strm->avail_out == 0) return False; + if (s->state_out_len == 0) break; + *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; + BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); + s->state_out_len--; + s->strm->next_out++; + s->strm->avail_out--; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + /* can a new run be started? */ + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; + + s->state_out_len = 1; + s->state_out_ch = s->k0; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 2; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 3; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + s->state_out_len = ((Int32)k1) + 4; + BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; + s->k0 ^= BZ_RAND_MASK; s->nblock_used++; + } + + } else { + + /* restore */ + UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC; + UChar c_state_out_ch = s->state_out_ch; + Int32 c_state_out_len = s->state_out_len; + Int32 c_nblock_used = s->nblock_used; + Int32 c_k0 = s->k0; + UInt32* c_tt = s->tt; + UInt32 c_tPos = s->tPos; + char* cs_next_out = s->strm->next_out; + unsigned int cs_avail_out = s->strm->avail_out; + Int32 ro_blockSize100k = s->blockSize100k; + /* end restore */ + + UInt32 avail_out_INIT = cs_avail_out; + Int32 s_save_nblockPP = s->save_nblock+1; + unsigned int total_out_lo32_old; + + while (True) { + + /* try to finish existing run */ + if (c_state_out_len > 0) { + while (True) { + if (cs_avail_out == 0) goto return_notr; + if (c_state_out_len == 1) break; + *( (UChar*)(cs_next_out) ) = c_state_out_ch; + BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); + c_state_out_len--; + cs_next_out++; + cs_avail_out--; + } + s_state_out_len_eq_one: + { + if (cs_avail_out == 0) { + c_state_out_len = 1; goto return_notr; + }; + *( (UChar*)(cs_next_out) ) = c_state_out_ch; + BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); + cs_next_out++; + cs_avail_out--; + } + } + /* Only caused by corrupt data stream? */ + if (c_nblock_used > s_save_nblockPP) + return True; + + /* can a new run be started? */ + if (c_nblock_used == s_save_nblockPP) { + c_state_out_len = 0; goto return_notr; + }; + c_state_out_ch = c_k0; + BZ_GET_FAST_C(k1); c_nblock_used++; + if (k1 != c_k0) { + c_k0 = k1; goto s_state_out_len_eq_one; + }; + if (c_nblock_used == s_save_nblockPP) + goto s_state_out_len_eq_one; + + c_state_out_len = 2; + BZ_GET_FAST_C(k1); c_nblock_used++; + if (c_nblock_used == s_save_nblockPP) continue; + if (k1 != c_k0) { c_k0 = k1; continue; }; + + c_state_out_len = 3; + BZ_GET_FAST_C(k1); c_nblock_used++; + if (c_nblock_used == s_save_nblockPP) continue; + if (k1 != c_k0) { c_k0 = k1; continue; }; + + BZ_GET_FAST_C(k1); c_nblock_used++; + c_state_out_len = ((Int32)k1) + 4; + BZ_GET_FAST_C(c_k0); c_nblock_used++; + } + + return_notr: + total_out_lo32_old = s->strm->total_out_lo32; + s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out); + if (s->strm->total_out_lo32 < total_out_lo32_old) + s->strm->total_out_hi32++; + + /* save */ + s->calculatedBlockCRC = c_calculatedBlockCRC; + s->state_out_ch = c_state_out_ch; + s->state_out_len = c_state_out_len; + s->nblock_used = c_nblock_used; + s->k0 = c_k0; + s->tt = c_tt; + s->tPos = c_tPos; + s->strm->next_out = cs_next_out; + s->strm->avail_out = cs_avail_out; + /* end save */ + } + return False; +} + + + +/*---------------------------------------------------*/ +__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) +{ + Int32 nb, na, mid; + nb = 0; + na = 256; + do { + mid = (nb + na) >> 1; + if (indx >= cftab[mid]) nb = mid; else na = mid; + } + while (na - nb != 1); + return nb; +} + + +/*---------------------------------------------------*/ +/* Return True iff data corruption is discovered. + Returns False if there is no problem. +*/ +static +Bool unRLE_obuf_to_output_SMALL ( DState* s ) +{ + UChar k1; + + if (s->blockRandomised) { + + while (True) { + /* try to finish existing run */ + while (True) { + if (s->strm->avail_out == 0) return False; + if (s->state_out_len == 0) break; + *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; + BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); + s->state_out_len--; + s->strm->next_out++; + s->strm->avail_out--; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + /* can a new run be started? */ + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; + + s->state_out_len = 1; + s->state_out_ch = s->k0; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 2; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 3; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + k1 ^= BZ_RAND_MASK; s->nblock_used++; + s->state_out_len = ((Int32)k1) + 4; + BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; + s->k0 ^= BZ_RAND_MASK; s->nblock_used++; + } + + } else { + + while (True) { + /* try to finish existing run */ + while (True) { + if (s->strm->avail_out == 0) return False; + if (s->state_out_len == 0) break; + *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; + BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); + s->state_out_len--; + s->strm->next_out++; + s->strm->avail_out--; + s->strm->total_out_lo32++; + if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + } + + /* can a new run be started? */ + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; + + s->state_out_len = 1; + s->state_out_ch = s->k0; + BZ_GET_SMALL(k1); s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 2; + BZ_GET_SMALL(k1); s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + s->state_out_len = 3; + BZ_GET_SMALL(k1); s->nblock_used++; + if (s->nblock_used == s->save_nblock+1) continue; + if (k1 != s->k0) { s->k0 = k1; continue; }; + + BZ_GET_SMALL(k1); s->nblock_used++; + s->state_out_len = ((Int32)k1) + 4; + BZ_GET_SMALL(s->k0); s->nblock_used++; + } + + } +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) +{ + Bool corrupt; + DState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + while (True) { + if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; + if (s->state == BZ_X_OUTPUT) { + if (s->smallDecompress) + corrupt = unRLE_obuf_to_output_SMALL ( s ); else + corrupt = unRLE_obuf_to_output_FAST ( s ); + if (corrupt) return BZ_DATA_ERROR; + if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { + BZ_FINALISE_CRC ( s->calculatedBlockCRC ); + if (s->verbosity >= 3) + VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, + s->calculatedBlockCRC ); + if (s->verbosity >= 2) VPrintf0 ( "]" ); + if (s->calculatedBlockCRC != s->storedBlockCRC) + return BZ_DATA_ERROR; + s->calculatedCombinedCRC + = (s->calculatedCombinedCRC << 1) | + (s->calculatedCombinedCRC >> 31); + s->calculatedCombinedCRC ^= s->calculatedBlockCRC; + s->state = BZ_X_BLKHDR_1; + } else { + return BZ_OK; + } + } + if (s->state >= BZ_X_MAGIC_1) { + Int32 r = BZ2_decompress ( s ); + if (r == BZ_STREAM_END) { + if (s->verbosity >= 3) + VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", + s->storedCombinedCRC, s->calculatedCombinedCRC ); + if (s->calculatedCombinedCRC != s->storedCombinedCRC) + return BZ_DATA_ERROR; + return r; + } + if (s->state != BZ_X_OUTPUT) return r; + } + } + + AssertH ( 0, 6001 ); + + return 0; /*NOTREACHED*/ +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) +{ + DState* s; + if (strm == NULL) return BZ_PARAM_ERROR; + s = strm->state; + if (s == NULL) return BZ_PARAM_ERROR; + if (s->strm != strm) return BZ_PARAM_ERROR; + + if (s->tt != NULL) BZFREE(s->tt); + if (s->ll16 != NULL) BZFREE(s->ll16); + if (s->ll4 != NULL) BZFREE(s->ll4); + + BZFREE(strm->state); + strm->state = NULL; + + return BZ_OK; +} + + +#ifndef BZ_NO_STDIO +/*---------------------------------------------------*/ +/*--- File I/O stuff ---*/ +/*---------------------------------------------------*/ + +#define BZ_SETERR(eee) \ +{ \ + if (bzerror != NULL) *bzerror = eee; \ + if (bzf != NULL) bzf->lastErr = eee; \ +} + +typedef + struct { + FILE* handle; + Char buf[BZ_MAX_UNUSED]; + Int32 bufN; + Bool writing; + bz_stream strm; + Int32 lastErr; + Bool initialisedOk; + } + bzFile; + + +/*---------------------------------------------*/ +static Bool myfeof ( FILE* f ) +{ + Int32 c = fgetc ( f ); + if (c == EOF) return True; + ungetc ( c, f ); + return False; +} + + +/*---------------------------------------------------*/ +BZFILE* BZ_API(BZ2_bzWriteOpen) + ( int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor ) +{ + Int32 ret; + bzFile* bzf = NULL; + + BZ_SETERR(BZ_OK); + + if (f == NULL || + (blockSize100k < 1 || blockSize100k > 9) || + (workFactor < 0 || workFactor > 250) || + (verbosity < 0 || verbosity > 4)) + { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; + + if (ferror(f)) + { BZ_SETERR(BZ_IO_ERROR); return NULL; }; + + bzf = malloc ( sizeof(bzFile) ); + if (bzf == NULL) + { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; + + BZ_SETERR(BZ_OK); + bzf->initialisedOk = False; + bzf->bufN = 0; + bzf->handle = f; + bzf->writing = True; + bzf->strm.bzalloc = NULL; + bzf->strm.bzfree = NULL; + bzf->strm.opaque = NULL; + + if (workFactor == 0) workFactor = 30; + ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, + verbosity, workFactor ); + if (ret != BZ_OK) + { BZ_SETERR(ret); free(bzf); return NULL; }; + + bzf->strm.avail_in = 0; + bzf->initialisedOk = True; + return bzf; +} + + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzWrite) + ( int* bzerror, + BZFILE* b, + void* buf, + int len ) +{ + Int32 n, n2, ret; + bzFile* bzf = (bzFile*)b; + + BZ_SETERR(BZ_OK); + if (bzf == NULL || buf == NULL || len < 0) + { BZ_SETERR(BZ_PARAM_ERROR); return; }; + if (!(bzf->writing)) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + + if (len == 0) + { BZ_SETERR(BZ_OK); return; }; + + bzf->strm.avail_in = len; + bzf->strm.next_in = buf; + + while (True) { + bzf->strm.avail_out = BZ_MAX_UNUSED; + bzf->strm.next_out = bzf->buf; + ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN ); + if (ret != BZ_RUN_OK) + { BZ_SETERR(ret); return; }; + + if (bzf->strm.avail_out < BZ_MAX_UNUSED) { + n = BZ_MAX_UNUSED - bzf->strm.avail_out; + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n, bzf->handle ); + if (n != n2 || ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + } + + if (bzf->strm.avail_in == 0) + { BZ_SETERR(BZ_OK); return; }; + } +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzWriteClose) + ( int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out ) +{ + BZ2_bzWriteClose64 ( bzerror, b, abandon, + nbytes_in, NULL, nbytes_out, NULL ); +} + + +void BZ_API(BZ2_bzWriteClose64) + ( int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, + unsigned int* nbytes_out_hi32 ) +{ + Int32 n, n2, ret; + bzFile* bzf = (bzFile*)b; + + if (bzf == NULL) + { BZ_SETERR(BZ_OK); return; }; + if (!(bzf->writing)) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + + if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0; + if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0; + if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0; + if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0; + + if ((!abandon) && bzf->lastErr == BZ_OK) { + while (True) { + bzf->strm.avail_out = BZ_MAX_UNUSED; + bzf->strm.next_out = bzf->buf; + ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH ); + if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END) + { BZ_SETERR(ret); return; }; + + if (bzf->strm.avail_out < BZ_MAX_UNUSED) { + n = BZ_MAX_UNUSED - bzf->strm.avail_out; + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n, bzf->handle ); + if (n != n2 || ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + } + + if (ret == BZ_STREAM_END) break; + } + } + + if ( !abandon && !ferror ( bzf->handle ) ) { + fflush ( bzf->handle ); + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return; }; + } + + if (nbytes_in_lo32 != NULL) + *nbytes_in_lo32 = bzf->strm.total_in_lo32; + if (nbytes_in_hi32 != NULL) + *nbytes_in_hi32 = bzf->strm.total_in_hi32; + if (nbytes_out_lo32 != NULL) + *nbytes_out_lo32 = bzf->strm.total_out_lo32; + if (nbytes_out_hi32 != NULL) + *nbytes_out_hi32 = bzf->strm.total_out_hi32; + + BZ_SETERR(BZ_OK); + BZ2_bzCompressEnd ( &(bzf->strm) ); + free ( bzf ); +} + + +/*---------------------------------------------------*/ +BZFILE* BZ_API(BZ2_bzReadOpen) + ( int* bzerror, + FILE* f, + int verbosity, + int small, + void* unused, + int nUnused ) +{ + bzFile* bzf = NULL; + int ret; + + BZ_SETERR(BZ_OK); + + if (f == NULL || + (small != 0 && small != 1) || + (verbosity < 0 || verbosity > 4) || + (unused == NULL && nUnused != 0) || + (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED))) + { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; + + if (ferror(f)) + { BZ_SETERR(BZ_IO_ERROR); return NULL; }; + + bzf = malloc ( sizeof(bzFile) ); + if (bzf == NULL) + { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; + + BZ_SETERR(BZ_OK); + + bzf->initialisedOk = False; + bzf->handle = f; + bzf->bufN = 0; + bzf->writing = False; + bzf->strm.bzalloc = NULL; + bzf->strm.bzfree = NULL; + bzf->strm.opaque = NULL; + + while (nUnused > 0) { + bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; + unused = ((void*)( 1 + ((UChar*)(unused)) )); + nUnused--; + } + + ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small ); + if (ret != BZ_OK) + { BZ_SETERR(ret); free(bzf); return NULL; }; + + bzf->strm.avail_in = bzf->bufN; + bzf->strm.next_in = bzf->buf; + + bzf->initialisedOk = True; + return bzf; +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) +{ + bzFile* bzf = (bzFile*)b; + + BZ_SETERR(BZ_OK); + if (bzf == NULL) + { BZ_SETERR(BZ_OK); return; }; + + if (bzf->writing) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + + if (bzf->initialisedOk) + (void)BZ2_bzDecompressEnd ( &(bzf->strm) ); + free ( bzf ); +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzRead) + ( int* bzerror, + BZFILE* b, + void* buf, + int len ) +{ + Int32 n, ret; + bzFile* bzf = (bzFile*)b; + + BZ_SETERR(BZ_OK); + + if (bzf == NULL || buf == NULL || len < 0) + { BZ_SETERR(BZ_PARAM_ERROR); return 0; }; + + if (bzf->writing) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; }; + + if (len == 0) + { BZ_SETERR(BZ_OK); return 0; }; + + bzf->strm.avail_out = len; + bzf->strm.next_out = buf; + + while (True) { + + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return 0; }; + + if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) { + n = fread ( bzf->buf, sizeof(UChar), + BZ_MAX_UNUSED, bzf->handle ); + if (ferror(bzf->handle)) + { BZ_SETERR(BZ_IO_ERROR); return 0; }; + bzf->bufN = n; + bzf->strm.avail_in = bzf->bufN; + bzf->strm.next_in = bzf->buf; + } + + ret = BZ2_bzDecompress ( &(bzf->strm) ); + + if (ret != BZ_OK && ret != BZ_STREAM_END) + { BZ_SETERR(ret); return 0; }; + + if (ret == BZ_OK && myfeof(bzf->handle) && + bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) + { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; + + if (ret == BZ_STREAM_END) + { BZ_SETERR(BZ_STREAM_END); + return len - bzf->strm.avail_out; }; + if (bzf->strm.avail_out == 0) + { BZ_SETERR(BZ_OK); return len; }; + + } + + return 0; /*not reached*/ +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzReadGetUnused) + ( int* bzerror, + BZFILE* b, + void** unused, + int* nUnused ) +{ + bzFile* bzf = (bzFile*)b; + if (bzf == NULL) + { BZ_SETERR(BZ_PARAM_ERROR); return; }; + if (bzf->lastErr != BZ_STREAM_END) + { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; + if (unused == NULL || nUnused == NULL) + { BZ_SETERR(BZ_PARAM_ERROR); return; }; + + BZ_SETERR(BZ_OK); + *nUnused = bzf->strm.avail_in; + *unused = bzf->strm.next_in; +} +#endif + + +/*---------------------------------------------------*/ +/*--- Misc convenience stuff ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int blockSize100k, + int verbosity, + int workFactor ) +{ + bz_stream strm; + int ret; + + if (dest == NULL || destLen == NULL || + source == NULL || + blockSize100k < 1 || blockSize100k > 9 || + verbosity < 0 || verbosity > 4 || + workFactor < 0 || workFactor > 250) + return BZ_PARAM_ERROR; + + if (workFactor == 0) workFactor = 30; + strm.bzalloc = NULL; + strm.bzfree = NULL; + strm.opaque = NULL; + ret = BZ2_bzCompressInit ( &strm, blockSize100k, + verbosity, workFactor ); + if (ret != BZ_OK) return ret; + + strm.next_in = source; + strm.next_out = dest; + strm.avail_in = sourceLen; + strm.avail_out = *destLen; + + ret = BZ2_bzCompress ( &strm, BZ_FINISH ); + if (ret == BZ_FINISH_OK) goto output_overflow; + if (ret != BZ_STREAM_END) goto errhandler; + + /* normal termination */ + *destLen -= strm.avail_out; + BZ2_bzCompressEnd ( &strm ); + return BZ_OK; + + output_overflow: + BZ2_bzCompressEnd ( &strm ); + return BZ_OUTBUFF_FULL; + + errhandler: + BZ2_bzCompressEnd ( &strm ); + return ret; +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzBuffToBuffDecompress) + ( char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int small, + int verbosity ) +{ + bz_stream strm; + int ret; + + if (dest == NULL || destLen == NULL || + source == NULL || + (small != 0 && small != 1) || + verbosity < 0 || verbosity > 4) + return BZ_PARAM_ERROR; + + strm.bzalloc = NULL; + strm.bzfree = NULL; + strm.opaque = NULL; + ret = BZ2_bzDecompressInit ( &strm, verbosity, small ); + if (ret != BZ_OK) return ret; + + strm.next_in = source; + strm.next_out = dest; + strm.avail_in = sourceLen; + strm.avail_out = *destLen; + + ret = BZ2_bzDecompress ( &strm ); + if (ret == BZ_OK) goto output_overflow_or_eof; + if (ret != BZ_STREAM_END) goto errhandler; + + /* normal termination */ + *destLen -= strm.avail_out; + BZ2_bzDecompressEnd ( &strm ); + return BZ_OK; + + output_overflow_or_eof: + if (strm.avail_out > 0) { + BZ2_bzDecompressEnd ( &strm ); + return BZ_UNEXPECTED_EOF; + } else { + BZ2_bzDecompressEnd ( &strm ); + return BZ_OUTBUFF_FULL; + }; + + errhandler: + BZ2_bzDecompressEnd ( &strm ); + return ret; +} + + +/*---------------------------------------------------*/ +/*-- + Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) + to support better zlib compatibility. + This code is not _officially_ part of libbzip2 (yet); + I haven't tested it, documented it, or considered the + threading-safeness of it. + If this code breaks, please contact both Yoshioka and me. +--*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +/*-- + return version like "0.9.5d, 4-Sept-1999". +--*/ +const char * BZ_API(BZ2_bzlibVersion)(void) +{ + return BZ_VERSION; +} + + +#ifndef BZ_NO_STDIO +/*---------------------------------------------------*/ + +#if defined(_WIN32) || defined(OS2) || defined(MSDOS) +# include +# include +# define SET_BINARY_MODE(file) _setmode(_fileno(file),O_BINARY) +#else +# define SET_BINARY_MODE(file) +#endif +static +BZFILE * bzopen_or_bzdopen + ( const char *path, /* no use when bzdopen */ + int fd, /* no use when bzdopen */ + const char *mode, + int open_mode) /* bzopen: 0, bzdopen:1 */ +{ + int bzerr; + char unused[BZ_MAX_UNUSED]; + int blockSize100k = 9; + int writing = 0; + char mode2[10] = ""; + FILE *fp = NULL; + BZFILE *bzfp = NULL; + int verbosity = 0; + int workFactor = 30; + int smallMode = 0; + int nUnused = 0; + + if (mode == NULL) return NULL; + while (*mode) { + switch (*mode) { + case 'r': + writing = 0; break; + case 'w': + writing = 1; break; + case 's': + smallMode = 1; break; + default: + if (isdigit((int)(*mode))) { + blockSize100k = *mode-BZ_HDR_0; + } + } + mode++; + } + strcat(mode2, writing ? "w" : "r" ); + strcat(mode2,"b"); /* binary mode */ + + if (open_mode==0) { + if (path==NULL || strcmp(path,"")==0) { + fp = (writing ? stdout : stdin); + SET_BINARY_MODE(fp); + } else { + fp = fopen(path,mode2); + } + } else { +#ifdef BZ_STRICT_ANSI + fp = NULL; +#else + fp = _fdopen(fd,mode2); +#endif + } + if (fp == NULL) return NULL; + + if (writing) { + /* Guard against total chaos and anarchy -- JRS */ + if (blockSize100k < 1) blockSize100k = 1; + if (blockSize100k > 9) blockSize100k = 9; + bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, + verbosity,workFactor); + } else { + bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode, + unused,nUnused); + } + if (bzfp == NULL) { + if (fp != stdin && fp != stdout) fclose(fp); + return NULL; + } + return bzfp; +} + + +/*---------------------------------------------------*/ +/*-- + open file for read or write. + ex) bzopen("file","w9") + case path="" or NULL => use stdin or stdout. +--*/ +BZFILE * BZ_API(BZ2_bzopen) + ( const char *path, + const char *mode ) +{ + return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0); +} + + +/*---------------------------------------------------*/ +BZFILE * BZ_API(BZ2_bzdopen) + ( int fd, + const char *mode ) +{ + return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1); +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len ) +{ + int bzerr, nread; + if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0; + nread = BZ2_bzRead(&bzerr,b,buf,len); + if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) { + return nread; + } else { + return -1; + } +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len ) +{ + int bzerr; + + BZ2_bzWrite(&bzerr,b,buf,len); + if(bzerr == BZ_OK){ + return len; + }else{ + return -1; + } +} + + +/*---------------------------------------------------*/ +int BZ_API(BZ2_bzflush) (BZFILE *b) +{ + /* do nothing now... */ + return 0; +} + + +/*---------------------------------------------------*/ +void BZ_API(BZ2_bzclose) (BZFILE* b) +{ + int bzerr; + FILE *fp; + + if (b==NULL) {return;} + fp = ((bzFile *)b)->handle; + if(((bzFile*)b)->writing){ + BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); + if(bzerr != BZ_OK){ + BZ2_bzWriteClose(NULL,b,1,NULL,NULL); + } + }else{ + BZ2_bzReadClose(&bzerr,b); + } + if(fp!=stdin && fp!=stdout){ + fclose(fp); + } +} + + +/*---------------------------------------------------*/ +/*-- + return last error code +--*/ +static const char *bzerrorstrings[] = { + "OK" + ,"SEQUENCE_ERROR" + ,"PARAM_ERROR" + ,"MEM_ERROR" + ,"DATA_ERROR" + ,"DATA_ERROR_MAGIC" + ,"IO_ERROR" + ,"UNEXPECTED_EOF" + ,"OUTBUFF_FULL" + ,"CONFIG_ERROR" + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ + ,"???" /* for future */ +}; + + +const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) +{ + int err = ((bzFile *)b)->lastErr; + + if(err>0) err = 0; + *errnum = err; + return bzerrorstrings[err*-1]; +} +#endif + + +/*-------------------------------------------------------------*/ +/*--- end bzlib.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/bzlib.h b/dep/StormLib/src/bzip2/bzlib.h new file mode 100644 index 000000000..c5b75d6d8 --- /dev/null +++ b/dep/StormLib/src/bzip2/bzlib.h @@ -0,0 +1,282 @@ + +/*-------------------------------------------------------------*/ +/*--- Public header file for the library. ---*/ +/*--- bzlib.h ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#ifndef _BZLIB_H +#define _BZLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define BZ_RUN 0 +#define BZ_FLUSH 1 +#define BZ_FINISH 2 + +#define BZ_OK 0 +#define BZ_RUN_OK 1 +#define BZ_FLUSH_OK 2 +#define BZ_FINISH_OK 3 +#define BZ_STREAM_END 4 +#define BZ_SEQUENCE_ERROR (-1) +#define BZ_PARAM_ERROR (-2) +#define BZ_MEM_ERROR (-3) +#define BZ_DATA_ERROR (-4) +#define BZ_DATA_ERROR_MAGIC (-5) +#define BZ_IO_ERROR (-6) +#define BZ_UNEXPECTED_EOF (-7) +#define BZ_OUTBUFF_FULL (-8) +#define BZ_CONFIG_ERROR (-9) + +typedef + struct { + char *next_in; + unsigned int avail_in; + unsigned int total_in_lo32; + unsigned int total_in_hi32; + + char *next_out; + unsigned int avail_out; + unsigned int total_out_lo32; + unsigned int total_out_hi32; + + void *state; + + void *(*bzalloc)(void *,int,int); + void (*bzfree)(void *,void *); + void *opaque; + } + bz_stream; + + +#ifndef BZ_IMPORT +#define BZ_EXPORT +#endif + +#ifndef BZ_NO_STDIO +/* Need a definitition for FILE */ +#include +#endif + +#ifdef _WIN32 +# include +# ifdef small + /* windows.h define small to char */ +# undef small +# endif +# ifdef BZ_EXPORT +# define BZ_API(func) WINAPI func +# define BZ_EXTERN extern +# else + /* import windows dll dynamically */ +# define BZ_API(func) (WINAPI * func) +# define BZ_EXTERN +# endif +#else +# define BZ_API(func) func +# define BZ_EXTERN extern +#endif + + +/*-- Core (low-level) library functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, + int small + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm + ); + + + +/*-- High(er) level library functions --*/ + +#ifndef BZ_NO_STDIO +#define BZ_MAX_UNUSED 5000 + +typedef void BZFILE; + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, + int small, + void* unused, + int nUnused + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused + ); + +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, + unsigned int* nbytes_out_hi32 + ); +#endif + + +/*-- Utility functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int small, + int verbosity + ); + + +/*-- + Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) + to support better zlib compatibility. + This code is not _officially_ part of libbzip2 (yet); + I haven't tested it, documented it, or considered the + threading-safeness of it. + If this code breaks, please contact both Yoshioka and me. +--*/ + +BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( + void + ); + +#ifndef BZ_NO_STDIO +BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( + const char *path, + const char *mode + ); + +BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( + int fd, + const char *mode + ); + +BZ_EXTERN int BZ_API(BZ2_bzread) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzwrite) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzflush) ( + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzclose) ( + BZFILE* b + ); + +BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( + BZFILE *b, + int *errnum + ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +/*-------------------------------------------------------------*/ +/*--- end bzlib.h ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/bzlib_private.h b/dep/StormLib/src/bzip2/bzlib_private.h new file mode 100644 index 000000000..23427879b --- /dev/null +++ b/dep/StormLib/src/bzip2/bzlib_private.h @@ -0,0 +1,509 @@ + +/*-------------------------------------------------------------*/ +/*--- Private header file for the library. ---*/ +/*--- bzlib_private.h ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#ifndef _BZLIB_PRIVATE_H +#define _BZLIB_PRIVATE_H + +#include + +#ifndef BZ_NO_STDIO +#include +#include +#include +#endif + +#include "bzlib.h" + + + +/*-- General stuff. --*/ + +#define BZ_VERSION "1.0.5, 10-Dec-2007" + +typedef char Char; +typedef unsigned char Bool; +typedef unsigned char UChar; +typedef int Int32; +typedef unsigned int UInt32; +typedef short Int16; +typedef unsigned short UInt16; + +#define True ((Bool)1) +#define False ((Bool)0) + +#ifndef __GNUC__ +#define __inline__ /* */ +#endif + +#ifndef BZ_NO_STDIO + +extern void BZ2_bz__AssertH__fail ( int errcode ); +#define AssertH(cond,errcode) \ + { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } + +#if BZ_DEBUG +#define AssertD(cond,msg) \ + { if (!(cond)) { \ + fprintf ( stderr, \ + "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ + exit(1); \ + }} +#else +#define AssertD(cond,msg) /* */ +#endif + +#define VPrintf0(zf) \ + fprintf(stderr,zf) +#define VPrintf1(zf,za1) \ + fprintf(stderr,zf,za1) +#define VPrintf2(zf,za1,za2) \ + fprintf(stderr,zf,za1,za2) +#define VPrintf3(zf,za1,za2,za3) \ + fprintf(stderr,zf,za1,za2,za3) +#define VPrintf4(zf,za1,za2,za3,za4) \ + fprintf(stderr,zf,za1,za2,za3,za4) +#define VPrintf5(zf,za1,za2,za3,za4,za5) \ + fprintf(stderr,zf,za1,za2,za3,za4,za5) + +#else + +extern void bz_internal_error ( int errcode ); +#define AssertH(cond,errcode) \ + { if (!(cond)) bz_internal_error ( errcode ); } +#define AssertD(cond,msg) do { } while (0) +#define VPrintf0(zf) do { } while (0) +#define VPrintf1(zf,za1) do { } while (0) +#define VPrintf2(zf,za1,za2) do { } while (0) +#define VPrintf3(zf,za1,za2,za3) do { } while (0) +#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0) +#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0) + +#endif + + +#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) +#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) + + +/*-- Header bytes. --*/ + +#define BZ_HDR_B 0x42 /* 'B' */ +#define BZ_HDR_Z 0x5a /* 'Z' */ +#define BZ_HDR_h 0x68 /* 'h' */ +#define BZ_HDR_0 0x30 /* '0' */ + +/*-- Constants for the back end. --*/ + +#define BZ_MAX_ALPHA_SIZE 258 +#define BZ_MAX_CODE_LEN 23 + +#define BZ_RUNA 0 +#define BZ_RUNB 1 + +#define BZ_N_GROUPS 6 +#define BZ_G_SIZE 50 +#define BZ_N_ITERS 4 + +#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE)) + + + +/*-- Stuff for randomising repetitive blocks. --*/ + +extern Int32 BZ2_rNums[512]; + +#define BZ_RAND_DECLS \ + Int32 rNToGo; \ + Int32 rTPos \ + +#define BZ_RAND_INIT_MASK \ + s->rNToGo = 0; \ + s->rTPos = 0 \ + +#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0) + +#define BZ_RAND_UPD_MASK \ + if (s->rNToGo == 0) { \ + s->rNToGo = BZ2_rNums[s->rTPos]; \ + s->rTPos++; \ + if (s->rTPos == 512) s->rTPos = 0; \ + } \ + s->rNToGo--; + + + +/*-- Stuff for doing CRCs. --*/ + +extern UInt32 BZ2_crc32Table[256]; + +#define BZ_INITIALISE_CRC(crcVar) \ +{ \ + crcVar = 0xffffffffL; \ +} + +#define BZ_FINALISE_CRC(crcVar) \ +{ \ + crcVar = ~(crcVar); \ +} + +#define BZ_UPDATE_CRC(crcVar,cha) \ +{ \ + crcVar = (crcVar << 8) ^ \ + BZ2_crc32Table[(crcVar >> 24) ^ \ + ((UChar)cha)]; \ +} + + + +/*-- States and modes for compression. --*/ + +#define BZ_M_IDLE 1 +#define BZ_M_RUNNING 2 +#define BZ_M_FLUSHING 3 +#define BZ_M_FINISHING 4 + +#define BZ_S_OUTPUT 1 +#define BZ_S_INPUT 2 + +#define BZ_N_RADIX 2 +#define BZ_N_QSORT 12 +#define BZ_N_SHELL 18 +#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) + + + + +/*-- Structure holding all the compression-side stuff. --*/ + +typedef + struct { + /* pointer back to the struct bz_stream */ + bz_stream* strm; + + /* mode this stream is in, and whether inputting */ + /* or outputting data */ + Int32 mode; + Int32 state; + + /* remembers avail_in when flush/finish requested */ + UInt32 avail_in_expect; + + /* for doing the block sorting */ + UInt32* arr1; + UInt32* arr2; + UInt32* ftab; + Int32 origPtr; + + /* aliases for arr1 and arr2 */ + UInt32* ptr; + UChar* block; + UInt16* mtfv; + UChar* zbits; + + /* for deciding when to use the fallback sorting algorithm */ + Int32 workFactor; + + /* run-length-encoding of the input */ + UInt32 state_in_ch; + Int32 state_in_len; + BZ_RAND_DECLS; + + /* input and output limits and current posns */ + Int32 nblock; + Int32 nblockMAX; + Int32 numZ; + Int32 state_out_pos; + + /* map of bytes used in block */ + Int32 nInUse; + Bool inUse[256]; + UChar unseqToSeq[256]; + + /* the buffer for bit stream creation */ + UInt32 bsBuff; + Int32 bsLive; + + /* block and combined CRCs */ + UInt32 blockCRC; + UInt32 combinedCRC; + + /* misc administratium */ + Int32 verbosity; + Int32 blockNo; + Int32 blockSize100k; + + /* stuff for coding the MTF values */ + Int32 nMTF; + Int32 mtfFreq [BZ_MAX_ALPHA_SIZE]; + UChar selector [BZ_MAX_SELECTORS]; + UChar selectorMtf[BZ_MAX_SELECTORS]; + + UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + /* second dimension: only 3 needed; 4 makes index calculations faster */ + UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4]; + + } + EState; + + + +/*-- externs for compression. --*/ + +extern void +BZ2_blockSort ( EState* ); + +extern void +BZ2_compressBlock ( EState*, Bool ); + +extern void +BZ2_bsInitWrite ( EState* ); + +extern void +BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); + +extern void +BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); + + + +/*-- states for decompression. --*/ + +#define BZ_X_IDLE 1 +#define BZ_X_OUTPUT 2 + +#define BZ_X_MAGIC_1 10 +#define BZ_X_MAGIC_2 11 +#define BZ_X_MAGIC_3 12 +#define BZ_X_MAGIC_4 13 +#define BZ_X_BLKHDR_1 14 +#define BZ_X_BLKHDR_2 15 +#define BZ_X_BLKHDR_3 16 +#define BZ_X_BLKHDR_4 17 +#define BZ_X_BLKHDR_5 18 +#define BZ_X_BLKHDR_6 19 +#define BZ_X_BCRC_1 20 +#define BZ_X_BCRC_2 21 +#define BZ_X_BCRC_3 22 +#define BZ_X_BCRC_4 23 +#define BZ_X_RANDBIT 24 +#define BZ_X_ORIGPTR_1 25 +#define BZ_X_ORIGPTR_2 26 +#define BZ_X_ORIGPTR_3 27 +#define BZ_X_MAPPING_1 28 +#define BZ_X_MAPPING_2 29 +#define BZ_X_SELECTOR_1 30 +#define BZ_X_SELECTOR_2 31 +#define BZ_X_SELECTOR_3 32 +#define BZ_X_CODING_1 33 +#define BZ_X_CODING_2 34 +#define BZ_X_CODING_3 35 +#define BZ_X_MTF_1 36 +#define BZ_X_MTF_2 37 +#define BZ_X_MTF_3 38 +#define BZ_X_MTF_4 39 +#define BZ_X_MTF_5 40 +#define BZ_X_MTF_6 41 +#define BZ_X_ENDHDR_2 42 +#define BZ_X_ENDHDR_3 43 +#define BZ_X_ENDHDR_4 44 +#define BZ_X_ENDHDR_5 45 +#define BZ_X_ENDHDR_6 46 +#define BZ_X_CCRC_1 47 +#define BZ_X_CCRC_2 48 +#define BZ_X_CCRC_3 49 +#define BZ_X_CCRC_4 50 + + + +/*-- Constants for the fast MTF decoder. --*/ + +#define MTFA_SIZE 4096 +#define MTFL_SIZE 16 + + + +/*-- Structure holding all the decompression-side stuff. --*/ + +typedef + struct { + /* pointer back to the struct bz_stream */ + bz_stream* strm; + + /* state indicator for this stream */ + Int32 state; + + /* for doing the final run-length decoding */ + UChar state_out_ch; + Int32 state_out_len; + Bool blockRandomised; + BZ_RAND_DECLS; + + /* the buffer for bit stream reading */ + UInt32 bsBuff; + Int32 bsLive; + + /* misc administratium */ + Int32 blockSize100k; + Bool smallDecompress; + Int32 currBlockNo; + Int32 verbosity; + + /* for undoing the Burrows-Wheeler transform */ + Int32 origPtr; + UInt32 tPos; + Int32 k0; + Int32 unzftab[256]; + Int32 nblock_used; + Int32 cftab[257]; + Int32 cftabCopy[257]; + + /* for undoing the Burrows-Wheeler transform (FAST) */ + UInt32 *tt; + + /* for undoing the Burrows-Wheeler transform (SMALL) */ + UInt16 *ll16; + UChar *ll4; + + /* stored and calculated CRCs */ + UInt32 storedBlockCRC; + UInt32 storedCombinedCRC; + UInt32 calculatedBlockCRC; + UInt32 calculatedCombinedCRC; + + /* map of bytes used in block */ + Int32 nInUse; + Bool inUse[256]; + Bool inUse16[16]; + UChar seqToUnseq[256]; + + /* for decoding the MTF values */ + UChar mtfa [MTFA_SIZE]; + Int32 mtfbase[256 / MTFL_SIZE]; + UChar selector [BZ_MAX_SELECTORS]; + UChar selectorMtf[BZ_MAX_SELECTORS]; + UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + + Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 minLens[BZ_N_GROUPS]; + + /* save area for scalars in the main decompress code */ + Int32 save_i; + Int32 save_j; + Int32 save_t; + Int32 save_alphaSize; + Int32 save_nGroups; + Int32 save_nSelectors; + Int32 save_EOB; + Int32 save_groupNo; + Int32 save_groupPos; + Int32 save_nextSym; + Int32 save_nblockMAX; + Int32 save_nblock; + Int32 save_es; + Int32 save_N; + Int32 save_curr; + Int32 save_zt; + Int32 save_zn; + Int32 save_zvec; + Int32 save_zj; + Int32 save_gSel; + Int32 save_gMinlen; + Int32* save_gLimit; + Int32* save_gBase; + Int32* save_gPerm; + + } + DState; + + + +/*-- Macros for decompression. --*/ + +#define BZ_GET_FAST(cccc) \ + /* c_tPos is unsigned, hence test < 0 is pointless. */ \ + if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ + s->tPos = s->tt[s->tPos]; \ + cccc = (UChar)(s->tPos & 0xff); \ + s->tPos >>= 8; + +#define BZ_GET_FAST_C(cccc) \ + /* c_tPos is unsigned, hence test < 0 is pointless. */ \ + if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \ + c_tPos = c_tt[c_tPos]; \ + cccc = (UChar)(c_tPos & 0xff); \ + c_tPos >>= 8; + +#define SET_LL4(i,n) \ + { if (((i) & 0x1) == 0) \ + s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \ + s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \ + } + +#define GET_LL4(i) \ + ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF) + +#define SET_LL(i,n) \ + { s->ll16[i] = (UInt16)(n & 0x0000ffff); \ + SET_LL4(i, n >> 16); \ + } + +#define GET_LL(i) \ + (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16)) + +#define BZ_GET_SMALL(cccc) \ + /* c_tPos is unsigned, hence test < 0 is pointless. */ \ + if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ + cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \ + s->tPos = GET_LL(s->tPos); + + +/*-- externs for decompression. --*/ + +extern Int32 +BZ2_indexIntoF ( Int32, Int32* ); + +extern Int32 +BZ2_decompress ( DState* ); + +extern void +BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, + Int32, Int32, Int32 ); + + +#endif + + +/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ + +#ifdef BZ_NO_STDIO +#ifndef NULL +#define NULL 0 +#endif +#endif + + +/*-------------------------------------------------------------*/ +/*--- end bzlib_private.h ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/compress.c b/dep/StormLib/src/bzip2/compress.c new file mode 100644 index 000000000..8c80a0797 --- /dev/null +++ b/dep/StormLib/src/bzip2/compress.c @@ -0,0 +1,672 @@ + +/*-------------------------------------------------------------*/ +/*--- Compression machinery (not incl block sorting) ---*/ +/*--- compress.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +/* CHANGES + 0.9.0 -- original version. + 0.9.0a/b -- no changes in this file. + 0.9.0c -- changed setting of nGroups in sendMTFValues() + so as to do a bit better on small files +*/ + +#include "bzlib_private.h" + + +/*---------------------------------------------------*/ +/*--- Bit stream I/O ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +void BZ2_bsInitWrite ( EState* s ) +{ + s->bsLive = 0; + s->bsBuff = 0; +} + + +/*---------------------------------------------------*/ +static +void bsFinishWrite ( EState* s ) +{ + while (s->bsLive > 0) { + s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24); + s->numZ++; + s->bsBuff <<= 8; + s->bsLive -= 8; + } +} + + +/*---------------------------------------------------*/ +#define bsNEEDW(nz) \ +{ \ + while (s->bsLive >= 8) { \ + s->zbits[s->numZ] \ + = (UChar)(s->bsBuff >> 24); \ + s->numZ++; \ + s->bsBuff <<= 8; \ + s->bsLive -= 8; \ + } \ +} + + +/*---------------------------------------------------*/ +static +__inline__ +void bsW ( EState* s, Int32 n, UInt32 v ) +{ + bsNEEDW ( n ); + s->bsBuff |= (v << (32 - s->bsLive - n)); + s->bsLive += n; +} + + +/*---------------------------------------------------*/ +static +void bsPutUInt32 ( EState* s, UInt32 u ) +{ + bsW ( s, 8, (u >> 24) & 0xffL ); + bsW ( s, 8, (u >> 16) & 0xffL ); + bsW ( s, 8, (u >> 8) & 0xffL ); + bsW ( s, 8, u & 0xffL ); +} + + +/*---------------------------------------------------*/ +static +void bsPutUChar ( EState* s, UChar c ) +{ + bsW( s, 8, (UInt32)c ); +} + + +/*---------------------------------------------------*/ +/*--- The back end proper ---*/ +/*---------------------------------------------------*/ + +/*---------------------------------------------------*/ +static +void makeMaps_e ( EState* s ) +{ + Int32 i; + s->nInUse = 0; + for (i = 0; i < 256; i++) + if (s->inUse[i]) { + s->unseqToSeq[i] = s->nInUse; + s->nInUse++; + } +} + + +/*---------------------------------------------------*/ +static +void generateMTFValues ( EState* s ) +{ + UChar yy[256]; + Int32 i, j; + Int32 zPend; + Int32 wr; + Int32 EOB; + + /* + After sorting (eg, here), + s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, + and + ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] + holds the original block data. + + The first thing to do is generate the MTF values, + and put them in + ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ]. + Because there are strictly fewer or equal MTF values + than block values, ptr values in this area are overwritten + with MTF values only when they are no longer needed. + + The final compressed bitstream is generated into the + area starting at + (UChar*) (&((UChar*)s->arr2)[s->nblock]) + + These storage aliases are set up in bzCompressInit(), + except for the last one, which is arranged in + compressBlock(). + */ + UInt32* ptr = s->ptr; + UChar* block = s->block; + UInt16* mtfv = s->mtfv; + + makeMaps_e ( s ); + EOB = s->nInUse+1; + + for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0; + + wr = 0; + zPend = 0; + for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i; + + for (i = 0; i < s->nblock; i++) { + UChar ll_i; + AssertD ( wr <= i, "generateMTFValues(1)" ); + j = ptr[i]-1; if (j < 0) j += s->nblock; + ll_i = s->unseqToSeq[block[j]]; + AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); + + if (yy[0] == ll_i) { + zPend++; + } else { + + if (zPend > 0) { + zPend--; + while (True) { + if (zPend & 1) { + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; + } else { + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; + } + if (zPend < 2) break; + zPend = (zPend - 2) / 2; + }; + zPend = 0; + } + { + register UChar rtmp; + register UChar* ryy_j; + register UChar rll_i; + rtmp = yy[1]; + yy[1] = yy[0]; + ryy_j = &(yy[1]); + rll_i = ll_i; + while ( rll_i != rtmp ) { + register UChar rtmp2; + ryy_j++; + rtmp2 = rtmp; + rtmp = *ryy_j; + *ryy_j = rtmp2; + }; + yy[0] = rtmp; + j = ryy_j - &(yy[0]); + mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++; + } + + } + } + + if (zPend > 0) { + zPend--; + while (True) { + if (zPend & 1) { + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; + } else { + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; + } + if (zPend < 2) break; + zPend = (zPend - 2) / 2; + }; + zPend = 0; + } + + mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++; + + s->nMTF = wr; +} + + +/*---------------------------------------------------*/ +#define BZ_LESSER_ICOST 0 +#define BZ_GREATER_ICOST 15 + +static +void sendMTFValues ( EState* s ) +{ + Int32 v, t, i, j, gs, ge, totc, bt, bc, iter; + Int32 nSelectors, alphaSize, minLen, maxLen, selCtr; + Int32 nGroups, nBytes; + + /*-- + UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + is a global since the decoder also needs it. + + Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; + are also globals only used in this proc. + Made global to keep stack frame size small. + --*/ + + + UInt16 cost[BZ_N_GROUPS]; + Int32 fave[BZ_N_GROUPS]; + + UInt16* mtfv = s->mtfv; + + if (s->verbosity >= 3) + VPrintf3( " %d in block, %d after MTF & 1-2 coding, " + "%d+2 syms in use\n", + s->nblock, s->nMTF, s->nInUse ); + + alphaSize = s->nInUse+2; + for (t = 0; t < BZ_N_GROUPS; t++) + for (v = 0; v < alphaSize; v++) + s->len[t][v] = BZ_GREATER_ICOST; + + /*--- Decide how many coding tables to use ---*/ + AssertH ( s->nMTF > 0, 3001 ); + if (s->nMTF < 200) nGroups = 2; else + if (s->nMTF < 600) nGroups = 3; else + if (s->nMTF < 1200) nGroups = 4; else + if (s->nMTF < 2400) nGroups = 5; else + nGroups = 6; + + /*--- Generate an initial set of coding tables ---*/ + { + Int32 nPart, remF, tFreq, aFreq; + + nPart = nGroups; + remF = s->nMTF; + gs = 0; + while (nPart > 0) { + tFreq = remF / nPart; + ge = gs-1; + aFreq = 0; + while (aFreq < tFreq && ge < alphaSize-1) { + ge++; + aFreq += s->mtfFreq[ge]; + } + + if (ge > gs + && nPart != nGroups && nPart != 1 + && ((nGroups-nPart) % 2 == 1)) { + aFreq -= s->mtfFreq[ge]; + ge--; + } + + if (s->verbosity >= 3) + VPrintf5( " initial group %d, [%d .. %d], " + "has %d syms (%4.1f%%)\n", + nPart, gs, ge, aFreq, + (100.0 * (float)aFreq) / (float)(s->nMTF) ); + + for (v = 0; v < alphaSize; v++) + if (v >= gs && v <= ge) + s->len[nPart-1][v] = BZ_LESSER_ICOST; else + s->len[nPart-1][v] = BZ_GREATER_ICOST; + + nPart--; + gs = ge+1; + remF -= aFreq; + } + } + + /*--- + Iterate up to BZ_N_ITERS times to improve the tables. + ---*/ + for (iter = 0; iter < BZ_N_ITERS; iter++) { + + for (t = 0; t < nGroups; t++) fave[t] = 0; + + for (t = 0; t < nGroups; t++) + for (v = 0; v < alphaSize; v++) + s->rfreq[t][v] = 0; + + /*--- + Set up an auxiliary length table which is used to fast-track + the common case (nGroups == 6). + ---*/ + if (nGroups == 6) { + for (v = 0; v < alphaSize; v++) { + s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v]; + s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v]; + s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v]; + } + } + + nSelectors = 0; + totc = 0; + gs = 0; + while (True) { + + /*--- Set group start & end marks. --*/ + if (gs >= s->nMTF) break; + ge = gs + BZ_G_SIZE - 1; + if (ge >= s->nMTF) ge = s->nMTF-1; + + /*-- + Calculate the cost of this group as coded + by each of the coding tables. + --*/ + for (t = 0; t < nGroups; t++) cost[t] = 0; + + if (nGroups == 6 && 50 == ge-gs+1) { + /*--- fast track the common case ---*/ + register UInt32 cost01, cost23, cost45; + register UInt16 icv; + cost01 = cost23 = cost45 = 0; + +# define BZ_ITER(nn) \ + icv = mtfv[gs+(nn)]; \ + cost01 += s->len_pack[icv][0]; \ + cost23 += s->len_pack[icv][1]; \ + cost45 += s->len_pack[icv][2]; \ + + BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4); + BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9); + BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14); + BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19); + BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24); + BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29); + BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34); + BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39); + BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44); + BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49); + +# undef BZ_ITER + + cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16; + cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16; + cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; + + } else { + /*--- slow version which correctly handles all situations ---*/ + for (i = gs; i <= ge; i++) { + UInt16 icv = mtfv[i]; + for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; + } + } + + /*-- + Find the coding table which is best for this group, + and record its identity in the selector table. + --*/ + bc = 999999999; bt = -1; + for (t = 0; t < nGroups; t++) + if (cost[t] < bc) { bc = cost[t]; bt = t; }; + totc += bc; + fave[bt]++; + s->selector[nSelectors] = bt; + nSelectors++; + + /*-- + Increment the symbol frequencies for the selected table. + --*/ + if (nGroups == 6 && 50 == ge-gs+1) { + /*--- fast track the common case ---*/ + +# define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++ + + BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4); + BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9); + BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14); + BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19); + BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24); + BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29); + BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34); + BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39); + BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44); + BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49); + +# undef BZ_ITUR + + } else { + /*--- slow version which correctly handles all situations ---*/ + for (i = gs; i <= ge; i++) + s->rfreq[bt][ mtfv[i] ]++; + } + + gs = ge+1; + } + if (s->verbosity >= 3) { + VPrintf2 ( " pass %d: size is %d, grp uses are ", + iter+1, totc/8 ); + for (t = 0; t < nGroups; t++) + VPrintf1 ( "%d ", fave[t] ); + VPrintf0 ( "\n" ); + } + + /*-- + Recompute the tables based on the accumulated frequencies. + --*/ + /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See + comment in huffman.c for details. */ + for (t = 0; t < nGroups; t++) + BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), + alphaSize, 17 /*20*/ ); + } + + + AssertH( nGroups < 8, 3002 ); + AssertH( nSelectors < 32768 && + nSelectors <= (2 + (900000 / BZ_G_SIZE)), + 3003 ); + + + /*--- Compute MTF values for the selectors. ---*/ + { + UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp; + for (i = 0; i < nGroups; i++) pos[i] = i; + for (i = 0; i < nSelectors; i++) { + ll_i = s->selector[i]; + j = 0; + tmp = pos[j]; + while ( ll_i != tmp ) { + j++; + tmp2 = tmp; + tmp = pos[j]; + pos[j] = tmp2; + }; + pos[0] = tmp; + s->selectorMtf[i] = j; + } + }; + + /*--- Assign actual codes for the tables. --*/ + for (t = 0; t < nGroups; t++) { + minLen = 32; + maxLen = 0; + for (i = 0; i < alphaSize; i++) { + if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; + if (s->len[t][i] < minLen) minLen = s->len[t][i]; + } + AssertH ( !(maxLen > 17 /*20*/ ), 3004 ); + AssertH ( !(minLen < 1), 3005 ); + BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), + minLen, maxLen, alphaSize ); + } + + /*--- Transmit the mapping table. ---*/ + { + Bool inUse16[16]; + for (i = 0; i < 16; i++) { + inUse16[i] = False; + for (j = 0; j < 16; j++) + if (s->inUse[i * 16 + j]) inUse16[i] = True; + } + + nBytes = s->numZ; + for (i = 0; i < 16; i++) + if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); + + for (i = 0; i < 16; i++) + if (inUse16[i]) + for (j = 0; j < 16; j++) { + if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); + } + + if (s->verbosity >= 3) + VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); + } + + /*--- Now the selectors. ---*/ + nBytes = s->numZ; + bsW ( s, 3, nGroups ); + bsW ( s, 15, nSelectors ); + for (i = 0; i < nSelectors; i++) { + for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); + bsW(s,1,0); + } + if (s->verbosity >= 3) + VPrintf1( "selectors %d, ", s->numZ-nBytes ); + + /*--- Now the coding tables. ---*/ + nBytes = s->numZ; + + for (t = 0; t < nGroups; t++) { + Int32 curr = s->len[t][0]; + bsW ( s, 5, curr ); + for (i = 0; i < alphaSize; i++) { + while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ }; + while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ }; + bsW ( s, 1, 0 ); + } + } + + if (s->verbosity >= 3) + VPrintf1 ( "code lengths %d, ", s->numZ-nBytes ); + + /*--- And finally, the block data proper ---*/ + nBytes = s->numZ; + selCtr = 0; + gs = 0; + while (True) { + if (gs >= s->nMTF) break; + ge = gs + BZ_G_SIZE - 1; + if (ge >= s->nMTF) ge = s->nMTF-1; + AssertH ( s->selector[selCtr] < nGroups, 3006 ); + + if (nGroups == 6 && 50 == ge-gs+1) { + /*--- fast track the common case ---*/ + UInt16 mtfv_i; + UChar* s_len_sel_selCtr + = &(s->len[s->selector[selCtr]][0]); + Int32* s_code_sel_selCtr + = &(s->code[s->selector[selCtr]][0]); + +# define BZ_ITAH(nn) \ + mtfv_i = mtfv[gs+(nn)]; \ + bsW ( s, \ + s_len_sel_selCtr[mtfv_i], \ + s_code_sel_selCtr[mtfv_i] ) + + BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4); + BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9); + BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14); + BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19); + BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24); + BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29); + BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34); + BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39); + BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44); + BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49); + +# undef BZ_ITAH + + } else { + /*--- slow version which correctly handles all situations ---*/ + for (i = gs; i <= ge; i++) { + bsW ( s, + s->len [s->selector[selCtr]] [mtfv[i]], + s->code [s->selector[selCtr]] [mtfv[i]] ); + } + } + + + gs = ge+1; + selCtr++; + } + AssertH( selCtr == nSelectors, 3007 ); + + if (s->verbosity >= 3) + VPrintf1( "codes %d\n", s->numZ-nBytes ); +} + + +/*---------------------------------------------------*/ +void BZ2_compressBlock ( EState* s, Bool is_last_block ) +{ + if (s->nblock > 0) { + + BZ_FINALISE_CRC ( s->blockCRC ); + s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31); + s->combinedCRC ^= s->blockCRC; + if (s->blockNo > 1) s->numZ = 0; + + if (s->verbosity >= 2) + VPrintf4( " block %d: crc = 0x%08x, " + "combined CRC = 0x%08x, size = %d\n", + s->blockNo, s->blockCRC, s->combinedCRC, s->nblock ); + + BZ2_blockSort ( s ); + } + + s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]); + + /*-- If this is the first block, create the stream header. --*/ + if (s->blockNo == 1) { + BZ2_bsInitWrite ( s ); + bsPutUChar ( s, BZ_HDR_B ); + bsPutUChar ( s, BZ_HDR_Z ); + bsPutUChar ( s, BZ_HDR_h ); + bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) ); + } + + if (s->nblock > 0) { + + bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 ); + bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 ); + bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 ); + + /*-- Now the block's CRC, so it is in a known place. --*/ + bsPutUInt32 ( s, s->blockCRC ); + + /*-- + Now a single bit indicating (non-)randomisation. + As of version 0.9.5, we use a better sorting algorithm + which makes randomisation unnecessary. So always set + the randomised bit to 'no'. Of course, the decoder + still needs to be able to handle randomised blocks + so as to maintain backwards compatibility with + older versions of bzip2. + --*/ + bsW(s,1,0); + + bsW ( s, 24, s->origPtr ); + generateMTFValues ( s ); + sendMTFValues ( s ); + } + + + /*-- If this is the last block, add the stream trailer. --*/ + if (is_last_block) { + + bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 ); + bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 ); + bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 ); + bsPutUInt32 ( s, s->combinedCRC ); + if (s->verbosity >= 2) + VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC ); + bsFinishWrite ( s ); + } +} + + +/*-------------------------------------------------------------*/ +/*--- end compress.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/crctable.c b/dep/StormLib/src/bzip2/crctable.c new file mode 100644 index 000000000..215687b2c --- /dev/null +++ b/dep/StormLib/src/bzip2/crctable.c @@ -0,0 +1,104 @@ + +/*-------------------------------------------------------------*/ +/*--- Table for doing CRCs ---*/ +/*--- crctable.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + +/*-- + I think this is an implementation of the AUTODIN-II, + Ethernet & FDDI 32-bit CRC standard. Vaguely derived + from code by Rob Warnock, in Section 51 of the + comp.compression FAQ. +--*/ + +UInt32 BZ2_crc32Table[256] = { + + /*-- Ugly, innit? --*/ + + 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L, + 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L, + 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L, + 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL, + 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L, + 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L, + 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L, + 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL, + 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L, + 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L, + 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L, + 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL, + 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L, + 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L, + 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L, + 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL, + 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL, + 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L, + 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L, + 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL, + 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL, + 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L, + 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L, + 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL, + 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL, + 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L, + 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L, + 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL, + 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL, + 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L, + 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L, + 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL, + 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L, + 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL, + 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL, + 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L, + 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L, + 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL, + 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL, + 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L, + 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L, + 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL, + 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL, + 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L, + 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L, + 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL, + 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL, + 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L, + 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L, + 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL, + 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L, + 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L, + 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L, + 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL, + 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L, + 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L, + 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L, + 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, + 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, + 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, + 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, + 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, + 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, + 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L +}; + + +/*-------------------------------------------------------------*/ +/*--- end crctable.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/decompress.c b/dep/StormLib/src/bzip2/decompress.c new file mode 100644 index 000000000..bba5e0fa3 --- /dev/null +++ b/dep/StormLib/src/bzip2/decompress.c @@ -0,0 +1,626 @@ + +/*-------------------------------------------------------------*/ +/*--- Decompression machinery ---*/ +/*--- decompress.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + + +/*---------------------------------------------------*/ +static +void makeMaps_d ( DState* s ) +{ + Int32 i; + s->nInUse = 0; + for (i = 0; i < 256; i++) + if (s->inUse[i]) { + s->seqToUnseq[s->nInUse] = i; + s->nInUse++; + } +} + + +/*---------------------------------------------------*/ +#define RETURN(rrr) \ + { retVal = rrr; goto save_state_and_return; }; + +#define GET_BITS(lll,vvv,nnn) \ + case lll: s->state = lll; \ + while (True) { \ + if (s->bsLive >= nnn) { \ + UInt32 v; \ + v = (s->bsBuff >> \ + (s->bsLive-nnn)) & ((1 << nnn)-1); \ + s->bsLive -= nnn; \ + vvv = v; \ + break; \ + } \ + if (s->strm->avail_in == 0) RETURN(BZ_OK); \ + s->bsBuff \ + = (s->bsBuff << 8) | \ + ((UInt32) \ + (*((UChar*)(s->strm->next_in)))); \ + s->bsLive += 8; \ + s->strm->next_in++; \ + s->strm->avail_in--; \ + s->strm->total_in_lo32++; \ + if (s->strm->total_in_lo32 == 0) \ + s->strm->total_in_hi32++; \ + } + +#define GET_UCHAR(lll,uuu) \ + GET_BITS(lll,uuu,8) + +#define GET_BIT(lll,uuu) \ + GET_BITS(lll,uuu,1) + +/*---------------------------------------------------*/ +#define GET_MTF_VAL(label1,label2,lval) \ +{ \ + if (groupPos == 0) { \ + groupNo++; \ + if (groupNo >= nSelectors) \ + RETURN(BZ_DATA_ERROR); \ + groupPos = BZ_G_SIZE; \ + gSel = s->selector[groupNo]; \ + gMinlen = s->minLens[gSel]; \ + gLimit = &(s->limit[gSel][0]); \ + gPerm = &(s->perm[gSel][0]); \ + gBase = &(s->base[gSel][0]); \ + } \ + groupPos--; \ + zn = gMinlen; \ + GET_BITS(label1, zvec, zn); \ + while (1) { \ + if (zn > 20 /* the longest code */) \ + RETURN(BZ_DATA_ERROR); \ + if (zvec <= gLimit[zn]) break; \ + zn++; \ + GET_BIT(label2, zj); \ + zvec = (zvec << 1) | zj; \ + }; \ + if (zvec - gBase[zn] < 0 \ + || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \ + RETURN(BZ_DATA_ERROR); \ + lval = gPerm[zvec - gBase[zn]]; \ +} + + +/*---------------------------------------------------*/ +Int32 BZ2_decompress ( DState* s ) +{ + UChar uc; + Int32 retVal; + Int32 minLen, maxLen; + bz_stream* strm = s->strm; + + /* stuff that needs to be saved/restored */ + Int32 i; + Int32 j; + Int32 t; + Int32 alphaSize; + Int32 nGroups; + Int32 nSelectors; + Int32 EOB; + Int32 groupNo; + Int32 groupPos; + Int32 nextSym; + Int32 nblockMAX; + Int32 nblock; + Int32 es; + Int32 N; + Int32 curr; + Int32 zt; + Int32 zn; + Int32 zvec; + Int32 zj; + Int32 gSel; + Int32 gMinlen; + Int32* gLimit; + Int32* gBase; + Int32* gPerm; + + if (s->state == BZ_X_MAGIC_1) { + /*initialise the save area*/ + s->save_i = 0; + s->save_j = 0; + s->save_t = 0; + s->save_alphaSize = 0; + s->save_nGroups = 0; + s->save_nSelectors = 0; + s->save_EOB = 0; + s->save_groupNo = 0; + s->save_groupPos = 0; + s->save_nextSym = 0; + s->save_nblockMAX = 0; + s->save_nblock = 0; + s->save_es = 0; + s->save_N = 0; + s->save_curr = 0; + s->save_zt = 0; + s->save_zn = 0; + s->save_zvec = 0; + s->save_zj = 0; + s->save_gSel = 0; + s->save_gMinlen = 0; + s->save_gLimit = NULL; + s->save_gBase = NULL; + s->save_gPerm = NULL; + } + + /*restore from the save area*/ + i = s->save_i; + j = s->save_j; + t = s->save_t; + alphaSize = s->save_alphaSize; + nGroups = s->save_nGroups; + nSelectors = s->save_nSelectors; + EOB = s->save_EOB; + groupNo = s->save_groupNo; + groupPos = s->save_groupPos; + nextSym = s->save_nextSym; + nblockMAX = s->save_nblockMAX; + nblock = s->save_nblock; + es = s->save_es; + N = s->save_N; + curr = s->save_curr; + zt = s->save_zt; + zn = s->save_zn; + zvec = s->save_zvec; + zj = s->save_zj; + gSel = s->save_gSel; + gMinlen = s->save_gMinlen; + gLimit = s->save_gLimit; + gBase = s->save_gBase; + gPerm = s->save_gPerm; + + retVal = BZ_OK; + + switch (s->state) { + + GET_UCHAR(BZ_X_MAGIC_1, uc); + if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC); + + GET_UCHAR(BZ_X_MAGIC_2, uc); + if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC); + + GET_UCHAR(BZ_X_MAGIC_3, uc) + if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); + + GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) + if (s->blockSize100k < (BZ_HDR_0 + 1) || + s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); + s->blockSize100k -= BZ_HDR_0; + + if (s->smallDecompress) { + s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); + s->ll4 = BZALLOC( + ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) + ); + if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); + } else { + s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) ); + if (s->tt == NULL) RETURN(BZ_MEM_ERROR); + } + + GET_UCHAR(BZ_X_BLKHDR_1, uc); + + if (uc == 0x17) goto endhdr_2; + if (uc != 0x31) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_2, uc); + if (uc != 0x41) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_3, uc); + if (uc != 0x59) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_4, uc); + if (uc != 0x26) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_5, uc); + if (uc != 0x53) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_BLKHDR_6, uc); + if (uc != 0x59) RETURN(BZ_DATA_ERROR); + + s->currBlockNo++; + if (s->verbosity >= 2) + VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); + + s->storedBlockCRC = 0; + GET_UCHAR(BZ_X_BCRC_1, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_BCRC_2, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_BCRC_3, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_BCRC_4, uc); + s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); + + GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1); + + s->origPtr = 0; + GET_UCHAR(BZ_X_ORIGPTR_1, uc); + s->origPtr = (s->origPtr << 8) | ((Int32)uc); + GET_UCHAR(BZ_X_ORIGPTR_2, uc); + s->origPtr = (s->origPtr << 8) | ((Int32)uc); + GET_UCHAR(BZ_X_ORIGPTR_3, uc); + s->origPtr = (s->origPtr << 8) | ((Int32)uc); + + if (s->origPtr < 0) + RETURN(BZ_DATA_ERROR); + if (s->origPtr > 10 + 100000*s->blockSize100k) + RETURN(BZ_DATA_ERROR); + + /*--- Receive the mapping table ---*/ + for (i = 0; i < 16; i++) { + GET_BIT(BZ_X_MAPPING_1, uc); + if (uc == 1) + s->inUse16[i] = True; else + s->inUse16[i] = False; + } + + for (i = 0; i < 256; i++) s->inUse[i] = False; + + for (i = 0; i < 16; i++) + if (s->inUse16[i]) + for (j = 0; j < 16; j++) { + GET_BIT(BZ_X_MAPPING_2, uc); + if (uc == 1) s->inUse[i * 16 + j] = True; + } + makeMaps_d ( s ); + if (s->nInUse == 0) RETURN(BZ_DATA_ERROR); + alphaSize = s->nInUse+2; + + /*--- Now the selectors ---*/ + GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); + if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR); + GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); + if (nSelectors < 1) RETURN(BZ_DATA_ERROR); + for (i = 0; i < nSelectors; i++) { + j = 0; + while (True) { + GET_BIT(BZ_X_SELECTOR_3, uc); + if (uc == 0) break; + j++; + if (j >= nGroups) RETURN(BZ_DATA_ERROR); + } + s->selectorMtf[i] = j; + } + + /*--- Undo the MTF values for the selectors. ---*/ + { + UChar pos[BZ_N_GROUPS], tmp, v; + for (v = 0; v < nGroups; v++) pos[v] = v; + + for (i = 0; i < nSelectors; i++) { + v = s->selectorMtf[i]; + tmp = pos[v]; + while (v > 0) { pos[v] = pos[v-1]; v--; } + pos[0] = tmp; + s->selector[i] = tmp; + } + } + + /*--- Now the coding tables ---*/ + for (t = 0; t < nGroups; t++) { + GET_BITS(BZ_X_CODING_1, curr, 5); + for (i = 0; i < alphaSize; i++) { + while (True) { + if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR); + GET_BIT(BZ_X_CODING_2, uc); + if (uc == 0) break; + GET_BIT(BZ_X_CODING_3, uc); + if (uc == 0) curr++; else curr--; + } + s->len[t][i] = curr; + } + } + + /*--- Create the Huffman decoding tables ---*/ + for (t = 0; t < nGroups; t++) { + minLen = 32; + maxLen = 0; + for (i = 0; i < alphaSize; i++) { + if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; + if (s->len[t][i] < minLen) minLen = s->len[t][i]; + } + BZ2_hbCreateDecodeTables ( + &(s->limit[t][0]), + &(s->base[t][0]), + &(s->perm[t][0]), + &(s->len[t][0]), + minLen, maxLen, alphaSize + ); + s->minLens[t] = minLen; + } + + /*--- Now the MTF values ---*/ + + EOB = s->nInUse+1; + nblockMAX = 100000 * s->blockSize100k; + groupNo = -1; + groupPos = 0; + + for (i = 0; i <= 255; i++) s->unzftab[i] = 0; + + /*-- MTF init --*/ + { + Int32 ii, jj, kk; + kk = MTFA_SIZE-1; + for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) { + for (jj = MTFL_SIZE-1; jj >= 0; jj--) { + s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj); + kk--; + } + s->mtfbase[ii] = kk + 1; + } + } + /*-- end MTF init --*/ + + nblock = 0; + GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym); + + while (True) { + + if (nextSym == EOB) break; + + if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) { + + es = -1; + N = 1; + do { + if (nextSym == BZ_RUNA) es = es + (0+1) * N; else + if (nextSym == BZ_RUNB) es = es + (1+1) * N; + N = N * 2; + GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym); + } + while (nextSym == BZ_RUNA || nextSym == BZ_RUNB); + + es++; + uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ]; + s->unzftab[uc] += es; + + if (s->smallDecompress) + while (es > 0) { + if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); + s->ll16[nblock] = (UInt16)uc; + nblock++; + es--; + } + else + while (es > 0) { + if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); + s->tt[nblock] = (UInt32)uc; + nblock++; + es--; + }; + + continue; + + } else { + + if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); + + /*-- uc = MTF ( nextSym-1 ) --*/ + { + Int32 ii, jj, kk, pp, lno, off; + UInt32 nn; + nn = (UInt32)(nextSym - 1); + + if (nn < MTFL_SIZE) { + /* avoid general-case expense */ + pp = s->mtfbase[0]; + uc = s->mtfa[pp+nn]; + while (nn > 3) { + Int32 z = pp+nn; + s->mtfa[(z) ] = s->mtfa[(z)-1]; + s->mtfa[(z)-1] = s->mtfa[(z)-2]; + s->mtfa[(z)-2] = s->mtfa[(z)-3]; + s->mtfa[(z)-3] = s->mtfa[(z)-4]; + nn -= 4; + } + while (nn > 0) { + s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; + }; + s->mtfa[pp] = uc; + } else { + /* general case */ + lno = nn / MTFL_SIZE; + off = nn % MTFL_SIZE; + pp = s->mtfbase[lno] + off; + uc = s->mtfa[pp]; + while (pp > s->mtfbase[lno]) { + s->mtfa[pp] = s->mtfa[pp-1]; pp--; + }; + s->mtfbase[lno]++; + while (lno > 0) { + s->mtfbase[lno]--; + s->mtfa[s->mtfbase[lno]] + = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; + lno--; + } + s->mtfbase[0]--; + s->mtfa[s->mtfbase[0]] = uc; + if (s->mtfbase[0] == 0) { + kk = MTFA_SIZE-1; + for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) { + for (jj = MTFL_SIZE-1; jj >= 0; jj--) { + s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj]; + kk--; + } + s->mtfbase[ii] = kk + 1; + } + } + } + } + /*-- end uc = MTF ( nextSym-1 ) --*/ + + s->unzftab[s->seqToUnseq[uc]]++; + if (s->smallDecompress) + s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else + s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]); + nblock++; + + GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym); + continue; + } + } + + /* Now we know what nblock is, we can do a better sanity + check on s->origPtr. + */ + if (s->origPtr < 0 || s->origPtr >= nblock) + RETURN(BZ_DATA_ERROR); + + /*-- Set up cftab to facilitate generation of T^(-1) --*/ + s->cftab[0] = 0; + for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; + for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; + for (i = 0; i <= 256; i++) { + if (s->cftab[i] < 0 || s->cftab[i] > nblock) { + /* s->cftab[i] can legitimately be == nblock */ + RETURN(BZ_DATA_ERROR); + } + } + + s->state_out_len = 0; + s->state_out_ch = 0; + BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); + s->state = BZ_X_OUTPUT; + if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); + + if (s->smallDecompress) { + + /*-- Make a copy of cftab, used in generation of T --*/ + for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i]; + + /*-- compute the T vector --*/ + for (i = 0; i < nblock; i++) { + uc = (UChar)(s->ll16[i]); + SET_LL(i, s->cftabCopy[uc]); + s->cftabCopy[uc]++; + } + + /*-- Compute T^(-1) by pointer reversal on T --*/ + i = s->origPtr; + j = GET_LL(i); + do { + Int32 tmp = GET_LL(j); + SET_LL(j, i); + i = j; + j = tmp; + } + while (i != s->origPtr); + + s->tPos = s->origPtr; + s->nblock_used = 0; + if (s->blockRandomised) { + BZ_RAND_INIT_MASK; + BZ_GET_SMALL(s->k0); s->nblock_used++; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + } else { + BZ_GET_SMALL(s->k0); s->nblock_used++; + } + + } else { + + /*-- compute the T^(-1) vector --*/ + for (i = 0; i < nblock; i++) { + uc = (UChar)(s->tt[i] & 0xff); + s->tt[s->cftab[uc]] |= (i << 8); + s->cftab[uc]++; + } + + s->tPos = s->tt[s->origPtr] >> 8; + s->nblock_used = 0; + if (s->blockRandomised) { + BZ_RAND_INIT_MASK; + BZ_GET_FAST(s->k0); s->nblock_used++; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + } else { + BZ_GET_FAST(s->k0); s->nblock_used++; + } + + } + + RETURN(BZ_OK); + + + + endhdr_2: + + GET_UCHAR(BZ_X_ENDHDR_2, uc); + if (uc != 0x72) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_3, uc); + if (uc != 0x45) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_4, uc); + if (uc != 0x38) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_5, uc); + if (uc != 0x50) RETURN(BZ_DATA_ERROR); + GET_UCHAR(BZ_X_ENDHDR_6, uc); + if (uc != 0x90) RETURN(BZ_DATA_ERROR); + + s->storedCombinedCRC = 0; + GET_UCHAR(BZ_X_CCRC_1, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_CCRC_2, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_CCRC_3, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + GET_UCHAR(BZ_X_CCRC_4, uc); + s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); + + s->state = BZ_X_IDLE; + RETURN(BZ_STREAM_END); + + default: AssertH ( False, 4001 ); + } + + AssertH ( False, 4002 ); + + save_state_and_return: + + s->save_i = i; + s->save_j = j; + s->save_t = t; + s->save_alphaSize = alphaSize; + s->save_nGroups = nGroups; + s->save_nSelectors = nSelectors; + s->save_EOB = EOB; + s->save_groupNo = groupNo; + s->save_groupPos = groupPos; + s->save_nextSym = nextSym; + s->save_nblockMAX = nblockMAX; + s->save_nblock = nblock; + s->save_es = es; + s->save_N = N; + s->save_curr = curr; + s->save_zt = zt; + s->save_zn = zn; + s->save_zvec = zvec; + s->save_zj = zj; + s->save_gSel = gSel; + s->save_gMinlen = gMinlen; + s->save_gLimit = gLimit; + s->save_gBase = gBase; + s->save_gPerm = gPerm; + + return retVal; +} + + +/*-------------------------------------------------------------*/ +/*--- end decompress.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/huffman.c b/dep/StormLib/src/bzip2/huffman.c new file mode 100644 index 000000000..87e79e38a --- /dev/null +++ b/dep/StormLib/src/bzip2/huffman.c @@ -0,0 +1,205 @@ + +/*-------------------------------------------------------------*/ +/*--- Huffman coding low-level stuff ---*/ +/*--- huffman.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + +/*---------------------------------------------------*/ +#define WEIGHTOF(zz0) ((zz0) & 0xffffff00) +#define DEPTHOF(zz1) ((zz1) & 0x000000ff) +#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3)) + +#define ADDWEIGHTS(zw1,zw2) \ + (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \ + (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2))) + +#define UPHEAP(z) \ +{ \ + Int32 zz, tmp; \ + zz = z; tmp = heap[zz]; \ + while (weight[tmp] < weight[heap[zz >> 1]]) { \ + heap[zz] = heap[zz >> 1]; \ + zz >>= 1; \ + } \ + heap[zz] = tmp; \ +} + +#define DOWNHEAP(z) \ +{ \ + Int32 zz, yy, tmp; \ + zz = z; tmp = heap[zz]; \ + while (True) { \ + yy = zz << 1; \ + if (yy > nHeap) break; \ + if (yy < nHeap && \ + weight[heap[yy+1]] < weight[heap[yy]]) \ + yy++; \ + if (weight[tmp] < weight[heap[yy]]) break; \ + heap[zz] = heap[yy]; \ + zz = yy; \ + } \ + heap[zz] = tmp; \ +} + + +/*---------------------------------------------------*/ +void BZ2_hbMakeCodeLengths ( UChar *len, + Int32 *freq, + Int32 alphaSize, + Int32 maxLen ) +{ + /*-- + Nodes and heap entries run from 1. Entry 0 + for both the heap and nodes is a sentinel. + --*/ + Int32 nNodes, nHeap, n1, n2, i, j, k; + Bool tooLong; + + Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; + Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; + Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; + + for (i = 0; i < alphaSize; i++) + weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; + + while (True) { + + nNodes = alphaSize; + nHeap = 0; + + heap[0] = 0; + weight[0] = 0; + parent[0] = -2; + + for (i = 1; i <= alphaSize; i++) { + parent[i] = -1; + nHeap++; + heap[nHeap] = i; + UPHEAP(nHeap); + } + + AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); + + while (nHeap > 1) { + n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); + n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); + nNodes++; + parent[n1] = parent[n2] = nNodes; + weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]); + parent[nNodes] = -1; + nHeap++; + heap[nHeap] = nNodes; + UPHEAP(nHeap); + } + + AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 ); + + tooLong = False; + for (i = 1; i <= alphaSize; i++) { + j = 0; + k = i; + while (parent[k] >= 0) { k = parent[k]; j++; } + len[i-1] = j; + if (j > maxLen) tooLong = True; + } + + if (! tooLong) break; + + /* 17 Oct 04: keep-going condition for the following loop used + to be 'i < alphaSize', which missed the last element, + theoretically leading to the possibility of the compressor + looping. However, this count-scaling step is only needed if + one of the generated Huffman code words is longer than + maxLen, which up to and including version 1.0.2 was 20 bits, + which is extremely unlikely. In version 1.0.3 maxLen was + changed to 17 bits, which has minimal effect on compression + ratio, but does mean this scaling step is used from time to + time, enough to verify that it works. + + This means that bzip2-1.0.3 and later will only produce + Huffman codes with a maximum length of 17 bits. However, in + order to preserve backwards compatibility with bitstreams + produced by versions pre-1.0.3, the decompressor must still + handle lengths of up to 20. */ + + for (i = 1; i <= alphaSize; i++) { + j = weight[i] >> 8; + j = 1 + (j / 2); + weight[i] = j << 8; + } + } +} + + +/*---------------------------------------------------*/ +void BZ2_hbAssignCodes ( Int32 *code, + UChar *length, + Int32 minLen, + Int32 maxLen, + Int32 alphaSize ) +{ + Int32 n, vec, i; + + vec = 0; + for (n = minLen; n <= maxLen; n++) { + for (i = 0; i < alphaSize; i++) + if (length[i] == n) { code[i] = vec; vec++; }; + vec <<= 1; + } +} + + +/*---------------------------------------------------*/ +void BZ2_hbCreateDecodeTables ( Int32 *limit, + Int32 *base, + Int32 *perm, + UChar *length, + Int32 minLen, + Int32 maxLen, + Int32 alphaSize ) +{ + Int32 pp, i, j, vec; + + pp = 0; + for (i = minLen; i <= maxLen; i++) + for (j = 0; j < alphaSize; j++) + if (length[j] == i) { perm[pp] = j; pp++; }; + + for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0; + for (i = 0; i < alphaSize; i++) base[length[i]+1]++; + + for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1]; + + for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0; + vec = 0; + + for (i = minLen; i <= maxLen; i++) { + vec += (base[i+1] - base[i]); + limit[i] = vec-1; + vec <<= 1; + } + for (i = minLen + 1; i <= maxLen; i++) + base[i] = ((limit[i-1] + 1) << 1) - base[i]; +} + + +/*-------------------------------------------------------------*/ +/*--- end huffman.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/bzip2/randtable.c b/dep/StormLib/src/bzip2/randtable.c new file mode 100644 index 000000000..068b76367 --- /dev/null +++ b/dep/StormLib/src/bzip2/randtable.c @@ -0,0 +1,84 @@ + +/*-------------------------------------------------------------*/ +/*--- Table for randomising repetitive blocks ---*/ +/*--- randtable.c ---*/ +/*-------------------------------------------------------------*/ + +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#include "bzlib_private.h" + + +/*---------------------------------------------*/ +Int32 BZ2_rNums[512] = { + 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, + 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, + 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, + 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, + 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, + 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, + 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, + 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, + 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, + 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, + 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, + 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, + 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, + 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, + 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, + 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, + 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, + 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, + 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, + 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, + 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, + 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, + 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, + 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, + 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, + 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, + 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, + 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, + 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, + 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, + 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, + 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, + 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, + 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, + 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, + 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, + 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, + 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, + 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, + 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, + 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, + 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, + 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, + 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, + 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, + 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, + 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, + 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, + 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, + 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, + 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, + 936, 638 +}; + + +/*-------------------------------------------------------------*/ +/*--- end randtable.c ---*/ +/*-------------------------------------------------------------*/ diff --git a/dep/StormLib/src/huffman/huff.cpp b/dep/StormLib/src/huffman/huff.cpp index 9de5acb51..e12dd7df0 100644 --- a/dep/StormLib/src/huffman/huff.cpp +++ b/dep/StormLib/src/huffman/huff.cpp @@ -13,266 +13,152 @@ /* 03.05.03 1.00 Lad Added compression methods */ /* 19.11.03 1.01 Dan Big endian handling */ /* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ -/* 09.01.13 3.00 Lad Refactored, beautified, documented :-) */ /*****************************************************************************/ - + #include #include - + #include "huff.h" +// Special for Mac - we have to know if normal pointer greater or less +// than 0x80000000. This variable is used in the PTR_VALID and PTR_INVALID +// macros +static long mul = 1; + +#define PTR_VALID(ptr) (((LONG_PTR)(ptr) * mul) > 0) +#define PTR_INVALID(ptr) (((LONG_PTR)(ptr) * mul) < 0) +#define PTR_INVALID_OR_NULL(ptr) (((LONG_PTR)(ptr) * mul) <= 0) + + //----------------------------------------------------------------------------- -// Table of byte-to-weight values +// Methods of the THTreeItem struct -// Table for (de)compression. Every compression type has 258 entries -static unsigned char ByteToWeight_00[] = +// 1501DB70 +THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast) { - 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00 -}; + if(pLast == NULL) + pLast = this + 1; + return pLast; +} -// Data for compression type 0x01 -static unsigned char ByteToWeight_01[] = +// Gets previous Huffman tree item (?) +THTreeItem * THTreeItem::GetPrevItem(LONG_PTR value) { - 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, - 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, - 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, - 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, - 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, - 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, - 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, - 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, - 0x00, 0x00 -}; - -// Data for compression type 0x02 -static unsigned char ByteToWeight_02[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, - 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, - 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, - 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x03 -static unsigned char ByteToWeight_03[] = -{ - 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, - 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, - 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, - 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, - 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, - 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, - 0x00, 0x00 -}; - -// Data for compression type 0x04 -static unsigned char ByteToWeight_04[] = -{ - 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x05 -static unsigned char ByteToWeight_05[] = -{ - 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, - 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, - 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, - 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - - // Data for compression type 0x06 -static unsigned char ByteToWeight_06[] = -{ - 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x07 -static unsigned char ByteToWeight_07[] = -{ - 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x08 -static unsigned char ByteToWeight_08[] = -{ - 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, - 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, - 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; + if(PTR_INVALID(prev)) + return PTR_NOT(prev); -static unsigned char * WeightTables[0x09] = + if(value == -1 || PTR_INVALID(value)) + value = (LONG_PTR)(this - next->prev); + return prev + value; + +// OLD VERSION +// if(PTR_INT(value) < 0) +// value = PTR_INT((item - item->next->prev)); +// return (THTreeItem *)((char *)prev + value); +} + +// 1500F5E0 +void THTreeItem::ClearItemLinks() { - ByteToWeight_00, - ByteToWeight_01, - ByteToWeight_02, - ByteToWeight_03, - ByteToWeight_04, - ByteToWeight_05, - ByteToWeight_06, - ByteToWeight_07, - ByteToWeight_08 -}; + next = prev = NULL; +} -//----------------------------------------------------------------------------- -// Debug/diagnostics - -#ifdef _DEBUG -void DumpHuffmannTree(THTreeItem * pItem) +// 1500BC90 +void THTreeItem::RemoveItem() { - THTreeItem * pChildLo; // Item with the lower weight - THTreeItem * pChildHi; // Item with the higher weight + THTreeItem * pTemp; // EDX - // Get the lower-weight branch - pChildLo = pItem->pChildLo; - if(pChildLo != NULL) + if(next != NULL) { - // Get the higher-weight branch - pChildHi = pChildLo->pPrev; + pTemp = prev; - // Parse the lower-weight branch - DumpHuffmannTree(pChildHi); - DumpHuffmannTree(pChildLo); + if(PTR_INVALID_OR_NULL(pTemp)) + pTemp = PTR_NOT(pTemp); + else + pTemp += (this - next->prev); + + pTemp->next = next; + next->prev = prev; + next = prev = NULL; + } +} + +/* +// OLD VERSION : Removes item from the tree (?) +static void RemoveItem(THTreeItem * item) +{ + THTreeItem * next = item->next; // ESI + THTreeItem * prev = item->prev; // EDX + + if(next == NULL) + return; + + if(PTR_INT(prev) < 0) + prev = PTR_NOT(prev); + else + // ??? usually item == next->prev, so what is it ? + prev = (THTreeItem *)((unsigned char *)prev + (unsigned long)((unsigned char *)item - (unsigned char *)(next->prev))); + + // Remove HTree item from the chain + prev->next = next; // Sets the 'first' pointer + next->prev = item->prev; + + // Invalidate pointers + item->next = NULL; + item->prev = NULL; +} +*/ + +//----------------------------------------------------------------------------- +// TOutputStream functions + +void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits) +{ + dwBitBuff |= (dwBuff << nBits); + nBits += nPutBits; + + // Flush completed bytes + while(nBits >= 8) + { + if(cbOutSize != 0) + { + *pbOutPos++ = (unsigned char)dwBitBuff; + cbOutSize--; + } + + dwBitBuff >>= 8; + nBits -= 8; } } -#endif //----------------------------------------------------------------------------- // TInputStream functions -TInputStream::TInputStream(void * pvInBuffer, size_t cbInBuffer) +// Gets one bit from input stream +unsigned long TInputStream::GetBit() { - pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - pbInBuffer = (unsigned char *)pvInBuffer; - BitBuffer = 0; - BitCount = 0; + unsigned long dwOneBit = 0; + + // Ensure that the input stream is reloaded, if there are no bits left + if(BitCount == 0) + { + // Refill the bit buffer + BitBuffer = *pbInBuffer++; + BitCount = 8; + } + + // Copy the bit from bit buffer to the variable + dwOneBit = (BitBuffer & 0x01); + BitBuffer >>= 1; + BitCount--; + + return dwOneBit; } // Gets 7 bits from the stream. DOES NOT remove the bits from input stream -unsigned int TInputStream::Peek7Bits() +unsigned long TInputStream::Get7Bits() { - unsigned int dwReloadByte = 0; + unsigned long dwReloadByte = 0; // If there is not enough bits to get the value, // we have to add 8 more bits from the input buffer @@ -287,32 +173,11 @@ unsigned int TInputStream::Peek7Bits() return (BitBuffer & 0x7F); } -// Gets one bit from input stream -unsigned int TInputStream::Get1Bit() -{ - unsigned int OneBit = 0; - - // Ensure that the input stream is reloaded, if there are no bits left - if(BitCount == 0) - { - // Refill the bit buffer - BitBuffer = *pbInBuffer++; - BitCount = 8; - } - - // Copy the bit from bit buffer to the variable - OneBit = (BitBuffer & 0x01); - BitBuffer >>= 1; - BitCount--; - - return OneBit; -} - // Gets the whole byte from the input stream. -unsigned int TInputStream::Get8Bits() +unsigned long TInputStream::Get8Bits() { - unsigned int dwReloadByte = 0; - unsigned int dwOneByte = 0; + unsigned long dwReloadByte = 0; + unsigned long dwOneByte = 0; // If there is not enough bits to get the value, // we have to add 8 more bits from the input buffer @@ -332,7 +197,7 @@ unsigned int TInputStream::Get8Bits() void TInputStream::SkipBits(unsigned int dwBitsToSkip) { - unsigned int dwReloadByte = 0; + unsigned long dwReloadByte = 0; // If there is not enough bits in the buffer, // we have to add 8 more bits from the input buffer @@ -349,525 +214,1090 @@ void TInputStream::SkipBits(unsigned int dwBitsToSkip) } //----------------------------------------------------------------------------- -// TOutputStream functions +// Functions for huffmann tree items -TOutputStream::TOutputStream(void * pvOutBuffer, size_t cbOutLength) +// Inserts item into the tree (?) +static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long nWhere, THTreeItem * item2) { - pbOutBufferEnd = (unsigned char *)pvOutBuffer + cbOutLength; - pbOutBuffer = (unsigned char *)pvOutBuffer; - BitBuffer = 0; - BitCount = 0; -} + THTreeItem * next = item->next; // EDI - next to the first item + THTreeItem * prev = item->prev; // ESI - prev to the first item + THTreeItem * prev2; // Pointer to previous item + LONG_PTR next2; // Pointer to the next item -void TOutputStream::PutBits(unsigned int dwValue, unsigned int nBitCount) -{ - BitBuffer |= (dwValue << BitCount); - BitCount += nBitCount; - - // Flush completed bytes - while(BitCount >= 8) + // The same code like in RemoveItem(item); + if(next != 0) // If the first item already has next one { - if(pbOutBuffer < pbOutBufferEnd) - *pbOutBuffer++ = (unsigned char)BitBuffer; - - BitBuffer >>= 8; - BitCount -= 8; + if(PTR_INVALID(prev)) + prev = PTR_NOT(prev); + else + prev += (item - next->prev); + + // 150083C1 + // Remove the item from the tree + prev->next = next; + next->prev = prev; + + // Invalidate 'prev' and 'next' pointer + item->next = 0; + item->prev = 0; } -} -void TOutputStream::Flush() -{ - while(BitCount != 0) + if(item2 == NULL) // EDX - If the second item is not entered, + item2 = PTR_PTR(&itemPtr[1]); // take the first tree item + + switch(nWhere) { - if(pbOutBuffer < pbOutBufferEnd) - *pbOutBuffer++ = (unsigned char)BitBuffer; + case SWITCH_ITEMS : // Switch the two items + item->next = item2->next; // item2->next (Pointer to pointer to first) + item->prev = item2->next->prev; + item2->next->prev = item; + item2->next = item; // Set the first item + return; - BitBuffer >>= 8; - BitCount -= ((BitCount > 8) ? 8 : BitCount); - } -} + case INSERT_ITEM: // Insert as the last item + item->next = item2; // Set next item (or pointer to pointer to first item) + item->prev = item2->prev; // Set prev item (or last item in the tree) -//----------------------------------------------------------------------------- -// Methods of the THTreeItem struct + next2 = PTR_INT(itemPtr[0]);// Usually NULL + prev2 = item2->prev; // Prev item to the second (or last tree item) -void THTreeItem::RemoveItem() -{ - if(pNext != NULL) - { - pPrev->pNext = pNext; - pNext->pPrev = pPrev; - pNext = pPrev = NULL; + if(PTR_INVALID(prev2)) + { + if(prev != NULL) + { + prev2 = PTR_NOT(prev); + if(prev2 != NULL) + { + prev2->next = item; + item2->prev = item; // Next after last item + } + } + return; + } + + if(PTR_INVALID(next2)) + next2 = (LONG_PTR)(item2 - item2->next->prev); +// next2 = (THTreeItem *)(unsigned long)((unsigned char *)item2 - (unsigned char *)(item2->next->prev)); + +// prev2 = (THTreeItem *)((char *)prev2 + (unsigned long)next2);// ??? + prev2 += next2; + prev2->next = item; + item2->prev = item; // Set the next/last item + return; + + default: + return; } } //----------------------------------------------------------------------------- // THuffmannTree class functions - -THuffmannTree::THuffmannTree(bool bCompression) + +THuffmannTree::THuffmannTree() { - pFirst = pLast = LIST_HEAD(); - MinValidValue = 1; - ItemsUsed = 0; - bIsCmp0 = 0; + // We have to check if the "this" pointer is less than zero + if((LONG_PTR)this < 0) + mul = -1; +} - memset(ItemsByByte, 0, sizeof(ItemsByByte)); +void THuffmannTree::InitTree(bool bCompression) +{ + THTreeItem * pItem; + unsigned int nCount; - // If we are going to decompress data, we need to invalidate all item links - // We do so by zeroing their ValidValue, so it becomes lower MinValidValue + // Clear links for all the items in the tree + for(pItem = items0008, nCount = 0x203; nCount != 0; pItem++, nCount--) + pItem->ClearItemLinks(); + + pItem3050 = NULL; + pItem3054 = PTR_PTR(&pItem3054); + pItem3058 = PTR_NOT(pItem3054); + + pItem305C = NULL; + pFirst = PTR_PTR(&pFirst); + pLast = PTR_NOT(pFirst); + + offs0004 = 1; + nItems = 0; + + // Clear all TQDecompress items. Do this only if preparing for decompression if(bCompression == false) { - memset(QuickLinks, 0, sizeof(QuickLinks)); + for(nCount = 0; nCount < sizeof(qd3474) / sizeof(TQDecompress); nCount++) + qd3474[nCount].offs00 = 0; } } -THuffmannTree::~THuffmannTree() -{ - // Our Huffmann tree does not use any memory allocations, - // so we don't need to do eny code in the destructor -} - -void THuffmannTree::LinkTwoItems(THTreeItem * pItem1, THTreeItem * pItem2) -{ - pItem2->pNext = pItem1->pNext; - pItem2->pPrev = pItem1->pNext->pPrev; - pItem1->pNext->pPrev = pItem2; - pItem1->pNext = pItem2; -} - -// Inserts item into the tree (?) -void THuffmannTree::InsertItem(THTreeItem * pNewItem, TInsertPoint InsertPoint, THTreeItem * pInsertPoint) -{ - // Remove the item from the tree - pNewItem->RemoveItem(); - - if(pInsertPoint == NULL) - pInsertPoint = LIST_HEAD(); - - switch(InsertPoint) - { - case InsertAfter: - LinkTwoItems(pInsertPoint, pNewItem); - return; - - case InsertBefore: - pNewItem->pNext = pInsertPoint; // Set next item (or pointer to pointer to first item) - pNewItem->pPrev = pInsertPoint->pPrev; // Set prev item (or last item in the tree) - pInsertPoint->pPrev->pNext = pNewItem; - pInsertPoint->pPrev = pNewItem; // Set the next/last item - return; - } -} - -THTreeItem * THuffmannTree::FindHigherOrEqualItem(THTreeItem * pItem, unsigned int Weight) -{ - // Parse all existing items - if(pItem != NULL) - { - while(pItem != LIST_HEAD()) - { - if(pItem->Weight >= Weight) - return pItem; - - pItem = pItem->pPrev; - } - } - - // If not found, we just get the first item - return LIST_HEAD(); -} - -THTreeItem * THuffmannTree::CreateNewItem(unsigned int DecompressedValue, unsigned int Weight, TInsertPoint InsertPoint) -{ - THTreeItem * pNewItem; - - // Allocate new item from the item pool - pNewItem = &ItemBuffer[ItemsUsed++]; - - // Insert this item to the top of the tree - InsertItem(pNewItem, InsertPoint, NULL); - - // Fill the rest of the item - pNewItem->DecompressedValue = DecompressedValue; - pNewItem->Weight = Weight; - pNewItem->pParent = NULL; - pNewItem->pChildLo = NULL; - return pNewItem; -} - -unsigned int THuffmannTree::FixupItemPosByWeight(THTreeItem * pNewItem, unsigned int MaxWeight) -{ - THTreeItem * pHigherItem; - - if(pNewItem->Weight < MaxWeight) - { - // Find an item that has higher weight than this one - pHigherItem = FindHigherOrEqualItem(pLast, pNewItem->Weight); - - // Remove the item and put it to the new position - pNewItem->RemoveItem(); - LinkTwoItems(pHigherItem, pNewItem); - } - else - { - MaxWeight = pNewItem->Weight; - } - - // Return the (updated) maximum weight - return MaxWeight; -} - // Builds Huffman tree. Called with the first 8 bits loaded from input stream -bool THuffmannTree::BuildTree(unsigned int CompressionType) +void THuffmannTree::BuildTree(unsigned int nCmpType) { - THTreeItem * pNewItem; - THTreeItem * pChildLo; - THTreeItem * pChildHi; - unsigned char * WeightTable; - unsigned int MaxWeight; // [ESP+10] - The greatest character found in table - + unsigned long maxByte; // [ESP+10] - The greatest character found in table + THTreeItem ** itemPtr; // [ESP+14] - Pointer to Huffman tree item pointer array + unsigned char * byteArray; // [ESP+1C] - Pointer to unsigned char in Table1502A630 + THTreeItem * child1; + unsigned long i; // egcs in linux doesn't like multiple for loops without an explicit i + + // Loop while pointer has a valid value + while(PTR_VALID(pLast)) // ESI - Last entry + { + THTreeItem * temp; // EAX + + if(pLast->next != NULL) // ESI->next + pLast->RemoveItem(); + // EDI = &offs3054 + pItem3058 = PTR_PTR(&pItem3054); // [EDI+4] + pLast->prev = pItem3058; // EAX + + temp = PTR_PTR(&pItem3054)->GetPrevItem(PTR_INT(&pItem3050)); + + temp->next = pLast; + pItem3054 = pLast; + } + // Clear all pointers in HTree item array - memset(ItemsByByte, 0, sizeof(ItemsByByte)); - MaxWeight = 0; - - // Ensure that the compression type is in range - if((CompressionType & 0x0F) > 0x08) - return false; - WeightTable = WeightTables[CompressionType & 0x0F]; - - // Build the linear list of entries that is sorted by byte weight - for(unsigned int i = 0; i < 0x100; i++) + memset(items306C, 0, sizeof(items306C)); + + maxByte = 0; // Greatest character found init to zero. + itemPtr = (THTreeItem **)&items306C; // Pointer to current entry in HTree item pointer array + + // Ensure we have low 8 bits only + nCmpType &= 0xFF; + byteArray = Table1502A630 + nCmpType * 258; // EDI also + + for(i = 0; i < 0x100; i++, itemPtr++) { + THTreeItem * item = pItem3058; // Item to be created + THTreeItem * pItem3 = pItem3058; + unsigned char oneByte = byteArray[i]; + // Skip all the bytes which are zero. - if(WeightTable[i] != 0) + if(byteArray[i] == 0) + continue; + + // If not valid pointer, take the first available item in the array + if(PTR_INVALID_OR_NULL(item)) + item = &items0008[nItems++]; + + // Insert this item as the top of the tree + InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); + + item->parent = NULL; // Invalidate child and parent + item->child = NULL; + *itemPtr = item; // Store pointer into pointer array + + item->dcmpByte = i; // Store counter + item->byteValue = oneByte; // Store byte value + if(oneByte >= maxByte) { - // Create new tree item - ItemsByByte[i] = pNewItem = CreateNewItem(i, WeightTable[i], InsertAfter); - - // We need to put the item to the right place in the list - MaxWeight = FixupItemPosByWeight(pNewItem, MaxWeight); - } - } - - // Insert termination entries at the end of the list - ItemsByByte[0x100] = CreateNewItem(0x100, 1, InsertBefore); - ItemsByByte[0x101] = CreateNewItem(0x101, 1, InsertBefore); - - // Now we need to build the tree. We start at the last entry - // and go backwards to the first one - pChildLo = pLast; - - // Work as long as both children are valid - // pChildHi is child with higher weight, pChildLo is the one with lower weight - while(pChildLo != LIST_HEAD()) - { - // Also get and verify the higher-weight child - pChildHi = pChildLo->pPrev; - if(pChildHi == LIST_HEAD()) - break; - - // Create new parent item for the children - pNewItem = CreateNewItem(0, pChildHi->Weight + pChildLo->Weight, InsertAfter); - - // Link both child items to their new parent - pChildLo->pParent = pNewItem; - pChildHi->pParent = pNewItem; - pNewItem->pChildLo = pChildLo; - - // Fixup the item's position by its weight - MaxWeight = FixupItemPosByWeight(pNewItem, MaxWeight); - - // Get the previous lower-weight child - pChildLo = pChildHi->pPrev; - } - - // Initialize the MinValidValue to 1, which invalidates all quick-link items - MinValidValue = 1; - return true; -} - -void THuffmannTree::IncWeightsAndRebalance(THTreeItem * pItem) -{ - THTreeItem * pHigherItem; // A previous item with greater or equal weight - THTreeItem * pChildHi; // The higher-weight child - THTreeItem * pChildLo; // The lower-weight child - THTreeItem * pParent; - - // Climb up the tree and increment weight of each tree item - for(; pItem != NULL; pItem = pItem->pParent) - { - // Increment the item's weight - pItem->Weight++; - - // Find a previous item with equal or greater weight, which is not equal to this item - pHigherItem = FindHigherOrEqualItem(pItem->pPrev, pItem->Weight); - pChildHi = pHigherItem->pNext; - - // If the item is not equal to the tree item, we need to rebalance the tree - if(pChildHi != pItem) - { - // Move the previous item to the RIGHT from the given item - pChildHi->RemoveItem(); - LinkTwoItems(pItem, pChildHi); - - // Move the given item AFTER the greater-weight tree item - pItem->RemoveItem(); - LinkTwoItems(pHigherItem, pItem); - - // We need to maintain the tree so that pChildHi->Weight is >= pChildLo->Weight. - // Rebalance the tree accordingly. - pChildLo = pChildHi->pParent->pChildLo; - pParent = pItem->pParent; - if(pParent->pChildLo == pItem) - pParent->pChildLo = pChildHi; - if(pChildLo == pChildHi) - pChildHi->pParent->pChildLo = pItem; - pParent = pItem->pParent; - pItem->pParent = pChildHi->pParent; - pChildHi->pParent = pParent; - - // Increment the global valid value. This invalidates all quick-link items. - MinValidValue++; - } - } -} - -void THuffmannTree::InsertNewBranchAndRebalance(unsigned int Value1, unsigned int Value2) -{ - THTreeItem * pLastItem = pLast; - THTreeItem * pChildHi; - THTreeItem * pChildLo; - - // Create higher-weight child - pChildHi = CreateNewItem(Value1, pLastItem->Weight, InsertBefore); - pChildHi->pParent = pLastItem; - ItemsByByte[Value1] = pChildHi; - - // Create lower-weight child - pChildLo = CreateNewItem(Value2, 0, InsertBefore); - pChildLo->pParent = pLastItem; - pLastItem->pChildLo = pChildLo; - ItemsByByte[Value2] = pChildLo; - - IncWeightsAndRebalance(pChildLo); -} - -void THuffmannTree::EncodeOneByte(TOutputStream * os, THTreeItem * pItem) -{ - THTreeItem * pParent = pItem->pParent; - unsigned int BitBuffer = 0; - unsigned int BitCount = 0; - - // Put 1's as long as there is parent - while(pParent != NULL) - { - // Fill the bit buffer - BitBuffer = (BitBuffer << 1) | ((pParent->pChildLo != pItem) ? 1 : 0); - BitCount++; - - // Move to the parent - pItem = pParent; - pParent = pParent->pParent; - } - - // Write the bits to the output stream - os->PutBits(BitBuffer, BitCount); -} - -unsigned int THuffmannTree::DecodeOneByte(TInputStream * is) -{ - THTreeItem * pItemLink = NULL; - THTreeItem * pItem; - unsigned int ItemLinkIndex; - unsigned int BitCount = 0; - - // Check for the end of the input stream - if(is->pbInBuffer >= is->pbInBufferEnd && is->BitCount < 7) - return 0x1FF; - - // Get the eventual quick-link index - ItemLinkIndex = is->Peek7Bits(); - - // Is the quick-link item valid? - if(QuickLinks[ItemLinkIndex].ValidValue > MinValidValue) - { - // If that item needs less than 7 bits, we can get decompressed value directly - if(QuickLinks[ItemLinkIndex].ValidBits <= 7) - { - is->SkipBits(QuickLinks[ItemLinkIndex].ValidBits); - return QuickLinks[ItemLinkIndex].DecompressedValue; + maxByte = oneByte; + continue; } - // Otherwise we cannot get decompressed value directly - // but we can skip 7 levels of tree parsing - pItem = QuickLinks[ItemLinkIndex].pItem; - is->SkipBits(7); + // Find the first item which has byte value greater than current one byte + if(PTR_VALID(pItem3 = pLast)) // EDI - Pointer to the last item + { + // 15006AF7 + if(pItem3 != NULL) + { + do // 15006AFB + { + if(pItem3->byteValue >= oneByte) + goto _15006B09; + pItem3 = pItem3->prev; + } + while(PTR_VALID(pItem3)); + } + } + pItem3 = NULL; + + // 15006B09 + _15006B09: + if(item->next != NULL) + item->RemoveItem(); + + // 15006B15 + if(pItem3 == NULL) + pItem3 = PTR_PTR(&pFirst); + + // 15006B1F + item->next = pItem3->next; + item->prev = pItem3->next->prev; + pItem3->next->prev = item; + pItem3->next = item; + } + + // 15006B4A + for(; i < 0x102; i++) + { + THTreeItem ** itemPtr = &items306C[i]; // EDI + + // 15006B59 + THTreeItem * item = pItem3058; // ESI + if(PTR_INVALID_OR_NULL(item)) + item = &items0008[nItems++]; + + InsertItem(&pItem305C, item, INSERT_ITEM, NULL); + + // 15006B89 + item->dcmpByte = i; + item->byteValue = 1; + item->parent = NULL; + item->child = NULL; + *itemPtr++ = item; + } + + // 15006BAA + if(PTR_VALID(child1 = pLast)) // EDI - last item (first child to item + { + THTreeItem * child2; // EBP + THTreeItem * item; // ESI + + // 15006BB8 + while(PTR_VALID(child2 = child1->prev)) + { + if(PTR_INVALID_OR_NULL(item = pItem3058)) + item = &items0008[nItems++]; + + // 15006BE3 + InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); + + // 15006BF3 + item->parent = NULL; + item->child = NULL; + + //EDX = child2->byteValue + child1->byteValue; + //EAX = child1->byteValue; + //ECX = maxByte; // The greatest character (0xFF usually) + + item->byteValue = child1->byteValue + child2->byteValue; // 0x02 + item->child = child1; // Prev item in the + child1->parent = item; + child2->parent = item; + + // EAX = item->byteValue; + if(item->byteValue >= maxByte) + maxByte = item->byteValue; + else + { + THTreeItem * pItem2 = child2->prev; // EDI + + // 15006C2D + while(PTR_VALID(pItem2)) + { + if(pItem2->byteValue >= item->byteValue) + goto _15006C3B; + pItem2 = pItem2->prev; + } + pItem2 = NULL; + + _15006C3B: + if(item->next != 0) + { + THTreeItem * temp4 = item->GetPrevItem(-1); + + temp4->next = item->next; // The first item changed + item->next->prev = item->prev; // First->prev changed to negative value + item->next = NULL; + item->prev = NULL; + } + + // 15006C62 + if(pItem2 == NULL) + pItem2 = PTR_PTR(&pFirst); + + item->next = pItem2->next; // Set item with 0x100 byte value + item->prev = pItem2->next->prev; // Set item with 0x17 byte value + pItem2->next->prev = item; // Changed prev of item with + pItem2->next = item; + } + + // 15006C7B + if(PTR_INVALID_OR_NULL(child1 = child2->prev)) + break; + } + } + // 15006C88 + offs0004 = 1; +} +/* +// Modifies Huffman tree. Adds new item and changes +void THuffmannTree::ModifyTree(unsigned long dwIndex) +{ + THTreeItem * pItem1 = pItem3058; // ESI + THTreeItem * pSaveLast = (PTR_INT(pLast) <= 0) ? NULL : pLast; // EBX + THTreeItem * temp; // EAX + + // Prepare the first item to insert to the tree + if(PTR_INT(pItem1) <= 0) + pItem1 = &items0008[nItems++]; + + // If item has any next item, remove it from the chain + if(pItem1->next != NULL) + { + THTreeItem * temp = pItem1->GetPrevItem(-1); // EAX + + temp->next = pItem1->next; + pItem1->next->prev = pItem1->prev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + pItem1->next = PTR_PTR(&pFirst); + pItem1->prev = pLast; + temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); + + // 150068E9 + temp->next = pItem1; + pLast = pItem1; + + pItem1->parent = NULL; + pItem1->child = NULL; + + // 150068F6 + pItem1->dcmpByte = pSaveLast->dcmpByte; // Copy item index + pItem1->byteValue = pSaveLast->byteValue; // Copy item byte value + pItem1->parent = pSaveLast; // Set parent to last item + items306C[pSaveLast->dcmpByte] = pItem1; // Insert item into item pointer array + + // Prepare the second item to insert into the tree + if(PTR_INT((pItem1 = pItem3058)) <= 0) + pItem1 = &items0008[nItems++]; + + // 1500692E + if(pItem1->next != NULL) + { + temp = pItem1->GetPrevItem(-1); // EAX + + temp->next = pItem1->next; + pItem1->next->prev = pItem1->prev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + // 1500694C + pItem1->next = PTR_PTR(&pFirst); + pItem1->prev = pLast; + temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); + + // 15006968 + temp->next = pItem1; + pLast = pItem1; + + // 1500696E + pItem1->child = NULL; + pItem1->dcmpByte = dwIndex; + pItem1->byteValue = 0; + pItem1->parent = pSaveLast; + pSaveLast->child = pItem1; + items306C[dwIndex] = pItem1; + + do + { + THTreeItem * pItem2 = pItem1; + THTreeItem * pItem3; + unsigned long byteValue; + + // 15006993 + byteValue = ++pItem1->byteValue; + + // Pass through all previous which have its value greater than byteValue + while(PTR_INT((pItem3 = pItem2->prev)) > 0) // EBX + { + if(pItem3->byteValue >= byteValue) + goto _150069AE; + + pItem2 = pItem2->prev; + } + // 150069AC + pItem3 = NULL; + + _150069AE: + if(pItem2 == pItem1) + continue; + + // 150069B2 + // Switch pItem2 with item + InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); + InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); + + // 150069D0 + // Switch parents of pItem1 and pItem2 + temp = pItem2->parent->child; + if(pItem1 == pItem1->parent->child) + pItem1->parent->child = pItem2; + + if(pItem2 == temp) + pItem2->parent->child = pItem1; + + // 150069ED + // Switch parents of pItem1 and pItem3 + temp = pItem1->parent; + pItem1 ->parent = pItem2->parent; + pItem2->parent = temp; + offs0004++; + } + while(PTR_INT((pItem1 = pItem1->parent)) > 0); +} + +void THuffmannTree::UninitTree() +{ + while(PTR_INT(pLast) > 0) + { + pItem = pItem305C->Call1501DB70(pLast); + pItem->RemoveItem(); + } + + for(pItem = pFirst; PTR_INT(pItem3058) > 0; pItem = pItem3058) + pItem->RemoveItem(); + PTR_PTR(&pItem3054)->RemoveItem(); + + for(pItem = items0008 + 0x203, nCount = 0x203; nCount != 0; nCount--) + { + pItem--; + pItem->RemoveItem(); + pItem->RemoveItem(); + } +} +*/ + +THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) +{ + THTreeItem * pItem1 = pItem3058; // EDX + THTreeItem * pItem2; // EAX + THTreeItem * pNext; + THTreeItem * pPrev; + THTreeItem ** ppItem; + + if(PTR_INVALID_OR_NULL(pItem1) || (pItem2 = pItem1) == NULL) + { + if((pItem2 = &items0008[nItems++]) != NULL) + pItem1 = pItem2; + else + pItem1 = pFirst; + } + else + pItem1 = pItem2; + + pNext = pItem1->next; + if(pNext != NULL) + { + pPrev = pItem1->prev; + if(PTR_INVALID_OR_NULL(pPrev)) + pPrev = PTR_NOT(pPrev); + else + pPrev += (pItem1 - pItem1->next->prev); + + pPrev->next = pNext; + pNext->prev = pPrev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + ppItem = &pFirst; // esi + if(nValue > 1) + { + // ecx = pFirst->next; + pItem1->next = *ppItem; + pItem1->prev = (*ppItem)->prev; + + (*ppItem)->prev = pItem2; + *ppItem = pItem1; + + pItem2->parent = NULL; + pItem2->child = NULL; } else { - // Just a sanity check - if(pFirst == LIST_HEAD()) - return 0x1FF; - - // We don't have the quick-link item, we need to parse the tree from its root - pItem = pFirst; - } - - // Step down the tree until we find a terminal item - while(pItem->pChildLo != NULL) - { - // If the next bit in the compressed stream is set, we get the higher-weight - // child. Otherwise, get the lower-weight child. - pItem = is->Get1Bit() ? pItem->pChildLo->pPrev : pItem->pChildLo; - BitCount++; - - // If the number of loaded bits reached 7, - // remember the current item for storing into quick-link item array - if(BitCount == 7) - pItemLink = pItem; - } - - // If we didn't get the item from the quick-link array, - // set the entry in it - if(QuickLinks[ItemLinkIndex].ValidValue < MinValidValue) - { - // If the current compressed byte was more than 7 bits, - // set a quick-link item with pointer to tree item - if(BitCount > 7) + pItem1->next = (THTreeItem *)ppItem; + pItem1->prev = ppItem[1]; + // edi = pItem305C; + pPrev = ppItem[1]; // ecx + if(PTR_INVALID_OR_NULL(pPrev)) { - QuickLinks[ItemLinkIndex].ValidValue = MinValidValue; - QuickLinks[ItemLinkIndex].ValidBits = BitCount; - QuickLinks[ItemLinkIndex].pItem = pItemLink; + pPrev = PTR_NOT(pPrev); + pPrev->next = pItem1; + pPrev->prev = pItem2; + + pItem2->parent = NULL; + pItem2->child = NULL; } else { - // Limit the quick-decompress item to lower amount of bits - // Coverity fix 84457: (x >> 32) has undefined behavior - ItemLinkIndex = (BitCount != 0) ? ItemLinkIndex & (0xFFFFFFFF >> (32 - BitCount)) : 0; - while(ItemLinkIndex < LINK_ITEM_COUNT) - { - // Fill the quick-decompress item - QuickLinks[ItemLinkIndex].ValidValue = MinValidValue; - QuickLinks[ItemLinkIndex].ValidBits = BitCount; - QuickLinks[ItemLinkIndex].DecompressedValue = pItem->DecompressedValue; + if(PTR_INVALID(pItem305C)) + pPrev += (THTreeItem *)ppItem - (*ppItem)->prev; + else + pPrev += PTR_INT(pItem305C); - // Increment the index - ItemLinkIndex += (1 << BitCount); - } + pPrev->next = pItem1; + ppItem[1] = pItem2; + pItem2->parent = NULL; + pItem2->child = NULL; } } - - // Return the decompressed value from the found item - return pItem->DecompressedValue; + return pItem2; } -unsigned int THuffmannTree::Compress(TOutputStream * os, void * pvInBuffer, int cbInBuffer, int CompressionType) +void THuffmannTree::Call1500E820(THTreeItem * pItem) { - unsigned char * pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; - unsigned char * pbOutBuff = os->pbOutBuffer; - unsigned char InputByte; - - if(!BuildTree(CompressionType)) - return 0; - bIsCmp0 = (CompressionType == 0); + THTreeItem * pItem1; // edi + THTreeItem * pItem2 = NULL; // eax + THTreeItem * pItem3; // edx + THTreeItem * pPrev; // ebx + + for(; pItem != NULL; pItem = pItem->parent) + { + pItem->byteValue++; + + for(pItem1 = pItem; ; pItem1 = pPrev) + { + pPrev = pItem1->prev; + if(PTR_INVALID_OR_NULL(pPrev)) + { + pPrev = NULL; + break; + } + + if(pPrev->byteValue >= pItem->byteValue) + break; + } + + if(pItem1 == pItem) + continue; + + if(pItem1->next != NULL) + { + pItem2 = pItem1->GetPrevItem(-1); + pItem2->next = pItem1->next; + pItem1->next->prev = pItem1->prev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + pItem2 = pItem->next; + pItem1->next = pItem2; + pItem1->prev = pItem2->prev; + pItem2->prev = pItem1; + pItem->next = pItem1; + if((pItem2 = pItem1) != NULL) + { + pItem2 = pItem->GetPrevItem(-1); + pItem2->next = pItem->next; + pItem->next->prev = pItem->prev; + pItem->next = NULL; + pItem->prev = NULL; + } + + if(pPrev == NULL) + pPrev = PTR_PTR(&pFirst); + + pItem2 = pPrev->next; + pItem->next = pItem2; + pItem->prev = pItem2->prev; + pItem2->prev = pItem; + pPrev->next = pItem; + + pItem3 = pItem1->parent->child; + pItem2 = pItem->parent; + if(pItem2->child == pItem) + pItem2->child = pItem1; + if(pItem3 == pItem1) + pItem1->parent->child = pItem; + + pItem2 = pItem->parent; + pItem->parent = pItem1->parent; + pItem1->parent = pItem2; + offs0004++; + } +} + +// 1500E920 +unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType) +{ + THTreeItem * pItem1; + THTreeItem * pItem2; + THTreeItem * pItem3; + THTreeItem * pTemp; + unsigned long dwBitBuff; + unsigned int nBits; + unsigned int nBit; + + BuildTree(nCmpType); + bIsCmp0 = (nCmpType == 0); // Store the compression type into output buffer - os->PutBits(CompressionType, 8); - - // Process the entire input buffer - while(pbInBuffer < pbInBufferEnd) + os->dwBitBuff |= (nCmpType << os->nBits); + os->nBits += 8; + + // Flush completed bytes + while(os->nBits >= 8) { - // Get the (next) byte from the input buffer - InputByte = *pbInBuffer++; - - // Do we have an item for such input value? - if(ItemsByByte[InputByte] == NULL) + if(os->cbOutSize != 0) { - // Encode the relationship - EncodeOneByte(os, ItemsByByte[0x101]); - - // Store the loaded byte into output stream - os->PutBits(InputByte, 8); - - InsertNewBranchAndRebalance(pLast->DecompressedValue, InputByte); + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->cbOutSize--; + } - if(bIsCmp0) + os->dwBitBuff >>= 8; + os->nBits -= 8; + } + + for(; nInLength != 0; nInLength--) + { + unsigned char bOneByte = *pbInBuffer++; + + if((pItem1 = items306C[bOneByte]) == NULL) + { + pItem2 = items306C[0x101]; // ecx + pItem3 = pItem2->parent; // eax + dwBitBuff = 0; + nBits = 0; + + for(; pItem3 != NULL; pItem3 = pItem3->parent) { - IncWeightsAndRebalance(ItemsByByte[InputByte]); + nBit = (pItem3->child != pItem2) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem2 = pItem3; + } + os->PutBits(dwBitBuff, nBits); + + // Store the loaded byte into output stream + os->dwBitBuff |= (bOneByte << os->nBits); + os->nBits += 8; + + // Flush the whole byte(s) + while(os->nBits >= 8) + { + if(os->cbOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->cbOutSize--; + } + os->dwBitBuff >>= 8; + os->nBits -= 8; + } + + pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; + pItem2 = Call1500E740(1); + pItem2->dcmpByte = pItem1->dcmpByte; + pItem2->byteValue = pItem1->byteValue; + pItem2->parent = pItem1; + items306C[pItem2->dcmpByte] = pItem2; + + pItem2 = Call1500E740(1); + pItem2->dcmpByte = bOneByte; + pItem2->byteValue = 0; + pItem2->parent = pItem1; + items306C[pItem2->dcmpByte] = pItem2; + pItem1->child = pItem2; + + Call1500E820(pItem2); + + if(bIsCmp0 != 0) + { + Call1500E820(items306C[bOneByte]); continue; } - - IncWeightsAndRebalance(ItemsByByte[InputByte]); + + for(pItem1 = items306C[bOneByte]; pItem1 != NULL; pItem1 = pItem1->parent) + { + pItem1->byteValue++; + pItem2 = pItem1; + + for(;;) + { + pItem3 = pItem2->prev; + if(PTR_INVALID_OR_NULL(pItem3)) + { + pItem3 = NULL; + break; + } + if(pItem3->byteValue >= pItem1->byteValue) + break; + pItem2 = pItem3; + } + + if(pItem2 != pItem1) + { + InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); + InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); + + pItem3 = pItem2->parent->child; + if(pItem1->parent->child == pItem1) + pItem1->parent->child = pItem2; + + if(pItem3 == pItem2) + pItem2->parent->child = pItem1; + + pTemp = pItem1->parent; + pItem1->parent = pItem2->parent; + pItem2->parent = pTemp; + offs0004++; + } + } + } +// 1500EB62 + else + { + dwBitBuff = 0; + nBits = 0; + for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) + { + nBit = (pItem2->child != pItem1) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem1 = pItem2; + } + os->PutBits(dwBitBuff, nBits); + } + +// 1500EB98 + if(bIsCmp0 != 0) + Call1500E820(items306C[bOneByte]); // 1500EB9D +// 1500EBAF + } // for(; nInLength != 0; nInLength--) + +// 1500EBB8 + pItem1 = items306C[0x100]; + dwBitBuff = 0; + nBits = 0; + for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) + { + nBit = (pItem2->child != pItem1) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem1 = pItem2; + } + +// 1500EBE6 + os->PutBits(dwBitBuff, nBits); + +// 1500EBEF + // Flush the remaining bits + while(os->nBits != 0) + { + if(os->cbOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->cbOutSize--; + } + os->dwBitBuff >>= 8; + os->nBits -= ((os->nBits > 8) ? 8 : os->nBits); + } + + return (unsigned int)(os->pbOutPos - os->pbOutBuffer); +} + +// Decompression using Huffman tree (1500E450) +unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) +{ + TQDecompress * qd; + THTreeItem * pItem1; + THTreeItem * pItem2; + unsigned char * pbOutPos = pbOutBuffer; + unsigned long nBitCount; + unsigned int nDcmpByte = 0; + unsigned int n8Bits; // 8 bits loaded from input stream + unsigned int n7Bits; // 7 bits loaded from input stream + bool bHasQdEntry; + + // Test the output length. Must not be NULL. + if(dwOutLength == 0) + return 0; + + // Get the compression type from the input stream + n8Bits = is->Get8Bits(); + + // Build the Huffman tree + BuildTree(n8Bits); + bIsCmp0 = (n8Bits == 0) ? 1 : 0; + + for(;;) + { + // Security check: If we are at the end of the input buffer, + // it means that the data is corrupt + if(is->BitCount == 0 && is->pbInBuffer >= is->pbInBufferEnd) + return 0; + + // Get 7 bits from input stream + n7Bits = is->Get7Bits(); + + // Try to use quick decompression. Check TQDecompress array for corresponding item. + // If found, ise the result byte instead. + qd = &qd3474[n7Bits]; + + // If there is a quick-pass possible (ebx) + bHasQdEntry = (qd->offs00 >= offs0004) ? true : false; + + // If we can use quick decompress, use it. + if(bHasQdEntry) + { + if(qd->nBits > 7) + { + is->SkipBits(7); + pItem1 = qd->pItem; + goto _1500E549; + } + is->SkipBits(qd->nBits); + nDcmpByte = qd->dcmpByte; } else { - EncodeOneByte(os, ItemsByByte[InputByte]); + pItem1 = pFirst->next->prev; + if(PTR_INVALID_OR_NULL(pItem1)) + pItem1 = NULL; +_1500E549: + nBitCount = 0; + pItem2 = NULL; + + do + { + if(pItem1 == NULL) + return 0; + + pItem1 = pItem1->child; // Move down by one level + if(is->GetBit()) // If current bit is set, move to previous + pItem1 = pItem1->prev; + + if(++nBitCount == 7) // If we are at 7th bit, save current HTree item. + pItem2 = pItem1; + } + while(pItem1->child != NULL); // Walk until tree has no deeper level + + if(bHasQdEntry == false) + { + if(nBitCount > 7) + { + qd->offs00 = offs0004; + qd->nBits = nBitCount; + qd->pItem = pItem2; + } + else + { + unsigned long nIndex = n7Bits & (0xFFFFFFFF >> (32 - nBitCount)); + unsigned long nAdd = (1 << nBitCount); + + for(qd = &qd3474[nIndex]; nIndex <= 0x7F; nIndex += nAdd, qd += nAdd) + { + qd->offs00 = offs0004; + qd->nBits = nBitCount; + qd->dcmpByte = pItem1->dcmpByte; + } + } + } + nDcmpByte = pItem1->dcmpByte; } - - if(bIsCmp0) + + if(nDcmpByte == 0x101) // Huffman tree needs to be modified { - IncWeightsAndRebalance(ItemsByByte[InputByte]); - } - } - - // Put the termination mark to the compressed stream - EncodeOneByte(os, ItemsByByte[0x100]); - - // Flush the remaining bits - os->Flush(); - return (unsigned int)(os->pbOutBuffer - pbOutBuff); -} - -// Decompression using Huffman tree (1500E450) -unsigned int THuffmannTree::Decompress(void * pvOutBuffer, unsigned int cbOutLength, TInputStream * is) -{ - unsigned char * pbOutBufferEnd = (unsigned char *)pvOutBuffer + cbOutLength; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned int DecompressedValue = 0; - unsigned int CompressionType = 0; - - // Test the output length. Must not be NULL. - if(cbOutLength == 0) - return 0; - - // Get the compression type from the input stream - CompressionType = is->Get8Bits(); - bIsCmp0 = (CompressionType == 0) ? 1 : 0; - - // Build the Huffman tree - if(!BuildTree(CompressionType)) - return 0; - - // Process the entire input buffer until end of the stream - while((DecompressedValue = DecodeOneByte(is)) != 0x100) - { - // Did an error occur? - if(DecompressedValue == 0x1FF) // An error occurred - return 0; + n8Bits = is->Get8Bits(); + pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; - // Huffman tree needs to be modified - if(DecompressedValue == 0x101) - { - // The decompressed byte is stored in the next 8 bits - DecompressedValue = is->Get8Bits(); + pItem2 = Call1500E740(1); + pItem2->parent = pItem1; + pItem2->dcmpByte = pItem1->dcmpByte; + pItem2->byteValue = pItem1->byteValue; + items306C[pItem2->dcmpByte] = pItem2; - InsertNewBranchAndRebalance(pLast->DecompressedValue, DecompressedValue); + pItem2 = Call1500E740(1); + pItem2->parent = pItem1; + pItem2->dcmpByte = n8Bits; + pItem2->byteValue = 0; + items306C[pItem2->dcmpByte] = pItem2; + pItem1->child = pItem2; + Call1500E820(pItem2); if(bIsCmp0 == 0) - IncWeightsAndRebalance(ItemsByByte[DecompressedValue]); + Call1500E820(items306C[n8Bits]); + + nDcmpByte = n8Bits; } - - // A byte successfully decoded - store it in the output stream - *pbOutBuffer++ = (unsigned char)DecompressedValue; - if(pbOutBuffer >= pbOutBufferEnd) + + if(nDcmpByte == 0x100) break; - + + *pbOutPos++ = (unsigned char)nDcmpByte; + if(--dwOutLength == 0) + break; + if(bIsCmp0) - { - IncWeightsAndRebalance(ItemsByByte[DecompressedValue]); - } + Call1500E820(items306C[nDcmpByte]); } - - return (unsigned int)(pbOutBuffer - (unsigned char *)pvOutBuffer); + + return (unsigned int)(pbOutPos - pbOutBuffer); } + +// Table for (de)compression. Every compression type has 258 entries +unsigned char THuffmannTree::Table1502A630[] = +{ + // Data for compression type 0x00 + 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, + + // Data for compression type 0x01 + 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, + 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, + 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, + 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, + 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, + 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, + 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, + 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, + 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, + 0x00, 0x00, + + // Data for compression type 0x02 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, + 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, + 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, + 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x03 + 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, + 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, + 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, + 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, + 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, + 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, + 0x00, 0x00, + + // Data for compression type 0x04 + 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x05 + 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, + 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, + 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, + 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x06 + 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x07 + 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x08 + 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, + 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, + 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 +}; diff --git a/dep/StormLib/src/huffman/huff.h b/dep/StormLib/src/huffman/huff.h index 89993fdef..d1c06e0f4 100644 --- a/dep/StormLib/src/huffman/huff.h +++ b/dep/StormLib/src/huffman/huff.h @@ -9,15 +9,25 @@ /* 03.05.03 2.00 Lad Added compression */ /* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ /*****************************************************************************/ - + #ifndef __HUFFMAN_H__ #define __HUFFMAN_H__ +#include "../StormPort.h" + //----------------------------------------------------------------------------- // Defines - -#define HUFF_ITEM_COUNT 0x203 // Number of items in the item pool -#define LINK_ITEM_COUNT 0x80 // Maximum number of quick-link items + +#define INSERT_ITEM 1 +#define SWITCH_ITEMS 2 // Switch the item1 and item2 + +#define PTR_NOT(ptr) (THTreeItem *)(~(DWORD_PTR)(ptr)) +#define PTR_PTR(ptr) ((THTreeItem *)(ptr)) +#define PTR_INT(ptr) (INT_PTR)(ptr) + +#ifndef NULL +#define NULL 0 +#endif //----------------------------------------------------------------------------- // Structures and classes @@ -27,76 +37,65 @@ class TInputStream { public: - TInputStream(void * pvInBuffer, size_t cbInBuffer); - unsigned int Get1Bit(); - unsigned int Peek7Bits(); - unsigned int Get8Bits(); + unsigned long GetBit(); + unsigned long Get7Bits(); + unsigned long Get8Bits(); void SkipBits(unsigned int BitCount); - - unsigned char * pbInBufferEnd; // End position in the the input buffer - unsigned char * pbInBuffer; // Current position in the the input buffer - unsigned int BitBuffer; // Input bit buffer - unsigned int BitCount; // Number of bits remaining in 'dwBitBuff' + + unsigned char * pbInBuffer; // Input data + unsigned char * pbInBufferEnd; // End of the input buffer + unsigned long BitBuffer; // Input bit buffer + unsigned int BitCount; // Number of bits remaining in 'dwBitBuff' }; - // Output stream for Huffmann compression class TOutputStream { public: - - TOutputStream(void * pvOutBuffer, size_t cbOutLength); - void PutBits(unsigned int dwValue, unsigned int nBitCount); - void Flush(); - - unsigned char * pbOutBufferEnd; // End position in the output buffer - unsigned char * pbOutBuffer; // Current position in the output buffer - unsigned int BitBuffer; // Bit buffer - unsigned int BitCount; // Number of bits in the bit buffer + + void PutBits(unsigned long dwBuff, unsigned int nPutBits); + + unsigned char * pbOutBuffer; // 00 : Output buffer + unsigned long cbOutSize; // 04 : Size of output buffer + unsigned char * pbOutPos; // 08 : Current output position + unsigned long dwBitBuff; // 0C : Bit buffer + unsigned long nBits; // 10 : Number of bits in the bit buffer }; -// A virtual tree item that represents the head of the item list -#define LIST_HEAD() ((THTreeItem *)(&pFirst)) - -enum TInsertPoint -{ - InsertAfter = 1, - InsertBefore = 2 -}; - -// Huffmann tree item +// Huffmann tree item (?) struct THTreeItem { - THTreeItem() { pPrev = pNext = NULL; DecompressedValue = 0; Weight = 0; pParent = pChildLo = NULL; } -// ~THTreeItem() { RemoveItem(); } - + THTreeItem * Call1501DB70(THTreeItem * pLast); + THTreeItem * GetPrevItem(LONG_PTR value); + void ClearItemLinks(); void RemoveItem(); -// void RemoveEntry(); - - THTreeItem * pNext; // Pointer to lower-weight tree item - THTreeItem * pPrev; // Pointer to higher-weight item - unsigned int DecompressedValue; // 08 - Decompressed byte value (also index in the array) - unsigned int Weight; // 0C - Weight - THTreeItem * pParent; // 10 - Pointer to parent item (NULL if none) - THTreeItem * pChildLo; // 14 - Pointer to the child with lower-weight child ("left child") + + THTreeItem * next; // 00 - Pointer to next THTreeItem + THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none) + unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value + unsigned long byteValue; // 0C - Some byte value + THTreeItem * parent; // 10 - Pointer to parent THTreeItem (NULL if none) + THTreeItem * child; // 14 - Pointer to child THTreeItem + int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive }; - -// Structure used for quick navigating in the huffmann tree. -// Allows skipping up to 7 bits in the compressed stream, thus -// decompressing a bit faster. Sometimes it can even get the decompressed -// byte directly. -struct TQuickLink -{ - unsigned int ValidValue; // If greater than THuffmannTree::MinValidValue, the entry is valid - unsigned int ValidBits; // Number of bits that are valid for this item link +// Structure used for quick decompress. The 'bitCount' contains number of bits +// and byte value contains result decompressed byte value. +// After each walk through Huffman tree are filled all entries which are +// multiplies of number of bits loaded from input stream. These entries +// contain number of bits and result value. At the next 7 bits is tested this +// structure first. If corresponding entry found, decompression routine will +// not walk through Huffman tree and directly stores output byte to output stream. +struct TQDecompress +{ + unsigned long offs00; // 00 - 1 if resolved + unsigned long nBits; // 04 - Bit count union { - THTreeItem * pItem; // Pointer to the item within the Huffmann tree - unsigned int DecompressedValue; // Value for direct decompression + unsigned long dcmpByte; // 08 - Byte value for decompress (if bitCount <= 7) + THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7 }; }; - // Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert // for the decompression, I do not know actually if the class is really a Hufmann @@ -104,40 +103,40 @@ struct TQuickLink class THuffmannTree { public: - - THuffmannTree(bool bCompression); - ~THuffmannTree(); - void LinkTwoItems(THTreeItem * pItem1, THTreeItem * pItem2); - void InsertItem(THTreeItem * item, TInsertPoint InsertPoint, THTreeItem * item2); + THuffmannTree(); + void InitTree(bool bCompression); + void BuildTree(unsigned int nCmpType); +// void ModifyTree(unsigned long dwIndex); +// void UninitTree(); - THTreeItem * FindHigherOrEqualItem(THTreeItem * pItem, unsigned int Weight); - THTreeItem * CreateNewItem(unsigned int DecompressedValue, unsigned int Weight, TInsertPoint InsertPoint); +// void Call15007010(Bit32 dwInLength, THTreeItem * item); + THTreeItem * Call1500E740(unsigned int nValue); + void Call1500E820(THTreeItem * pItem); + unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType); + unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is); - unsigned int FixupItemPosByWeight(THTreeItem * pItem, unsigned int MaxWeight); - bool BuildTree(unsigned int CompressionType); + unsigned long bIsCmp0; // 0000 - 1 if compression type 0 + unsigned long offs0004; // 0004 - Some flag + THTreeItem items0008[0x203]; // 0008 - HTree items - void IncWeightsAndRebalance(THTreeItem * pItem); - void InsertNewBranchAndRebalance(unsigned int Value1, unsigned int Value2); + //- Sometimes used as HTree item ----------- + THTreeItem * pItem3050; // 3050 - Always NULL (?) + THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item + THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid) - void EncodeOneByte(TOutputStream * os, THTreeItem * pItem); - unsigned int DecodeOneByte(TInputStream * is); + //- Sometimes used as HTree item ----------- + THTreeItem * pItem305C; // 305C - Usually NULL + THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item + THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid) + unsigned long nItems; // 3068 - Number of used HTree items - unsigned int Compress(TOutputStream * os, void * pvInBuffer, int cbInBuffer, int nCmpType); - unsigned int Decompress(void * pvOutBuffer, unsigned int cbOutLength, TInputStream * is); - - THTreeItem ItemBuffer[HUFF_ITEM_COUNT]; // Buffer for tree items. No memory allocation is needed - unsigned int ItemsUsed; // Number of tree items used from ItemBuffer - - // Head of the linear item list - THTreeItem * pFirst; // Pointer to the highest weight item - THTreeItem * pLast; // Pointer to the lowest weight item + //------------------------------------------- + THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array + TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression + int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive - THTreeItem * ItemsByByte[0x102]; // Array of item pointers, one for each possible byte value - TQuickLink QuickLinks[LINK_ITEM_COUNT]; // Array of quick-link items - - unsigned int MinValidValue; // A minimum value of TQDecompress::ValidValue to be considered valid - unsigned int bIsCmp0; // 1 if compression type 0 + static unsigned char Table1502A630[];// Some table }; #endif // __HUFFMAN_H__ diff --git a/dep/StormLib/src/huffman/huff_patch.cpp b/dep/StormLib/src/huffman/huff_patch.cpp new file mode 100644 index 000000000..6639107c5 --- /dev/null +++ b/dep/StormLib/src/huffman/huff_patch.cpp @@ -0,0 +1,1120 @@ +/*****************************************************************************/ +/* huffman.cpp Copyright (c) Ladislav Zezula 1998-2003 */ +/*---------------------------------------------------------------------------*/ +/* This module contains Huffmann (de)compression methods */ +/* */ +/* Authors : Ladislav Zezula (ladik@zezula.net) */ +/* ShadowFlare (BlakFlare@hotmail.com) */ +/* */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.xx 1.00 Lad The first version of dcmp.cpp */ +/* 03.05.03 1.00 Lad Added compression methods */ +/* 19.11.03 1.01 Dan Big endian handling */ +/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ +/*****************************************************************************/ + +#include +#include + +#include "huff.h" + +THTreeItem * gcpFirst, * gpFirst, * gcpItem3054, * gpItem3054; + +#define PTR_VALID(ptr) ((ptr) != gcpFirst && (ptr) != gcpItem3054) +#define PTR_INVALID(ptr) (!PTR_VALID(ptr)) +#define PTR_INVALID_OR_NULL(ptr) (0 == (ptr) || PTR_INVALID(ptr)) + +//----------------------------------------------------------------------------- +// Methods of the THTreeItem struct + +// 1501DB70 +THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast) +{ + if(pLast == NULL) + pLast = this + 1; + return pLast; +} + +// Gets previous Huffman tree item (?) +THTreeItem * THTreeItem::GetPrevItem(SIntPtr value) +{ + if(PTR_INVALID(prev)) + return PTR_NOT(prev); + + if(value == -1 || PTR_INVALID((THTreeItem *) value)) + value = (SIntPtr)(this - next->prev); + return prev + value; +} + +// 1500F5E0 +void THTreeItem::ClearItemLinks() +{ + next = prev = NULL; +} + +// 1500BC90 +void THTreeItem::RemoveItem() +{ + THTreeItem * pTemp; // EDX + + if(next != NULL) + { + pTemp = prev; + + if(PTR_INVALID(pTemp)) + pTemp = PTR_NOT(pTemp); + else + pTemp += (this - next->prev); + + pTemp->next = next; + next->prev = prev; + next = prev = NULL; + } +} + +//----------------------------------------------------------------------------- +// TOutputStream functions + +void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits) +{ + dwBitBuff |= (dwBuff << nBits); + nBits += nPutBits; + + // Flush completed bytes + while(nBits >= 8) + { + if(cbOutSize != 0) + { + *pbOutPos++ = (unsigned char)dwBitBuff; + cbOutSize--; + } + + dwBitBuff >>= 8; + nBits -= 8; + } +} + +//----------------------------------------------------------------------------- +// TInputStream functions + +// Gets one bit from input stream +unsigned long TInputStream::GetBit() +{ + unsigned long dwOneBit = 0; + + // Ensure that the input stream is reloaded, if there are no bits left + if(BitCount == 0) + { + // Refill the bit buffer + BitBuffer = *pbInBuffer++; + BitCount = 8; + } + + // Copy the bit from bit buffer to the variable + dwOneBit = (BitBuffer & 0x01); + BitBuffer >>= 1; + BitCount--; + + return dwOneBit; +} + +// Gets 7 bits from the stream. DOES NOT remove the bits from input stream +unsigned long TInputStream::Get7Bits() +{ + unsigned long dwReloadByte = 0; + + // If there is not enough bits to get the value, + // we have to add 8 more bits from the input buffer + if(BitCount < 7) + { + dwReloadByte = *pbInBuffer++; + BitBuffer |= dwReloadByte << BitCount; + BitCount += 8; + } + + // Return the first available 7 bits. DO NOT remove them from the input stream + return (BitBuffer & 0x7F); +} + +// Gets the whole byte from the input stream. +unsigned long TInputStream::Get8Bits() +{ + unsigned long dwReloadByte = 0; + unsigned long dwOneByte = 0; + + // If there is not enough bits to get the value, + // we have to add 8 more bits from the input buffer + if(BitCount < 8) + { + dwReloadByte = *pbInBuffer++; + BitBuffer |= dwReloadByte << BitCount; + BitCount += 8; + } + + // Return the lowest 8 its + dwOneByte = (BitBuffer & 0xFF); + BitBuffer >>= 8; + BitCount -= 8; + return dwOneByte; +} + +void TInputStream::SkipBits(unsigned int dwBitsToSkip) +{ + unsigned long dwReloadByte = 0; + + // If there is not enough bits in the buffer, + // we have to add 8 more bits from the input buffer + if(BitCount < dwBitsToSkip) + { + dwReloadByte = *pbInBuffer++; + BitBuffer |= dwReloadByte << BitCount; + BitCount += 8; + } + + // Skip the remaining bits + BitBuffer >>= dwBitsToSkip; + BitCount -= dwBitsToSkip; +} + +//----------------------------------------------------------------------------- +// Functions for huffmann tree items + +// Inserts item into the tree (?) +static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long where, THTreeItem * item2) +{ + THTreeItem * next = item->next; // EDI - next to the first item + THTreeItem * prev = item->prev; // ESI - prev to the first item + THTreeItem * prev2; // Pointer to previous item + THTreeItem * next2; // Pointer to the next item + + // The same code like in RemoveItem(item); + if(next != 0) // If the first item already has next one + { + if(PTR_INVALID(prev)) + prev = PTR_NOT(prev); + else + prev += (item - next->prev); + + // 150083C1 + // Remove the item from the tree + prev->next = next; + next->prev = prev; + + // Invalidate 'prev' and 'next' pointer + item->next = 0; + item->prev = 0; + } + + if(item2 == NULL) // EDX - If the second item is not entered, + item2 = PTR_PTR(&itemPtr[1]); // take the first tree item + + switch(where) + { + case SWITCH_ITEMS : // Switch the two items + item->next = item2->next; // item2->next (Pointer to pointer to first) + item->prev = item2->next->prev; + item2->next->prev = item; + item2->next = item; // Set the first item + return; + + case INSERT_ITEM: // Insert as the last item + item->next = item2; // Set next item (or pointer to pointer to first item) + item->prev = item2->prev; // Set prev item (or last item in the tree) + + next2 = itemPtr[0];// Usually NULL + prev2 = item2->prev; // Prev item to the second (or last tree item) + + if(PTR_INVALID(prev2)) + { + prev2 = PTR_NOT(prev); + + prev2->next = item; + item2->prev = item; // Next after last item + return; + } + + if(PTR_INVALID(next2)) + next2 = (THTreeItem *)(item2 - item2->next->prev); + + prev2 += (long) next2; + prev2->next = item; + item2->prev = item; // Set the next/last item + return; + + default: + return; + } +} + +//----------------------------------------------------------------------------- +// THuffmannTree class functions + +THuffmannTree::THuffmannTree() +{ +} + +void THuffmannTree::InitTree(bool bCompression) +{ + THTreeItem * pItem; + unsigned int nCount; + + // Clear links for all the items in the tree + for(pItem = items0008, nCount = 0x203; nCount != 0; pItem++, nCount--) + pItem->ClearItemLinks(); + + gcpItem3054 = (THTreeItem *) &gcpItem3054; + pItem3050 = NULL; + pItem3054 = PTR_PTR(&pItem3054); + pItem3058 = gcpItem3054; + gpItem3054 = pItem3054; + + gcpFirst = (THTreeItem *) &gcpFirst; + pItem305C = NULL; + pFirst = PTR_PTR(&pFirst); + pLast = gcpFirst; + gpFirst = pFirst; + + offs0004 = 1; + nItems = 0; + + // Clear all TQDecompress items. Do this only if preparing for decompression + if(bCompression == false) + { + for(nCount = 0; nCount < sizeof(qd3474) / sizeof(TQDecompress); nCount++) + qd3474[nCount].offs00 = 0; + } +} + +// Builds Huffman tree. Called with the first 8 bits loaded from input stream +void THuffmannTree::BuildTree(unsigned int nCmpType) +{ + unsigned long maxByte; // [ESP+10] - The greatest character found in table + THTreeItem ** itemPtr; // [ESP+14] - Pointer to Huffman tree item pointer array + unsigned char * byteArray; // [ESP+1C] - Pointer to unsigned char in Table1502A630 + THTreeItem * child1; + unsigned long i; // egcs in linux doesn't like multiple for loops without an explicit i + + // Loop while pointer has a valid value + while(PTR_VALID(pLast)) // ESI - Last entry + { + THTreeItem * temp; // EAX + + if(pLast->next != NULL) // ESI->next + pLast->RemoveItem(); + // EDI = &offs3054 + pItem3058 = PTR_PTR(&pItem3054); // [EDI+4] + pLast->prev = pItem3058; // EAX + + temp = PTR_PTR(&pItem3054)->GetPrevItem((SIntPtr)(&pItem3050)); + + temp->next = pLast; + pItem3054 = pLast; + } + + // Clear all pointers in HTree item array + memset(items306C, 0, sizeof(items306C)); + + maxByte = 0; // Greatest character found init to zero. + itemPtr = (THTreeItem **)&items306C; // Pointer to current entry in HTree item pointer array + + // Ensure we have low 8 bits only + nCmpType &= 0xFF; + byteArray = Table1502A630 + nCmpType * 258; // EDI also + + for(i = 0; i < 0x100; i++, itemPtr++) + { + THTreeItem * item = pItem3058; // Item to be created + THTreeItem * pItem3 = pItem3058; + unsigned char oneByte = byteArray[i]; + + // Skip all the bytes which are zero. + if(byteArray[i] == 0) + continue; + + // If not valid pointer, take the first available item in the array + if(PTR_INVALID_OR_NULL(item)) + item = &items0008[nItems++]; + + // Insert this item as the top of the tree + InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); + + item->parent = NULL; // Invalidate child and parent + item->child = NULL; + *itemPtr = item; // Store pointer into pointer array + + item->dcmpByte = i; // Store counter + item->byteValue = oneByte; // Store byte value + if(oneByte >= maxByte) + { + maxByte = oneByte; + continue; + } + + // Find the first item which has byte value greater than current one byte + if(PTR_VALID(pItem3 = pLast)) // EDI - Pointer to the last item + { + // 15006AF7 + if(pItem3 != NULL) + { + do // 15006AFB + { + if(pItem3->byteValue >= oneByte) + goto _15006B09; + pItem3 = pItem3->prev; + } + while(PTR_VALID(pItem3)); + } + } + pItem3 = NULL; + + // 15006B09 + _15006B09: + if(item->next != NULL) + item->RemoveItem(); + + // 15006B15 + if(pItem3 == NULL) + pItem3 = PTR_PTR(&pFirst); + + // 15006B1F + item->next = pItem3->next; + item->prev = pItem3->next->prev; + pItem3->next->prev = item; + pItem3->next = item; + } + + // 15006B4A + for(; i < 0x102; i++) + { + THTreeItem ** itemPtr = &items306C[i]; // EDI + + // 15006B59 + THTreeItem * item = pItem3058; // ESI + if(PTR_INVALID_OR_NULL(item)) + item = &items0008[nItems++]; + + InsertItem(&pItem305C, item, INSERT_ITEM, NULL); + + // 15006B89 + item->dcmpByte = i; + item->byteValue = 1; + item->parent = NULL; + item->child = NULL; + *itemPtr++ = item; + } + + // 15006BAA + if(PTR_VALID(child1 = pLast)) // EDI - last item (first child to item + { + THTreeItem * child2; // EBP + THTreeItem * item; // ESI + + // 15006BB8 + while(PTR_VALID(child2 = child1->prev)) + { + if(PTR_INVALID_OR_NULL(item = pItem3058)) + item = &items0008[nItems++]; + + // 15006BE3 + InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); + + // 15006BF3 + item->parent = NULL; + item->child = NULL; + + //EDX = child2->byteValue + child1->byteValue; + //EAX = child1->byteValue; + //ECX = maxByte; // The greatest character (0xFF usually) + + item->byteValue = child1->byteValue + child2->byteValue; // 0x02 + item->child = child1; // Prev item in the + child1->parent = item; + child2->parent = item; + + // EAX = item->byteValue; + if(item->byteValue >= maxByte) + maxByte = item->byteValue; + else + { + THTreeItem * pItem2 = child2->prev; // EDI + + // 15006C2D + while(PTR_VALID(pItem2)) + { + if(pItem2->byteValue >= item->byteValue) + goto _15006C3B; + pItem2 = pItem2->prev; + } + pItem2 = NULL; + + _15006C3B: + if(item->next != 0) + { + THTreeItem * temp4 = item->GetPrevItem(-1); + + temp4->next = item->next; // The first item changed + item->next->prev = item->prev; // First->prev changed to negative value + item->next = NULL; + item->prev = NULL; + } + + // 15006C62 + if(pItem2 == NULL) + pItem2 = PTR_PTR(&pFirst); + + item->next = pItem2->next; // Set item with 0x100 byte value + item->prev = pItem2->next->prev; // Set item with 0x17 byte value + pItem2->next->prev = item; // Changed prev of item with + pItem2->next = item; + } + + // 15006C7B + if(PTR_INVALID_OR_NULL(child1 = child2->prev)) + break; + } + } + // 15006C88 + offs0004 = 1; +} + +THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) +{ + THTreeItem * pItem1 = pItem3058; // EDX + THTreeItem * pItem2; // EAX + THTreeItem * pNext; + THTreeItem * pPrev; + THTreeItem ** ppItem; + + if(PTR_INVALID_OR_NULL(pItem1) || (pItem2 = pItem1) == NULL) + { + if((pItem2 = &items0008[nItems++]) != NULL) + pItem1 = pItem2; + else + pItem1 = pFirst; + } + else + pItem1 = pItem2; + + pNext = pItem1->next; + if(pNext != NULL) + { + pPrev = pItem1->prev; + if(PTR_INVALID(pPrev)) + pPrev = PTR_NOT(pPrev); + else + pPrev += (pItem1 - pItem1->next->prev); + + pPrev->next = pNext; + pNext->prev = pPrev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + ppItem = &pFirst; // esi + if(nValue > 1) + { + // ecx = pFirst->next; + pItem1->next = *ppItem; + pItem1->prev = (*ppItem)->prev; + + (*ppItem)->prev = pItem2; + *ppItem = pItem1; + + pItem2->parent = NULL; + pItem2->child = NULL; + } + else + { + pItem1->next = (THTreeItem *)ppItem; + pItem1->prev = ppItem[1]; + // edi = pItem305C; + pPrev = ppItem[1]; // ecx + if(PTR_INVALID(pPrev)) + { + pPrev = PTR_NOT(pPrev); + pPrev->next = pItem1; + pPrev->prev = pItem2; + + pItem2->parent = NULL; + pItem2->child = NULL; + } + else + { + if(PTR_INVALID(pItem305C)) + pPrev += (THTreeItem *)ppItem - (*ppItem)->prev; + else + pPrev += (long)pItem305C; + + pPrev->next = pItem1; + ppItem[1] = pItem2; + pItem2->parent = NULL; + pItem2->child = NULL; + } + } + return pItem2; +} + +void THuffmannTree::Call1500E820(THTreeItem * pItem) +{ + THTreeItem * pItem1; // edi + THTreeItem * pItem2 = NULL; // eax + THTreeItem * pItem3; // edx + THTreeItem * pPrev; // ebx + + for(; pItem != NULL; pItem = pItem->parent) + { + pItem->byteValue++; + + for(pItem1 = pItem; ; pItem1 = pPrev) + { + pPrev = pItem1->prev; + if(PTR_INVALID_OR_NULL(pPrev)) + { + pPrev = NULL; + break; + } + + if(pPrev->byteValue >= pItem->byteValue) + break; + } + + if(pItem1 == pItem) + continue; + + if(pItem1->next != NULL) + { + pItem2 = pItem1->GetPrevItem(-1); + pItem2->next = pItem1->next; + pItem1->next->prev = pItem1->prev; + pItem1->next = NULL; + pItem1->prev = NULL; + } + + pItem2 = pItem->next; + pItem1->next = pItem2; + pItem1->prev = pItem2->prev; + pItem2->prev = pItem1; + pItem->next = pItem1; + if((pItem2 = pItem1) != NULL) + { + pItem2 = pItem->GetPrevItem(-1); + pItem2->next = pItem->next; + pItem->next->prev = pItem->prev; + pItem->next = NULL; + pItem->prev = NULL; + } + + if(pPrev == NULL) + pPrev = PTR_PTR(&pFirst); + + pItem2 = pPrev->next; + pItem->next = pItem2; + pItem->prev = pItem2->prev; + pItem2->prev = pItem; + pPrev->next = pItem; + + pItem3 = pItem1->parent->child; + pItem2 = pItem->parent; + if(pItem2->child == pItem) + pItem2->child = pItem1; + if(pItem3 == pItem1) + pItem1->parent->child = pItem; + + pItem2 = pItem->parent; + pItem->parent = pItem1->parent; + pItem1->parent = pItem2; + offs0004++; + } +} + +// 1500E920 +unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType) +{ + THTreeItem * pItem1; + THTreeItem * pItem2; + THTreeItem * pItem3; + THTreeItem * pTemp; + unsigned long dwBitBuff; + unsigned int nBits; + unsigned int nBit; + + BuildTree(nCmpType); + bIsCmp0 = (nCmpType == 0); + + // Store the compression type into output buffer + os->dwBitBuff |= (nCmpType << os->nBits); + os->nBits += 8; + + // Flush completed bytes + while(os->nBits >= 8) + { + if(os->cbOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->cbOutSize--; + } + + os->dwBitBuff >>= 8; + os->nBits -= 8; + } + + for(; nInLength != 0; nInLength--) + { + unsigned char bOneByte = *pbInBuffer++; + + if((pItem1 = items306C[bOneByte]) == NULL) + { + pItem2 = items306C[0x101]; // ecx + pItem3 = pItem2->parent; // eax + dwBitBuff = 0; + nBits = 0; + + for(; pItem3 != NULL; pItem3 = pItem3->parent) + { + nBit = (pItem3->child != pItem2) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem2 = pItem3; + } + os->PutBits(dwBitBuff, nBits); + + // Store the loaded byte into output stream + os->dwBitBuff |= (bOneByte << os->nBits); + os->nBits += 8; + + // Flush the whole byte(s) + while(os->nBits >= 8) + { + if(os->cbOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->cbOutSize--; + } + os->dwBitBuff >>= 8; + os->nBits -= 8; + } + + pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; + pItem2 = Call1500E740(1); + pItem2->dcmpByte = pItem1->dcmpByte; + pItem2->byteValue = pItem1->byteValue; + pItem2->parent = pItem1; + items306C[pItem2->dcmpByte] = pItem2; + + pItem2 = Call1500E740(1); + pItem2->dcmpByte = bOneByte; + pItem2->byteValue = 0; + pItem2->parent = pItem1; + items306C[pItem2->dcmpByte] = pItem2; + pItem1->child = pItem2; + + Call1500E820(pItem2); + + if(bIsCmp0 != 0) + { + Call1500E820(items306C[bOneByte]); + continue; + } + + for(pItem1 = items306C[bOneByte]; pItem1 != NULL; pItem1 = pItem1->parent) + { + pItem1->byteValue++; + pItem2 = pItem1; + + for(;;) + { + pItem3 = pItem2->prev; + if(PTR_INVALID_OR_NULL(pItem3)) + { + pItem3 = NULL; + break; + } + if(pItem3->byteValue >= pItem1->byteValue) + break; + pItem2 = pItem3; + } + + if(pItem2 != pItem1) + { + InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); + InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); + + pItem3 = pItem2->parent->child; + if(pItem1->parent->child == pItem1) + pItem1->parent->child = pItem2; + + if(pItem3 == pItem2) + pItem2->parent->child = pItem1; + + pTemp = pItem1->parent; + pItem1->parent = pItem2->parent; + pItem2->parent = pTemp; + offs0004++; + } + } + } +// 1500EB62 + else + { + dwBitBuff = 0; + nBits = 0; + for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) + { + nBit = (pItem2->child != pItem1) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem1 = pItem2; + } + os->PutBits(dwBitBuff, nBits); + } + +// 1500EB98 + if(bIsCmp0 != 0) + Call1500E820(items306C[bOneByte]); // 1500EB9D +// 1500EBAF + } // for(; nInLength != 0; nInLength--) + +// 1500EBB8 + pItem1 = items306C[0x100]; + dwBitBuff = 0; + nBits = 0; + for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) + { + nBit = (pItem2->child != pItem1) ? 1 : 0; + dwBitBuff = (dwBitBuff << 1) | nBit; + nBits++; + pItem1 = pItem2; + } + +// 1500EBE6 + os->PutBits(dwBitBuff, nBits); + +// 1500EBEF + // Flush the remaining bits + while(os->nBits != 0) + { + if(os->cbOutSize != 0) + { + *os->pbOutPos++ = (unsigned char)os->dwBitBuff; + os->cbOutSize--; + } + os->dwBitBuff >>= 8; + os->nBits -= ((os->nBits > 8) ? 8 : os->nBits); + } + + return (unsigned int)(os->pbOutPos - os->pbOutBuffer); +} + +// Decompression using Huffman tree (1500E450) +unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) +{ + TQDecompress * qd; + THTreeItem * pItem1; + THTreeItem * pItem2; + unsigned char * pbOutPos = pbOutBuffer; + unsigned long nBitCount; + unsigned int nDcmpByte = 0; + unsigned int n8Bits; // 8 bits loaded from input stream + unsigned int n7Bits; // 7 bits loaded from input stream + bool bHasQdEntry; + + // Test the output length. Must not be NULL. + if(dwOutLength == 0) + return 0; + + // Get the compression type from the input stream + n8Bits = is->Get8Bits(); + + // Build the Huffman tree + BuildTree(n8Bits); + bIsCmp0 = (n8Bits == 0) ? 1 : 0; + + for(;;) + { + // Security check: If we are at the end of the input buffer, + // it means that the data are corrupt. + if(is->pbInBuffer > is->pbInBufferEnd) + return 0; + + // Get 7 bits from input stream + n7Bits = is->Get7Bits(); + + // Try to use quick decompression. Check TQDecompress array for corresponding item. + // If found, ise the result byte instead. + qd = &qd3474[n7Bits]; + + // If there is a quick-pass possible (ebx) + bHasQdEntry = (qd->offs00 >= offs0004) ? true : false; + + // If we can use quick decompress, use it. + if(bHasQdEntry) + { + if(qd->nBits > 7) + { + is->SkipBits(7); + pItem1 = qd->pItem; + goto _1500E549; + } + is->SkipBits(qd->nBits); + nDcmpByte = qd->dcmpByte; + } + else + { + pItem1 = pFirst->next->prev; + if(PTR_INVALID_OR_NULL(pItem1)) + pItem1 = NULL; +_1500E549: + nBitCount = 0; + pItem2 = NULL; + + do + { + pItem1 = pItem1->child; // Move down by one level + if(is->GetBit()) // If current bit is set, move to previous + pItem1 = pItem1->prev; + + if(++nBitCount == 7) // If we are at 7th bit, save current HTree item. + pItem2 = pItem1; + } + while(pItem1->child != NULL); // Walk until tree has no deeper level + + if(bHasQdEntry == false) + { + if(nBitCount > 7) + { + qd->offs00 = offs0004; + qd->nBits = nBitCount; + qd->pItem = pItem2; + } + else + { + unsigned long nIndex = n7Bits & (0xFFFFFFFF >> (32 - nBitCount)); + unsigned long nAdd = (1 << nBitCount); + + for(qd = &qd3474[nIndex]; nIndex <= 0x7F; nIndex += nAdd, qd += nAdd) + { + qd->offs00 = offs0004; + qd->nBits = nBitCount; + qd->dcmpByte = pItem1->dcmpByte; + } + } + } + nDcmpByte = pItem1->dcmpByte; + } + + if(nDcmpByte == 0x101) // Huffman tree needs to be modified + { + n8Bits = is->Get8Bits(); + pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; + + pItem2 = Call1500E740(1); + pItem2->parent = pItem1; + pItem2->dcmpByte = pItem1->dcmpByte; + pItem2->byteValue = pItem1->byteValue; + items306C[pItem2->dcmpByte] = pItem2; + + pItem2 = Call1500E740(1); + pItem2->parent = pItem1; + pItem2->dcmpByte = n8Bits; + pItem2->byteValue = 0; + items306C[pItem2->dcmpByte] = pItem2; + + pItem1->child = pItem2; + Call1500E820(pItem2); + if(bIsCmp0 == 0) + Call1500E820(items306C[n8Bits]); + + nDcmpByte = n8Bits; + } + + if(nDcmpByte == 0x100) + break; + + *pbOutPos++ = (unsigned char)nDcmpByte; + if(--dwOutLength == 0) + break; + + if(bIsCmp0) + Call1500E820(items306C[nDcmpByte]); + } + + return (unsigned int)(pbOutPos - pbOutBuffer); +} + + +// Table for (de)compression. Every compression type has 258 entries +unsigned char THuffmannTree::Table1502A630[] = +{ + // Data for compression type 0x00 + 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, + + // Data for compression type 0x01 + 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, + 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, + 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, + 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, + 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, + 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, + 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, + 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, + 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, + 0x00, 0x00, + + // Data for compression type 0x02 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, + 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, + 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, + 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x03 + 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, + 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, + 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, + 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, + 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, + 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, + 0x00, 0x00, + + // Data for compression type 0x04 + 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x05 + 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, + 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, + 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, + 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x06 + 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x07 + 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // Data for compression type 0x08 + 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, + 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, + 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 +}; diff --git a/dep/StormLib/src/huffman/huff_patch.h b/dep/StormLib/src/huffman/huff_patch.h new file mode 100644 index 000000000..ca2390c18 --- /dev/null +++ b/dep/StormLib/src/huffman/huff_patch.h @@ -0,0 +1,145 @@ +/*****************************************************************************/ +/* huffman.h Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Description : */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.xx 1.00 Lad The first version of huffman.h */ +/* 03.05.03 2.00 Lad Added compression */ +/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ +/*****************************************************************************/ + +#ifndef __HUFFMAN_H__ +#define __HUFFMAN_H__ + +#include + +#define SIntPtr intptr_t + +//----------------------------------------------------------------------------- +// Defines + +#define INSERT_ITEM 1 +#define SWITCH_ITEMS 2 // Switch the item1 and item2 + +#define PTR_NOT(ptr) ((ptr) == gcpFirst ? gpFirst : gpItem3054) +#define PTR_PTR(ptr) ((THTreeItem *)(ptr)) + +#ifndef NULL +#define NULL 0 +#endif + +//----------------------------------------------------------------------------- +// Structures and classes + +// Input stream for Huffmann decompression +class TInputStream +{ + public: + + unsigned long GetBit(); + unsigned long Get7Bits(); + unsigned long Get8Bits(); + void SkipBits(unsigned int BitCount); + + unsigned char * pbInBuffer; // Input data + unsigned char * pbInBufferEnd; // End of the input buffer + unsigned long BitBuffer; // Input bit buffer + unsigned int BitCount; // Number of bits remaining in 'dwBitBuff' +}; + +// Output stream for Huffmann compression +class TOutputStream +{ + public: + + void PutBits(unsigned long dwBuff, unsigned int nPutBits); + + unsigned char * pbOutBuffer; // 00 : Output buffer + unsigned long cbOutSize; // 04 : Size of output buffer + unsigned char * pbOutPos; // 08 : Current output position + unsigned long dwBitBuff; // 0C : Bit buffer + unsigned long nBits; // 10 : Number of bits in the bit buffer +}; + +// Huffmann tree item (?) +struct THTreeItem +{ + public: + + THTreeItem * Call1501DB70(THTreeItem * pLast); + THTreeItem * GetPrevItem(SIntPtr value); + void ClearItemLinks(); + void RemoveItem(); + + THTreeItem * next; // 00 - Pointer to next THTreeItem + THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none) + unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value + unsigned long byteValue; // 0C - Some byte value + THTreeItem * parent; // 10 - Pointer to parent THTreeItem (NULL if none) + THTreeItem * child; // 14 - Pointer to child THTreeItem + int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive +}; + +// Structure used for quick decompress. The 'bitCount' contains number of bits +// and byte value contains result decompressed byte value. +// After each walk through Huffman tree are filled all entries which are +// multiplies of number of bits loaded from input stream. These entries +// contain number of bits and result value. At the next 7 bits is tested this +// structure first. If corresponding entry found, decompression routine will +// not walk through Huffman tree and directly stores output byte to output stream. +struct TQDecompress +{ + unsigned long offs00; // 00 - 1 if resolved + unsigned long nBits; // 04 - Bit count + union + { + unsigned long dcmpByte; // 08 - Byte value for decompress (if bitCount <= 7) + THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7 + }; +}; + +// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert +// for the decompression, I do not know actually if the class is really a Hufmann +// tree. If someone knows the decompression details, please let me know +class THuffmannTree +{ + public: + + THuffmannTree(); + void InitTree(bool bCompression); + void BuildTree(unsigned int nCmpType); +// void ModifyTree(unsigned long dwIndex); +// void UninitTree(); + +// void Call15007010(Bit32 dwInLength, THTreeItem * item); + THTreeItem * Call1500E740(unsigned int nValue); + void Call1500E820(THTreeItem * pItem); + unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType); + unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is); + + unsigned long bIsCmp0; // 0000 - 1 if compression type 0 + unsigned long offs0004; // 0004 - Some flag + THTreeItem items0008[0x203]; // 0008 - HTree items + + //- Sometimes used as HTree item ----------- + THTreeItem * pItem3050; // 3050 - Always NULL (?) + THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item + THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid) + + //- Sometimes used as HTree item ----------- + THTreeItem * pItem305C; // 305C - Usually NULL + THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item + THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid) + unsigned long nItems; // 3068 - Number of used HTree items + + //------------------------------------------- + THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array + TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression + int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive + + static unsigned char Table1502A630[];// Some table +}; + +#endif // __HUFFMAN_H__ diff --git a/dep/StormLib/src/libtomcrypt/src/hashes/hash_memory.c b/dep/StormLib/src/libtomcrypt/src/hashes/hash_memory.c new file mode 100644 index 000000000..1daf0bffa --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/hashes/hash_memory.c @@ -0,0 +1,69 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file hash_memory.c + Hash memory helper, Tom St Denis +*/ + +/** + Hash a block of memory and store the digest. + @param hash The index of the hash you wish to use + @param in The data you wish to hash + @param inlen The length of the data to hash (octets) + @param out [out] Where to store the digest + @param outlen [in/out] Max size and resulting size of the digest + @return CRYPT_OK if successful +*/ +int hash_memory(int hash, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) +{ + hash_state *md; + int err; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + if ((err = hash_is_valid(hash)) != CRYPT_OK) { + return err; + } + + if (*outlen < hash_descriptor[hash].hashsize) { + *outlen = hash_descriptor[hash].hashsize; + return CRYPT_BUFFER_OVERFLOW; + } + + md = XMALLOC(sizeof(hash_state)); + if (md == NULL) { + return CRYPT_MEM; + } + + if ((err = hash_descriptor[hash].init(md)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash].process(md, in, inlen)) != CRYPT_OK) { + goto LBL_ERR; + } + err = hash_descriptor[hash].done(md, out); + *outlen = hash_descriptor[hash].hashsize; +LBL_ERR: +#ifdef LTC_CLEAN_STACK + zeromem(md, sizeof(hash_state)); +#endif + XFREE(md); + + return err; +} + +/* $Source: /cvs/libtom/libtomcrypt/src/hashes/helper/hash_memory.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:27:23 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/hashes/md5.c b/dep/StormLib/src/libtomcrypt/src/hashes/md5.c new file mode 100644 index 000000000..4cbd000c0 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/hashes/md5.c @@ -0,0 +1,368 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + + +/** + @file md5.c + LTC_MD5 hash function by Tom St Denis +*/ + +#ifdef LTC_MD5 + +const struct ltc_hash_descriptor md5_desc = +{ + "md5", + 3, + 16, + 64, + + /* OID */ + { 1, 2, 840, 113549, 2, 5, }, + 6, + + &md5_init, + &md5_process, + &md5_done, + &md5_test, + NULL +}; + +#define F(x,y,z) (z ^ (x & (y ^ z))) +#define G(x,y,z) (y ^ (z & (y ^ x))) +#define H(x,y,z) (x^y^z) +#define I(x,y,z) (y^(x|(~z))) + +#ifdef LTC_SMALL_CODE + +#define FF(a,b,c,d,M,s,t) \ + a = (a + F(b,c,d) + M + t); a = ROL(a, s) + b; + +#define GG(a,b,c,d,M,s,t) \ + a = (a + G(b,c,d) + M + t); a = ROL(a, s) + b; + +#define HH(a,b,c,d,M,s,t) \ + a = (a + H(b,c,d) + M + t); a = ROL(a, s) + b; + +#define II(a,b,c,d,M,s,t) \ + a = (a + I(b,c,d) + M + t); a = ROL(a, s) + b; + +static const unsigned char Worder[64] = { + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12, + 5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2, + 0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9 +}; + +static const unsigned char Rorder[64] = { + 7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22, + 5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20, + 4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23, + 6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21 +}; + +static const ulong32 Korder[64] = { +0xd76aa478UL, 0xe8c7b756UL, 0x242070dbUL, 0xc1bdceeeUL, 0xf57c0fafUL, 0x4787c62aUL, 0xa8304613UL, 0xfd469501UL, +0x698098d8UL, 0x8b44f7afUL, 0xffff5bb1UL, 0x895cd7beUL, 0x6b901122UL, 0xfd987193UL, 0xa679438eUL, 0x49b40821UL, +0xf61e2562UL, 0xc040b340UL, 0x265e5a51UL, 0xe9b6c7aaUL, 0xd62f105dUL, 0x02441453UL, 0xd8a1e681UL, 0xe7d3fbc8UL, +0x21e1cde6UL, 0xc33707d6UL, 0xf4d50d87UL, 0x455a14edUL, 0xa9e3e905UL, 0xfcefa3f8UL, 0x676f02d9UL, 0x8d2a4c8aUL, +0xfffa3942UL, 0x8771f681UL, 0x6d9d6122UL, 0xfde5380cUL, 0xa4beea44UL, 0x4bdecfa9UL, 0xf6bb4b60UL, 0xbebfbc70UL, +0x289b7ec6UL, 0xeaa127faUL, 0xd4ef3085UL, 0x04881d05UL, 0xd9d4d039UL, 0xe6db99e5UL, 0x1fa27cf8UL, 0xc4ac5665UL, +0xf4292244UL, 0x432aff97UL, 0xab9423a7UL, 0xfc93a039UL, 0x655b59c3UL, 0x8f0ccc92UL, 0xffeff47dUL, 0x85845dd1UL, +0x6fa87e4fUL, 0xfe2ce6e0UL, 0xa3014314UL, 0x4e0811a1UL, 0xf7537e82UL, 0xbd3af235UL, 0x2ad7d2bbUL, 0xeb86d391UL +}; + +#else + +#define FF(a,b,c,d,M,s,t) \ + a = (a + F(b,c,d) + M + t); a = ROLc(a, s) + b; + +#define GG(a,b,c,d,M,s,t) \ + a = (a + G(b,c,d) + M + t); a = ROLc(a, s) + b; + +#define HH(a,b,c,d,M,s,t) \ + a = (a + H(b,c,d) + M + t); a = ROLc(a, s) + b; + +#define II(a,b,c,d,M,s,t) \ + a = (a + I(b,c,d) + M + t); a = ROLc(a, s) + b; + + +#endif + +#ifdef LTC_CLEAN_STACK +static int _md5_compress(hash_state *md, unsigned char *buf) +#else +static int md5_compress(hash_state *md, unsigned char *buf) +#endif +{ + ulong32 i, W[16], a, b, c, d; +#ifdef LTC_SMALL_CODE + ulong32 t; +#endif + + /* copy the state into 512-bits into W[0..15] */ + for (i = 0; i < 16; i++) { + LOAD32L(W[i], buf + (4*i)); + } + + /* copy state */ + a = md->md5.state[0]; + b = md->md5.state[1]; + c = md->md5.state[2]; + d = md->md5.state[3]; + +#ifdef LTC_SMALL_CODE + for (i = 0; i < 16; ++i) { + FF(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); + t = d; d = c; c = b; b = a; a = t; + } + + for (; i < 32; ++i) { + GG(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); + t = d; d = c; c = b; b = a; a = t; + } + + for (; i < 48; ++i) { + HH(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); + t = d; d = c; c = b; b = a; a = t; + } + + for (; i < 64; ++i) { + II(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); + t = d; d = c; c = b; b = a; a = t; + } + +#else + FF(a,b,c,d,W[0],7,0xd76aa478UL) + FF(d,a,b,c,W[1],12,0xe8c7b756UL) + FF(c,d,a,b,W[2],17,0x242070dbUL) + FF(b,c,d,a,W[3],22,0xc1bdceeeUL) + FF(a,b,c,d,W[4],7,0xf57c0fafUL) + FF(d,a,b,c,W[5],12,0x4787c62aUL) + FF(c,d,a,b,W[6],17,0xa8304613UL) + FF(b,c,d,a,W[7],22,0xfd469501UL) + FF(a,b,c,d,W[8],7,0x698098d8UL) + FF(d,a,b,c,W[9],12,0x8b44f7afUL) + FF(c,d,a,b,W[10],17,0xffff5bb1UL) + FF(b,c,d,a,W[11],22,0x895cd7beUL) + FF(a,b,c,d,W[12],7,0x6b901122UL) + FF(d,a,b,c,W[13],12,0xfd987193UL) + FF(c,d,a,b,W[14],17,0xa679438eUL) + FF(b,c,d,a,W[15],22,0x49b40821UL) + GG(a,b,c,d,W[1],5,0xf61e2562UL) + GG(d,a,b,c,W[6],9,0xc040b340UL) + GG(c,d,a,b,W[11],14,0x265e5a51UL) + GG(b,c,d,a,W[0],20,0xe9b6c7aaUL) + GG(a,b,c,d,W[5],5,0xd62f105dUL) + GG(d,a,b,c,W[10],9,0x02441453UL) + GG(c,d,a,b,W[15],14,0xd8a1e681UL) + GG(b,c,d,a,W[4],20,0xe7d3fbc8UL) + GG(a,b,c,d,W[9],5,0x21e1cde6UL) + GG(d,a,b,c,W[14],9,0xc33707d6UL) + GG(c,d,a,b,W[3],14,0xf4d50d87UL) + GG(b,c,d,a,W[8],20,0x455a14edUL) + GG(a,b,c,d,W[13],5,0xa9e3e905UL) + GG(d,a,b,c,W[2],9,0xfcefa3f8UL) + GG(c,d,a,b,W[7],14,0x676f02d9UL) + GG(b,c,d,a,W[12],20,0x8d2a4c8aUL) + HH(a,b,c,d,W[5],4,0xfffa3942UL) + HH(d,a,b,c,W[8],11,0x8771f681UL) + HH(c,d,a,b,W[11],16,0x6d9d6122UL) + HH(b,c,d,a,W[14],23,0xfde5380cUL) + HH(a,b,c,d,W[1],4,0xa4beea44UL) + HH(d,a,b,c,W[4],11,0x4bdecfa9UL) + HH(c,d,a,b,W[7],16,0xf6bb4b60UL) + HH(b,c,d,a,W[10],23,0xbebfbc70UL) + HH(a,b,c,d,W[13],4,0x289b7ec6UL) + HH(d,a,b,c,W[0],11,0xeaa127faUL) + HH(c,d,a,b,W[3],16,0xd4ef3085UL) + HH(b,c,d,a,W[6],23,0x04881d05UL) + HH(a,b,c,d,W[9],4,0xd9d4d039UL) + HH(d,a,b,c,W[12],11,0xe6db99e5UL) + HH(c,d,a,b,W[15],16,0x1fa27cf8UL) + HH(b,c,d,a,W[2],23,0xc4ac5665UL) + II(a,b,c,d,W[0],6,0xf4292244UL) + II(d,a,b,c,W[7],10,0x432aff97UL) + II(c,d,a,b,W[14],15,0xab9423a7UL) + II(b,c,d,a,W[5],21,0xfc93a039UL) + II(a,b,c,d,W[12],6,0x655b59c3UL) + II(d,a,b,c,W[3],10,0x8f0ccc92UL) + II(c,d,a,b,W[10],15,0xffeff47dUL) + II(b,c,d,a,W[1],21,0x85845dd1UL) + II(a,b,c,d,W[8],6,0x6fa87e4fUL) + II(d,a,b,c,W[15],10,0xfe2ce6e0UL) + II(c,d,a,b,W[6],15,0xa3014314UL) + II(b,c,d,a,W[13],21,0x4e0811a1UL) + II(a,b,c,d,W[4],6,0xf7537e82UL) + II(d,a,b,c,W[11],10,0xbd3af235UL) + II(c,d,a,b,W[2],15,0x2ad7d2bbUL) + II(b,c,d,a,W[9],21,0xeb86d391UL) +#endif + + md->md5.state[0] = md->md5.state[0] + a; + md->md5.state[1] = md->md5.state[1] + b; + md->md5.state[2] = md->md5.state[2] + c; + md->md5.state[3] = md->md5.state[3] + d; + + return CRYPT_OK; +} + +#ifdef LTC_CLEAN_STACK +static int md5_compress(hash_state *md, unsigned char *buf) +{ + int err; + err = _md5_compress(md, buf); + burn_stack(sizeof(ulong32) * 21); + return err; +} +#endif + +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ +int md5_init(hash_state * md) +{ + LTC_ARGCHK(md != NULL); + md->md5.state[0] = 0x67452301UL; + md->md5.state[1] = 0xefcdab89UL; + md->md5.state[2] = 0x98badcfeUL; + md->md5.state[3] = 0x10325476UL; + md->md5.curlen = 0; + md->md5.length = 0; + return CRYPT_OK; +} + +/** + Process a block of memory though the hash + @param md The hash state + @param in The data to hash + @param inlen The length of the data (octets) + @return CRYPT_OK if successful +*/ +HASH_PROCESS(md5_process, md5_compress, md5, 64) + +/** + Terminate the hash to get the digest + @param md The hash state + @param out [out] The destination of the hash (16 bytes) + @return CRYPT_OK if successful +*/ +int md5_done(hash_state * md, unsigned char *out) +{ + int i; + + LTC_ARGCHK(md != NULL); + LTC_ARGCHK(out != NULL); + + if (md->md5.curlen >= sizeof(md->md5.buf)) { + return CRYPT_INVALID_ARG; + } + + + /* increase the length of the message */ + md->md5.length += md->md5.curlen * 8; + + /* append the '1' bit */ + md->md5.buf[md->md5.curlen++] = (unsigned char)0x80; + + /* if the length is currently above 56 bytes we append zeros + * then compress. Then we can fall back to padding zeros and length + * encoding like normal. + */ + if (md->md5.curlen > 56) { + while (md->md5.curlen < 64) { + md->md5.buf[md->md5.curlen++] = (unsigned char)0; + } + md5_compress(md, md->md5.buf); + md->md5.curlen = 0; + } + + /* pad upto 56 bytes of zeroes */ + while (md->md5.curlen < 56) { + md->md5.buf[md->md5.curlen++] = (unsigned char)0; + } + + /* store length */ + STORE64L(md->md5.length, md->md5.buf+56); + md5_compress(md, md->md5.buf); + + /* copy output */ + for (i = 0; i < 4; i++) { + STORE32L(md->md5.state[i], out+(4*i)); + } +#ifdef LTC_CLEAN_STACK + zeromem(md, sizeof(hash_state)); +#endif + return CRYPT_OK; +} + +/** + Self-test the hash + @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled +*/ +int md5_test(void) +{ + #ifndef LTC_TEST + return CRYPT_NOP; + #else + static const struct { + char *msg; + unsigned char hash[16]; + } tests[] = { + { "", + { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, + 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, + { "a", + {0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, + 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, + { "abc", + { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, + 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, + { "message digest", + { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, + 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, + { "abcdefghijklmnopqrstuvwxyz", + { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, + 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, + { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, + 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, + { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", + { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, + 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, + { NULL, { 0 } } + }; + + int i; + unsigned char tmp[16]; + hash_state md; + + for (i = 0; tests[i].msg != NULL; i++) { + md5_init(&md); + md5_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg)); + md5_done(&md, tmp); + if (XMEMCMP(tmp, tests[i].hash, 16) != 0) { + return CRYPT_FAIL_TESTVECTOR; + } + } + return CRYPT_OK; + #endif +} + +#endif + + + +/* $Source: /cvs/libtom/libtomcrypt/src/hashes/md5.c,v $ */ +/* $Revision: 1.10 $ */ +/* $Date: 2007/05/12 14:25:28 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/hashes/sha1.c b/dep/StormLib/src/libtomcrypt/src/hashes/sha1.c new file mode 100644 index 000000000..409d09542 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/hashes/sha1.c @@ -0,0 +1,288 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file sha1.c + LTC_SHA1 code by Tom St Denis +*/ + + +#ifdef LTC_SHA1 + +const struct ltc_hash_descriptor sha1_desc = +{ + "sha1", + 2, + 20, + 64, + + /* OID */ + { 1, 3, 14, 3, 2, 26, }, + 6, + + &sha1_init, + &sha1_process, + &sha1_done, + &sha1_test, + NULL +}; + +#define F0(x,y,z) (z ^ (x & (y ^ z))) +#define F1(x,y,z) (x ^ y ^ z) +#define F2(x,y,z) ((x & y) | (z & (x | y))) +#define F3(x,y,z) (x ^ y ^ z) + +#ifdef LTC_CLEAN_STACK +static int _sha1_compress(hash_state *md, unsigned char *buf) +#else +static int sha1_compress(hash_state *md, unsigned char *buf) +#endif +{ + ulong32 a,b,c,d,e,W[80],i; +#ifdef LTC_SMALL_CODE + ulong32 t; +#endif + + /* copy the state into 512-bits into W[0..15] */ + for (i = 0; i < 16; i++) { + LOAD32H(W[i], buf + (4*i)); + } + + /* copy state */ + a = md->sha1.state[0]; + b = md->sha1.state[1]; + c = md->sha1.state[2]; + d = md->sha1.state[3]; + e = md->sha1.state[4]; + + /* expand it */ + for (i = 16; i < 80; i++) { + W[i] = ROL(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1); + } + + /* compress */ + /* round one */ + #define FF0(a,b,c,d,e,i) e = (ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = ROLc(b, 30); + #define FF1(a,b,c,d,e,i) e = (ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = ROLc(b, 30); + #define FF2(a,b,c,d,e,i) e = (ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = ROLc(b, 30); + #define FF3(a,b,c,d,e,i) e = (ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = ROLc(b, 30); + +#ifdef LTC_SMALL_CODE + + for (i = 0; i < 20; ) { + FF0(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; + } + + for (; i < 40; ) { + FF1(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; + } + + for (; i < 60; ) { + FF2(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; + } + + for (; i < 80; ) { + FF3(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; + } + +#else + + for (i = 0; i < 20; ) { + FF0(a,b,c,d,e,i++); + FF0(e,a,b,c,d,i++); + FF0(d,e,a,b,c,i++); + FF0(c,d,e,a,b,i++); + FF0(b,c,d,e,a,i++); + } + + /* round two */ + for (; i < 40; ) { + FF1(a,b,c,d,e,i++); + FF1(e,a,b,c,d,i++); + FF1(d,e,a,b,c,i++); + FF1(c,d,e,a,b,i++); + FF1(b,c,d,e,a,i++); + } + + /* round three */ + for (; i < 60; ) { + FF2(a,b,c,d,e,i++); + FF2(e,a,b,c,d,i++); + FF2(d,e,a,b,c,i++); + FF2(c,d,e,a,b,i++); + FF2(b,c,d,e,a,i++); + } + + /* round four */ + for (; i < 80; ) { + FF3(a,b,c,d,e,i++); + FF3(e,a,b,c,d,i++); + FF3(d,e,a,b,c,i++); + FF3(c,d,e,a,b,i++); + FF3(b,c,d,e,a,i++); + } +#endif + + #undef FF0 + #undef FF1 + #undef FF2 + #undef FF3 + + /* store */ + md->sha1.state[0] = md->sha1.state[0] + a; + md->sha1.state[1] = md->sha1.state[1] + b; + md->sha1.state[2] = md->sha1.state[2] + c; + md->sha1.state[3] = md->sha1.state[3] + d; + md->sha1.state[4] = md->sha1.state[4] + e; + + return CRYPT_OK; +} + +#ifdef LTC_CLEAN_STACK +static int sha1_compress(hash_state *md, unsigned char *buf) +{ + int err; + err = _sha1_compress(md, buf); + burn_stack(sizeof(ulong32) * 87); + return err; +} +#endif + +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ +int sha1_init(hash_state * md) +{ + LTC_ARGCHK(md != NULL); + md->sha1.state[0] = 0x67452301UL; + md->sha1.state[1] = 0xefcdab89UL; + md->sha1.state[2] = 0x98badcfeUL; + md->sha1.state[3] = 0x10325476UL; + md->sha1.state[4] = 0xc3d2e1f0UL; + md->sha1.curlen = 0; + md->sha1.length = 0; + return CRYPT_OK; +} + +/** + Process a block of memory though the hash + @param md The hash state + @param in The data to hash + @param inlen The length of the data (octets) + @return CRYPT_OK if successful +*/ +HASH_PROCESS(sha1_process, sha1_compress, sha1, 64) + +/** + Terminate the hash to get the digest + @param md The hash state + @param out [out] The destination of the hash (20 bytes) + @return CRYPT_OK if successful +*/ +int sha1_done(hash_state * md, unsigned char *out) +{ + int i; + + LTC_ARGCHK(md != NULL); + LTC_ARGCHK(out != NULL); + + if (md->sha1.curlen >= sizeof(md->sha1.buf)) { + return CRYPT_INVALID_ARG; + } + + /* increase the length of the message */ + md->sha1.length += md->sha1.curlen * 8; + + /* append the '1' bit */ + md->sha1.buf[md->sha1.curlen++] = (unsigned char)0x80; + + /* if the length is currently above 56 bytes we append zeros + * then compress. Then we can fall back to padding zeros and length + * encoding like normal. + */ + if (md->sha1.curlen > 56) { + while (md->sha1.curlen < 64) { + md->sha1.buf[md->sha1.curlen++] = (unsigned char)0; + } + sha1_compress(md, md->sha1.buf); + md->sha1.curlen = 0; + } + + /* pad upto 56 bytes of zeroes */ + while (md->sha1.curlen < 56) { + md->sha1.buf[md->sha1.curlen++] = (unsigned char)0; + } + + /* store length */ + STORE64H(md->sha1.length, md->sha1.buf+56); + sha1_compress(md, md->sha1.buf); + + /* copy output */ + for (i = 0; i < 5; i++) { + STORE32H(md->sha1.state[i], out+(4*i)); + } +#ifdef LTC_CLEAN_STACK + zeromem(md, sizeof(hash_state)); +#endif + return CRYPT_OK; +} + +/** + Self-test the hash + @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled +*/ +int sha1_test(void) +{ + #ifndef LTC_TEST + return CRYPT_NOP; + #else + static const struct { + char *msg; + unsigned char hash[20]; + } tests[] = { + { "abc", + { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, + 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, + 0x9c, 0xd0, 0xd8, 0x9d } + }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, + 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, + 0xE5, 0x46, 0x70, 0xF1 } + } + }; + + int i; + unsigned char tmp[20]; + hash_state md; + + for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { + sha1_init(&md); + sha1_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); + sha1_done(&md, tmp); + if (XMEMCMP(tmp, tests[i].hash, 20) != 0) { + return CRYPT_FAIL_TESTVECTOR; + } + } + return CRYPT_OK; + #endif +} + +#endif + + + +/* $Source: /cvs/libtom/libtomcrypt/src/hashes/sha1.c,v $ */ +/* $Revision: 1.10 $ */ +/* $Date: 2007/05/12 14:25:28 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt.h new file mode 100644 index 000000000..74cdff475 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt.h @@ -0,0 +1,87 @@ +#ifndef TOMCRYPT_H_ +#define TOMCRYPT_H_ +#include +#include +#include +#include +#include +#include +#include + +/* use configuration data */ +#include "tomcrypt_custom.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* version */ +#define CRYPT 0x0117 +#define SCRYPT "1.17" + +/* max size of either a cipher/hash block or symmetric key [largest of the two] */ +#define MAXBLOCKSIZE 128 + +/* descriptor table size */ +#define TAB_SIZE 32 + +/* error codes [will be expanded in future releases] */ +enum { + CRYPT_OK=0, /* Result OK */ + CRYPT_ERROR, /* Generic Error */ + CRYPT_NOP, /* Not a failure but no operation was performed */ + + CRYPT_INVALID_KEYSIZE, /* Invalid key size given */ + CRYPT_INVALID_ROUNDS, /* Invalid number of rounds */ + CRYPT_FAIL_TESTVECTOR, /* Algorithm failed test vectors */ + + CRYPT_BUFFER_OVERFLOW, /* Not enough space for output */ + CRYPT_INVALID_PACKET, /* Invalid input packet given */ + + CRYPT_INVALID_PRNGSIZE, /* Invalid number of bits for a PRNG */ + CRYPT_ERROR_READPRNG, /* Could not read enough from PRNG */ + + CRYPT_INVALID_CIPHER, /* Invalid cipher specified */ + CRYPT_INVALID_HASH, /* Invalid hash specified */ + CRYPT_INVALID_PRNG, /* Invalid PRNG specified */ + + CRYPT_MEM, /* Out of memory */ + + CRYPT_PK_TYPE_MISMATCH, /* Not equivalent types of PK keys */ + CRYPT_PK_NOT_PRIVATE, /* Requires a private PK key */ + + CRYPT_INVALID_ARG, /* Generic invalid argument */ + CRYPT_FILE_NOTFOUND, /* File Not Found */ + + CRYPT_PK_INVALID_TYPE, /* Invalid type of PK key */ + CRYPT_PK_INVALID_SYSTEM,/* Invalid PK system specified */ + CRYPT_PK_DUP, /* Duplicate key already in key ring */ + CRYPT_PK_NOT_FOUND, /* Key not found in keyring */ + CRYPT_PK_INVALID_SIZE, /* Invalid size input for PK parameters */ + + CRYPT_INVALID_PRIME_SIZE,/* Invalid size of prime requested */ + CRYPT_PK_INVALID_PADDING /* Invalid padding on input */ +}; + +#include "tomcrypt_cfg.h" +#include "tomcrypt_macros.h" +#include "tomcrypt_cipher.h" +#include "tomcrypt_hash.h" +#include "tomcrypt_mac.h" +#include "tomcrypt_prng.h" +#include "tomcrypt_pk.h" +#include "tomcrypt_math.h" +#include "tomcrypt_misc.h" +#include "tomcrypt_argchk.h" +#include "tomcrypt_pkcs.h" + +#ifdef __cplusplus + } +#endif + +#endif /* TOMCRYPT_H_ */ + + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt.h,v $ */ +/* $Revision: 1.21 $ */ +/* $Date: 2006/12/16 19:34:05 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_argchk.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_argchk.h new file mode 100644 index 000000000..cfc93ad7e --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_argchk.h @@ -0,0 +1,38 @@ +/* Defines the LTC_ARGCHK macro used within the library */ +/* ARGTYPE is defined in mycrypt_cfg.h */ +#if ARGTYPE == 0 + +#include + +/* this is the default LibTomCrypt macro */ +void crypt_argchk(char *v, char *s, int d); +#define LTC_ARGCHK(x) if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } +#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) + +#elif ARGTYPE == 1 + +/* fatal type of error */ +#define LTC_ARGCHK(x) assert((x)) +#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) + +#elif ARGTYPE == 2 + +#define LTC_ARGCHK(x) if (!(x)) { fprintf(stderr, "\nwarning: ARGCHK failed at %s:%d\n", __FILE__, __LINE__); } +#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) + +#elif ARGTYPE == 3 + +#define LTC_ARGCHK(x) +#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) + +#elif ARGTYPE == 4 + +#define LTC_ARGCHK(x) if (!(x)) return CRYPT_INVALID_ARG; +#define LTC_ARGCHKVD(x) if (!(x)) return; + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_argchk.h,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/08/27 20:50:21 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_cfg.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_cfg.h new file mode 100644 index 000000000..7feae6e8b --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_cfg.h @@ -0,0 +1,136 @@ +/* This is the build config file. + * + * With this you can setup what to inlcude/exclude automatically during any build. Just comment + * out the line that #define's the word for the thing you want to remove. phew! + */ + +#ifndef TOMCRYPT_CFG_H +#define TOMCRYPT_CFG_H + +#if defined(_WIN32) || defined(_MSC_VER) +#define LTC_CALL __cdecl +#else +#ifndef LTC_CALL + #define LTC_CALL +#endif +#endif + +#ifndef LTC_EXPORT +#define LTC_EXPORT +#endif + +/* certain platforms use macros for these, making the prototypes broken */ +#ifndef LTC_NO_PROTOTYPES + +/* you can change how memory allocation works ... */ +LTC_EXPORT void * LTC_CALL XMALLOC(size_t n); +LTC_EXPORT void * LTC_CALL XREALLOC(void *p, size_t n); +LTC_EXPORT void * LTC_CALL XCALLOC(size_t n, size_t s); +LTC_EXPORT void LTC_CALL XFREE(void *p); + +LTC_EXPORT void LTC_CALL XQSORT(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); + + +/* change the clock function too */ +LTC_EXPORT clock_t LTC_CALL XCLOCK(void); + +/* various other functions */ +LTC_EXPORT void * LTC_CALL XMEMCPY(void *dest, const void *src, size_t n); +LTC_EXPORT int LTC_CALL XMEMCMP(const void *s1, const void *s2, size_t n); +LTC_EXPORT void * LTC_CALL XMEMSET(void *s, int c, size_t n); + +LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2); + +#endif + +/* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */ +#ifndef ARGTYPE + #define ARGTYPE 0 +#endif + +/* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code + * + * Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes. + * The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST** + * use the portable [slower] macros. + */ + +/* detect x86-32 machines somewhat */ +#if !defined(__STRICT_ANSI__) && (defined(INTEL_CC) || (defined(_MSC_VER) && defined(WIN32)) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__)))) + #define ENDIAN_LITTLE + #define ENDIAN_32BITWORD + #define LTC_FAST + #define LTC_FAST_TYPE unsigned long +#endif + +/* detects MIPS R5900 processors (PS2) */ +#if (defined(__R5900) || defined(R5900) || defined(__R5900__)) && (defined(_mips) || defined(__mips__) || defined(mips)) + #define ENDIAN_LITTLE + #define ENDIAN_64BITWORD +#endif + +/* detect amd64 */ +#if !defined(__STRICT_ANSI__) && defined(__x86_64__) + #define ENDIAN_LITTLE + #define ENDIAN_64BITWORD + #define LTC_FAST + #define LTC_FAST_TYPE unsigned long +#endif + +/* detect PPC32 */ +#if !defined(__STRICT_ANSI__) && defined(LTC_PPC32) + #define ENDIAN_BIG + #define ENDIAN_32BITWORD + #define LTC_FAST + #define LTC_FAST_TYPE unsigned long +#endif + +/* detect sparc and sparc64 */ +#if defined(__sparc__) + #define ENDIAN_BIG + #if defined(__arch64__) + #define ENDIAN_64BITWORD + #else + #define ENDIAN_32BITWORD + #endif +#endif + + +#ifdef LTC_NO_FAST + #ifdef LTC_FAST + #undef LTC_FAST + #endif +#endif + +/* No asm is a quick way to disable anything "not portable" */ +#ifdef LTC_NO_ASM + #undef ENDIAN_LITTLE + #undef ENDIAN_BIG + #undef ENDIAN_32BITWORD + #undef ENDIAN_64BITWORD + #undef LTC_FAST + #undef LTC_FAST_TYPE + #define LTC_NO_ROLC + #define LTC_NO_BSWAP +#endif + +/* #define ENDIAN_LITTLE */ +/* #define ENDIAN_BIG */ + +/* #define ENDIAN_32BITWORD */ +/* #define ENDIAN_64BITWORD */ + +#if (defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) && !(defined(ENDIAN_32BITWORD) || defined(ENDIAN_64BITWORD)) + #error You must specify a word size as well as endianess in tomcrypt_cfg.h +#endif + +#if !(defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) + #define ENDIAN_NEUTRAL +#endif + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cfg.h,v $ */ +/* $Revision: 1.19 $ */ +/* $Date: 2006/12/04 02:19:48 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_cipher.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_cipher.h new file mode 100644 index 000000000..bd740bf4a --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_cipher.h @@ -0,0 +1,891 @@ +/* ---- SYMMETRIC KEY STUFF ----- + * + * We put each of the ciphers scheduled keys in their own structs then we put all of + * the key formats in one union. This makes the function prototypes easier to use. + */ +#ifdef LTC_BLOWFISH +struct blowfish_key { + ulong32 S[4][256]; + ulong32 K[18]; +}; +#endif + +#ifdef LTC_RC5 +struct rc5_key { + int rounds; + ulong32 K[50]; +}; +#endif + +#ifdef LTC_RC6 +struct rc6_key { + ulong32 K[44]; +}; +#endif + +#ifdef LTC_SAFERP +struct saferp_key { + unsigned char K[33][16]; + long rounds; +}; +#endif + +#ifdef LTC_RIJNDAEL +struct rijndael_key { + ulong32 eK[60], dK[60]; + int Nr; +}; +#endif + +#ifdef LTC_KSEED +struct kseed_key { + ulong32 K[32], dK[32]; +}; +#endif + +#ifdef LTC_KASUMI +struct kasumi_key { + ulong32 KLi1[8], KLi2[8], + KOi1[8], KOi2[8], KOi3[8], + KIi1[8], KIi2[8], KIi3[8]; +}; +#endif + +#ifdef LTC_XTEA +struct xtea_key { + unsigned long A[32], B[32]; +}; +#endif + +#ifdef LTC_TWOFISH +#ifndef LTC_TWOFISH_SMALL + struct twofish_key { + ulong32 S[4][256], K[40]; + }; +#else + struct twofish_key { + ulong32 K[40]; + unsigned char S[32], start; + }; +#endif +#endif + +#ifdef LTC_SAFER +#define LTC_SAFER_K64_DEFAULT_NOF_ROUNDS 6 +#define LTC_SAFER_K128_DEFAULT_NOF_ROUNDS 10 +#define LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS 8 +#define LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS 10 +#define LTC_SAFER_MAX_NOF_ROUNDS 13 +#define LTC_SAFER_BLOCK_LEN 8 +#define LTC_SAFER_KEY_LEN (1 + LTC_SAFER_BLOCK_LEN * (1 + 2 * LTC_SAFER_MAX_NOF_ROUNDS)) +typedef unsigned char safer_block_t[LTC_SAFER_BLOCK_LEN]; +typedef unsigned char safer_key_t[LTC_SAFER_KEY_LEN]; +struct safer_key { safer_key_t key; }; +#endif + +#ifdef LTC_RC2 +struct rc2_key { unsigned xkey[64]; }; +#endif + +#ifdef LTC_DES +struct des_key { + ulong32 ek[32], dk[32]; +}; + +struct des3_key { + ulong32 ek[3][32], dk[3][32]; +}; +#endif + +#ifdef LTC_CAST5 +struct cast5_key { + ulong32 K[32], keylen; +}; +#endif + +#ifdef LTC_NOEKEON +struct noekeon_key { + ulong32 K[4], dK[4]; +}; +#endif + +#ifdef LTC_SKIPJACK +struct skipjack_key { + unsigned char key[10]; +}; +#endif + +#ifdef LTC_KHAZAD +struct khazad_key { + ulong64 roundKeyEnc[8 + 1]; + ulong64 roundKeyDec[8 + 1]; +}; +#endif + +#ifdef LTC_ANUBIS +struct anubis_key { + int keyBits; + int R; + ulong32 roundKeyEnc[18 + 1][4]; + ulong32 roundKeyDec[18 + 1][4]; +}; +#endif + +#ifdef LTC_MULTI2 +struct multi2_key { + int N; + ulong32 uk[8]; +}; +#endif + +typedef union Symmetric_key { +#ifdef LTC_DES + struct des_key des; + struct des3_key des3; +#endif +#ifdef LTC_RC2 + struct rc2_key rc2; +#endif +#ifdef LTC_SAFER + struct safer_key safer; +#endif +#ifdef LTC_TWOFISH + struct twofish_key twofish; +#endif +#ifdef LTC_BLOWFISH + struct blowfish_key blowfish; +#endif +#ifdef LTC_RC5 + struct rc5_key rc5; +#endif +#ifdef LTC_RC6 + struct rc6_key rc6; +#endif +#ifdef LTC_SAFERP + struct saferp_key saferp; +#endif +#ifdef LTC_RIJNDAEL + struct rijndael_key rijndael; +#endif +#ifdef LTC_XTEA + struct xtea_key xtea; +#endif +#ifdef LTC_CAST5 + struct cast5_key cast5; +#endif +#ifdef LTC_NOEKEON + struct noekeon_key noekeon; +#endif +#ifdef LTC_SKIPJACK + struct skipjack_key skipjack; +#endif +#ifdef LTC_KHAZAD + struct khazad_key khazad; +#endif +#ifdef LTC_ANUBIS + struct anubis_key anubis; +#endif +#ifdef LTC_KSEED + struct kseed_key kseed; +#endif +#ifdef LTC_KASUMI + struct kasumi_key kasumi; +#endif +#ifdef LTC_MULTI2 + struct multi2_key multi2; +#endif + void *data; +} symmetric_key; + +#ifdef LTC_ECB_MODE +/** A block cipher ECB structure */ +typedef struct { + /** The index of the cipher chosen */ + int cipher, + /** The block size of the given cipher */ + blocklen; + /** The scheduled key */ + symmetric_key key; +} symmetric_ECB; +#endif + +#ifdef LTC_CFB_MODE +/** A block cipher CFB structure */ +typedef struct { + /** The index of the cipher chosen */ + int cipher, + /** The block size of the given cipher */ + blocklen, + /** The padding offset */ + padlen; + /** The current IV */ + unsigned char IV[MAXBLOCKSIZE], + /** The pad used to encrypt/decrypt */ + pad[MAXBLOCKSIZE]; + /** The scheduled key */ + symmetric_key key; +} symmetric_CFB; +#endif + +#ifdef LTC_OFB_MODE +/** A block cipher OFB structure */ +typedef struct { + /** The index of the cipher chosen */ + int cipher, + /** The block size of the given cipher */ + blocklen, + /** The padding offset */ + padlen; + /** The current IV */ + unsigned char IV[MAXBLOCKSIZE]; + /** The scheduled key */ + symmetric_key key; +} symmetric_OFB; +#endif + +#ifdef LTC_CBC_MODE +/** A block cipher CBC structure */ +typedef struct { + /** The index of the cipher chosen */ + int cipher, + /** The block size of the given cipher */ + blocklen; + /** The current IV */ + unsigned char IV[MAXBLOCKSIZE]; + /** The scheduled key */ + symmetric_key key; +} symmetric_CBC; +#endif + + +#ifdef LTC_CTR_MODE +/** A block cipher CTR structure */ +typedef struct { + /** The index of the cipher chosen */ + int cipher, + /** The block size of the given cipher */ + blocklen, + /** The padding offset */ + padlen, + /** The mode (endianess) of the CTR, 0==little, 1==big */ + mode, + /** counter width */ + ctrlen; + + /** The counter */ + unsigned char ctr[MAXBLOCKSIZE], + /** The pad used to encrypt/decrypt */ + pad[MAXBLOCKSIZE]; + /** The scheduled key */ + symmetric_key key; +} symmetric_CTR; +#endif + + +#ifdef LTC_LRW_MODE +/** A LRW structure */ +typedef struct { + /** The index of the cipher chosen (must be a 128-bit block cipher) */ + int cipher; + + /** The current IV */ + unsigned char IV[16], + + /** the tweak key */ + tweak[16], + + /** The current pad, it's the product of the first 15 bytes against the tweak key */ + pad[16]; + + /** The scheduled symmetric key */ + symmetric_key key; + +#ifdef LRW_TABLES + /** The pre-computed multiplication table */ + unsigned char PC[16][256][16]; +#endif +} symmetric_LRW; +#endif + +#ifdef LTC_F8_MODE +/** A block cipher F8 structure */ +typedef struct { + /** The index of the cipher chosen */ + int cipher, + /** The block size of the given cipher */ + blocklen, + /** The padding offset */ + padlen; + /** The current IV */ + unsigned char IV[MAXBLOCKSIZE], + MIV[MAXBLOCKSIZE]; + /** Current block count */ + ulong32 blockcnt; + /** The scheduled key */ + symmetric_key key; +} symmetric_F8; +#endif + + +/** cipher descriptor table, last entry has "name == NULL" to mark the end of table */ +extern struct ltc_cipher_descriptor { + /** name of cipher */ + char *name; + /** internal ID */ + unsigned char ID; + /** min keysize (octets) */ + int min_key_length, + /** max keysize (octets) */ + max_key_length, + /** block size (octets) */ + block_length, + /** default number of rounds */ + default_rounds; + /** Setup the cipher + @param key The input symmetric key + @param keylen The length of the input key (octets) + @param num_rounds The requested number of rounds (0==default) + @param skey [out] The destination of the scheduled key + @return CRYPT_OK if successful + */ + int (*setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); + /** Encrypt a block + @param pt The plaintext + @param ct [out] The ciphertext + @param skey The scheduled key + @return CRYPT_OK if successful + */ + int (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); + /** Decrypt a block + @param ct The ciphertext + @param pt [out] The plaintext + @param skey The scheduled key + @return CRYPT_OK if successful + */ + int (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); + /** Test the block cipher + @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled + */ + int (*test)(void); + + /** Terminate the context + @param skey The scheduled key + */ + void (*done)(symmetric_key *skey); + + /** Determine a key size + @param keysize [in/out] The size of the key desired and the suggested size + @return CRYPT_OK if successful + */ + int (*keysize)(int *keysize); + +/** Accelerators **/ + /** Accelerated ECB encryption + @param pt Plaintext + @param ct Ciphertext + @param blocks The number of complete blocks to process + @param skey The scheduled key context + @return CRYPT_OK if successful + */ + int (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey); + + /** Accelerated ECB decryption + @param pt Plaintext + @param ct Ciphertext + @param blocks The number of complete blocks to process + @param skey The scheduled key context + @return CRYPT_OK if successful + */ + int (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey); + + /** Accelerated CBC encryption + @param pt Plaintext + @param ct Ciphertext + @param blocks The number of complete blocks to process + @param IV The initial value (input/output) + @param skey The scheduled key context + @return CRYPT_OK if successful + */ + int (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey); + + /** Accelerated CBC decryption + @param pt Plaintext + @param ct Ciphertext + @param blocks The number of complete blocks to process + @param IV The initial value (input/output) + @param skey The scheduled key context + @return CRYPT_OK if successful + */ + int (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey); + + /** Accelerated CTR encryption + @param pt Plaintext + @param ct Ciphertext + @param blocks The number of complete blocks to process + @param IV The initial value (input/output) + @param mode little or big endian counter (mode=0 or mode=1) + @param skey The scheduled key context + @return CRYPT_OK if successful + */ + int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey); + + /** Accelerated LRW + @param pt Plaintext + @param ct Ciphertext + @param blocks The number of complete blocks to process + @param IV The initial value (input/output) + @param tweak The LRW tweak + @param skey The scheduled key context + @return CRYPT_OK if successful + */ + int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey); + + /** Accelerated LRW + @param ct Ciphertext + @param pt Plaintext + @param blocks The number of complete blocks to process + @param IV The initial value (input/output) + @param tweak The LRW tweak + @param skey The scheduled key context + @return CRYPT_OK if successful + */ + int (*accel_lrw_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey); + + /** Accelerated CCM packet (one-shot) + @param key The secret key to use + @param keylen The length of the secret key (octets) + @param uskey A previously scheduled key [optional can be NULL] + @param nonce The session nonce [use once] + @param noncelen The length of the nonce + @param header The header for the session + @param headerlen The length of the header (octets) + @param pt [out] The plaintext + @param ptlen The length of the plaintext (octets) + @param ct [out] The ciphertext + @param tag [out] The destination tag + @param taglen [in/out] The max size and resulting size of the authentication tag + @param direction Encrypt or Decrypt direction (0 or 1) + @return CRYPT_OK if successful + */ + int (*accel_ccm_memory)( + const unsigned char *key, unsigned long keylen, + symmetric_key *uskey, + const unsigned char *nonce, unsigned long noncelen, + const unsigned char *header, unsigned long headerlen, + unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + unsigned char *tag, unsigned long *taglen, + int direction); + + /** Accelerated GCM packet (one shot) + @param key The secret key + @param keylen The length of the secret key + @param IV The initial vector + @param IVlen The length of the initial vector + @param adata The additional authentication data (header) + @param adatalen The length of the adata + @param pt The plaintext + @param ptlen The length of the plaintext (ciphertext length is the same) + @param ct The ciphertext + @param tag [out] The MAC tag + @param taglen [in/out] The MAC tag length + @param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT) + @return CRYPT_OK on success + */ + int (*accel_gcm_memory)( + const unsigned char *key, unsigned long keylen, + const unsigned char *IV, unsigned long IVlen, + const unsigned char *adata, unsigned long adatalen, + unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + unsigned char *tag, unsigned long *taglen, + int direction); + + /** Accelerated one shot LTC_OMAC + @param key The secret key + @param keylen The key length (octets) + @param in The message + @param inlen Length of message (octets) + @param out [out] Destination for tag + @param outlen [in/out] Initial and final size of out + @return CRYPT_OK on success + */ + int (*omac_memory)( + const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); + + /** Accelerated one shot XCBC + @param key The secret key + @param keylen The key length (octets) + @param in The message + @param inlen Length of message (octets) + @param out [out] Destination for tag + @param outlen [in/out] Initial and final size of out + @return CRYPT_OK on success + */ + int (*xcbc_memory)( + const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); + + /** Accelerated one shot F9 + @param key The secret key + @param keylen The key length (octets) + @param in The message + @param inlen Length of message (octets) + @param out [out] Destination for tag + @param outlen [in/out] Initial and final size of out + @return CRYPT_OK on success + @remark Requires manual padding + */ + int (*f9_memory)( + const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +} cipher_descriptor[]; + +#ifdef LTC_BLOWFISH +int blowfish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int blowfish_test(void); +void blowfish_done(symmetric_key *skey); +int blowfish_keysize(int *keysize); +extern const struct ltc_cipher_descriptor blowfish_desc; +#endif + +#ifdef LTC_RC5 +int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int rc5_test(void); +void rc5_done(symmetric_key *skey); +int rc5_keysize(int *keysize); +extern const struct ltc_cipher_descriptor rc5_desc; +#endif + +#ifdef LTC_RC6 +int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int rc6_test(void); +void rc6_done(symmetric_key *skey); +int rc6_keysize(int *keysize); +extern const struct ltc_cipher_descriptor rc6_desc; +#endif + +#ifdef LTC_RC2 +int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int rc2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int rc2_test(void); +void rc2_done(symmetric_key *skey); +int rc2_keysize(int *keysize); +extern const struct ltc_cipher_descriptor rc2_desc; +#endif + +#ifdef LTC_SAFERP +int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int saferp_test(void); +void saferp_done(symmetric_key *skey); +int saferp_keysize(int *keysize); +extern const struct ltc_cipher_descriptor saferp_desc; +#endif + +#ifdef LTC_SAFER +int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int safer_sk64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int safer_k128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int safer_sk128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int safer_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key); +int safer_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key); +int safer_k64_test(void); +int safer_sk64_test(void); +int safer_sk128_test(void); +void safer_done(symmetric_key *skey); +int safer_64_keysize(int *keysize); +int safer_128_keysize(int *keysize); +extern const struct ltc_cipher_descriptor safer_k64_desc, safer_k128_desc, safer_sk64_desc, safer_sk128_desc; +#endif + +#ifdef LTC_RIJNDAEL + +/* make aes an alias */ +#define aes_setup rijndael_setup +#define aes_ecb_encrypt rijndael_ecb_encrypt +#define aes_ecb_decrypt rijndael_ecb_decrypt +#define aes_test rijndael_test +#define aes_done rijndael_done +#define aes_keysize rijndael_keysize + +#define aes_enc_setup rijndael_enc_setup +#define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt +#define aes_enc_keysize rijndael_enc_keysize + +int rijndael_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int rijndael_test(void); +void rijndael_done(symmetric_key *skey); +int rijndael_keysize(int *keysize); +int rijndael_enc_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int rijndael_enc_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +void rijndael_enc_done(symmetric_key *skey); +int rijndael_enc_keysize(int *keysize); +extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc; +extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc; +#endif + +#ifdef LTC_XTEA +int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int xtea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int xtea_test(void); +void xtea_done(symmetric_key *skey); +int xtea_keysize(int *keysize); +extern const struct ltc_cipher_descriptor xtea_desc; +#endif + +#ifdef LTC_TWOFISH +int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int twofish_test(void); +void twofish_done(symmetric_key *skey); +int twofish_keysize(int *keysize); +extern const struct ltc_cipher_descriptor twofish_desc; +#endif + +#ifdef LTC_DES +int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int des_test(void); +void des_done(symmetric_key *skey); +int des_keysize(int *keysize); +int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int des3_test(void); +void des3_done(symmetric_key *skey); +int des3_keysize(int *keysize); +extern const struct ltc_cipher_descriptor des_desc, des3_desc; +#endif + +#ifdef LTC_CAST5 +int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int cast5_test(void); +void cast5_done(symmetric_key *skey); +int cast5_keysize(int *keysize); +extern const struct ltc_cipher_descriptor cast5_desc; +#endif + +#ifdef LTC_NOEKEON +int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int noekeon_test(void); +void noekeon_done(symmetric_key *skey); +int noekeon_keysize(int *keysize); +extern const struct ltc_cipher_descriptor noekeon_desc; +#endif + +#ifdef LTC_SKIPJACK +int skipjack_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int skipjack_test(void); +void skipjack_done(symmetric_key *skey); +int skipjack_keysize(int *keysize); +extern const struct ltc_cipher_descriptor skipjack_desc; +#endif + +#ifdef LTC_KHAZAD +int khazad_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int khazad_test(void); +void khazad_done(symmetric_key *skey); +int khazad_keysize(int *keysize); +extern const struct ltc_cipher_descriptor khazad_desc; +#endif + +#ifdef LTC_ANUBIS +int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int anubis_test(void); +void anubis_done(symmetric_key *skey); +int anubis_keysize(int *keysize); +extern const struct ltc_cipher_descriptor anubis_desc; +#endif + +#ifdef LTC_KSEED +int kseed_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int kseed_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int kseed_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int kseed_test(void); +void kseed_done(symmetric_key *skey); +int kseed_keysize(int *keysize); +extern const struct ltc_cipher_descriptor kseed_desc; +#endif + +#ifdef LTC_KASUMI +int kasumi_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int kasumi_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int kasumi_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int kasumi_test(void); +void kasumi_done(symmetric_key *skey); +int kasumi_keysize(int *keysize); +extern const struct ltc_cipher_descriptor kasumi_desc; +#endif + + +#ifdef LTC_MULTI2 +int multi2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); +int multi2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); +int multi2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); +int multi2_test(void); +void multi2_done(symmetric_key *skey); +int multi2_keysize(int *keysize); +extern const struct ltc_cipher_descriptor multi2_desc; +#endif + +#ifdef LTC_ECB_MODE +int ecb_start(int cipher, const unsigned char *key, + int keylen, int num_rounds, symmetric_ECB *ecb); +int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb); +int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb); +int ecb_done(symmetric_ECB *ecb); +#endif + +#ifdef LTC_CFB_MODE +int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key, + int keylen, int num_rounds, symmetric_CFB *cfb); +int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb); +int cfb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CFB *cfb); +int cfb_getiv(unsigned char *IV, unsigned long *len, symmetric_CFB *cfb); +int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb); +int cfb_done(symmetric_CFB *cfb); +#endif + +#ifdef LTC_OFB_MODE +int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key, + int keylen, int num_rounds, symmetric_OFB *ofb); +int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb); +int ofb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_OFB *ofb); +int ofb_getiv(unsigned char *IV, unsigned long *len, symmetric_OFB *ofb); +int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb); +int ofb_done(symmetric_OFB *ofb); +#endif + +#ifdef LTC_CBC_MODE +int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key, + int keylen, int num_rounds, symmetric_CBC *cbc); +int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CBC *cbc); +int cbc_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CBC *cbc); +int cbc_getiv(unsigned char *IV, unsigned long *len, symmetric_CBC *cbc); +int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc); +int cbc_done(symmetric_CBC *cbc); +#endif + +#ifdef LTC_CTR_MODE + +#define CTR_COUNTER_LITTLE_ENDIAN 0x0000 +#define CTR_COUNTER_BIG_ENDIAN 0x1000 +#define LTC_CTR_RFC3686 0x2000 + +int ctr_start( int cipher, + const unsigned char *IV, + const unsigned char *key, int keylen, + int num_rounds, int ctr_mode, + symmetric_CTR *ctr); +int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr); +int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr); +int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr); +int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr); +int ctr_done(symmetric_CTR *ctr); +int ctr_test(void); +#endif + +#ifdef LTC_LRW_MODE + +#define LRW_ENCRYPT 0 +#define LRW_DECRYPT 1 + +int lrw_start( int cipher, + const unsigned char *IV, + const unsigned char *key, int keylen, + const unsigned char *tweak, + int num_rounds, + symmetric_LRW *lrw); +int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw); +int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw); +int lrw_getiv(unsigned char *IV, unsigned long *len, symmetric_LRW *lrw); +int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw); +int lrw_done(symmetric_LRW *lrw); +int lrw_test(void); + +/* don't call */ +int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw); +#endif + +#ifdef LTC_F8_MODE +int f8_start( int cipher, const unsigned char *IV, + const unsigned char *key, int keylen, + const unsigned char *salt_key, int skeylen, + int num_rounds, symmetric_F8 *f8); +int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_F8 *f8); +int f8_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_F8 *f8); +int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8); +int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8); +int f8_done(symmetric_F8 *f8); +int f8_test_mode(void); +#endif + +#ifdef LTC_XTS_MODE +typedef struct { + symmetric_key key1, key2; + int cipher; +} symmetric_xts; + +int xts_start( int cipher, + const unsigned char *key1, + const unsigned char *key2, + unsigned long keylen, + int num_rounds, + symmetric_xts *xts); + +int xts_encrypt( + const unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + const unsigned char *tweak, + symmetric_xts *xts); +int xts_decrypt( + const unsigned char *ct, unsigned long ptlen, + unsigned char *pt, + const unsigned char *tweak, + symmetric_xts *xts); + +void xts_done(symmetric_xts *xts); +int xts_test(void); +void xts_mult_x(unsigned char *I); +#endif + +int find_cipher(const char *name); +int find_cipher_any(const char *name, int blocklen, int keylen); +int find_cipher_id(unsigned char ID); +int register_cipher(const struct ltc_cipher_descriptor *cipher); +int unregister_cipher(const struct ltc_cipher_descriptor *cipher); +int cipher_is_valid(int idx); + +LTC_MUTEX_PROTO(ltc_cipher_mutex) + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cipher.h,v $ */ +/* $Revision: 1.54 $ */ +/* $Date: 2007/05/12 14:37:41 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_custom.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_custom.h new file mode 100644 index 000000000..88ec8f984 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_custom.h @@ -0,0 +1,424 @@ +#ifndef TOMCRYPT_CUSTOM_H_ +#define TOMCRYPT_CUSTOM_H_ + +#define LTC_NO_CIPHERS +#define LTC_NO_HASHES +#define LTC_NO_MACS +#define LTC_NO_PRNGS +#define LTC_NO_CURVES +#define LTC_NO_MODES +#define LTC_NO_PKCS +#define LTC_NO_ROLC + +#define LTC_SOURCE +#define LTC_SHA1 +#define LTC_MD5 +#define LTC_DER +#define LTC_RC4 + +#define USE_LTM +#define LTM_DESC + +/* macros for various libc functions you can change for embedded targets */ +#ifndef XMALLOC + #ifdef malloc + #define LTC_NO_PROTOTYPES + #endif +#define XMALLOC LibTomMalloc +#endif +#ifndef XREALLOC + #ifdef realloc + #define LTC_NO_PROTOTYPES + #endif +#define XREALLOC LibTomRealloc +#endif +#ifndef XCALLOC + #ifdef calloc + #define LTC_NO_PROTOTYPES + #endif +#define XCALLOC LibTomCalloc +#endif +#ifndef XFREE + #ifdef free + #define LTC_NO_PROTOTYPES + #endif +#define XFREE LibTomFree +#endif + +#ifndef XMEMSET + #ifdef memset + #define LTC_NO_PROTOTYPES + #endif +#define XMEMSET memset +#endif +#ifndef XMEMCPY + #ifdef memcpy + #define LTC_NO_PROTOTYPES + #endif +#define XMEMCPY memcpy +#endif +#ifndef XMEMCMP + #ifdef memcmp + #define LTC_NO_PROTOTYPES + #endif +#define XMEMCMP memcmp +#endif +#ifndef XSTRCMP + #ifdef strcmp + #define LTC_NO_PROTOTYPES + #endif +#define XSTRCMP strcmp +#endif + +#ifndef XCLOCK +#define XCLOCK LibTomClock +#endif +#ifndef XCLOCKS_PER_SEC +#define XCLOCKS_PER_SEC CLOCKS_PER_SEC +#endif + +#ifndef XQSORT + #ifdef qsort + #define LTC_NO_PROTOTYPES + #endif +#define XQSORT LibTomQsort +#endif + +/* Easy button? */ +#ifdef LTC_EASY + #define LTC_NO_CIPHERS + #define LTC_RIJNDAEL + #define LTC_BLOWFISH + #define LTC_DES + #define LTC_CAST5 + + #define LTC_NO_MODES + #define LTC_ECB_MODE + #define LTC_CBC_MODE + #define LTC_CTR_MODE + + #define LTC_NO_HASHES + #define LTC_SHA1 + #define LTC_SHA512 + #define LTC_SHA384 + #define LTC_SHA256 + #define LTC_SHA224 + + #define LTC_NO_MACS + #define LTC_HMAC + #define LTC_OMAC + #define LTC_CCM_MODE + + #define LTC_NO_PRNGS + #define LTC_SPRNG + #define LTC_YARROW + #define LTC_DEVRANDOM + #define TRY_URANDOM_FIRST + + #define LTC_NO_PK + #define LTC_MRSA + #define LTC_MECC +#endif + +/* Use small code where possible */ +/* #define LTC_SMALL_CODE */ + +/* Enable self-test test vector checking */ +#ifndef LTC_NO_TEST + #define LTC_TEST +#endif + +/* clean the stack of functions which put private information on stack */ +/* #define LTC_CLEAN_STACK */ + +/* disable all file related functions */ +/* #define LTC_NO_FILE */ + +/* disable all forms of ASM */ +/* #define LTC_NO_ASM */ + +/* disable FAST mode */ +/* #define LTC_NO_FAST */ + +/* disable BSWAP on x86 */ +/* #define LTC_NO_BSWAP */ + +/* ---> Symmetric Block Ciphers <--- */ +#ifndef LTC_NO_CIPHERS + +#define LTC_BLOWFISH +#define LTC_RC2 +#define LTC_RC5 +#define LTC_RC6 +#define LTC_SAFERP +#define LTC_RIJNDAEL +#define LTC_XTEA +/* _TABLES tells it to use tables during setup, _SMALL means to use the smaller scheduled key format + * (saves 4KB of ram), _ALL_TABLES enables all tables during setup */ +#define LTC_TWOFISH +#ifndef LTC_NO_TABLES + #define LTC_TWOFISH_TABLES + /* #define LTC_TWOFISH_ALL_TABLES */ +#else + #define LTC_TWOFISH_SMALL +#endif +/* #define LTC_TWOFISH_SMALL */ +/* LTC_DES includes EDE triple-LTC_DES */ +#define LTC_DES +#define LTC_CAST5 +#define LTC_NOEKEON +#define LTC_SKIPJACK +#define LTC_SAFER +#define LTC_KHAZAD +#define LTC_ANUBIS +#define LTC_ANUBIS_TWEAK +#define LTC_KSEED +#define LTC_KASUMI + +#endif /* LTC_NO_CIPHERS */ + + +/* ---> Block Cipher Modes of Operation <--- */ +#ifndef LTC_NO_MODES + +#define LTC_CFB_MODE +#define LTC_OFB_MODE +#define LTC_ECB_MODE +#define LTC_CBC_MODE +#define LTC_CTR_MODE + +/* F8 chaining mode */ +#define LTC_F8_MODE + +/* LRW mode */ +#define LTC_LRW_MODE +#ifndef LTC_NO_TABLES + /* like GCM mode this will enable 16 8x128 tables [64KB] that make + * seeking very fast. + */ + #define LRW_TABLES +#endif + +/* XTS mode */ +#define LTC_XTS_MODE + +#endif /* LTC_NO_MODES */ + +/* ---> One-Way Hash Functions <--- */ +#ifndef LTC_NO_HASHES + +#define LTC_CHC_HASH +#define LTC_WHIRLPOOL +#define LTC_SHA512 +#define LTC_SHA384 +#define LTC_SHA256 +#define LTC_SHA224 +#define LTC_TIGER +#define LTC_SHA1 +#define LTC_MD5 +#define LTC_MD4 +#define LTC_MD2 +#define LTC_RIPEMD128 +#define LTC_RIPEMD160 +#define LTC_RIPEMD256 +#define LTC_RIPEMD320 + +#endif /* LTC_NO_HASHES */ + +/* ---> MAC functions <--- */ +#ifndef LTC_NO_MACS + +#define LTC_HMAC +#define LTC_OMAC +#define LTC_PMAC +#define LTC_XCBC +#define LTC_F9_MODE +#define LTC_PELICAN + +#if defined(LTC_PELICAN) && !defined(LTC_RIJNDAEL) + #error Pelican-MAC requires LTC_RIJNDAEL +#endif + +/* ---> Encrypt + Authenticate Modes <--- */ + +#define LTC_EAX_MODE +#if defined(LTC_EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(LTC_OMAC)) + #error LTC_EAX_MODE requires CTR and LTC_OMAC mode +#endif + +#define LTC_OCB_MODE +#define LTC_CCM_MODE +#define LTC_GCM_MODE + +/* Use 64KiB tables */ +#ifndef LTC_NO_TABLES + #define LTC_GCM_TABLES +#endif + +/* USE SSE2? requires GCC works on x86_32 and x86_64*/ +#ifdef LTC_GCM_TABLES +/* #define LTC_GCM_TABLES_SSE2 */ +#endif + +#endif /* LTC_NO_MACS */ + +/* Various tidbits of modern neatoness */ +#define LTC_BASE64 + +/* --> Pseudo Random Number Generators <--- */ +#ifndef LTC_NO_PRNGS + +/* Yarrow */ +#define LTC_YARROW +/* which descriptor of AES to use? */ +/* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */ +#define LTC_YARROW_AES 0 + +#if defined(LTC_YARROW) && !defined(LTC_CTR_MODE) + #error LTC_YARROW requires LTC_CTR_MODE chaining mode to be defined! +#endif + +/* a PRNG that simply reads from an available system source */ +#define LTC_SPRNG + +/* The LTC_RC4 stream cipher */ +#define LTC_RC4 + +/* Fortuna PRNG */ +#define LTC_FORTUNA +/* reseed every N calls to the read function */ +#define LTC_FORTUNA_WD 10 +/* number of pools (4..32) can save a bit of ram by lowering the count */ +#define LTC_FORTUNA_POOLS 32 + +/* Greg's LTC_SOBER128 PRNG ;-0 */ +#define LTC_SOBER128 + +/* the *nix style /dev/random device */ +#define LTC_DEVRANDOM +/* try /dev/urandom before trying /dev/random */ +#define TRY_URANDOM_FIRST + +#endif /* LTC_NO_PRNGS */ + +/* ---> math provider? <--- */ +#ifndef LTC_NO_MATH + +/* LibTomMath */ +#define LTM_LTC_DESC + +/* TomsFastMath */ +//#define TFM_LTC_DESC + +#endif /* LTC_NO_MATH */ + +/* ---> Public Key Crypto <--- */ +#ifndef LTC_NO_PK + +/* Include RSA support */ +#define LTC_MRSA + +/* Include Katja (a Rabin variant like RSA) */ +/* #define MKAT */ + +/* Digital Signature Algorithm */ +#define LTC_MDSA + +/* ECC */ +#define LTC_MECC + +/* use Shamir's trick for point mul (speeds up signature verification) */ +#define LTC_ECC_SHAMIR + +#if defined(TFM_LTC_DESC) && defined(LTC_MECC) + #define LTC_MECC_ACCEL +#endif + +/* do we want fixed point ECC */ +/* #define LTC_MECC_FP */ + +/* Timing Resistant? */ +/* #define LTC_ECC_TIMING_RESISTANT */ + +#endif /* LTC_NO_PK */ + +/* LTC_PKCS #1 (RSA) and #5 (Password Handling) stuff */ +#ifndef LTC_NO_PKCS + +#define LTC_PKCS_1 +#define LTC_PKCS_5 + +/* Include ASN.1 DER (required by DSA/RSA) */ +#define LTC_DER + +#endif /* LTC_NO_PKCS */ + +/* cleanup */ + +#ifdef LTC_MECC +/* Supported ECC Key Sizes */ +#ifndef LTC_NO_CURVES + #define ECC112 + #define ECC128 + #define ECC160 + #define ECC192 + #define ECC224 + #define ECC256 + #define ECC384 + #define ECC521 +#endif +#endif + +#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(MKATJA) + /* Include the MPI functionality? (required by the PK algorithms) */ + #define MPI +#endif + +#ifdef LTC_MRSA + #define LTC_PKCS_1 +#endif + +#if defined(LTC_DER) && !defined(MPI) + #error ASN.1 DER requires MPI functionality +#endif + +#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(MKATJA)) && !defined(LTC_DER) + #error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled +#endif + +/* THREAD management */ +#ifdef LTC_PTHREAD + +#include + +#define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER; +#define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x; +#define LTC_MUTEX_TYPE(x) pthread_mutex_t x; +#define LTC_MUTEX_INIT(x) pthread_mutex_init(x, NULL); +#define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x); +#define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x); + +#else + +/* default no functions */ +#define LTC_MUTEX_GLOBAL(x) +#define LTC_MUTEX_PROTO(x) +#define LTC_MUTEX_TYPE(x) +#define LTC_MUTEX_INIT(x) +#define LTC_MUTEX_LOCK(x) +#define LTC_MUTEX_UNLOCK(x) + +#endif + +/* Debuggers */ + +/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and LTC_RC4 work (see the code) */ +/* #define LTC_VALGRIND */ + +#endif + + + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_custom.h,v $ */ +/* $Revision: 1.73 $ */ +/* $Date: 2007/05/12 14:37:41 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_hash.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_hash.h new file mode 100644 index 000000000..18553ebf9 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_hash.h @@ -0,0 +1,378 @@ +/* ---- HASH FUNCTIONS ---- */ +#ifdef LTC_SHA512 +struct sha512_state { + ulong64 length, state[8]; + unsigned long curlen; + unsigned char buf[128]; +}; +#endif + +#ifdef LTC_SHA256 +struct sha256_state { + ulong64 length; + ulong32 state[8], curlen; + unsigned char buf[64]; +}; +#endif + +#ifdef LTC_SHA1 +struct sha1_state { + ulong64 length; + ulong32 state[5], curlen; + unsigned char buf[64]; +}; +#endif + +#ifdef LTC_MD5 +struct md5_state { + ulong64 length; + ulong32 state[4], curlen; + unsigned char buf[64]; +}; +#endif + +#ifdef LTC_MD4 +struct md4_state { + ulong64 length; + ulong32 state[4], curlen; + unsigned char buf[64]; +}; +#endif + +#ifdef LTC_TIGER +struct tiger_state { + ulong64 state[3], length; + unsigned long curlen; + unsigned char buf[64]; +}; +#endif + +#ifdef LTC_MD2 +struct md2_state { + unsigned char chksum[16], X[48], buf[16]; + unsigned long curlen; +}; +#endif + +#ifdef LTC_RIPEMD128 +struct rmd128_state { + ulong64 length; + unsigned char buf[64]; + ulong32 curlen, state[4]; +}; +#endif + +#ifdef LTC_RIPEMD160 +struct rmd160_state { + ulong64 length; + unsigned char buf[64]; + ulong32 curlen, state[5]; +}; +#endif + +#ifdef LTC_RIPEMD256 +struct rmd256_state { + ulong64 length; + unsigned char buf[64]; + ulong32 curlen, state[8]; +}; +#endif + +#ifdef LTC_RIPEMD320 +struct rmd320_state { + ulong64 length; + unsigned char buf[64]; + ulong32 curlen, state[10]; +}; +#endif + +#ifdef LTC_WHIRLPOOL +struct whirlpool_state { + ulong64 length, state[8]; + unsigned char buf[64]; + ulong32 curlen; +}; +#endif + +#ifdef LTC_CHC_HASH +struct chc_state { + ulong64 length; + unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE]; + ulong32 curlen; +}; +#endif + +typedef union Hash_state { +#ifdef LTC_CHC_HASH + struct chc_state chc; +#endif +#ifdef LTC_WHIRLPOOL + struct whirlpool_state whirlpool; +#endif +#ifdef LTC_SHA512 + struct sha512_state sha512; +#endif +#ifdef LTC_SHA256 + struct sha256_state sha256; +#endif +#ifdef LTC_SHA1 + struct sha1_state sha1; +#endif +#ifdef LTC_MD5 + struct md5_state md5; +#endif +#ifdef LTC_MD4 + struct md4_state md4; +#endif +#ifdef LTC_MD2 + struct md2_state md2; +#endif +#ifdef LTC_TIGER + struct tiger_state tiger; +#endif +#ifdef LTC_RIPEMD128 + struct rmd128_state rmd128; +#endif +#ifdef LTC_RIPEMD160 + struct rmd160_state rmd160; +#endif +#ifdef LTC_RIPEMD256 + struct rmd256_state rmd256; +#endif +#ifdef LTC_RIPEMD320 + struct rmd320_state rmd320; +#endif + void *data; +} hash_state; + +/** hash descriptor */ +extern struct ltc_hash_descriptor { + /** name of hash */ + char *name; + /** internal ID */ + unsigned char ID; + /** Size of digest in octets */ + unsigned long hashsize; + /** Input block size in octets */ + unsigned long blocksize; + /** ASN.1 OID */ + unsigned long OID[16]; + /** Length of DER encoding */ + unsigned long OIDlen; + + /** Init a hash state + @param hash The hash to initialize + @return CRYPT_OK if successful + */ + int (*init)(hash_state *hash); + /** Process a block of data + @param hash The hash state + @param in The data to hash + @param inlen The length of the data (octets) + @return CRYPT_OK if successful + */ + int (*process)(hash_state *hash, const unsigned char *in, unsigned long inlen); + /** Produce the digest and store it + @param hash The hash state + @param out [out] The destination of the digest + @return CRYPT_OK if successful + */ + int (*done)(hash_state *hash, unsigned char *out); + /** Self-test + @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled + */ + int (*test)(void); + + /* accelerated hmac callback: if you need to-do multiple packets just use the generic hmac_memory and provide a hash callback */ + int (*hmac_block)(const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); + +} hash_descriptor[]; + +#ifdef LTC_CHC_HASH +int chc_register(int cipher); +int chc_init(hash_state * md); +int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int chc_done(hash_state * md, unsigned char *hash); +int chc_test(void); +extern const struct ltc_hash_descriptor chc_desc; +#endif + +#ifdef LTC_WHIRLPOOL +int whirlpool_init(hash_state * md); +int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int whirlpool_done(hash_state * md, unsigned char *hash); +int whirlpool_test(void); +extern const struct ltc_hash_descriptor whirlpool_desc; +#endif + +#ifdef LTC_SHA512 +int sha512_init(hash_state * md); +int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int sha512_done(hash_state * md, unsigned char *hash); +int sha512_test(void); +extern const struct ltc_hash_descriptor sha512_desc; +#endif + +#ifdef LTC_SHA384 +#ifndef LTC_SHA512 + #error LTC_SHA512 is required for LTC_SHA384 +#endif +int sha384_init(hash_state * md); +#define sha384_process sha512_process +int sha384_done(hash_state * md, unsigned char *hash); +int sha384_test(void); +extern const struct ltc_hash_descriptor sha384_desc; +#endif + +#ifdef LTC_SHA256 +int sha256_init(hash_state * md); +int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int sha256_done(hash_state * md, unsigned char *hash); +int sha256_test(void); +extern const struct ltc_hash_descriptor sha256_desc; + +#ifdef LTC_SHA224 +#ifndef LTC_SHA256 + #error LTC_SHA256 is required for LTC_SHA224 +#endif +int sha224_init(hash_state * md); +#define sha224_process sha256_process +int sha224_done(hash_state * md, unsigned char *hash); +int sha224_test(void); +extern const struct ltc_hash_descriptor sha224_desc; +#endif +#endif + +#ifdef LTC_SHA1 +int sha1_init(hash_state * md); +int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int sha1_done(hash_state * md, unsigned char *hash); +int sha1_test(void); +extern const struct ltc_hash_descriptor sha1_desc; +#endif + +#ifdef LTC_MD5 +int md5_init(hash_state * md); +int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int md5_done(hash_state * md, unsigned char *hash); +int md5_test(void); +extern const struct ltc_hash_descriptor md5_desc; +#endif + +#ifdef LTC_MD4 +int md4_init(hash_state * md); +int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int md4_done(hash_state * md, unsigned char *hash); +int md4_test(void); +extern const struct ltc_hash_descriptor md4_desc; +#endif + +#ifdef LTC_MD2 +int md2_init(hash_state * md); +int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int md2_done(hash_state * md, unsigned char *hash); +int md2_test(void); +extern const struct ltc_hash_descriptor md2_desc; +#endif + +#ifdef LTC_TIGER +int tiger_init(hash_state * md); +int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int tiger_done(hash_state * md, unsigned char *hash); +int tiger_test(void); +extern const struct ltc_hash_descriptor tiger_desc; +#endif + +#ifdef LTC_RIPEMD128 +int rmd128_init(hash_state * md); +int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int rmd128_done(hash_state * md, unsigned char *hash); +int rmd128_test(void); +extern const struct ltc_hash_descriptor rmd128_desc; +#endif + +#ifdef LTC_RIPEMD160 +int rmd160_init(hash_state * md); +int rmd160_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int rmd160_done(hash_state * md, unsigned char *hash); +int rmd160_test(void); +extern const struct ltc_hash_descriptor rmd160_desc; +#endif + +#ifdef LTC_RIPEMD256 +int rmd256_init(hash_state * md); +int rmd256_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int rmd256_done(hash_state * md, unsigned char *hash); +int rmd256_test(void); +extern const struct ltc_hash_descriptor rmd256_desc; +#endif + +#ifdef LTC_RIPEMD320 +int rmd320_init(hash_state * md); +int rmd320_process(hash_state * md, const unsigned char *in, unsigned long inlen); +int rmd320_done(hash_state * md, unsigned char *hash); +int rmd320_test(void); +extern const struct ltc_hash_descriptor rmd320_desc; +#endif + + +int find_hash(const char *name); +int find_hash_id(unsigned char ID); +int find_hash_oid(const unsigned long *ID, unsigned long IDlen); +int find_hash_any(const char *name, int digestlen); +int register_hash(const struct ltc_hash_descriptor *hash); +int unregister_hash(const struct ltc_hash_descriptor *hash); +int hash_is_valid(int idx); + +LTC_MUTEX_PROTO(ltc_hash_mutex) + +int hash_memory(int hash, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, + const unsigned char *in, unsigned long inlen, ...); +int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outlen); +int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *outlen); + +/* a simple macro for making hash "process" functions */ +#define HASH_PROCESS(func_name, compress_name, state_var, block_size) \ +int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \ +{ \ + unsigned long n; \ + int err; \ + LTC_ARGCHK(md != NULL); \ + LTC_ARGCHK(in != NULL); \ + if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ + return CRYPT_INVALID_ARG; \ + } \ + while (inlen > 0) { \ + if (md-> state_var .curlen == 0 && inlen >= block_size) { \ + if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) { \ + return err; \ + } \ + md-> state_var .length += block_size * 8; \ + in += block_size; \ + inlen -= block_size; \ + } else { \ + n = MIN(inlen, (block_size - md-> state_var .curlen)); \ + memcpy(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \ + md-> state_var .curlen += n; \ + in += n; \ + inlen -= n; \ + if (md-> state_var .curlen == block_size) { \ + if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \ + return err; \ + } \ + md-> state_var .length += 8*block_size; \ + md-> state_var .curlen = 0; \ + } \ + } \ + } \ + return CRYPT_OK; \ +} + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */ +/* $Revision: 1.22 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_mac.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_mac.h new file mode 100644 index 000000000..7ad9516bd --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_mac.h @@ -0,0 +1,384 @@ +#ifdef LTC_HMAC +typedef struct Hmac_state { + hash_state md; + int hash; + hash_state hashstate; + unsigned char *key; +} hmac_state; + +int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned long keylen); +int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen); +int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen); +int hmac_test(void); +int hmac_memory(int hash, + const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int hmac_memory_multi(int hash, + const unsigned char *key, unsigned long keylen, + unsigned char *out, unsigned long *outlen, + const unsigned char *in, unsigned long inlen, ...); +int hmac_file(int hash, const char *fname, const unsigned char *key, + unsigned long keylen, + unsigned char *dst, unsigned long *dstlen); +#endif + +#ifdef LTC_OMAC + +typedef struct { + int cipher_idx, + buflen, + blklen; + unsigned char block[MAXBLOCKSIZE], + prev[MAXBLOCKSIZE], + Lu[2][MAXBLOCKSIZE]; + symmetric_key key; +} omac_state; + +int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned long keylen); +int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen); +int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen); +int omac_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int omac_memory_multi(int cipher, + const unsigned char *key, unsigned long keylen, + unsigned char *out, unsigned long *outlen, + const unsigned char *in, unsigned long inlen, ...); +int omac_file(int cipher, + const unsigned char *key, unsigned long keylen, + const char *filename, + unsigned char *out, unsigned long *outlen); +int omac_test(void); +#endif /* LTC_OMAC */ + +#ifdef LTC_PMAC + +typedef struct { + unsigned char Ls[32][MAXBLOCKSIZE], /* L shifted by i bits to the left */ + Li[MAXBLOCKSIZE], /* value of Li [current value, we calc from previous recall] */ + Lr[MAXBLOCKSIZE], /* L * x^-1 */ + block[MAXBLOCKSIZE], /* currently accumulated block */ + checksum[MAXBLOCKSIZE]; /* current checksum */ + + symmetric_key key; /* scheduled key for cipher */ + unsigned long block_index; /* index # for current block */ + int cipher_idx, /* cipher idx */ + block_len, /* length of block */ + buflen; /* number of bytes in the buffer */ +} pmac_state; + +int pmac_init(pmac_state *pmac, int cipher, const unsigned char *key, unsigned long keylen); +int pmac_process(pmac_state *pmac, const unsigned char *in, unsigned long inlen); +int pmac_done(pmac_state *pmac, unsigned char *out, unsigned long *outlen); + +int pmac_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *msg, unsigned long msglen, + unsigned char *out, unsigned long *outlen); + +int pmac_memory_multi(int cipher, + const unsigned char *key, unsigned long keylen, + unsigned char *out, unsigned long *outlen, + const unsigned char *in, unsigned long inlen, ...); + +int pmac_file(int cipher, + const unsigned char *key, unsigned long keylen, + const char *filename, + unsigned char *out, unsigned long *outlen); + +int pmac_test(void); + +/* internal functions */ +int pmac_ntz(unsigned long x); +void pmac_shift_xor(pmac_state *pmac); + +#endif /* PMAC */ + +#ifdef LTC_EAX_MODE + +#if !(defined(LTC_OMAC) && defined(LTC_CTR_MODE)) + #error LTC_EAX_MODE requires LTC_OMAC and CTR +#endif + +typedef struct { + unsigned char N[MAXBLOCKSIZE]; + symmetric_CTR ctr; + omac_state headeromac, ctomac; +} eax_state; + +int eax_init(eax_state *eax, int cipher, const unsigned char *key, unsigned long keylen, + const unsigned char *nonce, unsigned long noncelen, + const unsigned char *header, unsigned long headerlen); + +int eax_encrypt(eax_state *eax, const unsigned char *pt, unsigned char *ct, unsigned long length); +int eax_decrypt(eax_state *eax, const unsigned char *ct, unsigned char *pt, unsigned long length); +int eax_addheader(eax_state *eax, const unsigned char *header, unsigned long length); +int eax_done(eax_state *eax, unsigned char *tag, unsigned long *taglen); + +int eax_encrypt_authenticate_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *nonce, unsigned long noncelen, + const unsigned char *header, unsigned long headerlen, + const unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + unsigned char *tag, unsigned long *taglen); + +int eax_decrypt_verify_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *nonce, unsigned long noncelen, + const unsigned char *header, unsigned long headerlen, + const unsigned char *ct, unsigned long ctlen, + unsigned char *pt, + unsigned char *tag, unsigned long taglen, + int *stat); + + int eax_test(void); +#endif /* EAX MODE */ + +#ifdef LTC_OCB_MODE +typedef struct { + unsigned char L[MAXBLOCKSIZE], /* L value */ + Ls[32][MAXBLOCKSIZE], /* L shifted by i bits to the left */ + Li[MAXBLOCKSIZE], /* value of Li [current value, we calc from previous recall] */ + Lr[MAXBLOCKSIZE], /* L * x^-1 */ + R[MAXBLOCKSIZE], /* R value */ + checksum[MAXBLOCKSIZE]; /* current checksum */ + + symmetric_key key; /* scheduled key for cipher */ + unsigned long block_index; /* index # for current block */ + int cipher, /* cipher idx */ + block_len; /* length of block */ +} ocb_state; + +int ocb_init(ocb_state *ocb, int cipher, + const unsigned char *key, unsigned long keylen, const unsigned char *nonce); + +int ocb_encrypt(ocb_state *ocb, const unsigned char *pt, unsigned char *ct); +int ocb_decrypt(ocb_state *ocb, const unsigned char *ct, unsigned char *pt); + +int ocb_done_encrypt(ocb_state *ocb, + const unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + unsigned char *tag, unsigned long *taglen); + +int ocb_done_decrypt(ocb_state *ocb, + const unsigned char *ct, unsigned long ctlen, + unsigned char *pt, + const unsigned char *tag, unsigned long taglen, int *stat); + +int ocb_encrypt_authenticate_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *nonce, + const unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + unsigned char *tag, unsigned long *taglen); + +int ocb_decrypt_verify_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *nonce, + const unsigned char *ct, unsigned long ctlen, + unsigned char *pt, + const unsigned char *tag, unsigned long taglen, + int *stat); + +int ocb_test(void); + +/* internal functions */ +void ocb_shift_xor(ocb_state *ocb, unsigned char *Z); +int ocb_ntz(unsigned long x); +int s_ocb_done(ocb_state *ocb, const unsigned char *pt, unsigned long ptlen, + unsigned char *ct, unsigned char *tag, unsigned long *taglen, int mode); + +#endif /* LTC_OCB_MODE */ + +#ifdef LTC_CCM_MODE + +#define CCM_ENCRYPT 0 +#define CCM_DECRYPT 1 + +int ccm_memory(int cipher, + const unsigned char *key, unsigned long keylen, + symmetric_key *uskey, + const unsigned char *nonce, unsigned long noncelen, + const unsigned char *header, unsigned long headerlen, + unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + unsigned char *tag, unsigned long *taglen, + int direction); + +int ccm_test(void); + +#endif /* LTC_CCM_MODE */ + +#if defined(LRW_MODE) || defined(LTC_GCM_MODE) +void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c); +#endif + + +/* table shared between GCM and LRW */ +#if defined(LTC_GCM_TABLES) || defined(LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST)) +extern const unsigned char gcm_shift_table[]; +#endif + +#ifdef LTC_GCM_MODE + +#define GCM_ENCRYPT 0 +#define GCM_DECRYPT 1 + +#define LTC_GCM_MODE_IV 0 +#define LTC_GCM_MODE_AAD 1 +#define LTC_GCM_MODE_TEXT 2 + +typedef struct { + symmetric_key K; + unsigned char H[16], /* multiplier */ + X[16], /* accumulator */ + Y[16], /* counter */ + Y_0[16], /* initial counter */ + buf[16]; /* buffer for stuff */ + + int cipher, /* which cipher */ + ivmode, /* Which mode is the IV in? */ + mode, /* mode the GCM code is in */ + buflen; /* length of data in buf */ + + ulong64 totlen, /* 64-bit counter used for IV and AAD */ + pttotlen; /* 64-bit counter for the PT */ + +#ifdef LTC_GCM_TABLES + unsigned char PC[16][256][16] /* 16 tables of 8x128 */ +#ifdef LTC_GCM_TABLES_SSE2 +__attribute__ ((aligned (16))) +#endif +; +#endif +} gcm_state; + +void gcm_mult_h(gcm_state *gcm, unsigned char *I); + +int gcm_init(gcm_state *gcm, int cipher, + const unsigned char *key, int keylen); + +int gcm_reset(gcm_state *gcm); + +int gcm_add_iv(gcm_state *gcm, + const unsigned char *IV, unsigned long IVlen); + +int gcm_add_aad(gcm_state *gcm, + const unsigned char *adata, unsigned long adatalen); + +int gcm_process(gcm_state *gcm, + unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + int direction); + +int gcm_done(gcm_state *gcm, + unsigned char *tag, unsigned long *taglen); + +int gcm_memory( int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *IV, unsigned long IVlen, + const unsigned char *adata, unsigned long adatalen, + unsigned char *pt, unsigned long ptlen, + unsigned char *ct, + unsigned char *tag, unsigned long *taglen, + int direction); +int gcm_test(void); + +#endif /* LTC_GCM_MODE */ + +#ifdef LTC_PELICAN + +typedef struct pelican_state +{ + symmetric_key K; + unsigned char state[16]; + int buflen; +} pelican_state; + +int pelican_init(pelican_state *pelmac, const unsigned char *key, unsigned long keylen); +int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned long inlen); +int pelican_done(pelican_state *pelmac, unsigned char *out); +int pelican_test(void); + +int pelican_memory(const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out); + +#endif + +#ifdef LTC_XCBC + +/* add this to "keylen" to xcbc_init to use a pure three-key XCBC MAC */ +#define LTC_XCBC_PURE 0x8000UL + +typedef struct { + unsigned char K[3][MAXBLOCKSIZE], + IV[MAXBLOCKSIZE]; + + symmetric_key key; + + int cipher, + buflen, + blocksize; +} xcbc_state; + +int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned long keylen); +int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen); +int xcbc_done(xcbc_state *xcbc, unsigned char *out, unsigned long *outlen); +int xcbc_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int xcbc_memory_multi(int cipher, + const unsigned char *key, unsigned long keylen, + unsigned char *out, unsigned long *outlen, + const unsigned char *in, unsigned long inlen, ...); +int xcbc_file(int cipher, + const unsigned char *key, unsigned long keylen, + const char *filename, + unsigned char *out, unsigned long *outlen); +int xcbc_test(void); + +#endif + +#ifdef LTC_F9_MODE + +typedef struct { + unsigned char akey[MAXBLOCKSIZE], + ACC[MAXBLOCKSIZE], + IV[MAXBLOCKSIZE]; + + symmetric_key key; + + int cipher, + buflen, + keylen, + blocksize; +} f9_state; + +int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen); +int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen); +int f9_done(f9_state *f9, unsigned char *out, unsigned long *outlen); +int f9_memory(int cipher, + const unsigned char *key, unsigned long keylen, + const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int f9_memory_multi(int cipher, + const unsigned char *key, unsigned long keylen, + unsigned char *out, unsigned long *outlen, + const unsigned char *in, unsigned long inlen, ...); +int f9_file(int cipher, + const unsigned char *key, unsigned long keylen, + const char *filename, + unsigned char *out, unsigned long *outlen); +int f9_test(void); + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_mac.h,v $ */ +/* $Revision: 1.23 $ */ +/* $Date: 2007/05/12 14:37:41 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_macros.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_macros.h new file mode 100644 index 000000000..53bda9bb4 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_macros.h @@ -0,0 +1,424 @@ +/* fix for MSVC ...evil! */ +#ifdef _MSC_VER + #define CONST64(n) n ## ui64 + typedef unsigned __int64 ulong64; +#else + #define CONST64(n) n ## ULL + typedef unsigned long long ulong64; +#endif + +/* this is the "32-bit at least" data type + * Re-define it to suit your platform but it must be at least 32-bits + */ +#if defined(__x86_64__) || (defined(__sparc__) && defined(__arch64__)) + typedef unsigned ulong32; +#else + typedef unsigned long ulong32; +#endif + +/* ---- HELPER MACROS ---- */ +#ifdef ENDIAN_NEUTRAL + +#define STORE32L(x, y) \ + { (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ + (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } + +#define LOAD32L(x, y) \ + { x = ((unsigned long)((y)[3] & 255)<<24) | \ + ((unsigned long)((y)[2] & 255)<<16) | \ + ((unsigned long)((y)[1] & 255)<<8) | \ + ((unsigned long)((y)[0] & 255)); } + +#define STORE64L(x, y) \ + { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ + (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ + (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ + (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } + +#define LOAD64L(x, y) \ + { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ + (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ + (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ + (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } + +#define STORE32H(x, y) \ + { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \ + (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } + +#define LOAD32H(x, y) \ + { x = ((unsigned long)((y)[0] & 255)<<24) | \ + ((unsigned long)((y)[1] & 255)<<16) | \ + ((unsigned long)((y)[2] & 255)<<8) | \ + ((unsigned long)((y)[3] & 255)); } + +#define STORE64H(x, y) \ + { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ + (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ + (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ + (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } + +#define LOAD64H(x, y) \ + { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ + (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ + (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ + (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); } + +#endif /* ENDIAN_NEUTRAL */ + +#ifdef ENDIAN_LITTLE + +#if !defined(LTC_NO_BSWAP) && (defined(INTEL_CC) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__) || defined(__x86_64__)))) + +#define STORE32H(x, y) \ +asm __volatile__ ( \ + "bswapl %0 \n\t" \ + "movl %0,(%1)\n\t" \ + "bswapl %0 \n\t" \ + ::"r"(x), "r"(y)); + +#define LOAD32H(x, y) \ +asm __volatile__ ( \ + "movl (%1),%0\n\t" \ + "bswapl %0\n\t" \ + :"=r"(x): "r"(y)); + +#else + +#define STORE32H(x, y) \ + { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \ + (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } + +#define LOAD32H(x, y) \ + { x = ((unsigned long)((y)[0] & 255)<<24) | \ + ((unsigned long)((y)[1] & 255)<<16) | \ + ((unsigned long)((y)[2] & 255)<<8) | \ + ((unsigned long)((y)[3] & 255)); } + +#endif + + +/* x86_64 processor */ +#if !defined(LTC_NO_BSWAP) && (defined(__GNUC__) && defined(__x86_64__)) + +#define STORE64H(x, y) \ +asm __volatile__ ( \ + "bswapq %0 \n\t" \ + "movq %0,(%1)\n\t" \ + "bswapq %0 \n\t" \ + ::"r"(x), "r"(y)); + +#define LOAD64H(x, y) \ +asm __volatile__ ( \ + "movq (%1),%0\n\t" \ + "bswapq %0\n\t" \ + :"=r"(x): "r"(y)); + +#else + +#define STORE64H(x, y) \ + { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ + (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ + (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ + (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } + +#define LOAD64H(x, y) \ + { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ + (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ + (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ + (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); } + +#endif + +#ifdef ENDIAN_32BITWORD + +#define STORE32L(x, y) \ + { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } + +#define LOAD32L(x, y) \ + XMEMCPY(&(x), y, 4); + +#define STORE64L(x, y) \ + { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ + (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ + (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ + (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } + +#define LOAD64L(x, y) \ + { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ + (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ + (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ + (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } + +#else /* 64-bit words then */ + +#define STORE32L(x, y) \ + { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } + +#define LOAD32L(x, y) \ + { XMEMCPY(&(x), y, 4); x &= 0xFFFFFFFF; } + +#define STORE64L(x, y) \ + { ulong64 __t = (x); XMEMCPY(y, &__t, 8); } + +#define LOAD64L(x, y) \ + { XMEMCPY(&(x), y, 8); } + +#endif /* ENDIAN_64BITWORD */ + +#endif /* ENDIAN_LITTLE */ + +#ifdef ENDIAN_BIG +#define STORE32L(x, y) \ + { (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ + (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } + +#define LOAD32L(x, y) \ + { x = ((unsigned long)((y)[3] & 255)<<24) | \ + ((unsigned long)((y)[2] & 255)<<16) | \ + ((unsigned long)((y)[1] & 255)<<8) | \ + ((unsigned long)((y)[0] & 255)); } + +#define STORE64L(x, y) \ + { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ + (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ + (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ + (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } + +#define LOAD64L(x, y) \ + { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48) | \ + (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32) | \ + (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16) | \ + (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } + +#ifdef ENDIAN_32BITWORD + +#define STORE32H(x, y) \ + { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } + +#define LOAD32H(x, y) \ + XMEMCPY(&(x), y, 4); + +#define STORE64H(x, y) \ + { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ + (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ + (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ + (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } + +#define LOAD64H(x, y) \ + { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48)| \ + (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32)| \ + (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16)| \ + (((ulong64)((y)[6] & 255))<<8)| (((ulong64)((y)[7] & 255))); } + +#else /* 64-bit words then */ + +#define STORE32H(x, y) \ + { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } + +#define LOAD32H(x, y) \ + { XMEMCPY(&(x), y, 4); x &= 0xFFFFFFFF; } + +#define STORE64H(x, y) \ + { ulong64 __t = (x); XMEMCPY(y, &__t, 8); } + +#define LOAD64H(x, y) \ + { XMEMCPY(&(x), y, 8); } + +#endif /* ENDIAN_64BITWORD */ +#endif /* ENDIAN_BIG */ + +#define BSWAP(x) ( ((x>>24)&0x000000FFUL) | ((x<<24)&0xFF000000UL) | \ + ((x>>8)&0x0000FF00UL) | ((x<<8)&0x00FF0000UL) ) + + +/* 32-bit Rotates */ +#if defined(_MSC_VER) + +/* instrinsic rotate */ +#include +#pragma intrinsic(_lrotr,_lrotl) +#define ROR(x,n) _lrotr(x,n) +#define ROL(x,n) _lrotl(x,n) +#define RORc(x,n) _lrotr(x,n) +#define ROLc(x,n) _lrotl(x,n) + +#elif !defined(__STRICT_ANSI__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && !defined(INTEL_CC) && !defined(LTC_NO_ASM) + +static inline unsigned ROL(unsigned word, int i) +{ + asm ("roll %%cl,%0" + :"=r" (word) + :"0" (word),"c" (i)); + return word; +} + +static inline unsigned ROR(unsigned word, int i) +{ + asm ("rorl %%cl,%0" + :"=r" (word) + :"0" (word),"c" (i)); + return word; +} + +#ifndef LTC_NO_ROLC + +static inline unsigned ROLc(unsigned word, const int i) +{ + asm ("roll %2,%0" + :"=r" (word) + :"0" (word),"I" (i)); + return word; +} + +static inline unsigned RORc(unsigned word, const int i) +{ + asm ("rorl %2,%0" + :"=r" (word) + :"0" (word),"I" (i)); + return word; +} + +#else + +#define ROLc ROL +#define RORc ROR + +#endif + +#elif !defined(__STRICT_ANSI__) && defined(LTC_PPC32) + +static inline unsigned ROL(unsigned word, int i) +{ + asm ("rotlw %0,%0,%2" + :"=r" (word) + :"0" (word),"r" (i)); + return word; +} + +static inline unsigned ROR(unsigned word, int i) +{ + asm ("rotlw %0,%0,%2" + :"=r" (word) + :"0" (word),"r" (32-i)); + return word; +} + +#ifndef LTC_NO_ROLC + +static inline unsigned ROLc(unsigned word, const int i) +{ + asm ("rotlwi %0,%0,%2" + :"=r" (word) + :"0" (word),"I" (i)); + return word; +} + +static inline unsigned RORc(unsigned word, const int i) +{ + asm ("rotrwi %0,%0,%2" + :"=r" (word) + :"0" (word),"I" (i)); + return word; +} + +#else + +#define ROLc ROL +#define RORc ROR + +#endif + + +#else + +/* rotates the hard way */ +#define ROL(x, y) ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) +#define ROR(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)((y)&31)) | ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) +#define ROLc(x, y) ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) +#define RORc(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)((y)&31)) | ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) + +#endif + + +/* 64-bit Rotates */ +#if !defined(__STRICT_ANSI__) && defined(__GNUC__) && defined(__x86_64__) && !defined(LTC_NO_ASM) + +static inline unsigned long ROL64(unsigned long word, int i) +{ + asm("rolq %%cl,%0" + :"=r" (word) + :"0" (word),"c" (i)); + return word; +} + +static inline unsigned long ROR64(unsigned long word, int i) +{ + asm("rorq %%cl,%0" + :"=r" (word) + :"0" (word),"c" (i)); + return word; +} + +#ifndef LTC_NO_ROLC + +static inline unsigned long ROL64c(unsigned long word, const int i) +{ + asm("rolq %2,%0" + :"=r" (word) + :"0" (word),"J" (i)); + return word; +} + +static inline unsigned long ROR64c(unsigned long word, const int i) +{ + asm("rorq %2,%0" + :"=r" (word) + :"0" (word),"J" (i)); + return word; +} + +#else /* LTC_NO_ROLC */ + +#define ROL64c ROL64 +#define ROR64c ROR64 + +#endif + +#else /* Not x86_64 */ + +#define ROL64(x, y) \ + ( (((x)<<((ulong64)(y)&63)) | \ + (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)64-((y)&63)))) & CONST64(0xFFFFFFFFFFFFFFFF)) + +#define ROR64(x, y) \ + ( ((((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)(y)&CONST64(63))) | \ + ((x)<<((ulong64)(64-((y)&CONST64(63)))))) & CONST64(0xFFFFFFFFFFFFFFFF)) + +#define ROL64c(x, y) \ + ( (((x)<<((ulong64)(y)&63)) | \ + (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)64-((y)&63)))) & CONST64(0xFFFFFFFFFFFFFFFF)) + +#define ROR64c(x, y) \ + ( ((((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)(y)&CONST64(63))) | \ + ((x)<<((ulong64)(64-((y)&CONST64(63)))))) & CONST64(0xFFFFFFFFFFFFFFFF)) + +#endif + +#ifndef MAX + #define MAX(x, y) ( ((x)>(y))?(x):(y) ) +#endif + +#ifndef MIN + #define MIN(x, y) ( ((x)<(y))?(x):(y) ) +#endif + +/* extract a byte portably */ +#ifdef _MSC_VER + #define byte(x, n) ((unsigned char)((x) >> (8 * (n)))) +#else + #define byte(x, n) (((x) >> (8 * (n))) & 255) +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_macros.h,v $ */ +/* $Revision: 1.15 $ */ +/* $Date: 2006/11/29 23:43:57 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_math.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_math.h new file mode 100644 index 000000000..a05d7fff9 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_math.h @@ -0,0 +1,500 @@ +/** math functions **/ + +#define LTC_MP_LT -1 +#define LTC_MP_EQ 0 +#define LTC_MP_GT 1 + +#define LTC_MP_NO 0 +#define LTC_MP_YES 1 + +#ifndef LTC_MECC + typedef void ecc_point; +#endif + +#ifndef LTC_MRSA + typedef void rsa_key; +#endif + +/** math descriptor */ +typedef struct { + /** Name of the math provider */ + char *name; + + /** Bits per digit, amount of bits must fit in an unsigned long */ + int bits_per_digit; + +/* ---- init/deinit functions ---- */ + + /** initialize a bignum + @param a The number to initialize + @return CRYPT_OK on success + */ + int (*init)(void **a); + + /** init copy + @param dst The number to initialize and write to + @param src The number to copy from + @return CRYPT_OK on success + */ + int (*init_copy)(void **dst, void *src); + + /** deinit + @param a The number to free + @return CRYPT_OK on success + */ + void (*deinit)(void *a); + +/* ---- data movement ---- */ + + /** negate + @param src The number to negate + @param dst The destination + @return CRYPT_OK on success + */ + int (*neg)(void *src, void *dst); + + /** copy + @param src The number to copy from + @param dst The number to write to + @return CRYPT_OK on success + */ + int (*copy)(void *src, void *dst); + +/* ---- trivial low level functions ---- */ + + /** set small constant + @param a Number to write to + @param n Source upto bits_per_digit (actually meant for very small constants) + @return CRYPT_OK on succcess + */ + int (*set_int)(void *a, unsigned long n); + + /** get small constant + @param a Number to read, only fetches upto bits_per_digit from the number + @return The lower bits_per_digit of the integer (unsigned) + */ + unsigned long (*get_int)(void *a); + + /** get digit n + @param a The number to read from + @param n The number of the digit to fetch + @return The bits_per_digit sized n'th digit of a + */ + unsigned long (*get_digit)(void *a, int n); + + /** Get the number of digits that represent the number + @param a The number to count + @return The number of digits used to represent the number + */ + int (*get_digit_count)(void *a); + + /** compare two integers + @param a The left side integer + @param b The right side integer + @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison) + */ + int (*compare)(void *a, void *b); + + /** compare against int + @param a The left side integer + @param b The right side integer (upto bits_per_digit) + @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison) + */ + int (*compare_d)(void *a, unsigned long n); + + /** Count the number of bits used to represent the integer + @param a The integer to count + @return The number of bits required to represent the integer + */ + int (*count_bits)(void * a); + + /** Count the number of LSB bits which are zero + @param a The integer to count + @return The number of contiguous zero LSB bits + */ + int (*count_lsb_bits)(void *a); + + /** Compute a power of two + @param a The integer to store the power in + @param n The power of two you want to store (a = 2^n) + @return CRYPT_OK on success + */ + int (*twoexpt)(void *a , int n); + +/* ---- radix conversions ---- */ + + /** read ascii string + @param a The integer to store into + @param str The string to read + @param radix The radix the integer has been represented in (2-64) + @return CRYPT_OK on success + */ + int (*read_radix)(void *a, const char *str, int radix); + + /** write number to string + @param a The integer to store + @param str The destination for the string + @param radix The radix the integer is to be represented in (2-64) + @return CRYPT_OK on success + */ + int (*write_radix)(void *a, char *str, int radix); + + /** get size as unsigned char string + @param a The integer to get the size (when stored in array of octets) + @return The length of the integer + */ + unsigned long (*unsigned_size)(void *a); + + /** store an integer as an array of octets + @param src The integer to store + @param dst The buffer to store the integer in + @return CRYPT_OK on success + */ + int (*unsigned_write)(void *src, unsigned char *dst); + + /** read an array of octets and store as integer + @param dst The integer to load + @param src The array of octets + @param len The number of octets + @return CRYPT_OK on success + */ + int (*unsigned_read)(void *dst, unsigned char *src, unsigned long len); + +/* ---- basic math ---- */ + + /** add two integers + @param a The first source integer + @param b The second source integer + @param c The destination of "a + b" + @return CRYPT_OK on success + */ + int (*add)(void *a, void *b, void *c); + + + /** add two integers + @param a The first source integer + @param b The second source integer (single digit of upto bits_per_digit in length) + @param c The destination of "a + b" + @return CRYPT_OK on success + */ + int (*addi)(void *a, unsigned long b, void *c); + + /** subtract two integers + @param a The first source integer + @param b The second source integer + @param c The destination of "a - b" + @return CRYPT_OK on success + */ + int (*sub)(void *a, void *b, void *c); + + /** subtract two integers + @param a The first source integer + @param b The second source integer (single digit of upto bits_per_digit in length) + @param c The destination of "a - b" + @return CRYPT_OK on success + */ + int (*subi)(void *a, unsigned long b, void *c); + + /** multiply two integers + @param a The first source integer + @param b The second source integer (single digit of upto bits_per_digit in length) + @param c The destination of "a * b" + @return CRYPT_OK on success + */ + int (*mul)(void *a, void *b, void *c); + + /** multiply two integers + @param a The first source integer + @param b The second source integer (single digit of upto bits_per_digit in length) + @param c The destination of "a * b" + @return CRYPT_OK on success + */ + int (*muli)(void *a, unsigned long b, void *c); + + /** Square an integer + @param a The integer to square + @param b The destination + @return CRYPT_OK on success + */ + int (*sqr)(void *a, void *b); + + /** Divide an integer + @param a The dividend + @param b The divisor + @param c The quotient (can be NULL to signify don't care) + @param d The remainder (can be NULL to signify don't care) + @return CRYPT_OK on success + */ + int (*mpdiv)(void *a, void *b, void *c, void *d); + + /** divide by two + @param a The integer to divide (shift right) + @param b The destination + @return CRYPT_OK on success + */ + int (*div_2)(void *a, void *b); + + /** Get remainder (small value) + @param a The integer to reduce + @param b The modulus (upto bits_per_digit in length) + @param c The destination for the residue + @return CRYPT_OK on success + */ + int (*modi)(void *a, unsigned long b, unsigned long *c); + + /** gcd + @param a The first integer + @param b The second integer + @param c The destination for (a, b) + @return CRYPT_OK on success + */ + int (*gcd)(void *a, void *b, void *c); + + /** lcm + @param a The first integer + @param b The second integer + @param c The destination for [a, b] + @return CRYPT_OK on success + */ + int (*lcm)(void *a, void *b, void *c); + + /** Modular multiplication + @param a The first source + @param b The second source + @param c The modulus + @param d The destination (a*b mod c) + @return CRYPT_OK on success + */ + int (*mulmod)(void *a, void *b, void *c, void *d); + + /** Modular squaring + @param a The first source + @param b The modulus + @param c The destination (a*a mod b) + @return CRYPT_OK on success + */ + int (*sqrmod)(void *a, void *b, void *c); + + /** Modular inversion + @param a The value to invert + @param b The modulus + @param c The destination (1/a mod b) + @return CRYPT_OK on success + */ + int (*invmod)(void *, void *, void *); + +/* ---- reduction ---- */ + + /** setup montgomery + @param a The modulus + @param b The destination for the reduction digit + @return CRYPT_OK on success + */ + int (*montgomery_setup)(void *a, void **b); + + /** get normalization value + @param a The destination for the normalization value + @param b The modulus + @return CRYPT_OK on success + */ + int (*montgomery_normalization)(void *a, void *b); + + /** reduce a number + @param a The number [and dest] to reduce + @param b The modulus + @param c The value "b" from montgomery_setup() + @return CRYPT_OK on success + */ + int (*montgomery_reduce)(void *a, void *b, void *c); + + /** clean up (frees memory) + @param a The value "b" from montgomery_setup() + @return CRYPT_OK on success + */ + void (*montgomery_deinit)(void *a); + +/* ---- exponentiation ---- */ + + /** Modular exponentiation + @param a The base integer + @param b The power (can be negative) integer + @param c The modulus integer + @param d The destination + @return CRYPT_OK on success + */ + int (*exptmod)(void *a, void *b, void *c, void *d); + + /** Primality testing + @param a The integer to test + @param b The destination of the result (FP_YES if prime) + @return CRYPT_OK on success + */ + int (*isprime)(void *a, int *b); + +/* ---- (optional) ecc point math ---- */ + + /** ECC GF(p) point multiplication (from the NIST curves) + @param k The integer to multiply the point by + @param G The point to multiply + @param R The destination for kG + @param modulus The modulus for the field + @param map Boolean indicated whether to map back to affine or not (can be ignored if you work in affine only) + @return CRYPT_OK on success + */ + int (*ecc_ptmul)(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); + + /** ECC GF(p) point addition + @param P The first point + @param Q The second point + @param R The destination of P + Q + @param modulus The modulus + @param mp The "b" value from montgomery_setup() + @return CRYPT_OK on success + */ + int (*ecc_ptadd)(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp); + + /** ECC GF(p) point double + @param P The first point + @param R The destination of 2P + @param modulus The modulus + @param mp The "b" value from montgomery_setup() + @return CRYPT_OK on success + */ + int (*ecc_ptdbl)(ecc_point *P, ecc_point *R, void *modulus, void *mp); + + /** ECC mapping from projective to affine, currently uses (x,y,z) => (x/z^2, y/z^3, 1) + @param P The point to map + @param modulus The modulus + @param mp The "b" value from montgomery_setup() + @return CRYPT_OK on success + @remark The mapping can be different but keep in mind a ecc_point only has three + integers (x,y,z) so if you use a different mapping you have to make it fit. + */ + int (*ecc_map)(ecc_point *P, void *modulus, void *mp); + + /** Computes kA*A + kB*B = C using Shamir's Trick + @param A First point to multiply + @param kA What to multiple A by + @param B Second point to multiply + @param kB What to multiple B by + @param C [out] Destination point (can overlap with A or B + @param modulus Modulus for curve + @return CRYPT_OK on success + */ + int (*ecc_mul2add)(ecc_point *A, void *kA, + ecc_point *B, void *kB, + ecc_point *C, + void *modulus); + +/* ---- (optional) rsa optimized math (for internal CRT) ---- */ + + /** RSA Key Generation + @param prng An active PRNG state + @param wprng The index of the PRNG desired + @param size The size of the modulus (key size) desired (octets) + @param e The "e" value (public key). e==65537 is a good choice + @param key [out] Destination of a newly created private key pair + @return CRYPT_OK if successful, upon error all allocated ram is freed + */ + int (*rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key); + + + /** RSA exponentiation + @param in The octet array representing the base + @param inlen The length of the input + @param out The destination (to be stored in an octet array format) + @param outlen The length of the output buffer and the resulting size (zero padded to the size of the modulus) + @param which PK_PUBLIC for public RSA and PK_PRIVATE for private RSA + @param key The RSA key to use + @return CRYPT_OK on success + */ + int (*rsa_me)(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, int which, + rsa_key *key); +} ltc_math_descriptor; + +extern ltc_math_descriptor ltc_mp; + +int ltc_init_multi(void **a, ...); +void ltc_deinit_multi(void *a, ...); + +#ifdef LTM_DESC +extern const ltc_math_descriptor ltm_desc; +#endif + +#ifdef TFM_DESC +extern const ltc_math_descriptor tfm_desc; +#endif + +#ifdef GMP_DESC +extern const ltc_math_descriptor gmp_desc; +#endif + +#if !defined(DESC_DEF_ONLY) && defined(LTC_SOURCE) + +#define MP_DIGIT_BIT ltc_mp.bits_per_digit + +/* some handy macros */ +#define mp_init(a) ltc_mp.init(a) +#define mp_init_multi ltc_init_multi +#define mp_clear(a) ltc_mp.deinit(a) +#define mp_clear_multi ltc_deinit_multi +#define mp_init_copy(a, b) ltc_mp.init_copy(a, b) + +#define mp_neg(a, b) ltc_mp.neg(a, b) +#define mp_copy(a, b) ltc_mp.copy(a, b) + +#define mp_set(a, b) ltc_mp.set_int(a, b) +#define mp_set_int(a, b) ltc_mp.set_int(a, b) +#define mp_get_int(a) ltc_mp.get_int(a) +#define mp_get_digit(a, n) ltc_mp.get_digit(a, n) +#define mp_get_digit_count(a) ltc_mp.get_digit_count(a) +#define mp_cmp(a, b) ltc_mp.compare(a, b) +#define mp_cmp_d(a, b) ltc_mp.compare_d(a, b) +#define mp_count_bits(a) ltc_mp.count_bits(a) +#define mp_cnt_lsb(a) ltc_mp.count_lsb_bits(a) +#define mp_2expt(a, b) ltc_mp.twoexpt(a, b) + +#define mp_read_radix(a, b, c) ltc_mp.read_radix(a, b, c) +#define mp_toradix(a, b, c) ltc_mp.write_radix(a, b, c) +#define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a) +#define mp_to_unsigned_bin(a, b) ltc_mp.unsigned_write(a, b) +#define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c) + +#define mp_add(a, b, c) ltc_mp.add(a, b, c) +#define mp_add_d(a, b, c) ltc_mp.addi(a, b, c) +#define mp_sub(a, b, c) ltc_mp.sub(a, b, c) +#define mp_sub_d(a, b, c) ltc_mp.subi(a, b, c) +#define mp_mul(a, b, c) ltc_mp.mul(a, b, c) +#define mp_mul_d(a, b, c) ltc_mp.muli(a, b, c) +#define mp_sqr(a, b) ltc_mp.sqr(a, b) +#define mp_div(a, b, c, d) ltc_mp.mpdiv(a, b, c, d) +#define mp_div_2(a, b) ltc_mp.div_2(a, b) +#define mp_mod(a, b, c) ltc_mp.mpdiv(a, b, NULL, c) +#define mp_mod_d(a, b, c) ltc_mp.modi(a, b, c) +#define mp_gcd(a, b, c) ltc_mp.gcd(a, b, c) +#define mp_lcm(a, b, c) ltc_mp.lcm(a, b, c) + +#define mp_mulmod(a, b, c, d) ltc_mp.mulmod(a, b, c, d) +#define mp_sqrmod(a, b, c) ltc_mp.sqrmod(a, b, c) +#define mp_invmod(a, b, c) ltc_mp.invmod(a, b, c) + +#define mp_montgomery_setup(a, b) ltc_mp.montgomery_setup(a, b) +#define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b) +#define mp_montgomery_reduce(a, b, c) ltc_mp.montgomery_reduce(a, b, c) +#define mp_montgomery_free(a) ltc_mp.montgomery_deinit(a) + +#define mp_exptmod(a,b,c,d) ltc_mp.exptmod(a,b,c,d) +#define mp_prime_is_prime(a, b, c) ltc_mp.isprime(a, c) + +#define mp_iszero(a) (mp_cmp_d(a, 0) == LTC_MP_EQ ? LTC_MP_YES : LTC_MP_NO) +#define mp_isodd(a) (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO) +#define mp_exch(a, b) do { void *ABC__tmp = a; a = b; b = ABC__tmp; } while(0); + +#define mp_tohex(a, b) mp_toradix(a, b, 16) + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_math.h,v $ */ +/* $Revision: 1.44 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_misc.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_misc.h new file mode 100644 index 000000000..f5384cacc --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_misc.h @@ -0,0 +1,23 @@ +/* ---- LTC_BASE64 Routines ---- */ +#ifdef LTC_BASE64 +int base64_encode(const unsigned char *in, unsigned long len, + unsigned char *out, unsigned long *outlen); + +int base64_decode(const unsigned char *in, unsigned long len, + unsigned char *out, unsigned long *outlen); +#endif + +/* ---- MEM routines ---- */ +void zeromem(void *dst, size_t len); +void burn_stack(unsigned long len); + +const char *error_to_string(int err); + +extern const char *crypt_build_settings; + +/* ---- HMM ---- */ +int crypt_fsa(void *mp, ...); + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_misc.h,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_pk.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_pk.h new file mode 100644 index 000000000..b5f277a88 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_pk.h @@ -0,0 +1,558 @@ +/* ---- NUMBER THEORY ---- */ + +enum { + PK_PUBLIC=0, + PK_PRIVATE=1 +}; + +int rand_prime(void *N, long len, prng_state *prng, int wprng); + +/* ---- RSA ---- */ +#ifdef LTC_MRSA + +/* Min and Max RSA key sizes (in bits) */ +#define MIN_RSA_SIZE 1024 +#define MAX_RSA_SIZE 4096 + +/** RSA LTC_PKCS style key */ +typedef struct Rsa_key { + /** Type of key, PK_PRIVATE or PK_PUBLIC */ + int type; + /** The public exponent */ + void *e; + /** The private exponent */ + void *d; + /** The modulus */ + void *N; + /** The p factor of N */ + void *p; + /** The q factor of N */ + void *q; + /** The 1/q mod p CRT param */ + void *qP; + /** The d mod (p - 1) CRT param */ + void *dP; + /** The d mod (q - 1) CRT param */ + void *dQ; +} rsa_key; + +int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key); + +int rsa_exptmod(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, int which, + rsa_key *key); + +void rsa_free(rsa_key *key); + +/* These use LTC_PKCS #1 v2.0 padding */ +#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, _key) \ + rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_LTC_PKCS_1_OAEP, _key) + +#define rsa_decrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, _stat, _key) \ + rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_LTC_PKCS_1_OAEP, _stat, _key) + +#define rsa_sign_hash(_in, _inlen, _out, _outlen, _prng, _prng_idx, _hash_idx, _saltlen, _key) \ + rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_LTC_PKCS_1_PSS, _prng, _prng_idx, _hash_idx, _saltlen, _key) + +#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_idx, _saltlen, _stat, _key) \ + rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key) + +/* These can be switched between LTC_PKCS #1 v2.x and LTC_PKCS #1 v1.5 paddings */ +int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + const unsigned char *lparam, unsigned long lparamlen, + prng_state *prng, int prng_idx, int hash_idx, int padding, rsa_key *key); + +int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + const unsigned char *lparam, unsigned long lparamlen, + int hash_idx, int padding, + int *stat, rsa_key *key); + +int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + int padding, + prng_state *prng, int prng_idx, + int hash_idx, unsigned long saltlen, + rsa_key *key); + +int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen, + const unsigned char *hash, unsigned long hashlen, + int padding, + int hash_idx, unsigned long saltlen, + int *stat, rsa_key *key); + +/* LTC_PKCS #1 import/export */ +int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key); +int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key); + +/* Ladik: Added for verifying Blizzard strong signature verification */ +int rsa_verify_simple(const unsigned char *sig, unsigned long siglen, + const unsigned char *hash, unsigned long hashlen, + int *stat, + rsa_key *key); + +#endif + +/* ---- Katja ---- */ +#ifdef MKAT + +/* Min and Max KAT key sizes (in bits) */ +#define MIN_KAT_SIZE 1024 +#define MAX_KAT_SIZE 4096 + +/** Katja LTC_PKCS style key */ +typedef struct KAT_key { + /** Type of key, PK_PRIVATE or PK_PUBLIC */ + int type; + /** The private exponent */ + void *d; + /** The modulus */ + void *N; + /** The p factor of N */ + void *p; + /** The q factor of N */ + void *q; + /** The 1/q mod p CRT param */ + void *qP; + /** The d mod (p - 1) CRT param */ + void *dP; + /** The d mod (q - 1) CRT param */ + void *dQ; + /** The pq param */ + void *pq; +} katja_key; + +int katja_make_key(prng_state *prng, int wprng, int size, katja_key *key); + +int katja_exptmod(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, int which, + katja_key *key); + +void katja_free(katja_key *key); + +/* These use LTC_PKCS #1 v2.0 padding */ +int katja_encrypt_key(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + const unsigned char *lparam, unsigned long lparamlen, + prng_state *prng, int prng_idx, int hash_idx, katja_key *key); + +int katja_decrypt_key(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + const unsigned char *lparam, unsigned long lparamlen, + int hash_idx, int *stat, + katja_key *key); + +/* LTC_PKCS #1 import/export */ +int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key); +int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key); + +#endif + +/* ---- ECC Routines ---- */ +#ifdef LTC_MECC + +/* size of our temp buffers for exported keys */ +#define ECC_BUF_SIZE 256 + +/* max private key size */ +#define ECC_MAXSIZE 66 + +/** Structure defines a NIST GF(p) curve */ +typedef struct { + /** The size of the curve in octets */ + int size; + + /** name of curve */ + char *name; + + /** The prime that defines the field the curve is in (encoded in hex) */ + char *prime; + + /** The fields B param (hex) */ + char *B; + + /** The order of the curve (hex) */ + char *order; + + /** The x co-ordinate of the base point on the curve (hex) */ + char *Gx; + + /** The y co-ordinate of the base point on the curve (hex) */ + char *Gy; +} ltc_ecc_set_type; + +/** A point on a ECC curve, stored in Jacbobian format such that (x,y,z) => (x/z^2, y/z^3, 1) when interpretted as affine */ +typedef struct { + /** The x co-ordinate */ + void *x; + + /** The y co-ordinate */ + void *y; + + /** The z co-ordinate */ + void *z; +} ecc_point; + +/** An ECC key */ +typedef struct { + /** Type of key, PK_PRIVATE or PK_PUBLIC */ + int type; + + /** Index into the ltc_ecc_sets[] for the parameters of this curve; if -1, then this key is using user supplied curve in dp */ + int idx; + + /** pointer to domain parameters; either points to NIST curves (identified by idx >= 0) or user supplied curve */ + const ltc_ecc_set_type *dp; + + /** The public key */ + ecc_point pubkey; + + /** The private key */ + void *k; +} ecc_key; + +/** the ECC params provided */ +extern const ltc_ecc_set_type ltc_ecc_sets[]; + +int ecc_test(void); +void ecc_sizes(int *low, int *high); +int ecc_get_size(ecc_key *key); + +int ecc_make_key(prng_state *prng, int wprng, int keysize, ecc_key *key); +int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_set_type *dp); +void ecc_free(ecc_key *key); + +int ecc_export(unsigned char *out, unsigned long *outlen, int type, ecc_key *key); +int ecc_import(const unsigned char *in, unsigned long inlen, ecc_key *key); +int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, const ltc_ecc_set_type *dp); + +int ecc_ansi_x963_export(ecc_key *key, unsigned char *out, unsigned long *outlen); +int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key); +int ecc_ansi_x963_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp); + +int ecc_shared_secret(ecc_key *private_key, ecc_key *public_key, + unsigned char *out, unsigned long *outlen); + +int ecc_encrypt_key(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + prng_state *prng, int wprng, int hash, + ecc_key *key); + +int ecc_decrypt_key(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + ecc_key *key); + +int ecc_sign_hash(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + prng_state *prng, int wprng, ecc_key *key); + +int ecc_verify_hash(const unsigned char *sig, unsigned long siglen, + const unsigned char *hash, unsigned long hashlen, + int *stat, ecc_key *key); + +/* low level functions */ +ecc_point *ltc_ecc_new_point(void); +void ltc_ecc_del_point(ecc_point *p); +int ltc_ecc_is_valid_idx(int n); + +/* point ops (mp == montgomery digit) */ +#if !defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC) || defined(GMP_LTC_DESC) +/* R = 2P */ +int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp); + +/* R = P + Q */ +int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp); +#endif + +#if defined(LTC_MECC_FP) +/* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */ +int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); + +/* functions for saving/loading/freeing/adding to fixed point cache */ +int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen); +int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen); +void ltc_ecc_fp_free(void); +int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock); + +/* lock/unlock all points currently in fixed point cache */ +void ltc_ecc_fp_tablelock(int lock); +#endif + +/* R = kG */ +int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); + +#ifdef LTC_ECC_SHAMIR +/* kA*A + kB*B = C */ +int ltc_ecc_mul2add(ecc_point *A, void *kA, + ecc_point *B, void *kB, + ecc_point *C, + void *modulus); + +#ifdef LTC_MECC_FP +/* Shamir's trick with optimized point multiplication using fixed point cache */ +int ltc_ecc_fp_mul2add(ecc_point *A, void *kA, + ecc_point *B, void *kB, + ecc_point *C, void *modulus); +#endif + +#endif + + +/* map P to affine from projective */ +int ltc_ecc_map(ecc_point *P, void *modulus, void *mp); + +#endif + +#ifdef LTC_MDSA + +/* Max diff between group and modulus size in bytes */ +#define LTC_MDSA_DELTA 512 + +/* Max DSA group size in bytes (default allows 4k-bit groups) */ +#define LTC_MDSA_MAX_GROUP 512 + +/** DSA key structure */ +typedef struct { + /** The key type, PK_PRIVATE or PK_PUBLIC */ + int type; + + /** The order of the sub-group used in octets */ + int qord; + + /** The generator */ + void *g; + + /** The prime used to generate the sub-group */ + void *q; + + /** The large prime that generats the field the contains the sub-group */ + void *p; + + /** The private key */ + void *x; + + /** The public key */ + void *y; +} dsa_key; + +int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key); +void dsa_free(dsa_key *key); + +int dsa_sign_hash_raw(const unsigned char *in, unsigned long inlen, + void *r, void *s, + prng_state *prng, int wprng, dsa_key *key); + +int dsa_sign_hash(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + prng_state *prng, int wprng, dsa_key *key); + +int dsa_verify_hash_raw( void *r, void *s, + const unsigned char *hash, unsigned long hashlen, + int *stat, dsa_key *key); + +int dsa_verify_hash(const unsigned char *sig, unsigned long siglen, + const unsigned char *hash, unsigned long hashlen, + int *stat, dsa_key *key); + +int dsa_encrypt_key(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + prng_state *prng, int wprng, int hash, + dsa_key *key); + +int dsa_decrypt_key(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + dsa_key *key); + +int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key); +int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key); +int dsa_verify_key(dsa_key *key, int *stat); + +int dsa_shared_secret(void *private_key, void *base, + dsa_key *public_key, + unsigned char *out, unsigned long *outlen); +#endif + +#ifdef LTC_DER +/* DER handling */ + +enum { + LTC_ASN1_EOL, + LTC_ASN1_BOOLEAN, + LTC_ASN1_INTEGER, + LTC_ASN1_SHORT_INTEGER, + LTC_ASN1_BIT_STRING, + LTC_ASN1_OCTET_STRING, + LTC_ASN1_NULL, + LTC_ASN1_OBJECT_IDENTIFIER, + LTC_ASN1_IA5_STRING, + LTC_ASN1_PRINTABLE_STRING, + LTC_ASN1_UTF8_STRING, + LTC_ASN1_UTCTIME, + LTC_ASN1_CHOICE, + LTC_ASN1_SEQUENCE, + LTC_ASN1_SET, + LTC_ASN1_SETOF +}; + +/** A LTC ASN.1 list type */ +typedef struct ltc_asn1_list_ { + /** The LTC ASN.1 enumerated type identifier */ + int type; + /** The data to encode or place for decoding */ + void *data; + /** The size of the input or resulting output */ + unsigned long size; + /** The used flag, this is used by the CHOICE ASN.1 type to indicate which choice was made */ + int used; + /** prev/next entry in the list */ + struct ltc_asn1_list_ *prev, *next, *child, *parent; +} ltc_asn1_list; + +#define LTC_SET_ASN1(list, index, Type, Data, Size) \ + do { \ + int LTC_MACRO_temp = (index); \ + ltc_asn1_list *LTC_MACRO_list = (list); \ + LTC_MACRO_list[LTC_MACRO_temp].type = (Type); \ + LTC_MACRO_list[LTC_MACRO_temp].data = (void*)(Data); \ + LTC_MACRO_list[LTC_MACRO_temp].size = (Size); \ + LTC_MACRO_list[LTC_MACRO_temp].used = 0; \ + } while (0); + +/* SEQUENCE */ +int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen, + unsigned char *out, unsigned long *outlen, int type_of); + +#define der_encode_sequence(list, inlen, out, outlen) der_encode_sequence_ex(list, inlen, out, outlen, LTC_ASN1_SEQUENCE) + +int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen, + ltc_asn1_list *list, unsigned long outlen, int ordered); + +#define der_decode_sequence(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 1) + +int der_length_sequence(ltc_asn1_list *list, unsigned long inlen, + unsigned long *outlen); + +/* SET */ +#define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 0) +#define der_length_set der_length_sequence +int der_encode_set(ltc_asn1_list *list, unsigned long inlen, + unsigned char *out, unsigned long *outlen); + +int der_encode_setof(ltc_asn1_list *list, unsigned long inlen, + unsigned char *out, unsigned long *outlen); + +/* VA list handy helpers with triplets of */ +int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...); +int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...); + +/* FLEXI DECODER handle unknown list decoder */ +int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out); +void der_free_sequence_flexi(ltc_asn1_list *list); +void der_sequence_free(ltc_asn1_list *in); + +/* BOOLEAN */ +int der_length_boolean(unsigned long *outlen); +int der_encode_boolean(int in, + unsigned char *out, unsigned long *outlen); +int der_decode_boolean(const unsigned char *in, unsigned long inlen, + int *out); +/* INTEGER */ +int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen); +int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num); +int der_length_integer(void *num, unsigned long *len); + +/* INTEGER -- handy for 0..2^32-1 values */ +int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num); +int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen); +int der_length_short_integer(unsigned long num, unsigned long *outlen); + +/* BIT STRING */ +int der_encode_bit_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_decode_bit_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_length_bit_string(unsigned long nbits, unsigned long *outlen); + +/* OCTET STRING */ +int der_encode_octet_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_decode_octet_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_length_octet_string(unsigned long noctets, unsigned long *outlen); + +/* OBJECT IDENTIFIER */ +int der_encode_object_identifier(unsigned long *words, unsigned long nwords, + unsigned char *out, unsigned long *outlen); +int der_decode_object_identifier(const unsigned char *in, unsigned long inlen, + unsigned long *words, unsigned long *outlen); +int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen); +unsigned long der_object_identifier_bits(unsigned long x); + +/* IA5 STRING */ +int der_encode_ia5_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_decode_ia5_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen); + +int der_ia5_char_encode(int c); +int der_ia5_value_decode(int v); + +/* Printable STRING */ +int der_encode_printable_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_decode_printable_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); +int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen); + +int der_printable_char_encode(int c); +int der_printable_value_decode(int v); + +/* UTF-8 */ +#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined (__WCHAR_TYPE__)) && !defined(LTC_NO_WCHAR) +#include +#else +typedef ulong32 wchar_t; +#endif + +int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen); + +int der_decode_utf8_string(const unsigned char *in, unsigned long inlen, + wchar_t *out, unsigned long *outlen); +unsigned long der_utf8_charsize(const wchar_t c); +int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen); + + +/* CHOICE */ +int der_decode_choice(const unsigned char *in, unsigned long *inlen, + ltc_asn1_list *list, unsigned long outlen); + +/* UTCTime */ +typedef struct { + unsigned YY, /* year */ + MM, /* month */ + DD, /* day */ + hh, /* hour */ + mm, /* minute */ + ss, /* second */ + off_dir, /* timezone offset direction 0 == +, 1 == - */ + off_hh, /* timezone offset hours */ + off_mm; /* timezone offset minutes */ +} ltc_utctime; + +int der_encode_utctime(ltc_utctime *utctime, + unsigned char *out, unsigned long *outlen); + +int der_decode_utctime(const unsigned char *in, unsigned long *inlen, + ltc_utctime *out); + +int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen); + + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_pk.h,v $ */ +/* $Revision: 1.81 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_pkcs.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_pkcs.h new file mode 100644 index 000000000..84fb82a62 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_pkcs.h @@ -0,0 +1,89 @@ +/* LTC_PKCS Header Info */ + +/* ===> LTC_PKCS #1 -- RSA Cryptography <=== */ +#ifdef LTC_PKCS_1 + +enum ltc_pkcs_1_v1_5_blocks +{ + LTC_LTC_PKCS_1_EMSA = 1, /* Block type 1 (LTC_PKCS #1 v1.5 signature padding) */ + LTC_LTC_PKCS_1_EME = 2 /* Block type 2 (LTC_PKCS #1 v1.5 encryption padding) */ +}; + +enum ltc_pkcs_1_paddings +{ + LTC_LTC_PKCS_1_V1_5 = 1, /* LTC_PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */ + LTC_LTC_PKCS_1_OAEP = 2, /* LTC_PKCS #1 v2.0 encryption padding */ + LTC_LTC_PKCS_1_PSS = 3 /* LTC_PKCS #1 v2.1 signature padding */ +}; + +int pkcs_1_mgf1( int hash_idx, + const unsigned char *seed, unsigned long seedlen, + unsigned char *mask, unsigned long masklen); + +int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out); +int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen); + +/* *** v1.5 padding */ +int pkcs_1_v1_5_encode(const unsigned char *msg, + unsigned long msglen, + int block_type, + unsigned long modulus_bitlen, + prng_state *prng, + int prng_idx, + unsigned char *out, + unsigned long *outlen); + +int pkcs_1_v1_5_decode(const unsigned char *msg, + unsigned long msglen, + int block_type, + unsigned long modulus_bitlen, + unsigned char *out, + unsigned long *outlen, + int *is_valid); + +/* *** v2.1 padding */ +int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen, + const unsigned char *lparam, unsigned long lparamlen, + unsigned long modulus_bitlen, prng_state *prng, + int prng_idx, int hash_idx, + unsigned char *out, unsigned long *outlen); + +int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen, + const unsigned char *lparam, unsigned long lparamlen, + unsigned long modulus_bitlen, int hash_idx, + unsigned char *out, unsigned long *outlen, + int *res); + +int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, + unsigned long saltlen, prng_state *prng, + int prng_idx, int hash_idx, + unsigned long modulus_bitlen, + unsigned char *out, unsigned long *outlen); + +int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen, + const unsigned char *sig, unsigned long siglen, + unsigned long saltlen, int hash_idx, + unsigned long modulus_bitlen, int *res); + +#endif /* LTC_PKCS_1 */ + +/* ===> LTC_PKCS #5 -- Password Based Cryptography <=== */ +#ifdef LTC_PKCS_5 + +/* Algorithm #1 (old) */ +int pkcs_5_alg1(const unsigned char *password, unsigned long password_len, + const unsigned char *salt, + int iteration_count, int hash_idx, + unsigned char *out, unsigned long *outlen); + +/* Algorithm #2 (new) */ +int pkcs_5_alg2(const unsigned char *password, unsigned long password_len, + const unsigned char *salt, unsigned long salt_len, + int iteration_count, int hash_idx, + unsigned char *out, unsigned long *outlen); + +#endif /* LTC_PKCS_5 */ + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_pkcs.h,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_prng.h b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_prng.h new file mode 100644 index 000000000..f3e3e550e --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/headers/tomcrypt_prng.h @@ -0,0 +1,199 @@ +/* ---- PRNG Stuff ---- */ +#ifdef LTC_YARROW +struct yarrow_prng { + int cipher, hash; + unsigned char pool[MAXBLOCKSIZE]; + symmetric_CTR ctr; + LTC_MUTEX_TYPE(prng_lock) +}; +#endif + +#ifdef LTC_RC4 +struct rc4_prng { + int x, y; + unsigned char buf[256]; +}; +#endif + +#ifdef LTC_FORTUNA +struct fortuna_prng { + hash_state pool[LTC_FORTUNA_POOLS]; /* the pools */ + + symmetric_key skey; + + unsigned char K[32], /* the current key */ + IV[16]; /* IV for CTR mode */ + + unsigned long pool_idx, /* current pool we will add to */ + pool0_len, /* length of 0'th pool */ + wd; + + ulong64 reset_cnt; /* number of times we have reset */ + LTC_MUTEX_TYPE(prng_lock) +}; +#endif + +#ifdef LTC_SOBER128 +struct sober128_prng { + ulong32 R[17], /* Working storage for the shift register */ + initR[17], /* saved register contents */ + konst, /* key dependent constant */ + sbuf; /* partial word encryption buffer */ + + int nbuf, /* number of part-word stream bits buffered */ + flag, /* first add_entropy call or not? */ + set; /* did we call add_entropy to set key? */ + +}; +#endif + +typedef union Prng_state { + char dummy[1]; +#ifdef LTC_YARROW + struct yarrow_prng yarrow; +#endif +#ifdef LTC_RC4 + struct rc4_prng rc4; +#endif +#ifdef LTC_FORTUNA + struct fortuna_prng fortuna; +#endif +#ifdef LTC_SOBER128 + struct sober128_prng sober128; +#endif +} prng_state; + +/** PRNG descriptor */ +extern struct ltc_prng_descriptor { + /** Name of the PRNG */ + char *name; + /** size in bytes of exported state */ + int export_size; + /** Start a PRNG state + @param prng [out] The state to initialize + @return CRYPT_OK if successful + */ + int (*start)(prng_state *prng); + /** Add entropy to the PRNG + @param in The entropy + @param inlen Length of the entropy (octets)\ + @param prng The PRNG state + @return CRYPT_OK if successful + */ + int (*add_entropy)(const unsigned char *in, unsigned long inlen, prng_state *prng); + /** Ready a PRNG state to read from + @param prng The PRNG state to ready + @return CRYPT_OK if successful + */ + int (*ready)(prng_state *prng); + /** Read from the PRNG + @param out [out] Where to store the data + @param outlen Length of data desired (octets) + @param prng The PRNG state to read from + @return Number of octets read + */ + unsigned long (*read)(unsigned char *out, unsigned long outlen, prng_state *prng); + /** Terminate a PRNG state + @param prng The PRNG state to terminate + @return CRYPT_OK if successful + */ + int (*done)(prng_state *prng); + /** Export a PRNG state + @param out [out] The destination for the state + @param outlen [in/out] The max size and resulting size of the PRNG state + @param prng The PRNG to export + @return CRYPT_OK if successful + */ + int (*pexport)(unsigned char *out, unsigned long *outlen, prng_state *prng); + /** Import a PRNG state + @param in The data to import + @param inlen The length of the data to import (octets) + @param prng The PRNG to initialize/import + @return CRYPT_OK if successful + */ + int (*pimport)(const unsigned char *in, unsigned long inlen, prng_state *prng); + /** Self-test the PRNG + @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled + */ + int (*test)(void); +} prng_descriptor[]; + +#ifdef LTC_YARROW +int yarrow_start(prng_state *prng); +int yarrow_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); +int yarrow_ready(prng_state *prng); +unsigned long yarrow_read(unsigned char *out, unsigned long outlen, prng_state *prng); +int yarrow_done(prng_state *prng); +int yarrow_export(unsigned char *out, unsigned long *outlen, prng_state *prng); +int yarrow_import(const unsigned char *in, unsigned long inlen, prng_state *prng); +int yarrow_test(void); +extern const struct ltc_prng_descriptor yarrow_desc; +#endif + +#ifdef LTC_FORTUNA +int fortuna_start(prng_state *prng); +int fortuna_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); +int fortuna_ready(prng_state *prng); +unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state *prng); +int fortuna_done(prng_state *prng); +int fortuna_export(unsigned char *out, unsigned long *outlen, prng_state *prng); +int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prng); +int fortuna_test(void); +extern const struct ltc_prng_descriptor fortuna_desc; +#endif + +#ifdef LTC_RC4 +int rc4_start(prng_state *prng); +int rc4_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); +int rc4_ready(prng_state *prng); +unsigned long rc4_read(unsigned char *out, unsigned long outlen, prng_state *prng); +int rc4_done(prng_state *prng); +int rc4_export(unsigned char *out, unsigned long *outlen, prng_state *prng); +int rc4_import(const unsigned char *in, unsigned long inlen, prng_state *prng); +int rc4_test(void); +extern const struct ltc_prng_descriptor rc4_desc; +#endif + +#ifdef LTC_SPRNG +int sprng_start(prng_state *prng); +int sprng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); +int sprng_ready(prng_state *prng); +unsigned long sprng_read(unsigned char *out, unsigned long outlen, prng_state *prng); +int sprng_done(prng_state *prng); +int sprng_export(unsigned char *out, unsigned long *outlen, prng_state *prng); +int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng); +int sprng_test(void); +extern const struct ltc_prng_descriptor sprng_desc; +#endif + +#ifdef LTC_SOBER128 +int sober128_start(prng_state *prng); +int sober128_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); +int sober128_ready(prng_state *prng); +unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state *prng); +int sober128_done(prng_state *prng); +int sober128_export(unsigned char *out, unsigned long *outlen, prng_state *prng); +int sober128_import(const unsigned char *in, unsigned long inlen, prng_state *prng); +int sober128_test(void); +extern const struct ltc_prng_descriptor sober128_desc; +#endif + +int find_prng(const char *name); +int register_prng(const struct ltc_prng_descriptor *prng); +int unregister_prng(const struct ltc_prng_descriptor *prng); +int prng_is_valid(int idx); +LTC_MUTEX_PROTO(ltc_prng_mutex) + +/* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this + * might not work on all platforms as planned + */ +unsigned long rng_get_bytes(unsigned char *out, + unsigned long outlen, + void (*callback)(void)); + +int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void)); + + +/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_prng.h,v $ */ +/* $Revision: 1.9 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/math/ltm_desc.c b/dep/StormLib/src/libtomcrypt/src/math/ltm_desc.c new file mode 100644 index 000000000..25dc0b322 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/math/ltm_desc.c @@ -0,0 +1,483 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +#define DESC_DEF_ONLY +#include "../headers/tomcrypt.h" + +#ifdef LTM_DESC + +#include "../../../libtommath/tommath.h" + +static const struct { + int mpi_code, ltc_code; +} mpi_to_ltc_codes[] = { + { MP_OKAY , CRYPT_OK}, + { MP_MEM , CRYPT_MEM}, + { MP_VAL , CRYPT_INVALID_ARG}, +}; + +/** + Convert a MPI error to a LTC error (Possibly the most powerful function ever! Oh wait... no) + @param err The error to convert + @return The equivalent LTC error code or CRYPT_ERROR if none found +*/ +static int mpi_to_ltc_error(int err) +{ + int x; + + for (x = 0; x < (int)(sizeof(mpi_to_ltc_codes)/sizeof(mpi_to_ltc_codes[0])); x++) { + if (err == mpi_to_ltc_codes[x].mpi_code) { + return mpi_to_ltc_codes[x].ltc_code; + } + } + return CRYPT_ERROR; +} + +static int init(void **a) +{ + int err; + + LTC_ARGCHK(a != NULL); + + *a = XCALLOC(1, sizeof(mp_int)); + if (*a == NULL) { + return CRYPT_MEM; + } + + if ((err = mpi_to_ltc_error(mp_init(*a))) != CRYPT_OK) { + XFREE(*a); + } + return err; +} + +static void deinit(void *a) +{ + LTC_ARGCHKVD(a != NULL); + mp_clear(a); + XFREE(a); +} + +static int neg(void *a, void *b) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_neg(a, b)); +} + +static int copy(void *a, void *b) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_copy(a, b)); +} + +static int init_copy(void **a, void *b) +{ + if (init(a) != CRYPT_OK) { + return CRYPT_MEM; + } + return copy(b, *a); +} + +/* ---- trivial ---- */ +static int set_int(void *a, unsigned long b) +{ + LTC_ARGCHK(a != NULL); + return mpi_to_ltc_error(mp_set_int(a, b)); +} + +static unsigned long get_int(void *a) +{ + LTC_ARGCHK(a != NULL); + return mp_get_int(a); +} + +static unsigned long get_digit(void *a, int n) +{ + mp_int *A; + LTC_ARGCHK(a != NULL); + A = a; + return (n >= A->used || n < 0) ? 0 : A->dp[n]; +} + +static int get_digit_count(void *a) +{ + mp_int *A; + LTC_ARGCHK(a != NULL); + A = a; + return A->used; +} + +static int compare(void *a, void *b) +{ + int ret; + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + ret = mp_cmp(a, b); + switch (ret) { + case MP_LT: return LTC_MP_LT; + case MP_EQ: return LTC_MP_EQ; + case MP_GT: return LTC_MP_GT; + } + return 0; +} + +static int compare_d(void *a, unsigned long b) +{ + int ret; + LTC_ARGCHK(a != NULL); + ret = mp_cmp_d(a, b); + switch (ret) { + case MP_LT: return LTC_MP_LT; + case MP_EQ: return LTC_MP_EQ; + case MP_GT: return LTC_MP_GT; + } + return 0; +} + +static int count_bits(void *a) +{ + LTC_ARGCHK(a != NULL); + return mp_count_bits(a); +} + +static int count_lsb_bits(void *a) +{ + LTC_ARGCHK(a != NULL); + return mp_cnt_lsb(a); +} + + +static int twoexpt(void *a, int n) +{ + LTC_ARGCHK(a != NULL); + return mpi_to_ltc_error(mp_2expt(a, n)); +} + +/* ---- conversions ---- */ + +/* read ascii string */ +static int read_radix(void *a, const char *b, int radix) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_read_radix(a, b, radix)); +} + +/* write one */ +static int write_radix(void *a, char *b, int radix) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_toradix(a, b, radix)); +} + +/* get size as unsigned char string */ +static unsigned long unsigned_size(void *a) +{ + LTC_ARGCHK(a != NULL); + return mp_unsigned_bin_size(a); +} + +/* store */ +static int unsigned_write(void *a, unsigned char *b) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_to_unsigned_bin(a, b)); +} + +/* read */ +static int unsigned_read(void *a, unsigned char *b, unsigned long len) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_read_unsigned_bin(a, b, len)); +} + +/* add */ +static int add(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_add(a, b, c)); +} + +static int addi(void *a, unsigned long b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_add_d(a, b, c)); +} + +/* sub */ +static int sub(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_sub(a, b, c)); +} + +static int subi(void *a, unsigned long b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_sub_d(a, b, c)); +} + +/* mul */ +static int mul(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_mul(a, b, c)); +} + +static int muli(void *a, unsigned long b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_mul_d(a, b, c)); +} + +/* sqr */ +static int sqr(void *a, void *b) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_sqr(a, b)); +} + +/* div */ +static int divide(void *a, void *b, void *c, void *d) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_div(a, b, c, d)); +} + +static int div_2(void *a, void *b) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_div_2(a, b)); +} + +/* modi */ +static int modi(void *a, unsigned long b, unsigned long *c) +{ + mp_digit tmp; + int err; + + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(c != NULL); + + if ((err = mpi_to_ltc_error(mp_mod_d(a, b, &tmp))) != CRYPT_OK) { + return err; + } + *c = tmp; + return CRYPT_OK; +} + +/* gcd */ +static int gcd(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_gcd(a, b, c)); +} + +/* lcm */ +static int lcm(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_lcm(a, b, c)); +} + +static int mulmod(void *a, void *b, void *c, void *d) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + LTC_ARGCHK(d != NULL); + return mpi_to_ltc_error(mp_mulmod(a,b,c,d)); +} + +static int sqrmod(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_sqrmod(a,b,c)); +} + +/* invmod */ +static int invmod(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_invmod(a, b, c)); +} + +/* setup */ +static int montgomery_setup(void *a, void **b) +{ + int err; + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + *b = XCALLOC(1, sizeof(mp_digit)); + if (*b == NULL) { + return CRYPT_MEM; + } + if ((err = mpi_to_ltc_error(mp_montgomery_setup(a, (mp_digit *)*b))) != CRYPT_OK) { + XFREE(*b); + } + return err; +} + +/* get normalization value */ +static int montgomery_normalization(void *a, void *b) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + return mpi_to_ltc_error(mp_montgomery_calc_normalization(a, b)); +} + +/* reduce */ +static int montgomery_reduce(void *a, void *b, void *c) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + return mpi_to_ltc_error(mp_montgomery_reduce(a, b, *((mp_digit *)c))); +} + +/* clean up */ +static void montgomery_deinit(void *a) +{ + XFREE(a); +} + +static int exptmod(void *a, void *b, void *c, void *d) +{ + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + LTC_ARGCHK(c != NULL); + LTC_ARGCHK(d != NULL); + return mpi_to_ltc_error(mp_exptmod(a,b,c,d)); +} + +static int isprime(void *a, int *b) +{ + int err; + LTC_ARGCHK(a != NULL); + LTC_ARGCHK(b != NULL); + err = mpi_to_ltc_error(mp_prime_is_prime(a, 8, b)); + *b = (*b == MP_YES) ? LTC_MP_YES : LTC_MP_NO; + return err; +} + +const ltc_math_descriptor ltm_desc = { + + "LibTomMath", + (int)DIGIT_BIT, + + &init, + &init_copy, + &deinit, + + &neg, + ©, + + &set_int, + &get_int, + &get_digit, + &get_digit_count, + &compare, + &compare_d, + &count_bits, + &count_lsb_bits, + &twoexpt, + + &read_radix, + &write_radix, + &unsigned_size, + &unsigned_write, + &unsigned_read, + + &add, + &addi, + &sub, + &subi, + &mul, + &muli, + &sqr, + ÷, + &div_2, + &modi, + &gcd, + &lcm, + + &mulmod, + &sqrmod, + &invmod, + + &montgomery_setup, + &montgomery_normalization, + &montgomery_reduce, + &montgomery_deinit, + + &exptmod, + &isprime, + +#ifdef LTC_MECC +#ifdef LTC_MECC_FP + <c_ecc_fp_mulmod, +#else + <c_ecc_mulmod, +#endif + <c_ecc_projective_add_point, + <c_ecc_projective_dbl_point, + <c_ecc_map, +#ifdef LTC_ECC_SHAMIR +#ifdef LTC_MECC_FP + <c_ecc_fp_mul2add, +#else + <c_ecc_mul2add, +#endif /* LTC_MECC_FP */ +#else + NULL, +#endif /* LTC_ECC_SHAMIR */ +#else + NULL, NULL, NULL, NULL, NULL, +#endif /* LTC_MECC */ + +#ifdef LTC_MRSA + &rsa_make_key, + &rsa_exptmod, +#else + NULL, NULL +#endif +}; + + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/math/ltm_desc.c,v $ */ +/* $Revision: 1.31 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/math/multi.c b/dep/StormLib/src/libtomcrypt/src/math/multi.c new file mode 100644 index 000000000..7d40040a1 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/math/multi.c @@ -0,0 +1,61 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +#ifdef MPI +#include + +int ltc_init_multi(void **a, ...) +{ + void **cur = a; + int np = 0; + va_list args; + + va_start(args, a); + while (cur != NULL) { + if (mp_init(cur) != CRYPT_OK) { + /* failed */ + va_list clean_list; + + va_start(clean_list, a); + cur = a; + while (np--) { + mp_clear(*cur); + cur = va_arg(clean_list, void**); + } + va_end(clean_list); + return CRYPT_MEM; + } + ++np; + cur = va_arg(args, void**); + } + va_end(args); + return CRYPT_OK; +} + +void ltc_deinit_multi(void *a, ...) +{ + void *cur = a; + va_list args; + + va_start(args, a); + while (cur != NULL) { + mp_clear(cur); + cur = va_arg(args, void *); + } + va_end(args); +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/math/multi.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:27:23 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/math/rand_prime.c b/dep/StormLib/src/libtomcrypt/src/math/rand_prime.c new file mode 100644 index 000000000..913fa95a4 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/math/rand_prime.c @@ -0,0 +1,87 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file rand_prime.c + Generate a random prime, Tom St Denis +*/ + +#define USE_BBS 1 + +int rand_prime(void *N, long len, prng_state *prng, int wprng) +{ + int err, res, type; + unsigned char *buf; + + LTC_ARGCHK(N != NULL); + + /* get type */ + if (len < 0) { + type = USE_BBS; + len = -len; + } else { + type = 0; + } + + /* allow sizes between 2 and 512 bytes for a prime size */ + if (len < 2 || len > 512) { + return CRYPT_INVALID_PRIME_SIZE; + } + + /* valid PRNG? Better be! */ + if ((err = prng_is_valid(wprng)) != CRYPT_OK) { + return err; + } + + /* allocate buffer to work with */ + buf = XCALLOC(1, len); + if (buf == NULL) { + return CRYPT_MEM; + } + + do { + /* generate value */ + if (prng_descriptor[wprng].read(buf, len, prng) != (unsigned long)len) { + XFREE(buf); + return CRYPT_ERROR_READPRNG; + } + + /* munge bits */ + buf[0] |= 0x80 | 0x40; + buf[len-1] |= 0x01 | ((type & USE_BBS) ? 0x02 : 0x00); + + /* load value */ + if ((err = mp_read_unsigned_bin(N, buf, len)) != CRYPT_OK) { + XFREE(buf); + return err; + } + + /* test */ + if ((err = mp_prime_is_prime(N, 8, &res)) != CRYPT_OK) { + XFREE(buf); + return err; + } + } while (res == LTC_MP_NO); + +#ifdef LTC_CLEAN_STACK + zeromem(buf, len); +#endif + + XFREE(buf); + return CRYPT_OK; +} + + + +/* $Source: /cvs/libtom/libtomcrypt/src/math/rand_prime.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/12/28 01:27:23 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/base64_decode.c b/dep/StormLib/src/libtomcrypt/src/misc/base64_decode.c new file mode 100644 index 000000000..3d13393a1 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/base64_decode.c @@ -0,0 +1,104 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file base64_decode.c + Compliant base64 code donated by Wayne Scott (wscott@bitmover.com) +*/ + + +#ifdef LTC_BASE64 + +static const unsigned char map[256] = { +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, +255, 254, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, +255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 255 }; + +/** + base64 decode a block of memory + @param in The base64 data to decode + @param inlen The length of the base64 data + @param out [out] The destination of the binary decoded data + @param outlen [in/out] The max size and resulting size of the decoded data + @return CRYPT_OK if successful +*/ +int base64_decode(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long t, x, y, z; + unsigned char c; + int g; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + g = 3; + for (x = y = z = t = 0; x < inlen; x++) { + c = map[in[x]&0xFF]; + if (c == 255) continue; + /* the final = symbols are read and used to trim the remaining bytes */ + if (c == 254) { + c = 0; + /* prevent g < 0 which would potentially allow an overflow later */ + if (--g < 0) { + return CRYPT_INVALID_PACKET; + } + } else if (g != 3) { + /* we only allow = to be at the end */ + return CRYPT_INVALID_PACKET; + } + + t = (t<<6)|c; + + if (++y == 4) { + if (z + g > *outlen) { + return CRYPT_BUFFER_OVERFLOW; + } + out[z++] = (unsigned char)((t>>16)&255); + if (g > 1) out[z++] = (unsigned char)((t>>8)&255); + if (g > 2) out[z++] = (unsigned char)(t&255); + y = t = 0; + } + } + if (y != 0) { + return CRYPT_INVALID_PACKET; + } + *outlen = z; + return CRYPT_OK; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/base64/base64_decode.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_argchk.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_argchk.c new file mode 100644 index 000000000..537516d80 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_argchk.c @@ -0,0 +1,30 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" +#include + +/** + @file crypt_argchk.c + Perform argument checking, Tom St Denis +*/ + +#if (ARGTYPE == 0) +void crypt_argchk(char *v, char *s, int d) +{ + fprintf(stderr, "LTC_ARGCHK '%s' failure on line %d of file %s\n", + v, d, s); + (void)raise(SIGABRT); +} +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_argchk.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_find_hash.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_find_hash.c new file mode 100644 index 000000000..fef2d8cca --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_find_hash.c @@ -0,0 +1,40 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_find_hash.c + Find a hash, Tom St Denis +*/ + +/** + Find a registered hash by name + @param name The name of the hash to look for + @return >= 0 if found, -1 if not present +*/ +int find_hash(const char *name) +{ + int x; + LTC_ARGCHK(name != NULL); + LTC_MUTEX_LOCK(<c_hash_mutex); + for (x = 0; x < TAB_SIZE; x++) { + if (hash_descriptor[x].name != NULL && XSTRCMP(hash_descriptor[x].name, name) == 0) { + LTC_MUTEX_UNLOCK(<c_hash_mutex); + return x; + } + } + LTC_MUTEX_UNLOCK(<c_hash_mutex); + return -1; +} + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_hash.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_find_prng.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_find_prng.c new file mode 100644 index 000000000..fafbb0e22 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_find_prng.c @@ -0,0 +1,41 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_find_prng.c + Find a PRNG, Tom St Denis +*/ + +/** + Find a registered PRNG by name + @param name The name of the PRNG to look for + @return >= 0 if found, -1 if not present +*/ +int find_prng(const char *name) +{ + int x; + LTC_ARGCHK(name != NULL); + LTC_MUTEX_LOCK(<c_prng_mutex); + for (x = 0; x < TAB_SIZE; x++) { + if ((prng_descriptor[x].name != NULL) && XSTRCMP(prng_descriptor[x].name, name) == 0) { + LTC_MUTEX_UNLOCK(<c_prng_mutex); + return x; + } + } + LTC_MUTEX_UNLOCK(<c_prng_mutex); + return -1; +} + + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_prng.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c new file mode 100644 index 000000000..5925fd273 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c @@ -0,0 +1,27 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_hash_descriptor.c + Stores the hash descriptor table, Tom St Denis +*/ + +struct ltc_hash_descriptor hash_descriptor[TAB_SIZE] = { +{ NULL, 0, 0, 0, { 0 }, 0, NULL, NULL, NULL, NULL, NULL } +}; + +LTC_MUTEX_GLOBAL(ltc_hash_mutex) + + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_descriptor.c,v $ */ +/* $Revision: 1.10 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c new file mode 100644 index 000000000..8ed5105b5 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c @@ -0,0 +1,36 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_hash_is_valid.c + Determine if hash is valid, Tom St Denis +*/ + +/* + Test if a hash index is valid + @param idx The index of the hash to search for + @return CRYPT_OK if valid +*/ +int hash_is_valid(int idx) +{ + LTC_MUTEX_LOCK(<c_hash_mutex); + if (idx < 0 || idx >= TAB_SIZE || hash_descriptor[idx].name == NULL) { + LTC_MUTEX_UNLOCK(<c_hash_mutex); + return CRYPT_INVALID_HASH; + } + LTC_MUTEX_UNLOCK(<c_hash_mutex); + return CRYPT_OK; +} + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_libc.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_libc.c new file mode 100644 index 000000000..bcc89f4f9 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_libc.c @@ -0,0 +1,43 @@ +/*****************************************************************************/ +/* crypt_libc.c Copyright (c) Ladislav Zezula 2010 */ +/*---------------------------------------------------------------------------*/ +/* Description: */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 05.05.10 1.00 Lad The first version of crypt_libc.c */ +/*****************************************************************************/ + +// LibTomCrypt header +#include +#include "../headers/tomcrypt.h" + +void * LibTomMalloc(size_t n) +{ + return malloc(n); +} + +void * LibTomCalloc(size_t n, size_t s) +{ + return calloc(n, s); +} + +void * LibTomRealloc(void *p, size_t n) +{ + return realloc(p, n); +} + +void LibTomFree(void * p) +{ + free(p); +} + +clock_t LibTomClock(void) +{ + return clock(); +} + +void LibTomQsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)) +{ + qsort(base, nmemb, size, compar); +} diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c new file mode 100644 index 000000000..91ba9d162 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c @@ -0,0 +1,13 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +ltc_math_descriptor ltc_mp; diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_prng_descriptor.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_prng_descriptor.c new file mode 100644 index 000000000..c5b39e0c2 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_prng_descriptor.c @@ -0,0 +1,26 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_prng_descriptor.c + Stores the PRNG descriptors, Tom St Denis +*/ +struct ltc_prng_descriptor prng_descriptor[TAB_SIZE] = { +{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } +}; + +LTC_MUTEX_GLOBAL(ltc_prng_mutex) + + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_prng_descriptor.c,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_prng_is_valid.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_prng_is_valid.c new file mode 100644 index 000000000..d38fd3a3c --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_prng_is_valid.c @@ -0,0 +1,36 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_prng_is_valid.c + Determine if PRNG is valid, Tom St Denis +*/ + +/* + Test if a PRNG index is valid + @param idx The index of the PRNG to search for + @return CRYPT_OK if valid +*/ +int prng_is_valid(int idx) +{ + LTC_MUTEX_LOCK(<c_prng_mutex); + if (idx < 0 || idx >= TAB_SIZE || prng_descriptor[idx].name == NULL) { + LTC_MUTEX_UNLOCK(<c_prng_mutex); + return CRYPT_INVALID_PRNG; + } + LTC_MUTEX_UNLOCK(<c_prng_mutex); + return CRYPT_OK; +} + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_prng_is_valid.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_register_hash.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_register_hash.c new file mode 100644 index 000000000..173009154 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_register_hash.c @@ -0,0 +1,54 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_register_hash.c + Register a HASH, Tom St Denis +*/ + +/** + Register a hash with the descriptor table + @param hash The hash you wish to register + @return value >= 0 if successfully added (or already present), -1 if unsuccessful +*/ +int register_hash(const struct ltc_hash_descriptor *hash) +{ + int x; + + LTC_ARGCHK(hash != NULL); + + /* is it already registered? */ + LTC_MUTEX_LOCK(<c_hash_mutex); + for (x = 0; x < TAB_SIZE; x++) { + if (XMEMCMP(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) { + LTC_MUTEX_UNLOCK(<c_hash_mutex); + return x; + } + } + + /* find a blank spot */ + for (x = 0; x < TAB_SIZE; x++) { + if (hash_descriptor[x].name == NULL) { + XMEMCPY(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)); + LTC_MUTEX_UNLOCK(<c_hash_mutex); + return x; + } + } + + /* no spot */ + LTC_MUTEX_UNLOCK(<c_hash_mutex); + return -1; +} + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_register_hash.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/crypt_register_prng.c b/dep/StormLib/src/libtomcrypt/src/misc/crypt_register_prng.c new file mode 100644 index 000000000..29fc9bdf6 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/crypt_register_prng.c @@ -0,0 +1,54 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file crypt_register_prng.c + Register a PRNG, Tom St Denis +*/ + +/** + Register a PRNG with the descriptor table + @param prng The PRNG you wish to register + @return value >= 0 if successfully added (or already present), -1 if unsuccessful +*/ +int register_prng(const struct ltc_prng_descriptor *prng) +{ + int x; + + LTC_ARGCHK(prng != NULL); + + /* is it already registered? */ + LTC_MUTEX_LOCK(<c_prng_mutex); + for (x = 0; x < TAB_SIZE; x++) { + if (XMEMCMP(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) == 0) { + LTC_MUTEX_UNLOCK(<c_prng_mutex); + return x; + } + } + + /* find a blank spot */ + for (x = 0; x < TAB_SIZE; x++) { + if (prng_descriptor[x].name == NULL) { + XMEMCPY(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)); + LTC_MUTEX_UNLOCK(<c_prng_mutex); + return x; + } + } + + /* no spot */ + LTC_MUTEX_UNLOCK(<c_prng_mutex); + return -1; +} + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_register_prng.c,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/misc/zeromem.c b/dep/StormLib/src/libtomcrypt/src/misc/zeromem.c new file mode 100644 index 000000000..faa0efa78 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/misc/zeromem.c @@ -0,0 +1,34 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../headers/tomcrypt.h" + +/** + @file zeromem.c + Zero a block of memory, Tom St Denis +*/ + +/** + Zero a block of memory + @param out The destination of the area to zero + @param outlen The length of the area to zero (octets) +*/ +void zeromem(void *out, size_t outlen) +{ + unsigned char *mem = out; + LTC_ARGCHKVD(out != NULL); + while (outlen-- > 0) { + *mem++ = 0; + } +} + +/* $Source: /cvs/libtom/libtomcrypt/src/misc/zeromem.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c new file mode 100644 index 000000000..e53686750 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c @@ -0,0 +1,102 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_bit_string.c + ASN.1 DER, encode a BIT STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a BIT STRING + @param in The DER encoded BIT STRING + @param inlen The size of the DER BIT STRING + @param out [out] The array of bits stored (one per char) + @param outlen [in/out] The number of bits stored + @return CRYPT_OK if successful +*/ +int der_decode_bit_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long dlen, blen, x, y; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* packet must be at least 4 bytes */ + if (inlen < 4) { + return CRYPT_INVALID_ARG; + } + + /* check for 0x03 */ + if ((in[0]&0x1F) != 0x03) { + return CRYPT_INVALID_PACKET; + } + + /* offset in the data */ + x = 1; + + /* get the length of the data */ + if (in[x] & 0x80) { + /* long format get number of length bytes */ + y = in[x++] & 0x7F; + + /* invalid if 0 or > 2 */ + if (y == 0 || y > 2) { + return CRYPT_INVALID_PACKET; + } + + /* read the data len */ + dlen = 0; + while (y--) { + dlen = (dlen << 8) | (unsigned long)in[x++]; + } + } else { + /* short format */ + dlen = in[x++] & 0x7F; + } + + /* is the data len too long or too short? */ + if ((dlen == 0) || (dlen + x > inlen)) { + return CRYPT_INVALID_PACKET; + } + + /* get padding count */ + blen = ((dlen - 1) << 3) - (in[x++] & 7); + + /* too many bits? */ + if (blen > *outlen) { + *outlen = blen; + return CRYPT_BUFFER_OVERFLOW; + } + + /* decode/store the bits */ + for (y = 0; y < blen; y++) { + out[y] = (in[x] & (1 << (7 - (y & 7)))) ? 1 : 0; + if ((y & 7) == 7) { + ++x; + } + } + + /* we done */ + *outlen = blen; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_decode_bit_string.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_boolean.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_boolean.c new file mode 100644 index 000000000..617d4e861 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_boolean.c @@ -0,0 +1,47 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_boolean.c + ASN.1 DER, decode a BOOLEAN, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Read a BOOLEAN + @param in The destination for the DER encoded BOOLEAN + @param inlen The size of the DER BOOLEAN + @param out [out] The boolean to decode + @return CRYPT_OK if successful +*/ +int der_decode_boolean(const unsigned char *in, unsigned long inlen, + int *out) +{ + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + + if (inlen != 3 || in[0] != 0x01 || in[1] != 0x01 || (in[2] != 0x00 && in[2] != 0xFF)) { + return CRYPT_INVALID_ARG; + } + + *out = (in[2]==0xFF) ? 1 : 0; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/boolean/der_decode_boolean.c,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_choice.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_choice.c new file mode 100644 index 000000000..44a0891be --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_choice.c @@ -0,0 +1,182 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_choice.c + ASN.1 DER, decode a CHOICE, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Decode a CHOICE + @param in The DER encoded input + @param inlen [in/out] The size of the input and resulting size of read type + @param list The list of items to decode + @param outlen The number of items in the list + @return CRYPT_OK on success +*/ +int der_decode_choice(const unsigned char *in, unsigned long *inlen, + ltc_asn1_list *list, unsigned long outlen) +{ + unsigned long size, x, z; + void *data; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(inlen != NULL); + LTC_ARGCHK(list != NULL); + + /* get blk size */ + if (*inlen < 2) { + return CRYPT_INVALID_PACKET; + } + + /* set all of the "used" flags to zero */ + for (x = 0; x < outlen; x++) { + list[x].used = 0; + } + + /* now scan until we have a winner */ + for (x = 0; x < outlen; x++) { + size = list[x].size; + data = list[x].data; + + switch (list[x].type) { + case LTC_ASN1_INTEGER: + if (der_decode_integer(in, *inlen, data) == CRYPT_OK) { + if (der_length_integer(data, &z) == CRYPT_OK) { + list[x].used = 1; + *inlen = z; + return CRYPT_OK; + } + } + break; + + case LTC_ASN1_SHORT_INTEGER: + if (der_decode_short_integer(in, *inlen, data) == CRYPT_OK) { + if (der_length_short_integer(size, &z) == CRYPT_OK) { + list[x].used = 1; + *inlen = z; + return CRYPT_OK; + } + } + break; + + case LTC_ASN1_BIT_STRING: + if (der_decode_bit_string(in, *inlen, data, &size) == CRYPT_OK) { + if (der_length_bit_string(size, &z) == CRYPT_OK) { + list[x].used = 1; + list[x].size = size; + *inlen = z; + return CRYPT_OK; + } + } + break; + + case LTC_ASN1_OCTET_STRING: + if (der_decode_octet_string(in, *inlen, data, &size) == CRYPT_OK) { + if (der_length_octet_string(size, &z) == CRYPT_OK) { + list[x].used = 1; + list[x].size = size; + *inlen = z; + return CRYPT_OK; + } + } + break; + + case LTC_ASN1_NULL: + if (*inlen == 2 && in[x] == 0x05 && in[x+1] == 0x00) { + *inlen = 2; + list[x].used = 1; + return CRYPT_OK; + } + break; + + case LTC_ASN1_OBJECT_IDENTIFIER: + if (der_decode_object_identifier(in, *inlen, data, &size) == CRYPT_OK) { + if (der_length_object_identifier(data, size, &z) == CRYPT_OK) { + list[x].used = 1; + list[x].size = size; + *inlen = z; + return CRYPT_OK; + } + } + break; + + case LTC_ASN1_IA5_STRING: + if (der_decode_ia5_string(in, *inlen, data, &size) == CRYPT_OK) { + if (der_length_ia5_string(data, size, &z) == CRYPT_OK) { + list[x].used = 1; + list[x].size = size; + *inlen = z; + return CRYPT_OK; + } + } + break; + + + case LTC_ASN1_PRINTABLE_STRING: + if (der_decode_printable_string(in, *inlen, data, &size) == CRYPT_OK) { + if (der_length_printable_string(data, size, &z) == CRYPT_OK) { + list[x].used = 1; + list[x].size = size; + *inlen = z; + return CRYPT_OK; + } + } + break; + + case LTC_ASN1_UTF8_STRING: + if (der_decode_utf8_string(in, *inlen, data, &size) == CRYPT_OK) { + if (der_length_utf8_string(data, size, &z) == CRYPT_OK) { + list[x].used = 1; + list[x].size = size; + *inlen = z; + return CRYPT_OK; + } + } + break; + + case LTC_ASN1_UTCTIME: + z = *inlen; + if (der_decode_utctime(in, &z, data) == CRYPT_OK) { + list[x].used = 1; + *inlen = z; + return CRYPT_OK; + } + break; + + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + case LTC_ASN1_SEQUENCE: + if (der_decode_sequence(in, *inlen, data, size) == CRYPT_OK) { + if (der_length_sequence(data, size, &z) == CRYPT_OK) { + list[x].used = 1; + *inlen = z; + return CRYPT_OK; + } + } + break; + + default: + return CRYPT_INVALID_ARG; + } + } + + return CRYPT_INVALID_PACKET; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/choice/der_decode_choice.c,v $ */ +/* $Revision: 1.9 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c new file mode 100644 index 000000000..f2e073b8d --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c @@ -0,0 +1,96 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_ia5_string.c + ASN.1 DER, encode a IA5 STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a IA5 STRING + @param in The DER encoded IA5 STRING + @param inlen The size of the DER IA5 STRING + @param out [out] The array of octets stored (one per char) + @param outlen [in/out] The number of octets stored + @return CRYPT_OK if successful +*/ +int der_decode_ia5_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, len; + int t; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* must have header at least */ + if (inlen < 2) { + return CRYPT_INVALID_PACKET; + } + + /* check for 0x16 */ + if ((in[0] & 0x1F) != 0x16) { + return CRYPT_INVALID_PACKET; + } + x = 1; + + /* decode the length */ + if (in[x] & 0x80) { + /* valid # of bytes in length are 1,2,3 */ + y = in[x] & 0x7F; + if ((y == 0) || (y > 3) || ((x + y) > inlen)) { + return CRYPT_INVALID_PACKET; + } + + /* read the length in */ + len = 0; + ++x; + while (y--) { + len = (len << 8) | in[x++]; + } + } else { + len = in[x++] & 0x7F; + } + + /* is it too long? */ + if (len > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + if (len + x > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* read the data */ + for (y = 0; y < len; y++) { + t = der_ia5_value_decode(in[x++]); + if (t == -1) { + return CRYPT_INVALID_ARG; + } + out[y] = t; + } + + *outlen = y; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_decode_ia5_string.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_integer.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_integer.c new file mode 100644 index 000000000..cca274519 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_integer.c @@ -0,0 +1,110 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_integer.c + ASN.1 DER, decode an integer, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Read a mp_int integer + @param in The DER encoded data + @param inlen Size of DER encoded data + @param num The first mp_int to decode + @return CRYPT_OK if successful +*/ +int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num) +{ + unsigned long x, y, z; + int err; + + LTC_ARGCHK(num != NULL); + LTC_ARGCHK(in != NULL); + + /* min DER INTEGER is 0x02 01 00 == 0 */ + if (inlen < (1 + 1 + 1)) { + return CRYPT_INVALID_PACKET; + } + + /* ok expect 0x02 when we AND with 0001 1111 [1F] */ + x = 0; + if ((in[x++] & 0x1F) != 0x02) { + return CRYPT_INVALID_PACKET; + } + + /* now decode the len stuff */ + z = in[x++]; + + if ((z & 0x80) == 0x00) { + /* short form */ + + /* will it overflow? */ + if (x + z > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* no so read it */ + if ((err = mp_read_unsigned_bin(num, (unsigned char *)in + x, z)) != CRYPT_OK) { + return err; + } + } else { + /* long form */ + z &= 0x7F; + + /* will number of length bytes overflow? (or > 4) */ + if (((x + z) > inlen) || (z > 4) || (z == 0)) { + return CRYPT_INVALID_PACKET; + } + + /* now read it in */ + y = 0; + while (z--) { + y = ((unsigned long)(in[x++])) | (y << 8); + } + + /* now will reading y bytes overrun? */ + if ((x + y) > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* no so read it */ + if ((err = mp_read_unsigned_bin(num, (unsigned char *)in + x, y)) != CRYPT_OK) { + return err; + } + } + + /* see if it's negative */ + if (in[x] & 0x80) { + void *tmp; + if (mp_init(&tmp) != CRYPT_OK) { + return CRYPT_MEM; + } + + if (mp_2expt(tmp, mp_count_bits(num)) != CRYPT_OK || mp_sub(num, tmp, num) != CRYPT_OK) { + mp_clear(tmp); + return CRYPT_MEM; + } + mp_clear(tmp); + } + + return CRYPT_OK; + +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/integer/der_decode_integer.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c new file mode 100644 index 000000000..e7baae88e --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c @@ -0,0 +1,99 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_object_identifier.c + ASN.1 DER, Decode Object Identifier, Tom St Denis +*/ + +#ifdef LTC_DER +/** + Decode OID data and store the array of integers in words + @param in The OID DER encoded data + @param inlen The length of the OID data + @param words [out] The destination of the OID words + @param outlen [in/out] The number of OID words + @return CRYPT_OK if successful +*/ +int der_decode_object_identifier(const unsigned char *in, unsigned long inlen, + unsigned long *words, unsigned long *outlen) +{ + unsigned long x, y, t, len; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(words != NULL); + LTC_ARGCHK(outlen != NULL); + + /* header is at least 3 bytes */ + if (inlen < 3) { + return CRYPT_INVALID_PACKET; + } + + /* must be room for at least two words */ + if (*outlen < 2) { + return CRYPT_BUFFER_OVERFLOW; + } + + /* decode the packet header */ + x = 0; + if ((in[x++] & 0x1F) != 0x06) { + return CRYPT_INVALID_PACKET; + } + + /* get the length */ + if (in[x] < 128) { + len = in[x++]; + } else { + if (in[x] < 0x81 || in[x] > 0x82) { + return CRYPT_INVALID_PACKET; + } + y = in[x++] & 0x7F; + len = 0; + while (y--) { + len = (len << 8) | (unsigned long)in[x++]; + } + } + + if (len < 1 || (len + x) > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* decode words */ + y = 0; + t = 0; + while (len--) { + t = (t << 7) | (in[x] & 0x7F); + if (!(in[x++] & 0x80)) { + /* store t */ + if (y >= *outlen) { + return CRYPT_BUFFER_OVERFLOW; + } + if (y == 0) { + words[0] = t / 40; + words[1] = t % 40; + y = 2; + } else { + words[y++] = t; + } + t = 0; + } + } + + *outlen = y; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c new file mode 100644 index 000000000..523d0baa0 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c @@ -0,0 +1,91 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_octet_string.c + ASN.1 DER, encode a OCTET STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a OCTET STRING + @param in The DER encoded OCTET STRING + @param inlen The size of the DER OCTET STRING + @param out [out] The array of octets stored (one per char) + @param outlen [in/out] The number of octets stored + @return CRYPT_OK if successful +*/ +int der_decode_octet_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, len; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* must have header at least */ + if (inlen < 2) { + return CRYPT_INVALID_PACKET; + } + + /* check for 0x04 */ + if ((in[0] & 0x1F) != 0x04) { + return CRYPT_INVALID_PACKET; + } + x = 1; + + /* decode the length */ + if (in[x] & 0x80) { + /* valid # of bytes in length are 1,2,3 */ + y = in[x] & 0x7F; + if ((y == 0) || (y > 3) || ((x + y) > inlen)) { + return CRYPT_INVALID_PACKET; + } + + /* read the length in */ + len = 0; + ++x; + while (y--) { + len = (len << 8) | in[x++]; + } + } else { + len = in[x++] & 0x7F; + } + + /* is it too long? */ + if (len > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + if (len + x > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* read the data */ + for (y = 0; y < len; y++) { + out[y] = in[x++]; + } + + *outlen = y; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_decode_octet_string.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c new file mode 100644 index 000000000..f83259343 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c @@ -0,0 +1,96 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_printable_string.c + ASN.1 DER, encode a printable STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a printable STRING + @param in The DER encoded printable STRING + @param inlen The size of the DER printable STRING + @param out [out] The array of octets stored (one per char) + @param outlen [in/out] The number of octets stored + @return CRYPT_OK if successful +*/ +int der_decode_printable_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, len; + int t; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* must have header at least */ + if (inlen < 2) { + return CRYPT_INVALID_PACKET; + } + + /* check for 0x13 */ + if ((in[0] & 0x1F) != 0x13) { + return CRYPT_INVALID_PACKET; + } + x = 1; + + /* decode the length */ + if (in[x] & 0x80) { + /* valid # of bytes in length are 1,2,3 */ + y = in[x] & 0x7F; + if ((y == 0) || (y > 3) || ((x + y) > inlen)) { + return CRYPT_INVALID_PACKET; + } + + /* read the length in */ + len = 0; + ++x; + while (y--) { + len = (len << 8) | in[x++]; + } + } else { + len = in[x++] & 0x7F; + } + + /* is it too long? */ + if (len > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + if (len + x > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* read the data */ + for (y = 0; y < len; y++) { + t = der_printable_value_decode(in[x++]); + if (t == -1) { + return CRYPT_INVALID_ARG; + } + out[y] = t; + } + + *outlen = y; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_decode_printable_string.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c new file mode 100644 index 000000000..9b00f61b0 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c @@ -0,0 +1,287 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" +#include + + +/** + @file der_decode_sequence_ex.c + ASN.1 DER, decode a SEQUENCE, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Decode a SEQUENCE + @param in The DER encoded input + @param inlen The size of the input + @param list The list of items to decode + @param outlen The number of items in the list + @param ordered Search an unordeded or ordered list + @return CRYPT_OK on success +*/ +int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen, + ltc_asn1_list *list, unsigned long outlen, int ordered) +{ + int err, type; + unsigned long size, x, y, z, i, blksize; + void *data; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(list != NULL); + + /* get blk size */ + if (inlen < 2) { + return CRYPT_INVALID_PACKET; + } + + /* sequence type? We allow 0x30 SEQUENCE and 0x31 SET since fundamentally they're the same structure */ + x = 0; + if (in[x] != 0x30 && in[x] != 0x31) { + return CRYPT_INVALID_PACKET; + } + ++x; + + if (in[x] < 128) { + blksize = in[x++]; + } else if (in[x] & 0x80) { + if (in[x] < 0x81 || in[x] > 0x83) { + return CRYPT_INVALID_PACKET; + } + y = in[x++] & 0x7F; + + /* would reading the len bytes overrun? */ + if (x + y > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* read len */ + blksize = 0; + while (y--) { + blksize = (blksize << 8) | (unsigned long)in[x++]; + } + } + + /* would this blksize overflow? */ + if (x + blksize > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* mark all as unused */ + for (i = 0; i < outlen; i++) { + list[i].used = 0; + } + + /* ok read data */ + inlen = blksize; + for (i = 0; i < outlen; i++) { + z = 0; + type = list[i].type; + size = list[i].size; + data = list[i].data; + if (!ordered && list[i].used == 1) { continue; } + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + z = inlen; + if ((err = der_decode_boolean(in + x, z, ((int *)data))) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = der_length_boolean(&z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_INTEGER: + z = inlen; + if ((err = der_decode_integer(in + x, z, data)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + if ((err = der_length_integer(data, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_SHORT_INTEGER: + z = inlen; + if ((err = der_decode_short_integer(in + x, z, data)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + if ((err = der_length_short_integer(((unsigned long*)data)[0], &z)) != CRYPT_OK) { + goto LBL_ERR; + } + + break; + + case LTC_ASN1_BIT_STRING: + z = inlen; + if ((err = der_decode_bit_string(in + x, z, data, &size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + list[i].size = size; + if ((err = der_length_bit_string(size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_OCTET_STRING: + z = inlen; + if ((err = der_decode_octet_string(in + x, z, data, &size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + list[i].size = size; + if ((err = der_length_octet_string(size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_NULL: + if (inlen < 2 || in[x] != 0x05 || in[x+1] != 0x00) { + if (!ordered) { continue; } + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + z = 2; + break; + + case LTC_ASN1_OBJECT_IDENTIFIER: + z = inlen; + if ((err = der_decode_object_identifier(in + x, z, data, &size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + list[i].size = size; + if ((err = der_length_object_identifier(data, size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_IA5_STRING: + z = inlen; + if ((err = der_decode_ia5_string(in + x, z, data, &size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + list[i].size = size; + if ((err = der_length_ia5_string(data, size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + + case LTC_ASN1_PRINTABLE_STRING: + z = inlen; + if ((err = der_decode_printable_string(in + x, z, data, &size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + list[i].size = size; + if ((err = der_length_printable_string(data, size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_UTF8_STRING: + z = inlen; + if ((err = der_decode_utf8_string(in + x, z, data, &size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + list[i].size = size; + if ((err = der_length_utf8_string(data, size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_UTCTIME: + z = inlen; + if ((err = der_decode_utctime(in + x, &z, data)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + break; + + case LTC_ASN1_SET: + z = inlen; + if ((err = der_decode_set(in + x, z, data, size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + if ((err = der_length_sequence(data, size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + case LTC_ASN1_SETOF: + case LTC_ASN1_SEQUENCE: + /* detect if we have the right type */ + if ((type == LTC_ASN1_SETOF && (in[x] & 0x3F) != 0x31) || (type == LTC_ASN1_SEQUENCE && (in[x] & 0x3F) != 0x30)) { + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + + z = inlen; + if ((err = der_decode_sequence(in + x, z, data, size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + if ((err = der_length_sequence(data, size, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + break; + + + case LTC_ASN1_CHOICE: + z = inlen; + if ((err = der_decode_choice(in + x, &z, data, size)) != CRYPT_OK) { + if (!ordered) { continue; } + goto LBL_ERR; + } + break; + + default: + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + x += z; + inlen -= z; + list[i].used = 1; + if (!ordered) { + /* restart the decoder */ + i = -1; + } + } + + for (i = 0; i < outlen; i++) { + if (list[i].used == 0) { + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + } + err = CRYPT_OK; + +LBL_ERR: + return err; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_ex.c,v $ */ +/* $Revision: 1.16 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c new file mode 100644 index 000000000..9c648bc89 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c @@ -0,0 +1,386 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_sequence_flexi.c + ASN.1 DER, decode an array of ASN.1 types with a flexi parser, Tom St Denis +*/ + +#ifdef LTC_DER + +static unsigned long fetch_length(const unsigned char *in, unsigned long inlen) +{ + unsigned long x, y, z; + + y = 0; + + /* skip type and read len */ + if (inlen < 2) { + return 0xFFFFFFFF; + } + ++in; ++y; + + /* read len */ + x = *in++; ++y; + + /* <128 means literal */ + if (x < 128) { + return x+y; + } + x &= 0x7F; /* the lower 7 bits are the length of the length */ + inlen -= 2; + + /* len means len of len! */ + if (x == 0 || x > 4 || x > inlen) { + return 0xFFFFFFFF; + } + + y += x; + z = 0; + while (x--) { + z = (z<<8) | ((unsigned long)*in); + ++in; + } + return z+y; +} + +/** + ASN.1 DER Flexi(ble) decoder will decode arbitrary DER packets and create a linked list of the decoded elements. + @param in The input buffer + @param inlen [in/out] The length of the input buffer and on output the amount of decoded data + @param out [out] A pointer to the linked list + @return CRYPT_OK on success. +*/ +int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out) +{ + ltc_asn1_list *l; + unsigned long err, type, len, totlen, x, y; + void *realloc_tmp; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(inlen != NULL); + LTC_ARGCHK(out != NULL); + + l = NULL; + totlen = 0; + + /* scan the input and and get lengths and what not */ + while (*inlen) { + /* read the type byte */ + type = *in; + + /* fetch length */ + len = fetch_length(in, *inlen); + if (len > *inlen) { + err = CRYPT_INVALID_PACKET; + goto error; + } + + /* alloc new link */ + if (l == NULL) { + l = XCALLOC(1, sizeof(*l)); + if (l == NULL) { + err = CRYPT_MEM; + goto error; + } + } else { + l->next = XCALLOC(1, sizeof(*l)); + if (l->next == NULL) { + err = CRYPT_MEM; + goto error; + } + l->next->prev = l; + l = l->next; + } + + /* now switch on type */ + switch (type) { + case 0x01: /* BOOLEAN */ + l->type = LTC_ASN1_BOOLEAN; + l->size = 1; + l->data = XCALLOC(1, sizeof(int)); + + if ((err = der_decode_boolean(in, *inlen, l->data)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_boolean(&len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x02: /* INTEGER */ + /* init field */ + l->type = LTC_ASN1_INTEGER; + l->size = 1; + if ((err = mp_init(&l->data)) != CRYPT_OK) { + goto error; + } + + /* decode field */ + if ((err = der_decode_integer(in, *inlen, l->data)) != CRYPT_OK) { + goto error; + } + + /* calc length of object */ + if ((err = der_length_integer(l->data, &len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x03: /* BIT */ + /* init field */ + l->type = LTC_ASN1_BIT_STRING; + l->size = len * 8; /* *8 because we store decoded bits one per char and they are encoded 8 per char. */ + + if ((l->data = XCALLOC(1, l->size)) == NULL) { + err = CRYPT_MEM; + goto error; + } + + if ((err = der_decode_bit_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_bit_string(l->size, &len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x04: /* OCTET */ + + /* init field */ + l->type = LTC_ASN1_OCTET_STRING; + l->size = len; + + if ((l->data = XCALLOC(1, l->size)) == NULL) { + err = CRYPT_MEM; + goto error; + } + + if ((err = der_decode_octet_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_octet_string(l->size, &len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x05: /* NULL */ + + /* valid NULL is 0x05 0x00 */ + if (in[0] != 0x05 || in[1] != 0x00) { + err = CRYPT_INVALID_PACKET; + goto error; + } + + /* simple to store ;-) */ + l->type = LTC_ASN1_NULL; + l->data = NULL; + l->size = 0; + len = 2; + + break; + + case 0x06: /* OID */ + + /* init field */ + l->type = LTC_ASN1_OBJECT_IDENTIFIER; + l->size = len; + + if ((l->data = XCALLOC(len, sizeof(unsigned long))) == NULL) { + err = CRYPT_MEM; + goto error; + } + + if ((err = der_decode_object_identifier(in, *inlen, l->data, &l->size)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_object_identifier(l->data, l->size, &len)) != CRYPT_OK) { + goto error; + } + + /* resize it to save a bunch of mem */ + if ((realloc_tmp = XREALLOC(l->data, l->size * sizeof(unsigned long))) == NULL) { + /* out of heap but this is not an error */ + break; + } + l->data = realloc_tmp; + break; + + case 0x0C: /* UTF8 */ + + /* init field */ + l->type = LTC_ASN1_UTF8_STRING; + l->size = len; + + if ((l->data = XCALLOC(sizeof(wchar_t), l->size)) == NULL) { + err = CRYPT_MEM; + goto error; + } + + if ((err = der_decode_utf8_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_utf8_string(l->data, l->size, &len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x13: /* PRINTABLE */ + + /* init field */ + l->type = LTC_ASN1_PRINTABLE_STRING; + l->size = len; + + if ((l->data = XCALLOC(1, l->size)) == NULL) { + err = CRYPT_MEM; + goto error; + } + + if ((err = der_decode_printable_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_printable_string(l->data, l->size, &len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x16: /* IA5 */ + + /* init field */ + l->type = LTC_ASN1_IA5_STRING; + l->size = len; + + if ((l->data = XCALLOC(1, l->size)) == NULL) { + err = CRYPT_MEM; + goto error; + } + + if ((err = der_decode_ia5_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_ia5_string(l->data, l->size, &len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x17: /* UTC TIME */ + + /* init field */ + l->type = LTC_ASN1_UTCTIME; + l->size = 1; + + if ((l->data = XCALLOC(1, sizeof(ltc_utctime))) == NULL) { + err = CRYPT_MEM; + goto error; + } + + len = *inlen; + if ((err = der_decode_utctime(in, &len, l->data)) != CRYPT_OK) { + goto error; + } + + if ((err = der_length_utctime(l->data, &len)) != CRYPT_OK) { + goto error; + } + break; + + case 0x30: /* SEQUENCE */ + case 0x31: /* SET */ + + /* init field */ + l->type = (type == 0x30) ? LTC_ASN1_SEQUENCE : LTC_ASN1_SET; + + /* we have to decode the SEQUENCE header and get it's length */ + + /* move past type */ + ++in; --(*inlen); + + /* read length byte */ + x = *in++; --(*inlen); + + /* smallest SEQUENCE/SET header */ + y = 2; + + /* now if it's > 127 the next bytes are the length of the length */ + if (x > 128) { + x &= 0x7F; + in += x; + *inlen -= x; + + /* update sequence header len */ + y += x; + } + + /* Sequence elements go as child */ + len = len - y; + if ((err = der_decode_sequence_flexi(in, &len, &(l->child))) != CRYPT_OK) { + goto error; + } + + /* len update */ + totlen += y; + + /* link them up y0 */ + l->child->parent = l; + + break; + default: + /* invalid byte ... this is a soft error */ + /* remove link */ + l = l->prev; + XFREE(l->next); + l->next = NULL; + goto outside; + } + + /* advance pointers */ + totlen += len; + in += len; + *inlen -= len; + } + +outside: + + /* rewind l please */ + while (l->prev != NULL || l->parent != NULL) { + if (l->parent != NULL) { + l = l->parent; + } else { + l = l->prev; + } + } + + /* return */ + *out = l; + *inlen = totlen; + return CRYPT_OK; + +error: + /* free list */ + der_sequence_free(l); + + return err; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c,v $ */ +/* $Revision: 1.26 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c new file mode 100644 index 000000000..ff633df35 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c @@ -0,0 +1,139 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" +#include + + +/** + @file der_decode_sequence_multi.c + ASN.1 DER, decode a SEQUENCE, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Decode a SEQUENCE type using a VA list + @param in Input buffer + @param inlen Length of input in octets + @remark <...> is of the form (int, unsigned long, void*) + @return CRYPT_OK on success +*/ +int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...) +{ + int err, type; + unsigned long size, x; + void *data; + va_list args; + ltc_asn1_list *list; + + LTC_ARGCHK(in != NULL); + + /* get size of output that will be required */ + va_start(args, inlen); + x = 0; + for (;;) { + type = va_arg(args, int); + size = va_arg(args, unsigned long); + data = va_arg(args, void*); + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + case LTC_ASN1_INTEGER: + case LTC_ASN1_SHORT_INTEGER: + case LTC_ASN1_BIT_STRING: + case LTC_ASN1_OCTET_STRING: + case LTC_ASN1_NULL: + case LTC_ASN1_OBJECT_IDENTIFIER: + case LTC_ASN1_IA5_STRING: + case LTC_ASN1_PRINTABLE_STRING: + case LTC_ASN1_UTF8_STRING: + case LTC_ASN1_UTCTIME: + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + case LTC_ASN1_SEQUENCE: + case LTC_ASN1_CHOICE: + ++x; + break; + + default: + va_end(args); + return CRYPT_INVALID_ARG; + } + } + va_end(args); + + /* allocate structure for x elements */ + if (x == 0) { + return CRYPT_NOP; + } + + list = XCALLOC(sizeof(*list), x); + if (list == NULL) { + return CRYPT_MEM; + } + + /* fill in the structure */ + va_start(args, inlen); + x = 0; + for (;;) { + type = va_arg(args, int); + size = va_arg(args, unsigned long); + data = va_arg(args, void*); + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + case LTC_ASN1_INTEGER: + case LTC_ASN1_SHORT_INTEGER: + case LTC_ASN1_BIT_STRING: + case LTC_ASN1_OCTET_STRING: + case LTC_ASN1_NULL: + case LTC_ASN1_OBJECT_IDENTIFIER: + case LTC_ASN1_IA5_STRING: + case LTC_ASN1_PRINTABLE_STRING: + case LTC_ASN1_UTF8_STRING: + case LTC_ASN1_UTCTIME: + case LTC_ASN1_SEQUENCE: + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + case LTC_ASN1_CHOICE: + list[x].type = type; + list[x].size = size; + list[x++].data = data; + break; + + default: + va_end(args); + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + } + va_end(args); + + err = der_decode_sequence(in, inlen, list, x); +LBL_ERR: + XFREE(list); + return err; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_multi.c,v $ */ +/* $Revision: 1.13 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c new file mode 100644 index 000000000..907e4e1c3 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c @@ -0,0 +1,68 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_short_integer.c + ASN.1 DER, decode an integer, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Read a short integer + @param in The DER encoded data + @param inlen Size of data + @param num [out] The integer to decode + @return CRYPT_OK if successful +*/ +int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num) +{ + unsigned long len, x, y; + + LTC_ARGCHK(num != NULL); + LTC_ARGCHK(in != NULL); + + /* check length */ + if (inlen < 2) { + return CRYPT_INVALID_PACKET; + } + + /* check header */ + x = 0; + if ((in[x++] & 0x1F) != 0x02) { + return CRYPT_INVALID_PACKET; + } + + /* get the packet len */ + len = in[x++]; + + if (x + len > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* read number */ + y = 0; + while (len--) { + y = (y<<8) | (unsigned long)in[x++]; + } + *num = y; + + return CRYPT_OK; + +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_decode_short_integer.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utctime.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utctime.c new file mode 100644 index 000000000..7f3f0d766 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utctime.c @@ -0,0 +1,127 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_utctime.c + ASN.1 DER, decode a UTCTIME, Tom St Denis +*/ + +#ifdef LTC_DER + +static int char_to_int(unsigned char x) +{ + switch (x) { + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + } + return 100; +} + +#define DECODE_V(y, max) \ + y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ + if (y >= max) return CRYPT_INVALID_PACKET; \ + x += 2; + +/** + Decodes a UTC time structure in DER format (reads all 6 valid encoding formats) + @param in Input buffer + @param inlen Length of input buffer in octets + @param out [out] Destination of UTC time structure + @return CRYPT_OK if successful +*/ +int der_decode_utctime(const unsigned char *in, unsigned long *inlen, + ltc_utctime *out) +{ + unsigned char buf[32]; + unsigned long x; + int y; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(inlen != NULL); + LTC_ARGCHK(out != NULL); + + /* check header */ + if (*inlen < 2UL || (in[1] >= sizeof(buf)) || ((in[1] + 2UL) > *inlen)) { + return CRYPT_INVALID_PACKET; + } + + /* decode the string */ + for (x = 0; x < in[1]; x++) { + y = der_ia5_value_decode(in[x+2]); + if (y == -1) { + return CRYPT_INVALID_PACKET; + } + buf[x] = y; + } + *inlen = 2 + x; + + + /* possible encodings are +YYMMDDhhmmZ +YYMMDDhhmm+hh'mm' +YYMMDDhhmm-hh'mm' +YYMMDDhhmmssZ +YYMMDDhhmmss+hh'mm' +YYMMDDhhmmss-hh'mm' + + So let's do a trivial decode upto [including] mm + */ + + x = 0; + DECODE_V(out->YY, 100); + DECODE_V(out->MM, 13); + DECODE_V(out->DD, 32); + DECODE_V(out->hh, 24); + DECODE_V(out->mm, 60); + + /* clear timezone and seconds info */ + out->off_dir = out->off_hh = out->off_mm = out->ss = 0; + + /* now is it Z, +, - or 0-9 */ + if (buf[x] == 'Z') { + return CRYPT_OK; + } else if (buf[x] == '+' || buf[x] == '-') { + out->off_dir = (buf[x++] == '+') ? 0 : 1; + DECODE_V(out->off_hh, 24); + DECODE_V(out->off_mm, 60); + return CRYPT_OK; + } + + /* decode seconds */ + DECODE_V(out->ss, 60); + + /* now is it Z, +, - */ + if (buf[x] == 'Z') { + return CRYPT_OK; + } else if (buf[x] == '+' || buf[x] == '-') { + out->off_dir = (buf[x++] == '+') ? 0 : 1; + DECODE_V(out->off_hh, 24); + DECODE_V(out->off_mm, 60); + return CRYPT_OK; + } else { + return CRYPT_INVALID_PACKET; + } +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_decode_utctime.c,v $ */ +/* $Revision: 1.9 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c new file mode 100644 index 000000000..898d6cd2a --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c @@ -0,0 +1,111 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_decode_utf8_string.c + ASN.1 DER, encode a UTF8 STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a UTF8 STRING + @param in The DER encoded UTF8 STRING + @param inlen The size of the DER UTF8 STRING + @param out [out] The array of utf8s stored (one per char) + @param outlen [in/out] The number of utf8s stored + @return CRYPT_OK if successful +*/ +int der_decode_utf8_string(const unsigned char *in, unsigned long inlen, + wchar_t *out, unsigned long *outlen) +{ + wchar_t tmp; + unsigned long x, y, z, len; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* must have header at least */ + if (inlen < 2) { + return CRYPT_INVALID_PACKET; + } + + /* check for 0x0C */ + if ((in[0] & 0x1F) != 0x0C) { + return CRYPT_INVALID_PACKET; + } + x = 1; + + /* decode the length */ + if (in[x] & 0x80) { + /* valid # of bytes in length are 1,2,3 */ + y = in[x] & 0x7F; + if ((y == 0) || (y > 3) || ((x + y) > inlen)) { + return CRYPT_INVALID_PACKET; + } + + /* read the length in */ + len = 0; + ++x; + while (y--) { + len = (len << 8) | in[x++]; + } + } else { + len = in[x++] & 0x7F; + } + + if (len + x > inlen) { + return CRYPT_INVALID_PACKET; + } + + /* proceed to decode */ + for (y = 0; x < inlen; ) { + /* get first byte */ + tmp = in[x++]; + + /* count number of bytes */ + for (z = 0; (tmp & 0x80) && (z <= 4); z++, tmp = (tmp << 1) & 0xFF); + + if (z > 4 || (x + (z - 1) > inlen)) { + return CRYPT_INVALID_PACKET; + } + + /* decode, grab upper bits */ + tmp >>= z; + + /* grab remaining bytes */ + if (z > 1) { --z; } + while (z-- != 0) { + if ((in[x] & 0xC0) != 0x80) { + return CRYPT_INVALID_PACKET; + } + tmp = (tmp << 6) | ((wchar_t)in[x++] & 0x3F); + } + + if (y > *outlen) { + *outlen = y; + return CRYPT_BUFFER_OVERFLOW; + } + out[y++] = tmp; + } + *outlen = y; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utf8/der_decode_utf8_string.c,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_bit_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_bit_string.c new file mode 100644 index 000000000..ca29c58a7 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_bit_string.c @@ -0,0 +1,89 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_bit_string.c + ASN.1 DER, encode a BIT STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a BIT STRING + @param in The array of bits to store (one per char) + @param inlen The number of bits tostore + @param out [out] The destination for the DER encoded BIT STRING + @param outlen [in/out] The max size and resulting size of the DER BIT STRING + @return CRYPT_OK if successful +*/ +int der_encode_bit_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long len, x, y; + unsigned char buf; + int err; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* avoid overflows */ + if ((err = der_length_bit_string(inlen, &len)) != CRYPT_OK) { + return err; + } + + if (len > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + /* store header (include bit padding count in length) */ + x = 0; + y = (inlen >> 3) + ((inlen&7) ? 1 : 0) + 1; + + out[x++] = 0x03; + if (y < 128) { + out[x++] = (unsigned char)y; + } else if (y < 256) { + out[x++] = 0x81; + out[x++] = (unsigned char)y; + } else if (y < 65536) { + out[x++] = 0x82; + out[x++] = (unsigned char)((y>>8)&255); + out[x++] = (unsigned char)(y&255); + } + + /* store number of zero padding bits */ + out[x++] = (unsigned char)((8 - inlen) & 7); + + /* store the bits in big endian format */ + for (y = buf = 0; y < inlen; y++) { + buf |= (in[y] ? 1 : 0) << (7 - (y & 7)); + if ((y & 7) == 7) { + out[x++] = buf; + buf = 0; + } + } + /* store last byte */ + if (inlen & 7) { + out[x++] = buf; + } + *outlen = x; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_encode_bit_string.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_boolean.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_boolean.c new file mode 100644 index 000000000..ded2731f9 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_boolean.c @@ -0,0 +1,51 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_boolean.c + ASN.1 DER, encode a BOOLEAN, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a BOOLEAN + @param in The boolean to encode + @param out [out] The destination for the DER encoded BOOLEAN + @param outlen [in/out] The max size and resulting size of the DER BOOLEAN + @return CRYPT_OK if successful +*/ +int der_encode_boolean(int in, + unsigned char *out, unsigned long *outlen) +{ + LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(out != NULL); + + if (*outlen < 3) { + *outlen = 3; + return CRYPT_BUFFER_OVERFLOW; + } + + *outlen = 3; + out[0] = 0x01; + out[1] = 0x01; + out[2] = in ? 0xFF : 0x00; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/boolean/der_encode_boolean.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_ia5_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_ia5_string.c new file mode 100644 index 000000000..30d3f4374 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_ia5_string.c @@ -0,0 +1,85 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_ia5_string.c + ASN.1 DER, encode a IA5 STRING, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Store an IA5 STRING + @param in The array of IA5 to store (one per char) + @param inlen The number of IA5 to store + @param out [out] The destination for the DER encoded IA5 STRING + @param outlen [in/out] The max size and resulting size of the DER IA5 STRING + @return CRYPT_OK if successful +*/ +int der_encode_ia5_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, len; + int err; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* get the size */ + if ((err = der_length_ia5_string(in, inlen, &len)) != CRYPT_OK) { + return err; + } + + /* too big? */ + if (len > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + /* encode the header+len */ + x = 0; + out[x++] = 0x16; + if (inlen < 128) { + out[x++] = (unsigned char)inlen; + } else if (inlen < 256) { + out[x++] = 0x81; + out[x++] = (unsigned char)inlen; + } else if (inlen < 65536UL) { + out[x++] = 0x82; + out[x++] = (unsigned char)((inlen>>8)&255); + out[x++] = (unsigned char)(inlen&255); + } else if (inlen < 16777216UL) { + out[x++] = 0x83; + out[x++] = (unsigned char)((inlen>>16)&255); + out[x++] = (unsigned char)((inlen>>8)&255); + out[x++] = (unsigned char)(inlen&255); + } else { + return CRYPT_INVALID_ARG; + } + + /* store octets */ + for (y = 0; y < inlen; y++) { + out[x++] = der_ia5_char_encode(in[y]); + } + + /* retun length */ + *outlen = x; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_encode_ia5_string.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_integer.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_integer.c new file mode 100644 index 000000000..4137a94bb --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_integer.c @@ -0,0 +1,130 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_integer.c + ASN.1 DER, encode an integer, Tom St Denis +*/ + + +#ifdef LTC_DER + +/* Exports a positive bignum as DER format (upto 2^32 bytes in size) */ +/** + Store a mp_int integer + @param num The first mp_int to encode + @param out [out] The destination for the DER encoded integers + @param outlen [in/out] The max size and resulting size of the DER encoded integers + @return CRYPT_OK if successful +*/ +int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen) +{ + unsigned long tmplen, y; + int err, leading_zero; + + LTC_ARGCHK(num != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* find out how big this will be */ + if ((err = der_length_integer(num, &tmplen)) != CRYPT_OK) { + return err; + } + + if (*outlen < tmplen) { + *outlen = tmplen; + return CRYPT_BUFFER_OVERFLOW; + } + + if (mp_cmp_d(num, 0) != LTC_MP_LT) { + /* we only need a leading zero if the msb of the first byte is one */ + if ((mp_count_bits(num) & 7) == 0 || mp_iszero(num) == LTC_MP_YES) { + leading_zero = 1; + } else { + leading_zero = 0; + } + + /* get length of num in bytes (plus 1 since we force the msbyte to zero) */ + y = mp_unsigned_bin_size(num) + leading_zero; + } else { + leading_zero = 0; + y = mp_count_bits(num); + y = y + (8 - (y & 7)); + y = y >> 3; + if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) --y; + } + + /* now store initial data */ + *out++ = 0x02; + if (y < 128) { + /* short form */ + *out++ = (unsigned char)y; + } else if (y < 256) { + *out++ = 0x81; + *out++ = (unsigned char)y; + } else if (y < 65536UL) { + *out++ = 0x82; + *out++ = (unsigned char)((y>>8)&255); + *out++ = (unsigned char)y; + } else if (y < 16777216UL) { + *out++ = 0x83; + *out++ = (unsigned char)((y>>16)&255); + *out++ = (unsigned char)((y>>8)&255); + *out++ = (unsigned char)y; + } else { + return CRYPT_INVALID_ARG; + } + + /* now store msbyte of zero if num is non-zero */ + if (leading_zero) { + *out++ = 0x00; + } + + /* if it's not zero store it as big endian */ + if (mp_cmp_d(num, 0) == LTC_MP_GT) { + /* now store the mpint */ + if ((err = mp_to_unsigned_bin(num, out)) != CRYPT_OK) { + return err; + } + } else if (mp_iszero(num) != LTC_MP_YES) { + void *tmp; + + /* negative */ + if (mp_init(&tmp) != CRYPT_OK) { + return CRYPT_MEM; + } + + /* 2^roundup and subtract */ + y = mp_count_bits(num); + y = y + (8 - (y & 7)); + if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) y -= 8; + if (mp_2expt(tmp, y) != CRYPT_OK || mp_add(tmp, num, tmp) != CRYPT_OK) { + mp_clear(tmp); + return CRYPT_MEM; + } + if ((err = mp_to_unsigned_bin(tmp, out)) != CRYPT_OK) { + mp_clear(tmp); + return err; + } + mp_clear(tmp); + } + + /* we good */ + *outlen = tmplen; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/integer/der_encode_integer.c,v $ */ +/* $Revision: 1.9 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_object_identifier.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_object_identifier.c new file mode 100644 index 000000000..68e216276 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_object_identifier.c @@ -0,0 +1,111 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_object_identifier.c + ASN.1 DER, Encode Object Identifier, Tom St Denis +*/ + +#ifdef LTC_DER +/** + Encode an OID + @param words The words to encode (upto 32-bits each) + @param nwords The number of words in the OID + @param out [out] Destination of OID data + @param outlen [in/out] The max and resulting size of the OID + @return CRYPT_OK if successful +*/ +int der_encode_object_identifier(unsigned long *words, unsigned long nwords, + unsigned char *out, unsigned long *outlen) +{ + unsigned long i, x, y, z, t, mask, wordbuf; + int err; + + LTC_ARGCHK(words != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* check length */ + if ((err = der_length_object_identifier(words, nwords, &x)) != CRYPT_OK) { + return err; + } + if (x > *outlen) { + *outlen = x; + return CRYPT_BUFFER_OVERFLOW; + } + + /* compute length to store OID data */ + z = 0; + wordbuf = words[0] * 40 + words[1]; + for (y = 1; y < nwords; y++) { + t = der_object_identifier_bits(wordbuf); + z += t/7 + ((t%7) ? 1 : 0) + (wordbuf == 0 ? 1 : 0); + if (y < nwords - 1) { + wordbuf = words[y + 1]; + } + } + + /* store header + length */ + x = 0; + out[x++] = 0x06; + if (z < 128) { + out[x++] = (unsigned char)z; + } else if (z < 256) { + out[x++] = 0x81; + out[x++] = (unsigned char)z; + } else if (z < 65536UL) { + out[x++] = 0x82; + out[x++] = (unsigned char)((z>>8)&255); + out[x++] = (unsigned char)(z&255); + } else { + return CRYPT_INVALID_ARG; + } + + /* store first byte */ + wordbuf = words[0] * 40 + words[1]; + for (i = 1; i < nwords; i++) { + /* store 7 bit words in little endian */ + t = wordbuf & 0xFFFFFFFF; + if (t) { + y = x; + mask = 0; + while (t) { + out[x++] = (unsigned char)((t & 0x7F) | mask); + t >>= 7; + mask |= 0x80; /* upper bit is set on all but the last byte */ + } + /* now swap bytes y...x-1 */ + z = x - 1; + while (y < z) { + t = out[y]; out[y] = out[z]; out[z] = (unsigned char)t; + ++y; + --z; + } + } else { + /* zero word */ + out[x++] = 0x00; + } + + if (i < nwords - 1) { + wordbuf = words[i + 1]; + } + } + + *outlen = x; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_encode_object_identifier.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_octet_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_octet_string.c new file mode 100644 index 000000000..b3ee7f4a4 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_octet_string.c @@ -0,0 +1,86 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_octet_string.c + ASN.1 DER, encode a OCTET STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store an OCTET STRING + @param in The array of OCTETS to store (one per char) + @param inlen The number of OCTETS to store + @param out [out] The destination for the DER encoded OCTET STRING + @param outlen [in/out] The max size and resulting size of the DER OCTET STRING + @return CRYPT_OK if successful +*/ +int der_encode_octet_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, len; + int err; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* get the size */ + if ((err = der_length_octet_string(inlen, &len)) != CRYPT_OK) { + return err; + } + + /* too big? */ + if (len > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + /* encode the header+len */ + x = 0; + out[x++] = 0x04; + if (inlen < 128) { + out[x++] = (unsigned char)inlen; + } else if (inlen < 256) { + out[x++] = 0x81; + out[x++] = (unsigned char)inlen; + } else if (inlen < 65536UL) { + out[x++] = 0x82; + out[x++] = (unsigned char)((inlen>>8)&255); + out[x++] = (unsigned char)(inlen&255); + } else if (inlen < 16777216UL) { + out[x++] = 0x83; + out[x++] = (unsigned char)((inlen>>16)&255); + out[x++] = (unsigned char)((inlen>>8)&255); + out[x++] = (unsigned char)(inlen&255); + } else { + return CRYPT_INVALID_ARG; + } + + /* store octets */ + for (y = 0; y < inlen; y++) { + out[x++] = in[y]; + } + + /* retun length */ + *outlen = x; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_encode_octet_string.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_printable_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_printable_string.c new file mode 100644 index 000000000..a1dab5f40 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_printable_string.c @@ -0,0 +1,85 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_printable_string.c + ASN.1 DER, encode a printable STRING, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Store an printable STRING + @param in The array of printable to store (one per char) + @param inlen The number of printable to store + @param out [out] The destination for the DER encoded printable STRING + @param outlen [in/out] The max size and resulting size of the DER printable STRING + @return CRYPT_OK if successful +*/ +int der_encode_printable_string(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, len; + int err; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* get the size */ + if ((err = der_length_printable_string(in, inlen, &len)) != CRYPT_OK) { + return err; + } + + /* too big? */ + if (len > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + /* encode the header+len */ + x = 0; + out[x++] = 0x13; + if (inlen < 128) { + out[x++] = (unsigned char)inlen; + } else if (inlen < 256) { + out[x++] = 0x81; + out[x++] = (unsigned char)inlen; + } else if (inlen < 65536UL) { + out[x++] = 0x82; + out[x++] = (unsigned char)((inlen>>8)&255); + out[x++] = (unsigned char)(inlen&255); + } else if (inlen < 16777216UL) { + out[x++] = 0x83; + out[x++] = (unsigned char)((inlen>>16)&255); + out[x++] = (unsigned char)((inlen>>8)&255); + out[x++] = (unsigned char)(inlen&255); + } else { + return CRYPT_INVALID_ARG; + } + + /* store octets */ + for (y = 0; y < inlen; y++) { + out[x++] = der_printable_char_encode(in[y]); + } + + /* retun length */ + *outlen = x; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_encode_printable_string.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_ex.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_ex.c new file mode 100644 index 000000000..3df19cf4a --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_ex.c @@ -0,0 +1,335 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" +#include + + +/** + @file der_encode_sequence_ex.c + ASN.1 DER, encode a SEQUENCE, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Encode a SEQUENCE + @param list The list of items to encode + @param inlen The number of items in the list + @param out [out] The destination + @param outlen [in/out] The size of the output + @param type_of LTC_ASN1_SEQUENCE or LTC_ASN1_SET/LTC_ASN1_SETOF + @return CRYPT_OK on success +*/ +int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen, + unsigned char *out, unsigned long *outlen, int type_of) +{ + int err, type; + unsigned long size, x, y, z, i; + void *data; + + LTC_ARGCHK(list != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* get size of output that will be required */ + y = 0; + for (i = 0; i < inlen; i++) { + type = list[i].type; + size = list[i].size; + data = list[i].data; + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + if ((err = der_length_boolean(&x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_INTEGER: + if ((err = der_length_integer(data, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_SHORT_INTEGER: + if ((err = der_length_short_integer(*((unsigned long*)data), &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_BIT_STRING: + if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_OCTET_STRING: + if ((err = der_length_octet_string(size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_NULL: + y += 2; + break; + + case LTC_ASN1_OBJECT_IDENTIFIER: + if ((err = der_length_object_identifier(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_IA5_STRING: + if ((err = der_length_ia5_string(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_PRINTABLE_STRING: + if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_UTF8_STRING: + if ((err = der_length_utf8_string(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_UTCTIME: + if ((err = der_length_utctime(data, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + case LTC_ASN1_SEQUENCE: + if ((err = der_length_sequence(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + default: + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + } + + /* calc header size */ + z = y; + if (y < 128) { + y += 2; + } else if (y < 256) { + /* 0x30 0x81 LL */ + y += 3; + } else if (y < 65536UL) { + /* 0x30 0x82 LL LL */ + y += 4; + } else if (y < 16777216UL) { + /* 0x30 0x83 LL LL LL */ + y += 5; + } else { + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + + /* too big ? */ + if (*outlen < y) { + *outlen = y; + err = CRYPT_BUFFER_OVERFLOW; + goto LBL_ERR; + } + + /* store header */ + x = 0; + out[x++] = (type_of == LTC_ASN1_SEQUENCE) ? 0x30 : 0x31; + + if (z < 128) { + out[x++] = (unsigned char)z; + } else if (z < 256) { + out[x++] = 0x81; + out[x++] = (unsigned char)z; + } else if (z < 65536UL) { + out[x++] = 0x82; + out[x++] = (unsigned char)((z>>8UL)&255); + out[x++] = (unsigned char)(z&255); + } else if (z < 16777216UL) { + out[x++] = 0x83; + out[x++] = (unsigned char)((z>>16UL)&255); + out[x++] = (unsigned char)((z>>8UL)&255); + out[x++] = (unsigned char)(z&255); + } + + /* store data */ + *outlen -= x; + for (i = 0; i < inlen; i++) { + type = list[i].type; + size = list[i].size; + data = list[i].data; + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + z = *outlen; + if ((err = der_encode_boolean(*((int *)data), out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_INTEGER: + z = *outlen; + if ((err = der_encode_integer(data, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_SHORT_INTEGER: + z = *outlen; + if ((err = der_encode_short_integer(*((unsigned long*)data), out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_BIT_STRING: + z = *outlen; + if ((err = der_encode_bit_string(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_OCTET_STRING: + z = *outlen; + if ((err = der_encode_octet_string(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_NULL: + out[x++] = 0x05; + out[x++] = 0x00; + *outlen -= 2; + break; + + case LTC_ASN1_OBJECT_IDENTIFIER: + z = *outlen; + if ((err = der_encode_object_identifier(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_IA5_STRING: + z = *outlen; + if ((err = der_encode_ia5_string(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_PRINTABLE_STRING: + z = *outlen; + if ((err = der_encode_printable_string(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_UTF8_STRING: + z = *outlen; + if ((err = der_encode_utf8_string(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_UTCTIME: + z = *outlen; + if ((err = der_encode_utctime(data, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_SET: + z = *outlen; + if ((err = der_encode_set(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_SETOF: + z = *outlen; + if ((err = der_encode_setof(data, size, out + x, &z)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + case LTC_ASN1_SEQUENCE: + z = *outlen; + if ((err = der_encode_sequence_ex(data, size, out + x, &z, type)) != CRYPT_OK) { + goto LBL_ERR; + } + x += z; + *outlen -= z; + break; + + default: + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + } + *outlen = x; + err = CRYPT_OK; + +LBL_ERR: + return err; +} + +#endif diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_multi.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_multi.c new file mode 100644 index 000000000..782f042e1 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_multi.c @@ -0,0 +1,138 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" +#include + + +/** + @file der_encode_sequence_multi.c + ASN.1 DER, encode a SEQUENCE, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Encode a SEQUENCE type using a VA list + @param out [out] Destination for data + @param outlen [in/out] Length of buffer and resulting length of output + @remark <...> is of the form (int, unsigned long, void*) + @return CRYPT_OK on success +*/ +int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...) +{ + int err, type; + unsigned long size, x; + void *data; + va_list args; + ltc_asn1_list *list; + + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* get size of output that will be required */ + va_start(args, outlen); + x = 0; + for (;;) { + type = va_arg(args, int); + size = va_arg(args, unsigned long); + data = va_arg(args, void*); + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + case LTC_ASN1_INTEGER: + case LTC_ASN1_SHORT_INTEGER: + case LTC_ASN1_BIT_STRING: + case LTC_ASN1_OCTET_STRING: + case LTC_ASN1_NULL: + case LTC_ASN1_OBJECT_IDENTIFIER: + case LTC_ASN1_IA5_STRING: + case LTC_ASN1_PRINTABLE_STRING: + case LTC_ASN1_UTF8_STRING: + case LTC_ASN1_UTCTIME: + case LTC_ASN1_SEQUENCE: + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + ++x; + break; + + default: + va_end(args); + return CRYPT_INVALID_ARG; + } + } + va_end(args); + + /* allocate structure for x elements */ + if (x == 0) { + return CRYPT_NOP; + } + + list = XCALLOC(sizeof(*list), x); + if (list == NULL) { + return CRYPT_MEM; + } + + /* fill in the structure */ + va_start(args, outlen); + x = 0; + for (;;) { + type = va_arg(args, int); + size = va_arg(args, unsigned long); + data = va_arg(args, void*); + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + case LTC_ASN1_INTEGER: + case LTC_ASN1_SHORT_INTEGER: + case LTC_ASN1_BIT_STRING: + case LTC_ASN1_OCTET_STRING: + case LTC_ASN1_NULL: + case LTC_ASN1_OBJECT_IDENTIFIER: + case LTC_ASN1_IA5_STRING: + case LTC_ASN1_PRINTABLE_STRING: + case LTC_ASN1_UTF8_STRING: + case LTC_ASN1_UTCTIME: + case LTC_ASN1_SEQUENCE: + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + list[x].type = type; + list[x].size = size; + list[x++].data = data; + break; + + default: + va_end(args); + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + } + va_end(args); + + err = der_encode_sequence(list, x, out, outlen); +LBL_ERR: + XFREE(list); + return err; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c,v $ */ +/* $Revision: 1.12 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_set.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_set.c new file mode 100644 index 000000000..41f658722 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_set.c @@ -0,0 +1,103 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_set.c + ASN.1 DER, Encode a SET, Tom St Denis +*/ + +#ifdef LTC_DER + +/* LTC define to ASN.1 TAG */ +static int ltc_to_asn1(int v) +{ + switch (v) { + case LTC_ASN1_BOOLEAN: return 0x01; + case LTC_ASN1_INTEGER: + case LTC_ASN1_SHORT_INTEGER: return 0x02; + case LTC_ASN1_BIT_STRING: return 0x03; + case LTC_ASN1_OCTET_STRING: return 0x04; + case LTC_ASN1_NULL: return 0x05; + case LTC_ASN1_OBJECT_IDENTIFIER: return 0x06; + case LTC_ASN1_UTF8_STRING: return 0x0C; + case LTC_ASN1_PRINTABLE_STRING: return 0x13; + case LTC_ASN1_IA5_STRING: return 0x16; + case LTC_ASN1_UTCTIME: return 0x17; + case LTC_ASN1_SEQUENCE: return 0x30; + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: return 0x31; + default: return -1; + } +} + + +static int qsort_helper(const void *a, const void *b) +{ + ltc_asn1_list *A = (ltc_asn1_list *)a, *B = (ltc_asn1_list *)b; + int r; + + r = ltc_to_asn1(A->type) - ltc_to_asn1(B->type); + + /* for QSORT the order is UNDEFINED if they are "equal" which means it is NOT DETERMINISTIC. So we force it to be :-) */ + if (r == 0) { + /* their order in the original list now determines the position */ + return A->used - B->used; + } else { + return r; + } +} + +/* + Encode a SET type + @param list The list of items to encode + @param inlen The number of items in the list + @param out [out] The destination + @param outlen [in/out] The size of the output + @return CRYPT_OK on success +*/ +int der_encode_set(ltc_asn1_list *list, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + ltc_asn1_list *copy; + unsigned long x; + int err; + + /* make copy of list */ + copy = XCALLOC(inlen, sizeof(*copy)); + if (copy == NULL) { + return CRYPT_MEM; + } + + /* fill in used member with index so we can fully sort it */ + for (x = 0; x < inlen; x++) { + copy[x] = list[x]; + copy[x].used = x; + } + + /* sort it by the "type" field */ + XQSORT(copy, inlen, sizeof(*copy), &qsort_helper); + + /* call der_encode_sequence_ex() */ + err = der_encode_sequence_ex(copy, inlen, out, outlen, LTC_ASN1_SET); + + /* free list */ + XFREE(copy); + + return err; +} + + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/set/der_encode_set.c,v $ */ +/* $Revision: 1.12 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_setof.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_setof.c new file mode 100644 index 000000000..b4e97b5e6 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_setof.c @@ -0,0 +1,162 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_setof.c + ASN.1 DER, Encode SET OF, Tom St Denis +*/ + +#ifdef LTC_DER + +struct edge { + unsigned char *start; + unsigned long size; +}; + +static int qsort_helper(const void *a, const void *b) +{ + struct edge *A = (struct edge *)a, *B = (struct edge *)b; + int r; + unsigned long x; + + /* compare min length */ + r = XMEMCMP(A->start, B->start, MIN(A->size, B->size)); + + if (r == 0 && A->size != B->size) { + if (A->size > B->size) { + for (x = B->size; x < A->size; x++) { + if (A->start[x]) { + return 1; + } + } + } else { + for (x = A->size; x < B->size; x++) { + if (B->start[x]) { + return -1; + } + } + } + } + + return r; +} + +/** + Encode a SETOF stucture + @param list The list of items to encode + @param inlen The number of items in the list + @param out [out] The destination + @param outlen [in/out] The size of the output + @return CRYPT_OK on success +*/ +int der_encode_setof(ltc_asn1_list *list, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, z, hdrlen; + int err; + struct edge *edges; + unsigned char *ptr, *buf; + + /* check that they're all the same type */ + for (x = 1; x < inlen; x++) { + if (list[x].type != list[x-1].type) { + return CRYPT_INVALID_ARG; + } + } + + /* alloc buffer to store copy of output */ + buf = XCALLOC(1, *outlen); + if (buf == NULL) { + return CRYPT_MEM; + } + + /* encode list */ + if ((err = der_encode_sequence_ex(list, inlen, buf, outlen, LTC_ASN1_SETOF)) != CRYPT_OK) { + XFREE(buf); + return err; + } + + /* allocate edges */ + edges = XCALLOC(inlen, sizeof(*edges)); + if (edges == NULL) { + XFREE(buf); + return CRYPT_MEM; + } + + /* skip header */ + ptr = buf + 1; + + /* now skip length data */ + x = *ptr++; + if (x >= 0x80) { + ptr += (x & 0x7F); + } + + /* get the size of the static header */ + hdrlen = (unsigned long)((size_t)ptr - (size_t)buf); + + + /* scan for edges */ + x = 0; + while (ptr < (buf + *outlen)) { + /* store start */ + edges[x].start = ptr; + + /* skip type */ + z = 1; + + /* parse length */ + y = ptr[z++]; + if (y < 128) { + edges[x].size = y; + } else { + y &= 0x7F; + edges[x].size = 0; + while (y--) { + edges[x].size = (edges[x].size << 8) | ((unsigned long)ptr[z++]); + } + } + + /* skip content */ + edges[x].size += z; + ptr += edges[x].size; + ++x; + } + + /* sort based on contents (using edges) */ + XQSORT(edges, inlen, sizeof(*edges), &qsort_helper); + + /* copy static header */ + XMEMCPY(out, buf, hdrlen); + + /* copy+sort using edges+indecies to output from buffer */ + for (y = hdrlen, x = 0; x < inlen; x++) { + XMEMCPY(out+y, edges[x].start, edges[x].size); + y += edges[x].size; + } + +#ifdef LTC_CLEAN_STACK + zeromem(buf, *outlen); +#endif + + /* free buffers */ + XFREE(edges); + XFREE(buf); + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/set/der_encode_setof.c,v $ */ +/* $Revision: 1.12 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_short_integer.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_short_integer.c new file mode 100644 index 000000000..9b167d084 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_short_integer.c @@ -0,0 +1,97 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_short_integer.c + ASN.1 DER, encode an integer, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store a short integer in the range (0,2^32-1) + @param num The integer to encode + @param out [out] The destination for the DER encoded integers + @param outlen [in/out] The max size and resulting size of the DER encoded integers + @return CRYPT_OK if successful +*/ +int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen) +{ + unsigned long len, x, y, z; + int err; + + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* force to 32 bits */ + num &= 0xFFFFFFFFUL; + + /* find out how big this will be */ + if ((err = der_length_short_integer(num, &len)) != CRYPT_OK) { + return err; + } + + if (*outlen < len) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + /* get len of output */ + z = 0; + y = num; + while (y) { + ++z; + y >>= 8; + } + + /* handle zero */ + if (z == 0) { + z = 1; + } + + /* see if msb is set */ + z += (num&(1UL<<((z<<3) - 1))) ? 1 : 0; + + /* adjust the number so the msB is non-zero */ + for (x = 0; (z <= 4) && (x < (4 - z)); x++) { + num <<= 8; + } + + /* store header */ + x = 0; + out[x++] = 0x02; + out[x++] = (unsigned char)z; + + /* if 31st bit is set output a leading zero and decrement count */ + if (z == 5) { + out[x++] = 0; + --z; + } + + /* store values */ + for (y = 0; y < z; y++) { + out[x++] = (unsigned char)((num >> 24) & 0xFF); + num <<= 8; + } + + /* we good */ + *outlen = x; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_encode_short_integer.c,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utctime.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utctime.c new file mode 100644 index 000000000..167a2b490 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utctime.c @@ -0,0 +1,83 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_utctime.c + ASN.1 DER, encode a UTCTIME, Tom St Denis +*/ + +#ifdef LTC_DER + +static const char *baseten = "0123456789"; + +#define STORE_V(y) \ + out[x++] = der_ia5_char_encode(baseten[(y/10) % 10]); \ + out[x++] = der_ia5_char_encode(baseten[y % 10]); + +/** + Encodes a UTC time structure in DER format + @param utctime The UTC time structure to encode + @param out The destination of the DER encoding of the UTC time structure + @param outlen [in/out] The length of the DER encoding + @return CRYPT_OK if successful +*/ +int der_encode_utctime(ltc_utctime *utctime, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, tmplen; + int err; + + LTC_ARGCHK(utctime != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + if ((err = der_length_utctime(utctime, &tmplen)) != CRYPT_OK) { + return err; + } + if (tmplen > *outlen) { + *outlen = tmplen; + return CRYPT_BUFFER_OVERFLOW; + } + + /* store header */ + out[0] = 0x17; + + /* store values */ + x = 2; + STORE_V(utctime->YY); + STORE_V(utctime->MM); + STORE_V(utctime->DD); + STORE_V(utctime->hh); + STORE_V(utctime->mm); + STORE_V(utctime->ss); + + if (utctime->off_mm || utctime->off_hh) { + out[x++] = der_ia5_char_encode(utctime->off_dir ? '-' : '+'); + STORE_V(utctime->off_hh); + STORE_V(utctime->off_mm); + } else { + out[x++] = der_ia5_char_encode('Z'); + } + + /* store length */ + out[1] = (unsigned char)(x - 2); + + /* all good let's return */ + *outlen = x; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.c,v $ */ +/* $Revision: 1.10 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utf8_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utf8_string.c new file mode 100644 index 000000000..84d8d0621 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utf8_string.c @@ -0,0 +1,105 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_encode_utf8_string.c + ASN.1 DER, encode a UTF8 STRING, Tom St Denis +*/ + + +#ifdef LTC_DER + +/** + Store an UTF8 STRING + @param in The array of UTF8 to store (one per wchar_t) + @param inlen The number of UTF8 to store + @param out [out] The destination for the DER encoded UTF8 STRING + @param outlen [in/out] The max size and resulting size of the DER UTF8 STRING + @return CRYPT_OK if successful +*/ +int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned long x, y, len; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* get the size */ + for (x = len = 0; x < inlen; x++) { + if (in[x] < 0 || in[x] > 0x1FFFF) { + return CRYPT_INVALID_ARG; + } + len += der_utf8_charsize(in[x]); + } + + if (len < 128) { + y = 2 + len; + } else if (len < 256) { + y = 3 + len; + } else if (len < 65536UL) { + y = 4 + len; + } else if (len < 16777216UL) { + y = 5 + len; + } else { + return CRYPT_INVALID_ARG; + } + + /* too big? */ + if (y > *outlen) { + *outlen = len; + return CRYPT_BUFFER_OVERFLOW; + } + + /* encode the header+len */ + x = 0; + out[x++] = 0x0C; + if (len < 128) { + out[x++] = (unsigned char)len; + } else if (len < 256) { + out[x++] = 0x81; + out[x++] = (unsigned char)len; + } else if (len < 65536UL) { + out[x++] = 0x82; + out[x++] = (unsigned char)((len>>8)&255); + out[x++] = (unsigned char)(len&255); + } else if (len < 16777216UL) { + out[x++] = 0x83; + out[x++] = (unsigned char)((len>>16)&255); + out[x++] = (unsigned char)((len>>8)&255); + out[x++] = (unsigned char)(len&255); + } else { + return CRYPT_INVALID_ARG; + } + + /* store UTF8 */ + for (y = 0; y < inlen; y++) { + switch (der_utf8_charsize(in[y])) { + case 1: out[x++] = (unsigned char)in[y]; break; + case 2: out[x++] = 0xC0 | ((in[y] >> 6) & 0x1F); out[x++] = 0x80 | (in[y] & 0x3F); break; + case 3: out[x++] = 0xE0 | ((in[y] >> 12) & 0x0F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break; + case 4: out[x++] = 0xF0 | ((in[y] >> 18) & 0x07); out[x++] = 0x80 | ((in[y] >> 12) & 0x3F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break; + } + } + + /* retun length */ + *outlen = x; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utf8/der_encode_utf8_string.c,v $ */ +/* $Revision: 1.9 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_bit_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_bit_string.c new file mode 100644 index 000000000..2bffa3b63 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_bit_string.c @@ -0,0 +1,54 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_bit_string.c + ASN.1 DER, get length of BIT STRING, Tom St Denis +*/ + +#ifdef LTC_DER +/** + Gets length of DER encoding of BIT STRING + @param nbits The number of bits in the string to encode + @param outlen [out] The length of the DER encoding for the given string + @return CRYPT_OK if successful +*/ +int der_length_bit_string(unsigned long nbits, unsigned long *outlen) +{ + unsigned long nbytes; + LTC_ARGCHK(outlen != NULL); + + /* get the number of the bytes */ + nbytes = (nbits >> 3) + ((nbits & 7) ? 1 : 0) + 1; + + if (nbytes < 128) { + /* 03 LL PP DD DD DD ... */ + *outlen = 2 + nbytes; + } else if (nbytes < 256) { + /* 03 81 LL PP DD DD DD ... */ + *outlen = 3 + nbytes; + } else if (nbytes < 65536) { + /* 03 82 LL LL PP DD DD DD ... */ + *outlen = 4 + nbytes; + } else { + return CRYPT_INVALID_ARG; + } + + return CRYPT_OK; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_length_bit_string.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_boolean.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_boolean.c new file mode 100644 index 000000000..e34ce5c65 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_boolean.c @@ -0,0 +1,35 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_boolean.c + ASN.1 DER, get length of a BOOLEAN, Tom St Denis +*/ + +#ifdef LTC_DER +/** + Gets length of DER encoding of a BOOLEAN + @param outlen [out] The length of the DER encoding + @return CRYPT_OK if successful +*/ +int der_length_boolean(unsigned long *outlen) +{ + LTC_ARGCHK(outlen != NULL); + *outlen = 3; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/boolean/der_length_boolean.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c new file mode 100644 index 000000000..473bc7932 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c @@ -0,0 +1,194 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_ia5_string.c + ASN.1 DER, get length of IA5 STRING, Tom St Denis +*/ + +#ifdef LTC_DER + +static const struct { + int code, value; +} ia5_table[] = { +{ '\0', 0 }, +{ '\a', 7 }, +{ '\b', 8 }, +{ '\t', 9 }, +{ '\n', 10 }, +{ '\f', 12 }, +{ '\r', 13 }, +{ ' ', 32 }, +{ '!', 33 }, +{ '"', 34 }, +{ '#', 35 }, +{ '$', 36 }, +{ '%', 37 }, +{ '&', 38 }, +{ '\'', 39 }, +{ '(', 40 }, +{ ')', 41 }, +{ '*', 42 }, +{ '+', 43 }, +{ ',', 44 }, +{ '-', 45 }, +{ '.', 46 }, +{ '/', 47 }, +{ '0', 48 }, +{ '1', 49 }, +{ '2', 50 }, +{ '3', 51 }, +{ '4', 52 }, +{ '5', 53 }, +{ '6', 54 }, +{ '7', 55 }, +{ '8', 56 }, +{ '9', 57 }, +{ ':', 58 }, +{ ';', 59 }, +{ '<', 60 }, +{ '=', 61 }, +{ '>', 62 }, +{ '?', 63 }, +{ '@', 64 }, +{ 'A', 65 }, +{ 'B', 66 }, +{ 'C', 67 }, +{ 'D', 68 }, +{ 'E', 69 }, +{ 'F', 70 }, +{ 'G', 71 }, +{ 'H', 72 }, +{ 'I', 73 }, +{ 'J', 74 }, +{ 'K', 75 }, +{ 'L', 76 }, +{ 'M', 77 }, +{ 'N', 78 }, +{ 'O', 79 }, +{ 'P', 80 }, +{ 'Q', 81 }, +{ 'R', 82 }, +{ 'S', 83 }, +{ 'T', 84 }, +{ 'U', 85 }, +{ 'V', 86 }, +{ 'W', 87 }, +{ 'X', 88 }, +{ 'Y', 89 }, +{ 'Z', 90 }, +{ '[', 91 }, +{ '\\', 92 }, +{ ']', 93 }, +{ '^', 94 }, +{ '_', 95 }, +{ '`', 96 }, +{ 'a', 97 }, +{ 'b', 98 }, +{ 'c', 99 }, +{ 'd', 100 }, +{ 'e', 101 }, +{ 'f', 102 }, +{ 'g', 103 }, +{ 'h', 104 }, +{ 'i', 105 }, +{ 'j', 106 }, +{ 'k', 107 }, +{ 'l', 108 }, +{ 'm', 109 }, +{ 'n', 110 }, +{ 'o', 111 }, +{ 'p', 112 }, +{ 'q', 113 }, +{ 'r', 114 }, +{ 's', 115 }, +{ 't', 116 }, +{ 'u', 117 }, +{ 'v', 118 }, +{ 'w', 119 }, +{ 'x', 120 }, +{ 'y', 121 }, +{ 'z', 122 }, +{ '{', 123 }, +{ '|', 124 }, +{ '}', 125 }, +{ '~', 126 } +}; + +int der_ia5_char_encode(int c) +{ + int x; + for (x = 0; x < (int)(sizeof(ia5_table)/sizeof(ia5_table[0])); x++) { + if (ia5_table[x].code == c) { + return ia5_table[x].value; + } + } + return -1; +} + +int der_ia5_value_decode(int v) +{ + int x; + for (x = 0; x < (int)(sizeof(ia5_table)/sizeof(ia5_table[0])); x++) { + if (ia5_table[x].value == v) { + return ia5_table[x].code; + } + } + return -1; +} + +/** + Gets length of DER encoding of IA5 STRING + @param octets The values you want to encode + @param noctets The number of octets in the string to encode + @param outlen [out] The length of the DER encoding for the given string + @return CRYPT_OK if successful +*/ +int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen) +{ + unsigned long x; + + LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(octets != NULL); + + /* scan string for validity */ + for (x = 0; x < noctets; x++) { + if (der_ia5_char_encode(octets[x]) == -1) { + return CRYPT_INVALID_ARG; + } + } + + if (noctets < 128) { + /* 16 LL DD DD DD ... */ + *outlen = 2 + noctets; + } else if (noctets < 256) { + /* 16 81 LL DD DD DD ... */ + *outlen = 3 + noctets; + } else if (noctets < 65536UL) { + /* 16 82 LL LL DD DD DD ... */ + *outlen = 4 + noctets; + } else if (noctets < 16777216UL) { + /* 16 83 LL LL LL DD DD DD ... */ + *outlen = 5 + noctets; + } else { + return CRYPT_INVALID_ARG; + } + + return CRYPT_OK; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_length_ia5_string.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_integer.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_integer.c new file mode 100644 index 000000000..540d205f0 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_integer.c @@ -0,0 +1,82 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_integer.c + ASN.1 DER, get length of encoding, Tom St Denis +*/ + + +#ifdef LTC_DER +/** + Gets length of DER encoding of num + @param num The int to get the size of + @param outlen [out] The length of the DER encoding for the given integer + @return CRYPT_OK if successful +*/ +int der_length_integer(void *num, unsigned long *outlen) +{ + unsigned long z, len; + int leading_zero; + + LTC_ARGCHK(num != NULL); + LTC_ARGCHK(outlen != NULL); + + if (mp_cmp_d(num, 0) != LTC_MP_LT) { + /* positive */ + + /* we only need a leading zero if the msb of the first byte is one */ + if ((mp_count_bits(num) & 7) == 0 || mp_iszero(num) == LTC_MP_YES) { + leading_zero = 1; + } else { + leading_zero = 0; + } + + /* size for bignum */ + z = len = leading_zero + mp_unsigned_bin_size(num); + } else { + /* it's negative */ + /* find power of 2 that is a multiple of eight and greater than count bits */ + leading_zero = 0; + z = mp_count_bits(num); + z = z + (8 - (z & 7)); + if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) --z; + len = z = z >> 3; + } + + /* now we need a length */ + if (z < 128) { + /* short form */ + ++len; + } else { + /* long form (relies on z != 0), assumes length bytes < 128 */ + ++len; + + while (z) { + ++len; + z >>= 8; + } + } + + /* we need a 0x02 to indicate it's INTEGER */ + ++len; + + /* return length */ + *outlen = len; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/integer/der_length_integer.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c new file mode 100644 index 000000000..94c326f7c --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c @@ -0,0 +1,89 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_object_identifier.c + ASN.1 DER, get length of Object Identifier, Tom St Denis +*/ + +#ifdef LTC_DER + +unsigned long der_object_identifier_bits(unsigned long x) +{ + unsigned long c; + x &= 0xFFFFFFFF; + c = 0; + while (x) { + ++c; + x >>= 1; + } + return c; +} + + +/** + Gets length of DER encoding of Object Identifier + @param nwords The number of OID words + @param words The actual OID words to get the size of + @param outlen [out] The length of the DER encoding for the given string + @return CRYPT_OK if successful +*/ +int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen) +{ + unsigned long y, z, t, wordbuf; + + LTC_ARGCHK(words != NULL); + LTC_ARGCHK(outlen != NULL); + + + /* must be >= 2 words */ + if (nwords < 2) { + return CRYPT_INVALID_ARG; + } + + /* word1 = 0,1,2,3 and word2 0..39 */ + if (words[0] > 3 || (words[0] < 2 && words[1] > 39)) { + return CRYPT_INVALID_ARG; + } + + /* leading word is the first two */ + z = 0; + wordbuf = words[0] * 40 + words[1]; + for (y = 1; y < nwords; y++) { + t = der_object_identifier_bits(wordbuf); + z += t/7 + ((t%7) ? 1 : 0) + (wordbuf == 0 ? 1 : 0); + if (y < nwords - 1) { + /* grab next word */ + wordbuf = words[y+1]; + } + } + + /* now depending on the length our length encoding changes */ + if (z < 128) { + z += 2; + } else if (z < 256) { + z += 3; + } else if (z < 65536UL) { + z += 4; + } else { + return CRYPT_INVALID_ARG; + } + + *outlen = z; + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_length_object_identifier.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_octet_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_octet_string.c new file mode 100644 index 000000000..acd4053c1 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_octet_string.c @@ -0,0 +1,53 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_octet_string.c + ASN.1 DER, get length of OCTET STRING, Tom St Denis +*/ + +#ifdef LTC_DER +/** + Gets length of DER encoding of OCTET STRING + @param noctets The number of octets in the string to encode + @param outlen [out] The length of the DER encoding for the given string + @return CRYPT_OK if successful +*/ +int der_length_octet_string(unsigned long noctets, unsigned long *outlen) +{ + LTC_ARGCHK(outlen != NULL); + + if (noctets < 128) { + /* 04 LL DD DD DD ... */ + *outlen = 2 + noctets; + } else if (noctets < 256) { + /* 04 81 LL DD DD DD ... */ + *outlen = 3 + noctets; + } else if (noctets < 65536UL) { + /* 04 82 LL LL DD DD DD ... */ + *outlen = 4 + noctets; + } else if (noctets < 16777216UL) { + /* 04 83 LL LL LL DD DD DD ... */ + *outlen = 5 + noctets; + } else { + return CRYPT_INVALID_ARG; + } + + return CRYPT_OK; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_length_octet_string.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_printable_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_printable_string.c new file mode 100644 index 000000000..ef1ed0ede --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_printable_string.c @@ -0,0 +1,166 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_printable_string.c + ASN.1 DER, get length of Printable STRING, Tom St Denis +*/ + +#ifdef LTC_DER + +static const struct { + int code, value; +} printable_table[] = { +{ ' ', 32 }, +{ '\'', 39 }, +{ '(', 40 }, +{ ')', 41 }, +{ '+', 43 }, +{ ',', 44 }, +{ '-', 45 }, +{ '.', 46 }, +{ '/', 47 }, +{ '0', 48 }, +{ '1', 49 }, +{ '2', 50 }, +{ '3', 51 }, +{ '4', 52 }, +{ '5', 53 }, +{ '6', 54 }, +{ '7', 55 }, +{ '8', 56 }, +{ '9', 57 }, +{ ':', 58 }, +{ '=', 61 }, +{ '?', 63 }, +{ 'A', 65 }, +{ 'B', 66 }, +{ 'C', 67 }, +{ 'D', 68 }, +{ 'E', 69 }, +{ 'F', 70 }, +{ 'G', 71 }, +{ 'H', 72 }, +{ 'I', 73 }, +{ 'J', 74 }, +{ 'K', 75 }, +{ 'L', 76 }, +{ 'M', 77 }, +{ 'N', 78 }, +{ 'O', 79 }, +{ 'P', 80 }, +{ 'Q', 81 }, +{ 'R', 82 }, +{ 'S', 83 }, +{ 'T', 84 }, +{ 'U', 85 }, +{ 'V', 86 }, +{ 'W', 87 }, +{ 'X', 88 }, +{ 'Y', 89 }, +{ 'Z', 90 }, +{ 'a', 97 }, +{ 'b', 98 }, +{ 'c', 99 }, +{ 'd', 100 }, +{ 'e', 101 }, +{ 'f', 102 }, +{ 'g', 103 }, +{ 'h', 104 }, +{ 'i', 105 }, +{ 'j', 106 }, +{ 'k', 107 }, +{ 'l', 108 }, +{ 'm', 109 }, +{ 'n', 110 }, +{ 'o', 111 }, +{ 'p', 112 }, +{ 'q', 113 }, +{ 'r', 114 }, +{ 's', 115 }, +{ 't', 116 }, +{ 'u', 117 }, +{ 'v', 118 }, +{ 'w', 119 }, +{ 'x', 120 }, +{ 'y', 121 }, +{ 'z', 122 }, +}; + +int der_printable_char_encode(int c) +{ + int x; + for (x = 0; x < (int)(sizeof(printable_table)/sizeof(printable_table[0])); x++) { + if (printable_table[x].code == c) { + return printable_table[x].value; + } + } + return -1; +} + +int der_printable_value_decode(int v) +{ + int x; + for (x = 0; x < (int)(sizeof(printable_table)/sizeof(printable_table[0])); x++) { + if (printable_table[x].value == v) { + return printable_table[x].code; + } + } + return -1; +} + +/** + Gets length of DER encoding of Printable STRING + @param octets The values you want to encode + @param noctets The number of octets in the string to encode + @param outlen [out] The length of the DER encoding for the given string + @return CRYPT_OK if successful +*/ +int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen) +{ + unsigned long x; + + LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(octets != NULL); + + /* scan string for validity */ + for (x = 0; x < noctets; x++) { + if (der_printable_char_encode(octets[x]) == -1) { + return CRYPT_INVALID_ARG; + } + } + + if (noctets < 128) { + /* 16 LL DD DD DD ... */ + *outlen = 2 + noctets; + } else if (noctets < 256) { + /* 16 81 LL DD DD DD ... */ + *outlen = 3 + noctets; + } else if (noctets < 65536UL) { + /* 16 82 LL LL DD DD DD ... */ + *outlen = 4 + noctets; + } else if (noctets < 16777216UL) { + /* 16 83 LL LL LL DD DD DD ... */ + *outlen = 5 + noctets; + } else { + return CRYPT_INVALID_ARG; + } + + return CRYPT_OK; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_length_printable_string.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_sequence.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_sequence.c new file mode 100644 index 000000000..e75ed7e7e --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_sequence.c @@ -0,0 +1,169 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_sequence.c + ASN.1 DER, length a SEQUENCE, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Get the length of a DER sequence + @param list The sequences of items in the SEQUENCE + @param inlen The number of items + @param outlen [out] The length required in octets to store it + @return CRYPT_OK on success +*/ +int der_length_sequence(ltc_asn1_list *list, unsigned long inlen, + unsigned long *outlen) +{ + int err, type; + unsigned long size, x, y, z, i; + void *data; + + LTC_ARGCHK(list != NULL); + LTC_ARGCHK(outlen != NULL); + + /* get size of output that will be required */ + y = 0; + for (i = 0; i < inlen; i++) { + type = list[i].type; + size = list[i].size; + data = list[i].data; + + if (type == LTC_ASN1_EOL) { + break; + } + + switch (type) { + case LTC_ASN1_BOOLEAN: + if ((err = der_length_boolean(&x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_INTEGER: + if ((err = der_length_integer(data, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_SHORT_INTEGER: + if ((err = der_length_short_integer(*((unsigned long *)data), &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_BIT_STRING: + if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_OCTET_STRING: + if ((err = der_length_octet_string(size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_NULL: + y += 2; + break; + + case LTC_ASN1_OBJECT_IDENTIFIER: + if ((err = der_length_object_identifier(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_IA5_STRING: + if ((err = der_length_ia5_string(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_PRINTABLE_STRING: + if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_UTCTIME: + if ((err = der_length_utctime(data, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_UTF8_STRING: + if ((err = der_length_utf8_string(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + case LTC_ASN1_SEQUENCE: + if ((err = der_length_sequence(data, size, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + y += x; + break; + + + default: + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + } + + /* calc header size */ + z = y; + if (y < 128) { + y += 2; + } else if (y < 256) { + /* 0x30 0x81 LL */ + y += 3; + } else if (y < 65536UL) { + /* 0x30 0x82 LL LL */ + y += 4; + } else if (y < 16777216UL) { + /* 0x30 0x83 LL LL LL */ + y += 5; + } else { + err = CRYPT_INVALID_ARG; + goto LBL_ERR; + } + + /* store size */ + *outlen = y; + err = CRYPT_OK; + +LBL_ERR: + return err; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_length_sequence.c,v $ */ +/* $Revision: 1.14 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_short_integer.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_short_integer.c new file mode 100644 index 000000000..afa6dd0ee --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_short_integer.c @@ -0,0 +1,70 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_short_integer.c + ASN.1 DER, get length of encoding, Tom St Denis +*/ + + +#ifdef LTC_DER +/** + Gets length of DER encoding of num + @param num The integer to get the size of + @param outlen [out] The length of the DER encoding for the given integer + @return CRYPT_OK if successful +*/ +int der_length_short_integer(unsigned long num, unsigned long *outlen) +{ + unsigned long z, y, len; + + LTC_ARGCHK(outlen != NULL); + + /* force to 32 bits */ + num &= 0xFFFFFFFFUL; + + /* get the number of bytes */ + z = 0; + y = num; + while (y) { + ++z; + y >>= 8; + } + + /* handle zero */ + if (z == 0) { + z = 1; + } + + /* we need a 0x02 to indicate it's INTEGER */ + len = 1; + + /* length byte */ + ++len; + + /* bytes in value */ + len += z; + + /* see if msb is set */ + len += (num&(1UL<<((z<<3) - 1))) ? 1 : 0; + + /* return length */ + *outlen = len; + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_length_short_integer.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utctime.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utctime.c new file mode 100644 index 000000000..1296babba --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utctime.c @@ -0,0 +1,46 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_utctime.c + ASN.1 DER, get length of UTCTIME, Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Gets length of DER encoding of UTCTIME + @param utctime The UTC time structure to get the size of + @param outlen [out] The length of the DER encoding + @return CRYPT_OK if successful +*/ +int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen) +{ + LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(utctime != NULL); + + if (utctime->off_hh == 0 && utctime->off_mm == 0) { + /* we encode as YYMMDDhhmmssZ */ + *outlen = 2 + 13; + } else { + /* we encode as YYMMDDhhmmss{+|-}hh'mm' */ + *outlen = 2 + 17; + } + + return CRYPT_OK; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_length_utctime.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c new file mode 100644 index 000000000..514db8450 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c @@ -0,0 +1,83 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_length_utf8_string.c + ASN.1 DER, get length of UTF8 STRING, Tom St Denis +*/ + +#ifdef LTC_DER + +/** Return the size in bytes of a UTF-8 character + @param c The UTF-8 character to measure + @return The size in bytes +*/ +unsigned long der_utf8_charsize(const wchar_t c) +{ + if (c <= 0x7F) { + return 1; + } else if (c <= 0x7FF) { + return 2; + } else if (c <= 0xFFFF) { + return 3; + } else { + return 4; + } +} + +/** + Gets length of DER encoding of UTF8 STRING + @param in The characters to measure the length of + @param noctets The number of octets in the string to encode + @param outlen [out] The length of the DER encoding for the given string + @return CRYPT_OK if successful +*/ +int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen) +{ + unsigned long x, len; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(outlen != NULL); + + len = 0; + for (x = 0; x < noctets; x++) { + if (in[x] < 0 || in[x] > 0x10FFFF) { + return CRYPT_INVALID_ARG; + } + len += der_utf8_charsize(in[x]); + } + + if (len < 128) { + /* 0C LL DD DD DD ... */ + *outlen = 2 + len; + } else if (len < 256) { + /* 0C 81 LL DD DD DD ... */ + *outlen = 3 + len; + } else if (len < 65536UL) { + /* 0C 82 LL LL DD DD DD ... */ + *outlen = 4 + len; + } else if (len < 16777216UL) { + /* 0C 83 LL LL LL DD DD DD ... */ + *outlen = 5 + len; + } else { + return CRYPT_INVALID_ARG; + } + + return CRYPT_OK; +} + +#endif + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utf8/der_length_utf8_string.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_sequence_free.c b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_sequence_free.c new file mode 100644 index 000000000..488721539 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/asn1/der_sequence_free.c @@ -0,0 +1,65 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file der_sequence_free.c + ASN.1 DER, free's a structure allocated by der_decode_sequence_flexi(), Tom St Denis +*/ + +#ifdef LTC_DER + +/** + Free memory allocated by der_decode_sequence_flexi() + @param in The list to free +*/ +void der_sequence_free(ltc_asn1_list *in) +{ + ltc_asn1_list *l; + + /* walk to the start of the chain */ + while (in->prev != NULL || in->parent != NULL) { + if (in->parent != NULL) { + in = in->parent; + } else { + in = in->prev; + } + } + + /* now walk the list and free stuff */ + while (in != NULL) { + /* is there a child? */ + if (in->child) { + /* disconnect */ + in->child->parent = NULL; + der_sequence_free(in->child); + } + + switch (in->type) { + case LTC_ASN1_SET: + case LTC_ASN1_SETOF: + case LTC_ASN1_SEQUENCE: break; + case LTC_ASN1_INTEGER : if (in->data != NULL) { mp_clear(in->data); } break; + default : if (in->data != NULL) { XFREE(in->data); } + } + + /* move to next and free current */ + l = in->next; + free(in); + in = l; + } +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_sequence_free.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c new file mode 100644 index 000000000..5a1324c49 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c @@ -0,0 +1,76 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b + * + * All curves taken from NIST recommendation paper of July 1999 + * Available at http://csrc.nist.gov/cryptval/dss.htm + */ +#include "../../headers/tomcrypt.h" + +/** + @file ltc_ecc_map.c + ECC Crypto, Tom St Denis +*/ + +#ifdef LTC_MECC + +/** + Map a projective jacbobian point back to affine space + @param P [in/out] The point to map + @param modulus The modulus of the field the ECC curve is in + @param mp The "b" value from montgomery_setup() + @return CRYPT_OK on success +*/ +int ltc_ecc_map(ecc_point *P, void *modulus, void *mp) +{ + void *t1, *t2; + int err; + + LTC_ARGCHK(P != NULL); + LTC_ARGCHK(modulus != NULL); + LTC_ARGCHK(mp != NULL); + + if ((err = mp_init_multi(&t1, &t2, NULL)) != CRYPT_OK) { + return CRYPT_MEM; + } + + /* first map z back to normal */ + if ((err = mp_montgomery_reduce(P->z, modulus, mp)) != CRYPT_OK) { goto done; } + + /* get 1/z */ + if ((err = mp_invmod(P->z, modulus, t1)) != CRYPT_OK) { goto done; } + + /* get 1/z^2 and 1/z^3 */ + if ((err = mp_sqr(t1, t2)) != CRYPT_OK) { goto done; } + if ((err = mp_mod(t2, modulus, t2)) != CRYPT_OK) { goto done; } + if ((err = mp_mul(t1, t2, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_mod(t1, modulus, t1)) != CRYPT_OK) { goto done; } + + /* multiply against x/y */ + if ((err = mp_mul(P->x, t2, P->x)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(P->x, modulus, mp)) != CRYPT_OK) { goto done; } + if ((err = mp_mul(P->y, t1, P->y)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(P->y, modulus, mp)) != CRYPT_OK) { goto done; } + if ((err = mp_set(P->z, 1)) != CRYPT_OK) { goto done; } + + err = CRYPT_OK; +done: + mp_clear_multi(t1, t2, NULL); + return err; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_map.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ + diff --git a/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c new file mode 100644 index 000000000..2c468eaaf --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c @@ -0,0 +1,207 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b + * + * All curves taken from NIST recommendation paper of July 1999 + * Available at http://csrc.nist.gov/cryptval/dss.htm + */ +#include "../../headers/tomcrypt.h" + +/** + @file ltc_ecc_mul2add.c + ECC Crypto, Shamir's Trick, Tom St Denis +*/ + +#ifdef LTC_MECC + +#ifdef LTC_ECC_SHAMIR + +/** Computes kA*A + kB*B = C using Shamir's Trick + @param A First point to multiply + @param kA What to multiple A by + @param B Second point to multiply + @param kB What to multiple B by + @param C [out] Destination point (can overlap with A or B + @param modulus Modulus for curve + @return CRYPT_OK on success +*/ +int ltc_ecc_mul2add(ecc_point *A, void *kA, + ecc_point *B, void *kB, + ecc_point *C, + void *modulus) +{ + ecc_point *precomp[16]; + unsigned bitbufA, bitbufB, lenA, lenB, len, x, y, nA, nB, nibble; + unsigned char *tA, *tB; + int err, first; + void *mp, *mu; + + /* argchks */ + LTC_ARGCHK(A != NULL); + LTC_ARGCHK(B != NULL); + LTC_ARGCHK(C != NULL); + LTC_ARGCHK(kA != NULL); + LTC_ARGCHK(kB != NULL); + LTC_ARGCHK(modulus != NULL); + + /* allocate memory */ + tA = XCALLOC(1, ECC_BUF_SIZE); + if (tA == NULL) { + return CRYPT_MEM; + } + tB = XCALLOC(1, ECC_BUF_SIZE); + if (tB == NULL) { + XFREE(tA); + return CRYPT_MEM; + } + + /* get sizes */ + lenA = mp_unsigned_bin_size(kA); + lenB = mp_unsigned_bin_size(kB); + len = MAX(lenA, lenB); + + /* sanity check */ + if ((lenA > ECC_BUF_SIZE) || (lenB > ECC_BUF_SIZE)) { + err = CRYPT_INVALID_ARG; + goto ERR_T; + } + + /* extract and justify kA */ + mp_to_unsigned_bin(kA, (len - lenA) + tA); + + /* extract and justify kB */ + mp_to_unsigned_bin(kB, (len - lenB) + tB); + + /* allocate the table */ + for (x = 0; x < 16; x++) { + precomp[x] = ltc_ecc_new_point(); + if (precomp[x] == NULL) { + for (y = 0; y < x; ++y) { + ltc_ecc_del_point(precomp[y]); + } + err = CRYPT_MEM; + goto ERR_T; + } + } + + /* init montgomery reduction */ + if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { + goto ERR_P; + } + if ((err = mp_init(&mu)) != CRYPT_OK) { + goto ERR_MP; + } + if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) { + goto ERR_MU; + } + + /* copy ones ... */ + if ((err = mp_mulmod(A->x, mu, modulus, precomp[1]->x)) != CRYPT_OK) { goto ERR_MU; } + if ((err = mp_mulmod(A->y, mu, modulus, precomp[1]->y)) != CRYPT_OK) { goto ERR_MU; } + if ((err = mp_mulmod(A->z, mu, modulus, precomp[1]->z)) != CRYPT_OK) { goto ERR_MU; } + + if ((err = mp_mulmod(B->x, mu, modulus, precomp[1<<2]->x)) != CRYPT_OK) { goto ERR_MU; } + if ((err = mp_mulmod(B->y, mu, modulus, precomp[1<<2]->y)) != CRYPT_OK) { goto ERR_MU; } + if ((err = mp_mulmod(B->z, mu, modulus, precomp[1<<2]->z)) != CRYPT_OK) { goto ERR_MU; } + + /* precomp [i,0](A + B) table */ + if ((err = ltc_mp.ecc_ptdbl(precomp[1], precomp[2], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + if ((err = ltc_mp.ecc_ptadd(precomp[1], precomp[2], precomp[3], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + + /* precomp [0,i](A + B) table */ + if ((err = ltc_mp.ecc_ptdbl(precomp[1<<2], precomp[2<<2], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + if ((err = ltc_mp.ecc_ptadd(precomp[1<<2], precomp[2<<2], precomp[3<<2], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + + /* precomp [i,j](A + B) table (i != 0, j != 0) */ + for (x = 1; x < 4; x++) { + for (y = 1; y < 4; y++) { + if ((err = ltc_mp.ecc_ptadd(precomp[x], precomp[(y<<2)], precomp[x+(y<<2)], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + } + } + + nibble = 3; + first = 1; + bitbufA = tA[0]; + bitbufB = tB[0]; + + /* for every byte of the multiplicands */ + for (x = -1;; ) { + /* grab a nibble */ + if (++nibble == 4) { + ++x; if (x == len) break; + bitbufA = tA[x]; + bitbufB = tB[x]; + nibble = 0; + } + + /* extract two bits from both, shift/update */ + nA = (bitbufA >> 6) & 0x03; + nB = (bitbufB >> 6) & 0x03; + bitbufA = (bitbufA << 2) & 0xFF; + bitbufB = (bitbufB << 2) & 0xFF; + + /* if both zero, if first, continue */ + if ((nA == 0) && (nB == 0) && (first == 1)) { + continue; + } + + /* double twice, only if this isn't the first */ + if (first == 0) { + /* double twice */ + if ((err = ltc_mp.ecc_ptdbl(C, C, modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + if ((err = ltc_mp.ecc_ptdbl(C, C, modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + } + + /* if not both zero */ + if ((nA != 0) || (nB != 0)) { + if (first == 1) { + /* if first, copy from table */ + first = 0; + if ((err = mp_copy(precomp[nA + (nB<<2)]->x, C->x)) != CRYPT_OK) { goto ERR_MU; } + if ((err = mp_copy(precomp[nA + (nB<<2)]->y, C->y)) != CRYPT_OK) { goto ERR_MU; } + if ((err = mp_copy(precomp[nA + (nB<<2)]->z, C->z)) != CRYPT_OK) { goto ERR_MU; } + } else { + /* if not first, add from table */ + if ((err = ltc_mp.ecc_ptadd(C, precomp[nA + (nB<<2)], C, modulus, mp)) != CRYPT_OK) { goto ERR_MU; } + } + } + } + + /* reduce to affine */ + err = ltc_ecc_map(C, modulus, mp); + + /* clean up */ +ERR_MU: + mp_clear(mu); +ERR_MP: + mp_montgomery_free(mp); +ERR_P: + for (x = 0; x < 16; x++) { + ltc_ecc_del_point(precomp[x]); + } +ERR_T: +#ifdef LTC_CLEAN_STACK + zeromem(tA, ECC_BUF_SIZE); + zeromem(tB, ECC_BUF_SIZE); +#endif + XFREE(tA); + XFREE(tB); + + return err; +} + +#endif +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c new file mode 100644 index 000000000..f9d0cad83 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c @@ -0,0 +1,222 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b + * + * All curves taken from NIST recommendation paper of July 1999 + * Available at http://csrc.nist.gov/cryptval/dss.htm + */ +#include "../../headers/tomcrypt.h" + +/** + @file ltc_ecc_mulmod.c + ECC Crypto, Tom St Denis +*/ + +#ifdef LTC_MECC +#ifndef LTC_ECC_TIMING_RESISTANT + +/* size of sliding window, don't change this! */ +#define WINSIZE 4 + +/** + Perform a point multiplication + @param k The scalar to multiply by + @param G The base point + @param R [out] Destination for kG + @param modulus The modulus of the field the ECC curve is in + @param map Boolean whether to map back to affine or not (1==map, 0 == leave in projective) + @return CRYPT_OK on success +*/ +int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map) +{ + ecc_point *tG, *M[8]; + int i, j, err; + void *mu, *mp; + unsigned long buf; + int first, bitbuf, bitcpy, bitcnt, mode, digidx; + + LTC_ARGCHK(k != NULL); + LTC_ARGCHK(G != NULL); + LTC_ARGCHK(R != NULL); + LTC_ARGCHK(modulus != NULL); + + /* init montgomery reduction */ + if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { + return err; + } + if ((err = mp_init(&mu)) != CRYPT_OK) { + mp_montgomery_free(mp); + return err; + } + if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) { + mp_montgomery_free(mp); + mp_clear(mu); + return err; + } + + /* alloc ram for window temps */ + for (i = 0; i < 8; i++) { + M[i] = ltc_ecc_new_point(); + if (M[i] == NULL) { + for (j = 0; j < i; j++) { + ltc_ecc_del_point(M[j]); + } + mp_montgomery_free(mp); + mp_clear(mu); + return CRYPT_MEM; + } + } + + /* make a copy of G incase R==G */ + tG = ltc_ecc_new_point(); + if (tG == NULL) { err = CRYPT_MEM; goto done; } + + /* tG = G and convert to montgomery */ + if (mp_cmp_d(mu, 1) == LTC_MP_EQ) { + if ((err = mp_copy(G->x, tG->x)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(G->y, tG->y)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(G->z, tG->z)) != CRYPT_OK) { goto done; } + } else { + if ((err = mp_mulmod(G->x, mu, modulus, tG->x)) != CRYPT_OK) { goto done; } + if ((err = mp_mulmod(G->y, mu, modulus, tG->y)) != CRYPT_OK) { goto done; } + if ((err = mp_mulmod(G->z, mu, modulus, tG->z)) != CRYPT_OK) { goto done; } + } + mp_clear(mu); + mu = NULL; + + /* calc the M tab, which holds kG for k==8..15 */ + /* M[0] == 8G */ + if ((err = ltc_mp.ecc_ptdbl(tG, M[0], modulus, mp)) != CRYPT_OK) { goto done; } + if ((err = ltc_mp.ecc_ptdbl(M[0], M[0], modulus, mp)) != CRYPT_OK) { goto done; } + if ((err = ltc_mp.ecc_ptdbl(M[0], M[0], modulus, mp)) != CRYPT_OK) { goto done; } + + /* now find (8+k)G for k=1..7 */ + for (j = 9; j < 16; j++) { + if ((err = ltc_mp.ecc_ptadd(M[j-9], tG, M[j-8], modulus, mp)) != CRYPT_OK) { goto done; } + } + + /* setup sliding window */ + mode = 0; + bitcnt = 1; + buf = 0; + digidx = mp_get_digit_count(k) - 1; + bitcpy = bitbuf = 0; + first = 1; + + /* perform ops */ + for (;;) { + /* grab next digit as required */ + if (--bitcnt == 0) { + if (digidx == -1) { + break; + } + buf = mp_get_digit(k, digidx); + bitcnt = (int) ltc_mp.bits_per_digit; + --digidx; + } + + /* grab the next msb from the ltiplicand */ + i = (buf >> (ltc_mp.bits_per_digit - 1)) & 1; + buf <<= 1; + + /* skip leading zero bits */ + if (mode == 0 && i == 0) { + continue; + } + + /* if the bit is zero and mode == 1 then we double */ + if (mode == 1 && i == 0) { + if ((err = ltc_mp.ecc_ptdbl(R, R, modulus, mp)) != CRYPT_OK) { goto done; } + continue; + } + + /* else we add it to the window */ + bitbuf |= (i << (WINSIZE - ++bitcpy)); + mode = 2; + + if (bitcpy == WINSIZE) { + /* if this is the first window we do a simple copy */ + if (first == 1) { + /* R = kG [k = first window] */ + if ((err = mp_copy(M[bitbuf-8]->x, R->x)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(M[bitbuf-8]->y, R->y)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(M[bitbuf-8]->z, R->z)) != CRYPT_OK) { goto done; } + first = 0; + } else { + /* normal window */ + /* ok window is filled so double as required and add */ + /* double first */ + for (j = 0; j < WINSIZE; j++) { + if ((err = ltc_mp.ecc_ptdbl(R, R, modulus, mp)) != CRYPT_OK) { goto done; } + } + + /* then add, bitbuf will be 8..15 [8..2^WINSIZE] guaranteed */ + if ((err = ltc_mp.ecc_ptadd(R, M[bitbuf-8], R, modulus, mp)) != CRYPT_OK) { goto done; } + } + /* empty window and reset */ + bitcpy = bitbuf = 0; + mode = 1; + } + } + + /* if bits remain then double/add */ + if (mode == 2 && bitcpy > 0) { + /* double then add */ + for (j = 0; j < bitcpy; j++) { + /* only double if we have had at least one add first */ + if (first == 0) { + if ((err = ltc_mp.ecc_ptdbl(R, R, modulus, mp)) != CRYPT_OK) { goto done; } + } + + bitbuf <<= 1; + if ((bitbuf & (1 << WINSIZE)) != 0) { + if (first == 1){ + /* first add, so copy */ + if ((err = mp_copy(tG->x, R->x)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(tG->y, R->y)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(tG->z, R->z)) != CRYPT_OK) { goto done; } + first = 0; + } else { + /* then add */ + if ((err = ltc_mp.ecc_ptadd(R, tG, R, modulus, mp)) != CRYPT_OK) { goto done; } + } + } + } + } + + /* map R back from projective space */ + if (map) { + err = ltc_ecc_map(R, modulus, mp); + } else { + err = CRYPT_OK; + } +done: + if (mu != NULL) { + mp_clear(mu); + } + mp_montgomery_free(mp); + ltc_ecc_del_point(tG); + for (i = 0; i < 8; i++) { + ltc_ecc_del_point(M[i]); + } + return err; +} + +#endif + +#undef WINSIZE + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c,v $ */ +/* $Revision: 1.26 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c new file mode 100644 index 000000000..f5a4acb4c --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c @@ -0,0 +1,60 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b + * + * All curves taken from NIST recommendation paper of July 1999 + * Available at http://csrc.nist.gov/cryptval/dss.htm + */ +#include "../../headers/tomcrypt.h" + +/** + @file ltc_ecc_points.c + ECC Crypto, Tom St Denis +*/ + +#ifdef LTC_MECC + +/** + Allocate a new ECC point + @return A newly allocated point or NULL on error +*/ +ecc_point *ltc_ecc_new_point(void) +{ + ecc_point *p; + p = XCALLOC(1, sizeof(*p)); + if (p == NULL) { + return NULL; + } + if (mp_init_multi(&p->x, &p->y, &p->z, NULL) != CRYPT_OK) { + XFREE(p); + return NULL; + } + return p; +} + +/** Free an ECC point from memory + @param p The point to free +*/ +void ltc_ecc_del_point(ecc_point *p) +{ + /* prevents free'ing null arguments */ + if (p != NULL) { + mp_clear_multi(p->x, p->y, p->z, NULL); /* note: p->z may be NULL but that's ok with this function anyways */ + XFREE(p); + } +} + +#endif +/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_points.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ + diff --git a/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c new file mode 100644 index 000000000..b4416fc77 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c @@ -0,0 +1,196 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b + * + * All curves taken from NIST recommendation paper of July 1999 + * Available at http://csrc.nist.gov/cryptval/dss.htm + */ +#include "../../headers/tomcrypt.h" + +/** + @file ltc_ecc_projective_add_point.c + ECC Crypto, Tom St Denis +*/ + +#if defined(LTC_MECC) && (!defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC)) + +/** + Add two ECC points + @param P The point to add + @param Q The point to add + @param R [out] The destination of the double + @param modulus The modulus of the field the ECC curve is in + @param mp The "b" value from montgomery_setup() + @return CRYPT_OK on success +*/ +int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp) +{ + void *t1, *t2, *x, *y, *z; + int err; + + LTC_ARGCHK(P != NULL); + LTC_ARGCHK(Q != NULL); + LTC_ARGCHK(R != NULL); + LTC_ARGCHK(modulus != NULL); + LTC_ARGCHK(mp != NULL); + + if ((err = mp_init_multi(&t1, &t2, &x, &y, &z, NULL)) != CRYPT_OK) { + return err; + } + + /* should we dbl instead? */ + if ((err = mp_sub(modulus, Q->y, t1)) != CRYPT_OK) { goto done; } + + if ( (mp_cmp(P->x, Q->x) == LTC_MP_EQ) && + (Q->z != NULL && mp_cmp(P->z, Q->z) == LTC_MP_EQ) && + (mp_cmp(P->y, Q->y) == LTC_MP_EQ || mp_cmp(P->y, t1) == LTC_MP_EQ)) { + mp_clear_multi(t1, t2, x, y, z, NULL); + return ltc_ecc_projective_dbl_point(P, R, modulus, mp); + } + + if ((err = mp_copy(P->x, x)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(P->y, y)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(P->z, z)) != CRYPT_OK) { goto done; } + + /* if Z is one then these are no-operations */ + if (Q->z != NULL) { + /* T1 = Z' * Z' */ + if ((err = mp_sqr(Q->z, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + /* X = X * T1 */ + if ((err = mp_mul(t1, x, x)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK) { goto done; } + /* T1 = Z' * T1 */ + if ((err = mp_mul(Q->z, t1, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + /* Y = Y * T1 */ + if ((err = mp_mul(t1, y, y)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(y, modulus, mp)) != CRYPT_OK) { goto done; } + } + + /* T1 = Z*Z */ + if ((err = mp_sqr(z, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + /* T2 = X' * T1 */ + if ((err = mp_mul(Q->x, t1, t2)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } + /* T1 = Z * T1 */ + if ((err = mp_mul(z, t1, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + /* T1 = Y' * T1 */ + if ((err = mp_mul(Q->y, t1, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + + /* Y = Y - T1 */ + if ((err = mp_sub(y, t1, y)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(y, 0) == LTC_MP_LT) { + if ((err = mp_add(y, modulus, y)) != CRYPT_OK) { goto done; } + } + /* T1 = 2T1 */ + if ((err = mp_add(t1, t1, t1)) != CRYPT_OK) { goto done; } + if (mp_cmp(t1, modulus) != LTC_MP_LT) { + if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } + } + /* T1 = Y + T1 */ + if ((err = mp_add(t1, y, t1)) != CRYPT_OK) { goto done; } + if (mp_cmp(t1, modulus) != LTC_MP_LT) { + if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } + } + /* X = X - T2 */ + if ((err = mp_sub(x, t2, x)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(x, 0) == LTC_MP_LT) { + if ((err = mp_add(x, modulus, x)) != CRYPT_OK) { goto done; } + } + /* T2 = 2T2 */ + if ((err = mp_add(t2, t2, t2)) != CRYPT_OK) { goto done; } + if (mp_cmp(t2, modulus) != LTC_MP_LT) { + if ((err = mp_sub(t2, modulus, t2)) != CRYPT_OK) { goto done; } + } + /* T2 = X + T2 */ + if ((err = mp_add(t2, x, t2)) != CRYPT_OK) { goto done; } + if (mp_cmp(t2, modulus) != LTC_MP_LT) { + if ((err = mp_sub(t2, modulus, t2)) != CRYPT_OK) { goto done; } + } + + /* if Z' != 1 */ + if (Q->z != NULL) { + /* Z = Z * Z' */ + if ((err = mp_mul(z, Q->z, z)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(z, modulus, mp)) != CRYPT_OK) { goto done; } + } + + /* Z = Z * X */ + if ((err = mp_mul(z, x, z)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(z, modulus, mp)) != CRYPT_OK) { goto done; } + + /* T1 = T1 * X */ + if ((err = mp_mul(t1, x, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + /* X = X * X */ + if ((err = mp_sqr(x, x)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK) { goto done; } + /* T2 = T2 * x */ + if ((err = mp_mul(t2, x, t2)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } + /* T1 = T1 * X */ + if ((err = mp_mul(t1, x, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + + /* X = Y*Y */ + if ((err = mp_sqr(y, x)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK) { goto done; } + /* X = X - T2 */ + if ((err = mp_sub(x, t2, x)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(x, 0) == LTC_MP_LT) { + if ((err = mp_add(x, modulus, x)) != CRYPT_OK) { goto done; } + } + + /* T2 = T2 - X */ + if ((err = mp_sub(t2, x, t2)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(t2, 0) == LTC_MP_LT) { + if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } + } + /* T2 = T2 - X */ + if ((err = mp_sub(t2, x, t2)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(t2, 0) == LTC_MP_LT) { + if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } + } + /* T2 = T2 * Y */ + if ((err = mp_mul(t2, y, t2)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } + /* Y = T2 - T1 */ + if ((err = mp_sub(t2, t1, y)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(y, 0) == LTC_MP_LT) { + if ((err = mp_add(y, modulus, y)) != CRYPT_OK) { goto done; } + } + /* Y = Y/2 */ + if (mp_isodd(y)) { + if ((err = mp_add(y, modulus, y)) != CRYPT_OK) { goto done; } + } + if ((err = mp_div_2(y, y)) != CRYPT_OK) { goto done; } + + if ((err = mp_copy(x, R->x)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(y, R->y)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(z, R->z)) != CRYPT_OK) { goto done; } + + err = CRYPT_OK; +done: + mp_clear_multi(t1, t2, x, y, z, NULL); + return err; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c,v $ */ +/* $Revision: 1.16 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ + diff --git a/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c new file mode 100644 index 000000000..b990e0a14 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c @@ -0,0 +1,147 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b + * + * All curves taken from NIST recommendation paper of July 1999 + * Available at http://csrc.nist.gov/cryptval/dss.htm + */ +#include "../../headers/tomcrypt.h" + +/** + @file ltc_ecc_projective_dbl_point.c + ECC Crypto, Tom St Denis +*/ + +#if defined(LTC_MECC) && (!defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC)) + +/** + Double an ECC point + @param P The point to double + @param R [out] The destination of the double + @param modulus The modulus of the field the ECC curve is in + @param mp The "b" value from montgomery_setup() + @return CRYPT_OK on success +*/ +int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp) +{ + void *t1, *t2; + int err; + + LTC_ARGCHK(P != NULL); + LTC_ARGCHK(R != NULL); + LTC_ARGCHK(modulus != NULL); + LTC_ARGCHK(mp != NULL); + + if ((err = mp_init_multi(&t1, &t2, NULL)) != CRYPT_OK) { + return err; + } + + if (P != R) { + if ((err = mp_copy(P->x, R->x)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(P->y, R->y)) != CRYPT_OK) { goto done; } + if ((err = mp_copy(P->z, R->z)) != CRYPT_OK) { goto done; } + } + + /* t1 = Z * Z */ + if ((err = mp_sqr(R->z, t1)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } + /* Z = Y * Z */ + if ((err = mp_mul(R->z, R->y, R->z)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(R->z, modulus, mp)) != CRYPT_OK) { goto done; } + /* Z = 2Z */ + if ((err = mp_add(R->z, R->z, R->z)) != CRYPT_OK) { goto done; } + if (mp_cmp(R->z, modulus) != LTC_MP_LT) { + if ((err = mp_sub(R->z, modulus, R->z)) != CRYPT_OK) { goto done; } + } + + /* T2 = X - T1 */ + if ((err = mp_sub(R->x, t1, t2)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(t2, 0) == LTC_MP_LT) { + if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } + } + /* T1 = X + T1 */ + if ((err = mp_add(t1, R->x, t1)) != CRYPT_OK) { goto done; } + if (mp_cmp(t1, modulus) != LTC_MP_LT) { + if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } + } + /* T2 = T1 * T2 */ + if ((err = mp_mul(t1, t2, t2)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } + /* T1 = 2T2 */ + if ((err = mp_add(t2, t2, t1)) != CRYPT_OK) { goto done; } + if (mp_cmp(t1, modulus) != LTC_MP_LT) { + if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } + } + /* T1 = T1 + T2 */ + if ((err = mp_add(t1, t2, t1)) != CRYPT_OK) { goto done; } + if (mp_cmp(t1, modulus) != LTC_MP_LT) { + if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } + } + + /* Y = 2Y */ + if ((err = mp_add(R->y, R->y, R->y)) != CRYPT_OK) { goto done; } + if (mp_cmp(R->y, modulus) != LTC_MP_LT) { + if ((err = mp_sub(R->y, modulus, R->y)) != CRYPT_OK) { goto done; } + } + /* Y = Y * Y */ + if ((err = mp_sqr(R->y, R->y)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK) { goto done; } + /* T2 = Y * Y */ + if ((err = mp_sqr(R->y, t2)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } + /* T2 = T2/2 */ + if (mp_isodd(t2)) { + if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } + } + if ((err = mp_div_2(t2, t2)) != CRYPT_OK) { goto done; } + /* Y = Y * X */ + if ((err = mp_mul(R->y, R->x, R->y)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK) { goto done; } + + /* X = T1 * T1 */ + if ((err = mp_sqr(t1, R->x)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(R->x, modulus, mp)) != CRYPT_OK) { goto done; } + /* X = X - Y */ + if ((err = mp_sub(R->x, R->y, R->x)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(R->x, 0) == LTC_MP_LT) { + if ((err = mp_add(R->x, modulus, R->x)) != CRYPT_OK) { goto done; } + } + /* X = X - Y */ + if ((err = mp_sub(R->x, R->y, R->x)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(R->x, 0) == LTC_MP_LT) { + if ((err = mp_add(R->x, modulus, R->x)) != CRYPT_OK) { goto done; } + } + + /* Y = Y - X */ + if ((err = mp_sub(R->y, R->x, R->y)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(R->y, 0) == LTC_MP_LT) { + if ((err = mp_add(R->y, modulus, R->y)) != CRYPT_OK) { goto done; } + } + /* Y = Y * T1 */ + if ((err = mp_mul(R->y, t1, R->y)) != CRYPT_OK) { goto done; } + if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK) { goto done; } + /* Y = Y - T2 */ + if ((err = mp_sub(R->y, t2, R->y)) != CRYPT_OK) { goto done; } + if (mp_cmp_d(R->y, 0) == LTC_MP_LT) { + if ((err = mp_add(R->y, modulus, R->y)) != CRYPT_OK) { goto done; } + } + + err = CRYPT_OK; +done: + mp_clear_multi(t1, t2, NULL); + return err; +} +#endif +/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c,v $ */ +/* $Revision: 1.11 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ + diff --git a/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c new file mode 100644 index 000000000..e8f641806 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c @@ -0,0 +1,108 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file pkcs_1_mgf1.c + The Mask Generation Function (MGF1) for LTC_PKCS #1, Tom St Denis +*/ + +#ifdef LTC_PKCS_1 + +/** + Perform LTC_PKCS #1 MGF1 (internal) + @param seed The seed for MGF1 + @param seedlen The length of the seed + @param hash_idx The index of the hash desired + @param mask [out] The destination + @param masklen The length of the mask desired + @return CRYPT_OK if successful +*/ +int pkcs_1_mgf1(int hash_idx, + const unsigned char *seed, unsigned long seedlen, + unsigned char *mask, unsigned long masklen) +{ + unsigned long hLen, x; + ulong32 counter; + int err; + hash_state *md; + unsigned char *buf; + + LTC_ARGCHK(seed != NULL); + LTC_ARGCHK(mask != NULL); + + /* ensure valid hash */ + if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { + return err; + } + + /* get hash output size */ + hLen = hash_descriptor[hash_idx].hashsize; + + /* allocate memory */ + md = XMALLOC(sizeof(hash_state)); + buf = XMALLOC(hLen); + if (md == NULL || buf == NULL) { + if (md != NULL) { + XFREE(md); + } + if (buf != NULL) { + XFREE(buf); + } + return CRYPT_MEM; + } + + /* start counter */ + counter = 0; + + while (masklen > 0) { + /* handle counter */ + STORE32H(counter, buf); + ++counter; + + /* get hash of seed || counter */ + if ((err = hash_descriptor[hash_idx].init(md)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].process(md, seed, seedlen)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].process(md, buf, 4)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].done(md, buf)) != CRYPT_OK) { + goto LBL_ERR; + } + + /* store it */ + for (x = 0; x < hLen && masklen > 0; x++, masklen--) { + *mask++ = buf[x]; + } + } + + err = CRYPT_OK; +LBL_ERR: +#ifdef LTC_CLEAN_STACK + zeromem(buf, hLen); + zeromem(md, sizeof(hash_state)); +#endif + + XFREE(buf); + XFREE(md); + + return err; +} + +#endif /* LTC_PKCS_1 */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c new file mode 100644 index 000000000..709ab8a8c --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c @@ -0,0 +1,189 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file pkcs_1_oaep_decode.c + OAEP Padding for LTC_PKCS #1, Tom St Denis +*/ + +#ifdef LTC_PKCS_1 + +/** + LTC_PKCS #1 v2.00 OAEP decode + @param msg The encoded data to decode + @param msglen The length of the encoded data (octets) + @param lparam The session or system data (can be NULL) + @param lparamlen The length of the lparam + @param modulus_bitlen The bit length of the RSA modulus + @param hash_idx The index of the hash desired + @param out [out] Destination of decoding + @param outlen [in/out] The max size and resulting size of the decoding + @param res [out] Result of decoding, 1==valid, 0==invalid + @return CRYPT_OK if successful (even if invalid) +*/ +int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen, + const unsigned char *lparam, unsigned long lparamlen, + unsigned long modulus_bitlen, int hash_idx, + unsigned char *out, unsigned long *outlen, + int *res) +{ + unsigned char *DB, *seed, *mask; + unsigned long hLen, x, y, modulus_len; + int err; + + LTC_ARGCHK(msg != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(res != NULL); + + /* default to invalid packet */ + *res = 0; + + /* test valid hash */ + if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { + return err; + } + hLen = hash_descriptor[hash_idx].hashsize; + modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0); + + /* test hash/message size */ + if ((2*hLen >= (modulus_len - 2)) || (msglen != modulus_len)) { + return CRYPT_PK_INVALID_SIZE; + } + + /* allocate ram for DB/mask/salt of size modulus_len */ + DB = XMALLOC(modulus_len); + mask = XMALLOC(modulus_len); + seed = XMALLOC(hLen); + if (DB == NULL || mask == NULL || seed == NULL) { + if (DB != NULL) { + XFREE(DB); + } + if (mask != NULL) { + XFREE(mask); + } + if (seed != NULL) { + XFREE(seed); + } + return CRYPT_MEM; + } + + /* ok so it's now in the form + + 0x00 || maskedseed || maskedDB + + 1 || hLen || modulus_len - hLen - 1 + + */ + + /* must have leading 0x00 byte */ + if (msg[0] != 0x00) { + err = CRYPT_OK; + goto LBL_ERR; + } + + /* now read the masked seed */ + x = 1; + XMEMCPY(seed, msg + x, hLen); + x += hLen; + + /* now read the masked DB */ + XMEMCPY(DB, msg + x, modulus_len - hLen - 1); + x += modulus_len - hLen - 1; + + /* compute MGF1 of maskedDB (hLen) */ + if ((err = pkcs_1_mgf1(hash_idx, DB, modulus_len - hLen - 1, mask, hLen)) != CRYPT_OK) { + goto LBL_ERR; + } + + /* XOR against seed */ + for (y = 0; y < hLen; y++) { + seed[y] ^= mask[y]; + } + + /* compute MGF1 of seed (k - hlen - 1) */ + if ((err = pkcs_1_mgf1(hash_idx, seed, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) { + goto LBL_ERR; + } + + /* xor against DB */ + for (y = 0; y < (modulus_len - hLen - 1); y++) { + DB[y] ^= mask[y]; + } + + /* now DB == lhash || PS || 0x01 || M, PS == k - mlen - 2hlen - 2 zeroes */ + + /* compute lhash and store it in seed [reuse temps!] */ + x = modulus_len; + if (lparam != NULL) { + if ((err = hash_memory(hash_idx, lparam, lparamlen, seed, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + } else { + /* can't pass hash_memory a NULL so use DB with zero length */ + if ((err = hash_memory(hash_idx, DB, 0, seed, &x)) != CRYPT_OK) { + goto LBL_ERR; + } + } + + /* compare the lhash'es */ + if (XMEMCMP(seed, DB, hLen) != 0) { + err = CRYPT_OK; + goto LBL_ERR; + } + + /* now zeroes before a 0x01 */ + for (x = hLen; x < (modulus_len - hLen - 1) && DB[x] == 0x00; x++) { + /* step... */ + } + + /* error out if wasn't 0x01 */ + if (x == (modulus_len - hLen - 1) || DB[x] != 0x01) { + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + + /* rest is the message (and skip 0x01) */ + if ((modulus_len - hLen - 1 - ++x) > *outlen) { + *outlen = modulus_len - hLen - 1 - x; + err = CRYPT_BUFFER_OVERFLOW; + goto LBL_ERR; + } + + /* copy message */ + *outlen = modulus_len - hLen - 1 - x; + XMEMCPY(out, DB + x, modulus_len - hLen - 1 - x); + x += modulus_len - hLen - 1; + + /* valid packet */ + *res = 1; + + err = CRYPT_OK; +LBL_ERR: +#ifdef LTC_CLEAN_STACK + zeromem(DB, modulus_len); + zeromem(seed, hLen); + zeromem(mask, modulus_len); +#endif + + XFREE(seed); + XFREE(mask); + XFREE(DB); + + return err; +} + +#endif /* LTC_PKCS_1 */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c,v $ */ +/* $Revision: 1.13 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c new file mode 100644 index 000000000..c3a7211ef --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c @@ -0,0 +1,177 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file pkcs_1_pss_decode.c + LTC_PKCS #1 PSS Signature Padding, Tom St Denis +*/ + +#ifdef LTC_PKCS_1 + +/** + LTC_PKCS #1 v2.00 PSS decode + @param msghash The hash to verify + @param msghashlen The length of the hash (octets) + @param sig The signature data (encoded data) + @param siglen The length of the signature data (octets) + @param saltlen The length of the salt used (octets) + @param hash_idx The index of the hash desired + @param modulus_bitlen The bit length of the RSA modulus + @param res [out] The result of the comparison, 1==valid, 0==invalid + @return CRYPT_OK if successful (even if the comparison failed) +*/ +int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen, + const unsigned char *sig, unsigned long siglen, + unsigned long saltlen, int hash_idx, + unsigned long modulus_bitlen, int *res) +{ + unsigned char *DB, *mask, *salt, *hash; + unsigned long x, y, hLen, modulus_len; + int err; + hash_state md; + + LTC_ARGCHK(msghash != NULL); + LTC_ARGCHK(res != NULL); + + /* default to invalid */ + *res = 0; + + /* ensure hash is valid */ + if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { + return err; + } + + hLen = hash_descriptor[hash_idx].hashsize; + modulus_len = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); + + /* check sizes */ + if ((saltlen > modulus_len) || + (modulus_len < hLen + saltlen + 2) || (siglen != modulus_len)) { + return CRYPT_PK_INVALID_SIZE; + } + + /* allocate ram for DB/mask/salt/hash of size modulus_len */ + DB = XMALLOC(modulus_len); + mask = XMALLOC(modulus_len); + salt = XMALLOC(modulus_len); + hash = XMALLOC(modulus_len); + if (DB == NULL || mask == NULL || salt == NULL || hash == NULL) { + if (DB != NULL) { + XFREE(DB); + } + if (mask != NULL) { + XFREE(mask); + } + if (salt != NULL) { + XFREE(salt); + } + if (hash != NULL) { + XFREE(hash); + } + return CRYPT_MEM; + } + + /* ensure the 0xBC byte */ + if (sig[siglen-1] != 0xBC) { + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + + /* copy out the DB */ + x = 0; + XMEMCPY(DB, sig + x, modulus_len - hLen - 1); + x += modulus_len - hLen - 1; + + /* copy out the hash */ + XMEMCPY(hash, sig + x, hLen); + x += hLen; + + /* check the MSB */ + if ((sig[0] & ~(0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)))) != 0) { + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + + /* generate mask of length modulus_len - hLen - 1 from hash */ + if ((err = pkcs_1_mgf1(hash_idx, hash, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) { + goto LBL_ERR; + } + + /* xor against DB */ + for (y = 0; y < (modulus_len - hLen - 1); y++) { + DB[y] ^= mask[y]; + } + + /* now clear the first byte [make sure smaller than modulus] */ + DB[0] &= 0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)); + + /* DB = PS || 0x01 || salt, PS == modulus_len - saltlen - hLen - 2 zero bytes */ + + /* check for zeroes and 0x01 */ + for (x = 0; x < modulus_len - saltlen - hLen - 2; x++) { + if (DB[x] != 0x00) { + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + } + + /* check for the 0x01 */ + if (DB[x++] != 0x01) { + err = CRYPT_INVALID_PACKET; + goto LBL_ERR; + } + + /* M = (eight) 0x00 || msghash || salt, mask = H(M) */ + if ((err = hash_descriptor[hash_idx].init(&md)) != CRYPT_OK) { + goto LBL_ERR; + } + zeromem(mask, 8); + if ((err = hash_descriptor[hash_idx].process(&md, mask, 8)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].process(&md, msghash, msghashlen)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].process(&md, DB+x, saltlen)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].done(&md, mask)) != CRYPT_OK) { + goto LBL_ERR; + } + + /* mask == hash means valid signature */ + if (XMEMCMP(mask, hash, hLen) == 0) { + *res = 1; + } + + err = CRYPT_OK; +LBL_ERR: +#ifdef LTC_CLEAN_STACK + zeromem(DB, modulus_len); + zeromem(mask, modulus_len); + zeromem(salt, modulus_len); + zeromem(hash, modulus_len); +#endif + + XFREE(hash); + XFREE(salt); + XFREE(mask); + XFREE(DB); + + return err; +} + +#endif /* LTC_PKCS_1 */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c,v $ */ +/* $Revision: 1.11 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c new file mode 100644 index 000000000..68d5e8615 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c @@ -0,0 +1,175 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file pkcs_1_pss_encode.c + LTC_PKCS #1 PSS Signature Padding, Tom St Denis +*/ + +#ifdef LTC_PKCS_1 + +/** + LTC_PKCS #1 v2.00 Signature Encoding + @param msghash The hash to encode + @param msghashlen The length of the hash (octets) + @param saltlen The length of the salt desired (octets) + @param prng An active PRNG context + @param prng_idx The index of the PRNG desired + @param hash_idx The index of the hash desired + @param modulus_bitlen The bit length of the RSA modulus + @param out [out] The destination of the encoding + @param outlen [in/out] The max size and resulting size of the encoded data + @return CRYPT_OK if successful +*/ +int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, + unsigned long saltlen, prng_state *prng, + int prng_idx, int hash_idx, + unsigned long modulus_bitlen, + unsigned char *out, unsigned long *outlen) +{ + unsigned char *DB, *mask, *salt, *hash; + unsigned long x, y, hLen, modulus_len; + int err; + hash_state md; + + LTC_ARGCHK(msghash != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + + /* ensure hash and PRNG are valid */ + if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { + return err; + } + if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) { + return err; + } + + hLen = hash_descriptor[hash_idx].hashsize; + modulus_len = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); + + /* check sizes */ + if ((saltlen > modulus_len) || (modulus_len < hLen + saltlen + 2)) { + return CRYPT_PK_INVALID_SIZE; + } + + /* allocate ram for DB/mask/salt/hash of size modulus_len */ + DB = XMALLOC(modulus_len); + mask = XMALLOC(modulus_len); + salt = XMALLOC(modulus_len); + hash = XMALLOC(modulus_len); + if (DB == NULL || mask == NULL || salt == NULL || hash == NULL) { + if (DB != NULL) { + XFREE(DB); + } + if (mask != NULL) { + XFREE(mask); + } + if (salt != NULL) { + XFREE(salt); + } + if (hash != NULL) { + XFREE(hash); + } + return CRYPT_MEM; + } + + + /* generate random salt */ + if (saltlen > 0) { + if (prng_descriptor[prng_idx].read(salt, saltlen, prng) != saltlen) { + err = CRYPT_ERROR_READPRNG; + goto LBL_ERR; + } + } + + /* M = (eight) 0x00 || msghash || salt, hash = H(M) */ + if ((err = hash_descriptor[hash_idx].init(&md)) != CRYPT_OK) { + goto LBL_ERR; + } + zeromem(DB, 8); + if ((err = hash_descriptor[hash_idx].process(&md, DB, 8)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].process(&md, msghash, msghashlen)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].process(&md, salt, saltlen)) != CRYPT_OK) { + goto LBL_ERR; + } + if ((err = hash_descriptor[hash_idx].done(&md, hash)) != CRYPT_OK) { + goto LBL_ERR; + } + + /* generate DB = PS || 0x01 || salt, PS == modulus_len - saltlen - hLen - 2 zero bytes */ + x = 0; + XMEMSET(DB + x, 0, modulus_len - saltlen - hLen - 2); + x += modulus_len - saltlen - hLen - 2; + DB[x++] = 0x01; + XMEMCPY(DB + x, salt, saltlen); + x += saltlen; + + /* generate mask of length modulus_len - hLen - 1 from hash */ + if ((err = pkcs_1_mgf1(hash_idx, hash, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) { + goto LBL_ERR; + } + + /* xor against DB */ + for (y = 0; y < (modulus_len - hLen - 1); y++) { + DB[y] ^= mask[y]; + } + + /* output is DB || hash || 0xBC */ + if (*outlen < modulus_len) { + *outlen = modulus_len; + err = CRYPT_BUFFER_OVERFLOW; + goto LBL_ERR; + } + + /* DB len = modulus_len - hLen - 1 */ + y = 0; + XMEMCPY(out + y, DB, modulus_len - hLen - 1); + y += modulus_len - hLen - 1; + + /* hash */ + XMEMCPY(out + y, hash, hLen); + y += hLen; + + /* 0xBC */ + out[y] = 0xBC; + + /* now clear the 8*modulus_len - modulus_bitlen most significant bits */ + out[0] &= 0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)); + + /* store output size */ + *outlen = modulus_len; + err = CRYPT_OK; +LBL_ERR: +#ifdef LTC_CLEAN_STACK + zeromem(DB, modulus_len); + zeromem(mask, modulus_len); + zeromem(salt, modulus_len); + zeromem(hash, modulus_len); +#endif + + XFREE(hash); + XFREE(salt); + XFREE(mask); + XFREE(DB); + + return err; +} + +#endif /* LTC_PKCS_1 */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c,v $ */ +/* $Revision: 1.9 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c new file mode 100644 index 000000000..7c3711c17 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c @@ -0,0 +1,110 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** @file pkcs_1_v1_5_decode.c + * + * LTC_PKCS #1 v1.5 Padding. (Andreas Lange) + */ + +#ifdef LTC_PKCS_1 + +/** @brief LTC_PKCS #1 v1.5 decode. + * + * @param msg The encoded data to decode + * @param msglen The length of the encoded data (octets) + * @param block_type Block type to use in padding (\sa ltc_pkcs_1_v1_5_blocks) + * @param modulus_bitlen The bit length of the RSA modulus + * @param out [out] Destination of decoding + * @param outlen [in/out] The max size and resulting size of the decoding + * @param is_valid [out] Boolean whether the padding was valid + * + * @return CRYPT_OK if successful (even if invalid) + */ +int pkcs_1_v1_5_decode(const unsigned char *msg, + unsigned long msglen, + int block_type, + unsigned long modulus_bitlen, + unsigned char *out, + unsigned long *outlen, + int *is_valid) +{ + unsigned long modulus_len, ps_len, i; + int result; + + /* default to invalid packet */ + *is_valid = 0; + + modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0); + + /* test message size */ + + if ((msglen > modulus_len) || (modulus_len < 11)) { + return CRYPT_PK_INVALID_SIZE; + } + + /* separate encoded message */ + + if ((msg[0] != 0x00) || (msg[1] != (unsigned char)block_type)) { + result = CRYPT_INVALID_PACKET; + goto bail; + } + + if (block_type == LTC_LTC_PKCS_1_EME) { + for (i = 2; i < modulus_len; i++) { + /* separator */ + if (msg[i] == 0x00) { break; } + } + ps_len = i++ - 2; + + if ((i >= modulus_len) || (ps_len < 8)) { + /* There was no octet with hexadecimal value 0x00 to separate ps from m, + * or the length of ps is less than 8 octets. + */ + result = CRYPT_INVALID_PACKET; + goto bail; + } + } else { + for (i = 2; i < modulus_len - 1; i++) { + if (msg[i] != 0xFF) { break; } + } + + /* separator check */ + if (msg[i] != 0) { + /* There was no octet with hexadecimal value 0x00 to separate ps from m. */ + result = CRYPT_INVALID_PACKET; + goto bail; + } + + ps_len = i - 2; + } + + if (*outlen < (msglen - (2 + ps_len + 1))) { + *outlen = msglen - (2 + ps_len + 1); + result = CRYPT_BUFFER_OVERFLOW; + goto bail; + } + + *outlen = (msglen - (2 + ps_len + 1)); + XMEMCPY(out, &msg[2 + ps_len + 1], *outlen); + + /* valid packet */ + *is_valid = 1; + result = CRYPT_OK; +bail: + return result; +} /* pkcs_1_v1_5_decode */ + +#endif /* #ifdef LTC_PKCS_1 */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c new file mode 100644 index 000000000..4342919ed --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c @@ -0,0 +1,111 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/*! \file pkcs_1_v1_5_encode.c + * + * LTC_PKCS #1 v1.5 Padding (Andreas Lange) + */ + +#ifdef LTC_PKCS_1 + +/*! \brief LTC_PKCS #1 v1.5 encode. + * + * \param msg The data to encode + * \param msglen The length of the data to encode (octets) + * \param block_type Block type to use in padding (\sa ltc_pkcs_1_v1_5_blocks) + * \param modulus_bitlen The bit length of the RSA modulus + * \param prng An active PRNG state (only for LTC_LTC_PKCS_1_EME) + * \param prng_idx The index of the PRNG desired (only for LTC_LTC_PKCS_1_EME) + * \param out [out] The destination for the encoded data + * \param outlen [in/out] The max size and resulting size of the encoded data + * + * \return CRYPT_OK if successful + */ +int pkcs_1_v1_5_encode(const unsigned char *msg, + unsigned long msglen, + int block_type, + unsigned long modulus_bitlen, + prng_state *prng, + int prng_idx, + unsigned char *out, + unsigned long *outlen) +{ + unsigned long modulus_len, ps_len, i; + unsigned char *ps; + int result; + + /* valid block_type? */ + if ((block_type != LTC_LTC_PKCS_1_EMSA) && + (block_type != LTC_LTC_PKCS_1_EME)) { + return CRYPT_PK_INVALID_PADDING; + } + + if (block_type == LTC_LTC_PKCS_1_EME) { /* encryption padding, we need a valid PRNG */ + if ((result = prng_is_valid(prng_idx)) != CRYPT_OK) { + return result; + } + } + + modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0); + + /* test message size */ + if ((msglen + 11) > modulus_len) { + return CRYPT_PK_INVALID_SIZE; + } + + if (*outlen < modulus_len) { + *outlen = modulus_len; + result = CRYPT_BUFFER_OVERFLOW; + goto bail; + } + + /* generate an octets string PS */ + ps = &out[2]; + ps_len = modulus_len - msglen - 3; + + if (block_type == LTC_LTC_PKCS_1_EME) { + /* now choose a random ps */ + if (prng_descriptor[prng_idx].read(ps, ps_len, prng) != ps_len) { + result = CRYPT_ERROR_READPRNG; + goto bail; + } + + /* transform zero bytes (if any) to non-zero random bytes */ + for (i = 0; i < ps_len; i++) { + while (ps[i] == 0) { + if (prng_descriptor[prng_idx].read(&ps[i], 1, prng) != 1) { + result = CRYPT_ERROR_READPRNG; + goto bail; + } + } + } + } else { + XMEMSET(ps, 0xFF, ps_len); + } + + /* create string of length modulus_len */ + out[0] = 0x00; + out[1] = (unsigned char)block_type; /* block_type 1 or 2 */ + out[2 + ps_len] = 0x00; + XMEMCPY(&out[2 + ps_len + 1], msg, msglen); + *outlen = modulus_len; + + result = CRYPT_OK; +bail: + return result; +} /* pkcs_1_v1_5_encode */ + +#endif /* #ifdef LTC_PKCS_1 */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_exptmod.c b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_exptmod.c new file mode 100644 index 000000000..ba44106f2 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_exptmod.c @@ -0,0 +1,113 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_exptmod.c + RSA LTC_PKCS exptmod, Tom St Denis +*/ + +#ifdef LTC_MRSA + +/** + Compute an RSA modular exponentiation + @param in The input data to send into RSA + @param inlen The length of the input (octets) + @param out [out] The destination + @param outlen [in/out] The max size and resulting size of the output + @param which Which exponent to use, e.g. PK_PRIVATE or PK_PUBLIC + @param key The RSA key to use + @return CRYPT_OK if successful +*/ +int rsa_exptmod(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, int which, + rsa_key *key) +{ + void *tmp, *tmpa, *tmpb; + unsigned long x; + int err; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(key != NULL); + + /* is the key of the right type for the operation? */ + if (which == PK_PRIVATE && (key->type != PK_PRIVATE)) { + return CRYPT_PK_NOT_PRIVATE; + } + + /* must be a private or public operation */ + if (which != PK_PRIVATE && which != PK_PUBLIC) { + return CRYPT_PK_INVALID_TYPE; + } + + /* init and copy into tmp */ + if ((err = mp_init_multi(&tmp, &tmpa, &tmpb, NULL)) != CRYPT_OK) { return err; } + if ((err = mp_read_unsigned_bin(tmp, (unsigned char *)in, (int)inlen)) != CRYPT_OK) { goto error; } + + /* sanity check on the input */ + if (mp_cmp(key->N, tmp) == LTC_MP_LT) { + err = CRYPT_PK_INVALID_SIZE; + goto error; + } + + /* are we using the private exponent and is the key optimized? */ + if (which == PK_PRIVATE) { + /* tmpa = tmp^dP mod p */ + if ((err = mp_exptmod(tmp, key->dP, key->p, tmpa)) != CRYPT_OK) { goto error; } + + /* tmpb = tmp^dQ mod q */ + if ((err = mp_exptmod(tmp, key->dQ, key->q, tmpb)) != CRYPT_OK) { goto error; } + + /* tmp = (tmpa - tmpb) * qInv (mod p) */ + if ((err = mp_sub(tmpa, tmpb, tmp)) != CRYPT_OK) { goto error; } + if ((err = mp_mulmod(tmp, key->qP, key->p, tmp)) != CRYPT_OK) { goto error; } + + /* tmp = tmpb + q * tmp */ + if ((err = mp_mul(tmp, key->q, tmp)) != CRYPT_OK) { goto error; } + if ((err = mp_add(tmp, tmpb, tmp)) != CRYPT_OK) { goto error; } + } else { + /* exptmod it */ + if ((err = mp_exptmod(tmp, key->e, key->N, tmp)) != CRYPT_OK) { goto error; } + } + + /* read it back */ + x = (unsigned long)mp_unsigned_bin_size(key->N); + if (x > *outlen) { + *outlen = x; + err = CRYPT_BUFFER_OVERFLOW; + goto error; + } + + /* this should never happen ... */ + if (mp_unsigned_bin_size(tmp) > mp_unsigned_bin_size(key->N)) { + err = CRYPT_ERROR; + goto error; + } + *outlen = x; + + /* convert it */ + zeromem(out, x); + if ((err = mp_to_unsigned_bin(tmp, out+(x-mp_unsigned_bin_size(tmp)))) != CRYPT_OK) { goto error; } + + /* clean up and return */ + err = CRYPT_OK; +error: + mp_clear_multi(tmp, tmpa, tmpb, NULL); + return err; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_exptmod.c,v $ */ +/* $Revision: 1.18 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_free.c b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_free.c new file mode 100644 index 000000000..a10ed5928 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_free.c @@ -0,0 +1,34 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_free.c + Free an RSA key, Tom St Denis +*/ + +#ifdef LTC_MRSA + +/** + Free an RSA key from memory + @param key The RSA key to free +*/ +void rsa_free(rsa_key *key) +{ + LTC_ARGCHKVD(key != NULL); + mp_clear_multi(key->e, key->d, key->N, key->dQ, key->dP, key->qP, key->p, key->q, NULL); +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_free.c,v $ */ +/* $Revision: 1.10 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_import.c b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_import.c new file mode 100644 index 000000000..6254fd7ff --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_import.c @@ -0,0 +1,143 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_import.c + Import a LTC_PKCS RSA key, Tom St Denis +*/ + +#ifdef LTC_MRSA + +/** + Import an RSAPublicKey or RSAPrivateKey [two-prime only, only support >= 1024-bit keys, defined in LTC_PKCS #1 v2.1] + @param in The packet to import from + @param inlen It's length (octets) + @param key [out] Destination for newly imported key + @return CRYPT_OK if successful, upon error allocated memory is freed +*/ +int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key) +{ + int err; + void *zero; + unsigned char *tmpbuf; + unsigned long t, x, y, z, tmpoid[16]; + ltc_asn1_list ssl_pubkey_hashoid[2]; + ltc_asn1_list ssl_pubkey[2]; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(key != NULL); + LTC_ARGCHK(ltc_mp.name != NULL); + + /* init key */ + if ((err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, + &key->dP, &key->qP, &key->p, &key->q, NULL)) != CRYPT_OK) { + return err; + } + + /* see if the OpenSSL DER format RSA public key will work */ + tmpbuf = XCALLOC(1, MAX_RSA_SIZE*8); + if (tmpbuf == NULL) { + err = CRYPT_MEM; + goto LBL_ERR; + } + + /* this includes the internal hash ID and optional params (NULL in this case) */ + LTC_SET_ASN1(ssl_pubkey_hashoid, 0, LTC_ASN1_OBJECT_IDENTIFIER, tmpoid, sizeof(tmpoid)/sizeof(tmpoid[0])); + LTC_SET_ASN1(ssl_pubkey_hashoid, 1, LTC_ASN1_NULL, NULL, 0); + + /* the actual format of the SSL DER key is odd, it stores a RSAPublicKey in a **BIT** string ... so we have to extract it + then proceed to convert bit to octet + */ + LTC_SET_ASN1(ssl_pubkey, 0, LTC_ASN1_SEQUENCE, &ssl_pubkey_hashoid, 2); + LTC_SET_ASN1(ssl_pubkey, 1, LTC_ASN1_BIT_STRING, tmpbuf, MAX_RSA_SIZE*8); + + if (der_decode_sequence(in, inlen, + ssl_pubkey, 2UL) == CRYPT_OK) { + + /* ok now we have to reassemble the BIT STRING to an OCTET STRING. Thanks OpenSSL... */ + for (t = y = z = x = 0; x < ssl_pubkey[1].size; x++) { + y = (y << 1) | tmpbuf[x]; + if (++z == 8) { + tmpbuf[t++] = (unsigned char)y; + y = 0; + z = 0; + } + } + + /* now it should be SEQUENCE { INTEGER, INTEGER } */ + if ((err = der_decode_sequence_multi(tmpbuf, t, + LTC_ASN1_INTEGER, 1UL, key->N, + LTC_ASN1_INTEGER, 1UL, key->e, + LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { + XFREE(tmpbuf); + goto LBL_ERR; + } + XFREE(tmpbuf); + key->type = PK_PUBLIC; + return CRYPT_OK; + } + XFREE(tmpbuf); + + /* not SSL public key, try to match against LTC_PKCS #1 standards */ + if ((err = der_decode_sequence_multi(in, inlen, + LTC_ASN1_INTEGER, 1UL, key->N, + LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { + goto LBL_ERR; + } + + if (mp_cmp_d(key->N, 0) == LTC_MP_EQ) { + if ((err = mp_init(&zero)) != CRYPT_OK) { + goto LBL_ERR; + } + /* it's a private key */ + if ((err = der_decode_sequence_multi(in, inlen, + LTC_ASN1_INTEGER, 1UL, zero, + LTC_ASN1_INTEGER, 1UL, key->N, + LTC_ASN1_INTEGER, 1UL, key->e, + LTC_ASN1_INTEGER, 1UL, key->d, + LTC_ASN1_INTEGER, 1UL, key->p, + LTC_ASN1_INTEGER, 1UL, key->q, + LTC_ASN1_INTEGER, 1UL, key->dP, + LTC_ASN1_INTEGER, 1UL, key->dQ, + LTC_ASN1_INTEGER, 1UL, key->qP, + LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { + mp_clear(zero); + goto LBL_ERR; + } + mp_clear(zero); + key->type = PK_PRIVATE; + } else if (mp_cmp_d(key->N, 1) == LTC_MP_EQ) { + /* we don't support multi-prime RSA */ + err = CRYPT_PK_INVALID_TYPE; + goto LBL_ERR; + } else { + /* it's a public key and we lack e */ + if ((err = der_decode_sequence_multi(in, inlen, + LTC_ASN1_INTEGER, 1UL, key->N, + LTC_ASN1_INTEGER, 1UL, key->e, + LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { + goto LBL_ERR; + } + key->type = PK_PUBLIC; + } + return CRYPT_OK; +LBL_ERR: + mp_clear_multi(key->d, key->e, key->N, key->dQ, key->dP, key->qP, key->p, key->q, NULL); + return err; +} + +#endif /* LTC_MRSA */ + + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_import.c,v $ */ +/* $Revision: 1.23 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_make_key.c b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_make_key.c new file mode 100644 index 000000000..bd37b4ae1 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_make_key.c @@ -0,0 +1,112 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_make_key.c + RSA key generation, Tom St Denis +*/ + +#ifdef LTC_MRSA + +/** + Create an RSA key + @param prng An active PRNG state + @param wprng The index of the PRNG desired + @param size The size of the modulus (key size) desired (octets) + @param e The "e" value (public key). e==65537 is a good choice + @param key [out] Destination of a newly created private key pair + @return CRYPT_OK if successful, upon error all allocated ram is freed +*/ +int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key) +{ + void *p, *q, *tmp1, *tmp2, *tmp3; + int err; + + LTC_ARGCHK(ltc_mp.name != NULL); + LTC_ARGCHK(key != NULL); + + if ((size < (MIN_RSA_SIZE/8)) || (size > (MAX_RSA_SIZE/8))) { + return CRYPT_INVALID_KEYSIZE; + } + + if ((e < 3) || ((e & 1) == 0)) { + return CRYPT_INVALID_ARG; + } + + if ((err = prng_is_valid(wprng)) != CRYPT_OK) { + return err; + } + + if ((err = mp_init_multi(&p, &q, &tmp1, &tmp2, &tmp3, NULL)) != CRYPT_OK) { + return err; + } + + /* make primes p and q (optimization provided by Wayne Scott) */ + if ((err = mp_set_int(tmp3, e)) != CRYPT_OK) { goto errkey; } /* tmp3 = e */ + + /* make prime "p" */ + do { + if ((err = rand_prime( p, size/2, prng, wprng)) != CRYPT_OK) { goto errkey; } + if ((err = mp_sub_d( p, 1, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = p-1 */ + if ((err = mp_gcd( tmp1, tmp3, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = gcd(p-1, e) */ + } while (mp_cmp_d( tmp2, 1) != 0); /* while e divides p-1 */ + + /* make prime "q" */ + do { + if ((err = rand_prime( q, size/2, prng, wprng)) != CRYPT_OK) { goto errkey; } + if ((err = mp_sub_d( q, 1, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = q-1 */ + if ((err = mp_gcd( tmp1, tmp3, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = gcd(q-1, e) */ + } while (mp_cmp_d( tmp2, 1) != 0); /* while e divides q-1 */ + + /* tmp1 = lcm(p-1, q-1) */ + if ((err = mp_sub_d( p, 1, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = p-1 */ + /* tmp1 = q-1 (previous do/while loop) */ + if ((err = mp_lcm( tmp1, tmp2, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = lcm(p-1, q-1) */ + + /* make key */ + if ((err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, NULL)) != CRYPT_OK) { + goto errkey; + } + + if ((err = mp_set_int( key->e, e)) != CRYPT_OK) { goto errkey; } /* key->e = e */ + if ((err = mp_invmod( key->e, tmp1, key->d)) != CRYPT_OK) { goto errkey; } /* key->d = 1/e mod lcm(p-1,q-1) */ + if ((err = mp_mul( p, q, key->N)) != CRYPT_OK) { goto errkey; } /* key->N = pq */ + + /* optimize for CRT now */ + /* find d mod q-1 and d mod p-1 */ + if ((err = mp_sub_d( p, 1, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = q-1 */ + if ((err = mp_sub_d( q, 1, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = p-1 */ + if ((err = mp_mod( key->d, tmp1, key->dP)) != CRYPT_OK) { goto errkey; } /* dP = d mod p-1 */ + if ((err = mp_mod( key->d, tmp2, key->dQ)) != CRYPT_OK) { goto errkey; } /* dQ = d mod q-1 */ + if ((err = mp_invmod( q, p, key->qP)) != CRYPT_OK) { goto errkey; } /* qP = 1/q mod p */ + + if ((err = mp_copy( p, key->p)) != CRYPT_OK) { goto errkey; } + if ((err = mp_copy( q, key->q)) != CRYPT_OK) { goto errkey; } + + /* set key type (in this case it's CRT optimized) */ + key->type = PK_PRIVATE; + + /* return ok and free temps */ + err = CRYPT_OK; + goto cleanup; +errkey: + mp_clear_multi(key->d, key->e, key->N, key->dQ, key->dP, key->qP, key->p, key->q, NULL); +cleanup: + mp_clear_multi(tmp3, tmp2, tmp1, p, q, NULL); + return err; +} + +#endif + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_make_key.c,v $ */ +/* $Revision: 1.16 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_sign_hash.c b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_sign_hash.c new file mode 100644 index 000000000..49fb85875 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_sign_hash.c @@ -0,0 +1,134 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_sign_hash.c + RSA LTC_PKCS #1 v1.5 and v2 PSS sign hash, Tom St Denis and Andreas Lange +*/ + +#ifdef LTC_MRSA + +/** + LTC_PKCS #1 pad then sign + @param in The hash to sign + @param inlen The length of the hash to sign (octets) + @param out [out] The signature + @param outlen [in/out] The max size and resulting size of the signature + @param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5) + @param prng An active PRNG state + @param prng_idx The index of the PRNG desired + @param hash_idx The index of the hash desired + @param saltlen The length of the salt desired (octets) + @param key The private RSA key to use + @return CRYPT_OK if successful +*/ +int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen, + unsigned char *out, unsigned long *outlen, + int padding, + prng_state *prng, int prng_idx, + int hash_idx, unsigned long saltlen, + rsa_key *key) +{ + unsigned long modulus_bitlen, modulus_bytelen, x, y; + int err; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(key != NULL); + + /* valid padding? */ + if ((padding != LTC_LTC_PKCS_1_V1_5) && (padding != LTC_LTC_PKCS_1_PSS)) { + return CRYPT_PK_INVALID_PADDING; + } + + if (padding == LTC_LTC_PKCS_1_PSS) { + /* valid prng and hash ? */ + if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) { + return err; + } + if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { + return err; + } + } + + /* get modulus len in bits */ + modulus_bitlen = mp_count_bits((key->N)); + + /* outlen must be at least the size of the modulus */ + modulus_bytelen = mp_unsigned_bin_size((key->N)); + if (modulus_bytelen > *outlen) { + *outlen = modulus_bytelen; + return CRYPT_BUFFER_OVERFLOW; + } + + if (padding == LTC_LTC_PKCS_1_PSS) { + /* PSS pad the key */ + x = *outlen; + if ((err = pkcs_1_pss_encode(in, inlen, saltlen, prng, prng_idx, + hash_idx, modulus_bitlen, out, &x)) != CRYPT_OK) { + return err; + } + } else { + /* LTC_PKCS #1 v1.5 pad the hash */ + unsigned char *tmpin; + ltc_asn1_list digestinfo[2], siginfo[2]; + + /* not all hashes have OIDs... so sad */ + if (hash_descriptor[hash_idx].OIDlen == 0) { + return CRYPT_INVALID_ARG; + } + + /* construct the SEQUENCE + SEQUENCE { + SEQUENCE {hashoid OID + blah NULL + } + hash OCTET STRING + } + */ + LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, hash_descriptor[hash_idx].OID, hash_descriptor[hash_idx].OIDlen); + LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0); + LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2); + LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, in, inlen); + + /* allocate memory for the encoding */ + y = mp_unsigned_bin_size(key->N); + tmpin = XMALLOC(y); + if (tmpin == NULL) { + return CRYPT_MEM; + } + + if ((err = der_encode_sequence(siginfo, 2, tmpin, &y)) != CRYPT_OK) { + XFREE(tmpin); + return err; + } + + x = *outlen; + if ((err = pkcs_1_v1_5_encode(tmpin, y, LTC_LTC_PKCS_1_EMSA, + modulus_bitlen, NULL, 0, + out, &x)) != CRYPT_OK) { + XFREE(tmpin); + return err; + } + XFREE(tmpin); + } + + /* RSA encode it */ + return ltc_mp.rsa_me(out, x, out, outlen, PK_PRIVATE, key); +} + +#endif /* LTC_MRSA */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_sign_hash.c,v $ */ +/* $Revision: 1.11 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c new file mode 100644 index 000000000..103ae2f53 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c @@ -0,0 +1,167 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_verify_hash.c + RSA LTC_PKCS #1 v1.5 or v2 PSS signature verification, Tom St Denis and Andreas Lange +*/ + +#ifdef LTC_MRSA + +/** + LTC_PKCS #1 de-sign then v1.5 or PSS depad + @param sig The signature data + @param siglen The length of the signature data (octets) + @param hash The hash of the message that was signed + @param hashlen The length of the hash of the message that was signed (octets) + @param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5) + @param hash_idx The index of the desired hash + @param saltlen The length of the salt used during signature + @param stat [out] The result of the signature comparison, 1==valid, 0==invalid + @param key The public RSA key corresponding to the key that performed the signature + @return CRYPT_OK on success (even if the signature is invalid) +*/ +int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen, + const unsigned char *hash, unsigned long hashlen, + int padding, + int hash_idx, unsigned long saltlen, + int *stat, rsa_key *key) +{ + unsigned long modulus_bitlen, modulus_bytelen, x; + int err; + unsigned char *tmpbuf; + + LTC_ARGCHK(hash != NULL); + LTC_ARGCHK(sig != NULL); + LTC_ARGCHK(stat != NULL); + LTC_ARGCHK(key != NULL); + + /* default to invalid */ + *stat = 0; + + /* valid padding? */ + + if ((padding != LTC_LTC_PKCS_1_V1_5) && + (padding != LTC_LTC_PKCS_1_PSS)) { + return CRYPT_PK_INVALID_PADDING; + } + + if (padding == LTC_LTC_PKCS_1_PSS) { + /* valid hash ? */ + if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { + return err; + } + } + + /* get modulus len in bits */ + modulus_bitlen = mp_count_bits( (key->N)); + + /* outlen must be at least the size of the modulus */ + modulus_bytelen = mp_unsigned_bin_size( (key->N)); + if (modulus_bytelen != siglen) { + return CRYPT_INVALID_PACKET; + } + + /* allocate temp buffer for decoded sig */ + tmpbuf = XMALLOC(siglen); + if (tmpbuf == NULL) { + return CRYPT_MEM; + } + + /* RSA decode it */ + x = siglen; + if ((err = ltc_mp.rsa_me(sig, siglen, tmpbuf, &x, PK_PUBLIC, key)) != CRYPT_OK) { + XFREE(tmpbuf); + return err; + } + + /* make sure the output is the right size */ + if (x != siglen) { + XFREE(tmpbuf); + return CRYPT_INVALID_PACKET; + } + + if (padding == LTC_LTC_PKCS_1_PSS) { + /* PSS decode and verify it */ + err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_idx, modulus_bitlen, stat); + } else { + /* LTC_PKCS #1 v1.5 decode it */ + unsigned char *out; + unsigned long outlen, loid[16]; + int decoded; + ltc_asn1_list digestinfo[2], siginfo[2]; + + /* not all hashes have OIDs... so sad */ + if (hash_descriptor[hash_idx].OIDlen == 0) { + err = CRYPT_INVALID_ARG; + goto bail_2; + } + + /* allocate temp buffer for decoded hash */ + outlen = ((modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0)) - 3; + out = XMALLOC(outlen); + if (out == NULL) { + err = CRYPT_MEM; + goto bail_2; + } + + if ((err = pkcs_1_v1_5_decode(tmpbuf, x, LTC_LTC_PKCS_1_EMSA, modulus_bitlen, out, &outlen, &decoded)) != CRYPT_OK) { + XFREE(out); + goto bail_2; + } + + /* now we must decode out[0...outlen-1] using ASN.1, test the OID and then test the hash */ + /* construct the SEQUENCE + SEQUENCE { + SEQUENCE {hashoid OID + blah NULL + } + hash OCTET STRING + } + */ + LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, loid, sizeof(loid)/sizeof(loid[0])); + LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0); + LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2); + LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, tmpbuf, siglen); + + if ((err = der_decode_sequence(out, outlen, siginfo, 2)) != CRYPT_OK) { + XFREE(out); + goto bail_2; + } + + /* test OID */ + if ((digestinfo[0].size == hash_descriptor[hash_idx].OIDlen) && + (XMEMCMP(digestinfo[0].data, hash_descriptor[hash_idx].OID, sizeof(unsigned long) * hash_descriptor[hash_idx].OIDlen) == 0) && + (siginfo[1].size == hashlen) && + (XMEMCMP(siginfo[1].data, hash, hashlen) == 0)) { + *stat = 1; + } + +#ifdef LTC_CLEAN_STACK + zeromem(out, outlen); +#endif + XFREE(out); + } + +bail_2: +#ifdef LTC_CLEAN_STACK + zeromem(tmpbuf, siglen); +#endif + XFREE(tmpbuf); + return err; +} + +#endif /* LTC_MRSA */ + +/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_verify_hash.c,v $ */ +/* $Revision: 1.13 $ */ +/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c new file mode 100644 index 000000000..6d8888c85 --- /dev/null +++ b/dep/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c @@ -0,0 +1,87 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_verify_simple.c + Created by Ladislav Zezula (zezula@volny.cz) as modification + for Blizzard strong signature verification +*/ + +#ifdef LTC_MRSA + +/** + Simple RSA decryption + @param sig The signature data + @param siglen The length of the signature data (octets) + @param hash The hash of the message that was signed + @param hashlen The length of the hash of the message that was signed (octets) + @param stat [out] The result of the signature comparison, 1==valid, 0==invalid + @param key The public RSA key corresponding + @return Error code +*/ +int rsa_verify_simple(const unsigned char *sig, unsigned long siglen, + const unsigned char *hash, unsigned long hashlen, + int *stat, + rsa_key *key) +{ + unsigned long modulus_bitlen, modulus_bytelen, x; + unsigned char *tmpbuf; + int err; + + LTC_ARGCHK(sig != NULL); + LTC_ARGCHK(hash != NULL); + LTC_ARGCHK(stat != NULL); + LTC_ARGCHK(key != NULL); + + /* default to invalid */ + *stat = 0; + + /* get modulus len in bits */ + modulus_bitlen = mp_count_bits( (key->N)); + + /* outlen must be at least the size of the modulus */ + modulus_bytelen = mp_unsigned_bin_size( (key->N)); + if (modulus_bytelen != siglen) { + return CRYPT_INVALID_PACKET; + } + + /* allocate temp buffer for decoded sig */ + tmpbuf = XMALLOC(siglen); + if (tmpbuf == NULL) { + return CRYPT_MEM; + } + + /* RSA decode it */ + x = siglen; + if ((err = ltc_mp.rsa_me(sig, siglen, tmpbuf, &x, PK_PUBLIC, key)) != CRYPT_OK) { + XFREE(tmpbuf); + return err; + } + + /* make sure the output is the right size */ + if (x != siglen) { + XFREE(tmpbuf); + return CRYPT_INVALID_PACKET; + } + + /* compare the decrypted signature with the given hash */ + if(x == hashlen && XMEMCMP(tmpbuf, hash, hashlen) == 0) + *stat = 1; + +#ifdef LTC_CLEAN_STACK + zeromem(tmpbuf, siglen); +#endif + XFREE(tmpbuf); + return CRYPT_OK; +} + +#endif /* LTC_MRSA */ diff --git a/dep/StormLib/src/libtommath/bn_fast_mp_invmod.c b/dep/StormLib/src/libtommath/bn_fast_mp_invmod.c new file mode 100644 index 000000000..597d7a9b5 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_fast_mp_invmod.c @@ -0,0 +1,148 @@ +#include "tommath.h" +#ifdef BN_FAST_MP_INVMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* computes the modular inverse via binary extended euclidean algorithm, + * that is c = 1/a mod b + * + * Based on slow invmod except this is optimized for the case where b is + * odd as per HAC Note 14.64 on pp. 610 + */ +int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c) +{ + mp_int x, y, u, v, B, D; + int res, neg; + + /* 2. [modified] b must be odd */ + if (mp_iseven (b) == 1) { + return MP_VAL; + } + + /* init all our temps */ + if ((res = mp_init_multi(&x, &y, &u, &v, &B, &D, NULL)) != MP_OKAY) { + return res; + } + + /* x == modulus, y == value to invert */ + if ((res = mp_copy (b, &x)) != MP_OKAY) { + goto LBL_ERR; + } + + /* we need y = |a| */ + if ((res = mp_mod (a, b, &y)) != MP_OKAY) { + goto LBL_ERR; + } + + /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */ + if ((res = mp_copy (&x, &u)) != MP_OKAY) { + goto LBL_ERR; + } + if ((res = mp_copy (&y, &v)) != MP_OKAY) { + goto LBL_ERR; + } + mp_set (&D, 1); + +top: + /* 4. while u is even do */ + while (mp_iseven (&u) == 1) { + /* 4.1 u = u/2 */ + if ((res = mp_div_2 (&u, &u)) != MP_OKAY) { + goto LBL_ERR; + } + /* 4.2 if B is odd then */ + if (mp_isodd (&B) == 1) { + if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) { + goto LBL_ERR; + } + } + /* B = B/2 */ + if ((res = mp_div_2 (&B, &B)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* 5. while v is even do */ + while (mp_iseven (&v) == 1) { + /* 5.1 v = v/2 */ + if ((res = mp_div_2 (&v, &v)) != MP_OKAY) { + goto LBL_ERR; + } + /* 5.2 if D is odd then */ + if (mp_isodd (&D) == 1) { + /* D = (D-x)/2 */ + if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) { + goto LBL_ERR; + } + } + /* D = D/2 */ + if ((res = mp_div_2 (&D, &D)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* 6. if u >= v then */ + if (mp_cmp (&u, &v) != MP_LT) { + /* u = u - v, B = B - D */ + if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) { + goto LBL_ERR; + } + + if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) { + goto LBL_ERR; + } + } else { + /* v - v - u, D = D - B */ + if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) { + goto LBL_ERR; + } + + if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* if not zero goto step 4 */ + if (mp_iszero (&u) == 0) { + goto top; + } + + /* now a = C, b = D, gcd == g*v */ + + /* if v != 1 then there is no inverse */ + if (mp_cmp_d (&v, 1) != MP_EQ) { + res = MP_VAL; + goto LBL_ERR; + } + + /* b is now the inverse */ + neg = a->sign; + while (D.sign == MP_NEG) { + if ((res = mp_add (&D, b, &D)) != MP_OKAY) { + goto LBL_ERR; + } + } + mp_exch (&D, c); + c->sign = neg; + res = MP_OKAY; + +LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_mp_invmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_fast_mp_montgomery_reduce.c b/dep/StormLib/src/libtommath/bn_fast_mp_montgomery_reduce.c new file mode 100644 index 000000000..65eed7da1 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_fast_mp_montgomery_reduce.c @@ -0,0 +1,172 @@ +#include "tommath.h" +#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* computes xR**-1 == x (mod N) via Montgomery Reduction + * + * This is an optimized implementation of montgomery_reduce + * which uses the comba method to quickly calculate the columns of the + * reduction. + * + * Based on Algorithm 14.32 on pp.601 of HAC. +*/ +int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) +{ + int ix, res, olduse; + mp_word W[MP_WARRAY]; + + /* get old used count */ + olduse = x->used; + + /* grow a as required */ + if (x->alloc < n->used + 1) { + if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) { + return res; + } + } + + /* first we have to get the digits of the input into + * an array of double precision words W[...] + */ + { + register mp_word *_W; + register mp_digit *tmpx; + + /* alias for the W[] array */ + _W = W; + + /* alias for the digits of x*/ + tmpx = x->dp; + + /* copy the digits of a into W[0..a->used-1] */ + for (ix = 0; ix < x->used; ix++) { + *_W++ = *tmpx++; + } + + /* zero the high words of W[a->used..m->used*2] */ + for (; ix < n->used * 2 + 1; ix++) { + *_W++ = 0; + } + } + + /* now we proceed to zero successive digits + * from the least significant upwards + */ + for (ix = 0; ix < n->used; ix++) { + /* mu = ai * m' mod b + * + * We avoid a double precision multiplication (which isn't required) + * by casting the value down to a mp_digit. Note this requires + * that W[ix-1] have the carry cleared (see after the inner loop) + */ + register mp_digit mu; + mu = (mp_digit) (((W[ix] & MP_MASK) * rho) & MP_MASK); + + /* a = a + mu * m * b**i + * + * This is computed in place and on the fly. The multiplication + * by b**i is handled by offseting which columns the results + * are added to. + * + * Note the comba method normally doesn't handle carries in the + * inner loop In this case we fix the carry from the previous + * column since the Montgomery reduction requires digits of the + * result (so far) [see above] to work. This is + * handled by fixing up one carry after the inner loop. The + * carry fixups are done in order so after these loops the + * first m->used words of W[] have the carries fixed + */ + { + register int iy; + register mp_digit *tmpn; + register mp_word *_W; + + /* alias for the digits of the modulus */ + tmpn = n->dp; + + /* Alias for the columns set by an offset of ix */ + _W = W + ix; + + /* inner loop */ + for (iy = 0; iy < n->used; iy++) { + *_W++ += ((mp_word)mu) * ((mp_word)*tmpn++); + } + } + + /* now fix carry for next digit, W[ix+1] */ + W[ix + 1] += W[ix] >> ((mp_word) DIGIT_BIT); + } + + /* now we have to propagate the carries and + * shift the words downward [all those least + * significant digits we zeroed]. + */ + { + register mp_digit *tmpx; + register mp_word *_W, *_W1; + + /* nox fix rest of carries */ + + /* alias for current word */ + _W1 = W + ix; + + /* alias for next word, where the carry goes */ + _W = W + ++ix; + + for (; ix <= n->used * 2 + 1; ix++) { + *_W++ += *_W1++ >> ((mp_word) DIGIT_BIT); + } + + /* copy out, A = A/b**n + * + * The result is A/b**n but instead of converting from an + * array of mp_word to mp_digit than calling mp_rshd + * we just copy them in the right order + */ + + /* alias for destination word */ + tmpx = x->dp; + + /* alias for shifted double precision result */ + _W = W + n->used; + + for (ix = 0; ix < n->used + 1; ix++) { + *tmpx++ = (mp_digit)(*_W++ & ((mp_word) MP_MASK)); + } + + /* zero oldused digits, if the input a was larger than + * m->used+1 we'll have to clear the digits + */ + for (; ix < olduse; ix++) { + *tmpx++ = 0; + } + } + + /* set the max used and clamp */ + x->used = n->used + 1; + mp_clamp (x); + + /* if A >= m then A = A - m */ + if (mp_cmp_mag (x, n) != MP_LT) { + return s_mp_sub (x, n, x); + } + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_mp_montgomery_reduce.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_fast_s_mp_mul_digs.c b/dep/StormLib/src/libtommath/bn_fast_s_mp_mul_digs.c new file mode 100644 index 000000000..df83f89ec --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_fast_s_mp_mul_digs.c @@ -0,0 +1,107 @@ +#include "tommath.h" +#ifdef BN_FAST_S_MP_MUL_DIGS_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Fast (comba) multiplier + * + * This is the fast column-array [comba] multiplier. It is + * designed to compute the columns of the product first + * then handle the carries afterwards. This has the effect + * of making the nested loops that compute the columns very + * simple and schedulable on super-scalar processors. + * + * This has been modified to produce a variable number of + * digits of output so if say only a half-product is required + * you don't have to compute the upper half (a feature + * required for fast Barrett reduction). + * + * Based on Algorithm 14.12 on pp.595 of HAC. + * + */ +int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) +{ + int olduse, res, pa, ix, iz; + mp_digit W[MP_WARRAY]; + register mp_word _W; + + /* grow the destination as required */ + if (c->alloc < digs) { + if ((res = mp_grow (c, digs)) != MP_OKAY) { + return res; + } + } + + /* number of output digits to produce */ + pa = MIN(digs, a->used + b->used); + + /* clear the carry */ + _W = 0; + for (ix = 0; ix < pa; ix++) { + int tx, ty; + int iy; + mp_digit *tmpx, *tmpy; + + /* get offsets into the two bignums */ + ty = MIN(b->used-1, ix); + tx = ix - ty; + + /* setup temp aliases */ + tmpx = a->dp + tx; + tmpy = b->dp + ty; + + /* this is the number of times the loop will iterrate, essentially + while (tx++ < a->used && ty-- >= 0) { ... } + */ + iy = MIN(a->used-tx, ty+1); + + /* execute loop */ + for (iz = 0; iz < iy; ++iz) { + _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); + + } + + /* store term */ + W[ix] = ((mp_digit)_W) & MP_MASK; + + /* make next carry */ + _W = _W >> ((mp_word)DIGIT_BIT); + } + + /* setup dest */ + olduse = c->used; + c->used = pa; + + { + register mp_digit *tmpc; + tmpc = c->dp; + for (ix = 0; ix < pa+1; ix++) { + /* now extract the previous digit [below the carry] */ + *tmpc++ = W[ix]; + } + + /* clear unused digits [that existed in the old copy of c] */ + for (; ix < olduse; ix++) { + *tmpc++ = 0; + } + } + mp_clamp (c); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_digs.c,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_fast_s_mp_mul_high_digs.c b/dep/StormLib/src/libtommath/bn_fast_s_mp_mul_high_digs.c new file mode 100644 index 000000000..6866aab75 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_fast_s_mp_mul_high_digs.c @@ -0,0 +1,98 @@ +#include "tommath.h" +#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* this is a modified version of fast_s_mul_digs that only produces + * output digits *above* digs. See the comments for fast_s_mul_digs + * to see how it works. + * + * This is used in the Barrett reduction since for one of the multiplications + * only the higher digits were needed. This essentially halves the work. + * + * Based on Algorithm 14.12 on pp.595 of HAC. + */ +int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs) +{ + int olduse, res, pa, ix, iz; + mp_digit W[MP_WARRAY]; + mp_word _W; + + /* grow the destination as required */ + pa = a->used + b->used; + if (c->alloc < pa) { + if ((res = mp_grow (c, pa)) != MP_OKAY) { + return res; + } + } + + /* number of output digits to produce */ + pa = a->used + b->used; + _W = 0; + for (ix = digs; ix < pa; ix++) { + int tx, ty, iy; + mp_digit *tmpx, *tmpy; + + /* get offsets into the two bignums */ + ty = MIN(b->used-1, ix); + tx = ix - ty; + + /* setup temp aliases */ + tmpx = a->dp + tx; + tmpy = b->dp + ty; + + /* this is the number of times the loop will iterrate, essentially its + while (tx++ < a->used && ty-- >= 0) { ... } + */ + iy = MIN(a->used-tx, ty+1); + + /* execute loop */ + for (iz = 0; iz < iy; iz++) { + _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); + } + + /* store term */ + W[ix] = ((mp_digit)_W) & MP_MASK; + + /* make next carry */ + _W = _W >> ((mp_word)DIGIT_BIT); + } + + /* setup dest */ + olduse = c->used; + c->used = pa; + + { + register mp_digit *tmpc; + + tmpc = c->dp + digs; + for (ix = digs; ix < pa; ix++) { + /* now extract the previous digit [below the carry] */ + *tmpc++ = W[ix]; + } + + /* clear unused digits [that existed in the old copy of c] */ + for (; ix < olduse; ix++) { + *tmpc++ = 0; + } + } + mp_clamp (c); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_high_digs.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_fast_s_mp_sqr.c b/dep/StormLib/src/libtommath/bn_fast_s_mp_sqr.c new file mode 100644 index 000000000..5f9d58cac --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_fast_s_mp_sqr.c @@ -0,0 +1,114 @@ +#include "tommath.h" +#ifdef BN_FAST_S_MP_SQR_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* the jist of squaring... + * you do like mult except the offset of the tmpx [one that + * starts closer to zero] can't equal the offset of tmpy. + * So basically you set up iy like before then you min it with + * (ty-tx) so that it never happens. You double all those + * you add in the inner loop + +After that loop you do the squares and add them in. +*/ + +int fast_s_mp_sqr (mp_int * a, mp_int * b) +{ + int olduse, res, pa, ix, iz; + mp_digit W[MP_WARRAY], *tmpx; + mp_word W1; + + /* grow the destination as required */ + pa = a->used + a->used; + if (b->alloc < pa) { + if ((res = mp_grow (b, pa)) != MP_OKAY) { + return res; + } + } + + /* number of output digits to produce */ + W1 = 0; + for (ix = 0; ix < pa; ix++) { + int tx, ty, iy; + mp_word _W; + mp_digit *tmpy; + + /* clear counter */ + _W = 0; + + /* get offsets into the two bignums */ + ty = MIN(a->used-1, ix); + tx = ix - ty; + + /* setup temp aliases */ + tmpx = a->dp + tx; + tmpy = a->dp + ty; + + /* this is the number of times the loop will iterrate, essentially + while (tx++ < a->used && ty-- >= 0) { ... } + */ + iy = MIN(a->used-tx, ty+1); + + /* now for squaring tx can never equal ty + * we halve the distance since they approach at a rate of 2x + * and we have to round because odd cases need to be executed + */ + iy = MIN(iy, (ty-tx+1)>>1); + + /* execute loop */ + for (iz = 0; iz < iy; iz++) { + _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); + } + + /* double the inner product and add carry */ + _W = _W + _W + W1; + + /* even columns have the square term in them */ + if ((ix&1) == 0) { + _W += ((mp_word)a->dp[ix>>1])*((mp_word)a->dp[ix>>1]); + } + + /* store it */ + W[ix] = (mp_digit)(_W & MP_MASK); + + /* make next carry */ + W1 = _W >> ((mp_word)DIGIT_BIT); + } + + /* setup dest */ + olduse = b->used; + b->used = a->used+a->used; + + { + mp_digit *tmpb; + tmpb = b->dp; + for (ix = 0; ix < pa; ix++) { + *tmpb++ = W[ix] & MP_MASK; + } + + /* clear unused digits [that existed in the old copy of c] */ + for (; ix < olduse; ix++) { + *tmpb++ = 0; + } + } + mp_clamp (b); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_sqr.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_2expt.c b/dep/StormLib/src/libtommath/bn_mp_2expt.c new file mode 100644 index 000000000..f899eaee4 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_2expt.c @@ -0,0 +1,48 @@ +#include "tommath.h" +#ifdef BN_MP_2EXPT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* computes a = 2**b + * + * Simple algorithm which zeroes the int, grows it then just sets one bit + * as required. + */ +int +mp_2expt (mp_int * a, int b) +{ + int res; + + /* zero a as per default */ + mp_zero (a); + + /* grow a to accomodate the single bit */ + if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) { + return res; + } + + /* set the used count of where the bit will go */ + a->used = b / DIGIT_BIT + 1; + + /* put the single bit in its place */ + a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT); + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_2expt.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_abs.c b/dep/StormLib/src/libtommath/bn_mp_abs.c new file mode 100644 index 000000000..14f3a7e07 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_abs.c @@ -0,0 +1,43 @@ +#include "tommath.h" +#ifdef BN_MP_ABS_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* b = |a| + * + * Simple function copies the input and fixes the sign to positive + */ +int +mp_abs (mp_int * a, mp_int * b) +{ + int res; + + /* copy a to b */ + if (a != b) { + if ((res = mp_copy (a, b)) != MP_OKAY) { + return res; + } + } + + /* force the sign of b to positive */ + b->sign = MP_ZPOS; + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_abs.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_add.c b/dep/StormLib/src/libtommath/bn_mp_add.c new file mode 100644 index 000000000..b368b21c7 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_add.c @@ -0,0 +1,53 @@ +#include "tommath.h" +#ifdef BN_MP_ADD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* high level addition (handles signs) */ +int mp_add (mp_int * a, mp_int * b, mp_int * c) +{ + int sa, sb, res; + + /* get sign of both inputs */ + sa = a->sign; + sb = b->sign; + + /* handle two cases, not four */ + if (sa == sb) { + /* both positive or both negative */ + /* add their magnitudes, copy the sign */ + c->sign = sa; + res = s_mp_add (a, b, c); + } else { + /* one positive, the other negative */ + /* subtract the one with the greater magnitude from */ + /* the one of the lesser magnitude. The result gets */ + /* the sign of the one with the greater magnitude. */ + if (mp_cmp_mag (a, b) == MP_LT) { + c->sign = sb; + res = s_mp_sub (b, a, c); + } else { + c->sign = sa; + res = s_mp_sub (a, b, c); + } + } + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_add.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_add_d.c b/dep/StormLib/src/libtommath/bn_mp_add_d.c new file mode 100644 index 000000000..c147554bd --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_add_d.c @@ -0,0 +1,112 @@ +#include "tommath.h" +#ifdef BN_MP_ADD_D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* single digit addition */ +int +mp_add_d (mp_int * a, mp_digit b, mp_int * c) +{ + int res, ix, oldused; + mp_digit *tmpa, *tmpc, mu; + + /* grow c as required */ + if (c->alloc < a->used + 1) { + if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) { + return res; + } + } + + /* if a is negative and |a| >= b, call c = |a| - b */ + if (a->sign == MP_NEG && (a->used > 1 || a->dp[0] >= b)) { + /* temporarily fix sign of a */ + a->sign = MP_ZPOS; + + /* c = |a| - b */ + res = mp_sub_d(a, b, c); + + /* fix sign */ + a->sign = c->sign = MP_NEG; + + /* clamp */ + mp_clamp(c); + + return res; + } + + /* old number of used digits in c */ + oldused = c->used; + + /* sign always positive */ + c->sign = MP_ZPOS; + + /* source alias */ + tmpa = a->dp; + + /* destination alias */ + tmpc = c->dp; + + /* if a is positive */ + if (a->sign == MP_ZPOS) { + /* add digit, after this we're propagating + * the carry. + */ + *tmpc = *tmpa++ + b; + mu = *tmpc >> DIGIT_BIT; + *tmpc++ &= MP_MASK; + + /* now handle rest of the digits */ + for (ix = 1; ix < a->used; ix++) { + *tmpc = *tmpa++ + mu; + mu = *tmpc >> DIGIT_BIT; + *tmpc++ &= MP_MASK; + } + /* set final carry */ + ix++; + *tmpc++ = mu; + + /* setup size */ + c->used = a->used + 1; + } else { + /* a was negative and |a| < b */ + c->used = 1; + + /* the result is a single digit */ + if (a->used == 1) { + *tmpc++ = b - a->dp[0]; + } else { + *tmpc++ = b; + } + + /* setup count so the clearing of oldused + * can fall through correctly + */ + ix = 1; + } + + /* now zero to oldused */ + while (ix++ < oldused) { + *tmpc++ = 0; + } + mp_clamp(c); + + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_add_d.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_addmod.c b/dep/StormLib/src/libtommath/bn_mp_addmod.c new file mode 100644 index 000000000..0a21f62e9 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_addmod.c @@ -0,0 +1,41 @@ +#include "tommath.h" +#ifdef BN_MP_ADDMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* d = a + b (mod c) */ +int +mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) +{ + int res; + mp_int t; + + if ((res = mp_init (&t)) != MP_OKAY) { + return res; + } + + if ((res = mp_add (a, b, &t)) != MP_OKAY) { + mp_clear (&t); + return res; + } + res = mp_mod (&t, c, d); + mp_clear (&t); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_addmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_and.c b/dep/StormLib/src/libtommath/bn_mp_and.c new file mode 100644 index 000000000..6b7afc104 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_and.c @@ -0,0 +1,57 @@ +#include "tommath.h" +#ifdef BN_MP_AND_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* AND two ints together */ +int +mp_and (mp_int * a, mp_int * b, mp_int * c) +{ + int res, ix, px; + mp_int t, *x; + + if (a->used > b->used) { + if ((res = mp_init_copy (&t, a)) != MP_OKAY) { + return res; + } + px = b->used; + x = b; + } else { + if ((res = mp_init_copy (&t, b)) != MP_OKAY) { + return res; + } + px = a->used; + x = a; + } + + for (ix = 0; ix < px; ix++) { + t.dp[ix] &= x->dp[ix]; + } + + /* zero digits above the last from the smallest mp_int */ + for (; ix < t.used; ix++) { + t.dp[ix] = 0; + } + + mp_clamp (&t); + mp_exch (c, &t); + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_and.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_clamp.c b/dep/StormLib/src/libtommath/bn_mp_clamp.c new file mode 100644 index 000000000..d3cc21c3e --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_clamp.c @@ -0,0 +1,44 @@ +#include "tommath.h" +#ifdef BN_MP_CLAMP_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* trim unused digits + * + * This is used to ensure that leading zero digits are + * trimed and the leading "used" digit will be non-zero + * Typically very fast. Also fixes the sign if there + * are no more leading digits + */ +void +mp_clamp (mp_int * a) +{ + /* decrease used while the most significant digit is + * zero. + */ + while (a->used > 0 && a->dp[a->used - 1] == 0) { + --(a->used); + } + + /* reset the sign flag if used == 0 */ + if (a->used == 0) { + a->sign = MP_ZPOS; + } +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_clamp.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_clear.c b/dep/StormLib/src/libtommath/bn_mp_clear.c new file mode 100644 index 000000000..7644c3825 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_clear.c @@ -0,0 +1,44 @@ +#include "tommath.h" +#ifdef BN_MP_CLEAR_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* clear one (frees) */ +void +mp_clear (mp_int * a) +{ + int i; + + /* only do anything if a hasn't been freed previously */ + if (a->dp != NULL) { + /* first zero the digits */ + for (i = 0; i < a->used; i++) { + a->dp[i] = 0; + } + + /* free ram */ + XFREE(a->dp); + + /* reset members to make debugging easier */ + a->dp = NULL; + a->alloc = a->used = 0; + a->sign = MP_ZPOS; + } +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_clear.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_clear_multi.c b/dep/StormLib/src/libtommath/bn_mp_clear_multi.c new file mode 100644 index 000000000..a10762436 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_clear_multi.c @@ -0,0 +1,34 @@ +#include "tommath.h" +#ifdef BN_MP_CLEAR_MULTI_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include + +void mp_clear_multi(mp_int *mp, ...) +{ + mp_int* next_mp = mp; + va_list args; + va_start(args, mp); + while (next_mp != NULL) { + mp_clear(next_mp); + next_mp = va_arg(args, mp_int*); + } + va_end(args); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_clear_multi.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_cmp.c b/dep/StormLib/src/libtommath/bn_mp_cmp.c new file mode 100644 index 000000000..761d2b0dc --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_cmp.c @@ -0,0 +1,43 @@ +#include "tommath.h" +#ifdef BN_MP_CMP_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* compare two ints (signed)*/ +int +mp_cmp (mp_int * a, mp_int * b) +{ + /* compare based on sign */ + if (a->sign != b->sign) { + if (a->sign == MP_NEG) { + return MP_LT; + } else { + return MP_GT; + } + } + + /* compare digits */ + if (a->sign == MP_NEG) { + /* if negative compare opposite direction */ + return mp_cmp_mag(b, a); + } else { + return mp_cmp_mag(a, b); + } +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_cmp_d.c b/dep/StormLib/src/libtommath/bn_mp_cmp_d.c new file mode 100644 index 000000000..420dfd31a --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_cmp_d.c @@ -0,0 +1,44 @@ +#include "tommath.h" +#ifdef BN_MP_CMP_D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* compare a digit */ +int mp_cmp_d(mp_int * a, mp_digit b) +{ + /* compare based on sign */ + if (a->sign == MP_NEG) { + return MP_LT; + } + + /* compare based on magnitude */ + if (a->used > 1) { + return MP_GT; + } + + /* compare the only digit of a to b */ + if (a->dp[0] > b) { + return MP_GT; + } else if (a->dp[0] < b) { + return MP_LT; + } else { + return MP_EQ; + } +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_cmp_mag.c b/dep/StormLib/src/libtommath/bn_mp_cmp_mag.c new file mode 100644 index 000000000..92565a3b8 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_cmp_mag.c @@ -0,0 +1,55 @@ +#include "tommath.h" +#ifdef BN_MP_CMP_MAG_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* compare maginitude of two ints (unsigned) */ +int mp_cmp_mag (mp_int * a, mp_int * b) +{ + int n; + mp_digit *tmpa, *tmpb; + + /* compare based on # of non-zero digits */ + if (a->used > b->used) { + return MP_GT; + } + + if (a->used < b->used) { + return MP_LT; + } + + /* alias for a */ + tmpa = a->dp + (a->used - 1); + + /* alias for b */ + tmpb = b->dp + (a->used - 1); + + /* compare based on digits */ + for (n = 0; n < a->used; ++n, --tmpa, --tmpb) { + if (*tmpa > *tmpb) { + return MP_GT; + } + + if (*tmpa < *tmpb) { + return MP_LT; + } + } + return MP_EQ; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_mag.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_cnt_lsb.c b/dep/StormLib/src/libtommath/bn_mp_cnt_lsb.c new file mode 100644 index 000000000..60406610e --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_cnt_lsb.c @@ -0,0 +1,53 @@ +#include "tommath.h" +#ifdef BN_MP_CNT_LSB_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +static const int lnz[16] = { + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 +}; + +/* Counts the number of lsbs which are zero before the first zero bit */ +int mp_cnt_lsb(mp_int *a) +{ + int x; + mp_digit q, qq; + + /* easy out */ + if (mp_iszero(a) == 1) { + return 0; + } + + /* scan lower digits until non-zero */ + for (x = 0; x < a->used && a->dp[x] == 0; x++); + q = a->dp[x]; + x *= DIGIT_BIT; + + /* now scan this digit until a 1 is found */ + if ((q & 1) == 0) { + do { + qq = q & 15; + x += lnz[qq]; + q >>= 4; + } while (qq == 0); + } + return x; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cnt_lsb.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_copy.c b/dep/StormLib/src/libtommath/bn_mp_copy.c new file mode 100644 index 000000000..7828592da --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_copy.c @@ -0,0 +1,68 @@ +#include "tommath.h" +#ifdef BN_MP_COPY_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* copy, b = a */ +int +mp_copy (mp_int * a, mp_int * b) +{ + int res, n; + + /* if dst == src do nothing */ + if (a == b) { + return MP_OKAY; + } + + /* grow dest */ + if (b->alloc < a->used) { + if ((res = mp_grow (b, a->used)) != MP_OKAY) { + return res; + } + } + + /* zero b and copy the parameters over */ + { + register mp_digit *tmpa, *tmpb; + + /* pointer aliases */ + + /* source */ + tmpa = a->dp; + + /* destination */ + tmpb = b->dp; + + /* copy all the digits */ + for (n = 0; n < a->used; n++) { + *tmpb++ = *tmpa++; + } + + /* clear high digits */ + for (; n < b->used; n++) { + *tmpb++ = 0; + } + } + + /* copy used count and sign */ + b->used = a->used; + b->sign = a->sign; + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_copy.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_count_bits.c b/dep/StormLib/src/libtommath/bn_mp_count_bits.c new file mode 100644 index 000000000..9d8640fdf --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_count_bits.c @@ -0,0 +1,45 @@ +#include "tommath.h" +#ifdef BN_MP_COUNT_BITS_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* returns the number of bits in an int */ +int +mp_count_bits (mp_int * a) +{ + int r; + mp_digit q; + + /* shortcut */ + if (a->used == 0) { + return 0; + } + + /* get number of digits and add that */ + r = (a->used - 1) * DIGIT_BIT; + + /* take the last digit and count the bits in it */ + q = a->dp[a->used - 1]; + while (q > ((mp_digit) 0)) { + ++r; + q >>= ((mp_digit) 1); + } + return r; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_count_bits.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_div.c b/dep/StormLib/src/libtommath/bn_mp_div.c new file mode 100644 index 000000000..3004a3ea0 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_div.c @@ -0,0 +1,292 @@ +#include "tommath.h" +#ifdef BN_MP_DIV_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +#ifdef BN_MP_DIV_SMALL + +/* slower bit-bang division... also smaller */ +int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d) +{ + mp_int ta, tb, tq, q; + int res, n, n2; + + /* is divisor zero ? */ + if (mp_iszero (b) == 1) { + return MP_VAL; + } + + /* if a < b then q=0, r = a */ + if (mp_cmp_mag (a, b) == MP_LT) { + if (d != NULL) { + res = mp_copy (a, d); + } else { + res = MP_OKAY; + } + if (c != NULL) { + mp_zero (c); + } + return res; + } + + /* init our temps */ + if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL) != MP_OKAY)) { + return res; + } + + + mp_set(&tq, 1); + n = mp_count_bits(a) - mp_count_bits(b); + if (((res = mp_abs(a, &ta)) != MP_OKAY) || + ((res = mp_abs(b, &tb)) != MP_OKAY) || + ((res = mp_mul_2d(&tb, n, &tb)) != MP_OKAY) || + ((res = mp_mul_2d(&tq, n, &tq)) != MP_OKAY)) { + goto LBL_ERR; + } + + while (n-- >= 0) { + if (mp_cmp(&tb, &ta) != MP_GT) { + if (((res = mp_sub(&ta, &tb, &ta)) != MP_OKAY) || + ((res = mp_add(&q, &tq, &q)) != MP_OKAY)) { + goto LBL_ERR; + } + } + if (((res = mp_div_2d(&tb, 1, &tb, NULL)) != MP_OKAY) || + ((res = mp_div_2d(&tq, 1, &tq, NULL)) != MP_OKAY)) { + goto LBL_ERR; + } + } + + /* now q == quotient and ta == remainder */ + n = a->sign; + n2 = (a->sign == b->sign ? MP_ZPOS : MP_NEG); + if (c != NULL) { + mp_exch(c, &q); + c->sign = (mp_iszero(c) == MP_YES) ? MP_ZPOS : n2; + } + if (d != NULL) { + mp_exch(d, &ta); + d->sign = (mp_iszero(d) == MP_YES) ? MP_ZPOS : n; + } +LBL_ERR: + mp_clear_multi(&ta, &tb, &tq, &q, NULL); + return res; +} + +#else + +/* integer signed division. + * c*b + d == a [e.g. a/b, c=quotient, d=remainder] + * HAC pp.598 Algorithm 14.20 + * + * Note that the description in HAC is horribly + * incomplete. For example, it doesn't consider + * the case where digits are removed from 'x' in + * the inner loop. It also doesn't consider the + * case that y has fewer than three digits, etc.. + * + * The overall algorithm is as described as + * 14.20 from HAC but fixed to treat these cases. +*/ +int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d) +{ + mp_int q, x, y, t1, t2; + int res, n, t, i, norm, neg; + + /* is divisor zero ? */ + if (mp_iszero (b) == 1) { + return MP_VAL; + } + + /* if a < b then q=0, r = a */ + if (mp_cmp_mag (a, b) == MP_LT) { + if (d != NULL) { + res = mp_copy (a, d); + } else { + res = MP_OKAY; + } + if (c != NULL) { + mp_zero (c); + } + return res; + } + + if ((res = mp_init_size (&q, a->used + 2)) != MP_OKAY) { + return res; + } + q.used = a->used + 2; + + if ((res = mp_init (&t1)) != MP_OKAY) { + goto LBL_Q; + } + + if ((res = mp_init (&t2)) != MP_OKAY) { + goto LBL_T1; + } + + if ((res = mp_init_copy (&x, a)) != MP_OKAY) { + goto LBL_T2; + } + + if ((res = mp_init_copy (&y, b)) != MP_OKAY) { + goto LBL_X; + } + + /* fix the sign */ + neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG; + x.sign = y.sign = MP_ZPOS; + + /* normalize both x and y, ensure that y >= b/2, [b == 2**DIGIT_BIT] */ + norm = mp_count_bits(&y) % DIGIT_BIT; + if (norm < (int)(DIGIT_BIT-1)) { + norm = (DIGIT_BIT-1) - norm; + if ((res = mp_mul_2d (&x, norm, &x)) != MP_OKAY) { + goto LBL_Y; + } + if ((res = mp_mul_2d (&y, norm, &y)) != MP_OKAY) { + goto LBL_Y; + } + } else { + norm = 0; + } + + /* note hac does 0 based, so if used==5 then its 0,1,2,3,4, e.g. use 4 */ + n = x.used - 1; + t = y.used - 1; + + /* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */ + if ((res = mp_lshd (&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */ + goto LBL_Y; + } + + while (mp_cmp (&x, &y) != MP_LT) { + ++(q.dp[n - t]); + if ((res = mp_sub (&x, &y, &x)) != MP_OKAY) { + goto LBL_Y; + } + } + + /* reset y by shifting it back down */ + mp_rshd (&y, n - t); + + /* step 3. for i from n down to (t + 1) */ + for (i = n; i >= (t + 1); i--) { + if (i > x.used) { + continue; + } + + /* step 3.1 if xi == yt then set q{i-t-1} to b-1, + * otherwise set q{i-t-1} to (xi*b + x{i-1})/yt */ + if (x.dp[i] == y.dp[t]) { + q.dp[i - t - 1] = ((((mp_digit)1) << DIGIT_BIT) - 1); + } else { + mp_word tmp; + tmp = ((mp_word) x.dp[i]) << ((mp_word) DIGIT_BIT); + tmp |= ((mp_word) x.dp[i - 1]); + tmp /= ((mp_word) y.dp[t]); + if (tmp > (mp_word) MP_MASK) + tmp = MP_MASK; + q.dp[i - t - 1] = (mp_digit) (tmp & (mp_word) (MP_MASK)); + } + + /* while (q{i-t-1} * (yt * b + y{t-1})) > + xi * b**2 + xi-1 * b + xi-2 + + do q{i-t-1} -= 1; + */ + q.dp[i - t - 1] = (q.dp[i - t - 1] + 1) & MP_MASK; + do { + q.dp[i - t - 1] = (q.dp[i - t - 1] - 1) & MP_MASK; + + /* find left hand */ + mp_zero (&t1); + t1.dp[0] = (t - 1 < 0) ? 0 : y.dp[t - 1]; + t1.dp[1] = y.dp[t]; + t1.used = 2; + if ((res = mp_mul_d (&t1, q.dp[i - t - 1], &t1)) != MP_OKAY) { + goto LBL_Y; + } + + /* find right hand */ + t2.dp[0] = (i - 2 < 0) ? 0 : x.dp[i - 2]; + t2.dp[1] = (i - 1 < 0) ? 0 : x.dp[i - 1]; + t2.dp[2] = x.dp[i]; + t2.used = 3; + } while (mp_cmp_mag(&t1, &t2) == MP_GT); + + /* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */ + if ((res = mp_mul_d (&y, q.dp[i - t - 1], &t1)) != MP_OKAY) { + goto LBL_Y; + } + + if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) { + goto LBL_Y; + } + + if ((res = mp_sub (&x, &t1, &x)) != MP_OKAY) { + goto LBL_Y; + } + + /* if x < 0 then { x = x + y*b**{i-t-1}; q{i-t-1} -= 1; } */ + if (x.sign == MP_NEG) { + if ((res = mp_copy (&y, &t1)) != MP_OKAY) { + goto LBL_Y; + } + if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) { + goto LBL_Y; + } + if ((res = mp_add (&x, &t1, &x)) != MP_OKAY) { + goto LBL_Y; + } + + q.dp[i - t - 1] = (q.dp[i - t - 1] - 1UL) & MP_MASK; + } + } + + /* now q is the quotient and x is the remainder + * [which we have to normalize] + */ + + /* get sign before writing to c */ + x.sign = x.used == 0 ? MP_ZPOS : a->sign; + + if (c != NULL) { + mp_clamp (&q); + mp_exch (&q, c); + c->sign = neg; + } + + if (d != NULL) { + mp_div_2d (&x, norm, &x, NULL); + mp_exch (&x, d); + } + + res = MP_OKAY; + +LBL_Y:mp_clear (&y); +LBL_X:mp_clear (&x); +LBL_T2:mp_clear (&t2); +LBL_T1:mp_clear (&t1); +LBL_Q:mp_clear (&q); + return res; +} + +#endif + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_div_2.c b/dep/StormLib/src/libtommath/bn_mp_div_2.c new file mode 100644 index 000000000..f3b9d16fa --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_div_2.c @@ -0,0 +1,68 @@ +#include "tommath.h" +#ifdef BN_MP_DIV_2_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* b = a/2 */ +int mp_div_2(mp_int * a, mp_int * b) +{ + int x, res, oldused; + + /* copy */ + if (b->alloc < a->used) { + if ((res = mp_grow (b, a->used)) != MP_OKAY) { + return res; + } + } + + oldused = b->used; + b->used = a->used; + { + register mp_digit r, rr, *tmpa, *tmpb; + + /* source alias */ + tmpa = a->dp + b->used - 1; + + /* dest alias */ + tmpb = b->dp + b->used - 1; + + /* carry */ + r = 0; + for (x = b->used - 1; x >= 0; x--) { + /* get the carry for the next iteration */ + rr = *tmpa & 1; + + /* shift the current digit, add in carry and store */ + *tmpb-- = (*tmpa-- >> 1) | (r << (DIGIT_BIT - 1)); + + /* forward carry to next iteration */ + r = rr; + } + + /* zero excess digits */ + tmpb = b->dp + b->used; + for (x = b->used; x < oldused; x++) { + *tmpb++ = 0; + } + } + b->sign = a->sign; + mp_clamp (b); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_2.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_div_2d.c b/dep/StormLib/src/libtommath/bn_mp_div_2d.c new file mode 100644 index 000000000..861ea23a3 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_div_2d.c @@ -0,0 +1,97 @@ +#include "tommath.h" +#ifdef BN_MP_DIV_2D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* shift right by a certain bit count (store quotient in c, optional remainder in d) */ +int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) +{ + mp_digit D, r, rr; + int x, res; + mp_int t; + + + /* if the shift count is <= 0 then we do no work */ + if (b <= 0) { + res = mp_copy (a, c); + if (d != NULL) { + mp_zero (d); + } + return res; + } + + if ((res = mp_init (&t)) != MP_OKAY) { + return res; + } + + /* get the remainder */ + if (d != NULL) { + if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) { + mp_clear (&t); + return res; + } + } + + /* copy */ + if ((res = mp_copy (a, c)) != MP_OKAY) { + mp_clear (&t); + return res; + } + + /* shift by as many digits in the bit count */ + if (b >= (int)DIGIT_BIT) { + mp_rshd (c, b / DIGIT_BIT); + } + + /* shift any bit count < DIGIT_BIT */ + D = (mp_digit) (b % DIGIT_BIT); + if (D != 0) { + register mp_digit *tmpc, mask, shift; + + /* mask */ + mask = (((mp_digit)1) << D) - 1; + + /* shift for lsb */ + shift = DIGIT_BIT - D; + + /* alias */ + tmpc = c->dp + (c->used - 1); + + /* carry */ + r = 0; + for (x = c->used - 1; x >= 0; x--) { + /* get the lower bits of this word in a temp */ + rr = *tmpc & mask; + + /* shift the current word and mix in the carry bits from the previous word */ + *tmpc = (*tmpc >> D) | (r << shift); + --tmpc; + + /* set the carry to the carry bits of the current word found above */ + r = rr; + } + } + mp_clamp (c); + if (d != NULL) { + mp_exch (&t, d); + } + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_2d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_div_3.c b/dep/StormLib/src/libtommath/bn_mp_div_3.c new file mode 100644 index 000000000..4fc08fc4d --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_div_3.c @@ -0,0 +1,79 @@ +#include "tommath.h" +#ifdef BN_MP_DIV_3_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* divide by three (based on routine from MPI and the GMP manual) */ +int +mp_div_3 (mp_int * a, mp_int *c, mp_digit * d) +{ + mp_int q; + mp_word w, t; + mp_digit b; + int res, ix; + + /* b = 2**DIGIT_BIT / 3 */ + b = (((mp_word)1) << ((mp_word)DIGIT_BIT)) / ((mp_word)3); + + if ((res = mp_init_size(&q, a->used)) != MP_OKAY) { + return res; + } + + q.used = a->used; + q.sign = a->sign; + w = 0; + for (ix = a->used - 1; ix >= 0; ix--) { + w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]); + + if (w >= 3) { + /* multiply w by [1/3] */ + t = (w * ((mp_word)b)) >> ((mp_word)DIGIT_BIT); + + /* now subtract 3 * [w/3] from w, to get the remainder */ + w -= t+t+t; + + /* fixup the remainder as required since + * the optimization is not exact. + */ + while (w >= 3) { + t += 1; + w -= 3; + } + } else { + t = 0; + } + q.dp[ix] = (mp_digit)t; + } + + /* [optional] store the remainder */ + if (d != NULL) { + *d = (mp_digit)w; + } + + /* [optional] store the quotient */ + if (c != NULL) { + mp_clamp(&q); + mp_exch(&q, c); + } + mp_clear(&q); + + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_3.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_div_d.c b/dep/StormLib/src/libtommath/bn_mp_div_d.c new file mode 100644 index 000000000..c0318a4a1 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_div_d.c @@ -0,0 +1,115 @@ +#include "tommath.h" +#ifdef BN_MP_DIV_D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +static int s_is_power_of_two(mp_digit b, int *p) +{ + int x; + + /* fast return if no power of two */ + if ((b==0) || (b & (b-1))) { + return 0; + } + + for (x = 0; x < DIGIT_BIT; x++) { + if (b == (((mp_digit)1)<dp[0] & ((((mp_digit)1)<used)) != MP_OKAY) { + return res; + } + + q.used = a->used; + q.sign = a->sign; + w = 0; + for (ix = a->used - 1; ix >= 0; ix--) { + w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]); + + if (w >= b) { + t = (mp_digit)(w / b); + w -= ((mp_word)t) * ((mp_word)b); + } else { + t = 0; + } + q.dp[ix] = (mp_digit)t; + } + + if (d != NULL) { + *d = (mp_digit)w; + } + + if (c != NULL) { + mp_clamp(&q); + mp_exch(&q, c); + } + mp_clear(&q); + + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2007/01/09 04:44:32 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_dr_is_modulus.c b/dep/StormLib/src/libtommath/bn_mp_dr_is_modulus.c new file mode 100644 index 000000000..22ba5df3d --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_dr_is_modulus.c @@ -0,0 +1,43 @@ +#include "tommath.h" +#ifdef BN_MP_DR_IS_MODULUS_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines if a number is a valid DR modulus */ +int mp_dr_is_modulus(mp_int *a) +{ + int ix; + + /* must be at least two digits */ + if (a->used < 2) { + return 0; + } + + /* must be of the form b**k - a [a <= b] so all + * but the first digit must be equal to -1 (mod b). + */ + for (ix = 1; ix < a->used; ix++) { + if (a->dp[ix] != MP_MASK) { + return 0; + } + } + return 1; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_is_modulus.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_dr_reduce.c b/dep/StormLib/src/libtommath/bn_mp_dr_reduce.c new file mode 100644 index 000000000..0afac941f --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_dr_reduce.c @@ -0,0 +1,94 @@ +#include "tommath.h" +#ifdef BN_MP_DR_REDUCE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* reduce "x" in place modulo "n" using the Diminished Radix algorithm. + * + * Based on algorithm from the paper + * + * "Generating Efficient Primes for Discrete Log Cryptosystems" + * Chae Hoon Lim, Pil Joong Lee, + * POSTECH Information Research Laboratories + * + * The modulus must be of a special format [see manual] + * + * Has been modified to use algorithm 7.10 from the LTM book instead + * + * Input x must be in the range 0 <= x <= (n-1)**2 + */ +int +mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k) +{ + int err, i, m; + mp_word r; + mp_digit mu, *tmpx1, *tmpx2; + + /* m = digits in modulus */ + m = n->used; + + /* ensure that "x" has at least 2m digits */ + if (x->alloc < m + m) { + if ((err = mp_grow (x, m + m)) != MP_OKAY) { + return err; + } + } + +/* top of loop, this is where the code resumes if + * another reduction pass is required. + */ +top: + /* aliases for digits */ + /* alias for lower half of x */ + tmpx1 = x->dp; + + /* alias for upper half of x, or x/B**m */ + tmpx2 = x->dp + m; + + /* set carry to zero */ + mu = 0; + + /* compute (x mod B**m) + k * [x/B**m] inline and inplace */ + for (i = 0; i < m; i++) { + r = ((mp_word)*tmpx2++) * ((mp_word)k) + *tmpx1 + mu; + *tmpx1++ = (mp_digit)(r & MP_MASK); + mu = (mp_digit)(r >> ((mp_word)DIGIT_BIT)); + } + + /* set final carry */ + *tmpx1++ = mu; + + /* zero words above m */ + for (i = m + 1; i < x->used; i++) { + *tmpx1++ = 0; + } + + /* clamp, sub and return */ + mp_clamp (x); + + /* if x >= n then subtract and reduce again + * Each successive "recursion" makes the input smaller and smaller. + */ + if (mp_cmp_mag (x, n) != MP_LT) { + s_mp_sub(x, n, x); + goto top; + } + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_reduce.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_dr_setup.c b/dep/StormLib/src/libtommath/bn_mp_dr_setup.c new file mode 100644 index 000000000..a5152f713 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_dr_setup.c @@ -0,0 +1,32 @@ +#include "tommath.h" +#ifdef BN_MP_DR_SETUP_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines the setup value */ +void mp_dr_setup(mp_int *a, mp_digit *d) +{ + /* the casts are required if DIGIT_BIT is one less than + * the number of bits in a mp_digit [e.g. DIGIT_BIT==31] + */ + *d = (mp_digit)((((mp_word)1) << ((mp_word)DIGIT_BIT)) - + ((mp_word)a->dp[0])); +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_setup.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_exch.c b/dep/StormLib/src/libtommath/bn_mp_exch.c new file mode 100644 index 000000000..e5ec7f577 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_exch.c @@ -0,0 +1,34 @@ +#include "tommath.h" +#ifdef BN_MP_EXCH_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* swap the elements of two integers, for cases where you can't simply swap the + * mp_int pointers around + */ +void +mp_exch (mp_int * a, mp_int * b) +{ + mp_int t; + + t = *a; + *a = *b; + *b = t; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_expt_d.c b/dep/StormLib/src/libtommath/bn_mp_expt_d.c new file mode 100644 index 000000000..7bf371ce6 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_expt_d.c @@ -0,0 +1,57 @@ +#include "tommath.h" +#ifdef BN_MP_EXPT_D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* calculate c = a**b using a square-multiply algorithm */ +int mp_expt_d (mp_int * a, mp_digit b, mp_int * c) +{ + int res, x; + mp_int g; + + if ((res = mp_init_copy (&g, a)) != MP_OKAY) { + return res; + } + + /* set initial result */ + mp_set (c, 1); + + for (x = 0; x < (int) DIGIT_BIT; x++) { + /* square */ + if ((res = mp_sqr (c, c)) != MP_OKAY) { + mp_clear (&g); + return res; + } + + /* if the bit is set multiply */ + if ((b & (mp_digit) (((mp_digit)1) << (DIGIT_BIT - 1))) != 0) { + if ((res = mp_mul (c, &g, c)) != MP_OKAY) { + mp_clear (&g); + return res; + } + } + + /* shift to next bit */ + b <<= 1; + } + + mp_clear (&g); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_expt_d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_exptmod.c b/dep/StormLib/src/libtommath/bn_mp_exptmod.c new file mode 100644 index 000000000..27c46ea0a --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_exptmod.c @@ -0,0 +1,112 @@ +#include "tommath.h" +#ifdef BN_MP_EXPTMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + + +/* this is a shell function that calls either the normal or Montgomery + * exptmod functions. Originally the call to the montgomery code was + * embedded in the normal function but that wasted alot of stack space + * for nothing (since 99% of the time the Montgomery code would be called) + */ +int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y) +{ + int dr; + + /* modulus P must be positive */ + if (P->sign == MP_NEG) { + return MP_VAL; + } + + /* if exponent X is negative we have to recurse */ + if (X->sign == MP_NEG) { +#ifdef BN_MP_INVMOD_C + mp_int tmpG, tmpX; + int err; + + /* first compute 1/G mod P */ + if ((err = mp_init(&tmpG)) != MP_OKAY) { + return err; + } + if ((err = mp_invmod(G, P, &tmpG)) != MP_OKAY) { + mp_clear(&tmpG); + return err; + } + + /* now get |X| */ + if ((err = mp_init(&tmpX)) != MP_OKAY) { + mp_clear(&tmpG); + return err; + } + if ((err = mp_abs(X, &tmpX)) != MP_OKAY) { + mp_clear_multi(&tmpG, &tmpX, NULL); + return err; + } + + /* and now compute (1/G)**|X| instead of G**X [X < 0] */ + err = mp_exptmod(&tmpG, &tmpX, P, Y); + mp_clear_multi(&tmpG, &tmpX, NULL); + return err; +#else + /* no invmod */ + return MP_VAL; +#endif + } + +/* modified diminished radix reduction */ +#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && defined(BN_S_MP_EXPTMOD_C) + if (mp_reduce_is_2k_l(P) == MP_YES) { + return s_mp_exptmod(G, X, P, Y, 1); + } +#endif + +#ifdef BN_MP_DR_IS_MODULUS_C + /* is it a DR modulus? */ + dr = mp_dr_is_modulus(P); +#else + /* default to no */ + dr = 0; +#endif + +#ifdef BN_MP_REDUCE_IS_2K_C + /* if not, is it a unrestricted DR modulus? */ + if (dr == 0) { + dr = mp_reduce_is_2k(P) << 1; + } +#endif + + /* if the modulus is odd or dr != 0 use the montgomery method */ +#ifdef BN_MP_EXPTMOD_FAST_C + if (mp_isodd (P) == 1 || dr != 0) { + return mp_exptmod_fast (G, X, P, Y, dr); + } else { +#endif +#ifdef BN_S_MP_EXPTMOD_C + /* otherwise use the generic Barrett reduction technique */ + return s_mp_exptmod (G, X, P, Y, 0); +#else + /* no exptmod for evens */ + return MP_VAL; +#endif +#ifdef BN_MP_EXPTMOD_FAST_C + } +#endif +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_exptmod_fast.c b/dep/StormLib/src/libtommath/bn_mp_exptmod_fast.c new file mode 100644 index 000000000..31205d4e2 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_exptmod_fast.c @@ -0,0 +1,321 @@ +#include "tommath.h" +#ifdef BN_MP_EXPTMOD_FAST_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85 + * + * Uses a left-to-right k-ary sliding window to compute the modular exponentiation. + * The value of k changes based on the size of the exponent. + * + * Uses Montgomery or Diminished Radix reduction [whichever appropriate] + */ + +#ifdef MP_LOW_MEM + #define TAB_SIZE 32 +#else + #define TAB_SIZE 256 +#endif + +int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode) +{ + mp_int M[TAB_SIZE], res; + mp_digit buf, mp; + int err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize; + + /* use a pointer to the reduction algorithm. This allows us to use + * one of many reduction algorithms without modding the guts of + * the code with if statements everywhere. + */ + int (*redux)(mp_int*,mp_int*,mp_digit); + + /* find window size */ + x = mp_count_bits (X); + if (x <= 7) { + winsize = 2; + } else if (x <= 36) { + winsize = 3; + } else if (x <= 140) { + winsize = 4; + } else if (x <= 450) { + winsize = 5; + } else if (x <= 1303) { + winsize = 6; + } else if (x <= 3529) { + winsize = 7; + } else { + winsize = 8; + } + +#ifdef MP_LOW_MEM + if (winsize > 5) { + winsize = 5; + } +#endif + + /* init M array */ + /* init first cell */ + if ((err = mp_init(&M[1])) != MP_OKAY) { + return err; + } + + /* now init the second half of the array */ + for (x = 1<<(winsize-1); x < (1 << winsize); x++) { + if ((err = mp_init(&M[x])) != MP_OKAY) { + for (y = 1<<(winsize-1); y < x; y++) { + mp_clear (&M[y]); + } + mp_clear(&M[1]); + return err; + } + } + + /* determine and setup reduction code */ + if (redmode == 0) { +#ifdef BN_MP_MONTGOMERY_SETUP_C + /* now setup montgomery */ + if ((err = mp_montgomery_setup (P, &mp)) != MP_OKAY) { + goto LBL_M; + } +#else + err = MP_VAL; + goto LBL_M; +#endif + + /* automatically pick the comba one if available (saves quite a few calls/ifs) */ +#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C + if (((P->used * 2 + 1) < MP_WARRAY) && + P->used < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { + redux = fast_mp_montgomery_reduce; + } else +#endif + { +#ifdef BN_MP_MONTGOMERY_REDUCE_C + /* use slower baseline Montgomery method */ + redux = mp_montgomery_reduce; +#else + err = MP_VAL; + goto LBL_M; +#endif + } + } else if (redmode == 1) { +#if defined(BN_MP_DR_SETUP_C) && defined(BN_MP_DR_REDUCE_C) + /* setup DR reduction for moduli of the form B**k - b */ + mp_dr_setup(P, &mp); + redux = mp_dr_reduce; +#else + err = MP_VAL; + goto LBL_M; +#endif + } else { +#if defined(BN_MP_REDUCE_2K_SETUP_C) && defined(BN_MP_REDUCE_2K_C) + /* setup DR reduction for moduli of the form 2**k - b */ + if ((err = mp_reduce_2k_setup(P, &mp)) != MP_OKAY) { + goto LBL_M; + } + redux = mp_reduce_2k; +#else + err = MP_VAL; + goto LBL_M; +#endif + } + + /* setup result */ + if ((err = mp_init (&res)) != MP_OKAY) { + goto LBL_M; + } + + /* create M table + * + + * + * The first half of the table is not computed though accept for M[0] and M[1] + */ + + if (redmode == 0) { +#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C + /* now we need R mod m */ + if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) { + goto LBL_RES; + } +#else + err = MP_VAL; + goto LBL_RES; +#endif + + /* now set M[1] to G * R mod m */ + if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) { + goto LBL_RES; + } + } else { + mp_set(&res, 1); + if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) { + goto LBL_RES; + } + } + + /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */ + if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) { + goto LBL_RES; + } + + for (x = 0; x < (winsize - 1); x++) { + if ((err = mp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) { + goto LBL_RES; + } + } + + /* create upper table */ + for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) { + if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&M[x], P, mp)) != MP_OKAY) { + goto LBL_RES; + } + } + + /* set initial mode and bit cnt */ + mode = 0; + bitcnt = 1; + buf = 0; + digidx = X->used - 1; + bitcpy = 0; + bitbuf = 0; + + for (;;) { + /* grab next digit as required */ + if (--bitcnt == 0) { + /* if digidx == -1 we are out of digits so break */ + if (digidx == -1) { + break; + } + /* read next digit and reset bitcnt */ + buf = X->dp[digidx--]; + bitcnt = (int)DIGIT_BIT; + } + + /* grab the next msb from the exponent */ + y = (mp_digit)(buf >> (DIGIT_BIT - 1)) & 1; + buf <<= (mp_digit)1; + + /* if the bit is zero and mode == 0 then we ignore it + * These represent the leading zero bits before the first 1 bit + * in the exponent. Technically this opt is not required but it + * does lower the # of trivial squaring/reductions used + */ + if (mode == 0 && y == 0) { + continue; + } + + /* if the bit is zero and mode == 1 then we square */ + if (mode == 1 && y == 0) { + if ((err = mp_sqr (&res, &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, mp)) != MP_OKAY) { + goto LBL_RES; + } + continue; + } + + /* else we add it to the window */ + bitbuf |= (y << (winsize - ++bitcpy)); + mode = 2; + + if (bitcpy == winsize) { + /* ok window is filled so square as required and multiply */ + /* square first */ + for (x = 0; x < winsize; x++) { + if ((err = mp_sqr (&res, &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, mp)) != MP_OKAY) { + goto LBL_RES; + } + } + + /* then multiply */ + if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, mp)) != MP_OKAY) { + goto LBL_RES; + } + + /* empty window and reset */ + bitcpy = 0; + bitbuf = 0; + mode = 1; + } + } + + /* if bits remain then square/multiply */ + if (mode == 2 && bitcpy > 0) { + /* square then multiply if the bit is set */ + for (x = 0; x < bitcpy; x++) { + if ((err = mp_sqr (&res, &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, mp)) != MP_OKAY) { + goto LBL_RES; + } + + /* get next bit of the window */ + bitbuf <<= 1; + if ((bitbuf & (1 << winsize)) != 0) { + /* then multiply */ + if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, mp)) != MP_OKAY) { + goto LBL_RES; + } + } + } + } + + if (redmode == 0) { + /* fixup result if Montgomery reduction is used + * recall that any value in a Montgomery system is + * actually multiplied by R mod n. So we have + * to reduce one more time to cancel out the factor + * of R. + */ + if ((err = redux(&res, P, mp)) != MP_OKAY) { + goto LBL_RES; + } + } + + /* swap res with Y */ + mp_exch (&res, Y); + err = MP_OKAY; +LBL_RES:mp_clear (&res); +LBL_M: + mp_clear(&M[1]); + for (x = 1<<(winsize-1); x < (1 << winsize); x++) { + mp_clear (&M[x]); + } + return err; +} +#endif + + +/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod_fast.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_exteuclid.c b/dep/StormLib/src/libtommath/bn_mp_exteuclid.c new file mode 100644 index 000000000..9881d6edc --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_exteuclid.c @@ -0,0 +1,82 @@ +#include "tommath.h" +#ifdef BN_MP_EXTEUCLID_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Extended euclidean algorithm of (a, b) produces + a*u1 + b*u2 = u3 + */ +int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3) +{ + mp_int u1,u2,u3,v1,v2,v3,t1,t2,t3,q,tmp; + int err; + + if ((err = mp_init_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL)) != MP_OKAY) { + return err; + } + + /* initialize, (u1,u2,u3) = (1,0,a) */ + mp_set(&u1, 1); + if ((err = mp_copy(a, &u3)) != MP_OKAY) { goto _ERR; } + + /* initialize, (v1,v2,v3) = (0,1,b) */ + mp_set(&v2, 1); + if ((err = mp_copy(b, &v3)) != MP_OKAY) { goto _ERR; } + + /* loop while v3 != 0 */ + while (mp_iszero(&v3) == MP_NO) { + /* q = u3/v3 */ + if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) { goto _ERR; } + + /* (t1,t2,t3) = (u1,u2,u3) - (v1,v2,v3)q */ + if ((err = mp_mul(&v1, &q, &tmp)) != MP_OKAY) { goto _ERR; } + if ((err = mp_sub(&u1, &tmp, &t1)) != MP_OKAY) { goto _ERR; } + if ((err = mp_mul(&v2, &q, &tmp)) != MP_OKAY) { goto _ERR; } + if ((err = mp_sub(&u2, &tmp, &t2)) != MP_OKAY) { goto _ERR; } + if ((err = mp_mul(&v3, &q, &tmp)) != MP_OKAY) { goto _ERR; } + if ((err = mp_sub(&u3, &tmp, &t3)) != MP_OKAY) { goto _ERR; } + + /* (u1,u2,u3) = (v1,v2,v3) */ + if ((err = mp_copy(&v1, &u1)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(&v2, &u2)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(&v3, &u3)) != MP_OKAY) { goto _ERR; } + + /* (v1,v2,v3) = (t1,t2,t3) */ + if ((err = mp_copy(&t1, &v1)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(&t2, &v2)) != MP_OKAY) { goto _ERR; } + if ((err = mp_copy(&t3, &v3)) != MP_OKAY) { goto _ERR; } + } + + /* make sure U3 >= 0 */ + if (u3.sign == MP_NEG) { + mp_neg(&u1, &u1); + mp_neg(&u2, &u2); + mp_neg(&u3, &u3); + } + + /* copy result out */ + if (U1 != NULL) { mp_exch(U1, &u1); } + if (U2 != NULL) { mp_exch(U2, &u2); } + if (U3 != NULL) { mp_exch(U3, &u3); } + + err = MP_OKAY; +_ERR: mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL); + return err; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_exteuclid.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_fread.c b/dep/StormLib/src/libtommath/bn_mp_fread.c new file mode 100644 index 000000000..2976b30aa --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_fread.c @@ -0,0 +1,67 @@ +#include "tommath.h" +#ifdef BN_MP_FREAD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* read a bigint from a file stream in ASCII */ +int mp_fread(mp_int *a, int radix, FILE *stream) +{ + int err, ch, neg, y; + + /* clear a */ + mp_zero(a); + + /* if first digit is - then set negative */ + ch = fgetc(stream); + if (ch == '-') { + neg = MP_NEG; + ch = fgetc(stream); + } else { + neg = MP_ZPOS; + } + + for (;;) { + /* find y in the radix map */ + for (y = 0; y < radix; y++) { + if (mp_s_rmap[y] == ch) { + break; + } + } + if (y == radix) { + break; + } + + /* shift up and add */ + if ((err = mp_mul_d(a, radix, a)) != MP_OKAY) { + return err; + } + if ((err = mp_add_d(a, y, a)) != MP_OKAY) { + return err; + } + + ch = fgetc(stream); + } + if (mp_cmp_d(a, 0) != MP_EQ) { + a->sign = neg; + } + + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_fread.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_fwrite.c b/dep/StormLib/src/libtommath/bn_mp_fwrite.c new file mode 100644 index 000000000..6782b2e19 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_fwrite.c @@ -0,0 +1,52 @@ +#include "tommath.h" +#ifdef BN_MP_FWRITE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +int mp_fwrite(mp_int *a, int radix, FILE *stream) +{ + char *buf; + int err, len, x; + + if ((err = mp_radix_size(a, radix, &len)) != MP_OKAY) { + return err; + } + + buf = OPT_CAST(char) XMALLOC (len); + if (buf == NULL) { + return MP_MEM; + } + + if ((err = mp_toradix(a, buf, radix)) != MP_OKAY) { + XFREE (buf); + return err; + } + + for (x = 0; x < len; x++) { + if (fputc(buf[x], stream) == EOF) { + XFREE (buf); + return MP_VAL; + } + } + + XFREE (buf); + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_fwrite.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_gcd.c b/dep/StormLib/src/libtommath/bn_mp_gcd.c new file mode 100644 index 000000000..ce980eb6b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_gcd.c @@ -0,0 +1,105 @@ +#include "tommath.h" +#ifdef BN_MP_GCD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Greatest Common Divisor using the binary method */ +int mp_gcd (mp_int * a, mp_int * b, mp_int * c) +{ + mp_int u, v; + int k, u_lsb, v_lsb, res; + + /* either zero than gcd is the largest */ + if (mp_iszero (a) == MP_YES) { + return mp_abs (b, c); + } + if (mp_iszero (b) == MP_YES) { + return mp_abs (a, c); + } + + /* get copies of a and b we can modify */ + if ((res = mp_init_copy (&u, a)) != MP_OKAY) { + return res; + } + + if ((res = mp_init_copy (&v, b)) != MP_OKAY) { + goto LBL_U; + } + + /* must be positive for the remainder of the algorithm */ + u.sign = v.sign = MP_ZPOS; + + /* B1. Find the common power of two for u and v */ + u_lsb = mp_cnt_lsb(&u); + v_lsb = mp_cnt_lsb(&v); + k = MIN(u_lsb, v_lsb); + + if (k > 0) { + /* divide the power of two out */ + if ((res = mp_div_2d(&u, k, &u, NULL)) != MP_OKAY) { + goto LBL_V; + } + + if ((res = mp_div_2d(&v, k, &v, NULL)) != MP_OKAY) { + goto LBL_V; + } + } + + /* divide any remaining factors of two out */ + if (u_lsb != k) { + if ((res = mp_div_2d(&u, u_lsb - k, &u, NULL)) != MP_OKAY) { + goto LBL_V; + } + } + + if (v_lsb != k) { + if ((res = mp_div_2d(&v, v_lsb - k, &v, NULL)) != MP_OKAY) { + goto LBL_V; + } + } + + while (mp_iszero(&v) == 0) { + /* make sure v is the largest */ + if (mp_cmp_mag(&u, &v) == MP_GT) { + /* swap u and v to make sure v is >= u */ + mp_exch(&u, &v); + } + + /* subtract smallest from largest */ + if ((res = s_mp_sub(&v, &u, &v)) != MP_OKAY) { + goto LBL_V; + } + + /* Divide out all factors of two */ + if ((res = mp_div_2d(&v, mp_cnt_lsb(&v), &v, NULL)) != MP_OKAY) { + goto LBL_V; + } + } + + /* multiply by 2**k which we divided out at the beginning */ + if ((res = mp_mul_2d (&u, k, c)) != MP_OKAY) { + goto LBL_V; + } + c->sign = MP_ZPOS; + res = MP_OKAY; +LBL_V:mp_clear (&u); +LBL_U:mp_clear (&v); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_gcd.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_get_int.c b/dep/StormLib/src/libtommath/bn_mp_get_int.c new file mode 100644 index 000000000..d9c76d0d1 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_get_int.c @@ -0,0 +1,45 @@ +#include "tommath.h" +#ifdef BN_MP_GET_INT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* get the lower 32-bits of an mp_int */ +unsigned long mp_get_int(mp_int * a) +{ + int i; + unsigned long res; + + if (a->used == 0) { + return 0; + } + + /* get number of digits of the lsb we have to read */ + i = MIN(a->used,(int)((sizeof(unsigned long)*CHAR_BIT+DIGIT_BIT-1)/DIGIT_BIT))-1; + + /* get most significant digit of result */ + res = DIGIT(a,i); + + while (--i >= 0) { + res = (res << DIGIT_BIT) | DIGIT(a,i); + } + + /* force result to 32-bits always so it is consistent on non 32-bit platforms */ + return res & 0xFFFFFFFFUL; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_get_int.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_grow.c b/dep/StormLib/src/libtommath/bn_mp_grow.c new file mode 100644 index 000000000..a05dad73b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_grow.c @@ -0,0 +1,57 @@ +#include "tommath.h" +#ifdef BN_MP_GROW_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* grow as required */ +int mp_grow (mp_int * a, int size) +{ + int i; + mp_digit *tmp; + + /* if the alloc size is smaller alloc more ram */ + if (a->alloc < size) { + /* ensure there are always at least MP_PREC digits extra on top */ + size += (MP_PREC * 2) - (size % MP_PREC); + + /* reallocate the array a->dp + * + * We store the return in a temporary variable + * in case the operation failed we don't want + * to overwrite the dp member of a. + */ + tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * size); + if (tmp == NULL) { + /* reallocation failed but "a" is still valid [can be freed] */ + return MP_MEM; + } + + /* reallocation succeeded so set a->dp */ + a->dp = tmp; + + /* zero excess digits */ + i = a->alloc; + a->alloc = size; + for (; i < a->alloc; i++) { + a->dp[i] = 0; + } + } + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_grow.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_init.c b/dep/StormLib/src/libtommath/bn_mp_init.c new file mode 100644 index 000000000..107d98be6 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_init.c @@ -0,0 +1,46 @@ +#include "tommath.h" +#ifdef BN_MP_INIT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* init a new mp_int */ +int mp_init (mp_int * a) +{ + int i; + + /* allocate memory required and clear it */ + a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC); + if (a->dp == NULL) { + return MP_MEM; + } + + /* set the digits to zero */ + for (i = 0; i < MP_PREC; i++) { + a->dp[i] = 0; + } + + /* set the used to zero, allocated digits to the default precision + * and sign to positive */ + a->used = 0; + a->alloc = MP_PREC; + a->sign = MP_ZPOS; + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_init_copy.c b/dep/StormLib/src/libtommath/bn_mp_init_copy.c new file mode 100644 index 000000000..3ca1186ce --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_init_copy.c @@ -0,0 +1,32 @@ +#include "tommath.h" +#ifdef BN_MP_INIT_COPY_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* creates "a" then copies b into it */ +int mp_init_copy (mp_int * a, mp_int * b) +{ + int res; + + if ((res = mp_init (a)) != MP_OKAY) { + return res; + } + return mp_copy (b, a); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_copy.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_init_multi.c b/dep/StormLib/src/libtommath/bn_mp_init_multi.c new file mode 100644 index 000000000..4f6f367ff --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_init_multi.c @@ -0,0 +1,59 @@ +#include "tommath.h" +#ifdef BN_MP_INIT_MULTI_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include + +int mp_init_multi(mp_int *mp, ...) +{ + mp_err res = MP_OKAY; /* Assume ok until proven otherwise */ + int n = 0; /* Number of ok inits */ + mp_int* cur_arg = mp; + va_list args; + + va_start(args, mp); /* init args to next argument from caller */ + while (cur_arg != NULL) { + if (mp_init(cur_arg) != MP_OKAY) { + /* Oops - error! Back-track and mp_clear what we already + succeeded in init-ing, then return error. + */ + va_list clean_args; + + /* end the current list */ + va_end(args); + + /* now start cleaning up */ + cur_arg = mp; + va_start(clean_args, mp); + while (n--) { + mp_clear(cur_arg); + cur_arg = va_arg(clean_args, mp_int*); + } + va_end(clean_args); + res = MP_MEM; + break; + } + n++; + cur_arg = va_arg(args, mp_int*); + } + va_end(args); + return res; /* Assumed ok, if error flagged above. */ +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_multi.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_init_set.c b/dep/StormLib/src/libtommath/bn_mp_init_set.c new file mode 100644 index 000000000..853323f3a --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_init_set.c @@ -0,0 +1,32 @@ +#include "tommath.h" +#ifdef BN_MP_INIT_SET_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* initialize and set a digit */ +int mp_init_set (mp_int * a, mp_digit b) +{ + int err; + if ((err = mp_init(a)) != MP_OKAY) { + return err; + } + mp_set(a, b); + return err; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_set.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_init_set_int.c b/dep/StormLib/src/libtommath/bn_mp_init_set_int.c new file mode 100644 index 000000000..b2f8727e3 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_init_set_int.c @@ -0,0 +1,31 @@ +#include "tommath.h" +#ifdef BN_MP_INIT_SET_INT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* initialize and set a digit */ +int mp_init_set_int (mp_int * a, unsigned long b) +{ + int err; + if ((err = mp_init(a)) != MP_OKAY) { + return err; + } + return mp_set_int(a, b); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_set_int.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_init_size.c b/dep/StormLib/src/libtommath/bn_mp_init_size.c new file mode 100644 index 000000000..17b8d9fce --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_init_size.c @@ -0,0 +1,48 @@ +#include "tommath.h" +#ifdef BN_MP_INIT_SIZE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* init an mp_init for a given size */ +int mp_init_size (mp_int * a, int size) +{ + int x; + + /* pad size so there are always extra digits */ + size += (MP_PREC * 2) - (size % MP_PREC); + + /* alloc mem */ + a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * size); + if (a->dp == NULL) { + return MP_MEM; + } + + /* set the members */ + a->used = 0; + a->alloc = size; + a->sign = MP_ZPOS; + + /* zero the digits */ + for (x = 0; x < size; x++) { + a->dp[x] = 0; + } + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_size.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_invmod.c b/dep/StormLib/src/libtommath/bn_mp_invmod.c new file mode 100644 index 000000000..038e584a2 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_invmod.c @@ -0,0 +1,43 @@ +#include "tommath.h" +#ifdef BN_MP_INVMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* hac 14.61, pp608 */ +int mp_invmod (mp_int * a, mp_int * b, mp_int * c) +{ + /* b cannot be negative */ + if (b->sign == MP_NEG || mp_iszero(b) == 1) { + return MP_VAL; + } + +#ifdef BN_FAST_MP_INVMOD_C + /* if the modulus is odd we can use a faster routine instead */ + if (mp_isodd (b) == 1) { + return fast_mp_invmod (a, b, c); + } +#endif + +#ifdef BN_MP_INVMOD_SLOW_C + return mp_invmod_slow(a, b, c); +#endif + + return MP_VAL; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_invmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_invmod_slow.c b/dep/StormLib/src/libtommath/bn_mp_invmod_slow.c new file mode 100644 index 000000000..3792a4c23 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_invmod_slow.c @@ -0,0 +1,175 @@ +#include "tommath.h" +#ifdef BN_MP_INVMOD_SLOW_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* hac 14.61, pp608 */ +int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c) +{ + mp_int x, y, u, v, A, B, C, D; + int res; + + /* b cannot be negative */ + if (b->sign == MP_NEG || mp_iszero(b) == 1) { + return MP_VAL; + } + + /* init temps */ + if ((res = mp_init_multi(&x, &y, &u, &v, + &A, &B, &C, &D, NULL)) != MP_OKAY) { + return res; + } + + /* x = a, y = b */ + if ((res = mp_mod(a, b, &x)) != MP_OKAY) { + goto LBL_ERR; + } + if ((res = mp_copy (b, &y)) != MP_OKAY) { + goto LBL_ERR; + } + + /* 2. [modified] if x,y are both even then return an error! */ + if (mp_iseven (&x) == 1 && mp_iseven (&y) == 1) { + res = MP_VAL; + goto LBL_ERR; + } + + /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */ + if ((res = mp_copy (&x, &u)) != MP_OKAY) { + goto LBL_ERR; + } + if ((res = mp_copy (&y, &v)) != MP_OKAY) { + goto LBL_ERR; + } + mp_set (&A, 1); + mp_set (&D, 1); + +top: + /* 4. while u is even do */ + while (mp_iseven (&u) == 1) { + /* 4.1 u = u/2 */ + if ((res = mp_div_2 (&u, &u)) != MP_OKAY) { + goto LBL_ERR; + } + /* 4.2 if A or B is odd then */ + if (mp_isodd (&A) == 1 || mp_isodd (&B) == 1) { + /* A = (A+y)/2, B = (B-x)/2 */ + if ((res = mp_add (&A, &y, &A)) != MP_OKAY) { + goto LBL_ERR; + } + if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) { + goto LBL_ERR; + } + } + /* A = A/2, B = B/2 */ + if ((res = mp_div_2 (&A, &A)) != MP_OKAY) { + goto LBL_ERR; + } + if ((res = mp_div_2 (&B, &B)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* 5. while v is even do */ + while (mp_iseven (&v) == 1) { + /* 5.1 v = v/2 */ + if ((res = mp_div_2 (&v, &v)) != MP_OKAY) { + goto LBL_ERR; + } + /* 5.2 if C or D is odd then */ + if (mp_isodd (&C) == 1 || mp_isodd (&D) == 1) { + /* C = (C+y)/2, D = (D-x)/2 */ + if ((res = mp_add (&C, &y, &C)) != MP_OKAY) { + goto LBL_ERR; + } + if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) { + goto LBL_ERR; + } + } + /* C = C/2, D = D/2 */ + if ((res = mp_div_2 (&C, &C)) != MP_OKAY) { + goto LBL_ERR; + } + if ((res = mp_div_2 (&D, &D)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* 6. if u >= v then */ + if (mp_cmp (&u, &v) != MP_LT) { + /* u = u - v, A = A - C, B = B - D */ + if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) { + goto LBL_ERR; + } + + if ((res = mp_sub (&A, &C, &A)) != MP_OKAY) { + goto LBL_ERR; + } + + if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) { + goto LBL_ERR; + } + } else { + /* v - v - u, C = C - A, D = D - B */ + if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) { + goto LBL_ERR; + } + + if ((res = mp_sub (&C, &A, &C)) != MP_OKAY) { + goto LBL_ERR; + } + + if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* if not zero goto step 4 */ + if (mp_iszero (&u) == 0) + goto top; + + /* now a = C, b = D, gcd == g*v */ + + /* if v != 1 then there is no inverse */ + if (mp_cmp_d (&v, 1) != MP_EQ) { + res = MP_VAL; + goto LBL_ERR; + } + + /* if its too low */ + while (mp_cmp_d(&C, 0) == MP_LT) { + if ((res = mp_add(&C, b, &C)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* too big */ + while (mp_cmp_mag(&C, b) != MP_LT) { + if ((res = mp_sub(&C, b, &C)) != MP_OKAY) { + goto LBL_ERR; + } + } + + /* C is now the inverse */ + mp_exch (&C, c); + res = MP_OKAY; +LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_invmod_slow.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_is_square.c b/dep/StormLib/src/libtommath/bn_mp_is_square.c new file mode 100644 index 000000000..5d2fa072c --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_is_square.c @@ -0,0 +1,109 @@ +#include "tommath.h" +#ifdef BN_MP_IS_SQUARE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Check if remainders are possible squares - fast exclude non-squares */ +static const char rem_128[128] = { + 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 +}; + +static const char rem_105[105] = { + 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 +}; + +/* Store non-zero to ret if arg is square, and zero if not */ +int mp_is_square(mp_int *arg,int *ret) +{ + int res; + mp_digit c; + mp_int t; + unsigned long r; + + /* Default to Non-square :) */ + *ret = MP_NO; + + if (arg->sign == MP_NEG) { + return MP_VAL; + } + + /* digits used? (TSD) */ + if (arg->used == 0) { + return MP_OKAY; + } + + /* First check mod 128 (suppose that DIGIT_BIT is at least 7) */ + if (rem_128[127 & DIGIT(arg,0)] == 1) { + return MP_OKAY; + } + + /* Next check mod 105 (3*5*7) */ + if ((res = mp_mod_d(arg,105,&c)) != MP_OKAY) { + return res; + } + if (rem_105[c] == 1) { + return MP_OKAY; + } + + + if ((res = mp_init_set_int(&t,11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) { + return res; + } + if ((res = mp_mod(arg,&t,&t)) != MP_OKAY) { + goto ERR; + } + r = mp_get_int(&t); + /* Check for other prime modules, note it's not an ERROR but we must + * free "t" so the easiest way is to goto ERR. We know that res + * is already equal to MP_OKAY from the mp_mod call + */ + if ( (1L<<(r%11)) & 0x5C4L ) goto ERR; + if ( (1L<<(r%13)) & 0x9E4L ) goto ERR; + if ( (1L<<(r%17)) & 0x5CE8L ) goto ERR; + if ( (1L<<(r%19)) & 0x4F50CL ) goto ERR; + if ( (1L<<(r%23)) & 0x7ACCA0L ) goto ERR; + if ( (1L<<(r%29)) & 0xC2EDD0CL ) goto ERR; + if ( (1L<<(r%31)) & 0x6DE2B848L ) goto ERR; + + /* Final check - is sqr(sqrt(arg)) == arg ? */ + if ((res = mp_sqrt(arg,&t)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sqr(&t,&t)) != MP_OKAY) { + goto ERR; + } + + *ret = (mp_cmp_mag(&t,arg) == MP_EQ) ? MP_YES : MP_NO; +ERR:mp_clear(&t); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_is_square.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_jacobi.c b/dep/StormLib/src/libtommath/bn_mp_jacobi.c new file mode 100644 index 000000000..c70b946f3 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_jacobi.c @@ -0,0 +1,105 @@ +#include "tommath.h" +#ifdef BN_MP_JACOBI_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* computes the jacobi c = (a | n) (or Legendre if n is prime) + * HAC pp. 73 Algorithm 2.149 + */ +int mp_jacobi (mp_int * a, mp_int * p, int *c) +{ + mp_int a1, p1; + int k, s, r, res; + mp_digit residue; + + /* if p <= 0 return MP_VAL */ + if (mp_cmp_d(p, 0) != MP_GT) { + return MP_VAL; + } + + /* step 1. if a == 0, return 0 */ + if (mp_iszero (a) == 1) { + *c = 0; + return MP_OKAY; + } + + /* step 2. if a == 1, return 1 */ + if (mp_cmp_d (a, 1) == MP_EQ) { + *c = 1; + return MP_OKAY; + } + + /* default */ + s = 0; + + /* step 3. write a = a1 * 2**k */ + if ((res = mp_init_copy (&a1, a)) != MP_OKAY) { + return res; + } + + if ((res = mp_init (&p1)) != MP_OKAY) { + goto LBL_A1; + } + + /* divide out larger power of two */ + k = mp_cnt_lsb(&a1); + if ((res = mp_div_2d(&a1, k, &a1, NULL)) != MP_OKAY) { + goto LBL_P1; + } + + /* step 4. if e is even set s=1 */ + if ((k & 1) == 0) { + s = 1; + } else { + /* else set s=1 if p = 1/7 (mod 8) or s=-1 if p = 3/5 (mod 8) */ + residue = p->dp[0] & 7; + + if (residue == 1 || residue == 7) { + s = 1; + } else if (residue == 3 || residue == 5) { + s = -1; + } + } + + /* step 5. if p == 3 (mod 4) *and* a1 == 3 (mod 4) then s = -s */ + if ( ((p->dp[0] & 3) == 3) && ((a1.dp[0] & 3) == 3)) { + s = -s; + } + + /* if a1 == 1 we're done */ + if (mp_cmp_d (&a1, 1) == MP_EQ) { + *c = s; + } else { + /* n1 = n mod a1 */ + if ((res = mp_mod (p, &a1, &p1)) != MP_OKAY) { + goto LBL_P1; + } + if ((res = mp_jacobi (&p1, &a1, &r)) != MP_OKAY) { + goto LBL_P1; + } + *c = s * r; + } + + /* done */ + res = MP_OKAY; +LBL_P1:mp_clear (&p1); +LBL_A1:mp_clear (&a1); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_jacobi.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_karatsuba_mul.c b/dep/StormLib/src/libtommath/bn_mp_karatsuba_mul.c new file mode 100644 index 000000000..b15ec2496 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_karatsuba_mul.c @@ -0,0 +1,167 @@ +#include "tommath.h" +#ifdef BN_MP_KARATSUBA_MUL_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* c = |a| * |b| using Karatsuba Multiplication using + * three half size multiplications + * + * Let B represent the radix [e.g. 2**DIGIT_BIT] and + * let n represent half of the number of digits in + * the min(a,b) + * + * a = a1 * B**n + a0 + * b = b1 * B**n + b0 + * + * Then, a * b => + a1b1 * B**2n + ((a1 + a0)(b1 + b0) - (a0b0 + a1b1)) * B + a0b0 + * + * Note that a1b1 and a0b0 are used twice and only need to be + * computed once. So in total three half size (half # of + * digit) multiplications are performed, a0b0, a1b1 and + * (a1+b1)(a0+b0) + * + * Note that a multiplication of half the digits requires + * 1/4th the number of single precision multiplications so in + * total after one call 25% of the single precision multiplications + * are saved. Note also that the call to mp_mul can end up back + * in this function if the a0, a1, b0, or b1 are above the threshold. + * This is known as divide-and-conquer and leads to the famous + * O(N**lg(3)) or O(N**1.584) work which is asymptopically lower than + * the standard O(N**2) that the baseline/comba methods use. + * Generally though the overhead of this method doesn't pay off + * until a certain size (N ~ 80) is reached. + */ +int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c) +{ + mp_int x0, x1, y0, y1, t1, x0y0, x1y1; + int B, err; + + /* default the return code to an error */ + err = MP_MEM; + + /* min # of digits */ + B = MIN (a->used, b->used); + + /* now divide in two */ + B = B >> 1; + + /* init copy all the temps */ + if (mp_init_size (&x0, B) != MP_OKAY) + goto ERR; + if (mp_init_size (&x1, a->used - B) != MP_OKAY) + goto X0; + if (mp_init_size (&y0, B) != MP_OKAY) + goto X1; + if (mp_init_size (&y1, b->used - B) != MP_OKAY) + goto Y0; + + /* init temps */ + if (mp_init_size (&t1, B * 2) != MP_OKAY) + goto Y1; + if (mp_init_size (&x0y0, B * 2) != MP_OKAY) + goto T1; + if (mp_init_size (&x1y1, B * 2) != MP_OKAY) + goto X0Y0; + + /* now shift the digits */ + x0.used = y0.used = B; + x1.used = a->used - B; + y1.used = b->used - B; + + { + register int x; + register mp_digit *tmpa, *tmpb, *tmpx, *tmpy; + + /* we copy the digits directly instead of using higher level functions + * since we also need to shift the digits + */ + tmpa = a->dp; + tmpb = b->dp; + + tmpx = x0.dp; + tmpy = y0.dp; + for (x = 0; x < B; x++) { + *tmpx++ = *tmpa++; + *tmpy++ = *tmpb++; + } + + tmpx = x1.dp; + for (x = B; x < a->used; x++) { + *tmpx++ = *tmpa++; + } + + tmpy = y1.dp; + for (x = B; x < b->used; x++) { + *tmpy++ = *tmpb++; + } + } + + /* only need to clamp the lower words since by definition the + * upper words x1/y1 must have a known number of digits + */ + mp_clamp (&x0); + mp_clamp (&y0); + + /* now calc the products x0y0 and x1y1 */ + /* after this x0 is no longer required, free temp [x0==t2]! */ + if (mp_mul (&x0, &y0, &x0y0) != MP_OKAY) + goto X1Y1; /* x0y0 = x0*y0 */ + if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY) + goto X1Y1; /* x1y1 = x1*y1 */ + + /* now calc x1+x0 and y1+y0 */ + if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) + goto X1Y1; /* t1 = x1 - x0 */ + if (s_mp_add (&y1, &y0, &x0) != MP_OKAY) + goto X1Y1; /* t2 = y1 - y0 */ + if (mp_mul (&t1, &x0, &t1) != MP_OKAY) + goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */ + + /* add x0y0 */ + if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY) + goto X1Y1; /* t2 = x0y0 + x1y1 */ + if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY) + goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */ + + /* shift by B */ + if (mp_lshd (&t1, B) != MP_OKAY) + goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<used; + + /* now divide in two */ + B = B >> 1; + + /* init copy all the temps */ + if (mp_init_size (&x0, B) != MP_OKAY) + goto ERR; + if (mp_init_size (&x1, a->used - B) != MP_OKAY) + goto X0; + + /* init temps */ + if (mp_init_size (&t1, a->used * 2) != MP_OKAY) + goto X1; + if (mp_init_size (&t2, a->used * 2) != MP_OKAY) + goto T1; + if (mp_init_size (&x0x0, B * 2) != MP_OKAY) + goto T2; + if (mp_init_size (&x1x1, (a->used - B) * 2) != MP_OKAY) + goto X0X0; + + { + register int x; + register mp_digit *dst, *src; + + src = a->dp; + + /* now shift the digits */ + dst = x0.dp; + for (x = 0; x < B; x++) { + *dst++ = *src++; + } + + dst = x1.dp; + for (x = B; x < a->used; x++) { + *dst++ = *src++; + } + } + + x0.used = B; + x1.used = a->used - B; + + mp_clamp (&x0); + + /* now calc the products x0*x0 and x1*x1 */ + if (mp_sqr (&x0, &x0x0) != MP_OKAY) + goto X1X1; /* x0x0 = x0*x0 */ + if (mp_sqr (&x1, &x1x1) != MP_OKAY) + goto X1X1; /* x1x1 = x1*x1 */ + + /* now calc (x1+x0)**2 */ + if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) + goto X1X1; /* t1 = x1 - x0 */ + if (mp_sqr (&t1, &t1) != MP_OKAY) + goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */ + + /* add x0y0 */ + if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY) + goto X1X1; /* t2 = x0x0 + x1x1 */ + if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY) + goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */ + + /* shift by B */ + if (mp_lshd (&t1, B) != MP_OKAY) + goto X1X1; /* t1 = (x0x0 + x1x1 - (x1-x0)*(x1-x0))<sign = MP_ZPOS; + +LBL_T: + mp_clear_multi (&t1, &t2, NULL); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_lcm.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_lshd.c b/dep/StormLib/src/libtommath/bn_mp_lshd.c new file mode 100644 index 000000000..ffb0defd0 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_lshd.c @@ -0,0 +1,67 @@ +#include "tommath.h" +#ifdef BN_MP_LSHD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* shift left a certain amount of digits */ +int mp_lshd (mp_int * a, int b) +{ + int x, res; + + /* if its less than zero return */ + if (b <= 0) { + return MP_OKAY; + } + + /* grow to fit the new digits */ + if (a->alloc < a->used + b) { + if ((res = mp_grow (a, a->used + b)) != MP_OKAY) { + return res; + } + } + + { + register mp_digit *top, *bottom; + + /* increment the used by the shift amount then copy upwards */ + a->used += b; + + /* top */ + top = a->dp + a->used - 1; + + /* base */ + bottom = a->dp + a->used - 1 - b; + + /* much like mp_rshd this is implemented using a sliding window + * except the window goes the otherway around. Copying from + * the bottom to the top. see bn_mp_rshd.c for more info. + */ + for (x = a->used - 1; x >= b; x--) { + *top-- = *bottom--; + } + + /* zero the lower digits */ + top = a->dp; + for (x = 0; x < b; x++) { + *top++ = 0; + } + } + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_lshd.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mod.c b/dep/StormLib/src/libtommath/bn_mp_mod.c new file mode 100644 index 000000000..b24c71f9d --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mod.c @@ -0,0 +1,48 @@ +#include "tommath.h" +#ifdef BN_MP_MOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* c = a mod b, 0 <= c < b */ +int +mp_mod (mp_int * a, mp_int * b, mp_int * c) +{ + mp_int t; + int res; + + if ((res = mp_init (&t)) != MP_OKAY) { + return res; + } + + if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) { + mp_clear (&t); + return res; + } + + if (t.sign != b->sign) { + res = mp_add (b, &t, c); + } else { + res = MP_OKAY; + mp_exch (&t, c); + } + + mp_clear (&t); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mod_2d.c b/dep/StormLib/src/libtommath/bn_mp_mod_2d.c new file mode 100644 index 000000000..a54a02426 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mod_2d.c @@ -0,0 +1,55 @@ +#include "tommath.h" +#ifdef BN_MP_MOD_2D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* calc a value mod 2**b */ +int +mp_mod_2d (mp_int * a, int b, mp_int * c) +{ + int x, res; + + /* if b is <= 0 then zero the int */ + if (b <= 0) { + mp_zero (c); + return MP_OKAY; + } + + /* if the modulus is larger than the value than return */ + if (b >= (int) (a->used * DIGIT_BIT)) { + res = mp_copy (a, c); + return res; + } + + /* copy */ + if ((res = mp_copy (a, c)) != MP_OKAY) { + return res; + } + + /* zero digits above the last digit of the modulus */ + for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) { + c->dp[x] = 0; + } + /* clear the digit that is not completely outside/inside the modulus */ + c->dp[b / DIGIT_BIT] &= + (mp_digit) ((((mp_digit) 1) << (((mp_digit) b) % DIGIT_BIT)) - ((mp_digit) 1)); + mp_clamp (c); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mod_2d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mod_d.c b/dep/StormLib/src/libtommath/bn_mp_mod_d.c new file mode 100644 index 000000000..59886e773 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mod_d.c @@ -0,0 +1,27 @@ +#include "tommath.h" +#ifdef BN_MP_MOD_D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +int +mp_mod_d (mp_int * a, mp_digit b, mp_digit * c) +{ + return mp_div_d(a, b, NULL, c); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mod_d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_montgomery_calc_normalization.c b/dep/StormLib/src/libtommath/bn_mp_montgomery_calc_normalization.c new file mode 100644 index 000000000..fdefcbd99 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_montgomery_calc_normalization.c @@ -0,0 +1,59 @@ +#include "tommath.h" +#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* + * shifts with subtractions when the result is greater than b. + * + * The method is slightly modified to shift B unconditionally upto just under + * the leading bit of b. This saves alot of multiple precision shifting. + */ +int mp_montgomery_calc_normalization (mp_int * a, mp_int * b) +{ + int x, bits, res; + + /* how many bits of last digit does b use */ + bits = mp_count_bits (b) % DIGIT_BIT; + + if (b->used > 1) { + if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) { + return res; + } + } else { + mp_set(a, 1); + bits = 1; + } + + + /* now compute C = A * B mod b */ + for (x = bits - 1; x < (int)DIGIT_BIT; x++) { + if ((res = mp_mul_2 (a, a)) != MP_OKAY) { + return res; + } + if (mp_cmp_mag (a, b) != MP_LT) { + if ((res = s_mp_sub (a, b, a)) != MP_OKAY) { + return res; + } + } + } + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_calc_normalization.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_montgomery_reduce.c b/dep/StormLib/src/libtommath/bn_mp_montgomery_reduce.c new file mode 100644 index 000000000..173848e0a --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_montgomery_reduce.c @@ -0,0 +1,118 @@ +#include "tommath.h" +#ifdef BN_MP_MONTGOMERY_REDUCE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* computes xR**-1 == x (mod N) via Montgomery Reduction */ +int +mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) +{ + int ix, res, digs; + mp_digit mu; + + /* can the fast reduction [comba] method be used? + * + * Note that unlike in mul you're safely allowed *less* + * than the available columns [255 per default] since carries + * are fixed up in the inner loop. + */ + digs = n->used * 2 + 1; + if ((digs < MP_WARRAY) && + n->used < + (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { + return fast_mp_montgomery_reduce (x, n, rho); + } + + /* grow the input as required */ + if (x->alloc < digs) { + if ((res = mp_grow (x, digs)) != MP_OKAY) { + return res; + } + } + x->used = digs; + + for (ix = 0; ix < n->used; ix++) { + /* mu = ai * rho mod b + * + * The value of rho must be precalculated via + * montgomery_setup() such that + * it equals -1/n0 mod b this allows the + * following inner loop to reduce the + * input one digit at a time + */ + mu = (mp_digit) (((mp_word)x->dp[ix]) * ((mp_word)rho) & MP_MASK); + + /* a = a + mu * m * b**i */ + { + register int iy; + register mp_digit *tmpn, *tmpx, u; + register mp_word r; + + /* alias for digits of the modulus */ + tmpn = n->dp; + + /* alias for the digits of x [the input] */ + tmpx = x->dp + ix; + + /* set the carry to zero */ + u = 0; + + /* Multiply and add in place */ + for (iy = 0; iy < n->used; iy++) { + /* compute product and sum */ + r = ((mp_word)mu) * ((mp_word)*tmpn++) + + ((mp_word) u) + ((mp_word) * tmpx); + + /* get carry */ + u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); + + /* fix digit */ + *tmpx++ = (mp_digit)(r & ((mp_word) MP_MASK)); + } + /* At this point the ix'th digit of x should be zero */ + + + /* propagate carries upwards as required*/ + while (u) { + *tmpx += u; + u = *tmpx >> DIGIT_BIT; + *tmpx++ &= MP_MASK; + } + } + } + + /* at this point the n.used'th least + * significant digits of x are all zero + * which means we can shift x to the + * right by n.used digits and the + * residue is unchanged. + */ + + /* x = x/b**n.used */ + mp_clamp(x); + mp_rshd (x, n->used); + + /* if x >= n then x = x - n */ + if (mp_cmp_mag (x, n) != MP_LT) { + return s_mp_sub (x, n, x); + } + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_reduce.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_montgomery_setup.c b/dep/StormLib/src/libtommath/bn_mp_montgomery_setup.c new file mode 100644 index 000000000..6f277320e --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_montgomery_setup.c @@ -0,0 +1,59 @@ +#include "tommath.h" +#ifdef BN_MP_MONTGOMERY_SETUP_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* setups the montgomery reduction stuff */ +int +mp_montgomery_setup (mp_int * n, mp_digit * rho) +{ + mp_digit x, b; + +/* fast inversion mod 2**k + * + * Based on the fact that + * + * XA = 1 (mod 2**n) => (X(2-XA)) A = 1 (mod 2**2n) + * => 2*X*A - X*X*A*A = 1 + * => 2*(1) - (1) = 1 + */ + b = n->dp[0]; + + if ((b & 1) == 0) { + return MP_VAL; + } + + x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */ + x *= 2 - b * x; /* here x*a==1 mod 2**8 */ +#if !defined(MP_8BIT) + x *= 2 - b * x; /* here x*a==1 mod 2**16 */ +#endif +#if defined(MP_64BIT) || !(defined(MP_8BIT) || defined(MP_16BIT)) + x *= 2 - b * x; /* here x*a==1 mod 2**32 */ +#endif +#ifdef MP_64BIT + x *= 2 - b * x; /* here x*a==1 mod 2**64 */ +#endif + + /* rho = -1/m mod b */ + *rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_setup.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mul.c b/dep/StormLib/src/libtommath/bn_mp_mul.c new file mode 100644 index 000000000..a1315dac3 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mul.c @@ -0,0 +1,66 @@ +#include "tommath.h" +#ifdef BN_MP_MUL_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* high level multiplication (handles sign) */ +int mp_mul (mp_int * a, mp_int * b, mp_int * c) +{ + int res, neg; + neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG; + + /* use Toom-Cook? */ +#ifdef BN_MP_TOOM_MUL_C + if (MIN (a->used, b->used) >= TOOM_MUL_CUTOFF) { + res = mp_toom_mul(a, b, c); + } else +#endif +#ifdef BN_MP_KARATSUBA_MUL_C + /* use Karatsuba? */ + if (MIN (a->used, b->used) >= KARATSUBA_MUL_CUTOFF) { + res = mp_karatsuba_mul (a, b, c); + } else +#endif + { + /* can we use the fast multiplier? + * + * The fast multiplier can be used if the output will + * have less than MP_WARRAY digits and the number of + * digits won't affect carry propagation + */ + int digs = a->used + b->used + 1; + +#ifdef BN_FAST_S_MP_MUL_DIGS_C + if ((digs < MP_WARRAY) && + MIN(a->used, b->used) <= + (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { + res = fast_s_mp_mul_digs (a, b, c, digs); + } else +#endif +#ifdef BN_S_MP_MUL_DIGS_C + res = s_mp_mul (a, b, c); /* uses s_mp_mul_digs */ +#else + res = MP_VAL; +#endif + + } + c->sign = (c->used > 0) ? neg : MP_ZPOS; + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mul_2.c b/dep/StormLib/src/libtommath/bn_mp_mul_2.c new file mode 100644 index 000000000..3315744f1 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mul_2.c @@ -0,0 +1,82 @@ +#include "tommath.h" +#ifdef BN_MP_MUL_2_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* b = a*2 */ +int mp_mul_2(mp_int * a, mp_int * b) +{ + int x, res, oldused; + + /* grow to accomodate result */ + if (b->alloc < a->used + 1) { + if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) { + return res; + } + } + + oldused = b->used; + b->used = a->used; + + { + register mp_digit r, rr, *tmpa, *tmpb; + + /* alias for source */ + tmpa = a->dp; + + /* alias for dest */ + tmpb = b->dp; + + /* carry */ + r = 0; + for (x = 0; x < a->used; x++) { + + /* get what will be the *next* carry bit from the + * MSB of the current digit + */ + rr = *tmpa >> ((mp_digit)(DIGIT_BIT - 1)); + + /* now shift up this digit, add in the carry [from the previous] */ + *tmpb++ = ((*tmpa++ << ((mp_digit)1)) | r) & MP_MASK; + + /* copy the carry that would be from the source + * digit into the next iteration + */ + r = rr; + } + + /* new leading digit? */ + if (r != 0) { + /* add a MSB which is always 1 at this point */ + *tmpb = 1; + ++(b->used); + } + + /* now zero any excess digits on the destination + * that we didn't write to + */ + tmpb = b->dp + b->used; + for (x = b->used; x < oldused; x++) { + *tmpb++ = 0; + } + } + b->sign = a->sign; + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mul_2d.c b/dep/StormLib/src/libtommath/bn_mp_mul_2d.c new file mode 100644 index 000000000..c636c1798 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mul_2d.c @@ -0,0 +1,85 @@ +#include "tommath.h" +#ifdef BN_MP_MUL_2D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* shift left by a certain bit count */ +int mp_mul_2d (mp_int * a, int b, mp_int * c) +{ + mp_digit d; + int res; + + /* copy */ + if (a != c) { + if ((res = mp_copy (a, c)) != MP_OKAY) { + return res; + } + } + + if (c->alloc < (int)(c->used + b/DIGIT_BIT + 1)) { + if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) { + return res; + } + } + + /* shift by as many digits in the bit count */ + if (b >= (int)DIGIT_BIT) { + if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) { + return res; + } + } + + /* shift any bit count < DIGIT_BIT */ + d = (mp_digit) (b % DIGIT_BIT); + if (d != 0) { + register mp_digit *tmpc, shift, mask, r, rr; + register int x; + + /* bitmask for carries */ + mask = (((mp_digit)1) << d) - 1; + + /* shift for msbs */ + shift = DIGIT_BIT - d; + + /* alias */ + tmpc = c->dp; + + /* carry */ + r = 0; + for (x = 0; x < c->used; x++) { + /* get the higher bits of the current word */ + rr = (*tmpc >> shift) & mask; + + /* shift the current word and OR in the carry */ + *tmpc = ((*tmpc << d) | r) & MP_MASK; + ++tmpc; + + /* set the carry to the carry bits of the current word */ + r = rr; + } + + /* set final carry */ + if (r != 0) { + c->dp[(c->used)++] = r; + } + } + mp_clamp (c); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mul_d.c b/dep/StormLib/src/libtommath/bn_mp_mul_d.c new file mode 100644 index 000000000..a36a76bba --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mul_d.c @@ -0,0 +1,79 @@ +#include "tommath.h" +#ifdef BN_MP_MUL_D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* multiply by a digit */ +int +mp_mul_d (mp_int * a, mp_digit b, mp_int * c) +{ + mp_digit u, *tmpa, *tmpc; + mp_word r; + int ix, res, olduse; + + /* make sure c is big enough to hold a*b */ + if (c->alloc < a->used + 1) { + if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) { + return res; + } + } + + /* get the original destinations used count */ + olduse = c->used; + + /* set the sign */ + c->sign = a->sign; + + /* alias for a->dp [source] */ + tmpa = a->dp; + + /* alias for c->dp [dest] */ + tmpc = c->dp; + + /* zero carry */ + u = 0; + + /* compute columns */ + for (ix = 0; ix < a->used; ix++) { + /* compute product and carry sum for this term */ + r = ((mp_word) u) + ((mp_word)*tmpa++) * ((mp_word)b); + + /* mask off higher bits to get a single digit */ + *tmpc++ = (mp_digit) (r & ((mp_word) MP_MASK)); + + /* send carry into next iteration */ + u = (mp_digit) (r >> ((mp_word) DIGIT_BIT)); + } + + /* store final carry [if any] and increment ix offset */ + *tmpc++ = u; + ++ix; + + /* now zero digits above the top */ + while (ix++ < olduse) { + *tmpc++ = 0; + } + + /* set used count */ + c->used = a->used + 1; + mp_clamp(c); + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_mulmod.c b/dep/StormLib/src/libtommath/bn_mp_mulmod.c new file mode 100644 index 000000000..8ec98bbdd --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_mulmod.c @@ -0,0 +1,40 @@ +#include "tommath.h" +#ifdef BN_MP_MULMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* d = a * b (mod c) */ +int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) +{ + int res; + mp_int t; + + if ((res = mp_init (&t)) != MP_OKAY) { + return res; + } + + if ((res = mp_mul (a, b, &t)) != MP_OKAY) { + mp_clear (&t); + return res; + } + res = mp_mod (&t, c, d); + mp_clear (&t); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mulmod.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_n_root.c b/dep/StormLib/src/libtommath/bn_mp_n_root.c new file mode 100644 index 000000000..f188f5255 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_n_root.c @@ -0,0 +1,132 @@ +#include "tommath.h" +#ifdef BN_MP_N_ROOT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* find the n'th root of an integer + * + * Result found such that (c)**b <= a and (c+1)**b > a + * + * This algorithm uses Newton's approximation + * x[i+1] = x[i] - f(x[i])/f'(x[i]) + * which will find the root in log(N) time where + * each step involves a fair bit. This is not meant to + * find huge roots [square and cube, etc]. + */ +int mp_n_root (mp_int * a, mp_digit b, mp_int * c) +{ + mp_int t1, t2, t3; + int res, neg; + + /* input must be positive if b is even */ + if ((b & 1) == 0 && a->sign == MP_NEG) { + return MP_VAL; + } + + if ((res = mp_init (&t1)) != MP_OKAY) { + return res; + } + + if ((res = mp_init (&t2)) != MP_OKAY) { + goto LBL_T1; + } + + if ((res = mp_init (&t3)) != MP_OKAY) { + goto LBL_T2; + } + + /* if a is negative fudge the sign but keep track */ + neg = a->sign; + a->sign = MP_ZPOS; + + /* t2 = 2 */ + mp_set (&t2, 2); + + do { + /* t1 = t2 */ + if ((res = mp_copy (&t2, &t1)) != MP_OKAY) { + goto LBL_T3; + } + + /* t2 = t1 - ((t1**b - a) / (b * t1**(b-1))) */ + + /* t3 = t1**(b-1) */ + if ((res = mp_expt_d (&t1, b - 1, &t3)) != MP_OKAY) { + goto LBL_T3; + } + + /* numerator */ + /* t2 = t1**b */ + if ((res = mp_mul (&t3, &t1, &t2)) != MP_OKAY) { + goto LBL_T3; + } + + /* t2 = t1**b - a */ + if ((res = mp_sub (&t2, a, &t2)) != MP_OKAY) { + goto LBL_T3; + } + + /* denominator */ + /* t3 = t1**(b-1) * b */ + if ((res = mp_mul_d (&t3, b, &t3)) != MP_OKAY) { + goto LBL_T3; + } + + /* t3 = (t1**b - a)/(b * t1**(b-1)) */ + if ((res = mp_div (&t2, &t3, &t3, NULL)) != MP_OKAY) { + goto LBL_T3; + } + + if ((res = mp_sub (&t1, &t3, &t2)) != MP_OKAY) { + goto LBL_T3; + } + } while (mp_cmp (&t1, &t2) != MP_EQ); + + /* result can be off by a few so check */ + for (;;) { + if ((res = mp_expt_d (&t1, b, &t2)) != MP_OKAY) { + goto LBL_T3; + } + + if (mp_cmp (&t2, a) == MP_GT) { + if ((res = mp_sub_d (&t1, 1, &t1)) != MP_OKAY) { + goto LBL_T3; + } + } else { + break; + } + } + + /* reset the sign of a first */ + a->sign = neg; + + /* set the result */ + mp_exch (&t1, c); + + /* set the sign of the result */ + c->sign = neg; + + res = MP_OKAY; + +LBL_T3:mp_clear (&t3); +LBL_T2:mp_clear (&t2); +LBL_T1:mp_clear (&t1); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_n_root.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_neg.c b/dep/StormLib/src/libtommath/bn_mp_neg.c new file mode 100644 index 000000000..87a8b5004 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_neg.c @@ -0,0 +1,40 @@ +#include "tommath.h" +#ifdef BN_MP_NEG_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* b = -a */ +int mp_neg (mp_int * a, mp_int * b) +{ + int res; + if (a != b) { + if ((res = mp_copy (a, b)) != MP_OKAY) { + return res; + } + } + + if (mp_iszero(b) != MP_YES) { + b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS; + } else { + b->sign = MP_ZPOS; + } + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_neg.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_or.c b/dep/StormLib/src/libtommath/bn_mp_or.c new file mode 100644 index 000000000..12601eaf7 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_or.c @@ -0,0 +1,50 @@ +#include "tommath.h" +#ifdef BN_MP_OR_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* OR two ints together */ +int mp_or (mp_int * a, mp_int * b, mp_int * c) +{ + int res, ix, px; + mp_int t, *x; + + if (a->used > b->used) { + if ((res = mp_init_copy (&t, a)) != MP_OKAY) { + return res; + } + px = b->used; + x = b; + } else { + if ((res = mp_init_copy (&t, b)) != MP_OKAY) { + return res; + } + px = a->used; + x = a; + } + + for (ix = 0; ix < px; ix++) { + t.dp[ix] |= x->dp[ix]; + } + mp_clamp (&t); + mp_exch (c, &t); + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_or.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_prime_fermat.c b/dep/StormLib/src/libtommath/bn_mp_prime_fermat.c new file mode 100644 index 000000000..297e13c79 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_prime_fermat.c @@ -0,0 +1,62 @@ +#include "tommath.h" +#ifdef BN_MP_PRIME_FERMAT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* performs one Fermat test. + * + * If "a" were prime then b**a == b (mod a) since the order of + * the multiplicative sub-group would be phi(a) = a-1. That means + * it would be the same as b**(a mod (a-1)) == b**1 == b (mod a). + * + * Sets result to 1 if the congruence holds, or zero otherwise. + */ +int mp_prime_fermat (mp_int * a, mp_int * b, int *result) +{ + mp_int t; + int err; + + /* default to composite */ + *result = MP_NO; + + /* ensure b > 1 */ + if (mp_cmp_d(b, 1) != MP_GT) { + return MP_VAL; + } + + /* init t */ + if ((err = mp_init (&t)) != MP_OKAY) { + return err; + } + + /* compute t = b**a mod a */ + if ((err = mp_exptmod (b, a, a, &t)) != MP_OKAY) { + goto LBL_T; + } + + /* is it equal to b? */ + if (mp_cmp (&t, b) == MP_EQ) { + *result = MP_YES; + } + + err = MP_OKAY; +LBL_T:mp_clear (&t); + return err; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_fermat.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_prime_is_divisible.c b/dep/StormLib/src/libtommath/bn_mp_prime_is_divisible.c new file mode 100644 index 000000000..0ae649835 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_prime_is_divisible.c @@ -0,0 +1,50 @@ +#include "tommath.h" +#ifdef BN_MP_PRIME_IS_DIVISIBLE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines if an integers is divisible by one + * of the first PRIME_SIZE primes or not + * + * sets result to 0 if not, 1 if yes + */ +int mp_prime_is_divisible (mp_int * a, int *result) +{ + int err, ix; + mp_digit res; + + /* default to not */ + *result = MP_NO; + + for (ix = 0; ix < PRIME_SIZE; ix++) { + /* what is a mod LBL_prime_tab[ix] */ + if ((err = mp_mod_d (a, ltm_prime_tab[ix], &res)) != MP_OKAY) { + return err; + } + + /* is the residue zero? */ + if (res == 0) { + *result = MP_YES; + return MP_OKAY; + } + } + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_divisible.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_prime_is_prime.c b/dep/StormLib/src/libtommath/bn_mp_prime_is_prime.c new file mode 100644 index 000000000..0e1e94bad --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_prime_is_prime.c @@ -0,0 +1,83 @@ +#include "tommath.h" +#ifdef BN_MP_PRIME_IS_PRIME_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* performs a variable number of rounds of Miller-Rabin + * + * Probability of error after t rounds is no more than + + * + * Sets result to 1 if probably prime, 0 otherwise + */ +int mp_prime_is_prime (mp_int * a, int t, int *result) +{ + mp_int b; + int ix, err, res; + + /* default to no */ + *result = MP_NO; + + /* valid value of t? */ + if (t <= 0 || t > PRIME_SIZE) { + return MP_VAL; + } + + /* is the input equal to one of the primes in the table? */ + for (ix = 0; ix < PRIME_SIZE; ix++) { + if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) { + *result = 1; + return MP_OKAY; + } + } + + /* first perform trial division */ + if ((err = mp_prime_is_divisible (a, &res)) != MP_OKAY) { + return err; + } + + /* return if it was trivially divisible */ + if (res == MP_YES) { + return MP_OKAY; + } + + /* now perform the miller-rabin rounds */ + if ((err = mp_init (&b)) != MP_OKAY) { + return err; + } + + for (ix = 0; ix < t; ix++) { + /* set the prime */ + mp_set (&b, ltm_prime_tab[ix]); + + if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) { + goto LBL_B; + } + + if (res == MP_NO) { + goto LBL_B; + } + } + + /* passed the test */ + *result = MP_YES; +LBL_B:mp_clear (&b); + return err; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_prime.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_prime_miller_rabin.c b/dep/StormLib/src/libtommath/bn_mp_prime_miller_rabin.c new file mode 100644 index 000000000..47385bc81 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_prime_miller_rabin.c @@ -0,0 +1,103 @@ +#include "tommath.h" +#ifdef BN_MP_PRIME_MILLER_RABIN_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Miller-Rabin test of "a" to the base of "b" as described in + * HAC pp. 139 Algorithm 4.24 + * + * Sets result to 0 if definitely composite or 1 if probably prime. + * Randomly the chance of error is no more than 1/4 and often + * very much lower. + */ +int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result) +{ + mp_int n1, y, r; + int s, j, err; + + /* default */ + *result = MP_NO; + + /* ensure b > 1 */ + if (mp_cmp_d(b, 1) != MP_GT) { + return MP_VAL; + } + + /* get n1 = a - 1 */ + if ((err = mp_init_copy (&n1, a)) != MP_OKAY) { + return err; + } + if ((err = mp_sub_d (&n1, 1, &n1)) != MP_OKAY) { + goto LBL_N1; + } + + /* set 2**s * r = n1 */ + if ((err = mp_init_copy (&r, &n1)) != MP_OKAY) { + goto LBL_N1; + } + + /* count the number of least significant bits + * which are zero + */ + s = mp_cnt_lsb(&r); + + /* now divide n - 1 by 2**s */ + if ((err = mp_div_2d (&r, s, &r, NULL)) != MP_OKAY) { + goto LBL_R; + } + + /* compute y = b**r mod a */ + if ((err = mp_init (&y)) != MP_OKAY) { + goto LBL_R; + } + if ((err = mp_exptmod (b, &r, a, &y)) != MP_OKAY) { + goto LBL_Y; + } + + /* if y != 1 and y != n1 do */ + if (mp_cmp_d (&y, 1) != MP_EQ && mp_cmp (&y, &n1) != MP_EQ) { + j = 1; + /* while j <= s-1 and y != n1 */ + while ((j <= (s - 1)) && mp_cmp (&y, &n1) != MP_EQ) { + if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) { + goto LBL_Y; + } + + /* if y == 1 then composite */ + if (mp_cmp_d (&y, 1) == MP_EQ) { + goto LBL_Y; + } + + ++j; + } + + /* if y != n1 then composite */ + if (mp_cmp (&y, &n1) != MP_EQ) { + goto LBL_Y; + } + } + + /* probably prime now */ + *result = MP_YES; +LBL_Y:mp_clear (&y); +LBL_R:mp_clear (&r); +LBL_N1:mp_clear (&n1); + return err; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_miller_rabin.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_prime_next_prime.c b/dep/StormLib/src/libtommath/bn_mp_prime_next_prime.c new file mode 100644 index 000000000..833992bac --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_prime_next_prime.c @@ -0,0 +1,170 @@ +#include "tommath.h" +#ifdef BN_MP_PRIME_NEXT_PRIME_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* finds the next prime after the number "a" using "t" trials + * of Miller-Rabin. + * + * bbs_style = 1 means the prime must be congruent to 3 mod 4 + */ +int mp_prime_next_prime(mp_int *a, int t, int bbs_style) +{ + int err, res, x, y; + mp_digit res_tab[PRIME_SIZE], step, kstep; + mp_int b; + + /* ensure t is valid */ + if (t <= 0 || t > PRIME_SIZE) { + return MP_VAL; + } + + /* force positive */ + a->sign = MP_ZPOS; + + /* simple algo if a is less than the largest prime in the table */ + if (mp_cmp_d(a, ltm_prime_tab[PRIME_SIZE-1]) == MP_LT) { + /* find which prime it is bigger than */ + for (x = PRIME_SIZE - 2; x >= 0; x--) { + if (mp_cmp_d(a, ltm_prime_tab[x]) != MP_LT) { + if (bbs_style == 1) { + /* ok we found a prime smaller or + * equal [so the next is larger] + * + * however, the prime must be + * congruent to 3 mod 4 + */ + if ((ltm_prime_tab[x + 1] & 3) != 3) { + /* scan upwards for a prime congruent to 3 mod 4 */ + for (y = x + 1; y < PRIME_SIZE; y++) { + if ((ltm_prime_tab[y] & 3) == 3) { + mp_set(a, ltm_prime_tab[y]); + return MP_OKAY; + } + } + } + } else { + mp_set(a, ltm_prime_tab[x + 1]); + return MP_OKAY; + } + } + } + /* at this point a maybe 1 */ + if (mp_cmp_d(a, 1) == MP_EQ) { + mp_set(a, 2); + return MP_OKAY; + } + /* fall through to the sieve */ + } + + /* generate a prime congruent to 3 mod 4 or 1/3 mod 4? */ + if (bbs_style == 1) { + kstep = 4; + } else { + kstep = 2; + } + + /* at this point we will use a combination of a sieve and Miller-Rabin */ + + if (bbs_style == 1) { + /* if a mod 4 != 3 subtract the correct value to make it so */ + if ((a->dp[0] & 3) != 3) { + if ((err = mp_sub_d(a, (a->dp[0] & 3) + 1, a)) != MP_OKAY) { return err; }; + } + } else { + if (mp_iseven(a) == 1) { + /* force odd */ + if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { + return err; + } + } + } + + /* generate the restable */ + for (x = 1; x < PRIME_SIZE; x++) { + if ((err = mp_mod_d(a, ltm_prime_tab[x], res_tab + x)) != MP_OKAY) { + return err; + } + } + + /* init temp used for Miller-Rabin Testing */ + if ((err = mp_init(&b)) != MP_OKAY) { + return err; + } + + for (;;) { + /* skip to the next non-trivially divisible candidate */ + step = 0; + do { + /* y == 1 if any residue was zero [e.g. cannot be prime] */ + y = 0; + + /* increase step to next candidate */ + step += kstep; + + /* compute the new residue without using division */ + for (x = 1; x < PRIME_SIZE; x++) { + /* add the step to each residue */ + res_tab[x] += kstep; + + /* subtract the modulus [instead of using division] */ + if (res_tab[x] >= ltm_prime_tab[x]) { + res_tab[x] -= ltm_prime_tab[x]; + } + + /* set flag if zero */ + if (res_tab[x] == 0) { + y = 1; + } + } + } while (y == 1 && step < ((((mp_digit)1)<= ((((mp_digit)1)< size) { + return (x == 0) ? sizes[0].t : sizes[x - 1].t; + } + } + return sizes[x-1].t + 1; +} + + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_rabin_miller_trials.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_prime_random_ex.c b/dep/StormLib/src/libtommath/bn_mp_prime_random_ex.c new file mode 100644 index 000000000..4eec3f69e --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_prime_random_ex.c @@ -0,0 +1,125 @@ +#include "tommath.h" +#ifdef BN_MP_PRIME_RANDOM_EX_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* makes a truly random prime of a given size (bits), + * + * Flags are as follows: + * + * LTM_PRIME_BBS - make prime congruent to 3 mod 4 + * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS) + * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero + * LTM_PRIME_2MSB_ON - make the 2nd highest bit one + * + * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can + * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself + * so it can be NULL + * + */ + +/* This is possibly the mother of all prime generation functions, muahahahahaha! */ +int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat) +{ + unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb; + int res, err, bsize, maskOR_msb_offset; + + /* sanity check the input */ + if (size <= 1 || t <= 0) { + return MP_VAL; + } + + /* LTM_PRIME_SAFE implies LTM_PRIME_BBS */ + if (flags & LTM_PRIME_SAFE) { + flags |= LTM_PRIME_BBS; + } + + /* calc the byte size */ + bsize = (size>>3) + ((size&7)?1:0); + + /* we need a buffer of bsize bytes */ + tmp = OPT_CAST(unsigned char) XMALLOC(bsize); + if (tmp == NULL) { + return MP_MEM; + } + + /* calc the maskAND value for the MSbyte*/ + maskAND = ((size&7) == 0) ? 0xFF : (0xFF >> (8 - (size & 7))); + + /* calc the maskOR_msb */ + maskOR_msb = 0; + maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0; + if (flags & LTM_PRIME_2MSB_ON) { + maskOR_msb |= 0x80 >> ((9 - size) & 7); + } + + /* get the maskOR_lsb */ + maskOR_lsb = 1; + if (flags & LTM_PRIME_BBS) { + maskOR_lsb |= 3; + } + + do { + /* read the bytes */ + if (cb(tmp, bsize, dat) != bsize) { + err = MP_VAL; + goto error; + } + + /* work over the MSbyte */ + tmp[0] &= maskAND; + tmp[0] |= 1 << ((size - 1) & 7); + + /* mix in the maskORs */ + tmp[maskOR_msb_offset] |= maskOR_msb; + tmp[bsize-1] |= maskOR_lsb; + + /* read it in */ + if ((err = mp_read_unsigned_bin(a, tmp, bsize)) != MP_OKAY) { goto error; } + + /* is it prime? */ + if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; } + if (res == MP_NO) { + continue; + } + + if (flags & LTM_PRIME_SAFE) { + /* see if (a-1)/2 is prime */ + if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; } + if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; } + + /* is it prime? */ + if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; } + } + } while (res == MP_NO); + + if (flags & LTM_PRIME_SAFE) { + /* restore a to the original value */ + if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; } + if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; } + } + + err = MP_OKAY; +error: + XFREE(tmp); + return err; +} + + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_random_ex.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_radix_size.c b/dep/StormLib/src/libtommath/bn_mp_radix_size.c new file mode 100644 index 000000000..2378f1fc1 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_radix_size.c @@ -0,0 +1,78 @@ +#include "tommath.h" +#ifdef BN_MP_RADIX_SIZE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* returns size of ASCII reprensentation */ +int mp_radix_size (mp_int * a, int radix, int *size) +{ + int res, digs; + mp_int t; + mp_digit d; + + *size = 0; + + /* special case for binary */ + if (radix == 2) { + *size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1; + return MP_OKAY; + } + + /* make sure the radix is in range */ + if (radix < 2 || radix > 64) { + return MP_VAL; + } + + if (mp_iszero(a) == MP_YES) { + *size = 2; + return MP_OKAY; + } + + /* digs is the digit count */ + digs = 0; + + /* if it's negative add one for the sign */ + if (a->sign == MP_NEG) { + ++digs; + } + + /* init a copy of the input */ + if ((res = mp_init_copy (&t, a)) != MP_OKAY) { + return res; + } + + /* force temp to positive */ + t.sign = MP_ZPOS; + + /* fetch out all of the digits */ + while (mp_iszero (&t) == MP_NO) { + if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { + mp_clear (&t); + return res; + } + ++digs; + } + mp_clear (&t); + + /* return digs + 1, the 1 is for the NULL byte that would be required. */ + *size = digs + 1; + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_radix_size.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_radix_smap.c b/dep/StormLib/src/libtommath/bn_mp_radix_smap.c new file mode 100644 index 000000000..5cbe9520b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_radix_smap.c @@ -0,0 +1,24 @@ +#include "tommath.h" +#ifdef BN_MP_RADIX_SMAP_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* chars used in radix conversions */ +const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_radix_smap.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_rand.c b/dep/StormLib/src/libtommath/bn_mp_rand.c new file mode 100644 index 000000000..e1241785e --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_rand.c @@ -0,0 +1,55 @@ +#include "tommath.h" +#ifdef BN_MP_RAND_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* makes a pseudo-random int of a given size */ +int +mp_rand (mp_int * a, int digits) +{ + int res; + mp_digit d; + + mp_zero (a); + if (digits <= 0) { + return MP_OKAY; + } + + /* first place a random non-zero digit */ + do { + d = ((mp_digit) abs (rand ())) & MP_MASK; + } while (d == 0); + + if ((res = mp_add_d (a, d, a)) != MP_OKAY) { + return res; + } + + while (--digits > 0) { + if ((res = mp_lshd (a, 1)) != MP_OKAY) { + return res; + } + + if ((res = mp_add_d (a, ((mp_digit) abs (rand ())), a)) != MP_OKAY) { + return res; + } + } + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_rand.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_read_radix.c b/dep/StormLib/src/libtommath/bn_mp_read_radix.c new file mode 100644 index 000000000..6869668fb --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_read_radix.c @@ -0,0 +1,85 @@ +#include "tommath.h" +#ifdef BN_MP_READ_RADIX_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* read a string [ASCII] in a given radix */ +int mp_read_radix (mp_int * a, const char *str, int radix) +{ + int y, res, neg; + char ch; + + /* zero the digit bignum */ + mp_zero(a); + + /* make sure the radix is ok */ + if (radix < 2 || radix > 64) { + return MP_VAL; + } + + /* if the leading digit is a + * minus set the sign to negative. + */ + if (*str == '-') { + ++str; + neg = MP_NEG; + } else { + neg = MP_ZPOS; + } + + /* set the integer to the default of zero */ + mp_zero (a); + + /* process each digit of the string */ + while (*str) { + /* if the radix < 36 the conversion is case insensitive + * this allows numbers like 1AB and 1ab to represent the same value + * [e.g. in hex] + */ + ch = (char) ((radix < 36) ? toupper (*str) : *str); + for (y = 0; y < 64; y++) { + if (ch == mp_s_rmap[y]) { + break; + } + } + + /* if the char was found in the map + * and is less than the given radix add it + * to the number, otherwise exit the loop. + */ + if (y < radix) { + if ((res = mp_mul_d (a, (mp_digit) radix, a)) != MP_OKAY) { + return res; + } + if ((res = mp_add_d (a, (mp_digit) y, a)) != MP_OKAY) { + return res; + } + } else { + break; + } + ++str; + } + + /* set the sign only if a != 0 */ + if (mp_iszero(a) != 1) { + a->sign = neg; + } + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_read_radix.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_read_signed_bin.c b/dep/StormLib/src/libtommath/bn_mp_read_signed_bin.c new file mode 100644 index 000000000..e9a780c28 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_read_signed_bin.c @@ -0,0 +1,41 @@ +#include "tommath.h" +#ifdef BN_MP_READ_SIGNED_BIN_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* read signed bin, big endian, first byte is 0==positive or 1==negative */ +int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c) +{ + int res; + + /* read magnitude */ + if ((res = mp_read_unsigned_bin (a, b + 1, c - 1)) != MP_OKAY) { + return res; + } + + /* first byte is 0 for positive, non-zero for negative */ + if (b[0] == 0) { + a->sign = MP_ZPOS; + } else { + a->sign = MP_NEG; + } + + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_read_signed_bin.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_read_unsigned_bin.c b/dep/StormLib/src/libtommath/bn_mp_read_unsigned_bin.c new file mode 100644 index 000000000..7d3537041 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_read_unsigned_bin.c @@ -0,0 +1,55 @@ +#include "tommath.h" +#ifdef BN_MP_READ_UNSIGNED_BIN_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* reads a unsigned char array, assumes the msb is stored first [big endian] */ +int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c) +{ + int res; + + /* make sure there are at least two digits */ + if (a->alloc < 2) { + if ((res = mp_grow(a, 2)) != MP_OKAY) { + return res; + } + } + + /* zero the int */ + mp_zero (a); + + /* read the bytes in */ + while (c-- > 0) { + if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) { + return res; + } + +#ifndef MP_8BIT + a->dp[0] |= *b++; + a->used += 1; +#else + a->dp[0] = (*b & MP_MASK); + a->dp[1] |= ((*b++ >> 7U) & 1); + a->used += 2; +#endif + } + mp_clamp (a); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_read_unsigned_bin.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce.c b/dep/StormLib/src/libtommath/bn_mp_reduce.c new file mode 100644 index 000000000..3a6bb5aca --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce.c @@ -0,0 +1,100 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* reduces x mod m, assumes 0 < x < m**2, mu is + * precomputed via mp_reduce_setup. + * From HAC pp.604 Algorithm 14.42 + */ +int mp_reduce (mp_int * x, mp_int * m, mp_int * mu) +{ + mp_int q; + int res, um = m->used; + + /* q = x */ + if ((res = mp_init_copy (&q, x)) != MP_OKAY) { + return res; + } + + /* q1 = x / b**(k-1) */ + mp_rshd (&q, um - 1); + + /* according to HAC this optimization is ok */ + if (((unsigned long) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) { + if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) { + goto CLEANUP; + } + } else { +#ifdef BN_S_MP_MUL_HIGH_DIGS_C + if ((res = s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) { + goto CLEANUP; + } +#elif defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C) + if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) { + goto CLEANUP; + } +#else + { + res = MP_VAL; + goto CLEANUP; + } +#endif + } + + /* q3 = q2 / b**(k+1) */ + mp_rshd (&q, um + 1); + + /* x = x mod b**(k+1), quick (no division) */ + if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) { + goto CLEANUP; + } + + /* q = q * m mod b**(k+1), quick (no division) */ + if ((res = s_mp_mul_digs (&q, m, &q, um + 1)) != MP_OKAY) { + goto CLEANUP; + } + + /* x = x - q */ + if ((res = mp_sub (x, &q, x)) != MP_OKAY) { + goto CLEANUP; + } + + /* If x < 0, add b**(k+1) to it */ + if (mp_cmp_d (x, 0) == MP_LT) { + mp_set (&q, 1); + if ((res = mp_lshd (&q, um + 1)) != MP_OKAY) + goto CLEANUP; + if ((res = mp_add (x, &q, x)) != MP_OKAY) + goto CLEANUP; + } + + /* Back off if it's too big */ + while (mp_cmp (x, m) != MP_LT) { + if ((res = s_mp_sub (x, m, x)) != MP_OKAY) { + goto CLEANUP; + } + } + +CLEANUP: + mp_clear (&q); + + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce_2k.c b/dep/StormLib/src/libtommath/bn_mp_reduce_2k.c new file mode 100644 index 000000000..3191d8291 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce_2k.c @@ -0,0 +1,61 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_2K_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* reduces a modulo n where n is of the form 2**p - d */ +int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d) +{ + mp_int q; + int p, res; + + if ((res = mp_init(&q)) != MP_OKAY) { + return res; + } + + p = mp_count_bits(n); +top: + /* q = a/2**p, a = a mod 2**p */ + if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) { + goto ERR; + } + + if (d != 1) { + /* q = q * d */ + if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) { + goto ERR; + } + } + + /* a = a + q */ + if ((res = s_mp_add(a, &q, a)) != MP_OKAY) { + goto ERR; + } + + if (mp_cmp_mag(a, n) != MP_LT) { + s_mp_sub(a, n, a); + goto top; + } + +ERR: + mp_clear(&q); + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce_2k_l.c b/dep/StormLib/src/libtommath/bn_mp_reduce_2k_l.c new file mode 100644 index 000000000..49b7e344e --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce_2k_l.c @@ -0,0 +1,62 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_2K_L_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* reduces a modulo n where n is of the form 2**p - d + This differs from reduce_2k since "d" can be larger + than a single digit. +*/ +int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d) +{ + mp_int q; + int p, res; + + if ((res = mp_init(&q)) != MP_OKAY) { + return res; + } + + p = mp_count_bits(n); +top: + /* q = a/2**p, a = a mod 2**p */ + if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) { + goto ERR; + } + + /* q = q * d */ + if ((res = mp_mul(&q, d, &q)) != MP_OKAY) { + goto ERR; + } + + /* a = a + q */ + if ((res = s_mp_add(a, &q, a)) != MP_OKAY) { + goto ERR; + } + + if (mp_cmp_mag(a, n) != MP_LT) { + s_mp_sub(a, n, a); + goto top; + } + +ERR: + mp_clear(&q); + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_l.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce_2k_setup.c b/dep/StormLib/src/libtommath/bn_mp_reduce_2k_setup.c new file mode 100644 index 000000000..aa3b3bad8 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce_2k_setup.c @@ -0,0 +1,47 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_2K_SETUP_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines the setup value */ +int mp_reduce_2k_setup(mp_int *a, mp_digit *d) +{ + int res, p; + mp_int tmp; + + if ((res = mp_init(&tmp)) != MP_OKAY) { + return res; + } + + p = mp_count_bits(a); + if ((res = mp_2expt(&tmp, p)) != MP_OKAY) { + mp_clear(&tmp); + return res; + } + + if ((res = s_mp_sub(&tmp, a, &tmp)) != MP_OKAY) { + mp_clear(&tmp); + return res; + } + + *d = tmp.dp[0]; + mp_clear(&tmp); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce_2k_setup_l.c b/dep/StormLib/src/libtommath/bn_mp_reduce_2k_setup_l.c new file mode 100644 index 000000000..4eca87040 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce_2k_setup_l.c @@ -0,0 +1,44 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_2K_SETUP_L_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines the setup value */ +int mp_reduce_2k_setup_l(mp_int *a, mp_int *d) +{ + int res; + mp_int tmp; + + if ((res = mp_init(&tmp)) != MP_OKAY) { + return res; + } + + if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) { + goto ERR; + } + + if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) { + goto ERR; + } + +ERR: + mp_clear(&tmp); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup_l.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce_is_2k.c b/dep/StormLib/src/libtommath/bn_mp_reduce_is_2k.c new file mode 100644 index 000000000..b9ede9789 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce_is_2k.c @@ -0,0 +1,52 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_IS_2K_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines if mp_reduce_2k can be used */ +int mp_reduce_is_2k(mp_int *a) +{ + int ix, iy, iw; + mp_digit iz; + + if (a->used == 0) { + return MP_NO; + } else if (a->used == 1) { + return MP_YES; + } else if (a->used > 1) { + iy = mp_count_bits(a); + iz = 1; + iw = 1; + + /* Test every bit from the second digit up, must be 1 */ + for (ix = DIGIT_BIT; ix < iy; ix++) { + if ((a->dp[iw] & iz) == 0) { + return MP_NO; + } + iz <<= 1; + if (iz > (mp_digit)MP_MASK) { + ++iw; + iz = 1; + } + } + } + return MP_YES; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce_is_2k_l.c b/dep/StormLib/src/libtommath/bn_mp_reduce_is_2k_l.c new file mode 100644 index 000000000..787875f8b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce_is_2k_l.c @@ -0,0 +1,44 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_IS_2K_L_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines if reduce_2k_l can be used */ +int mp_reduce_is_2k_l(mp_int *a) +{ + int ix, iy; + + if (a->used == 0) { + return MP_NO; + } else if (a->used == 1) { + return MP_YES; + } else if (a->used > 1) { + /* if more than half of the digits are -1 we're sold */ + for (iy = ix = 0; ix < a->used; ix++) { + if (a->dp[ix] == MP_MASK) { + ++iy; + } + } + return (iy >= (a->used/2)) ? MP_YES : MP_NO; + + } + return MP_NO; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k_l.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_reduce_setup.c b/dep/StormLib/src/libtommath/bn_mp_reduce_setup.c new file mode 100644 index 000000000..00e0a62b9 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_reduce_setup.c @@ -0,0 +1,34 @@ +#include "tommath.h" +#ifdef BN_MP_REDUCE_SETUP_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* pre-calculate the value required for Barrett reduction + * For a given modulus "b" it calulates the value required in "a" + */ +int mp_reduce_setup (mp_int * a, mp_int * b) +{ + int res; + + if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) { + return res; + } + return mp_div (a, b, a, NULL); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_setup.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_rshd.c b/dep/StormLib/src/libtommath/bn_mp_rshd.c new file mode 100644 index 000000000..eac6721ba --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_rshd.c @@ -0,0 +1,72 @@ +#include "tommath.h" +#ifdef BN_MP_RSHD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* shift right a certain amount of digits */ +void mp_rshd (mp_int * a, int b) +{ + int x; + + /* if b <= 0 then ignore it */ + if (b <= 0) { + return; + } + + /* if b > used then simply zero it and return */ + if (a->used <= b) { + mp_zero (a); + return; + } + + { + register mp_digit *bottom, *top; + + /* shift the digits down */ + + /* bottom */ + bottom = a->dp; + + /* top [offset into digits] */ + top = a->dp + b; + + /* this is implemented as a sliding window where + * the window is b-digits long and digits from + * the top of the window are copied to the bottom + * + * e.g. + + b-2 | b-1 | b0 | b1 | b2 | ... | bb | ----> + /\ | ----> + \-------------------/ ----> + */ + for (x = 0; x < (a->used - b); x++) { + *bottom++ = *top++; + } + + /* zero the top digits */ + for (; x < a->used; x++) { + *bottom++ = 0; + } + } + + /* remove excess digits */ + a->used -= b; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_rshd.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_set.c b/dep/StormLib/src/libtommath/bn_mp_set.c new file mode 100644 index 000000000..d76d5bbd3 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_set.c @@ -0,0 +1,29 @@ +#include "tommath.h" +#ifdef BN_MP_SET_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* set to a digit */ +void mp_set (mp_int * a, mp_digit b) +{ + mp_zero (a); + a->dp[0] = b & MP_MASK; + a->used = (a->dp[0] != 0) ? 1 : 0; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_set.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_set_int.c b/dep/StormLib/src/libtommath/bn_mp_set_int.c new file mode 100644 index 000000000..68cf0e32b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_set_int.c @@ -0,0 +1,48 @@ +#include "tommath.h" +#ifdef BN_MP_SET_INT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* set a 32-bit const */ +int mp_set_int (mp_int * a, unsigned long b) +{ + int x, res; + + mp_zero (a); + + /* set four bits at a time */ + for (x = 0; x < 8; x++) { + /* shift the number up four bits */ + if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) { + return res; + } + + /* OR in the top four bits of the source */ + a->dp[0] |= (b >> 28) & 15; + + /* shift the source up to the next four bits */ + b <<= 4; + + /* ensure that digits are not clamped off */ + a->used += 1; + } + mp_clamp (a); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_set_int.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_shrink.c b/dep/StormLib/src/libtommath/bn_mp_shrink.c new file mode 100644 index 000000000..54920d140 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_shrink.c @@ -0,0 +1,35 @@ +#include "tommath.h" +#ifdef BN_MP_SHRINK_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* shrink a bignum */ +int mp_shrink (mp_int * a) +{ + mp_digit *tmp; + if (a->alloc != a->used && a->used > 0) { + if ((tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * a->used)) == NULL) { + return MP_MEM; + } + a->dp = tmp; + a->alloc = a->used; + } + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_shrink.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_signed_bin_size.c b/dep/StormLib/src/libtommath/bn_mp_signed_bin_size.c new file mode 100644 index 000000000..b9492a5e5 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_signed_bin_size.c @@ -0,0 +1,27 @@ +#include "tommath.h" +#ifdef BN_MP_SIGNED_BIN_SIZE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* get the size for an signed equivalent */ +int mp_signed_bin_size (mp_int * a) +{ + return 1 + mp_unsigned_bin_size (a); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_signed_bin_size.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_sqr.c b/dep/StormLib/src/libtommath/bn_mp_sqr.c new file mode 100644 index 000000000..c10fa6f3b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_sqr.c @@ -0,0 +1,58 @@ +#include "tommath.h" +#ifdef BN_MP_SQR_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* computes b = a*a */ +int +mp_sqr (mp_int * a, mp_int * b) +{ + int res; + +#ifdef BN_MP_TOOM_SQR_C + /* use Toom-Cook? */ + if (a->used >= TOOM_SQR_CUTOFF) { + res = mp_toom_sqr(a, b); + /* Karatsuba? */ + } else +#endif +#ifdef BN_MP_KARATSUBA_SQR_C +if (a->used >= KARATSUBA_SQR_CUTOFF) { + res = mp_karatsuba_sqr (a, b); + } else +#endif + { +#ifdef BN_FAST_S_MP_SQR_C + /* can we use the fast comba multiplier? */ + if ((a->used * 2 + 1) < MP_WARRAY && + a->used < + (1 << (sizeof(mp_word) * CHAR_BIT - 2*DIGIT_BIT - 1))) { + res = fast_s_mp_sqr (a, b); + } else +#endif +#ifdef BN_S_MP_SQR_C + res = s_mp_sqr (a, b); +#else + res = MP_VAL; +#endif + } + b->sign = MP_ZPOS; + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sqr.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_sqrmod.c b/dep/StormLib/src/libtommath/bn_mp_sqrmod.c new file mode 100644 index 000000000..5f4b2f3d6 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_sqrmod.c @@ -0,0 +1,41 @@ +#include "tommath.h" +#ifdef BN_MP_SQRMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* c = a * a (mod b) */ +int +mp_sqrmod (mp_int * a, mp_int * b, mp_int * c) +{ + int res; + mp_int t; + + if ((res = mp_init (&t)) != MP_OKAY) { + return res; + } + + if ((res = mp_sqr (a, &t)) != MP_OKAY) { + mp_clear (&t); + return res; + } + res = mp_mod (&t, b, c); + mp_clear (&t); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sqrmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_sqrt.c b/dep/StormLib/src/libtommath/bn_mp_sqrt.c new file mode 100644 index 000000000..e15ba98ca --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_sqrt.c @@ -0,0 +1,81 @@ +#include "tommath.h" +#ifdef BN_MP_SQRT_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* this function is less generic than mp_n_root, simpler and faster */ +int mp_sqrt(mp_int *arg, mp_int *ret) +{ + int res; + mp_int t1,t2; + + /* must be positive */ + if (arg->sign == MP_NEG) { + return MP_VAL; + } + + /* easy out */ + if (mp_iszero(arg) == MP_YES) { + mp_zero(ret); + return MP_OKAY; + } + + if ((res = mp_init_copy(&t1, arg)) != MP_OKAY) { + return res; + } + + if ((res = mp_init(&t2)) != MP_OKAY) { + goto E2; + } + + /* First approx. (not very bad for large arg) */ + mp_rshd (&t1,t1.used/2); + + /* t1 > 0 */ + if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) { + goto E1; + } + if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) { + goto E1; + } + if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) { + goto E1; + } + /* And now t1 > sqrt(arg) */ + do { + if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) { + goto E1; + } + if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) { + goto E1; + } + if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) { + goto E1; + } + /* t1 >= sqrt(arg) >= t2 at this point */ + } while (mp_cmp_mag(&t1,&t2) == MP_GT); + + mp_exch(&t1,ret); + +E1: mp_clear(&t2); +E2: mp_clear(&t1); + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sqrt.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_sub.c b/dep/StormLib/src/libtommath/bn_mp_sub.c new file mode 100644 index 000000000..6e7213861 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_sub.c @@ -0,0 +1,59 @@ +#include "tommath.h" +#ifdef BN_MP_SUB_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* high level subtraction (handles signs) */ +int +mp_sub (mp_int * a, mp_int * b, mp_int * c) +{ + int sa, sb, res; + + sa = a->sign; + sb = b->sign; + + if (sa != sb) { + /* subtract a negative from a positive, OR */ + /* subtract a positive from a negative. */ + /* In either case, ADD their magnitudes, */ + /* and use the sign of the first number. */ + c->sign = sa; + res = s_mp_add (a, b, c); + } else { + /* subtract a positive from a positive, OR */ + /* subtract a negative from a negative. */ + /* First, take the difference between their */ + /* magnitudes, then... */ + if (mp_cmp_mag (a, b) != MP_LT) { + /* Copy the sign from the first */ + c->sign = sa; + /* The first has a larger or equal magnitude */ + res = s_mp_sub (a, b, c); + } else { + /* The result has the *opposite* sign from */ + /* the first number. */ + c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS; + /* The second has a larger magnitude */ + res = s_mp_sub (b, a, c); + } + } + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sub.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_sub_d.c b/dep/StormLib/src/libtommath/bn_mp_sub_d.c new file mode 100644 index 000000000..aa08e31b3 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_sub_d.c @@ -0,0 +1,93 @@ +#include "tommath.h" +#ifdef BN_MP_SUB_D_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* single digit subtraction */ +int +mp_sub_d (mp_int * a, mp_digit b, mp_int * c) +{ + mp_digit *tmpa, *tmpc, mu; + int res, ix, oldused; + + /* grow c as required */ + if (c->alloc < a->used + 1) { + if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) { + return res; + } + } + + /* if a is negative just do an unsigned + * addition [with fudged signs] + */ + if (a->sign == MP_NEG) { + a->sign = MP_ZPOS; + res = mp_add_d(a, b, c); + a->sign = c->sign = MP_NEG; + + /* clamp */ + mp_clamp(c); + + return res; + } + + /* setup regs */ + oldused = c->used; + tmpa = a->dp; + tmpc = c->dp; + + /* if a <= b simply fix the single digit */ + if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) { + if (a->used == 1) { + *tmpc++ = b - *tmpa; + } else { + *tmpc++ = b; + } + ix = 1; + + /* negative/1digit */ + c->sign = MP_NEG; + c->used = 1; + } else { + /* positive/size */ + c->sign = MP_ZPOS; + c->used = a->used; + + /* subtract first digit */ + *tmpc = *tmpa++ - b; + mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1); + *tmpc++ &= MP_MASK; + + /* handle rest of the digits */ + for (ix = 1; ix < a->used; ix++) { + *tmpc = *tmpa++ - mu; + mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1); + *tmpc++ &= MP_MASK; + } + } + + /* zero excess digits */ + while (ix++ < oldused) { + *tmpc++ = 0; + } + mp_clamp(c); + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sub_d.c,v $ */ +/* $Revision: 1.6 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_submod.c b/dep/StormLib/src/libtommath/bn_mp_submod.c new file mode 100644 index 000000000..6617ff42c --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_submod.c @@ -0,0 +1,42 @@ +#include "tommath.h" +#ifdef BN_MP_SUBMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* d = a - b (mod c) */ +int +mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) +{ + int res; + mp_int t; + + + if ((res = mp_init (&t)) != MP_OKAY) { + return res; + } + + if ((res = mp_sub (a, b, &t)) != MP_OKAY) { + mp_clear (&t); + return res; + } + res = mp_mod (&t, c, d); + mp_clear (&t); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_submod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_to_signed_bin.c b/dep/StormLib/src/libtommath/bn_mp_to_signed_bin.c new file mode 100644 index 000000000..154f64b56 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_to_signed_bin.c @@ -0,0 +1,33 @@ +#include "tommath.h" +#ifdef BN_MP_TO_SIGNED_BIN_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* store in signed [big endian] format */ +int mp_to_signed_bin (mp_int * a, unsigned char *b) +{ + int res; + + if ((res = mp_to_unsigned_bin (a, b + 1)) != MP_OKAY) { + return res; + } + b[0] = (unsigned char) ((a->sign == MP_ZPOS) ? 0 : 1); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_to_signed_bin_n.c b/dep/StormLib/src/libtommath/bn_mp_to_signed_bin_n.c new file mode 100644 index 000000000..e119c380a --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_to_signed_bin_n.c @@ -0,0 +1,31 @@ +#include "tommath.h" +#ifdef BN_MP_TO_SIGNED_BIN_N_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* store in signed [big endian] format */ +int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen) +{ + if (*outlen < (unsigned long)mp_signed_bin_size(a)) { + return MP_VAL; + } + *outlen = mp_signed_bin_size(a); + return mp_to_signed_bin(a, b); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin_n.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_to_unsigned_bin.c b/dep/StormLib/src/libtommath/bn_mp_to_unsigned_bin.c new file mode 100644 index 000000000..ce69e5bf3 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_to_unsigned_bin.c @@ -0,0 +1,48 @@ +#include "tommath.h" +#ifdef BN_MP_TO_UNSIGNED_BIN_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* store in unsigned [big endian] format */ +int mp_to_unsigned_bin (mp_int * a, unsigned char *b) +{ + int x, res; + mp_int t; + + if ((res = mp_init_copy (&t, a)) != MP_OKAY) { + return res; + } + + x = 0; + while (mp_iszero (&t) == 0) { +#ifndef MP_8BIT + b[x++] = (unsigned char) (t.dp[0] & 255); +#else + b[x++] = (unsigned char) (t.dp[0] | ((t.dp[1] & 0x01) << 7)); +#endif + if ((res = mp_div_2d (&t, 8, &t, NULL)) != MP_OKAY) { + mp_clear (&t); + return res; + } + } + bn_reverse (b, x); + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_to_unsigned_bin_n.c b/dep/StormLib/src/libtommath/bn_mp_to_unsigned_bin_n.c new file mode 100644 index 000000000..dfa27c41b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_to_unsigned_bin_n.c @@ -0,0 +1,31 @@ +#include "tommath.h" +#ifdef BN_MP_TO_UNSIGNED_BIN_N_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* store in unsigned [big endian] format */ +int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen) +{ + if (*outlen < (unsigned long)mp_unsigned_bin_size(a)) { + return MP_VAL; + } + *outlen = mp_unsigned_bin_size(a); + return mp_to_unsigned_bin(a, b); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin_n.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_toom_mul.c b/dep/StormLib/src/libtommath/bn_mp_toom_mul.c new file mode 100644 index 000000000..e48c6b355 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_toom_mul.c @@ -0,0 +1,284 @@ +#include "tommath.h" +#ifdef BN_MP_TOOM_MUL_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* multiplication using the Toom-Cook 3-way algorithm + * + * Much more complicated than Karatsuba but has a lower + * asymptotic running time of O(N**1.464). This algorithm is + * only particularly useful on VERY large inputs + * (we're talking 1000s of digits here...). +*/ +int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c) +{ + mp_int w0, w1, w2, w3, w4, tmp1, tmp2, a0, a1, a2, b0, b1, b2; + int res, B; + + /* init temps */ + if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4, + &a0, &a1, &a2, &b0, &b1, + &b2, &tmp1, &tmp2, NULL)) != MP_OKAY) { + return res; + } + + /* B */ + B = MIN(a->used, b->used) / 3; + + /* a = a2 * B**2 + a1 * B + a0 */ + if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_copy(a, &a1)) != MP_OKAY) { + goto ERR; + } + mp_rshd(&a1, B); + mp_mod_2d(&a1, DIGIT_BIT * B, &a1); + + if ((res = mp_copy(a, &a2)) != MP_OKAY) { + goto ERR; + } + mp_rshd(&a2, B*2); + + /* b = b2 * B**2 + b1 * B + b0 */ + if ((res = mp_mod_2d(b, DIGIT_BIT * B, &b0)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_copy(b, &b1)) != MP_OKAY) { + goto ERR; + } + mp_rshd(&b1, B); + mp_mod_2d(&b1, DIGIT_BIT * B, &b1); + + if ((res = mp_copy(b, &b2)) != MP_OKAY) { + goto ERR; + } + mp_rshd(&b2, B*2); + + /* w0 = a0*b0 */ + if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) { + goto ERR; + } + + /* w4 = a2 * b2 */ + if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) { + goto ERR; + } + + /* w1 = (a2 + 2(a1 + 2a0))(b2 + 2(b1 + 2b0)) */ + if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) { + goto ERR; + } + + /* w3 = (a0 + 2(a1 + 2a2))(b0 + 2(b1 + 2b2)) */ + if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) { + goto ERR; + } + + + /* w2 = (a2 + a1 + a0)(b2 + b1 + b0) */ + if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&b2, &b1, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) { + goto ERR; + } + + /* now solve the matrix + + 0 0 0 0 1 + 1 2 4 8 16 + 1 1 1 1 1 + 16 8 4 2 1 + 1 0 0 0 0 + + using 12 subtractions, 4 shifts, + 2 small divisions and 1 small multiplication + */ + + /* r1 - r4 */ + if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - r0 */ + if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) { + goto ERR; + } + /* r1/2 */ + if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3/2 */ + if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) { + goto ERR; + } + /* r2 - r0 - r4 */ + if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) { + goto ERR; + } + /* r1 - r2 */ + if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - r2 */ + if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { + goto ERR; + } + /* r1 - 8r0 */ + if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - 8r4 */ + if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) { + goto ERR; + } + /* 3r2 - r1 - r3 */ + if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) { + goto ERR; + } + /* r1 - r2 */ + if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - r2 */ + if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { + goto ERR; + } + /* r1/3 */ + if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) { + goto ERR; + } + /* r3/3 */ + if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) { + goto ERR; + } + + /* at this point shift W[n] by B*n */ + if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) { + goto ERR; + } + +ERR: + mp_clear_multi(&w0, &w1, &w2, &w3, &w4, + &a0, &a1, &a2, &b0, &b1, + &b2, &tmp1, &tmp2, NULL); + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toom_mul.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_toom_sqr.c b/dep/StormLib/src/libtommath/bn_mp_toom_sqr.c new file mode 100644 index 000000000..fd8bc672a --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_toom_sqr.c @@ -0,0 +1,226 @@ +#include "tommath.h" +#ifdef BN_MP_TOOM_SQR_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* squaring using Toom-Cook 3-way algorithm */ +int +mp_toom_sqr(mp_int *a, mp_int *b) +{ + mp_int w0, w1, w2, w3, w4, tmp1, a0, a1, a2; + int res, B; + + /* init temps */ + if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL)) != MP_OKAY) { + return res; + } + + /* B */ + B = a->used / 3; + + /* a = a2 * B**2 + a1 * B + a0 */ + if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_copy(a, &a1)) != MP_OKAY) { + goto ERR; + } + mp_rshd(&a1, B); + mp_mod_2d(&a1, DIGIT_BIT * B, &a1); + + if ((res = mp_copy(a, &a2)) != MP_OKAY) { + goto ERR; + } + mp_rshd(&a2, B*2); + + /* w0 = a0*a0 */ + if ((res = mp_sqr(&a0, &w0)) != MP_OKAY) { + goto ERR; + } + + /* w4 = a2 * a2 */ + if ((res = mp_sqr(&a2, &w4)) != MP_OKAY) { + goto ERR; + } + + /* w1 = (a2 + 2(a1 + 2a0))**2 */ + if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_sqr(&tmp1, &w1)) != MP_OKAY) { + goto ERR; + } + + /* w3 = (a0 + 2(a1 + 2a2))**2 */ + if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_sqr(&tmp1, &w3)) != MP_OKAY) { + goto ERR; + } + + + /* w2 = (a2 + a1 + a0)**2 */ + if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sqr(&tmp1, &w2)) != MP_OKAY) { + goto ERR; + } + + /* now solve the matrix + + 0 0 0 0 1 + 1 2 4 8 16 + 1 1 1 1 1 + 16 8 4 2 1 + 1 0 0 0 0 + + using 12 subtractions, 4 shifts, 2 small divisions and 1 small multiplication. + */ + + /* r1 - r4 */ + if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - r0 */ + if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) { + goto ERR; + } + /* r1/2 */ + if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3/2 */ + if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) { + goto ERR; + } + /* r2 - r0 - r4 */ + if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) { + goto ERR; + } + /* r1 - r2 */ + if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - r2 */ + if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { + goto ERR; + } + /* r1 - 8r0 */ + if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - 8r4 */ + if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) { + goto ERR; + } + /* 3r2 - r1 - r3 */ + if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) { + goto ERR; + } + /* r1 - r2 */ + if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { + goto ERR; + } + /* r3 - r2 */ + if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { + goto ERR; + } + /* r1/3 */ + if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) { + goto ERR; + } + /* r3/3 */ + if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) { + goto ERR; + } + + /* at this point shift W[n] by B*n */ + if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) { + goto ERR; + } + + if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) { + goto ERR; + } + if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) { + goto ERR; + } + +ERR: + mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL); + return res; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toom_sqr.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_toradix.c b/dep/StormLib/src/libtommath/bn_mp_toradix.c new file mode 100644 index 000000000..539abe9ba --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_toradix.c @@ -0,0 +1,75 @@ +#include "tommath.h" +#ifdef BN_MP_TORADIX_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* stores a bignum as a ASCII string in a given radix (2..64) */ +int mp_toradix (mp_int * a, char *str, int radix) +{ + int res, digs; + mp_int t; + mp_digit d; + char *_s = str; + + /* check range of the radix */ + if (radix < 2 || radix > 64) { + return MP_VAL; + } + + /* quick out if its zero */ + if (mp_iszero(a) == 1) { + *str++ = '0'; + *str = '\0'; + return MP_OKAY; + } + + if ((res = mp_init_copy (&t, a)) != MP_OKAY) { + return res; + } + + /* if it is negative output a - */ + if (t.sign == MP_NEG) { + ++_s; + *str++ = '-'; + t.sign = MP_ZPOS; + } + + digs = 0; + while (mp_iszero (&t) == 0) { + if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { + mp_clear (&t); + return res; + } + *str++ = mp_s_rmap[d]; + ++digs; + } + + /* reverse the digits of the string. In this case _s points + * to the first digit [exluding the sign] of the number] + */ + bn_reverse ((unsigned char *)_s, digs); + + /* append a NULL so the string is properly terminated */ + *str = '\0'; + + mp_clear (&t); + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toradix.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_toradix_n.c b/dep/StormLib/src/libtommath/bn_mp_toradix_n.c new file mode 100644 index 000000000..0322f8d4b --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_toradix_n.c @@ -0,0 +1,88 @@ +#include "tommath.h" +#ifdef BN_MP_TORADIX_N_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* stores a bignum as a ASCII string in a given radix (2..64) + * + * Stores upto maxlen-1 chars and always a NULL byte + */ +int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen) +{ + int res, digs; + mp_int t; + mp_digit d; + char *_s = str; + + /* check range of the maxlen, radix */ + if (maxlen < 2 || radix < 2 || radix > 64) { + return MP_VAL; + } + + /* quick out if its zero */ + if (mp_iszero(a) == MP_YES) { + *str++ = '0'; + *str = '\0'; + return MP_OKAY; + } + + if ((res = mp_init_copy (&t, a)) != MP_OKAY) { + return res; + } + + /* if it is negative output a - */ + if (t.sign == MP_NEG) { + /* we have to reverse our digits later... but not the - sign!! */ + ++_s; + + /* store the flag and mark the number as positive */ + *str++ = '-'; + t.sign = MP_ZPOS; + + /* subtract a char */ + --maxlen; + } + + digs = 0; + while (mp_iszero (&t) == 0) { + if (--maxlen < 1) { + /* no more room */ + break; + } + if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { + mp_clear (&t); + return res; + } + *str++ = mp_s_rmap[d]; + ++digs; + } + + /* reverse the digits of the string. In this case _s points + * to the first digit [exluding the sign] of the number + */ + bn_reverse ((unsigned char *)_s, digs); + + /* append a NULL so the string is properly terminated */ + *str = '\0'; + + mp_clear (&t); + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toradix_n.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_unsigned_bin_size.c b/dep/StormLib/src/libtommath/bn_mp_unsigned_bin_size.c new file mode 100644 index 000000000..88f3e92dd --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_unsigned_bin_size.c @@ -0,0 +1,28 @@ +#include "tommath.h" +#ifdef BN_MP_UNSIGNED_BIN_SIZE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* get the size for an unsigned equivalent */ +int mp_unsigned_bin_size (mp_int * a) +{ + int size = mp_count_bits (a); + return (size / 8 + ((size & 7) != 0 ? 1 : 0)); +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_unsigned_bin_size.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_xor.c b/dep/StormLib/src/libtommath/bn_mp_xor.c new file mode 100644 index 000000000..bf0446ecf --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_xor.c @@ -0,0 +1,51 @@ +#include "tommath.h" +#ifdef BN_MP_XOR_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* XOR two ints together */ +int +mp_xor (mp_int * a, mp_int * b, mp_int * c) +{ + int res, ix, px; + mp_int t, *x; + + if (a->used > b->used) { + if ((res = mp_init_copy (&t, a)) != MP_OKAY) { + return res; + } + px = b->used; + x = b; + } else { + if ((res = mp_init_copy (&t, b)) != MP_OKAY) { + return res; + } + px = a->used; + x = a; + } + + for (ix = 0; ix < px; ix++) { + t.dp[ix] ^= x->dp[ix]; + } + mp_clamp (&t); + mp_exch (c, &t); + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_xor.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_mp_zero.c b/dep/StormLib/src/libtommath/bn_mp_zero.c new file mode 100644 index 000000000..f21db5ed5 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_mp_zero.c @@ -0,0 +1,36 @@ +#include "tommath.h" +#ifdef BN_MP_ZERO_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* set to zero */ +void mp_zero (mp_int * a) +{ + int n; + mp_digit *tmp; + + a->sign = MP_ZPOS; + a->used = 0; + + tmp = a->dp; + for (n = 0; n < a->alloc; n++) { + *tmp++ = 0; + } +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_zero.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_prime_tab.c b/dep/StormLib/src/libtommath/bn_prime_tab.c new file mode 100644 index 000000000..7d306dd56 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_prime_tab.c @@ -0,0 +1,61 @@ +#include "tommath.h" +#ifdef BN_PRIME_TAB_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +const mp_digit ltm_prime_tab[] = { + 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, + 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035, + 0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059, + 0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F, +#ifndef MP_8BIT + 0x0083, + 0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD, + 0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF, + 0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107, + 0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137, + + 0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167, + 0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199, + 0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9, + 0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7, + 0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239, + 0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265, + 0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293, + 0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF, + + 0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301, + 0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B, + 0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371, + 0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD, + 0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5, + 0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419, + 0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449, + 0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B, + + 0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7, + 0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503, + 0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529, + 0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F, + 0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3, + 0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7, + 0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623, + 0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653 +#endif +}; +#endif + +/* $Source: /cvs/libtom/libtommath/bn_prime_tab.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_reverse.c b/dep/StormLib/src/libtommath/bn_reverse.c new file mode 100644 index 000000000..d4a919af4 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_reverse.c @@ -0,0 +1,39 @@ +#include "tommath.h" +#ifdef BN_REVERSE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* reverse an array, used for radix code */ +void +bn_reverse (unsigned char *s, int len) +{ + int ix, iy; + unsigned char t; + + ix = 0; + iy = len - 1; + while (ix < iy) { + t = s[ix]; + s[ix] = s[iy]; + s[iy] = t; + ++ix; + --iy; + } +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_reverse.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_s_mp_add.c b/dep/StormLib/src/libtommath/bn_s_mp_add.c new file mode 100644 index 000000000..5ea9c6d20 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_s_mp_add.c @@ -0,0 +1,109 @@ +#include "tommath.h" +#ifdef BN_S_MP_ADD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* low level addition, based on HAC pp.594, Algorithm 14.7 */ +int +s_mp_add (mp_int * a, mp_int * b, mp_int * c) +{ + mp_int *x; + int olduse, res, min, max; + + /* find sizes, we let |a| <= |b| which means we have to sort + * them. "x" will point to the input with the most digits + */ + if (a->used > b->used) { + min = b->used; + max = a->used; + x = a; + } else { + min = a->used; + max = b->used; + x = b; + } + + /* init result */ + if (c->alloc < max + 1) { + if ((res = mp_grow (c, max + 1)) != MP_OKAY) { + return res; + } + } + + /* get old used digit count and set new one */ + olduse = c->used; + c->used = max + 1; + + { + register mp_digit u, *tmpa, *tmpb, *tmpc; + register int i; + + /* alias for digit pointers */ + + /* first input */ + tmpa = a->dp; + + /* second input */ + tmpb = b->dp; + + /* destination */ + tmpc = c->dp; + + /* zero the carry */ + u = 0; + for (i = 0; i < min; i++) { + /* Compute the sum at one digit, T[i] = A[i] + B[i] + U */ + *tmpc = *tmpa++ + *tmpb++ + u; + + /* U = carry bit of T[i] */ + u = *tmpc >> ((mp_digit)DIGIT_BIT); + + /* take away carry bit from T[i] */ + *tmpc++ &= MP_MASK; + } + + /* now copy higher words if any, that is in A+B + * if A or B has more digits add those in + */ + if (min != max) { + for (; i < max; i++) { + /* T[i] = X[i] + U */ + *tmpc = x->dp[i] + u; + + /* U = carry bit of T[i] */ + u = *tmpc >> ((mp_digit)DIGIT_BIT); + + /* take away carry bit from T[i] */ + *tmpc++ &= MP_MASK; + } + } + + /* add carry */ + *tmpc++ = u; + + /* clear digits above oldused */ + for (i = c->used; i < olduse; i++) { + *tmpc++ = 0; + } + } + + mp_clamp (c); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_add.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_s_mp_exptmod.c b/dep/StormLib/src/libtommath/bn_s_mp_exptmod.c new file mode 100644 index 000000000..9fb2da8fd --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_s_mp_exptmod.c @@ -0,0 +1,252 @@ +#include "tommath.h" +#ifdef BN_S_MP_EXPTMOD_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#ifdef MP_LOW_MEM + #define TAB_SIZE 32 +#else + #define TAB_SIZE 256 +#endif + +int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode) +{ + mp_int M[TAB_SIZE], res, mu; + mp_digit buf; + int err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize; + int (*redux)(mp_int*,mp_int*,mp_int*); + + /* find window size */ + x = mp_count_bits (X); + if (x <= 7) { + winsize = 2; + } else if (x <= 36) { + winsize = 3; + } else if (x <= 140) { + winsize = 4; + } else if (x <= 450) { + winsize = 5; + } else if (x <= 1303) { + winsize = 6; + } else if (x <= 3529) { + winsize = 7; + } else { + winsize = 8; + } + +#ifdef MP_LOW_MEM + if (winsize > 5) { + winsize = 5; + } +#endif + + /* init M array */ + /* init first cell */ + if ((err = mp_init(&M[1])) != MP_OKAY) { + return err; + } + + /* now init the second half of the array */ + for (x = 1<<(winsize-1); x < (1 << winsize); x++) { + if ((err = mp_init(&M[x])) != MP_OKAY) { + for (y = 1<<(winsize-1); y < x; y++) { + mp_clear (&M[y]); + } + mp_clear(&M[1]); + return err; + } + } + + /* create mu, used for Barrett reduction */ + if ((err = mp_init (&mu)) != MP_OKAY) { + goto LBL_M; + } + + if (redmode == 0) { + if ((err = mp_reduce_setup (&mu, P)) != MP_OKAY) { + goto LBL_MU; + } + redux = mp_reduce; + } else { + if ((err = mp_reduce_2k_setup_l (P, &mu)) != MP_OKAY) { + goto LBL_MU; + } + redux = mp_reduce_2k_l; + } + + /* create M table + * + * The M table contains powers of the base, + * e.g. M[x] = G**x mod P + * + * The first half of the table is not + * computed though accept for M[0] and M[1] + */ + if ((err = mp_mod (G, P, &M[1])) != MP_OKAY) { + goto LBL_MU; + } + + /* compute the value at M[1<<(winsize-1)] by squaring + * M[1] (winsize-1) times + */ + if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) { + goto LBL_MU; + } + + for (x = 0; x < (winsize - 1); x++) { + /* square it */ + if ((err = mp_sqr (&M[1 << (winsize - 1)], + &M[1 << (winsize - 1)])) != MP_OKAY) { + goto LBL_MU; + } + + /* reduce modulo P */ + if ((err = redux (&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) { + goto LBL_MU; + } + } + + /* create upper table, that is M[x] = M[x-1] * M[1] (mod P) + * for x = (2**(winsize - 1) + 1) to (2**winsize - 1) + */ + for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) { + if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) { + goto LBL_MU; + } + if ((err = redux (&M[x], P, &mu)) != MP_OKAY) { + goto LBL_MU; + } + } + + /* setup result */ + if ((err = mp_init (&res)) != MP_OKAY) { + goto LBL_MU; + } + mp_set (&res, 1); + + /* set initial mode and bit cnt */ + mode = 0; + bitcnt = 1; + buf = 0; + digidx = X->used - 1; + bitcpy = 0; + bitbuf = 0; + + for (;;) { + /* grab next digit as required */ + if (--bitcnt == 0) { + /* if digidx == -1 we are out of digits */ + if (digidx == -1) { + break; + } + /* read next digit and reset the bitcnt */ + buf = X->dp[digidx--]; + bitcnt = (int) DIGIT_BIT; + } + + /* grab the next msb from the exponent */ + y = (buf >> (mp_digit)(DIGIT_BIT - 1)) & 1; + buf <<= (mp_digit)1; + + /* if the bit is zero and mode == 0 then we ignore it + * These represent the leading zero bits before the first 1 bit + * in the exponent. Technically this opt is not required but it + * does lower the # of trivial squaring/reductions used + */ + if (mode == 0 && y == 0) { + continue; + } + + /* if the bit is zero and mode == 1 then we square */ + if (mode == 1 && y == 0) { + if ((err = mp_sqr (&res, &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, &mu)) != MP_OKAY) { + goto LBL_RES; + } + continue; + } + + /* else we add it to the window */ + bitbuf |= (y << (winsize - ++bitcpy)); + mode = 2; + + if (bitcpy == winsize) { + /* ok window is filled so square as required and multiply */ + /* square first */ + for (x = 0; x < winsize; x++) { + if ((err = mp_sqr (&res, &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, &mu)) != MP_OKAY) { + goto LBL_RES; + } + } + + /* then multiply */ + if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, &mu)) != MP_OKAY) { + goto LBL_RES; + } + + /* empty window and reset */ + bitcpy = 0; + bitbuf = 0; + mode = 1; + } + } + + /* if bits remain then square/multiply */ + if (mode == 2 && bitcpy > 0) { + /* square then multiply if the bit is set */ + for (x = 0; x < bitcpy; x++) { + if ((err = mp_sqr (&res, &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, &mu)) != MP_OKAY) { + goto LBL_RES; + } + + bitbuf <<= 1; + if ((bitbuf & (1 << winsize)) != 0) { + /* then multiply */ + if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) { + goto LBL_RES; + } + if ((err = redux (&res, P, &mu)) != MP_OKAY) { + goto LBL_RES; + } + } + } + } + + mp_exch (&res, Y); + err = MP_OKAY; +LBL_RES:mp_clear (&res); +LBL_MU:mp_clear (&mu); +LBL_M: + mp_clear(&M[1]); + for (x = 1<<(winsize-1); x < (1 << winsize); x++) { + mp_clear (&M[x]); + } + return err; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_exptmod.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_s_mp_mul_digs.c b/dep/StormLib/src/libtommath/bn_s_mp_mul_digs.c new file mode 100644 index 000000000..f04dacfb9 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_s_mp_mul_digs.c @@ -0,0 +1,90 @@ +#include "tommath.h" +#ifdef BN_S_MP_MUL_DIGS_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* multiplies |a| * |b| and only computes upto digs digits of result + * HAC pp. 595, Algorithm 14.12 Modified so you can control how + * many digits of output are created. + */ +int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) +{ + mp_int t; + int res, pa, pb, ix, iy; + mp_digit u; + mp_word r; + mp_digit tmpx, *tmpt, *tmpy; + + /* can we use the fast multiplier? */ + if (((digs) < MP_WARRAY) && + MIN (a->used, b->used) < + (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { + return fast_s_mp_mul_digs (a, b, c, digs); + } + + if ((res = mp_init_size (&t, digs)) != MP_OKAY) { + return res; + } + t.used = digs; + + /* compute the digits of the product directly */ + pa = a->used; + for (ix = 0; ix < pa; ix++) { + /* set the carry to zero */ + u = 0; + + /* limit ourselves to making digs digits of output */ + pb = MIN (b->used, digs - ix); + + /* setup some aliases */ + /* copy of the digit from a used within the nested loop */ + tmpx = a->dp[ix]; + + /* an alias for the destination shifted ix places */ + tmpt = t.dp + ix; + + /* an alias for the digits of b */ + tmpy = b->dp; + + /* compute the columns of the output and propagate the carry */ + for (iy = 0; iy < pb; iy++) { + /* compute the column as a mp_word */ + r = ((mp_word)*tmpt) + + ((mp_word)tmpx) * ((mp_word)*tmpy++) + + ((mp_word) u); + + /* the new column is the lower part of the result */ + *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); + + /* get the carry word from the result */ + u = (mp_digit) (r >> ((mp_word) DIGIT_BIT)); + } + /* set carry if it is placed below digs */ + if (ix + iy < digs) { + *tmpt = u; + } + } + + mp_clamp (&t); + mp_exch (&t, c); + + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_digs.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_s_mp_mul_high_digs.c b/dep/StormLib/src/libtommath/bn_s_mp_mul_high_digs.c new file mode 100644 index 000000000..b1d019925 --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_s_mp_mul_high_digs.c @@ -0,0 +1,81 @@ +#include "tommath.h" +#ifdef BN_S_MP_MUL_HIGH_DIGS_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* multiplies |a| * |b| and does not compute the lower digs digits + * [meant to get the higher part of the product] + */ +int +s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs) +{ + mp_int t; + int res, pa, pb, ix, iy; + mp_digit u; + mp_word r; + mp_digit tmpx, *tmpt, *tmpy; + + /* can we use the fast multiplier? */ +#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C + if (((a->used + b->used + 1) < MP_WARRAY) + && MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { + return fast_s_mp_mul_high_digs (a, b, c, digs); + } +#endif + + if ((res = mp_init_size (&t, a->used + b->used + 1)) != MP_OKAY) { + return res; + } + t.used = a->used + b->used + 1; + + pa = a->used; + pb = b->used; + for (ix = 0; ix < pa; ix++) { + /* clear the carry */ + u = 0; + + /* left hand side of A[ix] * B[iy] */ + tmpx = a->dp[ix]; + + /* alias to the address of where the digits will be stored */ + tmpt = &(t.dp[digs]); + + /* alias for where to read the right hand side from */ + tmpy = b->dp + (digs - ix); + + for (iy = digs - ix; iy < pb; iy++) { + /* calculate the double precision result */ + r = ((mp_word)*tmpt) + + ((mp_word)tmpx) * ((mp_word)*tmpy++) + + ((mp_word) u); + + /* get the lower part */ + *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); + + /* carry the carry */ + u = (mp_digit) (r >> ((mp_word) DIGIT_BIT)); + } + *tmpt = u; + } + mp_clamp (&t); + mp_exch (&t, c); + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_high_digs.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_s_mp_sqr.c b/dep/StormLib/src/libtommath/bn_s_mp_sqr.c new file mode 100644 index 000000000..c1e994efd --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_s_mp_sqr.c @@ -0,0 +1,84 @@ +#include "tommath.h" +#ifdef BN_S_MP_SQR_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */ +int s_mp_sqr (mp_int * a, mp_int * b) +{ + mp_int t; + int res, ix, iy, pa; + mp_word r; + mp_digit u, tmpx, *tmpt; + + pa = a->used; + if ((res = mp_init_size (&t, 2*pa + 1)) != MP_OKAY) { + return res; + } + + /* default used is maximum possible size */ + t.used = 2*pa + 1; + + for (ix = 0; ix < pa; ix++) { + /* first calculate the digit at 2*ix */ + /* calculate double precision result */ + r = ((mp_word) t.dp[2*ix]) + + ((mp_word)a->dp[ix])*((mp_word)a->dp[ix]); + + /* store lower part in result */ + t.dp[ix+ix] = (mp_digit) (r & ((mp_word) MP_MASK)); + + /* get the carry */ + u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); + + /* left hand side of A[ix] * A[iy] */ + tmpx = a->dp[ix]; + + /* alias for where to store the results */ + tmpt = t.dp + (2*ix + 1); + + for (iy = ix + 1; iy < pa; iy++) { + /* first calculate the product */ + r = ((mp_word)tmpx) * ((mp_word)a->dp[iy]); + + /* now calculate the double precision result, note we use + * addition instead of *2 since it's easier to optimize + */ + r = ((mp_word) *tmpt) + r + r + ((mp_word) u); + + /* store lower part */ + *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); + + /* get carry */ + u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); + } + /* propagate upwards */ + while (u != ((mp_digit) 0)) { + r = ((mp_word) *tmpt) + ((mp_word) u); + *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); + u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); + } + } + + mp_clamp (&t); + mp_exch (&t, b); + mp_clear (&t); + return MP_OKAY; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_sqr.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bn_s_mp_sub.c b/dep/StormLib/src/libtommath/bn_s_mp_sub.c new file mode 100644 index 000000000..0ae91cc4d --- /dev/null +++ b/dep/StormLib/src/libtommath/bn_s_mp_sub.c @@ -0,0 +1,89 @@ +#include "tommath.h" +#ifdef BN_S_MP_SUB_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */ +int +s_mp_sub (mp_int * a, mp_int * b, mp_int * c) +{ + int olduse, res, min, max; + + /* find sizes */ + min = b->used; + max = a->used; + + /* init result */ + if (c->alloc < max) { + if ((res = mp_grow (c, max)) != MP_OKAY) { + return res; + } + } + olduse = c->used; + c->used = max; + + { + register mp_digit u, *tmpa, *tmpb, *tmpc; + register int i; + + /* alias for digit pointers */ + tmpa = a->dp; + tmpb = b->dp; + tmpc = c->dp; + + /* set carry to zero */ + u = 0; + for (i = 0; i < min; i++) { + /* T[i] = A[i] - B[i] - U */ + *tmpc = *tmpa++ - *tmpb++ - u; + + /* U = carry bit of T[i] + * Note this saves performing an AND operation since + * if a carry does occur it will propagate all the way to the + * MSB. As a result a single shift is enough to get the carry + */ + u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1)); + + /* Clear carry from T[i] */ + *tmpc++ &= MP_MASK; + } + + /* now copy higher words if any, e.g. if A has more digits than B */ + for (; i < max; i++) { + /* T[i] = A[i] - U */ + *tmpc = *tmpa++ - u; + + /* U = carry bit of T[i] */ + u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1)); + + /* Clear carry from T[i] */ + *tmpc++ &= MP_MASK; + } + + /* clear digits above used (since we may not have grown result above) */ + for (i = c->used; i < olduse; i++) { + *tmpc++ = 0; + } + } + + mp_clamp (c); + return MP_OKAY; +} + +#endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_sub.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/bncore.c b/dep/StormLib/src/libtommath/bncore.c new file mode 100644 index 000000000..ad7347f84 --- /dev/null +++ b/dep/StormLib/src/libtommath/bncore.c @@ -0,0 +1,36 @@ +#include "tommath.h" +#ifdef BNCORE_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* Known optimal configurations + + CPU /Compiler /MUL CUTOFF/SQR CUTOFF +------------------------------------------------------------- + Intel P4 Northwood /GCC v3.4.1 / 88/ 128/LTM 0.32 ;-) + AMD Athlon64 /GCC v3.4.4 / 80/ 120/LTM 0.35 + +*/ + +int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsuba multiplication is used. */ + KARATSUBA_SQR_CUTOFF = 120, /* Min. number of digits before Karatsuba squaring is used. */ + + TOOM_MUL_CUTOFF = 350, /* no optimal values of these are known yet so set em high */ + TOOM_SQR_CUTOFF = 400; +#endif + +/* $Source: /cvs/libtom/libtommath/bncore.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/dep/StormLib/src/libtommath/tommath.h b/dep/StormLib/src/libtommath/tommath.h new file mode 100644 index 000000000..1ead3d04b --- /dev/null +++ b/dep/StormLib/src/libtommath/tommath.h @@ -0,0 +1,584 @@ +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com + */ +#ifndef BN_H_ +#define BN_H_ + +#include +#include +#include +#include +#include + +#include "tommath_class.h" + +#ifndef MIN + #define MIN(x,y) ((x)<(y)?(x):(y)) +#endif + +#ifndef MAX + #define MAX(x,y) ((x)>(y)?(x):(y)) +#endif + +#ifdef __cplusplus +extern "C" { + +/* C++ compilers don't like assigning void * to mp_digit * */ +#define OPT_CAST(x) (x *) + +#else + +/* C on the other hand doesn't care */ +#define OPT_CAST(x) + +#endif + + +/* detect 64-bit mode if possible */ +#if defined(__x86_64__) + #if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT)) + #define MP_64BIT + #endif +#endif + +/* some default configurations. + * + * A "mp_digit" must be able to hold DIGIT_BIT + 1 bits + * A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits + * + * At the very least a mp_digit must be able to hold 7 bits + * [any size beyond that is ok provided it doesn't overflow the data type] + */ +#ifdef MP_8BIT + typedef unsigned char mp_digit; + typedef unsigned short mp_word; +#elif defined(MP_16BIT) + typedef unsigned short mp_digit; + typedef unsigned long mp_word; +#elif defined(MP_64BIT) + /* for GCC only on supported platforms */ +#ifndef CRYPT + typedef unsigned long long ulong64; + typedef signed long long long64; +#endif + + typedef unsigned long mp_digit; + typedef unsigned long mp_word __attribute__ ((mode(TI))); + + #define DIGIT_BIT 60 +#else + /* this is the default case, 28-bit digits */ + + /* this is to make porting into LibTomCrypt easier :-) */ +#ifndef CRYPT + #if defined(_MSC_VER) || defined(__BORLANDC__) + typedef unsigned __int64 ulong64; + typedef signed __int64 long64; + #else + typedef unsigned long long ulong64; + typedef signed long long long64; + #endif +#endif + + typedef unsigned long mp_digit; + typedef ulong64 mp_word; + +#ifdef MP_31BIT + /* this is an extension that uses 31-bit digits */ + #define DIGIT_BIT 31 +#else + /* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */ + #define DIGIT_BIT 28 + #define MP_28BIT +#endif +#endif + +/* define heap macros */ +#ifndef CRYPT + /* default to libc stuff */ + #ifndef XMALLOC + #define XMALLOC malloc + #define XFREE free + #define XREALLOC realloc + #define XCALLOC calloc + #else + /* prototypes for our heap functions */ + extern void *XMALLOC(size_t n); + extern void *XREALLOC(void *p, size_t n); + extern void *XCALLOC(size_t n, size_t s); + extern void XFREE(void *p); + #endif +#endif + + +/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */ +#ifndef DIGIT_BIT + #define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1))) /* bits per digit */ +#endif + +#define MP_DIGIT_BIT DIGIT_BIT +#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) +#define MP_DIGIT_MAX MP_MASK + +/* equalities */ +#define MP_LT -1 /* less than */ +#define MP_EQ 0 /* equal to */ +#define MP_GT 1 /* greater than */ + +#define MP_ZPOS 0 /* positive integer */ +#define MP_NEG 1 /* negative */ + +#define MP_OKAY 0 /* ok result */ +#define MP_MEM -2 /* out of mem */ +#define MP_VAL -3 /* invalid input */ +#define MP_RANGE MP_VAL + +#define MP_YES 1 /* yes response */ +#define MP_NO 0 /* no response */ + +/* Primality generation flags */ +#define LTM_PRIME_BBS 0x0001 /* BBS style prime */ +#define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */ +#define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */ + +typedef int mp_err; + +/* you'll have to tune these... */ +extern int KARATSUBA_MUL_CUTOFF, + KARATSUBA_SQR_CUTOFF, + TOOM_MUL_CUTOFF, + TOOM_SQR_CUTOFF; + +/* define this to use lower memory usage routines (exptmods mostly) */ +/* #define MP_LOW_MEM */ + +/* default precision */ +#ifndef MP_PREC + #ifndef MP_LOW_MEM + #define MP_PREC 32 /* default digits of precision */ + #else + #define MP_PREC 8 /* default digits of precision */ + #endif +#endif + +/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */ +#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1)) + +/* the infamous mp_int structure */ +typedef struct { + int used, alloc, sign; + mp_digit *dp; +} mp_int; + +/* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */ +typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat); + + +#define USED(m) ((m)->used) +#define DIGIT(m,k) ((m)->dp[(k)]) +#define SIGN(m) ((m)->sign) + +/* error code to char* string */ +char *mp_error_to_string(int code); + +/* ---> init and deinit bignum functions <--- */ +/* init a bignum */ +int mp_init(mp_int *a); + +/* free a bignum */ +void mp_clear(mp_int *a); + +/* init a null terminated series of arguments */ +int mp_init_multi(mp_int *mp, ...); + +/* clear a null terminated series of arguments */ +void mp_clear_multi(mp_int *mp, ...); + +/* exchange two ints */ +void mp_exch(mp_int *a, mp_int *b); + +/* shrink ram required for a bignum */ +int mp_shrink(mp_int *a); + +/* grow an int to a given size */ +int mp_grow(mp_int *a, int size); + +/* init to a given number of digits */ +int mp_init_size(mp_int *a, int size); + +/* ---> Basic Manipulations <--- */ +#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO) +#define mp_iseven(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO) +#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO) + +/* set to zero */ +void mp_zero(mp_int *a); + +/* set to a digit */ +void mp_set(mp_int *a, mp_digit b); + +/* set a 32-bit const */ +int mp_set_int(mp_int *a, unsigned long b); + +/* get a 32-bit value */ +unsigned long mp_get_int(mp_int * a); + +/* initialize and set a digit */ +int mp_init_set (mp_int * a, mp_digit b); + +/* initialize and set 32-bit value */ +int mp_init_set_int (mp_int * a, unsigned long b); + +/* copy, b = a */ +int mp_copy(mp_int *a, mp_int *b); + +/* inits and copies, a = b */ +int mp_init_copy(mp_int *a, mp_int *b); + +/* trim unused digits */ +void mp_clamp(mp_int *a); + +/* ---> digit manipulation <--- */ + +/* right shift by "b" digits */ +void mp_rshd(mp_int *a, int b); + +/* left shift by "b" digits */ +int mp_lshd(mp_int *a, int b); + +/* c = a / 2**b */ +int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d); + +/* b = a/2 */ +int mp_div_2(mp_int *a, mp_int *b); + +/* c = a * 2**b */ +int mp_mul_2d(mp_int *a, int b, mp_int *c); + +/* b = a*2 */ +int mp_mul_2(mp_int *a, mp_int *b); + +/* c = a mod 2**d */ +int mp_mod_2d(mp_int *a, int b, mp_int *c); + +/* computes a = 2**b */ +int mp_2expt(mp_int *a, int b); + +/* Counts the number of lsbs which are zero before the first zero bit */ +int mp_cnt_lsb(mp_int *a); + +/* I Love Earth! */ + +/* makes a pseudo-random int of a given size */ +int mp_rand(mp_int *a, int digits); + +/* ---> binary operations <--- */ +/* c = a XOR b */ +int mp_xor(mp_int *a, mp_int *b, mp_int *c); + +/* c = a OR b */ +int mp_or(mp_int *a, mp_int *b, mp_int *c); + +/* c = a AND b */ +int mp_and(mp_int *a, mp_int *b, mp_int *c); + +/* ---> Basic arithmetic <--- */ + +/* b = -a */ +int mp_neg(mp_int *a, mp_int *b); + +/* b = |a| */ +int mp_abs(mp_int *a, mp_int *b); + +/* compare a to b */ +int mp_cmp(mp_int *a, mp_int *b); + +/* compare |a| to |b| */ +int mp_cmp_mag(mp_int *a, mp_int *b); + +/* c = a + b */ +int mp_add(mp_int *a, mp_int *b, mp_int *c); + +/* c = a - b */ +int mp_sub(mp_int *a, mp_int *b, mp_int *c); + +/* c = a * b */ +int mp_mul(mp_int *a, mp_int *b, mp_int *c); + +/* b = a*a */ +int mp_sqr(mp_int *a, mp_int *b); + +/* a/b => cb + d == a */ +int mp_div(mp_int *a, mp_int *b, mp_int *c, mp_int *d); + +/* c = a mod b, 0 <= c < b */ +int mp_mod(mp_int *a, mp_int *b, mp_int *c); + +/* ---> single digit functions <--- */ + +/* compare against a single digit */ +int mp_cmp_d(mp_int *a, mp_digit b); + +/* c = a + b */ +int mp_add_d(mp_int *a, mp_digit b, mp_int *c); + +/* c = a - b */ +int mp_sub_d(mp_int *a, mp_digit b, mp_int *c); + +/* c = a * b */ +int mp_mul_d(mp_int *a, mp_digit b, mp_int *c); + +/* a/b => cb + d == a */ +int mp_div_d(mp_int *a, mp_digit b, mp_int *c, mp_digit *d); + +/* a/3 => 3c + d == a */ +int mp_div_3(mp_int *a, mp_int *c, mp_digit *d); + +/* c = a**b */ +int mp_expt_d(mp_int *a, mp_digit b, mp_int *c); + +/* c = a mod b, 0 <= c < b */ +int mp_mod_d(mp_int *a, mp_digit b, mp_digit *c); + +/* ---> number theory <--- */ + +/* d = a + b (mod c) */ +int mp_addmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); + +/* d = a - b (mod c) */ +int mp_submod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); + +/* d = a * b (mod c) */ +int mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); + +/* c = a * a (mod b) */ +int mp_sqrmod(mp_int *a, mp_int *b, mp_int *c); + +/* c = 1/a (mod b) */ +int mp_invmod(mp_int *a, mp_int *b, mp_int *c); + +/* c = (a, b) */ +int mp_gcd(mp_int *a, mp_int *b, mp_int *c); + +/* produces value such that U1*a + U2*b = U3 */ +int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3); + +/* c = [a, b] or (a*b)/(a, b) */ +int mp_lcm(mp_int *a, mp_int *b, mp_int *c); + +/* finds one of the b'th root of a, such that |c|**b <= |a| + * + * returns error if a < 0 and b is even + */ +int mp_n_root(mp_int *a, mp_digit b, mp_int *c); + +/* special sqrt algo */ +int mp_sqrt(mp_int *arg, mp_int *ret); + +/* is number a square? */ +int mp_is_square(mp_int *arg, int *ret); + +/* computes the jacobi c = (a | n) (or Legendre if b is prime) */ +int mp_jacobi(mp_int *a, mp_int *n, int *c); + +/* used to setup the Barrett reduction for a given modulus b */ +int mp_reduce_setup(mp_int *a, mp_int *b); + +/* Barrett Reduction, computes a (mod b) with a precomputed value c + * + * Assumes that 0 < a <= b*b, note if 0 > a > -(b*b) then you can merely + * compute the reduction as -1 * mp_reduce(mp_abs(a)) [pseudo code]. + */ +int mp_reduce(mp_int *a, mp_int *b, mp_int *c); + +/* setups the montgomery reduction */ +int mp_montgomery_setup(mp_int *a, mp_digit *mp); + +/* computes a = B**n mod b without division or multiplication useful for + * normalizing numbers in a Montgomery system. + */ +int mp_montgomery_calc_normalization(mp_int *a, mp_int *b); + +/* computes x/R == x (mod N) via Montgomery Reduction */ +int mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp); + +/* returns 1 if a is a valid DR modulus */ +int mp_dr_is_modulus(mp_int *a); + +/* sets the value of "d" required for mp_dr_reduce */ +void mp_dr_setup(mp_int *a, mp_digit *d); + +/* reduces a modulo b using the Diminished Radix method */ +int mp_dr_reduce(mp_int *a, mp_int *b, mp_digit mp); + +/* returns true if a can be reduced with mp_reduce_2k */ +int mp_reduce_is_2k(mp_int *a); + +/* determines k value for 2k reduction */ +int mp_reduce_2k_setup(mp_int *a, mp_digit *d); + +/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */ +int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d); + +/* returns true if a can be reduced with mp_reduce_2k_l */ +int mp_reduce_is_2k_l(mp_int *a); + +/* determines k value for 2k reduction */ +int mp_reduce_2k_setup_l(mp_int *a, mp_int *d); + +/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */ +int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d); + +/* d = a**b (mod c) */ +int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); + +/* ---> Primes <--- */ + +/* number of primes */ +#ifdef MP_8BIT + #define PRIME_SIZE 31 +#else + #define PRIME_SIZE 256 +#endif + +/* table of first PRIME_SIZE primes */ +extern const mp_digit ltm_prime_tab[]; + +/* result=1 if a is divisible by one of the first PRIME_SIZE primes */ +int mp_prime_is_divisible(mp_int *a, int *result); + +/* performs one Fermat test of "a" using base "b". + * Sets result to 0 if composite or 1 if probable prime + */ +int mp_prime_fermat(mp_int *a, mp_int *b, int *result); + +/* performs one Miller-Rabin test of "a" using base "b". + * Sets result to 0 if composite or 1 if probable prime + */ +int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result); + +/* This gives [for a given bit size] the number of trials required + * such that Miller-Rabin gives a prob of failure lower than 2^-96 + */ +int mp_prime_rabin_miller_trials(int size); + +/* performs t rounds of Miller-Rabin on "a" using the first + * t prime bases. Also performs an initial sieve of trial + * division. Determines if "a" is prime with probability + * of error no more than (1/4)**t. + * + * Sets result to 1 if probably prime, 0 otherwise + */ +int mp_prime_is_prime(mp_int *a, int t, int *result); + +/* finds the next prime after the number "a" using "t" trials + * of Miller-Rabin. + * + * bbs_style = 1 means the prime must be congruent to 3 mod 4 + */ +int mp_prime_next_prime(mp_int *a, int t, int bbs_style); + +/* makes a truly random prime of a given size (bytes), + * call with bbs = 1 if you want it to be congruent to 3 mod 4 + * + * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can + * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself + * so it can be NULL + * + * The prime generated will be larger than 2^(8*size). + */ +#define mp_prime_random(a, t, size, bbs, cb, dat) mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat) + +/* makes a truly random prime of a given size (bits), + * + * Flags are as follows: + * + * LTM_PRIME_BBS - make prime congruent to 3 mod 4 + * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS) + * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero + * LTM_PRIME_2MSB_ON - make the 2nd highest bit one + * + * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can + * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself + * so it can be NULL + * + */ +int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat); + +/* ---> radix conversion <--- */ +int mp_count_bits(mp_int *a); + +int mp_unsigned_bin_size(mp_int *a); +int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c); +int mp_to_unsigned_bin(mp_int *a, unsigned char *b); +int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); + +int mp_signed_bin_size(mp_int *a); +int mp_read_signed_bin(mp_int *a, const unsigned char *b, int c); +int mp_to_signed_bin(mp_int *a, unsigned char *b); +int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); + +int mp_read_radix(mp_int *a, const char *str, int radix); +int mp_toradix(mp_int *a, char *str, int radix); +int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen); +int mp_radix_size(mp_int *a, int radix, int *size); + +int mp_fread(mp_int *a, int radix, FILE *stream); +int mp_fwrite(mp_int *a, int radix, FILE *stream); + +#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len)) +#define mp_raw_size(mp) mp_signed_bin_size(mp) +#define mp_toraw(mp, str) mp_to_signed_bin((mp), (str)) +#define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len)) +#define mp_mag_size(mp) mp_unsigned_bin_size(mp) +#define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str)) + +#define mp_tobinary(M, S) mp_toradix((M), (S), 2) +#define mp_tooctal(M, S) mp_toradix((M), (S), 8) +#define mp_todecimal(M, S) mp_toradix((M), (S), 10) +#define mp_tohex(M, S) mp_toradix((M), (S), 16) + +/* lowlevel functions, do not call! */ +int s_mp_add(mp_int *a, mp_int *b, mp_int *c); +int s_mp_sub(mp_int *a, mp_int *b, mp_int *c); +#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1) +int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs); +int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs); +int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs); +int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs); +int fast_s_mp_sqr(mp_int *a, mp_int *b); +int s_mp_sqr(mp_int *a, mp_int *b); +int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c); +int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c); +int mp_karatsuba_sqr(mp_int *a, mp_int *b); +int mp_toom_sqr(mp_int *a, mp_int *b); +int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c); +int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c); +int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp); +int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode); +int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int mode); +void bn_reverse(unsigned char *s, int len); + +extern const char *mp_s_rmap; + +#ifdef __cplusplus + } +#endif + +#endif + + +/* $Source: /cvs/libtom/libtommath/tommath.h,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff --git a/dep/StormLib/src/libtommath/tommath_class.h b/dep/StormLib/src/libtommath/tommath_class.h new file mode 100644 index 000000000..18d1553de --- /dev/null +++ b/dep/StormLib/src/libtommath/tommath_class.h @@ -0,0 +1,999 @@ +#if !(defined(LTM1) && defined(LTM2) && defined(LTM3)) +#if defined(LTM2) +#define LTM3 +#endif +#if defined(LTM1) +#define LTM2 +#endif +#define LTM1 + +#if defined(LTM_ALL) +#define BN_ERROR_C +#define BN_FAST_MP_INVMOD_C +#define BN_FAST_MP_MONTGOMERY_REDUCE_C +#define BN_FAST_S_MP_MUL_DIGS_C +#define BN_FAST_S_MP_MUL_HIGH_DIGS_C +#define BN_FAST_S_MP_SQR_C +#define BN_MP_2EXPT_C +#define BN_MP_ABS_C +#define BN_MP_ADD_C +#define BN_MP_ADD_D_C +#define BN_MP_ADDMOD_C +#define BN_MP_AND_C +#define BN_MP_CLAMP_C +#define BN_MP_CLEAR_C +#define BN_MP_CLEAR_MULTI_C +#define BN_MP_CMP_C +#define BN_MP_CMP_D_C +#define BN_MP_CMP_MAG_C +#define BN_MP_CNT_LSB_C +#define BN_MP_COPY_C +#define BN_MP_COUNT_BITS_C +#define BN_MP_DIV_C +#define BN_MP_DIV_2_C +#define BN_MP_DIV_2D_C +#define BN_MP_DIV_3_C +#define BN_MP_DIV_D_C +#define BN_MP_DR_IS_MODULUS_C +#define BN_MP_DR_REDUCE_C +#define BN_MP_DR_SETUP_C +#define BN_MP_EXCH_C +#define BN_MP_EXPT_D_C +#define BN_MP_EXPTMOD_C +#define BN_MP_EXPTMOD_FAST_C +#define BN_MP_EXTEUCLID_C +#define BN_MP_FREAD_C +#define BN_MP_FWRITE_C +#define BN_MP_GCD_C +#define BN_MP_GET_INT_C +#define BN_MP_GROW_C +#define BN_MP_INIT_C +#define BN_MP_INIT_COPY_C +#define BN_MP_INIT_MULTI_C +#define BN_MP_INIT_SET_C +#define BN_MP_INIT_SET_INT_C +#define BN_MP_INIT_SIZE_C +#define BN_MP_INVMOD_C +#define BN_MP_INVMOD_SLOW_C +#define BN_MP_IS_SQUARE_C +#define BN_MP_JACOBI_C +#define BN_MP_KARATSUBA_MUL_C +#define BN_MP_KARATSUBA_SQR_C +#define BN_MP_LCM_C +#define BN_MP_LSHD_C +#define BN_MP_MOD_C +#define BN_MP_MOD_2D_C +#define BN_MP_MOD_D_C +#define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C +#define BN_MP_MONTGOMERY_REDUCE_C +#define BN_MP_MONTGOMERY_SETUP_C +#define BN_MP_MUL_C +#define BN_MP_MUL_2_C +#define BN_MP_MUL_2D_C +#define BN_MP_MUL_D_C +#define BN_MP_MULMOD_C +#define BN_MP_N_ROOT_C +#define BN_MP_NEG_C +#define BN_MP_OR_C +#define BN_MP_PRIME_FERMAT_C +#define BN_MP_PRIME_IS_DIVISIBLE_C +#define BN_MP_PRIME_IS_PRIME_C +#define BN_MP_PRIME_MILLER_RABIN_C +#define BN_MP_PRIME_NEXT_PRIME_C +#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C +#define BN_MP_PRIME_RANDOM_EX_C +#define BN_MP_RADIX_SIZE_C +#define BN_MP_RADIX_SMAP_C +#define BN_MP_RAND_C +#define BN_MP_READ_RADIX_C +#define BN_MP_READ_SIGNED_BIN_C +#define BN_MP_READ_UNSIGNED_BIN_C +#define BN_MP_REDUCE_C +#define BN_MP_REDUCE_2K_C +#define BN_MP_REDUCE_2K_L_C +#define BN_MP_REDUCE_2K_SETUP_C +#define BN_MP_REDUCE_2K_SETUP_L_C +#define BN_MP_REDUCE_IS_2K_C +#define BN_MP_REDUCE_IS_2K_L_C +#define BN_MP_REDUCE_SETUP_C +#define BN_MP_RSHD_C +#define BN_MP_SET_C +#define BN_MP_SET_INT_C +#define BN_MP_SHRINK_C +#define BN_MP_SIGNED_BIN_SIZE_C +#define BN_MP_SQR_C +#define BN_MP_SQRMOD_C +#define BN_MP_SQRT_C +#define BN_MP_SUB_C +#define BN_MP_SUB_D_C +#define BN_MP_SUBMOD_C +#define BN_MP_TO_SIGNED_BIN_C +#define BN_MP_TO_SIGNED_BIN_N_C +#define BN_MP_TO_UNSIGNED_BIN_C +#define BN_MP_TO_UNSIGNED_BIN_N_C +#define BN_MP_TOOM_MUL_C +#define BN_MP_TOOM_SQR_C +#define BN_MP_TORADIX_C +#define BN_MP_TORADIX_N_C +#define BN_MP_UNSIGNED_BIN_SIZE_C +#define BN_MP_XOR_C +#define BN_MP_ZERO_C +#define BN_PRIME_TAB_C +#define BN_REVERSE_C +#define BN_S_MP_ADD_C +#define BN_S_MP_EXPTMOD_C +#define BN_S_MP_MUL_DIGS_C +#define BN_S_MP_MUL_HIGH_DIGS_C +#define BN_S_MP_SQR_C +#define BN_S_MP_SUB_C +#define BNCORE_C +#endif + +#if defined(BN_ERROR_C) + #define BN_MP_ERROR_TO_STRING_C +#endif + +#if defined(BN_FAST_MP_INVMOD_C) + #define BN_MP_ISEVEN_C + #define BN_MP_INIT_MULTI_C + #define BN_MP_COPY_C + #define BN_MP_MOD_C + #define BN_MP_SET_C + #define BN_MP_DIV_2_C + #define BN_MP_ISODD_C + #define BN_MP_SUB_C + #define BN_MP_CMP_C + #define BN_MP_ISZERO_C + #define BN_MP_CMP_D_C + #define BN_MP_ADD_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_MULTI_C +#endif + +#if defined(BN_FAST_MP_MONTGOMERY_REDUCE_C) + #define BN_MP_GROW_C + #define BN_MP_RSHD_C + #define BN_MP_CLAMP_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C +#endif + +#if defined(BN_FAST_S_MP_MUL_DIGS_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_FAST_S_MP_SQR_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_2EXPT_C) + #define BN_MP_ZERO_C + #define BN_MP_GROW_C +#endif + +#if defined(BN_MP_ABS_C) + #define BN_MP_COPY_C +#endif + +#if defined(BN_MP_ADD_C) + #define BN_S_MP_ADD_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C +#endif + +#if defined(BN_MP_ADD_D_C) + #define BN_MP_GROW_C + #define BN_MP_SUB_D_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_ADDMOD_C) + #define BN_MP_INIT_C + #define BN_MP_ADD_C + #define BN_MP_CLEAR_C + #define BN_MP_MOD_C +#endif + +#if defined(BN_MP_AND_C) + #define BN_MP_INIT_COPY_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_CLAMP_C) +#endif + +#if defined(BN_MP_CLEAR_C) +#endif + +#if defined(BN_MP_CLEAR_MULTI_C) + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_CMP_C) + #define BN_MP_CMP_MAG_C +#endif + +#if defined(BN_MP_CMP_D_C) +#endif + +#if defined(BN_MP_CMP_MAG_C) +#endif + +#if defined(BN_MP_CNT_LSB_C) + #define BN_MP_ISZERO_C +#endif + +#if defined(BN_MP_COPY_C) + #define BN_MP_GROW_C +#endif + +#if defined(BN_MP_COUNT_BITS_C) +#endif + +#if defined(BN_MP_DIV_C) + #define BN_MP_ISZERO_C + #define BN_MP_CMP_MAG_C + #define BN_MP_COPY_C + #define BN_MP_ZERO_C + #define BN_MP_INIT_MULTI_C + #define BN_MP_SET_C + #define BN_MP_COUNT_BITS_C + #define BN_MP_ABS_C + #define BN_MP_MUL_2D_C + #define BN_MP_CMP_C + #define BN_MP_SUB_C + #define BN_MP_ADD_C + #define BN_MP_DIV_2D_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_MULTI_C + #define BN_MP_INIT_SIZE_C + #define BN_MP_INIT_C + #define BN_MP_INIT_COPY_C + #define BN_MP_LSHD_C + #define BN_MP_RSHD_C + #define BN_MP_MUL_D_C + #define BN_MP_CLAMP_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_DIV_2_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_DIV_2D_C) + #define BN_MP_COPY_C + #define BN_MP_ZERO_C + #define BN_MP_INIT_C + #define BN_MP_MOD_2D_C + #define BN_MP_CLEAR_C + #define BN_MP_RSHD_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C +#endif + +#if defined(BN_MP_DIV_3_C) + #define BN_MP_INIT_SIZE_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_DIV_D_C) + #define BN_MP_ISZERO_C + #define BN_MP_COPY_C + #define BN_MP_DIV_2D_C + #define BN_MP_DIV_3_C + #define BN_MP_INIT_SIZE_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_DR_IS_MODULUS_C) +#endif + +#if defined(BN_MP_DR_REDUCE_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C +#endif + +#if defined(BN_MP_DR_SETUP_C) +#endif + +#if defined(BN_MP_EXCH_C) +#endif + +#if defined(BN_MP_EXPT_D_C) + #define BN_MP_INIT_COPY_C + #define BN_MP_SET_C + #define BN_MP_SQR_C + #define BN_MP_CLEAR_C + #define BN_MP_MUL_C +#endif + +#if defined(BN_MP_EXPTMOD_C) + #define BN_MP_INIT_C + #define BN_MP_INVMOD_C + #define BN_MP_CLEAR_C + #define BN_MP_ABS_C + #define BN_MP_CLEAR_MULTI_C + #define BN_MP_REDUCE_IS_2K_L_C + #define BN_S_MP_EXPTMOD_C + #define BN_MP_DR_IS_MODULUS_C + #define BN_MP_REDUCE_IS_2K_C + #define BN_MP_ISODD_C + #define BN_MP_EXPTMOD_FAST_C +#endif + +#if defined(BN_MP_EXPTMOD_FAST_C) + #define BN_MP_COUNT_BITS_C + #define BN_MP_INIT_C + #define BN_MP_CLEAR_C + #define BN_MP_MONTGOMERY_SETUP_C + #define BN_FAST_MP_MONTGOMERY_REDUCE_C + #define BN_MP_MONTGOMERY_REDUCE_C + #define BN_MP_DR_SETUP_C + #define BN_MP_DR_REDUCE_C + #define BN_MP_REDUCE_2K_SETUP_C + #define BN_MP_REDUCE_2K_C + #define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C + #define BN_MP_MULMOD_C + #define BN_MP_SET_C + #define BN_MP_MOD_C + #define BN_MP_COPY_C + #define BN_MP_SQR_C + #define BN_MP_MUL_C + #define BN_MP_EXCH_C +#endif + +#if defined(BN_MP_EXTEUCLID_C) + #define BN_MP_INIT_MULTI_C + #define BN_MP_SET_C + #define BN_MP_COPY_C + #define BN_MP_ISZERO_C + #define BN_MP_DIV_C + #define BN_MP_MUL_C + #define BN_MP_SUB_C + #define BN_MP_NEG_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_MULTI_C +#endif + +#if defined(BN_MP_FREAD_C) + #define BN_MP_ZERO_C + #define BN_MP_S_RMAP_C + #define BN_MP_MUL_D_C + #define BN_MP_ADD_D_C + #define BN_MP_CMP_D_C +#endif + +#if defined(BN_MP_FWRITE_C) + #define BN_MP_RADIX_SIZE_C + #define BN_MP_TORADIX_C +#endif + +#if defined(BN_MP_GCD_C) + #define BN_MP_ISZERO_C + #define BN_MP_ABS_C + #define BN_MP_ZERO_C + #define BN_MP_INIT_COPY_C + #define BN_MP_CNT_LSB_C + #define BN_MP_DIV_2D_C + #define BN_MP_CMP_MAG_C + #define BN_MP_EXCH_C + #define BN_S_MP_SUB_C + #define BN_MP_MUL_2D_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_GET_INT_C) +#endif + +#if defined(BN_MP_GROW_C) +#endif + +#if defined(BN_MP_INIT_C) +#endif + +#if defined(BN_MP_INIT_COPY_C) + #define BN_MP_COPY_C +#endif + +#if defined(BN_MP_INIT_MULTI_C) + #define BN_MP_ERR_C + #define BN_MP_INIT_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_INIT_SET_C) + #define BN_MP_INIT_C + #define BN_MP_SET_C +#endif + +#if defined(BN_MP_INIT_SET_INT_C) + #define BN_MP_INIT_C + #define BN_MP_SET_INT_C +#endif + +#if defined(BN_MP_INIT_SIZE_C) + #define BN_MP_INIT_C +#endif + +#if defined(BN_MP_INVMOD_C) + #define BN_MP_ISZERO_C + #define BN_MP_ISODD_C + #define BN_FAST_MP_INVMOD_C + #define BN_MP_INVMOD_SLOW_C +#endif + +#if defined(BN_MP_INVMOD_SLOW_C) + #define BN_MP_ISZERO_C + #define BN_MP_INIT_MULTI_C + #define BN_MP_MOD_C + #define BN_MP_COPY_C + #define BN_MP_ISEVEN_C + #define BN_MP_SET_C + #define BN_MP_DIV_2_C + #define BN_MP_ISODD_C + #define BN_MP_ADD_C + #define BN_MP_SUB_C + #define BN_MP_CMP_C + #define BN_MP_CMP_D_C + #define BN_MP_CMP_MAG_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_MULTI_C +#endif + +#if defined(BN_MP_IS_SQUARE_C) + #define BN_MP_MOD_D_C + #define BN_MP_INIT_SET_INT_C + #define BN_MP_MOD_C + #define BN_MP_GET_INT_C + #define BN_MP_SQRT_C + #define BN_MP_SQR_C + #define BN_MP_CMP_MAG_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_JACOBI_C) + #define BN_MP_CMP_D_C + #define BN_MP_ISZERO_C + #define BN_MP_INIT_COPY_C + #define BN_MP_CNT_LSB_C + #define BN_MP_DIV_2D_C + #define BN_MP_MOD_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_KARATSUBA_MUL_C) + #define BN_MP_MUL_C + #define BN_MP_INIT_SIZE_C + #define BN_MP_CLAMP_C + #define BN_MP_SUB_C + #define BN_MP_ADD_C + #define BN_MP_LSHD_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_KARATSUBA_SQR_C) + #define BN_MP_INIT_SIZE_C + #define BN_MP_CLAMP_C + #define BN_MP_SQR_C + #define BN_MP_SUB_C + #define BN_S_MP_ADD_C + #define BN_MP_LSHD_C + #define BN_MP_ADD_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_LCM_C) + #define BN_MP_INIT_MULTI_C + #define BN_MP_GCD_C + #define BN_MP_CMP_MAG_C + #define BN_MP_DIV_C + #define BN_MP_MUL_C + #define BN_MP_CLEAR_MULTI_C +#endif + +#if defined(BN_MP_LSHD_C) + #define BN_MP_GROW_C + #define BN_MP_RSHD_C +#endif + +#if defined(BN_MP_MOD_C) + #define BN_MP_INIT_C + #define BN_MP_DIV_C + #define BN_MP_CLEAR_C + #define BN_MP_ADD_C + #define BN_MP_EXCH_C +#endif + +#if defined(BN_MP_MOD_2D_C) + #define BN_MP_ZERO_C + #define BN_MP_COPY_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_MOD_D_C) + #define BN_MP_DIV_D_C +#endif + +#if defined(BN_MP_MONTGOMERY_CALC_NORMALIZATION_C) + #define BN_MP_COUNT_BITS_C + #define BN_MP_2EXPT_C + #define BN_MP_SET_C + #define BN_MP_MUL_2_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C +#endif + +#if defined(BN_MP_MONTGOMERY_REDUCE_C) + #define BN_FAST_MP_MONTGOMERY_REDUCE_C + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C + #define BN_MP_RSHD_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C +#endif + +#if defined(BN_MP_MONTGOMERY_SETUP_C) +#endif + +#if defined(BN_MP_MUL_C) + #define BN_MP_TOOM_MUL_C + #define BN_MP_KARATSUBA_MUL_C + #define BN_FAST_S_MP_MUL_DIGS_C + #define BN_S_MP_MUL_C + #define BN_S_MP_MUL_DIGS_C +#endif + +#if defined(BN_MP_MUL_2_C) + #define BN_MP_GROW_C +#endif + +#if defined(BN_MP_MUL_2D_C) + #define BN_MP_COPY_C + #define BN_MP_GROW_C + #define BN_MP_LSHD_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_MUL_D_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_MULMOD_C) + #define BN_MP_INIT_C + #define BN_MP_MUL_C + #define BN_MP_CLEAR_C + #define BN_MP_MOD_C +#endif + +#if defined(BN_MP_N_ROOT_C) + #define BN_MP_INIT_C + #define BN_MP_SET_C + #define BN_MP_COPY_C + #define BN_MP_EXPT_D_C + #define BN_MP_MUL_C + #define BN_MP_SUB_C + #define BN_MP_MUL_D_C + #define BN_MP_DIV_C + #define BN_MP_CMP_C + #define BN_MP_SUB_D_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_NEG_C) + #define BN_MP_COPY_C + #define BN_MP_ISZERO_C +#endif + +#if defined(BN_MP_OR_C) + #define BN_MP_INIT_COPY_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_PRIME_FERMAT_C) + #define BN_MP_CMP_D_C + #define BN_MP_INIT_C + #define BN_MP_EXPTMOD_C + #define BN_MP_CMP_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_PRIME_IS_DIVISIBLE_C) + #define BN_MP_MOD_D_C +#endif + +#if defined(BN_MP_PRIME_IS_PRIME_C) + #define BN_MP_CMP_D_C + #define BN_MP_PRIME_IS_DIVISIBLE_C + #define BN_MP_INIT_C + #define BN_MP_SET_C + #define BN_MP_PRIME_MILLER_RABIN_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_PRIME_MILLER_RABIN_C) + #define BN_MP_CMP_D_C + #define BN_MP_INIT_COPY_C + #define BN_MP_SUB_D_C + #define BN_MP_CNT_LSB_C + #define BN_MP_DIV_2D_C + #define BN_MP_EXPTMOD_C + #define BN_MP_CMP_C + #define BN_MP_SQRMOD_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_PRIME_NEXT_PRIME_C) + #define BN_MP_CMP_D_C + #define BN_MP_SET_C + #define BN_MP_SUB_D_C + #define BN_MP_ISEVEN_C + #define BN_MP_MOD_D_C + #define BN_MP_INIT_C + #define BN_MP_ADD_D_C + #define BN_MP_PRIME_MILLER_RABIN_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_PRIME_RABIN_MILLER_TRIALS_C) +#endif + +#if defined(BN_MP_PRIME_RANDOM_EX_C) + #define BN_MP_READ_UNSIGNED_BIN_C + #define BN_MP_PRIME_IS_PRIME_C + #define BN_MP_SUB_D_C + #define BN_MP_DIV_2_C + #define BN_MP_MUL_2_C + #define BN_MP_ADD_D_C +#endif + +#if defined(BN_MP_RADIX_SIZE_C) + #define BN_MP_COUNT_BITS_C + #define BN_MP_INIT_COPY_C + #define BN_MP_ISZERO_C + #define BN_MP_DIV_D_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_RADIX_SMAP_C) + #define BN_MP_S_RMAP_C +#endif + +#if defined(BN_MP_RAND_C) + #define BN_MP_ZERO_C + #define BN_MP_ADD_D_C + #define BN_MP_LSHD_C +#endif + +#if defined(BN_MP_READ_RADIX_C) + #define BN_MP_ZERO_C + #define BN_MP_S_RMAP_C + #define BN_MP_RADIX_SMAP_C + #define BN_MP_MUL_D_C + #define BN_MP_ADD_D_C + #define BN_MP_ISZERO_C +#endif + +#if defined(BN_MP_READ_SIGNED_BIN_C) + #define BN_MP_READ_UNSIGNED_BIN_C +#endif + +#if defined(BN_MP_READ_UNSIGNED_BIN_C) + #define BN_MP_GROW_C + #define BN_MP_ZERO_C + #define BN_MP_MUL_2D_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_REDUCE_C) + #define BN_MP_REDUCE_SETUP_C + #define BN_MP_INIT_COPY_C + #define BN_MP_RSHD_C + #define BN_MP_MUL_C + #define BN_S_MP_MUL_HIGH_DIGS_C + #define BN_FAST_S_MP_MUL_HIGH_DIGS_C + #define BN_MP_MOD_2D_C + #define BN_S_MP_MUL_DIGS_C + #define BN_MP_SUB_C + #define BN_MP_CMP_D_C + #define BN_MP_SET_C + #define BN_MP_LSHD_C + #define BN_MP_ADD_C + #define BN_MP_CMP_C + #define BN_S_MP_SUB_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_REDUCE_2K_C) + #define BN_MP_INIT_C + #define BN_MP_COUNT_BITS_C + #define BN_MP_DIV_2D_C + #define BN_MP_MUL_D_C + #define BN_S_MP_ADD_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_REDUCE_2K_L_C) + #define BN_MP_INIT_C + #define BN_MP_COUNT_BITS_C + #define BN_MP_DIV_2D_C + #define BN_MP_MUL_C + #define BN_S_MP_ADD_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_REDUCE_2K_SETUP_C) + #define BN_MP_INIT_C + #define BN_MP_COUNT_BITS_C + #define BN_MP_2EXPT_C + #define BN_MP_CLEAR_C + #define BN_S_MP_SUB_C +#endif + +#if defined(BN_MP_REDUCE_2K_SETUP_L_C) + #define BN_MP_INIT_C + #define BN_MP_2EXPT_C + #define BN_MP_COUNT_BITS_C + #define BN_S_MP_SUB_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_REDUCE_IS_2K_C) + #define BN_MP_REDUCE_2K_C + #define BN_MP_COUNT_BITS_C +#endif + +#if defined(BN_MP_REDUCE_IS_2K_L_C) +#endif + +#if defined(BN_MP_REDUCE_SETUP_C) + #define BN_MP_2EXPT_C + #define BN_MP_DIV_C +#endif + +#if defined(BN_MP_RSHD_C) + #define BN_MP_ZERO_C +#endif + +#if defined(BN_MP_SET_C) + #define BN_MP_ZERO_C +#endif + +#if defined(BN_MP_SET_INT_C) + #define BN_MP_ZERO_C + #define BN_MP_MUL_2D_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_SHRINK_C) +#endif + +#if defined(BN_MP_SIGNED_BIN_SIZE_C) + #define BN_MP_UNSIGNED_BIN_SIZE_C +#endif + +#if defined(BN_MP_SQR_C) + #define BN_MP_TOOM_SQR_C + #define BN_MP_KARATSUBA_SQR_C + #define BN_FAST_S_MP_SQR_C + #define BN_S_MP_SQR_C +#endif + +#if defined(BN_MP_SQRMOD_C) + #define BN_MP_INIT_C + #define BN_MP_SQR_C + #define BN_MP_CLEAR_C + #define BN_MP_MOD_C +#endif + +#if defined(BN_MP_SQRT_C) + #define BN_MP_N_ROOT_C + #define BN_MP_ISZERO_C + #define BN_MP_ZERO_C + #define BN_MP_INIT_COPY_C + #define BN_MP_RSHD_C + #define BN_MP_DIV_C + #define BN_MP_ADD_C + #define BN_MP_DIV_2_C + #define BN_MP_CMP_MAG_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_SUB_C) + #define BN_S_MP_ADD_C + #define BN_MP_CMP_MAG_C + #define BN_S_MP_SUB_C +#endif + +#if defined(BN_MP_SUB_D_C) + #define BN_MP_GROW_C + #define BN_MP_ADD_D_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_MP_SUBMOD_C) + #define BN_MP_INIT_C + #define BN_MP_SUB_C + #define BN_MP_CLEAR_C + #define BN_MP_MOD_C +#endif + +#if defined(BN_MP_TO_SIGNED_BIN_C) + #define BN_MP_TO_UNSIGNED_BIN_C +#endif + +#if defined(BN_MP_TO_SIGNED_BIN_N_C) + #define BN_MP_SIGNED_BIN_SIZE_C + #define BN_MP_TO_SIGNED_BIN_C +#endif + +#if defined(BN_MP_TO_UNSIGNED_BIN_C) + #define BN_MP_INIT_COPY_C + #define BN_MP_ISZERO_C + #define BN_MP_DIV_2D_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_TO_UNSIGNED_BIN_N_C) + #define BN_MP_UNSIGNED_BIN_SIZE_C + #define BN_MP_TO_UNSIGNED_BIN_C +#endif + +#if defined(BN_MP_TOOM_MUL_C) + #define BN_MP_INIT_MULTI_C + #define BN_MP_MOD_2D_C + #define BN_MP_COPY_C + #define BN_MP_RSHD_C + #define BN_MP_MUL_C + #define BN_MP_MUL_2_C + #define BN_MP_ADD_C + #define BN_MP_SUB_C + #define BN_MP_DIV_2_C + #define BN_MP_MUL_2D_C + #define BN_MP_MUL_D_C + #define BN_MP_DIV_3_C + #define BN_MP_LSHD_C + #define BN_MP_CLEAR_MULTI_C +#endif + +#if defined(BN_MP_TOOM_SQR_C) + #define BN_MP_INIT_MULTI_C + #define BN_MP_MOD_2D_C + #define BN_MP_COPY_C + #define BN_MP_RSHD_C + #define BN_MP_SQR_C + #define BN_MP_MUL_2_C + #define BN_MP_ADD_C + #define BN_MP_SUB_C + #define BN_MP_DIV_2_C + #define BN_MP_MUL_2D_C + #define BN_MP_MUL_D_C + #define BN_MP_DIV_3_C + #define BN_MP_LSHD_C + #define BN_MP_CLEAR_MULTI_C +#endif + +#if defined(BN_MP_TORADIX_C) + #define BN_MP_ISZERO_C + #define BN_MP_INIT_COPY_C + #define BN_MP_DIV_D_C + #define BN_MP_CLEAR_C + #define BN_MP_S_RMAP_C +#endif + +#if defined(BN_MP_TORADIX_N_C) + #define BN_MP_ISZERO_C + #define BN_MP_INIT_COPY_C + #define BN_MP_DIV_D_C + #define BN_MP_CLEAR_C + #define BN_MP_S_RMAP_C +#endif + +#if defined(BN_MP_UNSIGNED_BIN_SIZE_C) + #define BN_MP_COUNT_BITS_C +#endif + +#if defined(BN_MP_XOR_C) + #define BN_MP_INIT_COPY_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_MP_ZERO_C) +#endif + +#if defined(BN_PRIME_TAB_C) +#endif + +#if defined(BN_REVERSE_C) +#endif + +#if defined(BN_S_MP_ADD_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BN_S_MP_EXPTMOD_C) + #define BN_MP_COUNT_BITS_C + #define BN_MP_INIT_C + #define BN_MP_CLEAR_C + #define BN_MP_REDUCE_SETUP_C + #define BN_MP_REDUCE_C + #define BN_MP_REDUCE_2K_SETUP_L_C + #define BN_MP_REDUCE_2K_L_C + #define BN_MP_MOD_C + #define BN_MP_COPY_C + #define BN_MP_SQR_C + #define BN_MP_MUL_C + #define BN_MP_SET_C + #define BN_MP_EXCH_C +#endif + +#if defined(BN_S_MP_MUL_DIGS_C) + #define BN_FAST_S_MP_MUL_DIGS_C + #define BN_MP_INIT_SIZE_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_S_MP_MUL_HIGH_DIGS_C) + #define BN_FAST_S_MP_MUL_HIGH_DIGS_C + #define BN_MP_INIT_SIZE_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_S_MP_SQR_C) + #define BN_MP_INIT_SIZE_C + #define BN_MP_CLAMP_C + #define BN_MP_EXCH_C + #define BN_MP_CLEAR_C +#endif + +#if defined(BN_S_MP_SUB_C) + #define BN_MP_GROW_C + #define BN_MP_CLAMP_C +#endif + +#if defined(BNCORE_C) +#endif + +#ifdef LTM3 +#define LTM_LAST +#endif +#include "tommath_superclass.h" +#include "tommath_class.h" +#else +#define LTM_LAST +#endif + +/* $Source: /cvs/libtom/libtommath/tommath_class.h,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2005/07/28 11:59:32 $ */ diff --git a/dep/StormLib/src/libtommath/tommath_superclass.h b/dep/StormLib/src/libtommath/tommath_superclass.h new file mode 100644 index 000000000..2fdebe683 --- /dev/null +++ b/dep/StormLib/src/libtommath/tommath_superclass.h @@ -0,0 +1,76 @@ +/* super class file for PK algos */ + +/* default ... include all MPI */ +#define LTM_ALL + +/* RSA only (does not support DH/DSA/ECC) */ +/* #define SC_RSA_1 */ + +/* For reference.... On an Athlon64 optimizing for speed... + + LTM's mpi.o with all functions [striped] is 142KiB in size. + +*/ + +/* Works for RSA only, mpi.o is 68KiB */ +#ifdef SC_RSA_1 + #define BN_MP_SHRINK_C + #define BN_MP_LCM_C + #define BN_MP_PRIME_RANDOM_EX_C + #define BN_MP_INVMOD_C + #define BN_MP_GCD_C + #define BN_MP_MOD_C + #define BN_MP_MULMOD_C + #define BN_MP_ADDMOD_C + #define BN_MP_EXPTMOD_C + #define BN_MP_SET_INT_C + #define BN_MP_INIT_MULTI_C + #define BN_MP_CLEAR_MULTI_C + #define BN_MP_UNSIGNED_BIN_SIZE_C + #define BN_MP_TO_UNSIGNED_BIN_C + #define BN_MP_MOD_D_C + #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C + #define BN_REVERSE_C + #define BN_PRIME_TAB_C + + /* other modifiers */ + #define BN_MP_DIV_SMALL /* Slower division, not critical */ + + /* here we are on the last pass so we turn things off. The functions classes are still there + * but we remove them specifically from the build. This also invokes tweaks in functions + * like removing support for even moduli, etc... + */ +#ifdef LTM_LAST + #undef BN_MP_TOOM_MUL_C + #undef BN_MP_TOOM_SQR_C + #undef BN_MP_KARATSUBA_MUL_C + #undef BN_MP_KARATSUBA_SQR_C + #undef BN_MP_REDUCE_C + #undef BN_MP_REDUCE_SETUP_C + #undef BN_MP_DR_IS_MODULUS_C + #undef BN_MP_DR_SETUP_C + #undef BN_MP_DR_REDUCE_C + #undef BN_MP_REDUCE_IS_2K_C + #undef BN_MP_REDUCE_2K_SETUP_C + #undef BN_MP_REDUCE_2K_C + #undef BN_S_MP_EXPTMOD_C + #undef BN_MP_DIV_3_C + #undef BN_S_MP_MUL_HIGH_DIGS_C + #undef BN_FAST_S_MP_MUL_HIGH_DIGS_C + #undef BN_FAST_MP_INVMOD_C + + /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold + * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] + * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without + * trouble. + */ + #undef BN_S_MP_MUL_DIGS_C + #undef BN_S_MP_SQR_C + #undef BN_MP_MONTGOMERY_REDUCE_C +#endif + +#endif + +/* $Source: /cvs/libtom/libtommath/tommath_superclass.h,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2005/05/14 13:29:17 $ */ diff --git a/dep/StormLib/src/pklib/explode.c b/dep/StormLib/src/pklib/explode.c index 979617399..510845c42 100644 --- a/dep/StormLib/src/pklib/explode.c +++ b/dep/StormLib/src/pklib/explode.c @@ -16,7 +16,7 @@ #include "pklib.h" -#define PKDCL_OK 0 +#define PKDCL_OK 0 #define PKDCL_STREAM_END 1 // All data from the input stream is read #define PKDCL_NEED_DICT 2 // Need more data (dictionary) #define PKDCL_CONTINUE 10 // Internal flag, not returned to user @@ -31,7 +31,7 @@ char CopyrightPkware[] = "PKWARE Data Compression Library for Win32\r\n" //----------------------------------------------------------------------------- // Tables -static unsigned char DistBits[] = +static unsigned char DistBits[] = { 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, @@ -39,7 +39,7 @@ static unsigned char DistBits[] = 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }; -static unsigned char DistCode[] = +static unsigned char DistCode[] = { 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, @@ -88,7 +88,7 @@ static unsigned char ChBitsAsc[] = 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D }; -static unsigned short ChCodeAsc[] = +static unsigned short ChCodeAsc[] = { 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, @@ -121,7 +121,7 @@ static unsigned short ChCodeAsc[] = 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 + 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 }; //----------------------------------------------------------------------------- @@ -133,8 +133,8 @@ static void GenDecodeTabs( unsigned char * length_bits, // [in] Table of lengths. Each length is stored as number of bits size_t elements) // [in] Number of elements in start_indexes and length_bits { - unsigned int index; - unsigned int length; + unsigned long index; + unsigned long length; size_t i; for(i = 0; i < elements; i++) @@ -151,7 +151,7 @@ static void GenDecodeTabs( static void GenAscTabs(TDcmpStruct * pWork) { unsigned short * pChCodeAsc = &ChCodeAsc[0xFF]; - unsigned int acc, add; + unsigned long acc, add; unsigned short count; for(count = 0x00FF; pChCodeAsc >= ChCodeAsc; pChCodeAsc--, count--) @@ -227,7 +227,7 @@ static void GenAscTabs(TDcmpStruct * pWork) // Returns: PKDCL_OK: Operation was successful // PKDCL_STREAM_END: There are no more bits in the input buffer -static int WasteBits(TDcmpStruct * pWork, unsigned int nBits) +static int WasteBits(TDcmpStruct * pWork, unsigned long nBits) { // If number of bits required is less than number of (bits in the buffer) ? if(nBits <= pWork->extra_bits) @@ -267,22 +267,22 @@ static int WasteBits(TDcmpStruct * pWork, unsigned int nBits) // 0x305: End of stream // 0x306: Error -static unsigned int DecodeLit(TDcmpStruct * pWork) +static unsigned long DecodeLit(TDcmpStruct * pWork) { - unsigned int extra_length_bits; // Number of bits of extra literal length - unsigned int length_code; // Length code - unsigned int value; + unsigned long extra_length_bits; // Number of bits of extra literal length + unsigned long length_code; // Length code + unsigned long value; // Test the current bit in byte buffer. If is not set, simply return the next 8 bits. if(pWork->bit_buff & 1) { // Remove one bit from the input data if(WasteBits(pWork, 1)) - return 0x306; - + return 0x306; + // The next 8 bits hold the index to the length code table length_code = pWork->LengthCodes[pWork->bit_buff & 0xFF]; - + // Remove the apropriate number of bits if(WasteBits(pWork, pWork->LenBits[length_code])) return 0x306; @@ -290,7 +290,7 @@ static unsigned int DecodeLit(TDcmpStruct * pWork) // Are there some extra bits for the obtained length code ? if((extra_length_bits = pWork->ExLenBits[length_code]) != 0) { - unsigned int extra_length = pWork->bit_buff & ((1 << extra_length_bits) - 1); + unsigned long extra_length = pWork->bit_buff & ((1 << extra_length_bits) - 1); if(WasteBits(pWork, extra_length_bits)) { @@ -312,7 +312,7 @@ static unsigned int DecodeLit(TDcmpStruct * pWork) // If the binary compression type, read 8 bits and return them as one byte. if(pWork->ctype == CMP_BINARY) { - unsigned int uncompressed_byte = pWork->bit_buff & 0xFF; + unsigned long uncompressed_byte = pWork->bit_buff & 0xFF; if(WasteBits(pWork, 8)) return 0x306; @@ -357,11 +357,11 @@ static unsigned int DecodeLit(TDcmpStruct * pWork) // Decodes the distance of the repetition, backwards relative to the // current output buffer position -static unsigned int DecodeDist(TDcmpStruct * pWork, unsigned int rep_length) +static unsigned long DecodeDist(TDcmpStruct * pWork, unsigned long rep_length) { - unsigned int dist_pos_code; // Distance position code - unsigned int dist_pos_bits; // Number of bits of distance position - unsigned int distance; // Distance position + unsigned long dist_pos_code; // Distance position code + unsigned long dist_pos_bits; // Number of bits of distance position + unsigned long distance; // Distance position // Next 2-8 bits in the input buffer is the distance position code dist_pos_code = pWork->DistPosCodes[pWork->bit_buff & 0xFF]; @@ -388,10 +388,10 @@ static unsigned int DecodeDist(TDcmpStruct * pWork, unsigned int rep_length) return distance + 1; } -static unsigned int Expand(TDcmpStruct * pWork) +static unsigned long Expand(TDcmpStruct * pWork) { - unsigned int next_literal; // Literal decoded from the compressed data - unsigned int result; // Value to be returned + unsigned long next_literal; // Literal decoded from the compressed data + unsigned long result; // Value to be returned unsigned int copyBytes; // Number of bytes to copy to the output buffer pWork->outputPos = 0x1000; // Initialize output buffer position @@ -412,8 +412,8 @@ static unsigned int Expand(TDcmpStruct * pWork) { unsigned char * source; unsigned char * target; - unsigned int rep_length; // Length of the repetition, in bytes - unsigned int minus_dist; // Backward distance to the repetition, relative to the current buffer position + unsigned long rep_length; // Length of the repetition, in bytes + unsigned long minus_dist; // Backward distance to the repetition, relative to the current buffer position // Get the length of the repeating sequence. // Note that the repeating block may overlap the current output position, @@ -442,7 +442,7 @@ static unsigned int Expand(TDcmpStruct * pWork) { pWork->out_buff[pWork->outputPos++] = (unsigned char)next_literal; } - + // Flush the output buffer, if number of extracted bytes has reached the end if(pWork->outputPos >= 0x2000) { @@ -455,7 +455,7 @@ static unsigned int Expand(TDcmpStruct * pWork) // Note that if the output buffer overflowed previously, the extra decompressed bytes // are stored in "out_buff_overflow", and they will now be // within decompressed part of the output buffer. - memmove(pWork->out_buff, &pWork->out_buff[0x1000], pWork->outputPos - 0x1000); + memcpy(pWork->out_buff, &pWork->out_buff[0x1000], pWork->outputPos - 0x1000); pWork->outputPos -= 0x1000; } } @@ -495,7 +495,7 @@ unsigned int explode( pWork->in_pos = 3; // Position in input buffer // Test for the valid dictionary size - if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) + if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) return CMP_INVALID_DICTSIZE; pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction @@ -517,6 +517,6 @@ unsigned int explode( GenDecodeTabs(pWork->DistPosCodes, DistCode, pWork->DistBits, sizeof(pWork->DistBits)); if(Expand(pWork) != 0x306) return CMP_NO_ERROR; - + return CMP_ABORT; } diff --git a/dep/StormLib/src/pklib/implode.c b/dep/StormLib/src/pklib/implode.c index f29f54d64..fbbc6d8da 100644 --- a/dep/StormLib/src/pklib/implode.c +++ b/dep/StormLib/src/pklib/implode.c @@ -27,7 +27,7 @@ //----------------------------------------------------------------------------- // Tables -static unsigned char DistBits[] = +static unsigned char DistBits[] = { 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, @@ -35,7 +35,7 @@ static unsigned char DistBits[] = 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }; -static unsigned char DistCode[] = +static unsigned char DistCode[] = { 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, @@ -78,7 +78,7 @@ static unsigned char ChBitsAsc[] = 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D }; -static unsigned short ChCodeAsc[] = +static unsigned short ChCodeAsc[] = { 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, @@ -111,7 +111,7 @@ static unsigned short ChCodeAsc[] = 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 + 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 }; //----------------------------------------------------------------------------- @@ -140,7 +140,7 @@ static void SortBuffer(TCmpStruct * pWork, unsigned char * buffer_begin, unsigne // Zero the entire "phash_to_index" table memset(pWork->phash_to_index, 0, sizeof(pWork->phash_to_index)); - + // Step 1: Count amount of each PAIR_HASH in the input buffer // The table will look like this: // offs 0x000: Number of occurences of PAIR_HASH 0 @@ -150,7 +150,7 @@ static void SortBuffer(TCmpStruct * pWork, unsigned char * buffer_begin, unsigne for(buffer_ptr = buffer_begin; buffer_ptr < buffer_end; buffer_ptr++) pWork->phash_to_index[BYTE_PAIR_HASH(buffer_ptr)]++; - // Step 2: Convert the table to the array of PAIR_HASH amounts. + // Step 2: Convert the table to the array of PAIR_HASH amounts. // Each element contains count of PAIR_HASHes that is less or equal // to element index // The table will look like this: @@ -218,7 +218,7 @@ static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit { pWork->out_bytes++; bit_buff >>= (8 - out_bits); - + pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff; pWork->out_bits &= 7; } @@ -236,7 +236,7 @@ static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit // This function searches for a repetition // (a previous occurence of the current byte sequence) -// Returns length of the repetition, and stores the backward distance +// Returns length of the repetition, and stores the backward distance // to pWork structure. static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data) { @@ -277,7 +277,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data) phash_offs = pWork->phash_offs + phash_offs_index; prev_repetition = pWork->work_buff + phash_offs[0]; repetition_limit = input_data - 1; - + // If the current PAIR_HASH was not encountered before, // we haven't found a repetition. if(prev_repetition >= repetition_limit) @@ -303,7 +303,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data) { prev_repetition++; input_data_ptr++; - + // Are the bytes different ? if(*prev_repetition != *input_data_ptr) break; @@ -399,7 +399,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data) pWork->offs09BC[++offs_in_rep] = ++di_val; } - // + // // Now go through all the repetitions from the first found one // to the current input data, and check if any of them migh be // a start of a greater sequence match. @@ -408,7 +408,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data) prev_repetition = pWork->work_buff + phash_offs[0]; prev_rep_end = prev_repetition + rep_length; rep_length2 = rep_length; - + for(;;) { rep_length2 = pWork->offs09BC[rep_length2]; @@ -502,7 +502,7 @@ static void WriteCmpData(TCmpStruct * pWork) unsigned int save_rep_length; // Saved length of current repetition unsigned int save_distance = 0; // Saved distance of current repetition unsigned int rep_length; // Length of the found repetition - unsigned int phase = 0; // + unsigned int phase = 0; // // Store the compression type and dictionary size pWork->out_buff[0] = (char)pWork->ctype; @@ -542,12 +542,12 @@ static void WriteCmpData(TCmpStruct * pWork) input_data_end = pWork->work_buff + pWork->dsize_bytes + total_loaded; if(input_data_ended) input_data_end += 0x204; - + // // Warning: The end of the buffer passed to "SortBuffer" is actually 2 bytes beyond // valid data. It is questionable if this is actually a bug or not, // but it might cause the compressed data output to be dependent on random bytes - // that are in the buffer. + // that are in the buffer. // To prevent that, the calling application must always zero the compression // buffer before passing it to "implode" // @@ -556,7 +556,7 @@ static void WriteCmpData(TCmpStruct * pWork) // previously compressed data, if any. switch(phase) { - case 0: + case 0: SortBuffer(pWork, input_data, input_data_end + 1); phase++; if(pWork->dsize_bytes != 0x1000) @@ -662,7 +662,7 @@ _00402252:; if(input_data_ended == 0) { input_data -= 0x1000; - memmove(pWork->work_buff, pWork->work_buff + 0x1000, pWork->dsize_bytes + 0x204); + memcpy(pWork->work_buff, pWork->work_buff + 0x1000, pWork->dsize_bytes + 0x204); } } diff --git a/dep/StormLib/src/pklib/pklib.h b/dep/StormLib/src/pklib/pklib.h index 9eb2915b7..eb18049ab 100644 --- a/dep/StormLib/src/pklib/pklib.h +++ b/dep/StormLib/src/pklib/pklib.h @@ -11,6 +11,8 @@ #ifndef __PKLIB_H__ #define __PKLIB_H__ +#include "../StormPort.h" + //----------------------------------------------------------------------------- // Defines @@ -32,7 +34,7 @@ #ifndef PKEXPORT #ifdef WIN32 -#define PKEXPORT __cdecl // Use for normal __cdecl calling +#define PKEXPORT __cdecl // Use for normal __cdecl calling #else #define PKEXPORT #endif @@ -45,7 +47,7 @@ typedef struct { unsigned int distance; // 0000: Backward distance of the currently found repetition, decreased by 1 - unsigned int out_bytes; // 0004: # bytes available in out_buff + unsigned int out_bytes; // 0004: # bytes available in out_buff unsigned int out_bits; // 0008: # of bits available in the last out byte unsigned int dsize_bits; // 000C: Number of bits needed for dictionary size. 4 = 0x400, 5 = 0x800, 6 = 0x1000 unsigned int dsize_mask; // 0010: Bit mask for dictionary. 0x0F = 0x400, 0x1F = 0x800, 0x3F = 0x1000 @@ -55,14 +57,14 @@ typedef struct unsigned char dist_codes[0x40]; // 005C: Distance codes unsigned char nChBits[0x306]; // 009C: Table of literal bit lengths to be put to the output stream unsigned short nChCodes[0x306]; // 03A2: Table of literal codes to be put to the output stream - unsigned short offs09AE; // 09AE: + unsigned short offs09AE; // 09AE: void * param; // 09B0: User parameter unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4 void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8 unsigned short offs09BC[0x204]; // 09BC: - unsigned long offs0DC4; // 0DC4: + unsigned long offs0DC4; // 0DC4: unsigned short phash_to_index[0x900]; // 0DC8: Array of indexes (one for each PAIR_HASH) to the "pair_hash_offsets" table unsigned short phash_to_index_end; // 1FC8: End marker for "phash_to_index" table char out_buff[0x802]; // 1FCA: Compressed data @@ -99,15 +101,15 @@ typedef struct unsigned char in_buff[0x800]; // 2234: Buffer for data to be decompressed unsigned char DistPosCodes[0x100]; // 2A34: Table of distance position codes unsigned char LengthCodes[0x100]; // 2B34: Table of length codes - unsigned char offs2C34[0x100]; // 2C34: Buffer for - unsigned char offs2D34[0x100]; // 2D34: Buffer for - unsigned char offs2E34[0x80]; // 2EB4: Buffer for - unsigned char offs2EB4[0x100]; // 2EB4: Buffer for - unsigned char ChBitsAsc[0x100]; // 2FB4: Buffer for + unsigned char offs2C34[0x100]; // 2C34: Buffer for + unsigned char offs2D34[0x100]; // 2D34: Buffer for + unsigned char offs2E34[0x80]; // 2EB4: Buffer for + unsigned char offs2EB4[0x100]; // 2EB4: Buffer for + unsigned char ChBitsAsc[0x100]; // 2FB4: Buffer for unsigned char DistBits[0x40]; // 30B4: Numbers of bytes to skip copied block length unsigned char LenBits[0x10]; // 30F4: Numbers of bits for skip copied block length unsigned char ExLenBits[0x10]; // 3104: Number of valid bits for copied block - unsigned short LenBase[0x10]; // 3114: Buffer for + unsigned short LenBase[0x10]; // 3114: Buffer for } TDcmpStruct; #define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompression structure diff --git a/dep/StormLib/src/sparse/sparse.cpp b/dep/StormLib/src/sparse/sparse.cpp index 4fe09810e..96f2efd70 100644 --- a/dep/StormLib/src/sparse/sparse.cpp +++ b/dep/StormLib/src/sparse/sparse.cpp @@ -14,24 +14,22 @@ /* 19.11.03 1.01 Dan Big endian handling */ /* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ /*****************************************************************************/ - + #include #include - + #include "sparse.h" //----------------------------------------------------------------------------- // Public functions -void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +void CompressSparse(unsigned char * pbOutBuffer, int * pcbOutBuffer, unsigned char * pbInBuffer, int cbInBuffer) { - unsigned char * pbOutBufferEnd = (unsigned char *)pvOutBuffer + *pcbOutBuffer; - unsigned char * pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - unsigned char * pbLastNonZero = (unsigned char *)pvInBuffer; - unsigned char * pbOutBuffer0 = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffPtr = (unsigned char *)pvInBuffer; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; + unsigned char * pbOutBufferEnd = pbOutBuffer + *pcbOutBuffer; + unsigned char * pbInBufferEnd = pbInBuffer + cbInBuffer; + unsigned char * pbLastNonZero = pbInBuffer; + unsigned char * pbOutBuffer0 = pbOutBuffer; + unsigned char * pbInBuffPtr = pbInBuffer; size_t NumberOfNonZeros; size_t NumberOfZeros; @@ -88,7 +86,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i // Put marker that means "0x80 of nonzeros" *pbOutBuffer++ = 0xFF; memcpy(pbOutBuffer, pbInBuffer, 0x80); - + // Adjust counter of nonzeros and both pointers NumberOfNonZeros -= 0x80; pbOutBuffer += 0x80; @@ -108,7 +106,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i // Put marker that means "1 nonzero byte" *pbOutBuffer++ = 0x80; memcpy(pbOutBuffer, pbInBuffer, 1); - + // Adjust counter of nonzeros and both pointers NumberOfNonZeros--; pbOutBuffer++; @@ -130,6 +128,20 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i pbOutBuffer += NumberOfNonZeros; pbInBuffer += NumberOfNonZeros; } + else + { + // Verify if we still have enough space in output buffer + if((pbOutBuffer + 2) >= pbOutBufferEnd) + return; + + // Put marker that means "1 nonzero byte" + *pbOutBuffer++ = 0x80; + memcpy(pbOutBuffer, pbInBuffer, 1); + + // Adjust pointers + pbOutBuffer++; + pbInBuffer++; + } } // Now flush all zero bytes @@ -171,7 +183,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i // Put marker that means "Several zeros" *pbOutBuffer++ = (unsigned char)(NumberOfZeros - 3); - + // Adjust pointer pbInBuffer += NumberOfZeros; } @@ -196,7 +208,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i // Terminate with a marker that means "0x80 of nonzeros" *pbOutBuffer++ = 0xFF; memcpy(pbOutBuffer, pbInBuffer, NumberOfNonZeros); - + // Adjust pointer pbOutBuffer += NumberOfNonZeros; break; @@ -222,11 +234,9 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i *pcbOutBuffer = (int)(pbOutBuffer - pbOutBuffer0); } -int DecompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +int DecompressSparse(unsigned char * pbOutBuffer, int * pcbOutBuffer, unsigned char * pbInBuffer, int cbInBuffer) { - unsigned char * pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; + unsigned char * pbInBufferEnd = pbInBuffer + cbInBuffer; unsigned int cbChunkSize; unsigned int cbOutBuffer = 0; unsigned int OneByte; @@ -246,7 +256,7 @@ int DecompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, cbOutBuffer |= (OneByte << 0x00); // Verify the size of the stream against the output buffer size - if(cbOutBuffer > (unsigned int)*pcbOutBuffer) + if(cbOutBuffer > *pcbOutBuffer) return 0; // Put the output size to the buffer diff --git a/dep/StormLib/src/sparse/sparse.h b/dep/StormLib/src/sparse/sparse.h index 12f62b526..032395f0b 100644 --- a/dep/StormLib/src/sparse/sparse.h +++ b/dep/StormLib/src/sparse/sparse.h @@ -11,7 +11,9 @@ #ifndef __SPARSE_H__ #define __SPARSE_H__ -void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int DecompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); +#include "../StormPort.h" + +void CompressSparse(unsigned char * pbOutBuffer, int * pcbOutLength, unsigned char * pbInBuffer, int cbInLength); +int DecompressSparse(unsigned char * pbOutBuffer, int * pcbOutLength, unsigned char * pbInBuffer, int cbInLength); #endif // __SPARSE_H__ diff --git a/dep/StormLib/src/zlib/adler32.c b/dep/StormLib/src/zlib/adler32.c new file mode 100644 index 000000000..007ba2627 --- /dev/null +++ b/dep/StormLib/src/zlib/adler32.c @@ -0,0 +1,149 @@ +/* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-2004 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +#define BASE 65521UL /* largest prime smaller than 65536 */ +#define NMAX 5552 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + +#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} +#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); +#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); +#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); +#define DO16(buf) DO8(buf,0); DO8(buf,8); + +/* use NO_DIVIDE if your processor does not do division in hardware */ +#ifdef NO_DIVIDE +# define MOD(a) \ + do { \ + if (a >= (BASE << 16)) a -= (BASE << 16); \ + if (a >= (BASE << 15)) a -= (BASE << 15); \ + if (a >= (BASE << 14)) a -= (BASE << 14); \ + if (a >= (BASE << 13)) a -= (BASE << 13); \ + if (a >= (BASE << 12)) a -= (BASE << 12); \ + if (a >= (BASE << 11)) a -= (BASE << 11); \ + if (a >= (BASE << 10)) a -= (BASE << 10); \ + if (a >= (BASE << 9)) a -= (BASE << 9); \ + if (a >= (BASE << 8)) a -= (BASE << 8); \ + if (a >= (BASE << 7)) a -= (BASE << 7); \ + if (a >= (BASE << 6)) a -= (BASE << 6); \ + if (a >= (BASE << 5)) a -= (BASE << 5); \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ + if (a >= BASE) a -= BASE; \ + } while (0) +# define MOD4(a) \ + do { \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ + if (a >= BASE) a -= BASE; \ + } while (0) +#else +# define MOD(a) a %= BASE +# define MOD4(a) a %= BASE +#endif + +/* ========================================================================= */ +uLong ZEXPORT adler32(adler, buf, len) + uLong adler; + const Bytef *buf; + uInt len; +{ + unsigned long sum2; + unsigned n; + + /* split Adler-32 into component sums */ + sum2 = (adler >> 16) & 0xffff; + adler &= 0xffff; + + /* in case user likes doing a byte at a time, keep it fast */ + if (len == 1) { + adler += buf[0]; + if (adler >= BASE) + adler -= BASE; + sum2 += adler; + if (sum2 >= BASE) + sum2 -= BASE; + return adler | (sum2 << 16); + } + + /* initial Adler-32 value (deferred check for len == 1 speed) */ + if (buf == Z_NULL) + return 1L; + + /* in case short lengths are provided, keep it somewhat fast */ + if (len < 16) { + while (len--) { + adler += *buf++; + sum2 += adler; + } + if (adler >= BASE) + adler -= BASE; + MOD4(sum2); /* only added so many BASE's */ + return adler | (sum2 << 16); + } + + /* do length NMAX blocks -- requires just one modulo operation */ + while (len >= NMAX) { + len -= NMAX; + n = NMAX / 16; /* NMAX is divisible by 16 */ + do { + DO16(buf); /* 16 sums unrolled */ + buf += 16; + } while (--n); + MOD(adler); + MOD(sum2); + } + + /* do remaining bytes (less than NMAX, still just one modulo) */ + if (len) { /* avoid modulos if none remaining */ + while (len >= 16) { + len -= 16; + DO16(buf); + buf += 16; + } + while (len--) { + adler += *buf++; + sum2 += adler; + } + MOD(adler); + MOD(sum2); + } + + /* return recombined sums */ + return adler | (sum2 << 16); +} + +/* ========================================================================= */ +uLong ZEXPORT adler32_combine(adler1, adler2, len2) + uLong adler1; + uLong adler2; + z_off_t len2; +{ + unsigned long sum1; + unsigned long sum2; + unsigned rem; + + /* the derivation of this formula is left as an exercise for the reader */ + rem = (unsigned)(len2 % BASE); + sum1 = adler1 & 0xffff; + sum2 = rem * sum1; + MOD(sum2); + sum1 += (adler2 & 0xffff) + BASE - 1; + sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; + if (sum1 > BASE) sum1 -= BASE; + if (sum1 > BASE) sum1 -= BASE; + if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); + if (sum2 > BASE) sum2 -= BASE; + return sum1 | (sum2 << 16); +} diff --git a/dep/StormLib/src/zlib/compress.c b/dep/StormLib/src/zlib/compress.c new file mode 100644 index 000000000..ea4dfbe9d --- /dev/null +++ b/dep/StormLib/src/zlib/compress.c @@ -0,0 +1,80 @@ +/* compress.c -- compress a memory buffer + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; + int level; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; +#ifdef MAXSEG_64K + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; +#endif + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = deflateInit(&stream, level); + if (err != Z_OK) return err; + + err = deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + deflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = deflateEnd(&stream); + return err; +} + +/* =========================================================================== + */ +int ZEXPORT compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} + +/* =========================================================================== + If the default memLevel or windowBits for deflateInit() is changed, then + this function needs to be updated. + */ +uLong ZEXPORT compressBound (sourceLen) + uLong sourceLen; +{ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + + (sourceLen >> 25) + 13; +} diff --git a/dep/StormLib/src/zlib/compress2.c b/dep/StormLib/src/zlib/compress2.c new file mode 100644 index 000000000..df04f0148 --- /dev/null +++ b/dep/StormLib/src/zlib/compress2.c @@ -0,0 +1,79 @@ +/* compress.c -- compress a memory buffer + * Copyright (C) 1995-2003 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; + int level; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; +#ifdef MAXSEG_64K + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; +#endif + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = deflateInit(&stream, level); + if (err != Z_OK) return err; + + err = deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + deflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = deflateEnd(&stream); + return err; +} + +/* =========================================================================== + */ +int ZEXPORT compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} + +/* =========================================================================== + If the default memLevel or windowBits for deflateInit() is changed, then + this function needs to be updated. + */ +uLong ZEXPORT compressBound (sourceLen) + uLong sourceLen; +{ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; +} diff --git a/dep/StormLib/src/zlib/compress_zlib.c b/dep/StormLib/src/zlib/compress_zlib.c new file mode 100644 index 000000000..46e506158 --- /dev/null +++ b/dep/StormLib/src/zlib/compress_zlib.c @@ -0,0 +1,5 @@ +// Some compilers (e.g. Visual Studio 2012) don't like the name conflict between +// zlib\compress.c and bzip2\compress.c. This file is plain wrapper for compress.c +// in order to create obj file with a different name. + +#include "compress.c" diff --git a/dep/StormLib/src/zlib/crc32.c b/dep/StormLib/src/zlib/crc32.c new file mode 100644 index 000000000..f658a9ef5 --- /dev/null +++ b/dep/StormLib/src/zlib/crc32.c @@ -0,0 +1,423 @@ +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2005 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Thanks to Rodney Brown for his contribution of faster + * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing + * tables for updating the shift register in one step with three exclusive-ors + * instead of four steps with four exclusive-ors. This results in about a + * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. + */ + +/* @(#) $Id$ */ + +/* + Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore + protection on the static variables used to control the first-use generation + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + first call get_crc_table() to initialize the tables before allowing more than + one thread to use crc32(). + */ + +#ifdef MAKECRCH +# include +# ifndef DYNAMIC_CRC_TABLE +# define DYNAMIC_CRC_TABLE +# endif /* !DYNAMIC_CRC_TABLE */ +#endif /* MAKECRCH */ + +#include "zutil.h" /* for STDC and FAR definitions */ + +#define local static + +/* Find a four-byte integer type for crc32_little() and crc32_big(). */ +#ifndef NOBYFOUR +# ifdef STDC /* need ANSI C limits.h to determine sizes */ +# include +# define BYFOUR +# if (UINT_MAX == 0xffffffffUL) + typedef unsigned int u4; +# else +# if (ULONG_MAX == 0xffffffffUL) + typedef unsigned long u4; +# else +# if (USHRT_MAX == 0xffffffffUL) + typedef unsigned short u4; +# else +# undef BYFOUR /* can't find a four-byte integer type! */ +# endif +# endif +# endif +# endif /* STDC */ +#endif /* !NOBYFOUR */ + +/* Definitions for doing the crc four data bytes at a time. */ +#ifdef BYFOUR +# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ + (((w)&0xff00)<<8)+(((w)&0xff)<<24)) + local unsigned long crc32_little OF((unsigned long, + const unsigned char FAR *, unsigned)); + local unsigned long crc32_big OF((unsigned long, + const unsigned char FAR *, unsigned)); +# define TBLS 8 +#else +# define TBLS 1 +#endif /* BYFOUR */ + +/* Local functions for crc concatenation */ +local unsigned long gf2_matrix_times OF((unsigned long *mat, + unsigned long vec)); +local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); + +#ifdef DYNAMIC_CRC_TABLE + +local volatile int crc_table_empty = 1; +local unsigned long FAR crc_table[TBLS][256]; +local void make_crc_table OF((void)); +#ifdef MAKECRCH + local void write_table OF((FILE *, const unsigned long FAR *)); +#endif /* MAKECRCH */ +/* + Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The first table is simply the CRC of all possible eight bit values. This is + all the information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. The remaining tables + allow for word-at-a-time CRC calculation for both big-endian and little- + endian machines, where a word is four bytes. +*/ +local void make_crc_table() +{ + unsigned long c; + int n, k; + unsigned long poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static volatile int first = 1; /* flag to limit concurrent making */ + static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* See if another task is already doing this (not thread-safe, but better + than nothing -- significantly reduces duration of vulnerability in + case the advice about DYNAMIC_CRC_TABLE is ignored) */ + if (first) { + first = 0; + + /* make exclusive-or pattern from polynomial (0xedb88320UL) */ + poly = 0UL; + for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) + poly |= 1UL << (31 - p[n]); + + /* generate a crc for every 8-bit value */ + for (n = 0; n < 256; n++) { + c = (unsigned long)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[0][n] = c; + } + +#ifdef BYFOUR + /* generate crc for each value followed by one, two, and three zeros, + and then the byte reversal of those as well as the first table */ + for (n = 0; n < 256; n++) { + c = crc_table[0][n]; + crc_table[4][n] = REV(c); + for (k = 1; k < 4; k++) { + c = crc_table[0][c & 0xff] ^ (c >> 8); + crc_table[k][n] = c; + crc_table[k + 4][n] = REV(c); + } + } +#endif /* BYFOUR */ + + crc_table_empty = 0; + } + else { /* not first */ + /* wait for the other guy to finish (not efficient, but rare) */ + while (crc_table_empty) + ; + } + +#ifdef MAKECRCH + /* write out CRC tables to crc32.h */ + { + FILE *out; + + out = fopen("crc32.h", "w"); + if (out == NULL) return; + fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); + fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); + fprintf(out, "local const unsigned long FAR "); + fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); + write_table(out, crc_table[0]); +# ifdef BYFOUR + fprintf(out, "#ifdef BYFOUR\n"); + for (k = 1; k < 8; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_table[k]); + } + fprintf(out, "#endif\n"); +# endif /* BYFOUR */ + fprintf(out, " }\n};\n"); + fclose(out); + } +#endif /* MAKECRCH */ +} + +#ifdef MAKECRCH +local void write_table(out, table) + FILE *out; + const unsigned long FAR *table; +{ + int n; + + for (n = 0; n < 256; n++) + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); +} +#endif /* MAKECRCH */ + +#else /* !DYNAMIC_CRC_TABLE */ +/* ======================================================================== + * Tables of CRC-32s of all single-byte values, made by make_crc_table(). + */ +#include "crc32.h" +#endif /* DYNAMIC_CRC_TABLE */ + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const unsigned long FAR * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + return (const unsigned long FAR *)crc_table; +} + +/* ========================================================================= */ +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + if (buf == Z_NULL) return 0UL; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + +#ifdef BYFOUR + if (sizeof(void *) == sizeof(ptrdiff_t)) { + u4 endian; + + endian = 1; + if (*((unsigned char *)(&endian))) + return crc32_little(crc, buf, len); + else + return crc32_big(crc, buf, len); + } +#endif /* BYFOUR */ + crc = crc ^ 0xffffffffUL; + while (len >= 8) { + DO8; + len -= 8; + } + if (len) do { + DO1; + } while (--len); + return crc ^ 0xffffffffUL; +} + +#ifdef BYFOUR + +/* ========================================================================= */ +#define DOLIT4 c ^= *buf4++; \ + c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ + crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] +#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 + +/* ========================================================================= */ +local unsigned long crc32_little(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = (u4)crc; + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + while (len >= 32) { + DOLIT32; + len -= 32; + } + while (len >= 4) { + DOLIT4; + len -= 4; + } + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + } while (--len); + c = ~c; + return (unsigned long)c; +} + +/* ========================================================================= */ +#define DOBIG4 c ^= *++buf4; \ + c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ + crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] +#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 + +/* ========================================================================= */ +local unsigned long crc32_big(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = REV((u4)crc); + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4--; + while (len >= 32) { + DOBIG32; + len -= 32; + } + while (len >= 4) { + DOBIG4; + len -= 4; + } + buf4++; + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + } while (--len); + c = ~c; + return (unsigned long)(REV(c)); +} + +#endif /* BYFOUR */ + +#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ + +/* ========================================================================= */ +local unsigned long gf2_matrix_times(mat, vec) + unsigned long *mat; + unsigned long vec; +{ + unsigned long sum; + + sum = 0; + while (vec) { + if (vec & 1) + sum ^= *mat; + vec >>= 1; + mat++; + } + return sum; +} + +/* ========================================================================= */ +local void gf2_matrix_square(square, mat) + unsigned long *square; + unsigned long *mat; +{ + int n; + + for (n = 0; n < GF2_DIM; n++) + square[n] = gf2_matrix_times(mat, mat[n]); +} + +/* ========================================================================= */ +uLong ZEXPORT crc32_combine(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off_t len2; +{ + int n; + unsigned long row; + unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ + unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ + + /* degenerate case */ + if (len2 == 0) + return crc1; + + /* put operator for one zero bit in odd */ + odd[0] = 0xedb88320L; /* CRC-32 polynomial */ + row = 1; + for (n = 1; n < GF2_DIM; n++) { + odd[n] = row; + row <<= 1; + } + + /* put operator for two zero bits in even */ + gf2_matrix_square(even, odd); + + /* put operator for four zero bits in odd */ + gf2_matrix_square(odd, even); + + /* apply len2 zeros to crc1 (first square will put the operator for one + zero byte, eight zero bits, in even) */ + do { + /* apply zeros operator for this bit of len2 */ + gf2_matrix_square(even, odd); + if (len2 & 1) + crc1 = gf2_matrix_times(even, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + if (len2 == 0) + break; + + /* another iteration of the loop with odd and even swapped */ + gf2_matrix_square(odd, even); + if (len2 & 1) + crc1 = gf2_matrix_times(odd, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + } while (len2 != 0); + + /* return combined crc */ + crc1 ^= crc2; + return crc1; +} diff --git a/dep/StormLib/src/zlib/crc32.h b/dep/StormLib/src/zlib/crc32.h new file mode 100644 index 000000000..8053b6117 --- /dev/null +++ b/dep/StormLib/src/zlib/crc32.h @@ -0,0 +1,441 @@ +/* crc32.h -- tables for rapid CRC calculation + * Generated automatically by crc32.c + */ + +local const unsigned long FAR crc_table[TBLS][256] = +{ + { + 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, + 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, + 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, + 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, + 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, + 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, + 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, + 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, + 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, + 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, + 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, + 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, + 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, + 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, + 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, + 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, + 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, + 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, + 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, + 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, + 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, + 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, + 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, + 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, + 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, + 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, + 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, + 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, + 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, + 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, + 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, + 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, + 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, + 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, + 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, + 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, + 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, + 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, + 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, + 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, + 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, + 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, + 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, + 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, + 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, + 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, + 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, + 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, + 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, + 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, + 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, + 0x2d02ef8dUL +#ifdef BYFOUR + }, + { + 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, + 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, + 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, + 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, + 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, + 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, + 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, + 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, + 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, + 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, + 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, + 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, + 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, + 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, + 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, + 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, + 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, + 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, + 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, + 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, + 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, + 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, + 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, + 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, + 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, + 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, + 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, + 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, + 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, + 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, + 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, + 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, + 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, + 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, + 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, + 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, + 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, + 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, + 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, + 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, + 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, + 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, + 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, + 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, + 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, + 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, + 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, + 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, + 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, + 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, + 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, + 0x9324fd72UL + }, + { + 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, + 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, + 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, + 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, + 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, + 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, + 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, + 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, + 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, + 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, + 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, + 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, + 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, + 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, + 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, + 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, + 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, + 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, + 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, + 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, + 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, + 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, + 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, + 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, + 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, + 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, + 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, + 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, + 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, + 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, + 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, + 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, + 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, + 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, + 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, + 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, + 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, + 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, + 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, + 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, + 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, + 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, + 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, + 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, + 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, + 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, + 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, + 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, + 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, + 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, + 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, + 0xbe9834edUL + }, + { + 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, + 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, + 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, + 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, + 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, + 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, + 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, + 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, + 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, + 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, + 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, + 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, + 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, + 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, + 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, + 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, + 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, + 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, + 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, + 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, + 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, + 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, + 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, + 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, + 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, + 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, + 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, + 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, + 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, + 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, + 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, + 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, + 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, + 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, + 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, + 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, + 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, + 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, + 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, + 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, + 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, + 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, + 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, + 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, + 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, + 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, + 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, + 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, + 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, + 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, + 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, + 0xde0506f1UL + }, + { + 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, + 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, + 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, + 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, + 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, + 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, + 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, + 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, + 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, + 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, + 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, + 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, + 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, + 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, + 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, + 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, + 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, + 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, + 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, + 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, + 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, + 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, + 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, + 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, + 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, + 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, + 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, + 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, + 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, + 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, + 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, + 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, + 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, + 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, + 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, + 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, + 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, + 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, + 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, + 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, + 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, + 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, + 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, + 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, + 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, + 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, + 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, + 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, + 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, + 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, + 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, + 0x8def022dUL + }, + { + 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, + 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, + 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, + 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, + 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, + 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, + 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, + 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, + 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, + 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, + 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, + 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, + 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, + 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, + 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, + 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, + 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, + 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, + 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, + 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, + 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, + 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, + 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, + 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, + 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, + 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, + 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, + 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, + 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, + 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, + 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, + 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, + 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, + 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, + 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, + 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, + 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, + 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, + 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, + 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, + 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, + 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, + 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, + 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, + 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, + 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, + 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, + 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, + 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, + 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, + 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, + 0x72fd2493UL + }, + { + 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, + 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, + 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, + 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, + 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, + 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, + 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, + 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, + 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, + 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, + 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, + 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, + 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, + 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, + 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, + 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, + 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, + 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, + 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, + 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, + 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, + 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, + 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, + 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, + 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, + 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, + 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, + 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, + 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, + 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, + 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, + 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, + 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, + 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, + 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, + 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, + 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, + 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, + 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, + 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, + 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, + 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, + 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, + 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, + 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, + 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, + 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, + 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, + 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, + 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, + 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, + 0xed3498beUL + }, + { + 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, + 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, + 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, + 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, + 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, + 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, + 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, + 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, + 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, + 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, + 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, + 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, + 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, + 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, + 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, + 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, + 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, + 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, + 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, + 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, + 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, + 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, + 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, + 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, + 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, + 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, + 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, + 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, + 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, + 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, + 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, + 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, + 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, + 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, + 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, + 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, + 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, + 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, + 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, + 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, + 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, + 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, + 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, + 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, + 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, + 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, + 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, + 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, + 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, + 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, + 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, + 0xf10605deUL +#endif + } +}; diff --git a/dep/StormLib/src/zlib/deflate.c b/dep/StormLib/src/zlib/deflate.c new file mode 100644 index 000000000..29ce1f64a --- /dev/null +++ b/dep/StormLib/src/zlib/deflate.c @@ -0,0 +1,1736 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many people for bug reports and testing. + * + * REFERENCES + * + * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". + * Available in http://www.ietf.org/rfc/rfc1951.txt + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + */ + +/* @(#) $Id$ */ + +#include "deflate.h" + +const char deflate_copyright[] = + " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* =========================================================================== + * Function prototypes. + */ +typedef enum { + need_more, /* block not completed, need more input or more output */ + block_done, /* block flush performed */ + finish_started, /* finish started, need only more output at next deflate */ + finish_done /* finish done, accept no more input or output */ +} block_state; + +typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +/* Compression function. Returns the block state after the call. */ + +local void fill_window OF((deflate_state *s)); +local block_state deflate_stored OF((deflate_state *s, int flush)); +local block_state deflate_fast OF((deflate_state *s, int flush)); +#ifndef FASTEST +local block_state deflate_slow OF((deflate_state *s, int flush)); +#endif +local void lm_init OF((deflate_state *s)); +local void putShortMSB OF((deflate_state *s, uInt b)); +local void flush_pending OF((z_streamp strm)); +local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +#ifndef FASTEST +#ifdef ASMV + void match_init OF((void)); /* asm code initialization */ + uInt longest_match OF((deflate_state *s, IPos cur_match)); +#else +local uInt longest_match OF((deflate_state *s, IPos cur_match)); +#endif +#endif +local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); + +#ifdef DEBUG +local void check_match OF((deflate_state *s, IPos start, IPos match, + int length)); +#endif + +/* =========================================================================== + * Local data + */ + +#define NIL 0 +/* Tail of hash chains */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +typedef struct config_s { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; + compress_func func; +} config; + +#ifdef FASTEST +local const config configuration_table[2] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ +#else +local const config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8, deflate_fast}, +/* 3 */ {4, 6, 32, 32, deflate_fast}, + +/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32, deflate_slow}, +/* 6 */ {8, 16, 128, 128, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 8 */ {32, 128, 258, 1024, deflate_slow}, +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ +#endif + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +#ifndef NO_DUMMY_DECL +struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ +#endif + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) + + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * If this file is compiled with -DFASTEST, the compression level is forced + * to 1, and no hash chains are maintained. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef FASTEST +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#else +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#endif + +/* =========================================================================== + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. + */ +#define CLEAR_HASH(s) \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + +/* ========================================================================= */ +int ZEXPORT deflateInit_(strm, level, version, stream_size) + z_streamp strm; + int level; + const char *version; + int stream_size; +{ + return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, version, stream_size); + /* To do: ignore strm->next_in if we use it as window */ +} + +/* ========================================================================= */ +int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + version, stream_size) + z_streamp strm; + int level; + int method; + int windowBits; + int memLevel; + int strategy; + const char *version; + int stream_size; +{ + deflate_state *s; + int wrap = 1; + static const char my_version[] = ZLIB_VERSION; + + ushf *overlay; + /* We overlay pending_buf and d_buf+l_buf. This works since the average + * output size for (length,distance) codes is <= 24 bits. + */ + + if (version == Z_NULL || version[0] != my_version[0] || + stream_size != sizeof(z_stream)) { + return Z_VERSION_ERROR; + } + if (strm == Z_NULL) return Z_STREAM_ERROR; + + strm->msg = Z_NULL; + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + + if (windowBits < 0) { /* suppress zlib wrapper */ + wrap = 0; + windowBits = -windowBits; + } +#ifdef GZIP + else if (windowBits > 15) { + wrap = 2; /* write gzip wrapper instead */ + windowBits -= 16; + } +#endif + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || + windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_FIXED) { + return Z_STREAM_ERROR; + } + if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ + s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); + if (s == Z_NULL) return Z_MEM_ERROR; + strm->state = (struct internal_state FAR *)s; + s->strm = strm; + + s->wrap = wrap; + s->gzhead = Z_NULL; + s->w_bits = windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + + s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + s->pending_buf = (uchf *) overlay; + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + + if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || + s->pending_buf == Z_NULL) { + s->status = FINISH_STATE; + strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + deflateEnd (strm); + return Z_MEM_ERROR; + } + s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (Byte)method; + + return deflateReset(strm); +} + +/* ========================================================================= */ +int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +{ + deflate_state *s; + uInt length = dictLength; + uInt n; + IPos hash_head = 0; + + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || + strm->state->wrap == 2 || + (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) + return Z_STREAM_ERROR; + + s = strm->state; + if (s->wrap) + strm->adler = adler32(strm->adler, dictionary, dictLength); + + if (length < MIN_MATCH) return Z_OK; + if (length > MAX_DIST(s)) { + length = MAX_DIST(s); + dictionary += dictLength - length; /* use the tail of the dictionary */ + } + zmemcpy(s->window, dictionary, length); + s->strstart = length; + s->block_start = (long)length; + + /* Insert all strings in the hash table (except for the last two bytes). + * s->lookahead stays null, so s->ins_h will be recomputed at the next + * call of fill_window. + */ + s->ins_h = s->window[0]; + UPDATE_HASH(s, s->ins_h, s->window[1]); + for (n = 0; n <= length - MIN_MATCH; n++) { + INSERT_STRING(s, n, hash_head); + } + if (hash_head) hash_head = 0; /* to make compiler happy */ + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateReset (strm) + z_streamp strm; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { + return Z_STREAM_ERROR; + } + + strm->total_in = strm->total_out = 0; + strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->wrap < 0) { + s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ + } + s->status = s->wrap ? INIT_STATE : BUSY_STATE; + strm->adler = +#ifdef GZIP + s->wrap == 2 ? crc32(0L, Z_NULL, 0) : +#endif + adler32(0L, Z_NULL, 0); + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + lm_init(s); + + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateSetHeader (strm, head) + z_streamp strm; + gz_headerp head; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (strm->state->wrap != 2) return Z_STREAM_ERROR; + strm->state->gzhead = head; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflatePrime (strm, bits, value) + z_streamp strm; + int bits; + int value; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + strm->state->bi_valid = bits; + strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateParams(strm, level, strategy) + z_streamp strm; + int level; + int strategy; +{ + deflate_state *s; + compress_func func; + int err = Z_OK; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { + return Z_STREAM_ERROR; + } + func = configuration_table[s->level].func; + + if (func != configuration_table[level].func && strm->total_in != 0) { + /* Flush the last buffer: */ + err = deflate(strm, Z_PARTIAL_FLUSH); + } + if (s->level != level) { + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; + } + s->strategy = strategy; + return err; +} + +/* ========================================================================= */ +int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) + z_streamp strm; + int good_length; + int max_lazy; + int nice_length; + int max_chain; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + s->good_match = good_length; + s->max_lazy_match = max_lazy; + s->nice_match = nice_length; + s->max_chain_length = max_chain; + return Z_OK; +} + +/* ========================================================================= + * For the default windowBits of 15 and memLevel of 8, this function returns + * a close to exact, as well as small, upper bound on the compressed size. + * They are coded as constants here for a reason--if the #define's are + * changed, then this function needs to be changed as well. The return + * value for 15 and 8 only works for those exact settings. + * + * For any setting other than those defaults for windowBits and memLevel, + * the value returned is a conservative worst case for the maximum expansion + * resulting from using fixed blocks instead of stored blocks, which deflate + * can emit on compressed data for some combinations of the parameters. + * + * This function could be more sophisticated to provide closer upper bounds + * for every combination of windowBits and memLevel, as well as wrap. + * But even the conservative upper bound of about 14% expansion does not + * seem onerous for output buffer allocation. + */ +uLong ZEXPORT deflateBound(strm, sourceLen) + z_streamp strm; + uLong sourceLen; +{ + deflate_state *s; + uLong destLen; + + /* conservative upper bound */ + destLen = sourceLen + + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11; + + /* if can't get parameters, return conservative bound */ + if (strm == Z_NULL || strm->state == Z_NULL) + return destLen; + + /* if not default parameters, return conservative bound */ + s = strm->state; + if (s->w_bits != 15 || s->hash_bits != 8 + 7) + return destLen; + + /* default settings: return tight bound for that case */ + return compressBound(sourceLen); +} + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +local void putShortMSB (s, b) + deflate_state *s; + uInt b; +{ + put_byte(s, (Byte)(b >> 8)); + put_byte(s, (Byte)(b & 0xff)); +} + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output goes + * through this function so some applications may wish to modify it + * to avoid allocating a large strm->next_out buffer and copying into it. + * (See also read_buf()). + */ +local void flush_pending(strm) + z_streamp strm; +{ + unsigned len = strm->state->pending; + + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + zmemcpy(strm->next_out, strm->state->pending_out, len); + strm->next_out += len; + strm->state->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + strm->state->pending -= len; + if (strm->state->pending == 0) { + strm->state->pending_out = strm->state->pending_buf; + } +} + +/* ========================================================================= */ +int ZEXPORT deflate (strm, flush) + z_streamp strm; + int flush; +{ + int old_flush; /* value of flush param for previous deflate call */ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + flush > Z_FINISH || flush < 0) { + return Z_STREAM_ERROR; + } + s = strm->state; + + if (strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { + ERR_RETURN(strm, Z_STREAM_ERROR); + } + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); + + s->strm = strm; /* just in case */ + old_flush = s->last_flush; + s->last_flush = flush; + + /* Write the header */ + if (s->status == INIT_STATE) { +#ifdef GZIP + if (s->wrap == 2) { + strm->adler = crc32(0L, Z_NULL, 0); + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (s->gzhead == NULL) { + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, OS_CODE); + s->status = BUSY_STATE; + } + else { + put_byte(s, (s->gzhead->text ? 1 : 0) + + (s->gzhead->hcrc ? 2 : 0) + + (s->gzhead->extra == Z_NULL ? 0 : 4) + + (s->gzhead->name == Z_NULL ? 0 : 8) + + (s->gzhead->comment == Z_NULL ? 0 : 16) + ); + put_byte(s, (Byte)(s->gzhead->time & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, s->gzhead->os & 0xff); + if (s->gzhead->extra != NULL) { + put_byte(s, s->gzhead->extra_len & 0xff); + put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); + } + if (s->gzhead->hcrc) + strm->adler = crc32(strm->adler, s->pending_buf, + s->pending); + s->gzindex = 0; + s->status = EXTRA_STATE; + } + } + else +#endif + { + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags; + + if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) + level_flags = 0; + else if (s->level < 6) + level_flags = 1; + else if (s->level == 6) + level_flags = 2; + else + level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + s->status = BUSY_STATE; + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = adler32(0L, Z_NULL, 0); + } + } +#ifdef GZIP + if (s->status == EXTRA_STATE) { + if (s->gzhead->extra != NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + + while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) + break; + } + put_byte(s, s->gzhead->extra[s->gzindex]); + s->gzindex++; + } + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (s->gzindex == s->gzhead->extra_len) { + s->gzindex = 0; + s->status = NAME_STATE; + } + } + else + s->status = NAME_STATE; + } + if (s->status == NAME_STATE) { + if (s->gzhead->name != NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + int val; + + do { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) { + val = 1; + break; + } + } + val = s->gzhead->name[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (val == 0) { + s->gzindex = 0; + s->status = COMMENT_STATE; + } + } + else + s->status = COMMENT_STATE; + } + if (s->status == COMMENT_STATE) { + if (s->gzhead->comment != NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + int val; + + do { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) { + val = 1; + break; + } + } + val = s->gzhead->comment[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (val == 0) + s->status = HCRC_STATE; + } + else + s->status = HCRC_STATE; + } + if (s->status == HCRC_STATE) { + if (s->gzhead->hcrc) { + if (s->pending + 2 > s->pending_buf_size) + flush_pending(strm); + if (s->pending + 2 <= s->pending_buf_size) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + strm->adler = crc32(0L, Z_NULL, 0); + s->status = BUSY_STATE; + } + } + else + s->status = BUSY_STATE; + } +#endif + + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm->avail_in == 0 && flush <= old_flush && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* Start a new block or continue the current one. + */ + if (strm->avail_in != 0 || s->lookahead != 0 || + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { + block_state bstate; + + bstate = (*(configuration_table[s->level].func))(s, flush); + + if (bstate == finish_started || bstate == finish_done) { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) { + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate == block_done) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(s); + } else { /* FULL_FLUSH or SYNC_FLUSH */ + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) { + CLEAR_HASH(s); /* forget history */ + } + } + flush_pending(strm); + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + Assert(strm->avail_out > 0, "bug2"); + + if (flush != Z_FINISH) return Z_OK; + if (s->wrap <= 0) return Z_STREAM_END; + + /* Write the trailer */ +#ifdef GZIP + if (s->wrap == 2) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); + put_byte(s, (Byte)(strm->total_in & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); + } + else +#endif + { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int ZEXPORT deflateEnd (strm) + z_streamp strm; +{ + int status; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + + status = strm->state->status; + if (status != INIT_STATE && + status != EXTRA_STATE && + status != NAME_STATE && + status != COMMENT_STATE && + status != HCRC_STATE && + status != BUSY_STATE && + status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + + /* Deallocate in reverse order of allocations: */ + TRY_FREE(strm, strm->state->pending_buf); + TRY_FREE(strm, strm->state->head); + TRY_FREE(strm, strm->state->prev); + TRY_FREE(strm, strm->state->window); + + ZFREE(strm, strm->state); + strm->state = Z_NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +/* ========================================================================= + * Copy the source state to the destination state. + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +int ZEXPORT deflateCopy (dest, source) + z_streamp dest; + z_streamp source; +{ +#ifdef MAXSEG_64K + return Z_STREAM_ERROR; +#else + deflate_state *ds; + deflate_state *ss; + ushf *overlay; + + + if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + return Z_STREAM_ERROR; + } + + ss = source->state; + + zmemcpy(dest, source, sizeof(z_stream)); + + ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); + if (ds == Z_NULL) return Z_MEM_ERROR; + dest->state = (struct internal_state FAR *) ds; + zmemcpy(ds, ss, sizeof(deflate_state)); + ds->strm = dest; + + ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); + ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); + ds->pending_buf = (uchf *) overlay; + + if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || + ds->pending_buf == Z_NULL) { + deflateEnd (dest); + return Z_MEM_ERROR; + } + /* following zmemcpy do not work for 16-bit MSDOS */ + zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + + ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); + ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); + ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + + ds->l_desc.dyn_tree = ds->dyn_ltree; + ds->d_desc.dyn_tree = ds->dyn_dtree; + ds->bl_desc.dyn_tree = ds->bl_tree; + + return Z_OK; +#endif /* MAXSEG_64K */ +} + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local int read_buf(strm, buf, size) + z_streamp strm; + Bytef *buf; + unsigned size; +{ + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, strm->next_in, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, strm->next_in, len); + } +#endif + zmemcpy(buf, strm->next_in, len); + strm->next_in += len; + strm->total_in += len; + + return (int)len; +} + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init (s) + deflate_state *s; +{ + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +#ifndef FASTEST +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif +#endif +} + +#ifndef FASTEST +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +#ifndef ASMV +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or + * match.S. The code will be functionally equivalent. + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); +#else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; +#endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks below + * for insufficient lookahead only occur occasionally for performance + * reasons. Therefore uninitialized memory will be accessed, and + * conditional jumps will be made that depend on those values. + * However the length of the match is limited to the lookahead, so + * the output of deflate is not affected by the uninitialized values. + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; +} +#endif /* ASMV */ +#endif /* FASTEST */ + +/* --------------------------------------------------------------------------- + * Optimized version for level == 1 or strategy == Z_RLE only + */ +local uInt longest_match_fast(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + Assert(cur_match < s->strstart, "no future"); + + match = s->window + cur_match; + + /* Return failure if the match length is less than 2: + */ + if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match += 2; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + + if (len < MIN_MATCH) return MIN_MATCH - 1; + + s->match_start = cur_match; + return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; +} + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match(s, start, match, length) + deflate_state *s; + IPos start, match; + int length; +{ + /* check that the match is indeed a match */ + if (zmemcmp(s->window + match, + s->window + start, length) != EQUAL) { + fprintf(stderr, " start %u, match %u, length %d\n", + start, match, length); + do { + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); + z_error("invalid match"); + } + if (z_verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(s->window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(s, start, match, length) +#endif /* DEBUG */ + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(s) + deflate_state *s; +{ + register unsigned n, m; + register Posf *p; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize+MAX_DIST(s)) { + + zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + /* %%% avoid this when Z_RLE */ + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); + + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif + more += wsize; + } + if (s->strm->avail_in == 0) return; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead >= MIN_MATCH) { + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, eof) { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (charf *)&s->window[(unsigned)s->block_start] : \ + (charf *)Z_NULL), \ + (ulg)((long)s->strstart - s->block_start), \ + (eof)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + Tracev((stderr,"[FLUSH]")); \ +} + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, eof) { \ + FLUSH_BLOCK_ONLY(s, eof); \ + if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ +} + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * This function does not insert new strings in the dictionary since + * uncompressible data is probably not useful. This function is used + * only for the level=0 compression option. + * NOTE: this function should be optimized to avoid extra copying from + * window to pending_buf. + */ +local block_state deflate_stored(s, flush) + deflate_state *s; + int flush; +{ + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + ulg max_block_size = 0xffff; + ulg max_start; + + if (max_block_size > s->pending_buf_size - 5) { + max_block_size = s->pending_buf_size - 5; + } + + /* Copy as much as possible from input to output: */ + for (;;) { + /* Fill the window as much as possible: */ + if (s->lookahead <= 1) { + + Assert(s->strstart < s->w_size+MAX_DIST(s) || + s->block_start >= (long)s->w_size, "slide too late"); + + fill_window(s); + if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + + if (s->lookahead == 0) break; /* flush the current block */ + } + Assert(s->block_start >= 0L, "block gone"); + + s->strstart += s->lookahead; + s->lookahead = 0; + + /* Emit a stored block if pending_buf will be full: */ + max_start = s->block_start + max_block_size; + if (s->strstart == 0 || (ulg)s->strstart >= max_start) { + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s->lookahead = (uInt)(s->strstart - max_start); + s->strstart = (uInt)max_start; + FLUSH_BLOCK(s, 0); + } + /* Flush if we may have to slide, otherwise block_start may become + * negative and the data will be gone: + */ + if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { + FLUSH_BLOCK(s, 0); + } + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local block_state deflate_fast(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head = NIL; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ +#ifdef FASTEST + if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) || + (s->strategy == Z_RLE && s->strstart - hash_head == 1)) { + s->match_length = longest_match_fast (s, hash_head); + } +#else + if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { + s->match_length = longest_match (s, hash_head); + } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { + s->match_length = longest_match_fast (s, hash_head); + } +#endif + /* longest_match() or longest_match_fast() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); + + _tr_tally_dist(s, s->strstart - s->match_start, + s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ +#ifndef FASTEST + if (s->match_length <= s->max_insert_length && + s->lookahead >= MIN_MATCH) { + s->match_length--; /* string at strstart already in table */ + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); + s->strstart++; + } else +#endif + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +#ifndef FASTEST +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +local block_state deflate_slow(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head = NIL; /* head of hash chain */ + int bflush; /* set if current block must be flushed */ + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + */ + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; + + if (hash_head != NIL && s->prev_length < s->max_lazy_match && + s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { + s->match_length = longest_match (s, hash_head); + } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { + s->match_length = longest_match_fast (s, hash_head); + } + /* longest_match() or longest_match_fast() sets match_start */ + + if (s->match_length <= 5 && (s->strategy == Z_FILTERED +#if TOO_FAR <= 32767 + || (s->match_length == MIN_MATCH && + s->strstart - s->match_start > TOO_FAR) +#endif + )) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s->match_length = MIN_MATCH-1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + check_match(s, s->strstart-1, s->prev_match, s->prev_length); + + _tr_tally_dist(s, s->strstart -1 - s->prev_match, + s->prev_length - MIN_MATCH, bflush); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart++; + + if (bflush) FLUSH_BLOCK(s, 0); + + } else if (s->match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s->match_available) { + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} +#endif /* FASTEST */ + +#if 0 +/* =========================================================================== + * For Z_RLE, simply look for runs of bytes, generate matches only of distance + * one. Do not maintain a hash table. (It will be regenerated if this run of + * deflate switches away from Z_RLE.) + */ +local block_state deflate_rle(s, flush) + deflate_state *s; + int flush; +{ + int bflush; /* set if current block must be flushed */ + uInt run; /* length of run */ + uInt max; /* maximum length of run */ + uInt prev; /* byte at distance one to match */ + Bytef *scan; /* scan for end of run */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the longest encodable run. + */ + if (s->lookahead < MAX_MATCH) { + fill_window(s); + if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* See how many times the previous byte repeats */ + run = 0; + if (s->strstart > 0) { /* if there is a previous byte, that is */ + max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; + scan = s->window + s->strstart - 1; + prev = *scan++; + do { + if (*scan++ != prev) + break; + } while (++run < max); + } + + /* Emit match if have run of MIN_MATCH or longer, else emit literal */ + if (run >= MIN_MATCH) { + check_match(s, s->strstart, s->strstart - 1, run); + _tr_tally_dist(s, 1, run - MIN_MATCH, bflush); + s->lookahead -= run; + s->strstart += run; + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} +#endif diff --git a/dep/StormLib/src/zlib/deflate.h b/dep/StormLib/src/zlib/deflate.h new file mode 100644 index 000000000..05a5ab3a2 --- /dev/null +++ b/dep/StormLib/src/zlib/deflate.h @@ -0,0 +1,331 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2004 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef DEFLATE_H +#define DEFLATE_H + +#include "zutil.h" + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer creation by deflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip encoding + should be left enabled. */ +#ifndef NO_GZIP +# define GZIP +#endif + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define INIT_STATE 42 +#define EXTRA_STATE 69 +#define NAME_STATE 73 +#define COMMENT_STATE 91 +#define HCRC_STATE 103 +#define BUSY_STATE 113 +#define FINISH_STATE 666 +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + uInt pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + gz_headerp gzhead; /* gzip header information to write */ + uInt gzindex; /* where in extra, name, or comment */ + Byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to supress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + int last_eob_len; /* bit length of EOB code for last block */ + +#ifdef DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + + /* in trees.c */ +void _tr_init OF((deflate_state *s)); +int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); +void _tr_align OF((deflate_state *s)); +void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch _length_code[]; + extern uch _dist_code[]; +#else + extern const uch _length_code[]; + extern const uch _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (length); \ + ush dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif /* DEFLATE_H */ diff --git a/dep/StormLib/src/zlib/inffast.c b/dep/StormLib/src/zlib/inffast.c new file mode 100644 index 000000000..bbee92ed1 --- /dev/null +++ b/dep/StormLib/src/zlib/inffast.c @@ -0,0 +1,318 @@ +/* inffast.c -- fast decoding + * Copyright (C) 1995-2004 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifndef ASMINF + +/* Allow machine dependent optimization for post-increment or pre-increment. + Based on testing to date, + Pre-increment preferred for: + - PowerPC G3 (Adler) + - MIPS R5000 (Randers-Pehrson) + Post-increment preferred for: + - none + No measurable difference: + - Pentium III (Anderson) + - M68060 (Nikl) + */ +#ifdef POSTINC +# define OFF 0 +# define PUP(a) *(a)++ +#else +# define OFF 1 +# define PUP(a) *++(a) +#endif + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ +void inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + unsigned char FAR *in; /* local strm->next_in */ + unsigned char FAR *last; /* while in < last, enough input available */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ +#ifdef INFLATE_STRICT + unsigned dmax; /* maximum distance from zlib header */ +#endif + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned write; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code this; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char FAR *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + in = strm->next_in - OFF; + last = in + (strm->avail_in - 5); + out = strm->next_out - OFF; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); +#ifdef INFLATE_STRICT + dmax = state->dmax; +#endif + wsize = state->wsize; + whave = state->whave; + write = state->write; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + this = lcode[hold & lmask]; + dolen: + op = (unsigned)(this.bits); + hold >>= op; + bits -= op; + op = (unsigned)(this.op); + if (op == 0) { /* literal */ + Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", this.val)); + PUP(out) = (unsigned char)(this.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + Tracevv((stderr, "inflate: length %u\n", len)); + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + this = dcode[hold & dmask]; + dodist: + op = (unsigned)(this.bits); + hold >>= op; + bits -= op; + op = (unsigned)(this.op); + if (op & 16) { /* distance base */ + dist = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); +#ifdef INFLATE_STRICT + if (dist > dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + hold >>= op; + bits -= op; + Tracevv((stderr, "inflate: distance %u\n", dist)); + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + from = window - OFF; + if (write == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + else if (write < op) { /* wrap around window */ + from += wsize + write - op; + op -= write; + if (op < len) { /* some from end of window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = window - OFF; + if (write < len) { /* some from start of window */ + op = write; + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + } + else { /* contiguous in window */ + from += write - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } while (len > 2); + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ + this = dcode[this.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) { /* 2nd level length code */ + this = lcode[this.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) { /* end-of-block */ + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + else { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + } while (in < last && out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + /* update state and return */ + strm->next_in = in + OFF; + strm->next_out = out + OFF; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; +} + +/* + inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): + - Using bit fields for code structure + - Different op definition to avoid & for extra bits (do & for table bits) + - Three separate decoding do-loops for direct, window, and write == 0 + - Special case for distance > 1 copies to do overlapped load and store copy + - Explicit branch predictions (based on measured branch probabilities) + - Deferring match copy and interspersed it with decoding subsequent codes + - Swapping literal/length else + - Swapping window/direct else + - Larger unrolled copy loops (three is about right) + - Moving len -= 3 statement into middle of loop + */ + +#endif /* !ASMINF */ diff --git a/dep/StormLib/src/zlib/inffast.h b/dep/StormLib/src/zlib/inffast.h new file mode 100644 index 000000000..1e88d2d97 --- /dev/null +++ b/dep/StormLib/src/zlib/inffast.h @@ -0,0 +1,11 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +void inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/dep/StormLib/src/zlib/inffixed.h b/dep/StormLib/src/zlib/inffixed.h new file mode 100644 index 000000000..75ed4b597 --- /dev/null +++ b/dep/StormLib/src/zlib/inffixed.h @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. It + is part of the implementation of the compression library and + is subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; diff --git a/dep/StormLib/src/zlib/inflate.c b/dep/StormLib/src/zlib/inflate.c new file mode 100644 index 000000000..792fdee8e --- /dev/null +++ b/dep/StormLib/src/zlib/inflate.c @@ -0,0 +1,1368 @@ +/* inflate.c -- zlib decompression + * Copyright (C) 1995-2005 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * Change history: + * + * 1.2.beta0 24 Nov 2002 + * - First version -- complete rewrite of inflate to simplify code, avoid + * creation of window when not needed, minimize use of window when it is + * needed, make inffast.c even faster, implement gzip decoding, and to + * improve code readability and style over the previous zlib inflate code + * + * 1.2.beta1 25 Nov 2002 + * - Use pointers for available input and output checking in inffast.c + * - Remove input and output counters in inffast.c + * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 + * - Remove unnecessary second byte pull from length extra in inffast.c + * - Unroll direct copy to three copies per loop in inffast.c + * + * 1.2.beta2 4 Dec 2002 + * - Change external routine names to reduce potential conflicts + * - Correct filename to inffixed.h for fixed tables in inflate.c + * - Make hbuf[] unsigned char to match parameter type in inflate.c + * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) + * to avoid negation problem on Alphas (64 bit) in inflate.c + * + * 1.2.beta3 22 Dec 2002 + * - Add comments on state->bits assertion in inffast.c + * - Add comments on op field in inftrees.h + * - Fix bug in reuse of allocated window after inflateReset() + * - Remove bit fields--back to byte structure for speed + * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths + * - Change post-increments to pre-increments in inflate_fast(), PPC biased? + * - Add compile time option, POSTINC, to use post-increments instead (Intel?) + * - Make MATCH copy in inflate() much faster for when inflate_fast() not used + * - Use local copies of stream next and avail values, as well as local bit + * buffer and bit count in inflate()--for speed when inflate_fast() not used + * + * 1.2.beta4 1 Jan 2003 + * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings + * - Move a comment on output buffer sizes from inffast.c to inflate.c + * - Add comments in inffast.c to introduce the inflate_fast() routine + * - Rearrange window copies in inflate_fast() for speed and simplification + * - Unroll last copy for window match in inflate_fast() + * - Use local copies of window variables in inflate_fast() for speed + * - Pull out common write == 0 case for speed in inflate_fast() + * - Make op and len in inflate_fast() unsigned for consistency + * - Add FAR to lcode and dcode declarations in inflate_fast() + * - Simplified bad distance check in inflate_fast() + * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new + * source file infback.c to provide a call-back interface to inflate for + * programs like gzip and unzip -- uses window as output buffer to avoid + * window copying + * + * 1.2.beta5 1 Jan 2003 + * - Improved inflateBack() interface to allow the caller to provide initial + * input in strm. + * - Fixed stored blocks bug in inflateBack() + * + * 1.2.beta6 4 Jan 2003 + * - Added comments in inffast.c on effectiveness of POSTINC + * - Typecasting all around to reduce compiler warnings + * - Changed loops from while (1) or do {} while (1) to for (;;), again to + * make compilers happy + * - Changed type of window in inflateBackInit() to unsigned char * + * + * 1.2.beta7 27 Jan 2003 + * - Changed many types to unsigned or unsigned short to avoid warnings + * - Added inflateCopy() function + * + * 1.2.0 9 Mar 2003 + * - Changed inflateBack() interface to provide separate opaque descriptors + * for the in() and out() functions + * - Changed inflateBack() argument and in_func typedef to swap the length + * and buffer address return values for the input function + * - Check next_in and next_out for Z_NULL on entry to inflate() + * + * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifdef MAKEFIXED +# ifndef BUILDFIXED +# define BUILDFIXED +# endif +#endif + +/* function prototypes */ +local void fixedtables OF((struct inflate_state FAR *state)); +local int updatewindow OF((z_streamp strm, unsigned out)); +#ifdef BUILDFIXED + void makefixed OF((void)); +#endif +local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, + unsigned len)); + +int ZEXPORT inflateReset(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + strm->total_in = strm->total_out = state->total = 0; + strm->msg = Z_NULL; + strm->adler = 1; /* to support ill-conceived Java test suite */ + state->mode = HEAD; + state->last = 0; + state->havedict = 0; + state->dmax = 32768U; + state->head = Z_NULL; + state->wsize = 0; + state->whave = 0; + state->write = 0; + state->hold = 0; + state->bits = 0; + state->lencode = state->distcode = state->next = state->codes; + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + +int ZEXPORT inflatePrime(strm, bits, value) +z_streamp strm; +int bits; +int value; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; + value &= (1L << bits) - 1; + state->hold += value << state->bits; + state->bits += bits; + return Z_OK; +} + +int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) +z_streamp strm; +int windowBits; +const char *version; +int stream_size; +{ + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL) return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *) + ZALLOC(strm, 1, sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (struct internal_state FAR *)state; + if (windowBits < 0) { + state->wrap = 0; + windowBits = -windowBits; + } + else { + state->wrap = (windowBits >> 4) + 1; +#ifdef GUNZIP + if (windowBits < 48) windowBits &= 15; +#endif + } + if (windowBits < 8 || windowBits > 15) { + ZFREE(strm, state); + strm->state = Z_NULL; + return Z_STREAM_ERROR; + } + state->wbits = (unsigned)windowBits; + state->window = Z_NULL; + return inflateReset(strm); +} + +int ZEXPORT inflateInit_(strm, version, stream_size) +z_streamp strm; +const char *version; +int stream_size; +{ + return inflateInit2_(strm, DEF_WBITS, version, stream_size); +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +#ifdef MAKEFIXED +#include + +/* + Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also + defines BUILDFIXED, so the tables are built on the fly. makefixed() writes + those tables to stdout, which would be piped to inffixed.h. A small program + can simply call makefixed to do this: + + void makefixed(void); + + int main(void) + { + makefixed(); + return 0; + } + + Then that can be linked with zlib built with MAKEFIXED defined and run: + + a.out > inffixed.h + */ +void makefixed() +{ + unsigned low, size; + struct inflate_state state; + + fixedtables(&state); + puts(" /* inffixed.h -- table for decoding fixed codes"); + puts(" * Generated automatically by makefixed()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 7) == 0) printf("\n "); + printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, + state.lencode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) printf("\n "); + printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, + state.distcode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); +} +#endif /* MAKEFIXED */ + +/* + Update the window with the last wsize (normally 32K) bytes written before + returning. If window does not exist yet, create it. This is only called + when a window is already in use, or when output has been written during this + inflate call, but the end of the deflate stream has not been reached yet. + It is also called to create a window for dictionary data when a dictionary + is loaded. + + Providing output buffers larger than 32K to inflate() should provide a speed + advantage, since only the last 32K of output is copied to the sliding window + upon return from inflate(), and since all distances after the first 32K of + output will fall in the output data, making match copies simpler and faster. + The advantage may be dependent on the size of the processor's data caches. + */ +local int updatewindow(strm, out) +z_streamp strm; +unsigned out; +{ + struct inflate_state FAR *state; + unsigned copy, dist; + + state = (struct inflate_state FAR *)strm->state; + + /* if it hasn't been done already, allocate space for the window */ + if (state->window == Z_NULL) { + state->window = (unsigned char FAR *) + ZALLOC(strm, 1U << state->wbits, + sizeof(unsigned char)); + if (state->window == Z_NULL) return 1; + } + + /* if window not in use yet, initialize */ + if (state->wsize == 0) { + state->wsize = 1U << state->wbits; + state->write = 0; + state->whave = 0; + } + + /* copy state->wsize or less output bytes into the circular window */ + copy = out - strm->avail_out; + if (copy >= state->wsize) { + zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); + state->write = 0; + state->whave = state->wsize; + } + else { + dist = state->wsize - state->write; + if (dist > copy) dist = copy; + zmemcpy(state->window + state->write, strm->next_out - copy, dist); + copy -= dist; + if (copy) { + zmemcpy(state->window, strm->next_out - copy, copy); + state->write = copy; + state->whave = state->wsize; + } + else { + state->write += dist; + if (state->write == state->wsize) state->write = 0; + if (state->whave < state->wsize) state->whave += dist; + } + } + return 0; +} + +/* Macros for inflate(): */ + +/* check function to use adler32() for zlib or crc32() for gzip */ +#ifdef GUNZIP +# define UPDATE(check, buf, len) \ + (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) +#else +# define UPDATE(check, buf, len) adler32(check, buf, len) +#endif + +/* check macros for header crc */ +#ifdef GUNZIP +# define CRC2(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + check = crc32(check, hbuf, 2); \ + } while (0) + +# define CRC4(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + hbuf[2] = (unsigned char)((word) >> 16); \ + hbuf[3] = (unsigned char)((word) >> 24); \ + check = crc32(check, hbuf, 4); \ + } while (0) +#endif + +/* Load registers with state in inflate() for speed */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Restore state from registers in inflate() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflate() + if there is no input available. */ +#define PULLBYTE() \ + do { \ + if (have == 0) goto inf_leave; \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflate(). */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Reverse the bytes in a 32-bit value */ +#define REVERSE(q) \ + ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +/* + inflate() uses a state machine to process as much input data and generate as + much output data as possible before returning. The state machine is + structured roughly as follows: + + for (;;) switch (state) { + ... + case STATEn: + if (not enough input data or output space to make progress) + return; + ... make progress ... + state = STATEm; + break; + ... + } + + so when inflate() is called again, the same case is attempted again, and + if the appropriate resources are provided, the machine proceeds to the + next state. The NEEDBITS() macro is usually the way the state evaluates + whether it can proceed or should return. NEEDBITS() does the return if + the requested bits are not available. The typical use of the BITS macros + is: + + NEEDBITS(n); + ... do something with BITS(n) ... + DROPBITS(n); + + where NEEDBITS(n) either returns from inflate() if there isn't enough + input left to load n bits into the accumulator, or it continues. BITS(n) + gives the low n bits in the accumulator. When done, DROPBITS(n) drops + the low n bits off the accumulator. INITBITS() clears the accumulator + and sets the number of available bits to zero. BYTEBITS() discards just + enough bits to put the accumulator on a byte boundary. After BYTEBITS() + and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. + + NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return + if there is no input available. The decoding of variable length codes uses + PULLBYTE() directly in order to pull just enough bytes to decode the next + code, and no more. + + Some states loop until they get enough input, making sure that enough + state information is maintained to continue the loop where it left off + if NEEDBITS() returns in the loop. For example, want, need, and keep + would all have to actually be part of the saved state in case NEEDBITS() + returns: + + case STATEw: + while (want < need) { + NEEDBITS(n); + keep[want++] = BITS(n); + DROPBITS(n); + } + state = STATEx; + case STATEx: + + As shown above, if the next state is also the next case, then the break + is omitted. + + A state may also return if there is not enough output space available to + complete that state. Those states are copying stored data, writing a + literal byte, and copying a matching string. + + When returning, a "goto inf_leave" is used to update the total counters, + update the check value, and determine whether any progress has been made + during that inflate() call in order to return the proper return code. + Progress is defined as a change in either strm->avail_in or strm->avail_out. + When there is a window, goto inf_leave will update the window with the last + output written. If a goto inf_leave occurs in the middle of decompression + and there is no window currently, goto inf_leave will create one and copy + output to the window for the next call of inflate(). + + In this implementation, the flush parameter of inflate() only affects the + return code (per zlib.h). inflate() always writes as much as possible to + strm->next_out, given the space available and the provided input--the effect + documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers + the allocation of and copying into a sliding window until necessary, which + provides the effect documented in zlib.h for Z_FINISH when the entire input + stream available. So the only thing the flush parameter actually does is: + when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it + will return Z_BUF_ERROR if it has not reached the end of the stream. + */ + +int ZEXPORT inflate(strm, flush) +z_streamp strm; +int flush; +{ + struct inflate_state FAR *state; + unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned in, out; /* save starting available input and output */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code this; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ +#ifdef GUNZIP + unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ +#endif + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0)) + return Z_STREAM_ERROR; + + state = (struct inflate_state FAR *)strm->state; + if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ + LOAD(); + in = have; + out = left; + ret = Z_OK; + for (;;) + switch (state->mode) { + case HEAD: + if (state->wrap == 0) { + state->mode = TYPEDO; + break; + } + NEEDBITS(16); +#ifdef GUNZIP + if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + state->check = crc32(0L, Z_NULL, 0); + CRC2(state->check, hold); + INITBITS(); + state->mode = FLAGS; + break; + } + state->flags = 0; /* expect zlib header */ + if (state->head != Z_NULL) + state->head->done = -1; + if (!(state->wrap & 1) || /* check if zlib header allowed */ +#else + if ( +#endif + ((BITS(8) << 8) + (hold >> 8)) % 31) { + strm->msg = (char *)"incorrect header check"; + state->mode = BAD; + break; + } + if (BITS(4) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + DROPBITS(4); + len = BITS(4) + 8; + if (len > state->wbits) { + strm->msg = (char *)"invalid window size"; + state->mode = BAD; + break; + } + state->dmax = 1U << len; + Tracev((stderr, "inflate: zlib header ok\n")); + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = hold & 0x200 ? DICTID : TYPE; + INITBITS(); + break; +#ifdef GUNZIP + case FLAGS: + NEEDBITS(16); + state->flags = (int)(hold); + if ((state->flags & 0xff) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + if (state->flags & 0xe000) { + strm->msg = (char *)"unknown header flags set"; + state->mode = BAD; + break; + } + if (state->head != Z_NULL) + state->head->text = (int)((hold >> 8) & 1); + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = TIME; + case TIME: + NEEDBITS(32); + if (state->head != Z_NULL) + state->head->time = hold; + if (state->flags & 0x0200) CRC4(state->check, hold); + INITBITS(); + state->mode = OS; + case OS: + NEEDBITS(16); + if (state->head != Z_NULL) { + state->head->xflags = (int)(hold & 0xff); + state->head->os = (int)(hold >> 8); + } + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = EXLEN; + case EXLEN: + if (state->flags & 0x0400) { + NEEDBITS(16); + state->length = (unsigned)(hold); + if (state->head != Z_NULL) + state->head->extra_len = (unsigned)hold; + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + } + else if (state->head != Z_NULL) + state->head->extra = Z_NULL; + state->mode = EXTRA; + case EXTRA: + if (state->flags & 0x0400) { + copy = state->length; + if (copy > have) copy = have; + if (copy) { + if (state->head != Z_NULL && + state->head->extra != Z_NULL) { + len = state->head->extra_len - state->length; + zmemcpy(state->head->extra + len, next, + len + copy > state->head->extra_max ? + state->head->extra_max - len : copy); + } + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + state->length -= copy; + } + if (state->length) goto inf_leave; + } + state->length = 0; + state->mode = NAME; + case NAME: + if (state->flags & 0x0800) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->name != Z_NULL && + state->length < state->head->name_max) + state->head->name[state->length++] = len; + } while (len && copy < have); + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->name = Z_NULL; + state->length = 0; + state->mode = COMMENT; + case COMMENT: + if (state->flags & 0x1000) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->comment != Z_NULL && + state->length < state->head->comm_max) + state->head->comment[state->length++] = len; + } while (len && copy < have); + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->comment = Z_NULL; + state->mode = HCRC; + case HCRC: + if (state->flags & 0x0200) { + NEEDBITS(16); + if (hold != (state->check & 0xffff)) { + strm->msg = (char *)"header crc mismatch"; + state->mode = BAD; + break; + } + INITBITS(); + } + if (state->head != Z_NULL) { + state->head->hcrc = (int)((state->flags >> 9) & 1); + state->head->done = 1; + } + strm->adler = state->check = crc32(0L, Z_NULL, 0); + state->mode = TYPE; + break; +#endif + case DICTID: + NEEDBITS(32); + strm->adler = state->check = REVERSE(hold); + INITBITS(); + state->mode = DICT; + case DICT: + if (state->havedict == 0) { + RESTORE(); + return Z_NEED_DICT; + } + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = TYPE; + case TYPE: + if (flush == Z_BLOCK) goto inf_leave; + case TYPEDO: + if (state->last) { + BYTEBITS(); + state->mode = CHECK; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + case STORED: + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + state->mode = COPY; + case COPY: + copy = state->length; + if (copy) { + if (copy > have) copy = have; + if (copy > left) copy = left; + if (copy == 0) goto inf_leave; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + break; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + case TABLE: + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + state->have = 0; + state->mode = LENLENS; + case LENLENS: + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + state->have = 0; + state->mode = CODELENS; + case CODELENS: + while (state->have < state->nlen + state->ndist) { + for (;;) { + this = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.val < 16) { + NEEDBITS(this.bits); + DROPBITS(this.bits); + state->lens[state->have++] = this.val; + } + else { + if (this.val == 16) { + NEEDBITS(this.bits + 2); + DROPBITS(this.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = state->lens[state->have - 1]; + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (this.val == 17) { + NEEDBITS(this.bits + 3); + DROPBITS(this.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(this.bits + 7); + DROPBITS(this.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* build code tables */ + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN; + case LEN: + if (have >= 6 && left >= 258) { + RESTORE(); + inflate_fast(strm, out); + LOAD(); + break; + } + for (;;) { + this = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.op && (this.op & 0xf0) == 0) { + last = this; + for (;;) { + this = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + state->length = (unsigned)this.val; + if ((int)(this.op) == 0) { + Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", this.val)); + state->mode = LIT; + break; + } + if (this.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + if (this.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + state->extra = (unsigned)(this.op) & 15; + state->mode = LENEXT; + case LENEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + state->mode = DIST; + case DIST: + for (;;) { + this = state->distcode[BITS(state->distbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if ((this.op & 0xf0) == 0) { + last = this; + for (;;) { + this = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + if (this.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)this.val; + state->extra = (unsigned)(this.op) & 15; + state->mode = DISTEXT; + case DISTEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + } +#ifdef INFLATE_STRICT + if (state->offset > state->dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + if (state->offset > state->whave + out - left) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + state->mode = MATCH; + case MATCH: + if (left == 0) goto inf_leave; + copy = out - left; + if (state->offset > copy) { /* copy from window */ + copy = state->offset - copy; + if (copy > state->write) { + copy -= state->write; + from = state->window + (state->wsize - copy); + } + else + from = state->window + (state->write - copy); + if (copy > state->length) copy = state->length; + } + else { /* copy from output */ + from = put - state->offset; + copy = state->length; + } + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = *from++; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; + case LIT: + if (left == 0) goto inf_leave; + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + case CHECK: + if (state->wrap) { + NEEDBITS(32); + out -= left; + strm->total_out += out; + state->total += out; + if (out) + strm->adler = state->check = + UPDATE(state->check, put - out, out); + out = left; + if (( +#ifdef GUNZIP + state->flags ? hold : +#endif + REVERSE(hold)) != state->check) { + strm->msg = (char *)"incorrect data check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: check matches trailer\n")); + } +#ifdef GUNZIP + state->mode = LENGTH; + case LENGTH: + if (state->wrap && state->flags) { + NEEDBITS(32); + if (hold != (state->total & 0xffffffffUL)) { + strm->msg = (char *)"incorrect length check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: length matches trailer\n")); + } +#endif + state->mode = DONE; + case DONE: + ret = Z_STREAM_END; + goto inf_leave; + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + default: + return Z_STREAM_ERROR; + } + + /* + Return from inflate(), updating the total counts and the check value. + If there was no progress during the inflate() call, return a buffer + error. Call updatewindow() to create and/or update the window state. + Note: a memory error from inflate() is non-recoverable. + */ + inf_leave: + RESTORE(); + if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) + if (updatewindow(strm, out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + in -= strm->avail_in; + out -= strm->avail_out; + strm->total_in += in; + strm->total_out += out; + state->total += out; + if (state->wrap && out) + strm->adler = state->check = + UPDATE(state->check, strm->next_out - out, out); + strm->data_type = state->bits + (state->last ? 64 : 0) + + (state->mode == TYPE ? 128 : 0); + if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) + ret = Z_BUF_ERROR; + return ret; +} + +int ZEXPORT inflateEnd(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->window != Z_NULL) ZFREE(strm, state->window); + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + +int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) +z_streamp strm; +const Bytef *dictionary; +uInt dictLength; +{ + struct inflate_state FAR *state; + unsigned long id; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->wrap != 0 && state->mode != DICT) + return Z_STREAM_ERROR; + + /* check for correct dictionary id */ + if (state->mode == DICT) { + id = adler32(0L, Z_NULL, 0); + id = adler32(id, dictionary, dictLength); + if (id != state->check) + return Z_DATA_ERROR; + } + + /* copy dictionary to window */ + if (updatewindow(strm, strm->avail_out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + if (dictLength > state->wsize) { + zmemcpy(state->window, dictionary + dictLength - state->wsize, + state->wsize); + state->whave = state->wsize; + } + else { + zmemcpy(state->window + state->wsize - dictLength, dictionary, + dictLength); + state->whave = dictLength; + } + state->havedict = 1; + Tracev((stderr, "inflate: dictionary set\n")); + return Z_OK; +} + +int ZEXPORT inflateGetHeader(strm, head) +z_streamp strm; +gz_headerp head; +{ + struct inflate_state FAR *state; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; + + /* save header structure */ + state->head = head; + head->done = 0; + return Z_OK; +} + +/* + Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found + or when out of input. When called, *have is the number of pattern bytes + found in order so far, in 0..3. On return *have is updated to the new + state. If on return *have equals four, then the pattern was found and the + return value is how many bytes were read including the last byte of the + pattern. If *have is less than four, then the pattern has not been found + yet and the return value is len. In the latter case, syncsearch() can be + called again with more data and the *have state. *have is initialized to + zero for the first call. + */ +local unsigned syncsearch(have, buf, len) +unsigned FAR *have; +unsigned char FAR *buf; +unsigned len; +{ + unsigned got; + unsigned next; + + got = *have; + next = 0; + while (next < len && got < 4) { + if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) + got++; + else if (buf[next]) + got = 0; + else + got = 4 - got; + next++; + } + *have = got; + return next; +} + +int ZEXPORT inflateSync(strm) +z_streamp strm; +{ + unsigned len; /* number of bytes to look at or looked at */ + unsigned long in, out; /* temporary to save total_in and total_out */ + unsigned char buf[4]; /* to restore bit buffer to byte string */ + struct inflate_state FAR *state; + + /* check parameters */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; + + /* if first time, start search in bit buffer */ + if (state->mode != SYNC) { + state->mode = SYNC; + state->hold <<= state->bits & 7; + state->bits -= state->bits & 7; + len = 0; + while (state->bits >= 8) { + buf[len++] = (unsigned char)(state->hold); + state->hold >>= 8; + state->bits -= 8; + } + state->have = 0; + syncsearch(&(state->have), buf, len); + } + + /* search available input */ + len = syncsearch(&(state->have), strm->next_in, strm->avail_in); + strm->avail_in -= len; + strm->next_in += len; + strm->total_in += len; + + /* return no joy or set up to restart inflate() on a new block */ + if (state->have != 4) return Z_DATA_ERROR; + in = strm->total_in; out = strm->total_out; + inflateReset(strm); + strm->total_in = in; strm->total_out = out; + state->mode = TYPE; + return Z_OK; +} + +/* + Returns true if inflate is currently at the end of a block generated by + Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + implementation to provide an additional safety check. PPP uses + Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored + block. When decompressing, PPP checks that at the end of input packet, + inflate is waiting for these length bytes. + */ +int ZEXPORT inflateSyncPoint(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + return state->mode == STORED && state->bits == 0; +} + +int ZEXPORT inflateCopy(dest, source) +z_streamp dest; +z_streamp source; +{ + struct inflate_state FAR *state; + struct inflate_state FAR *copy; + unsigned char FAR *window; + unsigned wsize; + + /* check input */ + if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || + source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)source->state; + + /* allocate space */ + copy = (struct inflate_state FAR *) + ZALLOC(source, 1, sizeof(struct inflate_state)); + if (copy == Z_NULL) return Z_MEM_ERROR; + window = Z_NULL; + if (state->window != Z_NULL) { + window = (unsigned char FAR *) + ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); + if (window == Z_NULL) { + ZFREE(source, copy); + return Z_MEM_ERROR; + } + } + + /* copy state */ + zmemcpy(dest, source, sizeof(z_stream)); + zmemcpy(copy, state, sizeof(struct inflate_state)); + if (state->lencode >= state->codes && + state->lencode <= state->codes + ENOUGH - 1) { + copy->lencode = copy->codes + (state->lencode - state->codes); + copy->distcode = copy->codes + (state->distcode - state->codes); + } + copy->next = copy->codes + (state->next - state->codes); + if (window != Z_NULL) { + wsize = 1U << state->wbits; + zmemcpy(window, state->window, wsize); + } + copy->window = window; + dest->state = (struct internal_state FAR *)copy; + return Z_OK; +} diff --git a/dep/StormLib/src/zlib/inflate.h b/dep/StormLib/src/zlib/inflate.h new file mode 100644 index 000000000..07bd3e78a --- /dev/null +++ b/dep/StormLib/src/zlib/inflate.h @@ -0,0 +1,115 @@ +/* inflate.h -- internal inflate state definition + * Copyright (C) 1995-2004 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ +#ifndef NO_GZIP +# define GUNZIP +#endif + +/* Possible inflate modes between inflate() calls */ +typedef enum { + HEAD, /* i: waiting for magic header */ + FLAGS, /* i: waiting for method and flags (gzip) */ + TIME, /* i: waiting for modification time (gzip) */ + OS, /* i: waiting for extra flags and operating system (gzip) */ + EXLEN, /* i: waiting for extra length (gzip) */ + EXTRA, /* i: waiting for extra bytes (gzip) */ + NAME, /* i: waiting for end of file name (gzip) */ + COMMENT, /* i: waiting for end of comment (gzip) */ + HCRC, /* i: waiting for header crc (gzip) */ + DICTID, /* i: waiting for dictionary check value */ + DICT, /* waiting for inflateSetDictionary() call */ + TYPE, /* i: waiting for type bits, including last-flag bit */ + TYPEDO, /* i: same, but skip check to exit inflate on new block */ + STORED, /* i: waiting for stored size (length and complement) */ + COPY, /* i/o: waiting for input or output to copy stored block */ + TABLE, /* i: waiting for dynamic block table lengths */ + LENLENS, /* i: waiting for code length code lengths */ + CODELENS, /* i: waiting for length/lit and distance code lengths */ + LEN, /* i: waiting for length/lit code */ + LENEXT, /* i: waiting for length extra bits */ + DIST, /* i: waiting for distance code */ + DISTEXT, /* i: waiting for distance extra bits */ + MATCH, /* o: waiting for output space to copy string */ + LIT, /* o: waiting for output space to write literal */ + CHECK, /* i: waiting for 32-bit check value */ + LENGTH, /* i: waiting for 32-bit length (gzip) */ + DONE, /* finished check, done -- remain here until reset */ + BAD, /* got a data error -- remain here until reset */ + MEM, /* got an inflate() memory error -- remain here until reset */ + SYNC /* looking for synchronization bytes to restart inflate() */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to the BAD or MEM mode -- not shown for clarity) + + Process header: + HEAD -> (gzip) or (zlib) + (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME + NAME -> COMMENT -> HCRC -> TYPE + (zlib) -> DICTID or TYPE + DICTID -> DICT -> TYPE + Read deflate blocks: + TYPE -> STORED or TABLE or LEN or CHECK + STORED -> COPY -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN + Read deflate codes: + LEN -> LENEXT or LIT or TYPE + LENEXT -> DIST -> DISTEXT -> MATCH -> LEN + LIT -> LEN + Process trailer: + CHECK -> LENGTH -> DONE + */ + +/* state maintained between inflate() calls. Approximately 7K bytes. */ +struct inflate_state { + inflate_mode mode; /* current inflate mode */ + int last; /* true if processing last block */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + int havedict; /* true if dictionary provided */ + int flags; /* gzip header method and flags (0 if zlib) */ + unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ + gz_headerp head; /* where to save gzip header information */ + /* sliding window */ + unsigned wbits; /* log base 2 of requested window size */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned write; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* bit accumulator */ + unsigned long hold; /* input bit accumulator */ + unsigned bits; /* number of bits in "in" */ + /* for string and stored block copying */ + unsigned length; /* literal or length of data to copy */ + unsigned offset; /* distance back to copy string from */ + /* for table and code decoding */ + unsigned extra; /* extra bits needed */ + /* fixed and dynamic code tables */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ +}; diff --git a/dep/StormLib/src/zlib/inftrees.c b/dep/StormLib/src/zlib/inftrees.c new file mode 100644 index 000000000..8a9c13ff0 --- /dev/null +++ b/dep/StormLib/src/zlib/inftrees.c @@ -0,0 +1,329 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2005 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" + +#define MAXBITS 15 + +const char inflate_copyright[] = + " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* + Build a set of tables to decode the provided canonical Huffman code. + The code lengths are lens[0..codes-1]. The result starts at *table, + whose indices are 0..2^bits-1. work is a writable array of at least + lens shorts, which is used as a work area. type is the type of code + to be generated, CODES, LENS, or DISTS. On return, zero is success, + -1 is an invalid code, and +1 means that ENOUGH isn't enough. table + on return points to the next available entry's address. bits is the + requested root table index bits, and on return it is the actual root + table index bits. It will differ if the request is greater than the + longest code or if it is less than the shortest code. + */ +int inflate_table(type, lens, codes, table, bits, work) +codetype type; +unsigned short FAR *lens; +unsigned codes; +code FAR * FAR *table; +unsigned FAR *bits; +unsigned short FAR *work; +{ + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code this; /* table entry for duplication */ + code FAR *next; /* next available space in table */ + const unsigned short FAR *base; /* base value table to use */ + const unsigned short FAR *extra; /* extra bits table to use */ + int end; /* use base and extra for symbol > end */ + unsigned short count[MAXBITS+1]; /* number of codes of each length */ + unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; + static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577, 0, 0}; + static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ + 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 28, 28, 29, 29, 64, 64}; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) + count[len] = 0; + for (sym = 0; sym < codes; sym++) + count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAXBITS; max >= 1; max--) + if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) { /* no symbols to code at all */ + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)1; + this.val = (unsigned short)0; + *(*table)++ = this; /* make a table to force an error */ + *(*table)++ = this; + *bits = 1; + return 0; /* no symbols, but wait for decoding to report error */ + } + for (min = 1; min <= MAXBITS; min++) + if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || max != 1)) + return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) + if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked when a LENS table is being made + against the space in *table, ENOUGH, minus the maximum space needed by + the worst case distance code, MAXD. This should never happen, but the + sufficiency of ENOUGH has not been proven exhaustively, hence the check. + This assumes that when type == LENS, bits == 9. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + switch (type) { + case CODES: + base = extra = work; /* dummy value--not used */ + end = 19; + break; + case LENS: + base = lbase; + base -= 257; + extra = lext; + extra -= 257; + end = 256; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if (type == LENS && used >= ENOUGH - MAXD) + return 1; + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + this.bits = (unsigned char)(len - drop); + if ((int)(work[sym]) < end) { + this.op = (unsigned char)0; + this.val = work[sym]; + } + else if ((int)(work[sym]) > end) { + this.op = (unsigned char)(extra[work[sym]]); + this.val = base[work[sym]]; + } + else { + this.op = (unsigned char)(32 + 64); /* end of block */ + this.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + min = fill; /* save offset to next table */ + do { + fill -= incr; + next[(huff >> drop) + fill] = this; + } while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) { + /* if first time, transition to sub-tables */ + if (drop == 0) + drop = root; + + /* increment past last table */ + next += min; /* here min is 1 << curr */ + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if (type == LENS && used >= ENOUGH - MAXD) + return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + /* + Fill in rest of table for incomplete codes. This loop is similar to the + loop above in incrementing huff for table indices. It is assumed that + len is equal to curr + drop, so there is no loop needed to increment + through high index bits. When the current sub-table is filled, the loop + drops back to the root table to fill in any remaining entries there. + */ + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)(len - drop); + this.val = (unsigned short)0; + while (huff != 0) { + /* when done with sub-table, drop back to root table */ + if (drop != 0 && (huff & mask) != low) { + drop = 0; + len = root; + next = *table; + this.bits = (unsigned char)len; + } + + /* put invalid code marker in table */ + next[huff >> drop] = this; + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + } + + /* set return parameters */ + *table += used; + *bits = root; + return 0; +} diff --git a/dep/StormLib/src/zlib/inftrees.h b/dep/StormLib/src/zlib/inftrees.h new file mode 100644 index 000000000..b1104c87e --- /dev/null +++ b/dep/StormLib/src/zlib/inftrees.h @@ -0,0 +1,55 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2005 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 0001eeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of dynamic tree. The maximum found in a long but non- + exhaustive search was 1444 code structures (852 for length/literals + and 592 for distances, the latter actually the result of an + exhaustive search). The true maximum is not known, but the value + below is more than safe. */ +#define ENOUGH 2048 +#define MAXD 592 + +/* Type of code to build for inftable() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +extern int inflate_table OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); diff --git a/dep/StormLib/src/zlib/trees.c b/dep/StormLib/src/zlib/trees.c new file mode 100644 index 000000000..395e4e168 --- /dev/null +++ b/dep/StormLib/src/zlib/trees.c @@ -0,0 +1,1219 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1995-2005 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in a compressed form which is itself + * a Huffman encoding of the lengths of all the code strings (in + * ascending order by source values). The actual code strings are + * reconstructed from the lengths in the inflate process, as described + * in the deflate specification. + * + * REFERENCES + * + * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". + * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + */ + +/* @(#) $Id$ */ + +/* #define GEN_TREES_H */ + +#include "deflate.h" + +#ifdef DEBUG +# include +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +local const uch bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +#define Buf_size (8 * 2*sizeof(char)) +/* Number of bits used within bi_buf. (bi_buf might be implemented on + * more than 16 bits on some systems.) + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + +local ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +local ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +uch _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +uch _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + +struct static_tree_desc_s { + const ct_data *static_tree; /* static tree or NULL */ + const intf *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ +}; + +local static_tree_desc static_l_desc = +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; + +local static_tree_desc static_d_desc = +{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; + +local static_tree_desc static_bl_desc = +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void tr_static_init OF((void)); +local void init_block OF((deflate_state *s)); +local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); +local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); +local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); +local void build_tree OF((deflate_state *s, tree_desc *desc)); +local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local int build_bl_tree OF((deflate_state *s)); +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, + int blcodes)); +local void compress_block OF((deflate_state *s, ct_data *ltree, + ct_data *dtree)); +local void set_data_type OF((deflate_state *s)); +local unsigned bi_reverse OF((unsigned value, int length)); +local void bi_windup OF((deflate_state *s)); +local void bi_flush OF((deflate_state *s)); +local void copy_block OF((deflate_state *s, charf *buf, unsigned len, + int header)); + +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + +#ifndef DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(s, tree[c].Code, tree[c].Len); } +#endif + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +#ifdef DEBUG +local void send_bits OF((deflate_state *s, int value, int length)); + +local void send_bits(s, value, length) + deflate_state *s; + int value; /* value to send */ + int length; /* number of bits */ +{ + Tracevv((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (ulg)length; + + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (value << s->bi_valid); + put_short(s, s->bi_buf); + s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= value << s->bi_valid; + s->bi_valid += length; + } +} +#else /* !DEBUG */ + +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = value;\ + s->bi_buf |= (val << s->bi_valid);\ + put_short(s, s->bi_buf);\ + s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} +#endif /* DEBUG */ + + +/* the arguments must not have side effects */ + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +local void tr_static_init() +{ +#if defined(GEN_TREES_H) || !defined(STDC) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) return; + + /* For some embedded targets, global variables are not initialized: */ + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1< dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); +} +#endif /* GEN_TREES_H */ + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +void _tr_init(s) + deflate_state *s; +{ + tr_static_init(); + + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; + s->last_eob_len = 8; /* enough lookahead for inflate */ +#ifdef DEBUG + s->compressed_len = 0L; + s->bits_sent = 0L; +#endif + + /* Initialize the first block of the first file: */ + init_block(s); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(s) + deflate_state *s; +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(s, tree, top) \ +{\ + top = s->heap[SMALLEST]; \ + s->heap[SMALLEST] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m, depth) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap(s, tree, k) + deflate_state *s; + ct_data *tree; /* the tree to restore */ + int k; /* node to move down */ +{ + int v = s->heap[k]; + int j = k << 1; /* left son of k */ + while (j <= s->heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s->heap_len && + smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s->heap[j], s->depth)) break; + + /* Exchange v with the smallest son */ + s->heap[k] = s->heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s->heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen(s, desc) + deflate_state *s; + tree_desc *desc; /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (ulg)f * (bits + xbits); + if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = s->bl_count[bits]; + while (n != 0) { + m = s->heap[--h]; + if (m > max_code) continue; + if ((unsigned) tree[m].Len != (unsigned) bits) { + Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((long)bits - (long)tree[m].Len) + *(long)tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes (tree, max_code, bl_count) + ct_data *tree; /* the tree to decorate */ + int max_code; /* largest code with non zero frequency */ + ushf *bl_count; /* number of codes at each bit length */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s->heap_len < 2) { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + /* node is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + pqremove(s, tree, n); /* n = node of least frequency */ + m = s->heap[SMALLEST]; /* m = node of next least frequency */ + + s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ + s->heap[--(s->heap_max)] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? + s->depth[n] : s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == s->bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + s->heap[SMALLEST] = node++; + pqdownheap(s, tree, SMALLEST); + + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, (tree_desc *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +local void scan_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + s->bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) s->bl_tree[curlen].Freq++; + s->bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + s->bl_tree[REPZ_3_10].Freq++; + } else { + s->bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(s, curlen, s->bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + + } else { + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree(s) + deflate_state *s; +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, (tree_desc *)(&(s->bl_desc))); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + s->opt_len += 3*(max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + s->opt_len, s->static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees(s, lcodes, dcodes, blcodes) + deflate_state *s; + int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + +/* =========================================================================== + * Send a stored block + */ +void _tr_stored_block(s, buf, stored_len, eof) + deflate_state *s; + charf *buf; /* input block */ + ulg stored_len; /* length of input block */ + int eof; /* true if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ +#ifdef DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; + s->compressed_len += (stored_len + 4) << 3; +#endif + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ +} + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + * The current inflate code requires 9 bits of lookahead. If the + * last two codes for the previous block (real code plus EOB) were coded + * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + * the last real code. In this case we send two empty static blocks instead + * of one. (There are no problems if the previous block is stored or fixed.) + * To simplify the code, we assume the worst case of last real code encoded + * on one bit only. + */ +void _tr_align(s) + deflate_state *s; +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif + bi_flush(s); + /* Of the 10 bits for the empty block, we have already sent + * (10 - bi_valid) bits. The lookahead for the last real code (before + * the EOB of the previous block) was thus at least one plus the length + * of the EOB plus what we have just sent of the empty static block. + */ + if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; +#endif + bi_flush(s); + } + s->last_eob_len = 7; +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. + */ +void _tr_flush_block(s, buf, stored_len, eof) + deflate_state *s; + charf *buf; /* input block, or NULL if too old */ + ulg stored_len; /* length of input block */ + int eof; /* true if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s->level > 0) { + + /* Check if the file is binary or text */ + if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN) + set_data_type(s); + + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /* Determine the best encoding. Compute the block lengths in bytes. */ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + } else { + Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + +#ifdef FORCE_STORED + if (buf != (char*)0) { /* force stored block */ +#else + if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, eof); + +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else + } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { +#endif + send_bits(s, (STATIC_TREES<<1)+eof, 3); + compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->static_len; +#endif + } else { + send_bits(s, (DYN_TREES<<1)+eof, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, + max_blindex+1); + compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->opt_len; +#endif + } + Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (eof) { + bi_windup(s); +#ifdef DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + s->compressed_len-7*eof)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int _tr_tally (s, dist, lc) + deflate_state *s; + unsigned dist; /* distance of matched string */ + unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + s->d_buf[s->last_lit] = (ush)dist; + s->l_buf[s->last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST(s) && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + +#ifdef TRUNCATE_BLOCK + /* Try to guess if it is profitable to stop the current block here */ + if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)s->dyn_dtree[dcode].Freq * + (5L+extra_dbits[dcode]); + } + out_length >>= 3; + Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", + s->last_lit, in_length, out_length, + 100L - out_length*100L/in_length)); + if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; + } +#endif + return (s->last_lit == s->lit_bufsize-1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(s, ltree, dtree) + deflate_state *s; + ct_data *ltree; /* literal tree */ + ct_data *dtree; /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->last_lit != 0) do { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, + "pendingBuf overflow"); + + } while (lx < s->last_lit); + + send_code(s, END_BLOCK, ltree); + s->last_eob_len = ltree[END_BLOCK].Len; +} + +/* =========================================================================== + * Set the data type to BINARY or TEXT, using a crude approximation: + * set it to Z_TEXT if all symbols are either printable characters (33 to 255) + * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise. + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local void set_data_type(s) + deflate_state *s; +{ + int n; + + for (n = 0; n < 9; n++) + if (s->dyn_ltree[n].Freq != 0) + break; + if (n == 9) + for (n = 14; n < 32; n++) + if (s->dyn_ltree[n].Freq != 0) + break; + s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY; +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +local unsigned bi_reverse(code, len) + unsigned code; /* the value to invert */ + int len; /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(s) + deflate_state *s; +{ + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(s) + deflate_state *s; +{ + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} + +/* =========================================================================== + * Copy a stored block, storing first the length and its + * one's complement if requested. + */ +local void copy_block(s, buf, len, header) + deflate_state *s; + charf *buf; /* the input data */ + unsigned len; /* its length */ + int header; /* true if block header must be written */ +{ + bi_windup(s); /* align on byte boundary */ + s->last_eob_len = 8; /* enough lookahead for inflate */ + + if (header) { + put_short(s, (ush)len); + put_short(s, (ush)~len); +#ifdef DEBUG + s->bits_sent += 2*16; +#endif + } +#ifdef DEBUG + s->bits_sent += (ulg)len<<3; +#endif + while (len--) { + put_byte(s, *buf++); + } +} diff --git a/dep/StormLib/src/zlib/trees.h b/dep/StormLib/src/zlib/trees.h new file mode 100644 index 000000000..72facf900 --- /dev/null +++ b/dep/StormLib/src/zlib/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/contrib/extractor/libmpq/zconf.h b/dep/StormLib/src/zlib/zconf.h similarity index 77% rename from contrib/extractor/libmpq/zconf.h rename to dep/StormLib/src/zlib/zconf.h index 3cea897ed..03a9431c8 100644 --- a/contrib/extractor/libmpq/zconf.h +++ b/dep/StormLib/src/zlib/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2003 Jean-loup Gailly. + * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -13,43 +13,50 @@ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. */ #ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflatePrime z_deflatePrime -# define deflateParams z_deflateParams -# define deflateBound z_deflateBound -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateCopy z_inflateCopy -# define inflateReset z_inflateReset -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp #endif #if defined(__MSDOS__) && !defined(MSDOS) @@ -61,8 +68,10 @@ #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) @@ -281,7 +290,7 @@ typedef uLong FAR uLongf; # ifdef VMS # include /* for off_t */ # endif -# define z_off_t off_t +# define z_off_t off_t #endif #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ @@ -289,11 +298,11 @@ typedef uLong FAR uLongf; # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t -# define z_off_t long +# define z_off_t long #endif #if defined(__OS400__) -#define NO_vsnprintf +# define NO_vsnprintf #endif #if defined(__MVS__) diff --git a/contrib/extractor/libmpq/zlib.h b/dep/StormLib/src/zlib/zlib.h similarity index 83% rename from contrib/extractor/libmpq/zlib.h rename to dep/StormLib/src/zlib/zlib.h index 92edf96ff..022817927 100644 --- a/contrib/extractor/libmpq/zlib.h +++ b/dep/StormLib/src/zlib/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.1, November 17th, 2003 + version 1.2.3, July 18th, 2005 - Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,8 +37,8 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.1" -#define ZLIB_VERNUM 0x1210 +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 /* The 'zlib' compression library provides in-memory compression and @@ -53,24 +53,22 @@ extern "C" { application must provide more input and/or consume the output (providing more output space) before each call. - The compressed data format used by the in-memory functions is the zlib - format, which is a zlib wrapper documented in RFC 1950, wrapped around a - deflate stream, which is itself documented in RFC 1951. + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + This library can optionally read and write gzip streams in memory as well. + The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. - This library does not provide any functions to write gzip files in memory. - However such functions could be easily written using zlib's deflate function, - the documentation in the gzip RFC, and the examples in gzio.c. - The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input. @@ -97,13 +95,36 @@ typedef struct z_stream_s { free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ - int data_type; /* best guess about the data type: ascii or binary */ + int data_type; /* best guess about the data type: binary or text */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + /* The application must update next_in and avail_in when avail_in has dropped to zero. It must update next_out and avail_out when avail_out @@ -168,11 +189,13 @@ typedef z_stream FAR *z_streamp; #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_RLE 3 +#define Z_FIXED 4 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 -#define Z_ASCII 1 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 /* Possible values of the data_type field (though see inflate()) */ @@ -246,6 +269,10 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is flushed to the output buffer and the output is aligned on a byte boundary, so that the decompressor can get all input data available so far. (In particular @@ -257,7 +284,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - the compression. + compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated @@ -282,8 +309,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); deflate() sets strm->adler to the adler32 checksum of all input read so far (that is, total_in bytes). - deflate() may update data_type if it can make a good guess about - the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. @@ -365,11 +392,11 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it get to the next deflate block boundary. When decoding the zlib - or gzip format, this will cause inflate() to return immediately after the - header and before the first block. When doing a raw inflate, inflate() will - go ahead and process the first block, and will return when it gets to the end - of that block, or when it runs out of data. + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. Also to assist in this, on return inflate() will set strm->data_type to the @@ -401,7 +428,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); because Z_BLOCK is used. If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm-adler to the adler32 checksum of the dictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described @@ -478,7 +505,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but @@ -497,7 +525,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid @@ -526,7 +556,9 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size in deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. Upon return of this function, strm->adler is set to the adler32 value of the dictionary; the decompressor may later use this value to determine @@ -592,6 +624,23 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, if strm->avail_out was zero. */ +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); /* @@ -617,6 +666,30 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, stream state was inconsistent. */ +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + /* ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, int windowBits)); @@ -649,14 +722,15 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative - memLevel). msg is set to null if there is no error message. inflateInit2 - does not perform any decompression apart from reading the zlib header if - present: this will be done by inflate(). (So next_in and avail_in may be - modified, but next_out and avail_out are unchanged.) + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) */ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, @@ -664,11 +738,14 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, uInt dictLength)); /* Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate - if this call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by this call of - inflate. The compressor and decompressor must use exactly the same - dictionary (see deflateSetDictionary). + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is @@ -719,8 +796,64 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); stream state was inconsistent (such as zalloc or state being NULL). */ +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); /* -ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits, + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, unsigned char FAR *window)); Initialize the internal stream state for decompression using inflateBack() @@ -744,7 +877,7 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits, typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); -ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm, +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)); /* @@ -813,7 +946,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm, that inflateBack() cannot return Z_OK. */ -ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm)); +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); /* All memory allocated by inflateBackInit() is freed. @@ -1087,6 +1220,12 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); input stream, otherwise zero. */ +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + ZEXTERN int ZEXPORT gzclose OF((gzFile file)); /* Flushes all pending output if necessary, closes the compressed file @@ -1119,7 +1258,6 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); */ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); - /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns @@ -1135,12 +1273,21 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); if (adler != original_adler) error(); */ +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* - Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is NULL, this function returns the required initial value - for the crc. Pre- and post-conditioning (one's complement) is performed - within this function so it shouldn't be done by the application. + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. Usage example: uLong crc = crc32(0L, Z_NULL, 0); @@ -1151,6 +1298,16 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); if (crc != original_crc) error(); */ +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + /* various hacks, don't look :) */ @@ -1167,7 +1324,7 @@ ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int stream_size)); ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits, +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)); @@ -1189,7 +1346,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits, struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif -ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); diff --git a/dep/StormLib/src/zlib/zutil.c b/dep/StormLib/src/zlib/zutil.c new file mode 100644 index 000000000..d55f5948a --- /dev/null +++ b/dep/StormLib/src/zlib/zutil.c @@ -0,0 +1,318 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +#ifndef NO_DUMMY_DECL +struct internal_state {int dummy;}; /* for buggy compilers */ +#endif + +const char * const z_errmsg[10] = { +"need dictionary", /* Z_NEED_DICT 2 */ +"stream end", /* Z_STREAM_END 1 */ +"", /* Z_OK 0 */ +"file error", /* Z_ERRNO (-1) */ +"stream error", /* Z_STREAM_ERROR (-2) */ +"data error", /* Z_DATA_ERROR (-3) */ +"insufficient memory", /* Z_MEM_ERROR (-4) */ +"buffer error", /* Z_BUF_ERROR (-5) */ +"incompatible version",/* Z_VERSION_ERROR (-6) */ +""}; + + +const char * ZEXPORT zlibVersion() +{ + return ZLIB_VERSION; +} + +uLong ZEXPORT zlibCompileFlags() +{ + uLong flags; + + flags = 0; + switch (sizeof(uInt)) { + case 2: break; + case 4: flags += 1; break; + case 8: flags += 2; break; + default: flags += 3; + } + switch (sizeof(uLong)) { + case 2: break; + case 4: flags += 1 << 2; break; + case 8: flags += 2 << 2; break; + default: flags += 3 << 2; + } + switch (sizeof(voidpf)) { + case 2: break; + case 4: flags += 1 << 4; break; + case 8: flags += 2 << 4; break; + default: flags += 3 << 4; + } + switch (sizeof(z_off_t)) { + case 2: break; + case 4: flags += 1 << 6; break; + case 8: flags += 2 << 6; break; + default: flags += 3 << 6; + } +#ifdef DEBUG + flags += 1 << 8; +#endif +#if defined(ASMV) || defined(ASMINF) + flags += 1 << 9; +#endif +#ifdef ZLIB_WINAPI + flags += 1 << 10; +#endif +#ifdef BUILDFIXED + flags += 1 << 12; +#endif +#ifdef DYNAMIC_CRC_TABLE + flags += 1 << 13; +#endif +#ifdef NO_GZCOMPRESS + flags += 1L << 16; +#endif +#ifdef NO_GZIP + flags += 1L << 17; +#endif +#ifdef PKZIP_BUG_WORKAROUND + flags += 1L << 20; +#endif +#ifdef FASTEST + flags += 1L << 21; +#endif +#ifdef STDC +# ifdef NO_vsnprintf + flags += 1L << 25; +# ifdef HAS_vsprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_vsnprintf_void + flags += 1L << 26; +# endif +# endif +#else + flags += 1L << 24; +# ifdef NO_snprintf + flags += 1L << 25; +# ifdef HAS_sprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_snprintf_void + flags += 1L << 26; +# endif +# endif +#endif + return flags; +} + +#ifdef DEBUG + +# ifndef verbose +# define verbose 0 +# endif +int z_verbose = verbose; + +void z_error (m) + char *m; +{ + fprintf(stderr, "%s\n", m); + exit(1); +} +#endif + +/* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +const char * ZEXPORT zError(err) + int err; +{ + return ERR_MSG(err); +} + +#if defined(_WIN32_WCE) + /* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. + */ + int errno = 0; +#endif + +#ifndef HAVE_MEMCPY + +void zmemcpy(dest, source, len) + Bytef* dest; + const Bytef* source; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int zmemcmp(s1, s2, len) + const Bytef* s1; + const Bytef* s2; + uInt len; +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void zmemzero(dest, len) + Bytef* dest; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + + +#ifdef SYS16BIT + +#ifdef __TURBOC__ +/* Turbo C in 16-bit mode */ + +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); +} + +#endif /* __TURBOC__ */ + + +#ifdef M_I86 +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + _hfree(ptr); +} + +#endif /* M_I86 */ + +#endif /* SYS16BIT */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp malloc OF((uInt size)); +extern voidp calloc OF((uInt items, uInt size)); +extern void free OF((voidpf ptr)); +#endif + +voidpf zcalloc (opaque, items, size) + voidpf opaque; + unsigned items; + unsigned size; +{ + if (opaque) items += size - size; /* make compiler happy */ + return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + (voidpf)calloc(items, size); +} + +void zcfree (opaque, ptr) + voidpf opaque; + voidpf ptr; +{ + free(ptr); + if (opaque) return; /* make compiler happy */ +} + +#endif /* MY_ZCALLOC */ diff --git a/dep/StormLib/src/zlib/zutil.h b/dep/StormLib/src/zlib/zutil.h new file mode 100644 index 000000000..b7d5eff81 --- /dev/null +++ b/dep/StormLib/src/zlib/zutil.h @@ -0,0 +1,269 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#define ZLIB_INTERNAL +#include "zlib.h" + +#ifdef STDC +# ifndef _WIN32_WCE +# include +# endif +# include +# include +#endif +#ifdef NO_ERRNO_H +# ifdef _WIN32_WCE + /* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. We rename it to + * avoid conflict with other libraries that use the same workaround. + */ +# define errno z_errno +# endif + extern int errno; +#else +# ifndef _WIN32_WCE +# include +# endif +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +# ifdef M_I86 + #include +# endif +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifdef WIN32 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0f +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS + /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 + /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# define vsnprintf _vsnprintf +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +#endif +#ifdef VMS +# define NO_vsnprintf +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* ZUTIL_H */ diff --git a/dep/StormLib/storm_dll/storm_dll.cpp b/dep/StormLib/storm_dll/storm_dll.cpp new file mode 100644 index 000000000..2941f2a37 --- /dev/null +++ b/dep/StormLib/storm_dll/storm_dll.cpp @@ -0,0 +1,117 @@ +/*****************************************************************************/ +/* Storm.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* This is just a dummy module for building import library for Storm.dll */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 11.04.03 1.00 Lad The first version of Storm.cpp */ +/*****************************************************************************/ + +#include + +#define BUILDING_STORM_CPP +#define STORM_ALTERNATE_NAMES +#include "storm_dll.h" + +BOOL WINAPI SFILE(OpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(CloseArchive)(HANDLE hMPQ) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(GetArchiveName)(HANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(OpenFile)(LPCSTR lpFileName, HANDLE *hFile) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(OpenFileEx)(HANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, HANDLE *hFile) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(CloseFile)(HANDLE hFile) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +DWORD WINAPI SFILE(GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(GetFileArchive)(HANDLE hFile, HANDLE *hMPQ) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(GetFileName)(HANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +DWORD WINAPI SFILE(SetFilePointer)(HANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +LCID WINAPI SFILE(SetLocale)(LCID nNewLocale) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(GetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(SetBasePath)(LPCSTR lpNewBasePath) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SFILE(Destroy)() +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SCOMP(Compress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCmp, int uCmpType, int nCmpLevel) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} diff --git a/dep/StormLib/storm_dll/storm_dll.def b/dep/StormLib/storm_dll/storm_dll.def new file mode 100644 index 000000000..bdc7ce76e --- /dev/null +++ b/dep/StormLib/storm_dll/storm_dll.def @@ -0,0 +1,24 @@ +; Storm definition file with alternate Storm.dll names +LIBRARY "Storm" + +EXPORTS + StormCloseArchive @252 ; 0x0FC + StormCloseFile @253 ; 0x0FD + StormDestroy @262 ; 0x106 + StormGetFileArchive @264 ; 0x108 + StormGetFileSize @265 ; 0x109 + StormOpenArchive @266 ; 0x10A + StormOpenFile @267 ; 0x10B + StormOpenFileEx @268 ; 0x10C + StormReadFile @269 ; 0x10D + StormSetBasePath @270 ; 0x10E + StormSetFilePointer @271 ; 0x10F + StormSetLocale @272 ; 0x110 + StormGetBasePath @273 ; 0x111 + StormGetArchiveName @275 ; 0x113 + StormGetFileName @276 ; 0x114 + +; StormSetLastError @465 ; 0x + + StormCompress @551 ; 0x227 + StormDecompress @552 ; 0x228 diff --git a/dep/StormLib/storm_dll/storm_dll.h b/dep/StormLib/storm_dll/storm_dll.h new file mode 100644 index 000000000..6d67820a2 --- /dev/null +++ b/dep/StormLib/storm_dll/storm_dll.h @@ -0,0 +1,67 @@ +/*****************************************************************************/ +/* Storm.h Copyright Justin Olbrantz(Quantam) 2000 */ +/*---------------------------------------------------------------------------*/ +/* Storm Interface Library v1.0 for Windows */ +/* */ +/* Author : Justin Olbrantz(Quantam) */ +/* E-mail : omega@dragonfire.net */ +/* WWW : www.campaigncreations.com/starcraft/mpq2k/inside_mopaq/ */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* xx.xx.00 1.00 Qua The first version of Storm.h */ +/* 11.04.03 1.00 Lad Added some functions */ +/*****************************************************************************/ + +// We need the Windows data types for the Storm prototypes +#include + +#ifndef __STORM_H__ +#define __STORM_H__ + +// Somethimes is necessary to change the function names so they +// will not conflict with other MPQ tools. +#ifdef STORM_ALTERNATE_NAMES + #define SFILE(Name) Storm##Name + #define SCOMP(Name) Storm##Name +#else + #define SFILE(Name) SFile##Name + #define SCOMP(Name) SComp##Name +#endif + + +// Just in case anyone is still using C out there +#ifdef __cplusplus +extern "C" { +#endif + +// Storm file function prototypes +BOOL WINAPI SFILE(OpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ); +BOOL WINAPI SFILE(CloseArchive)(HANDLE hMPQ); +BOOL WINAPI SFILE(GetArchiveName)(HANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength); +BOOL WINAPI SFILE(OpenFile)(LPCSTR lpFileName, HANDLE *hFile); +BOOL WINAPI SFILE(OpenFileEx)(HANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, HANDLE *hFile); +BOOL WINAPI SFILE(CloseFile)(HANDLE hFile); +DWORD WINAPI SFILE(GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh); +BOOL WINAPI SFILE(GetFileArchive)(HANDLE hFile, HANDLE *hMPQ); +BOOL WINAPI SFILE(GetFileName)(HANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength); +DWORD WINAPI SFILE(SetFilePointer)(HANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod); +BOOL WINAPI SFILE(ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped); +LCID WINAPI SFILE(SetLocale)(LCID nNewLocale); +BOOL WINAPI SFILE(GetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength); +BOOL WINAPI SFILE(SetBasePath)(LPCSTR lpNewBasePath); + +// Storm (de)compression functions +BOOL WINAPI SCOMP(Compress) (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCmp, int uCmpType, int nCmpLevel); +BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); + + +#if defined(_MSC_VER) && !defined(BUILDING_STORM_CPP) +#pragma comment(lib, "Storm.lib") // Force linking Storm.lib and thus Storm.dll +#endif + +#ifdef __cplusplus +} +#endif + +#endif // __STORM_H__ diff --git a/dep/StormLib/stormlib_dll/DllMain.c b/dep/StormLib/stormlib_dll/DllMain.c new file mode 100644 index 000000000..d5ef37fc1 --- /dev/null +++ b/dep/StormLib/stormlib_dll/DllMain.c @@ -0,0 +1,24 @@ +/*****************************************************************************/ +/* DllMain.c Copyright (c) Ladislav Zezula 2006 */ +/*---------------------------------------------------------------------------*/ +/* Description: DllMain for the StormLib.dll library */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 23.11.06 1.00 Lad The first version of DllMain.c */ +/*****************************************************************************/ + +#define WIN32_LEAN_AND_MEAN +#include + +//----------------------------------------------------------------------------- +// DllMain + +DWORD WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(dwReason); + UNREFERENCED_PARAMETER(lpReserved); + + return TRUE; +} diff --git a/dep/StormLib/stormlib_dll/StormLib.def b/dep/StormLib/stormlib_dll/StormLib.def new file mode 100644 index 000000000..61da13dc0 --- /dev/null +++ b/dep/StormLib/stormlib_dll/StormLib.def @@ -0,0 +1,76 @@ +; +; Export file for Windows +; Copyright (c) 2007-2010 Ladislav Zezula +; ladik@zezula.net +; + +LIBRARY StormLib.dll + +EXPORTS + + SFileSetLocale + SFileGetLocale + + SFileOpenArchive + SFileCreateArchive + SFileGetArchiveBitmap + SFileFlushArchive + SFileCloseArchive + + SFileAddListFile + + SFileSetCompactCallback + SFileCompactArchive + + SFileGetMaxFileCount + SFileSetMaxFileCount + + SFileGetAttributes + SFileSetAttributes + SFileUpdateFileAttributes + + SFileOpenPatchArchive + SFileIsPatchedArchive + + SFileOpenFileEx + SFileGetFileSize + SFileSetFilePointer + SFileReadFile + SFileCloseFile + + SFileHasFile + SFileGetFileName + SFileGetFileInfo + + SFileExtractFile + + SFileVerifyFile + SFileVerifyRawData + SFileVerifyArchive + + SFileFindFirstFile + SFileFindNextFile + SFileFindClose + + SListFileFindFirstFile + SListFileFindNextFile + SListFileFindClose + + SFileEnumLocales + + SFileCreateFile + SFileWriteFile + SFileFinishFile + SFileAddFileEx + SFileAddFile + SFileAddWave + SFileRemoveFile + SFileRenameFile + SFileSetFileLocale + SFileSetDataCompression + SFileSetAddFileCallback + + SCompImplode + SCompExplode + SCompCompress + SCompDecompress diff --git a/dep/StormLib/stormlib_dll/StormLib.exp b/dep/StormLib/stormlib_dll/StormLib.exp new file mode 100644 index 000000000..eea00023a --- /dev/null +++ b/dep/StormLib/stormlib_dll/StormLib.exp @@ -0,0 +1,75 @@ +# +# Export file for Mac OS X +# Copyright (c) 2009 Sam Wilkins +# swilkins1337@gmail.com +# + +_SFileSetLocale +_SFileGetLocale + +_SFileOpenArchive +_SFileCreateArchive +_SFileGetArchiveBitmap +_SFileFlushArchive +_SFileCloseArchive + +_SFileAddListFile + +_SFileSetCompactCallback +_SFileCompactArchive + +_SFileGetMaxFileCount +_SFileSetMaxFileCount + +_SFileGetAttributes +_SFileSetAttributes +_SFileUpdateFileAttributes + +_SFileOpenPatchArchive +_SFileIsPatchedArchive + +_SFileOpenFileEx +_SFileGetFileSize +_SFileSetFilePointer +_SFileReadFile +_SFileCloseFile + +_SFileHasFile +_SFileGetFileName +_SFileGetFileInfo + +_SFileExtractFile + +_SFileVerifyFile +_SFileVerifyRawData +_SFileVerifyArchive + +_SFileFindFirstFile +_SFileFindNextFile +_SFileFindClose + +_SListFileFindFirstFile +_SListFileFindNextFile +_SListFileFindClose + +_SFileEnumLocales + +_SFileCreateFile +_SFileWriteFile +_SFileFinishFile +_SFileAddFileEx +_SFileAddFile +_SFileAddWave +_SFileRemoveFile +_SFileRenameFile +_SFileSetFileLocale +_SFileSetDataCompression +_SFileSetAddFileCallback + +_SCompImplode +_SCompExplode +_SCompCompress +_SCompDecompress + +_SetLastError +_GetLastError diff --git a/dep/StormLib/test/Test.cpp b/dep/StormLib/test/Test.cpp new file mode 100644 index 000000000..353ab7337 --- /dev/null +++ b/dep/StormLib/test/Test.cpp @@ -0,0 +1,1899 @@ +/*****************************************************************************/ +/* StormLibTest.cpp Copyright (c) Ladislav Zezula 2003 */ +/*---------------------------------------------------------------------------*/ +/* Test module for StormLib */ +/*---------------------------------------------------------------------------*/ +/* Date Ver Who Comment */ +/* -------- ---- --- ------- */ +/* 25.03.03 1.00 Lad The first version of StormLibTest.cpp */ +/*****************************************************************************/ + +#define _CRT_SECURE_NO_DEPRECATE +#define __INCLUDE_CRYPTOGRAPHY__ +#define __STORMLIB_SELF__ // Don't use StormLib.lib +#include + +#ifdef _MSC_VER +#include +#endif + +#include "../src/StormLib.h" +#include "../src/StormCommon.h" + +#ifdef _MSC_VER +#pragma warning(disable: 4505) // 'XXX' : unreferenced local function has been removed +#endif + +//------------------------------------------------------------------------------ +// Defines + +#ifdef PLATFORM_WINDOWS +#define WORK_PATH_ROOT "C:\\Multimedia\\MPQs\\" +#endif + +#ifdef PLATFORM_LINUX +#define WORK_PATH_ROOT "/home/user/MPQs/" +#endif + +#ifdef PLATFORM_MAC +#define WORK_PATH_ROOT "/Users/sam/StormLib/test" +#endif + +#ifndef LANG_CZECH +#define LANG_CZECH 0x0405 +#endif + +#define MPQ_SECTOR_SIZE 0x1000 + +#define MAKE_PATH(path) _T(WORK_PATH_ROOT) _T(path) + +// Unicode MPQ names +/* Czech */ static const wchar_t szUnicodeName1[] = {0x010C, 0x0065, 0x0073, 0x006B, 0x00FD, _T('.'), _T('m'), _T('p'), _T('q'), 0}; +/* Russian */ static const wchar_t szUnicodeName2[] = {0x0420, 0x0443, 0x0441, 0x0441, 0x043A, 0x0438, 0x0439, _T('.'), _T('m'), _T('p'), _T('q'), 0}; +/* Greece */ static const wchar_t szUnicodeName3[] = {0x03B5, 0x03BB, 0x03BB, 0x03B7, 0x03BD, 0x03B9, 0x03BA, 0x03AC, _T('.'), _T('m'), _T('p'), _T('q'), 0}; +/* Chinese */ static const wchar_t szUnicodeName4[] = {0x65E5, 0x672C, 0x8A9E, _T('.'), _T('m'), _T('p'), _T('q'), 0}; +/* Japanese */ static const wchar_t szUnicodeName5[] = {0x7B80, 0x4F53, 0x4E2D, 0x6587, _T('.'), _T('m'), _T('p'), _T('q'), 0}; +/* Arabic */ static const wchar_t szUnicodeName6[] = {0x0627, 0x0644, 0x0639, 0x0639, 0x0631, 0x0628, 0x064A, 0x0629, _T('.'), _T('m'), _T('p'), _T('q'), 0}; + +//----------------------------------------------------------------------------- +// Constants + +static const TCHAR * szWorkDir = MAKE_PATH("Work"); + +static unsigned int AddFlags[] = +{ +// Compression Encryption Fixed key Single Unit Sector CRC + 0 | 0 | 0 | 0 | 0, + 0 | MPQ_FILE_ENCRYPTED | 0 | 0 | 0, + 0 | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | 0 | 0, + 0 | 0 | 0 | MPQ_FILE_SINGLE_UNIT | 0, + 0 | MPQ_FILE_ENCRYPTED | 0 | MPQ_FILE_SINGLE_UNIT | 0, + 0 | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | MPQ_FILE_SINGLE_UNIT | 0, + MPQ_FILE_IMPLODE | 0 | 0 | 0 | 0, + MPQ_FILE_IMPLODE | MPQ_FILE_ENCRYPTED | 0 | 0 | 0, + MPQ_FILE_IMPLODE | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | 0 | 0, + MPQ_FILE_IMPLODE | 0 | 0 | MPQ_FILE_SINGLE_UNIT | 0, + MPQ_FILE_IMPLODE | MPQ_FILE_ENCRYPTED | 0 | MPQ_FILE_SINGLE_UNIT | 0, + MPQ_FILE_IMPLODE | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | MPQ_FILE_SINGLE_UNIT | 0, + MPQ_FILE_IMPLODE | 0 | 0 | 0 | MPQ_FILE_SECTOR_CRC, + MPQ_FILE_IMPLODE | MPQ_FILE_ENCRYPTED | 0 | 0 | MPQ_FILE_SECTOR_CRC, + MPQ_FILE_IMPLODE | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | 0 | MPQ_FILE_SECTOR_CRC, + MPQ_FILE_COMPRESS | 0 | 0 | 0 | 0, + MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | 0 | 0 | 0, + MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | 0 | 0, + MPQ_FILE_COMPRESS | 0 | 0 | MPQ_FILE_SINGLE_UNIT | 0, + MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | 0 | MPQ_FILE_SINGLE_UNIT | 0, + MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | MPQ_FILE_SINGLE_UNIT | 0, + MPQ_FILE_COMPRESS | 0 | 0 | 0 | MPQ_FILE_SECTOR_CRC, + MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | 0 | 0 | MPQ_FILE_SECTOR_CRC, + MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY | 0 | MPQ_FILE_SECTOR_CRC, + 0xFFFFFFFF +}; + +//----------------------------------------------------------------------------- +// Local testing functions + +static void clreol() +{ +#ifdef PLATFORM_WINDOWS + CONSOLE_SCREEN_BUFFER_INFO ScreenInfo; + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + LPTSTR szConsoleLine; + int nConsoleChars; + int i = 0; + + GetConsoleScreenBufferInfo(hConsole, &ScreenInfo); + nConsoleChars = (ScreenInfo.srWindow.Right - ScreenInfo.srWindow.Left); + if(nConsoleChars > 0) + { + szConsoleLine = new TCHAR[nConsoleChars + 3]; + if(szConsoleLine != NULL) + { + szConsoleLine[i++] = '\r'; + for(; i < nConsoleChars; i++) + szConsoleLine[i] = ' '; + szConsoleLine[i++] = '\r'; + szConsoleLine[i] = 0; + + _tprintf(szConsoleLine); + delete [] szConsoleLine; + } + } +#endif // PLATFORM_WINDOWS +} + +static void PrintfTA(const TCHAR * szFormat, const TCHAR * szStrT, const char * szStrA, int lcLocale = 0) +{ + TCHAR * szTemp; + TCHAR szBuffer[MAX_PATH]; + + // Convert ANSI string to TCHAR + for(szTemp = szBuffer; *szStrA != 0; szTemp++, szStrA++) + szTemp[0] = szStrA[0]; + szTemp[0] = 0; + + _tprintf(szFormat, szStrT, szBuffer, lcLocale); +} + +static void MergeLocalPath(TCHAR * szBuffer, const TCHAR * szPart1, const char * szPart2) +{ + // Copy directory name + while(*szPart1 != 0) + *szBuffer++ = *szPart1++; + + // Add separator + *szBuffer++ = _T('/'); + + // Copy file name + while(*szPart2 != 0) + *szBuffer++ = *szPart2++; + + // Terminate the string + *szBuffer = 0; +} + +int GetFirstDiffer(void * ptr1, void * ptr2, int nSize) +{ + char * buff1 = (char *)ptr1; + char * buff2 = (char *)ptr2; + int nDiffer; + + for(nDiffer = 0; nDiffer < nSize; nDiffer++) + { + if(*buff1++ != *buff2++) + return nDiffer; + } + return -1; +} + +static void WINAPI CompactCB(void * /* lpParam */, DWORD dwWork, ULONGLONG BytesDone, ULONGLONG TotalBytes) +{ + clreol(); + + _tprintf(_T("%u of %u "), (DWORD)BytesDone, (DWORD)TotalBytes); + switch(dwWork) + { + case CCB_CHECKING_FILES: + _tprintf(_T("Checking files in archive ...\r")); + break; + + case CCB_CHECKING_HASH_TABLE: + _tprintf(_T("Checking hash table ...\r")); + break; + + case CCB_COPYING_NON_MPQ_DATA: + _tprintf(_T("Copying non-MPQ data ...\r")); + break; + + case CCB_COMPACTING_FILES: + _tprintf(_T("Compacting archive ...\r")); + break; + + case CCB_CLOSING_ARCHIVE: + _tprintf(_T("Closing archive ...\r")); + break; + } +} + +static void GenerateRandomDataBlock(LPBYTE pbBuffer, DWORD cbBuffer) +{ + LPBYTE pbBufferEnd = pbBuffer + cbBuffer; + LPBYTE pbPtr = pbBuffer; + DWORD cbBytesToPut = 0; + BYTE ByteToPut = 0; + bool bRandomData = false; + + while(pbPtr < pbBufferEnd) + { + // If there are no bytes to put, we will generate new byte and length + if(cbBytesToPut == 0) + { + bRandomData = false; + switch(rand() % 10) + { + case 0: // A short sequence of zeros + cbBytesToPut = rand() % 0x08; + ByteToPut = 0; + break; + + case 1: // A long sequence of zeros + cbBytesToPut = rand() % 0x80; + ByteToPut = 0; + break; + + case 2: // A short sequence of non-zeros + cbBytesToPut = rand() % 0x08; + ByteToPut = (BYTE)(rand() % 0x100); + break; + + case 3: // A long sequence of non-zeros + cbBytesToPut = rand() % 0x80; + ByteToPut = (BYTE)(rand() % 0x100); + break; + + case 4: // A short random data + cbBytesToPut = rand() % 0x08; + bRandomData = true; + break; + + case 5: // A long random data + cbBytesToPut = rand() % 0x80; + bRandomData = true; + break; + + default: // A single random byte + cbBytesToPut = 1; + ByteToPut = (BYTE)(rand() % 0x100); + break; + } + } + + // Generate random byte, if needed + if(bRandomData) + ByteToPut = (BYTE)(rand() % 0x100); + + // Put next byte to the output buffer + *pbPtr++ = ByteToPut; + cbBytesToPut--; + } +} + +static bool CompareArchivedFiles(const char * szFileName, HANDLE hFile1, HANDLE hFile2, DWORD dwBlockSize) +{ + LPBYTE pbBuffer1 = NULL; + LPBYTE pbBuffer2 = NULL; + DWORD dwRead1; // Number of bytes read (Storm.dll) + DWORD dwRead2; // Number of bytes read (StormLib) + bool bResult1 = false; // Result from Storm.dll + bool bResult2 = false; // Result from StormLib + bool bResult = true; + int nDiff; + + szFileName = szFileName; + + // Allocate buffers + pbBuffer1 = new BYTE[dwBlockSize]; + pbBuffer2 = new BYTE[dwBlockSize]; + + for(;;) + { + // Read the file's content by both methods and compare the result + memset(pbBuffer1, 0, dwBlockSize); + memset(pbBuffer2, 0, dwBlockSize); + bResult1 = SFileReadFile(hFile1, pbBuffer1, dwBlockSize, &dwRead1, NULL); + bResult2 = SFileReadFile(hFile2, pbBuffer2, dwBlockSize, &dwRead2, NULL); + if(bResult1 != bResult2) + { + _tprintf(_T("Different results from SFileReadFile, Mpq1 %u, Mpq2 %u\n"), bResult1, bResult2); + bResult = false; + break; + } + + // Test the number of bytes read + if(dwRead1 != dwRead2) + { + _tprintf(_T("Different bytes read from SFileReadFile, Mpq1 %u, Mpq2 %u\n"), dwRead1, dwRead2); + bResult = false; + break; + } + + // No more bytes ==> OK + if(dwRead1 == 0) + break; + + // Test the content + if((nDiff = GetFirstDiffer(pbBuffer1, pbBuffer2, dwRead1)) != -1) + { + bResult = false; + break; + } + } + + delete [] pbBuffer2; + delete [] pbBuffer1; + return bResult; +} + +// Random read version +static bool CompareArchivedFilesRR(const char * /* szFileName */, HANDLE hFile1, HANDLE hFile2, DWORD dwBlockSize) +{ + const char * szPositions[3] = {"FILE_BEGIN ", "FILE_CURRENT", "FILE_END "}; + LPBYTE pbBuffer1 = NULL; + LPBYTE pbBuffer2 = NULL; + DWORD dwFileSize1; // File size (Storm.dll) + DWORD dwFileSize2; // File size (StormLib) + DWORD dwRead1; // Number of bytes read (Storm.dll) + DWORD dwRead2; // Number of bytes read (StormLib) + bool bResult1 = false; // Result from Storm.dll + bool bResult2 = false; // Result from StormLib + int nError = ERROR_SUCCESS; + + // Test the file size + dwFileSize1 = SFileGetFileSize(hFile1, NULL); + dwFileSize2 = SFileGetFileSize(hFile2, NULL); + if(dwFileSize1 != dwFileSize2) + { + _tprintf(_T("Different size from SFileGetFileSize (file1: %u, file2: %u)\n"), dwFileSize1, dwFileSize2); + return false; + } + + if(dwFileSize1 != 0) + { + for(int i = 0; i < 10000; i++) + { + DWORD dwRandom = rand() * rand(); + DWORD dwMoveMethod = dwRandom % 3; + DWORD dwPosition = dwRandom % dwFileSize1; + DWORD dwToRead = dwRandom % dwBlockSize; + + // Also test negative seek + if(rand() & 1) + { + int nPosition = (int)dwPosition; + dwPosition = (DWORD)(-nPosition); + } + + // Allocate buffers + pbBuffer1 = new BYTE[dwToRead]; + pbBuffer2 = new BYTE[dwToRead]; + + // Set the file pointer + _tprintf(_T("RndRead (%u): pos %8i from %s, size %u ...\r"), i, dwPosition, szPositions[dwMoveMethod], dwToRead); + dwRead1 = SFileSetFilePointer(hFile1, dwPosition, NULL, dwMoveMethod); + dwRead2 = SFileSetFilePointer(hFile2, dwPosition, NULL, dwMoveMethod); + if(dwRead1 != dwRead2) + { + _tprintf(_T("Difference returned by SFileSetFilePointer (file1: %u, file2: %u)\n"), dwRead1, dwRead2); + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + + // Read the file's content by both methods and compare the result + bResult1 = SFileReadFile(hFile1, pbBuffer1, dwToRead, &dwRead1, NULL); + bResult2 = SFileReadFile(hFile2, pbBuffer2, dwToRead, &dwRead2, NULL); + if(bResult1 != bResult2) + { + _tprintf(_T("Different results from SFileReadFile (file1: %u, file2: %u)\n\n"), bResult1, bResult2); + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + + // Test the number of bytes read + if(dwRead1 != dwRead2) + { + _tprintf(_T("Different bytes read from SFileReadFile (file1: %u, file2: %u)\n\n"), dwRead1, dwRead2); + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + + // Test the content + if(dwRead1 != 0 && memcmp(pbBuffer1, pbBuffer2, dwRead1)) + { + _tprintf(_T("Different data content from SFileReadFile\n")); + nError = ERROR_CAN_NOT_COMPLETE; + break; + } + + delete [] pbBuffer2; + delete [] pbBuffer1; + } + } + clreol(); + return (nError == ERROR_SUCCESS) ? true : false; +} + +//----------------------------------------------------------------------------- +// Opening local file + +static int TestOpenLocalFile(const char * szFileName) +{ + HANDLE hFile; + char szRetrievedName[MAX_PATH]; + + if(SFileOpenFileEx(NULL, szFileName, SFILE_OPEN_LOCAL_FILE, &hFile)) + { + SFileGetFileName(hFile, szRetrievedName); + SFileCloseFile(hFile); + } + + return ERROR_SUCCESS; +} + +//----------------------------------------------------------------------------- +// Partial file reading + +static int TestPartFileRead(const TCHAR * szFileName) +{ + ULONGLONG ByteOffset; + ULONGLONG FileSize = 0; + TFileStream * pStream; + BYTE BigBuffer[0x7000]; + BYTE Buffer[0x100]; + int nError = ERROR_SUCCESS; + + // Open the partial file + pStream = FileStream_OpenFile(szFileName, false); + if(pStream == NULL) + nError = GetLastError(); + + // Get the size of the stream + if(nError == ERROR_SUCCESS) + { + if(!FileStream_GetSize(pStream, &FileSize)) + nError = GetLastError(); + } + + // Read the last 0x7000 bytes + if(nError == ERROR_SUCCESS) + { + ByteOffset = FileSize - sizeof(BigBuffer); + if(!FileStream_Read(pStream, &ByteOffset, BigBuffer, sizeof(BigBuffer))) + nError = GetLastError(); + } + + // Read the last 0x100 bytes + if(nError == ERROR_SUCCESS) + { + ByteOffset = FileSize - sizeof(Buffer); + if(!FileStream_Read(pStream, &ByteOffset, Buffer, sizeof(Buffer))) + nError = GetLastError(); + } + + // Read 0x100 bytes from position (FileSize - 0xFF) + if(nError == ERROR_SUCCESS) + { + ByteOffset = FileSize - sizeof(Buffer) + 1; + if(!FileStream_Read(pStream, &ByteOffset, Buffer, sizeof(Buffer))) + nError = GetLastError(); + } + + FileStream_Close(pStream); + return nError; +} + +//----------------------------------------------------------------------------- +// Compare PKLIB decompression + +BYTE pbCompressed1[] = {0x00, 0x04, 0x00, 0x00, 0x04, 0xF0, 0x1F, 0x7B, 0x01, 0xFF}; +BYTE pbCompressed2[] = {0x00, 0x04, 0x00, 0x00, 0x04, 0xF0, 0x1F, 0x00, 0x00, 0x04, 0xFC, 0x03}; + +static int ComparePklibCompressions() +{ + char Decompressed[0x1000]; + char Compressed[0x1000]; + int cbDecompressed = 0x208; + int cbCompressed = sizeof(Compressed); + + memset(Decompressed, 0, cbDecompressed); + SCompImplode(Compressed, &cbCompressed, Decompressed, cbDecompressed); + + cbDecompressed = sizeof(Decompressed); + SCompExplode(Decompressed, &cbDecompressed, Compressed, cbCompressed); + + + return ERROR_SUCCESS; +} + +//----------------------------------------------------------------------------- +// Compare LZMA decompression + +#ifdef PLATFORM_WINDOWS +typedef void * (*ALLOC_MEMORY)(size_t); +typedef void (*FREE_MEMORY)(void *); +typedef int (GIVE_DATA)(void *); + +extern "C" int starcraft_decompress_lzma(char * pbInBuffer, int cbInBuffer, char * pbOutBuffer, int cbOutBuffer, int * pcbOutBuffer, ALLOC_MEMORY pfnAllocMemory, FREE_MEMORY pfnFreeMemory); +extern "C" int starcraft_compress_lzma(char * pbInBuffer, int cbInBuffer, int dummy1, char * pbOutBuffer, int cbOutBuffer, int dummy2, int * pcbOutBuffer, ALLOC_MEMORY pfnAllocMemory, FREE_MEMORY pfnFreeMemory, GIVE_DATA pfnGiveData); +void Compress_LZMA(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer, int *, int); +int Decompress_LZMA(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer); + +extern "C" void * operator_new(size_t sz) +{ + return malloc(sz); +} + +void * Memory_Allocate(size_t byte_size) +{ + return malloc(byte_size); +} + +void Memory_Free(void * address) +{ + if(address != NULL) + free(address); +} + +int GiveData(void *) +{ + return 0; +} + +static int StarcraftCompress_LZMA(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) +{ + return starcraft_compress_lzma(pbInBuffer, + cbInBuffer, + 0, + pbOutBuffer, + *pcbOutBuffer, + 0, + pcbOutBuffer, + Memory_Allocate, + Memory_Free, + GiveData); +} + +static int StarcraftDecompress_LZMA(char * pbOutBuffer, int * pcbOutBuffer, char * pbInBuffer, int cbInBuffer) +{ + return starcraft_decompress_lzma(pbInBuffer, + cbInBuffer, + pbOutBuffer, + *pcbOutBuffer, + pcbOutBuffer, + Memory_Allocate, + Memory_Free); +} + +static int CompareLzmaCompressions(int nSectorSize) +{ + LPBYTE pbCompressed1 = NULL; // Compressed by our code + LPBYTE pbCompressed2 = NULL; // Compressed by Blizzard's code + LPBYTE pbDecompressed1 = NULL; // Decompressed by our code + LPBYTE pbDecompressed2 = NULL; // Decompressed by Blizzard's code + LPBYTE pbOriginalData = NULL; + int nError = ERROR_SUCCESS; + + // Allocate buffers + // Must allocate twice blocks due to probable bug in Storm.dll. + // Storm.dll corrupts stack when uncompresses data with PKWARE DCL + // and no compression occurs. + pbDecompressed1 = new BYTE [nSectorSize]; + pbDecompressed2 = new BYTE [nSectorSize]; + pbCompressed1 = new BYTE [nSectorSize]; + pbCompressed2 = new BYTE [nSectorSize]; + pbOriginalData = new BYTE[nSectorSize]; + if(!pbDecompressed1 || !pbDecompressed2 || !pbCompressed1 || !pbCompressed2 || !pbOriginalData) + nError = ERROR_NOT_ENOUGH_MEMORY; + + if(nError == ERROR_SUCCESS) + { + for(int i = 0; i < 100000; i++) + { + int nDcmpLength1; + int nDcmpLength2; + int nCmpLength1; + int nCmpLength2; + int nDiff; + + clreol(); + _tprintf(_T("Testing compression of sector %u\r"), i + 1); + + // Generate random data sector + GenerateRandomDataBlock(pbOriginalData, nSectorSize); + + // Compress the sector by both methods + nCmpLength1 = nCmpLength2 = nSectorSize; +// Compress_LZMA((char *)pbCompressed1, &nCmpLength1, (char *)pbOriginalData, nSectorSize, 0, 0); + StarcraftCompress_LZMA((char *)pbCompressed1, &nCmpLength2, (char *)pbOriginalData, nSectorSize); + +__TryToDecompress: + + // Only test decompression when the compression actually succeeded + if(nCmpLength1 < nSectorSize) + { + // Decompress both data + nDcmpLength2 = nDcmpLength1 = nSectorSize; +// Decompress_LZMA((char *)pbDecompressed1, &nDcmpLength1, (char *)pbCompressed1, nCmpLength1); + StarcraftDecompress_LZMA((char *)pbDecompressed2, &nDcmpLength2, (char *)pbCompressed1, nCmpLength1); + + // Compare the length of the output data + if(nDcmpLength1 != nDcmpLength2) + { + _tprintf(_T("Difference in compressed blocks lengths (%u vs %u)\n"), nDcmpLength1, nDcmpLength2); + goto __TryToDecompress; + } + + // Compare the output + if((nDiff = GetFirstDiffer(pbDecompressed1, pbDecompressed2, nDcmpLength1)) != -1) + { + _tprintf(_T("Difference in decompressed blocks (offset 0x%08X)\n"), nDiff); + goto __TryToDecompress; + } + + // Check for data overflow + if(pbDecompressed1[nSectorSize] != 0xFD || pbDecompressed1[nSectorSize] != 0xFD) + { + _tprintf(_T("Damage after decompressed sector !!!\n")); + goto __TryToDecompress; + } + + // Compare the decompressed data against original data + if((nDiff = GetFirstDiffer(pbDecompressed1, pbOriginalData, nDcmpLength1)) != -1) + { + _tprintf(_T("Difference between original data and decompressed data (offset 0x%08X)\n"), nDiff); + goto __TryToDecompress; + } + } + } + } + + // Cleanup + if(pbOriginalData != NULL) + delete [] pbOriginalData; + if(pbCompressed2 != NULL) + delete [] pbCompressed2; + if(pbCompressed1 != NULL) + delete [] pbCompressed1; + if(pbDecompressed2 != NULL) + delete [] pbDecompressed2; + if(pbDecompressed1 != NULL) + delete [] pbDecompressed1; + clreol(); + return nError; +} +#endif // PLATFORM_WINDOWS + +//----------------------------------------------------------------------------- +// Compression method test + +static int TestSectorCompress(int nSectorSize) +{ + LPBYTE pbDecompressed = NULL; + LPBYTE pbCompressed = NULL; + LPBYTE pbOriginal = NULL; + int nError = ERROR_SUCCESS; + + // Allocate buffers + pbDecompressed = new BYTE[nSectorSize]; + pbCompressed = new BYTE[nSectorSize]; + pbOriginal = new BYTE[nSectorSize]; + if(!pbDecompressed || !pbCompressed || !pbOriginal) + nError = ERROR_NOT_ENOUGH_MEMORY; + + if(nError == ERROR_SUCCESS) + { + for(int i = 0; i < 100000; i++) + { + int nOriginalLength = nSectorSize % (rand() + 1); + int nCompressedLength; + int nDecompressedLength; + int nCmp = MPQ_COMPRESSION_SPARSE | MPQ_COMPRESSION_ZLIB | MPQ_COMPRESSION_BZIP2 | MPQ_COMPRESSION_PKWARE; + int nDiff; + + clreol(); + _tprintf(_T("Testing compression of sector %u\r"), i + 1); + + // Generate random data sector + GenerateRandomDataBlock(pbOriginal, nOriginalLength); + if(nOriginalLength == 0x123) + nOriginalLength = 0; + +__TryAgain: + + // Compress the sector + nCompressedLength = nOriginalLength; + SCompCompress((char *)pbCompressed, &nCompressedLength, (char *)pbOriginal, nOriginalLength, nCmp, 0, -1); +// SCompImplode((char *)pbCompressed, &nCompressedLength, (char *)pbOriginal, nOriginalLength); + + // When the method was unable to compress data, + // the compressed data must be identical to original data + if(nCompressedLength == nOriginalLength) + { + if((nDiff = GetFirstDiffer(pbCompressed, pbOriginal, nOriginalLength)) != -1) + { + _tprintf(_T("Compression error: Fail when unable to compress the data (Offset 0x%08X).\n"), nDiff); + goto __TryAgain; + } + } + + // Uncompress the sector + nDecompressedLength = nOriginalLength; + SCompDecompress((char *)pbDecompressed, &nDecompressedLength, (char *)pbCompressed, nCompressedLength); +// SCompExplode((char *)pbDecompressed, &nDecompressedLength, (char *)pbCompressed, nCompressedLength); + + // Check the decompressed length against original length + if(nDecompressedLength != nOriginalLength) + { + _tprintf(_T("Length of uncompressed data does not agree with original data length !!!\n")); + goto __TryAgain; + } + + // Check decompressed block against original block + if((nDiff = GetFirstDiffer(pbDecompressed, pbOriginal, nOriginalLength)) != -1) + { + _tprintf(_T("Decompressed sector does not agree with the original data !!! (Offset 0x%08X)\n"), nDiff); + goto __TryAgain; + } + } + } + + // Cleanup + delete [] pbOriginal; + delete [] pbCompressed; + delete [] pbDecompressed; + clreol(); + return nError; +} + +static int TestArchiveOpenAndClose(const TCHAR * szMpqName) +{ + const char * szFileName1 = "StringList\\Powers.stl"; +// const char * szFileName2 = "items\\map\\mapz_deleted.cel"; + TMPQArchive * ha = NULL; + HANDLE hFile1 = NULL; +// HANDLE hFile2 = NULL; + HANDLE hMpq = NULL; + int nError = ERROR_SUCCESS; + + if(nError == ERROR_SUCCESS) + { + _tprintf(_T("Opening archive %s ...\n"), szMpqName); + if(!SFileOpenArchive(szMpqName, 0, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE, &hMpq)) + nError = GetLastError(); + ha = (TMPQArchive *)hMpq; + } + + if(nError == ERROR_SUCCESS) + { + SFileAddListFile(hMpq, "c:\\Tools32\\Listfiles\\ListFile.txt"); + } + +/* + // Test for TBitArray + if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) + { + TBitArray * pBitArray = ha->pHetTable->pBetIndexes; + + for(ULONG i = 0; i < 0x10000; i++) + { + BYTE LoadedBits[0x20]; + BYTE SaveBits[0x40]; + unsigned int nBitPosition = (i >> 0x08); + unsigned int nBitCount = (i & 0xFF); + + memset(LoadedBits, 0, sizeof(LoadedBits)); + memcpy(SaveBits, pBitArray->Elements, sizeof(SaveBits)); + + // Load the index to the BET table + GetBits(pBitArray, nBitPosition, nBitCount, LoadedBits, sizeof(LoadedBits)); + + // Load the index to the BET table + SetBits(pBitArray, nBitPosition, nBitCount, LoadedBits, sizeof(LoadedBits)); + + // Verify the bits + if(memcmp(SaveBits, pBitArray->Elements, sizeof(SaveBits))) + assert(false); + } + } +*/ + // Verify the raw data in the archive + if(nError == ERROR_SUCCESS) + { + // Verify the archive + SFileVerifyRawData(hMpq, SFILE_VERIFY_FILE, szFileName1); + + // Try to open a file + if(!SFileOpenFileEx(hMpq, szFileName1, SFILE_OPEN_FROM_MPQ, &hFile1)) + { + nError = GetLastError(); + printf("%s - file not found in the MPQ\n", szFileName1); + } + } + + // Dummy read from the file + if(nError == ERROR_SUCCESS) + { + DWORD dwBytesRead = 0; + BYTE Buffer[0x1000]; + + SFileSetFileLocale(hFile1, 0x405); + SFileReadFile(hFile1, Buffer, sizeof(Buffer), &dwBytesRead, NULL); + } +/* + // Verify the MPQ listfile + if(nError == ERROR_SUCCESS) + { + SFileVerifyFile(hMpq, szFileName1, 0xFFFFFFFF); + if(!CompareArchivedFilesRR(szFileName1, hFile1, hFile2, 0x100000)) + nError = ERROR_CAN_NOT_COMPLETE; + } +*/ + if(hFile1 != NULL) + SFileCloseFile(hFile1); + if(hMpq != NULL) + SFileCloseArchive(hMpq); + return nError; +} + +static int TestFindFiles(const TCHAR * szMpqName) +{ + TMPQFile * hf; + HANDLE hFile; + HANDLE hMpq = NULL; + BYTE Buffer[100]; + int nError = ERROR_SUCCESS; + int nFiles = 0; + int nFound = 0; + + // Open the archive + if(nError == ERROR_SUCCESS) + { + _tprintf(_T("Opening \"%s\" for finding files ...\n"), szMpqName); + if(!SFileOpenArchive(szMpqName, 0, 0, &hMpq)) + nError = GetLastError(); + } + + // Compact the archive + if(nError == ERROR_SUCCESS) + { + SFILE_FIND_DATA sf; + HANDLE hFind; + DWORD dwExtraDataSize; + bool bFound = true; + + hFind = SFileFindFirstFile(hMpq, "*", &sf, "c:\\Tools32\\ListFiles\\ListFile.txt"); + while(hFind != NULL && bFound != false) + { + if(SFileOpenFileEx(hMpq, sf.cFileName, 0, &hFile)) + { + hf = (TMPQFile *)hFile; + SFileReadFile(hFile, Buffer, sizeof(Buffer), NULL, NULL); + nFiles++; + + if(sf.dwFileFlags & MPQ_FILE_SECTOR_CRC) + { + dwExtraDataSize = hf->SectorOffsets[hf->dwSectorCount + 1] - hf->SectorOffsets[hf->dwSectorCount]; + if(dwExtraDataSize != 0) + nFound++; + } + + SFileCloseFile(hFile); + } + + bFound = SFileFindNextFile(hFind, &sf); + } + } + + if(hMpq != NULL) + SFileCloseArchive(hMpq); + if(nError == ERROR_SUCCESS) + _tprintf(_T("Search complete\n")); + return nError; +} + +static int TestMpqCompacting(const TCHAR * szMpqName) +{ + HANDLE hMpq = NULL; + int nError = ERROR_SUCCESS; + + // Open the archive + if(nError == ERROR_SUCCESS) + { + _tprintf(_T("Opening \"%s\" for compacting ...\n"), szMpqName); + if(!SFileOpenArchive(szMpqName, 0, 0, &hMpq)) + nError = GetLastError(); + } + + if(nError == ERROR_SUCCESS) + { + const char * szFileName = "Shaders\\Effects\\shadowmap.wfx"; + + printf("Deleting file %s ...\r", szFileName); + if(!SFileRemoveFile(hMpq, szFileName, SFILE_OPEN_FROM_MPQ)) + nError = GetLastError(); + } +/* + // Compact the archive + if(nError == ERROR_SUCCESS) + { + _tprintf(_T("Compacting archive ...\r")); + SFileSetCompactCallback(hMpq, CompactCB, NULL); + if(!SFileCompactArchive(hMpq, "c:\\Tools32\\ListFiles\\ListFile.txt")) + nError = GetLastError(); + } +*/ + if(hMpq != NULL) + SFileCloseArchive(hMpq); + if(nError == ERROR_SUCCESS) + _tprintf(_T("Compacting complete (No errors)\n")); + return nError; +} + +static int TestCreateArchive(const TCHAR * szMpqName) +{ + TFileStream * pStream; + const TCHAR * szFileName1 = MAKE_PATH("FileTest.exe"); + const TCHAR * szFileName2 = MAKE_PATH("ZeroSize.txt"); + HANDLE hMpq = NULL; // Handle of created archive + DWORD dwVerifyResult; + DWORD dwFileCount = 0; + LCID LocaleIDs[] = {0x000, 0x405, 0x406, 0x407, 0xFFFF}; + char szMpqFileName[MAX_PATH]; + int nError = ERROR_SUCCESS; + int i; + + // Create the new file + _tprintf(_T("Creating %s ...\n"), szMpqName); + pStream = FileStream_CreateFile(szMpqName, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + if(pStream == NULL) + nError = GetLastError(); + + // Write some data + if(nError == ERROR_SUCCESS) + { + ULONGLONG FileSize = 0x100000; + + FileStream_SetSize(pStream, FileSize); + FileStream_Close(pStream); + } + + // Well, now create the MPQ archive + if(nError == ERROR_SUCCESS) + { + if(!SFileCreateArchive(szMpqName, + MPQ_CREATE_ARCHIVE_V4 | MPQ_CREATE_ATTRIBUTES, + 17, + &hMpq)) + { + nError = GetLastError(); + } + } + + // Add the same file multiple times + if(nError == ERROR_SUCCESS) + { + // Add FileTest.exe + for(i = 0; AddFlags[i] != 0xFFFFFFFF; i++) + { + sprintf(szMpqFileName, "FileTest_%02u.exe", i); + PrintfTA(_T("Adding %s as %s ...\n"), szFileName1, szMpqFileName); + if(SFileAddFileEx(hMpq, szFileName1, szMpqFileName, AddFlags[i], MPQ_COMPRESSION_ZLIB, MPQ_COMPRESSION_NEXT_SAME)) + { + dwVerifyResult = SFileVerifyFile(hMpq, szMpqFileName, MPQ_ATTRIBUTE_CRC32 | MPQ_ATTRIBUTE_MD5); + if(dwVerifyResult & (VERIFY_OPEN_ERROR | VERIFY_READ_ERROR | VERIFY_FILE_SECTOR_CRC_ERROR | VERIFY_FILE_CHECKSUM_ERROR | VERIFY_FILE_MD5_ERROR)) + printf("CRC error on \"%s\"\n", szMpqFileName); + dwFileCount++; + } + else + { + printf("Failed to add the file \"%s\".\n", szMpqFileName); + } + } + + + // Delete a file in the middle of the file table + SFileRemoveFile(hMpq, "FileTest_10.exe", SFILE_OPEN_FROM_MPQ); + SFileAddFileEx(hMpq, szFileName1, "FileTest_xx.exe", MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED, MPQ_COMPRESSION_ZLIB, MPQ_COMPRESSION_NEXT_SAME); + + // Try to decrement max file count + dwFileCount = SFileGetMaxFileCount(hMpq); + SFileSetMaxFileCount(hMpq, dwFileCount - 1); + + // Add ZeroSize.txt (1) + sprintf(szMpqFileName, "ZeroSize_1.txt"); + for(i = 0; LocaleIDs[i] != 0xFFFF; i++) + { + PrintfTA(_T("Adding %s as %s (locale %04x) ...\n"), szFileName2, szMpqFileName, LocaleIDs[i]); + SFileSetLocale(LocaleIDs[i]); + if(!SFileAddFileEx(hMpq, szFileName2, szMpqFileName, MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED, MPQ_COMPRESSION_ZLIB, MPQ_COMPRESSION_NEXT_SAME)) + printf("Cannot add the file\n"); + } + + // Add ZeroSize.txt (1) + sprintf(szMpqFileName, "ZeroSize_2.txt"); + for(int i = 0; LocaleIDs[i] != 0xFFFF; i++) + { + PrintfTA(_T("Adding %s as %s (locale %04x) ...\n"), szFileName2, szMpqFileName, LocaleIDs[i]); + SFileSetLocale(LocaleIDs[i]); + if(!SFileAddFileEx(hMpq, szFileName2, szMpqFileName, MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED, MPQ_COMPRESSION_ZLIB, MPQ_COMPRESSION_NEXT_SAME)) + printf("Cannot add the file\n"); + } + } + + // Test rename function + if(nError == ERROR_SUCCESS) + { + _tprintf(_T("Testing rename files ...\n")); + SFileSetLocale(LANG_NEUTRAL); + if(!SFileRenameFile(hMpq, "FileTest_08.exe", "FileTest_08a.exe")) + { + nError = GetLastError(); + _tprintf(_T("Failed to rename the file\n")); + } + + if(!SFileRenameFile(hMpq, "FileTest_08a.exe", "FileTest_08.exe")) + { + nError = GetLastError(); + _tprintf(_T("Failed to rename the file\n")); + } + + if(!SFileRenameFile(hMpq, "FileTest_10.exe", "FileTest_10a.exe")) + { + nError = GetLastError(); + _tprintf(_T("Failed to rename the file\n")); + } + + if(!SFileRenameFile(hMpq, "FileTest_10a.exe", "FileTest_10.exe")) + { + nError = GetLastError(); + _tprintf(_T("Failed to rename the file\n")); + } + + if(nError == ERROR_SUCCESS) + _tprintf(_T("Rename test succeeded.\n\n")); + else + _tprintf(_T("Rename test failed.\n\n")); + } + + // Compact the archive +// if(nError == ERROR_SUCCESS) +// SFileCompactArchive(hMpq); + + // Test changing hash table size + if(nError == ERROR_SUCCESS) + SFileSetMaxFileCount(hMpq, 0x95); + + if(hMpq != NULL) + SFileCloseArchive(hMpq); + + // Try to reopen the archive + if(SFileOpenArchive(szMpqName, 0, 0, &hMpq)) + SFileCloseArchive(hMpq); + + _tprintf(_T("\n")); + return nError; +} + +static int TestCreateArchive_PaliRoharBug(const TCHAR * szMpqName) +{ + const TCHAR * szFileName = MAKE_PATH("FileTest.exe"); + HANDLE hMpq = NULL; // Handle of created archive + DWORD dwMaxFileCount = 0; + DWORD dwMpqFlags = MPQ_FILE_ENCRYPTED | MPQ_FILE_COMPRESS; + char szMpqFileName[MAX_PATH]; + int nError = ERROR_SUCCESS; + int i; + + _tremove(szMpqName); + if(SFileCreateArchive(szMpqName, + MPQ_CREATE_ARCHIVE_V4 | MPQ_CREATE_ATTRIBUTES, + 1, + &hMpq)) + { + // Add the file there + SFileAddFileEx(hMpq, szFileName, "FileTest_base.exe", dwMpqFlags, MPQ_COMPRESSION_ZLIB, MPQ_COMPRESSION_NEXT_SAME); + SFileFlushArchive(hMpq); + SFileCloseArchive(hMpq); + + // Add the same file 10 times + for(i = 0; i < 10; i++) + { + if(SFileOpenArchive(szMpqName, 0, 0, &hMpq)) + { + dwMaxFileCount = SFileGetMaxFileCount(hMpq) + 1; + _tprintf(_T("Increasing max file count to %u ...\n"), dwMaxFileCount); + SFileSetMaxFileCount(hMpq, dwMaxFileCount); + + sprintf(szMpqFileName, "FileTest_%02u.exe", dwMaxFileCount); + PrintfTA(_T("Adding %s as %s\n"), szFileName, szMpqFileName); + if(!SFileAddFileEx(hMpq, szFileName, szMpqFileName, dwMpqFlags, MPQ_COMPRESSION_ZLIB, MPQ_COMPRESSION_NEXT_SAME)) + { + printf("Failed to add the file \"%s\".\n", szMpqFileName); + break; + } + + SFileFlushArchive(hMpq); + SFileCompactArchive(hMpq, NULL, false); + SFileCloseArchive(hMpq); + } + } + } + + _tprintf(_T("\n")); + return nError; +} + + +static int TestAddFilesToMpq( + const TCHAR * szMpqName, + ... + ) +{ + const TCHAR * szFileName; + const TCHAR * szSrc; + char * szTrg; + HANDLE hMpq; + va_list argList; + char szMpqFileName[MAX_PATH]; + int nError = ERROR_SUCCESS; + + if(!SFileOpenArchive(szMpqName, 0, 0, &hMpq)) + return GetLastError(); + + va_start(argList, szMpqName); + while((szFileName = va_arg(argList, const TCHAR *)) != NULL) + { + // Convert the plain name to ANSI + szSrc = GetPlainFileNameT(szFileName); + szTrg = szMpqFileName; + while(*szSrc != 0) + *szTrg++ = (char)*szSrc++; + *szTrg = 0; + + // Add the file to MPQ + if(!SFileAddFileEx(hMpq, szFileName, + szMpqFileName, + MPQ_FILE_COMPRESS, + MPQ_COMPRESSION_ZLIB, + MPQ_COMPRESSION_NEXT_SAME)) + { + nError = GetLastError(); + printf("Failed to add the file \"%s\"\n", szFileName); + } + } + + SFileCloseArchive(hMpq); + return nError; +} + +static int TestCreateArchiveFromMemory(const TCHAR * szMpqName) +{ +#define FILE_SIZE 65535 + + HANDLE hFile; + HANDLE hMPQ; + char* data = new char [FILE_SIZE]; // random memory data + char szFileName[100]; + int i; + + // Create an mpq file for testing + if(SFileCreateArchive(szMpqName, MPQ_CREATE_ARCHIVE_V2|MPQ_CREATE_ATTRIBUTES, 0x100000, &hMPQ)) + { + for(i = 0; i < 1000; i++) + { + sprintf(szFileName, "File%03u.bin", i); + printf("Adding file %s\r", szFileName); + + if(SFileCreateFile(hMPQ, szFileName, 0, FILE_SIZE, 0, MPQ_FILE_COMPRESS, &hFile)) + { + SFileWriteFile(hFile, data, FILE_SIZE, MPQ_COMPRESSION_ZLIB); + SFileFinishFile(hFile); + } + } + } + SFileCloseArchive(hMPQ); + delete [] data; + return ERROR_SUCCESS; +} + +static int TestFileReadAndWrite( + const TCHAR * szMpqName, + const char * szFileName) +{ + LPBYTE pvFile = NULL; + HANDLE hFile = NULL; + HANDLE hMpq = NULL; + DWORD dwBytesRead; + DWORD dwFileSize = 0; + int nError = ERROR_SUCCESS; + + if(!SFileOpenArchive(szMpqName, 0, 0, &hMpq)) + { + nError = GetLastError(); + _tprintf(_T("Failed to open the archive %s (%u).\n"), szMpqName, nError); + } + + if(nError == ERROR_SUCCESS) + { + if(!SFileOpenFileEx(hMpq, szFileName, 0, &hFile)) + { + nError = GetLastError(); + printf("Failed to open the file %s (%u).\n", szFileName, nError); + } + } + + if(nError == ERROR_SUCCESS) + { + if(!SFileGetFileInfo(hFile, SFILE_INFO_FILE_SIZE, &dwFileSize, sizeof(DWORD), NULL)) + { + nError = GetLastError(); + _tprintf(_T("Failed to get the file size (%u).\n"), nError); + } + } + + if(nError == ERROR_SUCCESS) + { + pvFile = new BYTE[dwFileSize]; + if(pvFile == NULL) + { + nError = ERROR_NOT_ENOUGH_MEMORY; + printf("Failed to allocate buffer for the file (%u).\n", nError); + } + } + + if(nError == ERROR_SUCCESS) + { + if(!SFileReadFile(hFile, pvFile, dwFileSize, &dwBytesRead, NULL)) + { + nError = GetLastError(); + printf("Failed to read file (%u).\n", nError); + } + } + + if(hFile != NULL) + { + SFileCloseFile(hFile); + hFile = NULL; + } + + if(nError == ERROR_SUCCESS) + { + if(!SFileCreateFile(hMpq, szFileName, 0, dwFileSize, 0, MPQ_FILE_REPLACEEXISTING, &hFile)) + { + nError = GetLastError(); + printf("Failed to create %s in the archive (%u).\n", szFileName, nError); + } + } + + if(nError == ERROR_SUCCESS) + { + if(!SFileWriteFile(hFile, pvFile, dwFileSize, 0)) + { + nError = GetLastError(); + printf("Failed to write the data to the MPQ (%u).\n", nError); + } + } + + if(hFile != NULL) + { + if(!SFileFinishFile(hFile)) + { + nError = GetLastError(); + printf("Failed to finalize file creation (%u).\n", nError); + } + } + + if(pvFile != NULL) + delete [] pvFile; + if(hMpq != NULL) + SFileCloseArchive(hMpq); + return nError; +} + +static int TestSignatureVerify(const TCHAR * szMpqName) +{ + HANDLE hMpq; + + if(SFileOpenArchive(szMpqName, 0, 0, &hMpq)) + { + _tprintf(_T("Verifying digital signature in %s:\n"), szMpqName); + switch(SFileVerifyArchive(hMpq)) + { + case ERROR_NO_SIGNATURE: + _tprintf(_T("No digital signature present.\n")); + break; + + case ERROR_VERIFY_FAILED: + _tprintf(_T("Failed to verify signature.\n")); + break; + + case ERROR_WEAK_SIGNATURE_OK: + _tprintf(_T("Weak signature is OK.\n")); + break; + + case ERROR_WEAK_SIGNATURE_ERROR: + _tprintf(_T("Weak signature mismatch.\n")); + break; + + case ERROR_STRONG_SIGNATURE_OK: + _tprintf(_T("Strong signature is OK.\n")); + break; + + case ERROR_STRONG_SIGNATURE_ERROR: + _tprintf(_T("Strong signature mismatch.\n")); + break; + } + + SFileCloseArchive(hMpq); + _tprintf(_T("\n")); + } + + return 0; +} + + +static int TestCreateArchiveCopy(const TCHAR * szMpqName, const TCHAR * szMpqCopyName, const char * szListFile) +{ + TFileStream * pStream; + TCHAR szLocalFile[MAX_PATH]; + HANDLE hMpq1 = NULL; // Handle of existing archive + HANDLE hMpq2 = NULL; // Handle of created archive + DWORD dwHashTableSize = 0; + int nError = ERROR_SUCCESS; + + // If no listfile or an empty one, use NULL + if(szListFile == NULL || *szListFile == 0) + szListFile = NULL; + + // Create the new file + pStream = FileStream_CreateFile(szMpqCopyName, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + if(pStream == NULL) + nError = GetLastError(); + + // Write some data + if(nError == ERROR_SUCCESS) + { + ULONGLONG FileSize = 0x100000; + + FileStream_SetSize(pStream, FileSize); + FileStream_Close(pStream); + } + + // Open the existing MPQ archive + if(nError == ERROR_SUCCESS) + { + _tprintf(_T("Opening %s ...\n"), szMpqName); + if(!SFileOpenArchive(szMpqName, 0, 0, &hMpq1)) + nError = GetLastError(); + } + + // Well, now create the MPQ archive + if(nError == ERROR_SUCCESS) + { + _tprintf(_T("Creating %s ...\n"), szMpqCopyName); + SFileGetFileInfo(hMpq1, SFILE_INFO_HASH_TABLE_SIZE, &dwHashTableSize, 4, NULL); + if(!SFileCreateArchive(szMpqCopyName, 0, dwHashTableSize, &hMpq2)) + nError = GetLastError(); + } + + // Copy all files from one archive to another + if(nError == ERROR_SUCCESS) + { + SFILE_FIND_DATA sf; + HANDLE hFind = SFileFindFirstFile(hMpq1, "*", &sf, szListFile); + bool bResult = true; + + _tprintf(_T("Copying files ...\n")); + + if(hFind != NULL) + { + while(bResult) + { + if(strcmp(sf.cFileName, LISTFILE_NAME) && strcmp(sf.cFileName, ATTRIBUTES_NAME)) + { + SFileSetLocale(sf.lcLocale); + + // Create the local file name + MergeLocalPath(szLocalFile, szWorkDir, sf.szPlainName); + if(SFileExtractFile(hMpq1, sf.cFileName, szLocalFile, SFILE_OPEN_FROM_MPQ)) + { + printf("Extracting %s ... OK\n", sf.cFileName); + if(!SFileAddFile(hMpq2, szLocalFile, sf.cFileName, sf.dwFileFlags)) + { + nError = GetLastError(); + printf("Adding %s ... Failed\n\n", sf.cFileName); + _tremove(szLocalFile); + break; + } + else + { + printf("Adding %s ... OK\n", sf.cFileName); + } + } + else + { + printf("Extracting %s ... Failed\n", sf.cFileName); + } + + // Delete the added file + _tremove(szLocalFile); + } + + // Find the next file + bResult = SFileFindNextFile(hFind, &sf); + } + + // Close the search handle + SFileFindClose(hFind); + printf("\n"); + } + } + + // Close both archives + if(hMpq2 != NULL) + SFileCloseArchive(hMpq2); + if(hMpq1 != NULL) + SFileCloseArchive(hMpq1); + return nError; +} + +static int TestOpenPatchedArchive(const TCHAR * szMpqName, ...) +{ + TFileStream * pStream; + HANDLE hFile = NULL; + HANDLE hMpq = NULL; + va_list argList; + const char * szFileName = "World\\Minimaps\\Azeroth\\noLiquid_map20_44.blp"; + TCHAR szLocFileName[MAX_PATH]; + LPBYTE pbFullFile = NULL; + DWORD dwFileSize; + int nError = ERROR_SUCCESS; + + // Open the primary MPQ + _tprintf(_T("Opening %s ...\n"), szMpqName); + if(!SFileOpenArchive(szMpqName, 0, MPQ_OPEN_READ_ONLY, &hMpq)) + { + nError = GetLastError(); + _tprintf(_T("Failed to open the archive %s ...\n"), szMpqName); + } + + // Add all patches + if(nError == ERROR_SUCCESS) + { + va_start(argList, szMpqName); + while((szMpqName = va_arg(argList, const TCHAR *)) != NULL) + { + _tprintf(_T("Adding patch %s ...\n"), szMpqName); + if(!SFileOpenPatchArchive(hMpq, szMpqName, NULL, 0)) + { + nError = GetLastError(); + printf("Failed to add patch %s ...\n", szMpqName); + } + } + va_end(argList); + } + + // Now search all files + if(nError == ERROR_SUCCESS) + { + SFILE_FIND_DATA sf; + HANDLE hFind; + bool bResult = true; + + hFind = SFileFindFirstFile(hMpq, "World\\Minimaps\\Azeroth\\noLiquid_map20_44.*", &sf, NULL); + while(hFind && bResult) + { + printf("%s\n", sf.cFileName); + bResult = SFileFindNextFile(hFind, &sf); + } + } + + // Now try to open patched version of a file + if(nError == ERROR_SUCCESS) + { + SFileExtractFile(hMpq, szFileName, _T("E:\\noLiquid_map20_44.blp"), SFILE_OPEN_FROM_MPQ); + } + + // Now try to open patched version of "Achievement.dbc" + if(nError == ERROR_SUCCESS) + { + printf("Opening patched file \"%s\" ...\n", szFileName); + SFileVerifyFile(hMpq, szFileName, SFILE_VERIFY_RAW_MD5); + if(!SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_PATCHED_FILE, &hFile)) + { + nError = GetLastError(); + printf("Failed to open patched file \"%s\"\n", szFileName); + } + } + + // Verify of the patched version is correct + if(nError == ERROR_SUCCESS) + { + TCHAR * szPatchChain = NULL; + DWORD cbPatchChain = 0; + + // Get the patch chain + SFileGetFileInfo(hFile, SFILE_INFO_PATCH_CHAIN, szPatchChain, cbPatchChain, &cbPatchChain); + szPatchChain = (TCHAR *)(new BYTE[cbPatchChain]); + SFileGetFileInfo(hFile, SFILE_INFO_PATCH_CHAIN, szPatchChain, cbPatchChain, &cbPatchChain); + delete [] szPatchChain; + + // Get the size of the full patched file + dwFileSize = SFileGetFileSize(hFile, NULL); + if(dwFileSize != 0) + { + DWORD dwBytesRead = 0; + BYTE TempData[0x100]; + + SFileReadFile(hFile, TempData, sizeof(TempData), &dwBytesRead, NULL); + SFileSetFilePointer(hFile, 0, NULL, FILE_BEGIN); + + // Allocate space for the full file + pbFullFile = new BYTE[dwFileSize]; + if(pbFullFile != NULL) + { + if(!SFileReadFile(hFile, pbFullFile, dwFileSize, NULL, NULL)) + { + nError = GetLastError(); + printf("Failed to read full patched file data \"%s\"\n", szFileName); + } + + if(nError == ERROR_SUCCESS) + { + MergeLocalPath(szLocFileName, MAKE_PATH("Work//"), GetPlainFileNameA(szFileName)); + pStream = FileStream_CreateFile(szLocFileName, STREAM_PROVIDER_LINEAR | BASE_PROVIDER_FILE); + if(pStream != NULL) + { + FileStream_Write(pStream, NULL, pbFullFile, dwFileSize); + FileStream_Close(pStream); + } + } + + delete [] pbFullFile; + } + } + } + + // Close handles + if(hFile != NULL) + SFileCloseFile(hFile); + if(hMpq != NULL) + SFileCloseArchive(hMpq); + return nError; +} + +static int TestCompareTwoArchives( + const TCHAR * szMpqName1, + const TCHAR * szMpqName2, + const char * szListFile, + DWORD dwBlockSize) +{ + TMPQArchive * ha1 = NULL; + TMPQArchive * ha2 = NULL; + HANDLE hMpq1 = NULL; // Handle of the first archive + HANDLE hMpq2 = NULL; // Handle of the second archive + HANDLE hFile1 = NULL; + HANDLE hFile2 = NULL; + int nError = ERROR_SUCCESS; + + // If no listfile or an empty one, use NULL + if(szListFile == NULL || *szListFile == 0) + szListFile = NULL; + + _tprintf(_T("=============== Comparing MPQ archives ===============\n")); + + // Open the first MPQ archive + if(nError == ERROR_SUCCESS && szMpqName1 != NULL) + { + _tprintf(_T("Opening %s ...\n"), szMpqName1); + if(!SFileOpenArchive(szMpqName1, 0, 0, &hMpq1)) + nError = GetLastError(); + ha1 = (TMPQArchive *)hMpq1; + } + + // Open the second MPQ archive + if(nError == ERROR_SUCCESS && szMpqName2 != NULL) + { + _tprintf(_T("Opening %s ...\n"), szMpqName2); + if(!SFileOpenArchive(szMpqName2, 0, 0, &hMpq2)) + nError = GetLastError(); + ha2 = (TMPQArchive *)hMpq2; + } + + // Compare the header + if(nError == ERROR_SUCCESS && (ha1 != NULL && ha2 != NULL)) + { + if(ha1->pHeader->dwHeaderSize != ha2->pHeader->dwHeaderSize) + printf(" - Header size is different\n"); + if(ha1->pHeader->wFormatVersion != ha2->pHeader->wFormatVersion) + printf(" - Format version is different\n"); + if(ha1->pHeader->wSectorSize != ha2->pHeader->wSectorSize) + printf(" - Sector size is different\n"); + if(ha1->pHeader->HetTableSize64 != ha2->pHeader->HetTableSize64) + printf(" - HET table size is different\n"); + if(ha1->pHeader->BetTableSize64 != ha2->pHeader->BetTableSize64) + printf(" - BET table size is different\n"); + if(ha1->pHeader->dwHashTableSize != ha2->pHeader->dwHashTableSize) + printf(" - Hash table size is different\n"); + if(ha1->pHeader->dwBlockTableSize != ha2->pHeader->dwBlockTableSize) + printf(" - Block table size is different\n"); + } + + // Find all files in the first archive and compare them + if(nError == ERROR_SUCCESS) + { + SFILE_FIND_DATA sf; + TMPQFile * hf1; + TMPQFile * hf2; + HANDLE hFind = SFileFindFirstFile(hMpq1, "*", &sf, szListFile); + bool bResult = true; + + while(hFind != NULL && bResult == true) + { +// printf("%s \r", sf.cFileName); + SFileSetLocale(sf.lcLocale); + + // Open the first file + if(!SFileOpenFileEx(hMpq1, sf.cFileName, 0, &hFile1)) + printf("Failed to open the file %s in the first archive\n", sf.cFileName); + + if(!SFileOpenFileEx(hMpq2, sf.cFileName, 0, &hFile2)) + printf("Failed to open the file %s in the second archive\n", sf.cFileName); + + if(hFile1 != NULL && hFile2 != NULL) + { + // Get the TMPQFile pointers + hf1 = (TMPQFile *)hFile1; + hf2 = (TMPQFile *)hFile2; + + // Compare the file sizes + if(hf1->pFileEntry->dwFileSize != hf2->pFileEntry->dwFileSize) + printf("Different file size: %s (%u x %u)\n", sf.cFileName, hf1->pFileEntry->dwFileSize, hf2->pFileEntry->dwFileSize); + + if(hf1->pFileEntry->dwCmpSize != hf2->pFileEntry->dwCmpSize) + printf("Different cmpr size: %s (%u x %u)\n", sf.cFileName, hf1->pFileEntry->dwCmpSize, hf2->pFileEntry->dwCmpSize); + + if(hf1->pFileEntry->dwFlags != hf2->pFileEntry->dwFlags) + printf("Different mpq flags: %s (%08X x %08X)\n", sf.cFileName, hf1->pFileEntry->dwFlags, hf2->pFileEntry->dwFlags); + + if(!CompareArchivedFiles(sf.cFileName, hFile1, hFile2, dwBlockSize)) + printf("Different file data: %s\n", sf.cFileName); + +// if(!CompareArchivedFilesRR(sf.cFileName, hFile1, hFile2, dwBlockSize)) +// printf("Different file data: %s\n", sf.cFileName); + } + + // Close both files + if(hFile2 != NULL) + SFileCloseFile(hFile2); + if(hFile1 != NULL) + SFileCloseFile(hFile1); + hFile2 = hFile1 = NULL; + + // Find the next file + bResult = SFileFindNextFile(hFind, &sf); + } + + // Close the find handle + if(hFind != NULL) + SFileFindClose(hFind); + } + + // Close both archives + clreol(); + printf("================ MPQ compare complete ================\n"); + if(hMpq2 != NULL) + SFileCloseArchive(hMpq2); + if(hMpq1 != NULL) + SFileCloseArchive(hMpq1); + return nError; +} + +//----------------------------------------------------------------------------- +// Searching all known MPQs + +#ifdef _WIN32 +static int TestSearchOneArchive(const TCHAR * szMpqName) +{ + SFILE_FIND_DATA sf; + HANDLE hFind; + HANDLE hMpq; + const TCHAR * szExtension; + bool bFound = true; + + // Get the file extension + szExtension = _tcsrchr(szMpqName, _T('.')); + if(szExtension == NULL) + return ERROR_SUCCESS; + + // Only search defined extensions + if(_tcsicmp(szExtension, _T(".mpq")) && _tcsnicmp(szExtension, _T(".SC2"), 4)) + return ERROR_SUCCESS; + + _tprintf(_T("Searching %s ...\n"), szMpqName); + + // Try to open the MPQ + if(SFileOpenArchive(szMpqName, 0, MPQ_OPEN_READ_ONLY, &hMpq)) + { + hFind = SFileFindFirstFile(hMpq, "*", &sf, NULL); + if(hFind != NULL) + { + while(bFound) + { + if(sf.dwFileFlags & MPQ_FILE_DELETE_MARKER) + _tprintf(_T("Delete marker: %s:%hs\n"), szMpqName, sf.cFileName); + + bFound = SFileFindNextFile(hFind, &sf); + } + } + + SFileCloseArchive(hMpq); + } + + return ERROR_SUCCESS; +} + +static int TestSearchAllArchives(const TCHAR * szSearchMask) +{ + WIN32_FIND_DATA wf; + LPTSTR szFilePart; + HANDLE hFind; + TCHAR szFullPath[MAX_PATH]; + BOOL bFound = TRUE; + + // Initiate search + _tcscpy(szFullPath, szSearchMask); + szFilePart = _tcschr(szFullPath, _T('*')); + assert(szFilePart != NULL); + + // Begin search + hFind = FindFirstFile(szSearchMask, &wf); + if(hFind != INVALID_HANDLE_VALUE) + { + while(bFound) + { + // Eliminate "." and ".." + if(wf.cFileName[0] != _T('.')) + { + // Construct the full path + _tcscpy(szFilePart, wf.cFileName); + + // If it a directory? + if(wf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + _tcscat(szFullPath, _T("\\*")); + TestSearchAllArchives(szFullPath); + } + else + { + TestSearchOneArchive(szFullPath); + } + } + bFound = FindNextFile(hFind, &wf); + } + FindClose(hFind); + } + + return ERROR_SUCCESS; +} +#endif + +//----------------------------------------------------------------------------- +// Main +// + +int main(void) +{ + int nError = ERROR_SUCCESS; + +#if defined(_MSC_VER) && defined(_DEBUG) + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif // defined(_MSC_VER) && defined(_DEBUG) + +// FileStream_OpenEncrypted(_T("e:\\Multimedia\\MPQs\\2010 - Starcraft II\\Installer UI 2 deDE.MPQE")); + + // Mix the random number generator +// srand(GetTickCount()); + + // Test structure sizes +// if(nError == ERROR_SUCCESS) +// nError = TestStructureSizes(); + +// if(nError == ERROR_SUCCESS) +// nError = TestOpenLocalFile("C:\\autoexec.bat"); + + // Test reading partial file +// if(nError == ERROR_SUCCESS) +// nError = TestPartFileRead(MAKE_PATH("2009 - PartialMPQs/patch.MPQ.part")); + +// if(nError == ERROR_SUCCESS) +// nError = ComparePklibCompressions(); + + // Test LZMA compression method against the code ripped from Starcraft II +// if(nError == ERROR_SUCCESS) +// nError = CompareLzmaCompressions(MPQ_SECTOR_SIZE); + + // Test compression methods +// if(nError == ERROR_SUCCESS) +// nError = TestSectorCompress(MPQ_SECTOR_SIZE); + + // Test the archive open and close + if(nError == ERROR_SUCCESS) + nError = TestArchiveOpenAndClose(MAKE_PATH("BrooDat.mpq")); +// nError = TestArchiveOpenAndClose(MAKE_PATH("2011 - WoW BETA/wow-update-13202.MPQ")); +// nError = TestArchiveOpenAndClose(MAKE_PATH("2002 - Warcraft III/ProtectedMap_HashTable_FakeValid.w3x")); +// nError = TestArchiveOpenAndClose(MAKE_PATH("2010 - Starcraft II/Installer Tome 1 enGB.MPQE")); +// nError = TestArchiveOpenAndClose(MAKE_PATH("1997 - Diablo I/DIABDAT_orig.MPQ")); +// nError = TestArchiveOpenAndClose(MAKE_PATH("2004 - World of Warcraft/SoundCache-enUS.MPQ")); +// nError = TestArchiveOpenAndClose(MAKE_PATH("smpq.mpq ")); + +// if(nError == ERROR_SUCCESS) +// nError = TestFindFiles(MAKE_PATH("2002 - Warcraft III/HumanEd.mpq")); + + // Create a big MPQ archive +// if(nError == ERROR_SUCCESS) +// nError = TestCreateArchive_PaliRoharBug(MAKE_PATH("Test.mpq")); +// nError = TestCreateArchive(MAKE_PATH("Test.mpq")); +// nError = TestCreateArchive((const TCHAR*)szUnicodeName1); +// nError = TestCreateArchive((const TCHAR*)szUnicodeName2); +// nError = TestCreateArchive((const TCHAR*)szUnicodeName3); +// nError = TestCreateArchive((const TCHAR*)szUnicodeName4); +// nError = TestCreateArchive((const TCHAR*)szUnicodeName5); +// nError = TestCreateArchive((const TCHAR*)szUnicodeName6); + +// if(nError == ERROR_SUCCESS) +// nError = TestAddFilesToMpq(MAKE_PATH("wow-update-13202.MPQ"), +// "c:\\Tools32\\Arj32.exe", +// "c:\\Tools32\\autoruns.chm", +// "c:\\Tools32\\CPUEater.exe", +// "c:\\Tools32\\dumpbin.exe", +// "c:\\Tools32\\editbin.exe", +// "c:\\Tools32\\fsg.ini", +// "c:\\Tools32\\hiew8.ini", +// "c:\\Tools32\\ida.bat", +// "c:\\Tools32\\mp3.ini", +// NULL); + +// if(nError == ERROR_SUCCESS) +// nError = TestCreateArchiveFromMemory(MAKE_PATH("Test-leak.mpq")); + +// if(nError == ERROR_SUCCESS) +// nError = TestFileReadAndWrite(MAKE_PATH("2002 - Warcraft III/(10)DustwallowKeys.w3m"), "war3map.j"); + + // Verify the archive signature +// if(nError == ERROR_SUCCESS) +// nError = TestSignatureVerify(MAKE_PATH("1998 - Starcraft/BW-1152.exe")); +// nError = TestSignatureVerify(MAKE_PATH("2002 - Warcraft III/(10)DustwallowKeys.w3m")); +// nError = TestSignatureVerify(MAKE_PATH("2002 - Warcraft III/War3TFT_121b_English.exe")); +// nError = TestSignatureVerify(MAKE_PATH("2004 - World of Warcraft/WoW-2.3.3.7799-to-2.4.0.8089-enUS-patch.exe")); +// nError = TestSignatureVerify(MAKE_PATH("2004 - World of Warcraft/standalone.MPQ")); + + // Compact the archive +// if(nError == ERROR_SUCCESS) +// nError = TestMpqCompacting(MAKE_PATH("wow-update-base-14333.MPQ")); + + // Create copy of the archive, appending some bytes before the MPQ header +// if(nError == ERROR_SUCCESS) +// nError = TestCreateArchiveCopy(MAKE_PATH("PartialMPQs/interface.MPQ.part"), MAKE_PATH("PartialMPQs/interface-copy.MPQ.part"), NULL); + +/* + if(nError == ERROR_SUCCESS) + { + nError = TestOpenPatchedArchive(MAKE_PATH("2011 - WoW 4.x/locale-enGB.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-13164.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-13205.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-13287.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-13329.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-13596.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-13623.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-enGB-13914.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-enGB-14007.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-enGB-14333.MPQ"), + MAKE_PATH("2011 - WoW 4.x/wow-update-enGB-14480.MPQ"), + NULL); + } +*/ + + if(nError == ERROR_SUCCESS) + { + nError = TestCompareTwoArchives(MAKE_PATH("Sound-copy.mpq"), + MAKE_PATH("Sound.mpq"), + NULL, + 0x1001); + } + + +// if(nError == ERROR_SUCCESS) +// nError = TestSearchAllArchives(MAKE_PATH("*")); + + return nError; +} diff --git a/dep/StormLib/test/starcraft_lzma.asm b/dep/StormLib/test/starcraft_lzma.asm new file mode 100644 index 000000000..0da46b20e --- /dev/null +++ b/dep/StormLib/test/starcraft_lzma.asm @@ -0,0 +1,11066 @@ +; +; LZMA compression code ripped from Starctaft II BEta +; Used while StormLib's LZMA implementation was tested against Starcraft compression +; Not used in StormLib. +; + +.686P +.MODEL FLAT +ASSUME FS: NOTHING + +.DATA + +;--------------------------------------------------------------------------- +; Data + +byte_4CB248 db 0, 0Bh, 0Bh, 0Bh ; indirect table for switch statement + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 1, 2, 3, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 4, 5, 6, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 7, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 8, 9, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Ah + align 10h + +dword_544960 dd 0BB40E64Eh ; DATA XREF: sub_401C72+B +dword_553598 dd ? ; DATA XREF: sub_4CB8A0+9 + +off_50CD3C dd offset sub_4A0605 ; DATA XREF: sub_4A05F7+1o + ; .data:off_52A004o ... +dword_50CD40 dd 0E06D7363h ; DATA XREF: _CxxThrowException(x,x)+Eo + dd 1 + dd 0 + dd 0 + dd 3 + dd 19930520h + dd 0 + dd 0 + +; --------------------------------------------------------------------------- + +off_546E20 dd offset sub_4CDD70 ; DATA XREF: sub_4D0270:loc_4D0324o +off_546E24 dd offset sub_4CDD90 ; DATA XREF: sub_4CF810+53r +off_546E28 dd offset off_50CD3C ; DATA XREF: .rdata:off_51B888o + dd 0 + db '.?AUISequentialInStream@@',0 + db 0 + db 0 +off_546E4C dd offset off_50CD3C ; DATA XREF: .rdata:off_51B8C0o + dd 0 + db '.?AUISequentialOutStream@@',0 + db 0 +off_546E70 dd offset off_50CD3C ; DATA XREF: .rdata:off_51B8F8o + dd 0 + db '.?AUICompressCoder@@',0 + db 0 + db 0 + db 0 +off_546E90 dd offset off_50CD3C ; DATA XREF: .rdata:off_51B944o + dd 0 + db '.?AUICompressSetOutStream@@',0 +off_546EB4 dd offset off_50CD3C ; DATA XREF: .rdata:0051B96Co + dd 0 + db '.?AUICompressSetCoderProperties@@',0 + db 0 + db 0 +off_546EE0 dd offset off_50CD3C ; DATA XREF: .rdata:0051B9B8o + dd 0 + db '.?AUICompressWriteCoderProperties@@',0 + dd offset off_50CD3C + dd 0 + db '.?AUCSystemException@@',0 + db 0 + dd offset off_50CD3C + dd 0 + db '.?AUCOutBufferException@@',0 + db 0 + db 0 +off_546F50 dd offset off_50CD3C ; DATA XREF: .rdata:0051BA04o + dd 0 + db '.?AVCInStreamMemory@@',0 + db 0 + db 0 +off_546F70 dd offset off_50CD3C ; DATA XREF: .rdata:off_51BA4Co + dd 0 + db '.?AVCMyUnknownImp@@',0 +off_546F8C dd offset off_50CD3C ; DATA XREF: .rdata:0051BAA8o + dd 0 + db '.?AVCOutStreamMemory@@',0 + db 0 +off_546FAC dd offset off_50CD3C ; DATA XREF: .rdata:0051BAFCo + dd 0 + db '.?AVCEncoder@NLZMA@NCompress@@',0 + db 0 +off_546FD4 dd offset off_50CD3C ; DATA XREF: .rdata:off_51BBECo + dd 0 + db '.?AVCBaseState@NLZMA@NCompress@@',0 + db 0 + db 0 + db 0 + +; --------------------------------------------------------------------------- + +dword_51B960 dd 0 ; DATA XREF: .rdata:00517A64o + dd 0 + dd 0 + dd offset off_546EB4 + dd 0 ; offset dword_51B974 + +dword_51B9AC dd 0 ; DATA XREF: .rdata:00517A78o + dd 0 + dd 0 + dd offset off_546EE0 + dd 0 ;offset dword_51B9C0 + +dword_51B9F8 dd 0 ; DATA XREF: .rdata:00517A8Co + dd 0 + dd 0 + dd offset off_546F50 + dd 0 ; offset dword_51BA0C + +dword_51BA9C dd 0 ; DATA XREF: .rdata:00517AA0o + dd 0 + dd 0 + dd offset off_546F8C + dd 0 ; offset dword_51BAB0 + +dword_51BAF0 dd 0 ; DATA XREF: .rdata:00517AF8o + dd 0 + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +dword_51BC58 dd 0 ; DATA XREF: .rdata:00517AE0o + dd 4 + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +dword_51BC6C dd 0 ; DATA XREF: .rdata:00517ACCo + dd 8 + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +dword_51BC80 dd 0 ; DATA XREF: .rdata:00517AB8o + dd 0Ch + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +; --------------------------------------------------------------------------- + +dword_512730 dd 0 ; DATA XREF: sub_48DB4D+B9o +dword_512734 dd 0 ; DATA XREF: CCmdTarget::GetInterface(void const *)+2Dr +dword_512738 dd 0C0h ; DATA XREF: CCmdTarget::GetInterface(void const *)+38r +dword_51273C dd 46000000h ; DATA XREF: CCmdTarget::GetInterface(void const *)+43r + +dword_5535A0 dd ? ; DATA XREF: sub_4CF900:loc_4CF94Co +dword_5535A4 dd ? ; DATA XREF: .text:004DAF37w +dword_5535A8 dd ? ; DATA XREF: .text:004DAF3Cw +dword_5535AC dd ? ; DATA XREF: .text:004DAF41w + +dword_5535B0 dd ? ; DATA XREF: sub_4CF900+5Eo +dword_5535B4 dd ? ; DATA XREF: .text:004DAF17w +dword_5535B8 dd ? ; DATA XREF: .text:004DAF1Cw +dword_5535BC dd ? ; DATA XREF: .text:004DAF21w + +dword_5535C0 dd ? ; DATA XREF: sub_4CF900:loc_4CF98Fo +dword_5535C4 dd ? ; DATA XREF: .text:004DAEF7w +dword_5535C8 dd ? ; DATA XREF: .text:004DAEFCw +dword_5535CC dd ? ; DATA XREF: .text:004DAF01w + + +dword_526DD0 dd 0 ; DATA XREF: .text:loc_4CF6CBo + dd 0 + dd 0 + dd 0 ; offset dword_526DE0 + +kLiteralNextStates db 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 +kMatchNextStates db 7, 7, 7, 7, 7, 7, 7, 0Ah, 0Ah, 0Ah, 0Ah, 0Ah +kRepNextStates db 8, 8, 8, 8, 8, 8, 8, 0Bh, 0Bh, 0Bh, 0Bh, 0Bh +kShortRepNextStates db 9, 9, 9, 9, 9, 9, 9, 0Bh, 0Bh, 0Bh, 0Bh, 0Bh + +dword_550998 dd 200h dup(?) +dword_551198 dd 800h dup(?) +dword_553198 dd 100h dup(?) + +ICompressSetOutStream_vftable dd offset __purecall ; DATA XREF: NCompress_NLZMA_CEncoder_CEncoder+2o + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset dword_51B960 +ICompressSetCoderProperties_vftable dd offset __purecall ; DATA XREF: NCompress_NLZMA_CEncoder_CEncoder+9o + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset dword_51B9AC +ICompressWriteCoderProperties_vftable dd offset __purecall ; DATA XREF: NCompress_NLZMA_CEncoder_CEncoder+10o + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset dword_51B9F8 +off_517A90 dd offset Interface1_QueryInterface + dd offset Interface1_AddRef + dd offset Interface1_Release + dd offset sub_4CCB20 + dd offset dword_51BA9C +off_517AA4 dd offset Interface1_QueryInterface ; DATA XREF: sub_4CF610+Eo + dd offset Interface1_AddRef + dd offset Interface2_Release + dd offset sub_4CCB90 + dd offset sub_4CF590 + dd offset dword_51BC80 +NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderProperties dd offset sub_4CFA50 ; DATA XREF: sub_4CF810+3Do + dd offset sub_4CFA10 + dd offset sub_4CFA70 + dd offset sub_4CDDB0 + dd offset dword_51BC6C +NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderProperties dd offset ICompressSetCoderProperties_QueryInterface ; DATA XREF: sub_4CF810+36o + dd offset ICompressSetCoderProperties_AddRef + dd offset ICompressSetCoderProperties_Release + dd offset ICompressSetCoderProperties_SetCoderProperties + dd offset dword_51BC58 +NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStream dd offset sub_4CFA20 ; DATA XREF: sub_4CF810+2Fo + dd offset sub_4CFA80 + dd offset sub_4CFA40 + dd offset sub_4CFA90 + dd offset sub_4CDE70 + dd offset dword_51BAF0 +NCompress_NLZMA_CEncoder_vftable dd offset sub_4CF900 ; DATA XREF: sub_4CF810+29o + dd offset sub_4CF9D0 + dd offset sub_4CF9E0 + dd offset CEncoder_Code + dd offset sub_4D0250 + +.CODE + +extrn _operator_new:PROC +extrn __allshr: PROC +extrn _free: PROC +extrn _memcmp: PROC +extrn _memcpy: PROC +extrn _memset: PROC +extrn ___report_gsfailure: PROC +extrn __purecall: PROC +VirtualAlloc PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD +VirtualFree PROTO STDCALL :DWORD,:DWORD,:DWORD + +; --------------------------------------------------------------------------- + +; void __cdecl j__free(void *Memory) +; 004843B8 +j__free proc near ; CODE XREF: sub_401048+16p + ; .text:004010CFp ... + jmp _free +j__free endp + + +; --------------------------------------------------------------------------- + +; int __cdecl unknown_libname_324(void *Buf1, void *Buf2) +unknown_libname_324 proc near +; sub_48B7BA + +Buf1 = dword ptr 4 +Buf2 = dword ptr 8 + + push 10h ; Size + push [esp+4+Buf2] ; Buf2 + push [esp+8+Buf1] ; Buf1 + call _memcmp + add esp, 0Ch + neg eax + sbb eax, eax + inc eax + retn +unknown_libname_324 endp + +; --------------------------------------------------------------------------- + +sub_4A05F7 proc near ; CODE XREF: sub_4A0605+3p + push ecx + mov dword ptr [ecx], offset off_50CD3C + call sub_4A98B8 + pop ecx + retn +sub_4A05F7 endp + +; --------------------------------------------------------------------------- + +; int __thiscall sub_4A0605(void *Memory, char) +sub_4A0605 proc near ; DATA XREF: .rdata:off_50CD3Co + +arg_0 = byte ptr 4 + + push esi + mov esi, ecx + call sub_4A05F7 + test [esp+4+arg_0], 1 + jz short loc_4A061B + push esi ; Memory + call j__free + pop ecx + +loc_4A061B: ; CODE XREF: sub_4A0605+Dj + mov eax, esi + pop esi + retn 4 +sub_4A0605 endp + +; --------------------------------------------------------------------------- + +sub_4A0686 proc near ; CODE XREF: sub_401C72+49p + ; sub_40222F+15Cp ... + cmp ecx, dword_544960 + jnz short loc_4A0690 + retn +loc_4A0690: ; CODE XREF: sub_4A0686+6j + jmp ___report_gsfailure +sub_4A0686 endp + +; --------------------------------------------------------------------------- + +sub_4A98B8 proc near ; CODE XREF: sub_4A05F7+7p + + int 3 + retn +sub_4A98B8 endp + +; =============== S U B R O U T I N E ======================================= + + +sub_4CAEC0 proc near ; CODE XREF: CEncoder_GetOptimum+514p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push esi + push edi + mov edi, [esp+8+arg_4] + lea eax, [edi-2] + cmp eax, 4 + mov esi, ecx + jb short loc_4CAED5 + mov eax, 3 + +loc_4CAED5: ; CODE XREF: sub_4CAEC0+Ej + mov edx, [esp+8+arg_0] + cmp edx, 80h + jnb short loc_4CAEEF + shl eax, 7 + add eax, edx + mov ecx, [esi+eax*4+33314h] + jmp short loc_4CAF25 +; --------------------------------------------------------------------------- + +loc_4CAEEF: ; CODE XREF: sub_4CAEC0+1Fj + mov ecx, 7FFFFh + sub ecx, edx + sar ecx, 1Fh + push ebx + and ecx, 0Ch + add ecx, 6 + mov ebx, edx + shr ebx, cl + shl eax, 5 + add eax, ecx + and edx, 0Fh + movzx ebx, byte ptr dword_551198[ebx] + lea eax, [ebx+eax*2] + mov ecx, [esi+eax*4+32F14h] + add ecx, [esi+edx*4+33B14h] + pop ebx + +loc_4CAF25: ; CODE XREF: sub_4CAEC0+2Dj + mov edx, [esp+8+arg_8] + imul edx, 110h + add edx, edi + mov eax, [esi+edx*4+295B8h] + pop edi + add eax, ecx + pop esi + retn 0Ch +sub_4CAEC0 endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CAF40: ; CODE XREF: .text:004DAED5j + push ecx + push ebx + push ebp + push esi + mov ebp, 2 + mov bl, 2 + push edi + mov byte ptr dword_551198, 0 + mov byte ptr dword_551198+1, 1 + mov [esp+10h], bl + mov edi, ebp + +loc_4CAF60: ; CODE XREF: .text:004CAF96j + mov ecx, edi + shr ecx, 1 + sub ecx, 1 + mov esi, 1 + shl esi, cl + test esi, esi + jbe short loc_4CAF89 + mov ecx, [esp+10h] + push esi + lea eax, dword_551198[ebp] + push ecx + push eax + call _memset + add esp, 0Ch + add ebp, esi + +loc_4CAF89: ; CODE XREF: .text:004CAF70j + add bl, 1 + add edi, 1 + cmp bl, 1Ah + mov [esp+10h], bl + jb short loc_4CAF60 + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CAFA0 proc near ; CODE XREF: sub_4CAFC0+90p + +arg_0 = dword ptr 4 + + mov eax, [esp+arg_0] + lea ecx, [eax-61h] + cmp cx, 19h + ja short locret_4CAFB2 + add eax, 0FFE0h + +locret_4CAFB2: ; CODE XREF: sub_4CAFA0+Bj + retn +sub_4CAFA0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + +sub_4CAFC0 proc near ; CODE XREF: ICompressSetCoderProperties_SetCoderProperties+A5p + movzx ecx, word ptr [eax] + lea edx, [ecx-61h] + cmp dx, 19h + ja short loc_4CAFD2 + add ecx, 0FFE0h + +loc_4CAFD2: ; CODE XREF: sub_4CAFC0+Aj + add eax, 2 + cmp cx, 48h + jnz short loc_4CB01B + movzx ecx, word ptr [eax] + lea edx, [ecx-61h] + cmp dx, 19h + ja short loc_4CAFED + add ecx, 0FFE0h + +loc_4CAFED: ; CODE XREF: sub_4CAFC0+25j + add eax, 2 + cmp cx, 43h + jz short loc_4CAFF9 + +loc_4CAFF6: ; CODE XREF: sub_4CAFC0+44j + ; sub_4CAFC0+4Bj ... + xor eax, eax + retn +; --------------------------------------------------------------------------- + +loc_4CAFF9: ; CODE XREF: sub_4CAFC0+34j + movzx ecx, word ptr [eax] + sub ecx, 30h + lea edx, [ecx-4] + test edx, edx + ja short loc_4CAFF6 + cmp word ptr [eax+2], 0 + jnz short loc_4CAFF6 + mov dword ptr [ebx], 0 + mov [edi], ecx + mov eax, 1 + retn +; --------------------------------------------------------------------------- + +loc_4CB01B: ; CODE XREF: sub_4CAFC0+19j + cmp cx, 42h + jnz short loc_4CAFF6 + movzx ecx, word ptr [eax] + lea edx, [ecx-61h] + cmp dx, 19h + ja short loc_4CB033 + add ecx, 0FFE0h + +loc_4CB033: ; CODE XREF: sub_4CAFC0+6Bj + add eax, 2 + cmp cx, 54h + jnz short loc_4CAFF6 + push esi + movzx esi, word ptr [eax] + sub esi, 30h + lea ecx, [esi-2] + cmp ecx, 2 + ja short loc_4CB06C + movzx eax, word ptr [eax+2] + push eax + call sub_4CAFA0 + add esp, 4 + test ax, ax + jnz short loc_4CB06C + mov dword ptr [ebx], 1 + mov [edi], esi + mov eax, 1 + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CB06C: ; CODE XREF: sub_4CAFC0+89j + ; sub_4CAFC0+9Bj + xor eax, eax + pop esi + retn +sub_4CAFC0 endp + + +ICompressSetCoderProperties_SetCoderProperties proc near ; DATA XREF: .rdata:00517ADCo + +var_4 = dword ptr -4 +pThis = dword ptr 4 +propIDs = dword ptr 8 +properties = dword ptr 0Ch +numProperties = dword ptr 10h + + push ecx + push ebx + push ebp + xor edx, edx + cmp [esp+0Ch+numProperties], edx + push esi + push edi + mov [esp+14h+var_4], edx + jbe loc_4CB20D + mov esi, [esp+14h+properties] + mov ebp, [esp+14h+pThis] + lea ecx, [ecx+0] + +loc_4CB090: ; CODE XREF: sub_4CB070+197j + mov eax, [esp+14h+propIDs] + mov eax, [eax+edx*4] + add eax, 0FFFFFC00h + cmp eax, 90h ; switch 145 cases + ja loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + movzx ecx, ds:byte_4CB248[eax] + jmp ds:off_4CB218[ecx*4] ; switch jump + +loc_4CB0B5: ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 80 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + lea ecx, [eax-5] + cmp ecx, 10Ch + ja short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+32EF0h], eax + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB0D4: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 82 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + mov [ebp+33B88h], eax + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB0E8: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 112 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + cmp dword ptr [esi+8], 0 + setz cl + mov [ebp+32EECh], cl + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB100: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 8 ; jumptable 004CB0AE case 81 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + lea edi, [ebp+0C4h] + lea ebx, [ebp+0CCh] + call sub_4CAFC0 + test eax, eax + jz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov edx, [esp+14h+var_4] + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB127: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 0Bh ; jumptable 004CB0AE case 128 + jz loc_4CB1F9 + +loc_4CB131: ; CODE XREF: sub_4CB070+31j + ; sub_4CB070+3Ej ... + pop edi ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + pop esi + pop ebp + mov eax, 80070057h + pop ebx + pop ecx + retn 10h +; --------------------------------------------------------------------------- + +loc_4CB13E: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 129 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB149: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 0 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + lea ecx, [eax-1] + cmp ecx, 3FFFFFFFh + ja short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+33B64h], eax + xor ecx, ecx + +loc_4CB165: ; CODE XREF: sub_4CB070+106j + mov edi, 1 + shl edi, cl + cmp eax, edi + jbe short loc_4CB178 + add ecx, 1 + cmp ecx, 1Eh + jb short loc_4CB165 + +loc_4CB178: ; CODE XREF: sub_4CB070+FEj + lea eax, [ecx+ecx] + mov [ebp+33B50h], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB183: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 64 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov ecx, [esi+8] + cmp ecx, 4 + ja short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, 1 + shl eax, cl + mov [ebp+33B54h], ecx + sub eax, 1 + mov [ebp+33B58h], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB1A9: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 66 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + cmp eax, 4 + ja loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+33B5Ch], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB1C3: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 65 + jnz loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + cmp eax, 8 + ja loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+33B60h], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB1E1: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 0Bh ; jumptable 004CB0AE case 144 + jnz loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + cmp word ptr [esi+8], 0FFFFh + setz cl + mov [ebp+33B8Ch], cl + +loc_4CB1F9: ; CODE XREF: sub_4CB070+5Fj + ; sub_4CB070+73j ... + add edx, 1 + add esi, 10h + cmp edx, [esp+14h+numProperties] + mov [esp+14h+var_4], edx + jb loc_4CB090 + +loc_4CB20D: ; CODE XREF: sub_4CB070+Fj + pop edi + pop esi + pop ebp + xor eax, eax + pop ebx + pop ecx + retn 10h + +off_4CB218 dd offset loc_4CB149, offset loc_4CB183, offset loc_4CB1C3 + dd offset loc_4CB1A9, offset loc_4CB0B5, offset loc_4CB100 ; jump table for switch statement + dd offset loc_4CB0D4, offset loc_4CB0E8, offset loc_4CB127 + dd offset loc_4CB13E, offset loc_4CB1E1, offset loc_4CB131 + +ICompressSetCoderProperties_SetCoderProperties endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CB2E0 proc near ; CODE XREF: CEncoder_GetOptimum+1199p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_4] + lea eax, [esi+esi*4] + lea edx, [ecx+eax*8] + mov [ecx+32F08h], esi + mov eax, [edx+100h] + mov ebx, [edx+104h] + push edi + +loc_4CB300: ; CODE XREF: sub_4CB2E0+A6j + lea edx, [esi+esi*4] + cmp byte ptr [ecx+edx*8+0F1h], 0 + lea edi, [ecx+edx*8] + jz short loc_4CB359 + lea edx, [eax+eax*4+1Eh] + lea edx, [ecx+edx*8] + mov dword ptr [edx+14h], 0FFFFFFFFh + mov byte ptr [edx+1], 0 + lea edx, [eax+eax*4] + lea edx, [ecx+edx*8] + lea ebp, [eax-1] + mov [edx+100h], ebp + cmp byte ptr [edi+0F2h], 0 + jz short loc_4CB359 + mov byte ptr [edx+0C9h], 0 + mov ebp, [edi+0F4h] + mov [edx+0D8h], ebp + mov edi, [edi+0F8h] + mov [edx+0DCh], edi + +loc_4CB359: ; CODE XREF: sub_4CB2E0+2Ej + ; sub_4CB2E0+58j + lea edx, [eax+eax*4] + add edx, edx + add edx, edx + add edx, edx + mov edi, eax + test edi, edi + mov eax, [edx+ecx+100h] + mov ebp, ebx + mov ebx, [edx+ecx+104h] + mov [edx+ecx+100h], esi + mov [edx+ecx+104h], ebp + mov esi, edi + jnz loc_4CB300 + mov eax, [ecx+104h] + mov edx, [esp+10h+arg_0] + pop edi + pop esi + mov [edx], eax + mov eax, [ecx+100h] + pop ebp + mov [ecx+32F0Ch], eax + pop ebx + retn 8 +sub_4CB2E0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CB3B0 proc near ; CODE XREF: CEncoder_GetOptimumFast+2Dp + ; CEncoder_GetOptimumFast+28Fp ... + +arg_0 = dword ptr 4 + + push ebx + push ebp + push esi + mov esi, ecx + mov ecx, [esi+80h] + mov edx, [esi+78h] + lea eax, [esi+32660h] + push eax + push ecx + xor ebx, ebx + call edx + mov ebp, [esp+14h+arg_0] + add esp, 8 + test eax, eax + mov [ebp+0], eax + jbe short loc_4CB446 + mov ebx, [esi+eax*4+32658h] + cmp ebx, [esi+32EF8h] + jnz short loc_4CB446 + mov eax, [esi+80h] + mov ecx, [esi+70h] + push edi + push eax + call ecx + mov edx, [esi+80h] + mov edi, eax + mov eax, [esi+74h] + push edx + add edi, 1 + call eax + mov ecx, [ebp+0] + mov ecx, [esi+ecx*4+3265Ch] + add esp, 8 + sub eax, 1 + add ecx, 1 + cmp edi, 111h + jbe short loc_4CB425 + mov edi, 111h + +loc_4CB425: ; CODE XREF: sub_4CB3B0+6Ej + mov edx, eax + sub edx, ecx + cmp ebx, edi + jnb short loc_4CB445 + mov ebp, edx + lea ecx, [eax+ebx] + sub ebp, eax + +loc_4CB434: ; CODE XREF: sub_4CB3B0+93j + mov dl, [ecx] + cmp dl, [ecx+ebp] + jnz short loc_4CB445 + add ebx, 1 + add ecx, 1 + cmp ebx, edi + jb short loc_4CB434 + +loc_4CB445: ; CODE XREF: sub_4CB3B0+7Bj + ; sub_4CB3B0+89j + pop edi + +loc_4CB446: ; CODE XREF: sub_4CB3B0+26j + ; sub_4CB3B0+35j + add dword ptr [esi+32F04h], 1 + pop esi + pop ebp + mov eax, ebx + pop ebx + retn 4 +sub_4CB3B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_GetOptimumFast proc near ; CODE XREF: CEncoder_CodeOneBlock+1F4p + +var_28 = dword ptr -28h +var_24 = dword ptr -24h +var_20 = dword ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +arg_0 = dword ptr 4 + + sub esp, 28h + push ebx + push esi + push edi + mov edi, ecx + mov eax, [edi+80h] + mov ecx, [edi+70h] + push eax + call ecx + add esp, 4 + cmp byte ptr [edi+32F10h], 0 + mov esi, eax + mov [esp+34h+var_24], esi + jnz short loc_4CB498 + lea edx, [esp+34h+var_20] + push edx + mov ecx, edi + call sub_4CB3B0 + mov ebx, [esp+34h+var_20] + jmp short loc_4CB4AF +; --------------------------------------------------------------------------- + +loc_4CB498: ; CODE XREF: CEncoder_GetOptimumFast+24j + mov ebx, [edi+32F00h] + mov eax, [edi+32EFCh] + mov [esp+34h+var_20], ebx + mov byte ptr [edi+32F10h], 0 + +loc_4CB4AF: ; CODE XREF: CEncoder_GetOptimumFast+36j + mov ecx, [edi+80h] + mov edx, [edi+74h] + push ecx + mov [esp+38h+var_28], eax + call edx + add esp, 4 + sub eax, 1 + cmp esi, 111h + jbe loc_4CB55E + mov [esp+34h+var_24], 111h + +loc_4CB4D9: ; CODE XREF: CEncoder_GetOptimumFast+101j + push ebp + xor ebp, ebp + lea ecx, [edi+14h] + mov [esp+38h+var_18], ebp + mov [esp+38h+var_14], ebp + mov [esp+38h+var_1C], ecx + jmp short loc_4CB4F0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CB4F0: ; CODE XREF: CEncoder_GetOptimumFast+8Bj + ; CEncoder_GetOptimumFast+132j + mov edx, [esp+38h+var_1C] + mov ecx, eax + sub ecx, [edx] + mov dl, [eax] + sub ecx, 1 + cmp dl, [ecx] + jnz short loc_4CB57F + mov dl, [eax+1] + cmp dl, [ecx+1] + jnz short loc_4CB57F + mov esi, 2 + cmp [esp+38h+var_24], esi + jbe short loc_4CB537 + lea edx, [eax+2] + sub ecx, eax + lea esp, [esp+0] + +loc_4CB520: ; CODE XREF: CEncoder_GetOptimumFast+D1j + mov bl, [edx] + cmp bl, [ecx+edx] + jnz short loc_4CB533 + add esi, 1 + add edx, 1 + cmp esi, [esp+38h+var_24] + jb short loc_4CB520 + +loc_4CB533: ; CODE XREF: CEncoder_GetOptimumFast+C5j + mov ebx, [esp+38h+var_20] + +loc_4CB537: ; CODE XREF: CEncoder_GetOptimumFast+B2j + cmp esi, [edi+32EF8h] + jnb short loc_4CB5B9 + mov edx, [esp+38h+var_14] + lea ecx, ds:0[ebp*4] + mov [esp+ecx+38h+var_10], esi + cmp esi, [esp+edx+38h+var_10] + jbe short loc_4CB587 + mov [esp+38h+var_18], ebp + mov [esp+38h+var_14], ecx + jmp short loc_4CB587 +; --------------------------------------------------------------------------- + +loc_4CB55E: ; CODE XREF: CEncoder_GetOptimumFast+6Bj + cmp esi, 2 + jnb loc_4CB4D9 + mov eax, [esp+34h+arg_0] + pop edi + pop esi + mov dword ptr [eax], 0FFFFFFFFh + mov eax, 1 + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB57F: ; CODE XREF: CEncoder_GetOptimumFast+9Fj + ; CEncoder_GetOptimumFast+A7j + mov [esp+ebp*4+38h+var_10], 0 + +loc_4CB587: ; CODE XREF: CEncoder_GetOptimumFast+F2j + ; CEncoder_GetOptimumFast+FCj + add [esp+38h+var_1C], 4 + add ebp, 1 + cmp ebp, 4 + jb loc_4CB4F0 + mov esi, [esp+38h+var_28] + cmp esi, [edi+32EF8h] + jb short loc_4CB5EC + mov eax, [edi+ebx*4+3265Ch] + mov ecx, [esp+38h+arg_0] + add eax, 4 + mov [ecx], eax + jmp loc_4CB69A +; --------------------------------------------------------------------------- + +loc_4CB5B9: ; CODE XREF: CEncoder_GetOptimumFast+DDj + mov eax, [esp+38h+arg_0] + mov [eax], ebp + lea eax, [esi-1] + test eax, eax + jz loc_4CB82E + mov ecx, [edi+80h] + mov edx, [edi+7Ch] + add [edi+32F04h], eax + push eax + push ecx + call edx + add esp, 8 + pop ebp + pop edi + mov eax, esi + pop esi + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB5EC: ; CODE XREF: CEncoder_GetOptimumFast+142j + xor ebp, ebp + cmp esi, 2 + mov [esp+38h+var_20], ebp + jb short loc_4CB65A + cmp ebx, 2 + mov ecx, [edi+ebx*4+3265Ch] + mov [esp+38h+var_20], ecx + jbe short loc_4CB63F + lea eax, [edi+ebx*4+32654h] + mov edi, edi + +loc_4CB610: ; CODE XREF: CEncoder_GetOptimumFast+1DDj + mov edx, [eax-4] + add edx, 1 + cmp esi, edx + jnz short loc_4CB63F + mov ecx, [esp+38h+var_20] + shr ecx, 7 + cmp ecx, [eax] + jbe short loc_4CB63F + mov edx, [eax-4] + mov ecx, [eax] + sub eax, 8 + sub ebx, 2 + cmp ebx, 2 + mov [esp+38h+var_28], edx + mov [esp+38h+var_20], ecx + mov esi, edx + ja short loc_4CB610 + +loc_4CB63F: ; CODE XREF: CEncoder_GetOptimumFast+1A5j + ; CEncoder_GetOptimumFast+1B8j ... + cmp esi, 2 + jnz short loc_4CB656 + cmp [esp+38h+var_20], 80h + jb short loc_4CB656 + mov [esp+38h+var_28], 1 + +loc_4CB656: ; CODE XREF: CEncoder_GetOptimumFast+1E2j + ; CEncoder_GetOptimumFast+1ECj + mov ebp, [esp+38h+var_20] + +loc_4CB65A: ; CODE XREF: CEncoder_GetOptimumFast+195j + mov edx, [esp+38h+var_18] + mov esi, [esp+edx*4+38h+var_10] + cmp esi, 2 + mov ebx, [esp+38h+var_28] + jb short loc_4CB6C7 + lea eax, [esi+1] + cmp eax, ebx + jnb short loc_4CB690 + lea ecx, [esi+2] + cmp ecx, ebx + jb short loc_4CB681 + cmp ebp, 200h + ja short loc_4CB690 + +loc_4CB681: ; CODE XREF: CEncoder_GetOptimumFast+217j + lea edx, [esi+3] + cmp edx, ebx + jb short loc_4CB6C7 + cmp ebp, 8000h + jbe short loc_4CB6C7 + +loc_4CB690: ; CODE XREF: CEncoder_GetOptimumFast+210j + ; CEncoder_GetOptimumFast+21Fj + mov eax, [esp+38h+arg_0] + mov ecx, [esp+38h+var_18] + mov [eax], ecx + +loc_4CB69A: ; CODE XREF: CEncoder_GetOptimumFast+154j + lea eax, [esi-1] + test eax, eax + jz loc_4CB82E + mov edx, [edi+80h] + add [edi+32F04h], eax + push eax + mov eax, [edi+7Ch] + push edx + call eax + add esp, 8 + pop ebp + pop edi + mov eax, esi + pop esi + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB6C7: ; CODE XREF: CEncoder_GetOptimumFast+209j + ; CEncoder_GetOptimumFast+226j ... + cmp ebx, 2 + jb short loc_4CB73E + cmp [esp+38h+var_24], 2 + jbe short loc_4CB73E + mov ecx, [edi+80h] + mov edx, [edi+70h] + push ecx + call edx + add esp, 4 + lea esi, [edi+32F00h] + push esi + mov ecx, edi + mov [esp+3Ch+var_24], eax + call sub_4CB3B0 + cmp eax, 2 + mov [edi+32EFCh], eax + jb short loc_4CB757 + cmp eax, ebx + mov ecx, [esi] + mov edx, [edi+ecx*4+3265Ch] + jb short loc_4CB710 + cmp edx, ebp + jb short loc_4CB737 + +loc_4CB710: ; CODE XREF: CEncoder_GetOptimumFast+2AAj + lea ecx, [ebx+1] + cmp eax, ecx + jnz short loc_4CB722 + mov esi, edx + shr esi, 7 + cmp esi, ebp + jbe short loc_4CB737 + cmp eax, ecx + +loc_4CB722: ; CODE XREF: CEncoder_GetOptimumFast+2B5j + ja short loc_4CB737 + add eax, 1 + cmp eax, ebx + jb short loc_4CB757 + cmp ebx, 3 + jb short loc_4CB757 + shr ebp, 7 + cmp ebp, edx + jbe short loc_4CB757 + +loc_4CB737: ; CODE XREF: CEncoder_GetOptimumFast+2AEj + ; CEncoder_GetOptimumFast+2BEj ... + mov byte ptr [edi+32F10h], 1 + +loc_4CB73E: ; CODE XREF: CEncoder_GetOptimumFast+26Aj + ; CEncoder_GetOptimumFast+271j + mov edx, [esp+38h+arg_0] + pop ebp + pop edi + pop esi + mov dword ptr [edx], 0FFFFFFFFh + mov eax, 1 + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB757: ; CODE XREF: CEncoder_GetOptimumFast+29Dj + ; CEncoder_GetOptimumFast+2C9j ... + mov eax, [edi+80h] + mov ecx, [edi+74h] + push eax + call ecx + lea ecx, [edi+14h] + add esp, 4 + sub eax, 1 + mov [esp+38h+var_18], 0 + mov ebx, ecx + +loc_4CB776: ; CODE XREF: CEncoder_GetOptimumFast+39Aj + mov dl, [eax+1] + mov ecx, eax + sub ecx, [ebx] + sub ecx, 1 + cmp dl, [ecx+1] + jnz short loc_4CB7DD + mov dl, [eax+2] + cmp dl, [ecx+2] + lea ebp, [eax+2] + jnz short loc_4CB7DD + mov esi, 2 + cmp [esp+38h+var_24], esi + jbe short loc_4CB7B4 + mov edx, ebp + mov ebp, ecx + sub ebp, eax + +loc_4CB7A1: ; CODE XREF: CEncoder_GetOptimumFast+352j + mov cl, [edx] + cmp cl, [edx+ebp] + jnz short loc_4CB7B4 + add esi, 1 + add edx, 1 + cmp esi, [esp+38h+var_24] + jb short loc_4CB7A1 + +loc_4CB7B4: ; CODE XREF: CEncoder_GetOptimumFast+339j + ; CEncoder_GetOptimumFast+346j + add esi, 1 + cmp esi, [esp+38h+var_28] + jb short loc_4CB7E9 + mov eax, [esp+38h+arg_0] + pop ebp + mov byte ptr [edi+32F10h], 1 + pop edi + pop esi + mov dword ptr [eax], 0FFFFFFFFh + mov eax, 1 + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB7DD: ; CODE XREF: CEncoder_GetOptimumFast+323j + ; CEncoder_GetOptimumFast+32Ej + mov edx, [esp+38h+var_18] + mov [esp+edx*4+38h+var_10], 0 + +loc_4CB7E9: ; CODE XREF: CEncoder_GetOptimumFast+35Bj + mov ecx, [esp+38h+var_18] + add ecx, 1 + add ebx, 4 + cmp ecx, 4 + mov [esp+38h+var_18], ecx + jb loc_4CB776 + mov esi, [esp+38h+var_28] + mov ecx, [esp+38h+var_20] + mov edx, [esp+38h+arg_0] + add ecx, 4 + lea eax, [esi-2] + test eax, eax + mov [edx], ecx + jz short loc_4CB82E + add [edi+32F04h], eax + mov ecx, [edi+7Ch] + push eax + mov eax, [edi+80h] + push eax + call ecx + add esp, 8 + +loc_4CB82E: ; CODE XREF: CEncoder_GetOptimumFast+164j + ; CEncoder_GetOptimumFast+23Fj ... + pop ebp + pop edi + mov eax, esi + pop esi + pop ebx + add esp, 28h + retn 4 +CEncoder_GetOptimumFast endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CB8A0 proc near ; CODE XREF: sub_4CD940+37p + +arg_0 = dword ptr 4 + + push edi + mov edi, [esp+4+arg_0] + test edi, edi + jz short loc_4CB8EB + mov eax, dword_553598 + test eax, eax + jnz short loc_4CB8DD + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + test eax, eax + jz short loc_4CB8D6 + mov dword ptr [eax], 0 + mov dword ptr [eax+4], 0 + mov dword ptr [eax+8], 0 + jmp short loc_4CB8D8 +; --------------------------------------------------------------------------- + +loc_4CB8D6: ; CODE XREF: sub_4CB8A0+1Ej + xor eax, eax + +loc_4CB8D8: ; CODE XREF: sub_4CB8A0+34j + mov dword_553598, eax + +loc_4CB8DD: ; CODE XREF: sub_4CB8A0+10j + mov eax, [eax] + test eax, eax + jz short loc_4CB8EB + push edi + call eax + add esp, 4 + pop edi + retn +; --------------------------------------------------------------------------- + +loc_4CB8EB: ; CODE XREF: sub_4CB8A0+7j + ; sub_4CB8A0+41j + xor eax, eax + pop edi + retn +sub_4CB8A0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CB8F0 proc near ; CODE XREF: sub_4CBA60+85p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push esi + mov esi, [esp+4+arg_0] + push edi + mov edi, [esi+44h] + add edi, [esi+40h] + add edi, [esp+8+arg_4] + cmp dword ptr [esi+4Ch], 0 + jz short loc_4CB911 + mov [esi+3Ch], edi + pop edi + mov eax, 1 + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CB911: ; CODE XREF: sub_4CB8F0+14j + mov eax, [esi+30h] + test eax, eax + jz short loc_4CB91D + cmp [esi+3Ch], edi + jz short loc_4CB93E + +loc_4CB91D: ; CODE XREF: sub_4CB8F0+26j + push ebx + mov ebx, [esp+0Ch+arg_8] + push eax + mov eax, [ebx+4] + call eax + mov dword ptr [esi+30h], 0 + mov [esi+3Ch], edi + mov ecx, [ebx] + push edi + call ecx + add esp, 8 + mov [esi+30h], eax + pop ebx + +loc_4CB93E: ; CODE XREF: sub_4CB8F0+2Bj + xor eax, eax + cmp [esi+30h], eax + pop edi + setnz al + pop esi + retn +sub_4CB8F0 endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CB950: ; DATA XREF: sub_4CCAA0+1Co + mov eax, [esp+4] + mov eax, [eax] + retn +; --------------------------------------------------------------------------- + align 10h + +loc_4CB960: ; DATA XREF: sub_4CCAA0+Eo + mov eax, [esp+4] + mov ecx, [eax] + mov edx, [esp+8] + mov al, [edx+ecx] + retn +; --------------------------------------------------------------------------- + align 10h +loc_4CB970: ; DATA XREF: sub_4CCAA0+15o + mov ecx, [esp+4] + +; =============== S U B R O U T I N E ======================================= + +; Attributes: library function + +; public: int __thiscall CRect::Height(void)const +?Height@CRect@@QBEHXZ proc near + mov eax, [ecx+0Ch] + sub eax, [ecx+4] + retn +?Height@CRect@@QBEHXZ endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CB980 proc near ; CODE XREF: sub_4CBC80+46p + ; sub_4CBD50+61p + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + cmp dword ptr [esi+38h], 0 + jnz short loc_4CB9F0 + cmp dword ptr [esi+68h], 0 + jnz short loc_4CB9F0 + mov eax, [esi] + sub eax, [esi+4] + mov ecx, [esi+30h] + add eax, [esi+0Ch] + sub ecx, eax + add ecx, [esi+3Ch] + jz short loc_4CB9F0 + push edi + +loc_4CB9A4: ; CODE XREF: sub_4CB980+63j + mov edx, [esi+34h] + lea edi, [esp+8+arg_0] + push edi + push ecx + push eax + mov eax, [edx] + push edx + call eax + add esp, 10h + test eax, eax + mov [esi+68h], eax + jnz short loc_4CB9EF + mov eax, [esp+8+arg_0] + test eax, eax + jz short loc_4CB9E8 + add [esi+0Ch], eax + mov eax, [esi+0Ch] + sub eax, [esi+4] + cmp eax, [esi+44h] + ja short loc_4CB9EF + mov eax, [esi] + sub eax, [esi+4] + mov ecx, [esi+30h] + add eax, [esi+0Ch] + sub ecx, eax + add ecx, [esi+3Ch] + jnz short loc_4CB9A4 + pop edi + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CB9E8: ; CODE XREF: sub_4CB980+43j + mov dword ptr [esi+38h], 1 + +loc_4CB9EF: ; CODE XREF: sub_4CB980+3Bj + ; sub_4CB980+51j + pop edi + +loc_4CB9F0: ; CODE XREF: sub_4CB980+9j + ; sub_4CB980+Fj ... + pop esi + retn +sub_4CB980 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBA00 proc near ; CODE XREF: sub_4CBD50+58p + +arg_0 = dword ptr 4 + + push ebx + push ebp + push esi + push edi + mov edi, [esp+10h+arg_0] + mov esi, [edi+0Ch] + mov eax, [edi+40h] + sub esi, [edi+4] + mov ebx, [edi] + mov ebp, [edi+30h] + add esi, eax + sub ebx, eax + mov eax, dword_553598 + test eax, eax + jnz short loc_4CBA44 + push 0Ch ; Size + call _operator_new ; operator new(uint) + xor ecx, ecx + add esp, 4 + cmp eax, ecx + jz short loc_4CBA3D + mov [eax], ecx + mov [eax+4], ecx + mov [eax+8], ecx + jmp short loc_4CBA3F +; --------------------------------------------------------------------------- + +loc_4CBA3D: ; CODE XREF: sub_4CBA00+31j + xor eax, eax + +loc_4CBA3F: ; CODE XREF: sub_4CBA00+3Bj + mov dword_553598, eax + +loc_4CBA44: ; CODE XREF: sub_4CBA00+21j + mov eax, [eax+8] + test eax, eax + jz short loc_4CBA53 + push esi + push ebx + push ebp + call eax + add esp, 0Ch + +loc_4CBA53: ; CODE XREF: sub_4CBA00+49j + mov eax, [edi+30h] + add eax, [edi+40h] + mov [edi], eax + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CBA00 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CBA60 proc near ; CODE XREF: sub_4D0270+D2p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h + + push ebx + push esi + push edi + mov edi, [esp+0Ch+arg_4] + cmp edi, 0C0000000h + jbe short loc_4CBAA2 + mov esi, [esp+0Ch+arg_0] + mov eax, [esi+20h] + mov edi, [esp+0Ch+arg_14] + mov ecx, [edi+4] + push eax + call ecx + xor ebx, ebx + add esp, 4 + cmp [esi+4Ch], ebx + mov [esi+20h], ebx + jnz short loc_4CBA9C + mov edx, [esi+30h] + mov eax, [edi+4] + push edx + call eax + add esp, 4 + mov [esi+30h], ebx + +loc_4CBA9C: ; CODE XREF: sub_4CBA60+2Bj + pop edi + pop esi + xor eax, eax + pop ebx + retn +; --------------------------------------------------------------------------- + +loc_4CBAA2: ; CODE XREF: sub_4CBA60+Dj + mov eax, edi + shr eax, 1 + cmp edi, 80000000h + jbe short loc_4CBAB3 + mov eax, edi + shr eax, 2 + +loc_4CBAB3: ; CODE XREF: sub_4CBA60+4Cj + mov ecx, [esp+0Ch+arg_8] + mov esi, [esp+0Ch+arg_0] + mov ebx, [esp+0Ch+arg_C] + lea edx, [edi+ecx+1] + push ebp + mov [esi+40h], edx + mov edx, [esp+10h+arg_10] + add ecx, ebx + lea ebp, [ebx+edx] + add ecx, edx + mov [esi+44h], ebp + mov ebp, [esp+10h+arg_14] + shr ecx, 1 + push ebp + lea eax, [ecx+eax+80000h] + push eax + push esi + call sub_4CB8F0 + add esp, 0Ch + test eax, eax + jz loc_4CBBEA + mov edx, [esi+48h] + mov [esi+1Ch], ebx + xor ebx, ebx + cmp edx, 2 + lea ebp, [edi+1] + mov [esi+5Ch], ebx + jnz short loc_4CBB0F + mov eax, 0FFFFh + jmp short loc_4CBB49 +; --------------------------------------------------------------------------- + +loc_4CBB0F: ; CODE XREF: sub_4CBA60+A6j + lea ecx, [edi-1] + mov eax, ecx + shr eax, 1 + or ecx, eax + mov eax, ecx + shr eax, 2 + or ecx, eax + mov eax, ecx + shr eax, 4 + or ecx, eax + mov eax, ecx + or eax, 1FFFE00h + shr eax, 8 + or eax, ecx + shr eax, 1 + cmp eax, 1000000h + jbe short loc_4CBB49 + cmp edx, 3 + jnz short loc_4CBB47 + mov eax, 0FFFFFFh + jmp short loc_4CBB49 +; --------------------------------------------------------------------------- + +loc_4CBB47: ; CODE XREF: sub_4CBA60+DEj + shr eax, 1 + +loc_4CBB49: ; CODE XREF: sub_4CBA60+ADj + ; sub_4CBA60+D9j ... + mov [esi+28h], eax + add eax, 1 + cmp edx, 2 + jbe short loc_4CBB5B + mov dword ptr [esi+5Ch], 400h + +loc_4CBB5B: ; CODE XREF: sub_4CBA60+F2j + cmp edx, 3 + jbe short loc_4CBB67 + add dword ptr [esi+5Ch], 10000h + +loc_4CBB67: ; CODE XREF: sub_4CBA60+FEj + cmp edx, 4 + jbe short loc_4CBB73 + add dword ptr [esi+5Ch], 100000h + +loc_4CBB73: ; CODE XREF: sub_4CBA60+10Aj + mov ecx, [esi+60h] + mov edx, [esi+5Ch] + add ecx, [esi+64h] + add eax, edx + cmp [esi+50h], ebx + mov [esi+58h], edi + mov [esi+60h], eax + mov [esi+18h], ebp + lea edx, [ebp+ebp+0] + jnz short loc_4CBB92 + mov edx, ebp + +loc_4CBB92: ; CODE XREF: sub_4CBA60+12Ej + lea edi, [eax+edx] + mov eax, [esi+20h] + cmp eax, ebx + mov [esi+64h], edx + jz short loc_4CBBA3 + cmp ecx, edi + jz short loc_4CBBE0 + +loc_4CBBA3: ; CODE XREF: sub_4CBA60+13Dj + mov ebp, [esp+10h+arg_14] + push eax + mov eax, [ebp+4] + call eax + lea eax, ds:0[edi*4] + mov ecx, eax + shr ecx, 2 + add esp, 4 + cmp ecx, edi + mov [esi+20h], ebx + jz short loc_4CBBC7 + xor eax, eax + jmp short loc_4CBBD0 +; --------------------------------------------------------------------------- + +loc_4CBBC7: ; CODE XREF: sub_4CBA60+161j + mov edx, [ebp+0] + push eax + call edx + add esp, 4 + +loc_4CBBD0: ; CODE XREF: sub_4CBA60+165j + cmp eax, ebx + mov [esi+20h], eax + jz short loc_4CBBEC + mov ecx, [esi+60h] + lea edx, [eax+ecx*4] + mov [esi+24h], edx + +loc_4CBBE0: ; CODE XREF: sub_4CBA60+141j + pop ebp + pop edi + pop esi + mov eax, 1 + pop ebx + retn +; --------------------------------------------------------------------------- + +loc_4CBBEA: ; CODE XREF: sub_4CBA60+8Fj + xor ebx, ebx + +loc_4CBBEC: ; CODE XREF: sub_4CBA60+175j + mov eax, [esi+20h] + mov ecx, [ebp+4] + push eax + call ecx + add esp, 4 + cmp [esi+4Ch], ebx + mov [esi+20h], ebx + jnz short loc_4CBC0F + mov edx, [esi+30h] + mov eax, [ebp+4] + push edx + call eax + add esp, 4 + mov [esi+30h], ebx + +loc_4CBC0F: ; CODE XREF: sub_4CBA60+19Ej + pop ebp + pop edi + pop esi + xor eax, eax + pop ebx + retn +sub_4CBA60 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBC20 proc near ; CODE XREF: sub_4CBD50+79p + +arg_0 = dword ptr 4 + + mov eax, [esp+arg_0] + mov edx, [eax+18h] + sub edx, [eax+14h] + push ebx + mov ebx, [eax+4] + or ecx, 0FFFFFFFFh + sub ecx, ebx + cmp edx, ecx + push esi + jnb short loc_4CBC3A + mov ecx, edx + +loc_4CBC3A: ; CODE XREF: sub_4CBC20+16j + mov esi, [eax+0Ch] + sub esi, ebx + push edi + mov edi, [eax+44h] + mov edx, esi + cmp edx, edi + ja short loc_4CBC54 + test edx, edx + jbe short loc_4CBC56 + mov edx, 1 + jmp short loc_4CBC56 +; --------------------------------------------------------------------------- + +loc_4CBC54: ; CODE XREF: sub_4CBC20+27j + sub edx, edi + +loc_4CBC56: ; CODE XREF: sub_4CBC20+2Bj + ; sub_4CBC20+32j + cmp edx, ecx + pop edi + jnb short loc_4CBC5D + mov ecx, edx + +loc_4CBC5D: ; CODE XREF: sub_4CBC20+39j + mov edx, [eax+1Ch] + cmp esi, edx + jbe short loc_4CBC66 + mov esi, edx + +loc_4CBC66: ; CODE XREF: sub_4CBC20+42j + add ebx, ecx + mov [eax+10h], esi + pop esi + mov [eax+8], ebx + pop ebx + retn +sub_4CBC20 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBC80 proc near ; DATA XREF: sub_4CCAA0+8o + +arg_0 = dword ptr 4 + + push ebx + push esi + mov esi, [esp+8+arg_0] + xor eax, eax + cmp [esi+60h], eax + jbe short loc_4CBCA2 + lea ecx, [ecx+0] + +loc_4CBC90: ; CODE XREF: sub_4CBC80+20j + mov ecx, [esi+20h] + mov dword ptr [ecx+eax*4], 0 + add eax, 1 + cmp eax, [esi+60h] + jb short loc_4CBC90 + +loc_4CBCA2: ; CODE XREF: sub_4CBC80+Bj + mov eax, [esi+18h] + mov edx, [esi+30h] + push esi + mov dword ptr [esi+14h], 0 + mov [esi], edx + mov [esi+0Ch], eax + mov [esi+4], eax + mov dword ptr [esi+68h], 0 + mov dword ptr [esi+38h], 0 + call sub_4CB980 + mov eax, [esi+18h] + mov ebx, [esi+4] + sub eax, [esi+14h] + or ecx, 0FFFFFFFFh + sub ecx, ebx + add esp, 4 + cmp eax, ecx + jnb short loc_4CBCE2 + mov ecx, eax + +loc_4CBCE2: ; CODE XREF: sub_4CBC80+5Ej + mov edx, [esi+0Ch] + sub edx, ebx + push edi + mov edi, [esi+44h] + mov eax, edx + cmp eax, edi + ja short loc_4CBCFC + test eax, eax + jbe short loc_4CBCFE + mov eax, 1 + jmp short loc_4CBCFE +; --------------------------------------------------------------------------- + +loc_4CBCFC: ; CODE XREF: sub_4CBC80+6Fj + sub eax, edi + +loc_4CBCFE: ; CODE XREF: sub_4CBC80+73j + ; sub_4CBC80+7Aj + cmp eax, ecx + pop edi + jnb short loc_4CBD05 + mov ecx, eax + +loc_4CBD05: ; CODE XREF: sub_4CBC80+81j + mov eax, edx + mov edx, [esi+1Ch] + cmp eax, edx + jbe short loc_4CBD10 + mov eax, edx + +loc_4CBD10: ; CODE XREF: sub_4CBC80+8Cj + add ebx, ecx + mov [esi+8], ebx + mov [esi+10h], eax + pop esi + pop ebx + retn +sub_4CBC80 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CBD20 proc near ; CODE XREF: sub_4CBD50+26p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push edi + mov edi, [esp+4+arg_8] + xor eax, eax + test edi, edi + jbe short loc_4CBD4C + mov edx, [esp+4+arg_4] + push esi + mov esi, [esp+8+arg_0] + +loc_4CBD34: ; CODE XREF: sub_4CBD20+29j + mov ecx, [edx+eax*4] + cmp ecx, esi + ja short loc_4CBD3F + xor ecx, ecx + jmp short loc_4CBD41 +; --------------------------------------------------------------------------- + +loc_4CBD3F: ; CODE XREF: sub_4CBD20+19j + sub ecx, esi + +loc_4CBD41: ; CODE XREF: sub_4CBD20+1Dj + mov [edx+eax*4], ecx + add eax, 1 + cmp eax, edi + jb short loc_4CBD34 + pop esi + +loc_4CBD4C: ; CODE XREF: sub_4CBD20+9j + pop edi + retn +sub_4CBD20 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + +sub_4CBD50 proc near ; CODE XREF: .text:004CC1A1p + ; .text:004CC20Ap ... + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + cmp dword ptr [esi+4], 0FFFFFFFFh + jnz short loc_4CBD88 + mov eax, [esi+64h] + add eax, [esi+60h] + mov ecx, [esi+20h] + push edi + mov edi, 0FFFFFFFEh + sub edi, [esi+58h] + push eax + push ecx + and edi, 0FFFFFC00h + push edi + call sub_4CBD20 + sub [esi+8], edi + sub [esi+4], edi + add esp, 0Ch + sub [esi+0Ch], edi + pop edi + +loc_4CBD88: ; CODE XREF: sub_4CBD50+9j + cmp dword ptr [esi+38h], 0 + jnz short loc_4CBDB9 + mov edx, [esi+0Ch] + sub edx, [esi+4] + mov eax, [esi+44h] + cmp eax, edx + jnz short loc_4CBDB9 + mov ecx, [esi+3Ch] + add ecx, [esi+30h] + sub ecx, [esi] + cmp ecx, eax + ja short loc_4CBDB0 + push esi + call sub_4CBA00 + add esp, 4 + +loc_4CBDB0: ; CODE XREF: sub_4CBD50+55j + push esi + call sub_4CB980 + add esp, 4 + +loc_4CBDB9: ; CODE XREF: sub_4CBD50+3Cj + ; sub_4CBD50+49j + mov edx, [esi+14h] + cmp edx, [esi+18h] + jnz short loc_4CBDC8 + mov dword ptr [esi+14h], 0 + +loc_4CBDC8: ; CODE XREF: sub_4CBD50+6Fj + push esi + call sub_4CBC20 + add esp, 4 + pop esi + retn +sub_4CBD50 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBDE0 proc near ; CODE XREF: sub_4CC5C0+1B7p + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch +arg_1C = dword ptr 20h +arg_20 = dword ptr 24h +arg_24 = dword ptr 28h + + push ecx + mov edx, [esp+4+arg_4] + mov ecx, [esp+4+arg_10] + mov eax, [esp+4+arg_14] + push ebx + mov [ecx+eax*4], edx + mov ecx, [esp+8+arg_8] + push ebp + push esi + sub ecx, edx + cmp [esp+10h+arg_1C], 0 + push edi + jz loc_4CBEAC + mov ebp, [esp+14h+arg_C] + mov ebx, [esp+14h+arg_24] + jmp short loc_4CBE14 +; --------------------------------------------------------------------------- + align 10h + +loc_4CBE10: ; CODE XREF: sub_4CBDE0+C6j + mov eax, [esp+14h+arg_14] + +loc_4CBE14: ; CODE XREF: sub_4CBDE0+2Dj + mov esi, [esp+14h+arg_18] + sub [esp+14h+arg_1C], 1 + cmp ecx, esi + jnb loc_4CBEAC + mov edx, ebp + sub edx, ecx + cmp eax, ecx + sbb edi, edi + and edi, esi + sub edi, ecx + add edi, eax + mov eax, [esp+14h+arg_10] + mov eax, [eax+edi*4] + mov [esp+14h+arg_4], eax + mov al, [edx+ebx] + cmp al, [ebx+ebp] + jnz short loc_4CBE99 + mov al, [edx] + cmp al, [ebp+0] + jnz short loc_4CBE99 + mov eax, [esp+14h+arg_0] + mov esi, 1 + cmp eax, esi + jz short loc_4CBE7A + sub edx, ebp + lea edi, [ebp+1] + mov [esp+14h+var_4], edx + jmp short loc_4CBE69 +; --------------------------------------------------------------------------- + +loc_4CBE65: ; CODE XREF: sub_4CBDE0+98j + mov edx, [esp+14h+var_4] + +loc_4CBE69: ; CODE XREF: sub_4CBDE0+83j + mov dl, [edx+edi] + cmp dl, [edi] + jnz short loc_4CBE7A + add esi, 1 + add edi, 1 + cmp esi, eax + jnz short loc_4CBE65 + +loc_4CBE7A: ; CODE XREF: sub_4CBDE0+78j + ; sub_4CBDE0+8Ej + cmp ebx, esi + jnb short loc_4CBE99 + mov edx, [esp+14h+arg_20] + mov [edx], esi + add edx, 4 + add ecx, 0FFFFFFFFh + mov [edx], ecx + add edx, 4 + cmp esi, eax + mov ebx, esi + mov [esp+14h+arg_20], edx + jz short loc_4CBEB6 + +loc_4CBE99: ; CODE XREF: sub_4CBDE0+64j + ; sub_4CBDE0+6Bj ... + mov ecx, [esp+14h+arg_8] + sub ecx, [esp+14h+arg_4] + cmp [esp+14h+arg_1C], 0 + jnz loc_4CBE10 + +loc_4CBEAC: ; CODE XREF: sub_4CBDE0+1Fj + ; sub_4CBDE0+3Fj + mov eax, [esp+14h+arg_20] + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn +; --------------------------------------------------------------------------- + +loc_4CBEB6: ; CODE XREF: sub_4CBDE0+B7j + pop edi + pop esi + pop ebp + mov eax, edx + pop ebx + pop ecx + retn +sub_4CBDE0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBEC0 proc near ; CODE XREF: .text:004CC1E7p + ; sub_4CC220+14Ep ... + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch +arg_1C = dword ptr 20h +arg_20 = dword ptr 24h +arg_24 = dword ptr 28h + + sub esp, 10h + mov eax, [esp+10h+arg_10] + mov edx, [esp+10h+arg_8] + sub edx, [esp+10h+arg_4] + push ebx + push ebp + push esi + push edi + mov edi, [esp+20h+arg_14] + lea eax, [eax+edi*8] + lea ecx, [eax+4] + mov [esp+20h+var_C], ecx + xor ecx, ecx + xor ebx, ebx + cmp [esp+20h+arg_1C], ecx + mov ebp, eax + mov [esp+20h+var_10], ebp + mov [esp+20h+var_8], ecx + mov [esp+20h+var_4], ebx + jnz short loc_4CBF24 + +loc_4CBEF9: ; CODE XREF: sub_4CBEC0+6Fj + ; sub_4CBEC0+151j + mov edx, [esp+20h+var_C] + mov eax, [esp+20h+arg_20] + pop edi + pop esi + mov dword ptr [ebp+0], 0 + pop ebp + mov dword ptr [edx], 0 + pop ebx + add esp, 10h + retn +; --------------------------------------------------------------------------- + jmp short loc_4CBF20 +; --------------------------------------------------------------------------- + align 10h + +loc_4CBF20: ; CODE XREF: sub_4CBEC0+56j + ; sub_4CBEC0+14Bj + mov edi, [esp+20h+arg_14] + +loc_4CBF24: ; CODE XREF: sub_4CBEC0+37j + mov eax, [esp+20h+arg_18] + sub [esp+20h+arg_1C], 1 + cmp edx, eax + jnb short loc_4CBEF9 + cmp edi, edx + sbb esi, esi + and esi, eax + mov eax, [esp+20h+arg_10] + sub esi, edx + add esi, edi + lea eax, [eax+esi*8] + mov esi, [esp+20h+arg_C] + sub esi, edx + cmp ecx, ebx + jb short loc_4CBF4E + mov ecx, ebx + +loc_4CBF4E: ; CODE XREF: sub_4CBEC0+8Aj + mov bl, [ecx+esi] + mov edi, [esp+20h+arg_C] + cmp bl, [ecx+edi] + jnz short loc_4CBFB8 + add ecx, 1 + cmp ecx, [esp+20h+arg_0] + jz short loc_4CBF93 + mov bl, [ecx+esi] + cmp bl, [ecx+edi] + jnz short loc_4CBF93 + add ecx, 1 + cmp ecx, [esp+20h+arg_0] + jz short loc_4CBF93 + mov ebx, edi + mov ebp, esi + lea edi, [ecx+ebx] + sub ebp, ebx + lea ecx, [ecx+0] + +loc_4CBF80: ; CODE XREF: sub_4CBEC0+D1j + mov bl, [edi+ebp] + cmp bl, [edi] + jnz short loc_4CBF93 + add ecx, 1 + add edi, 1 + cmp ecx, [esp+20h+arg_0] + jnz short loc_4CBF80 + +loc_4CBF93: ; CODE XREF: sub_4CBEC0+A1j + ; sub_4CBEC0+A9j ... + cmp [esp+20h+arg_24], ecx + jnb short loc_4CBFB8 + mov edi, [esp+20h+arg_20] + mov [edi], ecx + add edi, 4 + add edx, 0FFFFFFFFh + mov [edi], edx + add edi, 4 + cmp ecx, [esp+20h+arg_0] + mov [esp+20h+arg_24], ecx + mov [esp+20h+arg_20], edi + jz short loc_4CC016 + +loc_4CBFB8: ; CODE XREF: sub_4CBEC0+98j + ; sub_4CBEC0+D7j + mov dl, [ecx+esi] + mov esi, [esp+20h+arg_C] + cmp dl, [ecx+esi] + mov edx, [esp+20h+arg_4] + jnb short loc_4CBFE4 + mov esi, [esp+20h+var_10] + lea ebp, [eax+4] + mov ebx, ecx + mov ecx, [esp+20h+var_8] + mov [esi], edx + mov eax, [ebp+0] + mov [esp+20h+var_10], ebp + mov [esp+20h+var_4], ebx + jmp short loc_4CBFFC +; --------------------------------------------------------------------------- + +loc_4CBFE4: ; CODE XREF: sub_4CBEC0+106j + mov esi, [esp+20h+var_C] + mov ebp, [esp+20h+var_10] + mov ebx, [esp+20h+var_4] + mov [esi], edx + mov [esp+20h+var_C], eax + mov eax, [eax] + mov [esp+20h+var_8], ecx + +loc_4CBFFC: ; CODE XREF: sub_4CBEC0+122j + mov edx, [esp+20h+arg_8] + sub edx, eax + cmp [esp+20h+arg_1C], 0 + mov [esp+20h+arg_4], eax + jnz loc_4CBF20 + jmp loc_4CBEF9 +; --------------------------------------------------------------------------- + +loc_4CC016: ; CODE XREF: sub_4CBEC0+F6j + mov ecx, [eax] + mov edx, [esp+20h+var_10] + mov [edx], ecx + mov eax, [eax+4] + mov ecx, [esp+20h+var_C] + mov [ecx], eax + mov eax, edi + pop edi + pop esi + pop ebp + pop ebx + add esp, 10h + retn +sub_4CBEC0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CC040 proc near ; CODE XREF: sub_4CC220+F8p + ; sub_4CC3B0+173p ... + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch +arg_1C = dword ptr 20h + + sub esp, 10h + mov eax, [esp+10h+arg_10] + mov edx, [esp+10h+arg_4] + push ebx + push ebp + push esi + mov esi, [esp+1Ch+arg_14] + lea eax, [eax+esi*8] + lea ecx, [eax+4] + push edi + mov edi, eax + mov eax, [esp+20h+arg_8] + xor ebx, ebx + xor ebp, ebp + sub eax, edx + cmp [esp+20h+arg_1C], ebx + mov [esp+20h+var_C], ecx + mov [esp+20h+var_10], edi + mov [esp+20h+var_8], ebx + mov [esp+20h+var_4], ebp + jz loc_4CC159 + nop + +loc_4CC080: ; CODE XREF: sub_4CC040+114j + sub [esp+20h+arg_1C], 1 + cmp eax, [esp+20h+arg_18] + jnb loc_4CC159 + cmp esi, eax + sbb ecx, ecx + and ecx, [esp+20h+arg_18] + sub ecx, eax + add ecx, esi + mov esi, [esp+20h+arg_10] + lea edi, [esi+ecx*8] + mov ecx, [esp+20h+arg_C] + sub ecx, eax + cmp ebx, ebp + mov eax, ebx + jb short loc_4CC0B0 + mov eax, ebp + +loc_4CC0B0: ; CODE XREF: sub_4CC040+6Cj + mov bl, [eax+ecx] + mov esi, [esp+20h+arg_C] + cmp bl, [eax+esi] + jnz short loc_4CC102 + add eax, 1 + cmp eax, [esp+20h+arg_0] + jz short loc_4CC0E3 + mov ebx, esi + mov ebp, ecx + lea esi, [eax+ebx] + sub ebp, ebx + mov edi, edi + +loc_4CC0D0: ; CODE XREF: sub_4CC040+A1j + mov bl, [esi+ebp] + cmp bl, [esi] + jnz short loc_4CC0FC + add eax, 1 + add esi, 1 + cmp eax, [esp+20h+arg_0] + jnz short loc_4CC0D0 + +loc_4CC0E3: ; CODE XREF: sub_4CC040+83j + ; sub_4CC040+C0j + mov edx, [edi] + mov eax, [esp+20h+var_10] + mov [eax], edx + mov ecx, [edi+4] + mov edx, [esp+20h+var_C] + pop edi + pop esi + pop ebp + mov [edx], ecx + pop ebx + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC0FC: ; CODE XREF: sub_4CC040+95j + cmp eax, [esp+20h+arg_0] + jz short loc_4CC0E3 + +loc_4CC102: ; CODE XREF: sub_4CC040+7Aj + mov cl, [eax+ecx] + mov esi, [esp+20h+arg_C] + cmp cl, [eax+esi] + jnb short loc_4CC129 + mov ecx, [esp+20h+var_10] + mov ebx, [esp+20h+var_8] + add edi, 4 + mov ebp, eax + mov [ecx], edx + mov edx, [edi] + mov [esp+20h+var_10], edi + mov [esp+20h+var_4], ebp + jmp short loc_4CC143 +; --------------------------------------------------------------------------- + +loc_4CC129: ; CODE XREF: sub_4CC040+CCj + mov ecx, [esp+20h+var_C] + mov ebp, [esp+20h+var_4] + mov [ecx], edx + mov edx, [edi] + mov ebx, eax + mov [esp+20h+var_C], edi + mov edi, [esp+20h+var_10] + mov [esp+20h+var_8], ebx + +loc_4CC143: ; CODE XREF: sub_4CC040+E7j + mov eax, [esp+20h+arg_8] + sub eax, edx + cmp [esp+20h+arg_1C], 0 + jz short loc_4CC159 + mov esi, [esp+20h+arg_14] + jmp loc_4CC080 +; --------------------------------------------------------------------------- + +loc_4CC159: ; CODE XREF: sub_4CC040+39j + ; sub_4CC040+49j ... + mov eax, [esp+20h+var_C] + mov dword ptr [edi], 0 + pop edi + pop esi + pop ebp + mov dword ptr [eax], 0 + pop ebx + add esp, 10h + retn +sub_4CC040 endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CC180: ; DATA XREF: sub_4CCAA0+40o + push esi + mov esi, [esp+8] + mov edx, [esi+10h] + cmp edx, 2 + jnb short loc_4CC1AD + add dword ptr [esi+4], 1 + mov eax, [esi+4] + add dword ptr [esi+14h], 1 + add dword ptr [esi], 1 + cmp eax, [esi+8] + jnz short loc_4CC1A9 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC1A9: ; CODE XREF: .text:004CC19Ej + xor eax, eax + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CC1AD: ; CODE XREF: .text:004CC18Bj + mov eax, [esi] + xor ecx, ecx + mov ch, [eax+1] + push ebx + mov ebx, [esp+10h] + push edi + mov edi, [esi+4] + push 1 + push ebx + mov cl, [eax] + mov eax, ecx + mov ecx, [esi+20h] + lea eax, [ecx+eax*4] + mov ecx, [eax] + mov [eax], edi + mov eax, [esi+2Ch] + push eax + mov eax, [esi+18h] + push eax + mov eax, [esi+14h] + push eax + mov eax, [esi+24h] + push eax + mov eax, [esi] + push eax + mov eax, [esi+4] + push eax + push ecx + push edx + call sub_4CBEC0 + add dword ptr [esi+4], 1 + add dword ptr [esi+14h], 1 + add dword ptr [esi], 1 + mov edi, eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC212 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC212: ; CODE XREF: .text:004CC207j + mov eax, edi + pop edi + pop ebx + pop esi + retn + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC220 proc near ; DATA XREF: sub_4CCAA0+54o + +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 8 + push esi + mov esi, [esp+0Ch+arg_0] + mov eax, [esi+10h] + cmp eax, 3 + mov [esp+0Ch+arg_0], eax + jnb short loc_4CC259 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC252 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC252: ; CODE XREF: sub_4CC220+27j + xor eax, eax + pop esi + add esp, 8 + retn +; --------------------------------------------------------------------------- + +loc_4CC259: ; CODE XREF: sub_4CC220+12j + push ebx + mov ebx, [esi+20h] + push ebp + xor edx, edx + push edi + mov edi, [esi] + mov dh, [edi+2] + movzx ecx, byte ptr [edi] + movzx eax, byte ptr [edi+1] + xor eax, dword_553198[ecx*4] + xor edx, eax + and edx, [esi+28h] + mov ecx, eax + mov ebp, [ebx+edx*4+1000h] + mov eax, [esi+4] + and ecx, 3FFh + sub eax, [ebx+ecx*4] + mov [esp+18h+var_8], ebp + mov ebp, [esi+4] + mov [ebx+edx*4+1000h], ebp + mov ebx, [esi+20h] + mov edx, [ebx+edx*4+1000h] + mov [ebx+ecx*4], edx + mov ebx, [esp+18h+arg_4] + xor ebp, ebp + cmp eax, [esi+18h] + mov ecx, 2 + jnb loc_4CC348 + mov edx, edi + sub edx, eax + mov [esp+18h+var_4], edx + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC348 + mov edx, [esp+18h+arg_0] + cmp edx, ecx + jz short loc_4CC2EA + +loc_4CC2D3: ; CODE XREF: sub_4CC220+C4j + mov ebx, [esp+18h+var_4] + mov bl, [ebx+ecx] + cmp bl, [ecx+edi] + jnz short loc_4CC2E6 + add ecx, 1 + cmp ecx, edx + jnz short loc_4CC2D3 + +loc_4CC2E6: ; CODE XREF: sub_4CC220+BDj + mov ebx, [esp+18h+arg_4] + +loc_4CC2EA: ; CODE XREF: sub_4CC220+B1j + add eax, 0FFFFFFFFh + cmp ecx, edx + mov [ebx], ecx + mov [ebx+4], eax + mov ebp, 2 + jnz short loc_4CC34C + mov eax, [esi+2Ch] + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+2Ch+var_8] + push ecx + push eax + push edx + call sub_4CC040 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + add esp, 20h + cmp eax, [esi+8] + jnz short loc_4CC33E + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC33E: ; CODE XREF: sub_4CC220+113j + pop edi + mov eax, ebp + pop ebp + pop ebx + pop esi + add esp, 8 + retn +; --------------------------------------------------------------------------- + +loc_4CC348: ; CODE XREF: sub_4CC220+97j + ; sub_4CC220+A9j + mov edx, [esp+18h+arg_0] + +loc_4CC34C: ; CODE XREF: sub_4CC220+D9j + mov eax, [esi+2Ch] + push ecx + lea ecx, [ebx+ebp*4] + push ecx + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+34h+var_8] + push ecx + push eax + push edx + call sub_4CBEC0 + mov edi, eax + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC39B + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC39B: ; CODE XREF: sub_4CC220+170j + mov eax, edi + pop edi + pop ebp + pop ebx + pop esi + add esp, 8 + retn +sub_4CC220 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC3B0 proc near ; DATA XREF: sub_4CCAA0:loc_4CCB03o + +var_10 = dword ptr -10h +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 10h + push esi + mov esi, [esp+14h+arg_0] + mov eax, [esi+10h] + cmp eax, 4 + mov [esp+14h+arg_0], eax + jnb short loc_4CC3E9 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC3E2 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC3E2: ; CODE XREF: sub_4CC3B0+27j + xor eax, eax + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC3E9: ; CODE XREF: sub_4CC3B0+12j + push ebx + push ebp + push edi + mov edi, [esi] + movzx eax, byte ptr [edi] + movzx edx, byte ptr [edi+1] + xor edx, dword_553198[eax*4] + movzx eax, byte ptr [edi+2] + movzx ebp, byte ptr [edi+3] + mov ecx, eax + add eax, eax + add eax, eax + add eax, eax + xor eax, dword_553198[ebp*4] + mov ebp, [esi+4] + shl eax, 5 + shl ecx, 8 + xor eax, edx + and eax, [esi+28h] + xor ecx, edx + mov ebx, edx + mov edx, [esi+20h] + and ebx, 3FFh + sub ebp, [edx+ebx*4] + and ecx, 0FFFFh + mov [esp+20h+var_4], ebp + mov ebp, [esi+4] + sub ebp, [edx+ecx*4+1000h] + mov [esp+20h+var_10], ebp + mov ebp, [edx+eax*4+41000h] + mov [esp+20h+var_8], ebp + mov ebp, [esi+4] + mov [edx+eax*4+41000h], ebp + mov edx, [esi+20h] + mov eax, [edx+eax*4+41000h] + mov [edx+ecx*4+1000h], eax + mov eax, [esi+20h] + mov ecx, [eax+ecx*4+1000h] + mov [eax+ebx*4], ecx + mov ecx, [esp+20h+var_4] + mov ebx, [esp+20h+arg_4] + xor ebp, ebp + cmp ecx, [esi+18h] + mov eax, 1 + jnb short loc_4CC4A9 + mov edx, edi + sub edx, ecx + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC4A9 + mov eax, 2 + lea edx, [ecx-1] + mov [ebx], eax + mov [ebx+4], edx + mov ebp, eax + +loc_4CC4A9: ; CODE XREF: sub_4CC3B0+DEj + ; sub_4CC3B0+E8j + mov edx, [esp+20h+var_10] + cmp ecx, edx + jz short loc_4CC4D5 + cmp edx, [esi+18h] + jnb short loc_4CC4D5 + mov edx, edi + sub edx, [esp+20h+var_10] + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC4D5 + mov ecx, [esp+20h+var_10] + lea edx, [ecx-1] + mov [ebx+ebp*4+4], edx + mov eax, 3 + add ebp, 2 + +loc_4CC4D5: ; CODE XREF: sub_4CC3B0+FFj + ; sub_4CC3B0+104j ... + test ebp, ebp + mov edx, [esp+20h+arg_0] + jz short loc_4CC553 + cmp eax, edx + jz short loc_4CC4FE + mov edx, eax + sub edx, ecx + add edx, edi + +loc_4CC4E7: ; CODE XREF: sub_4CC3B0+148j + mov cl, [edx] + cmp cl, [eax+edi] + jnz short loc_4CC4FA + add eax, 1 + add edx, 1 + cmp eax, [esp+20h+arg_0] + jnz short loc_4CC4E7 + +loc_4CC4FA: ; CODE XREF: sub_4CC3B0+13Cj + mov edx, [esp+20h+arg_0] + +loc_4CC4FE: ; CODE XREF: sub_4CC3B0+12Fj + cmp eax, edx + mov [ebx+ebp*4-8], eax + jnz short loc_4CC553 + mov eax, [esi+2Ch] + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+34h+var_8] + push ecx + push eax + push edx + call sub_4CC040 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + add esp, 20h + cmp eax, [esi+8] + jnz short loc_4CC549 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC549: ; CODE XREF: sub_4CC3B0+18Ej + pop edi + mov eax, ebp + pop ebp + pop ebx + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC553: ; CODE XREF: sub_4CC3B0+12Bj + ; sub_4CC3B0+154j + cmp eax, 3 + jnb short loc_4CC55D + mov eax, 3 + +loc_4CC55D: ; CODE XREF: sub_4CC3B0+1A6j + push eax + mov eax, [esi+2Ch] + lea ecx, [ebx+ebp*4] + push ecx + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+3Ch+var_8] + push ecx + push eax + push edx + call sub_4CBEC0 + mov edi, eax + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC5AC + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC5AC: ; CODE XREF: sub_4CC3B0+1F1j + mov eax, edi + pop edi + pop ebp + pop ebx + pop esi + add esp, 10h + retn +sub_4CC3B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC5C0 proc near ; DATA XREF: sub_4CCAA0+29o + +var_10 = dword ptr -10h +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 10h + push esi + mov esi, [esp+14h+arg_0] + mov eax, [esi+10h] + cmp eax, 4 + mov [esp+14h+arg_0], eax + jnb short loc_4CC5F9 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC5F2 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC5F2: ; CODE XREF: sub_4CC5C0+27j + xor eax, eax + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC5F9: ; CODE XREF: sub_4CC5C0+12j + push ebx + push ebp + push edi + mov edi, [esi] + movzx eax, byte ptr [edi] + movzx edx, byte ptr [edi+1] + xor edx, dword_553198[eax*4] + movzx eax, byte ptr [edi+2] + movzx ebp, byte ptr [edi+3] + mov ecx, eax + add eax, eax + add eax, eax + add eax, eax + xor eax, dword_553198[ebp*4] + mov ebp, [esi+4] + shl eax, 5 + shl ecx, 8 + xor eax, edx + and eax, [esi+28h] + xor ecx, edx + mov ebx, edx + mov edx, [esi+20h] + and ebx, 3FFh + sub ebp, [edx+ebx*4] + and ecx, 0FFFFh + mov [esp+20h+var_4], ebp + mov ebp, [esi+4] + sub ebp, [edx+ecx*4+1000h] + mov [esp+20h+var_10], ebp + mov ebp, [edx+eax*4+41000h] + mov [esp+20h+var_8], ebp + mov ebp, [esi+4] + mov [edx+eax*4+41000h], ebp + mov edx, [esi+20h] + mov eax, [edx+eax*4+41000h] + mov [edx+ecx*4+1000h], eax + mov eax, [esi+20h] + mov ecx, [eax+ecx*4+1000h] + mov [eax+ebx*4], ecx + mov ecx, [esp+20h+var_4] + mov ebx, [esp+20h+arg_4] + xor ebp, ebp + cmp ecx, [esi+18h] + mov eax, 1 + jnb short loc_4CC6B9 + mov edx, edi + sub edx, ecx + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC6B9 + mov eax, 2 + lea edx, [ecx-1] + mov [ebx], eax + mov [ebx+4], edx + mov ebp, eax + +loc_4CC6B9: ; CODE XREF: sub_4CC5C0+DEj + ; sub_4CC5C0+E8j + mov edx, [esp+20h+var_10] + cmp ecx, edx + jz short loc_4CC6E5 + cmp edx, [esi+18h] + jnb short loc_4CC6E5 + mov edx, edi + sub edx, [esp+20h+var_10] + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC6E5 + mov ecx, [esp+20h+var_10] + lea edx, [ecx-1] + mov [ebx+ebp*4+4], edx + mov eax, 3 + add ebp, 2 + +loc_4CC6E5: ; CODE XREF: sub_4CC5C0+FFj + ; sub_4CC5C0+104j ... + test ebp, ebp + jz short loc_4CC747 + cmp eax, [esp+20h+arg_0] + jz short loc_4CC708 + mov edx, eax + sub edx, ecx + add edx, edi + +loc_4CC6F5: ; CODE XREF: sub_4CC5C0+146j + mov cl, [edx] + cmp cl, [eax+edi] + jnz short loc_4CC708 + add eax, 1 + add edx, 1 + cmp eax, [esp+20h+arg_0] + jnz short loc_4CC6F5 + +loc_4CC708: ; CODE XREF: sub_4CC5C0+12Dj + ; sub_4CC5C0+13Aj + cmp eax, [esp+20h+arg_0] + mov [ebx+ebp*4-8], eax + jnz short loc_4CC747 + mov edx, [esi+14h] + mov eax, [esi+24h] + mov ecx, [esp+20h+var_8] + mov [eax+edx*4], ecx + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC73D + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC73D: ; CODE XREF: sub_4CC5C0+172j + pop edi + mov eax, ebp + pop ebp + pop ebx + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC747: ; CODE XREF: sub_4CC5C0+127j + ; sub_4CC5C0+150j + cmp eax, 3 + jnb short loc_4CC751 + mov eax, 3 + +loc_4CC751: ; CODE XREF: sub_4CC5C0+18Aj + mov ecx, [esi+18h] + push eax + mov eax, [esi+2Ch] + lea edx, [ebx+ebp*4] + push edx + mov edx, [esi+14h] + push eax + mov eax, [esi+24h] + push ecx + mov ecx, [esi] + push edx + mov edx, [esi+4] + push eax + mov eax, [esp+38h+var_8] + push ecx + mov ecx, [esp+3Ch+arg_0] + push edx + push eax + push ecx + call sub_4CBDE0 + mov edi, eax + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC7A4 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC7A4: ; CODE XREF: sub_4CC5C0+1D9j + mov eax, edi + pop edi + pop ebp + pop ebx + pop esi + add esp, 10h + retn +sub_4CC5C0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC7B0 proc near ; DATA XREF: sub_4CCAA0+47o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + mov ebp, [esp+8+arg_4] + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + +loc_4CC7C1: ; CODE XREF: sub_4CC7B0+6Dj + mov edx, [esi+10h] + cmp edx, 2 + jb short loc_4CC802 + mov eax, [esi] + mov ebx, [esi+4] + xor ecx, ecx + mov ch, [eax+1] + mov cl, [eax] + mov eax, ecx + mov ecx, [esi+20h] + lea eax, [ecx+eax*4] + mov ecx, [eax] + mov [eax], ebx + mov eax, [esi+2Ch] + push eax + mov eax, [esi+18h] + push eax + mov eax, [esi+14h] + push eax + mov eax, [esi+24h] + push eax + mov eax, [esi] + push eax + mov eax, [esi+4] + push eax + push ecx + push edx + call sub_4CC040 + add esp, 20h + +loc_4CC802: ; CODE XREF: sub_4CC7B0+17j + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CC81B + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC81B: ; CODE XREF: sub_4CC7B0+60j + sub ebp, edi + jnz short loc_4CC7C1 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC7B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC830 proc near ; DATA XREF: sub_4CCAA0+5Bo + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + lea ecx, [ecx+0] + +loc_4CC840: ; CODE XREF: sub_4CC830+9Fj + mov ebp, [esi+10h] + cmp ebp, 3 + jb short loc_4CC8B2 + mov ecx, [esi] + movzx edx, byte ptr [ecx] + movzx eax, byte ptr [ecx+1] + xor eax, dword_553198[edx*4] + mov ebx, [esi+4] + xor edx, edx + mov dh, [ecx+2] + xor edx, eax + and edx, [esi+28h] + and eax, 3FFh + mov ecx, edx + mov edx, [esi+20h] + mov edi, [edx+ecx*4+1000h] + lea edx, [edx+ecx*4+1000h] + mov [edx], ebx + mov edx, [esi+20h] + mov ecx, [edx+ecx*4+1000h] + mov [edx+eax*4], ecx + mov edx, [esi+2Ch] + mov eax, [esi+18h] + mov ecx, [esi+14h] + push edx + mov edx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push edx + push eax + push ecx + push edi + push ebp + call sub_4CC040 + add esp, 20h + mov edi, 1 + +loc_4CC8B2: ; CODE XREF: sub_4CC830+16j + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CC8CB + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC8CB: ; CODE XREF: sub_4CC830+90j + sub [esp+10h+arg_4], edi + jnz loc_4CC840 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC830 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC8E0 proc near ; DATA XREF: sub_4CCAA0+6Ao + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + lea ecx, [ecx+0] + +loc_4CC8F0: ; CODE XREF: sub_4CC8E0+D6j + mov eax, [esi+10h] + cmp eax, 4 + mov [esp+10h+arg_0], eax + jb loc_4CC999 + mov eax, [esi] + movzx edi, byte ptr [eax+2] + movzx edx, byte ptr [eax] + movzx ebx, byte ptr [eax+3] + movzx ecx, byte ptr [eax+1] + xor ecx, dword_553198[edx*4] + mov ebp, [esi+4] + lea eax, ds:0[edi*8] + xor eax, dword_553198[ebx*4] + mov edx, edi + mov edi, [esi+20h] + shl eax, 5 + xor eax, ecx + and eax, [esi+28h] + shl edx, 8 + mov ebx, [edi+eax*4+41000h] + xor edx, ecx + and edx, 0FFFFh + mov [edi+edx*4+1000h], ebp + mov edi, [esi+20h] + mov edx, [edi+edx*4+1000h] + and ecx, 3FFh + mov [edi+ecx*4], edx + mov ecx, [esi+20h] + mov edx, [esi+4] + mov [ecx+eax*4+41000h], edx + mov eax, [esi+2Ch] + mov ecx, [esi+18h] + mov edx, [esi+14h] + push eax + mov eax, [esi+24h] + push ecx + mov ecx, [esi] + push edx + mov edx, [esi+4] + push eax + mov eax, [esp+20h+arg_0] + push ecx + push edx + push ebx + push eax + call sub_4CC040 + add esp, 20h + mov edi, 1 + +loc_4CC999: ; CODE XREF: sub_4CC8E0+1Aj + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CC9B2 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC9B2: ; CODE XREF: sub_4CC8E0+C7j + sub [esp+10h+arg_4], edi + jnz loc_4CC8F0 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC8E0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC9D0 proc near ; DATA XREF: sub_4CCAA0+30o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + lea ecx, [ecx+0] + +loc_4CC9E0: ; CODE XREF: sub_4CC9D0+BAj + cmp dword ptr [esi+10h], 4 + jb loc_4CCA6D + mov eax, [esi] + movzx edi, byte ptr [eax+2] + movzx edx, byte ptr [eax] + movzx ebx, byte ptr [eax+3] + movzx ecx, byte ptr [eax+1] + xor ecx, dword_553198[edx*4] + mov ebp, [esi+4] + lea eax, ds:0[edi*8] + xor eax, dword_553198[ebx*4] + mov edx, edi + mov edi, [esi+20h] + shl eax, 5 + xor eax, ecx + and eax, [esi+28h] + mov ebx, [edi+eax*4+41000h] + lea edi, [edi+eax*4+41000h] + mov [edi], ebp + mov edi, [esi+20h] + mov eax, [edi+eax*4+41000h] + shl edx, 8 + xor edx, ecx + and edx, 0FFFFh + mov [edi+edx*4+1000h], eax + mov eax, [esi+20h] + mov edx, [eax+edx*4+1000h] + and ecx, 3FFh + mov [eax+ecx*4], edx + mov eax, [esi+14h] + mov ecx, [esi+24h] + mov [ecx+eax*4], ebx + mov edi, 1 + +loc_4CCA6D: ; CODE XREF: sub_4CC9D0+14j + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CCA86 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CCA86: ; CODE XREF: sub_4CC9D0+ABj + sub [esp+10h+arg_4], edi + jnz loc_4CC9E0 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC9D0 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CCAA0 proc near ; CODE XREF: sub_4D0270+F3p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + mov eax, [esp+arg_4] + mov ecx, [esp+arg_0] + mov dword ptr [eax], offset sub_4CBC80 + mov dword ptr [eax+4], offset loc_4CB960 + mov dword ptr [eax+8], offset loc_4CB970 + mov dword ptr [eax+0Ch], offset loc_4CB950 + cmp dword ptr [ecx+50h], 0 + jnz short loc_4CCAD8 + mov dword ptr [eax+10h], offset sub_4CC5C0 + mov dword ptr [eax+14h], offset sub_4CC9D0 + retn +; --------------------------------------------------------------------------- + +loc_4CCAD8: ; CODE XREF: sub_4CCAA0+27j + mov ecx, [ecx+48h] + cmp ecx, 2 + jnz short loc_4CCAEF + mov dword ptr [eax+10h], offset loc_4CC180 + mov dword ptr [eax+14h], offset sub_4CC7B0 + retn +; --------------------------------------------------------------------------- + +loc_4CCAEF: ; CODE XREF: sub_4CCAA0+3Ej + cmp ecx, 3 + jnz short loc_4CCB03 + mov dword ptr [eax+10h], offset sub_4CC220 + mov dword ptr [eax+14h], offset sub_4CC830 + retn +; --------------------------------------------------------------------------- + +loc_4CCB03: ; CODE XREF: sub_4CCAA0+52j + mov dword ptr [eax+10h], offset sub_4CC3B0 + mov dword ptr [eax+14h], offset sub_4CC8E0 + retn +sub_4CCAA0 endp + +; --------------------------------------------------------------------------- + +Interface1_AddRef proc near ; DATA XREF: .rdata:00517A94o +;sub_4CCB80 + +arg_0 = dword ptr 4 + mov eax, [esp+arg_0] + add dword ptr [eax+4], 1 + mov eax, [eax+4] + retn 4 +Interface1_AddRef endp + +; --------------------------------------------------------------------------- + +sub_4CCB20 proc near ; DATA XREF: .rdata:00517A9Co + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + push esi + mov esi, [esp+4+arg_0] + mov ecx, [esi+10h] + sub ecx, [esi+18h] + mov eax, [esi+14h] + sbb eax, [esi+1Ch] + xor edx, edx + cmp edx, eax + push edi + mov edi, [esp+8+arg_8] + jb short loc_4CCB48 + ja short loc_4CCB42 + cmp edi, ecx + jbe short loc_4CCB48 + +loc_4CCB42: ; CODE XREF: sub_4CCB20+1Cj + mov edi, [esi+10h] + sub edi, [esi+18h] + +loc_4CCB48: ; CODE XREF: sub_4CCB20+1Aj + ; sub_4CCB20+20j + mov eax, [esp+8+arg_C] + test eax, eax + jz short loc_4CCB52 + mov [eax], edi + +loc_4CCB52: ; CODE XREF: sub_4CCB20+2Ej + test edi, edi + jz short loc_4CCB72 + mov eax, [esi+8] + add eax, [esi+18h] + mov ecx, [esp+8+arg_4] + push edi ; size_t + push eax ; void * + push ecx ; void * + call _memcpy ; Microsoft VisualC 2-8/net runtime + add esp, 0Ch + add [esi+18h], edi + adc dword ptr [esi+1Ch], 0 + +loc_4CCB72: ; CODE XREF: sub_4CCB20+34j + pop edi + xor eax, eax + pop esi + retn 10h +sub_4CCB20 endp + +; --------------------------------------------------------------------------- + +sub_4CCB90 proc near ; DATA XREF: .rdata:00517AB0o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + push ebx + mov ebx, [esp+4+arg_8] + push esi + mov esi, [esp+8+arg_0] + mov ecx, [esi+10h] + mov eax, [esi+14h] + push edi + xor edi, edi + sub ecx, [esi+18h] + sbb eax, [esi+1Ch] + cmp edi, eax + jb short loc_4CCBC2 + ja short loc_4CCBB3 + cmp ebx, ecx + jbe short loc_4CCBC2 + +loc_4CCBB3: ; CODE XREF: sub_4CCB90+1Dj + pop edi + mov byte ptr [esi+20h], 1 + pop esi + mov eax, 80004005h + pop ebx + retn 10h + +loc_4CCBC2: ; CODE XREF: sub_4CCB90+1Bj + ; sub_4CCB90+21j + mov ecx, [esi+8] + mov eax, [esp+0Ch+arg_4] + add ecx, [esi+18h] + push ebx ; size_t + push eax ; void * + push ecx ; void * + call _memcpy ; Microsoft VisualC 2-8/net runtime + mov eax, [esp+18h+arg_C] + add esp, 0Ch + add [esi+18h], ebx + adc [esi+1Ch], edi + test eax, eax + jz short loc_4CCBE7 + mov [eax], ebx + +loc_4CCBE7: ; CODE XREF: sub_4CCB90+53j + pop edi + pop esi + xor eax, eax + pop ebx + retn 10h +sub_4CCB90 endp + +; --------------------------------------------------------------------------- + align 10h +; --------------------------------------------------------------------------- + +LzmaProps_Decode proc near ; CODE XREF: Decompress_lzma_internal+35p +;sub_4CCBF0 + +propsRes = dword ptr 4 +propsData = dword ptr 8 +propsSize = dword ptr 0Ch + + cmp [esp+propsSize], 5 ; LZMA_PROPS_SIZE + jge short loc_4CCBFD + +loc_4CCBF7: ; CODE XREF: LzmaProps_Decode+16j + mov eax, 1 + retn +; --------------------------------------------------------------------------- + +loc_4CCBFD: ; CODE XREF: LzmaProps_Decode+5j + mov eax, [esp+propsData] + mov cl, [eax] + cmp cl, 0E1h ; 9 * 5 * 5 + jnb short loc_4CCBF7 + cmp cl, 2Dh + push edi + mov edi, [esp+4+propsRes] + mov dword ptr [edi+8], 0 + jb short loc_4CCC40 + push esi + movzx esi, cl + mov eax, 6C16C16Dh + mul esi + mov eax, esi + sub eax, edx + shr eax, 1 + add eax, edx + shr eax, 5 + movzx eax, al + mov edx, eax + pop esi + +loc_4CCC35: ; CODE XREF: LzmaProps_Decode+4Bj + add cl, 0D3h + sub eax, 1 + jnz short loc_4CCC35 + mov [edi+8], edx + +loc_4CCC40: ; CODE XREF: LzmaProps_Decode+27j + cmp cl, 9 + mov dword ptr [edi+4], 0 + jb short loc_4CCC6B + movzx edx, cl + mov eax, 38E38E39h + mul edx + shr edx, 1 + movzx eax, dl + mov edx, eax + lea ecx, [ecx+0] + +loc_4CCC60: ; CODE XREF: LzmaProps_Decode+76j + add cl, 0F7h + sub eax, 1 + jnz short loc_4CCC60 + mov [edi+4], edx + +loc_4CCC6B: ; CODE XREF: LzmaProps_Decode+5Aj + movzx eax, cl + mov [edi], eax + xor eax, eax + pop edi + retn +LzmaProps_Decode endp + +sub_4CCC80 proc near ; CODE XREF: Decompress_lzma_internal+97p + +var_3C = dword ptr -3Ch +var_38 = dword ptr -38h +var_34 = dword ptr -34h +var_30 = dword ptr -30h +var_2C = dword ptr -2Ch +var_28 = dword ptr -28h +var_24 = dword ptr -24h +var_20 = dword ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch + + sub esp, 3Ch + mov eax, [esp+3Ch+arg_0] + mov ecx, [eax+8] + push ebx + push ebp + mov ebp, 1 + mov edx, ebp + shl edx, cl + mov ecx, [eax+4] + xor ebx, ebx + push esi + sub edx, ebp + mov [esp+48h+var_C], edx + mov edx, ebp + shl edx, cl + mov ecx, [esp+48h+arg_C] + push edi + mov edi, [eax+0Ch] + sub edx, ebp + mov [esp+4Ch+var_8], edx + mov edx, [eax] + mov [ecx], ebx + mov ecx, [esp+4Ch+arg_18] + mov [ecx], ebx + mov ecx, [eax+4] + add ecx, edx + mov eax, 300h + shl eax, cl + mov [esp+4Ch+var_20], edi + mov [esp+4Ch+var_2C], ebx + mov byte ptr [esp+4Ch+arg_0], bl + add eax, 736h + mov [esp+4Ch+var_14], edx + mov [esp+4Ch+var_34], ebx + mov [esp+4Ch+var_38], ebp + mov [esp+4Ch+var_24], ebp + mov [esp+4Ch+var_28], ebp + mov [esp+4Ch+var_18], ebp + jz short loc_4CCD04 + mov ecx, eax + shr ecx, 1 + mov eax, 4000400h + rep stosd + adc ecx, ecx + rep stosw + +loc_4CCD04: ; CODE XREF: sub_4CCC80+72j + mov edx, [esp+4Ch+arg_8] + mov ecx, [esp+4Ch+arg_4] + lea edi, [ecx+edx] + xor esi, esi + or eax, 0FFFFFFFFh + mov [esp+4Ch+var_3C], edi + xor edx, edx + lea ebx, [ebx+0] + +loc_4CCD20: ; CODE XREF: sub_4CCC80+BCj + cmp ecx, edi + jz loc_4CCF0B + movzx ebp, byte ptr [ecx] + shl esi, 8 + or esi, ebp + mov ebp, 1 + add edx, ebp + add ecx, ebp + cmp edx, 5 + jl short loc_4CCD20 + cmp [esp+4Ch+arg_14], ebx + mov [esp+4Ch+arg_8], ecx + jbe loc_4CCFCD + lea esp, [esp+0] + +loc_4CCD50: ; CODE XREF: sub_4CCC80+32Dj + mov edx, [esp+4Ch+var_34] + mov ecx, [esp+4Ch+var_C] + and ecx, [esp+4Ch+var_2C] + mov edi, [esp+4Ch+var_20] + mov ebx, edx + shl ebx, 4 + add ebx, ecx + cmp eax, 1000000h + lea ebx, [edi+ebx*2] + mov [esp+4Ch+var_1C], ecx + mov [esp+4Ch+var_30], ebx + jnb short loc_4CCD99 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebp, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebp + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CCD99: ; CODE XREF: sub_4CCC80+F7j + movzx ebx, word ptr [ebx] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb loc_4CCFF4 + mov edi, [esp+4Ch+var_30] + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + mov ebp, [esp+4Ch+var_8] + sar ecx, 5 + add ecx, ebx + movzx ebx, byte ptr [esp+4Ch+arg_0] + mov [edi], cx + mov edi, [esp+4Ch+var_2C] + mov ecx, 8 + sub cl, byte ptr [esp+4Ch+var_14] + and ebp, edi + shr ebx, cl + mov ecx, [esp+4Ch+var_14] + shl ebp, cl + mov ecx, [esp+4Ch+var_20] + mov edx, 1 + add ebx, ebp + imul ebx, 600h + cmp [esp+4Ch+var_34], 7 + lea ebp, [ebx+ecx+0E6Ch] + mov [esp+4Ch+var_30], ebp + jl loc_4CCEB0 + sub edi, [esp+4Ch+var_38] + mov ecx, [esp+4Ch+arg_10] + movzx ebx, byte ptr [edi+ecx] + jmp short loc_4CCE20 +; --------------------------------------------------------------------------- + align 10h + +loc_4CCE20: ; CODE XREF: sub_4CCC80+197j + ; sub_4CCC80+2C6j + add ebx, ebx + mov [esp+4Ch+var_10], ebx + and ebx, 100h + cmp eax, 1000000h + lea ecx, [ebx+edx] + lea ebp, [ebp+ecx*2+200h] + mov [esp+4Ch+arg_0], ebp + jnb short loc_4CCE61 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edi, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, edi + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CCE61: ; CODE XREF: sub_4CCC80+1BFj + movzx edi, word ptr [ebp+0] + movzx ebp, di + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb loc_4CCF15 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, edi + mov edi, [esp+4Ch+arg_0] + add edx, edx + test ebx, ebx + mov [edi], cx + jz loc_4CCF36 + +loc_4CCE97: ; CODE XREF: sub_4CCC80+2B0j + cmp edx, 100h + jge loc_4CCF70 + mov ebp, [esp+4Ch+var_30] + jmp short loc_4CCEB0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CCEB0: ; CODE XREF: sub_4CCC80+185j + ; sub_4CCC80+227j ... + cmp eax, 1000000h + lea ecx, [edx+edx] + mov [esp+4Ch+arg_0], ecx + jnb short loc_4CCEDE + mov edi, [esp+4Ch+arg_8] + cmp edi, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [edi] + shl esi, 8 + shl eax, 8 + or esi, ebx + add edi, 1 + mov [esp+4Ch+arg_8], edi + +loc_4CCEDE: ; CODE XREF: sub_4CCC80+23Cj + movzx edi, word ptr [ecx+ebp] + movzx ebx, di + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebx + cmp esi, ecx + jnb short loc_4CCF4B + mov eax, ecx + mov ecx, 800h + sub ecx, ebx + sar ecx, 5 + add ecx, edi + mov edi, [esp+4Ch+arg_0] + mov [edi+ebp], cx + add edx, edx + jmp short loc_4CCF64 +; --------------------------------------------------------------------------- + +loc_4CCF0B: ; CODE XREF: sub_4CCC80+A2j + pop edi + pop esi + mov eax, ebp + pop ebp + pop ebx + add esp, 3Ch + retn +; --------------------------------------------------------------------------- + +loc_4CCF15: ; CODE XREF: sub_4CCC80+1F2j + sub eax, ecx + sub esi, ecx + mov cx, di + shr cx, 5 + sub di, cx + test ebx, ebx + mov ecx, [esp+4Ch+arg_0] + mov [ecx], di + lea edx, [edx+edx+1] + jz loc_4CCE97 + +loc_4CCF36: ; CODE XREF: sub_4CCC80+211j + cmp edx, 100h + jge short loc_4CCF70 + mov ebp, [esp+4Ch+var_30] + mov ebx, [esp+4Ch+var_10] + jmp loc_4CCE20 +; --------------------------------------------------------------------------- + +loc_4CCF4B: ; CODE XREF: sub_4CCC80+26Fj + mov dx, di + shr dx, 5 + sub di, dx + mov edx, [esp+4Ch+arg_0] + sub eax, ecx + sub esi, ecx + mov [edx+ebp], di + add edx, 1 + +loc_4CCF64: ; CODE XREF: sub_4CCC80+289j + cmp edx, 100h + jl loc_4CCEB0 + +loc_4CCF70: ; CODE XREF: sub_4CCC80+21Dj + ; sub_4CCC80+2BCj + mov ecx, [esp+4Ch+var_2C] + mov edi, [esp+4Ch+arg_10] + mov [ecx+edi], dl + add ecx, 1 + mov [esp+4Ch+var_2C], ecx + mov ecx, [esp+4Ch+var_34] + cmp ecx, 4 + mov byte ptr [esp+4Ch+arg_0], dl + jge short loc_4CCF99 + mov [esp+4Ch+var_34], 0 + jmp short loc_4CCFA5 +; --------------------------------------------------------------------------- + +loc_4CCF99: ; CODE XREF: sub_4CCC80+30Dj + cmp ecx, 0Ah + jge short loc_4CCFEF + sub ecx, 3 + +loc_4CCFA1: ; CODE XREF: sub_4CCC80+372j + mov [esp+4Ch+var_34], ecx + +loc_4CCFA5: ; CODE XREF: sub_4CCC80+317j + ; sub_4CCC80+530j ... + mov ecx, [esp+4Ch+var_2C] + cmp ecx, [esp+4Ch+arg_14] + jb loc_4CCD50 + +loc_4CCFB3: ; CODE XREF: sub_4CCC80+A13j + ; sub_4CCC80+A5Aj + cmp eax, 1000000h + jnb short loc_4CCFCD + mov edx, [esp+4Ch+arg_8] + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + add [esp+4Ch+arg_8], 1 + +loc_4CCFCD: ; CODE XREF: sub_4CCC80+C6j + ; sub_4CCC80+338j + mov eax, [esp+4Ch+arg_8] + sub eax, [esp+4Ch+arg_4] + mov ecx, [esp+4Ch+arg_C] + mov edx, [esp+4Ch+var_2C] + pop edi + mov [ecx], eax + mov eax, [esp+48h+arg_18] + pop esi + pop ebp + mov [eax], edx + xor eax, eax + pop ebx + add esp, 3Ch + retn +; --------------------------------------------------------------------------- + +loc_4CCFEF: ; CODE XREF: sub_4CCC80+31Cj + sub ecx, 6 + jmp short loc_4CCFA1 +; --------------------------------------------------------------------------- + +loc_4CCFF4: ; CODE XREF: sub_4CCC80+129j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov ecx, [esp+4Ch+var_30] + mov [ecx], bx + jnb short loc_4CD030 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD030: ; CODE XREF: sub_4CCC80+38Ej + movzx ebx, word ptr [edi+edx*2+180h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD096 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, ebx + mov [edi+edx*2+180h], cx + mov ecx, [esp+4Ch+var_28] + mov ebp, [esp+4Ch+var_1C] + mov [esp+4Ch+var_18], ecx + mov ecx, [esp+4Ch+var_24] + mov [esp+4Ch+var_28], ecx + mov ecx, [esp+4Ch+var_38] + mov [esp+4Ch+var_24], ecx + xor ecx, ecx + cmp edx, 7 + setl cl + sub ecx, 1 + and ecx, 3 + mov [esp+4Ch+var_34], ecx + lea ecx, [edi+664h] + jmp loc_4CD30B +; --------------------------------------------------------------------------- + +loc_4CD096: ; CODE XREF: sub_4CCC80+3C5j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov [edi+edx*2+180h], bx + jnb short loc_4CD0D3 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD0D3: ; CODE XREF: sub_4CCC80+431j + movzx ebx, word ptr [edi+edx*2+198h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + mov [esp+4Ch+arg_0], ebx + jnb loc_4CD1D3 + mov ebx, 800h + sub ebx, ebp + mov ebp, [esp+4Ch+var_1C] + sar ebx, 5 + add ebx, [esp+4Ch+arg_0] + mov eax, ecx + mov [edi+edx*2+198h], bx + lea ebx, [edx+0Fh] + shl ebx, 4 + add ebx, ebp + cmp ecx, 1000000h + lea ebx, [edi+ebx*2] + mov [esp+4Ch+var_30], ebx + jnb short loc_4CD147 + mov ebx, [esp+4Ch+arg_8] + cmp ebx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + shl ecx, 8 + mov eax, ecx + movzx ecx, byte ptr [ebx] + shl esi, 8 + or esi, ecx + add ebx, 1 + mov [esp+4Ch+arg_8], ebx + +loc_4CD147: ; CODE XREF: sub_4CCC80+4A3j + mov ecx, [esp+4Ch+var_30] + movzx ecx, word ptr [ecx] + mov [esp+4Ch+arg_0], ecx + movzx ebx, cx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebx + cmp esi, ecx + jnb short loc_4CD1B5 + mov edi, [esp+4Ch+var_30] + mov eax, ecx + mov ecx, 800h + sub ecx, ebx + sar ecx, 5 + add ecx, [esp+4Ch+arg_0] + mov [edi], cx + mov edi, [esp+4Ch+var_2C] + test edi, edi + jz loc_4CD6E2 + xor ecx, ecx + cmp edx, 7 + mov edx, [esp+4Ch+arg_10] + setnl cl + lea ecx, [ecx+ecx+9] + mov [esp+4Ch+var_34], ecx + mov ecx, edi + sub ecx, [esp+4Ch+var_38] + add edi, 1 + mov cl, [ecx+edx] + mov [edi+edx-1], cl + mov byte ptr [esp+4Ch+arg_0], cl + mov [esp+4Ch+var_2C], edi + jmp loc_4CCFA5 +; --------------------------------------------------------------------------- + +loc_4CD1B5: ; CODE XREF: sub_4CCC80+4DFj + sub eax, ecx + sub esi, ecx + mov ecx, [esp+4Ch+arg_0] + mov bx, cx + shr bx, 5 + sub cx, bx + mov ebx, [esp+4Ch+var_30] + mov [ebx], cx + jmp loc_4CD2F0 +; --------------------------------------------------------------------------- + +loc_4CD1D3: ; CODE XREF: sub_4CCC80+46Cj + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov [edi+edx*2+198h], bx + jnb short loc_4CD210 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD210: ; CODE XREF: sub_4CCC80+56Ej + movzx ebx, word ptr [edi+edx*2+1B0h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD246 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, ebx + mov [edi+edx*2+1B0h], cx + mov ecx, [esp+4Ch+var_24] + jmp loc_4CD2E0 +; --------------------------------------------------------------------------- + +loc_4CD246: ; CODE XREF: sub_4CCC80+5A5j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov [edi+edx*2+1B0h], bx + jnb short loc_4CD283 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD283: ; CODE XREF: sub_4CCC80+5E1j + movzx ebx, word ptr [edi+edx*2+1C8h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD2B6 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, ebx + mov [edi+edx*2+1C8h], cx + mov ecx, [esp+4Ch+var_28] + jmp short loc_4CD2D8 +; --------------------------------------------------------------------------- + +loc_4CD2B6: ; CODE XREF: sub_4CCC80+618j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + mov ecx, [esp+4Ch+var_18] + mov [edi+edx*2+1C8h], bx + mov ebx, [esp+4Ch+var_28] + mov [esp+4Ch+var_18], ebx + +loc_4CD2D8: ; CODE XREF: sub_4CCC80+634j + mov ebx, [esp+4Ch+var_24] + mov [esp+4Ch+var_28], ebx + +loc_4CD2E0: ; CODE XREF: sub_4CCC80+5C1j + mov ebx, [esp+4Ch+var_38] + mov ebp, [esp+4Ch+var_1C] + mov [esp+4Ch+var_24], ebx + mov [esp+4Ch+var_38], ecx + +loc_4CD2F0: ; CODE XREF: sub_4CCC80+54Ej + xor ecx, ecx + cmp edx, 7 + setnl cl + sub ecx, 1 + and ecx, 0FFFFFFFDh + add ecx, 0Bh + mov [esp+4Ch+var_34], ecx + lea ecx, [edi+0A68h] + +loc_4CD30B: ; CODE XREF: sub_4CCC80+411j + cmp eax, 1000000h + jnb short loc_4CD332 + mov edx, [esp+4Ch+arg_8] + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edi, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, edi + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD332: ; CODE XREF: sub_4CCC80+690j + movzx edi, word ptr [ecx] + movzx ebx, di + mov edx, eax + shr edx, 0Bh + imul edx, ebx + cmp esi, edx + jnb short loc_4CD36E + mov eax, edx + mov edx, 800h + sub edx, ebx + sar edx, 5 + add edx, edi + mov [ecx], dx + shl ebp, 4 + lea ecx, [ecx+ebp+4] + mov [esp+4Ch+var_1C], 0 + mov edx, 3 + jmp loc_4CD409 +; --------------------------------------------------------------------------- + +loc_4CD36E: ; CODE XREF: sub_4CCC80+6C2j + sub eax, edx + sub esi, edx + mov dx, di + shr dx, 5 + sub di, dx + cmp eax, 1000000h + mov [ecx], di + jnb short loc_4CD3A6 + mov edx, [esp+4Ch+arg_8] + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edi, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, edi + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD3A6: ; CODE XREF: sub_4CCC80+704j + movzx edx, word ptr [ecx+2] + movzx ebx, dx + mov edi, eax + shr edi, 0Bh + imul edi, ebx + cmp esi, edi + jnb short loc_4CD3E4 + mov eax, edi + mov edi, 800h + sub edi, ebx + sar edi, 5 + add edi, edx + shl ebp, 4 + mov [ecx+2], di + lea ecx, [ecx+ebp+104h] + mov [esp+4Ch+var_1C], 8 + mov edx, 3 + jmp short loc_4CD409 +; --------------------------------------------------------------------------- + +loc_4CD3E4: ; CODE XREF: sub_4CCC80+737j + sub eax, edi + sub esi, edi + mov di, dx + shr di, 5 + sub dx, di + mov [ecx+2], dx + add ecx, 204h + mov [esp+4Ch+var_1C], 10h + mov edx, 8 + +loc_4CD409: ; CODE XREF: sub_4CCC80+6E9j + ; sub_4CCC80+762j + mov [esp+4Ch+arg_0], edx + mov [esp+4Ch+var_10], edx + mov ebx, 1 + jmp short loc_4CD420 +; --------------------------------------------------------------------------- + align 10h + +loc_4CD420: ; CODE XREF: sub_4CCC80+796j + ; sub_4CCC80+819j + cmp eax, 1000000h + mov edx, [esp+4Ch+arg_8] + lea edi, [ebx+ebx] + mov [esp+4Ch+var_30], edi + jnb short loc_4CD44E + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebp, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, ebp + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD44E: ; CODE XREF: sub_4CCC80+7B0j + movzx edi, word ptr [edi+ecx] + movzx ebp, di + mov edx, eax + shr edx, 0Bh + imul edx, ebp + cmp esi, edx + jnb short loc_4CD47B + mov eax, edx + mov edx, 800h + sub edx, ebp + sar edx, 5 + add edx, edi + mov edi, [esp+4Ch+var_30] + mov [edi+ecx], dx + add ebx, ebx + jmp short loc_4CD494 +; --------------------------------------------------------------------------- + +loc_4CD47B: ; CODE XREF: sub_4CCC80+7DFj + mov ebx, [esp+4Ch+var_30] + sub eax, edx + sub esi, edx + mov dx, di + shr dx, 5 + sub di, dx + mov [ebx+ecx], di + add ebx, 1 + +loc_4CD494: ; CODE XREF: sub_4CCC80+7F9j + sub [esp+4Ch+var_10], 1 + jnz short loc_4CD420 + mov ecx, [esp+4Ch+arg_0] + mov edx, 1 + shl edx, cl + mov ecx, [esp+4Ch+var_1C] + sub ecx, edx + add ebx, ecx + cmp [esp+4Ch+var_34], 4 + mov [esp+4Ch+var_4], ebx + jge loc_4CD69D + add [esp+4Ch+var_34], 7 + cmp ebx, 4 + jl short loc_4CD4CC + mov ebx, 3 + +loc_4CD4CC: ; CODE XREF: sub_4CCC80+845j + mov ecx, [esp+4Ch+var_20] + shl ebx, 7 + lea ecx, [ebx+ecx+360h] + mov [esp+4Ch+var_30], ecx + mov [esp+4Ch+arg_0], 6 + mov edi, 1 + jmp short loc_4CD4F0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CD4F0: ; CODE XREF: sub_4CCC80+86Bj + ; sub_4CCC80+8E3j + cmp eax, 1000000h + mov edx, [esp+4Ch+arg_8] + lea ebx, [edi+edi] + jnb short loc_4CD51A + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebp, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, ebp + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD51A: ; CODE XREF: sub_4CCC80+87Cj + movzx edx, word ptr [ebx+ecx] + movzx ebp, dx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD545 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, edx + mov [esp+4Ch+var_10], ecx + mov edx, ecx + add edi, edi + jmp short loc_4CD556 +; --------------------------------------------------------------------------- + +loc_4CD545: ; CODE XREF: sub_4CCC80+8ABj + sub eax, ecx + sub esi, ecx + mov cx, dx + shr cx, 5 + sub dx, cx + lea edi, [ebx+1] + +loc_4CD556: ; CODE XREF: sub_4CCC80+8C3j + sub [esp+4Ch+arg_0], 1 + mov ecx, [esp+4Ch+var_30] + mov [ebx+ecx], dx + jnz short loc_4CD4F0 + sub edi, 40h + cmp edi, 4 + jl loc_4CD68A + mov ebx, 1 + mov ecx, edi + mov edx, edi + sar ecx, 1 + and edx, ebx + sub ecx, ebx + or edx, 2 + cmp edi, 0Eh + mov [esp+4Ch+var_30], ecx + jge short loc_4CD5A1 + shl edx, cl + mov ecx, [esp+4Ch+var_20] + mov [esp+4Ch+var_38], edx + sub edx, edi + lea ebp, [ecx+edx*2+55Eh] + jmp short loc_4CD5F3 +; --------------------------------------------------------------------------- + +loc_4CD5A1: ; CODE XREF: sub_4CCC80+90Aj + mov edi, [esp+4Ch+arg_8] + sub ecx, 4 + +loc_4CD5A8: ; CODE XREF: sub_4CCC80+958j + cmp eax, 1000000h + jnb short loc_4CD5CA + cmp edi, [esp+4Ch+var_3C] + jz loc_4CD6EF + movzx ebp, byte ptr [edi] + shl esi, 8 + shl eax, 8 + or esi, ebp + add edi, ebx + mov [esp+4Ch+arg_8], edi + +loc_4CD5CA: ; CODE XREF: sub_4CCC80+92Dj + shr eax, 1 + add edx, edx + cmp esi, eax + jb short loc_4CD5D6 + sub esi, eax + or edx, ebx + +loc_4CD5D6: ; CODE XREF: sub_4CCC80+950j + sub ecx, ebx + jnz short loc_4CD5A8 + mov ebp, [esp+4Ch+var_20] + add ebp, 644h + shl edx, 4 + mov [esp+4Ch+var_38], edx + mov [esp+4Ch+var_30], 4 + +loc_4CD5F3: ; CODE XREF: sub_4CCC80+91Fj + mov [esp+4Ch+var_1C], ebx + mov [esp+4Ch+arg_0], ebx + jmp short loc_4CD600 +; --------------------------------------------------------------------------- + align 10h + +loc_4CD600: ; CODE XREF: sub_4CCC80+97Bj + ; sub_4CCC80+A02j + mov ebx, [esp+4Ch+arg_0] + add ebx, ebx + cmp eax, 1000000h + jnb short loc_4CD62D + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, edx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD62D: ; CODE XREF: sub_4CCC80+98Bj + movzx edi, word ptr [ebx+ebp] + movzx ecx, di + mov edx, eax + shr edx, 0Bh + imul edx, ecx + cmp esi, edx + jnb short loc_4CD658 + mov eax, edx + mov edx, 800h + sub edx, ecx + sar edx, 5 + add edx, edi + shl [esp+4Ch+arg_0], 1 + mov [ebx+ebp], dx + jmp short loc_4CD679 +; --------------------------------------------------------------------------- + +loc_4CD658: ; CODE XREF: sub_4CCC80+9BEj + mov cx, di + shr cx, 5 + sub di, cx + sub eax, edx + sub esi, edx + mov edx, [esp+4Ch+var_1C] + mov [ebx+ebp], di + add ebx, 1 + or [esp+4Ch+var_38], edx + mov [esp+4Ch+arg_0], ebx + +loc_4CD679: ; CODE XREF: sub_4CCC80+9D6j + shl [esp+4Ch+var_1C], 1 + sub [esp+4Ch+var_30], 1 + jnz loc_4CD600 + jmp short loc_4CD68E +; --------------------------------------------------------------------------- + +loc_4CD68A: ; CODE XREF: sub_4CCC80+8EBj + mov [esp+4Ch+var_38], edi + +loc_4CD68E: ; CODE XREF: sub_4CCC80+A08j + add [esp+4Ch+var_38], 1 + jz loc_4CCFB3 + mov ebx, [esp+4Ch+var_4] + +loc_4CD69D: ; CODE XREF: sub_4CCC80+837j + mov ebp, [esp+4Ch+var_2C] + mov ecx, [esp+4Ch+var_38] + add ebx, 2 + cmp ecx, ebp + ja short loc_4CD6E2 + mov edi, ebp + sub edi, ecx + add edi, [esp+4Ch+arg_10] + +loc_4CD6B4: ; CODE XREF: sub_4CCC80+A60j + mov cl, [edi] + mov edx, [esp+4Ch+arg_10] + sub ebx, 1 + mov [edx+ebp], cl + add ebp, 1 + add edi, 1 + test ebx, ebx + mov byte ptr [esp+4Ch+arg_0], cl + mov [esp+4Ch+var_2C], ebp + jz loc_4CCFA5 + cmp ebp, [esp+4Ch+arg_14] + jnb loc_4CCFB3 + jmp short loc_4CD6B4 +; --------------------------------------------------------------------------- + +loc_4CD6E2: ; CODE XREF: sub_4CCC80+101j + ; sub_4CCC80+1C9j ... + pop edi + pop esi + pop ebp + mov eax, 1 + pop ebx + add esp, 3Ch + retn +; --------------------------------------------------------------------------- + +loc_4CD6EF: ; CODE XREF: sub_4CCC80+933j + pop edi + pop esi + pop ebp + mov eax, ebx + pop ebx + add esp, 3Ch + retn +sub_4CCC80 endp + +_starcraft_decompress_lzma PROC +;sub_4CD700 + +var_14 = byte ptr -14h +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +pbInBuffer = dword ptr 4 +cbInBuffer = dword ptr 8 +pbOutBuffer = dword ptr 0Ch +cbOutBuffer = dword ptr 10h +pcbOutBuffer = dword ptr 14h +pfnAllocateMemory= dword ptr 18h +pfnFreeMemory = dword ptr 1Ch + + sub esp, 14h + push ebx + mov ebx, [esp+18h+cbInBuffer] + cmp ebx, 0Eh ; LZMA_PROPS_SIZE + 8 + jnb short loc_4CD714 + xor al, al + pop ebx + add esp, 14h + retn +; --------------------------------------------------------------------------- + +loc_4CD714: ; CODE XREF: Decompress_lzma_internal+Bj + push ebp + mov ebp, [esp+1Ch+pcbOutBuffer] + push edi + mov edi, [esp+20h+pbInBuffer] + mov dword ptr [ebp+0], 0 + cmp byte ptr [edi], 0 + jnz short loc_4CD741 + push 5 + lea eax, [edi+1] + push eax + lea ecx, [esp+28h+var_10] + push ecx + call LzmaProps_Decode + add esp, 0Ch + test eax, eax + jz short loc_4CD74A + +loc_4CD741: ; CODE XREF: Decompress_lzma_internal+28j + pop edi + pop ebp + xor al, al + pop ebx + add esp, 14h + retn +; --------------------------------------------------------------------------- + +loc_4CD74A: ; CODE XREF: Decompress_lzma_internal+3Fj + mov edx, [esp+20h+var_10] + mov eax, [esp+20h+var_C] + lea ecx, [eax+edx] + mov edx, 300h + shl edx, cl + push esi + lea eax, [edx+edx+0E6Ch] + push eax + call [esp+28h+pfnAllocateMemory] + mov esi, eax + add esp, 4 + test esi, esi + mov [esp+24h+var_4], esi + jz short loc_4CD7AA + mov edx, [esp+24h+cbOutBuffer] + mov eax, [esp+24h+pbOutBuffer] + lea ecx, [esp+24h+cbInBuffer] + push ecx ; cbInBuffer + push edx ; cbOutBuffer + push eax ; pbOutBuffer + lea ecx, [esp+30h+var_14] + push ecx ; &var_14 + add ebx, 0FFFFFFF2h + push ebx ; cbInBuffer - LZMA86_HEADER_SIZE + add edi, 0Eh + lea edx, [esp+38h+var_10] + push edi ; pbInBuffer + LZMA86_HEADER_SIZE + push edx ; dest + call sub_4CCC80 + push esi + mov edi, eax + call [esp+44h+pfnFreeMemory] + add esp, 20h + test edi, edi + jz short loc_4CD7B4 + +loc_4CD7AA: ; CODE XREF: Decompress_lzma_internal+74j + pop esi + pop edi + pop ebp + xor al, al + pop ebx + add esp, 14h + retn +; --------------------------------------------------------------------------- + +loc_4CD7B4: ; CODE XREF: Decompress_lzma_internal+A8j + mov eax, [esp+24h+cbInBuffer] + pop esi + pop edi + mov [ebp+0], eax + pop ebp + mov al, 1 + pop ebx + add esp, 14h + retn +_starcraft_decompress_lzma ENDP + +; =============== S U B R O U T I N E ======================================= + +sub_4CD7D0 proc near ; CODE XREF: sub_4CDC00+74p + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + or esi, 8 + xor eax, eax + cmp esi, 1 + jz short loc_4CD806 + push edi + +loc_4CD7E0: ; CODE XREF: sub_4CD7D0+33j + mov edx, esi + shr esi, 1 + mov edi, [ecx+esi*4] + and edx, 1 + sub edi, edx + neg edx + xor edi, edx + shr edi, 2 + and edi, 1FFh + add eax, dword_550998[edi*4] + cmp esi, 1 + jnz short loc_4CD7E0 + pop edi + +loc_4CD806: ; CODE XREF: sub_4CD7D0+Dj + pop esi + retn 4 +sub_4CD7D0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD810 proc near ; CODE XREF: CEncoder_FillAlignPrices+17p + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 + + push ecx + push ebx + push ebp + push esi + xor eax, eax + push edi + mov edi, [esp+14h+arg_0] + mov [esp+14h+var_4], ecx + lea esi, [eax+1] + lea ebx, [eax+4] + +loc_4CD825: ; CODE XREF: sub_4CD810+42j + mov ecx, [esp+14h+var_4] + mov ecx, [ecx+esi*4] + mov edx, edi + and edx, 1 + sub ecx, edx + mov ebp, edx + neg ebp + xor ecx, ebp + shr ecx, 2 + and ecx, 1FFh + add eax, dword_550998[ecx*4] + add esi, esi + shr edi, 1 + or esi, edx + sub ebx, 1 + jnz short loc_4CD825 + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn 4 +sub_4CD810 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD860 proc near ; CODE XREF: CEncoder_FillDistancesPrices+6Bp + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push edi + mov edi, [esp+4+arg_4] + xor eax, eax + test edi, edi + lea edx, [eax+1] + jz short loc_4CD8A7 + push ebx + push ebp + push esi + mov esi, [esp+10h+arg_8] + +loc_4CD875: ; CODE XREF: sub_4CD860+42j + mov ebx, [esp+10h+arg_0] + mov ebx, [ebx+edx*4] + mov ecx, esi + and ecx, 1 + sub ebx, ecx + mov ebp, ecx + neg ebp + xor ebx, ebp + shr ebx, 2 + and ebx, 1FFh + add eax, dword_550998[ebx*4] + add edx, edx + shr esi, 1 + or edx, ecx + sub edi, 1 + jnz short loc_4CD875 + pop esi + pop ebp + pop ebx + +loc_4CD8A7: ; CODE XREF: sub_4CD860+Cj + pop edi + retn +sub_4CD860 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD8B0 proc near ; CODE XREF: CEncoder_CodeOneBlock+7B8p + mov eax, [ecx+24h] + mov edx, [ecx+1Ch] + push ebx + push esi + mov esi, [ecx+30h] + xor ebx, ebx + push edi + mov edi, [ecx+34h] + sub esi, eax + sbb edi, ebx + add esi, edx + adc edi, ebx + cmp eax, edx + jbe short loc_4CD8D4 + mov eax, [ecx+28h] + add esi, eax + adc edi, ebx + +loc_4CD8D4: ; CODE XREF: sub_4CD8B0+1Bj + mov eax, [ecx] + xor edx, edx + add eax, esi + adc edx, edi + pop edi + add eax, 4 + pop esi + adc edx, ebx + pop ebx + retn +sub_4CD8B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD8F0 proc near ; CODE XREF: sub_4CD940+21p + ; .text:loc_4CF730j ... + mov eax, dword_553598 + test eax, eax + push esi + mov esi, ecx + push edi + mov edi, [esi] + jnz short loc_4CD92A + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + test eax, eax + jz short loc_4CD923 + mov dword ptr [eax], 0 + mov dword ptr [eax+4], 0 + mov dword ptr [eax+8], 0 + jmp short loc_4CD925 +; --------------------------------------------------------------------------- + +loc_4CD923: ; CODE XREF: sub_4CD8F0+1Bj + xor eax, eax + +loc_4CD925: ; CODE XREF: sub_4CD8F0+31j + mov dword_553598, eax + +loc_4CD92A: ; CODE XREF: sub_4CD8F0+Dj + mov eax, [eax+4] + test eax, eax + jz short loc_4CD937 + push edi + call eax + add esp, 4 + +loc_4CD937: ; CODE XREF: sub_4CD8F0+3Fj + pop edi + mov dword ptr [esi], 0 + pop esi + retn +sub_4CD8F0 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CD940 proc near ; CODE XREF: sub_4D0270+74p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + mov ebx, [esp+4+arg_4] + push esi + mov esi, ecx + cmp dword ptr [esi], 0 + push edi + mov edi, [esp+0Ch+arg_0] + jz short loc_4CD95F + mov eax, [esi+8] + add eax, [esi+4] + lea ecx, [edi+ebx] + cmp ecx, eax + jz short loc_4CD981 + +loc_4CD95F: ; CODE XREF: sub_4CD940+10j + mov ecx, esi + call sub_4CD8F0 + lea ecx, [edi+ebx] + mov edx, 1 + shl edx, cl + imul edx, 0C00h + push edx + call sub_4CB8A0 + add esp, 4 + mov [esi], eax + +loc_4CD981: ; CODE XREF: sub_4CD940+1Dj + mov ecx, edi + mov eax, 1 + shl eax, cl + mov [esi+8], edi + pop edi + mov [esi+4], ebx + sub eax, 1 + mov [esi+0Ch], eax + xor eax, eax + cmp [esi], eax + pop esi + setnz al + pop ebx + retn 8 +sub_4CD940 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CD9B0 proc near ; CODE XREF: CEncoder_GetOptimum+436p + ; CEncoder_GetOptimum+AE1p + +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = dword ptr 0Ch + + mov edx, [esp+arg_0] + test edx, edx + push esi + jnz short loc_4CD9F2 + movzx eax, [esp+4+arg_4] + mov edx, eax + shl edx, 4 + add edx, [esp+4+arg_8] + mov esi, 800h + sub esi, [ecx+edx*4+284B0h] + mov ecx, [ecx+eax*4+28420h] + shr esi, 2 + mov eax, dword_550998[esi*4] + shr ecx, 2 + add eax, dword_550998[ecx*4] + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CD9F2: ; CODE XREF: sub_4CD9B0+7j + movzx esi, [esp+4+arg_4] + mov eax, 800h + sub eax, [ecx+esi*4+28420h] + shr eax, 2 + cmp edx, 1 + mov eax, dword_550998[eax*4] + jnz short loc_4CDA27 + mov ecx, [ecx+esi*4+28450h] + shr ecx, 2 + add eax, dword_550998[ecx*4] + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CDA27: ; CODE XREF: sub_4CD9B0+60j + push edi + add edx, 0FFFFFFFEh + mov edi, 800h + sub edi, [ecx+esi*4+28450h] + mov ecx, [ecx+esi*4+28480h] + sub ecx, edx + neg edx + xor ecx, edx + shr edi, 2 + mov edx, dword_550998[edi*4] + shr ecx, 2 + and ecx, 1FFh + add edx, dword_550998[ecx*4] + pop edi + add eax, edx + pop esi + retn 0Ch +sub_4CD9B0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CDA70 proc near ; CODE XREF: CEncoder_CodeReal+10Cp + ; CEncoder_CodeReal+134p ... + push esi + mov esi, [ecx] + cmp dword ptr [esi+80h], 0 + jz short loc_4CDA8C + cmp byte ptr [esi+33B95h], 0 + jz short loc_4CDA8C + mov byte ptr [esi+33B95h], 0 + +loc_4CDA8C: ; CODE XREF: sub_4CDA70+Aj + ; sub_4CDA70+13j + mov eax, [esi+33B8Ch] + test eax, eax + jz short loc_4CDAA8 + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + mov dword ptr [esi+33B8Ch], 0 + +loc_4CDAA8: ; CODE XREF: sub_4CDA70+24j + mov ecx, [esi+4] + mov edx, [ecx+10h] + lea eax, [esi+4] + push eax + call edx + pop esi + retn +sub_4CDA70 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CDAC0 proc near ; CODE XREF: CEncoder_GetOptimum+2C4p + ; CEncoder_GetOptimum+7ACp ... + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = byte ptr 0Ch + + push ecx + push ebx + push ebp + xor ebp, ebp + cmp byte ptr [esp+0Ch+arg_0], 0 + push esi + mov eax, ecx + push edi + mov [esp+14h+var_4], eax + lea edi, [ebp+1] + lea ebx, [ebp+8] + jz short loc_4CDB3B + movzx ecx, [esp+14h+arg_8] + mov [esp+14h+arg_0], ecx + +loc_4CDAE3: ; CODE XREF: sub_4CDAC0+71j + movzx esi, [esp+14h+arg_4] + mov edx, [esp+14h+arg_0] + sub ebx, 1 + movzx ecx, bl + shr esi, cl + shr edx, cl + and esi, 1 + mov ecx, esi + shl ecx, 8 + add ecx, edi + mov eax, [eax+ecx*4+400h] + and edx, 1 + sub eax, edx + mov ecx, edx + neg ecx + xor eax, ecx + shr eax, 2 + and eax, 1FFh + add ebp, dword_550998[eax*4] + add edi, edi + or edi, edx + cmp esi, edx + jnz short loc_4CDB33 + test ebx, ebx + jz short loc_4CDB75 + mov eax, [esp+14h+var_4] + jmp short loc_4CDAE3 +; --------------------------------------------------------------------------- + +loc_4CDB33: ; CODE XREF: sub_4CDAC0+67j + test ebx, ebx + jz short loc_4CDB75 + mov eax, [esp+14h+var_4] + +loc_4CDB3B: ; CODE XREF: sub_4CDAC0+18j + movzx edx, [esp+14h+arg_8] + mov [esp+14h+arg_0], edx + +loc_4CDB44: ; CODE XREF: sub_4CDAC0+B3j + mov edx, [esp+14h+arg_0] + sub ebx, 1 + mov cl, bl + shr edx, cl + mov ecx, [eax+edi*4] + add edi, edi + and edx, 1 + sub ecx, edx + mov esi, edx + neg esi + xor ecx, esi + shr ecx, 2 + and ecx, 1FFh + add ebp, dword_550998[ecx*4] + or edi, edx + test ebx, ebx + jnz short loc_4CDB44 + +loc_4CDB75: ; CODE XREF: sub_4CDAC0+6Bj + ; sub_4CDAC0+75j + pop edi + pop esi + mov eax, ebp + pop ebp + pop ebx + pop ecx + retn 0Ch +sub_4CDAC0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CDB80 proc near ; CODE XREF: sub_4CDEA0+11Ep + ; sub_4CDEA0+137p + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + test esi, esi + mov edx, 400h + push edi + mov [ecx], edx + mov [ecx+4], edx + jbe short loc_4CDBE6 + lea eax, [ecx+20Ch] + lea ebx, [ebx+0] + +loc_4CDBA0: ; CODE XREF: sub_4CDB80+64j + mov [eax-200h], edx + mov [eax-1FCh], edx + mov [eax-1F8h], edx + mov [eax-1F4h], edx + mov [eax-1F0h], edx + mov [eax-1ECh], edx + mov [eax-1E8h], edx + mov [eax], edx + mov [eax+4], edx + mov [eax+8], edx + mov [eax+0Ch], edx + mov [eax+10h], edx + mov [eax+14h], edx + mov [eax+18h], edx + add eax, 20h + sub esi, 1 + jnz short loc_4CDBA0 + +loc_4CDBE6: ; CODE XREF: sub_4CDB80+12j + lea edi, [ecx+40Ch] + mov ecx, 0FFh + mov eax, edx + rep stosd + pop edi + pop esi + retn 4 +sub_4CDB80 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CDC00 proc near ; CODE XREF: sub_4CF740+22p + ; sub_4CF780+2Bp + +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + sub esp, 0Ch + push ebx + push ebp + push esi + push edi + mov edi, ecx + mov eax, [edi] + mov ebx, [esp+1Ch+arg_0] + mov ecx, eax + shr ecx, 2 + mov edx, dword_550998[ecx*4] + mov ecx, 800h + sub ecx, eax + shr ecx, 2 + mov eax, dword_550998[ecx*4] + mov ecx, [edi+4] + mov [esp+1Ch+var_C], edx + mov edx, ecx + shr edx, 2 + mov ebp, dword_550998[edx*4] + mov edx, 800h + sub edx, ecx + shr edx, 2 + mov ecx, dword_550998[edx*4] + add ebp, eax + add ecx, eax + mov [esp+1Ch+var_8], ebp + mov [esp+1Ch+var_4], ecx + xor esi, esi + mov edi, edi + +loc_4CDC60: ; CODE XREF: sub_4CDC00+8Aj + cmp esi, [esp+1Ch+arg_4] + jnb loc_4CDD62 + mov eax, ebx + shl eax, 5 + push esi + lea ecx, [eax+edi+8] + call sub_4CD7D0 + add eax, [esp+1Ch+var_C] + mov ecx, [esp+1Ch+arg_8] + mov [ecx+esi*4], eax + add esi, 1 + cmp esi, 8 + jb short loc_4CDC60 + cmp esi, 10h + jnb short loc_4CDD00 + lea ecx, [esi-8] + mov [esp+1Ch+arg_0], ecx + jmp short loc_4CDCA0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CDCA0: ; CODE XREF: sub_4CDC00+98j + ; sub_4CDC00+FEj + cmp esi, [esp+1Ch+arg_4] + jnb loc_4CDD62 + or ecx, 8 + xor edx, edx + cmp ecx, 1 + jz short loc_4CDCE4 + +loc_4CDCB4: ; CODE XREF: sub_4CDC00+DEj + mov eax, ecx + shr ecx, 1 + and eax, 1 + lea ebp, [ecx+ebx*8] + mov ebp, [edi+ebp*4+208h] + sub ebp, eax + neg eax + xor ebp, eax + shr ebp, 2 + and ebp, 1FFh + add edx, dword_550998[ebp*4] + cmp ecx, 1 + jnz short loc_4CDCB4 + mov ebp, [esp+1Ch+var_8] + +loc_4CDCE4: ; CODE XREF: sub_4CDC00+B2j + mov eax, [esp+1Ch+arg_8] + mov ecx, [esp+1Ch+arg_0] + add edx, ebp + mov [eax+esi*4], edx + add esi, 1 + add ecx, 1 + cmp esi, 10h + mov [esp+1Ch+arg_0], ecx + jb short loc_4CDCA0 + +loc_4CDD00: ; CODE XREF: sub_4CDC00+8Fj + cmp esi, [esp+1Ch+arg_4] + jnb short loc_4CDD62 + lea ebx, [esi-10h] + lea esp, [esp+0] + +loc_4CDD10: ; CODE XREF: sub_4CDC00+160j + mov ecx, ebx + or ecx, 100h + xor edx, edx + cmp ecx, 1 + jz short loc_4CDD49 + nop + +loc_4CDD20: ; CODE XREF: sub_4CDC00+147j + mov eax, ecx + shr ecx, 1 + mov ebp, [edi+ecx*4+408h] + and eax, 1 + sub ebp, eax + neg eax + xor ebp, eax + shr ebp, 2 + and ebp, 1FFh + add edx, dword_550998[ebp*4] + cmp ecx, 1 + jnz short loc_4CDD20 + +loc_4CDD49: ; CODE XREF: sub_4CDC00+11Dj + mov ecx, [esp+1Ch+var_4] + mov eax, [esp+1Ch+arg_8] + add edx, ecx + mov [eax+esi*4], edx + add esi, 1 + add ebx, 1 + cmp esi, [esp+1Ch+arg_4] + jb short loc_4CDD10 + +loc_4CDD62: ; CODE XREF: sub_4CDC00+64j + ; sub_4CDC00+A4j ... + pop edi + pop esi + pop ebp + pop ebx + add esp, 0Ch + retn 0Ch +sub_4CDC00 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +; int __cdecl sub_4CDD70(SIZE_T dwSize) +sub_4CDD70 proc near ; DATA XREF: .data:off_546E20o + +dwSize = dword ptr 4 + + mov eax, [esp+dwSize] + test eax, eax + jnz short loc_4CDD79 + retn +; --------------------------------------------------------------------------- + +loc_4CDD79: ; CODE XREF: sub_4CDD70+6j + push 4 ; flProtect + push 1000h ; flAllocationType + push eax ; dwSize + push 0 ; lpAddress + call ds:VirtualAlloc + retn +sub_4CDD70 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +; int __cdecl sub_4CDD90(LPVOID lpAddress) +sub_4CDD90 proc near ; CODE XREF: sub_4CF810+53p + ; sub_4CF810+73p + ; DATA XREF: ... + +lpAddress = dword ptr 4 + + mov eax, [esp+lpAddress] + test eax, eax + jz short locret_4CDDA6 + push 8000h ; dwFreeType + push 0 ; dwSize + push eax ; lpAddress + call ds:VirtualFree + +locret_4CDDA6: ; CODE XREF: sub_4CDD90+6j + retn +sub_4CDD90 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CDDB0 proc near ; DATA XREF: .rdata:00517AC8o + +var_10 = dword ptr -10h +var_C = byte ptr -0Ch +var_B = byte ptr -0Bh +var_A = byte ptr -0Ah +var_9 = byte ptr -9 +var_8 = byte ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 10h + mov eax, dword_544960 + xor eax, esp + mov [esp+10h+var_4], eax + mov ecx, [esp+10h+arg_0] + mov al, [ecx+33B50h] + mov dl, 5 + imul dl + add al, [ecx+33B58h] + mov dl, 9 + imul dl + add al, [ecx+33B5Ch] + push ebp + mov ebp, [esp+14h+arg_4] + mov [esp+14h+var_C], al + mov eax, [ecx+33B60h] + mov ecx, eax + mov edx, eax + push esi + shr ecx, 8 + shr edx, 10h + mov [esp+18h+var_B], al + shr eax, 18h + push edi + mov [esp+1Ch+var_A], cl + mov [esp+1Ch+var_9], dl + mov [esp+1Ch+var_8], al + mov esi, 5 + lea edi, [esp+1Ch+var_C] + +loc_4CDE13: ; CODE XREF: sub_4CDDB0+85j + mov eax, [ebp+0] + mov edx, [eax+0Ch] + lea ecx, [esp+1Ch+var_10] + push ecx + push esi + push edi + push ebp + call edx + mov ecx, [esp+1Ch+var_10] + add edi, ecx + sub esi, ecx + test eax, eax + jnz short loc_4CDE37 + test ecx, ecx + jz short loc_4CDE4B + test esi, esi + jnz short loc_4CDE13 + +loc_4CDE37: ; CODE XREF: sub_4CDDB0+7Dj + pop edi + pop esi + pop ebp + mov ecx, [esp+10h+var_4] + xor ecx, esp + call sub_4A0686 + add esp, 10h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CDE4B: ; CODE XREF: sub_4CDDB0+81j + mov ecx, [esp+1Ch+var_4] + pop edi + pop esi + pop ebp + xor ecx, esp + mov eax, 80004005h + call sub_4A0686 + add esp, 10h + retn 8 +sub_4CDDB0 endp + + align 10h + +; =============== S U B R O U T I N E ======================================= + +sub_4CDE70 proc near ; DATA XREF: .rdata:00517AF4o + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + mov eax, [esi+50h] + test eax, eax + jz short loc_4CDE8B + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + mov dword ptr [esi+50h], 0 + +loc_4CDE8B: ; CODE XREF: sub_4CDE70+Aj + xor eax, eax + pop esi + retn 4 +sub_4CDE70 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CDEA0 proc near ; CODE XREF: CEncoder_SetStreams+3Cp + +var_4 = dword ptr -4 + + push ecx + push ebx + xor ebx, ebx + push ebp + push esi + mov esi, ecx + mov byte ptr [esi+10h], 0 + mov byte ptr [esi+11h], 0 + mov [esi+14h], ebx + mov [esi+18h], ebx + mov [esi+1Ch], ebx + mov [esi+20h], ebx + mov eax, [esi+50h] + mov [esi+4Ch], ebx + mov [esi+48h], eax + mov [esi+44h], ebx + mov [esi+58h], ebx + mov [esi+5Ch], ebx + mov [esi+64h], bl + push edi + mov [esi+30h], ebx + mov [esi+34h], ebx + mov dword ptr [esi+38h], 0FFFFFFFFh + mov dword ptr [esi+28h], 1 + mov [esi+2Ch], bl + lea ecx, [esi+28420h] + lea edi, [esi+284B0h] + mov [esp+14h+var_4], 0Ch + mov ebp, 400h + +loc_4CDF02: ; CODE XREF: sub_4CDEA0+9Cj + xor edx, edx + mov eax, edi + jmp short loc_4CDF10 +; --------------------------------------------------------------------------- + align 10h + +loc_4CDF10: ; CODE XREF: sub_4CDEA0+66j + ; sub_4CDEA0+84j + mov [eax-3C0h], ebp + mov [eax], ebp + add edx, 1 + add eax, 4 + cmp edx, [esi+33B60h] + jbe short loc_4CDF10 + mov [ecx-30h], ebp + mov [ecx], ebp + mov [ecx+30h], ebp + mov [ecx+60h], ebp + add ecx, 4 + add edi, 40h + sub [esp+14h+var_4], 1 + jnz short loc_4CDF02 + mov ecx, [esi+32658h] + add ecx, [esi+32654h] + mov eax, 1 + shl eax, cl + cmp eax, ebx + jbe short loc_4CDF7C + xor edx, edx + mov ebx, eax + lea esp, [esp+0] + +loc_4CDF60: ; CODE XREF: sub_4CDEA0+DAj + mov edi, [esi+32650h] + add edi, edx + mov ecx, 300h + mov eax, ebp + add edx, 0C00h + sub ebx, 1 + rep stosd + jnz short loc_4CDF60 + +loc_4CDF7C: ; CODE XREF: sub_4CDEA0+B3j + lea edx, [esi+287B4h] + mov ebx, 4 + +loc_4CDF87: ; CODE XREF: sub_4CDEA0+FBj + mov edi, edx + mov ecx, 3Fh + mov eax, ebp + add edx, 100h + sub ebx, 1 + rep stosd + jnz short loc_4CDF87 + lea edi, [esi+28BB0h] + mov ecx, 72h + rep stosd + mov ecx, [esi+33B5Ch] + mov edx, 1 + shl edx, cl + lea ecx, [esi+28DB8h] + push edx + call sub_4CDB80 + mov ecx, [esi+33B5Ch] + mov eax, 1 + shl eax, cl + lea ecx, [esi+2DA04h] + push eax + call sub_4CDB80 + mov eax, ebp + mov [esi+28D7Ch], eax + mov [esi+28D80h], eax + mov [esi+28D84h], eax + mov [esi+28D88h], eax + mov [esi+28D8Ch], eax + mov [esi+28D90h], eax + mov [esi+28D94h], eax + mov [esi+28D98h], eax + mov [esi+28D9Ch], eax + mov [esi+28DA0h], eax + mov [esi+28DA4h], eax + mov [esi+28DA8h], eax + mov [esi+28DACh], eax + mov [esi+28DB0h], eax + mov [esi+28DB4h], eax + xor eax, eax + pop edi + mov [esi+32F10h], bl + mov [esi+32F08h], eax + mov [esi+32F0Ch], eax + mov [esi+32F04h], eax + pop esi + pop ebp + pop ebx + pop ecx + retn +sub_4CDEA0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF450 proc near ; CODE XREF: .text:004CF692p + ; CEncoder_Flush+42p + +var_8 = dword ptr -8 +var_4 = dword ptr -4 + + sub esp, 8 + push esi + mov esi, ecx + mov eax, [esi+0Ch] + push edi + mov edi, [esi+4] + cmp eax, edi + jb short loc_4CF464 + mov edi, [esi+10h] + +loc_4CF464: ; CODE XREF: sub_4CF450+Fj + push ebp + mov ebp, [esi+20h] + xor edx, edx + sub edi, eax + cmp ebp, edx + mov [esp+14h+var_4], edx + jz short loc_4CF4BA + push ebx + mov ebx, [esi] + add ebx, eax + mov eax, dword_553598 + cmp eax, edx + jnz short loc_4CF4A5 + push 0Ch ; Size + call _operator_new ; operator new(uint) + xor ecx, ecx + add esp, 4 + cmp eax, ecx + jz short loc_4CF49C + mov [eax], ecx + mov [eax+4], ecx + mov [eax+8], ecx + jmp short loc_4CF49E +; --------------------------------------------------------------------------- + +loc_4CF49C: ; CODE XREF: sub_4CF450+40j + xor eax, eax + +loc_4CF49E: ; CODE XREF: sub_4CF450+4Aj + mov dword_553598, eax + xor edx, edx + +loc_4CF4A5: ; CODE XREF: sub_4CF450+30j + mov eax, [eax+8] + cmp eax, edx + jz short loc_4CF4B6 + push edi + push ebx + push ebp + call eax + add esp, 0Ch + xor edx, edx + +loc_4CF4B6: ; CODE XREF: sub_4CF450+5Aj + add [esi+20h], edi + pop ebx + +loc_4CF4BA: ; CODE XREF: sub_4CF450+22j + mov eax, [esi+14h] + cmp eax, edx + pop ebp + jz short loc_4CF4E4 + mov [esp+10h+var_8], edx + mov ecx, [eax] + lea edx, [esp+10h+var_8] + push edx + mov edx, [esi] + add edx, [esi+0Ch] + push edi + push edx + push eax + mov eax, [ecx+0Ch] + call eax + mov edi, [esp+10h+var_8] + mov [esp+10h+var_4], eax + xor edx, edx + +loc_4CF4E4: ; CODE XREF: sub_4CF450+70j + add [esi+0Ch], edi + mov ecx, [esi+0Ch] + mov eax, [esi+10h] + cmp ecx, eax + jnz short loc_4CF4F4 + mov [esi+0Ch], edx + +loc_4CF4F4: ; CODE XREF: sub_4CF450+9Fj + cmp [esi+4], eax + jnz short loc_4CF500 + mov byte ptr [esi+24h], 1 + mov [esi+4], edx + +loc_4CF500: ; CODE XREF: sub_4CF450+A7j + mov ecx, [esi+0Ch] + cmp ecx, [esi+4] + jbe short loc_4CF50A + mov eax, ecx + +loc_4CF50A: ; CODE XREF: sub_4CF450+B6j + add [esi+18h], edi + mov [esi+8], eax + mov eax, [esp+10h+var_4] + adc [esi+1Ch], edx + pop edi + pop esi + add esp, 8 + retn +sub_4CF450 endp + +; --------------------------------------------------------------------------- + align 10h + + +; --------------------------------------------------------------------------- + +; int __stdcall Interface1_QueryInterface(int, void *Buf1, int) +Interface1_QueryInterface proc near ; DATA XREF: .rdata:off_517A90o +; sub_4CF520 + +arg_0 = dword ptr 4 +Buf1 = dword ptr 8 +arg_8 = dword ptr 0Ch + + mov eax, [esp+Buf1] + push offset dword_512730 ; Buf2 + push eax ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF54D + mov eax, [esp+arg_0] + mov ecx, [esp+arg_8] + mov [ecx], eax + mov edx, [eax] + push eax + mov eax, [edx+4] + call eax + xor eax, eax + retn 0Ch +loc_4CF54D: ; CODE XREF: Interface1_QueryInterface+14j + mov eax, 80004002h + retn 0Ch +Interface1_QueryInterface endp + +; --------------------------------------------------------------------------- + +; int __stdcall Interface1_Release(void *pUnknown) +Interface1_Release proc near ; DATA XREF: .rdata:00517A98o + +pUnknown = dword ptr 4 + + mov ecx, [esp+pUnknown] + add dword ptr [ecx+4], 0FFFFFFFFh + mov eax, [ecx+4] + jnz short locret_4CF585 + push ecx ; Memory + mov dword ptr [ecx], offset off_517A90 + mov dword ptr [ecx+8], 0 + call j__free + add esp, 4 + xor eax, eax + +locret_4CF585: ; CODE XREF: Interface1_Release+Bj + retn 4 +Interface1_Release endp + +; --------------------------------------------------------------------------- + +sub_4CF590 proc near ; DATA XREF: .rdata:00517AB4o + +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + mov eax, [esp+arg_0] + mov edx, [eax+10h] + sub edx, [eax+18h] + mov ecx, [eax+14h] + sbb ecx, [eax+1Ch] + push ebx + mov ebx, [esp+4+arg_8] + push edi + mov edi, [esp+8+arg_C] + cmp edi, ecx + jb short loc_4CF5C2 + ja short loc_4CF5B4 + cmp ebx, edx + jbe short loc_4CF5C2 + +loc_4CF5B4: ; CODE XREF: sub_4CF590+1Ej + pop edi + mov byte ptr [eax+20h], 1 + mov eax, 80004005h + pop ebx + retn 10h +; --------------------------------------------------------------------------- + +loc_4CF5C2: ; CODE XREF: sub_4CF590+1Cj + ; sub_4CF590+22j + push esi + xor esi, esi + xor ecx, ecx + test edi, edi + jb short loc_4CF5FA + ja short loc_4CF5D1 + test ebx, ebx + jbe short loc_4CF5FA + +loc_4CF5D1: ; CODE XREF: sub_4CF590+3Bj + mov dl, [esp+0Ch+arg_4] + push ebp + +loc_4CF5D6: ; CODE XREF: sub_4CF590+5Fj + ; sub_4CF590+67j + mov ebp, [eax+18h] + mov ebx, [eax+8] + mov [ebx+ebp], dl + add dword ptr [eax+18h], 1 + adc dword ptr [eax+1Ch], 0 + add esi, 1 + adc ecx, 0 + cmp ecx, edi + jb short loc_4CF5D6 + ja short loc_4CF5F9 + cmp esi, [esp+10h+arg_8] + jb short loc_4CF5D6 + +loc_4CF5F9: ; CODE XREF: sub_4CF590+61j + pop ebp + +loc_4CF5FA: ; CODE XREF: sub_4CF590+39j + ; sub_4CF590+3Fj + pop esi + pop edi + xor eax, eax + pop ebx + retn 10h +sub_4CF590 endp + +; =============== S U B R O U T I N E ======================================= + +; int __stdcall Interface2_Release(void *pUnknown) +Interface2_Release proc near ; DATA XREF: .rdata:00517AACo +; sub_4CF610 + +pUnknown = dword ptr 4 + + mov ecx, [esp+pUnknown] + add dword ptr [ecx+4], 0FFFFFFFFh + mov eax, [ecx+4] + jnz short locret_4CF635 + push ecx ; Memory + mov dword ptr [ecx], offset off_517AA4 + mov dword ptr [ecx+8], 0 + call j__free + add esp, 4 + xor eax, eax + +locret_4CF635: ; CODE XREF: Interface2_Release+Bj + retn 4 +Interface2_Release endp + +; =============== S U B R O U T I N E ======================================= + +loc_4CF640: ; CODE XREF: sub_4CF6E0+39p + ; sub_4CFAC0+57p ... + push ecx + push ebx + push esi + push edi + mov edi, ecx + mov esi, [edi+8] + cmp esi, 0FF000000h + jb short loc_4CF661 + mov edx, [edi+0Ch] + mov eax, esi + mov cl, 20h + call __allshr ; Microsoft VisualC 2-8/net runtime + test eax, eax + jz short loc_4CF6B6 + +loc_4CF661: ; CODE XREF: .text:004CF64Fj + mov bl, [edi+4] + lea esi, [edi+18h] + +loc_4CF667: ; CODE XREF: .text:004CF6A9j + mov eax, [edi+8] + mov edx, [edi+0Ch] + mov cl, 20h + call __allshr ; Microsoft VisualC 2-8/net runtime + mov ecx, [esi+4] + mov edx, [esi] + add al, bl + mov [ecx+edx], al + add dword ptr [esi+4], 1 + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CF6A3 + cmp [esi+0Ch], eax + jz short loc_4CF6A3 + nop + +loc_4CF690: ; CODE XREF: .text:004CF6A1j + mov ecx, esi + call sub_4CF450 + test eax, eax + jnz short loc_4CF6CB + mov eax, [esi+0Ch] + cmp eax, [esi+4] + jnz short loc_4CF690 + +loc_4CF6A3: ; CODE XREF: .text:004CF688j + ; .text:004CF68Dj + or bl, 0FFh + add dword ptr [edi], 0FFFFFFFFh + jnz short loc_4CF667 + mov esi, [edi+8] + mov edx, esi + shr edx, 18h + mov [edi+4], dl + +loc_4CF6B6: ; CODE XREF: .text:004CF65Fj + add dword ptr [edi], 1 + shl esi, 8 + mov [edi+8], esi + mov dword ptr [edi+0Ch], 0 + pop edi + pop esi + pop ebx + pop ecx + retn + +; --------------------------------------------------------------------------- + +loc_4CF6CB: ; CODE XREF: .text:004CF699j + push offset dword_526DD0 + lea ecx, [esp+10h] + push ecx + mov [esp+14h], eax + int 3 +; call __CxxThrowException@8 ; _CxxThrowException(x,x) +; --------------------------------------------------------------------------- + + db 2 dup(0CCh) + +; =============== S U B R O U T I N E ======================================= + + +sub_4CF6E0 proc near ; CODE XREF: sub_4D0770+FBp + ; CEncoder_CodeOneBlock+6C5p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push esi + push edi + mov edi, [esp+8+arg_4] + add edi, 0FFFFFFFFh + mov esi, ecx + js short loc_4CF724 + push ebp + mov ebp, [esp+0Ch+arg_0] + +loc_4CF6F2: ; CODE XREF: sub_4CF6E0+41j + shr dword ptr [esi+10h], 1 + mov eax, [esi+10h] + mov edx, ebp + mov ecx, edi + shr edx, cl + test dl, 1 + jz short loc_4CF70A + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + +loc_4CF70A: ; CODE XREF: sub_4CF6E0+21j + cmp eax, 1000000h + jnb short loc_4CF71E + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CF71E: ; CODE XREF: sub_4CF6E0+2Fj + sub edi, 1 + jns short loc_4CF6F2 + pop ebp + +loc_4CF724: ; CODE XREF: sub_4CF6E0+Bj + pop edi + pop esi + retn 8 +sub_4CF6E0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF740 proc near ; CODE XREF: sub_4D0770+DFp + ; CEncoder_CodeOneBlock+58Ap ... + +arg_0 = dword ptr 4 + + push esi + push edi + mov edi, [esp+8+arg_0] + mov eax, edi + imul eax, 440h + mov esi, ecx + mov edx, [esi+4C08h] + lea ecx, [eax+esi+808h] + push ecx + push edx + push edi + mov ecx, esi + call sub_4CDC00 + mov eax, [esi+4C08h] + mov [esi+edi*4+4C0Ch], eax + pop edi + pop esi + retn 4 +sub_4CF740 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF780 proc near ; CODE XREF: CEncoder_SetStreams+7Ep + ; CEncoder_SetStreams+A6p + +arg_0 = dword ptr 4 + + push esi + push edi + xor edi, edi + cmp [esp+8+arg_0], edi + mov esi, ecx + jbe short loc_4CF7CC + push ebx + push ebp + lea ebx, [esi+4C0Ch] + lea ebp, [esi+808h] + lea ebx, [ebx+0] + +loc_4CF7A0: ; CODE XREF: sub_4CF780+48j + mov eax, [esi+4C08h] + push ebp + push eax + push edi + mov ecx, esi + call sub_4CDC00 + mov ecx, [esi+4C08h] + mov [ebx], ecx + add edi, 1 + add ebx, 4 + add ebp, 440h + cmp edi, [esp+10h+arg_0] + jb short loc_4CF7A0 + pop ebp + pop ebx + +loc_4CF7CC: ; CODE XREF: sub_4CF780+Aj + pop edi + pop esi + retn 4 +sub_4CF780 endp + +; --------------------------------------------------------------------------- + align 10h +CEncoder_GetOptimum proc near ; CODE XREF: CEncoder_CodeOneBlock+201p + +var_7D = byte ptr -7Dh +var_7C = dword ptr -7Ch +var_78 = dword ptr -78h +var_74 = dword ptr -74h +var_70 = dword ptr -70h +var_6C = dword ptr -6Ch +var_68 = dword ptr -68h +var_64 = dword ptr -64h +var_60 = dword ptr -60h +var_5C = dword ptr -5Ch +var_58 = dword ptr -58h +var_54 = dword ptr -54h +var_50 = dword ptr -50h +var_4C = dword ptr -4Ch +var_48 = dword ptr -48h +var_44 = dword ptr -44h +var_40 = dword ptr -40h +var_3C = dword ptr -3Ch +var_38 = dword ptr -38h +var_34 = dword ptr -34h +var_30 = dword ptr -30h +var_2C = dword ptr -2Ch +var_28 = dword ptr -28h +var_24 = dword ptr -24h +var_20 = dword ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 80h + push ebp + mov ebp, ecx + mov edx, [ebp+32F0Ch] + cmp [ebp+32F08h], edx + push esi + jz short loc_4CE0A5 + mov esi, [esp+88h+arg_4] + lea eax, [edx+edx*4+1Eh] + lea ecx, [ebp+eax*8+0] + mov eax, [ecx+10h] + sub eax, edx + mov edx, [ecx+14h] + mov [esi], edx + mov ecx, [ecx+10h] + pop esi + mov [ebp+32F0Ch], ecx + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE0A5: ; CODE XREF: CEncoder_GetOptimum+16j + mov edx, [ebp+80h] + mov eax, [ebp+70h] + push ebx + xor esi, esi + push edx + mov [ebp+32F08h], esi + mov [ebp+32F0Ch], esi + call eax + add esp, 4 + cmp byte ptr [ebp+32F10h], 0 + mov ebx, eax + mov [esp+8Ch+var_60], eax + jnz short loc_4CE0E4 + lea ecx, [esp+8Ch+var_70] + push ecx + mov ecx, ebp + call sub_4CB3B0 + mov [esp+8Ch+var_68], eax + jmp short loc_4CE0FF +; --------------------------------------------------------------------------- + +loc_4CE0E4: ; CODE XREF: CEncoder_GetOptimum+70j + mov edx, [ebp+32EFCh] + mov eax, [ebp+32F00h] + mov [esp+8Ch+var_68], edx + mov [esp+8Ch+var_70], eax + mov byte ptr [ebp+32F10h], 0 + +loc_4CE0FF: ; CODE XREF: CEncoder_GetOptimum+82j + mov ecx, [ebp+80h] + mov edx, [ebp+74h] + push edi + push ecx + call edx + mov edi, eax + add esp, 4 + sub edi, 1 + cmp ebx, 2 + jnb short loc_4CE138 + mov eax, [esp+90h+arg_4] + pop edi + pop ebx + pop esi + mov dword ptr [eax], 0FFFFFFFFh + mov eax, 1 + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE138: ; CODE XREF: CEncoder_GetOptimum+B7j + cmp ebx, 111h + jbe short loc_4CE149 + mov ebx, 111h + mov [esp+90h+var_60], ebx + +loc_4CE149: ; CODE XREF: CEncoder_GetOptimum+DEj + lea ecx, [ebp+14h] + mov [esp+90h+var_50], esi + mov [esp+90h+var_64], esi + xor edx, edx + mov [esp+90h+var_4C], esi + mov [esp+90h+var_6C], ecx + mov edi, edi + +loc_4CE160: ; CODE XREF: CEncoder_GetOptimum+180j + mov eax, [esp+90h+var_6C] + mov eax, [eax] + mov ecx, edi + sub ecx, eax + mov [esp+edx+90h+var_20], eax + mov al, [edi] + sub ecx, 1 + cmp al, [ecx] + jnz short loc_4CE1C9 + mov al, [edi+1] + cmp al, [ecx+1] + jnz short loc_4CE1C9 + mov eax, 2 + cmp ebx, eax + jbe short loc_4CE1A7 + lea esi, [edi+2] + sub ecx, edi + lea ecx, [ecx+0] + +loc_4CE190: ; CODE XREF: CEncoder_GetOptimum+143j + mov bl, [esi] + cmp bl, [ecx+esi] + mov ebx, [esp+90h+var_60] + jnz short loc_4CE1A5 + add eax, 1 + add esi, 1 + cmp eax, ebx + jb short loc_4CE190 + +loc_4CE1A5: ; CODE XREF: CEncoder_GetOptimum+139j + xor esi, esi + +loc_4CE1A7: ; CODE XREF: CEncoder_GetOptimum+126j + mov ecx, [esp+90h+var_4C] + mov [esp+edx+90h+var_10], eax + cmp eax, [esp+ecx+90h+var_10] + jbe short loc_4CE1D0 + mov eax, [esp+90h+var_64] + mov [esp+90h+var_50], eax + mov [esp+90h+var_4C], edx + jmp short loc_4CE1D0 +; --------------------------------------------------------------------------- + +loc_4CE1C9: ; CODE XREF: CEncoder_GetOptimum+115j + ; CEncoder_GetOptimum+11Dj + mov [esp+edx+90h+var_10], esi + +loc_4CE1D0: ; CODE XREF: CEncoder_GetOptimum+159j + ; CEncoder_GetOptimum+167j + add [esp+90h+var_64], 1 + add [esp+90h+var_6C], 4 + add edx, 4 + cmp edx, 10h + jb loc_4CE160 + mov ecx, [esp+90h+var_50] + mov ebx, [esp+ecx*4+90h+var_10] + mov eax, [ebp+32EF8h] + cmp ebx, eax + mov [esp+90h+var_40], ebx + jb short loc_4CE234 + mov edx, [esp+90h+arg_4] + lea eax, [ebx-1] + cmp eax, esi + mov [edx], ecx + jz short loc_4CE225 + add [ebp+32F04h], eax + mov ecx, [ebp+7Ch] + push eax + mov eax, [ebp+80h] + push eax + call ecx + add esp, 8 + +loc_4CE225: ; CODE XREF: CEncoder_GetOptimum+1ADj + pop edi + mov eax, ebx + pop ebx + pop esi + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE234: ; CODE XREF: CEncoder_GetOptimum+19Dj + mov esi, [esp+90h+var_68] + cmp esi, eax + jb short loc_4CE27F + mov edx, [esp+90h+var_70] + mov eax, [ebp+edx*4+3265Ch] + mov ecx, [esp+90h+arg_4] + add eax, 4 + mov [ecx], eax + lea eax, [esi-1] + test eax, eax + jz short loc_4CE270 + mov edx, [ebp+80h] + add [ebp+32F04h], eax + push eax + mov eax, [ebp+7Ch] + push edx + call eax + add esp, 8 + +loc_4CE270: ; CODE XREF: CEncoder_GetOptimum+1F8j + pop edi + pop ebx + mov eax, esi + pop esi + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE27F: ; CODE XREF: CEncoder_GetOptimum+1DAj + mov al, [edi] + mov esi, [esp+90h+var_20] + sub edi, esi + cmp [esp+90h+var_68], 2 + mov cl, [edi-1] + mov byte ptr [esp+90h+var_4C], al + mov byte ptr [esp+90h+var_50], cl + jnb short loc_4CE2C1 + cmp al, cl + jz short loc_4CE2C1 + cmp ebx, 2 + jnb short loc_4CE2C1 + mov ecx, [esp+90h+arg_4] + pop edi + pop ebx + pop esi + mov dword ptr [ecx], 0FFFFFFFFh + mov eax, 1 + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE2C1: ; CODE XREF: CEncoder_GetOptimum+237j + ; CEncoder_GetOptimum+23Bj ... + mov edx, [esp+90h+var_4C] + mov bl, [ebp+10h] + mov edi, [ebp+33B60h] + and edi, [esp+90h+arg_0] + mov ecx, [esp+90h+var_50] + push edx + cmp bl, 7 + setnb dl + push ecx + mov [ebp+0F0h], bl + mov eax, [ebp+32654h] + mov ecx, 8 + sub cl, al + push edx + movzx edx, byte ptr [ebp+11h] + shr edx, cl + mov ecx, [ebp+3265Ch] + and ecx, [esp+9Ch+arg_0] + mov [esp+9Ch+var_3C], ecx + mov ecx, eax + mov eax, [esp+9Ch+var_3C] + shl eax, cl + add edx, eax + imul edx, 0C00h + add edx, [ebp+32650h] + mov ecx, edx + call sub_4CDAC0 + movzx ecx, bl + shl ecx, 4 + add ecx, edi + mov edx, [ebp+ecx*4+280F0h] + shr edx, 2 + add eax, dword_550998[edx*4] + mov ebx, 800h + mov [ebp+124h], eax + mov dword ptr [ebp+12Ch], 0FFFFFFFFh + mov byte ptr [ebp+119h], 0 + mov cl, [ebp+10h] + movzx eax, cl + mov edx, eax + shl edx, 4 + add edx, edi + sub ebx, [ebp+edx*4+280F0h] + mov edx, 800h + sub edx, [ebp+eax*4+283F0h] + mov al, byte ptr [esp+90h+var_4C] + shr edx, 2 + mov edx, dword_550998[edx*4] + shr ebx, 2 + mov ebx, dword_550998[ebx*4] + add edx, ebx + cmp byte ptr [esp+90h+var_50], al + mov [esp+90h+var_44], ebx + mov [esp+90h+var_3C], edx + jnz short loc_4CE3F3 + movzx eax, cl + mov ebx, [ebp+eax*4+28420h] + mov ecx, eax + shl ecx, 4 + add ecx, edi + mov ecx, [ebp+ecx*4+284B0h] + shr ecx, 2 + mov eax, dword_550998[ecx*4] + shr ebx, 2 + add eax, dword_550998[ebx*4] + add eax, edx + cmp eax, [ebp+124h] + jnb short loc_4CE3F3 + mov [ebp+124h], eax + mov dword ptr [ebp+12Ch], 0 + mov byte ptr [ebp+119h], 0 + +loc_4CE3F3: ; CODE XREF: CEncoder_GetOptimum+344j + ; CEncoder_GetOptimum+37Aj + mov eax, [esp+90h+var_68] + mov ecx, [esp+90h+var_40] + cmp eax, ecx + jb short loc_4CE405 + mov [esp+90h+var_7C], eax + jmp short loc_4CE40B +; --------------------------------------------------------------------------- + +loc_4CE405: ; CODE XREF: CEncoder_GetOptimum+39Dj + mov [esp+90h+var_7C], ecx + mov eax, ecx + +loc_4CE40B: ; CODE XREF: CEncoder_GetOptimum+3A3j + cmp eax, 2 + jnb short loc_4CE431 + mov edx, [ebp+12Ch] + mov eax, [esp+90h+arg_4] + pop edi + pop ebx + pop esi + mov [eax], edx + mov eax, 1 + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE431: ; CODE XREF: CEncoder_GetOptimum+3AEj + mov ecx, [esp+90h+var_1C] + mov edx, [esp+90h+var_18] + xor ebx, ebx + mov [ebp+128h], ebx + mov [ebp+10Ch], ecx + mov ecx, [esp+90h+var_14] + mov [ebp+110h], edx + lea edx, [eax+eax*4] + mov [ebp+114h], ecx + mov [ebp+108h], esi + lea ecx, [ebp+edx*8+0FCh] + jmp short loc_4CE470 +; --------------------------------------------------------------------------- + align 10h + +loc_4CE470: ; CODE XREF: CEncoder_GetOptimum+407j + ; CEncoder_GetOptimum+41Fj + mov dword ptr [ecx], 0FFFFFFFh + sub eax, 1 + sub ecx, 28h + cmp eax, 2 + jnb short loc_4CE470 + +loc_4CE481: ; CODE XREF: CEncoder_GetOptimum+48Ej + mov esi, [esp+ebx*4+90h+var_10] + cmp esi, 2 + jb short loc_4CE4E8 + movzx eax, byte ptr [ebp+10h] + push edi + push eax + push ebx + mov ecx, ebp + call sub_4CD9B0 + add eax, [esp+90h+var_3C] + mov ecx, edi + imul ecx, 110h + add ecx, esi + mov [esp+90h+var_40], eax + lea edx, [esi+esi*4] + lea eax, [ebp+ecx*4+2E204h] + lea ecx, [ebp+edx*8+0FCh] + mov edi, edi + +loc_4CE4C0: ; CODE XREF: CEncoder_GetOptimum+486j + mov edx, [eax] + add edx, [esp+90h+var_40] + cmp edx, [ecx] + jnb short loc_4CE4DA + mov [ecx], edx + mov dword ptr [ecx+4], 0 + mov [ecx+8], ebx + mov byte ptr [ecx-0Bh], 0 + +loc_4CE4DA: ; CODE XREF: CEncoder_GetOptimum+468j + sub esi, 1 + sub eax, 4 + sub ecx, 28h + cmp esi, 2 + jnb short loc_4CE4C0 + +loc_4CE4E8: ; CODE XREF: CEncoder_GetOptimum+42Bj + add ebx, 1 + cmp ebx, 4 + jb short loc_4CE481 + movzx eax, byte ptr [ebp+10h] + mov ecx, [ebp+eax*4+283F0h] + shr ecx, 2 + mov eax, dword_550998[ecx*4] + add eax, [esp+90h+var_44] + mov [esp+90h+var_3C], eax + mov eax, [esp+90h+var_10] + cmp eax, 2 + lea ebx, [eax+1] + jnb short loc_4CE521 + mov ebx, 2 + +loc_4CE521: ; CODE XREF: CEncoder_GetOptimum+4BAj + cmp ebx, [esp+90h+var_68] + ja loc_4CE5BA + xor eax, eax + cmp ebx, [ebp+32660h] + mov [esp+90h+var_60], eax + jbe short loc_4CE550 + lea esp, [esp+0] + +loc_4CE540: ; CODE XREF: CEncoder_GetOptimum+4EAj + add eax, 2 + cmp ebx, [ebp+eax*4+32660h] + ja short loc_4CE540 + mov [esp+90h+var_60], eax + +loc_4CE550: ; CODE XREF: CEncoder_GetOptimum+4D7j + lea edx, [ebx+ebx*4] + lea esi, [ebp+edx*8+0FCh] + lea ebx, [ebx+0] + +loc_4CE560: ; CODE XREF: CEncoder_GetOptimum+558j + mov eax, [esp+90h+var_60] + mov eax, [ebp+eax*4+32664h] + push edi + push ebx + push eax + mov ecx, ebp + mov [esp+9Ch+var_40], eax + call sub_4CAEC0 + add eax, [esp+90h+var_3C] + cmp eax, [esi] + jnb short loc_4CE598 + mov ecx, [esp+90h+var_40] + add ecx, 4 + mov [esi], eax + mov dword ptr [esi+4], 0 + mov [esi+8], ecx + mov byte ptr [esi-0Bh], 0 + +loc_4CE598: ; CODE XREF: CEncoder_GetOptimum+51Fj + mov eax, [esp+90h+var_60] + cmp ebx, [ebp+eax*4+32660h] + jnz short loc_4CE5B2 + add eax, 2 + cmp eax, [esp+90h+var_70] + mov [esp+90h+var_60], eax + jz short loc_4CE5BA + +loc_4CE5B2: ; CODE XREF: CEncoder_GetOptimum+543j + add ebx, 1 + add esi, 28h + jmp short loc_4CE560 +; --------------------------------------------------------------------------- + +loc_4CE5BA: ; CODE XREF: CEncoder_GetOptimum+4C5j + ; CEncoder_GetOptimum+550j + mov eax, 1 + cmp [esp+90h+var_7C], eax + mov [esp+90h+var_78], eax + jz loc_4CF1D0 + mov esi, eax + jmp short loc_4CE5D5 +; --------------------------------------------------------------------------- + +loc_4CE5D1: ; CODE XREF: CEncoder_GetOptimum+116Aj + mov esi, [esp+90h+var_78] + +loc_4CE5D5: ; CODE XREF: CEncoder_GetOptimum+56Fj + mov edx, [ebp+80h] + mov eax, [ebp+70h] + push edx + call eax + add esp, 4 + lea ecx, [esp+90h+var_4C] + push ecx + mov ecx, ebp + mov [esp+94h+var_60], eax + call sub_4CB3B0 + cmp eax, [ebp+32EF8h] + mov [esp+90h+var_28], eax + jnb loc_4CF1D7 + add [esp+90h+arg_0], 1 + lea edx, [esi+esi*4+1Eh] + mov bl, [ebp+edx*8+1] + test bl, bl + lea eax, [ebp+edx*8+0] + mov edx, [eax+10h] + jz short loc_4CE673 + sub edx, 1 + cmp byte ptr [eax+2], 0 + jz short loc_4CE660 + mov ecx, [eax+4] + add ecx, 6 + cmp dword ptr [eax+8], 4 + lea ecx, [ecx+ecx*4] + mov cl, [ebp+ecx*8+0] + movzx ecx, cl + jnb short loc_4CE64F + mov cl, ds:kRepNextStates[ecx] + movzx ecx, cl + mov cl, ds:kLiteralNextStates[ecx] + jmp short loc_4CE67B +; --------------------------------------------------------------------------- + +loc_4CE64F: ; CODE XREF: CEncoder_GetOptimum+5DCj + mov cl, ds:kMatchNextStates[ecx] + movzx ecx, cl + mov cl, ds:kLiteralNextStates[ecx] + jmp short loc_4CE67B +; --------------------------------------------------------------------------- + +loc_4CE660: ; CODE XREF: CEncoder_GetOptimum+5C6j + lea ecx, [edx+edx*4+1Eh] + mov cl, [ebp+ecx*8+0] + movzx ecx, cl + mov cl, ds:kLiteralNextStates[ecx] + jmp short loc_4CE67B +; --------------------------------------------------------------------------- + +loc_4CE673: ; CODE XREF: CEncoder_GetOptimum+5BDj + lea ecx, [edx+edx*4+1Eh] + mov cl, [ebp+ecx*8+0] + +loc_4CE67B: ; CODE XREF: CEncoder_GetOptimum+5EDj + ; CEncoder_GetOptimum+5FEj ... + add esi, 0FFFFFFFFh + cmp edx, esi + jnz short loc_4CE6AC + cmp dword ptr [eax+14h], 0 + jnz short loc_4CE69A + movzx edx, cl + mov bl, ds:kShortRepNextStates[edx] + mov byte ptr [esp+90h+var_64], bl + jmp loc_4CE754 +; --------------------------------------------------------------------------- + +loc_4CE69A: ; CODE XREF: CEncoder_GetOptimum+626j + movzx ecx, cl + mov bl, ds:kLiteralNextStates[ecx] + mov byte ptr [esp+90h+var_64], bl + jmp loc_4CE754 +; --------------------------------------------------------------------------- + +loc_4CE6AC: ; CODE XREF: CEncoder_GetOptimum+620j + test bl, bl + jz short loc_4CE6CB + cmp byte ptr [eax+2], 0 + jz short loc_4CE6CB + mov edi, [eax+8] + mov edx, [eax+4] + movzx ecx, cl + mov bl, ds:kRepNextStates[ecx] + mov [esp+90h+var_68], edi + jmp short loc_4CE6EA +; --------------------------------------------------------------------------- + +loc_4CE6CB: ; CODE XREF: CEncoder_GetOptimum+64Ej + ; CEncoder_GetOptimum+654j + mov esi, [eax+14h] + cmp esi, 4 + mov [esp+90h+var_68], esi + movzx ecx, cl + mov edi, esi + jnb short loc_4CE6E4 + mov bl, ds:kRepNextStates[ecx] + jmp short loc_4CE6EA +; --------------------------------------------------------------------------- + +loc_4CE6E4: ; CODE XREF: CEncoder_GetOptimum+67Aj + mov bl, ds:kMatchNextStates[ecx] + +loc_4CE6EA: ; CODE XREF: CEncoder_GetOptimum+669j + ; CEncoder_GetOptimum+682j + cmp edi, 4 + lea edx, [edx+edx*4+1Eh] + mov byte ptr [esp+90h+var_64], bl + lea edx, [ebp+edx*8+0] + jnb short loc_4CE738 + mov ecx, [edx+edi*4+18h] + mov esi, 1 + cmp edi, esi + mov [esp+90h+var_20], ecx + jb short loc_4CE723 + mov ecx, edi + lea esi, [edx+18h] + lea edi, [esp+90h+var_1C] + rep movsd + mov esi, [esp+90h+var_68] + add esi, 1 + cmp esi, 4 + jnb short loc_4CE754 + +loc_4CE723: ; CODE XREF: CEncoder_GetOptimum+6AAj + lea edx, [edx+esi*4+18h] + mov ecx, 4 + lea edi, [esp+esi*4+90h+var_20] + sub ecx, esi + mov esi, edx + rep movsd + jmp short loc_4CE754 +; --------------------------------------------------------------------------- + +loc_4CE738: ; CODE XREF: CEncoder_GetOptimum+699j + mov ecx, [edx+18h] + mov [esp+90h+var_1C], ecx + mov ecx, [edx+1Ch] + mov edx, [edx+20h] + add edi, 0FFFFFFFCh + mov [esp+90h+var_20], edi + mov [esp+90h+var_18], ecx + mov [esp+90h+var_14], edx + +loc_4CE754: ; CODE XREF: CEncoder_GetOptimum+635j + ; CEncoder_GetOptimum+647j ... + mov ecx, [esp+90h+var_1C] + mov edx, [esp+90h+var_18] + mov edi, [esp+90h+var_20] + mov [eax], bl + mov [eax+1Ch], ecx + mov ecx, [esp+90h+var_14] + mov [eax+18h], edi + mov [eax+20h], edx + mov [eax+24h], ecx + mov esi, [eax+0Ch] + mov edx, [ebp+80h] + mov eax, [ebp+74h] + push edx + mov [esp+94h+var_3C], esi + call eax + movzx ecx, byte ptr [eax-1] + sub eax, 1 + mov edx, eax + mov byte ptr [esp+94h+var_5C], cl + sub edx, edi + movzx ecx, byte ptr [edx-1] + lea edi, [edx-1] + mov edx, [ebp+32654h] + mov byte ptr [esp+94h+var_58], cl + mov ecx, [ebp+33B60h] + and ecx, [esp+94h+arg_0] + mov [esp+94h+var_40], edi + movzx edi, bl + mov [esp+94h+var_54], ecx + mov [esp+94h+var_68], edi + add esp, 4 + shl edi, 4 + add edi, ecx + mov ecx, [esp+90h+var_5C] + push ecx + mov ecx, [esp+94h+var_58] + push ecx + cmp bl, 7 + mov ebx, [ebp+3265Ch] + setnb cl + and ebx, [esp+98h+arg_0] + mov [esp+98h+var_74], eax + movzx eax, byte ptr [eax-1] + push ecx + mov ecx, 8 + sub cl, dl + shr eax, cl + mov ecx, edx + shl ebx, cl + add eax, ebx + imul eax, 0C00h + add eax, [ebp+32650h] + mov ecx, eax + call sub_4CDAC0 + mov ecx, [ebp+edi*4+280F0h] + shr ecx, 2 + add eax, dword_550998[ecx*4] + mov ecx, [esp+90h+var_78] + add eax, esi + lea edx, [ecx+ecx*4+23h] + cmp eax, [ebp+edx*8+0Ch] + lea esi, [ebp+edx*8+0] + mov [esp+90h+var_7D], 0 + jnb short loc_4CE851 + mov [esi+0Ch], eax + mov [esi+10h], ecx + mov dword ptr [esi+14h], 0FFFFFFFFh + mov byte ptr [esi+1], 0 + mov [esp+90h+var_7D], 1 + +loc_4CE851: ; CODE XREF: CEncoder_GetOptimum+7D9j + mov ebx, [esp+90h+var_68] + mov edx, 800h + sub edx, [ebp+edi*4+280F0h] + shr edx, 2 + mov ecx, dword_550998[edx*4] + add ecx, [esp+90h+var_3C] + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + mov ebx, [esp+90h+var_78] + shr edx, 2 + mov edx, dword_550998[edx*4] + add edx, ecx + mov [esp+90h+var_24], ecx + mov cl, byte ptr [esp+90h+var_58] + cmp cl, byte ptr [esp+90h+var_5C] + mov [esp+90h+var_38], edx + jnz short loc_4CE8EB + cmp [esi+10h], ebx + jnb short loc_4CE8A8 + cmp dword ptr [esi+14h], 0 + jz short loc_4CE8EB + +loc_4CE8A8: ; CODE XREF: CEncoder_GetOptimum+840j + mov ecx, [esp+90h+var_68] + mov ecx, [ebp+ecx*4+28420h] + mov edi, [ebp+edi*4+284B0h] + shr ecx, 2 + mov ecx, dword_550998[ecx*4] + shr edi, 2 + add ecx, dword_550998[edi*4] + add ecx, edx + cmp ecx, [esi+0Ch] + ja short loc_4CE8EB + mov [esi+0Ch], ecx + mov [esi+10h], ebx + mov dword ptr [esi+14h], 0 + mov byte ptr [esi+1], 0 + mov [esp+90h+var_7D], 1 + +loc_4CE8EB: ; CODE XREF: CEncoder_GetOptimum+83Bj + ; CEncoder_GetOptimum+846j ... + mov edx, [esp+90h+var_60] + mov ecx, 0FFFh + sub ecx, ebx + cmp ecx, edx + jnb short loc_4CE900 + mov edx, ecx + mov [esp+90h+var_60], edx + +loc_4CE900: ; CODE XREF: CEncoder_GetOptimum+898j + cmp edx, 2 + mov ebx, edx + mov [esp+90h+var_6C], ebx + jb loc_4CF1BB + mov esi, [ebp+32EF8h] + mov edi, [esp+90h+var_60] + cmp edi, esi + jbe short loc_4CE923 + mov ebx, esi + mov [esp+90h+var_6C], esi + +loc_4CE923: ; CODE XREF: CEncoder_GetOptimum+8BBj + cmp [esp+90h+var_7D], 0 + jnz loc_4CEA90 + mov dl, byte ptr [esp+90h+var_5C] + cmp byte ptr [esp+90h+var_58], dl + jz loc_4CEA90 + lea ecx, [esi+1] + cmp edi, ecx + jb short loc_4CE945 + mov edi, ecx + +loc_4CE945: ; CODE XREF: CEncoder_GetOptimum+8E1j + mov esi, 1 + cmp edi, esi + jbe short loc_4CE975 + mov ebx, [esp+90h+var_74] + mov edx, [esp+90h+var_40] + lea ecx, [ebx+1] + sub edx, ebx + jmp short loc_4CE960 +; --------------------------------------------------------------------------- + align 10h + +loc_4CE960: ; CODE XREF: CEncoder_GetOptimum+8FBj + ; CEncoder_GetOptimum+90Fj + mov bl, [ecx] + cmp bl, [edx+ecx] + jnz short loc_4CE971 + add esi, 1 + add ecx, 1 + cmp esi, edi + jb short loc_4CE960 + +loc_4CE971: ; CODE XREF: CEncoder_GetOptimum+905j + mov ebx, [esp+90h+var_6C] + +loc_4CE975: ; CODE XREF: CEncoder_GetOptimum+8ECj + add esi, 0FFFFFFFFh + cmp esi, 2 + mov [esp+90h+var_50], esi + jb loc_4CEA90 + mov ecx, [esp+90h+var_68] + mov dl, ds:kLiteralNextStates[ecx] + mov ecx, [esp+90h+arg_0] + movzx ebx, dl + add ecx, 1 + and ecx, [ebp+33B60h] + mov edx, ebx + shl edx, 4 + lea esi, [edx+ecx] + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + mov edi, 800h + sub edi, [ebp+esi*4+280F0h] + shr edx, 2 + mov edx, dword_550998[edx*4] + shr edi, 2 + add edx, dword_550998[edi*4] + mov edi, [esp+90h+var_78] + add edx, eax + mov eax, [esp+90h+var_50] + lea edi, [eax+edi+1] + mov eax, [esp+90h+var_7C] + cmp eax, edi + mov [esp+90h+var_40], esi + jnb short loc_4CEA22 + mov esi, [esp+90h+var_7C] + lea eax, [eax+eax*4] + lea eax, [ebp+eax*8+0FCh] + mov [esp+90h+var_3C], eax + mov eax, edi + sub eax, esi + add esi, eax + mov [esp+90h+var_7C], esi + mov esi, [esp+90h+var_3C] + +loc_4CEA10: ; CODE XREF: CEncoder_GetOptimum+9BCj + add esi, 28h + sub eax, 1 + mov dword ptr [esi], 0FFFFFFFh + jnz short loc_4CEA10 + mov esi, [esp+90h+var_40] + +loc_4CEA22: ; CODE XREF: CEncoder_GetOptimum+98Ej + imul ecx, 110h + add ecx, [esp+90h+var_50] + mov eax, 800h + sub eax, [ebp+esi*4+284B0h] + mov esi, [ebp+ebx*4+28420h] + mov ebx, [esp+90h+var_6C] + shr eax, 2 + mov eax, dword_550998[eax*4] + shr esi, 2 + add eax, dword_550998[esi*4] + mov esi, [esp+90h+var_7C] + add eax, [ebp+ecx*4+2E204h] + lea ecx, [edi+edi*4+1Eh] + add eax, edx + cmp eax, [ebp+ecx*8+0Ch] + lea ecx, [ebp+ecx*8+0] + jnb short loc_4CEA94 + mov edx, [esp+90h+var_78] + add edx, 1 + mov [ecx+0Ch], eax + mov [ecx+10h], edx + mov dword ptr [ecx+14h], 0 + mov byte ptr [ecx+1], 1 + mov byte ptr [ecx+2], 0 + jmp short loc_4CEA94 +; --------------------------------------------------------------------------- + +loc_4CEA90: ; CODE XREF: CEncoder_GetOptimum+8C8j + ; CEncoder_GetOptimum+8D6j ... + mov esi, [esp+90h+var_7C] + +loc_4CEA94: ; CODE XREF: CEncoder_GetOptimum+A10j + ; CEncoder_GetOptimum+A2Ej + mov [esp+90h+var_70], 0 + mov ecx, [esp+90h+var_70] + mov [esp+90h+var_40], 2 + jmp short loc_4CEAB8 +; --------------------------------------------------------------------------- + align 10h + +loc_4CEAB0: ; CODE XREF: CEncoder_GetOptimum+D63j + mov ebx, [esp+90h+var_6C] + mov esi, [esp+90h+var_7C] + +loc_4CEAB8: ; CODE XREF: CEncoder_GetOptimum+A48j + mov edx, [esp+90h+var_74] + mov eax, edx + sub eax, [esp+ecx*4+90h+var_20] + mov cl, [edx] + sub eax, 1 + cmp cl, [eax] + mov [esp+90h+var_48], eax + jnz loc_4CEDB5 + mov cl, [edx+1] + cmp cl, [eax+1] + jnz loc_4CEDB5 + mov edi, 2 + cmp ebx, edi + jbe short loc_4CEB01 + lea ecx, [edx+2] + sub eax, edx + lea ecx, [ecx+0] + +loc_4CEAF0: ; CODE XREF: CEncoder_GetOptimum+A9Fj + mov dl, [ecx] + cmp dl, [eax+ecx] + jnz short loc_4CEB01 + add edi, 1 + add ecx, 1 + cmp edi, ebx + jb short loc_4CEAF0 + +loc_4CEB01: ; CODE XREF: CEncoder_GetOptimum+A86j + ; CEncoder_GetOptimum+A95j + mov eax, [esp+90h+var_78] + lea ebx, [edi+eax] + cmp esi, ebx + jnb short loc_4CEB2E + mov eax, ebx + lea ecx, [esi+esi*4] + sub eax, esi + add esi, eax + lea ecx, [ebp+ecx*8+0FCh] + mov [esp+90h+var_7C], esi + +loc_4CEB20: ; CODE XREF: CEncoder_GetOptimum+ACCj + add ecx, 28h + sub eax, 1 + mov dword ptr [ecx], 0FFFFFFFh + jnz short loc_4CEB20 + +loc_4CEB2E: ; CODE XREF: CEncoder_GetOptimum+AAAj + mov edx, [esp+90h+var_54] + mov eax, [esp+90h+var_64] + mov ecx, [esp+90h+var_70] + push edx + push eax + push ecx + mov ecx, ebp + mov esi, edi + call sub_4CD9B0 + add eax, [esp+90h+var_38] + mov ecx, [esp+90h+var_54] + imul ecx, 110h + lea edx, [edi+ecx] + mov [esp+90h+var_34], ecx + lea ecx, [ebp+edx*4+2E204h] + mov [esp+90h+var_50], ecx + lea edx, [ebx+ebx*4] + mov ebx, [esp+90h+var_50] + mov [esp+90h+var_2C], eax + lea ecx, [ebp+edx*8+0FCh] + +loc_4CEB78: ; CODE XREF: CEncoder_GetOptimum+B40j + mov edx, [ebx] + add edx, eax + cmp edx, [ecx] + jnb short loc_4CEB94 + mov [ecx], edx + mov edx, [esp+90h+var_78] + mov [ecx+4], edx + mov edx, [esp+90h+var_70] + mov [ecx+8], edx + mov byte ptr [ecx-0Bh], 0 + +loc_4CEB94: ; CODE XREF: CEncoder_GetOptimum+B1Ej + sub edi, 1 + sub ebx, 4 + sub ecx, 28h + cmp edi, 2 + jnb short loc_4CEB78 + cmp [esp+90h+var_70], 0 + jnz short loc_4CEBB0 + lea eax, [esi+1] + mov [esp+90h+var_40], eax + +loc_4CEBB0: ; CODE XREF: CEncoder_GetOptimum+B47j + mov ecx, [ebp+32EF8h] + mov edx, [esp+90h+var_60] + lea eax, [esi+1] + add ecx, eax + cmp edx, ecx + jnb short loc_4CEBC5 + mov ecx, edx + +loc_4CEBC5: ; CODE XREF: CEncoder_GetOptimum+B61j + cmp eax, ecx + jnb short loc_4CEBE7 + mov ebx, [esp+90h+var_74] + mov edi, [esp+90h+var_48] + lea edx, [eax+ebx] + sub edi, ebx + +loc_4CEBD6: ; CODE XREF: CEncoder_GetOptimum+B85j + mov bl, [edx] + cmp bl, [edx+edi] + jnz short loc_4CEBE7 + add eax, 1 + add edx, 1 + cmp eax, ecx + jb short loc_4CEBD6 + +loc_4CEBE7: ; CODE XREF: CEncoder_GetOptimum+B67j + ; CEncoder_GetOptimum+B7Bj + or ecx, 0FFFFFFFFh + sub ecx, esi + add eax, ecx + cmp eax, 2 + mov [esp+90h+var_44], eax + jb loc_4CEDB5 + mov edx, [esp+90h+var_68] + mov cl, ds:kRepNextStates[edx] + mov eax, [ebp+33B60h] + mov edi, [esp+90h+arg_0] + movzx ecx, cl + mov ebx, eax + lea edx, [esi+edi] + and ebx, edx + mov edx, ecx + mov cl, ds:kLiteralNextStates[ecx] + shl edx, 4 + add ebx, edx + mov edx, [ebp+ebx*4+280F0h] + movzx ebx, cl + shr edx, 2 + mov edx, dword_550998[edx*4] + mov [esp+90h+var_30], edx + lea edi, [esi+edi+1] + and edi, eax + mov eax, [ebp+32654h] + mov ecx, ebx + shl ecx, 4 + add ecx, edi + mov [esp+90h+var_50], ecx + mov ecx, [esp+90h+var_74] + movzx edx, byte ptr [esi+ecx] + push edx + mov edx, [esp+94h+var_48] + movzx edx, byte ptr [esi+edx] + push edx + movzx edx, byte ptr [ecx+esi-1] + mov ecx, 8 + sub cl, al + shr edx, cl + mov ecx, [esp+98h+arg_0] + lea eax, [esi+ecx] + mov ecx, [ebp+3265Ch] + and ecx, eax + mov eax, ecx + mov ecx, [ebp+32654h] + shl eax, cl + push 1 + add edx, eax + imul edx, 0C00h + add edx, [ebp+32650h] + mov ecx, edx + call sub_4CDAC0 + mov ecx, [esp+90h+var_50] + mov edx, 800h + sub edx, [ebp+ecx*4+280F0h] + mov ecx, [esp+90h+var_34] + shr edx, 2 + add eax, dword_550998[edx*4] + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + shr edx, 2 + add eax, dword_550998[edx*4] + lea edx, [esi+ecx] + add eax, [ebp+edx*4+2E204h] + mov ecx, [esp+90h+var_44] + add eax, [esp+90h+var_30] + mov edx, [esp+90h+var_78] + add eax, [esp+90h+var_2C] + add ecx, esi + lea ecx, [ecx+edx+1] + cmp [esp+90h+var_7C], ecx + mov [esp+90h+var_30], ecx + jnb short loc_4CED3E + mov edx, [esp+90h+var_7C] + lea edx, [edx+edx*4] + lea edx, [ebp+edx*8+0FCh] + mov [esp+90h+var_2C], edx + mov edx, [esp+90h+var_7C] + sub ecx, edx + add edx, ecx + mov [esp+90h+var_7C], edx + mov edx, [esp+90h+var_2C] + jmp short loc_4CED30 +; --------------------------------------------------------------------------- + align 10h + +loc_4CED30: ; CODE XREF: CEncoder_GetOptimum+CCBj + ; CEncoder_GetOptimum+CDCj + add edx, 28h + sub ecx, 1 + mov dword ptr [edx], 0FFFFFFFh + jnz short loc_4CED30 + +loc_4CED3E: ; CODE XREF: CEncoder_GetOptimum+CA7j + mov edx, [esp+90h+var_50] + imul edi, 110h + add edi, [esp+90h+var_44] + mov ecx, 800h + sub ecx, [ebp+edx*4+284B0h] + mov edx, [ebp+ebx*4+28420h] + shr ecx, 2 + mov ecx, dword_550998[ecx*4] + shr edx, 2 + add ecx, dword_550998[edx*4] + add ecx, [ebp+edi*4+2E204h] + add ecx, eax + mov eax, [esp+90h+var_30] + lea eax, [eax+eax*4+1Eh] + cmp ecx, [ebp+eax*8+0Ch] + lea eax, [ebp+eax*8+0] + jnb short loc_4CEDB5 + mov [eax+0Ch], ecx + mov ecx, [esp+90h+var_78] + lea edx, [esi+ecx+1] + mov [eax+4], ecx + mov ecx, [esp+90h+var_70] + mov [eax+10h], edx + mov dword ptr [eax+14h], 0 + mov byte ptr [eax+1], 1 + mov byte ptr [eax+2], 1 + mov [eax+8], ecx + +loc_4CEDB5: ; CODE XREF: CEncoder_GetOptimum+A6Dj + ; CEncoder_GetOptimum+A79j ... + mov ecx, [esp+90h+var_70] + add ecx, 1 + cmp ecx, 4 + mov [esp+90h+var_70], ecx + jb loc_4CEAB0 + mov edx, [esp+90h+var_28] + mov ecx, [esp+90h+var_6C] + cmp edx, ecx + jbe short loc_4CEDFB + xor eax, eax + cmp ecx, [ebp+32660h] + mov edx, ecx + jbe short loc_4CEDED + +loc_4CEDE1: ; CODE XREF: CEncoder_GetOptimum+D8Bj + add eax, 2 + cmp ecx, [ebp+eax*4+32660h] + ja short loc_4CEDE1 + +loc_4CEDED: ; CODE XREF: CEncoder_GetOptimum+D7Fj + mov [ebp+eax*4+32660h], ecx + add eax, 2 + mov [esp+90h+var_4C], eax + +loc_4CEDFB: ; CODE XREF: CEncoder_GetOptimum+D73j + mov esi, [esp+90h+var_40] + cmp edx, esi + jb loc_4CF1BB + mov eax, [esp+90h+var_68] + mov ecx, [ebp+eax*4+283F0h] + shr ecx, 2 + mov eax, dword_550998[ecx*4] + add eax, [esp+90h+var_24] + mov ecx, [esp+90h+var_7C] + mov [esp+90h+var_40], eax + mov eax, [esp+90h+var_78] + add eax, edx + cmp ecx, eax + jnb short loc_4CEE52 + lea edx, [ecx+ecx*4] + sub eax, ecx + add ecx, eax + lea edx, [ebp+edx*8+0FCh] + mov [esp+90h+var_7C], ecx + +loc_4CEE44: ; CODE XREF: CEncoder_GetOptimum+DF0j + add edx, 28h + sub eax, 1 + mov dword ptr [edx], 0FFFFFFFh + jnz short loc_4CEE44 + +loc_4CEE52: ; CODE XREF: CEncoder_GetOptimum+DD0j + xor eax, eax + cmp esi, [ebp+32660h] + mov [esp+90h+var_70], eax + jbe short loc_4CEE70 + +loc_4CEE60: ; CODE XREF: CEncoder_GetOptimum+E0Aj + add eax, 2 + cmp esi, [ebp+eax*4+32660h] + ja short loc_4CEE60 + mov [esp+90h+var_70], eax + +loc_4CEE70: ; CODE XREF: CEncoder_GetOptimum+DFEj + lea ebx, ds:0[eax*4] + mov edx, [ebx+ebp+32664h] + mov ecx, 7FFFFh + sub ecx, edx + sar ecx, 1Fh + and ecx, 0Ch + add ecx, 6 + mov eax, edx + shr eax, cl + mov [esp+90h+var_6C], edx + lea edi, [esi+1] + movzx eax, byte ptr dword_551198[eax] + lea ecx, [eax+ecx*2] + mov eax, [esp+90h+var_54] + imul eax, 110h + add eax, esi + lea eax, [ebp+eax*4+295B8h] + mov [esp+90h+var_3C], ecx + mov ecx, [esp+90h+var_78] + mov [esp+90h+var_54], eax + lea eax, [esi+ecx] + lea eax, [eax+eax*4] + lea ecx, [ebp+eax*8+0FCh] + mov [esp+90h+var_50], ecx + +loc_4CEED3: ; CODE XREF: CEncoder_GetOptimum+1156j + lea eax, [edi-3] + cmp eax, 4 + jb short loc_4CEEE0 + mov eax, 3 + +loc_4CEEE0: ; CODE XREF: CEncoder_GetOptimum+E79j + cmp edx, 80h + jnb short loc_4CEEF6 + shl eax, 7 + add eax, edx + mov eax, [ebp+eax*4+33314h] + jmp short loc_4CEF10 +; --------------------------------------------------------------------------- + +loc_4CEEF6: ; CODE XREF: CEncoder_GetOptimum+E86j + shl eax, 6 + add eax, [esp+90h+var_3C] + mov esi, edx + mov eax, [ebp+eax*4+32F14h] + and esi, 0Fh + add eax, [ebp+esi*4+33B14h] + +loc_4CEF10: ; CODE XREF: CEncoder_GetOptimum+E94j + add eax, [esp+90h+var_40] + mov esi, [esp+90h+var_54] + add eax, [esi] + cmp eax, [ecx] + mov [esp+90h+var_2C], eax + jnb short loc_4CEF35 + mov [ecx], eax + mov eax, [esp+90h+var_78] + add edx, 4 + mov [ecx+4], eax + mov [ecx+8], edx + mov byte ptr [ecx-0Bh], 0 + +loc_4CEF35: ; CODE XREF: CEncoder_GetOptimum+EC0j + lea eax, [edi-1] + cmp eax, [ebx+ebp+32660h] + jnz loc_4CF1A1 + mov ebx, [esp+90h+var_74] + mov eax, [ebp+32EF8h] + mov esi, [esp+90h+var_60] + mov edx, ebx + sub edx, [esp+90h+var_6C] + add eax, edi + sub edx, 1 + cmp esi, eax + mov ecx, edi + jnb short loc_4CEF6C + mov eax, esi + mov [esp+90h+var_44], esi + jmp short loc_4CEF70 +; --------------------------------------------------------------------------- + +loc_4CEF6C: ; CODE XREF: CEncoder_GetOptimum+F02j + mov [esp+90h+var_44], eax + +loc_4CEF70: ; CODE XREF: CEncoder_GetOptimum+F0Aj + cmp edi, eax + jnb short loc_4CEF93 + lea esi, [edi+edx] + sub ebx, edx + lea esp, [esp+0] + +loc_4CEF80: ; CODE XREF: CEncoder_GetOptimum+F31j + mov al, [ebx+esi] + cmp al, [esi] + jnz short loc_4CEF93 + add ecx, 1 + add esi, 1 + cmp ecx, [esp+90h+var_44] + jb short loc_4CEF80 + +loc_4CEF93: ; CODE XREF: CEncoder_GetOptimum+F12j + ; CEncoder_GetOptimum+F25j + or esi, 0FFFFFFFFh + lea eax, [edi-1] + sub esi, eax + add ecx, esi + cmp ecx, 2 + mov [esp+90h+var_48], ecx + jb loc_4CF157 + mov ecx, [esp+90h+var_68] + mov bl, ds:kMatchNextStates[ecx] + mov ecx, [ebp+33B60h] + mov eax, [esp+90h+arg_0] + lea esi, [edi+eax-1] + mov eax, ecx + and eax, esi + movzx esi, bl + movzx edx, byte ptr [edi+edx-1] + mov ebx, esi + shl ebx, 4 + add ebx, eax + mov ebx, [ebp+ebx*4+280F0h] + shr ebx, 2 + mov ebx, dword_550998[ebx*4] + mov [esp+90h+var_28], ebx + mov bl, ds:kLiteralNextStates[esi] + lea esi, [eax+1] + mov eax, [ebp+32654h] + and esi, ecx + movzx ebx, bl + mov ecx, ebx + shl ecx, 4 + add ecx, esi + mov [esp+90h+var_44], ecx + mov ecx, [esp+90h+var_74] + movzx ecx, byte ptr [ecx+edi-1] + push ecx + mov ecx, [esp+94h+var_74] + push edx + movzx edx, byte ptr [edi+ecx-2] + mov ecx, 8 + sub cl, al + shr edx, cl + mov ecx, [esp+98h+arg_0] + lea eax, [edi+ecx-1] + mov ecx, [ebp+3265Ch] + and ecx, eax + mov eax, ecx + mov ecx, [ebp+32654h] + shl eax, cl + push 1 + add edx, eax + imul edx, 0C00h + add edx, [ebp+32650h] + mov ecx, edx + call sub_4CDAC0 + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + mov ecx, 800h + shr edx, 2 + add eax, dword_550998[edx*4] + mov edx, [esp+90h+var_44] + sub ecx, [ebp+edx*4+280F0h] + mov edx, [esp+90h+var_78] + shr ecx, 2 + add eax, dword_550998[ecx*4] + mov ecx, [esp+90h+var_48] + add eax, [esp+90h+var_28] + add ecx, edx + add eax, [esp+90h+var_2C] + add ecx, edi + cmp [esp+90h+var_7C], ecx + mov [esp+90h+var_28], ecx + jnb short loc_4CF0DE + mov edx, [esp+90h+var_7C] + lea edx, [edx+edx*4] + lea edx, [ebp+edx*8+0FCh] + mov [esp+90h+var_24], edx + mov edx, [esp+90h+var_7C] + sub ecx, edx + add edx, ecx + mov [esp+90h+var_7C], edx + mov edx, [esp+90h+var_24] + lea ecx, [ecx+0] + +loc_4CF0D0: ; CODE XREF: CEncoder_GetOptimum+107Cj + add edx, 28h + sub ecx, 1 + mov dword ptr [edx], 0FFFFFFFh + jnz short loc_4CF0D0 + +loc_4CF0DE: ; CODE XREF: CEncoder_GetOptimum+1049j + mov edx, [esp+90h+var_44] + imul esi, 110h + add esi, [esp+90h+var_48] + mov ecx, 800h + sub ecx, [ebp+edx*4+284B0h] + mov edx, [ebp+ebx*4+28420h] + shr ecx, 2 + mov ecx, dword_550998[ecx*4] + shr edx, 2 + add ecx, dword_550998[edx*4] + add ecx, [ebp+esi*4+2E204h] + add ecx, eax + mov eax, [esp+90h+var_28] + lea eax, [eax+eax*4+1Eh] + cmp ecx, [ebp+eax*8+0Ch] + lea eax, [ebp+eax*8+0] + jnb short loc_4CF157 + mov [eax+0Ch], ecx + mov ecx, [esp+90h+var_78] + lea edx, [ecx+edi] + mov [eax+4], ecx + mov ecx, [esp+90h+var_6C] + add ecx, 4 + mov [eax+10h], edx + mov dword ptr [eax+14h], 0 + mov byte ptr [eax+1], 1 + mov byte ptr [eax+2], 1 + mov [eax+8], ecx + +loc_4CF157: ; CODE XREF: CEncoder_GetOptimum+F44j + ; CEncoder_GetOptimum+10CCj + mov eax, [esp+90h+var_70] + add eax, 2 + cmp eax, [esp+90h+var_4C] + mov [esp+90h+var_70], eax + jz short loc_4CF1BB + lea ebx, ds:0[eax*4] + mov eax, [ebx+ebp+32664h] + cmp eax, 80h + mov [esp+90h+var_6C], eax + jb short loc_4CF1A1 + mov ecx, 7FFFFh + sub ecx, eax + sar ecx, 1Fh + and ecx, 0Ch + add ecx, 6 + shr eax, cl + movzx edx, byte ptr dword_551198[eax] + lea eax, [edx+ecx*2] + mov [esp+90h+var_3C], eax + +loc_4CF1A1: ; CODE XREF: CEncoder_GetOptimum+EDFj + ; CEncoder_GetOptimum+111Fj + add [esp+90h+var_50], 28h + add [esp+90h+var_54], 4 + mov ecx, [esp+90h+var_50] + mov edx, [esp+90h+var_6C] + add edi, 1 + jmp loc_4CEED3 +; --------------------------------------------------------------------------- + +loc_4CF1BB: ; CODE XREF: CEncoder_GetOptimum+8A9j + ; CEncoder_GetOptimum+DA1j ... + mov eax, [esp+90h+var_78] + add eax, 1 + cmp eax, [esp+90h+var_7C] + mov [esp+90h+var_78], eax + jnz loc_4CE5D1 + +loc_4CF1D0: ; CODE XREF: CEncoder_GetOptimum+567j + mov ecx, [esp+90h+var_78] + push ecx + jmp short loc_4CF1EF +; --------------------------------------------------------------------------- + +loc_4CF1D7: ; CODE XREF: CEncoder_GetOptimum+59Ej + mov ecx, [esp+90h+var_4C] + mov [ebp+32F00h], ecx + mov [ebp+32EFCh], eax + mov byte ptr [ebp+32F10h], 1 + push esi + +loc_4CF1EF: ; CODE XREF: CEncoder_GetOptimum+1175j + mov edx, [esp+94h+arg_4] + push edx + mov ecx, ebp + call sub_4CB2E0 + pop edi + pop ebx + pop esi + pop ebp + add esp, 80h + retn 8 +CEncoder_GetOptimum endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CF210: ; DATA XREF: CEncoder_CodeOneBlock+44o + mov edx, [esp+10h] + mov eax, [esp+4] + mov eax, [eax+4] + mov ecx, [eax] + push edx + mov edx, [esp+10h] + push edx + mov edx, [esp+10h] + push edx + push eax + mov eax, [ecx+0Ch] + call eax + retn +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_FillDistancesPrices proc near ; CODE XREF: CEncoder_SetStreams+4Fp + ; CEncoder_CodeOneBlock+751p + +var_20C = dword ptr -20Ch +var_208 = dword ptr -208h +var_204 = dword ptr -204h +var_200 = dword ptr -200h + + sub esp, 20Ch + push ebx + push ebp + push esi + push edi + mov ebx, ecx + mov esi, 4 + +loc_4CF241: ; CODE XREF: CEncoder_FillDistancesPrices+80j + cmp esi, 2000h + jnb short loc_4CF252 + movzx edx, byte ptr dword_551198[esi] + jmp short loc_4CF27A +; --------------------------------------------------------------------------- + +loc_4CF252: ; CODE XREF: CEncoder_FillDistancesPrices+17j + cmp esi, 2000000h + jnb short loc_4CF26B + mov eax, esi + shr eax, 0Ch + movzx edx, byte ptr dword_551198[eax] + add edx, 18h + jmp short loc_4CF27A +; --------------------------------------------------------------------------- + +loc_4CF26B: ; CODE XREF: CEncoder_FillDistancesPrices+28j + mov ecx, esi + shr ecx, 18h + movzx edx, byte ptr dword_551198[ecx] + add edx, 30h + +loc_4CF27A: ; CODE XREF: CEncoder_FillDistancesPrices+20j + ; CEncoder_FillDistancesPrices+39j + mov ecx, edx + mov eax, edx + and eax, 1 + shr ecx, 1 + sub ecx, 1 + or eax, 2 + shl eax, cl + mov edi, esi + sub edi, eax + push edi + sub eax, edx + push ecx + lea edx, [ebx+eax*4+28BACh] + push edx + call sub_4CD860 + mov [esp+esi*4+228h+var_200], eax + add esi, 1 + add esp, 0Ch + cmp esi, 80h + jb short loc_4CF241 + lea ebp, [esp+21Ch+var_200] + sub ebp, ebx + lea esi, [ebx+3331Ch] + sub ebp, 33314h + lea edx, [ebx+32F14h] + mov [esp+21Ch+var_20C], esi + mov [esp+21Ch+var_208], ebp + mov [esp+21Ch+var_204], 4 + jmp short loc_4CF2E4 +; --------------------------------------------------------------------------- + align 10h + +loc_4CF2E0: ; CODE XREF: CEncoder_FillDistancesPrices+1BDj + mov esi, [esp+21Ch+var_20C] + +loc_4CF2E4: ; CODE XREF: CEncoder_FillDistancesPrices+AAj + xor edi, edi + cmp [ebx+33B58h], edi + jbe short loc_4CF33F + mov edi, edi + +loc_4CF2F0: ; CODE XREF: CEncoder_FillDistancesPrices+109j + mov ecx, edi + or ecx, 40h + xor esi, esi + cmp ecx, 1 + jz short loc_4CF32D + lea esp, [esp+0] + +loc_4CF300: ; CODE XREF: CEncoder_FillDistancesPrices+F7j + mov eax, ecx + shr ecx, 1 + mov ebp, [edx+ecx*4-0A764h] + and eax, 1 + sub ebp, eax + neg eax + xor ebp, eax + shr ebp, 2 + and ebp, 1FFh + add esi, dword_550998[ebp*4] + cmp ecx, 1 + jnz short loc_4CF300 + mov ebp, [esp+21Ch+var_208] + +loc_4CF32D: ; CODE XREF: CEncoder_FillDistancesPrices+CAj + mov [edx+edi*4], esi + add edi, 1 + cmp edi, [ebx+33B58h] + jb short loc_4CF2F0 + mov esi, [esp+21Ch+var_20C] + +loc_4CF33F: ; CODE XREF: CEncoder_FillDistancesPrices+BCj + mov eax, 0Eh + cmp [ebx+33B58h], eax + jbe short loc_4CF368 + lea esp, [esp+0] + +loc_4CF350: ; CODE XREF: CEncoder_FillDistancesPrices+136j + mov ecx, eax + shr ecx, 1 + sub ecx, 5 + shl ecx, 6 + add [edx+eax*4], ecx + add eax, 1 + cmp eax, [ebx+33B58h] + jb short loc_4CF350 + +loc_4CF368: ; CODE XREF: CEncoder_FillDistancesPrices+11Aj + mov eax, [edx] + mov [esi-8], eax + mov ecx, [edx+4] + mov [esi-4], ecx + mov eax, [edx+8] + mov [esi], eax + mov ecx, [edx+0Ch] + mov [esi+4], ecx + mov eax, 4 + add esi, 8 + +loc_4CF386: ; CODE XREF: CEncoder_FillDistancesPrices+19Ej + cmp eax, 2000h + jnb short loc_4CF396 + movzx ecx, byte ptr dword_551198[eax] + jmp short loc_4CF3BB +; --------------------------------------------------------------------------- + +loc_4CF396: ; CODE XREF: CEncoder_FillDistancesPrices+15Bj + cmp eax, 2000000h + mov ecx, eax + jnb short loc_4CF3AE + shr ecx, 0Ch + movzx ecx, byte ptr dword_551198[ecx] + add ecx, 18h + jmp short loc_4CF3BB +; --------------------------------------------------------------------------- + +loc_4CF3AE: ; CODE XREF: CEncoder_FillDistancesPrices+16Dj + shr ecx, 18h + movzx ecx, byte ptr dword_551198[ecx] + add ecx, 30h + +loc_4CF3BB: ; CODE XREF: CEncoder_FillDistancesPrices+164j + ; CEncoder_FillDistancesPrices+17Cj + mov ecx, [edx+ecx*4] + add ecx, [esi+ebp] + add eax, 1 + mov [esi], ecx + add esi, 4 + cmp eax, 80h + jb short loc_4CF386 + add [esp+21Ch+var_20C], 200h + sub ebp, 200h + add edx, 100h + sub [esp+21Ch+var_204], 1 + mov [esp+21Ch+var_208], ebp + jnz loc_4CF2E0 + pop edi + pop esi + pop ebp + mov dword ptr [ebx+33B70h], 0 + pop ebx + add esp, 20Ch + retn +CEncoder_FillDistancesPrices endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_FillAlignPrices proc near ; CODE XREF: CEncoder_SetStreams+56p + ; CEncoder_CodeOneBlock+761p + push ebx + push ebp + push esi + mov ebp, ecx + push edi + xor esi, esi + lea ebx, [ebp+28D78h] + lea edi, [ebp+33B14h] + +loc_4CF424: ; CODE XREF: CEncoder_FillAlignPrices+27j + push esi + mov ecx, ebx + call sub_4CD810 + mov [edi], eax + add esi, 1 + add edi, 4 + cmp esi, 10h + jb short loc_4CF424 + pop edi + pop esi + mov dword ptr [ebp+33B54h], 0 + pop ebp + pop ebx + retn +CEncoder_FillAlignPrices endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF810 proc near ; CODE XREF: sub_4D0250+3p + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 + + push 0FFFFFFFFh + push offset loc_4DA0C9 + mov eax, dword ptr fs:[0] + push eax + push ecx + push ebx + push esi + mov eax, dword_544960 + xor eax, esp + push eax + lea eax, [esp+1Ch+var_C] + mov dword ptr fs:[0], eax + mov esi, ecx + mov [esp+1Ch+var_10], esi + mov dword ptr [esi], offset NCompress_NLZMA_CEncoder_vftable + mov dword ptr [esi+4], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStream + mov dword ptr [esi+8], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderProperties + mov dword ptr [esi+0Ch], offset NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderProperties + mov eax, [esi+0A4h] + push eax ; lpAddress + mov [esp+20h+var_4], 1 + call off_546E24 + xor ebx, ebx + add esp, 4 + cmp [esi+0D0h], ebx + mov [esi+0A4h], ebx + jnz short loc_4CF892 + mov ecx, [esi+0B4h] + push ecx ; lpAddress + call off_546E24 + add esp, 4 + mov [esi+0B4h], ebx + +loc_4CF892: ; CODE XREF: sub_4CF810+6Aj + mov eax, [esi+33B8Ch] + cmp eax, ebx + jz short loc_4CF8A4 + mov edx, [eax] + push eax + mov eax, [edx+8] + call eax + +loc_4CF8A4: ; CODE XREF: sub_4CF810+8Aj + lea ecx, [esi+32650h] + mov byte ptr [esp+1Ch+var_4], bl + call sub_4CD8F0 + mov eax, [esi+40h] + cmp eax, ebx + mov [esp+1Ch+var_4], 0FFFFFFFFh + jz short loc_4CF8CF + push 8000h ; dwFreeType + push ebx ; dwSize + push eax ; lpAddress + call ds:VirtualFree + +loc_4CF8CF: ; CODE XREF: sub_4CF810+B0j + mov [esi+40h], ebx + mov esi, [esi+54h] + cmp esi, ebx + jz short loc_4CF8E1 + mov ecx, [esi] + mov edx, [ecx+8] + push esi + call edx + +loc_4CF8E1: ; CODE XREF: sub_4CF810+C7j + mov ecx, [esp+1Ch+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop esi + pop ebx + add esp, 10h + retn +sub_4CF810 endp + +; =============== S U B R O U T I N E ======================================= + +; int __stdcall sub_4CF900(int, void *Buf1, int) +sub_4CF900 proc near ; CODE XREF: sub_4CFA20+5j + ; ICompressSetCoderProperties_QueryInterface+5j ... + +arg_0 = dword ptr 4 +Buf1 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push esi + mov esi, [esp+4+Buf1] + push offset dword_512730 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF94C + +loc_4CF917: ; CODE XREF: sub_4CF900+5Cj + mov eax, [esp+4+arg_0] + test eax, eax + jz short loc_4CF936 + mov edx, [esp+4+arg_8] + lea ecx, [eax+4] + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF936: ; CODE XREF: sub_4CF900+1Dj + ; sub_4CF900+76j ... + mov edx, [esp+4+arg_8] + xor ecx, ecx + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF94C: ; CODE XREF: sub_4CF900+15j + push offset dword_5535A0 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jnz short loc_4CF917 + push offset dword_5535B0 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF98F + mov eax, [esp+4+arg_0] + test eax, eax + jz short loc_4CF936 + mov edx, [esp+4+arg_8] + lea ecx, [eax+8] + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF98F: ; CODE XREF: sub_4CF900+6Ej + push offset dword_5535C0 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF9C0 + mov eax, [esp+4+arg_0] + test eax, eax + jz short loc_4CF936 + mov edx, [esp+4+arg_8] + lea ecx, [eax+0Ch] + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF9C0: ; CODE XREF: sub_4CF900+9Fj + mov eax, 80004002h + pop esi + retn 0Ch +sub_4CF900 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CF9D0 proc near ; CODE XREF: ICompressSetCoderProperties_AddRef+5j + ; sub_4CFA10+5j ... + +arg_0 = dword ptr 4 + + mov eax, [esp+arg_0] + add dword ptr [eax+24h], 1 + mov eax, [eax+24h] + retn 4 +sub_4CF9D0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CF9E0 proc near ; CODE XREF: sub_4CFA40+5j + ; ICompressSetCoderProperties_Release+5j ... + +arg_0 = dword ptr 4 + + mov ecx, [esp+arg_0] + add dword ptr [ecx+24h], 0FFFFFFFFh + mov eax, [ecx+24h] + jnz short locret_4CF9F8 + mov eax, [ecx] + mov edx, [eax+10h] + push 1 + call edx + xor eax, eax + +locret_4CF9F8: ; CODE XREF: sub_4CF9E0+Bj + retn 4 +sub_4CF9E0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +ICompressSetCoderProperties_AddRef proc near ; DATA XREF: .rdata:00517AD4o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 8 + jmp sub_4CF9D0 +ICompressSetCoderProperties_AddRef endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA10 proc near ; DATA XREF: .rdata:00517AC0o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 0Ch + jmp sub_4CF9D0 +sub_4CFA10 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA20 proc near ; DATA XREF: .rdata:NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStreamo + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 4 + jmp sub_4CF900 +sub_4CFA20 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +ICompressSetCoderProperties_QueryInterface proc near ; DATA XREF: .rdata:NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderPropertieso + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 8 + jmp sub_4CF900 +ICompressSetCoderProperties_QueryInterface endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA40 proc near ; DATA XREF: .rdata:00517AECo + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 4 + jmp sub_4CF9E0 +sub_4CFA40 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA50 proc near ; DATA XREF: .rdata:NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderPropertieso + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + sub [esp+arg_0], 0Ch + jmp sub_4CF900 +sub_4CFA50 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +ICompressSetCoderProperties_Release proc near ; DATA XREF: .rdata:00517AD8o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 8 + jmp sub_4CF9E0 +ICompressSetCoderProperties_Release endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA70 proc near ; DATA XREF: .rdata:00517AC4o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 0Ch + jmp sub_4CF9E0 +sub_4CFA70 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA80 proc near ; DATA XREF: .rdata:00517AE8o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 4 + jmp sub_4CF9D0 +sub_4CFA80 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA90 proc near ; DATA XREF: .rdata:00517AF0o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push esi + mov esi, [esp+4+arg_4] + test esi, esi + push edi + mov edi, [esp+8+arg_0] + jz short loc_4CFAA6 + mov eax, [esi] + mov ecx, [eax+4] + push esi + call ecx + +loc_4CFAA6: ; CODE XREF: sub_4CFA90+Cj + mov eax, [edi+50h] + test eax, eax + jz short loc_4CFAB5 + mov edx, [eax] + push eax + mov eax, [edx+8] + call eax + +loc_4CFAB5: ; CODE XREF: sub_4CFA90+1Bj + mov [edi+50h], esi + pop edi + xor eax, eax + pop esi + retn 8 +sub_4CFA90 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CFAC0 proc near ; CODE XREF: CEncoder_CodeOneBlock+42Ap + ; CEncoder_CodeOneBlock+517p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + mov eax, [esp+arg_0] + push esi + mov esi, [eax+10h] + mov edx, esi + shr edx, 0Bh + imul edx, [ecx] + cmp [esp+4+arg_4], 0 + jnz short loc_4CFAEC + mov [eax+10h], edx + mov edx, [ecx] + mov esi, 800h + sub esi, edx + shr esi, 5 + add esi, edx + mov [ecx], esi + jmp short loc_4CFB03 +; --------------------------------------------------------------------------- + +loc_4CFAEC: ; CODE XREF: sub_4CFAC0+15j + add [eax+8], edx + adc dword ptr [eax+0Ch], 0 + sub esi, edx + mov [eax+10h], esi + mov edx, [ecx] + mov esi, edx + shr esi, 5 + sub edx, esi + mov [ecx], edx + +loc_4CFB03: ; CODE XREF: sub_4CFAC0+2Aj + mov ecx, [eax+10h] + cmp ecx, 1000000h + pop esi + jnb short locret_4CFB1C + shl ecx, 8 + mov [eax+10h], ecx + mov ecx, eax + call loc_4CF640 + +locret_4CFB1C: ; CODE XREF: sub_4CFAC0+4Dj + retn 8 +sub_4CFAC0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CFB20 proc near ; CODE XREF: sub_4D0020+52p + ; sub_4D0020+E4p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov ebx, 1 + mov edx, 3 + +loc_4CFB34: ; CODE XREF: sub_4CFB20+8Cj + mov edi, [esp+10h+arg_4] + sub edx, 1 + mov ecx, edx + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFB70 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFB8B +; --------------------------------------------------------------------------- + +loc_4CFB70: ; CODE XREF: sub_4CFB20+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFB8B: ; CODE XREF: sub_4CFB20+4Ej + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFBA6 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFBA6: ; CODE XREF: sub_4CFB20+73j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFB34 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFB20 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFBC0 proc near ; CODE XREF: sub_4D0020+136p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov ebx, 1 + mov edx, 8 + +loc_4CFBD4: ; CODE XREF: sub_4CFBC0+8Cj + mov edi, [esp+10h+arg_4] + sub edx, 1 + mov ecx, edx + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFC10 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFC2B +; --------------------------------------------------------------------------- + +loc_4CFC10: ; CODE XREF: sub_4CFBC0+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFC2B: ; CODE XREF: sub_4CFBC0+4Ej + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFC46 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFC46: ; CODE XREF: sub_4CFBC0+73j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFBD4 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFBC0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFC60 proc near ; CODE XREF: sub_4D0770+EDp + ; CEncoder_CodeOneBlock+67Cp + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov ebx, 1 + mov edx, 6 + +loc_4CFC74: ; CODE XREF: sub_4CFC60+8Cj + mov edi, [esp+10h+arg_4] + sub edx, 1 + mov ecx, edx + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFCB0 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFCCB +; --------------------------------------------------------------------------- + +loc_4CFCB0: ; CODE XREF: sub_4CFC60+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFCCB: ; CODE XREF: sub_4CFC60+4Ej + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFCE6 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFCE6: ; CODE XREF: sub_4CFC60+73j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFC74 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFC60 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFD00 proc near ; CODE XREF: sub_4D0770+109p + ; CEncoder_CodeOneBlock+6D5p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov edi, 1 + mov [esp+10h+arg_0], 4 + +loc_4CFD17: ; CODE XREF: sub_4CFD00+87j + mov ecx, [esi+10h] + mov ebx, [esp+10h+arg_4] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+edi*4+0] + and ebx, 1 + test ebx, ebx + jnz short loc_4CFD48 + mov [esi+10h], eax + mov eax, [ebp+edi*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+edi*4+0], ecx + jmp short loc_4CFD63 +; --------------------------------------------------------------------------- + +loc_4CFD48: ; CODE XREF: sub_4CFD00+2Dj + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+edi*4+0] + mov edx, eax + shr edx, 5 + sub eax, edx + mov [ebp+edi*4+0], eax + +loc_4CFD63: ; CODE XREF: sub_4CFD00+46j + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFD7A + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CFD7A: ; CODE XREF: sub_4CFD00+6Bj + shr [esp+10h+arg_4], 1 + add edi, edi + or edi, ebx + sub [esp+10h+arg_0], 1 + jnz short loc_4CFD17 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFD00 endp + + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFD90 proc near ; CODE XREF: CEncoder_CodeOneBlock+6AFp + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + mov eax, [esp+arg_8] + test eax, eax + push edi + mov edi, 1 + jle loc_4CFE26 + push ebx + push ebp + mov ebp, [esp+0Ch+arg_0] + push esi + mov esi, [esp+10h+arg_4] + mov [esp+10h+arg_8], eax + +loc_4CFDB1: ; CODE XREF: sub_4CFD90+91j + mov ecx, [esi+10h] + mov ebx, [esp+10h+arg_C] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+edi*4+0] + and ebx, 1 + test ebx, ebx + jnz short loc_4CFDE2 + mov [esi+10h], eax + mov eax, [ebp+edi*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+edi*4+0], ecx + jmp short loc_4CFDFD +; --------------------------------------------------------------------------- + +loc_4CFDE2: ; CODE XREF: sub_4CFD90+37j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+edi*4+0] + mov edx, eax + shr edx, 5 + sub eax, edx + mov [ebp+edi*4+0], eax + +loc_4CFDFD: ; CODE XREF: sub_4CFD90+50j + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFE14 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CFE14: ; CODE XREF: sub_4CFD90+75j + shr [esp+10h+arg_C], 1 + add edi, edi + or edi, ebx + sub [esp+10h+arg_8], 1 + jnz short loc_4CFDB1 + pop esi + pop ebp + pop ebx + +loc_4CFE26: ; CODE XREF: sub_4CFD90+Cj + pop edi + retn +sub_4CFD90 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFE30 proc near ; CODE XREF: CEncoder_CodeOneBlock+190p + ; CEncoder_CodeOneBlock+2CCp + +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebx, ecx + mov ebp, 1 + mov edx, 8 + +loc_4CFE44: ; CODE XREF: sub_4CFE30+88j + movzx edi, [esp+10h+arg_4] + sub edx, 1 + mov cl, dl + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebx+ebp*4] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFE7E + mov [esi+10h], eax + mov eax, [ebx+ebp*4] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebx+ebp*4], ecx + jmp short loc_4CFE97 +; --------------------------------------------------------------------------- + +loc_4CFE7E: ; CODE XREF: sub_4CFE30+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebx+ebp*4] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebx+ebp*4], eax + +loc_4CFE97: ; CODE XREF: sub_4CFE30+4Cj + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFEB2 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFEB2: ; CODE XREF: sub_4CFE30+6Fj + add ebp, ebp + or ebp, edi + test edx, edx + jnz short loc_4CFE44 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFE30 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CFED0 proc near ; CODE XREF: CEncoder_CodeOneBlock+300p + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = byte ptr 0Ch + + push ecx + push ebx + push ebp + push esi + mov esi, [esp+10h+arg_0] + push edi + mov [esp+14h+var_4], ecx + mov ebx, 1 + mov edx, 8 + jmp short loc_4CFEF0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CFEF0: ; CODE XREF: sub_4CFED0+17j + ; sub_4CFED0+ADj + movzx ebp, [esp+14h+arg_4] + movzx edi, [esp+14h+arg_8] + sub edx, 1 + movzx ecx, dl + shr ebp, cl + shr edi, cl + mov ecx, [esp+14h+var_4] + mov [esp+14h+arg_0], edx + mov edx, [esi+10h] + and ebp, 1 + lea eax, [ebp+1] + shl eax, 8 + add eax, ebx + lea ecx, [ecx+eax*4] + mov eax, edx + shr eax, 0Bh + imul eax, [ecx] + and edi, 1 + test edi, edi + jnz short loc_4CFF41 + mov [esi+10h], eax + mov eax, [ecx] + mov edx, 800h + sub edx, eax + shr edx, 5 + add edx, eax + mov [ecx], edx + jmp short loc_4CFF58 +; --------------------------------------------------------------------------- + +loc_4CFF41: ; CODE XREF: sub_4CFED0+5Aj + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub edx, eax + mov [esi+10h], edx + mov eax, [ecx] + mov edx, eax + shr edx, 5 + sub eax, edx + mov [ecx], eax + +loc_4CFF58: ; CODE XREF: sub_4CFED0+6Fj + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFF6F + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CFF6F: ; CODE XREF: sub_4CFED0+90j + mov edx, [esp+14h+arg_0] + add ebx, ebx + or ebx, edi + cmp ebp, edi + jnz short loc_4CFF8B + test edx, edx + jnz loc_4CFEF0 + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CFF8B: ; CODE XREF: sub_4CFED0+A9j + test edx, edx + jz loc_4D0012 + +loc_4CFF93: ; CODE XREF: sub_4CFED0+140j + movzx edi, [esp+14h+arg_8] + mov ebp, [esp+14h+var_4] + sub edx, 1 + mov cl, dl + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+14h+arg_0], edx + jnz short loc_4CFFD4 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFFEF +; --------------------------------------------------------------------------- + +loc_4CFFD4: ; CODE XREF: sub_4CFED0+E9j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFFEF: ; CODE XREF: sub_4CFED0+102j + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D000A + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+14h+arg_0] + +loc_4D000A: ; CODE XREF: sub_4CFED0+127j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFF93 + +loc_4D0012: ; CODE XREF: sub_4CFED0+BDj + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn 0Ch +sub_4CFED0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4D0020 proc near ; CODE XREF: sub_4D0770+C6p + ; CEncoder_CodeOneBlock+56Dp ... + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push ebp + mov ebp, [esp+4+arg_4] + cmp ebp, 8 + push esi + mov esi, [esp+8+arg_0] + push edi + mov edi, ecx + jnb short loc_4D007D + mov eax, [esi+10h] + shr eax, 0Bh + imul eax, [edi] + mov [esi+10h], eax + mov eax, [edi] + mov ecx, 800h + sub ecx, eax + +loc_4D0047: ; DATA XREF: .rdata:0050C3BCo + shr ecx, 5 + add ecx, eax + mov [edi], ecx + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D0065 + shl eax, 8 + +loc_4D005B: ; DATA XREF: .rdata:005064B0o + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D0065: ; CODE XREF: sub_4D0020+36j + mov edx, [esp+0Ch+arg_8] + push ebp + shl edx, 5 + push esi + lea ecx, [edx+edi+8] + call sub_4CFB20 + pop edi + pop esi + pop ebp + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D007D: ; CODE XREF: sub_4D0020+10j + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edi] + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [edi] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edi], eax + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D00B6 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D00B6: ; CODE XREF: sub_4D0020+87j + cmp ebp, 10h + jnb short loc_4D010F + mov edx, [esi+10h] + shr edx, 0Bh + imul edx, [edi+4] + mov [esi+10h], edx + mov eax, [edi+4] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [edi+4], ecx + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D00F1 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D00F1: ; CODE XREF: sub_4D0020+C2j + mov edx, [esp+0Ch+arg_8] + add ebp, 0FFFFFFF8h + push ebp + shl edx, 5 + push esi + lea ecx, [edx+edi+208h] + call sub_4CFB20 + pop edi + pop esi + pop ebp + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D010F: ; CODE XREF: sub_4D0020+99j + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edi+4] + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [edi+4] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edi+4], eax + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D014B + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D014B: ; CODE XREF: sub_4D0020+11Cj + add ebp, 0FFFFFFF0h + push ebp + push esi + lea ecx, [edi+408h] + call sub_4CFBC0 + pop edi + pop esi + pop ebp + retn 0Ch +sub_4D0020 endp + +; =============== S U B R O U T I N E ======================================= + +NCompress_NLZMA_CEncoder_CEncoder proc near ; CODE XREF: Compress_lzma_internal+149p + mov eax, ecx + mov dword ptr [eax+4], offset ICompressSetOutStream_vftable + mov dword ptr [eax+8], offset ICompressSetCoderProperties_vftable + mov dword ptr [eax+0Ch], offset ICompressWriteCoderProperties_vftable + xor ecx, ecx + mov [eax+24h], ecx + mov dword ptr [eax], offset NCompress_NLZMA_CEncoder_vftable + mov dword ptr [eax+4], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStream + mov dword ptr [eax+8], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderProperties + mov dword ptr [eax+0Ch], offset NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderProperties + mov [eax+40h], ecx + mov [eax+44h], ecx + mov [eax+54h], ecx + mov [eax+60h], ecx + mov [eax+32650h], ecx + mov dword ptr [eax+32EF8h], 20h + mov dword ptr [eax+33B58h], 2Ch + mov dword ptr [eax+33B5Ch], 2 + mov [eax+33B64h], ecx + mov dword ptr [eax+33B6Ch], 00400000h + mov edx, 3 + mov [eax+33B60h], edx + mov [eax+33B68h], edx + mov [eax+33B8Ch], ecx + mov [eax+33B90h], ecx + mov [eax+33B94h], cl + mov [eax+0B4h], ecx + mov [eax+0A4h], ecx + mov dword ptr [eax+0B0h], 20h + mov dword ptr [eax+0D4h], 1 + mov dword ptr [eax+0CCh], 4 + mov [eax+0D0h], ecx + mov [eax+0D8h], ecx + mov [eax+32EF4h], cl + retn +NCompress_NLZMA_CEncoder_CEncoder endp + +; =============== S U B R O U T I N E ======================================= + +; int __thiscall sub_4D0250(void *Memory, char) +sub_4D0250 proc near ; DATA XREF: .rdata:00517B0Co + +arg_0 = byte ptr 4 + + push esi + mov esi, ecx + call sub_4CF810 + test [esp+4+arg_0], 1 + jz short loc_4D0268 + push esi ; Memory + call j__free + add esp, 4 + +loc_4D0268: ; CODE XREF: sub_4D0250+Dj + mov eax, esi + pop esi + retn 4 +sub_4D0250 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4D0270 proc near ; CODE XREF: CEncoder_SetStreams+14p + push esi + mov esi, ecx + mov eax, [esi+40h] + test eax, eax + push edi + mov edi, 100000h + jz short loc_4D0297 + cmp [esi+50h], edi + jz short loc_4D02C5 + test eax, eax + jz short loc_4D0297 + push 8000h ; dwFreeType + push 0 ; dwSize + push eax ; lpAddress + call ds:VirtualFree + +loc_4D0297: ; CODE XREF: sub_4D0270+Ej + ; sub_4D0270+17j + push 4 ; flProtect + push 1000h ; flAllocationType + push edi ; dwSize + push 0 ; lpAddress + mov dword ptr [esi+40h], 0 + mov [esi+50h], edi + call ds:VirtualAlloc + test eax, eax + mov [esi+40h], eax + setnz al + test al, al + jnz short loc_4D02C5 + pop edi + mov eax, 8007000Eh + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4D02C5: ; CODE XREF: sub_4D0270+13j + ; sub_4D0270+4Bj + mov eax, [esi+33B68h] + mov ecx, [esi+33B64h] + cmp dword ptr [esi+0D4h], 0 + push ebx + push eax + push ecx + lea ecx, [esi+32650h] + setnz bl + call sub_4CD940 + test al, al + jz short loc_4D034F + mov ecx, [esi+33B6Ch] + mov edx, 1000000h + cmp edx, ecx + sbb eax, eax + neg eax + push ebp + mov ebp, [esi+32EF8h] + mov [esi+0D8h], eax + mov eax, ebp + shr eax, 1 + add eax, 10h + test bl, bl + jnz short loc_4D0318 + shr eax, 1 + +loc_4D0318: ; CODE XREF: sub_4D0270+A4j + mov edx, [esi+33B90h] + test edx, edx + jz short loc_4D0324 + mov eax, edx + +loc_4D0324: ; CODE XREF: sub_4D0270+B0j + push offset off_546E20 + push 111h + push ebp + push 1000h + push ecx + lea edi, [esi+84h] + push edi + mov [esi+0B0h], eax + call sub_4CBA60 + add esp, 18h + test eax, eax + pop ebp + jnz short loc_4D0358 + +loc_4D034F: ; CODE XREF: sub_4D0270+7Bj + pop ebx + pop edi + mov eax, 8007000Eh + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4D0358: ; CODE XREF: sub_4D0270+DDj + mov [esi+80h], edi + add esi, 68h + push esi + push edi + call sub_4CCAA0 + add esp, 8 + pop ebx + pop edi + xor eax, eax + pop esi + retn +sub_4D0270 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_SetStreams proc near ; CODE XREF: CEncoder_CodeReal+4Ap + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + mov eax, [esp+arg_0] + push esi + mov esi, ecx + mov [esi+33B84h], eax + mov byte ptr [esi+33B80h], 0 + call sub_4D0270 + test eax, eax + jnz loc_4D0441 + mov edx, [esp+4+arg_4] + mov ecx, [esi+4] + lea eax, [esi+4] + push edx + push eax + mov eax, [ecx+0Ch] + call eax + test eax, eax + jnz loc_4D0441 + mov ecx, esi + call sub_4CDEA0 + test eax, eax + jnz short loc_4D0441 + cmp [esi+32EF4h], al + jnz short loc_4D03DB + mov ecx, esi + call CEncoder_FillDistancesPrices + mov ecx, esi + call CEncoder_FillAlignPrices + +loc_4D03DB: ; CODE XREF: CEncoder_SetStreams+4Bj + mov ecx, [esi+32EF8h] + sub ecx, 1 + mov [esi+2D9C0h], ecx + mov ecx, [esi+33B5Ch] + mov edx, 1 + shl edx, cl + lea ecx, [esi+28DB8h] + push edx + call sub_4CF780 + mov ecx, [esi+33B5Ch] + mov eax, [esi+32EF8h] + mov edx, 1 + shl edx, cl + sub eax, 1 + lea ecx, [esi+2DA04h] + mov [esi+3260Ch], eax + push edx + call sub_4CF780 + mov dword ptr [esi+33B78h], 0 + mov dword ptr [esi+33B7Ch], 0 + xor eax, eax + +loc_4D0441: ; CODE XREF: CEncoder_SetStreams+1Bj + ; CEncoder_SetStreams+34j ... + pop esi + retn 10h +CEncoder_SetStreams endp + +;Compress_lzma_internal proc near ; CODE XREF: Compress_lzma+34p +_starcraft_compress_lzma proc near ; CODE XREF: Compress_lzma+34p +; sub_4D0450 + +var_58 = dword ptr -58h +var_54 = dword ptr -54h +var_50 = dword ptr -50h +var_4C = dword ptr -4Ch +var_48 = dword ptr -48h +var_44 = dword ptr -44h +var_40 = dword ptr -40h +var_3C = word ptr -3Ch +var_34 = dword ptr -34h +var_2C = word ptr -2Ch +var_24 = dword ptr -24h +var_1C = dword ptr -1Ch +var_14 = dword ptr -14h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +pbInBuffer = dword ptr 4 +cbInBuffer = dword ptr 8 +pcbInBuffer = dword ptr 0Ch +pbOutBuffer = dword ptr 10h +cbOutBuffer = dword ptr 14h +dummy = dword ptr 18h +pcbOutBuffer = dword ptr 1Ch +pfnAllocateMemory= dword ptr 20h +pfnFreeMemory = dword ptr 24h +pfnGiveData = dword ptr 28h + + push 0FFFFFFFFh + push offset loc_4DA0FB + mov eax, dword ptr fs:[0] + push eax + sub esp, 4Ch + push ebx + push ebp + push esi + push edi + mov eax, dword_544960 + xor eax, esp + push eax + lea eax, [esp+6Ch+var_C] + mov dword ptr fs:[0], eax + mov eax, dword_553598 + xor ebx, ebx + cmp eax, ebx + jnz short loc_4D04A1 + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D049A + mov [eax], ebx + mov [eax+4], ebx + mov [eax+8], ebx + jmp short loc_4D049C +; --------------------------------------------------------------------------- + +loc_4D049A: ; CODE XREF: Compress_lzma_internal+3Ej + xor eax, eax + +loc_4D049C: ; CODE XREF: Compress_lzma_internal+48j + mov dword ptr dword_553598, eax + +loc_4D04A1: ; CODE XREF: Compress_lzma_internal+30j + cmp [eax], ebx + jnz short loc_4D04B3 + mov ecx, [esp+6Ch+pfnAllocateMemory] + mov [eax], ecx + mov eax, dword_553598 + +loc_4D04B3: ; CODE XREF: Compress_lzma_internal+53j + cmp eax, ebx + jnz short loc_4D04D6 + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D04CF + mov [eax], ebx + mov [eax+4], ebx + mov [eax+8], ebx + jmp short loc_4D04D1 +; --------------------------------------------------------------------------- + +loc_4D04CF: ; CODE XREF: Compress_lzma_internal+73j + xor eax, eax + +loc_4D04D1: ; CODE XREF: Compress_lzma_internal+7Dj + mov dword_553598, eax + +loc_4D04D6: ; CODE XREF: Compress_lzma_internal+65j + cmp [eax+4], ebx + jnz short loc_4D04EA + mov edx, [esp+6Ch+pfnFreeMemory] + mov [eax+4], edx + mov eax, dword_553598 + +loc_4D04EA: ; CODE XREF: Compress_lzma_internal+89j + cmp [eax+8], ebx + jnz short loc_4D04F9 + mov ecx, [esp+6Ch+pfnGiveData] + mov [eax+8], ecx + +loc_4D04F9: ; CODE XREF: Compress_lzma_internal+9Dj + mov edx, [esp+6Ch+pcbOutBuffer] + mov ebp, [esp+6Ch+pcbInBuffer] + cmp ebp, ebx + mov esi, [esp+6Ch+cbInBuffer] + mov [edx], ebx + mov edx, 1 + mov eax, esi + mov ecx, ebp + ja short loc_4D0520 + cmp esi, ebx + jbe short loc_4D053A + jmp short loc_4D0520 +; --------------------------------------------------------------------------- + align 10h + +loc_4D0520: ; CODE XREF: Compress_lzma_internal+C5j + ; Compress_lzma_internal+CBj ... + shrd eax, ecx, 1 + add edx, edx + shr ecx, 1 + cmp edx, 2000000h + ja short loc_4D053A + cmp ecx, ebx + ja short loc_4D0520 + jb short loc_4D053A + cmp eax, ebx + ja short loc_4D0520 + +loc_4D053A: ; CODE XREF: Compress_lzma_internal+C9j + ; Compress_lzma_internal+DEj ... + mov eax, 13h + push 33B98h ; Size + mov [esp+70h+var_48], 470h + mov [esp+70h+var_44], 400h + mov [esp+70h+var_40], 450h + mov [esp+70h+var_3C], ax + mov [esp+70h+var_2C], ax + mov word ptr [esp+70h+var_1C], ax + mov [esp+70h+var_34], 2 + mov [esp+70h+var_24], edx + mov [esp+70h+var_14], 40h + mov [esp+70h+var_58], ebx + call _operator_new ; operator new(uint) + add esp, 4 + mov [esp+6Ch+var_4C], eax + cmp eax, ebx + mov [esp+6Ch+var_4], ebx + jz short loc_4D05A4 + mov ecx, eax + call NCompress_NLZMA_CEncoder_CEncoder + mov [esp+6Ch+var_54], eax + jmp short loc_4D05AA +; --------------------------------------------------------------------------- + +loc_4D05A4: ; CODE XREF: Compress_lzma_internal+145j + mov [esp+6Ch+var_54], ebx + mov eax, ebx + +loc_4D05AA: ; CODE XREF: Compress_lzma_internal+152j + or edi, 0FFFFFFFFh + cmp eax, ebx + mov [esp+6Ch+var_4], edi + jz short loc_4D05D1 + mov ecx, [eax+8] + push 3 + lea edx, [esp+70h+var_3C] + push edx + add eax, 8 + lea edx, [esp+74h+var_48] + push edx + push eax + mov eax, [ecx+0Ch] + call eax ; ICompressSetCodeProperties::SetCoderProperties + test eax, eax + jz short loc_4D05D5 + +loc_4D05D1: ; CODE XREF: Compress_lzma_internal+163j + mov [esp+6Ch+var_58], edi + +loc_4D05D5: ; CODE XREF: Compress_lzma_internal+17Fj + push 28h ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D060E + mov ecx, [esp+6Ch+pbInBuffer] + mov [eax+4], ebx + add dword ptr [eax+4], 1 + mov dword ptr [eax], offset off_517A90 + mov [eax+8], ecx + mov [eax+10h], esi + mov [eax+14h], ebp + mov [eax+18h], ebx + mov [eax+1Ch], ebx + mov [eax+20h], bl + mov edi, eax ; EDI = pInStreamMemory + mov [esp+6Ch+var_50], eax + jmp short loc_4D0614 +; --------------------------------------------------------------------------- + +loc_4D060E: ; CODE XREF: Compress_lzma_internal+191j + xor edi, edi + mov [esp+6Ch+var_50], edi + +loc_4D0614: ; CODE XREF: Compress_lzma_internal+1BCj + push 28h ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D0657 + mov edx, [esp+6Ch+pbOutBuffer] + mov ecx, [esp+6Ch+cbOutBuffer] + mov [eax+4], ebx + add dword ptr [eax+4], 1 + mov [eax+8], edx + mov edx, [esp+6Ch+dummy] + mov dword ptr [eax], offset off_517AA4 + mov [eax+10h], ecx + mov [eax+14h], edx + mov [eax+18h], ebx + mov [eax+1Ch], ebx + mov [eax+20h], bl + mov esi, eax ; ESI = pOutStreamMemory + jmp short loc_4D0659 +; --------------------------------------------------------------------------- + +loc_4D0657: ; CODE XREF: Compress_lzma_internal+1D0j + xor esi, esi + +loc_4D0659: ; CODE XREF: Compress_lzma_internal+205j + cmp edi, ebx + jz short loc_4D0661 + cmp esi, ebx + jnz short loc_4D0669 + +loc_4D0661: ; CODE XREF: Compress_lzma_internal+20Bj + mov [esp+6Ch+var_58], 0FFFFFFFFh + +loc_4D0669: ; CODE XREF: Compress_lzma_internal+20Fj + mov eax, [esi] ; EAX = pOutStreamMemory->vftable + mov ecx, [eax+10h] ; ECX = + push ebx + mov edi, 1 + push edi + push ebx + push esi + call ecx + test eax, eax + jz short loc_4D0681 + mov [esp+6Ch+var_58], edi + +loc_4D0681: ; CODE XREF: Compress_lzma_internal+22Bj + mov eax, [esp+6Ch+var_54] + mov edx, [eax+0Ch] + add eax, 0Ch + push esi + push eax + mov eax, [edx+0Ch] + call eax + test eax, eax + jz short loc_4D069A + mov [esp+6Ch+var_58], edi + +loc_4D069A: ; CODE XREF: Compress_lzma_internal+244j + xor edi, edi + jmp short loc_4D06A4 +; --------------------------------------------------------------------------- + align 10h + +loc_4D06A0: ; CODE XREF: Compress_lzma_internal+27Fj + mov ebp, [esp+6Ch+pcbInBuffer] + +loc_4D06A4: ; CODE XREF: Compress_lzma_internal+24Cj + mov eax, [esp+6Ch+cbInBuffer] + push ebx + push 1 + mov edx, ebp + mov ecx, edi + call __allshr ; Microsoft VisualC 2-8/net runtime + push eax + mov eax, [esi] + mov ecx, [eax+10h] + push esi + call ecx + test eax, eax + jz short loc_4D06C9 + mov [esp+6Ch+var_58], 1 + +loc_4D06C9: ; CODE XREF: Compress_lzma_internal+26Fj + add edi, 8 + cmp edi, 40h + jl short loc_4D06A0 + mov ebp, [esp+6Ch+var_54] + xor edi, edi + cmp [esp+6Ch+var_58], ebx + jnz short loc_4D0723 + mov eax, [esp+6Ch+var_50] + mov edx, [ebp+0] + mov ecx, [edx+0Ch] + push ebx + push ebx + push ebx + push esi + push eax + push ebp + call ecx + mov ecx, [esi+18h] + mov edi, eax + mov eax, [esi+1Ch] + cmp eax, ebx + ja short loc_4D0700 + cmp ecx, 0FFFFFFFFh + jbe short loc_4D0709 + +loc_4D0700: ; CODE XREF: Compress_lzma_internal+2A9j + or ecx, 0FFFFFFFFh + mov [esp+6Ch+pcbInBuffer], ebx + jmp short loc_4D070D +; --------------------------------------------------------------------------- + +loc_4D0709: ; CODE XREF: Compress_lzma_internal+2AEj + mov [esp+6Ch+pcbInBuffer], eax + +loc_4D070D: ; CODE XREF: Compress_lzma_internal+2B7j + mov edx, [esp+6Ch+pcbOutBuffer] + mov [edx], ecx + cmp [esi+20h], bl + jz short loc_4D0723 + mov [esp+6Ch+var_58], 1 + +loc_4D0723: ; CODE XREF: Compress_lzma_internal+28Bj + ; Compress_lzma_internal+2C9j + mov eax, [esp+6Ch+var_50] + cmp eax, ebx + jz short loc_4D0733 + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + +loc_4D0733: ; CODE XREF: Compress_lzma_internal+2D9j + mov eax, [esi] + mov ecx, [eax+8] + push esi + call ecx + mov edx, [ebp+0] + mov eax, [edx+10h] + push 1 + mov ecx, ebp + call eax + mov eax, [esp+6Ch+var_58] + cmp eax, ebx + jnz short loc_4D0755 + neg edi + sbb edi, edi + mov eax, edi + +loc_4D0755: ; CODE XREF: Compress_lzma_internal+2FDj + mov ecx, [esp+6Ch+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebp + pop ebx + add esp, 58h + retn +_starcraft_compress_lzma endp +;Compress_lzma_internal endp + +; =============== S U B R O U T I N E ======================================= + +Compress_lzma proc near ; DATA XREF: .rdata:00509684o + +pbOutBuffer = dword ptr 4 +pcbOutBuffer = dword ptr 8 +pbInBuffer = dword ptr 0Ch +cbInBuffer = dword ptr 10h + + push esi + push edi +; call sub_47F198 + mov esi, [esp+8+pcbOutBuffer] ; ESI = pcbOutBuffer + mov edi, [esp+8+cbInBuffer] ; EDI = cbInBuffer +; push offset GiveDataToCompress +; push offset FreeMemory_47F3AB +; push offset AllocateMemory_47F396 + push esi ; pcbOutBuffer + push 0 + mov [eax+493E0h], eax + push dword ptr [esi] ; cbOutBuffer + push [esp+20h+pbOutBuffer] ; pbOutBuffer + push 0 + push edi ; cbInBuffer + push [esp+2Ch+pbInBuffer] ; pbInBuffer +; call Compress_lzma_internal + add esp, 28h + sub eax, 0 + jz short loc_47F401 + mov [esi], edi + dec eax + +loc_47F401: ; CODE XREF: Compress_lzma+3Fj + pop edi + pop esi + retn +Compress_lzma endp + +; =============== S U B R O U T I N E ======================================= + +sub_4D0770 proc near ; CODE XREF: CEncoder_Flush+1Ap + +arg_0 = dword ptr 4 + + push edi + mov edi, ecx + cmp byte ptr [edi+33B94h], 0 + jz loc_4D0881 + movzx eax, byte ptr [edi+10h] + mov ecx, [edi+38h] + shl eax, 4 + push ebx + mov ebx, [esp+8+arg_0] + add eax, ebx + lea edx, [edi+eax*4+280F0h] + push ebp + push esi + lea esi, [edi+28h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edx] + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D07D3 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D07D3: ; CODE XREF: sub_4D0770+54j + movzx edx, byte ptr [edi+10h] + mov ecx, [esi+10h] + lea eax, [edi+edx*4+283F0h] + shr ecx, 0Bh + imul ecx, [eax] + mov [esi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D0811 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D0811: ; CODE XREF: sub_4D0770+92j + movzx eax, byte ptr [edi+10h] + mov cl, ds:kMatchNextStates[eax] + push ebx + mov [edi+10h], cl + cmp byte ptr [edi+32EF4h], 0 + push 0 + lea ebp, [edi+28DB8h] + push esi + mov ecx, ebp + setz byte ptr [esp+1Ch+arg_0] + call sub_4D0020 + cmp byte ptr [esp+10h+arg_0], 0 + jz short loc_4D0854 + add dword ptr [ebp+ebx*4+4C0Ch], 0FFFFFFFFh + jnz short loc_4D0854 + push ebx + mov ecx, ebp + call sub_4CF740 + +loc_4D0854: ; CODE XREF: sub_4D0770+D0j + ; sub_4D0770+DAj + push 3Fh + push esi + lea ecx, [edi+287B0h] + call sub_4CFC60 + push 1Ah + push 3FFFFFFh + mov ecx, esi + call sub_4CF6E0 + push 0Fh + push esi + lea ecx, [edi+28D78h] + call sub_4CFD00 + pop esi + pop ebp + pop ebx + +loc_4D0881: ; CODE XREF: sub_4D0770+Aj + pop edi + retn 4 +sub_4D0770 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_Flush proc near ; CODE XREF: CEncoder_CodeOneBlock+BAp + ; CEncoder_CodeOneBlock+1D0p ... + +arg_0 = dword ptr 4 + + push esi + mov esi, ecx + mov eax, [esi+0ECh] + test eax, eax + jnz short loc_4D08E5 + mov eax, [esi+33B60h] + and eax, [esp+4+arg_0] + push ebx + push edi + push eax + call sub_4D0770 + lea ebx, [esi+28h] + mov edi, 5 + +loc_4D08B7: ; CODE XREF: CEncoder_Flush+31j + mov ecx, ebx + call loc_4CF640 + sub edi, 1 + jnz short loc_4D08B7 + mov ecx, [esi+4Ch] + add esi, 40h + cmp ecx, [esi+4] + pop edi + pop ebx + jz short loc_4D08E3 + +loc_4D08D0: ; CODE XREF: CEncoder_Flush+51j + mov ecx, esi + call sub_4CF450 + test eax, eax + jnz short loc_4D08E5 + mov edx, [esi+0Ch] + cmp edx, [esi+4] + jnz short loc_4D08D0 + +loc_4D08E3: ; CODE XREF: CEncoder_Flush+3Ej + xor eax, eax + +loc_4D08E5: ; CODE XREF: CEncoder_Flush+Bj + ; CEncoder_Flush+49j + pop esi + retn 4 +CEncoder_Flush endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_CodeOneBlock proc near ; CODE XREF: CEncoder_CodeReal+B1p + ; CEncoder_CodeReal+F5p + +var_20 = byte ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + sub esp, 20h + push ebp + push esi + mov esi, ecx + push edi + mov edi, [esi+33B84h] + xor ebp, ebp + cmp edi, ebp + jz short loc_4D0952 + mov eax, [edi] + mov ecx, [eax+4] + push edi + call ecx + mov eax, [esi+33B8Ch] + cmp eax, ebp + jz short loc_4D091E + mov edx, [eax] + push eax + mov eax, [edx+8] + call eax + +loc_4D091E: ; CODE XREF: CEncoder_CodeOneBlock+24j + mov [esi+33B8Ch], edi + mov ecx, [esi+80h] + mov edx, [esi+68h] + lea eax, [esi+33B88h] + push ecx + mov dword ptr [eax], offset loc_4CF210 + mov [esi+0B8h], eax + call edx + add esp, 4 + mov byte ptr [esi+33B95h], 1 + mov [esi+33B84h], ebp + +loc_4D0952: ; CODE XREF: CEncoder_CodeOneBlock+12j + mov eax, [esp+2Ch+arg_8] + mov dword ptr [eax], 1 + cmp byte ptr [esi+33B80h], 0 + jz short loc_4D0974 + mov eax, [esi+0ECh] + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D0974: ; CODE XREF: CEncoder_CodeOneBlock+73j + mov ecx, [esi+33B78h] + or ecx, [esi+33B7Ch] + push ebx + mov byte ptr [esi+33B80h], 1 + jnz loc_4D0A9C + mov edx, [esi+80h] + mov eax, [esi+70h] + push edx + call eax + add esp, 4 + test eax, eax + jnz short loc_4D09B9 + mov ecx, [esi+33B78h] + push ecx + mov ecx, esi + call CEncoder_Flush + pop ebx + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D09B9: ; CODE XREF: CEncoder_CodeOneBlock+AFj + lea edx, [esp+30h+var_4] + push edx + mov ecx, esi + call sub_4CB3B0 + movzx ecx, byte ptr [esi+10h] + mov eax, [esi+33B60h] + and eax, [esi+33B78h] + mov edx, [esi+38h] + lea edi, [esi+28h] + shl ecx, 4 + add eax, ecx + shr edx, 0Bh + imul edx, [esi+eax*4+280F0h] + lea eax, [esi+eax*4+280F0h] + mov [edi+10h], edx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0A1C + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0A1C: ; CODE XREF: CEncoder_CodeOneBlock+11Dj + movzx eax, byte ptr [esi+10h] + mov cl, ds:kLiteralNextStates[eax] + mov [esi+10h], cl + mov edx, [esi+32F04h] + mov eax, [esi+80h] + mov ecx, [esi+6Ch] + neg edx + push edx + push eax + call ecx + mov bl, al + mov eax, [esi+32654h] + add esp, 8 + mov byte ptr [esp+30h+var_10], bl + mov edx, [esp+30h+var_10] + push edx + movzx edx, byte ptr [esi+11h] + push edi + mov edi, [esi+3265Ch] + and edi, [esi+33B78h] + mov ecx, 8 + sub cl, al + shr edx, cl + mov ecx, eax + shl edi, cl + add edx, edi + imul edx, 0C00h + add edx, [esi+32650h] + mov ecx, edx + call sub_4CFE30 + add dword ptr [esi+32F04h], 0FFFFFFFFh + add dword ptr [esi+33B78h], 1 + mov [esi+11h], bl + adc [esi+33B7Ch], ebp + +loc_4D0A9C: ; CODE XREF: CEncoder_CodeOneBlock+98j + mov edi, [esi+33B78h] + mov eax, [esi+80h] + mov ecx, [esi+70h] + push eax + mov [esp+34h+var_14], edi + mov [esp+34h+var_4], edi + call ecx + add esp, 4 + test eax, eax + jnz short loc_4D0AD4 + push edi + mov ecx, esi + call CEncoder_Flush + pop ebx + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + align 10h + +loc_4D0AD0: ; CODE XREF: CEncoder_CodeOneBlock+735j + ; CEncoder_CodeOneBlock+78Bj + mov edi, [esp+30h+var_14] + +loc_4D0AD4: ; CODE XREF: CEncoder_CodeOneBlock+1CBj + cmp byte ptr [esi+32EF4h], 0 + mov ecx, esi + jz short loc_4D0AEB + lea edx, [esp+30h+var_1C] + push edx + call CEncoder_GetOptimumFast + jmp short loc_4D0AF6 +; --------------------------------------------------------------------------- + +loc_4D0AEB: ; CODE XREF: CEncoder_CodeOneBlock+1EDj + lea eax, [esp+30h+var_1C] + push eax + push edi + call CEncoder_GetOptimum + +loc_4D0AF6: ; CODE XREF: CEncoder_CodeOneBlock+1F9j + mov ebx, [esi+33B60h] + and ebx, edi + cmp eax, 1 + mov [esp+30h+var_18], eax + jnz loc_4D0C0E + cmp [esp+30h+var_1C], 0FFFFFFFFh + jnz loc_4D0C0E + movzx ecx, byte ptr [esi+10h] + mov edx, [esi+38h] + lea ebp, [esi+28h] + shl ecx, 4 + shr edx, 0Bh + add ecx, ebx + imul edx, [esi+ecx*4+280F0h] + lea eax, [esi+ecx*4+280F0h] + mov [ebp+10h], edx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [ebp+10h] + cmp eax, 1000000h + jnb short loc_4D0B61 + shl eax, 8 + mov ecx, ebp + mov [ebp+10h], eax + call loc_4CF640 + +loc_4D0B61: ; CODE XREF: CEncoder_CodeOneBlock+262j + mov eax, [esi+32F04h] + mov ecx, [esi+80h] + mov edx, [esi+6Ch] + neg eax + push eax + push ecx + call edx + movzx edi, byte ptr [esi+11h] + mov edx, [esi+3265Ch] + and edx, [esp+38h+var_14] + mov bl, al + mov eax, [esi+32654h] + mov ecx, 8 + sub cl, al + shr edi, cl + mov ecx, eax + shl edx, cl + add esp, 8 + mov byte ptr [esp+30h+var_10], bl + add edi, edx + imul edi, 0C00h + add edi, [esi+32650h] + cmp byte ptr [esi+10h], 7 + jnb short loc_4D0BC3 + mov eax, [esp+30h+var_10] + push eax + push ebp + mov ecx, edi + call sub_4CFE30 + jmp short loc_4D0BF5 +; --------------------------------------------------------------------------- + +loc_4D0BC3: ; CODE XREF: CEncoder_CodeOneBlock+2C2j + mov edx, [esi+80h] + mov eax, [esi+6Ch] + or ecx, 0FFFFFFFFh + sub ecx, [esi+14h] + sub ecx, [esi+32F04h] + push ecx + push edx + call eax + mov ecx, [esp+38h+var_10] + add esp, 8 + mov byte ptr [esp+30h+var_C], al + mov edx, [esp+30h+var_C] + push ecx + push edx + push ebp + mov ecx, edi + call sub_4CFED0 + +loc_4D0BF5: ; CODE XREF: CEncoder_CodeOneBlock+2D1j + movzx eax, byte ptr [esi+10h] + mov cl, ds:kLiteralNextStates[eax] + mov ebp, [esp+30h+var_18] + mov [esi+10h], cl + mov [esi+11h], bl + jmp loc_4D1013 +; --------------------------------------------------------------------------- + +loc_4D0C0E: ; CODE XREF: CEncoder_CodeOneBlock+215j + ; CEncoder_CodeOneBlock+220j + movzx edx, byte ptr [esi+10h] + mov ecx, [esi+38h] + lea edi, [esi+28h] + shl edx, 4 + mov eax, ecx + shr eax, 0Bh + add edx, ebx + imul eax, [esi+edx*4+280F0h] + add [edi+8], eax + lea edx, [esi+edx*4+280F0h] + mov ebp, 0 + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0C63 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0C63: ; CODE XREF: CEncoder_CodeOneBlock+364j + cmp [esp+30h+var_1C], 4 + movzx edx, byte ptr [esi+10h] + mov ecx, [edi+10h] + jnb loc_4D0E91 + mov eax, ecx + shr eax, 0Bh + imul eax, [esi+edx*4+283F0h] + add [edi+8], eax + lea edx, [esi+edx*4+283F0h] + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0CB6 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0CB6: ; CODE XREF: CEncoder_CodeOneBlock+3B7j + mov eax, [esp+30h+var_1C] + cmp eax, ebp + mov ecx, [edi+10h] + jnz short loc_4D0D24 + movzx edx, byte ptr [esi+10h] + lea eax, [esi+edx*4+28420h] + shr ecx, 0Bh + imul ecx, [eax] + mov [edi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0CFC + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0CFC: ; CODE XREF: CEncoder_CodeOneBlock+3FDj + mov ebp, [esp+30h+var_18] + movzx ecx, byte ptr [esi+10h] + xor eax, eax + cmp ebp, 1 + setnz al + shl ecx, 4 + add ecx, ebx + lea ecx, [esi+ecx*4+284B0h] + push eax + push edi + call sub_4CFAC0 + jmp loc_4D0E2E +; --------------------------------------------------------------------------- + +loc_4D0D24: ; CODE XREF: CEncoder_CodeOneBlock+3CFj + mov edx, [esi+eax*4+14h] + movzx eax, byte ptr [esi+10h] + mov [esp+30h+var_8], edx + lea edx, [esi+eax*4+28420h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edx] + add [edi+8], eax + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0D6C + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0D6C: ; CODE XREF: CEncoder_CodeOneBlock+46Dj + cmp [esp+30h+var_1C], 1 + mov ecx, [edi+10h] + jnz short loc_4D0DB3 + movzx edx, byte ptr [esi+10h] + lea eax, [esi+edx*4+28450h] + shr ecx, 0Bh + imul ecx, [eax] + mov [edi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0E1D + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + jmp short loc_4D0E1D +; --------------------------------------------------------------------------- + +loc_4D0DB3: ; CODE XREF: CEncoder_CodeOneBlock+484j + movzx eax, byte ptr [esi+10h] + lea edx, [esi+eax*4+28450h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edx] + add [edi+8], eax + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0DF3 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0DF3: ; CODE XREF: CEncoder_CodeOneBlock+4F4j + mov ebp, [esp+30h+var_1C] + movzx eax, byte ptr [esi+10h] + lea edx, [ebp-2] + push edx + push edi + lea ecx, [esi+eax*4+28480h] + call sub_4CFAC0 + cmp ebp, 3 + jnz short loc_4D0E17 + mov ecx, [esi+1Ch] + mov [esi+20h], ecx + +loc_4D0E17: ; CODE XREF: CEncoder_CodeOneBlock+51Fj + mov edx, [esi+18h] + mov [esi+1Ch], edx + +loc_4D0E1D: ; CODE XREF: CEncoder_CodeOneBlock+4B2j + ; CEncoder_CodeOneBlock+4C1j + mov eax, [esi+14h] + mov ecx, [esp+30h+var_8] + mov ebp, [esp+30h+var_18] + mov [esi+18h], eax + mov [esi+14h], ecx + +loc_4D0E2E: ; CODE XREF: CEncoder_CodeOneBlock+42Fj + cmp ebp, 1 + jnz short loc_4D0E45 + movzx edx, byte ptr [esi+10h] + mov al, ds:kShortRepNextStates[edx] + mov [esi+10h], al + jmp loc_4D0FF5 +; --------------------------------------------------------------------------- + +loc_4D0E45: ; CODE XREF: CEncoder_CodeOneBlock+541j + cmp byte ptr [esi+32EF4h], 0 + push ebx + lea edx, [ebp-2] + push edx + lea ecx, [esi+2DA04h] + push edi + setz [esp+3Ch+var_20] + call sub_4D0020 + cmp [esp+30h+var_20], 0 + jz short loc_4D0E7F + add dword ptr [esi+ebx*4+32610h], 0FFFFFFFFh + lea ecx, [esi+2DA04h] + jnz short loc_4D0E7F + push ebx + call sub_4CF740 + +loc_4D0E7F: ; CODE XREF: CEncoder_CodeOneBlock+577j + ; CEncoder_CodeOneBlock+587j + movzx eax, byte ptr [esi+10h] + mov cl, ds:kRepNextStates[eax] + mov [esi+10h], cl + jmp loc_4D0FF5 +; --------------------------------------------------------------------------- + +loc_4D0E91: ; CODE XREF: CEncoder_CodeOneBlock+37Fj + lea eax, [esi+edx*4+283F0h] + shr ecx, 0Bh + imul ecx, [eax] + mov [edi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0EC8 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0EC8: ; CODE XREF: CEncoder_CodeOneBlock+5C9j + movzx eax, byte ptr [esi+10h] + mov cl, ds:kMatchNextStates[eax] + mov eax, [esp+30h+var_18] + mov [esi+10h], cl + cmp byte ptr [esi+32EF4h], 0 + push ebx + setz [esp+34h+var_20] + add eax, 0FFFFFFFEh + push eax + lea ebp, [esi+28DB8h] + push edi + mov ecx, ebp + call sub_4D0020 + cmp [esp+30h+var_20], 0 + jz short loc_4D0F11 + add dword ptr [ebp+ebx*4+4C0Ch], 0FFFFFFFFh + jnz short loc_4D0F11 + push ebx + mov ecx, ebp + call sub_4CF740 + +loc_4D0F11: ; CODE XREF: CEncoder_CodeOneBlock+60Dj + ; CEncoder_CodeOneBlock+617j + mov eax, [esp+30h+var_1C] + sub eax, 4 + cmp eax, 2000h + mov [esp+30h+var_1C], eax + jnb short loc_4D0F2C + movzx ebp, byte ptr dword_551198[eax] + jmp short loc_4D0F4F +; --------------------------------------------------------------------------- + +loc_4D0F2C: ; CODE XREF: CEncoder_CodeOneBlock+631j + cmp eax, 2000000h + jnb short loc_4D0F42 + shr eax, 0Ch + movzx ebp, byte ptr dword_551198[eax] + add ebp, 18h + jmp short loc_4D0F4F +; --------------------------------------------------------------------------- + +loc_4D0F42: ; CODE XREF: CEncoder_CodeOneBlock+641j + shr eax, 18h + movzx ebp, byte ptr dword_551198[eax] + add ebp, 30h + +loc_4D0F4F: ; CODE XREF: CEncoder_CodeOneBlock+63Aj + ; CEncoder_CodeOneBlock+650j + mov eax, [esp+30h+var_18] + add eax, 0FFFFFFFEh + cmp eax, 4 + jb short loc_4D0F60 + mov eax, 3 + +loc_4D0F60: ; CODE XREF: CEncoder_CodeOneBlock+669j + push ebp + shl eax, 8 + push edi + lea ecx, [eax+esi+287B0h] + call sub_4CFC60 + cmp ebp, 4 + jb short loc_4D0FD1 + mov ebx, [esp+30h+var_1C] + mov ecx, ebp + mov eax, ebp + and eax, 1 + shr ecx, 1 + sub ecx, 1 + or eax, 2 + shl eax, cl + sub ebx, eax + cmp ebp, 0Eh + jnb short loc_4D0FA9 + push ebx + push ecx + sub eax, ebp + lea edx, [esi+eax*4+28BACh] + push edi + push edx + call sub_4CFD90 + add esp, 10h + jmp short loc_4D0FD1 +; --------------------------------------------------------------------------- + +loc_4D0FA9: ; CODE XREF: CEncoder_CodeOneBlock+6A0j + add ecx, 0FFFFFFFCh + push ecx + mov eax, ebx + shr eax, 4 + push eax + mov ecx, edi + call sub_4CF6E0 + and ebx, 0Fh + push ebx + push edi + lea ecx, [esi+28D78h] + call sub_4CFD00 + add dword ptr [esi+33B54h], 1 + +loc_4D0FD1: ; CODE XREF: CEncoder_CodeOneBlock+684j + ; CEncoder_CodeOneBlock+6B7j + mov ecx, [esi+1Ch] + mov edx, [esi+18h] + mov eax, [esi+14h] + add dword ptr [esi+33B70h], 1 + mov ebp, [esp+30h+var_18] + mov [esi+20h], ecx + mov ecx, [esp+30h+var_1C] + mov [esi+1Ch], edx + mov [esi+18h], eax + mov [esi+14h], ecx + +loc_4D0FF5: ; CODE XREF: CEncoder_CodeOneBlock+550j + ; CEncoder_CodeOneBlock+59Cj + mov eax, [esi+80h] + mov ecx, [esi+6Ch] + mov edx, ebp + sub edx, [esi+32F04h] + sub edx, 1 + push edx + push eax + call ecx + add esp, 8 + mov [esi+11h], al + +loc_4D1013: ; CODE XREF: CEncoder_CodeOneBlock+319j + sub [esi+32F04h], ebp + mov eax, [esi+32F04h] + add [esp+30h+var_14], ebp + test eax, eax + jnz loc_4D0AD0 + cmp [esi+32EF4h], al + jnz short loc_4D1056 + cmp dword ptr [esi+33B70h], 80h + jb short loc_4D1046 + mov ecx, esi + call CEncoder_FillDistancesPrices + +loc_4D1046: ; CODE XREF: CEncoder_CodeOneBlock+74Dj + cmp dword ptr [esi+33B54h], 10h + jb short loc_4D1056 + mov ecx, esi + call CEncoder_FillAlignPrices + +loc_4D1056: ; CODE XREF: CEncoder_CodeOneBlock+741j + ; CEncoder_CodeOneBlock+75Dj + mov edx, [esi+80h] + mov eax, [esi+70h] + push edx + call eax + add esp, 4 + test eax, eax + mov eax, [esp+30h+var_14] + jz short loc_4D10D7 + mov ecx, [esp+30h+var_4] + mov edx, eax + sub edx, ecx + cmp edx, 4000h + jb loc_4D0AD0 + sub eax, ecx + add [esi+33B78h], eax + mov ecx, [esi+33B78h] + mov eax, [esp+30h+arg_0] + adc dword ptr [esi+33B7Ch], 0 + mov [eax], ecx + mov edx, [esi+33B7Ch] + lea ecx, [esi+28h] + mov [eax+4], edx + call sub_4CD8B0 + mov ecx, [esp+30h+arg_4] + mov [ecx], eax + mov eax, [esp+30h+arg_8] + mov [ecx+4], edx + pop ebx + mov byte ptr [esi+33B80h], 0 + pop edi + mov dword ptr [eax], 0 + mov eax, [esi+0ECh] + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D10D7: ; CODE XREF: CEncoder_CodeOneBlock+77Bj + push eax + mov ecx, esi + call CEncoder_Flush + pop ebx + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +CEncoder_CodeOneBlock endp + +; --------------------------------------------------------------------------- + align 10h +CEncoder_CodeReal proc near ; CODE XREF: CEncoder_Code+49p + +var_20 = dword ptr -20h +processedOutSize= byte ptr -1Ch +processedInSize = byte ptr -14h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +inStream = dword ptr 4 +outStream = dword ptr 8 +inSize = dword ptr 0Ch +outSize = dword ptr 10h +progress = dword ptr 14h + + push 0FFFFFFFFh + push offset loc_4DA128 + mov eax, dword ptr fs:[0] + push eax + sub esp, 14h + push ebp + push esi + push edi + mov eax, dword_544960 + xor eax, esp + push eax + lea eax, [esp+30h+var_C] + mov dword ptr fs:[0], eax + mov esi, ecx + mov [esp+30h+var_20], esi + mov eax, [esp+30h+outSize] + mov ecx, [esp+30h+inSize] + mov edx, [esp+30h+outStream] + push eax + mov eax, [esp+34h+inStream] + push ecx + push edx + push eax + mov ecx, esi + mov [esp+40h+var_4], 0 + call CEncoder_SetStreams + mov edi, eax + test edi, edi + jz short loc_4D1190 + cmp dword ptr [esi+80h], 0 + mov [esp+30h+var_4], 0FFFFFFFFh + jz short loc_4D1166 + cmp byte ptr [esi+33B95h], 0 + jz short loc_4D1166 + mov byte ptr [esi+33B95h], 0 + +loc_4D1166: ; CODE XREF: CEncoder_CodeReal+64j + ; CEncoder_CodeReal+6Dj + mov eax, [esi+33B8Ch] + test eax, eax + jz short loc_4D1182 + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + mov dword ptr [esi+33B8Ch], 0 + +loc_4D1182: ; CODE XREF: CEncoder_CodeReal+7Ej + mov ecx, [esi+4] + mov edx, [ecx+10h] + lea eax, [esi+4] + push eax + call edx + jmp short loc_4D1201 +; --------------------------------------------------------------------------- + +loc_4D1190: ; CODE XREF: CEncoder_CodeReal+53j + lea eax, [esp+30h+outSize] + push eax + lea ecx, [esp+34h+processedOutSize] + push ecx + lea edx, [esp+38h+processedInSize] + push edx + mov ecx, esi + call CEncoder_CodeOneBlock + mov edi, eax + test edi, edi + jnz short loc_4D11F0 + mov ebp, [esp+30h+progress] + +loc_4D11B0: ; CODE XREF: CEncoder_CodeReal+FEj + cmp [esp+30h+outSize], 0 + jnz short loc_4D1218 + test ebp, ebp + jz short loc_4D11D4 + mov eax, [ebp+0] + mov eax, [eax+0Ch] + lea ecx, [esp+30h+processedOutSize] + push ecx + lea edx, [esp+34h+processedInSize] + push edx + push ebp + call eax ; SetRatioInfo + mov edi, eax + test edi, edi + jnz short loc_4D11F0 + +loc_4D11D4: ; CODE XREF: CEncoder_CodeReal+C9j + lea ecx, [esp+30h+outSize] + push ecx + lea edx, [esp+34h+processedOutSize] + push edx + lea eax, [esp+38h+processedInSize] + push eax + mov ecx, esi + call CEncoder_CodeOneBlock + mov edi, eax + test edi, edi + jz short loc_4D11B0 + +loc_4D11F0: ; CODE XREF: CEncoder_CodeReal+BAj + ; CEncoder_CodeReal+E2j + lea ecx, [esp+30h+var_20] + mov [esp+30h+var_4], 0FFFFFFFFh + call sub_4CDA70 + +loc_4D1201: ; CODE XREF: CEncoder_CodeReal+9Ej + mov eax, edi + mov ecx, [esp+30h+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebp + add esp, 20h + retn 14h +; --------------------------------------------------------------------------- + +loc_4D1218: ; CODE XREF: CEncoder_CodeReal+C5j + lea ecx, [esp+30h+var_20] + mov [esp+30h+var_4], 0FFFFFFFFh + call sub_4CDA70 + xor eax, eax + mov ecx, [esp+30h+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebp + add esp, 20h + retn 14h +CEncoder_CodeReal endp + +; =============== S U B R O U T I N E ======================================= +; Attributes: bp-based frame + +CEncoder_Code proc near ; DATA XREF: .rdata:00517B08o +; sub_4D1240 + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +pThis = dword ptr 8 +pInStream = dword ptr 0Ch +pOutStream = dword ptr 10h +pInSize = dword ptr 14h +pOutSize = dword ptr 18h +progress = dword ptr 1Ch + + push ebp + mov ebp, esp + push 0FFFFFFFFh + push offset loc_4DA150 + mov eax, dword ptr fs:[0] + push eax + sub esp, 8 + push ebx + push esi + push edi + mov eax, dword_544960 + xor eax, ebp + push eax + lea eax, [ebp+var_C] + mov dword ptr fs:[0], eax + mov [ebp+var_10], esp + mov eax, [ebp+progress] + mov ecx, [ebp+pOutSize] + mov edx, [ebp+pInSize] + push eax + mov eax, [ebp+pOutStream] + push ecx + mov ecx, [ebp+pInStream] + push edx + push eax + push ecx + mov ecx, [ebp+pThis] + mov [ebp+var_4], 0 + call CEncoder_CodeReal + mov ecx, [ebp+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + retn 18h +CEncoder_Code endp + +; --------------------------------------------------------------------------- + +loc_4DA0FB: ; DATA XREF: Compress_lzma_internal+2o + mov edx, [esp+8] + lea eax, [edx-5Ch] + mov ecx, [edx-60h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset dword_526E44 + int 3; +; jmp ___CxxFrameHandler3 + +loc_4DA0C9: ; DATA XREF: sub_4CF810+2o + mov edx, [esp+8] + lea eax, [edx-0Ch] + mov ecx, [edx-10h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset dword_526E18 + int 3; +; jmp ___CxxFrameHandler3 + +loc_4DA128: ; DATA XREF: CEncoder_CodeReal+2o + mov edx, [esp+8] + lea eax, [edx-20h] + mov ecx, [edx-24h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset unk_526E70 + int 3; +; jmp ___CxxFrameHandler3 + +loc_4DA150: ; DATA XREF: CEncoder_Code+5o + mov edx, [esp+8] + lea eax, [edx+0Ch] + mov ecx, [edx-18h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset unk_526ED8 + int 3; +; jmp ___CxxFrameHandler3 + +END diff --git a/dep/StormLib/test/starcraft_sparse.asm b/dep/StormLib/test/starcraft_sparse.asm new file mode 100644 index 000000000..8d710951c --- /dev/null +++ b/dep/StormLib/test/starcraft_sparse.asm @@ -0,0 +1,387 @@ +.686P +.MODEL FLAT +ASSUME FS: NOTHING +.CODE + +extrn _memset:PROC + +; +; int starcraft_compress_sparse(char * pbOutBuffer, int * pcbOutLength, char * pbInBuffer, int cbInBuffer); +; + +_starcraft_compress_sparse PROC +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +pbOutBufferEnd = dword ptr -4 +pbOutBuffer = dword ptr 8 +pcbOutBuffer = dword ptr 0Ch +pbInBuffer = dword ptr 10h +cbInBuffer = dword ptr 14h + + push ebp + mov ebp, esp + sub esp, 0Ch + mov eax, [ebp+pcbOutBuffer] + mov eax, [eax] + mov edx, [ebp+pbOutBuffer] + add eax, edx + mov [ebp+pbOutBufferEnd], eax + mov eax, [ebp+cbInBuffer] + push edi + mov edi, [ebp+pbInBuffer] + add edx, 4 + cmp edx, [ebp+pbOutBufferEnd] + lea ecx, [edi+eax] + mov [ebp+var_C], ecx + jnb loc_466A24 + push ebx + push esi + mov esi, [ebp+pbOutBuffer] + mov edx, eax + shr edx, 18h + mov [esi], dl + inc esi + mov edx, eax + shr edx, 10h + mov [esi], dl + inc esi + mov edx, eax + shr edx, 8 + mov [esi], dl + inc esi + mov [esi], al + lea eax, [ecx-3] + inc esi + cmp edi, eax + jnb loc_4669FC + mov ebx, 80h + +loc_466885: ; CODE XREF: Compress_sparse+1CDj + and [ebp+pbInBuffer], 0 + cmp edi, ecx + mov eax, edi + mov [ebp+cbInBuffer], edi + jnb short loc_4668B5 + +loc_466892: ; CODE XREF: Compress_sparse+8Aj + mov edx, [ebp+cbInBuffer] + cmp byte ptr [edx], 0 + jnz short loc_46689F + inc [ebp+pbInBuffer] + jmp short loc_4668AD +; --------------------------------------------------------------------------- + +loc_46689F: ; CODE XREF: Compress_sparse+6Fj + cmp [ebp+pbInBuffer], 3 + jnb short loc_4668B5 + mov eax, [ebp+cbInBuffer] + inc eax + and [ebp+pbInBuffer], 0 + +loc_4668AD: ; CODE XREF: Compress_sparse+74j + inc [ebp+cbInBuffer] + cmp [ebp+cbInBuffer], ecx + jb short loc_466892 + +loc_4668B5: ; CODE XREF: Compress_sparse+67j + ; Compress_sparse+7Aj + sub eax, edi + mov [ebp+cbInBuffer], eax + jz loc_466984 + cmp eax, 81h + jbe short loc_466901 + lea eax, [esi+81h] + jmp short loc_4668D2 +; --------------------------------------------------------------------------- + +loc_4668CF: ; CODE XREF: Compress_sparse+D6j + mov eax, [ebp+var_8] + +loc_4668D2: ; CODE XREF: Compress_sparse+A4j + cmp eax, [ebp+pbOutBufferEnd] + jnb loc_466A22 + push ebx + mov byte ptr [esi], 0FFh + inc esi + inc eax + push edi + push esi + mov [ebp+var_8], eax + call _memset ; Microsoft VisualC 2-8/net runtime + sub [ebp+cbInBuffer], ebx + add [ebp+var_8], ebx + add esp, 0Ch + add esi, ebx + add edi, ebx + cmp [ebp+cbInBuffer], 81h + ja short loc_4668CF + +loc_466901: ; CODE XREF: Compress_sparse+9Cj + cmp [ebp+cbInBuffer], ebx + jbe short loc_466926 + lea eax, [esi+2] + cmp eax, [ebp+pbOutBufferEnd] + jnb loc_466A22 + push 1 + mov [esi], bl + inc esi + push edi + push esi + call _memset ; Microsoft VisualC 2-8/net runtime + add esp, 0Ch + inc esi + inc edi + dec [ebp+cbInBuffer] + +loc_466926: ; CODE XREF: Compress_sparse+DBj + mov eax, [ebp+cbInBuffer] + cmp eax, 1 + jb short loc_466957 + lea ecx, [eax+esi+1] + cmp ecx, [ebp+pbOutBufferEnd] + jnb loc_466A22 + mov cl, al + dec cl + or cl, bl + push eax + mov [esi], cl + inc esi + push edi + push esi + call _memset ; Microsoft VisualC 2-8/net runtime + add esi, [ebp+cbInBuffer] + add esp, 0Ch + add edi, [ebp+cbInBuffer] + jmp short loc_466981 +; --------------------------------------------------------------------------- + +loc_466957: ; CODE XREF: Compress_sparse+103j + lea eax, [esi+2] + cmp eax, [ebp+pbOutBufferEnd] + jnb loc_466A22 + push 1 + mov [esi], bl + inc esi + push edi + push esi + call _memset ; Microsoft VisualC 2-8/net runtime + mov eax, [ebp+pbInBuffer] + mov ecx, [ebp+cbInBuffer] + add esp, 0Ch + lea eax, [eax+ecx-1] + inc esi + inc edi + mov [ebp+pbInBuffer], eax + +loc_466981: ; CODE XREF: Compress_sparse+12Cj + mov ecx, [ebp+var_C] + +loc_466984: ; CODE XREF: Compress_sparse+91j + cmp [ebp+pbInBuffer], 85h + jbe short loc_4669B9 + lea eax, [esi+1] + mov [ebp+cbInBuffer], eax + +loc_466993: ; CODE XREF: Compress_sparse+18Ej + mov eax, [ebp+cbInBuffer] + cmp eax, [ebp+pbOutBufferEnd] + jnb loc_466A22 + mov eax, 82h + sub [ebp+pbInBuffer], eax + mov byte ptr [esi], 7Fh + inc esi + inc [ebp+cbInBuffer] + add edi, eax + cmp [ebp+pbInBuffer], 85h + ja short loc_466993 + +loc_4669B9: ; CODE XREF: Compress_sparse+162j + cmp [ebp+pbInBuffer], 82h + jbe short loc_4669D6 + lea eax, [esi+1] + cmp eax, [ebp+pbOutBufferEnd] + jnb short loc_466A22 + mov byte ptr [esi], 0 + add edi, 3 + sub [ebp+pbInBuffer], 3 + mov esi, eax + +loc_4669D6: ; CODE XREF: Compress_sparse+197j + cmp [ebp+pbInBuffer], 3 + jb short loc_4669F1 + lea eax, [esi+1] + cmp eax, [ebp+pbOutBufferEnd] + jnb short loc_466A22 + mov dl, byte ptr [ebp+pbInBuffer] + sub dl, 3 + add edi, [ebp+pbInBuffer] + mov [esi], dl + mov esi, eax + +loc_4669F1: ; CODE XREF: Compress_sparse+1B1j + lea eax, [ecx-3] + cmp edi, eax + jb loc_466885 + +loc_4669FC: ; CODE XREF: Compress_sparse+51j + cmp edi, ecx + jnb short loc_466A1A + mov eax, edi + +loc_466A02: ; CODE XREF: Compress_sparse+1E2j + mov dl, [eax] + inc eax + test dl, dl + jnz short loc_466A27 + cmp eax, ecx + jb short loc_466A02 + lea eax, [esi+1] + cmp eax, [ebp+pbOutBufferEnd] + jnb short loc_466A22 + mov byte ptr [esi], 7Fh + mov esi, eax + +loc_466A1A: ; CODE XREF: Compress_sparse+1D5j + ; Compress_sparse+21Cj + sub esi, [ebp+pbOutBuffer] + mov eax, [ebp+pcbOutBuffer] + mov [eax], esi + +loc_466A22: ; CODE XREF: Compress_sparse+ACj + ; Compress_sparse+E3j ... + pop esi + pop ebx + +loc_466A24: ; CODE XREF: Compress_sparse+26j + pop edi + leave + retn +; --------------------------------------------------------------------------- + +loc_466A27: ; CODE XREF: Compress_sparse+1DEj + sub ecx, edi + mov ebx, ecx + lea eax, [ebx+esi+1] + cmp eax, [ebp+pbOutBufferEnd] + jnb short loc_466A22 + push ebx + mov byte ptr [esi], 0FFh + inc esi + push edi + push esi + call _memset ; Microsoft VisualC 2-8/net runtime + add esp, 0Ch + add esi, ebx + jmp short loc_466A1A +_starcraft_compress_sparse ENDP + +; +; int starcraft_decompress_sparse(char * pbOutBuffer, int * pcbOutLength, char * pbInBuffer, int cbInBuffer); +; + +_starcraft_decompress_sparse PROC +pbInBufferEnd = dword ptr -4 +pbOutBuffer = dword ptr 8 +pcbOutBuffer = dword ptr 0Ch +pbInBuffer = dword ptr 10h +cbInBuffer = dword ptr 14h + + push ebp + mov ebp, esp + push ecx + mov eax, [ebp+pbOutBuffer] + push esi + mov esi, [ebp+pbInBuffer] ; ESI - pbInBuffer + mov [ebp+pbOutBuffer], eax + mov eax, [ebp+cbInBuffer] + cmp eax, 5 + lea ecx, [esi+eax] + mov [ebp+pbInBufferEnd], ecx + jnb short loc_466A6A + xor al, al + jmp loc_466AF5 +; --------------------------------------------------------------------------- + +loc_466A6A: ; CODE XREF: Decompress_sparse+1Aj + push edi + movzx edi, byte ptr [esi] + shl edi, 18h + inc esi + movzx eax, byte ptr [esi] + shl eax, 10h + or edi, eax + xor eax, eax + inc esi + mov ah, [esi] + or edi, eax + inc esi + movzx eax, byte ptr [esi] + or edi, eax + mov eax, [ebp+pcbOutBuffer] + inc esi + cmp esi, ecx + mov [ebp+pbInBuffer], edi ; EDI = cbOutBuffer + mov [eax], edi + jnb short loc_466AF2 + push ebx + +loc_466A95: ; CODE XREF: Decompress_sparse+A8j + movzx eax, byte ptr [esi] + inc esi + test al, al + jns short loc_466AC1 + and eax, 7Fh + inc eax ; AL = (*pbInBuffer & 0x7F) + 1 + mov [ebp+cbInBuffer], eax + cmp eax, edi ; AL < cbOutBuffer ? + lea eax, [ebp+cbInBuffer] + jb short loc_466AAE + lea eax, [ebp+pbInBuffer] + +loc_466AAE: ; CODE XREF: Decompress_sparse+62j + mov ebx, [eax] + push ebx + push esi + push [ebp+pbOutBuffer] + call _memset ; Microsoft VisualC 2-8/net runtime + add esp, 0Ch + add esi, ebx + jmp short loc_466AE4 +; --------------------------------------------------------------------------- + +loc_466AC1: ; CODE XREF: Decompress_sparse+54j + and eax, 7Fh + add eax, 3 + mov [ebp+cbInBuffer], eax + cmp eax, edi + lea eax, [ebp+cbInBuffer] + jb short loc_466AD4 + lea eax, [ebp+pbInBuffer] + +loc_466AD4: ; CODE XREF: Decompress_sparse+88j + mov ebx, [eax] + push ebx ; Size + push 0 ; Val + push [ebp+pbOutBuffer] ; Dst + call _memset + add esp, 0Ch + +loc_466AE4: ; CODE XREF: Decompress_sparse+78j + add [ebp+pbOutBuffer], ebx + sub edi, ebx + cmp esi, [ebp+pbInBufferEnd] + mov [ebp+pbInBuffer], edi + jb short loc_466A95 + pop ebx + +loc_466AF2: ; CODE XREF: Decompress_sparse+4Bj + mov al, 1 + pop edi + +loc_466AF5: ; CODE XREF: Decompress_sparse+1Ej + pop esi + leave + retn +_starcraft_decompress_sparse ENDP + +END diff --git a/dep/StormLib/test/x86_ripped_code.asm b/dep/StormLib/test/x86_ripped_code.asm new file mode 100644 index 000000000..4b4be328a --- /dev/null +++ b/dep/StormLib/test/x86_ripped_code.asm @@ -0,0 +1,1231 @@ +.686P +.MODEL FLAT +ASSUME FS: NOTHING +.CODE + +extrn _memset:PROC +extrn _memcpy:PROC +extrn _memmove:PROC + +;------------------------------------------------------------------------------ +; Structures +; + +;------------------------------------------------------------------------------ +; Functions +; + +_aullrem proc near ; CODE XREF: sub_6CC140+3Ap + ; sub_6CC1E0+57p ... + +DividendLo = dword ptr 8 +DividendHi = dword ptr 0Ch +DivisorLo = dword ptr 10h +DivisorHi = dword ptr 14h + + push ebx + mov eax, [esp+DivisorHi] + or eax, eax + jnz short loc_8F8FE1 + mov ecx, [esp+DivisorLo] + mov eax, [esp+DividendHi] + xor edx, edx + div ecx + mov eax, [esp+DividendLo] + div ecx + mov eax, edx + xor edx, edx + jmp short loc_8F9031 +; --------------------------------------------------------------------------- + +loc_8F8FE1: ; CODE XREF: _aullrem+7j + mov ecx, eax + mov ebx, [esp+DivisorLo] + mov edx, [esp+DividendHi] + mov eax, [esp+DividendLo] + +loc_8F8FEF: ; CODE XREF: _aullrem+39j + shr ecx, 1 + rcr ebx, 1 + shr edx, 1 + rcr eax, 1 + or ecx, ecx + jnz short loc_8F8FEF + div ebx + mov ecx, eax + mul [esp+DivisorHi] + xchg eax, ecx + mul [esp+DivisorLo] + add edx, ecx + jb short loc_8F901A + cmp edx, [esp+DividendHi] + ja short loc_8F901A + jb short loc_8F9022 + cmp eax, [esp+DividendLo] + jbe short loc_8F9022 + +loc_8F901A: ; CODE XREF: _aullrem+4Aj + ; _aullrem+50j + sub eax, [esp+DivisorLo] + sbb edx, [esp+DivisorHi] + +loc_8F9022: ; CODE XREF: _aullrem+52j + ; _aullrem+58j + sub eax, [esp+DividendLo] + sbb edx, [esp+DividendHi] + neg edx + neg eax + sbb edx, 0 + +loc_8F9031: ; CODE XREF: _aullrem+1Fj + pop ebx + retn 10h +_aullrem endp + +_aullshr proc near ; CODE XREF: sub_40E2B6+1ECp + ; sub_40E2B6+240p ... + cmp cl, 40h + jnb short loc_414BDA + cmp cl, 20h + jnb short loc_414BD0 + shrd eax, edx, cl + shr edx, cl + retn +; --------------------------------------------------------------------------- + +loc_414BD0: ; CODE XREF: _aullshr+8j + mov eax, edx + xor edx, edx + and cl, 1Fh + shr eax, cl + retn +; --------------------------------------------------------------------------- + +loc_414BDA: ; CODE XREF: _aullshr+3j + xor eax, eax + xor edx, edx + retn +_aullshr endp + + +; =============== S U B R O U T I N E ======================================= + +; Attributes: bp-based frame + +SFileDecryptMpqHeader proc near ; CODE XREF: sub_6D00E0+AEp + ; sub_6D00E0+D3p + +EncryptedDataAligned= dword ptr -88h +var_48 = dword ptr -48h +DecryptBuffer = dword ptr -44h +var_40 = dword ptr -40h +var_3C = dword ptr -3Ch +var_38 = dword ptr -38h +var_34 = dword ptr -34h +var_30 = dword ptr -30h +var_2C = dword ptr -2Ch +var_28 = dword ptr -28h +var_24 = dword ptr -24h +var_20 = dword ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +var_0C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_FFFFFFF8 = dword ptr 0 +arg_FFFFFFFC = dword ptr 4 +arg_0 = dword ptr 8 + + push ebp + mov ebp, esp + sub esp, 88h + mov eax, [ecx+8] + mov edx, [ecx+14h] + push ebx + mov ebx, [ecx+10h] + mov [ebp+var_0C], eax + mov eax, [ebp+arg_0] + push esi + push edi + mov edi, [ecx+0Ch] + mov [ebp+DecryptBuffer], ecx + mov [ebp+var_10], edx + test al, 3 + jz short loc_6C9F03 + mov ecx, [eax] + mov [ebp+EncryptedDataAligned], ecx + mov ecx, [eax+4] + mov [ebp+EncryptedDataAligned+4], ecx + mov ecx, [eax+8] + mov [ebp+EncryptedDataAligned+8], ecx + mov ecx, [eax+0Ch] + mov [ebp+EncryptedDataAligned+0Ch], ecx + mov ecx, [eax+10h] + mov [ebp+EncryptedDataAligned+10h], ecx + mov ecx, [eax+14h] + mov [ebp+EncryptedDataAligned+14h], ecx + mov ecx, [eax+18h] + mov [ebp+EncryptedDataAligned+18h], ecx + mov ecx, [eax+1Ch] + mov [ebp+EncryptedDataAligned+1Ch], ecx + mov ecx, [eax+20h] + mov [ebp+EncryptedDataAligned+20h], ecx + mov ecx, [eax+24h] + mov [ebp+EncryptedDataAligned+24h], ecx + mov ecx, [eax+28h] + mov [ebp+EncryptedDataAligned+28h], ecx + mov ecx, [eax+2Ch] + mov [ebp+EncryptedDataAligned+2Ch], ecx + mov ecx, [eax+30h] + mov [ebp+EncryptedDataAligned+30h], ecx + mov ecx, [eax+34h] + mov [ebp+EncryptedDataAligned+34h], ecx + mov ecx, [eax+38h] + mov eax, [eax+3Ch] + mov [ebp+EncryptedDataAligned+3Ch], eax + mov [ebp+EncryptedDataAligned+38h], ecx + lea eax, [ebp+EncryptedDataAligned] + +loc_6C9F03: ; CODE XREF: SFileDecryptMpqHeader+26j + mov ecx, [eax] + mov [ebp+var_30], ecx + mov esi, edi + not esi + and esi, edx + mov edx, ebx + and edx, edi + or esi, edx + add esi, ecx + mov ecx, [ebp+var_0C] + lea edx, [esi+ecx-28955B88h] + mov ecx, [eax+4] + rol edx, 7 + add edx, edi + mov [ebp+var_2C], ecx + mov ecx, edx + not ecx + and ecx, ebx + mov esi, edi + and esi, edx + or ecx, esi + add ecx, [ebp+var_2C] + mov esi, [ebp+var_10] + lea esi, [ecx+esi-173848AAh] + mov ecx, [eax+8] + mov [ebp+var_40], ecx + rol esi, 0Ch + add esi, edx + mov ecx, esi + not ecx + and ecx, edi + mov edi, esi + and edi, edx + or ecx, edi + add ecx, [ebp+var_40] + lea edi, [ecx+ebx+242070DBh] + mov ecx, [eax+0Ch] + ror edi, 0Fh + add edi, esi + mov [ebp+var_1C], ecx + mov ebx, edi + not ebx + and ebx, edx + mov ecx, esi + and ecx, edi + or ebx, ecx + add ebx, [ebp+var_1C] + mov ecx, [ebp+DecryptBuffer] + mov ecx, [ecx+0Ch] + lea ecx, [ebx+ecx-3E423112h] + ror ecx, 0Ah + add ecx, edi + mov [ebp+var_4], edi + and edi, ecx + mov ebx, ecx + not ebx + and ebx, esi + or ebx, edi + mov edi, [eax+10h] + add ebx, edi + lea edx, [ebx+edx-0A83F051h] + rol edx, 7 + add edx, ecx + mov [ebp+arg_0], edx + not edx + and edx, [ebp+var_4] + mov ebx, ecx + and ebx, [ebp+arg_0] + mov [ebp+var_10], edi + mov edi, [eax+14h] + or edx, ebx + add edx, edi + lea esi, [edx+esi+4787C62Ah] + mov edx, [eax+18h] + mov [ebp+var_34], edi + mov edi, [ebp+arg_0] + rol esi, 0Ch + add esi, edi + mov [ebp+var_20], edx + mov edx, esi + not edx + and edx, ecx + mov ebx, esi + and ebx, edi + or edx, ebx + add edx, [ebp+var_20] + mov ebx, [ebp+var_4] + lea edx, [edx+ebx-57CFB9EDh] + ror edx, 0Fh + add edx, esi + mov ebx, edx + not ebx + and ebx, edi + mov edi, esi + and edi, edx + or ebx, edi + mov edi, [eax+1Ch] + add ebx, edi + lea ecx, [ebx+ecx-2B96AFFh] + ror ecx, 0Ah + add ecx, edx + mov [ebp+var_3C], edi + mov edi, [eax+20h] + mov [ebp+var_14], edi + mov edi, ecx + not edi + and edi, esi + mov ebx, edx + and ebx, ecx + or edi, ebx + add edi, [ebp+var_14] + mov ebx, [ebp+arg_0] + lea edi, [edi+ebx+698098D8h] + mov [ebp+var_8], ecx + rol edi, 7 + add edi, ecx + and ecx, edi + mov ebx, edi + not ebx + and ebx, edx + or ebx, ecx + mov ecx, [eax+24h] + add ebx, ecx + mov [ebp+var_0C], ecx + mov ecx, [eax+28h] + lea esi, [ebx+esi-74BB0851h] + mov [ebp+var_24], ecx + rol esi, 0Ch + add esi, edi + mov ecx, esi + not ecx + and ecx, [ebp+var_8] + mov ebx, esi + and ebx, edi + or ecx, ebx + add ecx, [ebp+var_24] + mov ebx, esi + lea edx, [ecx+edx-0A44Fh] + mov ecx, [eax+2Ch] + ror edx, 0Fh + add edx, esi + mov [ebp+var_18], ecx + and ebx, edx + mov ecx, edx + not ecx + and ecx, edi + or ecx, ebx + add ecx, [ebp+var_18] + mov ebx, [ebp+var_8] + lea ecx, [ecx+ebx-76A32842h] + ror ecx, 0Ah + add ecx, edx + mov ebx, ecx + not ebx + mov [ebp+var_4], edx + and edx, ecx + and ebx, esi + or ebx, edx + mov edx, [eax+30h] + add ebx, edx + mov [ebp+var_38], edx + lea edi, [ebx+edi+6B901122h] + mov edx, [eax+34h] + rol edi, 7 + add edi, ecx + mov [ebp+arg_0], edi + not edi + and edi, [ebp+var_4] + mov ebx, ecx + and ebx, [ebp+arg_0] + mov [ebp+var_8], edx + or edi, ebx + add edi, edx + mov edx, [eax+38h] + mov eax, [eax+3Ch] + lea esi, [edi+esi-2678E6Dh] + rol esi, 0Ch + add esi, [ebp+arg_0] + mov [ebp+var_28], edx + mov edi, esi + not edi + mov edx, edi + and edx, ecx + mov ebx, esi + and ebx, [ebp+arg_0] + or edx, ebx + add edx, [ebp+var_28] + mov ebx, [ebp+var_4] + lea edx, [edx+ebx-5986BC72h] + mov [ebp+var_4], eax + ror edx, 0Fh + add edx, esi + mov ebx, edx + not ebx + mov [ebp+var_48], ebx + and ebx, [ebp+arg_0] + mov eax, esi + and eax, edx + or ebx, eax + add ebx, [ebp+var_4] + and edi, edx + lea ecx, [ebx+ecx+49B40821h] + ror ecx, 0Ah + add ecx, edx + mov eax, esi + and eax, ecx + or edi, eax + add edi, [ebp+var_2C] + mov eax, [ebp+arg_0] + lea edi, [edi+eax-9E1DA9Eh] + mov eax, [ebp+var_48] + and eax, ecx + rol edi, 5 + add edi, ecx + mov ebx, edx + and ebx, edi + or eax, ebx + add eax, [ebp+var_20] + lea esi, [eax+esi-3FBF4CC0h] + rol esi, 9 + add esi, edi + mov eax, ecx + not eax + and eax, edi + mov ebx, esi + and ebx, ecx + or eax, ebx + add eax, [ebp+var_18] + lea edx, [eax+edx+265E5A51h] + rol edx, 0Eh + add edx, esi + mov eax, edi + not eax + and eax, esi + mov ebx, edx + and ebx, edi + or eax, ebx + add eax, [ebp+var_30] + lea ecx, [eax+ecx-16493856h] + ror ecx, 0Ch + mov eax, esi + add ecx, edx + not eax + and eax, edx + mov ebx, esi + and ebx, ecx + or eax, ebx + add eax, [ebp+var_34] + lea edi, [eax+edi-29D0EFA3h] + rol edi, 5 + add edi, ecx + mov [ebp+arg_0], edi + mov eax, edx + not eax + and eax, ecx + mov edi, edx + and edi, [ebp+arg_0] + or eax, edi + add eax, [ebp+var_24] + mov edi, ecx + lea esi, [eax+esi+2441453h] + mov eax, [ebp+arg_0] + not edi + and edi, eax + rol esi, 9 + add esi, eax + not eax + and eax, esi + mov ebx, esi + and ebx, ecx + or edi, ebx + add edi, [ebp+var_4] + lea edx, [edi+edx-275E197Fh] + rol edx, 0Eh + add edx, esi + mov edi, edx + and edi, [ebp+arg_0] + or eax, edi + add eax, [ebp+var_10] + mov edi, esi + lea ecx, [eax+ecx-182C0438h] + ror ecx, 0Ch + add ecx, edx + and edi, ecx + mov eax, esi + not eax + and eax, edx + or eax, edi + add eax, [ebp+var_0C] + mov edi, [ebp+arg_0] + lea eax, [eax+edi+21E1CDE6h] + rol eax, 5 + add eax, ecx + mov [ebp+arg_0], eax + mov eax, edx + not eax + and eax, ecx + mov edi, edx + and edi, [ebp+arg_0] + or eax, edi + add eax, [ebp+var_28] + mov edi, ecx + lea esi, [eax+esi-3CC8F82Ah] + mov eax, [ebp+arg_0] + rol esi, 9 + add esi, eax + not edi + and edi, eax + mov ebx, esi + and ebx, ecx + or edi, ebx + add edi, [ebp+var_1C] + not eax + lea edx, [edi+edx-0B2AF279h] + rol edx, 0Eh + add edx, esi + and eax, esi + mov edi, edx + and edi, [ebp+arg_0] + or eax, edi + add eax, [ebp+var_14] + lea ecx, [eax+ecx+455A14EDh] + ror ecx, 0Ch + add ecx, edx + mov eax, esi + not eax + and eax, edx + mov edi, esi + and edi, ecx + or eax, edi + add eax, [ebp+var_8] + mov edi, [ebp+arg_0] + lea eax, [eax+edi-561C16FBh] + rol eax, 5 + add eax, ecx + mov [ebp+arg_0], eax + mov eax, edx + not eax + and eax, ecx + mov edi, edx + and edi, [ebp+arg_0] + or eax, edi + add eax, [ebp+var_40] + mov edi, ecx + lea esi, [eax+esi-3105C08h] + mov eax, [ebp+arg_0] + not edi + and edi, eax + rol esi, 9 + add esi, eax + mov ebx, esi + and ebx, ecx + or edi, ebx + add edi, [ebp+var_3C] + not eax + lea edx, [edi+edx+676F02D9h] + and eax, esi + rol edx, 0Eh + add edx, esi + mov edi, edx + and edi, [ebp+arg_0] + or eax, edi + add eax, [ebp+var_38] + mov edi, [ebp+arg_0] + lea ecx, [eax+ecx-72D5B376h] + ror ecx, 0Ch + add ecx, edx + mov eax, esi + xor eax, edx + xor eax, ecx + add eax, [ebp+var_34] + lea eax, [eax+edi-5C6BEh] + rol eax, 4 + add eax, ecx + mov edi, edx + xor edi, ecx + xor edi, eax + add edi, [ebp+var_14] + lea esi, [edi+esi-788E097Fh] + rol esi, 0Bh + add esi, eax + mov edi, esi + xor edi, ecx + xor edi, eax + add edi, [ebp+var_18] + lea edx, [edi+edx+6D9D6122h] + rol edx, 10h + add edx, esi + mov edi, esi + xor edi, edx + mov ebx, edi + xor ebx, eax + add ebx, [ebp+var_28] + lea ecx, [ebx+ecx-21AC7F4h] + ror ecx, 9 + add ecx, edx + xor edi, ecx + add edi, [ebp+var_2C] + lea eax, [edi+eax-5B4115BCh] + rol eax, 4 + mov edi, edx + add eax, ecx + xor edi, ecx + xor edi, eax + add edi, [ebp+var_10] + lea esi, [edi+esi+4BDECFA9h] + rol esi, 0Bh + add esi, eax + mov edi, esi + xor edi, ecx + xor edi, eax + add edi, [ebp+var_3C] + lea edx, [edi+edx-944B4A0h] + rol edx, 10h + add edx, esi + mov edi, esi + xor edi, edx + mov ebx, edi + xor ebx, eax + add ebx, [ebp+var_24] + lea ecx, [ebx+ecx-41404390h] + ror ecx, 9 + add ecx, edx + xor edi, ecx + add edi, [ebp+var_8] + lea eax, [edi+eax+289B7EC6h] + rol eax, 4 + add eax, ecx + mov edi, edx + xor edi, ecx + xor edi, eax + add edi, [ebp+var_30] + lea esi, [edi+esi-155ED806h] + rol esi, 0Bh + add esi, eax + mov edi, esi + xor edi, ecx + xor edi, eax + add edi, [ebp+var_1C] + lea edi, [edi+edx-2B10CF7Bh] + rol edi, 10h + add edi, esi + mov edx, esi + xor edx, edi + mov ebx, edx + xor ebx, eax + add ebx, [ebp+var_20] + lea ecx, [ebx+ecx+4881D05h] + ror ecx, 9 + add ecx, edi + xor edx, ecx + add edx, [ebp+var_0C] + lea eax, [edx+eax-262B2FC7h] + rol eax, 4 + add eax, ecx + mov edx, edi + xor edx, ecx + xor edx, eax + add edx, [ebp+var_38] + lea edx, [edx+esi-1924661Bh] + rol edx, 0Bh + add edx, eax + mov esi, edx + xor esi, ecx + xor esi, eax + add esi, [ebp+var_4] + mov ebx, edx + lea esi, [esi+edi+1FA27CF8h] + mov edi, [ebp+var_40] + rol esi, 10h + add esi, edx + xor ebx, esi + xor ebx, eax + add ebx, edi + lea ecx, [ebx+ecx-3B53A99Bh] + ror ecx, 9 + add ecx, esi + mov ebx, edx + not ebx + or ebx, ecx + xor ebx, esi + add ebx, [ebp+var_30] + lea eax, [ebx+eax-0BD6DDBCh] + rol eax, 6 + add eax, ecx + mov ebx, esi + not ebx + or ebx, eax + xor ebx, ecx + add ebx, [ebp+var_3C] + lea edx, [ebx+edx+432AFF97h] + rol edx, 0Ah + add edx, eax + mov ebx, ecx + not ebx + or ebx, edx + xor ebx, eax + add ebx, [ebp+var_28] + lea esi, [ebx+esi-546BDC59h] + rol esi, 0Fh + add esi, edx + mov ebx, eax + not ebx + or ebx, esi + xor ebx, edx + add ebx, [ebp+var_34] + lea ecx, [ebx+ecx-36C5FC7h] + ror ecx, 0Bh + add ecx, esi + mov ebx, edx + not ebx + or ebx, ecx + xor ebx, esi + add ebx, [ebp+var_38] + lea eax, [ebx+eax+655B59C3h] + rol eax, 6 + add eax, ecx + mov ebx, esi + not ebx + or ebx, eax + xor ebx, ecx + add ebx, [ebp+var_1C] + lea edx, [ebx+edx-70F3336Eh] + rol edx, 0Ah + add edx, eax + mov ebx, ecx + not ebx + or ebx, edx + xor ebx, eax + add ebx, [ebp+var_24] + lea esi, [ebx+esi-100B83h] + rol esi, 0Fh + add esi, edx + mov ebx, eax + not ebx + or ebx, esi + xor ebx, edx + add ebx, [ebp+var_2C] + lea ecx, [ebx+ecx-7A7BA22Fh] + ror ecx, 0Bh + add ecx, esi + mov ebx, edx + not ebx + or ebx, ecx + xor ebx, esi + add ebx, [ebp+var_14] + lea eax, [ebx+eax+6FA87E4Fh] + rol eax, 6 + add eax, ecx + mov ebx, esi + not ebx + or ebx, eax + xor ebx, ecx + add ebx, [ebp+var_4] + lea edx, [ebx+edx-1D31920h] + rol edx, 0Ah + add edx, eax + mov ebx, ecx + not ebx + or ebx, edx + xor ebx, eax + add ebx, [ebp+var_20] + lea esi, [ebx+esi-5CFEBCECh] + rol esi, 0Fh + mov ebx, eax + add esi, edx + not ebx + or ebx, esi + xor ebx, edx + add ebx, [ebp+var_8] + lea ecx, [ebx+ecx+4E0811A1h] + ror ecx, 0Bh + add ecx, esi + mov ebx, edx + not ebx + or ebx, ecx + xor ebx, esi + add ebx, [ebp+var_10] + lea eax, [ebx+eax-8AC817Eh] + rol eax, 6 + add eax, ecx + mov ebx, esi + not ebx + or ebx, eax + xor ebx, ecx + add ebx, [ebp+var_18] + lea edx, [ebx+edx-42C50DCBh] + rol edx, 0Ah + add edx, eax + mov ebx, ecx + not ebx + or ebx, edx + xor ebx, eax + add ebx, edi + lea esi, [ebx+esi+2AD7D2BBh] + mov edi, eax + not edi + rol esi, 0Fh + add esi, edx + or edi, esi + xor edi, edx + add edi, [ebp+var_0C] + lea edi, [edi+ecx-14792C6Fh] + mov ecx, [ebp+DecryptBuffer] + mov ebx, [ecx+8] + add ebx, eax + mov eax, [ecx+10h] + ror edi, 0Bh + add edi, [ecx+0Ch] + add eax, esi + add edi, esi + mov [ecx+10h], eax + mov eax, [ecx+14h] + mov [ecx+0Ch], edi + pop edi + add eax, edx + pop esi + mov [ecx+8], ebx + mov [ecx+14h], eax + pop ebx + mov esp, ebp + pop ebp + retn 4 +SFileDecryptMpqHeader endp + +; --------------------------------------------------------------------------- + +; --------------------------------------------------------------------------- + +sub_6D00E0 proc near ; CODE XREF: sub_6D0210+59p + ; sub_6D0210+66p ... + +var_10 = dword ptr -10h +pbMpqHeader = dword ptr -4 +pMpqHeader = dword ptr 8 +dwSize = dword ptr 0Ch + + push ebp + mov ebp, esp + push ecx + mov eax, [ebp+pMpqHeader] ; EAX = MPQ Header + push ebx + mov ebx, [ebp+dwSize] ; EBX - size of MPQ Header + push esi + push edi + mov esi, ecx ; ESI - decryption buffer (6 DWORDs) + mov edi, [esi] + shr edi, 3 + and edi, 3Fh + mov [ebp+pbMpqHeader], eax + lea ecx, ds:0[ebx*8] ; ECX = sizeof header * 8 + test ebx, ebx + jbe loc_6D01F8 + add [esi], ecx + mov edx, ebx ; EDX = size of header + shr edx, 1Dh + add [esi+4], edx + mov edx, [esi+4] + cmp [esi], ecx + jnb short loc_6D011E + inc edx + mov [esi+4], edx + +loc_6D011E: ; CODE XREF: sub_6D00E0+38j + test edi, edi + jz short loc_6D0196 + lea eax, [edi+ebx] + cmp eax, 40h + jbe short loc_6D0136 + mov eax, 40h + sub eax, edi + mov [ebp+dwSize], eax + jmp short loc_6D013B +; --------------------------------------------------------------------------- + +loc_6D0136: ; CODE XREF: sub_6D00E0+48j + mov [ebp+dwSize], ebx + mov eax, ebx + +loc_6D013B: ; CODE XREF: sub_6D00E0+54j + mov edx, [ebp+pMpqHeader] + add edx, eax + lea ecx, [edi+esi+18h] + mov [ebp+pbMpqHeader], edx + cmp ecx, edx + jnb short loc_6D0163 + lea edx, [ecx+eax] + mov ecx, [ebp+pMpqHeader] + cmp edx, ecx + jbe short loc_6D0166 + push eax + push ecx + lea eax, [edi+esi+18h] + push eax + call _memmove + jmp short loc_6D0172 +; --------------------------------------------------------------------------- + +loc_6D0163: ; CODE XREF: sub_6D00E0+69j + mov ecx, [ebp+pMpqHeader] + +loc_6D0166: ; CODE XREF: sub_6D00E0+73j + push eax + push ecx + lea eax, [edi+esi+18h] + push eax + call _memcpy + +loc_6D0172: ; CODE XREF: sub_6D00E0+81j + mov eax, [ebp+dwSize] + lea ecx, [eax+edi] + add esp, 0Ch + cmp ecx, 40h + jl short loc_6D01F8 + mov edx, [ebp+pbMpqHeader] + sub ebx, eax + lea eax, [esi+18h] + push eax + mov ecx, esi + mov [ebp+pbMpqHeader], edx + call SFileDecryptMpqHeader + mov eax, [ebp+pbMpqHeader] + +loc_6D0196: ; CODE XREF: sub_6D00E0+40j + cmp ebx, 40h + jl short loc_6D01C4 + mov edi, ebx + shr edi, 6 + mov ecx, edi + neg ecx + shl ecx, 6 + add ebx, ecx + lea esp, [esp+0] + +loc_6D01B0: ; CODE XREF: sub_6D00E0+E2j + push eax + mov ecx, esi + call SFileDecryptMpqHeader + add [ebp+pbMpqHeader], 40h + sub edi, 1 + mov eax, [ebp+pbMpqHeader] + jnz short loc_6D01B0 + +loc_6D01C4: ; CODE XREF: sub_6D00E0+B9j + test ebx, ebx + jz short loc_6D01F8 + add esi, 18h + lea edx, [ebx+eax] + cmp esi, edx + jnb short loc_6D01ED + lea ecx, [esi+ebx] + cmp ecx, eax + jbe short loc_6D01ED + push ebx + push eax + push esi + call _memmove + add esp, 0Ch + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + retn 8 +; --------------------------------------------------------------------------- + +loc_6D01ED: ; CODE XREF: sub_6D00E0+F0j + ; sub_6D00E0+F7j + push ebx + push eax + push esi + call _memcpy + add esp, 0Ch + +loc_6D01F8: ; CODE XREF: sub_6D00E0+23j + ; sub_6D00E0+9Ej ... + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + retn 8 +sub_6D00E0 endp + +aA_1: ; DATA XREF: sub_6249D0+68o + ; sub_6D0210+4Fo ... + dw 80h, 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + +sub_6D0210 proc near ; CODE XREF: SFileVerifyMpqHeaderMD5+42p + ; sub_6D2D60+A9p ... + +var_8 = byte ptr -8 +var_6 = byte ptr -6 +var_5 = byte ptr -5 +var_4 = byte ptr -4 +var_3 = byte ptr -3 +var_2 = byte ptr -2 +var_1 = byte ptr -1 +arg_0 = dword ptr 8 + + push ebp + mov ebp, esp + sub esp, 8 + push esi + mov esi, ecx ; Source address + mov eax, [esi] + mov ecx, eax + shr ecx, 8 + mov [ebp-7], cl + mov ecx, eax + shr ecx, 18h + mov [ebp+var_5], cl + mov ecx, [esi+4] + mov edx, eax + shr edx, 10h + mov [ebp+var_6], dl + mov edx, ecx + mov [ebp+var_4], cl + shr edx, 8 + mov [ebp+var_3], dl + mov edx, ecx + shr ecx, 18h + mov [ebp+var_1], cl + mov [ebp+var_8], al + shr eax, 3 + mov ecx, 0FFFFFFF7h + sub ecx, eax + and ecx, 3Fh + push edi + inc ecx + push ecx + shr edx, 10h + push offset aA_1 ; "" + mov ecx, esi + mov [ebp+var_2], dl + call sub_6D00E0 + push 8 + lea edx, [ebp+var_8] + push edx + mov ecx, esi + call sub_6D00E0 + mov edi, [ebp+arg_0] + xor eax, eax + +loc_6D0280: ; CODE XREF: sub_6D0210+8Ej + mov ecx, eax + and ecx, 3 + add ecx, ecx + mov edx, eax + sar edx, 2 + mov edx, [esi+edx*4+8] + add ecx, ecx + add ecx, ecx + shr edx, cl + inc eax + cmp eax, 10h + mov [eax+edi-1], dl + jl short loc_6D0280 + pop edi + pop esi + mov esp, ebp + pop ebp + retn 4 +sub_6D0210 endp + + +sub_6CEBE0 proc near ; CODE XREF: sub_4A72D0+49p + ; SFileVerifyMpqHeaderMD5+51p ... + +var_4 = dword ptr -4 +arg_0 = dword ptr 8 + + push ebp + mov ebp, esp + mov edx, [ebp+arg_0] + mov eax, 10h + push esi + lea esp, [esp+0] + +loc_6CEBF0: ; CODE XREF: sub_6CEBE0+22j + mov esi, [ecx] + cmp esi, [edx] + jnz short loc_6CEC14 + sub eax, 4 + add edx, 4 + add ecx, 4 + cmp eax, 4 + jnb short loc_6CEBF0 + xor eax, eax + xor edx, edx + test eax, eax + setz dl + mov al, dl + pop esi + pop ebp + retn 4 +; --------------------------------------------------------------------------- + +loc_6CEC14: ; CODE XREF: sub_6CEBE0+14j + movzx eax, byte ptr [ecx] + movzx esi, byte ptr [edx] + sub eax, esi + jnz short loc_6CEC40 + movzx eax, byte ptr [ecx+1] + movzx esi, byte ptr [edx+1] + sub eax, esi + jnz short loc_6CEC40 + movzx eax, byte ptr [ecx+2] + movzx esi, byte ptr [edx+2] + sub eax, esi + jnz short loc_6CEC40 + movzx eax, byte ptr [ecx+3] + movzx ecx, byte ptr [edx+3] + sub eax, ecx + +loc_6CEC40: ; CODE XREF: sub_6CEBE0+3Cj + ; sub_6CEBE0+48j ... + sar eax, 1Fh + or eax, 1 + xor edx, edx + test eax, eax + setz dl + mov al, dl + pop esi + pop ebp + retn 4 +sub_6CEBE0 endp + +SFileVerifyMpqHeaderMD5 proc near ; CODE XREF: SFileVerifyMpqHeader+6Bp + +var_68 = dword ptr -68h +var_64 = dword ptr -64h +var_60 = dword ptr -60h +var_5C = dword ptr -5Ch +var_58 = dword ptr -58h +var_54 = dword ptr -54h +var_10 = dword ptr -10h + + push ebp + mov ebp, esp + sub esp, 68h + push esi + mov esi, eax ; ESI = pointer to MPQ Header + xor eax, eax + push 0C0h + push esi + lea ecx, [ebp+var_68] + mov [ebp+var_64], eax + mov [ebp+var_68], eax + mov [ebp+var_60], 67452301h + mov [ebp+var_5C], 0EFCDAB89h + mov [ebp+var_58], 98BADCFEh + mov [ebp+var_54], 10325476h + call sub_6D00E0 + lea eax, [ebp+var_10] + push eax + lea ecx, [ebp+var_68] + call sub_6D0210 + add esi, 0C0h + push esi + lea ecx, [ebp+var_10] + call sub_6CEBE0 + pop esi + mov esp, ebp + pop ebp + retn +SFileVerifyMpqHeaderMD5 endp + + +_wow_SFileVerifyMpqHeaderMD5 proc + push ebp + mov ebp, esp + mov eax, [ebp+8] + call SFileVerifyMpqHeaderMD5 + mov esp, ebp + pop ebp + retn +_wow_SFileVerifyMpqHeaderMD5 endp + +END diff --git a/dep/StormLib/test/x86_starcraft_lzma.asm b/dep/StormLib/test/x86_starcraft_lzma.asm new file mode 100644 index 000000000..bb13200b4 --- /dev/null +++ b/dep/StormLib/test/x86_starcraft_lzma.asm @@ -0,0 +1,11066 @@ +; +; LZMA compression code ripped from Starctaft II BEta +; Used while StormLib's LZMA implementation was tested against Starcraft compression +; Not used in StormLib. +; + +.686P +.MODEL FLAT +ASSUME FS: NOTHING + +.DATA + +;--------------------------------------------------------------------------- +; Data + +byte_4CB248 db 0, 0Bh, 0Bh, 0Bh ; indirect table for switch statement + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 1, 2, 3, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 4, 5, 6, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 7, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 8, 9, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Bh, 0Bh, 0Bh, 0Bh + db 0Ah + align 10h + +dword_544960 dd 0BB40E64Eh ; DATA XREF: sub_401C72+B +dword_553598 dd ? ; DATA XREF: sub_4CB8A0+9 + +off_50CD3C dd offset sub_4A0605 ; DATA XREF: sub_4A05F7+1o + ; .data:off_52A004o ... +dword_50CD40 dd 0E06D7363h ; DATA XREF: _CxxThrowException(x,x)+Eo + dd 1 + dd 0 + dd 0 + dd 3 + dd 19930520h + dd 0 + dd 0 + +; --------------------------------------------------------------------------- + +off_546E20 dd offset sub_4CDD70 ; DATA XREF: sub_4D0270:loc_4D0324o +off_546E24 dd offset sub_4CDD90 ; DATA XREF: sub_4CF810+53r +off_546E28 dd offset off_50CD3C ; DATA XREF: .rdata:off_51B888o + dd 0 + db '.?AUISequentialInStream@@',0 + db 0 + db 0 +off_546E4C dd offset off_50CD3C ; DATA XREF: .rdata:off_51B8C0o + dd 0 + db '.?AUISequentialOutStream@@',0 + db 0 +off_546E70 dd offset off_50CD3C ; DATA XREF: .rdata:off_51B8F8o + dd 0 + db '.?AUICompressCoder@@',0 + db 0 + db 0 + db 0 +off_546E90 dd offset off_50CD3C ; DATA XREF: .rdata:off_51B944o + dd 0 + db '.?AUICompressSetOutStream@@',0 +off_546EB4 dd offset off_50CD3C ; DATA XREF: .rdata:0051B96Co + dd 0 + db '.?AUICompressSetCoderProperties@@',0 + db 0 + db 0 +off_546EE0 dd offset off_50CD3C ; DATA XREF: .rdata:0051B9B8o + dd 0 + db '.?AUICompressWriteCoderProperties@@',0 + dd offset off_50CD3C + dd 0 + db '.?AUCSystemException@@',0 + db 0 + dd offset off_50CD3C + dd 0 + db '.?AUCOutBufferException@@',0 + db 0 + db 0 +off_546F50 dd offset off_50CD3C ; DATA XREF: .rdata:0051BA04o + dd 0 + db '.?AVCInStreamMemory@@',0 + db 0 + db 0 +off_546F70 dd offset off_50CD3C ; DATA XREF: .rdata:off_51BA4Co + dd 0 + db '.?AVCMyUnknownImp@@',0 +off_546F8C dd offset off_50CD3C ; DATA XREF: .rdata:0051BAA8o + dd 0 + db '.?AVCOutStreamMemory@@',0 + db 0 +off_546FAC dd offset off_50CD3C ; DATA XREF: .rdata:0051BAFCo + dd 0 + db '.?AVCEncoder@NLZMA@NCompress@@',0 + db 0 +off_546FD4 dd offset off_50CD3C ; DATA XREF: .rdata:off_51BBECo + dd 0 + db '.?AVCBaseState@NLZMA@NCompress@@',0 + db 0 + db 0 + db 0 + +; --------------------------------------------------------------------------- + +dword_51B960 dd 0 ; DATA XREF: .rdata:00517A64o + dd 0 + dd 0 + dd offset off_546EB4 + dd 0 ; offset dword_51B974 + +dword_51B9AC dd 0 ; DATA XREF: .rdata:00517A78o + dd 0 + dd 0 + dd offset off_546EE0 + dd 0 ;offset dword_51B9C0 + +dword_51B9F8 dd 0 ; DATA XREF: .rdata:00517A8Co + dd 0 + dd 0 + dd offset off_546F50 + dd 0 ; offset dword_51BA0C + +dword_51BA9C dd 0 ; DATA XREF: .rdata:00517AA0o + dd 0 + dd 0 + dd offset off_546F8C + dd 0 ; offset dword_51BAB0 + +dword_51BAF0 dd 0 ; DATA XREF: .rdata:00517AF8o + dd 0 + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +dword_51BC58 dd 0 ; DATA XREF: .rdata:00517AE0o + dd 4 + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +dword_51BC6C dd 0 ; DATA XREF: .rdata:00517ACCo + dd 8 + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +dword_51BC80 dd 0 ; DATA XREF: .rdata:00517AB8o + dd 0Ch + dd 0 + dd offset off_546FAC + dd 0 ; offset dword_51BB04 + +; --------------------------------------------------------------------------- + +dword_512730 dd 0 ; DATA XREF: sub_48DB4D+B9o +dword_512734 dd 0 ; DATA XREF: CCmdTarget::GetInterface(void const *)+2Dr +dword_512738 dd 0C0h ; DATA XREF: CCmdTarget::GetInterface(void const *)+38r +dword_51273C dd 46000000h ; DATA XREF: CCmdTarget::GetInterface(void const *)+43r + +dword_5535A0 dd ? ; DATA XREF: sub_4CF900:loc_4CF94Co +dword_5535A4 dd ? ; DATA XREF: .text:004DAF37w +dword_5535A8 dd ? ; DATA XREF: .text:004DAF3Cw +dword_5535AC dd ? ; DATA XREF: .text:004DAF41w + +dword_5535B0 dd ? ; DATA XREF: sub_4CF900+5Eo +dword_5535B4 dd ? ; DATA XREF: .text:004DAF17w +dword_5535B8 dd ? ; DATA XREF: .text:004DAF1Cw +dword_5535BC dd ? ; DATA XREF: .text:004DAF21w + +dword_5535C0 dd ? ; DATA XREF: sub_4CF900:loc_4CF98Fo +dword_5535C4 dd ? ; DATA XREF: .text:004DAEF7w +dword_5535C8 dd ? ; DATA XREF: .text:004DAEFCw +dword_5535CC dd ? ; DATA XREF: .text:004DAF01w + + +dword_526DD0 dd 0 ; DATA XREF: .text:loc_4CF6CBo + dd 0 + dd 0 + dd 0 ; offset dword_526DE0 + +kLiteralNextStates db 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 +kMatchNextStates db 7, 7, 7, 7, 7, 7, 7, 0Ah, 0Ah, 0Ah, 0Ah, 0Ah +kRepNextStates db 8, 8, 8, 8, 8, 8, 8, 0Bh, 0Bh, 0Bh, 0Bh, 0Bh +kShortRepNextStates db 9, 9, 9, 9, 9, 9, 9, 0Bh, 0Bh, 0Bh, 0Bh, 0Bh + +dword_550998 dd 200h dup(?) +dword_551198 dd 800h dup(?) +dword_553198 dd 100h dup(?) + +ICompressSetOutStream_vftable dd offset __purecall ; DATA XREF: NCompress_NLZMA_CEncoder_CEncoder+2o + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset dword_51B960 +ICompressSetCoderProperties_vftable dd offset __purecall ; DATA XREF: NCompress_NLZMA_CEncoder_CEncoder+9o + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset dword_51B9AC +ICompressWriteCoderProperties_vftable dd offset __purecall ; DATA XREF: NCompress_NLZMA_CEncoder_CEncoder+10o + dd offset __purecall + dd offset __purecall + dd offset __purecall + dd offset dword_51B9F8 +off_517A90 dd offset Interface1_QueryInterface + dd offset Interface1_AddRef + dd offset Interface1_Release + dd offset sub_4CCB20 + dd offset dword_51BA9C +off_517AA4 dd offset Interface1_QueryInterface ; DATA XREF: sub_4CF610+Eo + dd offset Interface1_AddRef + dd offset Interface2_Release + dd offset sub_4CCB90 + dd offset sub_4CF590 + dd offset dword_51BC80 +NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderProperties dd offset sub_4CFA50 ; DATA XREF: sub_4CF810+3Do + dd offset sub_4CFA10 + dd offset sub_4CFA70 + dd offset sub_4CDDB0 + dd offset dword_51BC6C +NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderProperties dd offset ICompressSetCoderProperties_QueryInterface ; DATA XREF: sub_4CF810+36o + dd offset ICompressSetCoderProperties_AddRef + dd offset ICompressSetCoderProperties_Release + dd offset ICompressSetCoderProperties_SetCoderProperties + dd offset dword_51BC58 +NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStream dd offset sub_4CFA20 ; DATA XREF: sub_4CF810+2Fo + dd offset sub_4CFA80 + dd offset sub_4CFA40 + dd offset sub_4CFA90 + dd offset sub_4CDE70 + dd offset dword_51BAF0 +NCompress_NLZMA_CEncoder_vftable dd offset sub_4CF900 ; DATA XREF: sub_4CF810+29o + dd offset sub_4CF9D0 + dd offset sub_4CF9E0 + dd offset CEncoder_Code + dd offset sub_4D0250 + +.CODE + +extrn _operator_new:PROC +extrn __allshr: PROC +extrn _free: PROC +extrn _memcmp: PROC +extrn _memcpy: PROC +extrn _memset: PROC +extrn ___report_gsfailure: PROC +extrn __purecall: PROC +VirtualAlloc PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD +VirtualFree PROTO STDCALL :DWORD,:DWORD,:DWORD + +; --------------------------------------------------------------------------- + +; void __cdecl j__free(void *Memory) +; 004843B8 +j__free proc near ; CODE XREF: sub_401048+16p + ; .text:004010CFp ... + jmp _free +j__free endp + + +; --------------------------------------------------------------------------- + +; int __cdecl unknown_libname_324(void *Buf1, void *Buf2) +unknown_libname_324 proc near +; sub_48B7BA + +Buf1 = dword ptr 4 +Buf2 = dword ptr 8 + + push 10h ; Size + push [esp+4+Buf2] ; Buf2 + push [esp+8+Buf1] ; Buf1 + call _memcmp + add esp, 0Ch + neg eax + sbb eax, eax + inc eax + retn +unknown_libname_324 endp + +; --------------------------------------------------------------------------- + +sub_4A05F7 proc near ; CODE XREF: sub_4A0605+3p + push ecx + mov dword ptr [ecx], offset off_50CD3C + call sub_4A98B8 + pop ecx + retn +sub_4A05F7 endp + +; --------------------------------------------------------------------------- + +; int __thiscall sub_4A0605(void *Memory, char) +sub_4A0605 proc near ; DATA XREF: .rdata:off_50CD3Co + +arg_0 = byte ptr 4 + + push esi + mov esi, ecx + call sub_4A05F7 + test [esp+4+arg_0], 1 + jz short loc_4A061B + push esi ; Memory + call j__free + pop ecx + +loc_4A061B: ; CODE XREF: sub_4A0605+Dj + mov eax, esi + pop esi + retn 4 +sub_4A0605 endp + +; --------------------------------------------------------------------------- + +sub_4A0686 proc near ; CODE XREF: sub_401C72+49p + ; sub_40222F+15Cp ... + cmp ecx, dword_544960 + jnz short loc_4A0690 + retn +loc_4A0690: ; CODE XREF: sub_4A0686+6j + jmp ___report_gsfailure +sub_4A0686 endp + +; --------------------------------------------------------------------------- + +sub_4A98B8 proc near ; CODE XREF: sub_4A05F7+7p + + int 3 + retn +sub_4A98B8 endp + +; =============== S U B R O U T I N E ======================================= + + +sub_4CAEC0 proc near ; CODE XREF: CEncoder_GetOptimum+514p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push esi + push edi + mov edi, [esp+8+arg_4] + lea eax, [edi-2] + cmp eax, 4 + mov esi, ecx + jb short loc_4CAED5 + mov eax, 3 + +loc_4CAED5: ; CODE XREF: sub_4CAEC0+Ej + mov edx, [esp+8+arg_0] + cmp edx, 80h + jnb short loc_4CAEEF + shl eax, 7 + add eax, edx + mov ecx, [esi+eax*4+33314h] + jmp short loc_4CAF25 +; --------------------------------------------------------------------------- + +loc_4CAEEF: ; CODE XREF: sub_4CAEC0+1Fj + mov ecx, 7FFFFh + sub ecx, edx + sar ecx, 1Fh + push ebx + and ecx, 0Ch + add ecx, 6 + mov ebx, edx + shr ebx, cl + shl eax, 5 + add eax, ecx + and edx, 0Fh + movzx ebx, byte ptr dword_551198[ebx] + lea eax, [ebx+eax*2] + mov ecx, [esi+eax*4+32F14h] + add ecx, [esi+edx*4+33B14h] + pop ebx + +loc_4CAF25: ; CODE XREF: sub_4CAEC0+2Dj + mov edx, [esp+8+arg_8] + imul edx, 110h + add edx, edi + mov eax, [esi+edx*4+295B8h] + pop edi + add eax, ecx + pop esi + retn 0Ch +sub_4CAEC0 endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CAF40: ; CODE XREF: .text:004DAED5j + push ecx + push ebx + push ebp + push esi + mov ebp, 2 + mov bl, 2 + push edi + mov byte ptr dword_551198, 0 + mov byte ptr dword_551198+1, 1 + mov [esp+10h], bl + mov edi, ebp + +loc_4CAF60: ; CODE XREF: .text:004CAF96j + mov ecx, edi + shr ecx, 1 + sub ecx, 1 + mov esi, 1 + shl esi, cl + test esi, esi + jbe short loc_4CAF89 + mov ecx, [esp+10h] + push esi + lea eax, dword_551198[ebp] + push ecx + push eax + call _memset + add esp, 0Ch + add ebp, esi + +loc_4CAF89: ; CODE XREF: .text:004CAF70j + add bl, 1 + add edi, 1 + cmp bl, 1Ah + mov [esp+10h], bl + jb short loc_4CAF60 + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CAFA0 proc near ; CODE XREF: sub_4CAFC0+90p + +arg_0 = dword ptr 4 + + mov eax, [esp+arg_0] + lea ecx, [eax-61h] + cmp cx, 19h + ja short locret_4CAFB2 + add eax, 0FFE0h + +locret_4CAFB2: ; CODE XREF: sub_4CAFA0+Bj + retn +sub_4CAFA0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + +sub_4CAFC0 proc near ; CODE XREF: ICompressSetCoderProperties_SetCoderProperties+A5p + movzx ecx, word ptr [eax] + lea edx, [ecx-61h] + cmp dx, 19h + ja short loc_4CAFD2 + add ecx, 0FFE0h + +loc_4CAFD2: ; CODE XREF: sub_4CAFC0+Aj + add eax, 2 + cmp cx, 48h + jnz short loc_4CB01B + movzx ecx, word ptr [eax] + lea edx, [ecx-61h] + cmp dx, 19h + ja short loc_4CAFED + add ecx, 0FFE0h + +loc_4CAFED: ; CODE XREF: sub_4CAFC0+25j + add eax, 2 + cmp cx, 43h + jz short loc_4CAFF9 + +loc_4CAFF6: ; CODE XREF: sub_4CAFC0+44j + ; sub_4CAFC0+4Bj ... + xor eax, eax + retn +; --------------------------------------------------------------------------- + +loc_4CAFF9: ; CODE XREF: sub_4CAFC0+34j + movzx ecx, word ptr [eax] + sub ecx, 30h + lea edx, [ecx-4] + test edx, edx + ja short loc_4CAFF6 + cmp word ptr [eax+2], 0 + jnz short loc_4CAFF6 + mov dword ptr [ebx], 0 + mov [edi], ecx + mov eax, 1 + retn +; --------------------------------------------------------------------------- + +loc_4CB01B: ; CODE XREF: sub_4CAFC0+19j + cmp cx, 42h + jnz short loc_4CAFF6 + movzx ecx, word ptr [eax] + lea edx, [ecx-61h] + cmp dx, 19h + ja short loc_4CB033 + add ecx, 0FFE0h + +loc_4CB033: ; CODE XREF: sub_4CAFC0+6Bj + add eax, 2 + cmp cx, 54h + jnz short loc_4CAFF6 + push esi + movzx esi, word ptr [eax] + sub esi, 30h + lea ecx, [esi-2] + cmp ecx, 2 + ja short loc_4CB06C + movzx eax, word ptr [eax+2] + push eax + call sub_4CAFA0 + add esp, 4 + test ax, ax + jnz short loc_4CB06C + mov dword ptr [ebx], 1 + mov [edi], esi + mov eax, 1 + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CB06C: ; CODE XREF: sub_4CAFC0+89j + ; sub_4CAFC0+9Bj + xor eax, eax + pop esi + retn +sub_4CAFC0 endp + + +ICompressSetCoderProperties_SetCoderProperties proc near ; DATA XREF: .rdata:00517ADCo + +var_4 = dword ptr -4 +pThis = dword ptr 4 +propIDs = dword ptr 8 +properties = dword ptr 0Ch +numProperties = dword ptr 10h + + push ecx + push ebx + push ebp + xor edx, edx + cmp [esp+0Ch+numProperties], edx + push esi + push edi + mov [esp+14h+var_4], edx + jbe loc_4CB20D + mov esi, [esp+14h+properties] + mov ebp, [esp+14h+pThis] + lea ecx, [ecx+0] + +loc_4CB090: ; CODE XREF: sub_4CB070+197j + mov eax, [esp+14h+propIDs] + mov eax, [eax+edx*4] + add eax, 0FFFFFC00h + cmp eax, 90h ; switch 145 cases + ja loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + movzx ecx, ds:byte_4CB248[eax] + jmp ds:off_4CB218[ecx*4] ; switch jump + +loc_4CB0B5: ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 80 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + lea ecx, [eax-5] + cmp ecx, 10Ch + ja short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+32EF0h], eax + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB0D4: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 82 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + mov [ebp+33B88h], eax + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB0E8: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 112 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + cmp dword ptr [esi+8], 0 + setz cl + mov [ebp+32EECh], cl + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB100: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 8 ; jumptable 004CB0AE case 81 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + lea edi, [ebp+0C4h] + lea ebx, [ebp+0CCh] + call sub_4CAFC0 + test eax, eax + jz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov edx, [esp+14h+var_4] + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB127: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 0Bh ; jumptable 004CB0AE case 128 + jz loc_4CB1F9 + +loc_4CB131: ; CODE XREF: sub_4CB070+31j + ; sub_4CB070+3Ej ... + pop edi ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + pop esi + pop ebp + mov eax, 80070057h + pop ebx + pop ecx + retn 10h +; --------------------------------------------------------------------------- + +loc_4CB13E: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 129 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + jmp loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB149: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 0 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + lea ecx, [eax-1] + cmp ecx, 3FFFFFFFh + ja short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+33B64h], eax + xor ecx, ecx + +loc_4CB165: ; CODE XREF: sub_4CB070+106j + mov edi, 1 + shl edi, cl + cmp eax, edi + jbe short loc_4CB178 + add ecx, 1 + cmp ecx, 1Eh + jb short loc_4CB165 + +loc_4CB178: ; CODE XREF: sub_4CB070+FEj + lea eax, [ecx+ecx] + mov [ebp+33B50h], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB183: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 64 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov ecx, [esi+8] + cmp ecx, 4 + ja short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, 1 + shl eax, cl + mov [ebp+33B54h], ecx + sub eax, 1 + mov [ebp+33B58h], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB1A9: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 66 + jnz short loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + cmp eax, 4 + ja loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+33B5Ch], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB1C3: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 13h ; jumptable 004CB0AE case 65 + jnz loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov eax, [esi+8] + cmp eax, 8 + ja loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + mov [ebp+33B60h], eax + jmp short loc_4CB1F9 +; --------------------------------------------------------------------------- + +loc_4CB1E1: ; CODE XREF: sub_4CB070+3Ej + ; DATA XREF: .text:off_4CB218o + cmp word ptr [esi], 0Bh ; jumptable 004CB0AE case 144 + jnz loc_4CB131 ; default + ; jumptable 004CB0AE cases 1-63,67-79,83-111,113-127,130-143 + cmp word ptr [esi+8], 0FFFFh + setz cl + mov [ebp+33B8Ch], cl + +loc_4CB1F9: ; CODE XREF: sub_4CB070+5Fj + ; sub_4CB070+73j ... + add edx, 1 + add esi, 10h + cmp edx, [esp+14h+numProperties] + mov [esp+14h+var_4], edx + jb loc_4CB090 + +loc_4CB20D: ; CODE XREF: sub_4CB070+Fj + pop edi + pop esi + pop ebp + xor eax, eax + pop ebx + pop ecx + retn 10h + +off_4CB218 dd offset loc_4CB149, offset loc_4CB183, offset loc_4CB1C3 + dd offset loc_4CB1A9, offset loc_4CB0B5, offset loc_4CB100 ; jump table for switch statement + dd offset loc_4CB0D4, offset loc_4CB0E8, offset loc_4CB127 + dd offset loc_4CB13E, offset loc_4CB1E1, offset loc_4CB131 + +ICompressSetCoderProperties_SetCoderProperties endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CB2E0 proc near ; CODE XREF: CEncoder_GetOptimum+1199p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_4] + lea eax, [esi+esi*4] + lea edx, [ecx+eax*8] + mov [ecx+32F08h], esi + mov eax, [edx+100h] + mov ebx, [edx+104h] + push edi + +loc_4CB300: ; CODE XREF: sub_4CB2E0+A6j + lea edx, [esi+esi*4] + cmp byte ptr [ecx+edx*8+0F1h], 0 + lea edi, [ecx+edx*8] + jz short loc_4CB359 + lea edx, [eax+eax*4+1Eh] + lea edx, [ecx+edx*8] + mov dword ptr [edx+14h], 0FFFFFFFFh + mov byte ptr [edx+1], 0 + lea edx, [eax+eax*4] + lea edx, [ecx+edx*8] + lea ebp, [eax-1] + mov [edx+100h], ebp + cmp byte ptr [edi+0F2h], 0 + jz short loc_4CB359 + mov byte ptr [edx+0C9h], 0 + mov ebp, [edi+0F4h] + mov [edx+0D8h], ebp + mov edi, [edi+0F8h] + mov [edx+0DCh], edi + +loc_4CB359: ; CODE XREF: sub_4CB2E0+2Ej + ; sub_4CB2E0+58j + lea edx, [eax+eax*4] + add edx, edx + add edx, edx + add edx, edx + mov edi, eax + test edi, edi + mov eax, [edx+ecx+100h] + mov ebp, ebx + mov ebx, [edx+ecx+104h] + mov [edx+ecx+100h], esi + mov [edx+ecx+104h], ebp + mov esi, edi + jnz loc_4CB300 + mov eax, [ecx+104h] + mov edx, [esp+10h+arg_0] + pop edi + pop esi + mov [edx], eax + mov eax, [ecx+100h] + pop ebp + mov [ecx+32F0Ch], eax + pop ebx + retn 8 +sub_4CB2E0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CB3B0 proc near ; CODE XREF: CEncoder_GetOptimumFast+2Dp + ; CEncoder_GetOptimumFast+28Fp ... + +arg_0 = dword ptr 4 + + push ebx + push ebp + push esi + mov esi, ecx + mov ecx, [esi+80h] + mov edx, [esi+78h] + lea eax, [esi+32660h] + push eax + push ecx + xor ebx, ebx + call edx + mov ebp, [esp+14h+arg_0] + add esp, 8 + test eax, eax + mov [ebp+0], eax + jbe short loc_4CB446 + mov ebx, [esi+eax*4+32658h] + cmp ebx, [esi+32EF8h] + jnz short loc_4CB446 + mov eax, [esi+80h] + mov ecx, [esi+70h] + push edi + push eax + call ecx + mov edx, [esi+80h] + mov edi, eax + mov eax, [esi+74h] + push edx + add edi, 1 + call eax + mov ecx, [ebp+0] + mov ecx, [esi+ecx*4+3265Ch] + add esp, 8 + sub eax, 1 + add ecx, 1 + cmp edi, 111h + jbe short loc_4CB425 + mov edi, 111h + +loc_4CB425: ; CODE XREF: sub_4CB3B0+6Ej + mov edx, eax + sub edx, ecx + cmp ebx, edi + jnb short loc_4CB445 + mov ebp, edx + lea ecx, [eax+ebx] + sub ebp, eax + +loc_4CB434: ; CODE XREF: sub_4CB3B0+93j + mov dl, [ecx] + cmp dl, [ecx+ebp] + jnz short loc_4CB445 + add ebx, 1 + add ecx, 1 + cmp ebx, edi + jb short loc_4CB434 + +loc_4CB445: ; CODE XREF: sub_4CB3B0+7Bj + ; sub_4CB3B0+89j + pop edi + +loc_4CB446: ; CODE XREF: sub_4CB3B0+26j + ; sub_4CB3B0+35j + add dword ptr [esi+32F04h], 1 + pop esi + pop ebp + mov eax, ebx + pop ebx + retn 4 +sub_4CB3B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_GetOptimumFast proc near ; CODE XREF: CEncoder_CodeOneBlock+1F4p + +var_28 = dword ptr -28h +var_24 = dword ptr -24h +var_20 = dword ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +arg_0 = dword ptr 4 + + sub esp, 28h + push ebx + push esi + push edi + mov edi, ecx + mov eax, [edi+80h] + mov ecx, [edi+70h] + push eax + call ecx + add esp, 4 + cmp byte ptr [edi+32F10h], 0 + mov esi, eax + mov [esp+34h+var_24], esi + jnz short loc_4CB498 + lea edx, [esp+34h+var_20] + push edx + mov ecx, edi + call sub_4CB3B0 + mov ebx, [esp+34h+var_20] + jmp short loc_4CB4AF +; --------------------------------------------------------------------------- + +loc_4CB498: ; CODE XREF: CEncoder_GetOptimumFast+24j + mov ebx, [edi+32F00h] + mov eax, [edi+32EFCh] + mov [esp+34h+var_20], ebx + mov byte ptr [edi+32F10h], 0 + +loc_4CB4AF: ; CODE XREF: CEncoder_GetOptimumFast+36j + mov ecx, [edi+80h] + mov edx, [edi+74h] + push ecx + mov [esp+38h+var_28], eax + call edx + add esp, 4 + sub eax, 1 + cmp esi, 111h + jbe loc_4CB55E + mov [esp+34h+var_24], 111h + +loc_4CB4D9: ; CODE XREF: CEncoder_GetOptimumFast+101j + push ebp + xor ebp, ebp + lea ecx, [edi+14h] + mov [esp+38h+var_18], ebp + mov [esp+38h+var_14], ebp + mov [esp+38h+var_1C], ecx + jmp short loc_4CB4F0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CB4F0: ; CODE XREF: CEncoder_GetOptimumFast+8Bj + ; CEncoder_GetOptimumFast+132j + mov edx, [esp+38h+var_1C] + mov ecx, eax + sub ecx, [edx] + mov dl, [eax] + sub ecx, 1 + cmp dl, [ecx] + jnz short loc_4CB57F + mov dl, [eax+1] + cmp dl, [ecx+1] + jnz short loc_4CB57F + mov esi, 2 + cmp [esp+38h+var_24], esi + jbe short loc_4CB537 + lea edx, [eax+2] + sub ecx, eax + lea esp, [esp+0] + +loc_4CB520: ; CODE XREF: CEncoder_GetOptimumFast+D1j + mov bl, [edx] + cmp bl, [ecx+edx] + jnz short loc_4CB533 + add esi, 1 + add edx, 1 + cmp esi, [esp+38h+var_24] + jb short loc_4CB520 + +loc_4CB533: ; CODE XREF: CEncoder_GetOptimumFast+C5j + mov ebx, [esp+38h+var_20] + +loc_4CB537: ; CODE XREF: CEncoder_GetOptimumFast+B2j + cmp esi, [edi+32EF8h] + jnb short loc_4CB5B9 + mov edx, [esp+38h+var_14] + lea ecx, ds:0[ebp*4] + mov [esp+ecx+38h+var_10], esi + cmp esi, [esp+edx+38h+var_10] + jbe short loc_4CB587 + mov [esp+38h+var_18], ebp + mov [esp+38h+var_14], ecx + jmp short loc_4CB587 +; --------------------------------------------------------------------------- + +loc_4CB55E: ; CODE XREF: CEncoder_GetOptimumFast+6Bj + cmp esi, 2 + jnb loc_4CB4D9 + mov eax, [esp+34h+arg_0] + pop edi + pop esi + mov dword ptr [eax], 0FFFFFFFFh + mov eax, 1 + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB57F: ; CODE XREF: CEncoder_GetOptimumFast+9Fj + ; CEncoder_GetOptimumFast+A7j + mov [esp+ebp*4+38h+var_10], 0 + +loc_4CB587: ; CODE XREF: CEncoder_GetOptimumFast+F2j + ; CEncoder_GetOptimumFast+FCj + add [esp+38h+var_1C], 4 + add ebp, 1 + cmp ebp, 4 + jb loc_4CB4F0 + mov esi, [esp+38h+var_28] + cmp esi, [edi+32EF8h] + jb short loc_4CB5EC + mov eax, [edi+ebx*4+3265Ch] + mov ecx, [esp+38h+arg_0] + add eax, 4 + mov [ecx], eax + jmp loc_4CB69A +; --------------------------------------------------------------------------- + +loc_4CB5B9: ; CODE XREF: CEncoder_GetOptimumFast+DDj + mov eax, [esp+38h+arg_0] + mov [eax], ebp + lea eax, [esi-1] + test eax, eax + jz loc_4CB82E + mov ecx, [edi+80h] + mov edx, [edi+7Ch] + add [edi+32F04h], eax + push eax + push ecx + call edx + add esp, 8 + pop ebp + pop edi + mov eax, esi + pop esi + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB5EC: ; CODE XREF: CEncoder_GetOptimumFast+142j + xor ebp, ebp + cmp esi, 2 + mov [esp+38h+var_20], ebp + jb short loc_4CB65A + cmp ebx, 2 + mov ecx, [edi+ebx*4+3265Ch] + mov [esp+38h+var_20], ecx + jbe short loc_4CB63F + lea eax, [edi+ebx*4+32654h] + mov edi, edi + +loc_4CB610: ; CODE XREF: CEncoder_GetOptimumFast+1DDj + mov edx, [eax-4] + add edx, 1 + cmp esi, edx + jnz short loc_4CB63F + mov ecx, [esp+38h+var_20] + shr ecx, 7 + cmp ecx, [eax] + jbe short loc_4CB63F + mov edx, [eax-4] + mov ecx, [eax] + sub eax, 8 + sub ebx, 2 + cmp ebx, 2 + mov [esp+38h+var_28], edx + mov [esp+38h+var_20], ecx + mov esi, edx + ja short loc_4CB610 + +loc_4CB63F: ; CODE XREF: CEncoder_GetOptimumFast+1A5j + ; CEncoder_GetOptimumFast+1B8j ... + cmp esi, 2 + jnz short loc_4CB656 + cmp [esp+38h+var_20], 80h + jb short loc_4CB656 + mov [esp+38h+var_28], 1 + +loc_4CB656: ; CODE XREF: CEncoder_GetOptimumFast+1E2j + ; CEncoder_GetOptimumFast+1ECj + mov ebp, [esp+38h+var_20] + +loc_4CB65A: ; CODE XREF: CEncoder_GetOptimumFast+195j + mov edx, [esp+38h+var_18] + mov esi, [esp+edx*4+38h+var_10] + cmp esi, 2 + mov ebx, [esp+38h+var_28] + jb short loc_4CB6C7 + lea eax, [esi+1] + cmp eax, ebx + jnb short loc_4CB690 + lea ecx, [esi+2] + cmp ecx, ebx + jb short loc_4CB681 + cmp ebp, 200h + ja short loc_4CB690 + +loc_4CB681: ; CODE XREF: CEncoder_GetOptimumFast+217j + lea edx, [esi+3] + cmp edx, ebx + jb short loc_4CB6C7 + cmp ebp, 8000h + jbe short loc_4CB6C7 + +loc_4CB690: ; CODE XREF: CEncoder_GetOptimumFast+210j + ; CEncoder_GetOptimumFast+21Fj + mov eax, [esp+38h+arg_0] + mov ecx, [esp+38h+var_18] + mov [eax], ecx + +loc_4CB69A: ; CODE XREF: CEncoder_GetOptimumFast+154j + lea eax, [esi-1] + test eax, eax + jz loc_4CB82E + mov edx, [edi+80h] + add [edi+32F04h], eax + push eax + mov eax, [edi+7Ch] + push edx + call eax + add esp, 8 + pop ebp + pop edi + mov eax, esi + pop esi + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB6C7: ; CODE XREF: CEncoder_GetOptimumFast+209j + ; CEncoder_GetOptimumFast+226j ... + cmp ebx, 2 + jb short loc_4CB73E + cmp [esp+38h+var_24], 2 + jbe short loc_4CB73E + mov ecx, [edi+80h] + mov edx, [edi+70h] + push ecx + call edx + add esp, 4 + lea esi, [edi+32F00h] + push esi + mov ecx, edi + mov [esp+3Ch+var_24], eax + call sub_4CB3B0 + cmp eax, 2 + mov [edi+32EFCh], eax + jb short loc_4CB757 + cmp eax, ebx + mov ecx, [esi] + mov edx, [edi+ecx*4+3265Ch] + jb short loc_4CB710 + cmp edx, ebp + jb short loc_4CB737 + +loc_4CB710: ; CODE XREF: CEncoder_GetOptimumFast+2AAj + lea ecx, [ebx+1] + cmp eax, ecx + jnz short loc_4CB722 + mov esi, edx + shr esi, 7 + cmp esi, ebp + jbe short loc_4CB737 + cmp eax, ecx + +loc_4CB722: ; CODE XREF: CEncoder_GetOptimumFast+2B5j + ja short loc_4CB737 + add eax, 1 + cmp eax, ebx + jb short loc_4CB757 + cmp ebx, 3 + jb short loc_4CB757 + shr ebp, 7 + cmp ebp, edx + jbe short loc_4CB757 + +loc_4CB737: ; CODE XREF: CEncoder_GetOptimumFast+2AEj + ; CEncoder_GetOptimumFast+2BEj ... + mov byte ptr [edi+32F10h], 1 + +loc_4CB73E: ; CODE XREF: CEncoder_GetOptimumFast+26Aj + ; CEncoder_GetOptimumFast+271j + mov edx, [esp+38h+arg_0] + pop ebp + pop edi + pop esi + mov dword ptr [edx], 0FFFFFFFFh + mov eax, 1 + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB757: ; CODE XREF: CEncoder_GetOptimumFast+29Dj + ; CEncoder_GetOptimumFast+2C9j ... + mov eax, [edi+80h] + mov ecx, [edi+74h] + push eax + call ecx + lea ecx, [edi+14h] + add esp, 4 + sub eax, 1 + mov [esp+38h+var_18], 0 + mov ebx, ecx + +loc_4CB776: ; CODE XREF: CEncoder_GetOptimumFast+39Aj + mov dl, [eax+1] + mov ecx, eax + sub ecx, [ebx] + sub ecx, 1 + cmp dl, [ecx+1] + jnz short loc_4CB7DD + mov dl, [eax+2] + cmp dl, [ecx+2] + lea ebp, [eax+2] + jnz short loc_4CB7DD + mov esi, 2 + cmp [esp+38h+var_24], esi + jbe short loc_4CB7B4 + mov edx, ebp + mov ebp, ecx + sub ebp, eax + +loc_4CB7A1: ; CODE XREF: CEncoder_GetOptimumFast+352j + mov cl, [edx] + cmp cl, [edx+ebp] + jnz short loc_4CB7B4 + add esi, 1 + add edx, 1 + cmp esi, [esp+38h+var_24] + jb short loc_4CB7A1 + +loc_4CB7B4: ; CODE XREF: CEncoder_GetOptimumFast+339j + ; CEncoder_GetOptimumFast+346j + add esi, 1 + cmp esi, [esp+38h+var_28] + jb short loc_4CB7E9 + mov eax, [esp+38h+arg_0] + pop ebp + mov byte ptr [edi+32F10h], 1 + pop edi + pop esi + mov dword ptr [eax], 0FFFFFFFFh + mov eax, 1 + pop ebx + add esp, 28h + retn 4 +; --------------------------------------------------------------------------- + +loc_4CB7DD: ; CODE XREF: CEncoder_GetOptimumFast+323j + ; CEncoder_GetOptimumFast+32Ej + mov edx, [esp+38h+var_18] + mov [esp+edx*4+38h+var_10], 0 + +loc_4CB7E9: ; CODE XREF: CEncoder_GetOptimumFast+35Bj + mov ecx, [esp+38h+var_18] + add ecx, 1 + add ebx, 4 + cmp ecx, 4 + mov [esp+38h+var_18], ecx + jb loc_4CB776 + mov esi, [esp+38h+var_28] + mov ecx, [esp+38h+var_20] + mov edx, [esp+38h+arg_0] + add ecx, 4 + lea eax, [esi-2] + test eax, eax + mov [edx], ecx + jz short loc_4CB82E + add [edi+32F04h], eax + mov ecx, [edi+7Ch] + push eax + mov eax, [edi+80h] + push eax + call ecx + add esp, 8 + +loc_4CB82E: ; CODE XREF: CEncoder_GetOptimumFast+164j + ; CEncoder_GetOptimumFast+23Fj ... + pop ebp + pop edi + mov eax, esi + pop esi + pop ebx + add esp, 28h + retn 4 +CEncoder_GetOptimumFast endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CB8A0 proc near ; CODE XREF: sub_4CD940+37p + +arg_0 = dword ptr 4 + + push edi + mov edi, [esp+4+arg_0] + test edi, edi + jz short loc_4CB8EB + mov eax, dword_553598 + test eax, eax + jnz short loc_4CB8DD + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + test eax, eax + jz short loc_4CB8D6 + mov dword ptr [eax], 0 + mov dword ptr [eax+4], 0 + mov dword ptr [eax+8], 0 + jmp short loc_4CB8D8 +; --------------------------------------------------------------------------- + +loc_4CB8D6: ; CODE XREF: sub_4CB8A0+1Ej + xor eax, eax + +loc_4CB8D8: ; CODE XREF: sub_4CB8A0+34j + mov dword_553598, eax + +loc_4CB8DD: ; CODE XREF: sub_4CB8A0+10j + mov eax, [eax] + test eax, eax + jz short loc_4CB8EB + push edi + call eax + add esp, 4 + pop edi + retn +; --------------------------------------------------------------------------- + +loc_4CB8EB: ; CODE XREF: sub_4CB8A0+7j + ; sub_4CB8A0+41j + xor eax, eax + pop edi + retn +sub_4CB8A0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CB8F0 proc near ; CODE XREF: sub_4CBA60+85p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push esi + mov esi, [esp+4+arg_0] + push edi + mov edi, [esi+44h] + add edi, [esi+40h] + add edi, [esp+8+arg_4] + cmp dword ptr [esi+4Ch], 0 + jz short loc_4CB911 + mov [esi+3Ch], edi + pop edi + mov eax, 1 + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CB911: ; CODE XREF: sub_4CB8F0+14j + mov eax, [esi+30h] + test eax, eax + jz short loc_4CB91D + cmp [esi+3Ch], edi + jz short loc_4CB93E + +loc_4CB91D: ; CODE XREF: sub_4CB8F0+26j + push ebx + mov ebx, [esp+0Ch+arg_8] + push eax + mov eax, [ebx+4] + call eax + mov dword ptr [esi+30h], 0 + mov [esi+3Ch], edi + mov ecx, [ebx] + push edi + call ecx + add esp, 8 + mov [esi+30h], eax + pop ebx + +loc_4CB93E: ; CODE XREF: sub_4CB8F0+2Bj + xor eax, eax + cmp [esi+30h], eax + pop edi + setnz al + pop esi + retn +sub_4CB8F0 endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CB950: ; DATA XREF: sub_4CCAA0+1Co + mov eax, [esp+4] + mov eax, [eax] + retn +; --------------------------------------------------------------------------- + align 10h + +loc_4CB960: ; DATA XREF: sub_4CCAA0+Eo + mov eax, [esp+4] + mov ecx, [eax] + mov edx, [esp+8] + mov al, [edx+ecx] + retn +; --------------------------------------------------------------------------- + align 10h +loc_4CB970: ; DATA XREF: sub_4CCAA0+15o + mov ecx, [esp+4] + +; =============== S U B R O U T I N E ======================================= + +; Attributes: library function + +; public: int __thiscall CRect::Height(void)const +?Height@CRect@@QBEHXZ proc near + mov eax, [ecx+0Ch] + sub eax, [ecx+4] + retn +?Height@CRect@@QBEHXZ endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CB980 proc near ; CODE XREF: sub_4CBC80+46p + ; sub_4CBD50+61p + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + cmp dword ptr [esi+38h], 0 + jnz short loc_4CB9F0 + cmp dword ptr [esi+68h], 0 + jnz short loc_4CB9F0 + mov eax, [esi] + sub eax, [esi+4] + mov ecx, [esi+30h] + add eax, [esi+0Ch] + sub ecx, eax + add ecx, [esi+3Ch] + jz short loc_4CB9F0 + push edi + +loc_4CB9A4: ; CODE XREF: sub_4CB980+63j + mov edx, [esi+34h] + lea edi, [esp+8+arg_0] + push edi + push ecx + push eax + mov eax, [edx] + push edx + call eax + add esp, 10h + test eax, eax + mov [esi+68h], eax + jnz short loc_4CB9EF + mov eax, [esp+8+arg_0] + test eax, eax + jz short loc_4CB9E8 + add [esi+0Ch], eax + mov eax, [esi+0Ch] + sub eax, [esi+4] + cmp eax, [esi+44h] + ja short loc_4CB9EF + mov eax, [esi] + sub eax, [esi+4] + mov ecx, [esi+30h] + add eax, [esi+0Ch] + sub ecx, eax + add ecx, [esi+3Ch] + jnz short loc_4CB9A4 + pop edi + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CB9E8: ; CODE XREF: sub_4CB980+43j + mov dword ptr [esi+38h], 1 + +loc_4CB9EF: ; CODE XREF: sub_4CB980+3Bj + ; sub_4CB980+51j + pop edi + +loc_4CB9F0: ; CODE XREF: sub_4CB980+9j + ; sub_4CB980+Fj ... + pop esi + retn +sub_4CB980 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBA00 proc near ; CODE XREF: sub_4CBD50+58p + +arg_0 = dword ptr 4 + + push ebx + push ebp + push esi + push edi + mov edi, [esp+10h+arg_0] + mov esi, [edi+0Ch] + mov eax, [edi+40h] + sub esi, [edi+4] + mov ebx, [edi] + mov ebp, [edi+30h] + add esi, eax + sub ebx, eax + mov eax, dword_553598 + test eax, eax + jnz short loc_4CBA44 + push 0Ch ; Size + call _operator_new ; operator new(uint) + xor ecx, ecx + add esp, 4 + cmp eax, ecx + jz short loc_4CBA3D + mov [eax], ecx + mov [eax+4], ecx + mov [eax+8], ecx + jmp short loc_4CBA3F +; --------------------------------------------------------------------------- + +loc_4CBA3D: ; CODE XREF: sub_4CBA00+31j + xor eax, eax + +loc_4CBA3F: ; CODE XREF: sub_4CBA00+3Bj + mov dword_553598, eax + +loc_4CBA44: ; CODE XREF: sub_4CBA00+21j + mov eax, [eax+8] + test eax, eax + jz short loc_4CBA53 + push esi + push ebx + push ebp + call eax + add esp, 0Ch + +loc_4CBA53: ; CODE XREF: sub_4CBA00+49j + mov eax, [edi+30h] + add eax, [edi+40h] + mov [edi], eax + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CBA00 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CBA60 proc near ; CODE XREF: sub_4D0270+D2p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h + + push ebx + push esi + push edi + mov edi, [esp+0Ch+arg_4] + cmp edi, 0C0000000h + jbe short loc_4CBAA2 + mov esi, [esp+0Ch+arg_0] + mov eax, [esi+20h] + mov edi, [esp+0Ch+arg_14] + mov ecx, [edi+4] + push eax + call ecx + xor ebx, ebx + add esp, 4 + cmp [esi+4Ch], ebx + mov [esi+20h], ebx + jnz short loc_4CBA9C + mov edx, [esi+30h] + mov eax, [edi+4] + push edx + call eax + add esp, 4 + mov [esi+30h], ebx + +loc_4CBA9C: ; CODE XREF: sub_4CBA60+2Bj + pop edi + pop esi + xor eax, eax + pop ebx + retn +; --------------------------------------------------------------------------- + +loc_4CBAA2: ; CODE XREF: sub_4CBA60+Dj + mov eax, edi + shr eax, 1 + cmp edi, 80000000h + jbe short loc_4CBAB3 + mov eax, edi + shr eax, 2 + +loc_4CBAB3: ; CODE XREF: sub_4CBA60+4Cj + mov ecx, [esp+0Ch+arg_8] + mov esi, [esp+0Ch+arg_0] + mov ebx, [esp+0Ch+arg_C] + lea edx, [edi+ecx+1] + push ebp + mov [esi+40h], edx + mov edx, [esp+10h+arg_10] + add ecx, ebx + lea ebp, [ebx+edx] + add ecx, edx + mov [esi+44h], ebp + mov ebp, [esp+10h+arg_14] + shr ecx, 1 + push ebp + lea eax, [ecx+eax+80000h] + push eax + push esi + call sub_4CB8F0 + add esp, 0Ch + test eax, eax + jz loc_4CBBEA + mov edx, [esi+48h] + mov [esi+1Ch], ebx + xor ebx, ebx + cmp edx, 2 + lea ebp, [edi+1] + mov [esi+5Ch], ebx + jnz short loc_4CBB0F + mov eax, 0FFFFh + jmp short loc_4CBB49 +; --------------------------------------------------------------------------- + +loc_4CBB0F: ; CODE XREF: sub_4CBA60+A6j + lea ecx, [edi-1] + mov eax, ecx + shr eax, 1 + or ecx, eax + mov eax, ecx + shr eax, 2 + or ecx, eax + mov eax, ecx + shr eax, 4 + or ecx, eax + mov eax, ecx + or eax, 1FFFE00h + shr eax, 8 + or eax, ecx + shr eax, 1 + cmp eax, 1000000h + jbe short loc_4CBB49 + cmp edx, 3 + jnz short loc_4CBB47 + mov eax, 0FFFFFFh + jmp short loc_4CBB49 +; --------------------------------------------------------------------------- + +loc_4CBB47: ; CODE XREF: sub_4CBA60+DEj + shr eax, 1 + +loc_4CBB49: ; CODE XREF: sub_4CBA60+ADj + ; sub_4CBA60+D9j ... + mov [esi+28h], eax + add eax, 1 + cmp edx, 2 + jbe short loc_4CBB5B + mov dword ptr [esi+5Ch], 400h + +loc_4CBB5B: ; CODE XREF: sub_4CBA60+F2j + cmp edx, 3 + jbe short loc_4CBB67 + add dword ptr [esi+5Ch], 10000h + +loc_4CBB67: ; CODE XREF: sub_4CBA60+FEj + cmp edx, 4 + jbe short loc_4CBB73 + add dword ptr [esi+5Ch], 100000h + +loc_4CBB73: ; CODE XREF: sub_4CBA60+10Aj + mov ecx, [esi+60h] + mov edx, [esi+5Ch] + add ecx, [esi+64h] + add eax, edx + cmp [esi+50h], ebx + mov [esi+58h], edi + mov [esi+60h], eax + mov [esi+18h], ebp + lea edx, [ebp+ebp+0] + jnz short loc_4CBB92 + mov edx, ebp + +loc_4CBB92: ; CODE XREF: sub_4CBA60+12Ej + lea edi, [eax+edx] + mov eax, [esi+20h] + cmp eax, ebx + mov [esi+64h], edx + jz short loc_4CBBA3 + cmp ecx, edi + jz short loc_4CBBE0 + +loc_4CBBA3: ; CODE XREF: sub_4CBA60+13Dj + mov ebp, [esp+10h+arg_14] + push eax + mov eax, [ebp+4] + call eax + lea eax, ds:0[edi*4] + mov ecx, eax + shr ecx, 2 + add esp, 4 + cmp ecx, edi + mov [esi+20h], ebx + jz short loc_4CBBC7 + xor eax, eax + jmp short loc_4CBBD0 +; --------------------------------------------------------------------------- + +loc_4CBBC7: ; CODE XREF: sub_4CBA60+161j + mov edx, [ebp+0] + push eax + call edx + add esp, 4 + +loc_4CBBD0: ; CODE XREF: sub_4CBA60+165j + cmp eax, ebx + mov [esi+20h], eax + jz short loc_4CBBEC + mov ecx, [esi+60h] + lea edx, [eax+ecx*4] + mov [esi+24h], edx + +loc_4CBBE0: ; CODE XREF: sub_4CBA60+141j + pop ebp + pop edi + pop esi + mov eax, 1 + pop ebx + retn +; --------------------------------------------------------------------------- + +loc_4CBBEA: ; CODE XREF: sub_4CBA60+8Fj + xor ebx, ebx + +loc_4CBBEC: ; CODE XREF: sub_4CBA60+175j + mov eax, [esi+20h] + mov ecx, [ebp+4] + push eax + call ecx + add esp, 4 + cmp [esi+4Ch], ebx + mov [esi+20h], ebx + jnz short loc_4CBC0F + mov edx, [esi+30h] + mov eax, [ebp+4] + push edx + call eax + add esp, 4 + mov [esi+30h], ebx + +loc_4CBC0F: ; CODE XREF: sub_4CBA60+19Ej + pop ebp + pop edi + pop esi + xor eax, eax + pop ebx + retn +sub_4CBA60 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBC20 proc near ; CODE XREF: sub_4CBD50+79p + +arg_0 = dword ptr 4 + + mov eax, [esp+arg_0] + mov edx, [eax+18h] + sub edx, [eax+14h] + push ebx + mov ebx, [eax+4] + or ecx, 0FFFFFFFFh + sub ecx, ebx + cmp edx, ecx + push esi + jnb short loc_4CBC3A + mov ecx, edx + +loc_4CBC3A: ; CODE XREF: sub_4CBC20+16j + mov esi, [eax+0Ch] + sub esi, ebx + push edi + mov edi, [eax+44h] + mov edx, esi + cmp edx, edi + ja short loc_4CBC54 + test edx, edx + jbe short loc_4CBC56 + mov edx, 1 + jmp short loc_4CBC56 +; --------------------------------------------------------------------------- + +loc_4CBC54: ; CODE XREF: sub_4CBC20+27j + sub edx, edi + +loc_4CBC56: ; CODE XREF: sub_4CBC20+2Bj + ; sub_4CBC20+32j + cmp edx, ecx + pop edi + jnb short loc_4CBC5D + mov ecx, edx + +loc_4CBC5D: ; CODE XREF: sub_4CBC20+39j + mov edx, [eax+1Ch] + cmp esi, edx + jbe short loc_4CBC66 + mov esi, edx + +loc_4CBC66: ; CODE XREF: sub_4CBC20+42j + add ebx, ecx + mov [eax+10h], esi + pop esi + mov [eax+8], ebx + pop ebx + retn +sub_4CBC20 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBC80 proc near ; DATA XREF: sub_4CCAA0+8o + +arg_0 = dword ptr 4 + + push ebx + push esi + mov esi, [esp+8+arg_0] + xor eax, eax + cmp [esi+60h], eax + jbe short loc_4CBCA2 + lea ecx, [ecx+0] + +loc_4CBC90: ; CODE XREF: sub_4CBC80+20j + mov ecx, [esi+20h] + mov dword ptr [ecx+eax*4], 0 + add eax, 1 + cmp eax, [esi+60h] + jb short loc_4CBC90 + +loc_4CBCA2: ; CODE XREF: sub_4CBC80+Bj + mov eax, [esi+18h] + mov edx, [esi+30h] + push esi + mov dword ptr [esi+14h], 0 + mov [esi], edx + mov [esi+0Ch], eax + mov [esi+4], eax + mov dword ptr [esi+68h], 0 + mov dword ptr [esi+38h], 0 + call sub_4CB980 + mov eax, [esi+18h] + mov ebx, [esi+4] + sub eax, [esi+14h] + or ecx, 0FFFFFFFFh + sub ecx, ebx + add esp, 4 + cmp eax, ecx + jnb short loc_4CBCE2 + mov ecx, eax + +loc_4CBCE2: ; CODE XREF: sub_4CBC80+5Ej + mov edx, [esi+0Ch] + sub edx, ebx + push edi + mov edi, [esi+44h] + mov eax, edx + cmp eax, edi + ja short loc_4CBCFC + test eax, eax + jbe short loc_4CBCFE + mov eax, 1 + jmp short loc_4CBCFE +; --------------------------------------------------------------------------- + +loc_4CBCFC: ; CODE XREF: sub_4CBC80+6Fj + sub eax, edi + +loc_4CBCFE: ; CODE XREF: sub_4CBC80+73j + ; sub_4CBC80+7Aj + cmp eax, ecx + pop edi + jnb short loc_4CBD05 + mov ecx, eax + +loc_4CBD05: ; CODE XREF: sub_4CBC80+81j + mov eax, edx + mov edx, [esi+1Ch] + cmp eax, edx + jbe short loc_4CBD10 + mov eax, edx + +loc_4CBD10: ; CODE XREF: sub_4CBC80+8Cj + add ebx, ecx + mov [esi+8], ebx + mov [esi+10h], eax + pop esi + pop ebx + retn +sub_4CBC80 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CBD20 proc near ; CODE XREF: sub_4CBD50+26p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push edi + mov edi, [esp+4+arg_8] + xor eax, eax + test edi, edi + jbe short loc_4CBD4C + mov edx, [esp+4+arg_4] + push esi + mov esi, [esp+8+arg_0] + +loc_4CBD34: ; CODE XREF: sub_4CBD20+29j + mov ecx, [edx+eax*4] + cmp ecx, esi + ja short loc_4CBD3F + xor ecx, ecx + jmp short loc_4CBD41 +; --------------------------------------------------------------------------- + +loc_4CBD3F: ; CODE XREF: sub_4CBD20+19j + sub ecx, esi + +loc_4CBD41: ; CODE XREF: sub_4CBD20+1Dj + mov [edx+eax*4], ecx + add eax, 1 + cmp eax, edi + jb short loc_4CBD34 + pop esi + +loc_4CBD4C: ; CODE XREF: sub_4CBD20+9j + pop edi + retn +sub_4CBD20 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + +sub_4CBD50 proc near ; CODE XREF: .text:004CC1A1p + ; .text:004CC20Ap ... + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + cmp dword ptr [esi+4], 0FFFFFFFFh + jnz short loc_4CBD88 + mov eax, [esi+64h] + add eax, [esi+60h] + mov ecx, [esi+20h] + push edi + mov edi, 0FFFFFFFEh + sub edi, [esi+58h] + push eax + push ecx + and edi, 0FFFFFC00h + push edi + call sub_4CBD20 + sub [esi+8], edi + sub [esi+4], edi + add esp, 0Ch + sub [esi+0Ch], edi + pop edi + +loc_4CBD88: ; CODE XREF: sub_4CBD50+9j + cmp dword ptr [esi+38h], 0 + jnz short loc_4CBDB9 + mov edx, [esi+0Ch] + sub edx, [esi+4] + mov eax, [esi+44h] + cmp eax, edx + jnz short loc_4CBDB9 + mov ecx, [esi+3Ch] + add ecx, [esi+30h] + sub ecx, [esi] + cmp ecx, eax + ja short loc_4CBDB0 + push esi + call sub_4CBA00 + add esp, 4 + +loc_4CBDB0: ; CODE XREF: sub_4CBD50+55j + push esi + call sub_4CB980 + add esp, 4 + +loc_4CBDB9: ; CODE XREF: sub_4CBD50+3Cj + ; sub_4CBD50+49j + mov edx, [esi+14h] + cmp edx, [esi+18h] + jnz short loc_4CBDC8 + mov dword ptr [esi+14h], 0 + +loc_4CBDC8: ; CODE XREF: sub_4CBD50+6Fj + push esi + call sub_4CBC20 + add esp, 4 + pop esi + retn +sub_4CBD50 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBDE0 proc near ; CODE XREF: sub_4CC5C0+1B7p + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch +arg_1C = dword ptr 20h +arg_20 = dword ptr 24h +arg_24 = dword ptr 28h + + push ecx + mov edx, [esp+4+arg_4] + mov ecx, [esp+4+arg_10] + mov eax, [esp+4+arg_14] + push ebx + mov [ecx+eax*4], edx + mov ecx, [esp+8+arg_8] + push ebp + push esi + sub ecx, edx + cmp [esp+10h+arg_1C], 0 + push edi + jz loc_4CBEAC + mov ebp, [esp+14h+arg_C] + mov ebx, [esp+14h+arg_24] + jmp short loc_4CBE14 +; --------------------------------------------------------------------------- + align 10h + +loc_4CBE10: ; CODE XREF: sub_4CBDE0+C6j + mov eax, [esp+14h+arg_14] + +loc_4CBE14: ; CODE XREF: sub_4CBDE0+2Dj + mov esi, [esp+14h+arg_18] + sub [esp+14h+arg_1C], 1 + cmp ecx, esi + jnb loc_4CBEAC + mov edx, ebp + sub edx, ecx + cmp eax, ecx + sbb edi, edi + and edi, esi + sub edi, ecx + add edi, eax + mov eax, [esp+14h+arg_10] + mov eax, [eax+edi*4] + mov [esp+14h+arg_4], eax + mov al, [edx+ebx] + cmp al, [ebx+ebp] + jnz short loc_4CBE99 + mov al, [edx] + cmp al, [ebp+0] + jnz short loc_4CBE99 + mov eax, [esp+14h+arg_0] + mov esi, 1 + cmp eax, esi + jz short loc_4CBE7A + sub edx, ebp + lea edi, [ebp+1] + mov [esp+14h+var_4], edx + jmp short loc_4CBE69 +; --------------------------------------------------------------------------- + +loc_4CBE65: ; CODE XREF: sub_4CBDE0+98j + mov edx, [esp+14h+var_4] + +loc_4CBE69: ; CODE XREF: sub_4CBDE0+83j + mov dl, [edx+edi] + cmp dl, [edi] + jnz short loc_4CBE7A + add esi, 1 + add edi, 1 + cmp esi, eax + jnz short loc_4CBE65 + +loc_4CBE7A: ; CODE XREF: sub_4CBDE0+78j + ; sub_4CBDE0+8Ej + cmp ebx, esi + jnb short loc_4CBE99 + mov edx, [esp+14h+arg_20] + mov [edx], esi + add edx, 4 + add ecx, 0FFFFFFFFh + mov [edx], ecx + add edx, 4 + cmp esi, eax + mov ebx, esi + mov [esp+14h+arg_20], edx + jz short loc_4CBEB6 + +loc_4CBE99: ; CODE XREF: sub_4CBDE0+64j + ; sub_4CBDE0+6Bj ... + mov ecx, [esp+14h+arg_8] + sub ecx, [esp+14h+arg_4] + cmp [esp+14h+arg_1C], 0 + jnz loc_4CBE10 + +loc_4CBEAC: ; CODE XREF: sub_4CBDE0+1Fj + ; sub_4CBDE0+3Fj + mov eax, [esp+14h+arg_20] + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn +; --------------------------------------------------------------------------- + +loc_4CBEB6: ; CODE XREF: sub_4CBDE0+B7j + pop edi + pop esi + pop ebp + mov eax, edx + pop ebx + pop ecx + retn +sub_4CBDE0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CBEC0 proc near ; CODE XREF: .text:004CC1E7p + ; sub_4CC220+14Ep ... + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch +arg_1C = dword ptr 20h +arg_20 = dword ptr 24h +arg_24 = dword ptr 28h + + sub esp, 10h + mov eax, [esp+10h+arg_10] + mov edx, [esp+10h+arg_8] + sub edx, [esp+10h+arg_4] + push ebx + push ebp + push esi + push edi + mov edi, [esp+20h+arg_14] + lea eax, [eax+edi*8] + lea ecx, [eax+4] + mov [esp+20h+var_C], ecx + xor ecx, ecx + xor ebx, ebx + cmp [esp+20h+arg_1C], ecx + mov ebp, eax + mov [esp+20h+var_10], ebp + mov [esp+20h+var_8], ecx + mov [esp+20h+var_4], ebx + jnz short loc_4CBF24 + +loc_4CBEF9: ; CODE XREF: sub_4CBEC0+6Fj + ; sub_4CBEC0+151j + mov edx, [esp+20h+var_C] + mov eax, [esp+20h+arg_20] + pop edi + pop esi + mov dword ptr [ebp+0], 0 + pop ebp + mov dword ptr [edx], 0 + pop ebx + add esp, 10h + retn +; --------------------------------------------------------------------------- + jmp short loc_4CBF20 +; --------------------------------------------------------------------------- + align 10h + +loc_4CBF20: ; CODE XREF: sub_4CBEC0+56j + ; sub_4CBEC0+14Bj + mov edi, [esp+20h+arg_14] + +loc_4CBF24: ; CODE XREF: sub_4CBEC0+37j + mov eax, [esp+20h+arg_18] + sub [esp+20h+arg_1C], 1 + cmp edx, eax + jnb short loc_4CBEF9 + cmp edi, edx + sbb esi, esi + and esi, eax + mov eax, [esp+20h+arg_10] + sub esi, edx + add esi, edi + lea eax, [eax+esi*8] + mov esi, [esp+20h+arg_C] + sub esi, edx + cmp ecx, ebx + jb short loc_4CBF4E + mov ecx, ebx + +loc_4CBF4E: ; CODE XREF: sub_4CBEC0+8Aj + mov bl, [ecx+esi] + mov edi, [esp+20h+arg_C] + cmp bl, [ecx+edi] + jnz short loc_4CBFB8 + add ecx, 1 + cmp ecx, [esp+20h+arg_0] + jz short loc_4CBF93 + mov bl, [ecx+esi] + cmp bl, [ecx+edi] + jnz short loc_4CBF93 + add ecx, 1 + cmp ecx, [esp+20h+arg_0] + jz short loc_4CBF93 + mov ebx, edi + mov ebp, esi + lea edi, [ecx+ebx] + sub ebp, ebx + lea ecx, [ecx+0] + +loc_4CBF80: ; CODE XREF: sub_4CBEC0+D1j + mov bl, [edi+ebp] + cmp bl, [edi] + jnz short loc_4CBF93 + add ecx, 1 + add edi, 1 + cmp ecx, [esp+20h+arg_0] + jnz short loc_4CBF80 + +loc_4CBF93: ; CODE XREF: sub_4CBEC0+A1j + ; sub_4CBEC0+A9j ... + cmp [esp+20h+arg_24], ecx + jnb short loc_4CBFB8 + mov edi, [esp+20h+arg_20] + mov [edi], ecx + add edi, 4 + add edx, 0FFFFFFFFh + mov [edi], edx + add edi, 4 + cmp ecx, [esp+20h+arg_0] + mov [esp+20h+arg_24], ecx + mov [esp+20h+arg_20], edi + jz short loc_4CC016 + +loc_4CBFB8: ; CODE XREF: sub_4CBEC0+98j + ; sub_4CBEC0+D7j + mov dl, [ecx+esi] + mov esi, [esp+20h+arg_C] + cmp dl, [ecx+esi] + mov edx, [esp+20h+arg_4] + jnb short loc_4CBFE4 + mov esi, [esp+20h+var_10] + lea ebp, [eax+4] + mov ebx, ecx + mov ecx, [esp+20h+var_8] + mov [esi], edx + mov eax, [ebp+0] + mov [esp+20h+var_10], ebp + mov [esp+20h+var_4], ebx + jmp short loc_4CBFFC +; --------------------------------------------------------------------------- + +loc_4CBFE4: ; CODE XREF: sub_4CBEC0+106j + mov esi, [esp+20h+var_C] + mov ebp, [esp+20h+var_10] + mov ebx, [esp+20h+var_4] + mov [esi], edx + mov [esp+20h+var_C], eax + mov eax, [eax] + mov [esp+20h+var_8], ecx + +loc_4CBFFC: ; CODE XREF: sub_4CBEC0+122j + mov edx, [esp+20h+arg_8] + sub edx, eax + cmp [esp+20h+arg_1C], 0 + mov [esp+20h+arg_4], eax + jnz loc_4CBF20 + jmp loc_4CBEF9 +; --------------------------------------------------------------------------- + +loc_4CC016: ; CODE XREF: sub_4CBEC0+F6j + mov ecx, [eax] + mov edx, [esp+20h+var_10] + mov [edx], ecx + mov eax, [eax+4] + mov ecx, [esp+20h+var_C] + mov [ecx], eax + mov eax, edi + pop edi + pop esi + pop ebp + pop ebx + add esp, 10h + retn +sub_4CBEC0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CC040 proc near ; CODE XREF: sub_4CC220+F8p + ; sub_4CC3B0+173p ... + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch +arg_1C = dword ptr 20h + + sub esp, 10h + mov eax, [esp+10h+arg_10] + mov edx, [esp+10h+arg_4] + push ebx + push ebp + push esi + mov esi, [esp+1Ch+arg_14] + lea eax, [eax+esi*8] + lea ecx, [eax+4] + push edi + mov edi, eax + mov eax, [esp+20h+arg_8] + xor ebx, ebx + xor ebp, ebp + sub eax, edx + cmp [esp+20h+arg_1C], ebx + mov [esp+20h+var_C], ecx + mov [esp+20h+var_10], edi + mov [esp+20h+var_8], ebx + mov [esp+20h+var_4], ebp + jz loc_4CC159 + nop + +loc_4CC080: ; CODE XREF: sub_4CC040+114j + sub [esp+20h+arg_1C], 1 + cmp eax, [esp+20h+arg_18] + jnb loc_4CC159 + cmp esi, eax + sbb ecx, ecx + and ecx, [esp+20h+arg_18] + sub ecx, eax + add ecx, esi + mov esi, [esp+20h+arg_10] + lea edi, [esi+ecx*8] + mov ecx, [esp+20h+arg_C] + sub ecx, eax + cmp ebx, ebp + mov eax, ebx + jb short loc_4CC0B0 + mov eax, ebp + +loc_4CC0B0: ; CODE XREF: sub_4CC040+6Cj + mov bl, [eax+ecx] + mov esi, [esp+20h+arg_C] + cmp bl, [eax+esi] + jnz short loc_4CC102 + add eax, 1 + cmp eax, [esp+20h+arg_0] + jz short loc_4CC0E3 + mov ebx, esi + mov ebp, ecx + lea esi, [eax+ebx] + sub ebp, ebx + mov edi, edi + +loc_4CC0D0: ; CODE XREF: sub_4CC040+A1j + mov bl, [esi+ebp] + cmp bl, [esi] + jnz short loc_4CC0FC + add eax, 1 + add esi, 1 + cmp eax, [esp+20h+arg_0] + jnz short loc_4CC0D0 + +loc_4CC0E3: ; CODE XREF: sub_4CC040+83j + ; sub_4CC040+C0j + mov edx, [edi] + mov eax, [esp+20h+var_10] + mov [eax], edx + mov ecx, [edi+4] + mov edx, [esp+20h+var_C] + pop edi + pop esi + pop ebp + mov [edx], ecx + pop ebx + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC0FC: ; CODE XREF: sub_4CC040+95j + cmp eax, [esp+20h+arg_0] + jz short loc_4CC0E3 + +loc_4CC102: ; CODE XREF: sub_4CC040+7Aj + mov cl, [eax+ecx] + mov esi, [esp+20h+arg_C] + cmp cl, [eax+esi] + jnb short loc_4CC129 + mov ecx, [esp+20h+var_10] + mov ebx, [esp+20h+var_8] + add edi, 4 + mov ebp, eax + mov [ecx], edx + mov edx, [edi] + mov [esp+20h+var_10], edi + mov [esp+20h+var_4], ebp + jmp short loc_4CC143 +; --------------------------------------------------------------------------- + +loc_4CC129: ; CODE XREF: sub_4CC040+CCj + mov ecx, [esp+20h+var_C] + mov ebp, [esp+20h+var_4] + mov [ecx], edx + mov edx, [edi] + mov ebx, eax + mov [esp+20h+var_C], edi + mov edi, [esp+20h+var_10] + mov [esp+20h+var_8], ebx + +loc_4CC143: ; CODE XREF: sub_4CC040+E7j + mov eax, [esp+20h+arg_8] + sub eax, edx + cmp [esp+20h+arg_1C], 0 + jz short loc_4CC159 + mov esi, [esp+20h+arg_14] + jmp loc_4CC080 +; --------------------------------------------------------------------------- + +loc_4CC159: ; CODE XREF: sub_4CC040+39j + ; sub_4CC040+49j ... + mov eax, [esp+20h+var_C] + mov dword ptr [edi], 0 + pop edi + pop esi + pop ebp + mov dword ptr [eax], 0 + pop ebx + add esp, 10h + retn +sub_4CC040 endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CC180: ; DATA XREF: sub_4CCAA0+40o + push esi + mov esi, [esp+8] + mov edx, [esi+10h] + cmp edx, 2 + jnb short loc_4CC1AD + add dword ptr [esi+4], 1 + mov eax, [esi+4] + add dword ptr [esi+14h], 1 + add dword ptr [esi], 1 + cmp eax, [esi+8] + jnz short loc_4CC1A9 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC1A9: ; CODE XREF: .text:004CC19Ej + xor eax, eax + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4CC1AD: ; CODE XREF: .text:004CC18Bj + mov eax, [esi] + xor ecx, ecx + mov ch, [eax+1] + push ebx + mov ebx, [esp+10h] + push edi + mov edi, [esi+4] + push 1 + push ebx + mov cl, [eax] + mov eax, ecx + mov ecx, [esi+20h] + lea eax, [ecx+eax*4] + mov ecx, [eax] + mov [eax], edi + mov eax, [esi+2Ch] + push eax + mov eax, [esi+18h] + push eax + mov eax, [esi+14h] + push eax + mov eax, [esi+24h] + push eax + mov eax, [esi] + push eax + mov eax, [esi+4] + push eax + push ecx + push edx + call sub_4CBEC0 + add dword ptr [esi+4], 1 + add dword ptr [esi+14h], 1 + add dword ptr [esi], 1 + mov edi, eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC212 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC212: ; CODE XREF: .text:004CC207j + mov eax, edi + pop edi + pop ebx + pop esi + retn + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC220 proc near ; DATA XREF: sub_4CCAA0+54o + +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 8 + push esi + mov esi, [esp+0Ch+arg_0] + mov eax, [esi+10h] + cmp eax, 3 + mov [esp+0Ch+arg_0], eax + jnb short loc_4CC259 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC252 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC252: ; CODE XREF: sub_4CC220+27j + xor eax, eax + pop esi + add esp, 8 + retn +; --------------------------------------------------------------------------- + +loc_4CC259: ; CODE XREF: sub_4CC220+12j + push ebx + mov ebx, [esi+20h] + push ebp + xor edx, edx + push edi + mov edi, [esi] + mov dh, [edi+2] + movzx ecx, byte ptr [edi] + movzx eax, byte ptr [edi+1] + xor eax, dword_553198[ecx*4] + xor edx, eax + and edx, [esi+28h] + mov ecx, eax + mov ebp, [ebx+edx*4+1000h] + mov eax, [esi+4] + and ecx, 3FFh + sub eax, [ebx+ecx*4] + mov [esp+18h+var_8], ebp + mov ebp, [esi+4] + mov [ebx+edx*4+1000h], ebp + mov ebx, [esi+20h] + mov edx, [ebx+edx*4+1000h] + mov [ebx+ecx*4], edx + mov ebx, [esp+18h+arg_4] + xor ebp, ebp + cmp eax, [esi+18h] + mov ecx, 2 + jnb loc_4CC348 + mov edx, edi + sub edx, eax + mov [esp+18h+var_4], edx + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC348 + mov edx, [esp+18h+arg_0] + cmp edx, ecx + jz short loc_4CC2EA + +loc_4CC2D3: ; CODE XREF: sub_4CC220+C4j + mov ebx, [esp+18h+var_4] + mov bl, [ebx+ecx] + cmp bl, [ecx+edi] + jnz short loc_4CC2E6 + add ecx, 1 + cmp ecx, edx + jnz short loc_4CC2D3 + +loc_4CC2E6: ; CODE XREF: sub_4CC220+BDj + mov ebx, [esp+18h+arg_4] + +loc_4CC2EA: ; CODE XREF: sub_4CC220+B1j + add eax, 0FFFFFFFFh + cmp ecx, edx + mov [ebx], ecx + mov [ebx+4], eax + mov ebp, 2 + jnz short loc_4CC34C + mov eax, [esi+2Ch] + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+2Ch+var_8] + push ecx + push eax + push edx + call sub_4CC040 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + add esp, 20h + cmp eax, [esi+8] + jnz short loc_4CC33E + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC33E: ; CODE XREF: sub_4CC220+113j + pop edi + mov eax, ebp + pop ebp + pop ebx + pop esi + add esp, 8 + retn +; --------------------------------------------------------------------------- + +loc_4CC348: ; CODE XREF: sub_4CC220+97j + ; sub_4CC220+A9j + mov edx, [esp+18h+arg_0] + +loc_4CC34C: ; CODE XREF: sub_4CC220+D9j + mov eax, [esi+2Ch] + push ecx + lea ecx, [ebx+ebp*4] + push ecx + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+34h+var_8] + push ecx + push eax + push edx + call sub_4CBEC0 + mov edi, eax + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC39B + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC39B: ; CODE XREF: sub_4CC220+170j + mov eax, edi + pop edi + pop ebp + pop ebx + pop esi + add esp, 8 + retn +sub_4CC220 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC3B0 proc near ; DATA XREF: sub_4CCAA0:loc_4CCB03o + +var_10 = dword ptr -10h +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 10h + push esi + mov esi, [esp+14h+arg_0] + mov eax, [esi+10h] + cmp eax, 4 + mov [esp+14h+arg_0], eax + jnb short loc_4CC3E9 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC3E2 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC3E2: ; CODE XREF: sub_4CC3B0+27j + xor eax, eax + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC3E9: ; CODE XREF: sub_4CC3B0+12j + push ebx + push ebp + push edi + mov edi, [esi] + movzx eax, byte ptr [edi] + movzx edx, byte ptr [edi+1] + xor edx, dword_553198[eax*4] + movzx eax, byte ptr [edi+2] + movzx ebp, byte ptr [edi+3] + mov ecx, eax + add eax, eax + add eax, eax + add eax, eax + xor eax, dword_553198[ebp*4] + mov ebp, [esi+4] + shl eax, 5 + shl ecx, 8 + xor eax, edx + and eax, [esi+28h] + xor ecx, edx + mov ebx, edx + mov edx, [esi+20h] + and ebx, 3FFh + sub ebp, [edx+ebx*4] + and ecx, 0FFFFh + mov [esp+20h+var_4], ebp + mov ebp, [esi+4] + sub ebp, [edx+ecx*4+1000h] + mov [esp+20h+var_10], ebp + mov ebp, [edx+eax*4+41000h] + mov [esp+20h+var_8], ebp + mov ebp, [esi+4] + mov [edx+eax*4+41000h], ebp + mov edx, [esi+20h] + mov eax, [edx+eax*4+41000h] + mov [edx+ecx*4+1000h], eax + mov eax, [esi+20h] + mov ecx, [eax+ecx*4+1000h] + mov [eax+ebx*4], ecx + mov ecx, [esp+20h+var_4] + mov ebx, [esp+20h+arg_4] + xor ebp, ebp + cmp ecx, [esi+18h] + mov eax, 1 + jnb short loc_4CC4A9 + mov edx, edi + sub edx, ecx + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC4A9 + mov eax, 2 + lea edx, [ecx-1] + mov [ebx], eax + mov [ebx+4], edx + mov ebp, eax + +loc_4CC4A9: ; CODE XREF: sub_4CC3B0+DEj + ; sub_4CC3B0+E8j + mov edx, [esp+20h+var_10] + cmp ecx, edx + jz short loc_4CC4D5 + cmp edx, [esi+18h] + jnb short loc_4CC4D5 + mov edx, edi + sub edx, [esp+20h+var_10] + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC4D5 + mov ecx, [esp+20h+var_10] + lea edx, [ecx-1] + mov [ebx+ebp*4+4], edx + mov eax, 3 + add ebp, 2 + +loc_4CC4D5: ; CODE XREF: sub_4CC3B0+FFj + ; sub_4CC3B0+104j ... + test ebp, ebp + mov edx, [esp+20h+arg_0] + jz short loc_4CC553 + cmp eax, edx + jz short loc_4CC4FE + mov edx, eax + sub edx, ecx + add edx, edi + +loc_4CC4E7: ; CODE XREF: sub_4CC3B0+148j + mov cl, [edx] + cmp cl, [eax+edi] + jnz short loc_4CC4FA + add eax, 1 + add edx, 1 + cmp eax, [esp+20h+arg_0] + jnz short loc_4CC4E7 + +loc_4CC4FA: ; CODE XREF: sub_4CC3B0+13Cj + mov edx, [esp+20h+arg_0] + +loc_4CC4FE: ; CODE XREF: sub_4CC3B0+12Fj + cmp eax, edx + mov [ebx+ebp*4-8], eax + jnz short loc_4CC553 + mov eax, [esi+2Ch] + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+34h+var_8] + push ecx + push eax + push edx + call sub_4CC040 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + add esp, 20h + cmp eax, [esi+8] + jnz short loc_4CC549 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC549: ; CODE XREF: sub_4CC3B0+18Ej + pop edi + mov eax, ebp + pop ebp + pop ebx + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC553: ; CODE XREF: sub_4CC3B0+12Bj + ; sub_4CC3B0+154j + cmp eax, 3 + jnb short loc_4CC55D + mov eax, 3 + +loc_4CC55D: ; CODE XREF: sub_4CC3B0+1A6j + push eax + mov eax, [esi+2Ch] + lea ecx, [ebx+ebp*4] + push ecx + mov ecx, [esi+18h] + push eax + mov eax, [esi+14h] + push ecx + mov ecx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push eax + mov eax, [esp+3Ch+var_8] + push ecx + push eax + push edx + call sub_4CBEC0 + mov edi, eax + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC5AC + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC5AC: ; CODE XREF: sub_4CC3B0+1F1j + mov eax, edi + pop edi + pop ebp + pop ebx + pop esi + add esp, 10h + retn +sub_4CC3B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC5C0 proc near ; DATA XREF: sub_4CCAA0+29o + +var_10 = dword ptr -10h +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 10h + push esi + mov esi, [esp+14h+arg_0] + mov eax, [esi+10h] + cmp eax, 4 + mov [esp+14h+arg_0], eax + jnb short loc_4CC5F9 + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC5F2 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC5F2: ; CODE XREF: sub_4CC5C0+27j + xor eax, eax + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC5F9: ; CODE XREF: sub_4CC5C0+12j + push ebx + push ebp + push edi + mov edi, [esi] + movzx eax, byte ptr [edi] + movzx edx, byte ptr [edi+1] + xor edx, dword_553198[eax*4] + movzx eax, byte ptr [edi+2] + movzx ebp, byte ptr [edi+3] + mov ecx, eax + add eax, eax + add eax, eax + add eax, eax + xor eax, dword_553198[ebp*4] + mov ebp, [esi+4] + shl eax, 5 + shl ecx, 8 + xor eax, edx + and eax, [esi+28h] + xor ecx, edx + mov ebx, edx + mov edx, [esi+20h] + and ebx, 3FFh + sub ebp, [edx+ebx*4] + and ecx, 0FFFFh + mov [esp+20h+var_4], ebp + mov ebp, [esi+4] + sub ebp, [edx+ecx*4+1000h] + mov [esp+20h+var_10], ebp + mov ebp, [edx+eax*4+41000h] + mov [esp+20h+var_8], ebp + mov ebp, [esi+4] + mov [edx+eax*4+41000h], ebp + mov edx, [esi+20h] + mov eax, [edx+eax*4+41000h] + mov [edx+ecx*4+1000h], eax + mov eax, [esi+20h] + mov ecx, [eax+ecx*4+1000h] + mov [eax+ebx*4], ecx + mov ecx, [esp+20h+var_4] + mov ebx, [esp+20h+arg_4] + xor ebp, ebp + cmp ecx, [esi+18h] + mov eax, 1 + jnb short loc_4CC6B9 + mov edx, edi + sub edx, ecx + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC6B9 + mov eax, 2 + lea edx, [ecx-1] + mov [ebx], eax + mov [ebx+4], edx + mov ebp, eax + +loc_4CC6B9: ; CODE XREF: sub_4CC5C0+DEj + ; sub_4CC5C0+E8j + mov edx, [esp+20h+var_10] + cmp ecx, edx + jz short loc_4CC6E5 + cmp edx, [esi+18h] + jnb short loc_4CC6E5 + mov edx, edi + sub edx, [esp+20h+var_10] + mov dl, [edx] + cmp dl, [edi] + jnz short loc_4CC6E5 + mov ecx, [esp+20h+var_10] + lea edx, [ecx-1] + mov [ebx+ebp*4+4], edx + mov eax, 3 + add ebp, 2 + +loc_4CC6E5: ; CODE XREF: sub_4CC5C0+FFj + ; sub_4CC5C0+104j ... + test ebp, ebp + jz short loc_4CC747 + cmp eax, [esp+20h+arg_0] + jz short loc_4CC708 + mov edx, eax + sub edx, ecx + add edx, edi + +loc_4CC6F5: ; CODE XREF: sub_4CC5C0+146j + mov cl, [edx] + cmp cl, [eax+edi] + jnz short loc_4CC708 + add eax, 1 + add edx, 1 + cmp eax, [esp+20h+arg_0] + jnz short loc_4CC6F5 + +loc_4CC708: ; CODE XREF: sub_4CC5C0+12Dj + ; sub_4CC5C0+13Aj + cmp eax, [esp+20h+arg_0] + mov [ebx+ebp*4-8], eax + jnz short loc_4CC747 + mov edx, [esi+14h] + mov eax, [esi+24h] + mov ecx, [esp+20h+var_8] + mov [eax+edx*4], ecx + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CC73D + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC73D: ; CODE XREF: sub_4CC5C0+172j + pop edi + mov eax, ebp + pop ebp + pop ebx + pop esi + add esp, 10h + retn +; --------------------------------------------------------------------------- + +loc_4CC747: ; CODE XREF: sub_4CC5C0+127j + ; sub_4CC5C0+150j + cmp eax, 3 + jnb short loc_4CC751 + mov eax, 3 + +loc_4CC751: ; CODE XREF: sub_4CC5C0+18Aj + mov ecx, [esi+18h] + push eax + mov eax, [esi+2Ch] + lea edx, [ebx+ebp*4] + push edx + mov edx, [esi+14h] + push eax + mov eax, [esi+24h] + push ecx + mov ecx, [esi] + push edx + mov edx, [esi+4] + push eax + mov eax, [esp+38h+var_8] + push ecx + mov ecx, [esp+3Ch+arg_0] + push edx + push eax + push ecx + call sub_4CBDE0 + mov edi, eax + mov eax, 1 + add [esi+14h], eax + add [esi], eax + add [esi+4], eax + mov eax, [esi+4] + sub edi, ebx + add esp, 28h + sar edi, 2 + cmp eax, [esi+8] + jnz short loc_4CC7A4 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC7A4: ; CODE XREF: sub_4CC5C0+1D9j + mov eax, edi + pop edi + pop ebp + pop ebx + pop esi + add esp, 10h + retn +sub_4CC5C0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC7B0 proc near ; DATA XREF: sub_4CCAA0+47o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + mov ebp, [esp+8+arg_4] + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + +loc_4CC7C1: ; CODE XREF: sub_4CC7B0+6Dj + mov edx, [esi+10h] + cmp edx, 2 + jb short loc_4CC802 + mov eax, [esi] + mov ebx, [esi+4] + xor ecx, ecx + mov ch, [eax+1] + mov cl, [eax] + mov eax, ecx + mov ecx, [esi+20h] + lea eax, [ecx+eax*4] + mov ecx, [eax] + mov [eax], ebx + mov eax, [esi+2Ch] + push eax + mov eax, [esi+18h] + push eax + mov eax, [esi+14h] + push eax + mov eax, [esi+24h] + push eax + mov eax, [esi] + push eax + mov eax, [esi+4] + push eax + push ecx + push edx + call sub_4CC040 + add esp, 20h + +loc_4CC802: ; CODE XREF: sub_4CC7B0+17j + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CC81B + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC81B: ; CODE XREF: sub_4CC7B0+60j + sub ebp, edi + jnz short loc_4CC7C1 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC7B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC830 proc near ; DATA XREF: sub_4CCAA0+5Bo + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + lea ecx, [ecx+0] + +loc_4CC840: ; CODE XREF: sub_4CC830+9Fj + mov ebp, [esi+10h] + cmp ebp, 3 + jb short loc_4CC8B2 + mov ecx, [esi] + movzx edx, byte ptr [ecx] + movzx eax, byte ptr [ecx+1] + xor eax, dword_553198[edx*4] + mov ebx, [esi+4] + xor edx, edx + mov dh, [ecx+2] + xor edx, eax + and edx, [esi+28h] + and eax, 3FFh + mov ecx, edx + mov edx, [esi+20h] + mov edi, [edx+ecx*4+1000h] + lea edx, [edx+ecx*4+1000h] + mov [edx], ebx + mov edx, [esi+20h] + mov ecx, [edx+ecx*4+1000h] + mov [edx+eax*4], ecx + mov edx, [esi+2Ch] + mov eax, [esi+18h] + mov ecx, [esi+14h] + push edx + mov edx, [esi+24h] + push eax + mov eax, [esi] + push ecx + mov ecx, [esi+4] + push edx + push eax + push ecx + push edi + push ebp + call sub_4CC040 + add esp, 20h + mov edi, 1 + +loc_4CC8B2: ; CODE XREF: sub_4CC830+16j + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CC8CB + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC8CB: ; CODE XREF: sub_4CC830+90j + sub [esp+10h+arg_4], edi + jnz loc_4CC840 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC830 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC8E0 proc near ; DATA XREF: sub_4CCAA0+6Ao + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + lea ecx, [ecx+0] + +loc_4CC8F0: ; CODE XREF: sub_4CC8E0+D6j + mov eax, [esi+10h] + cmp eax, 4 + mov [esp+10h+arg_0], eax + jb loc_4CC999 + mov eax, [esi] + movzx edi, byte ptr [eax+2] + movzx edx, byte ptr [eax] + movzx ebx, byte ptr [eax+3] + movzx ecx, byte ptr [eax+1] + xor ecx, dword_553198[edx*4] + mov ebp, [esi+4] + lea eax, ds:0[edi*8] + xor eax, dword_553198[ebx*4] + mov edx, edi + mov edi, [esi+20h] + shl eax, 5 + xor eax, ecx + and eax, [esi+28h] + shl edx, 8 + mov ebx, [edi+eax*4+41000h] + xor edx, ecx + and edx, 0FFFFh + mov [edi+edx*4+1000h], ebp + mov edi, [esi+20h] + mov edx, [edi+edx*4+1000h] + and ecx, 3FFh + mov [edi+ecx*4], edx + mov ecx, [esi+20h] + mov edx, [esi+4] + mov [ecx+eax*4+41000h], edx + mov eax, [esi+2Ch] + mov ecx, [esi+18h] + mov edx, [esi+14h] + push eax + mov eax, [esi+24h] + push ecx + mov ecx, [esi] + push edx + mov edx, [esi+4] + push eax + mov eax, [esp+20h+arg_0] + push ecx + push edx + push ebx + push eax + call sub_4CC040 + add esp, 20h + mov edi, 1 + +loc_4CC999: ; CODE XREF: sub_4CC8E0+1Aj + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CC9B2 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CC9B2: ; CODE XREF: sub_4CC8E0+C7j + sub [esp+10h+arg_4], edi + jnz loc_4CC8F0 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC8E0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CC9D0 proc near ; DATA XREF: sub_4CCAA0+30o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov edi, 1 + lea ecx, [ecx+0] + +loc_4CC9E0: ; CODE XREF: sub_4CC9D0+BAj + cmp dword ptr [esi+10h], 4 + jb loc_4CCA6D + mov eax, [esi] + movzx edi, byte ptr [eax+2] + movzx edx, byte ptr [eax] + movzx ebx, byte ptr [eax+3] + movzx ecx, byte ptr [eax+1] + xor ecx, dword_553198[edx*4] + mov ebp, [esi+4] + lea eax, ds:0[edi*8] + xor eax, dword_553198[ebx*4] + mov edx, edi + mov edi, [esi+20h] + shl eax, 5 + xor eax, ecx + and eax, [esi+28h] + mov ebx, [edi+eax*4+41000h] + lea edi, [edi+eax*4+41000h] + mov [edi], ebp + mov edi, [esi+20h] + mov eax, [edi+eax*4+41000h] + shl edx, 8 + xor edx, ecx + and edx, 0FFFFh + mov [edi+edx*4+1000h], eax + mov eax, [esi+20h] + mov edx, [eax+edx*4+1000h] + and ecx, 3FFh + mov [eax+ecx*4], edx + mov eax, [esi+14h] + mov ecx, [esi+24h] + mov [ecx+eax*4], ebx + mov edi, 1 + +loc_4CCA6D: ; CODE XREF: sub_4CC9D0+14j + add [esi+4], edi + mov eax, [esi+4] + add [esi+14h], edi + add [esi], edi + cmp eax, [esi+8] + jnz short loc_4CCA86 + push esi + call sub_4CBD50 + add esp, 4 + +loc_4CCA86: ; CODE XREF: sub_4CC9D0+ABj + sub [esp+10h+arg_4], edi + jnz loc_4CC9E0 + pop edi + pop esi + pop ebp + pop ebx + retn +sub_4CC9D0 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CCAA0 proc near ; CODE XREF: sub_4D0270+F3p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + mov eax, [esp+arg_4] + mov ecx, [esp+arg_0] + mov dword ptr [eax], offset sub_4CBC80 + mov dword ptr [eax+4], offset loc_4CB960 + mov dword ptr [eax+8], offset loc_4CB970 + mov dword ptr [eax+0Ch], offset loc_4CB950 + cmp dword ptr [ecx+50h], 0 + jnz short loc_4CCAD8 + mov dword ptr [eax+10h], offset sub_4CC5C0 + mov dword ptr [eax+14h], offset sub_4CC9D0 + retn +; --------------------------------------------------------------------------- + +loc_4CCAD8: ; CODE XREF: sub_4CCAA0+27j + mov ecx, [ecx+48h] + cmp ecx, 2 + jnz short loc_4CCAEF + mov dword ptr [eax+10h], offset loc_4CC180 + mov dword ptr [eax+14h], offset sub_4CC7B0 + retn +; --------------------------------------------------------------------------- + +loc_4CCAEF: ; CODE XREF: sub_4CCAA0+3Ej + cmp ecx, 3 + jnz short loc_4CCB03 + mov dword ptr [eax+10h], offset sub_4CC220 + mov dword ptr [eax+14h], offset sub_4CC830 + retn +; --------------------------------------------------------------------------- + +loc_4CCB03: ; CODE XREF: sub_4CCAA0+52j + mov dword ptr [eax+10h], offset sub_4CC3B0 + mov dword ptr [eax+14h], offset sub_4CC8E0 + retn +sub_4CCAA0 endp + +; --------------------------------------------------------------------------- + +Interface1_AddRef proc near ; DATA XREF: .rdata:00517A94o +;sub_4CCB80 + +arg_0 = dword ptr 4 + mov eax, [esp+arg_0] + add dword ptr [eax+4], 1 + mov eax, [eax+4] + retn 4 +Interface1_AddRef endp + +; --------------------------------------------------------------------------- + +sub_4CCB20 proc near ; DATA XREF: .rdata:00517A9Co + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + push esi + mov esi, [esp+4+arg_0] + mov ecx, [esi+10h] + sub ecx, [esi+18h] + mov eax, [esi+14h] + sbb eax, [esi+1Ch] + xor edx, edx + cmp edx, eax + push edi + mov edi, [esp+8+arg_8] + jb short loc_4CCB48 + ja short loc_4CCB42 + cmp edi, ecx + jbe short loc_4CCB48 + +loc_4CCB42: ; CODE XREF: sub_4CCB20+1Cj + mov edi, [esi+10h] + sub edi, [esi+18h] + +loc_4CCB48: ; CODE XREF: sub_4CCB20+1Aj + ; sub_4CCB20+20j + mov eax, [esp+8+arg_C] + test eax, eax + jz short loc_4CCB52 + mov [eax], edi + +loc_4CCB52: ; CODE XREF: sub_4CCB20+2Ej + test edi, edi + jz short loc_4CCB72 + mov eax, [esi+8] + add eax, [esi+18h] + mov ecx, [esp+8+arg_4] + push edi ; size_t + push eax ; void * + push ecx ; void * + call _memcpy ; Microsoft VisualC 2-8/net runtime + add esp, 0Ch + add [esi+18h], edi + adc dword ptr [esi+1Ch], 0 + +loc_4CCB72: ; CODE XREF: sub_4CCB20+34j + pop edi + xor eax, eax + pop esi + retn 10h +sub_4CCB20 endp + +; --------------------------------------------------------------------------- + +sub_4CCB90 proc near ; DATA XREF: .rdata:00517AB0o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + push ebx + mov ebx, [esp+4+arg_8] + push esi + mov esi, [esp+8+arg_0] + mov ecx, [esi+10h] + mov eax, [esi+14h] + push edi + xor edi, edi + sub ecx, [esi+18h] + sbb eax, [esi+1Ch] + cmp edi, eax + jb short loc_4CCBC2 + ja short loc_4CCBB3 + cmp ebx, ecx + jbe short loc_4CCBC2 + +loc_4CCBB3: ; CODE XREF: sub_4CCB90+1Dj + pop edi + mov byte ptr [esi+20h], 1 + pop esi + mov eax, 80004005h + pop ebx + retn 10h + +loc_4CCBC2: ; CODE XREF: sub_4CCB90+1Bj + ; sub_4CCB90+21j + mov ecx, [esi+8] + mov eax, [esp+0Ch+arg_4] + add ecx, [esi+18h] + push ebx ; size_t + push eax ; void * + push ecx ; void * + call _memcpy ; Microsoft VisualC 2-8/net runtime + mov eax, [esp+18h+arg_C] + add esp, 0Ch + add [esi+18h], ebx + adc [esi+1Ch], edi + test eax, eax + jz short loc_4CCBE7 + mov [eax], ebx + +loc_4CCBE7: ; CODE XREF: sub_4CCB90+53j + pop edi + pop esi + xor eax, eax + pop ebx + retn 10h +sub_4CCB90 endp + +; --------------------------------------------------------------------------- + align 10h +; --------------------------------------------------------------------------- + +LzmaProps_Decode proc near ; CODE XREF: Decompress_lzma_internal+35p +;sub_4CCBF0 + +propsRes = dword ptr 4 +propsData = dword ptr 8 +propsSize = dword ptr 0Ch + + cmp [esp+propsSize], 5 ; LZMA_PROPS_SIZE + jge short loc_4CCBFD + +loc_4CCBF7: ; CODE XREF: LzmaProps_Decode+16j + mov eax, 1 + retn +; --------------------------------------------------------------------------- + +loc_4CCBFD: ; CODE XREF: LzmaProps_Decode+5j + mov eax, [esp+propsData] + mov cl, [eax] + cmp cl, 0E1h ; 9 * 5 * 5 + jnb short loc_4CCBF7 + cmp cl, 2Dh + push edi + mov edi, [esp+4+propsRes] + mov dword ptr [edi+8], 0 + jb short loc_4CCC40 + push esi + movzx esi, cl + mov eax, 6C16C16Dh + mul esi + mov eax, esi + sub eax, edx + shr eax, 1 + add eax, edx + shr eax, 5 + movzx eax, al + mov edx, eax + pop esi + +loc_4CCC35: ; CODE XREF: LzmaProps_Decode+4Bj + add cl, 0D3h + sub eax, 1 + jnz short loc_4CCC35 + mov [edi+8], edx + +loc_4CCC40: ; CODE XREF: LzmaProps_Decode+27j + cmp cl, 9 + mov dword ptr [edi+4], 0 + jb short loc_4CCC6B + movzx edx, cl + mov eax, 38E38E39h + mul edx + shr edx, 1 + movzx eax, dl + mov edx, eax + lea ecx, [ecx+0] + +loc_4CCC60: ; CODE XREF: LzmaProps_Decode+76j + add cl, 0F7h + sub eax, 1 + jnz short loc_4CCC60 + mov [edi+4], edx + +loc_4CCC6B: ; CODE XREF: LzmaProps_Decode+5Aj + movzx eax, cl + mov [edi], eax + xor eax, eax + pop edi + retn +LzmaProps_Decode endp + +sub_4CCC80 proc near ; CODE XREF: Decompress_lzma_internal+97p + +var_3C = dword ptr -3Ch +var_38 = dword ptr -38h +var_34 = dword ptr -34h +var_30 = dword ptr -30h +var_2C = dword ptr -2Ch +var_28 = dword ptr -28h +var_24 = dword ptr -24h +var_20 = dword ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h +arg_10 = dword ptr 14h +arg_14 = dword ptr 18h +arg_18 = dword ptr 1Ch + + sub esp, 3Ch + mov eax, [esp+3Ch+arg_0] + mov ecx, [eax+8] + push ebx + push ebp + mov ebp, 1 + mov edx, ebp + shl edx, cl + mov ecx, [eax+4] + xor ebx, ebx + push esi + sub edx, ebp + mov [esp+48h+var_C], edx + mov edx, ebp + shl edx, cl + mov ecx, [esp+48h+arg_C] + push edi + mov edi, [eax+0Ch] + sub edx, ebp + mov [esp+4Ch+var_8], edx + mov edx, [eax] + mov [ecx], ebx + mov ecx, [esp+4Ch+arg_18] + mov [ecx], ebx + mov ecx, [eax+4] + add ecx, edx + mov eax, 300h + shl eax, cl + mov [esp+4Ch+var_20], edi + mov [esp+4Ch+var_2C], ebx + mov byte ptr [esp+4Ch+arg_0], bl + add eax, 736h + mov [esp+4Ch+var_14], edx + mov [esp+4Ch+var_34], ebx + mov [esp+4Ch+var_38], ebp + mov [esp+4Ch+var_24], ebp + mov [esp+4Ch+var_28], ebp + mov [esp+4Ch+var_18], ebp + jz short loc_4CCD04 + mov ecx, eax + shr ecx, 1 + mov eax, 4000400h + rep stosd + adc ecx, ecx + rep stosw + +loc_4CCD04: ; CODE XREF: sub_4CCC80+72j + mov edx, [esp+4Ch+arg_8] + mov ecx, [esp+4Ch+arg_4] + lea edi, [ecx+edx] + xor esi, esi + or eax, 0FFFFFFFFh + mov [esp+4Ch+var_3C], edi + xor edx, edx + lea ebx, [ebx+0] + +loc_4CCD20: ; CODE XREF: sub_4CCC80+BCj + cmp ecx, edi + jz loc_4CCF0B + movzx ebp, byte ptr [ecx] + shl esi, 8 + or esi, ebp + mov ebp, 1 + add edx, ebp + add ecx, ebp + cmp edx, 5 + jl short loc_4CCD20 + cmp [esp+4Ch+arg_14], ebx + mov [esp+4Ch+arg_8], ecx + jbe loc_4CCFCD + lea esp, [esp+0] + +loc_4CCD50: ; CODE XREF: sub_4CCC80+32Dj + mov edx, [esp+4Ch+var_34] + mov ecx, [esp+4Ch+var_C] + and ecx, [esp+4Ch+var_2C] + mov edi, [esp+4Ch+var_20] + mov ebx, edx + shl ebx, 4 + add ebx, ecx + cmp eax, 1000000h + lea ebx, [edi+ebx*2] + mov [esp+4Ch+var_1C], ecx + mov [esp+4Ch+var_30], ebx + jnb short loc_4CCD99 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebp, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebp + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CCD99: ; CODE XREF: sub_4CCC80+F7j + movzx ebx, word ptr [ebx] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb loc_4CCFF4 + mov edi, [esp+4Ch+var_30] + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + mov ebp, [esp+4Ch+var_8] + sar ecx, 5 + add ecx, ebx + movzx ebx, byte ptr [esp+4Ch+arg_0] + mov [edi], cx + mov edi, [esp+4Ch+var_2C] + mov ecx, 8 + sub cl, byte ptr [esp+4Ch+var_14] + and ebp, edi + shr ebx, cl + mov ecx, [esp+4Ch+var_14] + shl ebp, cl + mov ecx, [esp+4Ch+var_20] + mov edx, 1 + add ebx, ebp + imul ebx, 600h + cmp [esp+4Ch+var_34], 7 + lea ebp, [ebx+ecx+0E6Ch] + mov [esp+4Ch+var_30], ebp + jl loc_4CCEB0 + sub edi, [esp+4Ch+var_38] + mov ecx, [esp+4Ch+arg_10] + movzx ebx, byte ptr [edi+ecx] + jmp short loc_4CCE20 +; --------------------------------------------------------------------------- + align 10h + +loc_4CCE20: ; CODE XREF: sub_4CCC80+197j + ; sub_4CCC80+2C6j + add ebx, ebx + mov [esp+4Ch+var_10], ebx + and ebx, 100h + cmp eax, 1000000h + lea ecx, [ebx+edx] + lea ebp, [ebp+ecx*2+200h] + mov [esp+4Ch+arg_0], ebp + jnb short loc_4CCE61 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edi, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, edi + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CCE61: ; CODE XREF: sub_4CCC80+1BFj + movzx edi, word ptr [ebp+0] + movzx ebp, di + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb loc_4CCF15 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, edi + mov edi, [esp+4Ch+arg_0] + add edx, edx + test ebx, ebx + mov [edi], cx + jz loc_4CCF36 + +loc_4CCE97: ; CODE XREF: sub_4CCC80+2B0j + cmp edx, 100h + jge loc_4CCF70 + mov ebp, [esp+4Ch+var_30] + jmp short loc_4CCEB0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CCEB0: ; CODE XREF: sub_4CCC80+185j + ; sub_4CCC80+227j ... + cmp eax, 1000000h + lea ecx, [edx+edx] + mov [esp+4Ch+arg_0], ecx + jnb short loc_4CCEDE + mov edi, [esp+4Ch+arg_8] + cmp edi, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [edi] + shl esi, 8 + shl eax, 8 + or esi, ebx + add edi, 1 + mov [esp+4Ch+arg_8], edi + +loc_4CCEDE: ; CODE XREF: sub_4CCC80+23Cj + movzx edi, word ptr [ecx+ebp] + movzx ebx, di + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebx + cmp esi, ecx + jnb short loc_4CCF4B + mov eax, ecx + mov ecx, 800h + sub ecx, ebx + sar ecx, 5 + add ecx, edi + mov edi, [esp+4Ch+arg_0] + mov [edi+ebp], cx + add edx, edx + jmp short loc_4CCF64 +; --------------------------------------------------------------------------- + +loc_4CCF0B: ; CODE XREF: sub_4CCC80+A2j + pop edi + pop esi + mov eax, ebp + pop ebp + pop ebx + add esp, 3Ch + retn +; --------------------------------------------------------------------------- + +loc_4CCF15: ; CODE XREF: sub_4CCC80+1F2j + sub eax, ecx + sub esi, ecx + mov cx, di + shr cx, 5 + sub di, cx + test ebx, ebx + mov ecx, [esp+4Ch+arg_0] + mov [ecx], di + lea edx, [edx+edx+1] + jz loc_4CCE97 + +loc_4CCF36: ; CODE XREF: sub_4CCC80+211j + cmp edx, 100h + jge short loc_4CCF70 + mov ebp, [esp+4Ch+var_30] + mov ebx, [esp+4Ch+var_10] + jmp loc_4CCE20 +; --------------------------------------------------------------------------- + +loc_4CCF4B: ; CODE XREF: sub_4CCC80+26Fj + mov dx, di + shr dx, 5 + sub di, dx + mov edx, [esp+4Ch+arg_0] + sub eax, ecx + sub esi, ecx + mov [edx+ebp], di + add edx, 1 + +loc_4CCF64: ; CODE XREF: sub_4CCC80+289j + cmp edx, 100h + jl loc_4CCEB0 + +loc_4CCF70: ; CODE XREF: sub_4CCC80+21Dj + ; sub_4CCC80+2BCj + mov ecx, [esp+4Ch+var_2C] + mov edi, [esp+4Ch+arg_10] + mov [ecx+edi], dl + add ecx, 1 + mov [esp+4Ch+var_2C], ecx + mov ecx, [esp+4Ch+var_34] + cmp ecx, 4 + mov byte ptr [esp+4Ch+arg_0], dl + jge short loc_4CCF99 + mov [esp+4Ch+var_34], 0 + jmp short loc_4CCFA5 +; --------------------------------------------------------------------------- + +loc_4CCF99: ; CODE XREF: sub_4CCC80+30Dj + cmp ecx, 0Ah + jge short loc_4CCFEF + sub ecx, 3 + +loc_4CCFA1: ; CODE XREF: sub_4CCC80+372j + mov [esp+4Ch+var_34], ecx + +loc_4CCFA5: ; CODE XREF: sub_4CCC80+317j + ; sub_4CCC80+530j ... + mov ecx, [esp+4Ch+var_2C] + cmp ecx, [esp+4Ch+arg_14] + jb loc_4CCD50 + +loc_4CCFB3: ; CODE XREF: sub_4CCC80+A13j + ; sub_4CCC80+A5Aj + cmp eax, 1000000h + jnb short loc_4CCFCD + mov edx, [esp+4Ch+arg_8] + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + add [esp+4Ch+arg_8], 1 + +loc_4CCFCD: ; CODE XREF: sub_4CCC80+C6j + ; sub_4CCC80+338j + mov eax, [esp+4Ch+arg_8] + sub eax, [esp+4Ch+arg_4] + mov ecx, [esp+4Ch+arg_C] + mov edx, [esp+4Ch+var_2C] + pop edi + mov [ecx], eax + mov eax, [esp+48h+arg_18] + pop esi + pop ebp + mov [eax], edx + xor eax, eax + pop ebx + add esp, 3Ch + retn +; --------------------------------------------------------------------------- + +loc_4CCFEF: ; CODE XREF: sub_4CCC80+31Cj + sub ecx, 6 + jmp short loc_4CCFA1 +; --------------------------------------------------------------------------- + +loc_4CCFF4: ; CODE XREF: sub_4CCC80+129j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov ecx, [esp+4Ch+var_30] + mov [ecx], bx + jnb short loc_4CD030 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD030: ; CODE XREF: sub_4CCC80+38Ej + movzx ebx, word ptr [edi+edx*2+180h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD096 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, ebx + mov [edi+edx*2+180h], cx + mov ecx, [esp+4Ch+var_28] + mov ebp, [esp+4Ch+var_1C] + mov [esp+4Ch+var_18], ecx + mov ecx, [esp+4Ch+var_24] + mov [esp+4Ch+var_28], ecx + mov ecx, [esp+4Ch+var_38] + mov [esp+4Ch+var_24], ecx + xor ecx, ecx + cmp edx, 7 + setl cl + sub ecx, 1 + and ecx, 3 + mov [esp+4Ch+var_34], ecx + lea ecx, [edi+664h] + jmp loc_4CD30B +; --------------------------------------------------------------------------- + +loc_4CD096: ; CODE XREF: sub_4CCC80+3C5j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov [edi+edx*2+180h], bx + jnb short loc_4CD0D3 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD0D3: ; CODE XREF: sub_4CCC80+431j + movzx ebx, word ptr [edi+edx*2+198h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + mov [esp+4Ch+arg_0], ebx + jnb loc_4CD1D3 + mov ebx, 800h + sub ebx, ebp + mov ebp, [esp+4Ch+var_1C] + sar ebx, 5 + add ebx, [esp+4Ch+arg_0] + mov eax, ecx + mov [edi+edx*2+198h], bx + lea ebx, [edx+0Fh] + shl ebx, 4 + add ebx, ebp + cmp ecx, 1000000h + lea ebx, [edi+ebx*2] + mov [esp+4Ch+var_30], ebx + jnb short loc_4CD147 + mov ebx, [esp+4Ch+arg_8] + cmp ebx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + shl ecx, 8 + mov eax, ecx + movzx ecx, byte ptr [ebx] + shl esi, 8 + or esi, ecx + add ebx, 1 + mov [esp+4Ch+arg_8], ebx + +loc_4CD147: ; CODE XREF: sub_4CCC80+4A3j + mov ecx, [esp+4Ch+var_30] + movzx ecx, word ptr [ecx] + mov [esp+4Ch+arg_0], ecx + movzx ebx, cx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebx + cmp esi, ecx + jnb short loc_4CD1B5 + mov edi, [esp+4Ch+var_30] + mov eax, ecx + mov ecx, 800h + sub ecx, ebx + sar ecx, 5 + add ecx, [esp+4Ch+arg_0] + mov [edi], cx + mov edi, [esp+4Ch+var_2C] + test edi, edi + jz loc_4CD6E2 + xor ecx, ecx + cmp edx, 7 + mov edx, [esp+4Ch+arg_10] + setnl cl + lea ecx, [ecx+ecx+9] + mov [esp+4Ch+var_34], ecx + mov ecx, edi + sub ecx, [esp+4Ch+var_38] + add edi, 1 + mov cl, [ecx+edx] + mov [edi+edx-1], cl + mov byte ptr [esp+4Ch+arg_0], cl + mov [esp+4Ch+var_2C], edi + jmp loc_4CCFA5 +; --------------------------------------------------------------------------- + +loc_4CD1B5: ; CODE XREF: sub_4CCC80+4DFj + sub eax, ecx + sub esi, ecx + mov ecx, [esp+4Ch+arg_0] + mov bx, cx + shr bx, 5 + sub cx, bx + mov ebx, [esp+4Ch+var_30] + mov [ebx], cx + jmp loc_4CD2F0 +; --------------------------------------------------------------------------- + +loc_4CD1D3: ; CODE XREF: sub_4CCC80+46Cj + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov [edi+edx*2+198h], bx + jnb short loc_4CD210 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD210: ; CODE XREF: sub_4CCC80+56Ej + movzx ebx, word ptr [edi+edx*2+1B0h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD246 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, ebx + mov [edi+edx*2+1B0h], cx + mov ecx, [esp+4Ch+var_24] + jmp loc_4CD2E0 +; --------------------------------------------------------------------------- + +loc_4CD246: ; CODE XREF: sub_4CCC80+5A5j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + cmp eax, 1000000h + mov [edi+edx*2+1B0h], bx + jnb short loc_4CD283 + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, ebx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD283: ; CODE XREF: sub_4CCC80+5E1j + movzx ebx, word ptr [edi+edx*2+1C8h] + movzx ebp, bx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD2B6 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, ebx + mov [edi+edx*2+1C8h], cx + mov ecx, [esp+4Ch+var_28] + jmp short loc_4CD2D8 +; --------------------------------------------------------------------------- + +loc_4CD2B6: ; CODE XREF: sub_4CCC80+618j + sub eax, ecx + sub esi, ecx + mov cx, bx + shr cx, 5 + sub bx, cx + mov ecx, [esp+4Ch+var_18] + mov [edi+edx*2+1C8h], bx + mov ebx, [esp+4Ch+var_28] + mov [esp+4Ch+var_18], ebx + +loc_4CD2D8: ; CODE XREF: sub_4CCC80+634j + mov ebx, [esp+4Ch+var_24] + mov [esp+4Ch+var_28], ebx + +loc_4CD2E0: ; CODE XREF: sub_4CCC80+5C1j + mov ebx, [esp+4Ch+var_38] + mov ebp, [esp+4Ch+var_1C] + mov [esp+4Ch+var_24], ebx + mov [esp+4Ch+var_38], ecx + +loc_4CD2F0: ; CODE XREF: sub_4CCC80+54Ej + xor ecx, ecx + cmp edx, 7 + setnl cl + sub ecx, 1 + and ecx, 0FFFFFFFDh + add ecx, 0Bh + mov [esp+4Ch+var_34], ecx + lea ecx, [edi+0A68h] + +loc_4CD30B: ; CODE XREF: sub_4CCC80+411j + cmp eax, 1000000h + jnb short loc_4CD332 + mov edx, [esp+4Ch+arg_8] + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edi, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, edi + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD332: ; CODE XREF: sub_4CCC80+690j + movzx edi, word ptr [ecx] + movzx ebx, di + mov edx, eax + shr edx, 0Bh + imul edx, ebx + cmp esi, edx + jnb short loc_4CD36E + mov eax, edx + mov edx, 800h + sub edx, ebx + sar edx, 5 + add edx, edi + mov [ecx], dx + shl ebp, 4 + lea ecx, [ecx+ebp+4] + mov [esp+4Ch+var_1C], 0 + mov edx, 3 + jmp loc_4CD409 +; --------------------------------------------------------------------------- + +loc_4CD36E: ; CODE XREF: sub_4CCC80+6C2j + sub eax, edx + sub esi, edx + mov dx, di + shr dx, 5 + sub di, dx + cmp eax, 1000000h + mov [ecx], di + jnb short loc_4CD3A6 + mov edx, [esp+4Ch+arg_8] + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edi, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, edi + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD3A6: ; CODE XREF: sub_4CCC80+704j + movzx edx, word ptr [ecx+2] + movzx ebx, dx + mov edi, eax + shr edi, 0Bh + imul edi, ebx + cmp esi, edi + jnb short loc_4CD3E4 + mov eax, edi + mov edi, 800h + sub edi, ebx + sar edi, 5 + add edi, edx + shl ebp, 4 + mov [ecx+2], di + lea ecx, [ecx+ebp+104h] + mov [esp+4Ch+var_1C], 8 + mov edx, 3 + jmp short loc_4CD409 +; --------------------------------------------------------------------------- + +loc_4CD3E4: ; CODE XREF: sub_4CCC80+737j + sub eax, edi + sub esi, edi + mov di, dx + shr di, 5 + sub dx, di + mov [ecx+2], dx + add ecx, 204h + mov [esp+4Ch+var_1C], 10h + mov edx, 8 + +loc_4CD409: ; CODE XREF: sub_4CCC80+6E9j + ; sub_4CCC80+762j + mov [esp+4Ch+arg_0], edx + mov [esp+4Ch+var_10], edx + mov ebx, 1 + jmp short loc_4CD420 +; --------------------------------------------------------------------------- + align 10h + +loc_4CD420: ; CODE XREF: sub_4CCC80+796j + ; sub_4CCC80+819j + cmp eax, 1000000h + mov edx, [esp+4Ch+arg_8] + lea edi, [ebx+ebx] + mov [esp+4Ch+var_30], edi + jnb short loc_4CD44E + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebp, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, ebp + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD44E: ; CODE XREF: sub_4CCC80+7B0j + movzx edi, word ptr [edi+ecx] + movzx ebp, di + mov edx, eax + shr edx, 0Bh + imul edx, ebp + cmp esi, edx + jnb short loc_4CD47B + mov eax, edx + mov edx, 800h + sub edx, ebp + sar edx, 5 + add edx, edi + mov edi, [esp+4Ch+var_30] + mov [edi+ecx], dx + add ebx, ebx + jmp short loc_4CD494 +; --------------------------------------------------------------------------- + +loc_4CD47B: ; CODE XREF: sub_4CCC80+7DFj + mov ebx, [esp+4Ch+var_30] + sub eax, edx + sub esi, edx + mov dx, di + shr dx, 5 + sub di, dx + mov [ebx+ecx], di + add ebx, 1 + +loc_4CD494: ; CODE XREF: sub_4CCC80+7F9j + sub [esp+4Ch+var_10], 1 + jnz short loc_4CD420 + mov ecx, [esp+4Ch+arg_0] + mov edx, 1 + shl edx, cl + mov ecx, [esp+4Ch+var_1C] + sub ecx, edx + add ebx, ecx + cmp [esp+4Ch+var_34], 4 + mov [esp+4Ch+var_4], ebx + jge loc_4CD69D + add [esp+4Ch+var_34], 7 + cmp ebx, 4 + jl short loc_4CD4CC + mov ebx, 3 + +loc_4CD4CC: ; CODE XREF: sub_4CCC80+845j + mov ecx, [esp+4Ch+var_20] + shl ebx, 7 + lea ecx, [ebx+ecx+360h] + mov [esp+4Ch+var_30], ecx + mov [esp+4Ch+arg_0], 6 + mov edi, 1 + jmp short loc_4CD4F0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CD4F0: ; CODE XREF: sub_4CCC80+86Bj + ; sub_4CCC80+8E3j + cmp eax, 1000000h + mov edx, [esp+4Ch+arg_8] + lea ebx, [edi+edi] + jnb short loc_4CD51A + cmp edx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx ebp, byte ptr [edx] + shl esi, 8 + shl eax, 8 + or esi, ebp + add edx, 1 + mov [esp+4Ch+arg_8], edx + +loc_4CD51A: ; CODE XREF: sub_4CCC80+87Cj + movzx edx, word ptr [ebx+ecx] + movzx ebp, dx + mov ecx, eax + shr ecx, 0Bh + imul ecx, ebp + cmp esi, ecx + jnb short loc_4CD545 + mov eax, ecx + mov ecx, 800h + sub ecx, ebp + sar ecx, 5 + add ecx, edx + mov [esp+4Ch+var_10], ecx + mov edx, ecx + add edi, edi + jmp short loc_4CD556 +; --------------------------------------------------------------------------- + +loc_4CD545: ; CODE XREF: sub_4CCC80+8ABj + sub eax, ecx + sub esi, ecx + mov cx, dx + shr cx, 5 + sub dx, cx + lea edi, [ebx+1] + +loc_4CD556: ; CODE XREF: sub_4CCC80+8C3j + sub [esp+4Ch+arg_0], 1 + mov ecx, [esp+4Ch+var_30] + mov [ebx+ecx], dx + jnz short loc_4CD4F0 + sub edi, 40h + cmp edi, 4 + jl loc_4CD68A + mov ebx, 1 + mov ecx, edi + mov edx, edi + sar ecx, 1 + and edx, ebx + sub ecx, ebx + or edx, 2 + cmp edi, 0Eh + mov [esp+4Ch+var_30], ecx + jge short loc_4CD5A1 + shl edx, cl + mov ecx, [esp+4Ch+var_20] + mov [esp+4Ch+var_38], edx + sub edx, edi + lea ebp, [ecx+edx*2+55Eh] + jmp short loc_4CD5F3 +; --------------------------------------------------------------------------- + +loc_4CD5A1: ; CODE XREF: sub_4CCC80+90Aj + mov edi, [esp+4Ch+arg_8] + sub ecx, 4 + +loc_4CD5A8: ; CODE XREF: sub_4CCC80+958j + cmp eax, 1000000h + jnb short loc_4CD5CA + cmp edi, [esp+4Ch+var_3C] + jz loc_4CD6EF + movzx ebp, byte ptr [edi] + shl esi, 8 + shl eax, 8 + or esi, ebp + add edi, ebx + mov [esp+4Ch+arg_8], edi + +loc_4CD5CA: ; CODE XREF: sub_4CCC80+92Dj + shr eax, 1 + add edx, edx + cmp esi, eax + jb short loc_4CD5D6 + sub esi, eax + or edx, ebx + +loc_4CD5D6: ; CODE XREF: sub_4CCC80+950j + sub ecx, ebx + jnz short loc_4CD5A8 + mov ebp, [esp+4Ch+var_20] + add ebp, 644h + shl edx, 4 + mov [esp+4Ch+var_38], edx + mov [esp+4Ch+var_30], 4 + +loc_4CD5F3: ; CODE XREF: sub_4CCC80+91Fj + mov [esp+4Ch+var_1C], ebx + mov [esp+4Ch+arg_0], ebx + jmp short loc_4CD600 +; --------------------------------------------------------------------------- + align 10h + +loc_4CD600: ; CODE XREF: sub_4CCC80+97Bj + ; sub_4CCC80+A02j + mov ebx, [esp+4Ch+arg_0] + add ebx, ebx + cmp eax, 1000000h + jnb short loc_4CD62D + mov ecx, [esp+4Ch+arg_8] + cmp ecx, [esp+4Ch+var_3C] + jz loc_4CD6E2 + movzx edx, byte ptr [ecx] + shl esi, 8 + shl eax, 8 + or esi, edx + add ecx, 1 + mov [esp+4Ch+arg_8], ecx + +loc_4CD62D: ; CODE XREF: sub_4CCC80+98Bj + movzx edi, word ptr [ebx+ebp] + movzx ecx, di + mov edx, eax + shr edx, 0Bh + imul edx, ecx + cmp esi, edx + jnb short loc_4CD658 + mov eax, edx + mov edx, 800h + sub edx, ecx + sar edx, 5 + add edx, edi + shl [esp+4Ch+arg_0], 1 + mov [ebx+ebp], dx + jmp short loc_4CD679 +; --------------------------------------------------------------------------- + +loc_4CD658: ; CODE XREF: sub_4CCC80+9BEj + mov cx, di + shr cx, 5 + sub di, cx + sub eax, edx + sub esi, edx + mov edx, [esp+4Ch+var_1C] + mov [ebx+ebp], di + add ebx, 1 + or [esp+4Ch+var_38], edx + mov [esp+4Ch+arg_0], ebx + +loc_4CD679: ; CODE XREF: sub_4CCC80+9D6j + shl [esp+4Ch+var_1C], 1 + sub [esp+4Ch+var_30], 1 + jnz loc_4CD600 + jmp short loc_4CD68E +; --------------------------------------------------------------------------- + +loc_4CD68A: ; CODE XREF: sub_4CCC80+8EBj + mov [esp+4Ch+var_38], edi + +loc_4CD68E: ; CODE XREF: sub_4CCC80+A08j + add [esp+4Ch+var_38], 1 + jz loc_4CCFB3 + mov ebx, [esp+4Ch+var_4] + +loc_4CD69D: ; CODE XREF: sub_4CCC80+837j + mov ebp, [esp+4Ch+var_2C] + mov ecx, [esp+4Ch+var_38] + add ebx, 2 + cmp ecx, ebp + ja short loc_4CD6E2 + mov edi, ebp + sub edi, ecx + add edi, [esp+4Ch+arg_10] + +loc_4CD6B4: ; CODE XREF: sub_4CCC80+A60j + mov cl, [edi] + mov edx, [esp+4Ch+arg_10] + sub ebx, 1 + mov [edx+ebp], cl + add ebp, 1 + add edi, 1 + test ebx, ebx + mov byte ptr [esp+4Ch+arg_0], cl + mov [esp+4Ch+var_2C], ebp + jz loc_4CCFA5 + cmp ebp, [esp+4Ch+arg_14] + jnb loc_4CCFB3 + jmp short loc_4CD6B4 +; --------------------------------------------------------------------------- + +loc_4CD6E2: ; CODE XREF: sub_4CCC80+101j + ; sub_4CCC80+1C9j ... + pop edi + pop esi + pop ebp + mov eax, 1 + pop ebx + add esp, 3Ch + retn +; --------------------------------------------------------------------------- + +loc_4CD6EF: ; CODE XREF: sub_4CCC80+933j + pop edi + pop esi + pop ebp + mov eax, ebx + pop ebx + add esp, 3Ch + retn +sub_4CCC80 endp + +_starcraft_decompress_lzma PROC +;sub_4CD700 + +var_14 = byte ptr -14h +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +pbInBuffer = dword ptr 4 +cbInBuffer = dword ptr 8 +pbOutBuffer = dword ptr 0Ch +cbOutBuffer = dword ptr 10h +pcbOutBuffer = dword ptr 14h +pfnAllocateMemory= dword ptr 18h +pfnFreeMemory = dword ptr 1Ch + + sub esp, 14h + push ebx + mov ebx, [esp+18h+cbInBuffer] + cmp ebx, 0Eh ; LZMA_PROPS_SIZE + 8 + jnb short loc_4CD714 + xor al, al + pop ebx + add esp, 14h + retn +; --------------------------------------------------------------------------- + +loc_4CD714: ; CODE XREF: Decompress_lzma_internal+Bj + push ebp + mov ebp, [esp+1Ch+pcbOutBuffer] + push edi + mov edi, [esp+20h+pbInBuffer] + mov dword ptr [ebp+0], 0 + cmp byte ptr [edi], 0 + jnz short loc_4CD741 + push 5 + lea eax, [edi+1] + push eax + lea ecx, [esp+28h+var_10] + push ecx + call LzmaProps_Decode + add esp, 0Ch + test eax, eax + jz short loc_4CD74A + +loc_4CD741: ; CODE XREF: Decompress_lzma_internal+28j + pop edi + pop ebp + xor al, al + pop ebx + add esp, 14h + retn +; --------------------------------------------------------------------------- + +loc_4CD74A: ; CODE XREF: Decompress_lzma_internal+3Fj + mov edx, [esp+20h+var_10] + mov eax, [esp+20h+var_C] + lea ecx, [eax+edx] + mov edx, 300h + shl edx, cl + push esi + lea eax, [edx+edx+0E6Ch] + push eax + call [esp+28h+pfnAllocateMemory] + mov esi, eax + add esp, 4 + test esi, esi + mov [esp+24h+var_4], esi + jz short loc_4CD7AA + mov edx, [esp+24h+cbOutBuffer] + mov eax, [esp+24h+pbOutBuffer] + lea ecx, [esp+24h+cbInBuffer] + push ecx ; cbInBuffer + push edx ; cbOutBuffer + push eax ; pbOutBuffer + lea ecx, [esp+30h+var_14] + push ecx ; &var_14 + add ebx, 0FFFFFFF2h + push ebx ; cbInBuffer - LZMA86_HEADER_SIZE + add edi, 0Eh + lea edx, [esp+38h+var_10] + push edi ; pbInBuffer + LZMA86_HEADER_SIZE + push edx ; dest + call sub_4CCC80 + push esi + mov edi, eax + call [esp+44h+pfnFreeMemory] + add esp, 20h + test edi, edi + jz short loc_4CD7B4 + +loc_4CD7AA: ; CODE XREF: Decompress_lzma_internal+74j + pop esi + pop edi + pop ebp + xor al, al + pop ebx + add esp, 14h + retn +; --------------------------------------------------------------------------- + +loc_4CD7B4: ; CODE XREF: Decompress_lzma_internal+A8j + mov eax, [esp+24h+cbInBuffer] + pop esi + pop edi + mov [ebp+0], eax + pop ebp + mov al, 1 + pop ebx + add esp, 14h + retn +_starcraft_decompress_lzma ENDP + +; =============== S U B R O U T I N E ======================================= + +sub_4CD7D0 proc near ; CODE XREF: sub_4CDC00+74p + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + or esi, 8 + xor eax, eax + cmp esi, 1 + jz short loc_4CD806 + push edi + +loc_4CD7E0: ; CODE XREF: sub_4CD7D0+33j + mov edx, esi + shr esi, 1 + mov edi, [ecx+esi*4] + and edx, 1 + sub edi, edx + neg edx + xor edi, edx + shr edi, 2 + and edi, 1FFh + add eax, dword_550998[edi*4] + cmp esi, 1 + jnz short loc_4CD7E0 + pop edi + +loc_4CD806: ; CODE XREF: sub_4CD7D0+Dj + pop esi + retn 4 +sub_4CD7D0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD810 proc near ; CODE XREF: CEncoder_FillAlignPrices+17p + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 + + push ecx + push ebx + push ebp + push esi + xor eax, eax + push edi + mov edi, [esp+14h+arg_0] + mov [esp+14h+var_4], ecx + lea esi, [eax+1] + lea ebx, [eax+4] + +loc_4CD825: ; CODE XREF: sub_4CD810+42j + mov ecx, [esp+14h+var_4] + mov ecx, [ecx+esi*4] + mov edx, edi + and edx, 1 + sub ecx, edx + mov ebp, edx + neg ebp + xor ecx, ebp + shr ecx, 2 + and ecx, 1FFh + add eax, dword_550998[ecx*4] + add esi, esi + shr edi, 1 + or esi, edx + sub ebx, 1 + jnz short loc_4CD825 + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn 4 +sub_4CD810 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD860 proc near ; CODE XREF: CEncoder_FillDistancesPrices+6Bp + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push edi + mov edi, [esp+4+arg_4] + xor eax, eax + test edi, edi + lea edx, [eax+1] + jz short loc_4CD8A7 + push ebx + push ebp + push esi + mov esi, [esp+10h+arg_8] + +loc_4CD875: ; CODE XREF: sub_4CD860+42j + mov ebx, [esp+10h+arg_0] + mov ebx, [ebx+edx*4] + mov ecx, esi + and ecx, 1 + sub ebx, ecx + mov ebp, ecx + neg ebp + xor ebx, ebp + shr ebx, 2 + and ebx, 1FFh + add eax, dword_550998[ebx*4] + add edx, edx + shr esi, 1 + or edx, ecx + sub edi, 1 + jnz short loc_4CD875 + pop esi + pop ebp + pop ebx + +loc_4CD8A7: ; CODE XREF: sub_4CD860+Cj + pop edi + retn +sub_4CD860 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD8B0 proc near ; CODE XREF: CEncoder_CodeOneBlock+7B8p + mov eax, [ecx+24h] + mov edx, [ecx+1Ch] + push ebx + push esi + mov esi, [ecx+30h] + xor ebx, ebx + push edi + mov edi, [ecx+34h] + sub esi, eax + sbb edi, ebx + add esi, edx + adc edi, ebx + cmp eax, edx + jbe short loc_4CD8D4 + mov eax, [ecx+28h] + add esi, eax + adc edi, ebx + +loc_4CD8D4: ; CODE XREF: sub_4CD8B0+1Bj + mov eax, [ecx] + xor edx, edx + add eax, esi + adc edx, edi + pop edi + add eax, 4 + pop esi + adc edx, ebx + pop ebx + retn +sub_4CD8B0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CD8F0 proc near ; CODE XREF: sub_4CD940+21p + ; .text:loc_4CF730j ... + mov eax, dword_553598 + test eax, eax + push esi + mov esi, ecx + push edi + mov edi, [esi] + jnz short loc_4CD92A + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + test eax, eax + jz short loc_4CD923 + mov dword ptr [eax], 0 + mov dword ptr [eax+4], 0 + mov dword ptr [eax+8], 0 + jmp short loc_4CD925 +; --------------------------------------------------------------------------- + +loc_4CD923: ; CODE XREF: sub_4CD8F0+1Bj + xor eax, eax + +loc_4CD925: ; CODE XREF: sub_4CD8F0+31j + mov dword_553598, eax + +loc_4CD92A: ; CODE XREF: sub_4CD8F0+Dj + mov eax, [eax+4] + test eax, eax + jz short loc_4CD937 + push edi + call eax + add esp, 4 + +loc_4CD937: ; CODE XREF: sub_4CD8F0+3Fj + pop edi + mov dword ptr [esi], 0 + pop esi + retn +sub_4CD8F0 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CD940 proc near ; CODE XREF: sub_4D0270+74p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + mov ebx, [esp+4+arg_4] + push esi + mov esi, ecx + cmp dword ptr [esi], 0 + push edi + mov edi, [esp+0Ch+arg_0] + jz short loc_4CD95F + mov eax, [esi+8] + add eax, [esi+4] + lea ecx, [edi+ebx] + cmp ecx, eax + jz short loc_4CD981 + +loc_4CD95F: ; CODE XREF: sub_4CD940+10j + mov ecx, esi + call sub_4CD8F0 + lea ecx, [edi+ebx] + mov edx, 1 + shl edx, cl + imul edx, 0C00h + push edx + call sub_4CB8A0 + add esp, 4 + mov [esi], eax + +loc_4CD981: ; CODE XREF: sub_4CD940+1Dj + mov ecx, edi + mov eax, 1 + shl eax, cl + mov [esi+8], edi + pop edi + mov [esi+4], ebx + sub eax, 1 + mov [esi+0Ch], eax + xor eax, eax + cmp [esi], eax + pop esi + setnz al + pop ebx + retn 8 +sub_4CD940 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CD9B0 proc near ; CODE XREF: CEncoder_GetOptimum+436p + ; CEncoder_GetOptimum+AE1p + +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = dword ptr 0Ch + + mov edx, [esp+arg_0] + test edx, edx + push esi + jnz short loc_4CD9F2 + movzx eax, [esp+4+arg_4] + mov edx, eax + shl edx, 4 + add edx, [esp+4+arg_8] + mov esi, 800h + sub esi, [ecx+edx*4+284B0h] + mov ecx, [ecx+eax*4+28420h] + shr esi, 2 + mov eax, dword_550998[esi*4] + shr ecx, 2 + add eax, dword_550998[ecx*4] + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CD9F2: ; CODE XREF: sub_4CD9B0+7j + movzx esi, [esp+4+arg_4] + mov eax, 800h + sub eax, [ecx+esi*4+28420h] + shr eax, 2 + cmp edx, 1 + mov eax, dword_550998[eax*4] + jnz short loc_4CDA27 + mov ecx, [ecx+esi*4+28450h] + shr ecx, 2 + add eax, dword_550998[ecx*4] + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CDA27: ; CODE XREF: sub_4CD9B0+60j + push edi + add edx, 0FFFFFFFEh + mov edi, 800h + sub edi, [ecx+esi*4+28450h] + mov ecx, [ecx+esi*4+28480h] + sub ecx, edx + neg edx + xor ecx, edx + shr edi, 2 + mov edx, dword_550998[edi*4] + shr ecx, 2 + and ecx, 1FFh + add edx, dword_550998[ecx*4] + pop edi + add eax, edx + pop esi + retn 0Ch +sub_4CD9B0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CDA70 proc near ; CODE XREF: CEncoder_CodeReal+10Cp + ; CEncoder_CodeReal+134p ... + push esi + mov esi, [ecx] + cmp dword ptr [esi+80h], 0 + jz short loc_4CDA8C + cmp byte ptr [esi+33B95h], 0 + jz short loc_4CDA8C + mov byte ptr [esi+33B95h], 0 + +loc_4CDA8C: ; CODE XREF: sub_4CDA70+Aj + ; sub_4CDA70+13j + mov eax, [esi+33B8Ch] + test eax, eax + jz short loc_4CDAA8 + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + mov dword ptr [esi+33B8Ch], 0 + +loc_4CDAA8: ; CODE XREF: sub_4CDA70+24j + mov ecx, [esi+4] + mov edx, [ecx+10h] + lea eax, [esi+4] + push eax + call edx + pop esi + retn +sub_4CDA70 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CDAC0 proc near ; CODE XREF: CEncoder_GetOptimum+2C4p + ; CEncoder_GetOptimum+7ACp ... + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = byte ptr 0Ch + + push ecx + push ebx + push ebp + xor ebp, ebp + cmp byte ptr [esp+0Ch+arg_0], 0 + push esi + mov eax, ecx + push edi + mov [esp+14h+var_4], eax + lea edi, [ebp+1] + lea ebx, [ebp+8] + jz short loc_4CDB3B + movzx ecx, [esp+14h+arg_8] + mov [esp+14h+arg_0], ecx + +loc_4CDAE3: ; CODE XREF: sub_4CDAC0+71j + movzx esi, [esp+14h+arg_4] + mov edx, [esp+14h+arg_0] + sub ebx, 1 + movzx ecx, bl + shr esi, cl + shr edx, cl + and esi, 1 + mov ecx, esi + shl ecx, 8 + add ecx, edi + mov eax, [eax+ecx*4+400h] + and edx, 1 + sub eax, edx + mov ecx, edx + neg ecx + xor eax, ecx + shr eax, 2 + and eax, 1FFh + add ebp, dword_550998[eax*4] + add edi, edi + or edi, edx + cmp esi, edx + jnz short loc_4CDB33 + test ebx, ebx + jz short loc_4CDB75 + mov eax, [esp+14h+var_4] + jmp short loc_4CDAE3 +; --------------------------------------------------------------------------- + +loc_4CDB33: ; CODE XREF: sub_4CDAC0+67j + test ebx, ebx + jz short loc_4CDB75 + mov eax, [esp+14h+var_4] + +loc_4CDB3B: ; CODE XREF: sub_4CDAC0+18j + movzx edx, [esp+14h+arg_8] + mov [esp+14h+arg_0], edx + +loc_4CDB44: ; CODE XREF: sub_4CDAC0+B3j + mov edx, [esp+14h+arg_0] + sub ebx, 1 + mov cl, bl + shr edx, cl + mov ecx, [eax+edi*4] + add edi, edi + and edx, 1 + sub ecx, edx + mov esi, edx + neg esi + xor ecx, esi + shr ecx, 2 + and ecx, 1FFh + add ebp, dword_550998[ecx*4] + or edi, edx + test ebx, ebx + jnz short loc_4CDB44 + +loc_4CDB75: ; CODE XREF: sub_4CDAC0+6Bj + ; sub_4CDAC0+75j + pop edi + pop esi + mov eax, ebp + pop ebp + pop ebx + pop ecx + retn 0Ch +sub_4CDAC0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CDB80 proc near ; CODE XREF: sub_4CDEA0+11Ep + ; sub_4CDEA0+137p + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + test esi, esi + mov edx, 400h + push edi + mov [ecx], edx + mov [ecx+4], edx + jbe short loc_4CDBE6 + lea eax, [ecx+20Ch] + lea ebx, [ebx+0] + +loc_4CDBA0: ; CODE XREF: sub_4CDB80+64j + mov [eax-200h], edx + mov [eax-1FCh], edx + mov [eax-1F8h], edx + mov [eax-1F4h], edx + mov [eax-1F0h], edx + mov [eax-1ECh], edx + mov [eax-1E8h], edx + mov [eax], edx + mov [eax+4], edx + mov [eax+8], edx + mov [eax+0Ch], edx + mov [eax+10h], edx + mov [eax+14h], edx + mov [eax+18h], edx + add eax, 20h + sub esi, 1 + jnz short loc_4CDBA0 + +loc_4CDBE6: ; CODE XREF: sub_4CDB80+12j + lea edi, [ecx+40Ch] + mov ecx, 0FFh + mov eax, edx + rep stosd + pop edi + pop esi + retn 4 +sub_4CDB80 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CDC00 proc near ; CODE XREF: sub_4CF740+22p + ; sub_4CF780+2Bp + +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + sub esp, 0Ch + push ebx + push ebp + push esi + push edi + mov edi, ecx + mov eax, [edi] + mov ebx, [esp+1Ch+arg_0] + mov ecx, eax + shr ecx, 2 + mov edx, dword_550998[ecx*4] + mov ecx, 800h + sub ecx, eax + shr ecx, 2 + mov eax, dword_550998[ecx*4] + mov ecx, [edi+4] + mov [esp+1Ch+var_C], edx + mov edx, ecx + shr edx, 2 + mov ebp, dword_550998[edx*4] + mov edx, 800h + sub edx, ecx + shr edx, 2 + mov ecx, dword_550998[edx*4] + add ebp, eax + add ecx, eax + mov [esp+1Ch+var_8], ebp + mov [esp+1Ch+var_4], ecx + xor esi, esi + mov edi, edi + +loc_4CDC60: ; CODE XREF: sub_4CDC00+8Aj + cmp esi, [esp+1Ch+arg_4] + jnb loc_4CDD62 + mov eax, ebx + shl eax, 5 + push esi + lea ecx, [eax+edi+8] + call sub_4CD7D0 + add eax, [esp+1Ch+var_C] + mov ecx, [esp+1Ch+arg_8] + mov [ecx+esi*4], eax + add esi, 1 + cmp esi, 8 + jb short loc_4CDC60 + cmp esi, 10h + jnb short loc_4CDD00 + lea ecx, [esi-8] + mov [esp+1Ch+arg_0], ecx + jmp short loc_4CDCA0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CDCA0: ; CODE XREF: sub_4CDC00+98j + ; sub_4CDC00+FEj + cmp esi, [esp+1Ch+arg_4] + jnb loc_4CDD62 + or ecx, 8 + xor edx, edx + cmp ecx, 1 + jz short loc_4CDCE4 + +loc_4CDCB4: ; CODE XREF: sub_4CDC00+DEj + mov eax, ecx + shr ecx, 1 + and eax, 1 + lea ebp, [ecx+ebx*8] + mov ebp, [edi+ebp*4+208h] + sub ebp, eax + neg eax + xor ebp, eax + shr ebp, 2 + and ebp, 1FFh + add edx, dword_550998[ebp*4] + cmp ecx, 1 + jnz short loc_4CDCB4 + mov ebp, [esp+1Ch+var_8] + +loc_4CDCE4: ; CODE XREF: sub_4CDC00+B2j + mov eax, [esp+1Ch+arg_8] + mov ecx, [esp+1Ch+arg_0] + add edx, ebp + mov [eax+esi*4], edx + add esi, 1 + add ecx, 1 + cmp esi, 10h + mov [esp+1Ch+arg_0], ecx + jb short loc_4CDCA0 + +loc_4CDD00: ; CODE XREF: sub_4CDC00+8Fj + cmp esi, [esp+1Ch+arg_4] + jnb short loc_4CDD62 + lea ebx, [esi-10h] + lea esp, [esp+0] + +loc_4CDD10: ; CODE XREF: sub_4CDC00+160j + mov ecx, ebx + or ecx, 100h + xor edx, edx + cmp ecx, 1 + jz short loc_4CDD49 + nop + +loc_4CDD20: ; CODE XREF: sub_4CDC00+147j + mov eax, ecx + shr ecx, 1 + mov ebp, [edi+ecx*4+408h] + and eax, 1 + sub ebp, eax + neg eax + xor ebp, eax + shr ebp, 2 + and ebp, 1FFh + add edx, dword_550998[ebp*4] + cmp ecx, 1 + jnz short loc_4CDD20 + +loc_4CDD49: ; CODE XREF: sub_4CDC00+11Dj + mov ecx, [esp+1Ch+var_4] + mov eax, [esp+1Ch+arg_8] + add edx, ecx + mov [eax+esi*4], edx + add esi, 1 + add ebx, 1 + cmp esi, [esp+1Ch+arg_4] + jb short loc_4CDD10 + +loc_4CDD62: ; CODE XREF: sub_4CDC00+64j + ; sub_4CDC00+A4j ... + pop edi + pop esi + pop ebp + pop ebx + add esp, 0Ch + retn 0Ch +sub_4CDC00 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +; int __cdecl sub_4CDD70(SIZE_T dwSize) +sub_4CDD70 proc near ; DATA XREF: .data:off_546E20o + +dwSize = dword ptr 4 + + mov eax, [esp+dwSize] + test eax, eax + jnz short loc_4CDD79 + retn +; --------------------------------------------------------------------------- + +loc_4CDD79: ; CODE XREF: sub_4CDD70+6j + push 4 ; flProtect + push 1000h ; flAllocationType + push eax ; dwSize + push 0 ; lpAddress + call ds:VirtualAlloc + retn +sub_4CDD70 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +; int __cdecl sub_4CDD90(void * lpAddress) +sub_4CDD90 proc near ; CODE XREF: sub_4CF810+53p + ; sub_4CF810+73p + ; DATA XREF: ... + +lpAddress = dword ptr 4 + + mov eax, [esp+lpAddress] + test eax, eax + jz short locret_4CDDA6 + push 8000h ; dwFreeType + push 0 ; dwSize + push eax ; lpAddress + call ds:VirtualFree + +locret_4CDDA6: ; CODE XREF: sub_4CDD90+6j + retn +sub_4CDD90 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CDDB0 proc near ; DATA XREF: .rdata:00517AC8o + +var_10 = dword ptr -10h +var_C = byte ptr -0Ch +var_B = byte ptr -0Bh +var_A = byte ptr -0Ah +var_9 = byte ptr -9 +var_8 = byte ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 10h + mov eax, dword_544960 + xor eax, esp + mov [esp+10h+var_4], eax + mov ecx, [esp+10h+arg_0] + mov al, [ecx+33B50h] + mov dl, 5 + imul dl + add al, [ecx+33B58h] + mov dl, 9 + imul dl + add al, [ecx+33B5Ch] + push ebp + mov ebp, [esp+14h+arg_4] + mov [esp+14h+var_C], al + mov eax, [ecx+33B60h] + mov ecx, eax + mov edx, eax + push esi + shr ecx, 8 + shr edx, 10h + mov [esp+18h+var_B], al + shr eax, 18h + push edi + mov [esp+1Ch+var_A], cl + mov [esp+1Ch+var_9], dl + mov [esp+1Ch+var_8], al + mov esi, 5 + lea edi, [esp+1Ch+var_C] + +loc_4CDE13: ; CODE XREF: sub_4CDDB0+85j + mov eax, [ebp+0] + mov edx, [eax+0Ch] + lea ecx, [esp+1Ch+var_10] + push ecx + push esi + push edi + push ebp + call edx + mov ecx, [esp+1Ch+var_10] + add edi, ecx + sub esi, ecx + test eax, eax + jnz short loc_4CDE37 + test ecx, ecx + jz short loc_4CDE4B + test esi, esi + jnz short loc_4CDE13 + +loc_4CDE37: ; CODE XREF: sub_4CDDB0+7Dj + pop edi + pop esi + pop ebp + mov ecx, [esp+10h+var_4] + xor ecx, esp + call sub_4A0686 + add esp, 10h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CDE4B: ; CODE XREF: sub_4CDDB0+81j + mov ecx, [esp+1Ch+var_4] + pop edi + pop esi + pop ebp + xor ecx, esp + mov eax, 80004005h + call sub_4A0686 + add esp, 10h + retn 8 +sub_4CDDB0 endp + + align 10h + +; =============== S U B R O U T I N E ======================================= + +sub_4CDE70 proc near ; DATA XREF: .rdata:00517AF4o + +arg_0 = dword ptr 4 + + push esi + mov esi, [esp+4+arg_0] + mov eax, [esi+50h] + test eax, eax + jz short loc_4CDE8B + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + mov dword ptr [esi+50h], 0 + +loc_4CDE8B: ; CODE XREF: sub_4CDE70+Aj + xor eax, eax + pop esi + retn 4 +sub_4CDE70 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CDEA0 proc near ; CODE XREF: CEncoder_SetStreams+3Cp + +var_4 = dword ptr -4 + + push ecx + push ebx + xor ebx, ebx + push ebp + push esi + mov esi, ecx + mov byte ptr [esi+10h], 0 + mov byte ptr [esi+11h], 0 + mov [esi+14h], ebx + mov [esi+18h], ebx + mov [esi+1Ch], ebx + mov [esi+20h], ebx + mov eax, [esi+50h] + mov [esi+4Ch], ebx + mov [esi+48h], eax + mov [esi+44h], ebx + mov [esi+58h], ebx + mov [esi+5Ch], ebx + mov [esi+64h], bl + push edi + mov [esi+30h], ebx + mov [esi+34h], ebx + mov dword ptr [esi+38h], 0FFFFFFFFh + mov dword ptr [esi+28h], 1 + mov [esi+2Ch], bl + lea ecx, [esi+28420h] + lea edi, [esi+284B0h] + mov [esp+14h+var_4], 0Ch + mov ebp, 400h + +loc_4CDF02: ; CODE XREF: sub_4CDEA0+9Cj + xor edx, edx + mov eax, edi + jmp short loc_4CDF10 +; --------------------------------------------------------------------------- + align 10h + +loc_4CDF10: ; CODE XREF: sub_4CDEA0+66j + ; sub_4CDEA0+84j + mov [eax-3C0h], ebp + mov [eax], ebp + add edx, 1 + add eax, 4 + cmp edx, [esi+33B60h] + jbe short loc_4CDF10 + mov [ecx-30h], ebp + mov [ecx], ebp + mov [ecx+30h], ebp + mov [ecx+60h], ebp + add ecx, 4 + add edi, 40h + sub [esp+14h+var_4], 1 + jnz short loc_4CDF02 + mov ecx, [esi+32658h] + add ecx, [esi+32654h] + mov eax, 1 + shl eax, cl + cmp eax, ebx + jbe short loc_4CDF7C + xor edx, edx + mov ebx, eax + lea esp, [esp+0] + +loc_4CDF60: ; CODE XREF: sub_4CDEA0+DAj + mov edi, [esi+32650h] + add edi, edx + mov ecx, 300h + mov eax, ebp + add edx, 0C00h + sub ebx, 1 + rep stosd + jnz short loc_4CDF60 + +loc_4CDF7C: ; CODE XREF: sub_4CDEA0+B3j + lea edx, [esi+287B4h] + mov ebx, 4 + +loc_4CDF87: ; CODE XREF: sub_4CDEA0+FBj + mov edi, edx + mov ecx, 3Fh + mov eax, ebp + add edx, 100h + sub ebx, 1 + rep stosd + jnz short loc_4CDF87 + lea edi, [esi+28BB0h] + mov ecx, 72h + rep stosd + mov ecx, [esi+33B5Ch] + mov edx, 1 + shl edx, cl + lea ecx, [esi+28DB8h] + push edx + call sub_4CDB80 + mov ecx, [esi+33B5Ch] + mov eax, 1 + shl eax, cl + lea ecx, [esi+2DA04h] + push eax + call sub_4CDB80 + mov eax, ebp + mov [esi+28D7Ch], eax + mov [esi+28D80h], eax + mov [esi+28D84h], eax + mov [esi+28D88h], eax + mov [esi+28D8Ch], eax + mov [esi+28D90h], eax + mov [esi+28D94h], eax + mov [esi+28D98h], eax + mov [esi+28D9Ch], eax + mov [esi+28DA0h], eax + mov [esi+28DA4h], eax + mov [esi+28DA8h], eax + mov [esi+28DACh], eax + mov [esi+28DB0h], eax + mov [esi+28DB4h], eax + xor eax, eax + pop edi + mov [esi+32F10h], bl + mov [esi+32F08h], eax + mov [esi+32F0Ch], eax + mov [esi+32F04h], eax + pop esi + pop ebp + pop ebx + pop ecx + retn +sub_4CDEA0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF450 proc near ; CODE XREF: .text:004CF692p + ; CEncoder_Flush+42p + +var_8 = dword ptr -8 +var_4 = dword ptr -4 + + sub esp, 8 + push esi + mov esi, ecx + mov eax, [esi+0Ch] + push edi + mov edi, [esi+4] + cmp eax, edi + jb short loc_4CF464 + mov edi, [esi+10h] + +loc_4CF464: ; CODE XREF: sub_4CF450+Fj + push ebp + mov ebp, [esi+20h] + xor edx, edx + sub edi, eax + cmp ebp, edx + mov [esp+14h+var_4], edx + jz short loc_4CF4BA + push ebx + mov ebx, [esi] + add ebx, eax + mov eax, dword_553598 + cmp eax, edx + jnz short loc_4CF4A5 + push 0Ch ; Size + call _operator_new ; operator new(uint) + xor ecx, ecx + add esp, 4 + cmp eax, ecx + jz short loc_4CF49C + mov [eax], ecx + mov [eax+4], ecx + mov [eax+8], ecx + jmp short loc_4CF49E +; --------------------------------------------------------------------------- + +loc_4CF49C: ; CODE XREF: sub_4CF450+40j + xor eax, eax + +loc_4CF49E: ; CODE XREF: sub_4CF450+4Aj + mov dword_553598, eax + xor edx, edx + +loc_4CF4A5: ; CODE XREF: sub_4CF450+30j + mov eax, [eax+8] + cmp eax, edx + jz short loc_4CF4B6 + push edi + push ebx + push ebp + call eax + add esp, 0Ch + xor edx, edx + +loc_4CF4B6: ; CODE XREF: sub_4CF450+5Aj + add [esi+20h], edi + pop ebx + +loc_4CF4BA: ; CODE XREF: sub_4CF450+22j + mov eax, [esi+14h] + cmp eax, edx + pop ebp + jz short loc_4CF4E4 + mov [esp+10h+var_8], edx + mov ecx, [eax] + lea edx, [esp+10h+var_8] + push edx + mov edx, [esi] + add edx, [esi+0Ch] + push edi + push edx + push eax + mov eax, [ecx+0Ch] + call eax + mov edi, [esp+10h+var_8] + mov [esp+10h+var_4], eax + xor edx, edx + +loc_4CF4E4: ; CODE XREF: sub_4CF450+70j + add [esi+0Ch], edi + mov ecx, [esi+0Ch] + mov eax, [esi+10h] + cmp ecx, eax + jnz short loc_4CF4F4 + mov [esi+0Ch], edx + +loc_4CF4F4: ; CODE XREF: sub_4CF450+9Fj + cmp [esi+4], eax + jnz short loc_4CF500 + mov byte ptr [esi+24h], 1 + mov [esi+4], edx + +loc_4CF500: ; CODE XREF: sub_4CF450+A7j + mov ecx, [esi+0Ch] + cmp ecx, [esi+4] + jbe short loc_4CF50A + mov eax, ecx + +loc_4CF50A: ; CODE XREF: sub_4CF450+B6j + add [esi+18h], edi + mov [esi+8], eax + mov eax, [esp+10h+var_4] + adc [esi+1Ch], edx + pop edi + pop esi + add esp, 8 + retn +sub_4CF450 endp + +; --------------------------------------------------------------------------- + align 10h + + +; --------------------------------------------------------------------------- + +; int __stdcall Interface1_QueryInterface(int, void *Buf1, int) +Interface1_QueryInterface proc near ; DATA XREF: .rdata:off_517A90o +; sub_4CF520 + +arg_0 = dword ptr 4 +Buf1 = dword ptr 8 +arg_8 = dword ptr 0Ch + + mov eax, [esp+Buf1] + push offset dword_512730 ; Buf2 + push eax ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF54D + mov eax, [esp+arg_0] + mov ecx, [esp+arg_8] + mov [ecx], eax + mov edx, [eax] + push eax + mov eax, [edx+4] + call eax + xor eax, eax + retn 0Ch +loc_4CF54D: ; CODE XREF: Interface1_QueryInterface+14j + mov eax, 80004002h + retn 0Ch +Interface1_QueryInterface endp + +; --------------------------------------------------------------------------- + +; int __stdcall Interface1_Release(void *pUnknown) +Interface1_Release proc near ; DATA XREF: .rdata:00517A98o + +pUnknown = dword ptr 4 + + mov ecx, [esp+pUnknown] + add dword ptr [ecx+4], 0FFFFFFFFh + mov eax, [ecx+4] + jnz short locret_4CF585 + push ecx ; Memory + mov dword ptr [ecx], offset off_517A90 + mov dword ptr [ecx+8], 0 + call j__free + add esp, 4 + xor eax, eax + +locret_4CF585: ; CODE XREF: Interface1_Release+Bj + retn 4 +Interface1_Release endp + +; --------------------------------------------------------------------------- + +sub_4CF590 proc near ; DATA XREF: .rdata:00517AB4o + +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + mov eax, [esp+arg_0] + mov edx, [eax+10h] + sub edx, [eax+18h] + mov ecx, [eax+14h] + sbb ecx, [eax+1Ch] + push ebx + mov ebx, [esp+4+arg_8] + push edi + mov edi, [esp+8+arg_C] + cmp edi, ecx + jb short loc_4CF5C2 + ja short loc_4CF5B4 + cmp ebx, edx + jbe short loc_4CF5C2 + +loc_4CF5B4: ; CODE XREF: sub_4CF590+1Ej + pop edi + mov byte ptr [eax+20h], 1 + mov eax, 80004005h + pop ebx + retn 10h +; --------------------------------------------------------------------------- + +loc_4CF5C2: ; CODE XREF: sub_4CF590+1Cj + ; sub_4CF590+22j + push esi + xor esi, esi + xor ecx, ecx + test edi, edi + jb short loc_4CF5FA + ja short loc_4CF5D1 + test ebx, ebx + jbe short loc_4CF5FA + +loc_4CF5D1: ; CODE XREF: sub_4CF590+3Bj + mov dl, [esp+0Ch+arg_4] + push ebp + +loc_4CF5D6: ; CODE XREF: sub_4CF590+5Fj + ; sub_4CF590+67j + mov ebp, [eax+18h] + mov ebx, [eax+8] + mov [ebx+ebp], dl + add dword ptr [eax+18h], 1 + adc dword ptr [eax+1Ch], 0 + add esi, 1 + adc ecx, 0 + cmp ecx, edi + jb short loc_4CF5D6 + ja short loc_4CF5F9 + cmp esi, [esp+10h+arg_8] + jb short loc_4CF5D6 + +loc_4CF5F9: ; CODE XREF: sub_4CF590+61j + pop ebp + +loc_4CF5FA: ; CODE XREF: sub_4CF590+39j + ; sub_4CF590+3Fj + pop esi + pop edi + xor eax, eax + pop ebx + retn 10h +sub_4CF590 endp + +; =============== S U B R O U T I N E ======================================= + +; int __stdcall Interface2_Release(void *pUnknown) +Interface2_Release proc near ; DATA XREF: .rdata:00517AACo +; sub_4CF610 + +pUnknown = dword ptr 4 + + mov ecx, [esp+pUnknown] + add dword ptr [ecx+4], 0FFFFFFFFh + mov eax, [ecx+4] + jnz short locret_4CF635 + push ecx ; Memory + mov dword ptr [ecx], offset off_517AA4 + mov dword ptr [ecx+8], 0 + call j__free + add esp, 4 + xor eax, eax + +locret_4CF635: ; CODE XREF: Interface2_Release+Bj + retn 4 +Interface2_Release endp + +; =============== S U B R O U T I N E ======================================= + +loc_4CF640: ; CODE XREF: sub_4CF6E0+39p + ; sub_4CFAC0+57p ... + push ecx + push ebx + push esi + push edi + mov edi, ecx + mov esi, [edi+8] + cmp esi, 0FF000000h + jb short loc_4CF661 + mov edx, [edi+0Ch] + mov eax, esi + mov cl, 20h + call __allshr ; Microsoft VisualC 2-8/net runtime + test eax, eax + jz short loc_4CF6B6 + +loc_4CF661: ; CODE XREF: .text:004CF64Fj + mov bl, [edi+4] + lea esi, [edi+18h] + +loc_4CF667: ; CODE XREF: .text:004CF6A9j + mov eax, [edi+8] + mov edx, [edi+0Ch] + mov cl, 20h + call __allshr ; Microsoft VisualC 2-8/net runtime + mov ecx, [esi+4] + mov edx, [esi] + add al, bl + mov [ecx+edx], al + add dword ptr [esi+4], 1 + mov eax, [esi+4] + cmp eax, [esi+8] + jnz short loc_4CF6A3 + cmp [esi+0Ch], eax + jz short loc_4CF6A3 + nop + +loc_4CF690: ; CODE XREF: .text:004CF6A1j + mov ecx, esi + call sub_4CF450 + test eax, eax + jnz short loc_4CF6CB + mov eax, [esi+0Ch] + cmp eax, [esi+4] + jnz short loc_4CF690 + +loc_4CF6A3: ; CODE XREF: .text:004CF688j + ; .text:004CF68Dj + or bl, 0FFh + add dword ptr [edi], 0FFFFFFFFh + jnz short loc_4CF667 + mov esi, [edi+8] + mov edx, esi + shr edx, 18h + mov [edi+4], dl + +loc_4CF6B6: ; CODE XREF: .text:004CF65Fj + add dword ptr [edi], 1 + shl esi, 8 + mov [edi+8], esi + mov dword ptr [edi+0Ch], 0 + pop edi + pop esi + pop ebx + pop ecx + retn + +; --------------------------------------------------------------------------- + +loc_4CF6CB: ; CODE XREF: .text:004CF699j + push offset dword_526DD0 + lea ecx, [esp+10h] + push ecx + mov [esp+14h], eax + int 3 +; call __CxxThrowException@8 ; _CxxThrowException(x,x) +; --------------------------------------------------------------------------- + + db 2 dup(0CCh) + +; =============== S U B R O U T I N E ======================================= + + +sub_4CF6E0 proc near ; CODE XREF: sub_4D0770+FBp + ; CEncoder_CodeOneBlock+6C5p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push esi + push edi + mov edi, [esp+8+arg_4] + add edi, 0FFFFFFFFh + mov esi, ecx + js short loc_4CF724 + push ebp + mov ebp, [esp+0Ch+arg_0] + +loc_4CF6F2: ; CODE XREF: sub_4CF6E0+41j + shr dword ptr [esi+10h], 1 + mov eax, [esi+10h] + mov edx, ebp + mov ecx, edi + shr edx, cl + test dl, 1 + jz short loc_4CF70A + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + +loc_4CF70A: ; CODE XREF: sub_4CF6E0+21j + cmp eax, 1000000h + jnb short loc_4CF71E + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CF71E: ; CODE XREF: sub_4CF6E0+2Fj + sub edi, 1 + jns short loc_4CF6F2 + pop ebp + +loc_4CF724: ; CODE XREF: sub_4CF6E0+Bj + pop edi + pop esi + retn 8 +sub_4CF6E0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF740 proc near ; CODE XREF: sub_4D0770+DFp + ; CEncoder_CodeOneBlock+58Ap ... + +arg_0 = dword ptr 4 + + push esi + push edi + mov edi, [esp+8+arg_0] + mov eax, edi + imul eax, 440h + mov esi, ecx + mov edx, [esi+4C08h] + lea ecx, [eax+esi+808h] + push ecx + push edx + push edi + mov ecx, esi + call sub_4CDC00 + mov eax, [esi+4C08h] + mov [esi+edi*4+4C0Ch], eax + pop edi + pop esi + retn 4 +sub_4CF740 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF780 proc near ; CODE XREF: CEncoder_SetStreams+7Ep + ; CEncoder_SetStreams+A6p + +arg_0 = dword ptr 4 + + push esi + push edi + xor edi, edi + cmp [esp+8+arg_0], edi + mov esi, ecx + jbe short loc_4CF7CC + push ebx + push ebp + lea ebx, [esi+4C0Ch] + lea ebp, [esi+808h] + lea ebx, [ebx+0] + +loc_4CF7A0: ; CODE XREF: sub_4CF780+48j + mov eax, [esi+4C08h] + push ebp + push eax + push edi + mov ecx, esi + call sub_4CDC00 + mov ecx, [esi+4C08h] + mov [ebx], ecx + add edi, 1 + add ebx, 4 + add ebp, 440h + cmp edi, [esp+10h+arg_0] + jb short loc_4CF7A0 + pop ebp + pop ebx + +loc_4CF7CC: ; CODE XREF: sub_4CF780+Aj + pop edi + pop esi + retn 4 +sub_4CF780 endp + +; --------------------------------------------------------------------------- + align 10h +CEncoder_GetOptimum proc near ; CODE XREF: CEncoder_CodeOneBlock+201p + +var_7D = byte ptr -7Dh +var_7C = dword ptr -7Ch +var_78 = dword ptr -78h +var_74 = dword ptr -74h +var_70 = dword ptr -70h +var_6C = dword ptr -6Ch +var_68 = dword ptr -68h +var_64 = dword ptr -64h +var_60 = dword ptr -60h +var_5C = dword ptr -5Ch +var_58 = dword ptr -58h +var_54 = dword ptr -54h +var_50 = dword ptr -50h +var_4C = dword ptr -4Ch +var_48 = dword ptr -48h +var_44 = dword ptr -44h +var_40 = dword ptr -40h +var_3C = dword ptr -3Ch +var_38 = dword ptr -38h +var_34 = dword ptr -34h +var_30 = dword ptr -30h +var_2C = dword ptr -2Ch +var_28 = dword ptr -28h +var_24 = dword ptr -24h +var_20 = dword ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + sub esp, 80h + push ebp + mov ebp, ecx + mov edx, [ebp+32F0Ch] + cmp [ebp+32F08h], edx + push esi + jz short loc_4CE0A5 + mov esi, [esp+88h+arg_4] + lea eax, [edx+edx*4+1Eh] + lea ecx, [ebp+eax*8+0] + mov eax, [ecx+10h] + sub eax, edx + mov edx, [ecx+14h] + mov [esi], edx + mov ecx, [ecx+10h] + pop esi + mov [ebp+32F0Ch], ecx + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE0A5: ; CODE XREF: CEncoder_GetOptimum+16j + mov edx, [ebp+80h] + mov eax, [ebp+70h] + push ebx + xor esi, esi + push edx + mov [ebp+32F08h], esi + mov [ebp+32F0Ch], esi + call eax + add esp, 4 + cmp byte ptr [ebp+32F10h], 0 + mov ebx, eax + mov [esp+8Ch+var_60], eax + jnz short loc_4CE0E4 + lea ecx, [esp+8Ch+var_70] + push ecx + mov ecx, ebp + call sub_4CB3B0 + mov [esp+8Ch+var_68], eax + jmp short loc_4CE0FF +; --------------------------------------------------------------------------- + +loc_4CE0E4: ; CODE XREF: CEncoder_GetOptimum+70j + mov edx, [ebp+32EFCh] + mov eax, [ebp+32F00h] + mov [esp+8Ch+var_68], edx + mov [esp+8Ch+var_70], eax + mov byte ptr [ebp+32F10h], 0 + +loc_4CE0FF: ; CODE XREF: CEncoder_GetOptimum+82j + mov ecx, [ebp+80h] + mov edx, [ebp+74h] + push edi + push ecx + call edx + mov edi, eax + add esp, 4 + sub edi, 1 + cmp ebx, 2 + jnb short loc_4CE138 + mov eax, [esp+90h+arg_4] + pop edi + pop ebx + pop esi + mov dword ptr [eax], 0FFFFFFFFh + mov eax, 1 + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE138: ; CODE XREF: CEncoder_GetOptimum+B7j + cmp ebx, 111h + jbe short loc_4CE149 + mov ebx, 111h + mov [esp+90h+var_60], ebx + +loc_4CE149: ; CODE XREF: CEncoder_GetOptimum+DEj + lea ecx, [ebp+14h] + mov [esp+90h+var_50], esi + mov [esp+90h+var_64], esi + xor edx, edx + mov [esp+90h+var_4C], esi + mov [esp+90h+var_6C], ecx + mov edi, edi + +loc_4CE160: ; CODE XREF: CEncoder_GetOptimum+180j + mov eax, [esp+90h+var_6C] + mov eax, [eax] + mov ecx, edi + sub ecx, eax + mov [esp+edx+90h+var_20], eax + mov al, [edi] + sub ecx, 1 + cmp al, [ecx] + jnz short loc_4CE1C9 + mov al, [edi+1] + cmp al, [ecx+1] + jnz short loc_4CE1C9 + mov eax, 2 + cmp ebx, eax + jbe short loc_4CE1A7 + lea esi, [edi+2] + sub ecx, edi + lea ecx, [ecx+0] + +loc_4CE190: ; CODE XREF: CEncoder_GetOptimum+143j + mov bl, [esi] + cmp bl, [ecx+esi] + mov ebx, [esp+90h+var_60] + jnz short loc_4CE1A5 + add eax, 1 + add esi, 1 + cmp eax, ebx + jb short loc_4CE190 + +loc_4CE1A5: ; CODE XREF: CEncoder_GetOptimum+139j + xor esi, esi + +loc_4CE1A7: ; CODE XREF: CEncoder_GetOptimum+126j + mov ecx, [esp+90h+var_4C] + mov [esp+edx+90h+var_10], eax + cmp eax, [esp+ecx+90h+var_10] + jbe short loc_4CE1D0 + mov eax, [esp+90h+var_64] + mov [esp+90h+var_50], eax + mov [esp+90h+var_4C], edx + jmp short loc_4CE1D0 +; --------------------------------------------------------------------------- + +loc_4CE1C9: ; CODE XREF: CEncoder_GetOptimum+115j + ; CEncoder_GetOptimum+11Dj + mov [esp+edx+90h+var_10], esi + +loc_4CE1D0: ; CODE XREF: CEncoder_GetOptimum+159j + ; CEncoder_GetOptimum+167j + add [esp+90h+var_64], 1 + add [esp+90h+var_6C], 4 + add edx, 4 + cmp edx, 10h + jb loc_4CE160 + mov ecx, [esp+90h+var_50] + mov ebx, [esp+ecx*4+90h+var_10] + mov eax, [ebp+32EF8h] + cmp ebx, eax + mov [esp+90h+var_40], ebx + jb short loc_4CE234 + mov edx, [esp+90h+arg_4] + lea eax, [ebx-1] + cmp eax, esi + mov [edx], ecx + jz short loc_4CE225 + add [ebp+32F04h], eax + mov ecx, [ebp+7Ch] + push eax + mov eax, [ebp+80h] + push eax + call ecx + add esp, 8 + +loc_4CE225: ; CODE XREF: CEncoder_GetOptimum+1ADj + pop edi + mov eax, ebx + pop ebx + pop esi + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE234: ; CODE XREF: CEncoder_GetOptimum+19Dj + mov esi, [esp+90h+var_68] + cmp esi, eax + jb short loc_4CE27F + mov edx, [esp+90h+var_70] + mov eax, [ebp+edx*4+3265Ch] + mov ecx, [esp+90h+arg_4] + add eax, 4 + mov [ecx], eax + lea eax, [esi-1] + test eax, eax + jz short loc_4CE270 + mov edx, [ebp+80h] + add [ebp+32F04h], eax + push eax + mov eax, [ebp+7Ch] + push edx + call eax + add esp, 8 + +loc_4CE270: ; CODE XREF: CEncoder_GetOptimum+1F8j + pop edi + pop ebx + mov eax, esi + pop esi + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE27F: ; CODE XREF: CEncoder_GetOptimum+1DAj + mov al, [edi] + mov esi, [esp+90h+var_20] + sub edi, esi + cmp [esp+90h+var_68], 2 + mov cl, [edi-1] + mov byte ptr [esp+90h+var_4C], al + mov byte ptr [esp+90h+var_50], cl + jnb short loc_4CE2C1 + cmp al, cl + jz short loc_4CE2C1 + cmp ebx, 2 + jnb short loc_4CE2C1 + mov ecx, [esp+90h+arg_4] + pop edi + pop ebx + pop esi + mov dword ptr [ecx], 0FFFFFFFFh + mov eax, 1 + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE2C1: ; CODE XREF: CEncoder_GetOptimum+237j + ; CEncoder_GetOptimum+23Bj ... + mov edx, [esp+90h+var_4C] + mov bl, [ebp+10h] + mov edi, [ebp+33B60h] + and edi, [esp+90h+arg_0] + mov ecx, [esp+90h+var_50] + push edx + cmp bl, 7 + setnb dl + push ecx + mov [ebp+0F0h], bl + mov eax, [ebp+32654h] + mov ecx, 8 + sub cl, al + push edx + movzx edx, byte ptr [ebp+11h] + shr edx, cl + mov ecx, [ebp+3265Ch] + and ecx, [esp+9Ch+arg_0] + mov [esp+9Ch+var_3C], ecx + mov ecx, eax + mov eax, [esp+9Ch+var_3C] + shl eax, cl + add edx, eax + imul edx, 0C00h + add edx, [ebp+32650h] + mov ecx, edx + call sub_4CDAC0 + movzx ecx, bl + shl ecx, 4 + add ecx, edi + mov edx, [ebp+ecx*4+280F0h] + shr edx, 2 + add eax, dword_550998[edx*4] + mov ebx, 800h + mov [ebp+124h], eax + mov dword ptr [ebp+12Ch], 0FFFFFFFFh + mov byte ptr [ebp+119h], 0 + mov cl, [ebp+10h] + movzx eax, cl + mov edx, eax + shl edx, 4 + add edx, edi + sub ebx, [ebp+edx*4+280F0h] + mov edx, 800h + sub edx, [ebp+eax*4+283F0h] + mov al, byte ptr [esp+90h+var_4C] + shr edx, 2 + mov edx, dword_550998[edx*4] + shr ebx, 2 + mov ebx, dword_550998[ebx*4] + add edx, ebx + cmp byte ptr [esp+90h+var_50], al + mov [esp+90h+var_44], ebx + mov [esp+90h+var_3C], edx + jnz short loc_4CE3F3 + movzx eax, cl + mov ebx, [ebp+eax*4+28420h] + mov ecx, eax + shl ecx, 4 + add ecx, edi + mov ecx, [ebp+ecx*4+284B0h] + shr ecx, 2 + mov eax, dword_550998[ecx*4] + shr ebx, 2 + add eax, dword_550998[ebx*4] + add eax, edx + cmp eax, [ebp+124h] + jnb short loc_4CE3F3 + mov [ebp+124h], eax + mov dword ptr [ebp+12Ch], 0 + mov byte ptr [ebp+119h], 0 + +loc_4CE3F3: ; CODE XREF: CEncoder_GetOptimum+344j + ; CEncoder_GetOptimum+37Aj + mov eax, [esp+90h+var_68] + mov ecx, [esp+90h+var_40] + cmp eax, ecx + jb short loc_4CE405 + mov [esp+90h+var_7C], eax + jmp short loc_4CE40B +; --------------------------------------------------------------------------- + +loc_4CE405: ; CODE XREF: CEncoder_GetOptimum+39Dj + mov [esp+90h+var_7C], ecx + mov eax, ecx + +loc_4CE40B: ; CODE XREF: CEncoder_GetOptimum+3A3j + cmp eax, 2 + jnb short loc_4CE431 + mov edx, [ebp+12Ch] + mov eax, [esp+90h+arg_4] + pop edi + pop ebx + pop esi + mov [eax], edx + mov eax, 1 + pop ebp + add esp, 80h + retn 8 +; --------------------------------------------------------------------------- + +loc_4CE431: ; CODE XREF: CEncoder_GetOptimum+3AEj + mov ecx, [esp+90h+var_1C] + mov edx, [esp+90h+var_18] + xor ebx, ebx + mov [ebp+128h], ebx + mov [ebp+10Ch], ecx + mov ecx, [esp+90h+var_14] + mov [ebp+110h], edx + lea edx, [eax+eax*4] + mov [ebp+114h], ecx + mov [ebp+108h], esi + lea ecx, [ebp+edx*8+0FCh] + jmp short loc_4CE470 +; --------------------------------------------------------------------------- + align 10h + +loc_4CE470: ; CODE XREF: CEncoder_GetOptimum+407j + ; CEncoder_GetOptimum+41Fj + mov dword ptr [ecx], 0FFFFFFFh + sub eax, 1 + sub ecx, 28h + cmp eax, 2 + jnb short loc_4CE470 + +loc_4CE481: ; CODE XREF: CEncoder_GetOptimum+48Ej + mov esi, [esp+ebx*4+90h+var_10] + cmp esi, 2 + jb short loc_4CE4E8 + movzx eax, byte ptr [ebp+10h] + push edi + push eax + push ebx + mov ecx, ebp + call sub_4CD9B0 + add eax, [esp+90h+var_3C] + mov ecx, edi + imul ecx, 110h + add ecx, esi + mov [esp+90h+var_40], eax + lea edx, [esi+esi*4] + lea eax, [ebp+ecx*4+2E204h] + lea ecx, [ebp+edx*8+0FCh] + mov edi, edi + +loc_4CE4C0: ; CODE XREF: CEncoder_GetOptimum+486j + mov edx, [eax] + add edx, [esp+90h+var_40] + cmp edx, [ecx] + jnb short loc_4CE4DA + mov [ecx], edx + mov dword ptr [ecx+4], 0 + mov [ecx+8], ebx + mov byte ptr [ecx-0Bh], 0 + +loc_4CE4DA: ; CODE XREF: CEncoder_GetOptimum+468j + sub esi, 1 + sub eax, 4 + sub ecx, 28h + cmp esi, 2 + jnb short loc_4CE4C0 + +loc_4CE4E8: ; CODE XREF: CEncoder_GetOptimum+42Bj + add ebx, 1 + cmp ebx, 4 + jb short loc_4CE481 + movzx eax, byte ptr [ebp+10h] + mov ecx, [ebp+eax*4+283F0h] + shr ecx, 2 + mov eax, dword_550998[ecx*4] + add eax, [esp+90h+var_44] + mov [esp+90h+var_3C], eax + mov eax, [esp+90h+var_10] + cmp eax, 2 + lea ebx, [eax+1] + jnb short loc_4CE521 + mov ebx, 2 + +loc_4CE521: ; CODE XREF: CEncoder_GetOptimum+4BAj + cmp ebx, [esp+90h+var_68] + ja loc_4CE5BA + xor eax, eax + cmp ebx, [ebp+32660h] + mov [esp+90h+var_60], eax + jbe short loc_4CE550 + lea esp, [esp+0] + +loc_4CE540: ; CODE XREF: CEncoder_GetOptimum+4EAj + add eax, 2 + cmp ebx, [ebp+eax*4+32660h] + ja short loc_4CE540 + mov [esp+90h+var_60], eax + +loc_4CE550: ; CODE XREF: CEncoder_GetOptimum+4D7j + lea edx, [ebx+ebx*4] + lea esi, [ebp+edx*8+0FCh] + lea ebx, [ebx+0] + +loc_4CE560: ; CODE XREF: CEncoder_GetOptimum+558j + mov eax, [esp+90h+var_60] + mov eax, [ebp+eax*4+32664h] + push edi + push ebx + push eax + mov ecx, ebp + mov [esp+9Ch+var_40], eax + call sub_4CAEC0 + add eax, [esp+90h+var_3C] + cmp eax, [esi] + jnb short loc_4CE598 + mov ecx, [esp+90h+var_40] + add ecx, 4 + mov [esi], eax + mov dword ptr [esi+4], 0 + mov [esi+8], ecx + mov byte ptr [esi-0Bh], 0 + +loc_4CE598: ; CODE XREF: CEncoder_GetOptimum+51Fj + mov eax, [esp+90h+var_60] + cmp ebx, [ebp+eax*4+32660h] + jnz short loc_4CE5B2 + add eax, 2 + cmp eax, [esp+90h+var_70] + mov [esp+90h+var_60], eax + jz short loc_4CE5BA + +loc_4CE5B2: ; CODE XREF: CEncoder_GetOptimum+543j + add ebx, 1 + add esi, 28h + jmp short loc_4CE560 +; --------------------------------------------------------------------------- + +loc_4CE5BA: ; CODE XREF: CEncoder_GetOptimum+4C5j + ; CEncoder_GetOptimum+550j + mov eax, 1 + cmp [esp+90h+var_7C], eax + mov [esp+90h+var_78], eax + jz loc_4CF1D0 + mov esi, eax + jmp short loc_4CE5D5 +; --------------------------------------------------------------------------- + +loc_4CE5D1: ; CODE XREF: CEncoder_GetOptimum+116Aj + mov esi, [esp+90h+var_78] + +loc_4CE5D5: ; CODE XREF: CEncoder_GetOptimum+56Fj + mov edx, [ebp+80h] + mov eax, [ebp+70h] + push edx + call eax + add esp, 4 + lea ecx, [esp+90h+var_4C] + push ecx + mov ecx, ebp + mov [esp+94h+var_60], eax + call sub_4CB3B0 + cmp eax, [ebp+32EF8h] + mov [esp+90h+var_28], eax + jnb loc_4CF1D7 + add [esp+90h+arg_0], 1 + lea edx, [esi+esi*4+1Eh] + mov bl, [ebp+edx*8+1] + test bl, bl + lea eax, [ebp+edx*8+0] + mov edx, [eax+10h] + jz short loc_4CE673 + sub edx, 1 + cmp byte ptr [eax+2], 0 + jz short loc_4CE660 + mov ecx, [eax+4] + add ecx, 6 + cmp dword ptr [eax+8], 4 + lea ecx, [ecx+ecx*4] + mov cl, [ebp+ecx*8+0] + movzx ecx, cl + jnb short loc_4CE64F + mov cl, ds:kRepNextStates[ecx] + movzx ecx, cl + mov cl, ds:kLiteralNextStates[ecx] + jmp short loc_4CE67B +; --------------------------------------------------------------------------- + +loc_4CE64F: ; CODE XREF: CEncoder_GetOptimum+5DCj + mov cl, ds:kMatchNextStates[ecx] + movzx ecx, cl + mov cl, ds:kLiteralNextStates[ecx] + jmp short loc_4CE67B +; --------------------------------------------------------------------------- + +loc_4CE660: ; CODE XREF: CEncoder_GetOptimum+5C6j + lea ecx, [edx+edx*4+1Eh] + mov cl, [ebp+ecx*8+0] + movzx ecx, cl + mov cl, ds:kLiteralNextStates[ecx] + jmp short loc_4CE67B +; --------------------------------------------------------------------------- + +loc_4CE673: ; CODE XREF: CEncoder_GetOptimum+5BDj + lea ecx, [edx+edx*4+1Eh] + mov cl, [ebp+ecx*8+0] + +loc_4CE67B: ; CODE XREF: CEncoder_GetOptimum+5EDj + ; CEncoder_GetOptimum+5FEj ... + add esi, 0FFFFFFFFh + cmp edx, esi + jnz short loc_4CE6AC + cmp dword ptr [eax+14h], 0 + jnz short loc_4CE69A + movzx edx, cl + mov bl, ds:kShortRepNextStates[edx] + mov byte ptr [esp+90h+var_64], bl + jmp loc_4CE754 +; --------------------------------------------------------------------------- + +loc_4CE69A: ; CODE XREF: CEncoder_GetOptimum+626j + movzx ecx, cl + mov bl, ds:kLiteralNextStates[ecx] + mov byte ptr [esp+90h+var_64], bl + jmp loc_4CE754 +; --------------------------------------------------------------------------- + +loc_4CE6AC: ; CODE XREF: CEncoder_GetOptimum+620j + test bl, bl + jz short loc_4CE6CB + cmp byte ptr [eax+2], 0 + jz short loc_4CE6CB + mov edi, [eax+8] + mov edx, [eax+4] + movzx ecx, cl + mov bl, ds:kRepNextStates[ecx] + mov [esp+90h+var_68], edi + jmp short loc_4CE6EA +; --------------------------------------------------------------------------- + +loc_4CE6CB: ; CODE XREF: CEncoder_GetOptimum+64Ej + ; CEncoder_GetOptimum+654j + mov esi, [eax+14h] + cmp esi, 4 + mov [esp+90h+var_68], esi + movzx ecx, cl + mov edi, esi + jnb short loc_4CE6E4 + mov bl, ds:kRepNextStates[ecx] + jmp short loc_4CE6EA +; --------------------------------------------------------------------------- + +loc_4CE6E4: ; CODE XREF: CEncoder_GetOptimum+67Aj + mov bl, ds:kMatchNextStates[ecx] + +loc_4CE6EA: ; CODE XREF: CEncoder_GetOptimum+669j + ; CEncoder_GetOptimum+682j + cmp edi, 4 + lea edx, [edx+edx*4+1Eh] + mov byte ptr [esp+90h+var_64], bl + lea edx, [ebp+edx*8+0] + jnb short loc_4CE738 + mov ecx, [edx+edi*4+18h] + mov esi, 1 + cmp edi, esi + mov [esp+90h+var_20], ecx + jb short loc_4CE723 + mov ecx, edi + lea esi, [edx+18h] + lea edi, [esp+90h+var_1C] + rep movsd + mov esi, [esp+90h+var_68] + add esi, 1 + cmp esi, 4 + jnb short loc_4CE754 + +loc_4CE723: ; CODE XREF: CEncoder_GetOptimum+6AAj + lea edx, [edx+esi*4+18h] + mov ecx, 4 + lea edi, [esp+esi*4+90h+var_20] + sub ecx, esi + mov esi, edx + rep movsd + jmp short loc_4CE754 +; --------------------------------------------------------------------------- + +loc_4CE738: ; CODE XREF: CEncoder_GetOptimum+699j + mov ecx, [edx+18h] + mov [esp+90h+var_1C], ecx + mov ecx, [edx+1Ch] + mov edx, [edx+20h] + add edi, 0FFFFFFFCh + mov [esp+90h+var_20], edi + mov [esp+90h+var_18], ecx + mov [esp+90h+var_14], edx + +loc_4CE754: ; CODE XREF: CEncoder_GetOptimum+635j + ; CEncoder_GetOptimum+647j ... + mov ecx, [esp+90h+var_1C] + mov edx, [esp+90h+var_18] + mov edi, [esp+90h+var_20] + mov [eax], bl + mov [eax+1Ch], ecx + mov ecx, [esp+90h+var_14] + mov [eax+18h], edi + mov [eax+20h], edx + mov [eax+24h], ecx + mov esi, [eax+0Ch] + mov edx, [ebp+80h] + mov eax, [ebp+74h] + push edx + mov [esp+94h+var_3C], esi + call eax + movzx ecx, byte ptr [eax-1] + sub eax, 1 + mov edx, eax + mov byte ptr [esp+94h+var_5C], cl + sub edx, edi + movzx ecx, byte ptr [edx-1] + lea edi, [edx-1] + mov edx, [ebp+32654h] + mov byte ptr [esp+94h+var_58], cl + mov ecx, [ebp+33B60h] + and ecx, [esp+94h+arg_0] + mov [esp+94h+var_40], edi + movzx edi, bl + mov [esp+94h+var_54], ecx + mov [esp+94h+var_68], edi + add esp, 4 + shl edi, 4 + add edi, ecx + mov ecx, [esp+90h+var_5C] + push ecx + mov ecx, [esp+94h+var_58] + push ecx + cmp bl, 7 + mov ebx, [ebp+3265Ch] + setnb cl + and ebx, [esp+98h+arg_0] + mov [esp+98h+var_74], eax + movzx eax, byte ptr [eax-1] + push ecx + mov ecx, 8 + sub cl, dl + shr eax, cl + mov ecx, edx + shl ebx, cl + add eax, ebx + imul eax, 0C00h + add eax, [ebp+32650h] + mov ecx, eax + call sub_4CDAC0 + mov ecx, [ebp+edi*4+280F0h] + shr ecx, 2 + add eax, dword_550998[ecx*4] + mov ecx, [esp+90h+var_78] + add eax, esi + lea edx, [ecx+ecx*4+23h] + cmp eax, [ebp+edx*8+0Ch] + lea esi, [ebp+edx*8+0] + mov [esp+90h+var_7D], 0 + jnb short loc_4CE851 + mov [esi+0Ch], eax + mov [esi+10h], ecx + mov dword ptr [esi+14h], 0FFFFFFFFh + mov byte ptr [esi+1], 0 + mov [esp+90h+var_7D], 1 + +loc_4CE851: ; CODE XREF: CEncoder_GetOptimum+7D9j + mov ebx, [esp+90h+var_68] + mov edx, 800h + sub edx, [ebp+edi*4+280F0h] + shr edx, 2 + mov ecx, dword_550998[edx*4] + add ecx, [esp+90h+var_3C] + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + mov ebx, [esp+90h+var_78] + shr edx, 2 + mov edx, dword_550998[edx*4] + add edx, ecx + mov [esp+90h+var_24], ecx + mov cl, byte ptr [esp+90h+var_58] + cmp cl, byte ptr [esp+90h+var_5C] + mov [esp+90h+var_38], edx + jnz short loc_4CE8EB + cmp [esi+10h], ebx + jnb short loc_4CE8A8 + cmp dword ptr [esi+14h], 0 + jz short loc_4CE8EB + +loc_4CE8A8: ; CODE XREF: CEncoder_GetOptimum+840j + mov ecx, [esp+90h+var_68] + mov ecx, [ebp+ecx*4+28420h] + mov edi, [ebp+edi*4+284B0h] + shr ecx, 2 + mov ecx, dword_550998[ecx*4] + shr edi, 2 + add ecx, dword_550998[edi*4] + add ecx, edx + cmp ecx, [esi+0Ch] + ja short loc_4CE8EB + mov [esi+0Ch], ecx + mov [esi+10h], ebx + mov dword ptr [esi+14h], 0 + mov byte ptr [esi+1], 0 + mov [esp+90h+var_7D], 1 + +loc_4CE8EB: ; CODE XREF: CEncoder_GetOptimum+83Bj + ; CEncoder_GetOptimum+846j ... + mov edx, [esp+90h+var_60] + mov ecx, 0FFFh + sub ecx, ebx + cmp ecx, edx + jnb short loc_4CE900 + mov edx, ecx + mov [esp+90h+var_60], edx + +loc_4CE900: ; CODE XREF: CEncoder_GetOptimum+898j + cmp edx, 2 + mov ebx, edx + mov [esp+90h+var_6C], ebx + jb loc_4CF1BB + mov esi, [ebp+32EF8h] + mov edi, [esp+90h+var_60] + cmp edi, esi + jbe short loc_4CE923 + mov ebx, esi + mov [esp+90h+var_6C], esi + +loc_4CE923: ; CODE XREF: CEncoder_GetOptimum+8BBj + cmp [esp+90h+var_7D], 0 + jnz loc_4CEA90 + mov dl, byte ptr [esp+90h+var_5C] + cmp byte ptr [esp+90h+var_58], dl + jz loc_4CEA90 + lea ecx, [esi+1] + cmp edi, ecx + jb short loc_4CE945 + mov edi, ecx + +loc_4CE945: ; CODE XREF: CEncoder_GetOptimum+8E1j + mov esi, 1 + cmp edi, esi + jbe short loc_4CE975 + mov ebx, [esp+90h+var_74] + mov edx, [esp+90h+var_40] + lea ecx, [ebx+1] + sub edx, ebx + jmp short loc_4CE960 +; --------------------------------------------------------------------------- + align 10h + +loc_4CE960: ; CODE XREF: CEncoder_GetOptimum+8FBj + ; CEncoder_GetOptimum+90Fj + mov bl, [ecx] + cmp bl, [edx+ecx] + jnz short loc_4CE971 + add esi, 1 + add ecx, 1 + cmp esi, edi + jb short loc_4CE960 + +loc_4CE971: ; CODE XREF: CEncoder_GetOptimum+905j + mov ebx, [esp+90h+var_6C] + +loc_4CE975: ; CODE XREF: CEncoder_GetOptimum+8ECj + add esi, 0FFFFFFFFh + cmp esi, 2 + mov [esp+90h+var_50], esi + jb loc_4CEA90 + mov ecx, [esp+90h+var_68] + mov dl, ds:kLiteralNextStates[ecx] + mov ecx, [esp+90h+arg_0] + movzx ebx, dl + add ecx, 1 + and ecx, [ebp+33B60h] + mov edx, ebx + shl edx, 4 + lea esi, [edx+ecx] + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + mov edi, 800h + sub edi, [ebp+esi*4+280F0h] + shr edx, 2 + mov edx, dword_550998[edx*4] + shr edi, 2 + add edx, dword_550998[edi*4] + mov edi, [esp+90h+var_78] + add edx, eax + mov eax, [esp+90h+var_50] + lea edi, [eax+edi+1] + mov eax, [esp+90h+var_7C] + cmp eax, edi + mov [esp+90h+var_40], esi + jnb short loc_4CEA22 + mov esi, [esp+90h+var_7C] + lea eax, [eax+eax*4] + lea eax, [ebp+eax*8+0FCh] + mov [esp+90h+var_3C], eax + mov eax, edi + sub eax, esi + add esi, eax + mov [esp+90h+var_7C], esi + mov esi, [esp+90h+var_3C] + +loc_4CEA10: ; CODE XREF: CEncoder_GetOptimum+9BCj + add esi, 28h + sub eax, 1 + mov dword ptr [esi], 0FFFFFFFh + jnz short loc_4CEA10 + mov esi, [esp+90h+var_40] + +loc_4CEA22: ; CODE XREF: CEncoder_GetOptimum+98Ej + imul ecx, 110h + add ecx, [esp+90h+var_50] + mov eax, 800h + sub eax, [ebp+esi*4+284B0h] + mov esi, [ebp+ebx*4+28420h] + mov ebx, [esp+90h+var_6C] + shr eax, 2 + mov eax, dword_550998[eax*4] + shr esi, 2 + add eax, dword_550998[esi*4] + mov esi, [esp+90h+var_7C] + add eax, [ebp+ecx*4+2E204h] + lea ecx, [edi+edi*4+1Eh] + add eax, edx + cmp eax, [ebp+ecx*8+0Ch] + lea ecx, [ebp+ecx*8+0] + jnb short loc_4CEA94 + mov edx, [esp+90h+var_78] + add edx, 1 + mov [ecx+0Ch], eax + mov [ecx+10h], edx + mov dword ptr [ecx+14h], 0 + mov byte ptr [ecx+1], 1 + mov byte ptr [ecx+2], 0 + jmp short loc_4CEA94 +; --------------------------------------------------------------------------- + +loc_4CEA90: ; CODE XREF: CEncoder_GetOptimum+8C8j + ; CEncoder_GetOptimum+8D6j ... + mov esi, [esp+90h+var_7C] + +loc_4CEA94: ; CODE XREF: CEncoder_GetOptimum+A10j + ; CEncoder_GetOptimum+A2Ej + mov [esp+90h+var_70], 0 + mov ecx, [esp+90h+var_70] + mov [esp+90h+var_40], 2 + jmp short loc_4CEAB8 +; --------------------------------------------------------------------------- + align 10h + +loc_4CEAB0: ; CODE XREF: CEncoder_GetOptimum+D63j + mov ebx, [esp+90h+var_6C] + mov esi, [esp+90h+var_7C] + +loc_4CEAB8: ; CODE XREF: CEncoder_GetOptimum+A48j + mov edx, [esp+90h+var_74] + mov eax, edx + sub eax, [esp+ecx*4+90h+var_20] + mov cl, [edx] + sub eax, 1 + cmp cl, [eax] + mov [esp+90h+var_48], eax + jnz loc_4CEDB5 + mov cl, [edx+1] + cmp cl, [eax+1] + jnz loc_4CEDB5 + mov edi, 2 + cmp ebx, edi + jbe short loc_4CEB01 + lea ecx, [edx+2] + sub eax, edx + lea ecx, [ecx+0] + +loc_4CEAF0: ; CODE XREF: CEncoder_GetOptimum+A9Fj + mov dl, [ecx] + cmp dl, [eax+ecx] + jnz short loc_4CEB01 + add edi, 1 + add ecx, 1 + cmp edi, ebx + jb short loc_4CEAF0 + +loc_4CEB01: ; CODE XREF: CEncoder_GetOptimum+A86j + ; CEncoder_GetOptimum+A95j + mov eax, [esp+90h+var_78] + lea ebx, [edi+eax] + cmp esi, ebx + jnb short loc_4CEB2E + mov eax, ebx + lea ecx, [esi+esi*4] + sub eax, esi + add esi, eax + lea ecx, [ebp+ecx*8+0FCh] + mov [esp+90h+var_7C], esi + +loc_4CEB20: ; CODE XREF: CEncoder_GetOptimum+ACCj + add ecx, 28h + sub eax, 1 + mov dword ptr [ecx], 0FFFFFFFh + jnz short loc_4CEB20 + +loc_4CEB2E: ; CODE XREF: CEncoder_GetOptimum+AAAj + mov edx, [esp+90h+var_54] + mov eax, [esp+90h+var_64] + mov ecx, [esp+90h+var_70] + push edx + push eax + push ecx + mov ecx, ebp + mov esi, edi + call sub_4CD9B0 + add eax, [esp+90h+var_38] + mov ecx, [esp+90h+var_54] + imul ecx, 110h + lea edx, [edi+ecx] + mov [esp+90h+var_34], ecx + lea ecx, [ebp+edx*4+2E204h] + mov [esp+90h+var_50], ecx + lea edx, [ebx+ebx*4] + mov ebx, [esp+90h+var_50] + mov [esp+90h+var_2C], eax + lea ecx, [ebp+edx*8+0FCh] + +loc_4CEB78: ; CODE XREF: CEncoder_GetOptimum+B40j + mov edx, [ebx] + add edx, eax + cmp edx, [ecx] + jnb short loc_4CEB94 + mov [ecx], edx + mov edx, [esp+90h+var_78] + mov [ecx+4], edx + mov edx, [esp+90h+var_70] + mov [ecx+8], edx + mov byte ptr [ecx-0Bh], 0 + +loc_4CEB94: ; CODE XREF: CEncoder_GetOptimum+B1Ej + sub edi, 1 + sub ebx, 4 + sub ecx, 28h + cmp edi, 2 + jnb short loc_4CEB78 + cmp [esp+90h+var_70], 0 + jnz short loc_4CEBB0 + lea eax, [esi+1] + mov [esp+90h+var_40], eax + +loc_4CEBB0: ; CODE XREF: CEncoder_GetOptimum+B47j + mov ecx, [ebp+32EF8h] + mov edx, [esp+90h+var_60] + lea eax, [esi+1] + add ecx, eax + cmp edx, ecx + jnb short loc_4CEBC5 + mov ecx, edx + +loc_4CEBC5: ; CODE XREF: CEncoder_GetOptimum+B61j + cmp eax, ecx + jnb short loc_4CEBE7 + mov ebx, [esp+90h+var_74] + mov edi, [esp+90h+var_48] + lea edx, [eax+ebx] + sub edi, ebx + +loc_4CEBD6: ; CODE XREF: CEncoder_GetOptimum+B85j + mov bl, [edx] + cmp bl, [edx+edi] + jnz short loc_4CEBE7 + add eax, 1 + add edx, 1 + cmp eax, ecx + jb short loc_4CEBD6 + +loc_4CEBE7: ; CODE XREF: CEncoder_GetOptimum+B67j + ; CEncoder_GetOptimum+B7Bj + or ecx, 0FFFFFFFFh + sub ecx, esi + add eax, ecx + cmp eax, 2 + mov [esp+90h+var_44], eax + jb loc_4CEDB5 + mov edx, [esp+90h+var_68] + mov cl, ds:kRepNextStates[edx] + mov eax, [ebp+33B60h] + mov edi, [esp+90h+arg_0] + movzx ecx, cl + mov ebx, eax + lea edx, [esi+edi] + and ebx, edx + mov edx, ecx + mov cl, ds:kLiteralNextStates[ecx] + shl edx, 4 + add ebx, edx + mov edx, [ebp+ebx*4+280F0h] + movzx ebx, cl + shr edx, 2 + mov edx, dword_550998[edx*4] + mov [esp+90h+var_30], edx + lea edi, [esi+edi+1] + and edi, eax + mov eax, [ebp+32654h] + mov ecx, ebx + shl ecx, 4 + add ecx, edi + mov [esp+90h+var_50], ecx + mov ecx, [esp+90h+var_74] + movzx edx, byte ptr [esi+ecx] + push edx + mov edx, [esp+94h+var_48] + movzx edx, byte ptr [esi+edx] + push edx + movzx edx, byte ptr [ecx+esi-1] + mov ecx, 8 + sub cl, al + shr edx, cl + mov ecx, [esp+98h+arg_0] + lea eax, [esi+ecx] + mov ecx, [ebp+3265Ch] + and ecx, eax + mov eax, ecx + mov ecx, [ebp+32654h] + shl eax, cl + push 1 + add edx, eax + imul edx, 0C00h + add edx, [ebp+32650h] + mov ecx, edx + call sub_4CDAC0 + mov ecx, [esp+90h+var_50] + mov edx, 800h + sub edx, [ebp+ecx*4+280F0h] + mov ecx, [esp+90h+var_34] + shr edx, 2 + add eax, dword_550998[edx*4] + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + shr edx, 2 + add eax, dword_550998[edx*4] + lea edx, [esi+ecx] + add eax, [ebp+edx*4+2E204h] + mov ecx, [esp+90h+var_44] + add eax, [esp+90h+var_30] + mov edx, [esp+90h+var_78] + add eax, [esp+90h+var_2C] + add ecx, esi + lea ecx, [ecx+edx+1] + cmp [esp+90h+var_7C], ecx + mov [esp+90h+var_30], ecx + jnb short loc_4CED3E + mov edx, [esp+90h+var_7C] + lea edx, [edx+edx*4] + lea edx, [ebp+edx*8+0FCh] + mov [esp+90h+var_2C], edx + mov edx, [esp+90h+var_7C] + sub ecx, edx + add edx, ecx + mov [esp+90h+var_7C], edx + mov edx, [esp+90h+var_2C] + jmp short loc_4CED30 +; --------------------------------------------------------------------------- + align 10h + +loc_4CED30: ; CODE XREF: CEncoder_GetOptimum+CCBj + ; CEncoder_GetOptimum+CDCj + add edx, 28h + sub ecx, 1 + mov dword ptr [edx], 0FFFFFFFh + jnz short loc_4CED30 + +loc_4CED3E: ; CODE XREF: CEncoder_GetOptimum+CA7j + mov edx, [esp+90h+var_50] + imul edi, 110h + add edi, [esp+90h+var_44] + mov ecx, 800h + sub ecx, [ebp+edx*4+284B0h] + mov edx, [ebp+ebx*4+28420h] + shr ecx, 2 + mov ecx, dword_550998[ecx*4] + shr edx, 2 + add ecx, dword_550998[edx*4] + add ecx, [ebp+edi*4+2E204h] + add ecx, eax + mov eax, [esp+90h+var_30] + lea eax, [eax+eax*4+1Eh] + cmp ecx, [ebp+eax*8+0Ch] + lea eax, [ebp+eax*8+0] + jnb short loc_4CEDB5 + mov [eax+0Ch], ecx + mov ecx, [esp+90h+var_78] + lea edx, [esi+ecx+1] + mov [eax+4], ecx + mov ecx, [esp+90h+var_70] + mov [eax+10h], edx + mov dword ptr [eax+14h], 0 + mov byte ptr [eax+1], 1 + mov byte ptr [eax+2], 1 + mov [eax+8], ecx + +loc_4CEDB5: ; CODE XREF: CEncoder_GetOptimum+A6Dj + ; CEncoder_GetOptimum+A79j ... + mov ecx, [esp+90h+var_70] + add ecx, 1 + cmp ecx, 4 + mov [esp+90h+var_70], ecx + jb loc_4CEAB0 + mov edx, [esp+90h+var_28] + mov ecx, [esp+90h+var_6C] + cmp edx, ecx + jbe short loc_4CEDFB + xor eax, eax + cmp ecx, [ebp+32660h] + mov edx, ecx + jbe short loc_4CEDED + +loc_4CEDE1: ; CODE XREF: CEncoder_GetOptimum+D8Bj + add eax, 2 + cmp ecx, [ebp+eax*4+32660h] + ja short loc_4CEDE1 + +loc_4CEDED: ; CODE XREF: CEncoder_GetOptimum+D7Fj + mov [ebp+eax*4+32660h], ecx + add eax, 2 + mov [esp+90h+var_4C], eax + +loc_4CEDFB: ; CODE XREF: CEncoder_GetOptimum+D73j + mov esi, [esp+90h+var_40] + cmp edx, esi + jb loc_4CF1BB + mov eax, [esp+90h+var_68] + mov ecx, [ebp+eax*4+283F0h] + shr ecx, 2 + mov eax, dword_550998[ecx*4] + add eax, [esp+90h+var_24] + mov ecx, [esp+90h+var_7C] + mov [esp+90h+var_40], eax + mov eax, [esp+90h+var_78] + add eax, edx + cmp ecx, eax + jnb short loc_4CEE52 + lea edx, [ecx+ecx*4] + sub eax, ecx + add ecx, eax + lea edx, [ebp+edx*8+0FCh] + mov [esp+90h+var_7C], ecx + +loc_4CEE44: ; CODE XREF: CEncoder_GetOptimum+DF0j + add edx, 28h + sub eax, 1 + mov dword ptr [edx], 0FFFFFFFh + jnz short loc_4CEE44 + +loc_4CEE52: ; CODE XREF: CEncoder_GetOptimum+DD0j + xor eax, eax + cmp esi, [ebp+32660h] + mov [esp+90h+var_70], eax + jbe short loc_4CEE70 + +loc_4CEE60: ; CODE XREF: CEncoder_GetOptimum+E0Aj + add eax, 2 + cmp esi, [ebp+eax*4+32660h] + ja short loc_4CEE60 + mov [esp+90h+var_70], eax + +loc_4CEE70: ; CODE XREF: CEncoder_GetOptimum+DFEj + lea ebx, ds:0[eax*4] + mov edx, [ebx+ebp+32664h] + mov ecx, 7FFFFh + sub ecx, edx + sar ecx, 1Fh + and ecx, 0Ch + add ecx, 6 + mov eax, edx + shr eax, cl + mov [esp+90h+var_6C], edx + lea edi, [esi+1] + movzx eax, byte ptr dword_551198[eax] + lea ecx, [eax+ecx*2] + mov eax, [esp+90h+var_54] + imul eax, 110h + add eax, esi + lea eax, [ebp+eax*4+295B8h] + mov [esp+90h+var_3C], ecx + mov ecx, [esp+90h+var_78] + mov [esp+90h+var_54], eax + lea eax, [esi+ecx] + lea eax, [eax+eax*4] + lea ecx, [ebp+eax*8+0FCh] + mov [esp+90h+var_50], ecx + +loc_4CEED3: ; CODE XREF: CEncoder_GetOptimum+1156j + lea eax, [edi-3] + cmp eax, 4 + jb short loc_4CEEE0 + mov eax, 3 + +loc_4CEEE0: ; CODE XREF: CEncoder_GetOptimum+E79j + cmp edx, 80h + jnb short loc_4CEEF6 + shl eax, 7 + add eax, edx + mov eax, [ebp+eax*4+33314h] + jmp short loc_4CEF10 +; --------------------------------------------------------------------------- + +loc_4CEEF6: ; CODE XREF: CEncoder_GetOptimum+E86j + shl eax, 6 + add eax, [esp+90h+var_3C] + mov esi, edx + mov eax, [ebp+eax*4+32F14h] + and esi, 0Fh + add eax, [ebp+esi*4+33B14h] + +loc_4CEF10: ; CODE XREF: CEncoder_GetOptimum+E94j + add eax, [esp+90h+var_40] + mov esi, [esp+90h+var_54] + add eax, [esi] + cmp eax, [ecx] + mov [esp+90h+var_2C], eax + jnb short loc_4CEF35 + mov [ecx], eax + mov eax, [esp+90h+var_78] + add edx, 4 + mov [ecx+4], eax + mov [ecx+8], edx + mov byte ptr [ecx-0Bh], 0 + +loc_4CEF35: ; CODE XREF: CEncoder_GetOptimum+EC0j + lea eax, [edi-1] + cmp eax, [ebx+ebp+32660h] + jnz loc_4CF1A1 + mov ebx, [esp+90h+var_74] + mov eax, [ebp+32EF8h] + mov esi, [esp+90h+var_60] + mov edx, ebx + sub edx, [esp+90h+var_6C] + add eax, edi + sub edx, 1 + cmp esi, eax + mov ecx, edi + jnb short loc_4CEF6C + mov eax, esi + mov [esp+90h+var_44], esi + jmp short loc_4CEF70 +; --------------------------------------------------------------------------- + +loc_4CEF6C: ; CODE XREF: CEncoder_GetOptimum+F02j + mov [esp+90h+var_44], eax + +loc_4CEF70: ; CODE XREF: CEncoder_GetOptimum+F0Aj + cmp edi, eax + jnb short loc_4CEF93 + lea esi, [edi+edx] + sub ebx, edx + lea esp, [esp+0] + +loc_4CEF80: ; CODE XREF: CEncoder_GetOptimum+F31j + mov al, [ebx+esi] + cmp al, [esi] + jnz short loc_4CEF93 + add ecx, 1 + add esi, 1 + cmp ecx, [esp+90h+var_44] + jb short loc_4CEF80 + +loc_4CEF93: ; CODE XREF: CEncoder_GetOptimum+F12j + ; CEncoder_GetOptimum+F25j + or esi, 0FFFFFFFFh + lea eax, [edi-1] + sub esi, eax + add ecx, esi + cmp ecx, 2 + mov [esp+90h+var_48], ecx + jb loc_4CF157 + mov ecx, [esp+90h+var_68] + mov bl, ds:kMatchNextStates[ecx] + mov ecx, [ebp+33B60h] + mov eax, [esp+90h+arg_0] + lea esi, [edi+eax-1] + mov eax, ecx + and eax, esi + movzx esi, bl + movzx edx, byte ptr [edi+edx-1] + mov ebx, esi + shl ebx, 4 + add ebx, eax + mov ebx, [ebp+ebx*4+280F0h] + shr ebx, 2 + mov ebx, dword_550998[ebx*4] + mov [esp+90h+var_28], ebx + mov bl, ds:kLiteralNextStates[esi] + lea esi, [eax+1] + mov eax, [ebp+32654h] + and esi, ecx + movzx ebx, bl + mov ecx, ebx + shl ecx, 4 + add ecx, esi + mov [esp+90h+var_44], ecx + mov ecx, [esp+90h+var_74] + movzx ecx, byte ptr [ecx+edi-1] + push ecx + mov ecx, [esp+94h+var_74] + push edx + movzx edx, byte ptr [edi+ecx-2] + mov ecx, 8 + sub cl, al + shr edx, cl + mov ecx, [esp+98h+arg_0] + lea eax, [edi+ecx-1] + mov ecx, [ebp+3265Ch] + and ecx, eax + mov eax, ecx + mov ecx, [ebp+32654h] + shl eax, cl + push 1 + add edx, eax + imul edx, 0C00h + add edx, [ebp+32650h] + mov ecx, edx + call sub_4CDAC0 + mov edx, 800h + sub edx, [ebp+ebx*4+283F0h] + mov ecx, 800h + shr edx, 2 + add eax, dword_550998[edx*4] + mov edx, [esp+90h+var_44] + sub ecx, [ebp+edx*4+280F0h] + mov edx, [esp+90h+var_78] + shr ecx, 2 + add eax, dword_550998[ecx*4] + mov ecx, [esp+90h+var_48] + add eax, [esp+90h+var_28] + add ecx, edx + add eax, [esp+90h+var_2C] + add ecx, edi + cmp [esp+90h+var_7C], ecx + mov [esp+90h+var_28], ecx + jnb short loc_4CF0DE + mov edx, [esp+90h+var_7C] + lea edx, [edx+edx*4] + lea edx, [ebp+edx*8+0FCh] + mov [esp+90h+var_24], edx + mov edx, [esp+90h+var_7C] + sub ecx, edx + add edx, ecx + mov [esp+90h+var_7C], edx + mov edx, [esp+90h+var_24] + lea ecx, [ecx+0] + +loc_4CF0D0: ; CODE XREF: CEncoder_GetOptimum+107Cj + add edx, 28h + sub ecx, 1 + mov dword ptr [edx], 0FFFFFFFh + jnz short loc_4CF0D0 + +loc_4CF0DE: ; CODE XREF: CEncoder_GetOptimum+1049j + mov edx, [esp+90h+var_44] + imul esi, 110h + add esi, [esp+90h+var_48] + mov ecx, 800h + sub ecx, [ebp+edx*4+284B0h] + mov edx, [ebp+ebx*4+28420h] + shr ecx, 2 + mov ecx, dword_550998[ecx*4] + shr edx, 2 + add ecx, dword_550998[edx*4] + add ecx, [ebp+esi*4+2E204h] + add ecx, eax + mov eax, [esp+90h+var_28] + lea eax, [eax+eax*4+1Eh] + cmp ecx, [ebp+eax*8+0Ch] + lea eax, [ebp+eax*8+0] + jnb short loc_4CF157 + mov [eax+0Ch], ecx + mov ecx, [esp+90h+var_78] + lea edx, [ecx+edi] + mov [eax+4], ecx + mov ecx, [esp+90h+var_6C] + add ecx, 4 + mov [eax+10h], edx + mov dword ptr [eax+14h], 0 + mov byte ptr [eax+1], 1 + mov byte ptr [eax+2], 1 + mov [eax+8], ecx + +loc_4CF157: ; CODE XREF: CEncoder_GetOptimum+F44j + ; CEncoder_GetOptimum+10CCj + mov eax, [esp+90h+var_70] + add eax, 2 + cmp eax, [esp+90h+var_4C] + mov [esp+90h+var_70], eax + jz short loc_4CF1BB + lea ebx, ds:0[eax*4] + mov eax, [ebx+ebp+32664h] + cmp eax, 80h + mov [esp+90h+var_6C], eax + jb short loc_4CF1A1 + mov ecx, 7FFFFh + sub ecx, eax + sar ecx, 1Fh + and ecx, 0Ch + add ecx, 6 + shr eax, cl + movzx edx, byte ptr dword_551198[eax] + lea eax, [edx+ecx*2] + mov [esp+90h+var_3C], eax + +loc_4CF1A1: ; CODE XREF: CEncoder_GetOptimum+EDFj + ; CEncoder_GetOptimum+111Fj + add [esp+90h+var_50], 28h + add [esp+90h+var_54], 4 + mov ecx, [esp+90h+var_50] + mov edx, [esp+90h+var_6C] + add edi, 1 + jmp loc_4CEED3 +; --------------------------------------------------------------------------- + +loc_4CF1BB: ; CODE XREF: CEncoder_GetOptimum+8A9j + ; CEncoder_GetOptimum+DA1j ... + mov eax, [esp+90h+var_78] + add eax, 1 + cmp eax, [esp+90h+var_7C] + mov [esp+90h+var_78], eax + jnz loc_4CE5D1 + +loc_4CF1D0: ; CODE XREF: CEncoder_GetOptimum+567j + mov ecx, [esp+90h+var_78] + push ecx + jmp short loc_4CF1EF +; --------------------------------------------------------------------------- + +loc_4CF1D7: ; CODE XREF: CEncoder_GetOptimum+59Ej + mov ecx, [esp+90h+var_4C] + mov [ebp+32F00h], ecx + mov [ebp+32EFCh], eax + mov byte ptr [ebp+32F10h], 1 + push esi + +loc_4CF1EF: ; CODE XREF: CEncoder_GetOptimum+1175j + mov edx, [esp+94h+arg_4] + push edx + mov ecx, ebp + call sub_4CB2E0 + pop edi + pop ebx + pop esi + pop ebp + add esp, 80h + retn 8 +CEncoder_GetOptimum endp + +; --------------------------------------------------------------------------- + align 10h + +loc_4CF210: ; DATA XREF: CEncoder_CodeOneBlock+44o + mov edx, [esp+10h] + mov eax, [esp+4] + mov eax, [eax+4] + mov ecx, [eax] + push edx + mov edx, [esp+10h] + push edx + mov edx, [esp+10h] + push edx + push eax + mov eax, [ecx+0Ch] + call eax + retn +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_FillDistancesPrices proc near ; CODE XREF: CEncoder_SetStreams+4Fp + ; CEncoder_CodeOneBlock+751p + +var_20C = dword ptr -20Ch +var_208 = dword ptr -208h +var_204 = dword ptr -204h +var_200 = dword ptr -200h + + sub esp, 20Ch + push ebx + push ebp + push esi + push edi + mov ebx, ecx + mov esi, 4 + +loc_4CF241: ; CODE XREF: CEncoder_FillDistancesPrices+80j + cmp esi, 2000h + jnb short loc_4CF252 + movzx edx, byte ptr dword_551198[esi] + jmp short loc_4CF27A +; --------------------------------------------------------------------------- + +loc_4CF252: ; CODE XREF: CEncoder_FillDistancesPrices+17j + cmp esi, 2000000h + jnb short loc_4CF26B + mov eax, esi + shr eax, 0Ch + movzx edx, byte ptr dword_551198[eax] + add edx, 18h + jmp short loc_4CF27A +; --------------------------------------------------------------------------- + +loc_4CF26B: ; CODE XREF: CEncoder_FillDistancesPrices+28j + mov ecx, esi + shr ecx, 18h + movzx edx, byte ptr dword_551198[ecx] + add edx, 30h + +loc_4CF27A: ; CODE XREF: CEncoder_FillDistancesPrices+20j + ; CEncoder_FillDistancesPrices+39j + mov ecx, edx + mov eax, edx + and eax, 1 + shr ecx, 1 + sub ecx, 1 + or eax, 2 + shl eax, cl + mov edi, esi + sub edi, eax + push edi + sub eax, edx + push ecx + lea edx, [ebx+eax*4+28BACh] + push edx + call sub_4CD860 + mov [esp+esi*4+228h+var_200], eax + add esi, 1 + add esp, 0Ch + cmp esi, 80h + jb short loc_4CF241 + lea ebp, [esp+21Ch+var_200] + sub ebp, ebx + lea esi, [ebx+3331Ch] + sub ebp, 33314h + lea edx, [ebx+32F14h] + mov [esp+21Ch+var_20C], esi + mov [esp+21Ch+var_208], ebp + mov [esp+21Ch+var_204], 4 + jmp short loc_4CF2E4 +; --------------------------------------------------------------------------- + align 10h + +loc_4CF2E0: ; CODE XREF: CEncoder_FillDistancesPrices+1BDj + mov esi, [esp+21Ch+var_20C] + +loc_4CF2E4: ; CODE XREF: CEncoder_FillDistancesPrices+AAj + xor edi, edi + cmp [ebx+33B58h], edi + jbe short loc_4CF33F + mov edi, edi + +loc_4CF2F0: ; CODE XREF: CEncoder_FillDistancesPrices+109j + mov ecx, edi + or ecx, 40h + xor esi, esi + cmp ecx, 1 + jz short loc_4CF32D + lea esp, [esp+0] + +loc_4CF300: ; CODE XREF: CEncoder_FillDistancesPrices+F7j + mov eax, ecx + shr ecx, 1 + mov ebp, [edx+ecx*4-0A764h] + and eax, 1 + sub ebp, eax + neg eax + xor ebp, eax + shr ebp, 2 + and ebp, 1FFh + add esi, dword_550998[ebp*4] + cmp ecx, 1 + jnz short loc_4CF300 + mov ebp, [esp+21Ch+var_208] + +loc_4CF32D: ; CODE XREF: CEncoder_FillDistancesPrices+CAj + mov [edx+edi*4], esi + add edi, 1 + cmp edi, [ebx+33B58h] + jb short loc_4CF2F0 + mov esi, [esp+21Ch+var_20C] + +loc_4CF33F: ; CODE XREF: CEncoder_FillDistancesPrices+BCj + mov eax, 0Eh + cmp [ebx+33B58h], eax + jbe short loc_4CF368 + lea esp, [esp+0] + +loc_4CF350: ; CODE XREF: CEncoder_FillDistancesPrices+136j + mov ecx, eax + shr ecx, 1 + sub ecx, 5 + shl ecx, 6 + add [edx+eax*4], ecx + add eax, 1 + cmp eax, [ebx+33B58h] + jb short loc_4CF350 + +loc_4CF368: ; CODE XREF: CEncoder_FillDistancesPrices+11Aj + mov eax, [edx] + mov [esi-8], eax + mov ecx, [edx+4] + mov [esi-4], ecx + mov eax, [edx+8] + mov [esi], eax + mov ecx, [edx+0Ch] + mov [esi+4], ecx + mov eax, 4 + add esi, 8 + +loc_4CF386: ; CODE XREF: CEncoder_FillDistancesPrices+19Ej + cmp eax, 2000h + jnb short loc_4CF396 + movzx ecx, byte ptr dword_551198[eax] + jmp short loc_4CF3BB +; --------------------------------------------------------------------------- + +loc_4CF396: ; CODE XREF: CEncoder_FillDistancesPrices+15Bj + cmp eax, 2000000h + mov ecx, eax + jnb short loc_4CF3AE + shr ecx, 0Ch + movzx ecx, byte ptr dword_551198[ecx] + add ecx, 18h + jmp short loc_4CF3BB +; --------------------------------------------------------------------------- + +loc_4CF3AE: ; CODE XREF: CEncoder_FillDistancesPrices+16Dj + shr ecx, 18h + movzx ecx, byte ptr dword_551198[ecx] + add ecx, 30h + +loc_4CF3BB: ; CODE XREF: CEncoder_FillDistancesPrices+164j + ; CEncoder_FillDistancesPrices+17Cj + mov ecx, [edx+ecx*4] + add ecx, [esi+ebp] + add eax, 1 + mov [esi], ecx + add esi, 4 + cmp eax, 80h + jb short loc_4CF386 + add [esp+21Ch+var_20C], 200h + sub ebp, 200h + add edx, 100h + sub [esp+21Ch+var_204], 1 + mov [esp+21Ch+var_208], ebp + jnz loc_4CF2E0 + pop edi + pop esi + pop ebp + mov dword ptr [ebx+33B70h], 0 + pop ebx + add esp, 20Ch + retn +CEncoder_FillDistancesPrices endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_FillAlignPrices proc near ; CODE XREF: CEncoder_SetStreams+56p + ; CEncoder_CodeOneBlock+761p + push ebx + push ebp + push esi + mov ebp, ecx + push edi + xor esi, esi + lea ebx, [ebp+28D78h] + lea edi, [ebp+33B14h] + +loc_4CF424: ; CODE XREF: CEncoder_FillAlignPrices+27j + push esi + mov ecx, ebx + call sub_4CD810 + mov [edi], eax + add esi, 1 + add edi, 4 + cmp esi, 10h + jb short loc_4CF424 + pop edi + pop esi + mov dword ptr [ebp+33B54h], 0 + pop ebp + pop ebx + retn +CEncoder_FillAlignPrices endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CF810 proc near ; CODE XREF: sub_4D0250+3p + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 + + push 0FFFFFFFFh + push offset loc_4DA0C9 + mov eax, dword ptr fs:[0] + push eax + push ecx + push ebx + push esi + mov eax, dword_544960 + xor eax, esp + push eax + lea eax, [esp+1Ch+var_C] + mov dword ptr fs:[0], eax + mov esi, ecx + mov [esp+1Ch+var_10], esi + mov dword ptr [esi], offset NCompress_NLZMA_CEncoder_vftable + mov dword ptr [esi+4], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStream + mov dword ptr [esi+8], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderProperties + mov dword ptr [esi+0Ch], offset NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderProperties + mov eax, [esi+0A4h] + push eax ; lpAddress + mov [esp+20h+var_4], 1 + call off_546E24 + xor ebx, ebx + add esp, 4 + cmp [esi+0D0h], ebx + mov [esi+0A4h], ebx + jnz short loc_4CF892 + mov ecx, [esi+0B4h] + push ecx ; lpAddress + call off_546E24 + add esp, 4 + mov [esi+0B4h], ebx + +loc_4CF892: ; CODE XREF: sub_4CF810+6Aj + mov eax, [esi+33B8Ch] + cmp eax, ebx + jz short loc_4CF8A4 + mov edx, [eax] + push eax + mov eax, [edx+8] + call eax + +loc_4CF8A4: ; CODE XREF: sub_4CF810+8Aj + lea ecx, [esi+32650h] + mov byte ptr [esp+1Ch+var_4], bl + call sub_4CD8F0 + mov eax, [esi+40h] + cmp eax, ebx + mov [esp+1Ch+var_4], 0FFFFFFFFh + jz short loc_4CF8CF + push 8000h ; dwFreeType + push ebx ; dwSize + push eax ; lpAddress + call ds:VirtualFree + +loc_4CF8CF: ; CODE XREF: sub_4CF810+B0j + mov [esi+40h], ebx + mov esi, [esi+54h] + cmp esi, ebx + jz short loc_4CF8E1 + mov ecx, [esi] + mov edx, [ecx+8] + push esi + call edx + +loc_4CF8E1: ; CODE XREF: sub_4CF810+C7j + mov ecx, [esp+1Ch+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop esi + pop ebx + add esp, 10h + retn +sub_4CF810 endp + +; =============== S U B R O U T I N E ======================================= + +; int __stdcall sub_4CF900(int, void *Buf1, int) +sub_4CF900 proc near ; CODE XREF: sub_4CFA20+5j + ; ICompressSetCoderProperties_QueryInterface+5j ... + +arg_0 = dword ptr 4 +Buf1 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push esi + mov esi, [esp+4+Buf1] + push offset dword_512730 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF94C + +loc_4CF917: ; CODE XREF: sub_4CF900+5Cj + mov eax, [esp+4+arg_0] + test eax, eax + jz short loc_4CF936 + mov edx, [esp+4+arg_8] + lea ecx, [eax+4] + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF936: ; CODE XREF: sub_4CF900+1Dj + ; sub_4CF900+76j ... + mov edx, [esp+4+arg_8] + xor ecx, ecx + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF94C: ; CODE XREF: sub_4CF900+15j + push offset dword_5535A0 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jnz short loc_4CF917 + push offset dword_5535B0 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF98F + mov eax, [esp+4+arg_0] + test eax, eax + jz short loc_4CF936 + mov edx, [esp+4+arg_8] + lea ecx, [eax+8] + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF98F: ; CODE XREF: sub_4CF900+6Ej + push offset dword_5535C0 ; Buf2 + push esi ; Buf1 + call unknown_libname_324 ; MFC 3.1/4.0/4.2/8.0 32bit + add esp, 8 + test eax, eax + jz short loc_4CF9C0 + mov eax, [esp+4+arg_0] + test eax, eax + jz short loc_4CF936 + mov edx, [esp+4+arg_8] + lea ecx, [eax+0Ch] + mov [edx], ecx + mov ecx, [eax] + mov edx, [ecx+4] + push eax + call edx + xor eax, eax + pop esi + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CF9C0: ; CODE XREF: sub_4CF900+9Fj + mov eax, 80004002h + pop esi + retn 0Ch +sub_4CF900 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CF9D0 proc near ; CODE XREF: ICompressSetCoderProperties_AddRef+5j + ; sub_4CFA10+5j ... + +arg_0 = dword ptr 4 + + mov eax, [esp+arg_0] + add dword ptr [eax+24h], 1 + mov eax, [eax+24h] + retn 4 +sub_4CF9D0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CF9E0 proc near ; CODE XREF: sub_4CFA40+5j + ; ICompressSetCoderProperties_Release+5j ... + +arg_0 = dword ptr 4 + + mov ecx, [esp+arg_0] + add dword ptr [ecx+24h], 0FFFFFFFFh + mov eax, [ecx+24h] + jnz short locret_4CF9F8 + mov eax, [ecx] + mov edx, [eax+10h] + push 1 + call edx + xor eax, eax + +locret_4CF9F8: ; CODE XREF: sub_4CF9E0+Bj + retn 4 +sub_4CF9E0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +ICompressSetCoderProperties_AddRef proc near ; DATA XREF: .rdata:00517AD4o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 8 + jmp sub_4CF9D0 +ICompressSetCoderProperties_AddRef endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA10 proc near ; DATA XREF: .rdata:00517AC0o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 0Ch + jmp sub_4CF9D0 +sub_4CFA10 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA20 proc near ; DATA XREF: .rdata:NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStreamo + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 4 + jmp sub_4CF900 +sub_4CFA20 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +ICompressSetCoderProperties_QueryInterface proc near ; DATA XREF: .rdata:NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderPropertieso + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 8 + jmp sub_4CF900 +ICompressSetCoderProperties_QueryInterface endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA40 proc near ; DATA XREF: .rdata:00517AECo + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 4 + jmp sub_4CF9E0 +sub_4CFA40 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA50 proc near ; DATA XREF: .rdata:NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderPropertieso + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + sub [esp+arg_0], 0Ch + jmp sub_4CF900 +sub_4CFA50 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +ICompressSetCoderProperties_Release proc near ; DATA XREF: .rdata:00517AD8o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 8 + jmp sub_4CF9E0 +ICompressSetCoderProperties_Release endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA70 proc near ; DATA XREF: .rdata:00517AC4o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 0Ch + jmp sub_4CF9E0 +sub_4CFA70 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA80 proc near ; DATA XREF: .rdata:00517AE8o + +arg_0 = dword ptr 4 + + sub [esp+arg_0], 4 + jmp sub_4CF9D0 +sub_4CFA80 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFA90 proc near ; DATA XREF: .rdata:00517AF0o + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push esi + mov esi, [esp+4+arg_4] + test esi, esi + push edi + mov edi, [esp+8+arg_0] + jz short loc_4CFAA6 + mov eax, [esi] + mov ecx, [eax+4] + push esi + call ecx + +loc_4CFAA6: ; CODE XREF: sub_4CFA90+Cj + mov eax, [edi+50h] + test eax, eax + jz short loc_4CFAB5 + mov edx, [eax] + push eax + mov eax, [edx+8] + call eax + +loc_4CFAB5: ; CODE XREF: sub_4CFA90+1Bj + mov [edi+50h], esi + pop edi + xor eax, eax + pop esi + retn 8 +sub_4CFA90 endp + +; =============== S U B R O U T I N E ======================================= + +sub_4CFAC0 proc near ; CODE XREF: CEncoder_CodeOneBlock+42Ap + ; CEncoder_CodeOneBlock+517p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + mov eax, [esp+arg_0] + push esi + mov esi, [eax+10h] + mov edx, esi + shr edx, 0Bh + imul edx, [ecx] + cmp [esp+4+arg_4], 0 + jnz short loc_4CFAEC + mov [eax+10h], edx + mov edx, [ecx] + mov esi, 800h + sub esi, edx + shr esi, 5 + add esi, edx + mov [ecx], esi + jmp short loc_4CFB03 +; --------------------------------------------------------------------------- + +loc_4CFAEC: ; CODE XREF: sub_4CFAC0+15j + add [eax+8], edx + adc dword ptr [eax+0Ch], 0 + sub esi, edx + mov [eax+10h], esi + mov edx, [ecx] + mov esi, edx + shr esi, 5 + sub edx, esi + mov [ecx], edx + +loc_4CFB03: ; CODE XREF: sub_4CFAC0+2Aj + mov ecx, [eax+10h] + cmp ecx, 1000000h + pop esi + jnb short locret_4CFB1C + shl ecx, 8 + mov [eax+10h], ecx + mov ecx, eax + call loc_4CF640 + +locret_4CFB1C: ; CODE XREF: sub_4CFAC0+4Dj + retn 8 +sub_4CFAC0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + + +sub_4CFB20 proc near ; CODE XREF: sub_4D0020+52p + ; sub_4D0020+E4p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov ebx, 1 + mov edx, 3 + +loc_4CFB34: ; CODE XREF: sub_4CFB20+8Cj + mov edi, [esp+10h+arg_4] + sub edx, 1 + mov ecx, edx + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFB70 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFB8B +; --------------------------------------------------------------------------- + +loc_4CFB70: ; CODE XREF: sub_4CFB20+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFB8B: ; CODE XREF: sub_4CFB20+4Ej + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFBA6 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFBA6: ; CODE XREF: sub_4CFB20+73j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFB34 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFB20 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFBC0 proc near ; CODE XREF: sub_4D0020+136p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov ebx, 1 + mov edx, 8 + +loc_4CFBD4: ; CODE XREF: sub_4CFBC0+8Cj + mov edi, [esp+10h+arg_4] + sub edx, 1 + mov ecx, edx + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFC10 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFC2B +; --------------------------------------------------------------------------- + +loc_4CFC10: ; CODE XREF: sub_4CFBC0+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFC2B: ; CODE XREF: sub_4CFBC0+4Ej + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFC46 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFC46: ; CODE XREF: sub_4CFBC0+73j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFBD4 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFBC0 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFC60 proc near ; CODE XREF: sub_4D0770+EDp + ; CEncoder_CodeOneBlock+67Cp + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov ebx, 1 + mov edx, 6 + +loc_4CFC74: ; CODE XREF: sub_4CFC60+8Cj + mov edi, [esp+10h+arg_4] + sub edx, 1 + mov ecx, edx + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFCB0 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFCCB +; --------------------------------------------------------------------------- + +loc_4CFCB0: ; CODE XREF: sub_4CFC60+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFCCB: ; CODE XREF: sub_4CFC60+4Ej + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFCE6 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFCE6: ; CODE XREF: sub_4CFC60+73j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFC74 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFC60 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFD00 proc near ; CODE XREF: sub_4D0770+109p + ; CEncoder_CodeOneBlock+6D5p + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebp, ecx + mov edi, 1 + mov [esp+10h+arg_0], 4 + +loc_4CFD17: ; CODE XREF: sub_4CFD00+87j + mov ecx, [esi+10h] + mov ebx, [esp+10h+arg_4] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+edi*4+0] + and ebx, 1 + test ebx, ebx + jnz short loc_4CFD48 + mov [esi+10h], eax + mov eax, [ebp+edi*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+edi*4+0], ecx + jmp short loc_4CFD63 +; --------------------------------------------------------------------------- + +loc_4CFD48: ; CODE XREF: sub_4CFD00+2Dj + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+edi*4+0] + mov edx, eax + shr edx, 5 + sub eax, edx + mov [ebp+edi*4+0], eax + +loc_4CFD63: ; CODE XREF: sub_4CFD00+46j + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFD7A + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CFD7A: ; CODE XREF: sub_4CFD00+6Bj + shr [esp+10h+arg_4], 1 + add edi, edi + or edi, ebx + sub [esp+10h+arg_0], 1 + jnz short loc_4CFD17 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFD00 endp + + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFD90 proc near ; CODE XREF: CEncoder_CodeOneBlock+6AFp + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch +arg_C = dword ptr 10h + + mov eax, [esp+arg_8] + test eax, eax + push edi + mov edi, 1 + jle loc_4CFE26 + push ebx + push ebp + mov ebp, [esp+0Ch+arg_0] + push esi + mov esi, [esp+10h+arg_4] + mov [esp+10h+arg_8], eax + +loc_4CFDB1: ; CODE XREF: sub_4CFD90+91j + mov ecx, [esi+10h] + mov ebx, [esp+10h+arg_C] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+edi*4+0] + and ebx, 1 + test ebx, ebx + jnz short loc_4CFDE2 + mov [esi+10h], eax + mov eax, [ebp+edi*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+edi*4+0], ecx + jmp short loc_4CFDFD +; --------------------------------------------------------------------------- + +loc_4CFDE2: ; CODE XREF: sub_4CFD90+37j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+edi*4+0] + mov edx, eax + shr edx, 5 + sub eax, edx + mov [ebp+edi*4+0], eax + +loc_4CFDFD: ; CODE XREF: sub_4CFD90+50j + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFE14 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CFE14: ; CODE XREF: sub_4CFD90+75j + shr [esp+10h+arg_C], 1 + add edi, edi + or edi, ebx + sub [esp+10h+arg_8], 1 + jnz short loc_4CFDB1 + pop esi + pop ebp + pop ebx + +loc_4CFE26: ; CODE XREF: sub_4CFD90+Cj + pop edi + retn +sub_4CFD90 endp + +; --------------------------------------------------------------------------- + align 10h + +; =============== S U B R O U T I N E ======================================= + + +sub_4CFE30 proc near ; CODE XREF: CEncoder_CodeOneBlock+190p + ; CEncoder_CodeOneBlock+2CCp + +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 + + push ebx + push ebp + push esi + mov esi, [esp+0Ch+arg_0] + push edi + mov ebx, ecx + mov ebp, 1 + mov edx, 8 + +loc_4CFE44: ; CODE XREF: sub_4CFE30+88j + movzx edi, [esp+10h+arg_4] + sub edx, 1 + mov cl, dl + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebx+ebp*4] + and edi, 1 + test edi, edi + mov [esp+10h+arg_0], edx + jnz short loc_4CFE7E + mov [esi+10h], eax + mov eax, [ebx+ebp*4] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebx+ebp*4], ecx + jmp short loc_4CFE97 +; --------------------------------------------------------------------------- + +loc_4CFE7E: ; CODE XREF: sub_4CFE30+35j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebx+ebp*4] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebx+ebp*4], eax + +loc_4CFE97: ; CODE XREF: sub_4CFE30+4Cj + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFEB2 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+10h+arg_0] + +loc_4CFEB2: ; CODE XREF: sub_4CFE30+6Fj + add ebp, ebp + or ebp, edi + test edx, edx + jnz short loc_4CFE44 + pop edi + pop esi + pop ebp + pop ebx + retn 8 +sub_4CFE30 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4CFED0 proc near ; CODE XREF: CEncoder_CodeOneBlock+300p + +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = byte ptr 8 +arg_8 = byte ptr 0Ch + + push ecx + push ebx + push ebp + push esi + mov esi, [esp+10h+arg_0] + push edi + mov [esp+14h+var_4], ecx + mov ebx, 1 + mov edx, 8 + jmp short loc_4CFEF0 +; --------------------------------------------------------------------------- + align 10h + +loc_4CFEF0: ; CODE XREF: sub_4CFED0+17j + ; sub_4CFED0+ADj + movzx ebp, [esp+14h+arg_4] + movzx edi, [esp+14h+arg_8] + sub edx, 1 + movzx ecx, dl + shr ebp, cl + shr edi, cl + mov ecx, [esp+14h+var_4] + mov [esp+14h+arg_0], edx + mov edx, [esi+10h] + and ebp, 1 + lea eax, [ebp+1] + shl eax, 8 + add eax, ebx + lea ecx, [ecx+eax*4] + mov eax, edx + shr eax, 0Bh + imul eax, [ecx] + and edi, 1 + test edi, edi + jnz short loc_4CFF41 + mov [esi+10h], eax + mov eax, [ecx] + mov edx, 800h + sub edx, eax + shr edx, 5 + add edx, eax + mov [ecx], edx + jmp short loc_4CFF58 +; --------------------------------------------------------------------------- + +loc_4CFF41: ; CODE XREF: sub_4CFED0+5Aj + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub edx, eax + mov [esi+10h], edx + mov eax, [ecx] + mov edx, eax + shr edx, 5 + sub eax, edx + mov [ecx], eax + +loc_4CFF58: ; CODE XREF: sub_4CFED0+6Fj + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4CFF6F + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4CFF6F: ; CODE XREF: sub_4CFED0+90j + mov edx, [esp+14h+arg_0] + add ebx, ebx + or ebx, edi + cmp ebp, edi + jnz short loc_4CFF8B + test edx, edx + jnz loc_4CFEF0 + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4CFF8B: ; CODE XREF: sub_4CFED0+A9j + test edx, edx + jz loc_4D0012 + +loc_4CFF93: ; CODE XREF: sub_4CFED0+140j + movzx edi, [esp+14h+arg_8] + mov ebp, [esp+14h+var_4] + sub edx, 1 + mov cl, dl + shr edi, cl + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [ebp+ebx*4+0] + and edi, 1 + test edi, edi + mov [esp+14h+arg_0], edx + jnz short loc_4CFFD4 + mov [esi+10h], eax + mov eax, [ebp+ebx*4+0] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [ebp+ebx*4+0], ecx + jmp short loc_4CFFEF +; --------------------------------------------------------------------------- + +loc_4CFFD4: ; CODE XREF: sub_4CFED0+E9j + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [ebp+ebx*4+0] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [ebp+ebx*4+0], eax + +loc_4CFFEF: ; CODE XREF: sub_4CFED0+102j + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D000A + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + mov edx, [esp+14h+arg_0] + +loc_4D000A: ; CODE XREF: sub_4CFED0+127j + add ebx, ebx + or ebx, edi + test edx, edx + jnz short loc_4CFF93 + +loc_4D0012: ; CODE XREF: sub_4CFED0+BDj + pop edi + pop esi + pop ebp + pop ebx + pop ecx + retn 0Ch +sub_4CFED0 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4D0020 proc near ; CODE XREF: sub_4D0770+C6p + ; CEncoder_CodeOneBlock+56Dp ... + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + push ebp + mov ebp, [esp+4+arg_4] + cmp ebp, 8 + push esi + mov esi, [esp+8+arg_0] + push edi + mov edi, ecx + jnb short loc_4D007D + mov eax, [esi+10h] + shr eax, 0Bh + imul eax, [edi] + mov [esi+10h], eax + mov eax, [edi] + mov ecx, 800h + sub ecx, eax + +loc_4D0047: ; DATA XREF: .rdata:0050C3BCo + shr ecx, 5 + add ecx, eax + mov [edi], ecx + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D0065 + shl eax, 8 + +loc_4D005B: ; DATA XREF: .rdata:005064B0o + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D0065: ; CODE XREF: sub_4D0020+36j + mov edx, [esp+0Ch+arg_8] + push ebp + shl edx, 5 + push esi + lea ecx, [edx+edi+8] + call sub_4CFB20 + pop edi + pop esi + pop ebp + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D007D: ; CODE XREF: sub_4D0020+10j + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edi] + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [edi] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edi], eax + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D00B6 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D00B6: ; CODE XREF: sub_4D0020+87j + cmp ebp, 10h + jnb short loc_4D010F + mov edx, [esi+10h] + shr edx, 0Bh + imul edx, [edi+4] + mov [esi+10h], edx + mov eax, [edi+4] + mov ecx, 800h + sub ecx, eax + shr ecx, 5 + add ecx, eax + mov [edi+4], ecx + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D00F1 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D00F1: ; CODE XREF: sub_4D0020+C2j + mov edx, [esp+0Ch+arg_8] + add ebp, 0FFFFFFF8h + push ebp + shl edx, 5 + push esi + lea ecx, [edx+edi+208h] + call sub_4CFB20 + pop edi + pop esi + pop ebp + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D010F: ; CODE XREF: sub_4D0020+99j + mov ecx, [esi+10h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edi+4] + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [edi+4] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edi+4], eax + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D014B + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D014B: ; CODE XREF: sub_4D0020+11Cj + add ebp, 0FFFFFFF0h + push ebp + push esi + lea ecx, [edi+408h] + call sub_4CFBC0 + pop edi + pop esi + pop ebp + retn 0Ch +sub_4D0020 endp + +; =============== S U B R O U T I N E ======================================= + +NCompress_NLZMA_CEncoder_CEncoder proc near ; CODE XREF: Compress_lzma_internal+149p + mov eax, ecx + mov dword ptr [eax+4], offset ICompressSetOutStream_vftable + mov dword ptr [eax+8], offset ICompressSetCoderProperties_vftable + mov dword ptr [eax+0Ch], offset ICompressWriteCoderProperties_vftable + xor ecx, ecx + mov [eax+24h], ecx + mov dword ptr [eax], offset NCompress_NLZMA_CEncoder_vftable + mov dword ptr [eax+4], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetOutStream + mov dword ptr [eax+8], offset NCompress_NLZMA_CEncoder_vftable_ICompressSetCoderProperties + mov dword ptr [eax+0Ch], offset NCompress_NLZMA_CEncoder_vftable_ICompressWriteCoderProperties + mov [eax+40h], ecx + mov [eax+44h], ecx + mov [eax+54h], ecx + mov [eax+60h], ecx + mov [eax+32650h], ecx + mov dword ptr [eax+32EF8h], 20h + mov dword ptr [eax+33B58h], 2Ch + mov dword ptr [eax+33B5Ch], 2 + mov [eax+33B64h], ecx + mov dword ptr [eax+33B6Ch], 00400000h + mov edx, 3 + mov [eax+33B60h], edx + mov [eax+33B68h], edx + mov [eax+33B8Ch], ecx + mov [eax+33B90h], ecx + mov [eax+33B94h], cl + mov [eax+0B4h], ecx + mov [eax+0A4h], ecx + mov dword ptr [eax+0B0h], 20h + mov dword ptr [eax+0D4h], 1 + mov dword ptr [eax+0CCh], 4 + mov [eax+0D0h], ecx + mov [eax+0D8h], ecx + mov [eax+32EF4h], cl + retn +NCompress_NLZMA_CEncoder_CEncoder endp + +; =============== S U B R O U T I N E ======================================= + +; int __thiscall sub_4D0250(void *Memory, char) +sub_4D0250 proc near ; DATA XREF: .rdata:00517B0Co + +arg_0 = byte ptr 4 + + push esi + mov esi, ecx + call sub_4CF810 + test [esp+4+arg_0], 1 + jz short loc_4D0268 + push esi ; Memory + call j__free + add esp, 4 + +loc_4D0268: ; CODE XREF: sub_4D0250+Dj + mov eax, esi + pop esi + retn 4 +sub_4D0250 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +sub_4D0270 proc near ; CODE XREF: CEncoder_SetStreams+14p + push esi + mov esi, ecx + mov eax, [esi+40h] + test eax, eax + push edi + mov edi, 100000h + jz short loc_4D0297 + cmp [esi+50h], edi + jz short loc_4D02C5 + test eax, eax + jz short loc_4D0297 + push 8000h ; dwFreeType + push 0 ; dwSize + push eax ; lpAddress + call ds:VirtualFree + +loc_4D0297: ; CODE XREF: sub_4D0270+Ej + ; sub_4D0270+17j + push 4 ; flProtect + push 1000h ; flAllocationType + push edi ; dwSize + push 0 ; lpAddress + mov dword ptr [esi+40h], 0 + mov [esi+50h], edi + call ds:VirtualAlloc + test eax, eax + mov [esi+40h], eax + setnz al + test al, al + jnz short loc_4D02C5 + pop edi + mov eax, 8007000Eh + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4D02C5: ; CODE XREF: sub_4D0270+13j + ; sub_4D0270+4Bj + mov eax, [esi+33B68h] + mov ecx, [esi+33B64h] + cmp dword ptr [esi+0D4h], 0 + push ebx + push eax + push ecx + lea ecx, [esi+32650h] + setnz bl + call sub_4CD940 + test al, al + jz short loc_4D034F + mov ecx, [esi+33B6Ch] + mov edx, 1000000h + cmp edx, ecx + sbb eax, eax + neg eax + push ebp + mov ebp, [esi+32EF8h] + mov [esi+0D8h], eax + mov eax, ebp + shr eax, 1 + add eax, 10h + test bl, bl + jnz short loc_4D0318 + shr eax, 1 + +loc_4D0318: ; CODE XREF: sub_4D0270+A4j + mov edx, [esi+33B90h] + test edx, edx + jz short loc_4D0324 + mov eax, edx + +loc_4D0324: ; CODE XREF: sub_4D0270+B0j + push offset off_546E20 + push 111h + push ebp + push 1000h + push ecx + lea edi, [esi+84h] + push edi + mov [esi+0B0h], eax + call sub_4CBA60 + add esp, 18h + test eax, eax + pop ebp + jnz short loc_4D0358 + +loc_4D034F: ; CODE XREF: sub_4D0270+7Bj + pop ebx + pop edi + mov eax, 8007000Eh + pop esi + retn +; --------------------------------------------------------------------------- + +loc_4D0358: ; CODE XREF: sub_4D0270+DDj + mov [esi+80h], edi + add esi, 68h + push esi + push edi + call sub_4CCAA0 + add esp, 8 + pop ebx + pop edi + xor eax, eax + pop esi + retn +sub_4D0270 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_SetStreams proc near ; CODE XREF: CEncoder_CodeReal+4Ap + +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 + + mov eax, [esp+arg_0] + push esi + mov esi, ecx + mov [esi+33B84h], eax + mov byte ptr [esi+33B80h], 0 + call sub_4D0270 + test eax, eax + jnz loc_4D0441 + mov edx, [esp+4+arg_4] + mov ecx, [esi+4] + lea eax, [esi+4] + push edx + push eax + mov eax, [ecx+0Ch] + call eax + test eax, eax + jnz loc_4D0441 + mov ecx, esi + call sub_4CDEA0 + test eax, eax + jnz short loc_4D0441 + cmp [esi+32EF4h], al + jnz short loc_4D03DB + mov ecx, esi + call CEncoder_FillDistancesPrices + mov ecx, esi + call CEncoder_FillAlignPrices + +loc_4D03DB: ; CODE XREF: CEncoder_SetStreams+4Bj + mov ecx, [esi+32EF8h] + sub ecx, 1 + mov [esi+2D9C0h], ecx + mov ecx, [esi+33B5Ch] + mov edx, 1 + shl edx, cl + lea ecx, [esi+28DB8h] + push edx + call sub_4CF780 + mov ecx, [esi+33B5Ch] + mov eax, [esi+32EF8h] + mov edx, 1 + shl edx, cl + sub eax, 1 + lea ecx, [esi+2DA04h] + mov [esi+3260Ch], eax + push edx + call sub_4CF780 + mov dword ptr [esi+33B78h], 0 + mov dword ptr [esi+33B7Ch], 0 + xor eax, eax + +loc_4D0441: ; CODE XREF: CEncoder_SetStreams+1Bj + ; CEncoder_SetStreams+34j ... + pop esi + retn 10h +CEncoder_SetStreams endp + +;Compress_lzma_internal proc near ; CODE XREF: Compress_lzma+34p +_starcraft_compress_lzma proc near ; CODE XREF: Compress_lzma+34p +; sub_4D0450 + +var_58 = dword ptr -58h +var_54 = dword ptr -54h +var_50 = dword ptr -50h +var_4C = dword ptr -4Ch +var_48 = dword ptr -48h +var_44 = dword ptr -44h +var_40 = dword ptr -40h +var_3C = word ptr -3Ch +var_34 = dword ptr -34h +var_2C = word ptr -2Ch +var_24 = dword ptr -24h +var_1C = dword ptr -1Ch +var_14 = dword ptr -14h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +pbInBuffer = dword ptr 4 +cbInBuffer = dword ptr 8 +pcbInBuffer = dword ptr 0Ch +pbOutBuffer = dword ptr 10h +cbOutBuffer = dword ptr 14h +dummy = dword ptr 18h +pcbOutBuffer = dword ptr 1Ch +pfnAllocateMemory= dword ptr 20h +pfnFreeMemory = dword ptr 24h +pfnGiveData = dword ptr 28h + + push 0FFFFFFFFh + push offset loc_4DA0FB + mov eax, dword ptr fs:[0] + push eax + sub esp, 4Ch + push ebx + push ebp + push esi + push edi + mov eax, dword_544960 + xor eax, esp + push eax + lea eax, [esp+6Ch+var_C] + mov dword ptr fs:[0], eax + mov eax, dword_553598 + xor ebx, ebx + cmp eax, ebx + jnz short loc_4D04A1 + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D049A + mov [eax], ebx + mov [eax+4], ebx + mov [eax+8], ebx + jmp short loc_4D049C +; --------------------------------------------------------------------------- + +loc_4D049A: ; CODE XREF: Compress_lzma_internal+3Ej + xor eax, eax + +loc_4D049C: ; CODE XREF: Compress_lzma_internal+48j + mov dword ptr dword_553598, eax + +loc_4D04A1: ; CODE XREF: Compress_lzma_internal+30j + cmp [eax], ebx + jnz short loc_4D04B3 + mov ecx, [esp+6Ch+pfnAllocateMemory] + mov [eax], ecx + mov eax, dword_553598 + +loc_4D04B3: ; CODE XREF: Compress_lzma_internal+53j + cmp eax, ebx + jnz short loc_4D04D6 + push 0Ch ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D04CF + mov [eax], ebx + mov [eax+4], ebx + mov [eax+8], ebx + jmp short loc_4D04D1 +; --------------------------------------------------------------------------- + +loc_4D04CF: ; CODE XREF: Compress_lzma_internal+73j + xor eax, eax + +loc_4D04D1: ; CODE XREF: Compress_lzma_internal+7Dj + mov dword_553598, eax + +loc_4D04D6: ; CODE XREF: Compress_lzma_internal+65j + cmp [eax+4], ebx + jnz short loc_4D04EA + mov edx, [esp+6Ch+pfnFreeMemory] + mov [eax+4], edx + mov eax, dword_553598 + +loc_4D04EA: ; CODE XREF: Compress_lzma_internal+89j + cmp [eax+8], ebx + jnz short loc_4D04F9 + mov ecx, [esp+6Ch+pfnGiveData] + mov [eax+8], ecx + +loc_4D04F9: ; CODE XREF: Compress_lzma_internal+9Dj + mov edx, [esp+6Ch+pcbOutBuffer] + mov ebp, [esp+6Ch+pcbInBuffer] + cmp ebp, ebx + mov esi, [esp+6Ch+cbInBuffer] + mov [edx], ebx + mov edx, 1 + mov eax, esi + mov ecx, ebp + ja short loc_4D0520 + cmp esi, ebx + jbe short loc_4D053A + jmp short loc_4D0520 +; --------------------------------------------------------------------------- + align 10h + +loc_4D0520: ; CODE XREF: Compress_lzma_internal+C5j + ; Compress_lzma_internal+CBj ... + shrd eax, ecx, 1 + add edx, edx + shr ecx, 1 + cmp edx, 2000000h + ja short loc_4D053A + cmp ecx, ebx + ja short loc_4D0520 + jb short loc_4D053A + cmp eax, ebx + ja short loc_4D0520 + +loc_4D053A: ; CODE XREF: Compress_lzma_internal+C9j + ; Compress_lzma_internal+DEj ... + mov eax, 13h + push 33B98h ; Size + mov [esp+70h+var_48], 470h + mov [esp+70h+var_44], 400h + mov [esp+70h+var_40], 450h + mov [esp+70h+var_3C], ax + mov [esp+70h+var_2C], ax + mov word ptr [esp+70h+var_1C], ax + mov [esp+70h+var_34], 2 + mov [esp+70h+var_24], edx + mov [esp+70h+var_14], 40h + mov [esp+70h+var_58], ebx + call _operator_new ; operator new(uint) + add esp, 4 + mov [esp+6Ch+var_4C], eax + cmp eax, ebx + mov [esp+6Ch+var_4], ebx + jz short loc_4D05A4 + mov ecx, eax + call NCompress_NLZMA_CEncoder_CEncoder + mov [esp+6Ch+var_54], eax + jmp short loc_4D05AA +; --------------------------------------------------------------------------- + +loc_4D05A4: ; CODE XREF: Compress_lzma_internal+145j + mov [esp+6Ch+var_54], ebx + mov eax, ebx + +loc_4D05AA: ; CODE XREF: Compress_lzma_internal+152j + or edi, 0FFFFFFFFh + cmp eax, ebx + mov [esp+6Ch+var_4], edi + jz short loc_4D05D1 + mov ecx, [eax+8] + push 3 + lea edx, [esp+70h+var_3C] + push edx + add eax, 8 + lea edx, [esp+74h+var_48] + push edx + push eax + mov eax, [ecx+0Ch] + call eax ; ICompressSetCodeProperties::SetCoderProperties + test eax, eax + jz short loc_4D05D5 + +loc_4D05D1: ; CODE XREF: Compress_lzma_internal+163j + mov [esp+6Ch+var_58], edi + +loc_4D05D5: ; CODE XREF: Compress_lzma_internal+17Fj + push 28h ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D060E + mov ecx, [esp+6Ch+pbInBuffer] + mov [eax+4], ebx + add dword ptr [eax+4], 1 + mov dword ptr [eax], offset off_517A90 + mov [eax+8], ecx + mov [eax+10h], esi + mov [eax+14h], ebp + mov [eax+18h], ebx + mov [eax+1Ch], ebx + mov [eax+20h], bl + mov edi, eax ; EDI = pInStreamMemory + mov [esp+6Ch+var_50], eax + jmp short loc_4D0614 +; --------------------------------------------------------------------------- + +loc_4D060E: ; CODE XREF: Compress_lzma_internal+191j + xor edi, edi + mov [esp+6Ch+var_50], edi + +loc_4D0614: ; CODE XREF: Compress_lzma_internal+1BCj + push 28h ; Size + call _operator_new ; operator new(uint) + add esp, 4 + cmp eax, ebx + jz short loc_4D0657 + mov edx, [esp+6Ch+pbOutBuffer] + mov ecx, [esp+6Ch+cbOutBuffer] + mov [eax+4], ebx + add dword ptr [eax+4], 1 + mov [eax+8], edx + mov edx, [esp+6Ch+dummy] + mov dword ptr [eax], offset off_517AA4 + mov [eax+10h], ecx + mov [eax+14h], edx + mov [eax+18h], ebx + mov [eax+1Ch], ebx + mov [eax+20h], bl + mov esi, eax ; ESI = pOutStreamMemory + jmp short loc_4D0659 +; --------------------------------------------------------------------------- + +loc_4D0657: ; CODE XREF: Compress_lzma_internal+1D0j + xor esi, esi + +loc_4D0659: ; CODE XREF: Compress_lzma_internal+205j + cmp edi, ebx + jz short loc_4D0661 + cmp esi, ebx + jnz short loc_4D0669 + +loc_4D0661: ; CODE XREF: Compress_lzma_internal+20Bj + mov [esp+6Ch+var_58], 0FFFFFFFFh + +loc_4D0669: ; CODE XREF: Compress_lzma_internal+20Fj + mov eax, [esi] ; EAX = pOutStreamMemory->vftable + mov ecx, [eax+10h] ; ECX = + push ebx + mov edi, 1 + push edi + push ebx + push esi + call ecx + test eax, eax + jz short loc_4D0681 + mov [esp+6Ch+var_58], edi + +loc_4D0681: ; CODE XREF: Compress_lzma_internal+22Bj + mov eax, [esp+6Ch+var_54] + mov edx, [eax+0Ch] + add eax, 0Ch + push esi + push eax + mov eax, [edx+0Ch] + call eax + test eax, eax + jz short loc_4D069A + mov [esp+6Ch+var_58], edi + +loc_4D069A: ; CODE XREF: Compress_lzma_internal+244j + xor edi, edi + jmp short loc_4D06A4 +; --------------------------------------------------------------------------- + align 10h + +loc_4D06A0: ; CODE XREF: Compress_lzma_internal+27Fj + mov ebp, [esp+6Ch+pcbInBuffer] + +loc_4D06A4: ; CODE XREF: Compress_lzma_internal+24Cj + mov eax, [esp+6Ch+cbInBuffer] + push ebx + push 1 + mov edx, ebp + mov ecx, edi + call __allshr ; Microsoft VisualC 2-8/net runtime + push eax + mov eax, [esi] + mov ecx, [eax+10h] + push esi + call ecx + test eax, eax + jz short loc_4D06C9 + mov [esp+6Ch+var_58], 1 + +loc_4D06C9: ; CODE XREF: Compress_lzma_internal+26Fj + add edi, 8 + cmp edi, 40h + jl short loc_4D06A0 + mov ebp, [esp+6Ch+var_54] + xor edi, edi + cmp [esp+6Ch+var_58], ebx + jnz short loc_4D0723 + mov eax, [esp+6Ch+var_50] + mov edx, [ebp+0] + mov ecx, [edx+0Ch] + push ebx + push ebx + push ebx + push esi + push eax + push ebp + call ecx + mov ecx, [esi+18h] + mov edi, eax + mov eax, [esi+1Ch] + cmp eax, ebx + ja short loc_4D0700 + cmp ecx, 0FFFFFFFFh + jbe short loc_4D0709 + +loc_4D0700: ; CODE XREF: Compress_lzma_internal+2A9j + or ecx, 0FFFFFFFFh + mov [esp+6Ch+pcbInBuffer], ebx + jmp short loc_4D070D +; --------------------------------------------------------------------------- + +loc_4D0709: ; CODE XREF: Compress_lzma_internal+2AEj + mov [esp+6Ch+pcbInBuffer], eax + +loc_4D070D: ; CODE XREF: Compress_lzma_internal+2B7j + mov edx, [esp+6Ch+pcbOutBuffer] + mov [edx], ecx + cmp [esi+20h], bl + jz short loc_4D0723 + mov [esp+6Ch+var_58], 1 + +loc_4D0723: ; CODE XREF: Compress_lzma_internal+28Bj + ; Compress_lzma_internal+2C9j + mov eax, [esp+6Ch+var_50] + cmp eax, ebx + jz short loc_4D0733 + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + +loc_4D0733: ; CODE XREF: Compress_lzma_internal+2D9j + mov eax, [esi] + mov ecx, [eax+8] + push esi + call ecx + mov edx, [ebp+0] + mov eax, [edx+10h] + push 1 + mov ecx, ebp + call eax + mov eax, [esp+6Ch+var_58] + cmp eax, ebx + jnz short loc_4D0755 + neg edi + sbb edi, edi + mov eax, edi + +loc_4D0755: ; CODE XREF: Compress_lzma_internal+2FDj + mov ecx, [esp+6Ch+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebp + pop ebx + add esp, 58h + retn +_starcraft_compress_lzma endp +;Compress_lzma_internal endp + +; =============== S U B R O U T I N E ======================================= + +Compress_lzma proc near ; DATA XREF: .rdata:00509684o + +pbOutBuffer = dword ptr 4 +pcbOutBuffer = dword ptr 8 +pbInBuffer = dword ptr 0Ch +cbInBuffer = dword ptr 10h + + push esi + push edi +; call sub_47F198 + mov esi, [esp+8+pcbOutBuffer] ; ESI = pcbOutBuffer + mov edi, [esp+8+cbInBuffer] ; EDI = cbInBuffer +; push offset GiveDataToCompress +; push offset FreeMemory_47F3AB +; push offset AllocateMemory_47F396 + push esi ; pcbOutBuffer + push 0 + mov [eax+493E0h], eax + push dword ptr [esi] ; cbOutBuffer + push [esp+20h+pbOutBuffer] ; pbOutBuffer + push 0 + push edi ; cbInBuffer + push [esp+2Ch+pbInBuffer] ; pbInBuffer +; call Compress_lzma_internal + add esp, 28h + sub eax, 0 + jz short loc_47F401 + mov [esi], edi + dec eax + +loc_47F401: ; CODE XREF: Compress_lzma+3Fj + pop edi + pop esi + retn +Compress_lzma endp + +; =============== S U B R O U T I N E ======================================= + +sub_4D0770 proc near ; CODE XREF: CEncoder_Flush+1Ap + +arg_0 = dword ptr 4 + + push edi + mov edi, ecx + cmp byte ptr [edi+33B94h], 0 + jz loc_4D0881 + movzx eax, byte ptr [edi+10h] + mov ecx, [edi+38h] + shl eax, 4 + push ebx + mov ebx, [esp+8+arg_0] + add eax, ebx + lea edx, [edi+eax*4+280F0h] + push ebp + push esi + lea esi, [edi+28h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edx] + add [esi+8], eax + adc dword ptr [esi+0Ch], 0 + sub ecx, eax + mov [esi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D07D3 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D07D3: ; CODE XREF: sub_4D0770+54j + movzx edx, byte ptr [edi+10h] + mov ecx, [esi+10h] + lea eax, [edi+edx*4+283F0h] + shr ecx, 0Bh + imul ecx, [eax] + mov [esi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [esi+10h] + cmp eax, 1000000h + jnb short loc_4D0811 + shl eax, 8 + mov ecx, esi + mov [esi+10h], eax + call loc_4CF640 + +loc_4D0811: ; CODE XREF: sub_4D0770+92j + movzx eax, byte ptr [edi+10h] + mov cl, ds:kMatchNextStates[eax] + push ebx + mov [edi+10h], cl + cmp byte ptr [edi+32EF4h], 0 + push 0 + lea ebp, [edi+28DB8h] + push esi + mov ecx, ebp + setz byte ptr [esp+1Ch+arg_0] + call sub_4D0020 + cmp byte ptr [esp+10h+arg_0], 0 + jz short loc_4D0854 + add dword ptr [ebp+ebx*4+4C0Ch], 0FFFFFFFFh + jnz short loc_4D0854 + push ebx + mov ecx, ebp + call sub_4CF740 + +loc_4D0854: ; CODE XREF: sub_4D0770+D0j + ; sub_4D0770+DAj + push 3Fh + push esi + lea ecx, [edi+287B0h] + call sub_4CFC60 + push 1Ah + push 3FFFFFFh + mov ecx, esi + call sub_4CF6E0 + push 0Fh + push esi + lea ecx, [edi+28D78h] + call sub_4CFD00 + pop esi + pop ebp + pop ebx + +loc_4D0881: ; CODE XREF: sub_4D0770+Aj + pop edi + retn 4 +sub_4D0770 endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_Flush proc near ; CODE XREF: CEncoder_CodeOneBlock+BAp + ; CEncoder_CodeOneBlock+1D0p ... + +arg_0 = dword ptr 4 + + push esi + mov esi, ecx + mov eax, [esi+0ECh] + test eax, eax + jnz short loc_4D08E5 + mov eax, [esi+33B60h] + and eax, [esp+4+arg_0] + push ebx + push edi + push eax + call sub_4D0770 + lea ebx, [esi+28h] + mov edi, 5 + +loc_4D08B7: ; CODE XREF: CEncoder_Flush+31j + mov ecx, ebx + call loc_4CF640 + sub edi, 1 + jnz short loc_4D08B7 + mov ecx, [esi+4Ch] + add esi, 40h + cmp ecx, [esi+4] + pop edi + pop ebx + jz short loc_4D08E3 + +loc_4D08D0: ; CODE XREF: CEncoder_Flush+51j + mov ecx, esi + call sub_4CF450 + test eax, eax + jnz short loc_4D08E5 + mov edx, [esi+0Ch] + cmp edx, [esi+4] + jnz short loc_4D08D0 + +loc_4D08E3: ; CODE XREF: CEncoder_Flush+3Ej + xor eax, eax + +loc_4D08E5: ; CODE XREF: CEncoder_Flush+Bj + ; CEncoder_Flush+49j + pop esi + retn 4 +CEncoder_Flush endp + +; --------------------------------------------------------------------------- + align 10h +; =============== S U B R O U T I N E ======================================= + +CEncoder_CodeOneBlock proc near ; CODE XREF: CEncoder_CodeReal+B1p + ; CEncoder_CodeReal+F5p + +var_20 = byte ptr -20h +var_1C = dword ptr -1Ch +var_18 = dword ptr -18h +var_14 = dword ptr -14h +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_8 = dword ptr -8 +var_4 = dword ptr -4 +arg_0 = dword ptr 4 +arg_4 = dword ptr 8 +arg_8 = dword ptr 0Ch + + sub esp, 20h + push ebp + push esi + mov esi, ecx + push edi + mov edi, [esi+33B84h] + xor ebp, ebp + cmp edi, ebp + jz short loc_4D0952 + mov eax, [edi] + mov ecx, [eax+4] + push edi + call ecx + mov eax, [esi+33B8Ch] + cmp eax, ebp + jz short loc_4D091E + mov edx, [eax] + push eax + mov eax, [edx+8] + call eax + +loc_4D091E: ; CODE XREF: CEncoder_CodeOneBlock+24j + mov [esi+33B8Ch], edi + mov ecx, [esi+80h] + mov edx, [esi+68h] + lea eax, [esi+33B88h] + push ecx + mov dword ptr [eax], offset loc_4CF210 + mov [esi+0B8h], eax + call edx + add esp, 4 + mov byte ptr [esi+33B95h], 1 + mov [esi+33B84h], ebp + +loc_4D0952: ; CODE XREF: CEncoder_CodeOneBlock+12j + mov eax, [esp+2Ch+arg_8] + mov dword ptr [eax], 1 + cmp byte ptr [esi+33B80h], 0 + jz short loc_4D0974 + mov eax, [esi+0ECh] + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D0974: ; CODE XREF: CEncoder_CodeOneBlock+73j + mov ecx, [esi+33B78h] + or ecx, [esi+33B7Ch] + push ebx + mov byte ptr [esi+33B80h], 1 + jnz loc_4D0A9C + mov edx, [esi+80h] + mov eax, [esi+70h] + push edx + call eax + add esp, 4 + test eax, eax + jnz short loc_4D09B9 + mov ecx, [esi+33B78h] + push ecx + mov ecx, esi + call CEncoder_Flush + pop ebx + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D09B9: ; CODE XREF: CEncoder_CodeOneBlock+AFj + lea edx, [esp+30h+var_4] + push edx + mov ecx, esi + call sub_4CB3B0 + movzx ecx, byte ptr [esi+10h] + mov eax, [esi+33B60h] + and eax, [esi+33B78h] + mov edx, [esi+38h] + lea edi, [esi+28h] + shl ecx, 4 + add eax, ecx + shr edx, 0Bh + imul edx, [esi+eax*4+280F0h] + lea eax, [esi+eax*4+280F0h] + mov [edi+10h], edx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0A1C + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0A1C: ; CODE XREF: CEncoder_CodeOneBlock+11Dj + movzx eax, byte ptr [esi+10h] + mov cl, ds:kLiteralNextStates[eax] + mov [esi+10h], cl + mov edx, [esi+32F04h] + mov eax, [esi+80h] + mov ecx, [esi+6Ch] + neg edx + push edx + push eax + call ecx + mov bl, al + mov eax, [esi+32654h] + add esp, 8 + mov byte ptr [esp+30h+var_10], bl + mov edx, [esp+30h+var_10] + push edx + movzx edx, byte ptr [esi+11h] + push edi + mov edi, [esi+3265Ch] + and edi, [esi+33B78h] + mov ecx, 8 + sub cl, al + shr edx, cl + mov ecx, eax + shl edi, cl + add edx, edi + imul edx, 0C00h + add edx, [esi+32650h] + mov ecx, edx + call sub_4CFE30 + add dword ptr [esi+32F04h], 0FFFFFFFFh + add dword ptr [esi+33B78h], 1 + mov [esi+11h], bl + adc [esi+33B7Ch], ebp + +loc_4D0A9C: ; CODE XREF: CEncoder_CodeOneBlock+98j + mov edi, [esi+33B78h] + mov eax, [esi+80h] + mov ecx, [esi+70h] + push eax + mov [esp+34h+var_14], edi + mov [esp+34h+var_4], edi + call ecx + add esp, 4 + test eax, eax + jnz short loc_4D0AD4 + push edi + mov ecx, esi + call CEncoder_Flush + pop ebx + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + align 10h + +loc_4D0AD0: ; CODE XREF: CEncoder_CodeOneBlock+735j + ; CEncoder_CodeOneBlock+78Bj + mov edi, [esp+30h+var_14] + +loc_4D0AD4: ; CODE XREF: CEncoder_CodeOneBlock+1CBj + cmp byte ptr [esi+32EF4h], 0 + mov ecx, esi + jz short loc_4D0AEB + lea edx, [esp+30h+var_1C] + push edx + call CEncoder_GetOptimumFast + jmp short loc_4D0AF6 +; --------------------------------------------------------------------------- + +loc_4D0AEB: ; CODE XREF: CEncoder_CodeOneBlock+1EDj + lea eax, [esp+30h+var_1C] + push eax + push edi + call CEncoder_GetOptimum + +loc_4D0AF6: ; CODE XREF: CEncoder_CodeOneBlock+1F9j + mov ebx, [esi+33B60h] + and ebx, edi + cmp eax, 1 + mov [esp+30h+var_18], eax + jnz loc_4D0C0E + cmp [esp+30h+var_1C], 0FFFFFFFFh + jnz loc_4D0C0E + movzx ecx, byte ptr [esi+10h] + mov edx, [esi+38h] + lea ebp, [esi+28h] + shl ecx, 4 + shr edx, 0Bh + add ecx, ebx + imul edx, [esi+ecx*4+280F0h] + lea eax, [esi+ecx*4+280F0h] + mov [ebp+10h], edx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [ebp+10h] + cmp eax, 1000000h + jnb short loc_4D0B61 + shl eax, 8 + mov ecx, ebp + mov [ebp+10h], eax + call loc_4CF640 + +loc_4D0B61: ; CODE XREF: CEncoder_CodeOneBlock+262j + mov eax, [esi+32F04h] + mov ecx, [esi+80h] + mov edx, [esi+6Ch] + neg eax + push eax + push ecx + call edx + movzx edi, byte ptr [esi+11h] + mov edx, [esi+3265Ch] + and edx, [esp+38h+var_14] + mov bl, al + mov eax, [esi+32654h] + mov ecx, 8 + sub cl, al + shr edi, cl + mov ecx, eax + shl edx, cl + add esp, 8 + mov byte ptr [esp+30h+var_10], bl + add edi, edx + imul edi, 0C00h + add edi, [esi+32650h] + cmp byte ptr [esi+10h], 7 + jnb short loc_4D0BC3 + mov eax, [esp+30h+var_10] + push eax + push ebp + mov ecx, edi + call sub_4CFE30 + jmp short loc_4D0BF5 +; --------------------------------------------------------------------------- + +loc_4D0BC3: ; CODE XREF: CEncoder_CodeOneBlock+2C2j + mov edx, [esi+80h] + mov eax, [esi+6Ch] + or ecx, 0FFFFFFFFh + sub ecx, [esi+14h] + sub ecx, [esi+32F04h] + push ecx + push edx + call eax + mov ecx, [esp+38h+var_10] + add esp, 8 + mov byte ptr [esp+30h+var_C], al + mov edx, [esp+30h+var_C] + push ecx + push edx + push ebp + mov ecx, edi + call sub_4CFED0 + +loc_4D0BF5: ; CODE XREF: CEncoder_CodeOneBlock+2D1j + movzx eax, byte ptr [esi+10h] + mov cl, ds:kLiteralNextStates[eax] + mov ebp, [esp+30h+var_18] + mov [esi+10h], cl + mov [esi+11h], bl + jmp loc_4D1013 +; --------------------------------------------------------------------------- + +loc_4D0C0E: ; CODE XREF: CEncoder_CodeOneBlock+215j + ; CEncoder_CodeOneBlock+220j + movzx edx, byte ptr [esi+10h] + mov ecx, [esi+38h] + lea edi, [esi+28h] + shl edx, 4 + mov eax, ecx + shr eax, 0Bh + add edx, ebx + imul eax, [esi+edx*4+280F0h] + add [edi+8], eax + lea edx, [esi+edx*4+280F0h] + mov ebp, 0 + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0C63 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0C63: ; CODE XREF: CEncoder_CodeOneBlock+364j + cmp [esp+30h+var_1C], 4 + movzx edx, byte ptr [esi+10h] + mov ecx, [edi+10h] + jnb loc_4D0E91 + mov eax, ecx + shr eax, 0Bh + imul eax, [esi+edx*4+283F0h] + add [edi+8], eax + lea edx, [esi+edx*4+283F0h] + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0CB6 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0CB6: ; CODE XREF: CEncoder_CodeOneBlock+3B7j + mov eax, [esp+30h+var_1C] + cmp eax, ebp + mov ecx, [edi+10h] + jnz short loc_4D0D24 + movzx edx, byte ptr [esi+10h] + lea eax, [esi+edx*4+28420h] + shr ecx, 0Bh + imul ecx, [eax] + mov [edi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0CFC + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0CFC: ; CODE XREF: CEncoder_CodeOneBlock+3FDj + mov ebp, [esp+30h+var_18] + movzx ecx, byte ptr [esi+10h] + xor eax, eax + cmp ebp, 1 + setnz al + shl ecx, 4 + add ecx, ebx + lea ecx, [esi+ecx*4+284B0h] + push eax + push edi + call sub_4CFAC0 + jmp loc_4D0E2E +; --------------------------------------------------------------------------- + +loc_4D0D24: ; CODE XREF: CEncoder_CodeOneBlock+3CFj + mov edx, [esi+eax*4+14h] + movzx eax, byte ptr [esi+10h] + mov [esp+30h+var_8], edx + lea edx, [esi+eax*4+28420h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edx] + add [edi+8], eax + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0D6C + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0D6C: ; CODE XREF: CEncoder_CodeOneBlock+46Dj + cmp [esp+30h+var_1C], 1 + mov ecx, [edi+10h] + jnz short loc_4D0DB3 + movzx edx, byte ptr [esi+10h] + lea eax, [esi+edx*4+28450h] + shr ecx, 0Bh + imul ecx, [eax] + mov [edi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0E1D + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + jmp short loc_4D0E1D +; --------------------------------------------------------------------------- + +loc_4D0DB3: ; CODE XREF: CEncoder_CodeOneBlock+484j + movzx eax, byte ptr [esi+10h] + lea edx, [esi+eax*4+28450h] + mov eax, ecx + shr eax, 0Bh + imul eax, [edx] + add [edi+8], eax + adc [edi+0Ch], ebp + sub ecx, eax + mov [edi+10h], ecx + mov eax, [edx] + mov ecx, eax + shr ecx, 5 + sub eax, ecx + mov [edx], eax + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0DF3 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0DF3: ; CODE XREF: CEncoder_CodeOneBlock+4F4j + mov ebp, [esp+30h+var_1C] + movzx eax, byte ptr [esi+10h] + lea edx, [ebp-2] + push edx + push edi + lea ecx, [esi+eax*4+28480h] + call sub_4CFAC0 + cmp ebp, 3 + jnz short loc_4D0E17 + mov ecx, [esi+1Ch] + mov [esi+20h], ecx + +loc_4D0E17: ; CODE XREF: CEncoder_CodeOneBlock+51Fj + mov edx, [esi+18h] + mov [esi+1Ch], edx + +loc_4D0E1D: ; CODE XREF: CEncoder_CodeOneBlock+4B2j + ; CEncoder_CodeOneBlock+4C1j + mov eax, [esi+14h] + mov ecx, [esp+30h+var_8] + mov ebp, [esp+30h+var_18] + mov [esi+18h], eax + mov [esi+14h], ecx + +loc_4D0E2E: ; CODE XREF: CEncoder_CodeOneBlock+42Fj + cmp ebp, 1 + jnz short loc_4D0E45 + movzx edx, byte ptr [esi+10h] + mov al, ds:kShortRepNextStates[edx] + mov [esi+10h], al + jmp loc_4D0FF5 +; --------------------------------------------------------------------------- + +loc_4D0E45: ; CODE XREF: CEncoder_CodeOneBlock+541j + cmp byte ptr [esi+32EF4h], 0 + push ebx + lea edx, [ebp-2] + push edx + lea ecx, [esi+2DA04h] + push edi + setz [esp+3Ch+var_20] + call sub_4D0020 + cmp [esp+30h+var_20], 0 + jz short loc_4D0E7F + add dword ptr [esi+ebx*4+32610h], 0FFFFFFFFh + lea ecx, [esi+2DA04h] + jnz short loc_4D0E7F + push ebx + call sub_4CF740 + +loc_4D0E7F: ; CODE XREF: CEncoder_CodeOneBlock+577j + ; CEncoder_CodeOneBlock+587j + movzx eax, byte ptr [esi+10h] + mov cl, ds:kRepNextStates[eax] + mov [esi+10h], cl + jmp loc_4D0FF5 +; --------------------------------------------------------------------------- + +loc_4D0E91: ; CODE XREF: CEncoder_CodeOneBlock+37Fj + lea eax, [esi+edx*4+283F0h] + shr ecx, 0Bh + imul ecx, [eax] + mov [edi+10h], ecx + mov ecx, [eax] + mov edx, 800h + sub edx, ecx + shr edx, 5 + add edx, ecx + mov [eax], edx + mov eax, [edi+10h] + cmp eax, 1000000h + jnb short loc_4D0EC8 + shl eax, 8 + mov ecx, edi + mov [edi+10h], eax + call loc_4CF640 + +loc_4D0EC8: ; CODE XREF: CEncoder_CodeOneBlock+5C9j + movzx eax, byte ptr [esi+10h] + mov cl, ds:kMatchNextStates[eax] + mov eax, [esp+30h+var_18] + mov [esi+10h], cl + cmp byte ptr [esi+32EF4h], 0 + push ebx + setz [esp+34h+var_20] + add eax, 0FFFFFFFEh + push eax + lea ebp, [esi+28DB8h] + push edi + mov ecx, ebp + call sub_4D0020 + cmp [esp+30h+var_20], 0 + jz short loc_4D0F11 + add dword ptr [ebp+ebx*4+4C0Ch], 0FFFFFFFFh + jnz short loc_4D0F11 + push ebx + mov ecx, ebp + call sub_4CF740 + +loc_4D0F11: ; CODE XREF: CEncoder_CodeOneBlock+60Dj + ; CEncoder_CodeOneBlock+617j + mov eax, [esp+30h+var_1C] + sub eax, 4 + cmp eax, 2000h + mov [esp+30h+var_1C], eax + jnb short loc_4D0F2C + movzx ebp, byte ptr dword_551198[eax] + jmp short loc_4D0F4F +; --------------------------------------------------------------------------- + +loc_4D0F2C: ; CODE XREF: CEncoder_CodeOneBlock+631j + cmp eax, 2000000h + jnb short loc_4D0F42 + shr eax, 0Ch + movzx ebp, byte ptr dword_551198[eax] + add ebp, 18h + jmp short loc_4D0F4F +; --------------------------------------------------------------------------- + +loc_4D0F42: ; CODE XREF: CEncoder_CodeOneBlock+641j + shr eax, 18h + movzx ebp, byte ptr dword_551198[eax] + add ebp, 30h + +loc_4D0F4F: ; CODE XREF: CEncoder_CodeOneBlock+63Aj + ; CEncoder_CodeOneBlock+650j + mov eax, [esp+30h+var_18] + add eax, 0FFFFFFFEh + cmp eax, 4 + jb short loc_4D0F60 + mov eax, 3 + +loc_4D0F60: ; CODE XREF: CEncoder_CodeOneBlock+669j + push ebp + shl eax, 8 + push edi + lea ecx, [eax+esi+287B0h] + call sub_4CFC60 + cmp ebp, 4 + jb short loc_4D0FD1 + mov ebx, [esp+30h+var_1C] + mov ecx, ebp + mov eax, ebp + and eax, 1 + shr ecx, 1 + sub ecx, 1 + or eax, 2 + shl eax, cl + sub ebx, eax + cmp ebp, 0Eh + jnb short loc_4D0FA9 + push ebx + push ecx + sub eax, ebp + lea edx, [esi+eax*4+28BACh] + push edi + push edx + call sub_4CFD90 + add esp, 10h + jmp short loc_4D0FD1 +; --------------------------------------------------------------------------- + +loc_4D0FA9: ; CODE XREF: CEncoder_CodeOneBlock+6A0j + add ecx, 0FFFFFFFCh + push ecx + mov eax, ebx + shr eax, 4 + push eax + mov ecx, edi + call sub_4CF6E0 + and ebx, 0Fh + push ebx + push edi + lea ecx, [esi+28D78h] + call sub_4CFD00 + add dword ptr [esi+33B54h], 1 + +loc_4D0FD1: ; CODE XREF: CEncoder_CodeOneBlock+684j + ; CEncoder_CodeOneBlock+6B7j + mov ecx, [esi+1Ch] + mov edx, [esi+18h] + mov eax, [esi+14h] + add dword ptr [esi+33B70h], 1 + mov ebp, [esp+30h+var_18] + mov [esi+20h], ecx + mov ecx, [esp+30h+var_1C] + mov [esi+1Ch], edx + mov [esi+18h], eax + mov [esi+14h], ecx + +loc_4D0FF5: ; CODE XREF: CEncoder_CodeOneBlock+550j + ; CEncoder_CodeOneBlock+59Cj + mov eax, [esi+80h] + mov ecx, [esi+6Ch] + mov edx, ebp + sub edx, [esi+32F04h] + sub edx, 1 + push edx + push eax + call ecx + add esp, 8 + mov [esi+11h], al + +loc_4D1013: ; CODE XREF: CEncoder_CodeOneBlock+319j + sub [esi+32F04h], ebp + mov eax, [esi+32F04h] + add [esp+30h+var_14], ebp + test eax, eax + jnz loc_4D0AD0 + cmp [esi+32EF4h], al + jnz short loc_4D1056 + cmp dword ptr [esi+33B70h], 80h + jb short loc_4D1046 + mov ecx, esi + call CEncoder_FillDistancesPrices + +loc_4D1046: ; CODE XREF: CEncoder_CodeOneBlock+74Dj + cmp dword ptr [esi+33B54h], 10h + jb short loc_4D1056 + mov ecx, esi + call CEncoder_FillAlignPrices + +loc_4D1056: ; CODE XREF: CEncoder_CodeOneBlock+741j + ; CEncoder_CodeOneBlock+75Dj + mov edx, [esi+80h] + mov eax, [esi+70h] + push edx + call eax + add esp, 4 + test eax, eax + mov eax, [esp+30h+var_14] + jz short loc_4D10D7 + mov ecx, [esp+30h+var_4] + mov edx, eax + sub edx, ecx + cmp edx, 4000h + jb loc_4D0AD0 + sub eax, ecx + add [esi+33B78h], eax + mov ecx, [esi+33B78h] + mov eax, [esp+30h+arg_0] + adc dword ptr [esi+33B7Ch], 0 + mov [eax], ecx + mov edx, [esi+33B7Ch] + lea ecx, [esi+28h] + mov [eax+4], edx + call sub_4CD8B0 + mov ecx, [esp+30h+arg_4] + mov [ecx], eax + mov eax, [esp+30h+arg_8] + mov [ecx+4], edx + pop ebx + mov byte ptr [esi+33B80h], 0 + pop edi + mov dword ptr [eax], 0 + mov eax, [esi+0ECh] + pop esi + pop ebp + add esp, 20h + retn 0Ch +; --------------------------------------------------------------------------- + +loc_4D10D7: ; CODE XREF: CEncoder_CodeOneBlock+77Bj + push eax + mov ecx, esi + call CEncoder_Flush + pop ebx + pop edi + pop esi + pop ebp + add esp, 20h + retn 0Ch +CEncoder_CodeOneBlock endp + +; --------------------------------------------------------------------------- + align 10h +CEncoder_CodeReal proc near ; CODE XREF: CEncoder_Code+49p + +var_20 = dword ptr -20h +processedOutSize= byte ptr -1Ch +processedInSize = byte ptr -14h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +inStream = dword ptr 4 +outStream = dword ptr 8 +inSize = dword ptr 0Ch +outSize = dword ptr 10h +progress = dword ptr 14h + + push 0FFFFFFFFh + push offset loc_4DA128 + mov eax, dword ptr fs:[0] + push eax + sub esp, 14h + push ebp + push esi + push edi + mov eax, dword_544960 + xor eax, esp + push eax + lea eax, [esp+30h+var_C] + mov dword ptr fs:[0], eax + mov esi, ecx + mov [esp+30h+var_20], esi + mov eax, [esp+30h+outSize] + mov ecx, [esp+30h+inSize] + mov edx, [esp+30h+outStream] + push eax + mov eax, [esp+34h+inStream] + push ecx + push edx + push eax + mov ecx, esi + mov [esp+40h+var_4], 0 + call CEncoder_SetStreams + mov edi, eax + test edi, edi + jz short loc_4D1190 + cmp dword ptr [esi+80h], 0 + mov [esp+30h+var_4], 0FFFFFFFFh + jz short loc_4D1166 + cmp byte ptr [esi+33B95h], 0 + jz short loc_4D1166 + mov byte ptr [esi+33B95h], 0 + +loc_4D1166: ; CODE XREF: CEncoder_CodeReal+64j + ; CEncoder_CodeReal+6Dj + mov eax, [esi+33B8Ch] + test eax, eax + jz short loc_4D1182 + mov ecx, [eax] + mov edx, [ecx+8] + push eax + call edx + mov dword ptr [esi+33B8Ch], 0 + +loc_4D1182: ; CODE XREF: CEncoder_CodeReal+7Ej + mov ecx, [esi+4] + mov edx, [ecx+10h] + lea eax, [esi+4] + push eax + call edx + jmp short loc_4D1201 +; --------------------------------------------------------------------------- + +loc_4D1190: ; CODE XREF: CEncoder_CodeReal+53j + lea eax, [esp+30h+outSize] + push eax + lea ecx, [esp+34h+processedOutSize] + push ecx + lea edx, [esp+38h+processedInSize] + push edx + mov ecx, esi + call CEncoder_CodeOneBlock + mov edi, eax + test edi, edi + jnz short loc_4D11F0 + mov ebp, [esp+30h+progress] + +loc_4D11B0: ; CODE XREF: CEncoder_CodeReal+FEj + cmp [esp+30h+outSize], 0 + jnz short loc_4D1218 + test ebp, ebp + jz short loc_4D11D4 + mov eax, [ebp+0] + mov eax, [eax+0Ch] + lea ecx, [esp+30h+processedOutSize] + push ecx + lea edx, [esp+34h+processedInSize] + push edx + push ebp + call eax ; SetRatioInfo + mov edi, eax + test edi, edi + jnz short loc_4D11F0 + +loc_4D11D4: ; CODE XREF: CEncoder_CodeReal+C9j + lea ecx, [esp+30h+outSize] + push ecx + lea edx, [esp+34h+processedOutSize] + push edx + lea eax, [esp+38h+processedInSize] + push eax + mov ecx, esi + call CEncoder_CodeOneBlock + mov edi, eax + test edi, edi + jz short loc_4D11B0 + +loc_4D11F0: ; CODE XREF: CEncoder_CodeReal+BAj + ; CEncoder_CodeReal+E2j + lea ecx, [esp+30h+var_20] + mov [esp+30h+var_4], 0FFFFFFFFh + call sub_4CDA70 + +loc_4D1201: ; CODE XREF: CEncoder_CodeReal+9Ej + mov eax, edi + mov ecx, [esp+30h+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebp + add esp, 20h + retn 14h +; --------------------------------------------------------------------------- + +loc_4D1218: ; CODE XREF: CEncoder_CodeReal+C5j + lea ecx, [esp+30h+var_20] + mov [esp+30h+var_4], 0FFFFFFFFh + call sub_4CDA70 + xor eax, eax + mov ecx, [esp+30h+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebp + add esp, 20h + retn 14h +CEncoder_CodeReal endp + +; =============== S U B R O U T I N E ======================================= +; Attributes: bp-based frame + +CEncoder_Code proc near ; DATA XREF: .rdata:00517B08o +; sub_4D1240 + +var_10 = dword ptr -10h +var_C = dword ptr -0Ch +var_4 = dword ptr -4 +pThis = dword ptr 8 +pInStream = dword ptr 0Ch +pOutStream = dword ptr 10h +pInSize = dword ptr 14h +pOutSize = dword ptr 18h +progress = dword ptr 1Ch + + push ebp + mov ebp, esp + push 0FFFFFFFFh + push offset loc_4DA150 + mov eax, dword ptr fs:[0] + push eax + sub esp, 8 + push ebx + push esi + push edi + mov eax, dword_544960 + xor eax, ebp + push eax + lea eax, [ebp+var_C] + mov dword ptr fs:[0], eax + mov [ebp+var_10], esp + mov eax, [ebp+progress] + mov ecx, [ebp+pOutSize] + mov edx, [ebp+pInSize] + push eax + mov eax, [ebp+pOutStream] + push ecx + mov ecx, [ebp+pInStream] + push edx + push eax + push ecx + mov ecx, [ebp+pThis] + mov [ebp+var_4], 0 + call CEncoder_CodeReal + mov ecx, [ebp+var_C] + mov dword ptr fs:[0], ecx + pop ecx + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + retn 18h +CEncoder_Code endp + +; --------------------------------------------------------------------------- + +loc_4DA0FB: ; DATA XREF: Compress_lzma_internal+2o + mov edx, [esp+8] + lea eax, [edx-5Ch] + mov ecx, [edx-60h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset dword_526E44 + int 3; +; jmp ___CxxFrameHandler3 + +loc_4DA0C9: ; DATA XREF: sub_4CF810+2o + mov edx, [esp+8] + lea eax, [edx-0Ch] + mov ecx, [edx-10h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset dword_526E18 + int 3; +; jmp ___CxxFrameHandler3 + +loc_4DA128: ; DATA XREF: CEncoder_CodeReal+2o + mov edx, [esp+8] + lea eax, [edx-20h] + mov ecx, [edx-24h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset unk_526E70 + int 3; +; jmp ___CxxFrameHandler3 + +loc_4DA150: ; DATA XREF: CEncoder_Code+5o + mov edx, [esp+8] + lea eax, [edx+0Ch] + mov ecx, [edx-18h] + xor ecx, eax + call sub_4A0686 + mov eax, 0 ; offset unk_526ED8 + int 3; +; jmp ___CxxFrameHandler3 + +END diff --git a/dep/acelite/CMakeLists.txt b/dep/acelite/CMakeLists.txt index 7cc577c21..7b24f491c 100644 --- a/dep/acelite/CMakeLists.txt +++ b/dep/acelite/CMakeLists.txt @@ -16,340 +16,4 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -project(ACE VERSION 6.5.5) - -set(ACE_SOURCES - ace/ACE.cpp - ace/ACE_crc32.cpp - ace/ACE_crc_ccitt.cpp - ace/ATM_Acceptor.cpp - ace/ATM_Addr.cpp - ace/ATM_Connector.cpp - ace/ATM_Params.cpp - ace/ATM_QoS.cpp - ace/ATM_Stream.cpp - ace/Activation_Queue.cpp - ace/Active_Map_Manager.cpp - ace/Addr.cpp - ace/Argv_Type_Converter.cpp - ace/Assert.cpp - ace/Asynch_IO.cpp - ace/Asynch_IO_Impl.cpp - ace/Asynch_Pseudo_Task.cpp - ace/Atomic_Op.cpp - ace/Barrier.cpp - ace/Base_Thread_Adapter.cpp - ace/Based_Pointer_Repository.cpp - ace/Basic_Stats.cpp - ace/Basic_Types.cpp - ace/CDR_Base.cpp - ace/CDR_Size.cpp - ace/CDR_Stream.cpp - ace/Capabilities.cpp - ace/Cleanup.cpp - ace/Codecs.cpp - ace/Codeset_IBM1047.cpp - ace/Codeset_Registry.cpp - ace/Codeset_Registry_db.cpp - ace/Condition_Attributes.cpp - ace/Condition_Recursive_Thread_Mutex.cpp - ace/Condition_Thread_Mutex.cpp - ace/Configuration.cpp - ace/Configuration_Import_Export.cpp - ace/Connection_Recycling_Strategy.cpp - ace/Containers.cpp - ace/Copy_Disabled.cpp - ace/DEV.cpp - ace/DEV_Addr.cpp - ace/DEV_Connector.cpp - ace/DEV_IO.cpp - ace/DLL.cpp - ace/DLL_Manager.cpp - ace/Date_Time.cpp - ace/Dev_Poll_Reactor.cpp - ace/Dirent.cpp - ace/Dirent_Selector.cpp - ace/Dump.cpp - ace/Dynamic.cpp - ace/Dynamic_Message_Strategy.cpp - ace/Dynamic_Service_Base.cpp - ace/Dynamic_Service_Dependency.cpp - ace/Encoding_Converter.cpp - ace/Encoding_Converter_Factory.cpp - ace/Event_Base.cpp - ace/Event_Handler.cpp - ace/Event_Handler_Handle_Timeout_Upcall.cpp - ace/FIFO.cpp - ace/FIFO_Recv.cpp - ace/FIFO_Recv_Msg.cpp - ace/FIFO_Send.cpp - ace/FIFO_Send_Msg.cpp - ace/FILE.cpp - ace/FILE_Addr.cpp - ace/FILE_Connector.cpp - ace/FILE_IO.cpp - ace/File_Lock.cpp - ace/Filecache.cpp - ace/Flag_Manip.cpp - ace/Framework_Component.cpp - ace/Functor.cpp - ace/Functor_String.cpp - ace/Get_Opt.cpp - ace/Handle_Ops.cpp - ace/Handle_Set.cpp - ace/Hashable.cpp - ace/High_Res_Timer.cpp - ace/ICMP_Socket.cpp - ace/INET_Addr.cpp - ace/IOStream.cpp - ace/IO_Cntl_Msg.cpp - ace/IO_SAP.cpp - ace/IPC_SAP.cpp - ace/Init_ACE.cpp - ace/LSOCK.cpp - ace/LSOCK_Acceptor.cpp - ace/LSOCK_CODgram.cpp - ace/LSOCK_Connector.cpp - ace/LSOCK_Dgram.cpp - ace/LSOCK_Stream.cpp - ace/Lib_Find.cpp - ace/Local_Memory_Pool.cpp - ace/Local_Name_Space.cpp - ace/Local_Tokens.cpp - ace/Lock.cpp - ace/Log_Category.cpp - ace/Log_Msg.cpp - ace/Log_Msg_Android_Logcat.cpp - ace/Log_Msg_Backend.cpp - ace/Log_Msg_Callback.cpp - ace/Log_Msg_IPC.cpp - ace/Log_Msg_NT_Event_Log.cpp - ace/Log_Msg_UNIX_Syslog.cpp - ace/Log_Record.cpp - ace/Logging_Strategy.cpp - ace/MEM_Acceptor.cpp - ace/MEM_Addr.cpp - ace/MEM_Connector.cpp - ace/MEM_IO.cpp - ace/MEM_SAP.cpp - ace/MEM_Stream.cpp - ace/MMAP_Memory_Pool.cpp - ace/Malloc.cpp - ace/Malloc_Allocator.cpp - ace/Mem_Map.cpp - ace/Message_Block.cpp - ace/Message_Queue.cpp - ace/Message_Queue_NT.cpp - ace/Message_Queue_Vx.cpp - ace/Method_Request.cpp - ace/Monitor_Admin.cpp - ace/Monitor_Admin_Manager.cpp - ace/Monitor_Base.cpp - ace/Monitor_Control_Action.cpp - ace/Monitor_Control_Types.cpp - ace/Monitor_Point_Registry.cpp - ace/Monitor_Size.cpp - ace/Monotonic_Time_Policy.cpp - ace/Msg_WFMO_Reactor.cpp - ace/Multihomed_INET_Addr.cpp - ace/Mutex.cpp - ace/NT_Service.cpp - ace/Name_Proxy.cpp - ace/Name_Request_Reply.cpp - ace/Name_Space.cpp - ace/Naming_Context.cpp - ace/Netlink_Addr.cpp - ace/Notification_Queue.cpp - ace/Notification_Strategy.cpp - ace/Null_Mutex.cpp - ace/OS_Errno.cpp - ace/OS_Log_Msg_Attributes.cpp - ace/OS_NS_Thread.cpp - ace/OS_NS_arpa_inet.cpp - ace/OS_NS_ctype.cpp - ace/OS_NS_devctl.cpp - ace/OS_NS_dirent.cpp - ace/OS_NS_dlfcn.cpp - ace/OS_NS_errno.cpp - ace/OS_NS_fcntl.cpp - ace/OS_NS_math.cpp - ace/OS_NS_netdb.cpp - ace/OS_NS_poll.cpp - ace/OS_NS_pwd.cpp - ace/OS_NS_regex.cpp - ace/OS_NS_signal.cpp - ace/OS_NS_stdio.cpp - ace/OS_NS_stdlib.cpp - ace/OS_NS_string.cpp - ace/OS_NS_strings.cpp - ace/OS_NS_stropts.cpp - ace/OS_NS_sys_mman.cpp - ace/OS_NS_sys_msg.cpp - ace/OS_NS_sys_resource.cpp - ace/OS_NS_sys_select.cpp - ace/OS_NS_sys_sendfile.cpp - ace/OS_NS_sys_shm.cpp - ace/OS_NS_sys_socket.cpp - ace/OS_NS_sys_stat.cpp - ace/OS_NS_sys_time.cpp - ace/OS_NS_sys_uio.cpp - ace/OS_NS_sys_utsname.cpp - ace/OS_NS_sys_wait.cpp - ace/OS_NS_time.cpp - ace/OS_NS_unistd.cpp - ace/OS_NS_wchar.cpp - ace/OS_NS_wctype.cpp - ace/OS_QoS.cpp - ace/OS_TLI.cpp - ace/OS_Thread_Adapter.cpp - ace/OS_main.cpp - ace/Obchunk.cpp - ace/Object_Manager.cpp - ace/Object_Manager_Base.cpp - ace/Obstack.cpp - ace/PI_Malloc.cpp - ace/POSIX_Asynch_IO.cpp - ace/POSIX_CB_Proactor.cpp - ace/POSIX_Proactor.cpp - ace/Pagefile_Memory_Pool.cpp - ace/Parse_Node.cpp - ace/Ping_Socket.cpp - ace/Pipe.cpp - ace/Priority_Reactor.cpp - ace/Proactor.cpp - ace/Proactor_Impl.cpp - ace/Process.cpp - ace/Process_Manager.cpp - ace/Process_Mutex.cpp - ace/Process_Semaphore.cpp - ace/Profile_Timer.cpp - ace/RW_Mutex.cpp - ace/RW_Process_Mutex.cpp - ace/RW_Thread_Mutex.cpp - ace/Reactor.cpp - ace/Reactor_Impl.cpp - ace/Reactor_Notification_Strategy.cpp - ace/Reactor_Timer_Interface.cpp - ace/Read_Buffer.cpp - ace/Recursive_Thread_Mutex.cpp - ace/Recyclable.cpp - ace/Registry.cpp - ace/Registry_Name_Space.cpp - ace/Remote_Name_Space.cpp - ace/Remote_Tokens.cpp - ace/SOCK.cpp - ace/SOCK_Acceptor.cpp - ace/SOCK_CODgram.cpp - ace/SOCK_Connector.cpp - ace/SOCK_Dgram.cpp - ace/SOCK_Dgram_Bcast.cpp - ace/SOCK_Dgram_Mcast.cpp - ace/SOCK_IO.cpp - ace/SOCK_Netlink.cpp - ace/SOCK_SEQPACK_Acceptor.cpp - ace/SOCK_SEQPACK_Association.cpp - ace/SOCK_SEQPACK_Connector.cpp - ace/SOCK_Stream.cpp - ace/SPIPE.cpp - ace/SPIPE_Acceptor.cpp - ace/SPIPE_Addr.cpp - ace/SPIPE_Connector.cpp - ace/SPIPE_Stream.cpp - ace/SString.cpp - ace/SUN_Proactor.cpp - ace/SV_Message.cpp - ace/SV_Message_Queue.cpp - ace/SV_Semaphore_Complex.cpp - ace/SV_Semaphore_Simple.cpp - ace/SV_Shared_Memory.cpp - ace/Sample_History.cpp - ace/Sbrk_Memory_Pool.cpp - ace/Sched_Params.cpp - ace/Select_Reactor_Base.cpp - ace/Semaphore.cpp - ace/Service_Config.cpp - ace/Service_Gestalt.cpp - ace/Service_Manager.cpp - ace/Service_Object.cpp - ace/Service_Repository.cpp - ace/Service_Types.cpp - ace/Shared_Memory.cpp - ace/Shared_Memory_MM.cpp - ace/Shared_Memory_Pool.cpp - ace/Shared_Memory_SV.cpp - ace/Shared_Object.cpp - ace/Sig_Adapter.cpp - ace/Sig_Handler.cpp - ace/Signal.cpp - ace/Sock_Connect.cpp - ace/Stack_Trace.cpp - ace/Stats.cpp - ace/String_Base_Const.cpp - ace/Svc_Conf_Lexer.cpp - ace/Svc_Conf_y.cpp - ace/Synch_Options.cpp - ace/System_Time.cpp - ace/TLI.cpp - ace/TLI_Acceptor.cpp - ace/TLI_Connector.cpp - ace/TLI_Stream.cpp - ace/TP_Reactor.cpp - ace/TSS_Adapter.cpp - ace/TTY_IO.cpp - ace/Task.cpp - ace/Thread.cpp - ace/Thread_Adapter.cpp - ace/Thread_Control.cpp - ace/Thread_Exit.cpp - ace/Thread_Hook.cpp - ace/Thread_Manager.cpp - ace/Thread_Mutex.cpp - ace/Thread_Semaphore.cpp - ace/Throughput_Stats.cpp - ace/Time_Policy.cpp - ace/Time_Value.cpp - ace/Timeprobe.cpp - ace/Token.cpp - ace/Token_Collection.cpp - ace/Token_Invariants.cpp - ace/Token_Manager.cpp - ace/Token_Request_Reply.cpp - ace/Trace.cpp - ace/UNIX_Addr.cpp - ace/UPIPE_Acceptor.cpp - ace/UPIPE_Connector.cpp - ace/UPIPE_Stream.cpp - ace/UTF16_Encoding_Converter.cpp - ace/UTF32_Encoding_Converter.cpp - ace/UTF8_Encoding_Converter.cpp - ace/UUID.cpp - ace/WFMO_Reactor.cpp - ace/WIN32_Asynch_IO.cpp - ace/WIN32_Proactor.cpp - ace/XML_Svc_Conf.cpp - ace/XTI_ATM_Mcast.cpp - ace/ace_wchar.cpp - $<$: - pch.cpp - pch.h - > -) - -add_library(ace STATIC - ${ACE_SOURCES} -) - -target_include_directories(ace - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_compile_definitions(ace - PUBLIC - ACE_AS_STATIC_LIBS - $<$:_WANT_SEMUN> -) - -if(PCH) - add_cxx_pch(ace ${CMAKE_CURRENT_SOURCE_DIR}/pch.h ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp) -endif() \ No newline at end of file +add_subdirectory(ace) diff --git a/dep/acelite/ace/ACE.cpp b/dep/acelite/ace/ACE.cpp index 7a26dff29..36c153c21 100644 --- a/dep/acelite/ace/ACE.cpp +++ b/dep/acelite/ace/ACE.cpp @@ -1,3 +1,5 @@ +// $Id: ACE.cpp 97355 2013-09-27 22:16:09Z shuston $ + #include "ace/ACE.h" #include "ace/Basic_Types.h" @@ -108,12 +110,6 @@ ACE::beta_version (void) return ACE_BETA_VERSION; } -u_int -ACE::micro_version (void) -{ - return ACE_MICRO_VERSION; -} - const ACE_TCHAR * ACE::compiler_name (void) { @@ -164,9 +160,7 @@ ACE::nibble2hex (u_int n) bool ACE::debug (void) { - //FUZZ: disable check_for_ace_log_categories - static const char *debug = ACE_OS::getenv ("ACE_DEBUG"); - //FUZZ: enable check_for_ace_log_categories + static const char* debug = ACE_OS::getenv ("ACELIB_DEBUG"); return (ACE::debug_ != 0) ? ACE::debug_ : (debug != 0 ? (*debug != '0') : false); } @@ -917,7 +911,7 @@ ACE::recv_n_i (ACE_HANDLE handle, // number of (char *ptr, int len) tuples. However, the count N is the // *total* number of trailing arguments, *not* a couple of the number // of tuple pairs! -#if !defined (ACE_LACKS_VA_FUNCTIONS) + ssize_t ACE::recv (ACE_HANDLE handle, size_t n, ...) { @@ -927,16 +921,9 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...) #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -949,17 +936,11 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...) ssize_t const result = ACE_OS::recvv (handle, iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; } -#endif /* ACE_LACKS_VA_FUNCTIONS */ - ssize_t ACE::recvv (ACE_HANDLE handle, @@ -1550,7 +1531,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, { // Check for possible blocking. if (n == -1 && - (errno == EWOULDBLOCK || errno == ENOBUFS)) + errno == EWOULDBLOCK || errno == ENOBUFS) { // Wait upto for the blocking to subside. int const rtn = ACE::handle_write_ready (handle, timeout); @@ -1705,7 +1686,7 @@ ACE::send_n_i (ACE_HANDLE handle, // the ints (basically, an varargs version of writev). The count N is // the *total* number of trailing arguments, *not* a couple of the // number of tuple pairs! -#if !defined (ACE_LACKS_VA_FUNCTIONS) + ssize_t ACE::send (ACE_HANDLE handle, size_t n, ...) { @@ -1715,16 +1696,9 @@ ACE::send (ACE_HANDLE handle, size_t n, ...) #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -1737,16 +1711,11 @@ ACE::send (ACE_HANDLE handle, size_t n, ...) ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; } -#endif /* ACE_LACKS_VA_FUNCTIONS */ ssize_t ACE::sendv (ACE_HANDLE handle, @@ -2318,7 +2287,6 @@ ACE::format_hexdump (const char *buffer, // We can fit 16 bytes output in text mode per line, 4 chars per byte. size_t maxlen = (obuf_sz / 68) * 16; - const ACE_TCHAR *const obuf_start = obuf; if (size > maxlen) size = maxlen; @@ -2333,20 +2301,22 @@ ACE::format_hexdump (const char *buffer, for (j = 0 ; j < 16; j++) { c = (u_char) buffer[(i << 4) + j]; // or, buffer[i*16+j] - ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start), + ACE_OS::sprintf (obuf, ACE_TEXT ("%02x "), c); obuf += 3; if (j == 7) { - *obuf++ = ACE_TEXT (' '); + ACE_OS::sprintf (obuf, + ACE_TEXT (" ")); + ++obuf; } textver[j] = ACE_OS::ace_isprint (c) ? c : u_char ('.'); } textver[j] = 0; - ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start), + ACE_OS::sprintf (obuf, #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) ACE_TEXT (" %ls\n"), #else @@ -2363,31 +2333,35 @@ ACE::format_hexdump (const char *buffer, for (i = 0 ; i < size % 16; i++) { c = (u_char) buffer[size - size % 16 + i]; - ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start), + ACE_OS::sprintf (obuf, ACE_TEXT ("%02x "), c); obuf += 3; if (i == 7) { - *obuf++ = ACE_TEXT (' '); + ACE_OS::sprintf (obuf, + ACE_TEXT (" ")); + ++obuf; } textver[i] = ACE_OS::ace_isprint (c) ? c : u_char ('.'); } for (i = size % 16; i < 16; i++) { - ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start), + ACE_OS::sprintf (obuf, ACE_TEXT (" ")); obuf += 3; if (i == 7) { - *obuf++ = ACE_TEXT (' '); + ACE_OS::sprintf (obuf, + ACE_TEXT (" ")); + ++obuf; } textver[i] = ' '; } textver[i] = 0; - ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start), + ACE_OS::sprintf (obuf, #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) ACE_TEXT (" %ls\n"), #else @@ -2398,10 +2372,11 @@ ACE::format_hexdump (const char *buffer, return size; } -/// Returns the current timestamp in the form -/// "hour:minute:second:microsecond." The month, day, and year are -/// also stored in the beginning of the date_and_time array -/// using ISO-8601 format. +// Returns the current timestamp in the form +// "hour:minute:second:microsecond." The month, day, and year are +// also stored in the beginning of the date_and_time array +// using ISO-8601 format. + ACE_TCHAR * ACE::timestamp (ACE_TCHAR date_and_time[], size_t date_and_timelen, @@ -2413,12 +2388,13 @@ ACE::timestamp (ACE_TCHAR date_and_time[], return_pointer_to_first_digit); } -/// Returns the given timestamp in the form -/// "hour:minute:second:microsecond." The month, day, and year are -/// also stored in the beginning of the date_and_time array -/// using ISO-8601 format. -/// 012345678901234567890123456 -/// 2010-12-02 12:56:00.123456 +// Returns the given timestamp in the form +// "hour:minute:second:microsecond." The month, day, and year are +// also stored in the beginning of the date_and_time array +// using ISO-8601 format. +// 012345678901234567890123456 +// 2010-12-02 12:56:00.123456 + ACE_TCHAR * ACE::timestamp (const ACE_Time_Value& time_value, ACE_TCHAR date_and_time[], @@ -2455,7 +2431,8 @@ ACE::timestamp (const ACE_Time_Value& time_value, return &date_and_time[10 + (return_pointer_to_first_digit != 0)]; } -/// This function rounds the request to a multiple of the page size. +// This function rounds the request to a multiple of the page size. + size_t ACE::round_to_pagesize (size_t len) { @@ -2637,7 +2614,8 @@ ACE::handle_timed_complete (ACE_HANDLE h, return h; } -/// Wait up to @a timeout amount of time to accept a connection. +// Wait up to amount of time to accept a connection. + int ACE::handle_timed_accept (ACE_HANDLE listener, ACE_Time_Value *timeout, @@ -2706,8 +2684,9 @@ ACE::handle_timed_accept (ACE_HANDLE listener, } } -/// Make the current process a UNIX daemon. This is based on Stevens -/// code from APUE. +// Make the current process a UNIX daemon. This is based on Stevens +// code from APUE. + int ACE::daemonize (const ACE_TCHAR pathname[], bool close_all_handles, @@ -2839,7 +2818,7 @@ ACE::max_handles (void) # endif /* RLIM_INFINITY */ #endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */ -#if defined (_SC_OPEN_MAX) && !defined (ACE_LACKS_SYSCONF) +#if defined (_SC_OPEN_MAX) return static_cast (ACE_OS::sysconf (_SC_OPEN_MAX)); #elif defined (FD_SETSIZE) return FD_SETSIZE; @@ -2911,7 +2890,7 @@ ACE::set_handle_limit (int new_limit, return 0; } -/// Euclid's greatest common divisor algorithm. +// Euclid's greatest common divisor algorithm. u_long ACE::gcd (u_long x, u_long y) { @@ -2926,7 +2905,7 @@ ACE::gcd (u_long x, u_long y) } -/// Calculates the minimum enclosing frame size for the given values. +// Calculates the minimum enclosing frame size for the given values. u_long ACE::minimum_frame_size (u_long period1, u_long period2) { @@ -3127,9 +3106,7 @@ ACE::sock_error (int error) return ACE_TEXT ("destination address required"); /* NOTREACHED */ default: - ACE_OS::snprintf (unknown_msg, - sizeof unknown_msg / sizeof unknown_msg[0], - ACE_TEXT ("unknown error: %d"), error); + ACE_OS::sprintf (unknown_msg, ACE_TEXT ("unknown error: %d"), error); return unknown_msg; /* NOTREACHED */ } @@ -3213,15 +3190,9 @@ ACE::strndup (const char *str, size_t n) continue; char *s; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (s, - (char *) ACE_Allocator::instance()->malloc (len + 1), - 0); -#else ACE_ALLOCATOR_RETURN (s, (char *) ACE_OS::malloc (len + 1), 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ return ACE_OS::strsncpy (s, str, len + 1); } @@ -3240,18 +3211,11 @@ ACE::strndup (const wchar_t *str, size_t n) len++) continue; - size_t const size = (len + 1) * sizeof (wchar_t); - wchar_t *s = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) + wchar_t *s; ACE_ALLOCATOR_RETURN (s, - static_cast ( - ACE_Allocator::instance ()->malloc (size)), + static_cast ( + ACE_OS::malloc ((len + 1) * sizeof (wchar_t))), 0); -#else - ACE_ALLOCATOR_RETURN (s, - static_cast (ACE_OS::malloc (size)), - 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ return ACE_OS::strsncpy (s, str, len + 1); } #endif /* ACE_HAS_WCHAR */ @@ -3271,17 +3235,9 @@ ACE::strnnew (const char *str, size_t n) continue; char *s; - -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (s, - static_cast (ACE_Allocator::instance ()->malloc (sizeof (char) * (len + 1))), - 0); -#else ACE_NEW_RETURN (s, char[len + 1], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ - return ACE_OS::strsncpy (s, str, len + 1); } @@ -3334,16 +3290,9 @@ ACE::strnew (const char *s) if (s == 0) return 0; char *t = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (t, - static_cast (ACE_Allocator::instance ()->malloc (sizeof (char) * (ACE_OS::strlen (s) + 1))), - 0); -#else ACE_NEW_RETURN (t, char [ACE_OS::strlen (s) + 1], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ - return ACE_OS::strcpy (t, s); } @@ -3353,19 +3302,10 @@ ACE::strnew (const wchar_t *s) { if (s == 0) return 0; - - size_t const n = ACE_OS::strlen (s) + 1; wchar_t *t = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (t, - static_cast ( - ACE_Allocator::instance ()->malloc ( - sizeof (wchar_t) * (n))), - 0); -#else - ACE_NEW_RETURN (t, wchar_t[n], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ - + ACE_NEW_RETURN (t, + wchar_t[ACE_OS::strlen (s) + 1], + 0); return ACE_OS::strcpy (t, s); } #endif /* ACE_HAS_WCHAR */ diff --git a/dep/acelite/ace/ACE.h b/dep/acelite/ace/ACE.h index 711363019..82edaf1a0 100644 --- a/dep/acelite/ace/ACE.h +++ b/dep/acelite/ace/ACE.h @@ -4,6 +4,8 @@ /** * @file ACE.h * + * $Id: ACE.h 97308 2013-09-01 00:58:08Z mesnier_p $ + * * This file contains value added ACE functions that extend the * behavior of the UNIX and Win32 OS calls. * @@ -11,7 +13,7 @@ * in order to manage the namespace better. These functions are put * here rather than in @c ACE_OS in order to separate concerns. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= @@ -54,18 +56,14 @@ class ACE_Handle_Set; namespace ACE { // = ACE version information. - /// e.g., the "6" in ACE 6.3.4 + /// e.g., the "5" in ACE 5.1.12. extern ACE_Export u_int major_version (void); - /// e.g., the "3" in ACE 6.3.4 + /// e.g., the "1" in ACE 5.1.12. extern ACE_Export u_int minor_version (void); - /// e.g., the "4" in ACE 6.3.4 - /// Returns 0 for "stable" (non-micro) releases. - extern ACE_Export u_int micro_version (void); - - /// e.g., the "4" in ACE 6.3.4 - /// Returns 0 for "stable" (non-micro) releases. + /// e.g., the "12" in ACE 5.1.12. + /// Returns 0 for "stable" (non-beta) releases. extern ACE_Export u_int beta_version (void); // = C++ compiler version information. @@ -215,9 +213,7 @@ namespace ACE * * @return -1 on error, else total number of bytes received. */ -#if !defined (ACE_LACKS_VA_FUNCTIONS) extern ACE_Export ssize_t recv (ACE_HANDLE handle, size_t n, ...); -#endif /* ACE_LACKS_VA_FUNCTIONS */ extern ACE_Export ssize_t recvv (ACE_HANDLE handle, iovec *iov, @@ -298,9 +294,7 @@ namespace ACE size_t *bytes_transferred = 0); /// Varargs variant. -#if !defined (ACE_LACKS_VA_FUNCTIONS) extern ACE_Export ssize_t send (ACE_HANDLE handle, size_t n, ...); -#endif /* ACE_LACKS_VA_FUNCTIONS */ extern ACE_Export ssize_t sendv (ACE_HANDLE handle, const iovec *iov, diff --git a/dep/acelite/ace/ACE.inl b/dep/acelite/ace/ACE.inl index f95982d73..95f45ee99 100644 --- a/dep/acelite/ace/ACE.inl +++ b/dep/acelite/ace/ACE.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ACE.inl 95761 2012-05-15 18:23:04Z johnnyw $ + #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_Thread.h" #include "ace/OS_NS_ctype.h" @@ -255,11 +258,7 @@ ACE::handle_exception_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout) ACE_INLINE void ACE::strdelete (char *s) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(s); -#else delete [] s; -#endif /* ACE_HAS_ALLOC_HOOKS */ } #if defined (ACE_HAS_WCHAR) diff --git a/dep/acelite/ace/ACE_crc32.cpp b/dep/acelite/ace/ACE_crc32.cpp index d3e994305..f9eb064f5 100644 --- a/dep/acelite/ace/ACE_crc32.cpp +++ b/dep/acelite/ace/ACE_crc32.cpp @@ -1,3 +1,5 @@ +// $Id: ACE_crc32.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/ACE.h" namespace diff --git a/dep/acelite/ace/ACE_crc_ccitt.cpp b/dep/acelite/ace/ACE_crc_ccitt.cpp index 374637e3d..c1455d791 100644 --- a/dep/acelite/ace/ACE_crc_ccitt.cpp +++ b/dep/acelite/ace/ACE_crc_ccitt.cpp @@ -1,3 +1,5 @@ +// $Id: ACE_crc_ccitt.cpp 96017 2012-08-08 22:18:09Z mitza $ + #include "ace/ACE.h" namespace diff --git a/dep/acelite/ace/ACE_export.h b/dep/acelite/ace/ACE_export.h index 700e562f7..6129a9250 100644 --- a/dep/acelite/ace/ACE_export.h +++ b/dep/acelite/ace/ACE_export.h @@ -1,4 +1,5 @@ // -*- C++ -*- +// $Id: ACE_export.h 97262 2013-08-09 08:32:10Z johnnyw $ // Definition for Win32 Export directives. // This file is generated automatically by // generate_export_file.pl @@ -50,7 +51,13 @@ #endif #if defined (__ACE_INLINE__) -# define ACE_NAMESPACE_INLINE_FUNCTION inline +# if defined (_MSC_VER) || defined (__MINGW32__) || defined (CYGWIN32) || \ + (defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x560) || \ + (defined (__HP_aCC) && (__HP_aCC >= 60500)) +# define ACE_NAMESPACE_INLINE_FUNCTION inline +# else +# define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS inline +# endif # define ACE_INLINE_TEMPLATE_FUNCTION inline #else # define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS diff --git a/dep/acelite/ace/ARGV.cpp b/dep/acelite/ace/ARGV.cpp index 18790043e..ed6e5e3e8 100644 --- a/dep/acelite/ace/ARGV.cpp +++ b/dep/acelite/ace/ARGV.cpp @@ -1,3 +1,5 @@ +// $Id: ARGV.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_ARGV_CPP #define ACE_ARGV_CPP @@ -13,8 +15,8 @@ // Open versioned namespace, if enabled by the user. ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tt (ACE_ARGV_Queue_Entry_T) -ACE_ALLOC_HOOK_DEFINE_Tt (ACE_ARGV_T) +ACE_ALLOC_HOOK_DEFINE (ACE_ARGV_Queue_Entry) +ACE_ALLOC_HOOK_DEFINE (ACE_ARGV) template void @@ -88,14 +90,8 @@ ACE_ARGV_T::ACE_ARGV_T (const CHAR_TYPE buf[], return; // Make an internal copy of the string. -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR(this->buf_, - static_cast (ACE_Allocator::instance()->malloc(sizeof (CHAR_TYPE) * (ACE_OS::strlen (buf) + 1)))); -#else ACE_NEW (this->buf_, CHAR_TYPE[ACE_OS::strlen (buf) + 1]); -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_OS::strcpy (this->buf_, buf); // Create this->argv_. @@ -207,13 +203,8 @@ ACE_ARGV_T::ACE_ARGV_T (CHAR_TYPE *first_argv[], ACE_OS::strcat (this->buf_, second_buf); // Delete the first and second buffers -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (first_buf); - ACE_Allocator::instance()->free (second_buf); -#else delete [] first_buf; delete [] second_buf; -#endif /* ACE_HAS_ALLOC_HOOKS */ } template @@ -271,19 +262,11 @@ ACE_ARGV_T::add (const CHAR_TYPE *next_arg, bool quote_arg) for (int i = 0; this->argv_[i] != 0; i++) ACE_OS::free ((void *) this->argv_[i]); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->argv_); -#else delete [] this->argv_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->argv_ = 0; } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->buf_); -#else delete [] this->buf_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->buf_ = 0; return 0; @@ -309,21 +292,10 @@ ACE_ARGV_T::~ACE_ARGV_T (void) if (this->argv_ != 0) for (int i = 0; this->argv_[i] != 0; i++) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->argv_[i]); -#else ACE_OS::free ((void *) this->argv_[i]); -#endif /* ACE_HAS_ALLOC_HOOKS */ - - -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->argv_); - ACE_Allocator::instance()->free (this->buf_); -#else delete [] this->argv_; delete [] this->buf_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } // Create buf_ out of the queue_. This is only used in the @@ -339,21 +311,11 @@ ACE_ARGV_T::create_buf_from_queue (void) if (this->argc_ <= 0) return -1; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->buf_); -#else delete [] this->buf_; -#endif /* ACE_HAS_ALLOC_HOOKS */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (this->buf_, - static_cast (ACE_Allocator::instance()->malloc(sizeof (CHAR_TYPE) * (this->length_ + this->argc_))), - -1); -#else ACE_NEW_RETURN (this->buf_, CHAR_TYPE[this->length_ + this->argc_], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Get an iterator over the queue ACE_Unbounded_Queue_Iterator > iter (this->queue_); diff --git a/dep/acelite/ace/ARGV.h b/dep/acelite/ace/ARGV.h index 962b453c7..1c291bd6e 100644 --- a/dep/acelite/ace/ARGV.h +++ b/dep/acelite/ace/ARGV.h @@ -4,7 +4,9 @@ /** * @file ARGV.h * - * @author Doug Schmidt + * $Id: ARGV.h 95972 2012-07-26 10:20:42Z johnnyw $ + * + * @author Doug Schmidt * @author Everett Anderson */ //========================================================================== @@ -297,7 +299,7 @@ private: /// The array of string arguments. CHAR_TYPE **argv_; - /// Buffer containing the argv contents. + /// Buffer containing the contents. CHAR_TYPE *buf_; /// Total length of the arguments in the queue, not counting diff --git a/dep/acelite/ace/ARGV.inl b/dep/acelite/ace/ARGV.inl index cd538e9ec..fdc5b13d7 100644 --- a/dep/acelite/ace/ARGV.inl +++ b/dep/acelite/ace/ARGV.inl @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: ARGV.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Global_Macros.h" // Open versioned namespace, if enabled by the user. diff --git a/dep/acelite/ace/ATM_Acceptor.cpp b/dep/acelite/ace/ATM_Acceptor.cpp index db7d67658..e0807d26e 100644 --- a/dep/acelite/ace/ATM_Acceptor.cpp +++ b/dep/acelite/ace/ATM_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: ATM_Acceptor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/ATM_Acceptor.h" diff --git a/dep/acelite/ace/ATM_Acceptor.h b/dep/acelite/ace/ATM_Acceptor.h index 736c980d6..1241a228c 100644 --- a/dep/acelite/ace/ATM_Acceptor.h +++ b/dep/acelite/ace/ATM_Acceptor.h @@ -4,6 +4,8 @@ /** * @file ATM_Acceptor.h * + * $Id: ATM_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Joe Hoffert */ //============================================================================= diff --git a/dep/acelite/ace/ATM_Acceptor.inl b/dep/acelite/ace/ATM_Acceptor.inl index 8e4aef7fa..18f84e550 100644 --- a/dep/acelite/ace/ATM_Acceptor.inl +++ b/dep/acelite/ace/ATM_Acceptor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ATM_Acceptor.inl 96985 2013-04-11 15:50:32Z huangh $ + // Open versioned namespace, if enabled by the user. ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/ATM_Addr.cpp b/dep/acelite/ace/ATM_Addr.cpp index afe10cc8f..24bffa632 100644 --- a/dep/acelite/ace/ATM_Addr.cpp +++ b/dep/acelite/ace/ATM_Addr.cpp @@ -1,3 +1,5 @@ +// $Id: ATM_Addr.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Defines the Internet domain address family address format. #include "ace/ATM_Addr.h" @@ -450,7 +452,7 @@ ACE_ATM_Addr::addr_to_string (void) const // Set a pointer to the address. void -ACE_ATM_Addr::set_addr (const void *addr, int len) +ACE_ATM_Addr::set_addr (void *addr, int len) { ACE_TRACE ("ACE_ATM_Addr::set_addr"); @@ -462,7 +464,8 @@ ACE_ATM_Addr::set_addr (const void *addr, int len) this->ACE_Addr::base_set (AF_UNSPEC, #endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_WS2 */ len); - ACE_OS::memcpy (&this->atm_addr_, addr, len); + ACE_OS::memcpy ((void *) &this->atm_addr_, + (void *) addr, len); } // Compare two addresses for inequality. diff --git a/dep/acelite/ace/ATM_Addr.h b/dep/acelite/ace/ATM_Addr.h index 8f8aac81d..7fa93f149 100644 --- a/dep/acelite/ace/ATM_Addr.h +++ b/dep/acelite/ace/ATM_Addr.h @@ -4,6 +4,8 @@ /** * @file ATM_Addr.h * + * $Id: ATM_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Joe Hoffert */ //========================================================================== @@ -148,7 +150,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the address. - virtual void set_addr (const void *, int); + virtual void set_addr (void *, int); /// Return the selector for network address. u_char get_selector (void) const; diff --git a/dep/acelite/ace/ATM_Addr.inl b/dep/acelite/ace/ATM_Addr.inl index d1f7e2c4d..55f43d661 100644 --- a/dep/acelite/ace/ATM_Addr.inl +++ b/dep/acelite/ace/ATM_Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ATM_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE u_char diff --git a/dep/acelite/ace/ATM_Connector.cpp b/dep/acelite/ace/ATM_Connector.cpp index b05860557..c734b2036 100644 --- a/dep/acelite/ace/ATM_Connector.cpp +++ b/dep/acelite/ace/ATM_Connector.cpp @@ -1,4 +1,6 @@ // ATM_Connector.cpp +// $Id: ATM_Connector.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/ATM_Connector.h" #if defined (ACE_HAS_ATM) diff --git a/dep/acelite/ace/ATM_Connector.h b/dep/acelite/ace/ATM_Connector.h index 2bca5b61d..940fc5a30 100644 --- a/dep/acelite/ace/ATM_Connector.h +++ b/dep/acelite/ace/ATM_Connector.h @@ -4,6 +4,8 @@ /** * @file ATM_Connector.h * + * $Id: ATM_Connector.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Joe Hoffert */ //============================================================================= diff --git a/dep/acelite/ace/ATM_Connector.inl b/dep/acelite/ace/ATM_Connector.inl index e35f40854..8e462d85c 100644 --- a/dep/acelite/ace/ATM_Connector.inl +++ b/dep/acelite/ace/ATM_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ATM_Connector.inl 96985 2013-04-11 15:50:32Z huangh $ + // Open versioned namespace, if enabled by the user. ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/ATM_Params.cpp b/dep/acelite/ace/ATM_Params.cpp index ac8a996e5..b8d7600f1 100644 --- a/dep/acelite/ace/ATM_Params.cpp +++ b/dep/acelite/ace/ATM_Params.cpp @@ -1,3 +1,5 @@ +// $Id: ATM_Params.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/ATM_Params.h" #if defined (ACE_HAS_ATM) diff --git a/dep/acelite/ace/ATM_Params.h b/dep/acelite/ace/ATM_Params.h index 34db50248..d1e8c9231 100644 --- a/dep/acelite/ace/ATM_Params.h +++ b/dep/acelite/ace/ATM_Params.h @@ -4,6 +4,8 @@ /** * @file ATM_Params.h * + * $Id: ATM_Params.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Joe Hoffert */ //========================================================================== diff --git a/dep/acelite/ace/ATM_Params.inl b/dep/acelite/ace/ATM_Params.inl index 59ec331b5..de2a4d451 100644 --- a/dep/acelite/ace/ATM_Params.inl +++ b/dep/acelite/ace/ATM_Params.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ATM_Params.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void diff --git a/dep/acelite/ace/ATM_QoS.cpp b/dep/acelite/ace/ATM_QoS.cpp index a6b097326..f711fb816 100644 --- a/dep/acelite/ace/ATM_QoS.cpp +++ b/dep/acelite/ace/ATM_QoS.cpp @@ -1,3 +1,5 @@ +// $Id: ATM_QoS.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/ATM_QoS.h" diff --git a/dep/acelite/ace/ATM_QoS.h b/dep/acelite/ace/ATM_QoS.h index 02aa7d7c9..4e35f3fdd 100644 --- a/dep/acelite/ace/ATM_QoS.h +++ b/dep/acelite/ace/ATM_QoS.h @@ -4,6 +4,8 @@ /** * @file ATM_QoS.h * + * $Id: ATM_QoS.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Joe Hoffert */ //========================================================================== diff --git a/dep/acelite/ace/ATM_QoS.inl b/dep/acelite/ace/ATM_QoS.inl index 479079e99..52b521119 100644 --- a/dep/acelite/ace/ATM_QoS.inl +++ b/dep/acelite/ace/ATM_QoS.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ATM_QoS.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void diff --git a/dep/acelite/ace/ATM_Stream.cpp b/dep/acelite/ace/ATM_Stream.cpp index f87ac4def..b114c3b12 100644 --- a/dep/acelite/ace/ATM_Stream.cpp +++ b/dep/acelite/ace/ATM_Stream.cpp @@ -1,3 +1,5 @@ +// $Id: ATM_Stream.cpp 97461 2013-12-12 16:30:01Z shuston $ + #include "ace/ATM_Stream.h" #if defined (ACE_HAS_ATM) diff --git a/dep/acelite/ace/ATM_Stream.h b/dep/acelite/ace/ATM_Stream.h index 10bd3e700..41ffb0da3 100644 --- a/dep/acelite/ace/ATM_Stream.h +++ b/dep/acelite/ace/ATM_Stream.h @@ -4,6 +4,8 @@ /** * @file ATM_Stream.h * + * $Id: ATM_Stream.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Joe Hoffert */ //============================================================================= diff --git a/dep/acelite/ace/ATM_Stream.inl b/dep/acelite/ace/ATM_Stream.inl index eda7ca9bc..94de09004 100644 --- a/dep/acelite/ace/ATM_Stream.inl +++ b/dep/acelite/ace/ATM_Stream.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: ATM_Stream.inl 92474 2010-11-02 13:29:39Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void diff --git a/dep/acelite/ace/Abstract_Timer_Queue.cpp b/dep/acelite/ace/Abstract_Timer_Queue.cpp index 021c637fe..3207733b2 100644 --- a/dep/acelite/ace/Abstract_Timer_Queue.cpp +++ b/dep/acelite/ace/Abstract_Timer_Queue.cpp @@ -1,3 +1,5 @@ +//$Id: Abstract_Timer_Queue.cpp 95334 2011-12-15 12:52:50Z msmit $ + #ifndef ACE_ABSTRACT_TIMER_QUEUE_CPP #define ACE_ABSTRACT_TIMER_QUEUE_CPP #include "ace/config-all.h" diff --git a/dep/acelite/ace/Abstract_Timer_Queue.h b/dep/acelite/ace/Abstract_Timer_Queue.h index 7dbbf7b4b..ddb8abf7f 100644 --- a/dep/acelite/ace/Abstract_Timer_Queue.h +++ b/dep/acelite/ace/Abstract_Timer_Queue.h @@ -1,3 +1,5 @@ +//$Id: Abstract_Timer_Queue.h 95368 2011-12-19 13:38:49Z mcorino $ + #ifndef ACE_ABSTRACT_TIMER_QUEUE_H #define ACE_ABSTRACT_TIMER_QUEUE_H @@ -11,8 +13,6 @@ * Brunsch, Irfan Pyarali and a cast of thousands. */ -#include "ace/Versioned_Namespace.h" - ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Forward declares @@ -184,7 +184,7 @@ public: /** * Determine the next event to timeout. Returns @a max if there are * no pending timers or if all pending timers are longer than max. - * @a the_timeout should be a pointer to storage for the timeout value, + * should be a pointer to storage for the timeout value, * and this value is also returned. This method does not acquire a * lock internally since it doesn't modify internal state. If you * need to call this method when the queue is being modified diff --git a/dep/acelite/ace/Acceptor.cpp b/dep/acelite/ace/Acceptor.cpp index 6b0f8fdc2..1b0188b07 100644 --- a/dep/acelite/ace/Acceptor.cpp +++ b/dep/acelite/ace/Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: Acceptor.cpp 97075 2013-04-24 15:01:48Z schmidt $ + #ifndef ACE_ACCEPTOR_CPP #define ACE_ACCEPTOR_CPP @@ -15,7 +17,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Acceptor) +ACE_ALLOC_HOOK_DEFINE(ACE_Acceptor) template void ACE_Acceptor::dump (void) const @@ -172,11 +174,11 @@ ACE_Acceptor::info (ACE_TCHAR **strp, else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1) return -1; - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%s\t %s %s"), - ACE_TEXT ("ACE_Acceptor"), - addr_str, - ACE_TEXT ("# acceptor factory\n")); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s %s"), + ACE_TEXT ("ACE_Acceptor"), + addr_str, + ACE_TEXT ("# acceptor factory\n")); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) return -1; @@ -447,7 +449,7 @@ ACE_Acceptor::handle_input (ACE_HANDLE listener) return 0; } -ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Strategy_Acceptor) +ACE_ALLOC_HOOK_DEFINE(ACE_Strategy_Acceptor) template int ACE_Strategy_Acceptor::suspend (void) @@ -832,15 +834,15 @@ ACE_Strategy_Acceptor::info (ACE_TCHAR **strp, return -1; // @@ Should add the protocol in... - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%s\t %s #%s\n"), - this->service_name_ == 0 - ? ACE_TEXT ("") - : this->service_name_, - service_addr_str, - this->service_description_ == 0 - ? ACE_TEXT ("") - : this->service_description_); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s #%s\n"), + this->service_name_ == 0 + ? ACE_TEXT ("") + : this->service_name_, + service_addr_str, + this->service_description_ == 0 + ? ACE_TEXT ("") + : this->service_description_); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) return -1; @@ -856,7 +858,7 @@ ACE_Strategy_Acceptor::fini (void) return this->ACE_Strategy_Acceptor::handle_close (); } -ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Oneshot_Acceptor) +ACE_ALLOC_HOOK_DEFINE(ACE_Oneshot_Acceptor) template void ACE_Oneshot_Acceptor::dump (void) const @@ -1199,11 +1201,11 @@ ACE_Oneshot_Acceptor::info (ACE_TCHAR **strp, else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1) return -1; - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%s\t %s %s"), - ACE_TEXT ("ACE_Oneshot_Acceptor"), - addr_str, - ACE_TEXT ("#oneshot acceptor factory\n")); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s %s"), + ACE_TEXT ("ACE_Oneshot_Acceptor"), + addr_str, + ACE_TEXT ("#oneshot acceptor factory\n")); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) return -1; diff --git a/dep/acelite/ace/Acceptor.h b/dep/acelite/ace/Acceptor.h index f4c7754f8..ee340547b 100644 --- a/dep/acelite/ace/Acceptor.h +++ b/dep/acelite/ace/Acceptor.h @@ -4,7 +4,9 @@ /** * @file Acceptor.h * - * @author Douglas C. Schmidt + * $Id: Acceptor.h 97084 2013-04-26 20:42:28Z schmidt $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Activation_Queue.cpp b/dep/acelite/ace/Activation_Queue.cpp index 61683993c..d2677e7c2 100644 --- a/dep/acelite/ace/Activation_Queue.cpp +++ b/dep/acelite/ace/Activation_Queue.cpp @@ -1,3 +1,5 @@ +// $Id: Activation_Queue.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Activation_Queue.h" #if !defined (__ACE_INLINE__) @@ -11,8 +13,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE (ACE_Activation_Queue) - void ACE_Activation_Queue::dump (void) const { diff --git a/dep/acelite/ace/Activation_Queue.h b/dep/acelite/ace/Activation_Queue.h index 7317c43d0..758ad56ae 100644 --- a/dep/acelite/ace/Activation_Queue.h +++ b/dep/acelite/ace/Activation_Queue.h @@ -4,8 +4,10 @@ /** * @file Activation_Queue.h * + * $Id: Activation_Queue.h 97436 2013-11-25 10:48:49Z johnnyw $ + * * @author Andres Kruse - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Activation_Queue.inl b/dep/acelite/ace/Activation_Queue.inl index b464dbdef..4c0ffc049 100644 --- a/dep/acelite/ace/Activation_Queue.inl +++ b/dep/acelite/ace/Activation_Queue.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Activation_Queue.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE size_t diff --git a/dep/acelite/ace/Active_Map_Manager.cpp b/dep/acelite/ace/Active_Map_Manager.cpp index b8813a0dd..574bcb857 100644 --- a/dep/acelite/ace/Active_Map_Manager.cpp +++ b/dep/acelite/ace/Active_Map_Manager.cpp @@ -1,3 +1,5 @@ +// $Id: Active_Map_Manager.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Active_Map_Manager.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Active_Map_Manager.h b/dep/acelite/ace/Active_Map_Manager.h index e0dbb7d55..7bade46aa 100644 --- a/dep/acelite/ace/Active_Map_Manager.h +++ b/dep/acelite/ace/Active_Map_Manager.h @@ -4,6 +4,8 @@ /** * @file Active_Map_Manager.h * + * $Id: Active_Map_Manager.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Active_Map_Manager.inl b/dep/acelite/ace/Active_Map_Manager.inl index 2fc8c13e5..df90ada6a 100644 --- a/dep/acelite/ace/Active_Map_Manager.inl +++ b/dep/acelite/ace/Active_Map_Manager.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Active_Map_Manager.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Active_Map_Manager_T.cpp b/dep/acelite/ace/Active_Map_Manager_T.cpp index 6341ca711..732cc2951 100644 --- a/dep/acelite/ace/Active_Map_Manager_T.cpp +++ b/dep/acelite/ace/Active_Map_Manager_T.cpp @@ -1,3 +1,5 @@ +// $Id: Active_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_ACTIVE_MAP_MANAGER_T_CPP #define ACE_ACTIVE_MAP_MANAGER_T_CPP @@ -13,7 +15,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Active_Map_Manager) +ACE_ALLOC_HOOK_DEFINE(ACE_Active_Map_Manager) ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Active_Map_Manager_T.h b/dep/acelite/ace/Active_Map_Manager_T.h index 11c7da37a..80eaada26 100644 --- a/dep/acelite/ace/Active_Map_Manager_T.h +++ b/dep/acelite/ace/Active_Map_Manager_T.h @@ -4,6 +4,8 @@ /** * @file Active_Map_Manager_T.h * + * $Id: Active_Map_Manager_T.h 84316 2009-02-03 19:46:05Z johnnyw $ + * * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Active_Map_Manager_T.inl b/dep/acelite/ace/Active_Map_Manager_T.inl index c8a6caf9b..647b55ebd 100644 --- a/dep/acelite/ace/Active_Map_Manager_T.inl +++ b/dep/acelite/ace/Active_Map_Manager_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Active_Map_Manager_T.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE int diff --git a/dep/acelite/ace/Addr.cpp b/dep/acelite/ace/Addr.cpp index 85f3523cf..86f49a4f0 100644 --- a/dep/acelite/ace/Addr.cpp +++ b/dep/acelite/ace/Addr.cpp @@ -1,3 +1,5 @@ +// $Id: Addr.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Addr.h" #if !defined (__ACE_INLINE__) @@ -6,9 +8,6 @@ #include "ace/Log_Category.h" #include "ace/os_include/sys/os_socket.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -39,7 +38,7 @@ ACE_Addr::get_addr (void) const } void -ACE_Addr::set_addr (const void *, int) +ACE_Addr::set_addr (void *, int) { } diff --git a/dep/acelite/ace/Addr.h b/dep/acelite/ace/Addr.h index 82c2d8335..e58ffe2c0 100644 --- a/dep/acelite/ace/Addr.h +++ b/dep/acelite/ace/Addr.h @@ -4,7 +4,9 @@ /** * @file Addr.h * - * @author Douglas C. Schmidt + * $Id: Addr.h 81030 2008-03-20 12:43:29Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -57,7 +59,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the address. - virtual void set_addr (const void *, int len); + virtual void set_addr (void *, int len); // = Equality/inequality tests /// Check for address equality. diff --git a/dep/acelite/ace/Addr.inl b/dep/acelite/ace/Addr.inl index ad6f03e21..0ff355eae 100644 --- a/dep/acelite/ace/Addr.inl +++ b/dep/acelite/ace/Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Addr.inl 87295 2009-11-02 14:45:59Z johnnyw $ + // Return the address of the address. ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Arg_Shifter.cpp b/dep/acelite/ace/Arg_Shifter.cpp index 29eace272..626786035 100644 --- a/dep/acelite/ace/Arg_Shifter.cpp +++ b/dep/acelite/ace/Arg_Shifter.cpp @@ -1,3 +1,5 @@ +// $Id: Arg_Shifter.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #ifndef ACE_ARG_SHIFTER_T_CPP #define ACE_ARG_SHIFTER_T_CPP @@ -6,9 +8,6 @@ #include "ace/OS_NS_strings.h" #include "ace/OS_Errno.h" #include "ace/OS_Memory.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -48,13 +47,9 @@ ACE_Arg_Shifter_T::init (void) { // If not provided with one, allocate a temporary array. if (this->temp_ == 0) -#if defined (ACE_HAS_ALLOC_HOOKS) - this->temp_ = reinterpret_cast - (ACE_Allocator::instance ()->malloc (sizeof (CHAR_TYPE*) * this->total_size_)); -#else ACE_NEW (this->temp_, const CHAR_TYPE *[this->total_size_]); -#endif /* ACE_HAS_ALLOC_HOOKS */ + if (this->temp_ != 0) { // Fill the temporary array. @@ -77,12 +72,7 @@ template ACE_Arg_Shifter_T::~ACE_Arg_Shifter_T (void) { // Delete the temporary vector. -#if defined (ACE_HAS_ALLOC_HOOKS) - if (this->temp_) - ACE_Allocator::instance ()->free (this->temp_); -#else delete [] temp_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } template @@ -130,20 +120,33 @@ template int ACE_Arg_Shifter_T::cur_arg_strncasecmp (const CHAR_TYPE *flag) { - if (!this->is_anything_left ()) - return -1; + // Check for a current argument + if (this->is_anything_left()) + { + size_t const flag_length = ACE_OS::strlen (flag); - const size_t flag_length = ACE_OS::strlen (flag); - const CHAR_TYPE *arg = this->temp_[this->current_index_]; - - if (ACE_OS::strncasecmp (arg, flag, flag_length) != 0) - return -1; - - const size_t arg_length = ACE_OS::strlen (arg); - size_t remaining = flag_length; - while (remaining < arg_length && arg[remaining] == CHAR_TYPE (' ')) - ++remaining; - return (arg_length == flag_length) ? 0 : static_cast (remaining); + // Check for presence of the flag + if (ACE_OS::strncasecmp(this->temp_[current_index_], + flag, + flag_length) == 0) + { + if (ACE_OS::strlen(temp_[current_index_]) == flag_length) + { + // match and lengths are equal + return 0; + } + else + { + // matches, with more info to boot! + size_t const remaining = ACE_OS::strspn + (this->temp_[current_index_] + flag_length, + ACE_TEXT (" ")) + flag_length; + return static_cast (remaining); + } + } + } + // failure + return -1; } template diff --git a/dep/acelite/ace/Arg_Shifter.h b/dep/acelite/ace/Arg_Shifter.h index 1ed6f1367..123a70560 100644 --- a/dep/acelite/ace/Arg_Shifter.h +++ b/dep/acelite/ace/Arg_Shifter.h @@ -4,6 +4,8 @@ /** * @file Arg_Shifter.h * + * $Id: Arg_Shifter.h 95972 2012-07-26 10:20:42Z johnnyw $ + * * @author Seth Widoff */ //============================================================================= @@ -75,13 +77,13 @@ public: * (the default) the object will allocate and free the temporary * vector transparently. */ - ACE_Arg_Shifter_T (int &argc, + ACE_Arg_Shifter_T (int& argc, const CHAR_TYPE **argv, const CHAR_TYPE **temp = 0); /// Same behavior as the preceding constructor, but without the /// "const" qualifier. - ACE_Arg_Shifter_T (int &argc, + ACE_Arg_Shifter_T (int& argc, CHAR_TYPE **argv, CHAR_TYPE **temp = 0); @@ -98,12 +100,12 @@ public: * * Safe to call without checking that a current arg exists * - * In the following examples, a pointer to the char* "value" is returned + * In the following examples, a pointer to the char* "value" is ret * * eg: main -foobar value, main -FooBar value * main -FOOBARvalue * - * all of the above will match the @a flag == -FooBar + * all of the above will all match the @a flag == -FooBar * and will return a char* to "value" * * main -foobar 4 would succeed and return a char* to "4" @@ -123,7 +125,7 @@ public: * together '-foobarflagVALUE', the flag is NOT consumed * and the cur arg is left pointing to the entire flag/value pair */ - const CHAR_TYPE *get_the_parameter (const CHAR_TYPE *flag); + const CHAR_TYPE *get_the_parameter (const CHAR_TYPE* flag); /** * Check if the current argument matches (case insensitive) @a flag @@ -134,7 +136,7 @@ public: * 0 is returned. * * ie: when current_arg = "-foobar" or "-FOOBAR" or "-fooBAR" - * this->cur_arg_strncasecmp ("-FooBar"); + * this->cur_arg_strncasecmp ("-FooBar); * will return 0 * * ------------------------------------------------------------ @@ -142,19 +144,11 @@ public: * Case B: Perfect Match (case insensitive) but the current_arg * is longer than the flag. Returns a number equal to the index * in the char* indicating the start of the extra characters - * after any initial spaces (see below). * * ie: when current_arg = "-foobar98023" - * this->cur_arg_strncasecmp ("-FooBar"); + * this->cur_arg_strncasecmp ("-FooBar); * will return 7 * - * Spaces separating the flag from its value (that are still part - * of the same argv element) are counted as part of the return value - * - * ie: when current_arg = "-foobar 98023" - * this->cur_arg_strncasecmp ("-FooBar"); - * will return 8 - * * Notice: this number will always be > 0 * * ------------------------------------------------------------ @@ -188,16 +182,16 @@ public: private: /// Copy Constructor should not be used. - ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T (const ACE_Arg_Shifter_T &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T (const ACE_Arg_Shifter_T&)) /// Assignment '=' operator should not be used. - ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T operator= (const ACE_Arg_Shifter_T &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T operator= (const ACE_Arg_Shifter_T&)) /// Refactor the constructor logic. void init (void); /// The size of the argument vector. - int &argc_; + int& argc_; /// The size of argv_. int total_size_; diff --git a/dep/acelite/ace/Argv_Type_Converter.cpp b/dep/acelite/ace/Argv_Type_Converter.cpp index 4c8e4fbb9..68b98d99d 100644 --- a/dep/acelite/ace/Argv_Type_Converter.cpp +++ b/dep/acelite/ace/Argv_Type_Converter.cpp @@ -1,3 +1,5 @@ +// $Id: Argv_Type_Converter.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Argv_Type_Converter.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Argv_Type_Converter.h b/dep/acelite/ace/Argv_Type_Converter.h index 9734a1de0..0cf62fa08 100644 --- a/dep/acelite/ace/Argv_Type_Converter.h +++ b/dep/acelite/ace/Argv_Type_Converter.h @@ -4,6 +4,8 @@ /** * @file Argv_Type_Converter.h * + * $Id: Argv_Type_Converter.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Si Mong Park */ //============================================================================= diff --git a/dep/acelite/ace/Argv_Type_Converter.inl b/dep/acelite/ace/Argv_Type_Converter.inl index 8c7bc89ca..e4b0ed5a0 100644 --- a/dep/acelite/ace/Argv_Type_Converter.inl +++ b/dep/acelite/ace/Argv_Type_Converter.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Argv_Type_Converter.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_TCHAR** diff --git a/dep/acelite/ace/Array_Base.cpp b/dep/acelite/ace/Array_Base.cpp index 830634f7b..49e42e1ad 100644 --- a/dep/acelite/ace/Array_Base.cpp +++ b/dep/acelite/ace/Array_Base.cpp @@ -1,3 +1,5 @@ +// $Id: Array_Base.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_ARRAY_BASE_CPP #define ACE_ARRAY_BASE_CPP diff --git a/dep/acelite/ace/Array_Base.h b/dep/acelite/ace/Array_Base.h index ceb6a7edc..9276bf6ee 100644 --- a/dep/acelite/ace/Array_Base.h +++ b/dep/acelite/ace/Array_Base.h @@ -4,7 +4,9 @@ /** * @file Array_Base.h * - * @author Douglas C. Schmidt + * $Id: Array_Base.h 93359 2011-02-11 11:33:12Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Array_Base.inl b/dep/acelite/ace/Array_Base.inl index ccd367f2d..046c1bffc 100644 --- a/dep/acelite/ace/Array_Base.inl +++ b/dep/acelite/ace/Array_Base.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Array_Base.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Clean up the array (e.g., delete dynamically allocated memory). diff --git a/dep/acelite/ace/Array_Map.cpp b/dep/acelite/ace/Array_Map.cpp index 4917c51e4..25b4e2457 100644 --- a/dep/acelite/ace/Array_Map.cpp +++ b/dep/acelite/ace/Array_Map.cpp @@ -1,3 +1,5 @@ +// $Id: Array_Map.cpp 92386 2010-10-28 07:44:37Z johnnyw $ + #ifndef ACE_ARRAY_MAP_CPP #define ACE_ARRAY_MAP_CPP @@ -13,64 +15,65 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template +template template -ACE_Array_Map::ACE_Array_Map (InputIterator f, - InputIterator l) +ACE_Array_Map::ACE_Array_Map (InputIterator f, + InputIterator l) : size_ (l - f) , capacity_ (size_) - , nodes_ (size_ == 0 ? 0 : this->alloc_.allocate (size_)) + , nodes_ (size_ == 0 ? 0 : new value_type[size_]) { - (void) std::uninitialized_copy (f, - l, - ACE_make_checked_array_iterator (this->begin (), - this->size_)); + (void) std::copy (f, + l, + ACE_make_checked_array_iterator (this->begin (), + this->size_)); + +// iterator n = this->begin (); + +// for (InputIterator i = f; i != l; ++i, ++n) +// *n = *i; } -template -ACE_Array_Map::ACE_Array_Map ( - ACE_Array_Map const & map) +template +ACE_Array_Map::ACE_Array_Map ( + ACE_Array_Map const & map) : size_ (map.size_) , capacity_ (map.size_) - , nodes_ (size_ == 0 ? 0 : this->alloc_.allocate (size_)) + , nodes_ (size_ == 0 ? 0 : new value_type[size_]) { - (void) std::uninitialized_copy (map.begin (), - map.end (), - ACE_make_checked_array_iterator (this->begin (), - this->size_)); + std::copy (map.begin (), + map.end (), + ACE_make_checked_array_iterator (this->begin (), + this->size_)); + +// iterator f = map.begin (); +// iterator l = map.end (); +// iterator n = this->begin (); + +// for (iterator i = f; i != l; ++i, ++n) +// *n = *i; } -template -ACE_Array_Map::~ACE_Array_Map (void) +template +ACE_Array_Map::~ACE_Array_Map (void) { - for (size_t idx = 0; idx != capacity_; ++idx) - { -#if defined (ACE_HAS_BCC32) - using std::pair; - (nodes_ + idx)->~pair(); -#else - (nodes_ + idx)->~value_type(); -#endif - - } - - alloc_.deallocate(this->nodes_, capacity_); + delete[] this->nodes_; } -template +template void -ACE_Array_Map::swap ( - ACE_Array_Map & map) +ACE_Array_Map::swap ( + ACE_Array_Map & map) { std::swap (this->size_, map.size_); std::swap (this->capacity_, map.capacity_); std::swap (this->nodes_, map.nodes_); } -template -std::pair::iterator, bool> -ACE_Array_Map::insert ( - typename ACE_Array_Map::value_type const & x) +template +std::pair::iterator, bool> +ACE_Array_Map::insert ( + typename ACE_Array_Map::value_type const & x) { // Linear insertion due to linear duplicate key search. @@ -95,10 +98,10 @@ ACE_Array_Map::insert ( return std::make_pair (i, inserted); } -template +template template void -ACE_Array_Map::insert (InputIterator f, InputIterator l) +ACE_Array_Map::insert (InputIterator f, InputIterator l) { this->grow (l - f); // Preallocate storage. @@ -108,10 +111,10 @@ ACE_Array_Map::insert (InputIterator f, InputIterato } } -template +template void -ACE_Array_Map::erase ( - typename ACE_Array_Map::iterator pos) +ACE_Array_Map::erase ( + typename ACE_Array_Map::iterator pos) { iterator const first = this->begin (); iterator const last = this->end (); @@ -135,10 +138,10 @@ ACE_Array_Map::erase ( } } -template -typename ACE_Array_Map::size_type -ACE_Array_Map::erase ( - typename ACE_Array_Map::key_type const & k) +template +typename ACE_Array_Map::size_type +ACE_Array_Map::erase ( + typename ACE_Array_Map::key_type const & k) { iterator pos = this->find (k); @@ -149,28 +152,28 @@ ACE_Array_Map::erase ( return old_size - this->size_; } -template +template void -ACE_Array_Map::erase ( - typename ACE_Array_Map::iterator first, - typename ACE_Array_Map::iterator last) +ACE_Array_Map::erase ( + typename ACE_Array_Map::iterator first, + typename ACE_Array_Map::iterator last) { if (this->begin () <= first && first < last && last < this->end ()) for (iterator i = first; i != last; ++i) this->erase (i); } -template +template void -ACE_Array_Map::clear (void) +ACE_Array_Map::clear (void) { this->size_ = 0; // No need to deallocate array nor destroy elements. } -template -typename ACE_Array_Map::iterator -ACE_Array_Map::find ( - typename ACE_Array_Map::key_type const & k) +template +typename ACE_Array_Map::iterator +ACE_Array_Map::find ( + typename ACE_Array_Map::key_type const & k) { iterator const the_end = this->end (); @@ -183,10 +186,10 @@ ACE_Array_Map::find ( return this->end (); } -template -typename ACE_Array_Map::const_iterator -ACE_Array_Map::find ( - typename ACE_Array_Map::key_type const & k) const +template +typename ACE_Array_Map::const_iterator +ACE_Array_Map::find ( + typename ACE_Array_Map::key_type const & k) const { const_iterator const the_end = this->end (); @@ -199,10 +202,10 @@ ACE_Array_Map::find ( return this->end (); } -template +template void -ACE_Array_Map::grow ( - typename ACE_Array_Map::size_type s) +ACE_Array_Map::grow ( + typename ACE_Array_Map::size_type s) { if (this->size () + s > this->capacity_) { @@ -211,7 +214,7 @@ ACE_Array_Map::grow ( // Strongly exception safe. - ACE_Array_Map temp (this->size () + s); + ACE_Array_Map temp (this->size () + s); std::copy (this->begin (), this->end (), @@ -230,10 +233,10 @@ ACE_Array_Map::grow ( // --------------------------------------------------------------- -template +template bool -operator== (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs) +operator== (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs) { // Do not include Array_Map capacity in comparison. It isn't useful // in this case. @@ -245,10 +248,10 @@ operator== (ACE_Array_Map const & lhs, rhs.size ()))); } -template +template bool -operator< (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs) +operator< (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs) { return std::lexicographical_compare (lhs.begin (), lhs.end (), rhs.begin (), rhs.end ()); diff --git a/dep/acelite/ace/Array_Map.h b/dep/acelite/ace/Array_Map.h index c68e7a1fe..5fe7f5268 100644 --- a/dep/acelite/ace/Array_Map.h +++ b/dep/acelite/ace/Array_Map.h @@ -4,6 +4,8 @@ /** * @file Array_Map.h * + * $Id: Array_Map.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * Light weight array-based map with fast iteration but linear * (i.e. O(n)) search times. STL-style interface is exposed. * @@ -29,18 +31,9 @@ #include #include #include -#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL -#if defined __SUNPRO_CC && !defined _RWSTD_ALLOCATOR -# define ACE_ARRAY_MAP_DEFAULT_ALLOCATOR(K, V) std::allocator_interface< \ - std::allocator, \ - std::pair > -#else -# define ACE_ARRAY_MAP_DEFAULT_ALLOCATOR(K, V) std::allocator > -#endif - /** * @class ACE_Array_Map * @@ -91,26 +84,24 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * -# Copy constructor * -# operator= */ -template, - class Alloc = ACE_ARRAY_MAP_DEFAULT_ALLOCATOR (Key, Value) > +template > class ACE_Array_Map { public: // STL-style typedefs/traits. - typedef Key key_type; - typedef Value mapped_type; - typedef Value data_type; - typedef std::pair value_type; - typedef Alloc allocator_type; - typedef value_type & reference; - typedef value_type const & const_reference; - typedef value_type * pointer; - typedef value_type const * const_pointer; - typedef value_type * iterator; - typedef value_type const * const_iterator; - typedef ptrdiff_t difference_type; - typedef size_t size_type; + typedef Key key_type; + typedef Value data_type; + typedef std::pair value_type; + typedef value_type * iterator; + typedef value_type const * const_iterator; + typedef value_type & reference; + typedef value_type const & const_reference; + typedef value_type * pointer; + typedef value_type const * const_pointer; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + ACE_DECLARE_STL_REVERSE_ITERATORS /// Default Constructor. @@ -244,9 +235,7 @@ public: * @par * map["Foo"] = 12; */ - mapped_type & operator[] (key_type const & k); - - allocator_type get_allocator() const { return alloc_; } + data_type & operator[] (key_type const & k); private: @@ -254,8 +243,6 @@ private: void grow (size_type s); private: - /// The allocator. - allocator_type alloc_; /// Number of elements in the map. size_type size_; @@ -268,19 +255,20 @@ private: /// Underlying array containing keys and data. value_type * nodes_; + }; // -------------------------------------------------------------- /// @c ACE_Array_Map equality operator. -template -bool operator== (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs); +template +bool operator== (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs); /// @c ACE_Array_Map lexicographical comparison operator. -template -bool operator< (ACE_Array_Map const & lhs, - ACE_Array_Map const & rhs); +template +bool operator< (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs); // -------------------------------------------------------------- diff --git a/dep/acelite/ace/Array_Map.inl b/dep/acelite/ace/Array_Map.inl index 32e7848c0..b053dc0a4 100644 --- a/dep/acelite/ace/Array_Map.inl +++ b/dep/acelite/ace/Array_Map.inl @@ -1,130 +1,132 @@ // -*- C++ -*- +// +// $Id: Array_Map.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template +template ACE_INLINE -ACE_Array_Map::ACE_Array_Map ( - typename ACE_Array_Map::size_type s) +ACE_Array_Map::ACE_Array_Map ( + typename ACE_Array_Map::size_type s) : size_ (0) , capacity_ (s) - , nodes_ (s == 0 ? 0 : this->alloc_.allocate (s)) + , nodes_ (s == 0 ? 0 : new value_type[s]) { - std::uninitialized_fill_n (this->nodes_, s, value_type ()); } -template -ACE_INLINE ACE_Array_Map & -ACE_Array_Map::operator= ( - ACE_Array_Map const & map) +template +ACE_INLINE ACE_Array_Map & +ACE_Array_Map::operator= ( + ACE_Array_Map const & map) { // Strongly exception-safe assignment. - ACE_Array_Map temp (map); + ACE_Array_Map temp (map); this->swap (temp); return *this; } -template -ACE_INLINE typename ACE_Array_Map::iterator -ACE_Array_Map::begin (void) +template +ACE_INLINE typename ACE_Array_Map::iterator +ACE_Array_Map::begin (void) { return this->nodes_; } -template -ACE_INLINE typename ACE_Array_Map::iterator -ACE_Array_Map::end (void) +template +ACE_INLINE typename ACE_Array_Map::iterator +ACE_Array_Map::end (void) { return this->nodes_ + this->size_; } -template -ACE_INLINE typename ACE_Array_Map::const_iterator -ACE_Array_Map::begin (void) const +template +ACE_INLINE typename ACE_Array_Map::const_iterator +ACE_Array_Map::begin (void) const { return this->nodes_; } -template -ACE_INLINE typename ACE_Array_Map::const_iterator -ACE_Array_Map::end (void) const +template +ACE_INLINE typename ACE_Array_Map::const_iterator +ACE_Array_Map::end (void) const { return this->nodes_ + this->size_; } -template -ACE_INLINE typename ACE_Array_Map::reverse_iterator -ACE_Array_Map::rbegin (void) +template +ACE_INLINE typename ACE_Array_Map::reverse_iterator +ACE_Array_Map::rbegin (void) { return reverse_iterator (this->end ()); } -template -ACE_INLINE typename ACE_Array_Map::reverse_iterator -ACE_Array_Map::rend (void) +template +ACE_INLINE typename ACE_Array_Map::reverse_iterator +ACE_Array_Map::rend (void) { return reverse_iterator (this->begin ()); } -template -ACE_INLINE typename ACE_Array_Map::const_reverse_iterator -ACE_Array_Map::rbegin (void) const +template +ACE_INLINE typename ACE_Array_Map::const_reverse_iterator +ACE_Array_Map::rbegin (void) const { return const_reverse_iterator (this->end ()); } -template -ACE_INLINE typename ACE_Array_Map::const_reverse_iterator -ACE_Array_Map::rend (void) const +template +ACE_INLINE typename ACE_Array_Map::const_reverse_iterator +ACE_Array_Map::rend (void) const { return const_reverse_iterator (this->begin ()); } -template -ACE_INLINE typename ACE_Array_Map::size_type -ACE_Array_Map::size (void) const +template +ACE_INLINE typename ACE_Array_Map::size_type +ACE_Array_Map::size (void) const { return this->size_; } -template -ACE_INLINE typename ACE_Array_Map::size_type -ACE_Array_Map::max_size (void) const +template +ACE_INLINE typename ACE_Array_Map::size_type +ACE_Array_Map::max_size (void) const { return size_type (-1) / sizeof (value_type); } -template +template ACE_INLINE bool -ACE_Array_Map::is_empty (void) const +ACE_Array_Map::is_empty (void) const { return this->size_ == 0; } // The following method is deprecated. -template +template ACE_INLINE bool -ACE_Array_Map::empty (void) const +ACE_Array_Map::empty (void) const { return this->is_empty (); } -template -ACE_INLINE typename ACE_Array_Map::size_type -ACE_Array_Map::count ( - typename ACE_Array_Map::key_type const & k) +template +ACE_INLINE typename ACE_Array_Map::size_type +ACE_Array_Map::count ( + typename ACE_Array_Map::key_type const & k) { return (this->find (k) == this->end () ? 0 : 1); // Only one datum per key. } -template -ACE_INLINE typename ACE_Array_Map::mapped_type & -ACE_Array_Map::operator[] ( - typename ACE_Array_Map::key_type const & k) +template +ACE_INLINE typename ACE_Array_Map::data_type & +ACE_Array_Map::operator[] ( + typename ACE_Array_Map::key_type const & k) { - iterator i = (this->insert (value_type (k, mapped_type ()))).first; + iterator i = (this->insert (value_type (k, data_type ()))).first; return (*i).second; } diff --git a/dep/acelite/ace/Assert.cpp b/dep/acelite/ace/Assert.cpp index 45524c643..ee8d56740 100644 --- a/dep/acelite/ace/Assert.cpp +++ b/dep/acelite/ace/Assert.cpp @@ -1,3 +1,5 @@ +// $Id: Assert.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Assert.h" #include "ace/Log_Category.h" @@ -14,12 +16,7 @@ __ace_assert(const char *file, int line, const ACE_TCHAR *expression) log->set (file, line, -1, error, log->restart (), log->msg_ostream (), log->msg_callback ()); -#ifdef ACE_LACKS_VA_FUNCTIONS -#define LOG_ARGS -#else -#define LOG_ARGS(X) X -#endif - log->log LOG_ARGS ((LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1)); + log->log (LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1); } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Assert.h b/dep/acelite/ace/Assert.h index 33c5a4c25..89363d4c6 100644 --- a/dep/acelite/ace/Assert.h +++ b/dep/acelite/ace/Assert.h @@ -4,7 +4,9 @@ /** * @file Assert.h * - * @author Douglas C. Schmidt + * $Id: Assert.h 82808 2008-09-23 11:27:27Z smcqueen $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Asynch_Acceptor.cpp b/dep/acelite/ace/Asynch_Acceptor.cpp index c518c3a62..498f9fdbb 100644 --- a/dep/acelite/ace/Asynch_Acceptor.cpp +++ b/dep/acelite/ace/Asynch_Acceptor.cpp @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: Asynch_Acceptor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_ASYNCH_ACCEPTOR_C #define ACE_ASYNCH_ACCEPTOR_C diff --git a/dep/acelite/ace/Asynch_Acceptor.h b/dep/acelite/ace/Asynch_Acceptor.h index 03efa702e..b806d6e45 100644 --- a/dep/acelite/ace/Asynch_Acceptor.h +++ b/dep/acelite/ace/Asynch_Acceptor.h @@ -4,6 +4,8 @@ /** * @file Asynch_Acceptor.h * + * $Id: Asynch_Acceptor.h 91693 2010-09-09 12:57:54Z johnnyw $ + * * @author Irfan Pyarali (irfan@cs.wustl.edu) */ //============================================================================= @@ -171,7 +173,7 @@ public: * another accept should be initiated. If the method returns a non-zero * value, another accept is initiated. * - * The default implementation always returns the value passed as the + * The default implemenation always returns the value passed as the * @c open() method's @a reissue_accept argument. That value can also * be changed using the @c reissue_accept() method. */ diff --git a/dep/acelite/ace/Asynch_Connector.cpp b/dep/acelite/ace/Asynch_Connector.cpp index 5391ca5ad..5876c0751 100644 --- a/dep/acelite/ace/Asynch_Connector.cpp +++ b/dep/acelite/ace/Asynch_Connector.cpp @@ -1,3 +1,5 @@ +// $Id: Asynch_Connector.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_ASYNCH_CONNECTOR_CPP #define ACE_ASYNCH_CONNECTOR_CPP diff --git a/dep/acelite/ace/Asynch_Connector.h b/dep/acelite/ace/Asynch_Connector.h index 8706fd222..7c7969cc2 100644 --- a/dep/acelite/ace/Asynch_Connector.h +++ b/dep/acelite/ace/Asynch_Connector.h @@ -4,6 +4,8 @@ /** * @file Asynch_Connector.h * + * $Id: Asynch_Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Alexander Libman */ //============================================================================= diff --git a/dep/acelite/ace/Asynch_IO.cpp b/dep/acelite/ace/Asynch_IO.cpp index f50cdc33d..1913ae10b 100644 --- a/dep/acelite/ace/Asynch_IO.cpp +++ b/dep/acelite/ace/Asynch_IO.cpp @@ -1,3 +1,5 @@ +// $Id: Asynch_IO.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Asynch_IO.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) diff --git a/dep/acelite/ace/Asynch_IO.h b/dep/acelite/ace/Asynch_IO.h index 1c7d5e4b8..058b83f69 100644 --- a/dep/acelite/ace/Asynch_IO.h +++ b/dep/acelite/ace/Asynch_IO.h @@ -4,6 +4,8 @@ /** * @file Asynch_IO.h * + * $Id: Asynch_IO.h 97246 2013-08-07 07:10:20Z johnnyw $ + * * This works on Win32 (defined (ACE_WIN32) && !defined * (ACE_HAS_WINCE)) platforms and on POSIX4 platforms with {aio_*} * routines (defined (ACE_HAS_AIO_CALLS)) @@ -983,13 +985,13 @@ public: ACE_Asynch_Accept_Result_Impl *implementation (void) const; protected: - /// Constructor. Implementation will not be deleted. + /// Contructor. Implementation will not be deleted. Result (ACE_Asynch_Accept_Result_Impl *implementation); /// Destructor. virtual ~Result (void); - /// Implementation class. + /// Impelmentation class. ACE_Asynch_Accept_Result_Impl *implementation_; }; private: @@ -1080,13 +1082,13 @@ public: ACE_Asynch_Connect_Result_Impl *implementation (void) const; protected: - /// Constructor. Implementation will not be deleted. + /// Contructor. Implementation will not be deleted. Result (ACE_Asynch_Connect_Result_Impl *implementation); /// Destructor. virtual ~Result (void); - /// Implementation class. + /// Impelmentation class. ACE_Asynch_Connect_Result_Impl *implementation_; }; private: diff --git a/dep/acelite/ace/Asynch_IO_Impl.cpp b/dep/acelite/ace/Asynch_IO_Impl.cpp index 1f25a1ee7..b4b47eda5 100644 --- a/dep/acelite/ace/Asynch_IO_Impl.cpp +++ b/dep/acelite/ace/Asynch_IO_Impl.cpp @@ -1,3 +1,5 @@ +// $Id: Asynch_IO_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Asynch_IO_Impl.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) diff --git a/dep/acelite/ace/Asynch_IO_Impl.h b/dep/acelite/ace/Asynch_IO_Impl.h index a4ec996df..e820529df 100644 --- a/dep/acelite/ace/Asynch_IO_Impl.h +++ b/dep/acelite/ace/Asynch_IO_Impl.h @@ -4,10 +4,14 @@ /** * @file Asynch_IO_Impl.h * + * $Id: Asynch_IO_Impl.h 93359 2011-02-11 11:33:12Z mcorino $ + * + * * This class contains asbtract base classes for all the concrete * implementation classes for the various asynchronous operations * that are used with the Praoctor. * + * * @author Irfan Pyarali (irfan@cs.wustl.edu) * @author Tim Harrison (harrison@cs.wustl.edu) * @author Alexander Babu Arulanthu @@ -42,6 +46,7 @@ class ACE_Proactor_Impl; * * @brief Abstract base class for the all the classes that provide * concrete implementations for ACE_Asynch_Result. + * */ class ACE_Export ACE_Asynch_Result_Impl { @@ -146,6 +151,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Read_Stream + * */ class ACE_Export ACE_Asynch_Read_Stream_Impl : public virtual ACE_Asynch_Operation_Impl { @@ -183,6 +189,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Read_Stream::Result class. + * */ class ACE_Export ACE_Asynch_Read_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl { @@ -210,6 +217,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Write_Stream class. + * */ class ACE_Export ACE_Asynch_Write_Stream_Impl : public virtual ACE_Asynch_Operation_Impl { @@ -247,6 +255,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Write_Stream::Result. + * */ class ACE_Export ACE_Asynch_Write_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl { @@ -274,6 +283,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Read_File::Result. + * */ class ACE_Export ACE_Asynch_Read_File_Impl : public virtual ACE_Asynch_Read_Stream_Impl { @@ -339,6 +349,7 @@ protected: * * @brief This is the abstract base class for all the concrete * implementation classes for ACE_Asynch_Read_File::Result. + * */ class ACE_Export ACE_Asynch_Read_File_Result_Impl : public virtual ACE_Asynch_Read_Stream_Result_Impl { @@ -357,6 +368,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Write_File. + * */ class ACE_Export ACE_Asynch_Write_File_Impl : public virtual ACE_Asynch_Write_Stream_Impl { @@ -423,6 +435,7 @@ protected: * @brief This is the abstract base class for all the concrete * implementation classes that provide different implementations * for the ACE_Asynch_Write_File::Result. + * */ class ACE_Export ACE_Asynch_Write_File_Result_Impl : public virtual ACE_Asynch_Write_Stream_Result_Impl { @@ -440,6 +453,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Accept. + * */ class ACE_Export ACE_Asynch_Accept_Impl : public virtual ACE_Asynch_Operation_Impl { @@ -476,6 +490,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Accept. + * */ class ACE_Export ACE_Asynch_Accept_Result_Impl : public virtual ACE_Asynch_Result_Impl { @@ -507,6 +522,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Connect. + * */ class ACE_Export ACE_Asynch_Connect_Impl : public virtual ACE_Asynch_Operation_Impl { @@ -535,6 +551,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Connect. + * */ class ACE_Export ACE_Asynch_Connect_Result_Impl : public virtual ACE_Asynch_Result_Impl { @@ -556,6 +573,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Transmit_File. + * */ class ACE_Asynch_Transmit_File_Impl : public virtual ACE_Asynch_Operation_Impl { @@ -585,6 +603,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Transmit_File::Result. + * */ class ACE_Export ACE_Asynch_Transmit_File_Result_Impl : public virtual ACE_Asynch_Result_Impl { @@ -623,6 +642,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Read_Dgram + * */ class ACE_Export ACE_Asynch_Read_Dgram_Impl : public virtual ACE_Asynch_Operation_Impl { @@ -674,6 +694,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Read_Dgram::Result class. + * */ class ACE_Export ACE_Asynch_Read_Dgram_Result_Impl : public virtual ACE_Asynch_Result_Impl { @@ -707,6 +728,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Write_Dgram class. + * */ class ACE_Export ACE_Asynch_Write_Dgram_Impl : public virtual ACE_Asynch_Operation_Impl { @@ -758,6 +780,7 @@ protected: * @brief Abstract base class for all the concrete implementation * classes that provide different implementations for the * ACE_Asynch_Write_Dgram::Result class. + * */ class ACE_Export ACE_Asynch_Write_Dgram_Result_Impl : public virtual ACE_Asynch_Result_Impl { diff --git a/dep/acelite/ace/Asynch_IO_Impl.inl b/dep/acelite/ace/Asynch_IO_Impl.inl index e6fce33b3..60dc69dfb 100644 --- a/dep/acelite/ace/Asynch_IO_Impl.inl +++ b/dep/acelite/ace/Asynch_IO_Impl.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Asynch_IO_Impl.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Asynch_Pseudo_Task.cpp b/dep/acelite/ace/Asynch_Pseudo_Task.cpp index 0b6a14b60..ff8da27db 100644 --- a/dep/acelite/ace/Asynch_Pseudo_Task.cpp +++ b/dep/acelite/ace/Asynch_Pseudo_Task.cpp @@ -1,3 +1,5 @@ +// $Id: Asynch_Pseudo_Task.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Asynch_Pseudo_Task.h" #include "ace/OS_NS_errno.h" diff --git a/dep/acelite/ace/Asynch_Pseudo_Task.h b/dep/acelite/ace/Asynch_Pseudo_Task.h index 4337361fe..6e2c3a1d4 100644 --- a/dep/acelite/ace/Asynch_Pseudo_Task.h +++ b/dep/acelite/ace/Asynch_Pseudo_Task.h @@ -4,6 +4,8 @@ /** * @file Asynch_Pseudo_Task.h * + * $Id: Asynch_Pseudo_Task.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Alexander Libman */ //============================================================================= @@ -34,6 +36,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** * @class ACE_Asynch_Pseudo_Task + * */ class ACE_Export ACE_Asynch_Pseudo_Task : public ACE_Task { diff --git a/dep/acelite/ace/Atomic_Op.cpp b/dep/acelite/ace/Atomic_Op.cpp index e1075809b..15be89e51 100644 --- a/dep/acelite/ace/Atomic_Op.cpp +++ b/dep/acelite/ace/Atomic_Op.cpp @@ -1,3 +1,5 @@ +// $Id: Atomic_Op.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Atomic_Op.h" #include "ace/OS_NS_unistd.h" @@ -32,7 +34,7 @@ single_cpu_increment (volatile long *value) (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))) return ace_atomic_add_long ( reinterpret_cast (value), 1); -#elif defined(__GNUC__) && defined(__PPC__) +#elif defined(__GNUC__) && defined(PPC) long tmp; asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) ); asm("addi %0,%0,1" : "+r" (tmp) ); @@ -56,7 +58,7 @@ single_cpu_decrement (volatile long *value) (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))) return ace_atomic_add_long ( reinterpret_cast (value), -1); -#elif defined(__GNUC__) && defined(__PPC__) +#elif defined(__GNUC__) && defined(PPC) long tmp; asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) ); asm("addi %0,%0,-1" : "+r" (tmp) ); @@ -79,7 +81,7 @@ single_cpu_exchange (volatile long *value, long rhs) (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))) return ace_atomic_swap_long ( reinterpret_cast (value), rhs); -#elif defined(__GNUC__) && defined(__PPC__) +#elif defined(__GNUC__) && defined(PPC) long tmp; asm("lwz %0,%1" : "=r" (tmp) : "m" (rhs) ); asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); @@ -102,7 +104,7 @@ single_cpu_exchange_add (volatile long *value, long rhs) (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64)))) return ace_atomic_swap_add_long ( reinterpret_cast (value), rhs); -#elif defined(__GNUC__) && defined(__PPC__) +#elif defined(__GNUC__) && defined(PPC) long tmp; asm("add %0,%1,%2" : "=r" (tmp) : "r" (*value), "r" (rhs) ); asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); diff --git a/dep/acelite/ace/Atomic_Op.h b/dep/acelite/ace/Atomic_Op.h index 0b2535e79..5c8673ebe 100644 --- a/dep/acelite/ace/Atomic_Op.h +++ b/dep/acelite/ace/Atomic_Op.h @@ -4,7 +4,9 @@ /** * @file Atomic_Op.h * - * @author Douglas C. Schmidt + * $Id: Atomic_Op.h 96147 2012-09-15 01:13:21Z shuston $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Atomic_Op.inl b/dep/acelite/ace/Atomic_Op.inl index 2f9ec57ba..711147864 100644 --- a/dep/acelite/ace/Atomic_Op.inl +++ b/dep/acelite/ace/Atomic_Op.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Atomic_Op.inl 96147 2012-09-15 01:13:21Z shuston $ + #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) # include "ace/os_include/os_intrin.h" # pragma intrinsic (_InterlockedExchange, _InterlockedExchangeAdd, _InterlockedIncrement, _InterlockedDecrement) diff --git a/dep/acelite/ace/Atomic_Op_GCC_T.cpp b/dep/acelite/ace/Atomic_Op_GCC_T.cpp index 3e7e7cada..d273f6e73 100644 --- a/dep/acelite/ace/Atomic_Op_GCC_T.cpp +++ b/dep/acelite/ace/Atomic_Op_GCC_T.cpp @@ -1,3 +1,5 @@ +// $Id: Atomic_Op_GCC_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/OS_NS_unistd.h" #if defined (ACE_HAS_GCC_ATOMIC_BUILTINS) && (ACE_HAS_GCC_ATOMIC_BUILTINS == 1) diff --git a/dep/acelite/ace/Atomic_Op_GCC_T.h b/dep/acelite/ace/Atomic_Op_GCC_T.h index 6a25fe176..f980f7f02 100644 --- a/dep/acelite/ace/Atomic_Op_GCC_T.h +++ b/dep/acelite/ace/Atomic_Op_GCC_T.h @@ -4,6 +4,8 @@ /** * @file Atomic_Op_GCC_T.h * + * $Id: Atomic_Op_GCC_T.h 95225 2011-12-05 20:25:15Z shuston $ + * * @author Johnny Willemsen ACE_LOCK & diff --git a/dep/acelite/ace/Atomic_Op_T.h b/dep/acelite/ace/Atomic_Op_T.h index 8031efb20..944c0454c 100644 --- a/dep/acelite/ace/Atomic_Op_T.h +++ b/dep/acelite/ace/Atomic_Op_T.h @@ -4,7 +4,9 @@ /** * @file Atomic_Op_T.h * - * @author Douglas C. Schmidt + * $Id: Atomic_Op_T.h 95761 2012-05-15 18:23:04Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -209,8 +211,8 @@ public: /// Dump the state of an object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. /// Manage copying... ACE_Atomic_Op_Ex (ACE_Atomic_Op_Ex const &); @@ -323,9 +325,6 @@ public: /// Dump the state of an object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - /** * Explicitly return @c value_ (by reference). This gives the user * full, unrestricted access to the underlying value. This method diff --git a/dep/acelite/ace/Atomic_Op_T.inl b/dep/acelite/ace/Atomic_Op_T.inl index 1b1eb988f..87e6b55d7 100644 --- a/dep/acelite/ace/Atomic_Op_T.inl +++ b/dep/acelite/ace/Atomic_Op_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Atomic_Op_T.inl 95225 2011-12-05 20:25:15Z shuston $ + #include "ace/Guard_T.h" #include diff --git a/dep/acelite/ace/Auto_Event.cpp b/dep/acelite/ace/Auto_Event.cpp index c95c0e855..7fb27c497 100644 --- a/dep/acelite/ace/Auto_Event.cpp +++ b/dep/acelite/ace/Auto_Event.cpp @@ -1,17 +1,13 @@ +// $Id: Auto_Event.cpp 96220 2012-11-06 10:03:41Z mcorino $ + #include "ace/Auto_Event.h" #if !defined (__ACE_INLINE__) #include "ace/Auto_Event.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Auto_Event_T) - template ACE_Auto_Event_T::ACE_Auto_Event_T ( int initial_state, diff --git a/dep/acelite/ace/Auto_Event.h b/dep/acelite/ace/Auto_Event.h index f01882c62..a75bd78e7 100644 --- a/dep/acelite/ace/Auto_Event.h +++ b/dep/acelite/ace/Auto_Event.h @@ -4,9 +4,11 @@ /** * @file Auto_Event.h * + * $Id: Auto_Event.h 96749 2013-02-02 19:08:38Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Auto_Event.inl b/dep/acelite/ace/Auto_Event.inl index 919c048d3..73427df33 100644 --- a/dep/acelite/ace/Auto_Event.inl +++ b/dep/acelite/ace/Auto_Event.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Auto_Event.inl 96220 2012-11-06 10:03:41Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Auto_Functor.cpp b/dep/acelite/ace/Auto_Functor.cpp index 7310d78d3..9d0dc79aa 100644 --- a/dep/acelite/ace/Auto_Functor.cpp +++ b/dep/acelite/ace/Auto_Functor.cpp @@ -1,3 +1,5 @@ +// $Id: Auto_Functor.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_AUTO_FUNCTOR_CPP #define ACE_AUTO_FUNCTOR_CPP diff --git a/dep/acelite/ace/Auto_Functor.h b/dep/acelite/ace/Auto_Functor.h index 7e75ae7b6..393a11c73 100644 --- a/dep/acelite/ace/Auto_Functor.h +++ b/dep/acelite/ace/Auto_Functor.h @@ -3,6 +3,8 @@ /** * @file Auto_Functor.h * + * $Id: Auto_Functor.h 92386 2010-10-28 07:44:37Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= @@ -50,6 +52,7 @@ struct Auto_Functor_Ref * Functor(Functor const &) throw();
* Functor & operator=(Functor const &) throw();
* void operator()(X * p) throw();
+ * */ template class Auto_Functor diff --git a/dep/acelite/ace/Auto_Functor.inl b/dep/acelite/ace/Auto_Functor.inl index be0c38361..5e714e014 100644 --- a/dep/acelite/ace/Auto_Functor.inl +++ b/dep/acelite/ace/Auto_Functor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Auto_Functor.inl 92386 2010-10-28 07:44:37Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE diff --git a/dep/acelite/ace/Auto_IncDec_T.cpp b/dep/acelite/ace/Auto_IncDec_T.cpp index 5d408c7db..137d8ff48 100644 --- a/dep/acelite/ace/Auto_IncDec_T.cpp +++ b/dep/acelite/ace/Auto_IncDec_T.cpp @@ -1,3 +1,5 @@ +// $Id: Auto_IncDec_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_AUTO_INCDEC_T_CPP #define ACE_AUTO_INCDEC_T_CPP @@ -12,13 +14,9 @@ #include "ace/Auto_IncDec_T.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Auto_IncDec) +ACE_ALLOC_HOOK_DEFINE(ACE_Auto_IncDec) template void ACE_Auto_IncDec::dump (void) const diff --git a/dep/acelite/ace/Auto_IncDec_T.h b/dep/acelite/ace/Auto_IncDec_T.h index d8e028344..ef2709c14 100644 --- a/dep/acelite/ace/Auto_IncDec_T.h +++ b/dep/acelite/ace/Auto_IncDec_T.h @@ -4,6 +4,8 @@ /** * @file Auto_IncDec_T.h * + * $Id: Auto_IncDec_T.h 97879 2014-09-08 13:29:28Z johnnyw $ + * * @author Edan Ayal */ //============================================================================= @@ -48,9 +50,6 @@ public: /// Dump the state of an object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Reference to the @c ACE_SAFELY_INCREMENTABLE_DECREMENTABLE counter /// we're incrementing/decrementing. diff --git a/dep/acelite/ace/Auto_IncDec_T.inl b/dep/acelite/ace/Auto_IncDec_T.inl index cb2144888..e61980e71 100644 --- a/dep/acelite/ace/Auto_IncDec_T.inl +++ b/dep/acelite/ace/Auto_IncDec_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Auto_IncDec_T.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Implicitly and automatically increment the counter. diff --git a/dep/acelite/ace/Auto_Ptr.cpp b/dep/acelite/ace/Auto_Ptr.cpp index 09028186a..81f458d34 100644 --- a/dep/acelite/ace/Auto_Ptr.cpp +++ b/dep/acelite/ace/Auto_Ptr.cpp @@ -1,20 +1,20 @@ +// $Id: Auto_Ptr.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #ifndef ACE_AUTO_PTR_CPP #define ACE_AUTO_PTR_CPP #include "ace/Auto_Ptr.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/Auto_Ptr.inl" #endif /* __ACE_INLINE__ */ + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Auto_Basic_Ptr) -ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Auto_Basic_Array_Ptr) +ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Ptr) +ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Array_Ptr) ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Auto_Ptr.h b/dep/acelite/ace/Auto_Ptr.h index 02fbddf99..e9468a73b 100644 --- a/dep/acelite/ace/Auto_Ptr.h +++ b/dep/acelite/ace/Auto_Ptr.h @@ -4,7 +4,9 @@ /** * @file Auto_Ptr.h * - * @author Doug Schmidt + * $Id: Auto_Ptr.h 92580 2010-11-15 09:48:02Z johnnyw $ + * + * @author Doug Schmidt * @author Irfan Pyarali * @author Jack Reeves * @author Dr. Harald M. Mueller @@ -76,9 +78,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL #include #if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) && \ (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0) -#if !defined (ACE_HAS_CPP17) using std::auto_ptr; -#endif /* !ACE_HAS_CPP17 */ #endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ #else /* ACE_HAS_STANDARD_CPP_LIBRARY */ diff --git a/dep/acelite/ace/Auto_Ptr.inl b/dep/acelite/ace/Auto_Ptr.inl index 1cc93536e..9ea47c3f2 100644 --- a/dep/acelite/ace/Auto_Ptr.inl +++ b/dep/acelite/ace/Auto_Ptr.inl @@ -1,9 +1,8 @@ // -*- C++ -*- -#include "ace/Global_Macros.h" +// +// $Id: Auto_Ptr.inl 80826 2008-03-04 14:51:23Z wotte $ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ +#include "ace/Global_Macros.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -121,12 +120,7 @@ ACE_Auto_Basic_Array_Ptr::reset (X *p) { ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::reset"); if (this->get () != p) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->get ()); -#else delete [] this->get (); -#endif /* ACE_HAS_ALLOC_HOOKS */ - this->p_ = p; } @@ -152,11 +146,7 @@ template ACE_INLINE ACE_Auto_Basic_Array_Ptr::~ACE_Auto_Basic_Array_Ptr (void) { ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::~ACE_Auto_Basic_Array_Ptr"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->get ()); -#else delete [] this->get (); -#endif /* ACE_HAS_ALLOC_HOOKS */ } template ACE_INLINE X & diff --git a/dep/acelite/ace/Barrier.cpp b/dep/acelite/ace/Barrier.cpp index 9eb706785..4c963bbd7 100644 --- a/dep/acelite/ace/Barrier.cpp +++ b/dep/acelite/ace/Barrier.cpp @@ -1,3 +1,5 @@ +// $Id: Barrier.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Barrier.h" #if defined (ACE_HAS_THREADS) @@ -9,10 +11,6 @@ #include "ace/Guard_T.h" #include "ace/OS_NS_errno.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if defined (ACE_HAS_DUMP) # include "ace/Log_Category.h" #endif /* ACE_HAS_DUMP */ diff --git a/dep/acelite/ace/Barrier.h b/dep/acelite/ace/Barrier.h index d6efaf2b8..e1e3815e1 100644 --- a/dep/acelite/ace/Barrier.h +++ b/dep/acelite/ace/Barrier.h @@ -4,9 +4,11 @@ /** * @file Barrier.h * + * $Id: Barrier.h 93359 2011-02-11 11:33:12Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Barrier.inl b/dep/acelite/ace/Barrier.inl index f742deeb6..10430d917 100644 --- a/dep/acelite/ace/Barrier.inl +++ b/dep/acelite/ace/Barrier.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Barrier.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Base_Thread_Adapter.cpp b/dep/acelite/ace/Base_Thread_Adapter.cpp index f965bac12..4b7b6a84c 100644 --- a/dep/acelite/ace/Base_Thread_Adapter.cpp +++ b/dep/acelite/ace/Base_Thread_Adapter.cpp @@ -1,3 +1,5 @@ +// $Id: Base_Thread_Adapter.cpp 95595 2012-03-07 13:33:25Z johnnyw $ + #include "ace/Base_Thread_Adapter.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/Base_Thread_Adapter.h b/dep/acelite/ace/Base_Thread_Adapter.h index d45ce6574..2075e9122 100644 --- a/dep/acelite/ace/Base_Thread_Adapter.h +++ b/dep/acelite/ace/Base_Thread_Adapter.h @@ -4,6 +4,8 @@ /** * @file Base_Thread_Adapter.h * + * $Id: Base_Thread_Adapter.h 95595 2012-03-07 13:33:25Z johnnyw $ + * * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/Base_Thread_Adapter.inl b/dep/acelite/ace/Base_Thread_Adapter.inl index febce6f49..3bac80246 100644 --- a/dep/acelite/ace/Base_Thread_Adapter.inl +++ b/dep/acelite/ace/Base_Thread_Adapter.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Base_Thread_Adapter.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE long diff --git a/dep/acelite/ace/Based_Pointer_Repository.cpp b/dep/acelite/ace/Based_Pointer_Repository.cpp index 6ec16f555..6143c4bd8 100644 --- a/dep/acelite/ace/Based_Pointer_Repository.cpp +++ b/dep/acelite/ace/Based_Pointer_Repository.cpp @@ -1,3 +1,5 @@ +// $Id: Based_Pointer_Repository.cpp 97383 2013-10-23 08:44:20Z mhengstmengel $ + #include "ace/Map_Manager.h" #include "ace/Based_Pointer_Repository.h" #include "ace/Guard_T.h" @@ -5,10 +7,6 @@ #include "ace/Synch_Traits.h" #include "ace/RW_Thread_Mutex.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** @@ -34,12 +32,8 @@ public: /// Synchronize concurrent access to the map. ACE_SYNCH_MUTEX lock_; - - ACE_ALLOC_HOOK_DECLARE; }; -ACE_ALLOC_HOOK_DEFINE(ACE_Based_Pointer_Repository_Rep); - ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository (void) { ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository"); diff --git a/dep/acelite/ace/Based_Pointer_Repository.h b/dep/acelite/ace/Based_Pointer_Repository.h index 00b6d2c4f..d549ce153 100644 --- a/dep/acelite/ace/Based_Pointer_Repository.h +++ b/dep/acelite/ace/Based_Pointer_Repository.h @@ -4,6 +4,8 @@ /** * @file Based_Pointer_Repository.h * + * $Id: Based_Pointer_Repository.h 84837 2009-03-16 13:01:15Z johnnyw $ + * * @author Dietrich Quehl * @author Douglas C. Schmidt */ diff --git a/dep/acelite/ace/Based_Pointer_T.cpp b/dep/acelite/ace/Based_Pointer_T.cpp index df983903c..d2fd33531 100644 --- a/dep/acelite/ace/Based_Pointer_T.cpp +++ b/dep/acelite/ace/Based_Pointer_T.cpp @@ -1,3 +1,5 @@ +// $Id: Based_Pointer_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_BASED_POINTER_T_CPP #define ACE_BASED_POINTER_T_CPP @@ -13,8 +15,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Based_Pointer_Basic) - template ACE_Based_Pointer::ACE_Based_Pointer (void) { diff --git a/dep/acelite/ace/Based_Pointer_T.h b/dep/acelite/ace/Based_Pointer_T.h index e0211603c..802e73ca0 100644 --- a/dep/acelite/ace/Based_Pointer_T.h +++ b/dep/acelite/ace/Based_Pointer_T.h @@ -4,6 +4,8 @@ /** * @file Based_Pointer_T.h * + * $Id: Based_Pointer_T.h 81705 2008-05-15 14:02:02Z johnnyw $ + * * @author Dietrich Quehl * @author Douglas C. Schmidt */ diff --git a/dep/acelite/ace/Based_Pointer_T.inl b/dep/acelite/ace/Based_Pointer_T.inl index 04ab75831..ba6a5aa51 100644 --- a/dep/acelite/ace/Based_Pointer_T.inl +++ b/dep/acelite/ace/Based_Pointer_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Based_Pointer_T.inl 81705 2008-05-15 14:02:02Z johnnyw $ + #define ACE_COMPUTE_BASED_POINTER(P) (((char *) (P) - (P)->base_offset_) + (P)->target_) #include "ace/Global_Macros.h" diff --git a/dep/acelite/ace/Basic_Stats.cpp b/dep/acelite/ace/Basic_Stats.cpp index 98e3193f3..9565ce494 100644 --- a/dep/acelite/ace/Basic_Stats.cpp +++ b/dep/acelite/ace/Basic_Stats.cpp @@ -1,3 +1,5 @@ +// $Id: Basic_Stats.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Basic_Stats.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/Basic_Stats.h b/dep/acelite/ace/Basic_Stats.h index 4cc4bd2d6..eb6c393b9 100644 --- a/dep/acelite/ace/Basic_Stats.h +++ b/dep/acelite/ace/Basic_Stats.h @@ -3,6 +3,8 @@ /** * @file Basic_Stats.h * + * $Id: Basic_Stats.h 95743 2012-05-13 12:29:28Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/Basic_Stats.inl b/dep/acelite/ace/Basic_Stats.inl index 185478ab7..e2f153884 100644 --- a/dep/acelite/ace/Basic_Stats.inl +++ b/dep/acelite/ace/Basic_Stats.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Basic_Stats.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Basic_Types.cpp b/dep/acelite/ace/Basic_Types.cpp index 56867684e..c915dabee 100644 --- a/dep/acelite/ace/Basic_Types.cpp +++ b/dep/acelite/ace/Basic_Types.cpp @@ -1 +1,3 @@ +// $Id: Basic_Types.cpp 95763 2012-05-16 06:43:51Z johnnyw $ + #include "ace/Basic_Types.h" diff --git a/dep/acelite/ace/Basic_Types.h b/dep/acelite/ace/Basic_Types.h index b9feefb5e..f674dcce2 100644 --- a/dep/acelite/ace/Basic_Types.h +++ b/dep/acelite/ace/Basic_Types.h @@ -4,6 +4,8 @@ /** * @file Basic_Types.h * + * $Id: Basic_Types.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author David L. Levine * * #defines the list of preprocessor macros below. The config.h file can diff --git a/dep/acelite/ace/Bound_Ptr.h b/dep/acelite/ace/Bound_Ptr.h index 4d07c5417..5176ff951 100644 --- a/dep/acelite/ace/Bound_Ptr.h +++ b/dep/acelite/ace/Bound_Ptr.h @@ -4,6 +4,8 @@ /** * @file Bound_Ptr.h * + * $Id: Bound_Ptr.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Christopher Kohlhoff * @author Boris Kolpackov */ @@ -20,9 +22,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if !defined (ACE_HAS_CPP11) -# include "ace/Auto_Ptr.h" -#endif /* !ACE_HAS_CPP11 */ +#include "ace/Auto_Ptr.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -116,11 +116,9 @@ public: /// object \ immediately. explicit ACE_Strong_Bound_Ptr (X *p = 0); -#if !defined (ACE_HAS_CPP11) /// Constructor that initializes an ACE_Strong_Bound_Ptr by stealing /// ownership of an object from an auto_ptr. explicit ACE_Strong_Bound_Ptr (auto_ptr p); -#endif /* !ACE_HAS_CPP11 */ /// Copy constructor binds @c this and @a r to the same object. ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r); @@ -218,12 +216,10 @@ public: /// underlying object. void reset (X *p = 0); -#if !defined (ACE_HAS_CPP11) /// Resets the ACE_Strong_Bound_Ptr to refer to a different /// underlying object, ownership of which is stolen from the /// auto_ptr. void reset (auto_ptr p); -#endif /* !ACE_HAS_CPP11 */ /// Allows us to check for NULL on all ACE_Strong_Bound_Ptr /// objects. @@ -385,17 +381,7 @@ private: ACE_END_VERSIONED_NAMESPACE_DECL -#if defined (__ACE_INLINE__) #include "ace/Bound_Ptr.inl" -#endif /* __ACE_INLINE__ */ - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Bound_Ptr.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Bound_Ptr.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #include /**/ "ace/post.h" diff --git a/dep/acelite/ace/Bound_Ptr.inl b/dep/acelite/ace/Bound_Ptr.inl index 826c9aa98..83a8dbfdf 100644 --- a/dep/acelite/ace/Bound_Ptr.inl +++ b/dep/acelite/ace/Bound_Ptr.inl @@ -1,4 +1,8 @@ /* -*- C++ -*- */ +// $Id: Bound_Ptr.inl 96985 2013-04-11 15:50:32Z huangh $ + +// Bound_Ptr.i + #include "ace/Guard_T.h" #if !defined (ACE_NEW_THROWS_EXCEPTIONS) # include "ace/Log_Category.h" @@ -146,14 +150,12 @@ ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (X *p) { } -#if !defined (ACE_HAS_CPP11) template inline ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (auto_ptr p) : counter_ (COUNTER::create_strong ()), ptr_ (p.release()) { } -#endif /* !ACE_HAS_CPP11 */ template inline ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) @@ -303,7 +305,6 @@ ACE_Strong_Bound_Ptr::reset (X *p) delete old_ptr; } -#if !defined (ACE_HAS_CPP11) template inline void ACE_Strong_Bound_Ptr::reset (auto_ptr p) { @@ -314,7 +315,6 @@ ACE_Strong_Bound_Ptr::reset (auto_ptr p) if (COUNTER::detach_strong (old_counter) == 0) delete old_ptr; } -#endif /* !ACE_HAS_CPP11 */ template inline ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (X *p) diff --git a/dep/acelite/ace/CDR_Base.cpp b/dep/acelite/ace/CDR_Base.cpp index 56b65f080..11e0da336 100644 --- a/dep/acelite/ace/CDR_Base.cpp +++ b/dep/acelite/ace/CDR_Base.cpp @@ -1,3 +1,5 @@ +// $Id: CDR_Base.cpp 97884 2014-09-08 18:00:53Z johnnyw $ + #include "ace/CDR_Base.h" #if !defined (__ACE_INLINE__) @@ -8,17 +10,6 @@ #include "ace/OS_Memory.h" #include "ace/OS_NS_string.h" -#ifdef ACE_LACKS_IOSTREAM_TOTALLY -#include "ace/OS_NS_stdio.h" -#else -#include "ace/streams.h" -#endif - -#include -#include -#include -#include - ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (NONNATIVE_LONGDOUBLE) @@ -52,7 +43,7 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) } #else char const * const o4 = ACE_ptr_align_binary (orig, 4); - // this is an _if_, not a _while_. The mismatch can only be by 2. + // this is an _if_, not a _while_. The mistmatch can only be by 2. if (orig != o4) { ACE_CDR::swap_2 (orig, target); @@ -74,7 +65,7 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) // end marks our barrier for not falling outside. char const * const end = orig + 2 * (n & (~3)); - // See if we're aligned for writing in 64 or 32 bit chunks... + // See if we're aligned for writting in 64 or 32 bit chunks... #if ACE_SIZEOF_LONG == 8 && \ !((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__)) if (target == ACE_ptr_align_binary (target, 8)) @@ -110,22 +101,25 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) __asm mov 4[edx], ebx; #elif ACE_SIZEOF_LONG == 8 // 64 bit architecture. - unsigned long a = * reinterpret_cast (orig); + ACE_REGISTER unsigned long a = + * reinterpret_cast (orig); - unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; - unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; + ACE_REGISTER unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; + ACE_REGISTER unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; a = (a1 | a2); * reinterpret_cast (target) = a; #else - ACE_UINT32 a = * reinterpret_cast (orig); - ACE_UINT32 b = * reinterpret_cast (orig + 4); + ACE_REGISTER ACE_UINT32 a = + * reinterpret_cast (orig); + ACE_REGISTER ACE_UINT32 b = + * reinterpret_cast (orig + 4); - ACE_UINT32 a1 = (a & 0x00ff00ffU) << 8; - ACE_UINT32 b1 = (b & 0x00ff00ffU) << 8; - ACE_UINT32 a2 = (a & 0xff00ff00U) >> 8; - ACE_UINT32 b2 = (b & 0xff00ff00U) >> 8; + ACE_REGISTER ACE_UINT32 a1 = (a & 0x00ff00ffU) << 8; + ACE_REGISTER ACE_UINT32 b1 = (b & 0x00ff00ffU) << 8; + ACE_REGISTER ACE_UINT32 a2 = (a & 0xff00ff00U) >> 8; + ACE_REGISTER ACE_UINT32 b2 = (b & 0xff00ff00U) >> 8; a = (a1 | a2); b = (b1 | b2); @@ -178,10 +172,11 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) __asm mov 4[edx], bx; #elif ACE_SIZEOF_LONG == 8 // 64 bit architecture. - unsigned long a = * reinterpret_cast (orig); + ACE_REGISTER unsigned long a = + * reinterpret_cast (orig); - unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; - unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; + ACE_REGISTER unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; + ACE_REGISTER unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; a = (a1 | a2); @@ -202,13 +197,15 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) * reinterpret_cast (target + 6) = b4; #endif #else - ACE_UINT32 a = * reinterpret_cast (orig); - ACE_UINT32 b = * reinterpret_cast (orig + 4); + ACE_REGISTER ACE_UINT32 a = + * reinterpret_cast (orig); + ACE_REGISTER ACE_UINT32 b = + * reinterpret_cast (orig + 4); - ACE_UINT32 a1 = (a & 0x00ff00ff) << 8; - ACE_UINT32 b1 = (b & 0x00ff00ff) << 8; - ACE_UINT32 a2 = (a & 0xff00ff00) >> 8; - ACE_UINT32 b2 = (b & 0xff00ff00) >> 8; + ACE_REGISTER ACE_UINT32 a1 = (a & 0x00ff00ff) << 8; + ACE_REGISTER ACE_UINT32 b1 = (b & 0x00ff00ff) << 8; + ACE_REGISTER ACE_UINT32 a2 = (a & 0xff00ff00) >> 8; + ACE_REGISTER ACE_UINT32 b2 = (b & 0xff00ff00) >> 8; a = (a1 | a2); b = (b1 | b2); @@ -242,12 +239,10 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) ACE_CDR::swap_2 (orig, target); orig += 2; target += 2; - // fallthrough case 2: ACE_CDR::swap_2 (orig, target); orig += 2; target += 2; - // fallthrough case 1: ACE_CDR::swap_2 (orig, target); } @@ -292,8 +287,10 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) { while (orig < end) { - unsigned long a = * reinterpret_cast (orig); - unsigned long b = * reinterpret_cast (orig + 8); + ACE_REGISTER unsigned long a = + * reinterpret_cast (orig); + ACE_REGISTER unsigned long b = + * reinterpret_cast (orig + 8); #if defined(ACE_HAS_INTEL_ASSEMBLY) asm ("bswapq %1" : "=r" (a) : "0" (a)); @@ -301,14 +298,14 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) asm ("rol $32, %1" : "=r" (a) : "0" (a)); asm ("rol $32, %1" : "=r" (b) : "0" (b)); #else - unsigned long a84 = (a & 0x000000ff000000ffL) << 24; - unsigned long b84 = (b & 0x000000ff000000ffL) << 24; - unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; - unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; - unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; - unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; - unsigned long a51 = (a & 0xff000000ff000000L) >> 24; - unsigned long b51 = (b & 0xff000000ff000000L) >> 24; + ACE_REGISTER unsigned long a84 = (a & 0x000000ff000000ffL) << 24; + ACE_REGISTER unsigned long b84 = (b & 0x000000ff000000ffL) << 24; + ACE_REGISTER unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; + ACE_REGISTER unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; + ACE_REGISTER unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; + ACE_REGISTER unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; + ACE_REGISTER unsigned long a51 = (a & 0xff000000ff000000L) >> 24; + ACE_REGISTER unsigned long b51 = (b & 0xff000000ff000000L) >> 24; a = (a84 | a73 | a62 | a51); b = (b84 | b73 | b62 | b51); @@ -326,8 +323,10 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) // We are out of luck, we have to write in 4 byte chunks. while (orig < end) { - unsigned long a = * reinterpret_cast (orig); - unsigned long b = * reinterpret_cast (orig + 8); + ACE_REGISTER unsigned long a = + * reinterpret_cast (orig); + ACE_REGISTER unsigned long b = + * reinterpret_cast (orig + 8); #if defined(ACE_HAS_INTEL_ASSEMBLY) asm ("bswapq %1" : "=r" (a) : "0" (a)); @@ -335,14 +334,14 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) asm ("rol $32, %1" : "=r" (a) : "0" (a)); asm ("rol $32, %1" : "=r" (b) : "0" (b)); #else - unsigned long a84 = (a & 0x000000ff000000ffL) << 24; - unsigned long b84 = (b & 0x000000ff000000ffL) << 24; - unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; - unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; - unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; - unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; - unsigned long a51 = (a & 0xff000000ff000000L) >> 24; - unsigned long b51 = (b & 0xff000000ff000000L) >> 24; + ACE_REGISTER unsigned long a84 = (a & 0x000000ff000000ffL) << 24; + ACE_REGISTER unsigned long b84 = (b & 0x000000ff000000ffL) << 24; + ACE_REGISTER unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; + ACE_REGISTER unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; + ACE_REGISTER unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; + ACE_REGISTER unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; + ACE_REGISTER unsigned long a51 = (a & 0xff000000ff000000L) >> 24; + ACE_REGISTER unsigned long b51 = (b & 0xff000000ff000000L) >> 24; a = (a84 | a73 | a62 | a51); b = (b84 | b73 | b62 | b51); @@ -374,10 +373,14 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) while (orig < end) { #if defined (ACE_HAS_PENTIUM) && defined (__GNUG__) - unsigned int a = *reinterpret_cast (orig); - unsigned int b = *reinterpret_cast (orig + 4); - unsigned int c = *reinterpret_cast (orig + 8); - unsigned int d = *reinterpret_cast (orig + 12); + ACE_REGISTER unsigned int a = + *reinterpret_cast (orig); + ACE_REGISTER unsigned int b = + *reinterpret_cast (orig + 4); + ACE_REGISTER unsigned int c = + *reinterpret_cast (orig + 8); + ACE_REGISTER unsigned int d = + *reinterpret_cast (orig + 12); asm ("bswap %1" : "=r" (a) : "0" (a)); asm ("bswap %1" : "=r" (b) : "0" (b)); @@ -406,10 +409,14 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) __asm mov 8[esi], ebx __asm mov 12[esi], eax #else - ACE_UINT32 a = * reinterpret_cast (orig); - ACE_UINT32 b = * reinterpret_cast (orig + 4); - ACE_UINT32 c = * reinterpret_cast (orig + 8); - ACE_UINT32 d = * reinterpret_cast (orig + 12); + ACE_REGISTER ACE_UINT32 a = + * reinterpret_cast (orig); + ACE_REGISTER ACE_UINT32 b = + * reinterpret_cast (orig + 4); + ACE_REGISTER ACE_UINT32 c = + * reinterpret_cast (orig + 8); + ACE_REGISTER ACE_UINT32 d = + * reinterpret_cast (orig + 12); // Expect the optimizer reordering this A LOT. // We leave it this way for clarity. @@ -436,12 +443,10 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) ACE_CDR::swap_4 (orig, target); orig += 4; target += 4; - // fallthrough case 2: ACE_CDR::swap_4 (orig, target); orig += 4; target += 4; - // fallthrough case 1: ACE_CDR::swap_4 (orig, target); } @@ -628,7 +633,7 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs) { exponent = 0x7fff; } - else if (exponent) // exponent 0 stays 0 in 128-bit + else { exponent = (exponent - max_eleven_bit) + max_fifteen_bit; } @@ -721,7 +726,7 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const { exponent = 0x7ff; } - else if (exponent) // exponent 0 stays 0 in 64-bit + else { exponent = (exponent - max_fifteen_bit) + max_eleven_bit; } @@ -769,871 +774,4 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const } #endif /* NONNATIVE_LONGDOUBLE */ - -// ACE_CDR::Fixed - -ACE_CDR::Fixed ACE_CDR::Fixed::from_integer (ACE_CDR::LongLong val) -{ - Fixed f; - f.value_[15] = (val < 0) ? NEGATIVE : POSITIVE; - f.digits_ = 0; - f.scale_ = 0; - bool high = true; - int idx = 15; - while (true) - { - const int mod = static_cast (val % 10); - const unsigned int digit = (mod < 0) ? -mod : mod; - if (high) - f.value_[idx--] |= digit << 4; - else - f.value_[idx] = digit; - high = !high; - ++f.digits_; - if (val >= 10 || val <= -10) - val /= 10; - else - break; - } - - ACE_OS::memset (f.value_, 0, idx + !high); - return f; -} - -ACE_CDR::Fixed ACE_CDR::Fixed::from_integer (ACE_CDR::ULongLong val) -{ - Fixed f; - f.value_[15] = POSITIVE; - f.digits_ = 0; - f.scale_ = 0; - bool high = true; - int idx = 15; - while (true) - { - const unsigned int digit = val % 10; - if (high) - f.value_[idx--] |= digit << 4; - else - f.value_[idx] = digit; - high = !high; - ++f.digits_; - if (val >= 10) - val /= 10; - else - break; - } - - ACE_OS::memset (f.value_, 0, idx + !high); - return f; -} - -ACE_CDR::Fixed ACE_CDR::Fixed::from_floating (LongDouble val) -{ -#if defined ACE_OPENVMS || (defined ACE_VXWORKS && !defined __RTP__) - typedef double BigFloat; -#elif defined NONNATIVE_LONGDOUBLE - typedef LongDouble::NativeImpl BigFloat; -#else - typedef LongDouble BigFloat; -#endif - - Fixed f; - f.digits_ = f.scale_ = 0; - bool negative = false; - if (val < 0) - { - val *= -1; - negative = true; - } - - // How many digits are to the left of the decimal point? - const size_t digits_left = - static_cast (1 + ((val > 0) ? std::log10 (val) : 0)); - if (digits_left > MAX_DIGITS) - { - ACE_OS::memset (f.value_, 0, sizeof f.value_); - return f; - } - - f.digits_ = MAX_DIGITS; - f.scale_ = 0; - BigFloat int_part; - BigFloat frac_part = std::modf (val, &int_part); - - // Insert the integer part from least to most significant - int idx = (static_cast (digits_left) + 1) / 2 - 1; - bool high = digits_left % 2; - if (idx >= 0) - f.value_[idx] = 0; - for (size_t i = 0; i < digits_left; ++i, high = !high) - { - const Octet digit = static_cast (std::fmod (int_part, 10)); - if (high) - f.value_[idx--] |= digit << 4; - else - f.value_[idx] = digit; - int_part /= 10; - } - - // Insert the fractional part from most to least significant - idx = static_cast (digits_left / 2); - high = digits_left % 2 == 0; - for (size_t i = digits_left; i < MAX_DIGITS; ++i, high = !high) - { - frac_part *= 10; - const Octet digit = static_cast (frac_part); - frac_part -= digit; - if (high) - f.value_[idx] = digit << 4; - else - f.value_[idx++] |= digit; - } - - if (frac_part >= 0.5) - ++f; // scale set after here so that ++ applies to the fractional part - - f.scale_ = static_cast (MAX_DIGITS - digits_left); - f.normalize (); - f.value_[15] |= negative ? NEGATIVE : POSITIVE; - return f; -} - -void ACE_CDR::Fixed::normalize (UShort min_scale) -{ - if (this->value_[15] & 0xf0 || !this->scale_) - return; - - // Calculate the number of nibbles that can be moved. - ACE_CDR::Octet nibbles = 0; - while (this->digit(nibbles) == 0 && this->scale_ - nibbles > min_scale) - ++nibbles; - - // Move and clear the nibbles. - for (ACE_CDR::Octet idx = nibbles; idx != this->digits_; ++idx) { - this->digit (idx - nibbles, this->digit (idx)); - this->digit (idx, 0); - } - - this->scale_ -= nibbles; - this->digits_ -= nibbles; -} - -ACE_CDR::Fixed ACE_CDR::Fixed::from_string (const char *str) -{ - const bool negative = *str == '-'; - if (negative || *str == '+') - ++str; - - const size_t span = ACE_OS::strspn (str, ".0123456789"); - - Fixed f; - f.value_[15] = negative ? NEGATIVE : POSITIVE; - f.digits_ = 0; - f.scale_ = 0; - - int idx = 15; - bool high = true; - for (size_t iter = span; iter && f.digits_ < MAX_DIGITS; --iter, high = !high) - { - if (str[iter - 1] == '.') - { - f.scale_ = static_cast (span - iter); - if (--iter == 0) - break; // skip '.' - } - - const unsigned int digit = str[iter - 1] - '0'; - if (high) - f.value_[idx--] |= digit << 4; - else - f.value_[idx] = digit; - ++f.digits_; - } - - if (!f.scale_ && str[span - f.digits_ - 1] == '.') - f.scale_ = f.digits_; - - if (idx >= 0) - ACE_OS::memset (f.value_, 0, idx + !high); - return f; -} - -ACE_CDR::Fixed ACE_CDR::Fixed::from_octets (const Octet *array, int len, - unsigned int scale) -{ - Fixed f; - ACE_OS::memcpy (f.value_ + 16 - len, array, len); - ACE_OS::memset (f.value_, 0, 16 - len); - f.scale_ = scale; - - f.digits_ = len * 2 - 1; - if (len > 1 && (array[0] >> 4) == 0) - --f.digits_; - - return f; -} - -ACE_CDR::Fixed::operator ACE_CDR::LongLong () const -{ - LongLong val (0); - - for (int i = this->digits_ - 1; i >= this->scale_; --i) - val = 10 * val + this->digit (i); - - if (this->sign ()) - val *= -1; - - return val; -} - -ACE_CDR::Fixed::operator ACE_CDR::LongDouble () const -{ - LongDouble val = ACE_CDR_LONG_DOUBLE_INITIALIZER; - - for (int i = this->digits_ - 1; i >= this->scale_; --i) - ACE_CDR_LONG_DOUBLE_ASSIGNMENT (val, 10 * val + this->digit (i)); - - for (int i = this->scale_ - 1; i >= 0; --i) - val += this->digit (i) * std::pow (10.0l, i - this->scale_); - - if (this->sign ()) - val *= -1; - - return val; -} - -ACE_CDR::Fixed ACE_CDR::Fixed::round (UShort scale) const -{ - Fixed f = *this; - if (scale < f.scale_) - { - for (UShort i = 0; i < f.scale_ - scale; ++i) - f.digit (i, 0); - f.normalize (scale); - const bool negative = f.sign (); - if (negative) - f.value_[15] = (f.value_[15] & 0xf0) | POSITIVE; - if (this->digit (this->scale_ - scale - 1) >= 5) - { - f.scale_ = 0; - ++f; - f.scale_ = static_cast (scale); - } - if (negative && !!f) - f.value_[15] = (f.value_[15] & 0xf0) | NEGATIVE; - } - return f; -} - -ACE_CDR::Fixed ACE_CDR::Fixed::truncate (UShort scale) const -{ - Fixed f = *this; - if (scale < f.scale_) - { - for (UShort i = 0; i < f.scale_ - scale; ++i) - f.digit (i, 0); - f.normalize (scale); - if (f.sign ()) - { - f.value_[15] = (f.value_[15] & 0xf0) | POSITIVE; - if (!!f) - f.value_[15] = (f.value_[15] & 0xf0) | NEGATIVE; - } - } - return f; -} - -namespace { - struct BufferAppender - { - BufferAppender (char *buffer, size_t buffer_size) - : buffer_ (buffer), buffer_size_ (buffer_size), idx_ (0) {} - - bool operator+= (char ch) - { - if (this->idx_ == this->buffer_size_ - 1) - return false; - this->buffer_[this->idx_++] = ch; - return true; - } - - char *const buffer_; - const size_t buffer_size_; - size_t idx_; - }; -} - -bool ACE_CDR::Fixed::to_string (char *buffer, size_t buffer_size) const -{ - if (!buffer || buffer_size < 2) - return false; - - const bool negative = this->sign (); - if (negative) - *buffer = '-'; - BufferAppender ba (buffer + negative, buffer_size - negative); - - for (int i = 15 - this->digits_ / 2; i < 16; ++i) - { - const Octet high = this->value_[i] >> 4, low = this->value_[i] & 0xf; - - if ((15 - i) * 2 != this->digits_) - { - if (this->scale_ == 1 + 2 * (15 - i)) - { - if (!ba.idx_ && !(ba += '0')) - return false; - - if (!(ba += '.')) - return false; - } - - if ((ba.idx_ || high) && !(ba += '0' + high)) - return false; - } - - if (this->scale_ && this->scale_ == 2 * (15 - i)) - { - if (!ba.idx_ && !(ba += '0')) - return false; - - if (!(ba += '.')) - return false; - } - - if (i < 15 && (ba.idx_ || low) && !(ba += '0' + low)) - return false; - } - - if (!ba.idx_ && !(ba += '0')) - return false; - - buffer[ba.idx_ + negative] = 0; - return true; -} - -const ACE_CDR::Octet *ACE_CDR::Fixed::to_octets (int &n) const -{ - n = (this->digits_ + 2) / 2; - return 16 - n + reinterpret_cast (this->value_); -} - -ACE_CDR::Fixed::ConstIterator ACE_CDR::Fixed::pre_add (const ACE_CDR::Fixed &f) -{ - ConstIterator rhs_iter = f.begin (); - if (f.scale_ > this->scale_) - { - const int scale_diff = f.scale_ - this->scale_; - rhs_iter += scale_diff - this->lshift (scale_diff); - } - - if (f.digits_ - f.scale_ > this->digits_ - this->scale_) - { - ACE_CDR::Octet new_digits = this->digits_ + (f.digits_ - f.scale_) - (this->digits_ - this->scale_); - if (new_digits > MAX_DIGITS) - { - for (size_t i = 0; i < static_cast (new_digits - MAX_DIGITS); ++i) - this->digit (static_cast (i), 0); - this->normalize (this->scale_ - (new_digits - MAX_DIGITS)); - this->digits_ = MAX_DIGITS; - } - else - this->digits_ = new_digits; - } - return rhs_iter; -} - -ACE_CDR::Fixed &ACE_CDR::Fixed::operator+= (const Fixed &rhs) -{ - if (!this->sign () && rhs.sign ()) - return *this -= -rhs; - - if (this->sign () && !rhs.sign ()) - { - Fixed negated = -*this; - negated -= rhs; - return *this = -negated; - } - - ConstIterator rhs_iter = this->pre_add (rhs); - - Iterator lhs_iter = this->begin (); - if (this->scale_ > rhs.scale_) - lhs_iter += this->scale_ - rhs.scale_; - - bool carry = false; - for (; rhs_iter != rhs.end (); ++lhs_iter, ++rhs_iter) - { - const Octet digit = *lhs_iter + *rhs_iter + carry; - carry = digit > 9; - *lhs_iter = digit - (carry ? 10 : 0); - } - - if (carry) - { - if (this->digits_ < MAX_DIGITS) - { - *lhs_iter = 1; - ++this->digits_; - } - else if (this->scale_) - { - this->digit (0, 0); - this->normalize (this->scale_ - 1); - this->digit (MAX_DIGITS - 1, 1); - } - } - - return *this; -} - -int ACE_CDR::Fixed::lshift (int digits) -{ - int bytes = 0; - for (; bytes < digits / 2; ++bytes) - if (this->value_[bytes]) - break; - - int shifted = 0; - if ((digits % 2) && !(this->value_[bytes] & 0xf0)) - { - for (int i = 0; i < 15 - bytes; ++i) - this->value_[i] = (this->value_[i + bytes] & 0xf) << 4 - | (this->value_[i + bytes + 1] >> 4); - std::memset (this->value_ + 15 - bytes, 0, bytes); - this->value_[15] &= 0xf; - shifted = 2 * bytes + 1; - } - else if (bytes) - { - std::memmove (this->value_, this->value_ + bytes, 16 - bytes); - this->value_[15] &= 0xf; - std::memset (this->value_ + 16 - bytes, 0, bytes - 1); - this->value_[15 - bytes] &= 0xf0; - shifted = 2 * bytes; - } - - this->digits_ += shifted; - if (this->digits_ > MAX_DIGITS) - this->digits_ = MAX_DIGITS; - - this->scale_ += shifted; - if (this->scale_ > MAX_DIGITS) - this->scale_ = MAX_DIGITS; - - return shifted; -} - -ACE_CDR::Fixed &ACE_CDR::Fixed::operator-= (const Fixed &rhs) -{ - if (!this->sign () && rhs.sign ()) - return *this += -rhs; - - if (this->sign () && !rhs.sign ()) - { - Fixed negated = -*this; - negated += rhs; - return *this = -negated; - } - - const Fixed before = *this; - ConstIterator rhs_iter = this->pre_add (rhs); - - Iterator lhs_iter = this->begin (); - if (this->scale_ > rhs.scale_) - lhs_iter += this->scale_ - rhs.scale_; - - bool borrow = false; - for (; rhs_iter != rhs.end (); ++lhs_iter, ++rhs_iter) - if (*rhs_iter + borrow <= *lhs_iter) - { - *lhs_iter -= *rhs_iter + borrow; - borrow = false; - } - else - { - *lhs_iter += 10 - *rhs_iter - borrow; - borrow = true; - } - - while (borrow && lhs_iter != this->end ()) - if (*lhs_iter) - { - --*lhs_iter; - borrow = false; - } - else - *lhs_iter = 9; - - if (borrow) - return *this = -(rhs - before); - - this->ltrim (); - return *this; -} - -ACE_CDR::Fixed &ACE_CDR::Fixed::operator*= (const Fixed &rhs) -{ - if (!this->sign () && rhs.sign ()) - this->value_[15] = (this->value_[15] & 0xf0) | NEGATIVE; - else if (this->sign () && rhs.sign ()) - this->value_[15] = (this->value_[15] & 0xf0) | POSITIVE; - - this->ltrim (); - Fixed right = rhs; - right.ltrim (); - - Octet temp[MAX_DIGITS * 2]; - int carry = 0; - - for (int col = 0; col < this->digits_ + right.digits_; ++col) - { - for (int row = (std::max) (0, col - this->digits_ + 1); - row < (std::min) (col + 1, int (right.digits_)); ++row) - carry += this->digit (col - row) * right.digit (row); - temp[col] = carry % 10; - carry /= 10; - } - - this->digits_ += right.digits_; - this->scale_ += right.scale_; - int digit_offset = 0; - - if (this->digits_ > MAX_DIGITS) - { - digit_offset = this->digits_ - MAX_DIGITS; - this->digits_ = MAX_DIGITS; - if (this->scale_ > digit_offset) - this->scale_ -= digit_offset; - } - - for (int i = 0; i < this->digits_; ++i) - this->digit (i, temp[i + digit_offset]); - - this->ltrim (); - return *this; -} - -ACE_CDR::Fixed &ACE_CDR::Fixed::operator/= (const Fixed &rhs) -{ - if (!rhs) - return *this; - - if (rhs.scale_ && rhs.scale_ <= this->scale_) - this->scale_ -= rhs.scale_; - else if (rhs.scale_) - { - const Octet shifted = this->lshift (rhs.scale_ - this->scale_); - this->scale_ -= shifted; - } - - Fixed rhs_no_scale = rhs; - rhs_no_scale.scale_ = 0; - rhs_no_scale.value_[15] = (rhs_no_scale.value_[15] & 0xf0) | POSITIVE; - rhs_no_scale.ltrim (); - - this->ltrim (); - - if (!this->sign () && rhs.sign ()) - this->value_[15] = (this->value_[15] & 0xf0) | NEGATIVE; - else if (this->sign () && rhs.sign ()) - this->value_[15] = (this->value_[15] & 0xf0) | POSITIVE; - - static const Fixed one = from_integer (LongLong (1)), - two = from_integer (LongLong (2)), - three = from_integer (LongLong (3)), - five = from_integer (LongLong (5)); - - if (rhs_no_scale == one) - return *this; - - // Most sig digit of rhs must be >= 5 - switch (rhs_no_scale.digit (rhs_no_scale.digits_ - 1)) - { - case 1: - return *this = (*this * five) / (rhs_no_scale * five); - case 2: - return *this = (*this * three) / (rhs_no_scale * three); - case 3: - case 4: - return *this = (*this * two) / (rhs_no_scale * two); - default: - break; - } - - const bool neg = this->sign (); - if (neg) - this->value_[15] = (this->value_[15] & 0xf0) | POSITIVE; - - Fixed r; - Fixed q = this->div_helper2 (rhs_no_scale, r); - q.scale_ = this->scale_; - - if (!r) { - *this = neg ? -q : q; - this->normalize (); - return *this; - } - - const int shift = q.lshift (MAX_DIGITS); - if (shift) - { - const Octet scale = r.lshift (shift); - r.scale_ = 0; - Fixed r2; - r = r.div_helper2 (rhs_no_scale, r2); - r.scale_ = scale; - q += r; - } - - *this = neg ? -q : q; - this->normalize (); - return *this; -} - -ACE_CDR::Fixed ACE_CDR::Fixed::div_helper2 (const Fixed &rhs, Fixed &r) const -{ - if (this->digits_ < rhs.digits_) - r = *this; - else if (this->digits_ == rhs.digits_) - if (*this < rhs) - r = *this; - else - { - r = *this - rhs; - return from_integer (LongLong (1)); - } - else if (this->digits_ == rhs.digits_ + 1) - return this->div_helper1 (rhs, r); - else - { - const int dig = this->digits_ - rhs.digits_ - 1; - Fixed top = *this, bot = *this; // split with bot having dig digits - for (int i = 0; i < dig; ++i) - top.digit (i, 0); - for (int i = dig; i < this->digits_; ++i) - bot.digit (i, 0); - bot.digits_ = dig; - top.scale_ += dig; - top.normalize (this->scale_); - - Fixed rtop; - const Fixed qtop = top.div_helper1 (rhs, rtop); - const Fixed qbot = rtop.join (dig, bot).div_helper2 (rhs, r); - return qtop.join (dig, qbot); - } - - return from_integer (); -} - -ACE_CDR::Fixed ACE_CDR::Fixed::div_helper1 (const Fixed &rhs, Fixed &r) const -{ - static const Fixed ten = from_integer (LongLong (10)); - if (*this >= rhs * ten) - return ten + (*this - rhs * ten).div_helper1 (rhs, r); - - int q = (this->digit (this->digits_ - 1) * 10 + - this->digit (this->digits_ - 2)) / rhs.digit (rhs.digits_ - 1); - if (q > 9) - q = 9; - Fixed t = from_integer (LongLong (q)) * rhs; - t.scale_ = this->scale_; - for (int i = 0; i < 2 && t > *this; ++i) - { - --q; - t -= rhs; - } - - r = *this - t; - return from_integer (LongLong (q)); -} - -ACE_CDR::Fixed ACE_CDR::Fixed::join (int digits, const Fixed &bot) const -{ - Fixed res = bot; - res.digits_ = this->digits_ + digits; - for (int i = digits; i < MAX_DIGITS && i - digits < this->digits_; ++i) - res.digit (i, this->digit (i - digits)); - return res; -} - -ACE_CDR::Fixed &ACE_CDR::Fixed::operator++ () -{ - if (this->sign ()) - { - this->value_[15] = (this->value_[15] & 0xf0) | POSITIVE; - if (!!--*this) // decrement and check if result is nonzero - this->value_[15] = (this->value_[15] & 0xf0) | NEGATIVE; - } - else - { - Iterator iter = this->begin (); - iter += this->scale_; - for (; iter != this->end (); ++iter) - { - if (*iter < 9) - { - ++*iter; - return *this; - } - *iter = 0; - } - if (this->digits_ < MAX_DIGITS) - { - ++this->digits_; - *iter = 1; - } - } - return *this; -} - -ACE_CDR::Fixed &ACE_CDR::Fixed::operator-- () -{ - if (this->sign ()) - { - this->value_[15] = (this->value_[15] & 0xf0) | POSITIVE; - ++*this; - this->value_[15] = (this->value_[15] & 0xf0) | NEGATIVE; - } - else - { - Fixed before = *this; - Iterator iter = this->begin (); - iter += this->scale_; - for (; iter != this->end (); ++iter) - { - if (*iter) - { - --*iter; - return *this; - } - *iter = 9; - } - *this = before - from_integer (ULongLong (1)); - } - return *this; -} - -bool ACE_CDR::Fixed::operator! () const -{ - static const Octet ZERO[] = {0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, POSITIVE}; - return 0 == ACE_OS::memcmp (this->value_, ZERO, sizeof ZERO); -} - -ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &lhs, const ACE_CDR::Fixed &rhs) -{ - char digits[ACE_CDR::Fixed::MAX_STRING_SIZE]; - rhs.to_string (digits, sizeof digits); - -#ifdef ACE_LACKS_IOSTREAM_TOTALLY - ACE_OS::fputs (digits, &lhs); -#else - lhs << digits; -#endif - return lhs; -} - -#ifndef ACE_LACKS_IOSTREAM_TOTALLY -std::istream &operator>> (std::istream &lhs, ACE_CDR::Fixed &rhs) -{ - double num; - lhs >> num; - ACE_CDR::LongDouble ld; - ACE_CDR_LONG_DOUBLE_ASSIGNMENT (ld, num); - rhs = ACE_CDR::Fixed::from_floating (ld); - return lhs; -} -#endif - -bool ACE_CDR::Fixed::less (const ACE_CDR::Fixed &rhs) const -{ - const Fixed &lhs = *this; - if (lhs.sign () != rhs.sign ()) - return lhs.sign (); - - // signs of lhs and rhs are the same so lhs < rhs reduces to: - // if positive, |lhs| < |rhs| - // if negative, |rhs| < |lhs| - // 'a' will refer to the value left of < and 'b' to the value to the right - const ACE_CDR::Fixed &a = lhs.sign () ? rhs : lhs, - &b = lhs.sign () ? lhs : rhs; - - if (a.scale_ == b.scale_) - return ACE_OS::memcmp (a.value_, b.value_, sizeof a.value_) < 0; - - const int a_int_dig = a.digits_ - a.scale_, b_int_dig = b.digits_ - b.scale_; - - if (a_int_dig > b_int_dig) - { - for (int i = 1; i <= a_int_dig - b_int_dig; ++i) - if (a.digit (a.digits_ - i)) - return false; - } - else if (a_int_dig < b_int_dig) - { - for (int i = 1; i <= b_int_dig - a_int_dig; ++i) - if (b.digit (b.digits_ - i)) - return true; - } - - const int common_frac = (std::min) (a.scale_, b.scale_), - common_dig = (std::min) (a_int_dig, b_int_dig) + common_frac, - a_off = a.scale_ - common_frac, // a's offset (more scale than b) - b_off = b.scale_ - common_frac; // b's offset (more scale than a) - - for (int i = 1; i <= common_dig; ++i) - if (a.digit (a_off + common_dig - i) < b.digit (b_off + common_dig - i)) - return true; - - for (int i = 1; i <= a_off; ++i) - if (a.digit (a_off - i)) - return false; - - for (int i = 1; i <= b_off; ++i) - if (b.digit (b_off - i)) - return true; - - return false; -} - -bool ACE_CDR::Fixed::equal (const ACE_CDR::Fixed &rhs) const -{ - const Fixed &lhs = *this; - if (lhs.sign () != rhs.sign ()) - return false; - - if (lhs.scale_ == rhs.scale_) - return 0 == ACE_OS::memcmp (lhs.value_, rhs.value_, sizeof lhs.value_); - - const ACE_CDR::Fixed &more = (lhs.scale_ > rhs.scale_) ? lhs : rhs, - &fewer = (lhs.scale_ > rhs.scale_) ? rhs : lhs; - - const ACE_CDR::Octet scale_diff = more.scale_ - fewer.scale_; - - ACE_CDR::Fixed::ConstIterator more_iter = more.begin (), - more_end = more.end (); - - for (ACE_CDR::Octet i = 0; i < scale_diff; ++i) - if (more_iter == more_end || *more_iter++) - return false; // digits in more that are missing in fewer must be 0 - - ACE_CDR::Fixed::ConstIterator fewer_iter = fewer.begin (), - fewer_end = fewer.end (); - - while (more_iter != more_end && fewer_iter != fewer_end) - if (*more_iter++ != *fewer_iter++) - return false; // digits in common must match - - while (more_iter != more_end) - if (*more_iter++) - return false; // extra (more significant) digits in more must be 0 - - while (fewer_iter != fewer_end) - if (*fewer_iter++) - return false; // extra (more significant) digits in fewer must be 0 - - return true; -} - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/CDR_Base.h b/dep/acelite/ace/CDR_Base.h index 22dd8adf9..32aa1b88b 100644 --- a/dep/acelite/ace/CDR_Base.h +++ b/dep/acelite/ace/CDR_Base.h @@ -4,6 +4,8 @@ /** * @file CDR_Base.h * + * $Id: CDR_Base.h 97885 2014-09-09 06:39:00Z johnnyw $ + * * ACE Common Data Representation (CDR) basic types. * * The current implementation assumes that the host has 1-byte, @@ -12,6 +14,7 @@ * Those assumptions are pretty good these days, with Crays being * the only known exception. * + * * @author TAO version by * @author Aniruddha Gokhale * @author Carlos O'Ryan @@ -36,9 +39,6 @@ #include "ace/Basic_Types.h" #include "ace/Default_Constants.h" #include "ace/Global_Macros.h" -#include "ace/iosfwd.h" - -#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -354,171 +354,6 @@ public: }; # endif /* ACE_SIZEOF_LONG_DOUBLE != 16 */ -#define ACE_HAS_CDR_FIXED - /// Fixed-point data type: up to 31 decimal digits and a sign bit - /// - /// See OMG 2011-11-01 CORBA Interfaces v3.2 sections 7.10, 7.11.3.4 - /// See OMG 2011-11-02 CORBA Interoperability v3.2 section 9.3.2.8 - /// See OMG 2012-07-02 IDL-to-C++ Mapping v1.3 section 5.13 - /// This class doesn't exactly match the IDL-to-C++ mapping because - /// it is meant for use inside a union in the IDL compiler and therefore - /// has no constructors. Standards-based middlware libraries such as - /// ORBs and DDSs can wrap this class in a class of their own to provide - /// the exact interface described by the mapping specification. - class ACE_Export Fixed - { - public: - enum - { - MAX_DIGITS = 31, - MAX_STRING_SIZE = 4 + MAX_DIGITS, // includes -, 0, ., terminator - POSITIVE = 0xc, - NEGATIVE = 0xd - }; - - static Fixed from_integer (LongLong val = 0); - static Fixed from_integer (ULongLong val); - static Fixed from_floating (LongDouble val); - static Fixed from_string (const char *str); - static Fixed from_octets (const Octet *array, int len, - unsigned int scale = 0); - - operator LongLong () const; - operator LongDouble () const; - - Fixed round (UShort scale) const; - Fixed truncate (UShort scale) const; - - bool to_string (char *buffer, size_t buffer_size) const; - const Octet *to_octets (int &n) const; - - Fixed &operator+= (const Fixed &rhs); - Fixed &operator-= (const Fixed &rhs); - Fixed &operator*= (const Fixed &rhs); - Fixed &operator/= (const Fixed &rhs); - - Fixed &operator++ (); - Fixed operator++ (int); - Fixed &operator-- (); - Fixed operator-- (int); - - Fixed operator+ () const; - Fixed operator- () const; - bool operator! () const; - - UShort fixed_digits () const; - UShort fixed_scale () const; - - bool sign () const; - Octet digit (int n) const; - void digit (int n, int value); - - bool less (const Fixed &rhs) const; - bool equal (const Fixed &rhs) const; - - class Proxy - { - bool high_nibble_; - Octet &element_; - public: - Proxy (bool high_nibble, Octet &element); - Proxy &operator= (Octet val); - Proxy &operator+= (int rhs); - Proxy &operator-= (int rhs); - Proxy &operator++ (); - Proxy &operator-- (); - operator Octet () const; - }; - - class IteratorBase - { - protected: - explicit IteratorBase (int digit); - bool high_nibble () const; - Octet &storage (Fixed *outer) const; - Octet storage (const Fixed *outer) const; - bool compare (const IteratorBase &rhs) const; - int digit_; - }; - - class Iterator - : public std::iterator - , private IteratorBase - { - public: - explicit Iterator (Fixed *outer, int digit = 0); - Proxy operator* (); - Iterator &operator+= (std::ptrdiff_t n); - Iterator &operator++ (); - Iterator operator++ (int); - Iterator &operator-- (); - Iterator operator-- (int); - bool operator== (const Iterator &rhs) const; - bool operator!= (const Iterator &rhs) const; - private: - Fixed *outer_; - }; - - class ConstIterator - : public std::iterator - , private IteratorBase - { - public: - explicit ConstIterator (const Fixed *outer, int digit = 0); - Octet operator* (); - ConstIterator &operator+= (std::ptrdiff_t n); - ConstIterator &operator++ (); - ConstIterator operator++ (int); - ConstIterator &operator-- (); - ConstIterator operator-- (int); - bool operator== (const ConstIterator &rhs) const; - bool operator!= (const ConstIterator &rhs) const; - private: - const Fixed *outer_; - }; - - Iterator begin (); - ConstIterator begin () const; - ConstIterator cbegin () const; - Iterator end (); - ConstIterator end () const; - ConstIterator cend () const; - - private: - /// CDR wire format for Fixed: marshaled as an octet array with - /// index 0 as the most significant octet and index n the least - /// significant. Each octet contains two decimal digits except for - /// the last octet (least sig) which has one decimal digit in - /// the high nibble and the sign indicator in the low nibble. - Octet value_[16]; - - /// digits_ is not marshaled, the receiver needs to know it - /// from the type information (for example, IDL). The value of - /// digits_ determines how many octets of value_ are masharled. - Octet digits_; - - /// scale_ is not marshaled, the receiver needs to know it - /// from the type information (for example, IDL). - Octet scale_; - - /// remove trailing zeros, shift down and reduce digits and scale - void normalize (UShort min_scale = 0); - - /// Add up to 'digits' of additional scale by shifting left without - /// removing significant digits. Returns number of digits shifted. - int lshift (int digits); - - /// Prepare to add (or subtract) f by changing the digits and scale - /// of *this, returnins an iterator to the least significant - /// digit of f that will influence the sum (or difference). - ConstIterator pre_add (const Fixed &f); - - Fixed div_helper2 (const Fixed &rhs, Fixed &r) const; - Fixed div_helper1 (const Fixed &rhs, Fixed &r) const; - Fixed join (int digits, const Fixed &bottom) const; - void ltrim (); - }; - //@} #if !defined (ACE_CDR_GIOP_MAJOR_VERSION) @@ -530,44 +365,6 @@ public: #endif /* ACE_CDR_GIOP_MINOR_VERSION */ }; -ACE_Export -ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &lhs, const ACE_CDR::Fixed &rhs); - -#ifndef ACE_LACKS_IOSTREAM_TOTALLY -ACE_Export -std::istream &operator>> (std::istream &lhs, ACE_CDR::Fixed &rhs); -#endif - -ACE_Export -bool operator< (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -bool operator> (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -bool operator>= (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -bool operator<= (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -bool operator== (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -bool operator!= (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -ACE_CDR::Fixed operator+ (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -ACE_CDR::Fixed operator- (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -ACE_CDR::Fixed operator* (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - -ACE_Export -ACE_CDR::Fixed operator/ (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs); - ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/CDR_Base.inl b/dep/acelite/ace/CDR_Base.inl index c31c3b785..f3229691c 100644 --- a/dep/acelite/ace/CDR_Base.inl +++ b/dep/acelite/ace/CDR_Base.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: CDR_Base.inl 97884 2014-09-08 18:00:53Z johnnyw $ + #if defined (ACE_HAS_INTRINSIC_BYTESWAP) // Take advantage of MSVC++ byte swapping compiler intrinsics (found // in ). @@ -37,6 +40,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // (none of the above) // => shift/masks using 32bit words. // +// // Some things you could find useful to know if you intend to mess // with this optimizations for swaps: // @@ -66,9 +70,6 @@ ACE_CDR::swap_2 (const char *orig, char* target) // function. *reinterpret_cast (target) = _byteswap_ushort (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BUILTIN_BSWAP16) - *reinterpret_cast (target) = - __builtin_bswap16 (*reinterpret_cast (orig)); #elif defined (ACE_HAS_BSWAP16) *reinterpret_cast (target) = bswap16 (*reinterpret_cast (orig)); @@ -89,8 +90,8 @@ ACE_CDR::swap_2 (const char *orig, char* target) __asm rol ax, 8; __asm mov [ecx], ax; #else - ACE_UINT16 usrc = * reinterpret_cast (orig); - ACE_UINT16* udst = reinterpret_cast (target); + ACE_REGISTER ACE_UINT16 usrc = * reinterpret_cast (orig); + ACE_REGISTER ACE_UINT16* udst = reinterpret_cast (target); *udst = (usrc << 8) | (usrc >> 8); #endif /* ACE_HAS_PENTIUM */ } @@ -103,9 +104,6 @@ ACE_CDR::swap_4 (const char* orig, char* target) // function. *reinterpret_cast (target) = _byteswap_ulong (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BUILTIN_BSWAP32) - *reinterpret_cast (target) = - __builtin_bswap32 (*reinterpret_cast (orig)); #elif defined (ACE_HAS_BSWAP32) *reinterpret_cast (target) = bswap32 (*reinterpret_cast (orig)); @@ -114,7 +112,7 @@ ACE_CDR::swap_4 (const char* orig, char* target) bswap_32 (*reinterpret_cast (orig)); #elif defined(ACE_HAS_INTEL_ASSEMBLY) // We have ACE_HAS_PENTIUM, so we know the sizeof's. - unsigned int j = + ACE_REGISTER unsigned int j = *reinterpret_cast (orig); asm ("bswap %1" : "=r" (j) : "0" (j)); *reinterpret_cast (target) = j; @@ -127,7 +125,7 @@ ACE_CDR::swap_4 (const char* orig, char* target) __asm bswap eax; __asm mov [ecx], eax; #else - ACE_UINT32 x = * reinterpret_cast (orig); + ACE_REGISTER ACE_UINT32 x = * reinterpret_cast (orig); x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); * reinterpret_cast (target) = x; #endif /* ACE_HAS_INTRINSIC_BYTESWAP */ @@ -141,9 +139,6 @@ ACE_CDR::swap_8 (const char* orig, char* target) // function. *reinterpret_cast (target) = _byteswap_uint64 (*reinterpret_cast (orig)); -#elif defined (ACE_HAS_BUILTIN_BSWAP64) - *reinterpret_cast (target) = - __builtin_bswap64 (*reinterpret_cast (orig)); #elif defined (ACE_HAS_BSWAP64) *reinterpret_cast (target) = bswap64 (*reinterpret_cast (orig)); @@ -152,14 +147,16 @@ ACE_CDR::swap_8 (const char* orig, char* target) bswap_64 (*reinterpret_cast (orig)); #elif (defined (__amd64__) || defined (__x86_64__)) && defined(__GNUG__) \ && !defined(ACE_LACKS_INLINE_ASSEMBLY) - unsigned long x = + ACE_REGISTER unsigned long x = * reinterpret_cast (orig); asm ("bswapq %1" : "=r" (x) : "0" (x)); *reinterpret_cast (target) = x; #elif defined(ACE_HAS_PENTIUM) && defined(__GNUG__) \ && !defined(ACE_LACKS_INLINE_ASSEMBLY) - unsigned int i =*reinterpret_cast (orig); - unsigned int j = *reinterpret_cast (orig + 4); + ACE_REGISTER unsigned int i = + *reinterpret_cast (orig); + ACE_REGISTER unsigned int j = + *reinterpret_cast (orig + 4); asm ("bswap %1" : "=r" (i) : "0" (i)); asm ("bswap %1" : "=r" (j) : "0" (j)); *reinterpret_cast (target + 4) = i; @@ -177,17 +174,20 @@ ACE_CDR::swap_8 (const char* orig, char* target) __asm mov [edx], ebx; #elif ACE_SIZEOF_LONG == 8 // 64 bit architecture. - unsigned long x = * reinterpret_cast (orig); - unsigned long x84 = (x & 0x000000ff000000ffUL) << 24; - unsigned long x73 = (x & 0x0000ff000000ff00UL) << 8; - unsigned long x62 = (x & 0x00ff000000ff0000UL) >> 8; - unsigned long x51 = (x & 0xff000000ff000000UL) >> 24; + ACE_REGISTER unsigned long x = + * reinterpret_cast (orig); + ACE_REGISTER unsigned long x84 = (x & 0x000000ff000000ffUL) << 24; + ACE_REGISTER unsigned long x73 = (x & 0x0000ff000000ff00UL) << 8; + ACE_REGISTER unsigned long x62 = (x & 0x00ff000000ff0000UL) >> 8; + ACE_REGISTER unsigned long x51 = (x & 0xff000000ff000000UL) >> 24; x = (x84 | x73 | x62 | x51); x = (x << 32) | (x >> 32); *reinterpret_cast (target) = x; #else - ACE_UINT32 x = * reinterpret_cast (orig); - ACE_UINT32 y = * reinterpret_cast (orig + 4); + ACE_REGISTER ACE_UINT32 x = + * reinterpret_cast (orig); + ACE_REGISTER ACE_UINT32 y = + * reinterpret_cast (orig + 4); x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24); * reinterpret_cast (target) = y; @@ -252,378 +252,6 @@ ACE_CDR::next_size (size_t minsize) return newsize; } -ACE_INLINE ACE_CDR::UShort -ACE_CDR::Fixed::fixed_digits () const -{ - return this->digits_; -} - -ACE_INLINE ACE_CDR::UShort -ACE_CDR::Fixed::fixed_scale () const -{ - return this->scale_; -} - -ACE_INLINE bool -ACE_CDR::Fixed::sign () const -{ - return (this->value_[15] & 0xf) == NEGATIVE; -} - -ACE_INLINE ACE_CDR::Octet -ACE_CDR::Fixed::digit (int n) const -{ - const Octet x = this->value_[15 - (n + 1) / 2]; - return (n % 2) ? x & 0xf : (x >> 4); -} - -ACE_INLINE void -ACE_CDR::Fixed::digit (int n, int val) -{ - const int idx = 15 - (n + 1) / 2; - this->value_[idx] = (n % 2) ? (this->value_[idx] & 0xf0) | val - : ((val << 4) | (this->value_[idx] & 0xf)); -} - -ACE_INLINE -ACE_CDR::Fixed::Proxy::Proxy (bool high_nibble, Octet &element) - : high_nibble_ (high_nibble), element_ (element) {} - -ACE_INLINE ACE_CDR::Fixed::Proxy & -ACE_CDR::Fixed::Proxy::operator= (Octet val) -{ - this->element_ = this->high_nibble_ - ? (val << 4) | (this->element_ & 0xf) - : ((this->element_ & 0xf0) | val); - return *this; -} - -ACE_INLINE ACE_CDR::Fixed::Proxy & -ACE_CDR::Fixed::Proxy::operator+= (int rhs) -{ - const Octet val = static_cast (*this + rhs); - return *this = val; -} - -ACE_INLINE ACE_CDR::Fixed::Proxy & -ACE_CDR::Fixed::Proxy::operator-= (int rhs) -{ - const Octet val = static_cast (*this - rhs); - return *this = val; -} - -ACE_INLINE ACE_CDR::Fixed::Proxy & -ACE_CDR::Fixed::Proxy::operator++ () -{ - const Octet val = static_cast (*this) + 1; - return *this = val; -} - -ACE_INLINE ACE_CDR::Fixed::Proxy & -ACE_CDR::Fixed::Proxy::operator-- () -{ - const Octet val = static_cast(*this) - 1; - return *this = val; -} - -ACE_INLINE -ACE_CDR::Fixed::Proxy::operator ACE_CDR::Octet () const -{ - return this->high_nibble_ ? this->element_ >> 4 : (this->element_ & 0xf); -} - -ACE_INLINE -ACE_CDR::Fixed::IteratorBase::IteratorBase (int digit) - : digit_ (digit) {} - -ACE_INLINE bool -ACE_CDR::Fixed::IteratorBase::high_nibble () const -{ - return this->digit_ % 2 == 0; -} - -ACE_INLINE ACE_CDR::Octet & -ACE_CDR::Fixed::IteratorBase::storage (Fixed *outer) const -{ - return outer->value_[15 - (this->digit_ + 1) / 2]; -} - -ACE_INLINE ACE_CDR::Octet -ACE_CDR::Fixed::IteratorBase::storage (const Fixed *outer) const -{ - return outer->value_[15 - (this->digit_ + 1) / 2]; -} - -ACE_INLINE bool -ACE_CDR::Fixed::IteratorBase::compare (const IteratorBase &rhs) const -{ - return this->digit_ == rhs.digit_; -} - -ACE_INLINE -ACE_CDR::Fixed::Iterator::Iterator (Fixed *outer, int digit) - : IteratorBase (digit), outer_ (outer) {} - -ACE_INLINE ACE_CDR::Fixed::Proxy -ACE_CDR::Fixed::Iterator::operator* () -{ - return Proxy (this->high_nibble (), this->storage (this->outer_)); -} - -ACE_INLINE ACE_CDR::Fixed::Iterator & -ACE_CDR::Fixed::Iterator::operator+= (std::ptrdiff_t n) -{ - this->digit_ += static_cast (n); - return *this; -} - -ACE_INLINE ACE_CDR::Fixed::Iterator & -ACE_CDR::Fixed::Iterator::operator++ () -{ - ++this->digit_; - return *this; -} - -ACE_INLINE ACE_CDR::Fixed::Iterator -ACE_CDR::Fixed::Iterator::operator++ (int) -{ - const Iterator cpy (*this); - ++this->digit_; - return cpy; -} - -ACE_INLINE ACE_CDR::Fixed::Iterator & -ACE_CDR::Fixed::Iterator::operator-- () -{ - --this->digit_; - return *this; -} - -ACE_INLINE ACE_CDR::Fixed::Iterator -ACE_CDR::Fixed::Iterator::operator-- (int) -{ - const Iterator cpy (*this); - --this->digit_; - return cpy; -} - -ACE_INLINE bool -ACE_CDR::Fixed::Iterator::operator== (const Iterator &rhs) const -{ - return this->compare (rhs); -} - -ACE_INLINE bool -ACE_CDR::Fixed::Iterator::operator!= (const Iterator &rhs) const -{ - return !(*this == rhs); -} - -ACE_INLINE -ACE_CDR::Fixed::ConstIterator::ConstIterator (const Fixed *outer, int digit) - : IteratorBase (digit), outer_ (outer) {} - -ACE_INLINE ACE_CDR::Octet -ACE_CDR::Fixed::ConstIterator::operator* () -{ - const Octet storage = this->storage (this->outer_); - return this->high_nibble () ? storage >> 4 : (storage & 0xf); -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator & -ACE_CDR::Fixed::ConstIterator::operator+= (std::ptrdiff_t n) -{ - this->digit_ += static_cast (n); - return *this; -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator & -ACE_CDR::Fixed::ConstIterator::operator++ () -{ - ++this->digit_; - return *this; -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator -ACE_CDR::Fixed::ConstIterator::operator++ (int) -{ - const ConstIterator cpy (*this); - ++this->digit_; - return cpy; -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator & -ACE_CDR::Fixed::ConstIterator::operator-- () -{ - --this->digit_; - return *this; -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator -ACE_CDR::Fixed::ConstIterator::operator-- (int) -{ - const ConstIterator cpy (*this); - --this->digit_; - return cpy; -} - -ACE_INLINE bool -ACE_CDR::Fixed::ConstIterator::operator== (const ConstIterator &rhs) const -{ - return this->compare (rhs); -} - -ACE_INLINE bool -ACE_CDR::Fixed::ConstIterator::operator!= (const ConstIterator &rhs) const -{ - return !(*this == rhs); -} - -ACE_INLINE ACE_CDR::Fixed::Iterator -ACE_CDR::Fixed::begin () -{ - return Iterator (this); -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator -ACE_CDR::Fixed::begin () const -{ - return ConstIterator (this); -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator -ACE_CDR::Fixed::cbegin () const -{ - return ConstIterator (this); -} - -ACE_INLINE ACE_CDR::Fixed::Iterator -ACE_CDR::Fixed::end () -{ - return Iterator (this, this->digits_); -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator -ACE_CDR::Fixed::end () const -{ - return ConstIterator (this, this->digits_); -} - -ACE_INLINE ACE_CDR::Fixed::ConstIterator -ACE_CDR::Fixed::cend () const -{ - return ConstIterator (this, this->digits_); -} - -ACE_INLINE ACE_CDR::Fixed -ACE_CDR::Fixed::operator++ (int) -{ - const Fixed cpy (*this); - ++*this; - return cpy; -} - -ACE_INLINE ACE_CDR::Fixed -ACE_CDR::Fixed::operator-- (int) -{ - const Fixed cpy (*this); - --*this; - return cpy; -} - -ACE_INLINE ACE_CDR::Fixed -ACE_CDR::Fixed::operator+ () const -{ - return *this; -} - -ACE_INLINE ACE_CDR::Fixed -ACE_CDR::Fixed::operator- () const -{ - Fixed f = *this; - f.value_[15] = (f.value_[15] & 0xf0) | (f.sign () ? POSITIVE : NEGATIVE); - return f; -} - -ACE_INLINE void -ACE_CDR::Fixed::ltrim () -{ - for (int i = this->digits_ - 1; i >= this->scale_ && i > 0; --i) - if (this->digit (i) == 0) - --this->digits_; - else - break; -} - -ACE_INLINE ACE_CDR::Fixed -operator+ (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - ACE_CDR::Fixed f = lhs; - f += rhs; - return f; -} - -ACE_INLINE ACE_CDR::Fixed -operator- (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - ACE_CDR::Fixed f = lhs; - f -= rhs; - return f; -} - -ACE_INLINE ACE_CDR::Fixed -operator* (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - ACE_CDR::Fixed f = lhs; - f *= rhs; - return f; -} - -ACE_INLINE ACE_CDR::Fixed -operator/ (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - ACE_CDR::Fixed f = lhs; - f /= rhs; - return f; -} - -ACE_INLINE bool -operator< (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - return lhs.less (rhs); -} - -ACE_INLINE bool -operator> (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - return rhs < lhs; -} - -ACE_INLINE bool -operator>= (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - return !(lhs < rhs); -} - -ACE_INLINE bool -operator<= (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - return !(rhs < lhs); -} - -ACE_INLINE bool -operator== (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - return lhs.equal (rhs); -} - -ACE_INLINE bool -operator!= (const ACE_CDR::Fixed &lhs, const ACE_CDR::Fixed &rhs) -{ - return !(lhs == rhs); -} - - ACE_END_VERSIONED_NAMESPACE_DECL // **************************************************************** diff --git a/dep/acelite/ace/CDR_Size.cpp b/dep/acelite/ace/CDR_Size.cpp index 4263532eb..40ea9d35b 100644 --- a/dep/acelite/ace/CDR_Size.cpp +++ b/dep/acelite/ace/CDR_Size.cpp @@ -1,3 +1,5 @@ +// $Id: CDR_Size.cpp 91813 2010-09-17 07:52:52Z johnnyw $ + #include "ace/CDR_Size.h" #include "ace/SString.h" #include "ace/OS_Memory.h" diff --git a/dep/acelite/ace/CDR_Size.h b/dep/acelite/ace/CDR_Size.h index a791b89bd..8c095e8b3 100644 --- a/dep/acelite/ace/CDR_Size.h +++ b/dep/acelite/ace/CDR_Size.h @@ -4,15 +4,21 @@ /** * @file CDR_Size.h * + * $Id: CDR_Size.h 96688 2013-01-22 12:28:42Z johnnyw $ + * + * * ACE Common Data Representation (CDR) size-calculating stream. * + * * The current implementation assumes that the host has 1-byte, * 2-byte and 4-byte integral types, and that it has single * precision and double precision IEEE floats. * Those assumptions are pretty good these days, with Crays being * the only known exception. * + * * @author Boris Kolpackov + * */ //============================================================================= @@ -44,7 +50,7 @@ public: ACE_SizeCDR (ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); - /// Returns @c false if an error has occurred. + /// Returns @c false if an error has ocurred. bool good_bit (void) const; /// Reset current size. @@ -68,7 +74,6 @@ public: ACE_CDR::Boolean write_float (ACE_CDR::Float x); ACE_CDR::Boolean write_double (const ACE_CDR::Double &x); ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x); - ACE_CDR::Boolean write_fixed (const ACE_CDR::Fixed &x); /// For string we offer methods that accept a precomputed length. ACE_CDR::Boolean write_string (const ACE_CDR::Char *x); @@ -78,10 +83,6 @@ public: ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x); ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, const ACE_CDR::WChar *x); - ACE_CDR::Boolean write_string (const std::string &x); -#if !defined(ACE_LACKS_STD_WSTRING) - ACE_CDR::Boolean write_wstring (const std::wstring &x); -#endif //@} /// @note the portion written starts at and ends @@ -206,8 +207,6 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, ACE_CDR::Float x); extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - const ACE_CDR::Fixed &x); // CDR size-calculating output operator from helper classes @@ -227,12 +226,6 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char* x); extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar* x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - const std::string& x); -#if !defined(ACE_LACKS_STD_WSTRING) -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, - const std::wstring& x); -#endif ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/CDR_Size.inl b/dep/acelite/ace/CDR_Size.inl index d138b3de1..4ea81523f 100644 --- a/dep/acelite/ace/CDR_Size.inl +++ b/dep/acelite/ace/CDR_Size.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: CDR_Size.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -112,13 +115,6 @@ ACE_SizeCDR::write_longdouble (const ACE_CDR::LongDouble &x) return this->write_16 (reinterpret_cast (temp)); } -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_fixed (const ACE_CDR::Fixed &x) -{ - return this->write_array (&x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, - (x.fixed_digits () + 2) / 2); -} - ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_string (const ACE_CDR::Char *x) { @@ -143,26 +139,6 @@ ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x) return this->write_wstring (0, 0); } -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_string (const std::string &x) -{ - ACE_CDR::ULong len = - static_cast (x.size ()); - return this->write_string (len, - x.empty () ? 0 : x.c_str ()); -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE ACE_CDR::Boolean -ACE_SizeCDR::write_wstring (const std::wstring &x) -{ - ACE_CDR::ULong len = - static_cast (x.size ()); - return this->write_wstring (len, - x.empty () ? 0 : x.c_str ()); -} -#endif - ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length) @@ -371,13 +347,6 @@ operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x) return (ACE_CDR::Boolean) ss.good_bit (); } -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, const ACE_CDR::Fixed &x) -{ - ss.write_fixed (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - ACE_INLINE ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char *x) { @@ -392,22 +361,6 @@ operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar *x) return (ACE_CDR::Boolean) ss.good_bit (); } -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, const std::string& x) -{ - ss.write_string (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_SizeCDR &ss, const std::wstring& x) -{ - ss.write_wstring (x); - return (ACE_CDR::Boolean) ss.good_bit (); -} -#endif - // The following use the helper classes ACE_INLINE ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x) diff --git a/dep/acelite/ace/CDR_Stream.cpp b/dep/acelite/ace/CDR_Stream.cpp index 32654aedd..48b6ab005 100644 --- a/dep/acelite/ace/CDR_Stream.cpp +++ b/dep/acelite/ace/CDR_Stream.cpp @@ -1,3 +1,5 @@ +// $Id: CDR_Stream.cpp 96411 2012-11-29 10:31:26Z johnnyw $ + #include "ace/CDR_Stream.h" #include "ace/SString.h" #include "ace/Auto_Ptr.h" @@ -1520,15 +1522,9 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x) // the memory is allocated. if (len > 0 && len <= this->length()) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (x, - static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::Char) * (len))), - 0); -#else ACE_NEW_RETURN (x, ACE_CDR::Char[len], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_Auto_Basic_Array_Ptr safe_data (x); @@ -1542,16 +1538,9 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x) { // Convert any null strings to empty strings since empty // strings can cause crashes. (See bug 58.) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (x, - static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::Char) * (1))), - 0); -#else ACE_NEW_RETURN (x, ACE_CDR::Char[1], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_OS::strcpy (const_cast (x), ""); return true; } @@ -1614,15 +1603,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) ACE_OutputCDR::wchar_maxbytes_); //allocating one extra for the null character needed by applications -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (x, - static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (len + 1))), - 0); -#else ACE_NEW_RETURN (x, ACE_CDR::WChar [len + 1], false); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_auto_ptr_reset (safe_data, x); @@ -1641,15 +1624,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) } else { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (x, - static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (len))), - 0); -#else ACE_NEW_RETURN (x, ACE_CDR::WChar [len], false); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_auto_ptr_reset (safe_data, x); @@ -1665,16 +1642,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) { // Convert any null strings to empty strings since empty // strings can cause crashes. (See bug 58.) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (x, - static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (1))), - 0); -#else - ACE_NEW_RETURN (x, - ACE_CDR::WChar [1], - false); -#endif /* ACE_HAS_ALLOC_HOOKS */ - + ACE_NEW_RETURN (x, + ACE_CDR::WChar[1], + false); x[0] = '\x00'; return true; } @@ -1684,146 +1654,6 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) return false; } -// As of C++11 std::string guarantees contiguous memory storage. -// That provides the opportunity to optimize CDR streaming. -ACE_CDR::Boolean -ACE_InputCDR::read_string (std::string& x) -{ -#if defined (ACE_HAS_CPP11) - // @@ This is a slight violation of "Optimize for the common case", - // i.e. normally the translator will be 0, but OTOH the code is - // smaller and should be better for the cache ;-) ;-) - if (this->char_translator_ != 0) - { - this->good_bit_ = this->char_translator_->read_string (*this, x); - return this->good_bit_; - } - - ACE_CDR::ULong len = 0; - - if (!this->read_ulong (len)) - return false; - - // A check for the length being too great is done later in the - // call to read_char_array but we want to have it done before - // the memory is allocated. - if (len > 0 && len <= this->length()) - { - try - { - x.resize (len-1); // no need to include the terminating '\0' here - } - catch (const std::bad_alloc&) - { - return false; - } - - if (len == 0 || this->read_char_array (&x[0], len-1)) - { - return this->skip_char (); // skip the terminating '\0' - } - } - - this->good_bit_ = false; - x.clear (); - return false; -#else - ACE_CDR::Char *buf = 0; - ACE_CDR::Boolean const marshal_flag = this->read_string (buf); - x.assign (buf); - ACE::strdelete (buf); - return marshal_flag; -#endif -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_CDR::Boolean -ACE_InputCDR::read_wstring (std::wstring& x) -{ -#if defined (ACE_HAS_CPP11) - // @@ This is a slight violation of "Optimize for the common case", - // i.e. normally the translator will be 0, but OTOH the code is - // smaller and should be better for the cache ;-) ;-) - if (this->wchar_translator_ != 0) - { - this->good_bit_ = this->wchar_translator_->read_wstring (*this, x); - return this->good_bit_; - } - if (ACE_OutputCDR::wchar_maxbytes_ == 0) - { - errno = EACCES; - return (this->good_bit_ = false); - } - - ACE_CDR::ULong len = 0; - - if (!this->read_ulong (len)) - { - return false; - } - - // A check for the length being too great is done later in the - // call to read_char_array but we want to have it done before - // the memory is allocated. - if (len > 0 && len <= this->length ()) - { - if (static_cast (this->major_version_) == 1 - && static_cast (this->minor_version_) == 2) - { - len /= - ACE_Utils::truncate_cast ( - ACE_OutputCDR::wchar_maxbytes_); - - try - { - x.resize (len); - } - catch (const std::bad_alloc&) - { - return false; - } - - if (this->read_wchar_array (&x[0], len)) - { - return true; - } - } - else - { - try - { - x.resize (len-1); // no need to include the terminating '\0' here - } - catch (const std::bad_alloc&) - { - return false; - } - - if (len == 1 || this->read_wchar_array (&x[0], len-1)) - { - return this->skip_wchar (); // skip the terminating '\0' - } - } - } - else if (len == 0) - { - x.clear (); - return true; - } - - this->good_bit_ = false; - x.clear (); - return false; -#else - ACE_CDR::WChar *buf = 0; - ACE_CDR::Boolean const marshal_flag = this->read_wstring (buf); - x.assign (buf); - ACE::strdelete (buf); - return marshal_flag; -#endif -} -#endif - ACE_CDR::Boolean ACE_InputCDR::read_array (void* x, size_t size, @@ -2367,36 +2197,12 @@ ACE_Char_Codeset_Translator::~ACE_Char_Codeset_Translator (void) { } -ACE_CDR::Boolean -ACE_Char_Codeset_Translator::read_string (ACE_InputCDR &cdr, - std::string &x) -{ - ACE_CDR::Char *buf = 0; - ACE_CDR::Boolean const marshal_flag = this->read_string (cdr, buf); - x.assign (buf); - ACE::strdelete (buf); - return marshal_flag; -} - // -------------------------------------------------------------- ACE_WChar_Codeset_Translator::~ACE_WChar_Codeset_Translator (void) { } -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_CDR::Boolean -ACE_WChar_Codeset_Translator::read_wstring (ACE_InputCDR &cdr, - std::wstring &x) -{ - ACE_CDR::WChar *buf = 0; - ACE_CDR::Boolean const marshal_flag = this->read_wstring (cdr, buf); - x.assign (buf); - ACE::strdelete (buf); - return marshal_flag; -} -#endif - // -------------------------------------------------------------- ACE_CDR::Boolean diff --git a/dep/acelite/ace/CDR_Stream.h b/dep/acelite/ace/CDR_Stream.h index be7f7c80e..3334c9308 100644 --- a/dep/acelite/ace/CDR_Stream.h +++ b/dep/acelite/ace/CDR_Stream.h @@ -4,6 +4,8 @@ /** * @file CDR_Stream.h * + * $Id: CDR_Stream.h 97972 2014-11-10 15:46:10Z johnnyw $ + * * ACE Common Data Representation (CDR) marshaling and demarshaling * classes. * @@ -26,6 +28,7 @@ * only when ACE_DISABLE_SWAP_ON_READ can be enabled. This option requires * ACE CDR engine to do both marshaling and demarshaling. * + * * @author TAO version by Aniruddha Gokhale * @author Carlos O'Ryan * @author ACE version by Jeff Parsons @@ -56,7 +59,6 @@ #include "Monitor_Size.h" #endif /* ACE_HAS_MONITOR_POINTS==1 */ -#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -122,7 +124,7 @@ public: /// with the alignment of @a data. /** * Create an output stream from an arbitrary buffer, care must be - * exercised with alignment, because this constructor will align if + * exercised with alignment, because this contructor will align if * needed. In this case @a data will not point to the start of the * output stream. @c begin()->rd_ptr() points to the start of the * output stream. See @c ACE_ptr_align_binary() to properly align a @@ -139,11 +141,11 @@ public: ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION); /// Build a CDR stream with an initial data block, it will *not* remove - /// @a data_block, since it did not allocated it. It's important to be - /// careful with the alignment of . + /// , since it did not allocated it. It's important to be + // careful with the alignment of . /** * Create an output stream from an arbitrary data block, care must be - * exercised with alignment, because this constructor will align if + * exercised with alignment, because this contructor will align if * needed. In this case @a data_block will not point to the * start of the output stream. begin()->rd_ptr() points to the start * off the output stream. See ACE_ptr_align_binary() to properly align a @@ -222,24 +224,6 @@ public: ACE_CDR::ULong bound_; ACE_CDR::Boolean nocopy_; }; - - struct ACE_Export from_std_string - { - from_std_string (const std::string &s, - ACE_CDR::ULong b); - const std::string &val_; - ACE_CDR::ULong bound_; - }; - -#if !defined(ACE_LACKS_STD_WSTRING) - struct ACE_Export from_std_wstring - { - from_std_wstring (const std::wstring &ws, - ACE_CDR::ULong b); - const std::wstring &val_; - ACE_CDR::ULong bound_; - }; -#endif //@} /** @@ -259,7 +243,6 @@ public: ACE_CDR::Boolean write_float (ACE_CDR::Float x); ACE_CDR::Boolean write_double (const ACE_CDR::Double &x); ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x); - ACE_CDR::Boolean write_fixed (const ACE_CDR::Fixed &x); /// For string we offer methods that accept a precomputed length. ACE_CDR::Boolean write_string (const ACE_CDR::Char *x); @@ -269,11 +252,6 @@ public: ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x); ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, const ACE_CDR::WChar *x); - ACE_CDR::Boolean write_string (const std::string &x); -#if !defined(ACE_LACKS_STD_WSTRING) - ACE_CDR::Boolean write_wstring (const std::wstring &x); -#endif - //@} /// @note the portion written starts at @a x and ends @@ -354,7 +332,7 @@ public: * type to insert. This requirement is satisfied by using one of the * placeholder-writing methods to align the stream for the anticipated * value and obtain the correct location. - * Treatment of @a x with respect to byte swapping is the same as for when + * Treatment of @a x with repect to byte swapping is the same as for when * any value is inserted. * * @param x The value to insert into the specified location. @@ -393,13 +371,12 @@ public: ACE_CDR::Boolean append_float (ACE_InputCDR &); ACE_CDR::Boolean append_double (ACE_InputCDR &); ACE_CDR::Boolean append_longdouble (ACE_InputCDR &); - ACE_CDR::Boolean append_fixed (ACE_InputCDR &); ACE_CDR::Boolean append_wstring (ACE_InputCDR &); ACE_CDR::Boolean append_string (ACE_InputCDR &); //@} - /// Returns @c false if an error has occurred. + /// Returns @c false if an error has ocurred. /** * @note The only expected error is to run out of memory. */ @@ -669,7 +646,7 @@ public: /** * Create an input stream from an arbitrary buffer. The buffer must - * be properly aligned because this constructor will *not* work if + * be properly aligned because this contructor will *not* work if * the buffer is aligned unproperly.See ACE_ptr_align_binary() for * instructions on how to align a pointer properly and use * ACE_CDR::MAX_ALIGNMENT for the correct alignment. @@ -701,7 +678,7 @@ public: ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION, ACE_Lock* lock = 0); - /// Create an input stream from an ACE_Data_Block. The @a flag + /// Create an input stream from an ACE_Data_Block. The /// indicates whether the @a data can be deleted by the CDR stream /// or not ACE_InputCDR (ACE_Data_Block *data, @@ -757,7 +734,7 @@ public: ACE_InputCDR &rhs_; }; - /// Transfer the contents from @a rhs to a new CDR + /// Transfer the contents from to a new CDR ACE_InputCDR (Transfer_Contents rhs); /// Destructor @@ -818,25 +795,6 @@ public: const ACE_CDR::WChar *&val_; ACE_CDR::ULong bound_; }; - - /// Helper classes for extracting bounded strings into std::string/wstring. - struct ACE_Export to_std_string - { - to_std_string (std::string &s, - ACE_CDR::ULong b); - std::string &val_; - ACE_CDR::ULong bound_; - }; - -#if !defined(ACE_LACKS_STD_WSTRING) - struct ACE_Export to_std_wstring - { - to_std_wstring (std::wstring &ws, - ACE_CDR::ULong b); - std::wstring &val_; - ACE_CDR::ULong bound_; - }; -#endif /* ACE_LACKS_STD_WSTRING */ //@} /** @@ -856,15 +814,10 @@ public: ACE_CDR::Boolean read_float (ACE_CDR::Float &x); ACE_CDR::Boolean read_double (ACE_CDR::Double &x); ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x); - ACE_CDR::Boolean read_fixed (ACE_CDR::Fixed &x); ACE_CDR::Boolean read_string (ACE_CDR::Char *&x); ACE_CDR::Boolean read_string (ACE_CString &x); ACE_CDR::Boolean read_wstring (ACE_CDR::WChar*& x); - ACE_CDR::Boolean read_string (std::string& x); -#if !defined(ACE_LACKS_STD_WSTRING) - ACE_CDR::Boolean read_wstring (std::wstring& x); -#endif //@} /** @@ -918,7 +871,6 @@ public: ACE_CDR::Boolean skip_float (void); ACE_CDR::Boolean skip_double (void); ACE_CDR::Boolean skip_longdouble (void); - ACE_CDR::Boolean skip_fixed (void); //@} /** @@ -1095,7 +1047,7 @@ private: // We could use void* or char* to make the interface more // consistent, but using native types let us exploit the strict // alignment requirements of CDR streams and implement the - // operations using assignment. + // operations using asignment. /** * Read an array of @a length elements, each of @a size bytes and the @@ -1161,12 +1113,6 @@ public: virtual ACE_CDR::Boolean read_string (ACE_InputCDR&, ACE_CDR::Char *&) = 0; - /// Read a std::string from the stream, including the length, converting - /// the characters from the stream codeset to the native codeset - /// (provide non-optimized default implementation) - virtual ACE_CDR::Boolean read_string (ACE_InputCDR&, - std::string &); - /// Read an array of characters from the stream, converting the /// characters from the stream codeset to the native codeset. virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR&, @@ -1263,13 +1209,6 @@ public: ACE_CDR::WChar&) = 0; virtual ACE_CDR::Boolean read_wstring (ACE_InputCDR&, ACE_CDR::WChar *&) = 0; -#if !defined(ACE_LACKS_STD_WSTRING) - /// Read a std::wstring from the stream, including the length, converting - /// the characters from the stream codeset to the native codeset - /// (provide non-optimized default implementation) - virtual ACE_CDR::Boolean read_wstring (ACE_InputCDR&, - std::wstring &); -#endif virtual ACE_CDR::Boolean read_wchar_array (ACE_InputCDR&, ACE_CDR::WChar*, ACE_CDR::ULong) = 0; @@ -1383,8 +1322,6 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_CDR::Float x); extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_CDR::Double x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - const ACE_CDR::Fixed &x); // CDR output operator from helper classes @@ -1404,16 +1341,6 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, const ACE_CDR::Char* x); extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, const ACE_CDR::WChar* x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_std_string x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - const std::string& x); -#if !defined(ACE_LACKS_STD_WSTRING) -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - ACE_OutputCDR::from_std_wstring x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, - const std::wstring& x); -#endif // Not used by CORBA or TAO extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, @@ -1438,8 +1365,6 @@ extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_CDR::Float &x); extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_CDR::Double &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - ACE_CDR::Fixed &x); // CDR input operator from helper classes @@ -1459,16 +1384,6 @@ extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_CDR::Char*& x); extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_CDR::WChar*& x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_InputCDR &os, - ACE_InputCDR::to_std_string x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - std::string& x); -#if !defined(ACE_LACKS_STD_WSTRING) -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_InputCDR &os, - ACE_InputCDR::to_std_wstring x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, - std::wstring& x); -#endif ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/CDR_Stream.inl b/dep/acelite/ace/CDR_Stream.inl index fe25108da..2be60c154 100644 --- a/dep/acelite/ace/CDR_Stream.inl +++ b/dep/acelite/ace/CDR_Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: CDR_Stream.inl 84206 2009-01-21 02:49:26Z schmidt $ + #include "ace/OS_NS_string.h" #include "ace/OS_Memory.h" @@ -127,40 +130,6 @@ ACE_InputCDR::to_wstring::to_wstring (const ACE_CDR::WChar *&ws, { } -ACE_INLINE -ACE_InputCDR::to_std_string::to_std_string (std::string &s, - ACE_CDR::ULong b) - : val_ (s), - bound_ (b) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_std_string::from_std_string (const std::string &ws, - ACE_CDR::ULong b) - : val_ (ws), - bound_ (b) -{ -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE -ACE_InputCDR::to_std_wstring::to_std_wstring (std::wstring &s, - ACE_CDR::ULong b) - : val_ (s), - bound_ (b) -{ -} - -ACE_INLINE -ACE_OutputCDR::from_std_wstring::from_std_wstring (const std::wstring &ws, - ACE_CDR::ULong b) - : val_ (ws), - bound_ (b) -{ -} -#endif - ACE_INLINE ACE_InputCDR::Transfer_Contents::Transfer_Contents (ACE_InputCDR &rhs) : rhs_ (rhs) @@ -301,14 +270,6 @@ ACE_OutputCDR::write_longdouble (const ACE_CDR::LongDouble &x) return this->write_16 (&x); } -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_fixed (const ACE_CDR::Fixed &x) -{ - int n; - const ACE_CDR::Octet *arr = x.to_octets (n); - return this->write_array (arr, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, n); -} - ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_string (const ACE_CDR::Char *x) { @@ -335,26 +296,6 @@ ACE_OutputCDR::write_wstring (const ACE_CDR::WChar *x) return this->write_wstring (0, 0); } -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_string (const std::string &x) -{ - ACE_CDR::ULong const len = - static_cast (x.size ()); - return this->write_string (len, - x.empty () ? 0 : x.c_str ()); -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::write_wstring (const std::wstring &x) -{ - ACE_CDR::ULong const len = - static_cast (x.size ()); - return this->write_wstring (len, - x.empty () ? 0 : x.c_str ()); -} -#endif - ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length) @@ -771,26 +712,6 @@ ACE_InputCDR::read_longdouble (ACE_CDR::LongDouble &x) return this->read_16 (&x); } -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::read_fixed (ACE_CDR::Fixed &x) -{ - ACE_CDR::Octet a[16]; - for (int i = 0; i < 16; ++i) - { - if (!this->read_1 (a + i)) - return false; - const unsigned low = a[i] & 0xf; - if (low == ACE_CDR::Fixed::POSITIVE || - low == ACE_CDR::Fixed::NEGATIVE) - { - x = ACE_CDR::Fixed::from_octets (a, i + 1); - return true; - } - } - - return false; -} - ACE_INLINE size_t ACE_InputCDR::length (void) const { @@ -1098,21 +1019,6 @@ ACE_InputCDR::skip_longdouble (void) return this->read_16 (&x); } -ACE_INLINE ACE_CDR::Boolean -ACE_InputCDR::skip_fixed (void) -{ - for (int i = 0; i < 16; ++i) - { - ACE_CDR::Octet x; - if (!this->read_1 (&x)) - return false; - const unsigned low = x & 0xf; - if (low == 0xc || low == 0xd) - return true; - } - return false; -} - ACE_INLINE char* ACE_InputCDR::end (void) { @@ -1253,13 +1159,6 @@ operator<< (ACE_OutputCDR &os, ACE_CDR::Double x) return (ACE_CDR::Boolean) os.good_bit (); } -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, const ACE_CDR::Fixed &x) -{ - os.write_fixed (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - ACE_INLINE ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, const ACE_CDR::Char *x) { @@ -1274,46 +1173,6 @@ operator<< (ACE_OutputCDR &os, const ACE_CDR::WChar *x) return (ACE_CDR::Boolean) os.good_bit (); } -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_std_string x) -{ - ACE_CDR::ULong len = - static_cast (x.val_.size ()); - - os.write_string (len, x.val_.c_str ()); - return - (ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_)); -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_std_wstring x) -{ - ACE_CDR::ULong len = - static_cast (x.val_.size ()); - - os.write_wstring (len, x.val_.c_str ()); - return - (ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_)); -} -#endif - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, const std::string& x) -{ - os.write_string (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, const std::wstring& x) -{ - os.write_wstring (x); - return (ACE_CDR::Boolean) os.good_bit (); -} -#endif - // The following use the helper classes ACE_INLINE ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_boolean x) @@ -1435,12 +1294,6 @@ operator>> (ACE_InputCDR &is, ACE_CDR::Double &x) return is.read_double (x) && is.good_bit (); } -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::Fixed &x) -{ - return is.read_fixed (x) && is.good_bit (); -} - ACE_INLINE ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_CDR::Char *&x) { @@ -1453,20 +1306,6 @@ operator>> (ACE_InputCDR &is, ACE_CDR::WChar *&x) return is.read_wstring (x) && is.good_bit (); } -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, std::string& x) -{ - return is.read_string (x) && is.good_bit (); -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, std::wstring& x) -{ - return is.read_wstring (x) && is.good_bit (); -} -#endif - // The following use the helper classes ACE_INLINE ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_InputCDR::to_boolean x) @@ -1514,29 +1353,6 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wstring x) || ACE_OS::strlen (x.val_) <= x.bound_)); } -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_std_string x) -{ - // check if the bounds are satisfied - return - (is.read_string (x.val_) - && is.good_bit () - && (!x.bound_ - || static_cast (x.val_.size ()) <= x.bound_)); -} - -#if !defined(ACE_LACKS_STD_WSTRING) -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_InputCDR::to_std_wstring x) -{ - // check if the bounds are satisfied - return - (is.read_wstring (x.val_) - && is.good_bit () - && (!x.bound_ - || static_cast (x.val_.size ()) <= x.bound_)); -} -#endif // *************************************************************************** // We must define these methods here because they use the "read_*" inlined // methods of the ACE_InputCDR class @@ -1633,24 +1449,13 @@ ACE_OutputCDR::append_longdouble (ACE_InputCDR &stream) return stream.read_longdouble (x) ? this->write_longdouble (x) : false; } -ACE_INLINE ACE_CDR::Boolean -ACE_OutputCDR::append_fixed (ACE_InputCDR &stream) -{ - ACE_CDR::Fixed x; - return stream.read_fixed (x) ? this->write_fixed (x) : false; -} - ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::append_string (ACE_InputCDR &stream) { ACE_CDR::Char *x = 0; ACE_CDR::Boolean const flag = (stream.read_string (x) ? this->write_string (x) : false); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(x); -#else delete [] x; -#endif /* ACE_HAS_ALLOC_HOOKS */ return flag; } @@ -1660,11 +1465,7 @@ ACE_OutputCDR::append_wstring (ACE_InputCDR &stream) ACE_CDR::WChar *x = 0; ACE_CDR::Boolean const flag = (stream.read_wstring (x) ? this->write_wstring (x) : false); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(x); -#else delete [] x; -#endif /* ACE_HAS_ALLOC_HOOKS */ return flag; } diff --git a/dep/acelite/ace/CE_Screen_Output.cpp b/dep/acelite/ace/CE_Screen_Output.cpp index 8711f1e57..141ed2cf4 100644 --- a/dep/acelite/ace/CE_Screen_Output.cpp +++ b/dep/acelite/ace/CE_Screen_Output.cpp @@ -1,3 +1,5 @@ +// $Id: CE_Screen_Output.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/CE_Screen_Output.h" #if defined (ACE_HAS_WINCE) diff --git a/dep/acelite/ace/CE_Screen_Output.h b/dep/acelite/ace/CE_Screen_Output.h index 65c697daa..62d4deaa0 100644 --- a/dep/acelite/ace/CE_Screen_Output.h +++ b/dep/acelite/ace/CE_Screen_Output.h @@ -4,6 +4,8 @@ /** * @file CE_Screen_Output.h * + * $Id: CE_Screen_Output.h 94271 2011-06-23 14:52:31Z johnnyw $ + * * @author Si Mong Park */ //============================================================================= diff --git a/dep/acelite/ace/CMakeLists.txt b/dep/acelite/ace/CMakeLists.txt new file mode 100644 index 000000000..56ec50557 --- /dev/null +++ b/dep/acelite/ace/CMakeLists.txt @@ -0,0 +1,337 @@ +# +# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +set(ace_STAT_SRCS + ACE.cpp + ACE_crc32.cpp + ACE_crc_ccitt.cpp + ace_wchar.cpp + Activation_Queue.cpp + Active_Map_Manager.cpp + Addr.cpp + Argv_Type_Converter.cpp + Assert.cpp + Asynch_IO.cpp + Asynch_IO_Impl.cpp + Asynch_Pseudo_Task.cpp + ATM_Acceptor.cpp + ATM_Addr.cpp + ATM_Connector.cpp + ATM_Params.cpp + ATM_QoS.cpp + ATM_Stream.cpp + Atomic_Op.cpp + Atomic_Op_Sparc.c + Barrier.cpp + Base_Thread_Adapter.cpp + Based_Pointer_Repository.cpp + Basic_Stats.cpp + Basic_Types.cpp + Capabilities.cpp + CDR_Base.cpp + CDR_Size.cpp + CDR_Stream.cpp + Cleanup.cpp + Codecs.cpp + Codeset_IBM1047.cpp + Codeset_Registry.cpp + Codeset_Registry_db.cpp + Condition_Attributes.cpp + Condition_Recursive_Thread_Mutex.cpp + Condition_Thread_Mutex.cpp + Configuration.cpp + Configuration_Import_Export.cpp + Connection_Recycling_Strategy.cpp + Containers.cpp + Copy_Disabled.cpp + Date_Time.cpp + DEV.cpp + DEV_Addr.cpp + DEV_Connector.cpp + DEV_IO.cpp + Dev_Poll_Reactor.cpp + Dirent.cpp + Dirent_Selector.cpp + DLL.cpp + DLL_Manager.cpp + Dump.cpp + Dynamic.cpp + Dynamic_Message_Strategy.cpp + Dynamic_Service_Base.cpp + Dynamic_Service_Dependency.cpp + Encoding_Converter.cpp + Encoding_Converter_Factory.cpp + Event_Base.cpp + Event_Handler.cpp + Event_Handler_Handle_Timeout_Upcall.cpp + FIFO.cpp + FIFO_Recv.cpp + FIFO_Recv_Msg.cpp + FIFO_Send.cpp + FIFO_Send_Msg.cpp + FILE.cpp + FILE_Addr.cpp + FILE_Connector.cpp + FILE_IO.cpp + File_Lock.cpp + Filecache.cpp + Flag_Manip.cpp + Framework_Component.cpp + Functor.cpp + Functor_String.cpp + Get_Opt.cpp + Handle_Ops.cpp + Handle_Set.cpp + Hashable.cpp + High_Res_Timer.cpp + ICMP_Socket.cpp + INET_Addr.cpp + Init_ACE.cpp + IO_Cntl_Msg.cpp + IO_SAP.cpp + IOStream.cpp + IPC_SAP.cpp + Lib_Find.cpp + Local_Memory_Pool.cpp + Local_Name_Space.cpp + Local_Tokens.cpp + Lock.cpp + Log_Category.cpp + Log_Msg.cpp + Log_Msg_Backend.cpp + Log_Msg_Callback.cpp + Log_Msg_IPC.cpp + Log_Msg_NT_Event_Log.cpp + Log_Msg_UNIX_Syslog.cpp + Log_Record.cpp + Logging_Strategy.cpp + LSOCK.cpp + LSOCK_Acceptor.cpp + LSOCK_CODgram.cpp + LSOCK_Connector.cpp + LSOCK_Dgram.cpp + LSOCK_Stream.cpp + Malloc.cpp + Malloc_Allocator.cpp + MEM_Acceptor.cpp + MEM_Addr.cpp + MEM_Connector.cpp + MEM_IO.cpp + Mem_Map.cpp + MEM_SAP.cpp + MEM_Stream.cpp + Message_Block.cpp + Message_Queue.cpp + Message_Queue_NT.cpp + Message_Queue_Vx.cpp + Method_Request.cpp + MMAP_Memory_Pool.cpp + Monitor_Admin.cpp + Monitor_Admin_Manager.cpp + Monitor_Base.cpp + Monitor_Control_Action.cpp + Monitor_Control_Types.cpp + Monitor_Point_Registry.cpp + Monitor_Size.cpp + Monotonic_Time_Policy.cpp + Msg_WFMO_Reactor.cpp + Multihomed_INET_Addr.cpp + Mutex.cpp + Name_Proxy.cpp + Name_Request_Reply.cpp + Name_Space.cpp + Naming_Context.cpp + Netlink_Addr.cpp + Notification_Queue.cpp + Notification_Strategy.cpp + NT_Service.cpp + Obchunk.cpp + Object_Manager.cpp + Object_Manager_Base.cpp + Obstack.cpp + OS_Errno.cpp + OS_Log_Msg_Attributes.cpp + OS_main.cpp + OS_NS_arpa_inet.cpp + OS_NS_ctype.cpp + OS_NS_dirent.cpp + OS_NS_dlfcn.cpp + OS_NS_errno.cpp + OS_NS_fcntl.cpp + OS_NS_math.cpp + OS_NS_netdb.cpp + OS_NS_poll.cpp + OS_NS_pwd.cpp + OS_NS_regex.cpp + OS_NS_signal.cpp + OS_NS_stdio.cpp + OS_NS_stdlib.cpp + OS_NS_string.cpp + OS_NS_strings.cpp + OS_NS_stropts.cpp + OS_NS_sys_mman.cpp + OS_NS_sys_msg.cpp + OS_NS_sys_resource.cpp + OS_NS_sys_select.cpp + OS_NS_sys_sendfile.cpp + OS_NS_sys_shm.cpp + OS_NS_sys_socket.cpp + OS_NS_sys_stat.cpp + OS_NS_sys_time.cpp + OS_NS_sys_uio.cpp + OS_NS_sys_utsname.cpp + OS_NS_sys_wait.cpp + OS_NS_Thread.cpp + OS_NS_time.cpp + OS_NS_unistd.cpp + OS_NS_wchar.cpp + OS_NS_wctype.cpp + OS_QoS.cpp + OS_Thread_Adapter.cpp + OS_TLI.cpp + Pagefile_Memory_Pool.cpp + Parse_Node.cpp + PI_Malloc.cpp + Ping_Socket.cpp + Pipe.cpp + POSIX_Asynch_IO.cpp + POSIX_CB_Proactor.cpp + POSIX_Proactor.cpp + Priority_Reactor.cpp + Proactor.cpp + Proactor_Impl.cpp + Process.cpp + Process_Manager.cpp + Process_Mutex.cpp + Process_Semaphore.cpp + Profile_Timer.cpp + Reactor.cpp + Reactor_Impl.cpp + Reactor_Notification_Strategy.cpp + Reactor_Timer_Interface.cpp + Read_Buffer.cpp + Recursive_Thread_Mutex.cpp + Recyclable.cpp + Registry.cpp + Registry_Name_Space.cpp + Remote_Name_Space.cpp + Remote_Tokens.cpp + Rtems_init.c + RW_Mutex.cpp + RW_Process_Mutex.cpp + RW_Thread_Mutex.cpp + Sample_History.cpp + Sbrk_Memory_Pool.cpp + Sched_Params.cpp + Select_Reactor_Base.cpp + Semaphore.cpp + Service_Config.cpp + Service_Gestalt.cpp + Service_Manager.cpp + Service_Object.cpp + Service_Repository.cpp + Service_Types.cpp + Shared_Memory.cpp + Shared_Memory_MM.cpp + Shared_Memory_Pool.cpp + Shared_Memory_SV.cpp + Shared_Object.cpp + Sig_Adapter.cpp + Sig_Handler.cpp + Signal.cpp + SOCK.cpp + SOCK_Acceptor.cpp + SOCK_CODgram.cpp + Sock_Connect.cpp + SOCK_Connector.cpp + SOCK_Dgram.cpp + SOCK_Dgram_Bcast.cpp + SOCK_Dgram_Mcast.cpp + SOCK_IO.cpp + SOCK_Netlink.cpp + SOCK_SEQPACK_Acceptor.cpp + SOCK_SEQPACK_Association.cpp + SOCK_SEQPACK_Connector.cpp + SOCK_Stream.cpp + SPIPE.cpp + SPIPE_Acceptor.cpp + SPIPE_Addr.cpp + SPIPE_Connector.cpp + SPIPE_Stream.cpp + SString.cpp + Stack_Trace.cpp + Stats.cpp + String_Base_Const.cpp + SUN_Proactor.cpp + SV_Message.cpp + SV_Message_Queue.cpp + SV_Semaphore_Complex.cpp + SV_Semaphore_Simple.cpp + SV_Shared_Memory.cpp + Svc_Conf_Lexer.cpp + Svc_Conf_y.cpp + Synch_Options.cpp + System_Time.cpp + Task.cpp + Thread.cpp + Thread_Adapter.cpp + Thread_Control.cpp + Thread_Exit.cpp + Thread_Hook.cpp + Thread_Manager.cpp + Thread_Mutex.cpp + Thread_Semaphore.cpp + Throughput_Stats.cpp + Time_Policy.cpp + Time_Value.cpp + Timeprobe.cpp + TLI.cpp + TLI_Acceptor.cpp + TLI_Connector.cpp + TLI_Stream.cpp + Token.cpp + Token_Collection.cpp + Token_Invariants.cpp + Token_Manager.cpp + Token_Request_Reply.cpp + TP_Reactor.cpp + Trace.cpp + TSS_Adapter.cpp + TTY_IO.cpp + UNIX_Addr.cpp + UPIPE_Acceptor.cpp + UPIPE_Connector.cpp + UPIPE_Stream.cpp + UTF16_Encoding_Converter.cpp + UTF32_Encoding_Converter.cpp + UTF8_Encoding_Converter.cpp + UUID.cpp + WFMO_Reactor.cpp + WIN32_Asynch_IO.cpp + WIN32_Proactor.cpp + XML_Svc_Conf.cpp + XTI_ATM_Mcast.cpp +) + +include_directories(${CMAKE_SOURCE_DIR}/dep/acelite) + +add_library(ace STATIC ${ace_STAT_SRCS}) + +if (MINGW) + target_link_libraries(ace ws2_32 iphlpapi netapi32 mswsock) +endif() diff --git a/dep/acelite/ace/CORBA_macros.h b/dep/acelite/ace/CORBA_macros.h index 9cd55e26d..8233b63cd 100644 --- a/dep/acelite/ace/CORBA_macros.h +++ b/dep/acelite/ace/CORBA_macros.h @@ -4,6 +4,8 @@ /** * @file CORBA_macros.h * + * $Id: CORBA_macros.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * Writing code that is portable between platforms with or without * native C++ exceptions is hard. The following macros offer some * help on this task, mostly oriented to making the ORB code and the diff --git a/dep/acelite/ace/Cache_Map_Manager_T.cpp b/dep/acelite/ace/Cache_Map_Manager_T.cpp index b92876a7f..06664cd06 100644 --- a/dep/acelite/ace/Cache_Map_Manager_T.cpp +++ b/dep/acelite/ace/Cache_Map_Manager_T.cpp @@ -1,3 +1,5 @@ +// $Id: Cache_Map_Manager_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_CACHE_MAP_MANAGER_T_CPP #define ACE_CACHE_MAP_MANAGER_T_CPP @@ -16,9 +18,11 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc7(ACE_Cache_Map_Manager) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Cache_Map_Iterator) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Cache_Map_Reverse_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Manager) + +ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Iterator) + +ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Reverse_Iterator) template ACE_Cache_Map_Manager::ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_s, diff --git a/dep/acelite/ace/Cache_Map_Manager_T.h b/dep/acelite/ace/Cache_Map_Manager_T.h index f76faec05..3f11d92fd 100644 --- a/dep/acelite/ace/Cache_Map_Manager_T.h +++ b/dep/acelite/ace/Cache_Map_Manager_T.h @@ -4,6 +4,8 @@ /** * @file Cache_Map_Manager_T.h * + * $Id: Cache_Map_Manager_T.h 92097 2010-09-30 05:41:49Z msmit $ + * * @author Kirthika Parameswaran */ //============================================================================= @@ -217,9 +219,6 @@ public: /// The caching strategy used on the cache. CACHING_STRATEGY &caching_strategy (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// The underlying map which needs to be cached. diff --git a/dep/acelite/ace/Cache_Map_Manager_T.inl b/dep/acelite/ace/Cache_Map_Manager_T.inl index dc2a42ef0..06378de04 100644 --- a/dep/acelite/ace/Cache_Map_Manager_T.inl +++ b/dep/acelite/ace/Cache_Map_Manager_T.inl @@ -1,5 +1,7 @@ // -*- C++ -*- // +//$Id: Cache_Map_Manager_T.inl 92097 2010-09-30 05:41:49Z msmit $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE int diff --git a/dep/acelite/ace/Cached_Connect_Strategy_T.cpp b/dep/acelite/ace/Cached_Connect_Strategy_T.cpp index 7a563edee..646247b48 100644 --- a/dep/acelite/ace/Cached_Connect_Strategy_T.cpp +++ b/dep/acelite/ace/Cached_Connect_Strategy_T.cpp @@ -1,3 +1,5 @@ +//$Id: Cached_Connect_Strategy_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_CACHED_CONNECT_STRATEGY_T_CPP #define ACE_CACHED_CONNECT_STRATEGY_T_CPP @@ -15,9 +17,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcoccc (ACE_Cached_Connect_Strategy_Ex) -ACE_ALLOC_HOOK_DEFINE_Tcoccc (ACE_Bounded_Cached_Connect_Strategy) - template ACE_Cached_Connect_Strategy_Ex::ACE_Cached_Connect_Strategy_Ex (CACHING_STRATEGY &caching_s, @@ -558,6 +557,7 @@ ACE_Cached_Connect_Strategy_Ex @@ -723,6 +723,8 @@ ACE_Bounded_Cached_Connect_Strategy */ //============================================================================= @@ -102,9 +104,6 @@ public: // = Accessor. CACHING_STRATEGY &caching_strategy (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Find an idle handle. @@ -225,11 +224,11 @@ public: MUTEX *lock = 0, int delete_lock = 0); - /// Destructor - virtual ~ACE_Bounded_Cached_Connect_Strategy (void); + /// Destructor + virtual ~ACE_Bounded_Cached_Connect_Strategy (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; protected: diff --git a/dep/acelite/ace/Caching_Strategies_T.cpp b/dep/acelite/ace/Caching_Strategies_T.cpp index 0cc25407a..3841c253c 100644 --- a/dep/acelite/ace/Caching_Strategies_T.cpp +++ b/dep/acelite/ace/Caching_Strategies_T.cpp @@ -1,3 +1,5 @@ +//$Id: Caching_Strategies_T.cpp 97844 2014-08-22 15:53:43Z mesnier_p $ + #ifndef ACE_CACHING_STRATEGIES_T_CPP #define ACE_CACHING_STRATEGIES_T_CPP @@ -47,11 +49,10 @@ ACE_FIFO_Caching_Strategy::ACE_FIFO_Caching_Strateg //////////////////////////////////////////////////////////////////////////////////////////////// -ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Caching_Strategy_Adapter) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_LRU_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_LFU_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_FIFO_Caching_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Null_Caching_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy) ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Caching_Strategies_T.h b/dep/acelite/ace/Caching_Strategies_T.h index 2f58b2ab4..48f5e898e 100644 --- a/dep/acelite/ace/Caching_Strategies_T.h +++ b/dep/acelite/ace/Caching_Strategies_T.h @@ -4,6 +4,8 @@ /** * @file Caching_Strategies_T.h * + * $Id: Caching_Strategies_T.h 92097 2010-09-30 05:41:49Z msmit $ + * * @author Kirthika Parameswaran */ //============================================================================= @@ -162,9 +164,6 @@ public: /// Dumps the state of the object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: /// Implementation class. @@ -260,9 +259,6 @@ public: /// Dumps the state of the object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: /// This element is the one which is the deciding factor for purging @@ -362,9 +358,6 @@ public: /// Dumps the state of the object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: /// The level about which the purging will happen automagically. @@ -456,9 +449,6 @@ public: /// Dumps the state of the object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: /// The order is the deciding factor for the item to be removed from @@ -536,9 +526,6 @@ public: /// Dumps the state of the object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: /// This is the helper class which will decide and expunge entries diff --git a/dep/acelite/ace/Caching_Strategies_T.inl b/dep/acelite/ace/Caching_Strategies_T.inl index dd9c98513..49364504d 100644 --- a/dep/acelite/ace/Caching_Strategies_T.inl +++ b/dep/acelite/ace/Caching_Strategies_T.inl @@ -1,5 +1,7 @@ // -*-C++-*- // +//$Id: Caching_Strategies_T.inl 96985 2013-04-11 15:50:32Z huangh $ + ////////////////////////////////////////////////////////////////////////////////// #include "ace/OS_Memory.h" diff --git a/dep/acelite/ace/Caching_Utility_T.cpp b/dep/acelite/ace/Caching_Utility_T.cpp index aa344562d..4713c974b 100644 --- a/dep/acelite/ace/Caching_Utility_T.cpp +++ b/dep/acelite/ace/Caching_Utility_T.cpp @@ -1,3 +1,5 @@ +// $Id: Caching_Utility_T.cpp 92264 2010-10-19 18:12:46Z olli $ + #ifndef ACE_CACHING_UTILITY_T_CPP #define ACE_CACHING_UTILITY_T_CPP diff --git a/dep/acelite/ace/Caching_Utility_T.h b/dep/acelite/ace/Caching_Utility_T.h index bdeb165fb..fc3c53c84 100644 --- a/dep/acelite/ace/Caching_Utility_T.h +++ b/dep/acelite/ace/Caching_Utility_T.h @@ -4,6 +4,8 @@ /** * @file Caching_Utility_T.h * + * $Id: Caching_Utility_T.h 97436 2013-11-25 10:48:49Z johnnyw $ + * * @author Kirthika Parameswaran */ //============================================================================= diff --git a/dep/acelite/ace/Capabilities.cpp b/dep/acelite/ace/Capabilities.cpp index 9ffceda2a..dbf9f6393 100644 --- a/dep/acelite/ace/Capabilities.cpp +++ b/dep/acelite/ace/Capabilities.cpp @@ -1,3 +1,5 @@ +// $Id: Capabilities.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Capabilities.h" #include "ace/OS_NS_ctype.h" #include "ace/OS_Memory.h" @@ -283,6 +285,7 @@ ACE_Capabilities::getval (const ACE_TCHAR *keyname, int &val) return 0; } +#if !defined (ACE_IS_SPLITTING) static int is_empty (const ACE_TCHAR *line) { @@ -300,6 +303,7 @@ is_line (const ACE_TCHAR *line) return *line != ACE_TEXT ('\0'); } +#endif /* !ACE_IS_SPLITTING */ int ACE_Capabilities::getent (const ACE_TCHAR *fname, const ACE_TCHAR *name) @@ -345,8 +349,4 @@ ACE_Capabilities::getent (const ACE_TCHAR *fname, const ACE_TCHAR *name) return -1; } -ACE_ALLOC_HOOK_DEFINE(ACE_StringCapEntry) -ACE_ALLOC_HOOK_DEFINE(ACE_IntCapEntry) -ACE_ALLOC_HOOK_DEFINE(ACE_BoolCapEntry) - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Capabilities.h b/dep/acelite/ace/Capabilities.h index c3939f407..f4c8b5cc6 100644 --- a/dep/acelite/ace/Capabilities.h +++ b/dep/acelite/ace/Capabilities.h @@ -4,6 +4,8 @@ /** * @file Capabilities.h * + * $Id: Capabilities.h 91077 2010-07-13 14:33:08Z johnnyw $ + * * @author Arturo Montes */ //============================================================================= @@ -25,6 +27,11 @@ #include "ace/SString.h" #include "ace/Functor_String.h" +#if defined (ACE_IS_SPLITTING) +# include "ace/OS_NS_ctype.h" +#endif /* ACE_IS_SPLITTING */ + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** @@ -73,7 +80,6 @@ class ACE_Export ACE_IntCapEntry : public ACE_CapEntry public: ACE_IntCapEntry (int val); int getval (void) const; - ACE_ALLOC_HOOK_DECLARE; protected: int val_; @@ -92,7 +98,6 @@ class ACE_Export ACE_StringCapEntry : public ACE_CapEntry public: ACE_StringCapEntry (const ACE_TString &val); ACE_TString getval (void) const; - ACE_ALLOC_HOOK_DECLARE; protected: ACE_TString val_; @@ -111,7 +116,6 @@ class ACE_Export ACE_BoolCapEntry : public ACE_CapEntry public: ACE_BoolCapEntry (int val); int getval (void) const; - ACE_ALLOC_HOOK_DECLARE; protected: int val_; @@ -187,6 +191,26 @@ private: CAPABILITIES_MAP caps_; }; +#if defined (ACE_IS_SPLITTING) +int +is_empty (const ACE_TCHAR *line) +{ + while (*line && ACE_OS::ace_isspace (*line)) + ++line; + + return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#'); +} + +int +is_line (const ACE_TCHAR *line) +{ + while (*line && ACE_OS::ace_isspace (*line)) + ++line; + + return *line != ACE_TEXT ('\0'); +} +#endif /* ACE_IS_SPLITTING */ + ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Capabilities.inl b/dep/acelite/ace/Capabilities.inl index 0579ae6cd..37284b286 100644 --- a/dep/acelite/ace/Capabilities.inl +++ b/dep/acelite/ace/Capabilities.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Capabilities.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Cleanup.cpp b/dep/acelite/ace/Cleanup.cpp index 0e162c8cf..1d5fe99f0 100644 --- a/dep/acelite/ace/Cleanup.cpp +++ b/dep/acelite/ace/Cleanup.cpp @@ -1,3 +1,5 @@ +// $Id: Cleanup.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ + #include "ace/Cleanup.h" #if !defined (ACE_HAS_INLINED_OSCALLS) @@ -8,10 +10,6 @@ #include "ace/OS_NS_string.h" #include "ace/os_include/os_typeinfo.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL void @@ -56,15 +54,9 @@ ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void *object, ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void) { if (this->name_) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) name_); -#else ACE_OS::free ((void *) name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } -ACE_ALLOC_HOOK_DEFINE(ACE_Cleanup_Info_Node) - bool ACE_Cleanup_Info_Node::operator== (const ACE_Cleanup_Info_Node &o) const { diff --git a/dep/acelite/ace/Cleanup.h b/dep/acelite/ace/Cleanup.h index 86044c85c..bd750724f 100644 --- a/dep/acelite/ace/Cleanup.h +++ b/dep/acelite/ace/Cleanup.h @@ -4,7 +4,9 @@ /** * @file Cleanup.h * - * @author Douglas C. Schmidt + * $Id: Cleanup.h 84163 2009-01-15 07:57:27Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -87,9 +89,6 @@ public: ACE_CLEANUP_FUNC cleanup_hook (void); void *param (void); - - ACE_ALLOC_HOOK_DECLARE; - private: /// Point to object that gets passed into the . void *object_; diff --git a/dep/acelite/ace/Cleanup.inl b/dep/acelite/ace/Cleanup.inl index fdae3412f..196a9f478 100644 --- a/dep/acelite/ace/Cleanup.inl +++ b/dep/acelite/ace/Cleanup.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Cleanup.inl 83956 2008-12-03 07:57:38Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Cleanup_Strategies_T.cpp b/dep/acelite/ace/Cleanup_Strategies_T.cpp index 53cf0b876..7ce542e28 100644 --- a/dep/acelite/ace/Cleanup_Strategies_T.cpp +++ b/dep/acelite/ace/Cleanup_Strategies_T.cpp @@ -1,3 +1,5 @@ +//$Id: Cleanup_Strategies_T.cpp 92097 2010-09-30 05:41:49Z msmit $ + #ifndef ACE_CLEANUP_STRATEGIES_T_CPP #define ACE_CLEANUP_STRATEGIES_T_CPP diff --git a/dep/acelite/ace/Cleanup_Strategies_T.h b/dep/acelite/ace/Cleanup_Strategies_T.h index 96900418a..ca51b47b1 100644 --- a/dep/acelite/ace/Cleanup_Strategies_T.h +++ b/dep/acelite/ace/Cleanup_Strategies_T.h @@ -4,6 +4,8 @@ /** * @file Cleanup_Strategies_T.h * + * $Id: Cleanup_Strategies_T.h 81388 2008-04-23 14:02:05Z johnnyw $ + * * @author Kirthika Parameswaran */ //============================================================================= diff --git a/dep/acelite/ace/Codecs.cpp b/dep/acelite/ace/Codecs.cpp index 7b22f2735..d0579ab92 100644 --- a/dep/acelite/ace/Codecs.cpp +++ b/dep/acelite/ace/Codecs.cpp @@ -1,12 +1,10 @@ +// $Id: Codecs.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Codecs.h" #include "ace/Log_Category.h" #include "ace/OS_Memory.h" #include "ace/OS_NS_ctype.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - namespace { // Just in case ... @@ -51,11 +49,7 @@ ACE_Base64::encode (const ACE_Byte* input, size_t length = ((input_len + 2) / 3) * 4; size_t num_lines = length / max_columns + 1; length += num_lines + 1; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (result, static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_Byte) * length)), 0); -#else ACE_NEW_RETURN (result, ACE_Byte[length], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ int char_count = 0; int bits = 0; @@ -143,12 +137,7 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) size_t result_len = ACE_Base64::length (input); ACE_Byte* result = 0; - -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (result, static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_Byte) * result_len)), 0); -#else ACE_NEW_RETURN (result, ACE_Byte[result_len], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_Byte* ptr = const_cast (input); while (*ptr != 0 && @@ -217,11 +206,7 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) if (errors) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(result); -#else delete[] result; -#endif /* ACE_HAS_ALLOC_HOOKS */ return 0; } result[pos] = 0; diff --git a/dep/acelite/ace/Codecs.h b/dep/acelite/ace/Codecs.h index f8d686397..2c4227dd0 100644 --- a/dep/acelite/ace/Codecs.h +++ b/dep/acelite/ace/Codecs.h @@ -4,12 +4,15 @@ /** * @file Codecs.h * + * $Id: Codecs.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Krishnakumar B * * Codecs is a generic wrapper for various encoding and decoding * mechanisms. Currently it includes Base64 content transfer-encoding as * specified by RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part * One: Format of Internet Message Bodies. + * */ //============================================================================= @@ -38,6 +41,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * This class provides methods to encode or decode a stream of bytes * to/from Base64 encoding. It doesn't convert the input stream to a * canonical form before encoding. + * */ class ACE_Export ACE_Base64 { @@ -55,6 +59,7 @@ public: * @return Encoded Base64 data in byte stream or NULL if input data cannot * be encoded. */ + static ACE_Byte* encode (const ACE_Byte* input, const size_t input_len, size_t* output_len, diff --git a/dep/acelite/ace/Codeset_IBM1047.cpp b/dep/acelite/ace/Codeset_IBM1047.cpp index edfd2bab4..3f5bad0b7 100644 --- a/dep/acelite/ace/Codeset_IBM1047.cpp +++ b/dep/acelite/ace/Codeset_IBM1047.cpp @@ -3,9 +3,12 @@ /** * @file Codeset_IBM1047.cpp * + * $Id: Codeset_IBM1047.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + * * Defines the arrays required to convert between ISO8859 (aka * Latin/1) and IBM1047 (aka EBCDIC). * + * * @author Jim Rogers (jrogers@viasoft.com) */ //============================================================================= @@ -119,42 +122,6 @@ ACE_IBM1047_ISO8859::read_string (ACE_InputCDR& in, return 0; } -ACE_CDR::Boolean -ACE_IBM1047_ISO8859::read_string (ACE_InputCDR& in, - std::string & x) -{ -#if defined (ACE_HAS_CPP11) - ACE_CDR::ULong len; - - in.read_ulong (len); - - if (len > 0) - { - try - { - x.resize (len); - } - catch (const std::bad_alloc&) - { - return false; - } - - if (this->read_char_array (in, &x[0], len)) - { - x.resize (len-1); // drop terminating '\0' read from stream - return true; - } - - delete [] x; - } - - x.clear (); - return false; -#else - return this->ACE_Char_Codeset_Translator::read_string (in, x); -#endif -} - ACE_CDR::Boolean ACE_IBM1047_ISO8859::read_char_array (ACE_InputCDR& in, ACE_CDR::Char* x, @@ -272,42 +239,6 @@ ACE_ISO8859_IBM1047::read_string (ACE_InputCDR &in, return 0; } -ACE_CDR::Boolean -ACE_ISO8859_IBM1047::read_string (ACE_InputCDR& in, - std::string & x) -{ -#if defined (ACE_HAS_CPP11) - ACE_CDR::ULong len; - - in.read_ulong (len); - - if (len > 0) - { - try - { - x.resize (len); - } - catch (const std::bad_alloc&) - { - return false; - } - - if (this->read_char_array (in, &x[0], len)) - { - x.resize (len-1); // drop terminating '\0' read from stream - return true; - } - - delete [] x; - } - - x.clear (); - return false; -#else - return this->ACE_Char_Codeset_Translator::read_string (in, x); -#endif -} - ACE_CDR::Boolean ACE_ISO8859_IBM1047::read_char_array (ACE_InputCDR &in, ACE_CDR::Char *x, diff --git a/dep/acelite/ace/Codeset_IBM1047.h b/dep/acelite/ace/Codeset_IBM1047.h index d9d84aa40..3caa8881f 100644 --- a/dep/acelite/ace/Codeset_IBM1047.h +++ b/dep/acelite/ace/Codeset_IBM1047.h @@ -4,6 +4,8 @@ /** * @file Codeset_IBM1047.h * + * $Id: Codeset_IBM1047.h 81388 2008-04-23 14:02:05Z johnnyw $ + * * Declares the arrays required to convert between ISO8859 (aka * Latin/1) and IBM1047 (aka EBCDIC). * @@ -53,8 +55,6 @@ public: ACE_CDR::Char &); virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, ACE_CDR::Char *&); - virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, - std::string &); virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR &, ACE_CDR::Char *, ACE_CDR::ULong); @@ -98,8 +98,6 @@ public: ACE_CDR::Char &); virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, ACE_CDR::Char *&); - virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, - std::string &); virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR &, ACE_CDR::Char *, ACE_CDR::ULong); diff --git a/dep/acelite/ace/Codeset_Registry.cpp b/dep/acelite/ace/Codeset_Registry.cpp index 7ae55118d..6c132a880 100644 --- a/dep/acelite/ace/Codeset_Registry.cpp +++ b/dep/acelite/ace/Codeset_Registry.cpp @@ -2,8 +2,11 @@ /** * @file Codeset_Registry.cpp * + * $Id: Codeset_Registry.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + * * emulated codset regstry functions * + * * @author Phil Mesnier */ //============================================================================= @@ -12,6 +15,8 @@ #include "ace/OS_Memory.h" #include "ace/OS_NS_string.h" +// $Id: Codeset_Registry.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #if !defined (__ACE_INLINE__) #include "ace/Codeset_Registry.inl" #endif /* __ACE_INLINE__ */ @@ -35,11 +40,7 @@ ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale, *num_sets = element->num_sets_; if (char_sets != 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (*char_sets,static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::UShort) * (element->num_sets_))),0); -#else ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::memcpy (*char_sets, element->char_sets_, element->num_sets_ * sizeof (ACE_CDR::UShort)); } @@ -63,11 +64,7 @@ ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id, *num_sets = element->num_sets_; if (char_sets != 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (*char_sets,static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::UShort) * (element->num_sets_))),0); -#else ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::memcpy (*char_sets, element->char_sets_, element->num_sets_ * sizeof (ACE_CDR::UShort)); } diff --git a/dep/acelite/ace/Codeset_Registry.h b/dep/acelite/ace/Codeset_Registry.h index 86599663f..28bd629ad 100644 --- a/dep/acelite/ace/Codeset_Registry.h +++ b/dep/acelite/ace/Codeset_Registry.h @@ -3,6 +3,8 @@ /** * @file Codeset_Registry.h * + * $Id: Codeset_Registry.h 93651 2011-03-28 08:49:11Z johnnyw $ + * * ACE wrapper around access functions for the OSF's DCE codeset registry * access functions * diff --git a/dep/acelite/ace/Codeset_Registry.inl b/dep/acelite/ace/Codeset_Registry.inl index f459d4d83..a83481800 100644 --- a/dep/acelite/ace/Codeset_Registry.inl +++ b/dep/acelite/ace/Codeset_Registry.inl @@ -3,10 +3,13 @@ /** * @file Codeset_Registry.inl * + * $Id: Codeset_Registry.inl 93651 2011-03-28 08:49:11Z johnnyw $ + * * ACE wrapper around access functions for the OSF's DCE codeset registry * access functions - the inline functions either call the system supplied * DCE based codeset regsitry function, or calls the emulation * + * * @author Phil Mesnier */ //============================================================================= diff --git a/dep/acelite/ace/Codeset_Registry_db.cpp b/dep/acelite/ace/Codeset_Registry_db.cpp index 53b719d87..32b38631c 100644 --- a/dep/acelite/ace/Codeset_Registry_db.cpp +++ b/dep/acelite/ace/Codeset_Registry_db.cpp @@ -1,4 +1,4 @@ -/* +/* $Id: Codeset_Registry_db.cpp 81756 2008-05-22 09:47:33Z johnnyw $ * Codeset registry DB, generated Fri Feb 28 21:01:30 2003 * source: code_set_registry1.2g.txt * diff --git a/dep/acelite/ace/Codeset_Symbols.h b/dep/acelite/ace/Codeset_Symbols.h index f57935f8c..6ffe198c1 100644 --- a/dep/acelite/ace/Codeset_Symbols.h +++ b/dep/acelite/ace/Codeset_Symbols.h @@ -4,6 +4,8 @@ /** * @file Codeset_Symbols.h * + * $Id: Codeset_Symbols.h 80826 2008-03-04 14:51:23Z wotte $ + * * Symbolic names for codeset ids. * * @author Dale Wilson (wilson_d@ociweb.com) diff --git a/dep/acelite/ace/Condition_Attributes.cpp b/dep/acelite/ace/Condition_Attributes.cpp index 9257b602d..bacc05b3c 100644 --- a/dep/acelite/ace/Condition_Attributes.cpp +++ b/dep/acelite/ace/Condition_Attributes.cpp @@ -2,9 +2,11 @@ /** * @file Condition_Attributes.cpp * + * $Id: Condition_Attributes.cpp 96265 2012-11-13 13:31:10Z johnnyw $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/Condition_Thread_Mutex.h" diff --git a/dep/acelite/ace/Condition_Attributes.h b/dep/acelite/ace/Condition_Attributes.h index 06b2676d8..704c74d41 100644 --- a/dep/acelite/ace/Condition_Attributes.h +++ b/dep/acelite/ace/Condition_Attributes.h @@ -4,9 +4,11 @@ /** * @file Condition_Attributes.h * + * $Id: Condition_Attributes.h 96265 2012-11-13 13:31:10Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Condition_Attributes.inl b/dep/acelite/ace/Condition_Attributes.inl index 7fecc4aaf..8af4a14d3 100644 --- a/dep/acelite/ace/Condition_Attributes.inl +++ b/dep/acelite/ace/Condition_Attributes.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Condition_Attributes.inl 96265 2012-11-13 13:31:10Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Condition_Recursive_Thread_Mutex.cpp b/dep/acelite/ace/Condition_Recursive_Thread_Mutex.cpp index e7a23dfe7..f49801447 100644 --- a/dep/acelite/ace/Condition_Recursive_Thread_Mutex.cpp +++ b/dep/acelite/ace/Condition_Recursive_Thread_Mutex.cpp @@ -3,9 +3,11 @@ /** * @file Condition_Recursive_Thread_Mutex.cpp * + * $Id: Condition_Recursive_Thread_Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/Condition_Recursive_Thread_Mutex.h" diff --git a/dep/acelite/ace/Condition_Recursive_Thread_Mutex.h b/dep/acelite/ace/Condition_Recursive_Thread_Mutex.h index f53ab12eb..a313a7f7b 100644 --- a/dep/acelite/ace/Condition_Recursive_Thread_Mutex.h +++ b/dep/acelite/ace/Condition_Recursive_Thread_Mutex.h @@ -4,9 +4,11 @@ /** * @file Condition_Recursive_Thread_Mutex.h * + * $Id: Condition_Recursive_Thread_Mutex.h 96073 2012-08-17 13:39:55Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== @@ -87,16 +89,19 @@ public: void dump (void) const; private: + // = Prevent assignment and copying. void operator= (const ACE_Condition &); ACE_Condition (const ACE_Condition &); private: + /// A normal (i.e., non-recursive) condition variable. ACE_cond_t cond_; /// Reference to the recursive mutex. ACE_Recursive_Thread_Mutex &mutex_; + }; typedef ACE_Condition ACE_Condition_Recursive_Thread_Mutex; diff --git a/dep/acelite/ace/Condition_T.cpp b/dep/acelite/ace/Condition_T.cpp index 7f6b16737..8d45c9c77 100644 --- a/dep/acelite/ace/Condition_T.cpp +++ b/dep/acelite/ace/Condition_T.cpp @@ -1,3 +1,5 @@ +// $Id: Condition_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_CONDITION_T_CPP #define ACE_CONDITION_T_CPP @@ -10,9 +12,6 @@ #if defined (ACE_HAS_THREADS) #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/Condition_T.inl" @@ -21,8 +20,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Condition) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Thread_Condition) +ACE_ALLOC_HOOK_DEFINE(ACE_Condition) template void ACE_Condition::dump (void) const diff --git a/dep/acelite/ace/Condition_T.h b/dep/acelite/ace/Condition_T.h index b0e4140d8..cbae002d7 100644 --- a/dep/acelite/ace/Condition_T.h +++ b/dep/acelite/ace/Condition_T.h @@ -4,9 +4,11 @@ /** * @file Condition_T.h * + * $Id: Condition_T.h 96061 2012-08-16 09:36:07Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== @@ -103,8 +105,8 @@ public: /// Dump the state of an object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. protected: /// Condition variable. @@ -146,8 +148,8 @@ public: /// Dump the state of an object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Condition_T.inl b/dep/acelite/ace/Condition_T.inl index dc4266229..e3b452734 100644 --- a/dep/acelite/ace/Condition_T.inl +++ b/dep/acelite/ace/Condition_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Condition_T.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE int diff --git a/dep/acelite/ace/Condition_Thread_Mutex.cpp b/dep/acelite/ace/Condition_Thread_Mutex.cpp index 7e9c505d4..87cfe531c 100644 --- a/dep/acelite/ace/Condition_Thread_Mutex.cpp +++ b/dep/acelite/ace/Condition_Thread_Mutex.cpp @@ -2,9 +2,11 @@ /** * @file Condition_Thread_Mutex.cpp * + * $Id: Condition_Thread_Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/Condition_Thread_Mutex.h" diff --git a/dep/acelite/ace/Condition_Thread_Mutex.h b/dep/acelite/ace/Condition_Thread_Mutex.h index 898e683fa..f39829cfe 100644 --- a/dep/acelite/ace/Condition_Thread_Mutex.h +++ b/dep/acelite/ace/Condition_Thread_Mutex.h @@ -4,9 +4,11 @@ /** * @file Condition_Thread_Mutex.h * + * $Id: Condition_Thread_Mutex.h 96073 2012-08-17 13:39:55Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== @@ -76,9 +78,9 @@ public: /** * Block on condition, or until absolute time-of-day has passed. If - * abstime == 0 use "blocking" wait semantics. Else, if @a abstime + * abstime == 0 use "blocking" semantics. Else, if @a abstime * != 0 and the call times out before the condition is signaled - * wait() returns -1 and sets errno to ETIME. + * returns -1 and sets errno to ETIME. */ int wait (const ACE_Time_Value *abstime); @@ -117,11 +119,11 @@ protected: /// Reference to mutex lock. ACE_Thread_Mutex &mutex_; - /// Keeps track of whether remove() has been called yet to avoid - /// multiple remove() calls, e.g., explicitly and implicitly in the + /// Keeps track of whether has been called yet to avoid + /// multiple calls, e.g., explicitly and implicitly in the /// destructor. This flag isn't protected by a lock, so make sure /// that you don't have multiple threads simultaneously calling - /// remove() on the same object, which is a bad idea anyway... + /// on the same object, which is a bad idea anyway... bool removed_; private: diff --git a/dep/acelite/ace/Condition_Thread_Mutex.inl b/dep/acelite/ace/Condition_Thread_Mutex.inl index 5db2808d1..f8c06f0ff 100644 --- a/dep/acelite/ace/Condition_Thread_Mutex.inl +++ b/dep/acelite/ace/Condition_Thread_Mutex.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Condition_Thread_Mutex.inl 96174 2012-10-03 08:25:59Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/Configuration.cpp b/dep/acelite/ace/Configuration.cpp index 196281078..7ca5ad6d8 100644 --- a/dep/acelite/ace/Configuration.cpp +++ b/dep/acelite/ace/Configuration.cpp @@ -1,3 +1,4 @@ +// $Id: Configuration.cpp 97769 2014-06-05 06:37:53Z johnnyw $ #include "ace/Configuration.h" #include "ace/Auto_Ptr.h" #include "ace/SString.h" @@ -13,10 +14,6 @@ #include "ace/Configuration.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Section_Key_Internal::ACE_Section_Key_Internal (void) @@ -337,13 +334,8 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const rc = (* (thisCharData + count) == * (rhsCharData + count)); } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(thisCharData); - ACE_Allocator::instance()->free(rhsCharData); -#else delete [] thisCharData; delete [] rhsCharData; -#endif /* ACE_HAS_ALLOC_HOOKS */ }// end if the length's match } // We should never have valueTypes of INVALID, therefore @@ -1220,15 +1212,9 @@ ACE_Configuration_Section_Key_Heap::~ACE_Configuration_Section_Key_Heap () { delete value_iter_; delete section_iter_; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (path_); -#else ACE_OS::free (path_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } -ACE_ALLOC_HOOK_DEFINE(ACE_Configuration_Section_Key_Heap) - ////////////////////////////////////////////////////////////////////////////// ACE_Configuration_Heap::ACE_Configuration_Heap (void) @@ -2069,11 +2055,7 @@ ACE_Configuration_Heap::get_binary_value ( } // Make a copy -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (data, static_cast (ACE_Allocator::instance()->malloc(sizeof(char) * VIntId.length_)), -1); -#else ACE_NEW_RETURN (data, char[VIntId.length_], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::memcpy (data, VIntId.data_.ptr_, VIntId.length_); length = VIntId.length_; return 0; diff --git a/dep/acelite/ace/Configuration.h b/dep/acelite/ace/Configuration.h index aa69ea49e..4c931e6ab 100644 --- a/dep/acelite/ace/Configuration.h +++ b/dep/acelite/ace/Configuration.h @@ -4,6 +4,8 @@ /** * @file Configuration.h * + * $Id: Configuration.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Chris Hafey * * The ACE configuration API provides a portable abstraction for @@ -735,9 +737,6 @@ public: /// The sub section iterator SUBSECTION_HASH::ITERATOR* section_iter_; - - ACE_ALLOC_HOOK_DECLARE; - protected: /// Destructor - will delete the iterators virtual ~ACE_Configuration_Section_Key_Heap (void); diff --git a/dep/acelite/ace/Configuration.inl b/dep/acelite/ace/Configuration.inl index ebd6d6f9e..19c2c591b 100644 --- a/dep/acelite/ace/Configuration.inl +++ b/dep/acelite/ace/Configuration.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Configuration.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const ACE_TCHAR* diff --git a/dep/acelite/ace/Configuration_Import_Export.cpp b/dep/acelite/ace/Configuration_Import_Export.cpp index c9da29bfb..15d869b8a 100644 --- a/dep/acelite/ace/Configuration_Import_Export.cpp +++ b/dep/acelite/ace/Configuration_Import_Export.cpp @@ -1,3 +1,5 @@ +// $Id: Configuration_Import_Export.cpp 96017 2012-08-08 22:18:09Z mitza $ + #include "ace/Configuration_Import_Export.h" #include "ace/OS_Errno.h" #include "ace/OS_NS_stdio.h" @@ -41,11 +43,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) u_int buffer_size = 4096; u_int read_pos = 0; ACE_TCHAR *buffer = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (buffer, static_cast (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * buffer_size))); -#else ACE_NEW_NORETURN (buffer, ACE_TCHAR[buffer_size]); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (!buffer) { ACE_Errno_Guard guard (errno); @@ -64,19 +62,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) { // allocate a new buffer - double size the previous one ACE_TCHAR *temp_buffer; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (temp_buffer, static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR) * buffer_size * 2))); -#else ACE_NEW_NORETURN (temp_buffer, ACE_TCHAR[buffer_size * 2]); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (!temp_buffer) { ACE_Errno_Guard guard (errno); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ (void) ACE_OS::fclose (in); return -1; } @@ -85,11 +75,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) ACE_OS::memcpy (temp_buffer, buffer, buffer_size); read_pos = buffer_size - 1; buffer_size *= 2; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ buffer = temp_buffer; continue; } @@ -106,11 +92,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) if (!end) { ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return -3; } *end = 0; @@ -118,11 +100,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) if (config_.expand_path (config_.root_section (), buffer + 1, section, 1)) { ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return -3; } continue; @@ -151,11 +129,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) if (config_.set_string_value (section, name, end)) { ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return -4; } } @@ -168,11 +142,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) static_cast (value))) { ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return -4; } } @@ -184,15 +154,9 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) size_t length = string_length / 3; size_t remaining = length; u_char* data = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (data, - static_cast (ACE_Allocator::instance()->malloc(sizeof(u_char) * length)), - -1); -#else ACE_NEW_RETURN (data, u_char[length], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ u_char* out = data; ACE_TCHAR* inb = end + 4; ACE_TCHAR* endptr = 0; @@ -207,21 +171,12 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) if (config_.set_binary_value (section, name, data, length)) { ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(data); - ACE_Allocator::instance()->free(buffer); -#else delete [] data; delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return -4; } else -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(data); -#else delete [] data; -#endif /* ACE_HAS_ALLOC_HOOKS */ } else { @@ -239,11 +194,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) if (rc != 0) { ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return rc; } } // end if maybe old format @@ -252,20 +203,12 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) if (ferror (in)) { ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return -1; } ACE_OS::fclose (in); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buffer); -#else delete [] buffer; -#endif /* ACE_HAS_ALLOC_HOOKS */ return 0; } @@ -296,21 +239,6 @@ ACE_Registry_ImpExp::export_config (const ACE_TCHAR* filename) return result; } - -#if !defined ACE_USES_WCHAR && defined ACE_LACKS_FPUTS -# define ACE_WRITE_STRING write_string -namespace -{ - int write_string (const char *string, FILE *stream) - { - const size_t count = ACE_OS::strlen (string); - return (ACE_OS::fwrite (string, 1, count, stream) < count) ? -1 : 0; - } -} -#else -# define ACE_WRITE_STRING ACE_OS::fputs -#endif - // Method provided by derived classes in order to write one section // to the file specified. Called by export_config when exporting // the entire configuration object. @@ -328,7 +256,7 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio header += path; header += ACE_TEXT ("]"); header += ACE_TEXT ("\n"); - if (ACE_WRITE_STRING (header.fast_rep (), out) < 0) + if (ACE_OS::fputs (header.fast_rep (), out) < 0) return -1; // Write out each value int index = 0; @@ -350,7 +278,7 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio u_int value; if (config_.get_integer_value (section, name.fast_rep (), value)) return -2; - ACE_OS::snprintf (int_value, 32, ACE_TEXT ("%08x"), value); + ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value); line += ACE_TEXT ("dword:"); line += int_value; break; @@ -365,9 +293,11 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio line += string_value + ACE_TEXT ("\""); break; } -#ifdef ACE_WIN32 +#ifdef _WIN32 case ACE_Configuration::INVALID: - break; + break; // JDO added break. Otherwise INVALID is processed + // like BINARY. If that's correct, please remove the + // break and these comments #endif case ACE_Configuration::BINARY: { @@ -385,23 +315,19 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio { line += ACE_TEXT (","); } - ACE_OS::snprintf (bin_value, 3, ACE_TEXT ("%02x"), *ptr); + ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr); line += bin_value; --binary_length; ++ptr; } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(binary_data); -#else delete [] (char*) binary_data; -#endif /* ACE_HAS_ALLOC_HOOKS */ break; } default: return -3; } line += ACE_TEXT ("\n"); - if (ACE_WRITE_STRING (line.fast_rep (), out) < 0) + if (ACE_OS::fputs (line.fast_rep (), out) < 0) return -4; ++index; } @@ -614,7 +540,7 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, ACE_TString header = ACE_TEXT ("["); header += path; header += ACE_TEXT ("]\n"); - if (ACE_WRITE_STRING (header.fast_rep (), out) < 0) + if (ACE_OS::fputs (header.fast_rep (), out) < 0) return -1; // Write out each value int index = 0; @@ -636,7 +562,7 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, u_int value; if (config_.get_integer_value (section, name.fast_rep (), value)) return -2; - ACE_OS::snprintf (int_value, 32, ACE_TEXT ("%08x"), value); + ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value); line += int_value; break; } @@ -671,17 +597,13 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, { line += ACE_TEXT (","); } - ACE_OS::snprintf (bin_value, 3, ACE_TEXT ("%02x"), *ptr); + ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr); line += bin_value; --binary_length; ++ptr; } line += ACE_TEXT ("\""); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(binary_data); -#else delete [] (char *) binary_data; -#endif /* ACE_HAS_ALLOC_HOOKS */ break; } default: @@ -690,7 +612,7 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, }// end switch on type line += ACE_TEXT ("\n"); - if (ACE_WRITE_STRING (line.fast_rep (), out) < 0) + if (ACE_OS::fputs (line.fast_rep (), out) < 0) return -4; ++index; }// end while enumerating values diff --git a/dep/acelite/ace/Configuration_Import_Export.h b/dep/acelite/ace/Configuration_Import_Export.h index f40019ecc..9995d095d 100644 --- a/dep/acelite/ace/Configuration_Import_Export.h +++ b/dep/acelite/ace/Configuration_Import_Export.h @@ -4,6 +4,8 @@ /** * @file Configuration_Import_Export.h * + * $Id: Configuration_Import_Export.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Jerry D. Odenwelder Jr. * Chris Hafey * @@ -40,6 +42,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * This class provides base functionality for configuration objects * that are persisted in files. It takes an ACE_Configuration * object that it populates with the data read. + * */ class ACE_Export ACE_Config_ImpExp_Base { @@ -86,6 +89,7 @@ private: * @todo * - Add dynamic buffer when importing. currently it will not allow * importing of values greater than a fixed amount (4096 bytes) + * */ class ACE_Export ACE_Registry_ImpExp : public ACE_Config_ImpExp_Base { diff --git a/dep/acelite/ace/Connection_Recycling_Strategy.cpp b/dep/acelite/ace/Connection_Recycling_Strategy.cpp index b5619a674..1dd20479e 100644 --- a/dep/acelite/ace/Connection_Recycling_Strategy.cpp +++ b/dep/acelite/ace/Connection_Recycling_Strategy.cpp @@ -1,3 +1,5 @@ +// $Id: Connection_Recycling_Strategy.cpp 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/Connection_Recycling_Strategy.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Connection_Recycling_Strategy.h b/dep/acelite/ace/Connection_Recycling_Strategy.h index 763c7e548..bce8cf1c2 100644 --- a/dep/acelite/ace/Connection_Recycling_Strategy.h +++ b/dep/acelite/ace/Connection_Recycling_Strategy.h @@ -4,6 +4,8 @@ /** * @file Connection_Recycling_Strategy.h * + * $Id: Connection_Recycling_Strategy.h 97246 2013-08-07 07:10:20Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= @@ -53,6 +55,7 @@ public: /// Cleanup hint and reset @a act_holder to zero if @a act_holder != 0. virtual int cleanup_hint (const void *recycling_act, void **act_holder = 0) = 0; + }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Connector.cpp b/dep/acelite/ace/Connector.cpp index 1303ab9ca..15179c866 100644 --- a/dep/acelite/ace/Connector.cpp +++ b/dep/acelite/ace/Connector.cpp @@ -1,3 +1,5 @@ +// $Id: Connector.cpp 97769 2014-06-05 06:37:53Z johnnyw $ + #ifndef ACE_CONNECTOR_CPP #define ACE_CONNECTOR_CPP @@ -13,9 +15,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc (ACE_NonBlocking_Connect_Handler) -ACE_ALLOC_HOOK_DEFINE_Tco (ACE_Connector) -ACE_ALLOC_HOOK_DEFINE_Tco (ACE_Strategy_Connector) +ACE_ALLOC_HOOK_DEFINE(ACE_Connector) template ACE_NonBlocking_Connect_Handler::ACE_NonBlocking_Connect_Handler (ACE_Connector_Base &connector, @@ -771,10 +771,10 @@ ACE_Connector::info (ACE_TCHAR **strp, size_t lengt ACE_TRACE ("ACE_Connector::info"); ACE_TCHAR buf[BUFSIZ]; - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%s\t %s"), - ACE_TEXT ("ACE_Connector"), - ACE_TEXT ("# connector factory\n")); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s"), + ACE_TEXT ("ACE_Connector"), + ACE_TEXT ("# connector factory\n")); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) return -1; diff --git a/dep/acelite/ace/Connector.h b/dep/acelite/ace/Connector.h index 2217fe97b..5a24daa01 100644 --- a/dep/acelite/ace/Connector.h +++ b/dep/acelite/ace/Connector.h @@ -4,7 +4,9 @@ /** * @file Connector.h * - * @author Douglas C. Schmidt + * $Id: Connector.h 97180 2013-05-29 16:51:19Z schmidt $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -59,6 +61,7 @@ template class ACE_NonBlocking_Connect_Handler : public ACE_Event_Handler { public: + /// Constructor. ACE_NonBlocking_Connect_Handler (ACE_Connector_Base &connector, SVC_HANDLER *, @@ -69,7 +72,7 @@ public: /// Close up and return underlying SVC_HANDLER through @c sh. /** - * If the return value is true the close was performed successfully, + * If the return value is true the close was performed succesfully, * implying that this object was removed from the reactor and thereby * (by means of reference counting decremented to 0) deleted. * If the return value is false, the close was not successful. @@ -123,6 +126,7 @@ public: ACE_ALLOC_HOOK_DECLARE; private: + /// Connector base. ACE_Connector_Base &connector_; @@ -477,9 +481,6 @@ public: virtual ACE_Connect_Strategy *connect_strategy (void) const; virtual ACE_Concurrency_Strategy *concurrency_strategy (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: // = The following three methods define the 's strategies // for creating, connecting, and activating SVC_HANDLER's, diff --git a/dep/acelite/ace/Containers.cpp b/dep/acelite/ace/Containers.cpp index 3e86f3afb..5a8ef29f9 100644 --- a/dep/acelite/ace/Containers.cpp +++ b/dep/acelite/ace/Containers.cpp @@ -1,7 +1,8 @@ +// $Id: Containers.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Containers.h" #if !defined (__ACE_INLINE__) #include "ace/Containers.inl" #endif /* __ACE_INLINE__ */ -ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node) diff --git a/dep/acelite/ace/Containers.h b/dep/acelite/ace/Containers.h index 4d671ca98..ecff8e368 100644 --- a/dep/acelite/ace/Containers.h +++ b/dep/acelite/ace/Containers.h @@ -4,7 +4,9 @@ /** * @file Containers.h * - * @author Douglas C. Schmidt + * $Id: Containers.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Containers.inl b/dep/acelite/ace/Containers.inl index cd7507d40..8094672a8 100644 --- a/dep/acelite/ace/Containers.inl +++ b/dep/acelite/ace/Containers.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Containers.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Containers_T.cpp b/dep/acelite/ace/Containers_T.cpp index 4fa39569b..8f0621e03 100644 --- a/dep/acelite/ace/Containers_T.cpp +++ b/dep/acelite/ace/Containers_T.cpp @@ -1,3 +1,5 @@ +// $Id: Containers_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_CONTAINERS_T_CPP #define ACE_CONTAINERS_T_CPP @@ -17,7 +19,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Bounded_Stack) +ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Stack) template void ACE_Bounded_Stack::dump (void) const @@ -81,7 +83,7 @@ ACE_Bounded_Stack::~ACE_Bounded_Stack (void) // ---------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Stack) +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Stack) template void ACE_Fixed_Stack::dump (void) const @@ -131,7 +133,7 @@ ACE_Fixed_Stack::~ACE_Fixed_Stack (void) //---------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Unbounded_Stack) +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Stack) template void ACE_Unbounded_Stack::dump (void) const @@ -337,7 +339,7 @@ ACE_Unbounded_Stack::remove (const T &item) } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List_Iterator_Base) +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator_Base) template ACE_Double_Linked_List_Iterator_Base::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List &dll) @@ -446,7 +448,7 @@ ACE_Double_Linked_List_Iterator_Base::dump_i (void) const } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator) template ACE_Double_Linked_List_Iterator::ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List &dll) @@ -551,7 +553,7 @@ ACE_Double_Linked_List_Iterator::operator-- (int) //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List_Reverse_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Reverse_Iterator) template ACE_Double_Linked_List_Reverse_Iterator::ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List &dll) @@ -657,7 +659,7 @@ ACE_Double_Linked_List_Reverse_Iterator::operator-- (int) } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List) +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List) template ACE_Double_Linked_List:: ACE_Double_Linked_List (ACE_Allocator *alloc) @@ -872,7 +874,7 @@ ACE_Double_Linked_List::remove_element (T *item) } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set) +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set) template size_t ACE_Fixed_Set::size (void) const @@ -1011,7 +1013,7 @@ ACE_Fixed_Set::remove (const T &item) } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set_Iterator_Base) +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator_Base) template void ACE_Fixed_Set_Iterator_Base::dump_i (void) const @@ -1092,7 +1094,7 @@ ACE_Fixed_Set_Iterator_Base::next_i (T *&item) } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator) template void ACE_Fixed_Set_Iterator::dump (void) const @@ -1146,7 +1148,7 @@ ACE_Fixed_Set_Iterator::operator* (void) } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set_Const_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Const_Iterator) template void ACE_Fixed_Set_Const_Iterator::dump (void) const @@ -1185,7 +1187,7 @@ ACE_Fixed_Set_Const_Iterator::operator* (void) const } //-------------------------------------------------- -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Bounded_Set) +ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set) template void ACE_Bounded_Set::dump (void) const @@ -1349,7 +1351,7 @@ ACE_Bounded_Set::remove (const T &item) return -1; } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Bounded_Set_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set_Iterator) template void ACE_Bounded_Set_Iterator::dump (void) const @@ -1413,7 +1415,7 @@ ACE_Bounded_Set_Iterator::next (T *&item) return 0; } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_DNode) +ACE_ALLOC_HOOK_DEFINE(ACE_DNode) template ACE_DNode::ACE_DNode (const T &i, ACE_DNode *n, ACE_DNode *p) @@ -1482,7 +1484,8 @@ ACE_Unbounded_Stack_Iterator::next (T *&item) } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Ordered_MultiSet) +ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet) + template ACE_Ordered_MultiSet::ACE_Ordered_MultiSet (ACE_Allocator *alloc) @@ -1789,7 +1792,7 @@ ACE_Ordered_MultiSet::delete_nodes (void) this->cur_size_ = 0; } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Ordered_MultiSet_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet_Iterator) template ACE_Ordered_MultiSet_Iterator::ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet &s) @@ -1825,6 +1828,8 @@ ACE_Ordered_MultiSet_Iterator::operator* (void) return *retv; } +ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node) + template T * ACE_DLList::insert_tail (T *new_item) { diff --git a/dep/acelite/ace/Containers_T.h b/dep/acelite/ace/Containers_T.h index 2220acc3b..6e6c5bd34 100644 --- a/dep/acelite/ace/Containers_T.h +++ b/dep/acelite/ace/Containers_T.h @@ -4,7 +4,9 @@ /** * @file Containers_T.h * - * @author Douglas C. Schmidt + * $Id: Containers_T.h 91995 2010-09-24 12:45:24Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -70,6 +72,7 @@ class ACE_Allocator; * -# Default constructor * -# Copy constructor * -# operator= + * */ template class ACE_Bounded_Stack @@ -200,6 +203,7 @@ private: * -# Default constructor * -# Copy constructor * -# operator= + * */ template class ACE_Fixed_Stack @@ -314,9 +318,6 @@ public: /// This isn't necessary, but it keeps some compilers happy. ~ACE_DNode (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: // = Initialization methods @@ -367,6 +368,7 @@ private: * -# Default constructor * -# Copy constructor * -# operator= + * */ template class ACE_Unbounded_Stack @@ -815,6 +817,7 @@ public: * -# Default constructor * -# Copy constructor * -# operator= + * */ template class ACE_Double_Linked_List @@ -963,7 +966,7 @@ protected: /** * Insert a @a new_item into the list. It will be added before * or after @a old_item. Default is to insert the new item *after* - * {head_}. Return 0 if succeed, -1 if error occurred. + * {head_}. Return 0 if succeed, -1 if error occured. */ int insert_element (T *new_item, int before = 0, @@ -1393,6 +1396,7 @@ public: * -# Copy constructor * -# operator= * -# operator== + * */ template class ACE_Fixed_Set @@ -1585,6 +1589,7 @@ private: * -# Copy constructor * -# operator= * -# operator== + * */ template class ACE_Bounded_Set @@ -1781,6 +1786,7 @@ private: * does not impose any restriction on how that ordering operator is * implemented. The set is implemented as a linked list. * + * * Requirements and Performance Characteristics * - Internal Structure * Double linked list @@ -1804,6 +1810,8 @@ private: * -# operator= * -# operator== * -# operator< + * + * */ template class ACE_Ordered_MultiSet diff --git a/dep/acelite/ace/Containers_T.inl b/dep/acelite/ace/Containers_T.inl index adc0f42cd..912c9df8b 100644 --- a/dep/acelite/ace/Containers_T.inl +++ b/dep/acelite/ace/Containers_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Containers_T.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE int diff --git a/dep/acelite/ace/Copy_Disabled.cpp b/dep/acelite/ace/Copy_Disabled.cpp index 59c6ba7af..f3fdfb71b 100644 --- a/dep/acelite/ace/Copy_Disabled.cpp +++ b/dep/acelite/ace/Copy_Disabled.cpp @@ -1,6 +1,8 @@ /** * @file Copy_Disabled.cpp * + * $Id: Copy_Disabled.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + * * @author Carlos O'Ryan */ diff --git a/dep/acelite/ace/Copy_Disabled.h b/dep/acelite/ace/Copy_Disabled.h index 374227e8a..f7b40e264 100644 --- a/dep/acelite/ace/Copy_Disabled.h +++ b/dep/acelite/ace/Copy_Disabled.h @@ -4,6 +4,8 @@ /** * @file Copy_Disabled.h * + * $Id: Copy_Disabled.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Carlos O'Ryan */ //=========================================================================== @@ -42,6 +44,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * { * // code here * }; + * */ class ACE_Export ACE_Copy_Disabled { diff --git a/dep/acelite/ace/Countdown_Time.h b/dep/acelite/ace/Countdown_Time.h index b6966d68f..b63228d60 100644 --- a/dep/acelite/ace/Countdown_Time.h +++ b/dep/acelite/ace/Countdown_Time.h @@ -4,7 +4,9 @@ /** * @file Countdown_Time.h * - * @author Douglas C. Schmidt + * $Id: Countdown_Time.h 95332 2011-12-15 11:09:41Z mcorino $ + * + * @author Douglas C. Schmidt * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Countdown_Time_T.cpp b/dep/acelite/ace/Countdown_Time_T.cpp index 8a38c4de1..fdac8216d 100644 --- a/dep/acelite/ace/Countdown_Time_T.cpp +++ b/dep/acelite/ace/Countdown_Time_T.cpp @@ -1,3 +1,5 @@ +// $Id: Countdown_Time_T.cpp 97130 2013-05-13 17:36:26Z mesnier_p $ + #ifndef ACE_COUNTDOWN_TIME_T_CPP #define ACE_COUNTDOWN_TIME_T_CPP diff --git a/dep/acelite/ace/Countdown_Time_T.h b/dep/acelite/ace/Countdown_Time_T.h index 12aab657b..cbcab9f4b 100644 --- a/dep/acelite/ace/Countdown_Time_T.h +++ b/dep/acelite/ace/Countdown_Time_T.h @@ -4,7 +4,9 @@ /** * @file Countdown_Time_T.h * - * @author Douglas C. Schmidt + * $Id: Countdown_Time_T.h 97130 2013-05-13 17:36:26Z mesnier_p $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Countdown_Time_T.inl b/dep/acelite/ace/Countdown_Time_T.inl index 319729d9c..3d6e7a2f7 100644 --- a/dep/acelite/ace/Countdown_Time_T.inl +++ b/dep/acelite/ace/Countdown_Time_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Countdown_Time_T.inl 95332 2011-12-15 11:09:41Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE bool diff --git a/dep/acelite/ace/DEV.cpp b/dep/acelite/ace/DEV.cpp index 08a7e581f..c95bb7f90 100644 --- a/dep/acelite/ace/DEV.cpp +++ b/dep/acelite/ace/DEV.cpp @@ -1,11 +1,9 @@ +// $Id: DEV.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/DEV.h" #include "ace/OS_NS_unistd.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/DEV.inl" #endif /* __ACE_INLINE__ */ diff --git a/dep/acelite/ace/DEV.h b/dep/acelite/ace/DEV.h index c74c23429..d8ce8628e 100644 --- a/dep/acelite/ace/DEV.h +++ b/dep/acelite/ace/DEV.h @@ -4,6 +4,8 @@ /** * @file DEV.h * + * $Id: DEV.h 91685 2010-09-09 09:35:14Z johnnyw $ + * * @author Gerhard Lenzer */ //============================================================================= diff --git a/dep/acelite/ace/DEV.inl b/dep/acelite/ace/DEV.inl index ee0bb7838..4d97a73d8 100644 --- a/dep/acelite/ace/DEV.inl +++ b/dep/acelite/ace/DEV.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: DEV.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/DEV_Addr.cpp b/dep/acelite/ace/DEV_Addr.cpp index c5c2cc3bc..037384388 100644 --- a/dep/acelite/ace/DEV_Addr.cpp +++ b/dep/acelite/ace/DEV_Addr.cpp @@ -1,3 +1,5 @@ +// $Id: DEV_Addr.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/DEV_Addr.h" #if !defined (__ACE_INLINE__) #include "ace/DEV_Addr.inl" @@ -5,9 +7,6 @@ #include "ace/Log_Category.h" #include "ace/OS_NS_string.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/DEV_Addr.h b/dep/acelite/ace/DEV_Addr.h index 3bbbad057..49ec5023a 100644 --- a/dep/acelite/ace/DEV_Addr.h +++ b/dep/acelite/ace/DEV_Addr.h @@ -4,6 +4,8 @@ /** * @file DEV_Addr.h * + * $Id: DEV_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Gerhard Lenzer and Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/DEV_Addr.inl b/dep/acelite/ace/DEV_Addr.inl index 3025745f2..5c1da68d7 100644 --- a/dep/acelite/ace/DEV_Addr.inl +++ b/dep/acelite/ace/DEV_Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: DEV_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_string.h" #include "ace/Global_Macros.h" #include "ace/os_include/sys/os_socket.h" diff --git a/dep/acelite/ace/DEV_Connector.cpp b/dep/acelite/ace/DEV_Connector.cpp index 159e5ecee..6251dc670 100644 --- a/dep/acelite/ace/DEV_Connector.cpp +++ b/dep/acelite/ace/DEV_Connector.cpp @@ -1,9 +1,8 @@ +// $Id: DEV_Connector.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/DEV_Connector.h" #include "ace/Handle_Ops.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/DEV_Connector.inl" diff --git a/dep/acelite/ace/DEV_Connector.h b/dep/acelite/ace/DEV_Connector.h index 5c889301b..a2dbc466b 100644 --- a/dep/acelite/ace/DEV_Connector.h +++ b/dep/acelite/ace/DEV_Connector.h @@ -4,7 +4,9 @@ /** * @file DEV_Connector.h * - * @author Gerhard Lenzer and Douglas C. Schmidt + * $Id: DEV_Connector.h 96985 2013-04-11 15:50:32Z huangh $ + * + * @author Gerhard Lenzer and Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/DEV_Connector.inl b/dep/acelite/ace/DEV_Connector.inl index b92b4d2a5..c53421f3b 100644 --- a/dep/acelite/ace/DEV_Connector.inl +++ b/dep/acelite/ace/DEV_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: DEV_Connector.inl 96985 2013-04-11 15:50:32Z huangh $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Creates a Local ACE_DEV. diff --git a/dep/acelite/ace/DEV_IO.cpp b/dep/acelite/ace/DEV_IO.cpp index f1dcda429..59b76bd26 100644 --- a/dep/acelite/ace/DEV_IO.cpp +++ b/dep/acelite/ace/DEV_IO.cpp @@ -1,8 +1,7 @@ +// $Id: DEV_IO.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/DEV_IO.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/DEV_IO.inl" @@ -65,26 +64,15 @@ ssize_t ACE_DEV_IO::send (size_t n, ...) const { ACE_TRACE ("ACE_DEV_IO::send"); -#ifdef ACE_LACKS_VA_FUNCTIONS - ACE_UNUSED_ARG (n); - ACE_NOTSUP_RETURN (-1); -#else va_list argp; int total_tuples = static_cast (n / 2); iovec *iovp; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -97,15 +85,10 @@ ACE_DEV_IO::send (size_t n, ...) const ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; -#endif // ACE_LACKS_VA_FUNCTIONS } // This is basically an interface to ACE_OS::readv, that doesn't use the @@ -118,26 +101,15 @@ ssize_t ACE_DEV_IO::recv (size_t n, ...) const { ACE_TRACE ("ACE_DEV_IO::recv"); -#ifdef ACE_LACKS_VA_FUNCTIONS - ACE_UNUSED_ARG (n); - ACE_NOTSUP_RETURN (-1); -#else va_list argp; int total_tuples = static_cast (n / 2); iovec *iovp; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -150,15 +122,10 @@ ACE_DEV_IO::recv (size_t n, ...) const ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; -#endif // ACE_LACKS_VA_FUNCTIONS } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/DEV_IO.h b/dep/acelite/ace/DEV_IO.h index 9a97c011f..3b1c3deb3 100644 --- a/dep/acelite/ace/DEV_IO.h +++ b/dep/acelite/ace/DEV_IO.h @@ -4,6 +4,8 @@ /** * @file DEV_IO.h * + * $Id: DEV_IO.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Gerhard Lenzer * @author Douglas C. Schmidt */ diff --git a/dep/acelite/ace/DEV_IO.inl b/dep/acelite/ace/DEV_IO.inl index 45e4a0970..796d24e11 100644 --- a/dep/acelite/ace/DEV_IO.inl +++ b/dep/acelite/ace/DEV_IO.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: DEV_IO.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_sys_uio.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_Memory.h" diff --git a/dep/acelite/ace/DLL.cpp b/dep/acelite/ace/DLL.cpp index 4fed8ba8d..c8b31e305 100644 --- a/dep/acelite/ace/DLL.cpp +++ b/dep/acelite/ace/DLL.cpp @@ -1,3 +1,5 @@ +// $Id: DLL.cpp 97888 2014-09-11 10:29:17Z mcorino $ + #include "ace/DLL.h" #include "ace/Log_Category.h" @@ -101,11 +103,7 @@ ACE_DLL::~ACE_DLL (void) // occur if full ACE_DLL initialization is interrupted due to errors // (e.g. attempting to open a DSO/DLL that does not exist). Make // sure this->dll_name_ is deallocated. -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->dll_name_); -#else delete [] this->dll_name_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } // This method opens the library based on the mode specified using the @@ -225,11 +223,7 @@ ACE_DLL::close (void) // Even if close_dll() failed, go ahead and cleanup. this->dll_handle_ = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->dll_name_); -#else delete [] this->dll_name_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->dll_name_ = 0; this->close_handle_on_destruction_ = false; diff --git a/dep/acelite/ace/DLL.h b/dep/acelite/ace/DLL.h index a5d8dae69..57da5d324 100644 --- a/dep/acelite/ace/DLL.h +++ b/dep/acelite/ace/DLL.h @@ -4,6 +4,8 @@ /** * @file DLL.h * + * $Id: DLL.h 97888 2014-09-11 10:29:17Z mcorino $ + * * @author Kirthika Parameswaran */ //============================================================================= @@ -154,7 +156,7 @@ public: */ void *symbol (const ACE_TCHAR *symbol_name, int ignore_errors = 0); - /// Returns a pointer to a string explaining that an error occurred. You + /// Returns a pointer to a string explaining that an error occured. You /// will need to consult the error log for the actual error string /// returned by the OS. ACE_TCHAR *error (void) const; diff --git a/dep/acelite/ace/DLL_Manager.cpp b/dep/acelite/ace/DLL_Manager.cpp index 68dda37c0..3c415052f 100644 --- a/dep/acelite/ace/DLL_Manager.cpp +++ b/dep/acelite/ace/DLL_Manager.cpp @@ -1,6 +1,7 @@ +// $Id: DLL_Manager.cpp 97888 2014-09-11 10:29:17Z mcorino $ + #include "ace/DLL_Manager.h" -#include "ace/Auto_Ptr.h" #include "ace/Log_Category.h" #include "ace/ACE.h" #include "ace/Framework_Component.h" @@ -29,15 +30,9 @@ ACE_DLL_Handle::~ACE_DLL_Handle (void) { ACE_TRACE ("ACE_DLL_Handle::~ACE_DLL_Handle"); this->close (1); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->dll_name_); -#else delete[] this->dll_name_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } -ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Handle) - const ACE_TCHAR * ACE_DLL_Handle::dll_name (void) const { @@ -117,54 +112,123 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, this->get_dll_names (dll_name, dll_names); #endif + ACE_Array_Iterator name_iter (dll_names); ACE_TString *name = 0; - for (ACE_Array_Iterator name_iter (dll_names); - name_iter.next (name); name_iter.advance ()) + while (name_iter.next (name)) { - if (this->open_i (name->c_str (), open_mode)) + // The ACE_SHLIB_HANDLE object is obtained. + this->handle_ = ACE_OS::dlopen (name->c_str (), + open_mode); + + if (ACE::debug ()) + { + ACE_TString err; + ACELIB_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), + name->c_str (), + open_mode, + ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) + ? ACE_TEXT ("succeeded") + : ACE_TEXT ("failed")), + this->error (err).c_str())); + } + + if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one? break; - this->log_error (name->c_str (), errors); + // If errno is ENOENT we just skip over this one, + // anything else - like an undefined symbol, for + // instance must be flagged here or the next error will + // mask it. + // @TODO: If we've found our DLL _and_ it's + // broken, should we continue at all? + if ((errno != 0) && (errno != ENOENT) && (errors || ACE::debug ())) + { + ACE_TString errtmp; + if (errors) + { + errors->push (this->error (errtmp)); + } + + if (ACE::debug ()) + { + if (!errors) + this->error (errtmp); + ACELIB_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\'%s\') failed, errno=") + ACE_TEXT ("%d: <%s>\n"), + name->c_str (), + ACE_ERRNO_GET, + errtmp.c_str ())); + } + } #if defined (AIX) -# define SHR_O ACE_TEXT("(shr.o)") -# define SHR_O_LEN (sizeof (SHR_O) / sizeof(ACE_TCHAR) - 1) // AIX often puts the shared library file (most often named // shr.o) inside an archive library. If this is an archive // library name, then try appending [shr.o] and retry. if (ACE_TString::npos != name->strstr (ACE_TEXT (".a"))) { ACE_TCHAR aix_pathname[MAXPATHLEN + 1]; - if (name->length () + SHR_O_LEN <= MAXPATHLEN) + ACE_OS::strncpy (aix_pathname, + name->c_str (), + name->length ()); + aix_pathname[name->length ()] = '\0'; + ACE_OS::strcat (aix_pathname, ACE_TEXT ("(shr.o)")); + open_mode |= RTLD_MEMBER; + + if (ACE::debug ()) { - ACE_OS::strcpy (aix_pathname, name->c_str()); - ACE_OS::strcat (aix_pathname, SHR_O); + ACE_TString err; + ACELIB_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), + aix_pathname, + open_mode, + (this->handle_ != ACE_SHLIB_INVALID_HANDLE + ? ACE_TEXT ("succeeded") + : ACE_TEXT ("failed")), + this->error(err).c_str())); } - else + + this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode); + if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) + break; + + // If errno is ENOENT we just skip over this one, anything + // else - like an undefined symbol, for instance + // must be flagged here or the next error will mask it. + // + // @TODO: If we've found our DLL _and_ it's broken, + // should we continue at all? + if ((errno != 0) && (errno != ENOENT) && (errors || ACE::debug ())) { + ACE_TString errtmp; if (errors) { - errors->push ("path is too long"); + errors->push (this->error (errtmp)); } if (ACE::debug ()) { + if (!errors) + this->error (errtmp); ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open: ") - ACE_TEXT ("('%s(shr.o)') is too long\n"), - name->c_str())); + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\'%s\') failed, errno=") + ACE_TEXT ("%d: <%s>\n"), + name->c_str (), + ACE_ERRNO_GET, + errtmp.c_str ())); } - - return -1; } - open_mode |= RTLD_MEMBER; - if (this->open_i (aix_pathname, open_mode)) - break; - - this->log_error (aix_pathname, errors); } #endif /* AIX */ + + name_iter.advance (); } if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) @@ -471,62 +535,6 @@ ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, return; } -bool -ACE_DLL_Handle::open_i (const ACE_TCHAR *dll_name, int open_mode) -{ - // The ACE_SHLIB_HANDLE object is obtained. - this->handle_ = ACE_OS::dlopen (dll_name, open_mode); - - if (ACE::debug ()) - { - ACE_TString err; - ACELIB_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") - ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), - dll_name, - open_mode, - ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) - ? ACE_TEXT ("succeeded") - : ACE_TEXT ("failed")), - this->error (err).c_str())); - } - - return this->handle_ != ACE_SHLIB_INVALID_HANDLE; -} - -void -ACE_DLL_Handle::log_error (const ACE_TCHAR *dll_name, ERROR_STACK *errors) -{ - // If errno is ENOENT we just skip over this one, anything - // else - like an undefined symbol, for instance - // must be flagged here or the next error will mask it. - // - // @TODO: If we've found our DLL _and_ it's broken, - // should we continue at all? - if (errno != ENOENT && (errors || ACE::debug ())) - { - ACE_TString errtmp; - if (errors) - { - errors->push (this->error (errtmp)); - } - - if (ACE::debug ()) - { - if (!errors) - this->error (errtmp); - - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") - ACE_TEXT ("(\'%s\') failed, errno=") - ACE_TEXT ("%d: <%s>\n"), - dll_name, - ACE_ERRNO_GET, - errtmp.c_str ())); - } - } -} - /******************************************************************/ // Pointer to the Singleton instance. @@ -590,8 +598,6 @@ ACE_DLL_Manager::~ACE_DLL_Manager (void) ACE_TEXT ("properly.\n"))); } -ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Manager) - ACE_DLL_Handle * ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, int open_mode, @@ -707,15 +713,9 @@ ACE_DLL_Manager::open (int size) ACE_DLL_Handle **temp = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (temp, - static_cast (ACE_Allocator::instance()->malloc(sizeof (ACE_DLL_Handle*) * size)), - -1); -#else ACE_NEW_RETURN (temp, ACE_DLL_Handle *[size], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->handle_vector_ = temp; this->total_size_ = size; @@ -744,12 +744,7 @@ ACE_DLL_Manager::close (void) } } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->handle_vector_); -#else delete [] this->handle_vector_; -#endif /* ACE_HAS_ALLOC_HOOKS */ - this->handle_vector_ = 0; this->current_size_ = 0; } diff --git a/dep/acelite/ace/DLL_Manager.h b/dep/acelite/ace/DLL_Manager.h index 9fea80a30..3ff163d9a 100644 --- a/dep/acelite/ace/DLL_Manager.h +++ b/dep/acelite/ace/DLL_Manager.h @@ -4,6 +4,8 @@ /** * @file DLL_Manager.h * + * $Id: DLL_Manager.h 97888 2014-09-11 10:29:17Z mcorino $ + * * @author Don Hinton */ //============================================================================= @@ -18,6 +20,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Auto_Ptr.h" #include "ace/Containers_T.h" #include "ace/SString.h" #include "ace/os_include/os_dlfcn.h" @@ -49,6 +52,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * Most of this class came from the original ACE_DLL class. ACE_DLL * is now just an interface that passed all it's calls either directly * or via ACE_DLL_Manager to this class for execution. + * */ class ACE_Export ACE_DLL_Handle { @@ -138,8 +142,6 @@ public: */ ACE_SHLIB_HANDLE get_handle (bool become_owner = false); - ACE_ALLOC_HOOK_DECLARE; - private: /// Returns a string explaining why or @@ -154,31 +156,6 @@ private: void get_dll_names (const ACE_TCHAR *dll_name, ACE_Array &try_names); - /** - * This method opens and dynamically links a library/DLL. - * @param dll_name The filename or path of the DLL to load. - * @param open_mode Flags to alter the actions taken when loading the DLL. - * The possible values are: - * @li @c RTLD_LAZY (this the default): loads identifier symbols but - * not the symbols for functions, which are loaded dynamically - * on demand. - * @li @c RTLD_NOW: performs all necessary relocations when - * @a dll_name is first loaded - * @li @c RTLD_GLOBAL: makes symbols available for relocation - * processing of any other DLLs. - * @retval false On failure - * @retval true On success. - */ - bool open_i (const ACE_TCHAR *dll_name, int open_mode); - - /** - * This method logs error of opening the DLL. - * @param dll_name The filename or path of the DLL to load. - * @param errors Optional address of an error stack to collect any errors - * encountered. - */ - void log_error (const ACE_TCHAR *dll_name, ERROR_STACK *errors); - /// Disallow copying and assignment since we don't handle them. ACE_DLL_Handle (const ACE_DLL_Handle &); void operator= (const ACE_DLL_Handle &); @@ -240,6 +217,7 @@ class ACE_Framework_Repository; * * ACE_DLL_UNLOAD_POLICY_DEFAULT - Default policy allows dlls to control * their own destinies, but will unload those that don't make a choice eagerly. + * */ class ACE_Export ACE_DLL_Manager { @@ -273,8 +251,6 @@ public: /// refcounts. void unload_policy (u_long unload_policy); - ACE_ALLOC_HOOK_DECLARE; - protected: /// Default constructor. diff --git a/dep/acelite/ace/Date_Time.cpp b/dep/acelite/ace/Date_Time.cpp index 8d84df812..2cc6b69f3 100644 --- a/dep/acelite/ace/Date_Time.cpp +++ b/dep/acelite/ace/Date_Time.cpp @@ -1,4 +1,6 @@ // Date_Time.cpp +// $Id: Date_Time.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Date_Time.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Date_Time.h b/dep/acelite/ace/Date_Time.h index aba5d0448..a15d435ee 100644 --- a/dep/acelite/ace/Date_Time.h +++ b/dep/acelite/ace/Date_Time.h @@ -4,7 +4,10 @@ /** * @file Date_Time.h * + * $Id: Date_Time.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Tim Harrison (harrison@cs.wustl.edu) (and he's darn proud of this ;-)) + * */ //========================================================================== diff --git a/dep/acelite/ace/Date_Time.inl b/dep/acelite/ace/Date_Time.inl index 196f572be..d34807d83 100644 --- a/dep/acelite/ace/Date_Time.inl +++ b/dep/acelite/ace/Date_Time.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Date_Time.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Global_Macros.h" #include "ace/Time_Value.h" #include "ace/OS_NS_sys_time.h" diff --git a/dep/acelite/ace/Default_Constants.h b/dep/acelite/ace/Default_Constants.h index 6a8d4acc8..ba455d429 100644 --- a/dep/acelite/ace/Default_Constants.h +++ b/dep/acelite/ace/Default_Constants.h @@ -4,7 +4,9 @@ /** * @file Default_Constants.h * - * @author Douglas C. Schmidt + * $Id: Default_Constants.h 95517 2012-01-30 10:05:01Z sma $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -76,11 +78,11 @@ # endif /* ACE_DEFAULT_TIMEOUT */ # if !defined (ACE_DEFAULT_BACKLOG) -# define ACE_DEFAULT_BACKLOG 5 +# define ACE_DEFAULT_BACKLOG 128 # endif /* ACE_DEFAULT_BACKLOG */ # if !defined (ACE_DEFAULT_ASYNCH_BACKLOG) -# define ACE_DEFAULT_ASYNCH_BACKLOG 5 +# define ACE_DEFAULT_ASYNCH_BACKLOG 128 # endif /* ACE_DEFAULT_ASYNCH_BACKLOG */ # if !defined (ACE_DEFAULT_THREADS) diff --git a/dep/acelite/ace/Dev_Poll_Reactor.cpp b/dep/acelite/ace/Dev_Poll_Reactor.cpp index 4d85a7092..6432b3c5a 100644 --- a/dep/acelite/ace/Dev_Poll_Reactor.cpp +++ b/dep/acelite/ace/Dev_Poll_Reactor.cpp @@ -1,3 +1,5 @@ +// $Id: Dev_Poll_Reactor.cpp 97894 2014-09-16 18:11:56Z johnnyw $ + #include "ace/OS_NS_errno.h" #include "ace/Dev_Poll_Reactor.h" #include "ace/Signal.h" @@ -42,10 +44,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Dev_Poll_Reactor) -ACE_ALLOC_HOOK_DEFINE(ACE_Dev_Poll_Reactor::Event_Tuple) -ACE_ALLOC_HOOK_DEFINE(ACE_Dev_Poll_Reactor_Notify) - ACE_Dev_Poll_Reactor_Notify::ACE_Dev_Poll_Reactor_Notify (void) : dp_reactor_ (0) , notification_pipe_ () @@ -76,16 +74,10 @@ ACE_Dev_Poll_Reactor_Notify::open (ACE_Reactor_Impl *r, if (this->notification_pipe_.open () == -1) return -1; -#if defined (F_SETFD) && !defined (ACE_LACKS_FCNTL) +#if defined (F_SETFD) // close-on-exec - if (ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1) == -1) - { - return -1; - } - if (ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1) == -1) - { - return -1; - } + ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1); + ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1); #endif /* F_SETFD */ #if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) @@ -1330,22 +1322,7 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) if (info != 0 && info->event_handler == eh) { if (status < 0) - { - this->remove_handler_i (handle, disp_mask, grd); -#ifdef ACE_HAS_EVENT_POLL - // epoll-based effectively suspends handlers around the upcall. - // If the handler must be resumed, check to be sure it's the - // same handle/handler combination still. - if (reactor_resumes_eh) - { - info = this->handler_rep_.find (handle); - if (info != 0 && info->event_handler == eh) - { - this->resume_handler_i (handle); - } - } -#endif /* ACE_HAS_EVENT_POLL */ - } + this->remove_handler_i (handle, disp_mask, grd); } } // Scope close handles eh ref count decrement, if needed. diff --git a/dep/acelite/ace/Dev_Poll_Reactor.h b/dep/acelite/ace/Dev_Poll_Reactor.h index 37798db97..1909c2e13 100644 --- a/dep/acelite/ace/Dev_Poll_Reactor.h +++ b/dep/acelite/ace/Dev_Poll_Reactor.h @@ -4,6 +4,8 @@ /** * @file Dev_Poll_Reactor.h * + * $Id: Dev_Poll_Reactor.h 97130 2013-05-13 17:36:26Z mesnier_p $ + * * @c /dev/poll (or Linux @c sys_epoll) based Reactor implementation. * * @author Ossama Othman @@ -166,8 +168,6 @@ public: /// 0 if there were only wake-ups (no handlers to dispatch). int dequeue_one (ACE_Notification_Buffer &nb); - ACE_ALLOC_HOOK_DECLARE; - protected: /** @@ -292,8 +292,6 @@ class ACE_Export ACE_Dev_Poll_Reactor : public ACE_Reactor_Impl /// Flag to say whether or not this handle is registered with epoll. bool controlled; - - ACE_ALLOC_HOOK_DECLARE; }; @@ -756,7 +754,7 @@ public: * Set the maximum number of times that ACE_Reactor_Impl will * iterate and dispatch the ACE_Event_Handlers that are passed in * via the notify queue before breaking out of its - * ACE_Message_Queue::dequeue() loop. By default, this is set to + * loop. By default, this is set to * -1, which means "iterate until the queue is empty." Setting this * to a value like "1 or 2" will increase "fairness" (and thus * prevent starvation) at the expense of slightly higher dispatching @@ -768,7 +766,7 @@ public: * Get the maximum number of times that the ACE_Reactor_Impl will * iterate and dispatch the ACE_Event_Handlers that are passed in * via the notify queue before breaking out of its - * ACE_Message_Queue::dequeue() loop. + * loop. */ virtual int max_notify_iterations (void); diff --git a/dep/acelite/ace/Dev_Poll_Reactor.inl b/dep/acelite/ace/Dev_Poll_Reactor.inl index aedd57057..ca16759e8 100644 --- a/dep/acelite/ace/Dev_Poll_Reactor.inl +++ b/dep/acelite/ace/Dev_Poll_Reactor.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Dev_Poll_Reactor.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Log_Category.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Dirent.cpp b/dep/acelite/ace/Dirent.cpp index 5f8bd074d..df1290e1e 100644 --- a/dep/acelite/ace/Dirent.cpp +++ b/dep/acelite/ace/Dirent.cpp @@ -1,3 +1,5 @@ +// $Id: Dirent.cpp 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Dirent.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Dirent.h b/dep/acelite/ace/Dirent.h index af982db8f..7735fb1f2 100644 --- a/dep/acelite/ace/Dirent.h +++ b/dep/acelite/ace/Dirent.h @@ -4,10 +4,12 @@ /** * @file Dirent.h * + * $Id: Dirent.h 91064 2010-07-12 10:11:24Z johnnyw $ + * * Define a portable C++ interface to ACE_OS_Dirent directory-entry * manipulation. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Dirent.inl b/dep/acelite/ace/Dirent.inl index 3e420f1cc..9e276cf8c 100644 --- a/dep/acelite/ace/Dirent.inl +++ b/dep/acelite/ace/Dirent.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Dirent.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Log_Category.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Dirent_Selector.cpp b/dep/acelite/ace/Dirent_Selector.cpp index f16d1da68..c1f480061 100644 --- a/dep/acelite/ace/Dirent_Selector.cpp +++ b/dep/acelite/ace/Dirent_Selector.cpp @@ -1,3 +1,5 @@ +// $Id: Dirent_Selector.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Dirent_Selector.h" #if !defined (__ACE_INLINE__) @@ -7,10 +9,6 @@ #include "ace/OS_NS_dirent.h" #include "ace/OS_NS_stdlib.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Construction/Destruction @@ -44,24 +42,12 @@ ACE_Dirent_Selector::close (void) #if defined (ACE_LACKS_STRUCT_DIR) // Only the lacking-struct-dir emulation allocates this. Native // scandir includes d_name in the dirent struct itself. -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->namelist_[n_]->d_name); -#else ACE_OS::free (this->namelist_[n_]->d_name); -#endif /* ACE_HAS_ALLOC_HOOKS */ #endif -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->namelist_[n_]); -#else ACE_OS::free (this->namelist_[n_]); -#endif /* ACE_HAS_ALLOC_HOOKS */ } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->namelist_); -#else ACE_OS::free (this->namelist_); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->namelist_ = 0; return 0; } diff --git a/dep/acelite/ace/Dirent_Selector.h b/dep/acelite/ace/Dirent_Selector.h index 0de9dc085..20673c473 100644 --- a/dep/acelite/ace/Dirent_Selector.h +++ b/dep/acelite/ace/Dirent_Selector.h @@ -4,6 +4,8 @@ /** * @file Dirent_Selector.h * + * $Id: Dirent_Selector.h 80826 2008-03-04 14:51:23Z wotte $ + * * Define a portable C++ interface to the method. * * @author Rich Newman diff --git a/dep/acelite/ace/Dirent_Selector.inl b/dep/acelite/ace/Dirent_Selector.inl index 27651569b..15f804704 100644 --- a/dep/acelite/ace/Dirent_Selector.inl +++ b/dep/acelite/ace/Dirent_Selector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Dirent_Selector.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/Dump.cpp b/dep/acelite/ace/Dump.cpp index 576417e81..649755a8b 100644 --- a/dep/acelite/ace/Dump.cpp +++ b/dep/acelite/ace/Dump.cpp @@ -1,12 +1,12 @@ +// $Id: Dump.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Dump.h" #include "ace/Guard_T.h" #include "ace/Thread_Mutex.h" #include "ace/Object_Manager.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -54,8 +54,6 @@ ACE_ODB::ACE_ODB (void) ACE_TRACE ("ACE_ODB::ACE_ODB"); } -ACE_ALLOC_HOOK_DEFINE(ACE_ODB) - ACE_ODB * ACE_ODB::instance (void) { diff --git a/dep/acelite/ace/Dump.h b/dep/acelite/ace/Dump.h index 09eafd1a6..fc1eca06d 100644 --- a/dep/acelite/ace/Dump.h +++ b/dep/acelite/ace/Dump.h @@ -4,6 +4,9 @@ /** * @file Dump.h * + * $Id: Dump.h 94034 2011-05-09 19:11:03Z johnnyw $ + * + * * A prototype mechanism that allow all ACE objects to be registered * with a central in-memory "database" that can dump the state of all * live ACE objects (e.g., from within a debugger). @@ -39,6 +42,7 @@ * 2. Adding support to allow particular classes of objects to * be selectively dumped. * + * * @author Doug Schmidt */ //============================================================================= @@ -127,8 +131,6 @@ public: /// Interface to the Singleton instance of the object database. static ACE_ODB *instance (void); - ACE_ALLOC_HOOK_DECLARE; - private: ACE_ODB (void); // Ensure we have a Singleton... diff --git a/dep/acelite/ace/Dump_T.cpp b/dep/acelite/ace/Dump_T.cpp index fc0833a9e..da2b62a6f 100644 --- a/dep/acelite/ace/Dump_T.cpp +++ b/dep/acelite/ace/Dump_T.cpp @@ -1,4 +1,7 @@ // Dump_T.cpp +// +// $Id: Dump_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_DUMP_T_CPP #define ACE_DUMP_T_CPP diff --git a/dep/acelite/ace/Dump_T.h b/dep/acelite/ace/Dump_T.h index b8859d113..69d86718b 100644 --- a/dep/acelite/ace/Dump_T.h +++ b/dep/acelite/ace/Dump_T.h @@ -4,6 +4,8 @@ /** * @file Dump_T.h * + * $Id: Dump_T.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Dynamic.cpp b/dep/acelite/ace/Dynamic.cpp index 469d67e40..59e9c79b8 100644 --- a/dep/acelite/ace/Dynamic.cpp +++ b/dep/acelite/ace/Dynamic.cpp @@ -1,3 +1,5 @@ +// $Id: Dynamic.cpp 97391 2013-10-28 09:38:26Z mhengstmengel $ + #include "ace/Dynamic.h" #include "ace/Singleton.h" #include "ace/TSS_T.h" @@ -18,8 +20,6 @@ ACE_Dynamic::ACE_Dynamic (void) ACE_TRACE ("ACE_Dynamic::ACE_Dynamic"); } -ACE_ALLOC_HOOK_DEFINE(ACE_Dynamic) - /* static */ ACE_Dynamic * ACE_Dynamic::instance (void) { diff --git a/dep/acelite/ace/Dynamic.h b/dep/acelite/ace/Dynamic.h index 041e3cdef..70dfcd8d9 100644 --- a/dep/acelite/ace/Dynamic.h +++ b/dep/acelite/ace/Dynamic.h @@ -4,6 +4,8 @@ /** * @file Dynamic.h * + * $Id: Dynamic.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt * @author Irfan Pyarali. */ @@ -54,8 +56,6 @@ public: static ACE_Dynamic *instance (void); - ACE_ALLOC_HOOK_DECLARE; - private: /** * Flag that indicates that the object was dynamically created. This diff --git a/dep/acelite/ace/Dynamic.inl b/dep/acelite/ace/Dynamic.inl index 795f33d2e..1e8e968f8 100644 --- a/dep/acelite/ace/Dynamic.inl +++ b/dep/acelite/ace/Dynamic.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Dynamic.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Dynamic_Message_Strategy.cpp b/dep/acelite/ace/Dynamic_Message_Strategy.cpp index 35802fdbf..de6e575c6 100644 --- a/dep/acelite/ace/Dynamic_Message_Strategy.cpp +++ b/dep/acelite/ace/Dynamic_Message_Strategy.cpp @@ -1,3 +1,5 @@ +// $Id: Dynamic_Message_Strategy.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Dynamic_Message_Strategy.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Dynamic_Message_Strategy.h b/dep/acelite/ace/Dynamic_Message_Strategy.h index f6d003c7a..ba1fee71d 100644 --- a/dep/acelite/ace/Dynamic_Message_Strategy.h +++ b/dep/acelite/ace/Dynamic_Message_Strategy.h @@ -4,7 +4,9 @@ /** * @file Dynamic_Message_Strategy.h * - * @author Douglas C. Schmidt + * $Id: Dynamic_Message_Strategy.h 97262 2013-08-09 08:32:10Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Dynamic_Message_Strategy.inl b/dep/acelite/ace/Dynamic_Message_Strategy.inl index 675e0f1e4..9742a07fd 100644 --- a/dep/acelite/ace/Dynamic_Message_Strategy.inl +++ b/dep/acelite/ace/Dynamic_Message_Strategy.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Dynamic_Message_Strategy.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE unsigned long diff --git a/dep/acelite/ace/Dynamic_Service.cpp b/dep/acelite/ace/Dynamic_Service.cpp index 8bf6871d1..28d6e4526 100644 --- a/dep/acelite/ace/Dynamic_Service.cpp +++ b/dep/acelite/ace/Dynamic_Service.cpp @@ -1,3 +1,5 @@ +// $Id: Dynamic_Service.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_DYNAMIC_SERVICE_CPP #define ACE_DYNAMIC_SERVICE_CPP diff --git a/dep/acelite/ace/Dynamic_Service.h b/dep/acelite/ace/Dynamic_Service.h index 84b45b0bd..b90095c76 100644 --- a/dep/acelite/ace/Dynamic_Service.h +++ b/dep/acelite/ace/Dynamic_Service.h @@ -4,8 +4,10 @@ /** * @file Dynamic_Service.h * + * $Id: Dynamic_Service.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Prashant Jain - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Dynamic_Service.inl b/dep/acelite/ace/Dynamic_Service.inl index 5ae958d8f..31324bf53 100644 --- a/dep/acelite/ace/Dynamic_Service.inl +++ b/dep/acelite/ace/Dynamic_Service.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Dynamic_Service.inl 81318 2008-04-10 10:12:05Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_USES_WCHAR) diff --git a/dep/acelite/ace/Dynamic_Service_Base.cpp b/dep/acelite/ace/Dynamic_Service_Base.cpp index d38f1a5cd..70090732b 100644 --- a/dep/acelite/ace/Dynamic_Service_Base.cpp +++ b/dep/acelite/ace/Dynamic_Service_Base.cpp @@ -1,3 +1,5 @@ +// $Id: Dynamic_Service_Base.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Dynamic_Service_Base.h" #include "ace/ACE.h" #include "ace/Service_Config.h" diff --git a/dep/acelite/ace/Dynamic_Service_Base.h b/dep/acelite/ace/Dynamic_Service_Base.h index 3d4649203..31fdadaa1 100644 --- a/dep/acelite/ace/Dynamic_Service_Base.h +++ b/dep/acelite/ace/Dynamic_Service_Base.h @@ -4,8 +4,10 @@ /** * @file Dynamic_Service_Base.h * + * $Id: Dynamic_Service_Base.h 89454 2010-03-11 09:35:25Z johnnyw $ + * * @author Prashant Jain - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Dynamic_Service_Dependency.cpp b/dep/acelite/ace/Dynamic_Service_Dependency.cpp index 0a7e9e03d..edd436473 100644 --- a/dep/acelite/ace/Dynamic_Service_Dependency.cpp +++ b/dep/acelite/ace/Dynamic_Service_Dependency.cpp @@ -1,3 +1,5 @@ +// $Id: Dynamic_Service_Dependency.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/ACE.h" #include "ace/DLL_Manager.h" #include "ace/Dynamic_Service_Dependency.h" diff --git a/dep/acelite/ace/Dynamic_Service_Dependency.h b/dep/acelite/ace/Dynamic_Service_Dependency.h index bb5294f40..0f187d003 100644 --- a/dep/acelite/ace/Dynamic_Service_Dependency.h +++ b/dep/acelite/ace/Dynamic_Service_Dependency.h @@ -4,6 +4,8 @@ /** * @file Dynamic_Service_Dependency.h * + * $Id: Dynamic_Service_Dependency.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Iliyan Jeliazkov */ //============================================================================= diff --git a/dep/acelite/ace/Encoding_Converter.cpp b/dep/acelite/ace/Encoding_Converter.cpp index 29a3a1d18..b5fd2b354 100644 --- a/dep/acelite/ace/Encoding_Converter.cpp +++ b/dep/acelite/ace/Encoding_Converter.cpp @@ -1,3 +1,4 @@ +// $Id: Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ #include "ace/Encoding_Converter.h" #if defined (ACE_USES_WCHAR) diff --git a/dep/acelite/ace/Encoding_Converter.h b/dep/acelite/ace/Encoding_Converter.h index c430e8f93..34d22fa29 100644 --- a/dep/acelite/ace/Encoding_Converter.h +++ b/dep/acelite/ace/Encoding_Converter.h @@ -4,6 +4,8 @@ /** * @file Encoding_Converter.h * + * $Id: Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * * This class is the base class for all encoding converters that convert * to and from UTF-8. * diff --git a/dep/acelite/ace/Encoding_Converter_Factory.cpp b/dep/acelite/ace/Encoding_Converter_Factory.cpp index 85f139fc1..f603ae3e8 100644 --- a/dep/acelite/ace/Encoding_Converter_Factory.cpp +++ b/dep/acelite/ace/Encoding_Converter_Factory.cpp @@ -1,3 +1,4 @@ +// $Id: Encoding_Converter_Factory.cpp 80826 2008-03-04 14:51:23Z wotte $ #include "ace/Encoding_Converter_Factory.h" #if defined (ACE_USES_WCHAR) diff --git a/dep/acelite/ace/Encoding_Converter_Factory.h b/dep/acelite/ace/Encoding_Converter_Factory.h index 1a871a4cc..1441c690b 100644 --- a/dep/acelite/ace/Encoding_Converter_Factory.h +++ b/dep/acelite/ace/Encoding_Converter_Factory.h @@ -4,6 +4,8 @@ /** * @file Encoding_Converter_Factory.h * + * $Id: Encoding_Converter_Factory.h 80826 2008-03-04 14:51:23Z wotte $ + * * This class can be used to create encoding converters of various types. * * @author Chad Elliott diff --git a/dep/acelite/ace/Env_Value_T.cpp b/dep/acelite/ace/Env_Value_T.cpp index a63e76844..1997bbea4 100644 --- a/dep/acelite/ace/Env_Value_T.cpp +++ b/dep/acelite/ace/Env_Value_T.cpp @@ -1,3 +1,5 @@ +// $Id: Env_Value_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_ENV_VALUE_T_CPP #define ACE_ENV_VALUE_T_CPP diff --git a/dep/acelite/ace/Env_Value_T.h b/dep/acelite/ace/Env_Value_T.h index 4e268d3f9..412baf935 100644 --- a/dep/acelite/ace/Env_Value_T.h +++ b/dep/acelite/ace/Env_Value_T.h @@ -4,9 +4,12 @@ /** * @file Env_Value_T.h * + * $Id: Env_Value_T.h 92712 2010-11-25 12:22:13Z johnnyw $ + * * Template to encapsulate getting a value from an environment variable * and using a supplied default value if not in the environment. * + * * @author Chris Cleeland (derived from work by Carlos O'Ryan) */ //============================================================================= diff --git a/dep/acelite/ace/Env_Value_T.inl b/dep/acelite/ace/Env_Value_T.inl index 1fc1b863f..d9af1b031 100644 --- a/dep/acelite/ace/Env_Value_T.inl +++ b/dep/acelite/ace/Env_Value_T.inl @@ -1,3 +1,5 @@ +// $Id: Env_Value_T.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE diff --git a/dep/acelite/ace/Event.cpp b/dep/acelite/ace/Event.cpp index 20fe07306..6352e2838 100644 --- a/dep/acelite/ace/Event.cpp +++ b/dep/acelite/ace/Event.cpp @@ -1,3 +1,5 @@ +// $Id: Event.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Event.h" #if !defined (__ACE_INLINE__) @@ -6,14 +8,9 @@ #include "ace/Log_Category.h" #include "ace/Condition_Attributes.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Event_T) - template ACE_Event_T::ACE_Event_T (int manual_reset, int initial_state, diff --git a/dep/acelite/ace/Event.h b/dep/acelite/ace/Event.h index e8c9db91f..9249b46d8 100644 --- a/dep/acelite/ace/Event.h +++ b/dep/acelite/ace/Event.h @@ -4,9 +4,11 @@ /** * @file Event.h * + * $Id: Event.h 96220 2012-11-06 10:03:41Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Event.inl b/dep/acelite/ace/Event.inl index b8a688be7..5be6f513c 100644 --- a/dep/acelite/ace/Event.inl +++ b/dep/acelite/ace/Event.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Event.inl 96220 2012-11-06 10:03:41Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Event_Base.cpp b/dep/acelite/ace/Event_Base.cpp index 3ec4ea02b..221ccd515 100644 --- a/dep/acelite/ace/Event_Base.cpp +++ b/dep/acelite/ace/Event_Base.cpp @@ -1,3 +1,5 @@ +// $Id: Event_Base.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Event_Base.h" #if !defined (__ACE_INLINE__) @@ -5,14 +7,9 @@ #endif /* __ACE_INLINE__ */ #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Event_Base) - ACE_Event_Base::ACE_Event_Base () : removed_ (false) { diff --git a/dep/acelite/ace/Event_Base.h b/dep/acelite/ace/Event_Base.h index a158c5e67..ed90a13ba 100644 --- a/dep/acelite/ace/Event_Base.h +++ b/dep/acelite/ace/Event_Base.h @@ -4,6 +4,8 @@ /** * @file Event_Base.h * + * $Id: Event_Base.h 96220 2012-11-06 10:03:41Z mcorino $ + * * Moved from Synch.h. * * @author Martin Corino diff --git a/dep/acelite/ace/Event_Base.inl b/dep/acelite/ace/Event_Base.inl index fa8cf909e..1372f7e9f 100644 --- a/dep/acelite/ace/Event_Base.inl +++ b/dep/acelite/ace/Event_Base.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Event_Base.inl 96220 2012-11-06 10:03:41Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_event_t diff --git a/dep/acelite/ace/Event_Handler.cpp b/dep/acelite/ace/Event_Handler.cpp index 82e6879be..c6ea62b6a 100644 --- a/dep/acelite/ace/Event_Handler.cpp +++ b/dep/acelite/ace/Event_Handler.cpp @@ -1,4 +1,6 @@ // Event_Handler.cpp +// $Id: Event_Handler.cpp 97856 2014-08-29 11:30:58Z johnnyw $ + #include "ace/Event_Handler.h" #include "ace/OS_Errno.h" #include "ace/Reactor.h" diff --git a/dep/acelite/ace/Event_Handler.h b/dep/acelite/ace/Event_Handler.h index caf5068a0..559edd1c4 100644 --- a/dep/acelite/ace/Event_Handler.h +++ b/dep/acelite/ace/Event_Handler.h @@ -4,7 +4,9 @@ /** * @file Event_Handler.h * - * @author Douglas C. Schmidt + * $Id: Event_Handler.h 97856 2014-08-29 11:30:58Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -20,7 +22,6 @@ #include "ace/os_include/os_signal.h" #include "ace/Atomic_Op.h" -#include "ace/OS_NS_Thread.h" #include "ace/Synch_Traits.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Event_Handler.inl b/dep/acelite/ace/Event_Handler.inl index 4ad5d2d26..d97c45466 100644 --- a/dep/acelite/ace/Event_Handler.inl +++ b/dep/acelite/ace/Event_Handler.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Event_Handler.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.cpp b/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.cpp index f361e5aae..b16679a11 100644 --- a/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.cpp +++ b/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.cpp @@ -1,3 +1,5 @@ +// $Id: Event_Handler_Handle_Timeout_Upcall.cpp 95586 2012-03-03 20:45:57Z johnnyw $ + #include "ace/Event_Handler_Handle_Timeout_Upcall.h" #include "ace/Reactor_Timer_Interface.h" #include "ace/Abstract_Timer_Queue.h" @@ -8,8 +10,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Event_Handler_Handle_Timeout_Upcall) - ACE_Event_Handler_Handle_Timeout_Upcall:: ACE_Event_Handler_Handle_Timeout_Upcall (void) : requires_reference_counting_ (0) diff --git a/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.h b/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.h index bb94a918d..0ce4a4dd9 100644 --- a/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.h +++ b/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.h @@ -1,3 +1,5 @@ +//$Id: Event_Handler_Handle_Timeout_Upcall.h 95334 2011-12-15 12:52:50Z msmit $ + #ifndef ACE_EVENT_HANDLER_HANDLE_TIMEOUT_UPCALL_H #define ACE_EVENT_HANDLER_HANDLE_TIMEOUT_UPCALL_H @@ -84,9 +86,6 @@ public: ACE_Event_Handler *handler, const void *arg); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: /// Flag indicating that reference counting is required for this diff --git a/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.inl b/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.inl index 8c0b41bb0..f52a7206c 100644 --- a/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.inl +++ b/dep/acelite/ace/Event_Handler_Handle_Timeout_Upcall.inl @@ -1,3 +1,5 @@ +// $Id: Event_Handler_Handle_Timeout_Upcall.inl 95336 2011-12-15 13:22:33Z msmit $ + #include "ace/Event_Handler.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Event_Handler_T.cpp b/dep/acelite/ace/Event_Handler_T.cpp index 51efca891..3d2649524 100644 --- a/dep/acelite/ace/Event_Handler_T.cpp +++ b/dep/acelite/ace/Event_Handler_T.cpp @@ -1,4 +1,7 @@ // Event_Handler_T.cpp +// +// $Id: Event_Handler_T.cpp 91626 2010-09-07 10:59:20Z johnnyw $ + #ifndef ACE_EVENT_HANDLER_T_CPP #define ACE_EVENT_HANDLER_T_CPP diff --git a/dep/acelite/ace/Event_Handler_T.h b/dep/acelite/ace/Event_Handler_T.h index ce9dc663d..61ea28a17 100644 --- a/dep/acelite/ace/Event_Handler_T.h +++ b/dep/acelite/ace/Event_Handler_T.h @@ -4,7 +4,9 @@ /** * @file Event_Handler_T.h * - * @author Douglas C. Schmidt + * $Id: Event_Handler_T.h 91626 2010-09-07 10:59:20Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Event_Handler_T.inl b/dep/acelite/ace/Event_Handler_T.inl index 64df02a1d..9c209f981 100644 --- a/dep/acelite/ace/Event_Handler_T.inl +++ b/dep/acelite/ace/Event_Handler_T.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Event_Handler_T.inl 91626 2010-09-07 10:59:20Z johnnyw $ + #include "ace/Global_Macros.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/FIFO.cpp b/dep/acelite/ace/FIFO.cpp index e598bb636..f7fc5fefb 100644 --- a/dep/acelite/ace/FIFO.cpp +++ b/dep/acelite/ace/FIFO.cpp @@ -1,3 +1,5 @@ +// $Id: FIFO.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/FIFO.h" #if !defined (__ACE_INLINE__) @@ -9,9 +11,6 @@ #include "ace/OS_NS_errno.h" #include "ace/OS_NS_sys_stat.h" #include "ace/OS_NS_fcntl.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/FIFO.h b/dep/acelite/ace/FIFO.h index 2c66ab10f..f4836368d 100644 --- a/dep/acelite/ace/FIFO.h +++ b/dep/acelite/ace/FIFO.h @@ -4,6 +4,8 @@ /** * @file FIFO.h * + * $Id: FIFO.h 91574 2010-08-30 16:52:24Z shuston $ + * * @author Doug Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/FIFO.inl b/dep/acelite/ace/FIFO.inl index 9fe5c733e..05cc030a9 100644 --- a/dep/acelite/ace/FIFO.inl +++ b/dep/acelite/ace/FIFO.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FIFO.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_unistd.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/FIFO_Recv.cpp b/dep/acelite/ace/FIFO_Recv.cpp index bb5568d56..1a573850a 100644 --- a/dep/acelite/ace/FIFO_Recv.cpp +++ b/dep/acelite/ace/FIFO_Recv.cpp @@ -1,9 +1,8 @@ +// $Id: FIFO_Recv.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/FIFO_Recv.h" #include "ace/Log_Category.h" #include "ace/OS_NS_fcntl.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/FIFO_Recv.inl" diff --git a/dep/acelite/ace/FIFO_Recv.h b/dep/acelite/ace/FIFO_Recv.h index bf3c9a8d2..2b6b2f25c 100644 --- a/dep/acelite/ace/FIFO_Recv.h +++ b/dep/acelite/ace/FIFO_Recv.h @@ -4,6 +4,8 @@ /** * @file FIFO_Recv.h * + * $Id: FIFO_Recv.h 91574 2010-08-30 16:52:24Z shuston $ + * * @author Doug Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/FIFO_Recv.inl b/dep/acelite/ace/FIFO_Recv.inl index aa95234c5..d4c3fee43 100644 --- a/dep/acelite/ace/FIFO_Recv.inl +++ b/dep/acelite/ace/FIFO_Recv.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FIFO_Recv.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/ACE.h" #include "ace/OS_NS_unistd.h" diff --git a/dep/acelite/ace/FIFO_Recv_Msg.cpp b/dep/acelite/ace/FIFO_Recv_Msg.cpp index 494f098ac..eb9d93dca 100644 --- a/dep/acelite/ace/FIFO_Recv_Msg.cpp +++ b/dep/acelite/ace/FIFO_Recv_Msg.cpp @@ -1,9 +1,8 @@ +// $Id: FIFO_Recv_Msg.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/FIFO_Recv_Msg.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/FIFO_Recv_Msg.inl" diff --git a/dep/acelite/ace/FIFO_Recv_Msg.h b/dep/acelite/ace/FIFO_Recv_Msg.h index 566f26fdf..6b691e97f 100644 --- a/dep/acelite/ace/FIFO_Recv_Msg.h +++ b/dep/acelite/ace/FIFO_Recv_Msg.h @@ -4,6 +4,8 @@ /** * @file FIFO_Recv_Msg.h * + * $Id: FIFO_Recv_Msg.h 84480 2009-02-16 18:58:16Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/FIFO_Recv_Msg.inl b/dep/acelite/ace/FIFO_Recv_Msg.inl index 917aee9df..d3215fb76 100644 --- a/dep/acelite/ace/FIFO_Recv_Msg.inl +++ b/dep/acelite/ace/FIFO_Recv_Msg.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FIFO_Recv_Msg.inl 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/Min_Max.h" #include "ace/OS_NS_stropts.h" #include "ace/Truncate.h" diff --git a/dep/acelite/ace/FIFO_Send.cpp b/dep/acelite/ace/FIFO_Send.cpp index 0c37b917e..64e1b9a72 100644 --- a/dep/acelite/ace/FIFO_Send.cpp +++ b/dep/acelite/ace/FIFO_Send.cpp @@ -1,8 +1,7 @@ +// $Id: FIFO_Send.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/FIFO_Send.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/FIFO_Send.inl" diff --git a/dep/acelite/ace/FIFO_Send.h b/dep/acelite/ace/FIFO_Send.h index 37580662b..c6bf60023 100644 --- a/dep/acelite/ace/FIFO_Send.h +++ b/dep/acelite/ace/FIFO_Send.h @@ -4,6 +4,8 @@ /** * @file FIFO_Send.h * + * $Id: FIFO_Send.h 91574 2010-08-30 16:52:24Z shuston $ + * * @author Doug Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/FIFO_Send.inl b/dep/acelite/ace/FIFO_Send.inl index ee0d8d0b5..a01facd61 100644 --- a/dep/acelite/ace/FIFO_Send.inl +++ b/dep/acelite/ace/FIFO_Send.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FIFO_Send.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/ACE.h" #include "ace/OS_NS_unistd.h" diff --git a/dep/acelite/ace/FIFO_Send_Msg.cpp b/dep/acelite/ace/FIFO_Send_Msg.cpp index 756a570f2..bc63ef993 100644 --- a/dep/acelite/ace/FIFO_Send_Msg.cpp +++ b/dep/acelite/ace/FIFO_Send_Msg.cpp @@ -1,10 +1,9 @@ +// $Id: FIFO_Send_Msg.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/FIFO_Send_Msg.h" #include "ace/Log_Category.h" #include "ace/OS_NS_sys_uio.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/FIFO_Send_Msg.inl" diff --git a/dep/acelite/ace/FIFO_Send_Msg.h b/dep/acelite/ace/FIFO_Send_Msg.h index 226f53da0..434ae1081 100644 --- a/dep/acelite/ace/FIFO_Send_Msg.h +++ b/dep/acelite/ace/FIFO_Send_Msg.h @@ -4,6 +4,8 @@ /** * @file FIFO_Send_Msg.h * + * $Id: FIFO_Send_Msg.h 84480 2009-02-16 18:58:16Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/FIFO_Send_Msg.inl b/dep/acelite/ace/FIFO_Send_Msg.inl index 74aaa1971..0a34e64e3 100644 --- a/dep/acelite/ace/FIFO_Send_Msg.inl +++ b/dep/acelite/ace/FIFO_Send_Msg.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FIFO_Send_Msg.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_stropts.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/FILE.cpp b/dep/acelite/ace/FILE.cpp index f7be0af71..49ff2c1ca 100644 --- a/dep/acelite/ace/FILE.cpp +++ b/dep/acelite/ace/FILE.cpp @@ -1,3 +1,5 @@ +// $Id: FILE.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + /* Defines the member functions for the base class of the ACE_IO_SAP ACE_FILE abstraction. */ @@ -6,10 +8,6 @@ #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_sys_stat.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/FILE.inl" #endif /* __ACE_INLINE__ */ diff --git a/dep/acelite/ace/FILE.h b/dep/acelite/ace/FILE.h index e128eda3a..b0cf71264 100644 --- a/dep/acelite/ace/FILE.h +++ b/dep/acelite/ace/FILE.h @@ -4,6 +4,8 @@ /** * @file FILE.h * + * $Id: FILE.h 91685 2010-09-09 09:35:14Z johnnyw $ + * * @author Gerhard Lenzer */ //============================================================================= diff --git a/dep/acelite/ace/FILE.inl b/dep/acelite/ace/FILE.inl index 69c3e0cd2..288374afc 100644 --- a/dep/acelite/ace/FILE.inl +++ b/dep/acelite/ace/FILE.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FILE.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/FILE_Addr.cpp b/dep/acelite/ace/FILE_Addr.cpp index 9d043f5fc..4ab5db9e9 100644 --- a/dep/acelite/ace/FILE_Addr.cpp +++ b/dep/acelite/ace/FILE_Addr.cpp @@ -1,3 +1,5 @@ +// $Id: FILE_Addr.cpp 97921 2014-10-10 21:58:31Z shuston $ + #include "ace/FILE_Addr.h" #include "ace/Lib_Find.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/FILE_Addr.h b/dep/acelite/ace/FILE_Addr.h index d35537301..432275b96 100644 --- a/dep/acelite/ace/FILE_Addr.h +++ b/dep/acelite/ace/FILE_Addr.h @@ -4,7 +4,9 @@ /** * @file FILE_Addr.h * - * @author Douglas C. Schmidt + * $Id: FILE_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/FILE_Addr.inl b/dep/acelite/ace/FILE_Addr.inl index c873ba8b0..0ae7d31d2 100644 --- a/dep/acelite/ace/FILE_Addr.inl +++ b/dep/acelite/ace/FILE_Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FILE_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/SString.h" diff --git a/dep/acelite/ace/FILE_Connector.cpp b/dep/acelite/ace/FILE_Connector.cpp index 5ff46dec5..834004d43 100644 --- a/dep/acelite/ace/FILE_Connector.cpp +++ b/dep/acelite/ace/FILE_Connector.cpp @@ -1,9 +1,8 @@ +// $Id: FILE_Connector.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/FILE_Connector.h" #include "ace/Handle_Ops.h" #include "ace/OS_NS_stdlib.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/FILE_Connector.inl" diff --git a/dep/acelite/ace/FILE_Connector.h b/dep/acelite/ace/FILE_Connector.h index b554a1e81..81678dadb 100644 --- a/dep/acelite/ace/FILE_Connector.h +++ b/dep/acelite/ace/FILE_Connector.h @@ -4,7 +4,9 @@ /** * @file FILE_Connector.h * - * @author Doug Schmidt + * $Id: FILE_Connector.h 96985 2013-04-11 15:50:32Z huangh $ + * + * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/FILE_Connector.inl b/dep/acelite/ace/FILE_Connector.inl index a12a6573b..5cde585f1 100644 --- a/dep/acelite/ace/FILE_Connector.inl +++ b/dep/acelite/ace/FILE_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FILE_Connector.inl 96985 2013-04-11 15:50:32Z huangh $ + // Creates a Local ACE_FILE. ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/FILE_IO.cpp b/dep/acelite/ace/FILE_IO.cpp index 1a999c83e..21f431909 100644 --- a/dep/acelite/ace/FILE_IO.cpp +++ b/dep/acelite/ace/FILE_IO.cpp @@ -1,12 +1,11 @@ +// $Id: FILE_IO.cpp 97355 2013-09-27 22:16:09Z shuston $ + #include "ace/FILE_IO.h" #include "ace/Log_Category.h" #include "ace/OS_NS_sys_stat.h" #include "ace/OS_Memory.h" #include "ace/Truncate.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/FILE_IO.inl" @@ -46,26 +45,15 @@ ssize_t ACE_FILE_IO::send (size_t n, ...) const { ACE_TRACE ("ACE_FILE_IO::send"); -#ifdef ACE_LACKS_VA_FUNCTIONS - ACE_UNUSED_ARG (n); - ACE_NOTSUP_RETURN (-1); -#else va_list argp; int total_tuples = ACE_Utils::truncate_cast (n / 2); iovec *iovp = 0; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -80,15 +68,10 @@ ACE_FILE_IO::send (size_t n, ...) const iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; -#endif // ACE_LACKS_VA_FUNCTIONS } // This is basically an interface to ACE_OS::readv, that doesn't use @@ -101,26 +84,15 @@ ssize_t ACE_FILE_IO::recv (size_t n, ...) const { ACE_TRACE ("ACE_FILE_IO::recv"); -#ifdef ACE_LACKS_VA_FUNCTIONS - ACE_UNUSED_ARG (n); - ACE_NOTSUP_RETURN (-1); -#else va_list argp; int total_tuples = ACE_Utils::truncate_cast (n / 2); iovec *iovp = 0; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -135,15 +107,10 @@ ACE_FILE_IO::recv (size_t n, ...) const iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; -#endif // ACE_LACKS_VA_FUNCTIONS } // Allows a client to read from a file without having to provide a @@ -163,15 +130,9 @@ ACE_FILE_IO::recvv (iovec *io_vec) { // Restrict to max size we can record in iov_len. size_t len = ACE_Utils::truncate_cast (length); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (io_vec->iov_base, - static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * len)), - -1); -#else ACE_NEW_RETURN (io_vec->iov_base, char[len], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ io_vec->iov_len = static_cast (this->recv_n (io_vec->iov_base, len)); return io_vec->iov_len; diff --git a/dep/acelite/ace/FILE_IO.h b/dep/acelite/ace/FILE_IO.h index 2ef049020..4540db830 100644 --- a/dep/acelite/ace/FILE_IO.h +++ b/dep/acelite/ace/FILE_IO.h @@ -4,7 +4,9 @@ /** * @file FILE_IO.h * - * @author Douglas C. Schmidt + * $Id: FILE_IO.h 92298 2010-10-21 11:15:17Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/FILE_IO.inl b/dep/acelite/ace/FILE_IO.inl index 57c300490..d2e4f756c 100644 --- a/dep/acelite/ace/FILE_IO.inl +++ b/dep/acelite/ace/FILE_IO.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: FILE_IO.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/ACE.h" #include "ace/OS_NS_sys_uio.h" #include "ace/OS_NS_unistd.h" diff --git a/dep/acelite/ace/File_Lock.cpp b/dep/acelite/ace/File_Lock.cpp index f5e421acb..bff6153ff 100644 --- a/dep/acelite/ace/File_Lock.cpp +++ b/dep/acelite/ace/File_Lock.cpp @@ -1,8 +1,7 @@ +// $Id: File_Lock.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/File_Lock.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/File_Lock.inl" diff --git a/dep/acelite/ace/File_Lock.h b/dep/acelite/ace/File_Lock.h index d71e42c00..4cd58fcd1 100644 --- a/dep/acelite/ace/File_Lock.h +++ b/dep/acelite/ace/File_Lock.h @@ -4,7 +4,9 @@ /** * @file File_Lock.h * - * @author Douglas C. Schmidt + * $Id: File_Lock.h 91064 2010-07-12 10:11:24Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/File_Lock.inl b/dep/acelite/ace/File_Lock.inl index fb9ae6e0c..cf0cefed1 100644 --- a/dep/acelite/ace/File_Lock.inl +++ b/dep/acelite/ace/File_Lock.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: File_Lock.inl 87213 2009-10-23 13:11:34Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/Filecache.cpp b/dep/acelite/ace/Filecache.cpp index 6916367bc..3a583962f 100644 --- a/dep/acelite/ace/Filecache.cpp +++ b/dep/acelite/ace/Filecache.cpp @@ -1,3 +1,5 @@ +// $Id: Filecache.cpp 97202 2013-06-19 22:35:11Z mesnier_p $ + #include "ace/Filecache.h" #include "ace/Object_Manager.h" #include "ace/Log_Category.h" @@ -171,11 +173,7 @@ ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (ACE_Filecache_Hash_Entry *next, template <> ACE_Filecache_Hash_Entry::~ACE_Hash_Map_Entry (void) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) ext_id_); -#else ACE_OS::free ((void *) ext_id_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } // We need these template specializations since KEY is defined as a @@ -236,8 +234,6 @@ ACE_Filecache::~ACE_Filecache (void) { } -ACE_ALLOC_HOOK_DEFINE(ACE_Filecache) - ACE_Filecache_Object * ACE_Filecache::insert_i (const ACE_TCHAR *filename, ACE_SYNCH_RW_MUTEX &filelock, @@ -624,8 +620,6 @@ ACE_Filecache_Object::~ACE_Filecache_Object (void) this->lock_.release (); } -ACE_ALLOC_HOOK_DEFINE(ACE_Filecache_Object) - int ACE_Filecache_Object::acquire (void) { diff --git a/dep/acelite/ace/Filecache.h b/dep/acelite/ace/Filecache.h index fb66ea3ab..2855e2023 100644 --- a/dep/acelite/ace/Filecache.h +++ b/dep/acelite/ace/Filecache.h @@ -4,6 +4,8 @@ /** * @file Filecache.h * + * $Id: Filecache.h 97202 2013-06-19 22:35:11Z mesnier_p $ + * * @author James Hu */ //============================================================================= @@ -186,8 +188,6 @@ public: /// was deleted. ACE_Filecache_Object *finish (ACE_Filecache_Object *&new_file); - ACE_ALLOC_HOOK_DECLARE; - protected: ACE_Filecache_Object *insert_i (const ACE_TCHAR *filename, ACE_SYNCH_RW_MUTEX &filelock, @@ -283,8 +283,6 @@ public: /// True if file on disk is newer than cached file. int update (void) const; - ACE_ALLOC_HOOK_DECLARE; - protected: /// Prevent from being called. ACE_Filecache_Object (void); diff --git a/dep/acelite/ace/Flag_Manip.cpp b/dep/acelite/ace/Flag_Manip.cpp index 0b5ec2d0e..6a4975798 100644 --- a/dep/acelite/ace/Flag_Manip.cpp +++ b/dep/acelite/ace/Flag_Manip.cpp @@ -1,3 +1,5 @@ +// $Id: Flag_Manip.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ + #include "ace/Flag_Manip.h" #if defined (ACE_LACKS_FCNTL) @@ -5,10 +7,6 @@ # include "ace/OS_NS_errno.h" #endif /* ACE_LACKS_FCNTL */ -#if defined (ACE_LACKS_IOCTL) -# include "ace/OS_NS_devctl.h" -#endif - #if !defined (__ACE_INLINE__) #include "ace/Flag_Manip.inl" #endif /* __ACE_INLINE__ */ @@ -33,13 +31,7 @@ ACE::set_flags (ACE_HANDLE handle, int flags) // blocking: (0) { int nonblock = 1; -# if defined (ACE_LACKS_IOCTL) - int dev_info; - return ACE_OS::posix_devctl (handle, FIONBIO, &nonblock, - sizeof nonblock, &dev_info); -# else return ACE_OS::ioctl (handle, FIONBIO, &nonblock); -# endif } default: ACE_NOTSUP_RETURN (-1); @@ -66,6 +58,7 @@ int ACE::clr_flags (ACE_HANDLE handle, int flags) { ACE_TRACE ("ACE::clr_flags"); + #if defined (ACE_LACKS_FCNTL) switch (flags) { @@ -74,13 +67,7 @@ ACE::clr_flags (ACE_HANDLE handle, int flags) // blocking: (0) { int nonblock = 0; -# if defined (ACE_LACKS_IOCTL) - int dev_info; - return ACE_OS::posix_devctl (handle, FIONBIO, &nonblock, - sizeof nonblock, &dev_info); -# else return ACE_OS::ioctl (handle, FIONBIO, &nonblock); -# endif } default: ACE_NOTSUP_RETURN (-1); diff --git a/dep/acelite/ace/Flag_Manip.h b/dep/acelite/ace/Flag_Manip.h index f9324dd34..0457dcb4d 100644 --- a/dep/acelite/ace/Flag_Manip.h +++ b/dep/acelite/ace/Flag_Manip.h @@ -4,6 +4,8 @@ /** * @file Flag_Manip.h * + * $Id: Flag_Manip.h 80826 2008-03-04 14:51:23Z wotte $ + * * This class includes the functions used for the Flag Manipulation. * * @author Priyanka Gontla diff --git a/dep/acelite/ace/Flag_Manip.inl b/dep/acelite/ace/Flag_Manip.inl index f6def7748..229a4ee59 100644 --- a/dep/acelite/ace/Flag_Manip.inl +++ b/dep/acelite/ace/Flag_Manip.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Flag_Manip.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_fcntl.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Framework_Component.cpp b/dep/acelite/ace/Framework_Component.cpp index 513d378b9..8adcdb156 100644 --- a/dep/acelite/ace/Framework_Component.cpp +++ b/dep/acelite/ace/Framework_Component.cpp @@ -1,3 +1,5 @@ +// $Id: Framework_Component.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Framework_Component.h" #if !defined (__ACE_INLINE__) @@ -42,15 +44,9 @@ ACE_Framework_Repository::open (int size) ACE_Framework_Component **temp = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (temp, - static_cast (ACE_Allocator::instance()->malloc(sizeof(ACE_Framework_Component*) * size)), - -1); -#else ACE_NEW_RETURN (temp, ACE_Framework_Component *[size], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->component_vector_ = temp; this->total_size_ = size; @@ -79,11 +75,7 @@ ACE_Framework_Repository::close (void) delete s; } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->component_vector_); -#else delete [] this->component_vector_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->component_vector_ = 0; this->current_size_ = 0; } diff --git a/dep/acelite/ace/Framework_Component.h b/dep/acelite/ace/Framework_Component.h index 9cf7c4d57..51330af86 100644 --- a/dep/acelite/ace/Framework_Component.h +++ b/dep/acelite/ace/Framework_Component.h @@ -4,6 +4,8 @@ /** * @file Framework_Component.h * + * $Id: Framework_Component.h 92208 2010-10-13 06:20:39Z johnnyw $ + * * A prototype mechanism that allows framework components, singletons * such as ACE_Reactor, ACE_Proactor, etc, to be registered with a * central repository managed by the ACE_Object_Manager or diff --git a/dep/acelite/ace/Framework_Component.inl b/dep/acelite/ace/Framework_Component.inl index e5d25bb2f..d9afc4c2d 100644 --- a/dep/acelite/ace/Framework_Component.inl +++ b/dep/acelite/ace/Framework_Component.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Framework_Component.inl 92208 2010-10-13 06:20:39Z johnnyw $ + #include "ace/ACE.h" #include "ace/Guard_T.h" diff --git a/dep/acelite/ace/Framework_Component_T.cpp b/dep/acelite/ace/Framework_Component_T.cpp index abefe8325..6f0be7b5e 100644 --- a/dep/acelite/ace/Framework_Component_T.cpp +++ b/dep/acelite/ace/Framework_Component_T.cpp @@ -1,12 +1,10 @@ +// $Id: Framework_Component_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_FRAMEWORK_COMPONENT_T_CPP #define ACE_FRAMEWORK_COMPONENT_T_CPP #include "ace/Framework_Component_T.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL template @@ -23,8 +21,6 @@ ACE_Framework_Component_T::~ACE_Framework_Component_T (void) Concrete::close_singleton (); } -ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Framework_Component_T) - template void ACE_Framework_Component_T::close_singleton (void) { diff --git a/dep/acelite/ace/Framework_Component_T.h b/dep/acelite/ace/Framework_Component_T.h index 6df8dbeac..a3deaf8fc 100644 --- a/dep/acelite/ace/Framework_Component_T.h +++ b/dep/acelite/ace/Framework_Component_T.h @@ -4,6 +4,8 @@ /** * @file Framework_Component_T.h * + * $Id: Framework_Component_T.h 92208 2010-10-13 06:20:39Z johnnyw $ + * * @author Don Hinton */ //============================================================================= @@ -46,8 +48,6 @@ public: /// Close the contained singleton. void close_singleton (void); - - ACE_ALLOC_HOOK_DECLARE; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Free_List.cpp b/dep/acelite/ace/Free_List.cpp index 36eed6d47..4da723f48 100644 --- a/dep/acelite/ace/Free_List.cpp +++ b/dep/acelite/ace/Free_List.cpp @@ -1,13 +1,11 @@ +// $Id: Free_List.cpp 81107 2008-03-27 11:12:42Z johnnyw $ + #ifndef ACE_FREE_LIST_CPP #define ACE_FREE_LIST_CPP #include "ace/Free_List.h" #include "ace/Guard_T.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ @@ -160,8 +158,6 @@ ACE_Locked_Free_List::dealloc (size_t n) } } -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Locked_Free_List) - ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_FREE_LIST_CPP */ diff --git a/dep/acelite/ace/Free_List.h b/dep/acelite/ace/Free_List.h index ae5ac9f64..24495d03b 100644 --- a/dep/acelite/ace/Free_List.h +++ b/dep/acelite/ace/Free_List.h @@ -4,6 +4,8 @@ /** * @file Free_List.h * + * $Id: Free_List.h 92298 2010-10-21 11:15:17Z johnnyw $ + * * @author Darrell Brunsch (brunsch@cs.wustl.edu) */ //============================================================================= @@ -99,8 +101,6 @@ public: /// Resizes the free list to @a newsize. virtual void resize (size_t newsize); - ACE_ALLOC_HOOK_DECLARE; - protected: /// Allocates @a n extra nodes for the freelist. virtual void alloc (size_t n); diff --git a/dep/acelite/ace/Functor.cpp b/dep/acelite/ace/Functor.cpp index b5b13c921..09e80a587 100644 --- a/dep/acelite/ace/Functor.cpp +++ b/dep/acelite/ace/Functor.cpp @@ -3,16 +3,19 @@ /** * @file Functor.cpp * + * $Id: Functor.cpp 95332 2011-12-15 11:09:41Z mcorino $ + * * Non-inlinable method definitions for non-templatized classes * and template specializations implementing the GOF Command Pattern, * and STL-style functors. * + * * @author Chris Gill * * Based on Command Pattern implementations originally done by * * Carlos O'Ryan - * Douglas C. Schmidt + * Douglas C. Schmidt * Sergio Flores-Gaitan * * and on STL-style functor implementations originally done by diff --git a/dep/acelite/ace/Functor.h b/dep/acelite/ace/Functor.h index 736dcd5a2..0241dc7d8 100644 --- a/dep/acelite/ace/Functor.h +++ b/dep/acelite/ace/Functor.h @@ -4,6 +4,8 @@ /** * @file Functor.h * + * $Id: Functor.h 95761 2012-05-15 18:23:04Z johnnyw $ + * * Non-templatized classes and class template specializations for * implementing function objects that are used in various places * in ACE. There are currently two major categories of function @@ -14,10 +16,11 @@ * Non-templatized classes for implementing the GoF Command Pattern, * also known as functors or function objects. * + * * @author Chris Gill * @author Based on Command Pattern implementations originally done by * @author Carlos O'Ryan - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Sergio Flores-Gaitan * @author and on STL-style functor implementations originally done by * @author Irfan Pyarali @@ -250,7 +253,8 @@ public: }; /** - * @brief Function object for hashing a void */ + * @brief Function object for hashing a void * + */ template<> class ACE_Export ACE_Hash { diff --git a/dep/acelite/ace/Functor.inl b/dep/acelite/ace/Functor.inl index f6a87f85f..0c4777c48 100644 --- a/dep/acelite/ace/Functor.inl +++ b/dep/acelite/ace/Functor.inl @@ -4,16 +4,19 @@ /** * @file Functor.inl * + * $Id: Functor.inl 95763 2012-05-16 06:43:51Z johnnyw $ + * * Inlinable method definitions for non-templatized classes * and template specializations implementing the GOF Command Pattern, * and STL-style functors. * + * * @author Chris Gill * * Based on Command Pattern implementations originally done by * * Carlos O'Ryan - * Douglas C. Schmidt + * Douglas C. Schmidt * Sergio Flores-Gaitan * * and on STL-style functor implementations originally done by diff --git a/dep/acelite/ace/Functor_String.cpp b/dep/acelite/ace/Functor_String.cpp index e12934fca..055e83a06 100644 --- a/dep/acelite/ace/Functor_String.cpp +++ b/dep/acelite/ace/Functor_String.cpp @@ -1,3 +1,5 @@ +// $Id: Functor_String.cpp 91287 2010-08-05 10:30:49Z johnnyw $ + #include "ace/Functor_String.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Functor_String.h b/dep/acelite/ace/Functor_String.h index c04cc01c5..4a2abb512 100644 --- a/dep/acelite/ace/Functor_String.h +++ b/dep/acelite/ace/Functor_String.h @@ -4,10 +4,12 @@ /** * @file Functor_String.h * + * $Id: Functor_String.h 93411 2011-02-18 22:21:16Z hillj $ + * * Class template specializations for ACE_*String types implementing * function objects that are used in various places in ATC. They * could be placed in Functor.h. But we don't want to couple string - * types to the rest of ACE+TAO. Hence they are placed in a separate + * types to the rest of ACE+TAO. Hence they are placed in a seperate * file. */ //========================================================================== diff --git a/dep/acelite/ace/Functor_String.inl b/dep/acelite/ace/Functor_String.inl index d6f427f4a..045cd05f7 100644 --- a/dep/acelite/ace/Functor_String.inl +++ b/dep/acelite/ace/Functor_String.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Functor_String.inl 93411 2011-02-18 22:21:16Z hillj $ + #include "ace/ACE.h" #include "ace/String_Base.h" diff --git a/dep/acelite/ace/Functor_T.cpp b/dep/acelite/ace/Functor_T.cpp index 9b99c5029..213b501aa 100644 --- a/dep/acelite/ace/Functor_T.cpp +++ b/dep/acelite/ace/Functor_T.cpp @@ -1,12 +1,10 @@ +// $Id: Functor_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_FUNCTOR_T_CPP #define ACE_FUNCTOR_T_CPP #include "ace/Functor_T.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ @@ -17,7 +15,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Command_Callback) +ACE_ALLOC_HOOK_DEFINE(ACE_Command_Callback) /////////////////////////////////// // GOF Command Pattern Templates // diff --git a/dep/acelite/ace/Functor_T.h b/dep/acelite/ace/Functor_T.h index 33b955ae9..9c2a4d5c3 100644 --- a/dep/acelite/ace/Functor_T.h +++ b/dep/acelite/ace/Functor_T.h @@ -4,6 +4,8 @@ /** * @file Functor_T.h * + * $Id: Functor_T.h 96943 2013-03-30 09:42:31Z mcorino $ + * * Templatized classes for implementing function objects that are * used in various places in ACE. There are currently two major * categories of function objects in ACE: GOF Command Pattern @@ -12,10 +14,11 @@ * method, while the STL-style functors are invoked via an * method. * + * * @author Chris Gill * @author Based on Command Pattern implementations originally done by * @author Carlos O'Ryan - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Sergio Flores-Gaitan * @author and on STL-style functor implementations originally done by * @author Irfan Pyarali @@ -69,8 +72,6 @@ public: /// Invokes the method @c action_ from the object @c receiver_. virtual int execute (void *arg = 0); - ACE_ALLOC_HOOK_DECLARE; - private: /// Object where the method resides. RECEIVER &receiver_; @@ -84,6 +85,7 @@ private: * * @brief Defines a class template that allows us to invoke a member * function using the GoF command style callback. + * */ template class ACE_Member_Function_Command : public ACE_Command_Base diff --git a/dep/acelite/ace/Functor_T.inl b/dep/acelite/ace/Functor_T.inl index 415a0090b..bfad287ba 100644 --- a/dep/acelite/ace/Functor_T.inl +++ b/dep/acelite/ace/Functor_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Functor_T.inl 96943 2013-03-30 09:42:31Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE diff --git a/dep/acelite/ace/Future.cpp b/dep/acelite/ace/Future.cpp index c2ec6adfc..e60f48a5c 100644 --- a/dep/acelite/ace/Future.cpp +++ b/dep/acelite/ace/Future.cpp @@ -1,3 +1,5 @@ + // $Id: Future.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_FUTURE_CPP #define ACE_FUTURE_CPP @@ -14,11 +16,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Holder) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Observer) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Rep) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future) - template ACE_Future_Holder::ACE_Future_Holder (void) { @@ -195,10 +192,7 @@ ACE_Future_Rep::set (const T &r, while (iterator != end) { OBSERVER *observer = *iterator++; - if (observer) - { - observer->update (caller); - } + observer->update (caller); } // Signal all the waiting threads. diff --git a/dep/acelite/ace/Future.h b/dep/acelite/ace/Future.h index 81fcb820c..0246263f1 100644 --- a/dep/acelite/ace/Future.h +++ b/dep/acelite/ace/Future.h @@ -4,8 +4,10 @@ /** * @file Future.h * + * $Id: Future.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * @author Andres Kruse - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Per Andersson and * @author John Tucker */ @@ -94,7 +96,7 @@ protected: * * @brief ACE_Future_Rep * - * An ACE_Future_Rep object encapsulates a pointer to an object + * An ACE_Future_Rep object encapsules a pointer to an object * of class T which is the result of an asynchronous method * invocation. It is pointed to by ACE_Future object[s] and * only accessible through them. diff --git a/dep/acelite/ace/Future_Set.cpp b/dep/acelite/ace/Future_Set.cpp index 413539b2a..1ba1fd6be 100644 --- a/dep/acelite/ace/Future_Set.cpp +++ b/dep/acelite/ace/Future_Set.cpp @@ -1,3 +1,5 @@ +// $Id: Future_Set.cpp 92900 2010-12-17 14:45:11Z mcorino $ + #ifndef ACE_FUTURE_SET_CPP #define ACE_FUTURE_SET_CPP @@ -11,8 +13,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Set) - template ACE_Future_Set::ACE_Future_Set (ACE_Message_Queue *new_queue) : delete_queue_ (false) diff --git a/dep/acelite/ace/Future_Set.h b/dep/acelite/ace/Future_Set.h index 937416496..d85152420 100644 --- a/dep/acelite/ace/Future_Set.h +++ b/dep/acelite/ace/Future_Set.h @@ -4,6 +4,8 @@ /** * @file Future_Set.h * + * $Id: Future_Set.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * @author John Tucker */ //============================================================================= diff --git a/dep/acelite/ace/Get_Opt.cpp b/dep/acelite/ace/Get_Opt.cpp index 9e8d7c1fb..5182da4eb 100644 --- a/dep/acelite/ace/Get_Opt.cpp +++ b/dep/acelite/ace/Get_Opt.cpp @@ -1,3 +1,5 @@ +// $Id: Get_Opt.cpp 97798 2014-07-03 10:57:43Z johnnyw $ + #include "ace/Get_Opt.h" #if !defined (__ACE_INLINE__) @@ -722,13 +724,7 @@ ACE_Get_Opt::ACE_Get_Opt_Long_Option::ACE_Get_Opt_Long_Option ( ACE_Get_Opt::ACE_Get_Opt_Long_Option::~ACE_Get_Opt_Long_Option (void) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast(this->name_)); -#else delete [] this->name_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } -ACE_ALLOC_HOOK_DEFINE(ACE_Get_Opt::ACE_Get_Opt_Long_Option); - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Get_Opt.h b/dep/acelite/ace/Get_Opt.h index 47aa82720..1c30096ea 100644 --- a/dep/acelite/ace/Get_Opt.h +++ b/dep/acelite/ace/Get_Opt.h @@ -4,7 +4,9 @@ /** * @file Get_Opt.h * - * @author Douglas C. Schmidt + * $Id: Get_Opt.h 86367 2009-08-05 09:41:11Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Don Hinton (added long option support) */ //========================================================================== @@ -405,8 +407,6 @@ private: /// simplifying long option handling, see tests/Get_Opt_Test.cpp /// for an example of this technique. int val_; - - ACE_ALLOC_HOOK_DECLARE; }; /// Updates nextchar_. diff --git a/dep/acelite/ace/Get_Opt.inl b/dep/acelite/ace/Get_Opt.inl index 32de1d85c..1f9151847 100644 --- a/dep/acelite/ace/Get_Opt.inl +++ b/dep/acelite/ace/Get_Opt.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Get_Opt.inl 93736 2011-04-05 12:38:35Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE bool diff --git a/dep/acelite/ace/Global_Macros.h b/dep/acelite/ace/Global_Macros.h index 23d81ef88..ecb94f0a8 100644 --- a/dep/acelite/ace/Global_Macros.h +++ b/dep/acelite/ace/Global_Macros.h @@ -4,7 +4,9 @@ /** * @file Global_Macros.h * - * @author Douglas C. Schmidt + * $Id: Global_Macros.h 97884 2014-09-08 18:00:53Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -38,6 +40,40 @@ # define ACE_DB(X) X # endif /* ACE_NDEBUG */ +// ACE_NO_HEAP_CHECK macro can be used to suppress false report of +// memory leaks. It turns off the built-in heap checking until the +// block is left. The old state will then be restored Only used for +// Win32 (in the moment). +# if defined (ACE_WIN32) + +# if defined (_DEBUG) && !defined (ACE_HAS_WINCE) && !defined (__BORLANDC__) +# include /**/ + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Export ACE_No_Heap_Check +{ +public: + ACE_No_Heap_Check (void) + : old_state (_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG)) + { _CrtSetDbgFlag (old_state & ~_CRTDBG_ALLOC_MEM_DF);} + ~ACE_No_Heap_Check (void) { _CrtSetDbgFlag (old_state);} +private: + int old_state; +}; + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +# define ACE_NO_HEAP_CHECK ACE_No_Heap_Check ____no_heap; +# else /* !_DEBUG */ +# define ACE_NO_HEAP_CHECK +# endif /* _DEBUG */ +# else /* !ACE_WIN32 */ +# define ACE_NO_HEAP_CHECK +# endif /* ACE_WIN32 */ + // Turn a number into a string. # define ACE_ITOA(X) #X @@ -61,7 +97,7 @@ # define ACE_ENDLESS_LOOP # endif /* ! ACE_ENDLESS_LOOP */ -# if defined (ACE_NEEDS_FUNC_DEFINITIONS) && !defined (ACE_HAS_CPP11) +# if defined (ACE_NEEDS_FUNC_DEFINITIONS) // It just evaporated ;-) Not pleasant. # define ACE_UNIMPLEMENTED_FUNC(f) # else @@ -72,14 +108,12 @@ # endif # endif /* ACE_NEEDS_FUNC_DEFINITIONS */ -// noexcept(false) specification to specify that the operation can -// throw an exception +// C++11 has deprecated the register keyword #if defined (ACE_HAS_CPP11) -#define ACE_NOEXCEPT_FALSE noexcept(false) +# define ACE_REGISTER #else -#define ACE_NOEXCEPT_FALSE +# define ACE_REGISTER register #endif - // ---------------------------------------------------------------- // FUZZ: disable check_for_ACE_Guard @@ -222,13 +256,6 @@ } \ while (0) -# define ACE_DES_FREE_THIS(DEALLOCATOR,CLASS) \ - do { \ - this->~CLASS (); \ - DEALLOCATOR (this); \ - } \ - while (0) - # define ACE_DES_ARRAY_FREE(POINTER,SIZE,DEALLOCATOR,CLASS) \ do { \ if (POINTER) \ @@ -479,9 +506,9 @@ typedef void (*ACE_Service_Object_Exterminator)(void *); * * The following macros are used to define helper objects used in * ACE's Service Configurator framework, which is described in - * Chapter 5 of C++NPv2 . This + * Chapter 5 of C++NPv2 . This * framework implements the Component Configurator pattern, which is - * described in Chapter 2 of POSA2 . + * described in Chapter 2 of POSA2 . * The intent of this pattern is to allow developers to dynamically * load and configure services into a system. With a little help from * this macros statically linked services can also be dynamically @@ -641,6 +668,7 @@ static ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS; * service. * @param SERVICE_CLASS must match the name of the class that * implements the service. + * */ # define ACE_FACTORY_DECLARE(CLS,SERVICE_CLASS) \ extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * \ @@ -773,6 +801,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC * * The ACE services defined in netsvcs use this helper macros for * simplicity. + * */ //@{ # define ACE_SVC_FACTORY_DECLARE(X) ACE_FACTORY_DECLARE (ACE_Svc, X) @@ -842,7 +871,7 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC #endif /* ACE_WIN32 */ -// Some useful abstractions for expressions involving +// Some useful abstrations for expressions involving // ACE_Allocator.malloc (). The difference between ACE_NEW_MALLOC* // with ACE_ALLOCATOR* is that they call constructors also. @@ -1009,6 +1038,16 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool # define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool +// Work around compilers that don't like in-class static integral +// constants. Constants in this case are meant to be compile-time +// constants so that they may be used as template arguments, for +// example. BOOST provides a similar macro. +#ifndef ACE_LACKS_STATIC_IN_CLASS_CONSTANTS +# define ACE_STATIC_CONSTANT(TYPE, ASSIGNMENT) static TYPE const ASSIGNMENT +#else +# define ACE_STATIC_CONSTANT(TYPE, ASSIGNMENT) enum { ASSIGNMENT } +#endif /* !ACE_LACKS_STATIC_IN_CLASS_CONSTANTS */ + #include /**/ "ace/post.h" #endif /*ACE_GLOBAL_MACROS_H*/ diff --git a/dep/acelite/ace/Guard_T.cpp b/dep/acelite/ace/Guard_T.cpp index dd4f9a2b9..8d26e2033 100644 --- a/dep/acelite/ace/Guard_T.cpp +++ b/dep/acelite/ace/Guard_T.cpp @@ -1,3 +1,5 @@ +// $Id: Guard_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_GUARD_T_CPP #define ACE_GUARD_T_CPP diff --git a/dep/acelite/ace/Guard_T.h b/dep/acelite/ace/Guard_T.h index ec415b794..43630f24d 100644 --- a/dep/acelite/ace/Guard_T.h +++ b/dep/acelite/ace/Guard_T.h @@ -4,9 +4,11 @@ /** * @file Guard_T.h * + * $Id: Guard_T.h 97875 2014-09-08 12:22:43Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== @@ -271,8 +273,8 @@ public: /// Dump the state of an object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. protected: /// Helper, meant for subclass only. diff --git a/dep/acelite/ace/Guard_T.inl b/dep/acelite/ace/Guard_T.inl index 02d6989cd..34b2b777f 100644 --- a/dep/acelite/ace/Guard_T.inl +++ b/dep/acelite/ace/Guard_T.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Guard_T.inl 93736 2011-04-05 12:38:35Z johnnyw $ + // FUZZ: disable check_for_ACE_Guard #include "ace/RW_Thread_Mutex.h" diff --git a/dep/acelite/ace/Handle_Gobbler.h b/dep/acelite/ace/Handle_Gobbler.h index 2d52e1f87..9d6890a03 100644 --- a/dep/acelite/ace/Handle_Gobbler.h +++ b/dep/acelite/ace/Handle_Gobbler.h @@ -4,6 +4,8 @@ /** * @file Handle_Gobbler.h * + * $Id: Handle_Gobbler.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Kirthika Parameswaran * @author Irfan Pyarali */ diff --git a/dep/acelite/ace/Handle_Gobbler.inl b/dep/acelite/ace/Handle_Gobbler.inl index 8bacb005d..6a053d88b 100644 --- a/dep/acelite/ace/Handle_Gobbler.inl +++ b/dep/acelite/ace/Handle_Gobbler.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Handle_Gobbler.inl 90388 2010-06-02 15:27:59Z vzykov $ + // Since this is only included in Handle_Gobbler.h, these should be // inline, not ACE_INLINE. // FUZZ: disable check_for_inline diff --git a/dep/acelite/ace/Handle_Ops.cpp b/dep/acelite/ace/Handle_Ops.cpp index 6d83f91b8..651e0e699 100644 --- a/dep/acelite/ace/Handle_Ops.cpp +++ b/dep/acelite/ace/Handle_Ops.cpp @@ -1,3 +1,5 @@ +// $Id: Handle_Ops.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ + #include "ace/Handle_Ops.h" #include "ace/OS_NS_errno.h" diff --git a/dep/acelite/ace/Handle_Ops.h b/dep/acelite/ace/Handle_Ops.h index bc95fd30c..c615380f8 100644 --- a/dep/acelite/ace/Handle_Ops.h +++ b/dep/acelite/ace/Handle_Ops.h @@ -4,6 +4,8 @@ /** * @file Handle_Ops.h * + * $Id: Handle_Ops.h 80826 2008-03-04 14:51:23Z wotte $ + * * Handle operations. */ //============================================================================= diff --git a/dep/acelite/ace/Handle_Set.cpp b/dep/acelite/ace/Handle_Set.cpp index 0643de5dc..aa2c53249 100644 --- a/dep/acelite/ace/Handle_Set.cpp +++ b/dep/acelite/ace/Handle_Set.cpp @@ -1,8 +1,7 @@ // Handle_Set.cpp +// $Id: Handle_Set.cpp 97884 2014-09-08 18:00:53Z johnnyw $ + #include "ace/Handle_Set.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/Handle_Set.inl" @@ -28,8 +27,6 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set) // default on Linux/glibc-2.1.x systems. Instead use "__fds_bits." // Ugly, but "what are you going to do?" 8-) #define fds_bits __fds_bits -#elif defined ACE_FDS_BITS -#define fds_bits ACE_FDS_BITS #endif /* ACE_LINUX && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 && !_XOPEN_SOURCE */ void @@ -121,12 +118,12 @@ ACE_Handle_Set::count_bits (u_long n) ACE_TRACE ("ACE_Handle_Set::count_bits"); #if defined (ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT) - int rval = 0; + ACE_REGISTER int rval = 0; // Count the number of enabled bits in . This algorithm is very // fast, i.e., O(enabled bits in n). - for (u_long m = n; + for (ACE_REGISTER u_long m = n; m != 0; m &= m - 1) rval++; @@ -147,8 +144,8 @@ ACE_Handle_Set::count_bits (u_long n) int ACE_Handle_Set::bitpos (u_long bit) { - int l = 0; - u_long n = bit - 1; + ACE_REGISTER int l = 0; + ACE_REGISTER u_long n = bit - 1; // This is a fast count method when have the most significative bit. @@ -345,7 +342,7 @@ ACE_Handle_Set_Iterator::operator () (void) } #else /* !ACE_HAS_BIG_FD_SET */ // Find the first word in fds_bits with bit on - u_long lsb = this->word_val_; + ACE_REGISTER u_long lsb = this->word_val_; if (lsb == 0) { @@ -386,7 +383,7 @@ ACE_Handle_Set_Iterator::operator () (void) // Remove least significative bit. this->word_val_ ^= lsb; - u_long n = lsb - this->oldlsb_; + ACE_REGISTER u_long n = lsb - this->oldlsb_; // Move index to bit distance between new lsb and old lsb. do diff --git a/dep/acelite/ace/Handle_Set.h b/dep/acelite/ace/Handle_Set.h index 21b239e42..13fd66324 100644 --- a/dep/acelite/ace/Handle_Set.h +++ b/dep/acelite/ace/Handle_Set.h @@ -4,7 +4,9 @@ /** * @file Handle_Set.h * - * @author Douglas C. Schmidt + * $Id: Handle_Set.h 97484 2013-12-20 08:09:58Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Handle_Set.inl b/dep/acelite/ace/Handle_Set.inl index d3cfe6d38..e6b961a7b 100644 --- a/dep/acelite/ace/Handle_Set.inl +++ b/dep/acelite/ace/Handle_Set.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Handle_Set.inl 97138 2013-05-16 17:55:36Z mitza $ + #include "ace/Log_Category.h" // AIX defines bzero() in this odd file... used by FD_ZERO @@ -65,16 +68,19 @@ ACE_INLINE int ACE_Handle_Set::is_set (ACE_HANDLE handle) const { ACE_TRACE ("ACE_Handle_Set::is_set"); - - fd_set *set = const_cast (&this->mask_); - int ret = FD_ISSET (handle, set); - #if defined (ACE_HAS_BIG_FD_SET) - ret = ret && this->size_ > 0; + return FD_ISSET (handle, + &this->mask_) + && this->size_ > 0; +#elif defined (ACE_HAS_NONCONST_FD_ISSET) + return FD_ISSET (handle, + const_cast (&this->mask_)); #elif defined (ACE_VXWORKS) && ACE_VXWORKS >= 0x690 - ret = ret != 0; -#endif - return ret; + return FD_ISSET (handle, &this->mask_) != 0; +#else + return FD_ISSET (handle, + &this->mask_); +#endif /* ACE_HAS_BIG_FD_SET */ } // Enables the handle. diff --git a/dep/acelite/ace/Hash_Cache_Map_Manager_T.cpp b/dep/acelite/ace/Hash_Cache_Map_Manager_T.cpp index 54ab98c34..194789775 100644 --- a/dep/acelite/ace/Hash_Cache_Map_Manager_T.cpp +++ b/dep/acelite/ace/Hash_Cache_Map_Manager_T.cpp @@ -1,3 +1,5 @@ +// $Id: Hash_Cache_Map_Manager_T.cpp 93359 2011-02-11 11:33:12Z mcorino $ + #ifndef ACE_HASH_CACHE_MAP_MANAGER_T_CPP #define ACE_HASH_CACHE_MAP_MANAGER_T_CPP @@ -13,7 +15,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc6(ACE_Hash_Cache_Map_Manager) +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Cache_Map_Manager) template ACE_Hash_Cache_Map_Manager::ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s, diff --git a/dep/acelite/ace/Hash_Cache_Map_Manager_T.h b/dep/acelite/ace/Hash_Cache_Map_Manager_T.h index e49bd4dfe..e1fc4d773 100644 --- a/dep/acelite/ace/Hash_Cache_Map_Manager_T.h +++ b/dep/acelite/ace/Hash_Cache_Map_Manager_T.h @@ -4,6 +4,8 @@ /** * @file Hash_Cache_Map_Manager_T.h * + * $Id: Hash_Cache_Map_Manager_T.h 93366 2011-02-11 19:30:35Z johnnyw $ + * * @author Kirthika Parameswaran */ //============================================================================= @@ -183,9 +185,6 @@ class ACE_Hash_Cache_Map_Manager : public ACE_CACHE_MAP_MANAGER /// Remove entry from map. int unbind (CACHE_ENTRY *entry); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Base class. typedef ACE_CACHE_MAP_MANAGER ACE_HCMM_BASE; diff --git a/dep/acelite/ace/Hash_Cache_Map_Manager_T.inl b/dep/acelite/ace/Hash_Cache_Map_Manager_T.inl index 1d9de7a0d..8c4bb1223 100644 --- a/dep/acelite/ace/Hash_Cache_Map_Manager_T.inl +++ b/dep/acelite/ace/Hash_Cache_Map_Manager_T.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Hash_Cache_Map_Manager_T.inl 93359 2011-02-11 11:33:12Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Hash_Map_Manager.h b/dep/acelite/ace/Hash_Map_Manager.h index 29f8cb3df..d6c0c4b8a 100644 --- a/dep/acelite/ace/Hash_Map_Manager.h +++ b/dep/acelite/ace/Hash_Map_Manager.h @@ -4,9 +4,11 @@ /** * @file Hash_Map_Manager.h * + * $Id: Hash_Map_Manager.h 80826 2008-03-04 14:51:23Z wotte $ + * * Backward compatibility header. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Hash_Map_Manager_T.cpp b/dep/acelite/ace/Hash_Map_Manager_T.cpp index 604cab120..86bb46633 100644 --- a/dep/acelite/ace/Hash_Map_Manager_T.cpp +++ b/dep/acelite/ace/Hash_Map_Manager_T.cpp @@ -3,6 +3,8 @@ /** * @file Hash_Map_Manager_T.cpp * + * $Id: Hash_Map_Manager_T.cpp 97062 2013-04-22 14:44:39Z johnnyw $ + * * @author Douglas C. Schmidt */ //============================================================================= @@ -25,14 +27,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Manager_Ex) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Iterator_Base_Ex) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Iterator_Ex) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Const_Iterator_Base_Ex) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Const_Iterator_Ex) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Reverse_Iterator_Ex) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Const_Reverse_Iterator_Ex) - template ACE_Hash_Map_Entry::ACE_Hash_Map_Entry (ACE_Hash_Map_Entry *next, ACE_Hash_Map_Entry *prev) @@ -397,6 +391,8 @@ ACE_Hash_Map_Manager_Ex::rebin // ------------------------------------------------------------ +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Base_Ex) + template void ACE_Hash_Map_Iterator_Base_Ex::dump_i (void) const { @@ -469,6 +465,8 @@ ACE_Hash_Map_Iterator_Base_Ex: // ------------------------------------------------------------ +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Base_Ex) + template void ACE_Hash_Map_Const_Iterator_Base_Ex::dump_i (void) const { diff --git a/dep/acelite/ace/Hash_Map_Manager_T.h b/dep/acelite/ace/Hash_Map_Manager_T.h index ea848c6c7..34d384b3b 100644 --- a/dep/acelite/ace/Hash_Map_Manager_T.h +++ b/dep/acelite/ace/Hash_Map_Manager_T.h @@ -4,7 +4,9 @@ /** * @file Hash_Map_Manager_T.h * - * @author Douglas C. Schmidt + * $Id: Hash_Map_Manager_T.h 96985 2013-04-11 15:50:32Z huangh $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -426,9 +428,6 @@ public: const_reverse_iterator rbegin (void) const; const_reverse_iterator rend (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: // = The following methods do the actual work. @@ -604,7 +603,7 @@ public: typedef typename container_type::difference_type difference_type; // = Initialization method. - /// Constructor. + /// Contructor. /** * If @a head != @c false, the iterator constructed is positioned * at the head of the map. It is positioned at the end otherwise. @@ -618,7 +617,7 @@ public: ACE_LOCK> &mm, bool head); - /// Constructor. + /// Contructor. /** * This constructor positions the iterator to the given @a entry. */ @@ -703,7 +702,7 @@ public: typedef typename container_type::difference_type difference_type; // = Initialization method. - /// Constructor. If head the iterator constructed is positioned + /// Contructor. If head the iterator constructed is positioned /// at the head of the map, it is positioned at the end otherwise. ACE_Hash_Map_Const_Iterator_Base_Ex (const ACE_Hash_Map_Manager_Ex &mm, bool head); @@ -788,7 +787,7 @@ public: ACE_Hash_Map_Iterator_Ex (ACE_Hash_Map_Manager_Ex &mm, int tail = 0); - /// Constructor. + /// Contructor. /** * This constructor positions the iterator to the given @a entry. */ diff --git a/dep/acelite/ace/Hash_Map_Manager_T.inl b/dep/acelite/ace/Hash_Map_Manager_T.inl index 7af638f58..bd5674599 100644 --- a/dep/acelite/ace/Hash_Map_Manager_T.inl +++ b/dep/acelite/ace/Hash_Map_Manager_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Hash_Map_Manager_T.inl 97062 2013-04-22 14:44:39Z johnnyw $ + #include "ace/Guard_T.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -701,6 +704,8 @@ ACE_Hash_Map_Const_Iterator_Base_Exmap_man_ != rhs.map_man_; } +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Ex) + template ACE_INLINE void ACE_Hash_Map_Iterator_Ex::dump (void) const { @@ -799,6 +804,8 @@ ACE_Hash_Map_Iterator_Ex::oper return retv; } +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Ex) + template ACE_INLINE void ACE_Hash_Map_Const_Iterator_Ex::dump (void) const { @@ -988,6 +995,8 @@ ACE_Hash_Map_Bucket_Iterator:: || this->map_man_ != rhs.map_man_; } +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Reverse_Iterator_Ex) + template ACE_INLINE void ACE_Hash_Map_Reverse_Iterator_Ex::dump (void) const { @@ -1056,6 +1065,8 @@ ACE_Hash_Map_Reverse_Iterator_Ex ACE_INLINE void ACE_Hash_Map_Const_Reverse_Iterator_Ex::dump (void) const { diff --git a/dep/acelite/ace/Hash_Map_With_Allocator_T.cpp b/dep/acelite/ace/Hash_Map_With_Allocator_T.cpp index 0f0a256f1..a5310e89f 100644 --- a/dep/acelite/ace/Hash_Map_With_Allocator_T.cpp +++ b/dep/acelite/ace/Hash_Map_With_Allocator_T.cpp @@ -1,3 +1,5 @@ +// $Id: Hash_Map_With_Allocator_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP #define ACE_HASH_MAP_WITH_ALLOCATOR_T_CPP diff --git a/dep/acelite/ace/Hash_Map_With_Allocator_T.h b/dep/acelite/ace/Hash_Map_With_Allocator_T.h index 21eaec5f6..bdfba00fb 100644 --- a/dep/acelite/ace/Hash_Map_With_Allocator_T.h +++ b/dep/acelite/ace/Hash_Map_With_Allocator_T.h @@ -4,6 +4,8 @@ /** * @file Hash_Map_With_Allocator_T.h * + * $Id: Hash_Map_With_Allocator_T.h 91743 2010-09-13 18:24:51Z johnnyw $ + * * @author Marina Spivak * @author Irfan Pyarali */ diff --git a/dep/acelite/ace/Hash_Map_With_Allocator_T.inl b/dep/acelite/ace/Hash_Map_With_Allocator_T.inl index 23214a7c2..99a603cfa 100644 --- a/dep/acelite/ace/Hash_Map_With_Allocator_T.inl +++ b/dep/acelite/ace/Hash_Map_With_Allocator_T.inl @@ -1,5 +1,7 @@ // -*- C++ -*- +// $Id: Hash_Map_With_Allocator_T.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE int diff --git a/dep/acelite/ace/Hash_Multi_Map_Manager_T.cpp b/dep/acelite/ace/Hash_Multi_Map_Manager_T.cpp index 51da4e4e5..6cf9d525f 100644 --- a/dep/acelite/ace/Hash_Multi_Map_Manager_T.cpp +++ b/dep/acelite/ace/Hash_Multi_Map_Manager_T.cpp @@ -3,6 +3,8 @@ /** * @file Hash_Multi_Map_Manager_T.cpp * + * $Id: Hash_Multi_Map_Manager_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + * * @author Shanshan Jiang */ //============================================================================= @@ -24,13 +26,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Manager) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Iterator_Base) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Const_Iterator_Base) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Iterator) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Const_Iterator) -ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Reverse_Iterator) - template ACE_Hash_Multi_Map_Entry::ACE_Hash_Multi_Map_Entry (ACE_Hash_Multi_Map_Entry *next, ACE_Hash_Multi_Map_Entry *prev) @@ -455,6 +450,8 @@ ACE_Hash_Multi_Map_Manager::re // ------------------------------------------------------------ +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Iterator_Base) + template void ACE_Hash_Multi_Map_Iterator_Base::dump_i (void) const { @@ -527,6 +524,8 @@ ACE_Hash_Multi_Map_Iterator_Base void ACE_Hash_Multi_Map_Const_Iterator_Base::dump_i (void) const { diff --git a/dep/acelite/ace/Hash_Multi_Map_Manager_T.h b/dep/acelite/ace/Hash_Multi_Map_Manager_T.h index d8f149e39..e5ded8746 100644 --- a/dep/acelite/ace/Hash_Multi_Map_Manager_T.h +++ b/dep/acelite/ace/Hash_Multi_Map_Manager_T.h @@ -4,6 +4,8 @@ /** * @file Hash_Multi_Map_Manager_T.h * + * $Id: Hash_Multi_Map_Manager_T.h 96985 2013-04-11 15:50:32Z huangh $ + * * The code in Hash_Multi_Map_Manager_T.* was based on the code in * Hash_Map_Manager_T.*. * @@ -424,9 +426,6 @@ public: ACE_Hash_Multi_Map_Reverse_Iterator rbegin (void); ACE_Hash_Multi_Map_Reverse_Iterator rend (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: // = The following methods do the actual work. @@ -614,7 +613,7 @@ class ACE_Hash_Multi_Map_Iterator_Base { public: // = Initialization method. - /// Constructor. If @a head != 0, the iterator constructed is positioned + /// Contructor. If @a head != 0, the iterator constructed is positioned /// at the head of the map, it is positioned at the end otherwise. ACE_Hash_Multi_Map_Iterator_Base (ACE_Hash_Multi_Map_Manager &mm, int head); @@ -681,7 +680,7 @@ class ACE_Hash_Multi_Map_Const_Iterator_Base { public: // = Initialization method. - /// Constructor. If @a head != 0, the iterator constructed is positioned + /// Contructor. If @a head != 0, the iterator constructed is positioned /// at the head of the map, it is positioned at the end otherwise. ACE_Hash_Multi_Map_Const_Iterator_Base (const ACE_Hash_Multi_Map_Manager &mm, int head); diff --git a/dep/acelite/ace/Hash_Multi_Map_Manager_T.inl b/dep/acelite/ace/Hash_Multi_Map_Manager_T.inl index 5c9c5f6c6..43a9fd3e1 100644 --- a/dep/acelite/ace/Hash_Multi_Map_Manager_T.inl +++ b/dep/acelite/ace/Hash_Multi_Map_Manager_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Hash_Multi_Map_Manager_T.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Guard_T.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -655,6 +658,8 @@ ACE_Hash_Multi_Map_Const_Iterator_Basemap_man_ != rhs.map_man_; } +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Iterator) + template ACE_INLINE void ACE_Hash_Multi_Map_Iterator::dump (void) const { @@ -725,6 +730,8 @@ ACE_Hash_Multi_Map_Iterator::o return retv; } +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Const_Iterator) + template ACE_INLINE void ACE_Hash_Multi_Map_Const_Iterator::dump (void) const { @@ -914,6 +921,7 @@ ACE_Hash_Multi_Map_Bucket_Iteratormap_man_ != rhs.map_man_; } +ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Reverse_Iterator) template ACE_INLINE void ACE_Hash_Multi_Map_Reverse_Iterator::dump (void) const diff --git a/dep/acelite/ace/Hashable.cpp b/dep/acelite/ace/Hashable.cpp index 547a3065f..24b240724 100644 --- a/dep/acelite/ace/Hashable.cpp +++ b/dep/acelite/ace/Hashable.cpp @@ -1,3 +1,5 @@ +//$Id: Hashable.cpp 93736 2011-04-05 12:38:35Z johnnyw $ + #include "ace/Hashable.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Hashable.h b/dep/acelite/ace/Hashable.h index 6e9e332ad..83f26ffee 100644 --- a/dep/acelite/ace/Hashable.h +++ b/dep/acelite/ace/Hashable.h @@ -4,6 +4,8 @@ /** * @file Hashable.h * + * $Id: Hashable.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Hashable.inl b/dep/acelite/ace/Hashable.inl index ac9af977a..1fb6956cf 100644 --- a/dep/acelite/ace/Hashable.inl +++ b/dep/acelite/ace/Hashable.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Hashable.inl 93736 2011-04-05 12:38:35Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/High_Res_Timer.cpp b/dep/acelite/ace/High_Res_Timer.cpp index 048cb4d63..e42c20a45 100644 --- a/dep/acelite/ace/High_Res_Timer.cpp +++ b/dep/acelite/ace/High_Res_Timer.cpp @@ -1,3 +1,5 @@ +// $Id: High_Res_Timer.cpp 97530 2014-01-16 10:37:21Z johnnyw $ + // Be very carefull before changing the calculations inside // ACE_High_Res_Timer. The precision matters and we are using integer // calculations not floating point. Also look good at the emulated 64 @@ -70,7 +72,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL /* static */ int ACE_High_Res_Timer::global_scale_factor_status_ = 0; -#if defined (ACE_LINUX) && !defined (ACE_LACKS_SSCANF) +#if defined (ACE_LINUX) // Determine the apparent CPU clock speed from /proc/cpuinfo ACE_UINT32 ACE_High_Res_Timer::get_cpuinfo (void) @@ -183,7 +185,8 @@ ACE_High_Res_Timer::get_cpuinfo (void) return scale_factor; } -#endif /* ACE_LINUX && !ACE_LACKS_SSCANF*/ +#endif /* ACE_LINUX */ + ACE_High_Res_Timer::global_scale_factor_type ACE_High_Res_Timer::global_scale_factor (void) @@ -221,11 +224,7 @@ ACE_High_Res_Timer::global_scale_factor (void) ACE_High_Res_Timer::global_scale_factor_status_ = -1; } # elif defined (ACE_LINUX) -# if defined (ACE_LACKS_SSCANF) - ACE_High_Res_Timer::global_scale_factor (1); -# else ACE_High_Res_Timer::global_scale_factor (ACE_High_Res_Timer::get_cpuinfo ()); -# endif /* ACE_LACKS_SSCANF */ # endif /* ! ACE_WIN32 && ! (ACE_LINUX && __alpha__) */ # if !defined (ACE_WIN32) @@ -443,18 +442,18 @@ ACE_High_Res_Timer::print_ave (const ACE_TCHAR *str, if (count > 1) { ACE_hrtime_t avg_nsecs = total_nanoseconds / (ACE_UINT32) count; - ACE_OS::snprintf (buf, 100, - ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"), - count, - total_secs, - (extra_nsecs + 500u) / 1000u, - (u_long) ((avg_nsecs + 500u) / 1000u)); + ACE_OS::sprintf (buf, + ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"), + count, + total_secs, + (extra_nsecs + 500u) / 1000u, + (u_long) ((avg_nsecs + 500u) / 1000u)); } else - ACE_OS::snprintf (buf, 100, - ACE_TEXT (" total %3lu.%06lu secs\n"), - total_secs, - (extra_nsecs + 500lu) / 1000lu); + ACE_OS::sprintf (buf, + ACE_TEXT (" total %3lu.%06lu secs\n"), + total_secs, + (extra_nsecs + 500lu) / 1000lu); ACE_OS::write (handle, str, @@ -486,18 +485,18 @@ ACE_High_Res_Timer::print_total (const ACE_TCHAR *str, { ACE_hrtime_t avg_nsecs = this->total_ / (ACE_UINT32) count; - ACE_OS::snprintf (buf, 100, - ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"), - count, - total_secs, - (extra_nsecs + 500u) / 1000u, - (u_long) ((avg_nsecs + 500u) / 1000u)); + ACE_OS::sprintf (buf, + ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"), + count, + total_secs, + (extra_nsecs + 500u) / 1000u, + (u_long) ((avg_nsecs + 500u) / 1000u)); } else - ACE_OS::snprintf (buf, 100, - ACE_TEXT (" total %3lu.%06u secs\n"), - total_secs, - (extra_nsecs + 500u) / 1000u); + ACE_OS::sprintf (buf, + ACE_TEXT (" total %3lu.%06u secs\n"), + total_secs, + (extra_nsecs + 500u) / 1000u); ACE_OS::write (handle, str, diff --git a/dep/acelite/ace/High_Res_Timer.h b/dep/acelite/ace/High_Res_Timer.h index 848ec9904..d01149bce 100644 --- a/dep/acelite/ace/High_Res_Timer.h +++ b/dep/acelite/ace/High_Res_Timer.h @@ -4,7 +4,9 @@ /** * @file High_Res_Timer.h * - * @author Douglas C. Schmidt + * $Id: High_Res_Timer.h 95798 2012-05-31 07:58:55Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -246,14 +248,14 @@ public: static void hrtime_to_tv (ACE_Time_Value &tv, const ACE_hrtime_t hrt); -#if defined (ACE_LINUX) && !defined (ACE_LACKS_SSCANF) +#if defined (ACE_LINUX) /** * This is used to find out the Mhz of the machine for the scale * factor. If there are any problems getting it, we just return 1 * (the default). */ static ACE_UINT32 get_cpuinfo (void); -#endif /* defined (ACE_LINUX) && !ACE_LACKS_SSCANF */ +#endif /* defined (ACE_LINUX) */ private: /** diff --git a/dep/acelite/ace/High_Res_Timer.inl b/dep/acelite/ace/High_Res_Timer.inl index fd0a1e8b0..c22c47cc3 100644 --- a/dep/acelite/ace/High_Res_Timer.inl +++ b/dep/acelite/ace/High_Res_Timer.inl @@ -1,4 +1,6 @@ // -*- C++ -*- */ +// $Id: High_Res_Timer.inl 95798 2012-05-31 07:58:55Z johnnyw $ + #include "ace/Global_Macros.h" #if defined (ACE_WIN32) diff --git a/dep/acelite/ace/ICMP_Socket.cpp b/dep/acelite/ace/ICMP_Socket.cpp index 87ed3f586..810751d31 100644 --- a/dep/acelite/ace/ICMP_Socket.cpp +++ b/dep/acelite/ace/ICMP_Socket.cpp @@ -1,3 +1,5 @@ +// $Id: ICMP_Socket.cpp 97309 2013-09-01 13:10:27Z mesnier_p $ + #include "ace/ICMP_Socket.h" #if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1) @@ -7,9 +9,6 @@ #include "ace/Log_Category.h" #include "ace/OS_NS_netdb.h" #include "ace/OS_NS_sys_socket.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/ICMP_Socket.h b/dep/acelite/ace/ICMP_Socket.h index 70161ca63..251ec307a 100644 --- a/dep/acelite/ace/ICMP_Socket.h +++ b/dep/acelite/ace/ICMP_Socket.h @@ -4,6 +4,8 @@ /** * @file ICMP_Socket.h * + * $Id: ICMP_Socket.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Robert S. Iakobashvili * @author Gonzalo A. Diethelm */ diff --git a/dep/acelite/ace/INET_Addr.cpp b/dep/acelite/ace/INET_Addr.cpp index b51cfe9fa..6decc75fa 100644 --- a/dep/acelite/ace/INET_Addr.cpp +++ b/dep/acelite/ace/INET_Addr.cpp @@ -1,3 +1,5 @@ +// $Id: INET_Addr.cpp 97355 2013-09-27 22:16:09Z shuston $ + // Defines the Internet domain address family address format. #include "ace/INET_Addr.h" @@ -16,9 +18,6 @@ #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_sys_socket.h" #include "ace/Truncate.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -70,9 +69,9 @@ ACE_INET_Addr::addr_to_string (ACE_TCHAR s[], if (size < total_len) return -1; else - ACE_OS::snprintf (s, size, format, - ACE_TEXT_CHAR_TO_TCHAR (hoststr), - this->get_port_number ()); + ACE_OS::sprintf (s, format, + ACE_TEXT_CHAR_TO_TCHAR (hoststr), + this->get_port_number ()); return 0; } @@ -155,38 +154,11 @@ ACE_INET_Addr::hash (void) const return this->get_ip_address () + this->get_port_number (); } -bool -ACE_INET_Addr::next (void) -{ - if (this->inet_addrs_.empty () || - this->inet_addrs_iter_ == this->inet_addrs_.end ()) - return false; - - union ip46 next_a = *this->inet_addrs_iter_++; - this->set_addr (&next_a, sizeof (next_a)); - return true; -} - -void -ACE_INET_Addr::reset (void) -{ - this->inet_addrs_iter_ = this->inet_addrs_.begin (); - this->next (); -} - ACE_INET_Addr::ACE_INET_Addr (void) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); -} - -ACE_INET_Addr & -ACE_INET_Addr::operator= (const ACE_INET_Addr& rhs) -{ - if (this != &rhs) - this->set (rhs); - return *this; + this->reset (); } int @@ -206,8 +178,6 @@ ACE_INET_Addr::set (const ACE_INET_Addr &sa) this->set_type (sa.get_type()); this->set_size (sa.get_size()); - this->inet_addrs_ = sa.inet_addrs_; - this->reset (); } return 0; @@ -283,11 +253,7 @@ ACE_INET_Addr::string_to_addr (const char s[], int address_family) result = this->set (port_p, ip_addr); } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (ACE_MALLOC_T (ip_buf)); -#else ACE_OS::free (ACE_MALLOC_T (ip_buf)); -#endif /* ACE_HAS_ALLOC_HOOKS */ return result; } @@ -295,7 +261,6 @@ int ACE_INET_Addr::set (const char address[], int address_family) { ACE_TRACE ("ACE_INET_Addr::set"); - this->reset_i (); return this->string_to_addr (address, address_family); } @@ -303,6 +268,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); this->set (address, address_family); } @@ -311,6 +277,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); this->set (address, address_family); } @@ -322,6 +289,7 @@ ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) : ACE_Addr (sa.get_type (), sa.get_size()) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); this->set (sa); } @@ -335,7 +303,6 @@ ACE_INET_Addr::set (u_short port_number, int map) { ACE_TRACE ("ACE_INET_Addr::set"); - this->reset_i (); this->set_address (reinterpret_cast (&inet_address), sizeof inet_address, encode, map); @@ -363,98 +330,112 @@ ACE_INET_Addr::set (u_short port_number, return -1; } - this->reset_i (); + ACE_OS::memset ((void *) &this->inet_addr_, + 0, + sizeof this->inet_addr_); -#if defined ACE_HAS_IPV6 && defined ACE_USES_IPV4_IPV6_MIGRATION +#if defined (ACE_HAS_IPV6) + // Let the IPv4 case fall through to the non-IPv6-capable section. + // We don't need the additional getaddrinfo() capability and the Linux + // getaddrinfo() is substantially slower than gethostbyname() w/ + // large vlans. +# if defined (ACE_USES_IPV4_IPV6_MIGRATION) if (address_family == AF_UNSPEC && !ACE::ipv6_enabled ()) address_family = AF_INET; -#endif /* ACE_HAS_IPV6 && ACE_USES_IPV4_IPV6_MIGRATION */ - -#ifdef ACE_HAS_IPV6 - if (address_family == AF_UNSPEC && ACE::ipv6_enabled ()) - address_family = AF_INET6; - - if (address_family != AF_INET - && ACE_OS::inet_pton (AF_INET6, host_name, - &this->inet_addr_.in6_.sin6_addr) == 1) +# endif /* ACE_USES_IPV4_IPV6_MIGRATION */ + if (address_family != AF_INET) { - this->base_set (AF_INET6, sizeof this->inet_addr_.in4_); -# ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN - this->inet_addr_.in6_.sin6_len = sizeof this->inet_addr_.in6_; -# endif - this->inet_addr_.in6_.sin6_family = AF_INET6; - this->set_size (sizeof this->inet_addr_.in6_); - this->set_type (AF_INET6); - this->set_port_number (port_number, encode); - return 0; +# if defined (ACE_HAS_GETHOSTBYNAME2) + hostent hentry; + hostent *hp; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! + + if (0 == ::gethostbyname2_r (host_name, AF_INET6, &hentry, + buf, sizeof(buf), &hp, &h_error)) + { + if (hp != 0) + { + struct sockaddr_in6 v6; + ACE_OS::memset (&v6, 0, sizeof (v6)); + v6.sin6_family = AF_INET6; + (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, + hp->h_addr, + hp->h_length); + this->set_type (hp->h_addrtype); + this->set_addr (&v6, hp->h_length); + this->set_port_number (port_number, encode); + return 0; + } + } + errno = h_error; + if (address_family == AF_INET6) + return -1; +# else + struct addrinfo hints; + struct addrinfo *res = 0; + int error = 0; + ACE_OS::memset (&hints, 0, sizeof (hints)); + hints.ai_family = AF_INET6; + if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) + { + this->set_type (res->ai_family); + this->set_addr (res->ai_addr, + ACE_Utils::truncate_cast(res->ai_addrlen)); + this->set_port_number (port_number, encode); + ::freeaddrinfo (res); + return 0; + } + if (address_family == AF_INET6) + { + if (res) + ::freeaddrinfo(res); + errno = error; + return -1; + } +# endif /* ACE_HAS_GETHOSTBYNAME2 */ + // Let AF_UNSPEC try again w/ IPv4. } -#else - address_family = AF_INET; #endif /* ACE_HAS_IPV6 */ - if (ACE_OS::inet_pton (AF_INET, host_name, - &this->inet_addr_.in4_.sin_addr) == 1) - { - this->base_set (AF_INET, sizeof this->inet_addr_.in4_); + // IPv6 not supported... insure the family is set to IPv4 + address_family = AF_INET; + this->set_type (address_family); + this->inet_addr_.in4_.sin_family = static_cast (address_family); #ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN - this->inet_addr_.in4_.sin_len = sizeof this->inet_addr_.in4_; + this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_); #endif - this->inet_addr_.in4_.sin_family = AF_INET; - this->set_size (sizeof this->inet_addr_.in4_); - this->set_type (AF_INET); - this->set_port_number (port_number, encode); - return 0; - } - - addrinfo hints; - ACE_OS::memset (&hints, 0, sizeof hints); - hints.ai_family = address_family; - // The ai_flags used to contain AI_ADDRCONFIG as well but that prevented - // lookups from completing if there is no, or only a loopback, IPv6 - // interface configured. See Bugzilla 4211 for more info. - - hints.ai_flags = AI_V4MAPPED; -#if defined(ACE_HAS_IPV6) && defined(AI_ALL) - // Without AI_ALL, Windows machines exhibit inconsistent behaviors on - // difference machines we have tested. - hints.ai_flags |= AI_ALL; -#endif - - // Note - specify the socktype here to avoid getting multiple entries - // returned with the same address for different socket types or - // protocols. If this causes a problem for some reason (an address that's - // available for TCP but not UDP, or vice-versa) this will need to change - // back to unrestricted hints and weed out the duplicate addresses by - // searching this->inet_addrs_ which would slow things down. - hints.ai_socktype = SOCK_STREAM; - - addrinfo *res = 0; - const int error = ACE_OS::getaddrinfo (host_name, 0, &hints, &res); - - if (error) + struct in_addr addrv4; + if (ACE_OS::inet_aton (host_name, + &addrv4) == 1) + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + else { - errno = error; - return -1; - } + hostent hentry; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! - this->set_type (res->ai_family); + hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, + buf, &h_error); + if (hp == 0) + errno = h_error; - for (addrinfo *curr = res; curr; curr = curr->ai_next) - { - ip46 addr; - ACE_OS::memcpy (&addr, curr->ai_addr, curr->ai_addrlen); -#ifdef ACE_HAS_IPV6 - if (curr->ai_family == AF_INET6) - addr.in6_.sin6_port = encode ? ACE_NTOHS (port_number) : port_number; + if (hp == 0) + { + return -1; + } else -#endif - addr.in4_.sin_port = encode ? ACE_NTOHS (port_number) : port_number; - this->inet_addrs_.push_back (addr); + { + (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, + hp->h_addr, + hp->h_length); + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + } } - - ACE_OS::freeaddrinfo (res); - this->reset (); - return 0; } // Helper function to get a port number from a port name. @@ -512,7 +493,6 @@ ACE_INET_Addr::set (const char port_name[], { ACE_TRACE ("ACE_INET_Addr::set"); - this->reset_i (); int const port_number = get_port_number_from_name (port_name, protocol); if (port_number == -1) { @@ -520,9 +500,6 @@ ACE_INET_Addr::set (const char port_name[], } int address_family = PF_UNSPEC; - if (ACE_OS::strcmp(protocol, "tcp") == 0) - address_family = AF_INET; - # if defined (ACE_HAS_IPV6) if (ACE_OS::strcmp (protocol, "tcp6") == 0) address_family = AF_INET6; @@ -542,7 +519,6 @@ ACE_INET_Addr::set (const char port_name[], { ACE_TRACE ("ACE_INET_Addr::set"); - this->reset_i (); int const port_number = get_port_number_from_name (port_name, protocol); if (port_number == -1) { @@ -600,7 +576,6 @@ ACE_INET_Addr::set (const sockaddr_in *addr, int len) { ACE_TRACE ("ACE_INET_Addr::set"); - this->reset_i (); if (addr->sin_family == AF_INET) { int maxlen = static_cast (sizeof (this->inet_addr_.in4_)); @@ -636,18 +611,17 @@ ACE_INET_Addr::get_addr (void) const } void -ACE_INET_Addr::set_addr (const void *addr, int len) +ACE_INET_Addr::set_addr (void *addr, int len) { this->set_addr (addr, len, 0); } // Set a pointer to the address. void -ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) +ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) { ACE_TRACE ("ACE_INET_Addr::set_addr"); - const struct sockaddr_in *getfamily = - static_cast (addr); + struct sockaddr_in *getfamily = static_cast (addr); if (getfamily->sin_family == AF_INET) { @@ -665,8 +639,7 @@ ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) #if defined (ACE_HAS_IPV6) else if (getfamily->sin_family == AF_INET6) { - const struct sockaddr_in6 *in6 = - static_cast (addr); + struct sockaddr_in6 *in6 = static_cast (addr); this->set_port_number (in6->sin6_port, 0); this->set_address (reinterpret_cast (&in6->sin6_addr), sizeof (in6->sin6_addr), @@ -682,6 +655,7 @@ ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); this->set (addr, len); } @@ -692,6 +666,7 @@ ACE_INET_Addr::ACE_INET_Addr (u_short port_number, : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); if (this->set (port_number, inet_address) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -707,6 +682,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); if (this->set (port_name, host_name, protocol) == -1) @@ -721,6 +697,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); if (this->set (port_name, host_name, protocol) == -1) @@ -737,6 +714,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -751,6 +729,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); + this->reset (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -848,21 +827,7 @@ ACE_INET_Addr::set_port_number (u_short port_number, this->inet_addr_.in6_.sin6_port = port_number; else #endif /* ACE_HAS_IPV6 */ - this->inet_addr_.in4_.sin_port = port_number; - - if (this->inet_addrs_.empty ()) - return; - for (std::vector::iterator i = this->inet_addrs_.begin (); - i != this->inet_addrs_.end (); - i++) - { -#if defined (ACE_HAS_IPV6) - if (this->get_type () == AF_INET6) - i->in6_.sin6_port = port_number; - else -#endif /* ACE_HAS_IPV6 */ - i->in4_.sin_port = port_number; - } + this->inet_addr_.in4_.sin_port = port_number; } // returns -2 when the hostname is truncated @@ -882,19 +847,64 @@ ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const #else if (this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY) #endif /* ACE_HAS_IPV6 */ - return (ACE_OS::hostname (hostname, len) == -1) ? -1 : 0; + { + if (ACE_OS::hostname (hostname, len) == -1) + return -1; + else + return 0; + } + else + { + void* addr = this->ip_addr_pointer (); + int size = this->ip_addr_size (); + int type = this->get_type (); - const ACE_SOCKET_LEN addr_size = -#ifdef ACE_HAS_IPV6 - (this->get_type () == PF_INET6) ? sizeof (sockaddr_in6) : -#endif - sizeof (sockaddr_in); +# if defined (ACE_HAS_IPV6) && defined (ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED) + // Most OS can not handle IPv6-mapped-IPv4 addresses (even + // though they are meant to) so map them back to IPv4 addresses + // before trying to resolve them + in_addr demapped_addr; + if (type == PF_INET6 && + (this->is_ipv4_mapped_ipv6 () || this->is_ipv4_compat_ipv6 ())) + { + ACE_OS::memcpy (&demapped_addr.s_addr, &this->inet_addr_.in6_.sin6_addr.s6_addr[12], 4); + addr = &demapped_addr; + size = sizeof(demapped_addr); + type = PF_INET; + } +# endif /* ACE_HAS_IPV6 */ - const int res = ACE_OS::getnameinfo ((const sockaddr *) this->get_addr (), - addr_size, hostname, - static_cast (len), - 0, 0, 0); - return (res == 0) ? 0 : -1; + int h_error; // Not the same as errno! + hostent hentry; + ACE_HOSTENT_DATA buf; + hostent * const hp = + ACE_OS::gethostbyaddr_r (static_cast (addr), + size, + type, + &hentry, + buf, + &h_error); + + if (hp == 0 || hp->h_name == 0) + return -1; + + if (ACE_OS::strlen (hp->h_name) >= len) + { + // We know the length, so use memcpy + if (len > 0) + { + ACE_OS::memcpy (hostname, hp->h_name, len - 1); + hostname[len-1]= '\0'; + } + errno = ENOSPC; + return -2; // -2 Means that we have a good string + // Using errno looks ok, but ENOSPC could be set on + // other places. + } + + ACE_OS::strcpy (hostname, hp->h_name); + return 0; + } } int ACE_INET_Addr::set_address (const char *ip_addr, @@ -961,20 +971,17 @@ int ACE_INET_Addr::set_address (const char *ip_addr, sizeof (ip6)); return 0; } - else - { - // Build up a 128 bit address. An IPv4-mapped IPv6 address - // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined - // in RFC 1884 */ - ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); - this->inet_addr_.in6_.sin6_addr.s6_addr[10] = - this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; - ACE_OS::memcpy - (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); - } + + // Build up a 128 bit address. An IPv4-mapped IPv6 address + // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined + // in RFC 1884 */ + ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); + this->inet_addr_.in6_.sin6_addr.s6_addr[10] = + this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; + ACE_OS::memcpy + (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); } #endif /* ACE_HAS_IPV6 */ - return 0; } /* end if (len == 4) */ #if defined (ACE_HAS_IPV6) @@ -992,6 +999,7 @@ int ACE_INET_Addr::set_address (const char *ip_addr, this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); #endif ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); + return 0; } /* end len == 16 */ #endif /* ACE_HAS_IPV6 */ @@ -1050,11 +1058,12 @@ ACE_INET_Addr::get_host_addr (char *dst, int size) const //} # if defined (ACE_WIN32) - sockaddr *sa = reinterpret_cast - (const_cast (&this->inet_addr_.in6_)); - if (ACE_OS::getnameinfo (sa, this->get_size (), dst, size, - 0, 0, // Don't want service name - NI_NUMERICHOST) == 0) + if (0 == ::getnameinfo (reinterpret_cast (&this->inet_addr_.in6_), + this->get_size (), + dst, + size, + 0, 0, // Don't want service name + NI_NUMERICHOST)) return dst; ACE_OS::set_errno_to_wsa_last_error (); return 0; @@ -1069,8 +1078,7 @@ ACE_INET_Addr::get_host_addr (char *dst, int size) const this->inet_addr_.in6_.sin6_scope_id != 0) { char scope_buf[32]; - ACE_OS::snprintf (scope_buf, 32, "%%%u", - this->inet_addr_.in6_.sin6_scope_id); + ACE_OS::sprintf (scope_buf, "%%%u", this->inet_addr_.in6_.sin6_scope_id); if ((ACE_OS::strlen (ch)+ACE_OS::strlen (scope_buf)) < (size_t)size) { ACE_OS::strcat (dst, scope_buf); diff --git a/dep/acelite/ace/INET_Addr.h b/dep/acelite/ace/INET_Addr.h index 856874df4..3272a96a5 100644 --- a/dep/acelite/ace/INET_Addr.h +++ b/dep/acelite/ace/INET_Addr.h @@ -4,7 +4,9 @@ /** * @file INET_Addr.h * - * @author Douglas C. Schmidt + * $Id: INET_Addr.h 95533 2012-02-14 22:59:17Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -19,7 +21,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" -#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -28,10 +29,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @brief Defines a C++ wrapper facade for the Internet domain address * family format. - * - * ACE_INET_Addr can hold all of the IP addresses assigned to a single name. - * By default it refers only to the first, if there is more than one. The - * next() method can make the others available in turn. */ class ACE_Export ACE_INET_Addr : public ACE_Addr { @@ -57,14 +54,10 @@ public: /** * Initializes an ACE_INET_Addr from the @a address, which can be - * "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"), - * "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"), - * "ip-number:port-number" (e.g., "128.252.166.57:1234"), - * "ip-number:port-name" (e.g., "128.252.166.57:telnet"), - * "[ipv6-number]:port-number (e.g, "[2001:db8::57]:1234") or - * "[ipv6-number]:port-name (e.g, "[2001:db8::57]:telnet"). - * If there is no ':' in the @a address it is assumed to be a port number, - * with the IP address being INADDR_ANY. + * "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or + * "128.252.166.57:1234"). If there is no ':' in the @a address it + * is assumed to be a port number, with the IP address being + * INADDR_ANY. */ explicit ACE_INET_Addr (const char address[], int address_family = AF_UNSPEC); @@ -117,20 +110,6 @@ public: // These methods are useful after the object has been constructed. - /// Assignment. In a more well-ordered world, member-wise assignment would - /// work fine. However, because of the class design feature that all of the - /// acceptor/connector-type classes that can be used in the - /// Acceptor-Connector framework take ACE_Addr objects instead of the - /// addressing class matching the family in use. The mechanism used to - /// enable this substitution to the more-appropriate class is - /// ACE_sap_any_cast, which casts the ACE_Addr to the more-specific class. - /// In this case, casting an ACE_Addr to ACE_INET_Addr then copying it. - /// Since adding multiple address support to ACE_INET_Addr, that cast-copy - /// operation ends up, in the member-wise case, copying a bogus vector - /// and doing lots of random damage. Thus, this operator is used to make - /// life ordered in this common scenario. - ACE_INET_Addr & operator= (const ACE_INET_Addr &rhs); - /// Initializes from another ACE_INET_Addr. int set (const ACE_INET_Addr &); @@ -178,15 +157,11 @@ public: const char protocol[] = "tcp"); /** - * Initializes an ACE_INET_Addr from the @a address, which can be - * "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"), - * "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"), - * "ip-number:port-number" (e.g., "128.252.166.57:1234"), - * "ip-number:port-name" (e.g., "128.252.166.57:telnet"), - * "[ipv6-number]:port-number (e.g, "[2001:db8::57]:1234") or - * "[ipv6-number]:port-name (e.g, "[2001:db8::57]:telnet"). - * If there is no ':' in the @a address it is assumed to be a port number, - * with the IP address being INADDR_ANY. + * Initializes an ACE_INET_Addr from the @a addr, which can be + * "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or + * "128.252.166.57:1234"). If there is no ':' in the @a address it + * is assumed to be a port number, with the IP address being + * INADDR_ANY. */ int set (const char addr[], int address_family = AF_UNSPEC); @@ -216,16 +191,16 @@ public: int get_addr_size(void) const; /// Set a pointer to the address. - virtual void set_addr (const void *, int len); + virtual void set_addr (void *, int len); /// Set a pointer to the address. - virtual void set_addr (const void *, int len, int map); + virtual void set_addr (void *, int len, int map); /** * Transform the current ACE_INET_Addr address into string format. - * If @a ipaddr_format is true this produces "ip-number:port-number" - * (e.g., "128.252.166.57:1234" or "[2001:db8::57]:1234"), whereas - * if @a ipaddr_format is false this produces "ip-name:port-number" (e.g., + * If @a ipaddr_format is ttrue this produces "ip-number:port-number" + * (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false + * this produces "ip-name:port-number" (e.g., * "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the * @a buffer is too small, else 0. */ @@ -237,11 +212,9 @@ public: * Initializes an ACE_INET_Addr from the @a address, which can be * "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"), * "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"), - * "ip-number:port-number" (e.g., "128.252.166.57:1234"), - * "ip-number:port-name" (e.g., "128.252.166.57:telnet"), - * "[ipv6-number]:port-number (e.g, "[2001:db8::57]:1234") or - * "[ipv6-number]:port-name (e.g, "[2001:db8::57]:telnet"). - * If there is no ':' in the @a address it is assumed to be a port number, + * "ip-number:port-number" (e.g., "128.252.166.57:1234"), or + * "ip-number:port-name" (e.g., "128.252.166.57:telnet"). If there + * is no ':' in the @a address it is assumed to be a port number, * with the IP address being INADDR_ANY. */ virtual int string_to_addr (const char address[], @@ -376,13 +349,6 @@ public: /// Computes and returns hash value. virtual u_long hash (void) const; - /// If there is another address to examine, move to it and return true; - /// else return false. - bool next (void); - - /// Reset the set of address so they can be scanned again using next(). - void reset (void); - /// Dump the state of an object. void dump (void) const; @@ -400,22 +366,18 @@ private: int determine_type (void) const; /// Initialize underlying inet_addr_ to default values - void reset_i (void); + void reset (void); /// Underlying representation. /// This union uses the knowledge that the two structures share the /// first member, sa_family (as all sockaddr structures do). - union ip46 + union { sockaddr_in in4_; #if defined (ACE_HAS_IPV6) sockaddr_in6 in6_; #endif /* ACE_HAS_IPV6 */ } inet_addr_; - // If there is more than one address assigned to a given name, this - // holds all of them; one is always copied to inet_addr_. - std::vector inet_addrs_; - std::vector::iterator inet_addrs_iter_; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/INET_Addr.inl b/dep/acelite/ace/INET_Addr.inl index 3e7b18f3e..eb3923185 100644 --- a/dep/acelite/ace/INET_Addr.inl +++ b/dep/acelite/ace/INET_Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: INET_Addr.inl 96017 2012-08-08 22:18:09Z mitza $ + #include "ace/OS_NS_string.h" #include "ace/Global_Macros.h" @@ -7,7 +10,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void -ACE_INET_Addr::reset_i (void) +ACE_INET_Addr::reset (void) { ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); if (this->get_type() == AF_INET) @@ -26,9 +29,6 @@ ACE_INET_Addr::reset_i (void) this->inet_addr_.in6_.sin6_family = AF_INET6; } #endif /* ACE_HAS_IPV6 */ - this->inet_addrs_.clear (); - this->inet_addrs_iter_ = this->inet_addrs_.end (); - } ACE_INLINE int diff --git a/dep/acelite/ace/IOStream.cpp b/dep/acelite/ace/IOStream.cpp index a4158b001..59d0191f4 100644 --- a/dep/acelite/ace/IOStream.cpp +++ b/dep/acelite/ace/IOStream.cpp @@ -1,3 +1,5 @@ +// $Id: IOStream.cpp 93359 2011-02-11 11:33:12Z mcorino $ + #ifndef ACE_IOSTREAM_CPP #define ACE_IOSTREAM_CPP diff --git a/dep/acelite/ace/IOStream.h b/dep/acelite/ace/IOStream.h index cd22e65e9..97bbc23b7 100644 --- a/dep/acelite/ace/IOStream.h +++ b/dep/acelite/ace/IOStream.h @@ -4,6 +4,8 @@ /** * @file IOStream.h * + * $Id: IOStream.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author James CE Johnson * @author Jim Crossley */ diff --git a/dep/acelite/ace/IOStream_T.cpp b/dep/acelite/ace/IOStream_T.cpp index 21b8e6626..3e7817d7c 100644 --- a/dep/acelite/ace/IOStream_T.cpp +++ b/dep/acelite/ace/IOStream_T.cpp @@ -1,3 +1,5 @@ +// $Id: IOStream_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_IOSTREAM_T_CPP #define ACE_IOSTREAM_T_CPP diff --git a/dep/acelite/ace/IOStream_T.h b/dep/acelite/ace/IOStream_T.h index d67e4ee41..6a6cda570 100644 --- a/dep/acelite/ace/IOStream_T.h +++ b/dep/acelite/ace/IOStream_T.h @@ -4,6 +4,8 @@ /** * @file IOStream_T.h * + * $Id: IOStream_T.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author James CE Johnson * @author Jim Crossley * diff --git a/dep/acelite/ace/IOStream_T.inl b/dep/acelite/ace/IOStream_T.inl index 1797de613..513d6ecb1 100644 --- a/dep/acelite/ace/IOStream_T.inl +++ b/dep/acelite/ace/IOStream_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: IOStream_T.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Handle_Set.h" #include "ace/OS_NS_errno.h" #include "ace/OS_NS_sys_select.h" diff --git a/dep/acelite/ace/IO_Cntl_Msg.cpp b/dep/acelite/ace/IO_Cntl_Msg.cpp index 3501a376c..b9badd5c1 100644 --- a/dep/acelite/ace/IO_Cntl_Msg.cpp +++ b/dep/acelite/ace/IO_Cntl_Msg.cpp @@ -1,3 +1,5 @@ +// $Id: IO_Cntl_Msg.cpp 92069 2010-09-28 11:38:59Z johnnyw $ + #include "ace/IO_Cntl_Msg.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/IO_Cntl_Msg.h b/dep/acelite/ace/IO_Cntl_Msg.h index e4f2a2a5f..1b20f53d4 100644 --- a/dep/acelite/ace/IO_Cntl_Msg.h +++ b/dep/acelite/ace/IO_Cntl_Msg.h @@ -4,6 +4,8 @@ /** * @file IO_Cntl_Msg.h * + * $Id: IO_Cntl_Msg.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/IO_Cntl_Msg.inl b/dep/acelite/ace/IO_Cntl_Msg.inl index 17f1dbcfb..8cfaad624 100644 --- a/dep/acelite/ace/IO_Cntl_Msg.inl +++ b/dep/acelite/ace/IO_Cntl_Msg.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: IO_Cntl_Msg.inl 97589 2014-02-14 18:38:51Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/IO_SAP.cpp b/dep/acelite/ace/IO_SAP.cpp index 9411e7653..cebbc8ff3 100644 --- a/dep/acelite/ace/IO_SAP.cpp +++ b/dep/acelite/ace/IO_SAP.cpp @@ -1,3 +1,5 @@ +// $Id: IO_SAP.cpp 97661 2014-03-17 09:52:07Z johnnyw $ + #include "ace/IO_SAP.h" #include "ace/Log_Category.h" @@ -5,9 +7,6 @@ #include "ace/OS_NS_errno.h" #include "ace/OS_NS_fcntl.h" #include "ace/os_include/os_signal.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/IO_SAP.inl" diff --git a/dep/acelite/ace/IO_SAP.h b/dep/acelite/ace/IO_SAP.h index f1183e638..44f5202d1 100644 --- a/dep/acelite/ace/IO_SAP.h +++ b/dep/acelite/ace/IO_SAP.h @@ -4,6 +4,8 @@ /** * @file IO_SAP.h * + * $Id: IO_SAP.h 97661 2014-03-17 09:52:07Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/IO_SAP.inl b/dep/acelite/ace/IO_SAP.inl index d3472bb97..4c3182fa6 100644 --- a/dep/acelite/ace/IO_SAP.inl +++ b/dep/acelite/ace/IO_SAP.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: IO_SAP.inl 93736 2011-04-05 12:38:35Z johnnyw $ + #include "ace/OS_NS_stropts.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/IPC_SAP.cpp b/dep/acelite/ace/IPC_SAP.cpp index 1bf77aaf2..edeae03fc 100644 --- a/dep/acelite/ace/IPC_SAP.cpp +++ b/dep/acelite/ace/IPC_SAP.cpp @@ -1,3 +1,5 @@ +// $Id: IPC_SAP.cpp 97661 2014-03-17 09:52:07Z johnnyw $ + #include "ace/IPC_SAP.h" #include "ace/Log_Category.h" @@ -5,9 +7,6 @@ #include "ace/os_include/os_signal.h" #include "ace/OS_NS_errno.h" #include "ace/OS_NS_fcntl.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/IPC_SAP.inl" diff --git a/dep/acelite/ace/IPC_SAP.h b/dep/acelite/ace/IPC_SAP.h index ff48c3657..c7576889e 100644 --- a/dep/acelite/ace/IPC_SAP.h +++ b/dep/acelite/ace/IPC_SAP.h @@ -4,7 +4,9 @@ /** * @file IPC_SAP.h * - * @author Douglas C. Schmidt + * $Id: IPC_SAP.h 97661 2014-03-17 09:52:07Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/IPC_SAP.inl b/dep/acelite/ace/IPC_SAP.inl index 841960914..5e8048690 100644 --- a/dep/acelite/ace/IPC_SAP.inl +++ b/dep/acelite/ace/IPC_SAP.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: IPC_SAP.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_stropts.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/If_Then_Else.h b/dep/acelite/ace/If_Then_Else.h index 5b8d3e93f..a6b0a4df6 100644 --- a/dep/acelite/ace/If_Then_Else.h +++ b/dep/acelite/ace/If_Then_Else.h @@ -8,6 +8,8 @@ * template described in the book "C++ Templates" by Vandevoorde and * Josuttis. * + * $Id: If_Then_Else.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Ossama Othman */ //============================================================================= diff --git a/dep/acelite/ace/Init_ACE.cpp b/dep/acelite/ace/Init_ACE.cpp index 9e07a8ab4..f3ea96866 100644 --- a/dep/acelite/ace/Init_ACE.cpp +++ b/dep/acelite/ace/Init_ACE.cpp @@ -1,3 +1,4 @@ +// $Id: Init_ACE.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ #include "ace/Init_ACE.h" #include "ace/Object_Manager.h" diff --git a/dep/acelite/ace/Init_ACE.h b/dep/acelite/ace/Init_ACE.h index dbf06ead9..5478139e4 100644 --- a/dep/acelite/ace/Init_ACE.h +++ b/dep/acelite/ace/Init_ACE.h @@ -4,6 +4,8 @@ /** * @file Init_ACE.h * + * $Id: Init_ACE.h 97431 2013-11-19 14:28:52Z johnnyw $ + * * Initialize and finalize the ACE library services. You can * generally execute the @a ACE::init() and @a ACE::fini() sequence * multiple times, but be aware that nothing that ACE controls (e.g., diff --git a/dep/acelite/ace/Intrusive_Auto_Ptr.cpp b/dep/acelite/ace/Intrusive_Auto_Ptr.cpp index 69ecffe28..4f9890353 100644 --- a/dep/acelite/ace/Intrusive_Auto_Ptr.cpp +++ b/dep/acelite/ace/Intrusive_Auto_Ptr.cpp @@ -1,3 +1,5 @@ +// $Id: Intrusive_Auto_Ptr.cpp 81166 2008-03-31 15:00:23Z iliyan $ + #ifndef ACE_INTRUSIVE_AUTO_PTR_CPP #define ACE_INTRUSIVE_AUTO_PTR_CPP @@ -9,8 +11,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Intrusive_Auto_Ptr) - template ACE_Intrusive_Auto_Ptr::~ACE_Intrusive_Auto_Ptr (void) { diff --git a/dep/acelite/ace/Intrusive_Auto_Ptr.h b/dep/acelite/ace/Intrusive_Auto_Ptr.h index 3448080f8..9c6ad3482 100644 --- a/dep/acelite/ace/Intrusive_Auto_Ptr.h +++ b/dep/acelite/ace/Intrusive_Auto_Ptr.h @@ -4,6 +4,8 @@ /** * @file Intrusive_Auto_Ptr.h * + * $Id: Intrusive_Auto_Ptr.h 81388 2008-04-23 14:02:05Z johnnyw $ + * * @author Iliyan Jeliazkov * * @note Modeled on http://www.boost.org/boost/intrusive_ptr.hpp @@ -15,6 +17,7 @@ #include /**/ "ace/pre.h" +#include "ace/Auto_Ptr.h" #include "ace/Atomic_Op.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) diff --git a/dep/acelite/ace/Intrusive_Auto_Ptr.inl b/dep/acelite/ace/Intrusive_Auto_Ptr.inl index 7d353e316..8216e7213 100644 --- a/dep/acelite/ace/Intrusive_Auto_Ptr.inl +++ b/dep/acelite/ace/Intrusive_Auto_Ptr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Intrusive_Auto_Ptr.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Guard_T.h" #include "ace/Log_Category.h" @@ -80,7 +83,7 @@ ACE_Intrusive_Auto_Ptr::operator = (const ACE_Intrusive_Auto_Ptr &rhs) // assign a zero if (rhs.rep_ == 0) { - X::intrusive_remove_ref (this->rep_); + X::intrusive_remove_ref (rhs.rep_); this->rep_ = 0; return; } diff --git a/dep/acelite/ace/Intrusive_List.cpp b/dep/acelite/ace/Intrusive_List.cpp index 0623adbe4..4b64ef1e8 100644 --- a/dep/acelite/ace/Intrusive_List.cpp +++ b/dep/acelite/ace/Intrusive_List.cpp @@ -1,3 +1,5 @@ +// $Id: Intrusive_List.cpp 92069 2010-09-28 11:38:59Z johnnyw $ + #ifndef ACE_INTRUSIVE_LIST_CPP #define ACE_INTRUSIVE_LIST_CPP diff --git a/dep/acelite/ace/Intrusive_List.h b/dep/acelite/ace/Intrusive_List.h index 0bc823960..b5f32f683 100644 --- a/dep/acelite/ace/Intrusive_List.h +++ b/dep/acelite/ace/Intrusive_List.h @@ -4,6 +4,8 @@ /** * @file Intrusive_List.h * + * $Id: Intrusive_List.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= @@ -50,6 +52,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @todo The ACE_Message_Queue is an example of an intrusive list (or * queue) but it is not implemented in terms of this class. + * */ template class ACE_Intrusive_List diff --git a/dep/acelite/ace/Intrusive_List.inl b/dep/acelite/ace/Intrusive_List.inl index 17d7a1565..851400937 100644 --- a/dep/acelite/ace/Intrusive_List.inl +++ b/dep/acelite/ace/Intrusive_List.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Intrusive_List.inl 91688 2010-09-09 11:21:50Z johnnyw $ + #include ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Intrusive_List_Node.cpp b/dep/acelite/ace/Intrusive_List_Node.cpp index 830ea4b1c..1e14537a4 100644 --- a/dep/acelite/ace/Intrusive_List_Node.cpp +++ b/dep/acelite/ace/Intrusive_List_Node.cpp @@ -1,3 +1,5 @@ +// $Id: Intrusive_List_Node.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_INTRUSIVE_LIST_NODE_CPP #define ACE_INTRUSIVE_LIST_NODE_CPP diff --git a/dep/acelite/ace/Intrusive_List_Node.h b/dep/acelite/ace/Intrusive_List_Node.h index 732a51792..dcfbd89e7 100644 --- a/dep/acelite/ace/Intrusive_List_Node.h +++ b/dep/acelite/ace/Intrusive_List_Node.h @@ -4,6 +4,8 @@ /** * @file Intrusive_List_Node.h * + * $Id: Intrusive_List_Node.h 83968 2008-12-04 08:11:41Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/Intrusive_List_Node.inl b/dep/acelite/ace/Intrusive_List_Node.inl index 220453adc..52c4f7dec 100644 --- a/dep/acelite/ace/Intrusive_List_Node.inl +++ b/dep/acelite/ace/Intrusive_List_Node.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Intrusive_List_Node.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE T* diff --git a/dep/acelite/ace/LOCK_SOCK_Acceptor.cpp b/dep/acelite/ace/LOCK_SOCK_Acceptor.cpp index 65a5512ba..2140454bc 100644 --- a/dep/acelite/ace/LOCK_SOCK_Acceptor.cpp +++ b/dep/acelite/ace/LOCK_SOCK_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: LOCK_SOCK_Acceptor.cpp 82723 2008-09-16 09:35:44Z johnnyw $ + #ifndef ACE_LOCK_SOCK_ACCEPTOR_CPP #define ACE_LOCK_SOCK_ACCEPTOR_CPP diff --git a/dep/acelite/ace/LOCK_SOCK_Acceptor.h b/dep/acelite/ace/LOCK_SOCK_Acceptor.h index 619e92f8a..6eff834eb 100644 --- a/dep/acelite/ace/LOCK_SOCK_Acceptor.h +++ b/dep/acelite/ace/LOCK_SOCK_Acceptor.h @@ -4,6 +4,8 @@ /** * @file LOCK_SOCK_Acceptor.h * + * $Id: LOCK_SOCK_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author James Hu and Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/LSOCK.cpp b/dep/acelite/ace/LSOCK.cpp index 332890ed8..401001396 100644 --- a/dep/acelite/ace/LSOCK.cpp +++ b/dep/acelite/ace/LSOCK.cpp @@ -1,3 +1,5 @@ +// $Id: LSOCK.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/LSOCK.h" @@ -6,9 +8,6 @@ #include "ace/Log_Category.h" #include "ace/OS_NS_sys_socket.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/LSOCK.inl" @@ -40,7 +39,7 @@ ACE_LSOCK::send_handle (const ACE_HANDLE handle) const u_char a[2]; iovec iov; msghdr send_msg; -#if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN]; cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ @@ -54,10 +53,7 @@ ACE_LSOCK::send_handle (const ACE_HANDLE handle) const send_msg.msg_name = 0; send_msg.msg_namelen = 0; -#if defined (ACE_LACKS_SENDMSG) - ACE_UNUSED_ARG(handle); -#else -# if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) cmsgptr->cmsg_level = SOL_SOCKET; cmsgptr->cmsg_type = SCM_RIGHTS; cmsgptr->cmsg_len = sizeof cmsgbuf; @@ -66,11 +62,10 @@ ACE_LSOCK::send_handle (const ACE_HANDLE handle) const ACE_HANDLE *ph = (ACE_HANDLE *) CMSG_DATA (cmsgptr); *ph = handle; send_msg.msg_flags = 0; -# else +#else send_msg.msg_accrights = (char *) &handle; send_msg.msg_accrightslen = sizeof handle; -# endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ -#endif /* ACE_LACKS_SENDMSG */ +#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ return ACE_OS::sendmsg (this->get_handle (), &send_msg, 0); } @@ -106,8 +101,6 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const recv_msg.msg_iovlen = 1; recv_msg.msg_name = 0; recv_msg.msg_namelen = 0; - -#ifndef ACE_LACKS_SENDMSG #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) recv_msg.msg_control = cmsgbuf; recv_msg.msg_controllen = sizeof cmsgbuf; @@ -115,7 +108,6 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const recv_msg.msg_accrights = (char *) &handle; recv_msg.msg_accrightslen = sizeof handle; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ -#endif /* ACE_LACKS_SENDMSG */ #if defined (ACE_HAS_STREAMS) @@ -150,7 +142,6 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const && ((u_char *) iov.iov_base)[0] == 0xab && ((u_char *) iov.iov_base)[1] == 0xcd) { -#ifndef ACE_LACKS_SENDMSG #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) // Close down the socket that was returned by the MSG_PEEK. cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; @@ -162,7 +153,7 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const recv_msg.msg_accrights = (char *) &handle; recv_msg.msg_accrightslen = sizeof handle; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ -#endif /* ACE_LACKS_SENDMSG */ + if (ACE_OS::recvmsg (this->get_handle (), &recv_msg, 0) == ACE_INVALID_HANDLE) return ACE_INVALID_HANDLE; diff --git a/dep/acelite/ace/LSOCK.h b/dep/acelite/ace/LSOCK.h index cb9603afd..7cf7abc47 100644 --- a/dep/acelite/ace/LSOCK.h +++ b/dep/acelite/ace/LSOCK.h @@ -4,6 +4,8 @@ /** * @file LSOCK.h * + * $Id: LSOCK.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/LSOCK.inl b/dep/acelite/ace/LSOCK.inl index 9815783f3..6bf726ad2 100644 --- a/dep/acelite/ace/LSOCK.inl +++ b/dep/acelite/ace/LSOCK.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: LSOCK.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Simple-minded constructor. diff --git a/dep/acelite/ace/LSOCK_Acceptor.cpp b/dep/acelite/ace/LSOCK_Acceptor.cpp index 28a45ea3f..e32f04d31 100644 --- a/dep/acelite/ace/LSOCK_Acceptor.cpp +++ b/dep/acelite/ace/LSOCK_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: LSOCK_Acceptor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/LSOCK_Acceptor.h" #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) @@ -5,9 +7,6 @@ #include "ace/Log_Category.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_sys_socket.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ diff --git a/dep/acelite/ace/LSOCK_Acceptor.h b/dep/acelite/ace/LSOCK_Acceptor.h index d15db5288..b10c55c5d 100644 --- a/dep/acelite/ace/LSOCK_Acceptor.h +++ b/dep/acelite/ace/LSOCK_Acceptor.h @@ -4,6 +4,8 @@ /** * @file LSOCK_Acceptor.h * + * $Id: LSOCK_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/LSOCK_CODgram.cpp b/dep/acelite/ace/LSOCK_CODgram.cpp index d3f6d72e6..6c9ec3906 100644 --- a/dep/acelite/ace/LSOCK_CODgram.cpp +++ b/dep/acelite/ace/LSOCK_CODgram.cpp @@ -1,10 +1,9 @@ +// $Id: LSOCK_CODgram.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/LSOCK_CODgram.h" #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ diff --git a/dep/acelite/ace/LSOCK_CODgram.h b/dep/acelite/ace/LSOCK_CODgram.h index 694df50d4..c2858a8ed 100644 --- a/dep/acelite/ace/LSOCK_CODgram.h +++ b/dep/acelite/ace/LSOCK_CODgram.h @@ -4,7 +4,9 @@ /** * @file LSOCK_CODgram.h * - * @author Douglas C. Schmidt + * $Id: LSOCK_CODgram.h 84419 2009-02-11 22:28:11Z shuston $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/LSOCK_CODgram.inl b/dep/acelite/ace/LSOCK_CODgram.inl index 1ebcf344b..02870c65a 100644 --- a/dep/acelite/ace/LSOCK_CODgram.inl +++ b/dep/acelite/ace/LSOCK_CODgram.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: LSOCK_CODgram.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Do nothing constructor. diff --git a/dep/acelite/ace/LSOCK_Connector.cpp b/dep/acelite/ace/LSOCK_Connector.cpp index a7c9b2e71..273580dbd 100644 --- a/dep/acelite/ace/LSOCK_Connector.cpp +++ b/dep/acelite/ace/LSOCK_Connector.cpp @@ -1,11 +1,9 @@ +// $Id: LSOCK_Connector.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/LSOCK_Connector.h" #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - diff --git a/dep/acelite/ace/LSOCK_Connector.h b/dep/acelite/ace/LSOCK_Connector.h index d3c0ee735..03d0fd0a5 100644 --- a/dep/acelite/ace/LSOCK_Connector.h +++ b/dep/acelite/ace/LSOCK_Connector.h @@ -4,7 +4,9 @@ /** * @file LSOCK_Connector.h * - * @author Doug Schmidt + * $Id: LSOCK_Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/LSOCK_Connector.inl b/dep/acelite/ace/LSOCK_Connector.inl index fa519c215..31e79c969 100644 --- a/dep/acelite/ace/LSOCK_Connector.inl +++ b/dep/acelite/ace/LSOCK_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: LSOCK_Connector.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Establish a connection. diff --git a/dep/acelite/ace/LSOCK_Dgram.cpp b/dep/acelite/ace/LSOCK_Dgram.cpp index 58059aede..929b64504 100644 --- a/dep/acelite/ace/LSOCK_Dgram.cpp +++ b/dep/acelite/ace/LSOCK_Dgram.cpp @@ -1,10 +1,9 @@ +// $Id: LSOCK_Dgram.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/LSOCK_Dgram.h" #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ diff --git a/dep/acelite/ace/LSOCK_Dgram.h b/dep/acelite/ace/LSOCK_Dgram.h index d0843cd92..e21a3ce9e 100644 --- a/dep/acelite/ace/LSOCK_Dgram.h +++ b/dep/acelite/ace/LSOCK_Dgram.h @@ -4,6 +4,8 @@ /** * @file LSOCK_Dgram.h * + * $Id: LSOCK_Dgram.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/LSOCK_Dgram.inl b/dep/acelite/ace/LSOCK_Dgram.inl index 6028a3586..3174adf00 100644 --- a/dep/acelite/ace/LSOCK_Dgram.inl +++ b/dep/acelite/ace/LSOCK_Dgram.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: LSOCK_Dgram.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void diff --git a/dep/acelite/ace/LSOCK_Stream.cpp b/dep/acelite/ace/LSOCK_Stream.cpp index 0bbf12695..060d4a5c1 100644 --- a/dep/acelite/ace/LSOCK_Stream.cpp +++ b/dep/acelite/ace/LSOCK_Stream.cpp @@ -1,11 +1,10 @@ +// $Id: LSOCK_Stream.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/LSOCK_Stream.h" #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) #include "ace/Log_Category.h" #include "ace/OS_NS_sys_socket.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ @@ -69,7 +68,7 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[], { ACE_TRACE ("ACE_LSOCK_Stream::send_msg"); msghdr send_msg; -#if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN]; cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ @@ -79,10 +78,7 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[], send_msg.msg_name = 0; send_msg.msg_namelen = 0; -#if defined (ACE_LACKS_SENDMSG) - ACE_UNUSED_ARG (handle); -#else -# if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) cmsgptr->cmsg_level = SOL_SOCKET; cmsgptr->cmsg_type = SCM_RIGHTS; cmsgptr->cmsg_len = sizeof cmsgbuf; @@ -90,11 +86,10 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[], send_msg.msg_controllen = sizeof cmsgbuf; *(ACE_HANDLE *) CMSG_DATA (cmsgptr) = handle; send_msg.msg_flags = 0 ; -# else +#else send_msg.msg_accrights = (char *) &handle; send_msg.msg_accrightslen = sizeof handle; -# endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ -#endif /* ACE_LACKS_SENDMSG */ +#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ return ACE_OS::sendmsg (this->ACE_SOCK_Stream::get_handle (), &send_msg, 0); @@ -110,7 +105,7 @@ ACE_LSOCK_Stream::recv_msg (iovec iov[], { ACE_TRACE ("ACE_LSOCK_Stream::recv_msg"); msghdr recv_msg; -#if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN]; cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ @@ -120,9 +115,7 @@ ACE_LSOCK_Stream::recv_msg (iovec iov[], recv_msg.msg_name = 0; recv_msg.msg_namelen = 0; -#if defined (ACE_LACKS_SENDMSG) - ACE_UNUSED_ARG (handle); -#elif defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) recv_msg.msg_control = cmsgbuf; recv_msg.msg_controllen = sizeof cmsgbuf; ssize_t result = ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (), @@ -132,12 +125,10 @@ ACE_LSOCK_Stream::recv_msg (iovec iov[], #else recv_msg.msg_accrights = (char *) &handle; recv_msg.msg_accrightslen = sizeof handle; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ /* ACE_LACKS_SENDMSG */ -#if defined ACE_LACKS_SENDMSG || !defined ACE_HAS_4_4BSD_SENDMSG_RECVMSG return ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (), &recv_msg, 0); -#endif +#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ } #endif /* ACE_HAS_MSG */ diff --git a/dep/acelite/ace/LSOCK_Stream.h b/dep/acelite/ace/LSOCK_Stream.h index 54f87e1fd..bdaed30a3 100644 --- a/dep/acelite/ace/LSOCK_Stream.h +++ b/dep/acelite/ace/LSOCK_Stream.h @@ -4,6 +4,8 @@ /** * @file LSOCK_Stream.h * + * $Id: LSOCK_Stream.h 92140 2010-10-04 12:37:52Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/LSOCK_Stream.inl b/dep/acelite/ace/LSOCK_Stream.inl index 16b948915..0d9421115 100644 --- a/dep/acelite/ace/LSOCK_Stream.inl +++ b/dep/acelite/ace/LSOCK_Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: LSOCK_Stream.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Sets both the file descriptors... Overrides handle from the base diff --git a/dep/acelite/ace/Lib_Find.cpp b/dep/acelite/ace/Lib_Find.cpp index 1ffc040ec..724868932 100644 --- a/dep/acelite/ace/Lib_Find.cpp +++ b/dep/acelite/ace/Lib_Find.cpp @@ -1,3 +1,5 @@ +// $Id: Lib_Find.cpp 97383 2013-10-23 08:44:20Z mhengstmengel $ + #include "ace/Lib_Find.h" #include "ace/Log_Category.h" #include "ace/OS_NS_string.h" @@ -8,10 +10,6 @@ #include "ace/OS_Memory.h" #include "ace/OS_NS_fcntl.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if defined (ACE_WIN32) # include "ace/OS_NS_strings.h" #endif /* ACE_WIN32 */ @@ -122,72 +120,72 @@ ACE::ldfind (const ACE_TCHAR* filename, { ACE_TRACE ("ACE::ldfind"); #if defined (ACE_OPENVMS) - if (ACE_OS::strlen (filename) >= maxpathnamelen) - { - errno = ENOMEM; - return -1; - } + if (ACE_OS::strlen(filename) >= maxpathnamelen) + { + errno = ENOMEM; + return -1; + } dsc$descriptor nameDsc; nameDsc.dsc$b_class = DSC$K_CLASS_S; nameDsc.dsc$b_dtype = DSC$K_DTYPE_T; - nameDsc.dsc$w_length = ACE_OS::strlen (filename); + nameDsc.dsc$w_length = ACE_OS::strlen(filename); nameDsc.dsc$a_pointer = (char*)filename; char symbol[] = "NULL"; dsc$descriptor symbolDsc; symbolDsc.dsc$b_class = DSC$K_CLASS_S; symbolDsc.dsc$b_dtype = DSC$K_DTYPE_T; - symbolDsc.dsc$w_length = ACE_OS::strlen (symbol); + symbolDsc.dsc$w_length = ACE_OS::strlen(symbol); symbolDsc.dsc$a_pointer = symbol; int symbolValue; int result; try - { - result = LIB$FIND_IMAGE_SYMBOL (&nameDsc, &symbolDsc, &symbolValue, 0, 0); - } - catch (chf$signal_array &sig) - { - result = sig.chf$l_sig_name; - } + { + result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0); + } + catch (chf$signal_array& sig) + { + result = sig.chf$l_sig_name; + } int severity = result & STS$M_SEVERITY; int conditionId = result & STS$M_COND_ID; if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO || (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID))) - { - ACE_OS::strcpy (pathname, filename); - return 0; - } + { + ACE_OS::strcpy(pathname, filename); + return 0; + } - if (ACE_OS::strlen (filename) + ACE_OS::strlen (ACE_DLL_PREFIX) >= maxpathnamelen) - { - errno = ENOMEM; - return -1; - } + if (ACE_OS::strlen(filename) + ACE_OS::strlen(ACE_DLL_PREFIX) >= maxpathnamelen) + { + errno = ENOMEM; + return -1; + } - ACE_OS::strcpy (pathname, ACE_DLL_PREFIX); - ACE_OS::strcat (pathname, filename); - nameDsc.dsc$w_length = ACE_OS::strlen (pathname); + ACE_OS::strcpy(pathname, ACE_DLL_PREFIX); + ACE_OS::strcat(pathname, filename); + nameDsc.dsc$w_length = ACE_OS::strlen(pathname); nameDsc.dsc$a_pointer = pathname; try - { - result = LIB$FIND_IMAGE_SYMBOL (&nameDsc, &symbolDsc, &symbolValue, 0, 0); - } - catch (chf$signal_array &sig) - { - result = sig.chf$l_sig_name; - } + { + result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0); + } + catch (chf$signal_array& sig) + { + result = sig.chf$l_sig_name; + } severity = result & STS$M_SEVERITY; conditionId = result & STS$M_COND_ID; if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO || (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID))) - { - return 0; - } + { + return 0; + } errno = ENOENT; return -1; #endif /* ACE_OPENVMS */ @@ -316,21 +314,21 @@ ACE::ldfind (const ACE_TCHAR* filename, #endif /* ACE_DIRECTORY_SEPARATOR_CHAR */ // First, try matching the filename *without* adding a // prefix. - ACE_OS::snprintf (pathname, maxpathnamelen, - ACE_TEXT ("%s%s%s"), - searchpathname, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); + ACE_OS::sprintf (pathname, + ACE_TEXT ("%s%s%s"), + searchpathname, + searchfilename, + has_suffix ? ACE_TEXT ("") : dll_suffix); if (ACE_OS::access (pathname, F_OK) == 0) return 0; // Second, try matching the filename *with* adding a prefix. - ACE_OS::snprintf (pathname, maxpathnamelen, - ACE_TEXT ("%s%s%s%s"), - searchpathname, - ACE_DLL_PREFIX, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); + ACE_OS::sprintf (pathname, + ACE_TEXT ("%s%s%s%s"), + searchpathname, + ACE_DLL_PREFIX, + searchfilename, + has_suffix ? ACE_TEXT ("") : dll_suffix); if (ACE_OS::access (pathname, F_OK) == 0) return 0; } @@ -350,12 +348,12 @@ ACE::ldfind (const ACE_TCHAR* filename, pathname, &file_component); if (pathlen >= maxpathnamelen) - { + { errno = ENOMEM; return -1; - } + } else if (pathlen > 0) - return 0; + return 0; // In case not found we should try again with the ACE_DLL_PREFIX // prefixed @@ -369,16 +367,16 @@ ACE::ldfind (const ACE_TCHAR* filename, pathname, &file_component); if (pathlen >= maxpathnamelen) - { + { errno = ENOMEM; return -1; - } + } else if (pathlen > 0) - return 0; + return 0; #else ACE_TCHAR *ld_path = 0; # if defined ACE_DEFAULT_LD_SEARCH_PATH - ld_path = const_cast (ACE_DEFAULT_LD_SEARCH_PATH); + ld_path = const_cast (ACE_DEFAULT_LD_SEARCH_PATH); # else # if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) ld_path = ACE_OS::getenv (ACE_LD_SEARCH_PATH); @@ -466,24 +464,24 @@ ACE::ldfind (const ACE_TCHAR* filename, // First, try matching the filename *without* adding a // prefix. - ACE_OS::snprintf (pathname, maxpathnamelen, - ACE_TEXT ("%s%c%s%s"), - path_entry, - ACE_DIRECTORY_SEPARATOR_CHAR, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); + ACE_OS::sprintf (pathname, + ACE_TEXT ("%s%c%s%s"), + path_entry, + ACE_DIRECTORY_SEPARATOR_CHAR, + searchfilename, + has_suffix ? ACE_TEXT ("") : dll_suffix); if (ACE_OS::access (pathname, F_OK) == 0) break; // Second, try matching the filename *with* adding a // prefix. - ACE_OS::snprintf (pathname, maxpathnamelen, - ACE_TEXT ("%s%c%s%s%s"), - path_entry, - ACE_DIRECTORY_SEPARATOR_CHAR, - ACE_DLL_PREFIX, - searchfilename, - has_suffix ? ACE_TEXT ("") : dll_suffix); + ACE_OS::sprintf (pathname, + ACE_TEXT ("%s%c%s%s%s"), + path_entry, + ACE_DIRECTORY_SEPARATOR_CHAR, + ACE_DLL_PREFIX, + searchfilename, + has_suffix ? ACE_TEXT ("") : dll_suffix); if (ACE_OS::access (pathname, F_OK) == 0) break; @@ -498,15 +496,11 @@ ACE::ldfind (const ACE_TCHAR* filename, if (ld_path_temp != 0) ACE_OS::free (ld_path_temp); #endif /* ACE_HAS_WINCE */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) ld_path); -#else ACE_OS::free ((void *) ld_path); -#endif /* ACE_HAS_ALLOC_HOOKS */ #if defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) - if (result == 0 || tag == 0) + if (result == 0 || tag == 0) #endif /* ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ - return result; + return result; } #endif /* ACE_WIN32 && !ACE_HAS_WINCE */ } @@ -559,15 +553,9 @@ ACE::ldname (const ACE_TCHAR *entry_point) + 1; ACE_TCHAR *new_name; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (new_name, - static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * size)), - 0); -#else ACE_NEW_RETURN (new_name, ACE_TCHAR[size], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::strcpy (new_name, entry_point); return new_name; diff --git a/dep/acelite/ace/Lib_Find.h b/dep/acelite/ace/Lib_Find.h index 3c72a1fc5..1ed2d8e72 100644 --- a/dep/acelite/ace/Lib_Find.h +++ b/dep/acelite/ace/Lib_Find.h @@ -6,6 +6,8 @@ * * All the static function calls needed to search and open shared * libraries. + * + * $Id: Lib_Find.h 93359 2011-02-11 11:33:12Z mcorino $ */ //============================================================================= @@ -29,7 +31,7 @@ namespace ACE /** * Finds the file @a filename either using an absolute path or using * a relative path in conjunction with ACE_LD_SEARCH_PATH (e.g., - * $LD_LIBRARY_PATH on UNIX or the directories scanned by Win32 API + * $LD_LIBRARY_PATH on UNIX or the directories scaned by Win32 API * SearchPath on Win32). This function will add appropriate suffix * (e.g., .dll on Win32 or .so on UNIX) according to the OS * platform. In addition, this function will apply the appropriate @@ -90,7 +92,7 @@ namespace ACE int mode, int perm = 0); - // @@ Though the following functions don't come under the same category as + // @@ Though the following functions dont come under the same category as // above, these are used only in the functions in this class. So it makes // more sense to move these functions too to this class. // diff --git a/dep/acelite/ace/Local_Memory_Pool.cpp b/dep/acelite/ace/Local_Memory_Pool.cpp index 0332f6f36..cb76f297e 100644 --- a/dep/acelite/ace/Local_Memory_Pool.cpp +++ b/dep/acelite/ace/Local_Memory_Pool.cpp @@ -1,3 +1,5 @@ +// $Id: Local_Memory_Pool.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Local_Memory_Pool.cpp #include "ace/Local_Memory_Pool.h" #include "ace/Auto_Ptr.h" @@ -53,15 +55,9 @@ ACE_Local_Memory_Pool::acquire (size_t nbytes, rounded_bytes = this->round_up (nbytes); char *temp = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (temp, - static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * rounded_bytes)), - 0); -#else ACE_NEW_RETURN (temp, char[rounded_bytes], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_Auto_Basic_Array_Ptr cp (temp); @@ -82,12 +78,7 @@ ACE_Local_Memory_Pool::release (int) for (ACE_Unbounded_Set::iterator i = this->allocated_chunks_.begin (); i != this->allocated_chunks_.end (); ++i) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(*i); -#else delete [] *i; -#endif /* ACE_HAS_ALLOC_HOOKS */ - this->allocated_chunks_.reset (); return 0; } diff --git a/dep/acelite/ace/Local_Memory_Pool.h b/dep/acelite/ace/Local_Memory_Pool.h index 1d931e3df..4216a97a7 100644 --- a/dep/acelite/ace/Local_Memory_Pool.h +++ b/dep/acelite/ace/Local_Memory_Pool.h @@ -4,7 +4,9 @@ /** * @file Local_Memory_Pool.h * - * @author Dougls C. Schmidt + * $Id: Local_Memory_Pool.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Dougls C. Schmidt * @author Prashant Jain */ //============================================================================= diff --git a/dep/acelite/ace/Local_Name_Space.cpp b/dep/acelite/ace/Local_Name_Space.cpp index 59645093e..36b9a8055 100644 --- a/dep/acelite/ace/Local_Name_Space.cpp +++ b/dep/acelite/ace/Local_Name_Space.cpp @@ -1,3 +1,5 @@ +// $Id: Local_Name_Space.cpp 91287 2010-08-05 10:30:49Z johnnyw $ + #include "ace/Local_Name_Space.h" #include "ace/ACE.h" #include "ace/RW_Process_Mutex.h" @@ -10,11 +12,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_NS_String::~ACE_NS_String (void) { if (this->delete_rep_) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->rep_); -#else delete [] this->rep_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_WCHAR_T * diff --git a/dep/acelite/ace/Local_Name_Space.h b/dep/acelite/ace/Local_Name_Space.h index 3938f77b8..c9606d02b 100644 --- a/dep/acelite/ace/Local_Name_Space.h +++ b/dep/acelite/ace/Local_Name_Space.h @@ -4,9 +4,11 @@ /** * @file Local_Name_Space.h * + * $Id: Local_Name_Space.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Prashant Jain (pjain@cs.wustl.edu) * @author Irfan Pyarali (irfan@wuerl.wustl.edu) - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu). + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu). */ //============================================================================= diff --git a/dep/acelite/ace/Local_Name_Space_T.cpp b/dep/acelite/ace/Local_Name_Space_T.cpp index cf04a35f4..d514214f9 100644 --- a/dep/acelite/ace/Local_Name_Space_T.cpp +++ b/dep/acelite/ace/Local_Name_Space_T.cpp @@ -1,3 +1,5 @@ +// $Id: Local_Name_Space_T.cpp 97590 2014-02-14 18:41:55Z johnnyw $ + #ifndef ACE_LOCAL_NAME_SPACE_T_CPP #define ACE_LOCAL_NAME_SPACE_T_CPP @@ -334,15 +336,9 @@ ACE_Local_Name_Space::resolve_i ( // Makes a copy here. Caller needs to call delete to free up // memory. char *new_type = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (new_type, - static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * (len + 1))), - -1); -#else ACE_NEW_RETURN (new_type, char [len + 1], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::strsncpy (new_type, temp, len + 1); type = new_type; @@ -392,8 +388,6 @@ ACE_Local_Name_Space::~ACE_Local_Name_Space (void) delete this->lock_; } -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Local_Name_Space) - template int ACE_Local_Name_Space::create_manager (void) { @@ -681,11 +675,7 @@ ACE_Local_Name_Space::list_types_i ( if (compiled_regexp) ACE_OS::free ((void *) compiled_regexp); #endif /* ACE_HAS_REGEX */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(pattern_rep); -#else delete [] pattern_rep; // delete pattern_rep; -#endif /* ACE_HAS_ALLOC_HOOKS */ return result; } @@ -802,11 +792,7 @@ ACE_Local_Name_Space::list_type_entries_i ( if (compiled_regexp) ACE_OS::free ((void *) compiled_regexp); #endif /* ACE_HAS_REGEX */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(pattern_rep); -#else delete [] pattern_rep; // delete pattern_rep; -#endif /* ACE_HAS_ALLOC_HOOKS */ return 0; } @@ -834,13 +820,8 @@ ACE_Local_Name_Space::dump_i (void) const key, value, type)); // We need to delete key and value since char_rep allocates // memory for them -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(key); - ACE_Allocator::instance()->free(value); -#else delete [] key; delete [] value; -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP)); diff --git a/dep/acelite/ace/Local_Name_Space_T.h b/dep/acelite/ace/Local_Name_Space_T.h index dc4052da8..33f9acc76 100644 --- a/dep/acelite/ace/Local_Name_Space_T.h +++ b/dep/acelite/ace/Local_Name_Space_T.h @@ -4,9 +4,11 @@ /** * @file Local_Name_Space_T.h * + * $Id: Local_Name_Space_T.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Prashant Jain * @author Irfan Pyarali and - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= @@ -212,8 +214,6 @@ public: typedef ACE_Allocator_Adapter > ALLOCATOR; - ACE_ALLOC_HOOK_DECLARE; - private: #if defined (ACE_WIN32) /// Remap the backing store diff --git a/dep/acelite/ace/Local_Tokens.cpp b/dep/acelite/ace/Local_Tokens.cpp index 67ce73af5..c7a79f882 100644 --- a/dep/acelite/ace/Local_Tokens.cpp +++ b/dep/acelite/ace/Local_Tokens.cpp @@ -1,3 +1,5 @@ +// $Id: Local_Tokens.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Local_Tokens.h" #if defined (ACE_HAS_TOKENS_LIBRARY) @@ -119,11 +121,11 @@ ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_Token_Proxy *new_proxy, // The cast is an attempt to get this to compile (and run, // hopefully) regardless of the type of ACE_thread_t. - ACE_OS::snprintf (name, sizeof name / sizeof name[0], - ACE_TEXT ("/%s/%u/%lu"), - host_name, - static_cast (ACE_OS::getpid ()), - *reinterpret_cast (&thread_id)); + ACE_OS::sprintf (name, + ACE_TEXT ("/%s/%u/%lu"), + host_name, + static_cast (ACE_OS::getpid ()), + *reinterpret_cast (&thread_id)); this->client_id (name); } @@ -1188,8 +1190,8 @@ ACE_Token_Proxy::open (const ACE_TCHAR *token_name, // We must have a name. if (token_name == 0) { - ACE_OS::snprintf (name, BUFSIZ, ACE_TEXT ("token %lx"), - reinterpret_cast (this)); + ACE_OS::sprintf (name, ACE_TEXT ("token %lx"), + reinterpret_cast (this)); token_name = name; } diff --git a/dep/acelite/ace/Local_Tokens.h b/dep/acelite/ace/Local_Tokens.h index 620aaf35c..d7efb99e6 100644 --- a/dep/acelite/ace/Local_Tokens.h +++ b/dep/acelite/ace/Local_Tokens.h @@ -4,8 +4,10 @@ /** * @file Local_Tokens.h * + * $Id: Local_Tokens.h 96985 2013-04-11 15:50:32Z huangh $ + * * @author Karl-Heinz Dorn - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Tim Harrison * * This file contains definitions for the following classes: @@ -34,6 +36,8 @@ * ACE_Thread_Semaphore, etc., that are defined in * $ACE_ROOT/ace/Synch.h or the * ACE_Token that's defined in $ACE_ROOT/ace/Token.h. + * + * */ //============================================================================= diff --git a/dep/acelite/ace/Local_Tokens.inl b/dep/acelite/ace/Local_Tokens.inl index 23dc5d867..a4c21ec67 100644 --- a/dep/acelite/ace/Local_Tokens.inl +++ b/dep/acelite/ace/Local_Tokens.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Local_Tokens.inl 96985 2013-04-11 15:50:32Z huangh $ + #if defined (ACE_HAS_TOKENS_LIBRARY) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Lock.cpp b/dep/acelite/ace/Lock.cpp index ada3e97f3..800cea220 100644 --- a/dep/acelite/ace/Lock.cpp +++ b/dep/acelite/ace/Lock.cpp @@ -1,3 +1,5 @@ +// $Id: Lock.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Lock.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Lock.h b/dep/acelite/ace/Lock.h index f13188001..cbf41306d 100644 --- a/dep/acelite/ace/Lock.h +++ b/dep/acelite/ace/Lock.h @@ -4,9 +4,11 @@ /** * @file Lock.h * + * $Id: Lock.h 93792 2011-04-07 11:48:50Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Lock.inl b/dep/acelite/ace/Lock.inl index 43b4bac08..7e3ae6839 100644 --- a/dep/acelite/ace/Lock.inl +++ b/dep/acelite/ace/Lock.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Lock.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Lock_Adapter_T.cpp b/dep/acelite/ace/Lock_Adapter_T.cpp index 0068e8ae0..abe619086 100644 --- a/dep/acelite/ace/Lock_Adapter_T.cpp +++ b/dep/acelite/ace/Lock_Adapter_T.cpp @@ -1,3 +1,5 @@ +// $Id: Lock_Adapter_T.cpp 93359 2011-02-11 11:33:12Z mcorino $ + #ifndef ACE_LOCK_ADAPTER_T_CPP #define ACE_LOCK_ADAPTER_T_CPP diff --git a/dep/acelite/ace/Lock_Adapter_T.h b/dep/acelite/ace/Lock_Adapter_T.h index 2e1f0a532..3785d7a2d 100644 --- a/dep/acelite/ace/Lock_Adapter_T.h +++ b/dep/acelite/ace/Lock_Adapter_T.h @@ -4,9 +4,11 @@ /** * @file Lock_Adapter_T.h * + * $Id: Lock_Adapter_T.h 93359 2011-02-11 11:33:12Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Lock_Adapter_T.inl b/dep/acelite/ace/Lock_Adapter_T.inl index 5de19ea5b..4ffaf6cb6 100644 --- a/dep/acelite/ace/Lock_Adapter_T.inl +++ b/dep/acelite/ace/Lock_Adapter_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Lock_Adapter_T.inl 93385 2011-02-14 20:21:20Z mitza $ + #include "ace/OS_Memory.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Log_Category.cpp b/dep/acelite/ace/Log_Category.cpp index f26e0be89..bf9c7c828 100644 --- a/dep/acelite/ace/Log_Category.cpp +++ b/dep/acelite/ace/Log_Category.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Category.cpp 97058 2013-04-19 14:41:18Z huangh $ + #include "ace/Log_Msg.h" #include "ace/Log_Category.h" #include "ace/Atomic_Op.h" @@ -72,8 +74,6 @@ ACE_Log_Category_TSS::ACE_Log_Category_TSS(ACE_Log_Category* category, ACE_Log_M { } -ACE_ALLOC_HOOK_DEFINE(ACE_Log_Category_TSS) - ACE_Log_Category_TSS* ACE_Log_Category::per_thr_obj() { diff --git a/dep/acelite/ace/Log_Category.h b/dep/acelite/ace/Log_Category.h index 2f6c0c226..5d9219421 100644 --- a/dep/acelite/ace/Log_Category.h +++ b/dep/acelite/ace/Log_Category.h @@ -4,6 +4,8 @@ /** * @file Log_Category.h * + * $Id: Log_Category.h 97213 2013-06-27 17:06:10Z huangh $ + * * @author Huang-Ming Huang */ //============================================================================= @@ -63,18 +65,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL } while (0) #endif #if !defined (ACELIB_ERROR_RETURN) -# ifdef ACE_LACKS_VA_FUNCTIONS -# define ACELIB_ERROR_RETURN(X, Y) \ - do { \ - int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \ - if (ace___ == 0) return Y;\ - ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \ - ace___->log (X); \ - return Y; \ - } while (0) -# else /* ACE_LACKS_VA_FUNCTIONS */ -# define ACELIB_ERROR_RETURN(X, Y) \ +#define ACELIB_ERROR_RETURN(X, Y) \ do { \ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \ @@ -83,20 +74,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ace___->log X; \ return Y; \ } while (0) -# endif /* ACE_LACKS_VA_FUNCTIONS */ #endif #if !defined (ACELIB_ERROR) -# ifdef ACE_LACKS_VA_FUNCTIONS -# define ACELIB_ERROR(X) \ - do { \ - int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \ - if (ace___ == 0) break;\ - ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \ - ace___->log (X); \ - } while (0) -# else /* ACE_LACKS_VA_FUNCTIONS */ -# define ACELIB_ERROR(X) \ +#define ACELIB_ERROR(X) \ do { \ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \ @@ -104,20 +84,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \ ace___->log X; \ } while (0) -# endif /* ACE_LACKS_VA_FUNCTIONS */ #endif #if !defined (ACELIB_DEBUG) -# ifdef ACE_LACKS_VA_FUNCTIONS -# define ACELIB_DEBUG(X) \ - do { \ - int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \ - if (ace___ == 0) break;\ - ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ - ace___->log (X); \ - } while (0) -# else /* ACE_LACKS_VA_FUNCTIONS */ -# define ACELIB_DEBUG(X) \ +#define ACELIB_DEBUG(X) \ do { \ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \ @@ -125,7 +94,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ ace___->log X; \ } while (0) -# endif /* ACE_LACKS_VA_FUNCTIONS */ #endif #if !defined (ACELIB_ERROR_BREAK) #define ACELIB_ERROR_BREAK(X) { ACELIB_ERROR (X); break; } @@ -179,25 +147,16 @@ public: int op_status, int errnum); -#if !defined (ACE_LACKS_VA_FUNCTIONS) ssize_t log (ACE_Log_Priority priority, const ACE_TCHAR *format, ...); #if defined (ACE_HAS_WCHAR) ssize_t log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format, ...); #endif /* ACE_HAS_WCHAR */ -#else /* ACE_LACKS_VA_FUNCTIONS */ - friend class ACE_Log_Formatter; - - ssize_t log (const ACE_Log_Formatter &formatter); -#endif /* ACE_LACKS_VA_FUNCTIONS */ ssize_t log (const ACE_TCHAR *format, ACE_Log_Priority priority, va_list argp); - ssize_t log (ACE_Log_Record &log_record, - int suppress_stderr = 0); - /** * Method to log hex dump. This is useful for debugging. Calls * log() to do the actual print, but formats first to make the chars @@ -208,8 +167,6 @@ public: size_t size, const ACE_TCHAR *text = 0); - ACE_ALLOC_HOOK_DECLARE; - private: friend class ACE_Log_Category; ACE_Log_Category* category_; diff --git a/dep/acelite/ace/Log_Category.inl b/dep/acelite/ace/Log_Category.inl index 42fcf84dc..2c22df5e4 100644 --- a/dep/acelite/ace/Log_Category.inl +++ b/dep/acelite/ace/Log_Category.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Log_Category.inl 97026 2013-04-15 17:48:38Z huangh $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE unsigned int @@ -75,7 +78,6 @@ void ACE_Log_Category_TSS::conditional_set (const char *file, logger_->conditional_set(file, line, op_status, errnum); } -#if !defined (ACE_LACKS_VA_FUNCTIONS) ACE_INLINE ssize_t ACE_Log_Category_TSS::log (ACE_Log_Priority priority, const ACE_TCHAR *format_str, ...) { @@ -109,18 +111,6 @@ ACE_Log_Category_TSS::log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *form return result; } #endif /* ACE_HAS_WCHAR */ -#else /* ACE_LACKS_VA_FUNCTIONS */ - -ACE_INLINE ssize_t -ACE_Log_Category_TSS::log (const ACE_Log_Formatter &formatter) -{ - if (this->log_priority_enabled (formatter.priority ())) - return logger_->log (formatter); - - return 0; -} - -#endif /* ACE_LACKS_VA_FUNCTIONS */ /** * An alternative logging mechanism that makes it possible to @@ -138,12 +128,6 @@ ACE_Log_Category_TSS::log (const ACE_TCHAR *format, return logger_->log(format, priority, argp, this); } -ACE_INLINE ssize_t -ACE_Log_Category_TSS::log (ACE_Log_Record &log_record, - int suppress_stderr) -{ - return logger_->log(log_record, suppress_stderr); -} ACE_INLINE int ACE_Log_Category_TSS::log_hexdump (ACE_Log_Priority priority, diff --git a/dep/acelite/ace/Log_Msg.cpp b/dep/acelite/ace/Log_Msg.cpp index 190c6d781..b500d25b7 100644 --- a/dep/acelite/ace/Log_Msg.cpp +++ b/dep/acelite/ace/Log_Msg.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Msg.cpp 97662 2014-03-17 10:11:16Z johnnyw $ + // We need this to get the status of ACE_NTRACE... #include "ace/config-all.h" @@ -13,7 +15,6 @@ #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_errno.h" #include "ace/OS_NS_sys_time.h" -#include "ace/OS_NS_string.h" #include "ace/OS_NS_wchar.h" #include "ace/OS_NS_signal.h" #include "ace/os_include/os_typeinfo.h" @@ -41,15 +42,11 @@ #include "ace/Stack_Trace.h" #include "ace/Atomic_Op.h" -#include - #if !defined (__ACE_INLINE__) #include "ace/Log_Msg.inl" #endif /* __ACE_INLINE__ */ -#ifdef ACE_ANDROID -# include "ace/Log_Msg_Android_Logcat.h" -#endif + ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -60,7 +57,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Log_Msg) # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ defined (ACE_HAS_TSS_EMULATION) -static ACE_thread_key_t the_log_msg_tss_key; +static ACE_thread_key_t the_log_msg_tss_key = 0; ACE_thread_key_t *log_msg_tss_key (void) { @@ -82,11 +79,11 @@ public: #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) # define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_NT_Event_Log -#elif defined (ACE_ANDROID) -# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_Android_Logcat #elif !defined (ACE_LACKS_UNIX_SYSLOG) && !defined (ACE_HAS_WINCE) # define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_UNIX_Syslog -#endif +#else +# define ACE_LOG_MSG_SYSLOG_BACKEND ACE_Log_Msg_IPC +#endif /* ! ACE_WIN32 */ // When doing ACE_OS::s[n]printf() calls in log(), we need to update // the space remaining in the output buffer based on what's returned from @@ -138,15 +135,7 @@ private: ACE_Log_Msg_Backend *ACE_Log_Msg_Manager::log_backend_ = 0; ACE_Log_Msg_Backend *ACE_Log_Msg_Manager::custom_backend_ = 0; -#ifndef ACE_DEFAULT_LOG_BACKEND_FLAGS -# ifdef ACE_ANDROID -# define ACE_DEFAULT_LOG_BACKEND_FLAGS ACE_Log_Msg::SYSLOG -# else -# define ACE_DEFAULT_LOG_BACKEND_FLAGS 0 -# endif -#endif - -u_long ACE_Log_Msg_Manager::log_backend_flags_ = ACE_DEFAULT_LOG_BACKEND_FLAGS; +u_long ACE_Log_Msg_Manager::log_backend_flags_ = 0; int ACE_Log_Msg_Manager::init_backend (const u_long *flags) { @@ -176,14 +165,16 @@ int ACE_Log_Msg_Manager::init_backend (const u_long *flags) if (ACE_Log_Msg_Manager::log_backend_ == 0) { -#ifdef ACE_LOG_MSG_SYSLOG_BACKEND + ACE_NO_HEAP_CHECK; + +#if (defined (WIN32) || !defined (ACE_LACKS_UNIX_SYSLOG)) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) // Allocate the ACE_Log_Msg_Backend instance. if (ACE_BIT_ENABLED (ACE_Log_Msg_Manager::log_backend_flags_, ACE_Log_Msg::SYSLOG)) ACE_NEW_RETURN (ACE_Log_Msg_Manager::log_backend_, ACE_LOG_MSG_SYSLOG_BACKEND, -1); else -#endif +#endif /* defined (WIN32) && !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) */ ACE_NEW_RETURN (ACE_Log_Msg_Manager::log_backend_, ACE_Log_Msg_IPC, -1); @@ -203,6 +194,8 @@ ACE_Log_Msg_Manager::get_lock (void) // to grab another one here. if (ACE_Log_Msg_Manager::lock_ == 0) { + ACE_NO_HEAP_CHECK; + ACE_NEW_RETURN (ACE_Log_Msg_Manager::lock_, ACE_Recursive_Thread_Mutex, 0); @@ -249,15 +242,12 @@ LOCAL_EXTERN_PREFIX void ACE_TSS_CLEANUP_NAME (void *ptr) { - if (ptr != 0) - { - // Delegate to thr_desc if this not has terminated - ACE_Log_Msg *log_msg = (ACE_Log_Msg *) ptr; - if (log_msg->thr_desc () != 0) - log_msg->thr_desc ()->log_msg_cleanup (log_msg); - else - delete log_msg; - } + // Delegate to thr_desc if this not has terminated + ACE_Log_Msg* log_msg = (ACE_Log_Msg*) ptr; + if (log_msg->thr_desc()!=0) + log_msg->thr_desc()->log_msg_cleanup(log_msg); + else + delete log_msg; } # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ #endif /* ! ACE_MT_SAFE */ @@ -312,18 +302,21 @@ ACE_Log_Msg::instance (void) // Allocate the Singleton lock. ACE_Log_Msg_Manager::get_lock (); - if (ACE_Thread::keycreate (log_msg_tss_key (), - &ACE_TSS_CLEANUP_NAME) != 0) - { - if (1 == ACE_OS_Object_Manager::starting_up()) - //This function is called before ACE_OS_Object_Manager is - //initialized. So the lock might not be valid. Assume it's - //single threaded and so don't need the lock. - ; - else - ACE_OS::thread_mutex_unlock (lock); - return 0; // Major problems, this should *never* happen! - } + { + ACE_NO_HEAP_CHECK; + if (ACE_Thread::keycreate (log_msg_tss_key (), + &ACE_TSS_CLEANUP_NAME) != 0) + { + if (1 == ACE_OS_Object_Manager::starting_up()) + //This function is called before ACE_OS_Object_Manager is + //initialized. So the lock might not be valid. Assume it's + //single threaded and so don't need the lock. + ; + else + ACE_OS::thread_mutex_unlock (lock); + return 0; // Major problems, this should *never* happen! + } + } ACE_Log_Msg::key_created_ = true; } @@ -350,20 +343,26 @@ ACE_Log_Msg::instance (void) if (tss_log_msg == 0) { // Allocate memory off the heap and store it in a pointer in - // thread-specific storage (on the stack...). The memory will - // always be freed by the thread rundown because of the TSS - // callback set up when the key was created. - ACE_NEW_RETURN (tss_log_msg, - ACE_Log_Msg, - 0); - // Store the dynamically allocated pointer in thread-specific - // storage. It gets deleted via the ACE_TSS_cleanup function - // when the thread terminates. + // thread-specific storage (on the stack...). Stop heap + // checking, the memory will always be freed by the thread + // rundown because of the TSS callback set up when the key was + // created. This prevents from getting these blocks reported as + // memory leaks. + { + ACE_NO_HEAP_CHECK; - if (ACE_Thread::setspecific (*(log_msg_tss_key()), - reinterpret_cast (tss_log_msg)) - != 0) - return 0; // Major problems, this should *never* happen! + ACE_NEW_RETURN (tss_log_msg, + ACE_Log_Msg, + 0); + // Store the dynamically allocated pointer in thread-specific + // storage. It gets deleted via the ACE_TSS_cleanup function + // when the thread terminates. + + if (ACE_Thread::setspecific (*(log_msg_tss_key()), + reinterpret_cast (tss_log_msg)) + != 0) + return 0; // Major problems, this should *never* happen! + } } return tss_log_msg; @@ -435,7 +434,7 @@ const ACE_TCHAR *ACE_Log_Msg::local_host_ = 0; const ACE_TCHAR *ACE_Log_Msg::program_name_ = 0; /// Default is to use stderr. -u_long ACE_Log_Msg::flags_ = ACE_DEFAULT_LOG_FLAGS; +u_long ACE_Log_Msg::flags_ = ACE_Log_Msg::STDERR; /// Current offset of msg_[]. ptrdiff_t ACE_Log_Msg::msg_off_ = 0; @@ -489,13 +488,14 @@ ACE_Log_Msg::close (void) // unload of libACE, by a program not linked with libACE, // ACE_TSS_cleanup will be invoked after libACE has been unloaded. // See Bugzilla 2980 for lots of details. + ACE_Log_Msg *tss_log_msg = 0; void *temp = 0; // Get the tss_log_msg from thread-specific storage. if (ACE_Thread::getspecific (*(log_msg_tss_key ()), &temp) != -1 && temp) { - ACE_Log_Msg *tss_log_msg = static_cast (temp); + tss_log_msg = static_cast (temp); // we haven't been cleaned up ACE_TSS_CLEANUP_NAME(tss_log_msg); if (ACE_Thread::setspecific(*(log_msg_tss_key()), @@ -538,13 +538,16 @@ ACE_Log_Msg::sync (const ACE_TCHAR *prog_name) if (prog_name) { // Must free if already allocated!!! -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::program_name_); -#else ACE_OS::free ((void *) ACE_Log_Msg::program_name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name); + // Stop heap checking, block will be freed by the destructor when + // the last ACE_Log_Msg instance is deleted. + // Heap checking state will be restored when the block is left. + { + ACE_NO_HEAP_CHECK; + + ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name); + } } ACE_Log_Msg::msg_off_ = 0; @@ -669,11 +672,7 @@ ACE_Log_Msg::ACE_Log_Msg (void) } } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (this->msg_, static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (ACE_MAXLOGMSGLEN+1)))); -#else ACE_NEW_NORETURN (this->msg_, ACE_TCHAR[ACE_MAXLOGMSGLEN+1]); -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_Log_Msg::~ACE_Log_Msg (void) @@ -717,32 +716,20 @@ ACE_Log_Msg::~ACE_Log_Msg (void) if (ACE_Log_Msg::program_name_) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::program_name_); -#else ACE_OS::free ((void *) ACE_Log_Msg::program_name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_Log_Msg::program_name_ = 0; } if (ACE_Log_Msg::local_host_) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::local_host_); -#else ACE_OS::free ((void *) ACE_Log_Msg::local_host_); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_Log_Msg::local_host_ = 0; } } this->cleanup_ostream (); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->msg_); -#else delete[] this->msg_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } void @@ -752,12 +739,7 @@ ACE_Log_Msg::cleanup_ostream () { if (--*this->ostream_refcount_ == 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - this->ostream_refcount_->~Atomic_ULong(); - ACE_Allocator::instance()->free(this->ostream_refcount_); -#else delete this->ostream_refcount_; -#endif /* ACE_HAS_ALLOC_HOOKS */ #if defined (ACE_LACKS_IOSTREAM_TOTALLY) ACE_OS::fclose (this->ostream_); #else @@ -782,18 +764,21 @@ ACE_Log_Msg::open (const ACE_TCHAR *prog_name, if (prog_name) { -#if defined(ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::program_name_); -#else ACE_OS::free ((void *) ACE_Log_Msg::program_name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_, - ACE_OS::strdup (prog_name), - -1); + // Stop heap checking, block will be freed by the destructor. + { + ACE_NO_HEAP_CHECK; + + ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_, + ACE_OS::strdup (prog_name), + -1); + } } else if (ACE_Log_Msg::program_name_ == 0) { + // Stop heap checking, block will be freed by the destructor. + ACE_NO_HEAP_CHECK; ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_, ACE_OS::strdup (ACE_TEXT ("")), -1); @@ -894,7 +879,6 @@ ACE_Log_Msg::open (const ACE_TCHAR *prog_name, return status; } -#ifndef ACE_LACKS_VA_FUNCTIONS /** * Valid Options (prefixed by '%', as in printf format strings) include: * 'A': print an ACE_timer_t value @@ -940,6 +924,7 @@ ACE_Log_Msg::log (ACE_Log_Priority log_priority, const ACE_TCHAR *format_str, ...) { ACE_TRACE ("ACE_Log_Msg::log"); + // Start of variable args section. va_list argp; @@ -978,12 +963,6 @@ ACE_Log_Msg::log (ACE_Log_Priority log_priority, } #endif /* ACE_HAS_WCHAR */ -#endif /* ACE_LACKS_VA_FUNCTIONS */ - -#if defined ACE_HAS_STRERROR_R && defined ACE_LACKS_STRERROR -#define ACE_LOG_MSG_USE_STRERROR_R -#endif - ssize_t ACE_Log_Msg::log (const ACE_TCHAR *format_str, ACE_Log_Priority log_priority, @@ -991,13 +970,6 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, ACE_Log_Category_TSS* category) { ACE_TRACE ("ACE_Log_Msg::log"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (log_priority); - ACE_UNUSED_ARG (format_str); - ACE_UNUSED_ARG (argp); - ACE_UNUSED_ARG (category); - ACE_NOTSUP_RETURN (-1); -#else // External decls. typedef void (*PTF)(...); @@ -1131,7 +1103,6 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, const ACE_TCHAR *abort_str = ACE_TEXT ("Aborting..."); const ACE_TCHAR *start_format = format_str; - size_t fspace = 128; ACE_TCHAR format[128]; // Converted format string ACE_OS::memset (format, '\0', 128); // Set this string to known values. ACE_TCHAR *fp = 0; // Current format pointer @@ -1140,14 +1111,8 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, bool skip_nul_locate = false; int this_len = 0; // How many chars s[n]printf wrote -#ifdef ACE_LOG_MSG_USE_STRERROR_R - char strerror_buf[128]; // always narrow chars - ACE_OS::strcpy (strerror_buf, "strerror_r failed"); -#endif - fp = format; *fp++ = *format_str++; // Copy in the % - --fspace; // Initialization to satisfy VC6 int tmp_indent = 0; @@ -1184,24 +1149,15 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, case '8': case '9': case '.': + case 'L': case 'h': *fp++ = *format_str; - --fspace; - done = false; - break; - case 'L': - *fp++ = 'l'; done = false; break; case '*': wp = va_arg (argp, int); - if (can_check) - this_len = ACE_OS::snprintf (fp, fspace, - ACE_TEXT ("%d"), wp); - else - this_len = ACE_OS::sprintf (fp, ACE_TEXT ("%d"), wp); - ACE_UPDATE_COUNT (fspace, this_len); + ACE_OS::sprintf (fp, ACE_TEXT ("%d"), wp); fp += ACE_OS::strlen (fp); done = false; break; @@ -1209,7 +1165,6 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, case 'A': // ACE_timer_t { ACE_OS::strcpy (fp, ACE_TEXT ("f")); - --fspace; double const value = va_arg (argp, double); if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, value); @@ -1299,13 +1254,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, case 'p': // string, ala perror() { errno = 0; - const int mapped = ACE::map_errno (this->errnum ()); -#ifdef ACE_LOG_MSG_USE_STRERROR_R - char *msg = ACE_OS::strerror_r (mapped, strerror_buf, - sizeof strerror_buf); -#else - char *msg = ACE_OS::strerror (mapped); -#endif + char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ())); // Windows can try to translate the errnum using // system calls if strerror() doesn't get anything useful. #if defined (ACE_WIN32) @@ -1525,13 +1474,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, case 'm': // Format the string assocated with the errno value. { errno = 0; - const int mapped = ACE::map_errno (this->errnum ()); -#ifdef ACE_LOG_MSG_USE_STRERROR_R - char *msg = ACE_OS::strerror_r (mapped, strerror_buf, - sizeof strerror_buf); -#else - char *msg = ACE_OS::strerror (mapped); -#endif + char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ())); // Windows can try to translate the errnum using // system calls if strerror() doesn't get anything useful. #if defined (ACE_WIN32) @@ -1714,14 +1657,12 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, ACE_Time_Value* time_value = va_arg (argp, ACE_Time_Value*); ACE::timestamp (*time_value, day_and_time, - sizeof (day_and_time) / sizeof (ACE_TCHAR), - true); + sizeof (day_and_time) / sizeof (ACE_TCHAR)); } else { ACE::timestamp (day_and_time, - sizeof (day_and_time) / sizeof (ACE_TCHAR), - true); + sizeof (day_and_time) / sizeof (ACE_TCHAR)); } #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) ACE_OS::strcpy (fp, ACE_TEXT ("ls")); @@ -1755,25 +1696,23 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, (bp, bspace, format, ACE::timestamp (*time_value, day_and_time, - sizeof day_and_time / sizeof (ACE_TCHAR), - true)); + sizeof day_and_time / sizeof (ACE_TCHAR))); else this_len = ACE_OS::sprintf (bp, format, ACE::timestamp (*time_value, day_and_time, - sizeof day_and_time / sizeof (ACE_TCHAR), - true)); + sizeof day_and_time / sizeof (ACE_TCHAR))); } else { if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, - ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR), true)); + ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR))); else this_len = ACE_OS::sprintf (bp, format, ACE::timestamp (day_and_time, - sizeof day_and_time / sizeof (ACE_TCHAR), true)); + sizeof day_and_time / sizeof (ACE_TCHAR))); } ACE_UPDATE_COUNT (bspace, this_len); break; @@ -1791,16 +1730,23 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, ACE_OS::sprintf (bp, format, static_cast (ACE_Thread::self ())); -#elif defined ACE_USES_WCHAR - { - char tid_buf[32] = {}; - ACE_OS::thr_id (tid_buf, sizeof tid_buf); - this_len = ACE_OS::strlen (tid_buf); - ACE_OS::strncpy (bp, ACE_TEXT_CHAR_TO_TCHAR (tid_buf), - bspace); - } #else - this_len = ACE_OS::thr_id (bp, bspace); + ACE_hthread_t t_id; + ACE_OS::thr_self (t_id); + + // Yes, this is an ugly C-style cast, but the correct + // C++ cast is different depending on whether the t_id + // is an integral type or a pointer type. FreeBSD uses + // a pointer type, but doesn't have a _np function to + // get an integral type, like the OSes above. + ACE_OS::strcpy (fp, ACE_TEXT ("lu")); + if (can_check) + this_len = ACE_OS::snprintf + (bp, bspace, format, (unsigned long)t_id); + else + this_len = ACE_OS::sprintf + (bp, format, (unsigned long)t_id); + #endif /* ACE_WIN32 */ ACE_UPDATE_COUNT (bspace, this_len); break; @@ -2205,589 +2151,8 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, } return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } -#ifdef ACE_LACKS_VA_FUNCTIONS -ACE_Log_Formatter operator, (ACE_Log_Priority prio, const char *fmt) -{ - return ACE_Log_Formatter (prio, fmt); -} - -ACE_Log_Formatter::ACE_Log_Formatter (ACE_Log_Priority prio, const char *fmt) - : saved_errno_ (errno) - , priority_ (prio) - , format_ (fmt) - , logger_ (ACE_LOG_MSG) - , abort_ (ABRT_NONE) - , in_prog_ (' ') - , last_star_ (0) -{ - const bool conditional_values = this->logger_->conditional_values_.is_set_; - this->logger_->conditional_values_.is_set_ = false; - - this->enabled_ = this->logger_->log_priority_enabled (prio); - if (!this->enabled_) return; - - if (conditional_values) - this->logger_->set (this->logger_->conditional_values_.file_, - this->logger_->conditional_values_.line_, - this->logger_->conditional_values_.op_status_, - this->logger_->conditional_values_.errnum_, - this->logger_->restart (), - this->logger_->msg_ostream (), - this->logger_->msg_callback ()); - this->bp_ = this->logger_->msg_ + ACE_Log_Msg::msg_off_; - this->bspace_ = ACE_Log_Record::MAXLOGMSGLEN; - if (ACE_Log_Msg::msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN) - this->bspace_ -= static_cast (ACE_Log_Msg::msg_off_); - - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE) - && ACE_Log_Msg::program_name_ != 0) - { - const int n = ACE_OS::snprintf (this->bp_, this->bspace_, "%s|", - ACE_Log_Msg::program_name_); - ACE_UPDATE_COUNT (this->bspace_, n); - this->bp_ += n; - } - - if (this->logger_->timestamp_) - { - ACE_TCHAR day_and_time[27]; - const bool time_only = this->logger_->timestamp_ == 1; - const ACE_TCHAR *const time = - ACE::timestamp (day_and_time, - sizeof day_and_time / sizeof (ACE_TCHAR), - time_only); - const int n = ACE_OS::snprintf (this->bp_, this->bspace_, "%s|", - time_only ? time : day_and_time); - ACE_UPDATE_COUNT (this->bspace_, n); - this->bp_ += n; - } -} - -int ACE_Log_Formatter::copy_trunc (const char *str, int limit) -{ - const int n = std::min (static_cast (this->bspace_), limit); - ACE_OS::memcpy (this->bp_, str, n); - ACE_UPDATE_COUNT (this->bspace_, n); - this->bp_ += n; - return n; -} - -void ACE_Log_Formatter::prepare_format () -{ - const char in_progress = this->in_prog_; - this->in_prog_ = ' '; - switch (in_progress) - { - case '*': - if (!this->process_conversion ()) return; - break; - case 'p': - { - // continuation of the '%p' format after the user's message - const int mapped = ACE::map_errno (this->logger_->errnum ()); -#ifdef ACE_LOG_MSG_USE_STRERROR_R - char strerror_buf[128]; // always narrow chars - ACE_OS::strcpy (strerror_buf, "strerror_r failed"); - const char *const msg = ACE_OS::strerror_r (mapped, strerror_buf, - sizeof strerror_buf); -#else - const char *const msg = ACE_OS::strerror (mapped); -#endif - this->copy_trunc (": ", 2); - this->copy_trunc (msg, ACE_OS::strlen (msg)); - break; - } - case 'r': - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT)) - { - const size_t len = ACE_OS::strlen (this->bp_); - this->bspace_ -= len + 1; - this->bp_ += len; - this->copy_trunc ("}", 1); - } - *this->bp_ = 0; - ACE_Log_Msg::msg_off_ = this->offset_; - break; - } - - *this->fmt_out_ = 0; - - while (const char *const pct = ACE_OS::strchr (this->format_, '%')) - { - const bool escaped = pct[1] == '%'; - this->format_ += 1 + this->copy_trunc (this->format_, - pct - this->format_ + escaped); - if (!this->bspace_) return; - if (!escaped) - { - ACE_OS::strcpy (this->fmt_out_, "%"); - this->fp_ = this->fmt_out_ + 1; - this->last_star_ = 0; - if (!this->process_conversion ()) return; - } - } - - this->copy_trunc (this->format_, ACE_OS::strlen (this->format_)); -} - -bool ACE_Log_Formatter::process_conversion () -{ - const size_t n = ACE_OS::strspn (this->format_, "-+ #0123456789.Lh"); - const size_t fspace = sizeof this->fmt_out_ - (this->fp_ - this->fmt_out_); - if (n >= fspace || !this->format_[n]) return true; - - // when copying to fmt_out_, convert L (used by ACE) to l (used by std) - for (size_t i = 0; i < n; ++i) - if (this->format_[i] == 'L') this->fp_[i] = 'l'; - else this->fp_[i] = this->format_[i]; - - this->fp_ += n; - *this->fp_ = 0; - this->in_prog_ = this->format_[n]; - const char *const format_start = this->format_; - this->format_ += n + (this->in_prog_ ? 1 : 0); - int len; - - switch (this->in_prog_) - { - // the following formatters (here through '?') take no argument - // from the "varags" list so they will end up returning true (keep parsing) - case '$': - this->copy_trunc ("\n", 1); - // fall-through - case 'I': - len = std::min (static_cast (this->bspace_), - this->logger_->trace_depth_ * - (this->last_star_ ? this->last_star_ : -#ifdef ACE_HAS_TRACE - ACE_Trace::get_nesting_indent ())); -#else - 4)); -#endif - ACE_OS::memset (this->bp_, ' ', len); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - break; - - case 'l': - ACE_OS::strcpy (this->fp_, "d"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - this->logger_->linenum ()); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - break; - - case 'm': - { - const int mapped = ACE::map_errno (this->logger_->errnum ()); -#ifdef ACE_LOG_MSG_USE_STRERROR_R - char strerror_buf[128]; // always narrow chars - ACE_OS::strcpy (strerror_buf, "strerror_r failed"); - const char *const msg = ACE_OS::strerror_r (mapped, strerror_buf, - sizeof strerror_buf); -#else - const char *const msg = ACE_OS::strerror (mapped); -#endif - ACE_OS::strcpy (this->fp_, "s"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, msg); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - } - break; - - case 'M': - { - const char *const pri = ACE_Log_Record::priority_name (this->priority_); - - // special case for %.1M: unique 1-char abbreviation for log priority - if (this->fp_ == this->fmt_out_ + 3 && - this->fmt_out_[1] == '.' && this->fmt_out_[2] == '1') - { - const char abbrev = - this->priority_ == LM_STARTUP ? 'U' : - this->priority_ == LM_EMERGENCY ? '!' : - (ACE_OS::strlen (pri) < 4) ? '?' : pri[3]; - this->copy_trunc (&abbrev, 1); - } - else - { - ACE_OS::strcpy (this->fp_, "s"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - pri); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - } - } - break; - - case 'n': - ACE_OS::strcpy (this->fp_, "s"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - ACE_Log_Msg::program_name_ ? - ACE_Log_Msg::program_name_ : ""); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - break; - - case 'N': - ACE_OS::strcpy (this->fp_, "s"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - this->logger_->file () ? - this->logger_->file () : ""); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - break; - - case 'P': - ACE_OS::strcpy (this->fp_, "d"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - static_cast (this->logger_->getpid ())); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - break; - - case 't': - ACE_OS::strcpy (this->fp_, "u"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - ACE_OS::thr_self ()); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - break; - - // %D and %T with # in the conversion spec do take an arg (ACE_Time_Value*) - case 'D': case 'T': - ACE_OS::strcpy (this->fp_, "s"); - if (ACE_OS::memchr (this->fmt_out_, '#', this->fp_ - this->fmt_out_)) - return false; - { - char day_and_time[27]; - const char *const time = - ACE::timestamp (day_and_time, sizeof day_and_time, true); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - this->in_prog_ == 'T' ? time : day_and_time); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - } - break; - - case '{': - this->logger_->inc (); - break; - case '}': - this->logger_->dec (); - break; - - case '?': - { - ACE_Stack_Trace trc(3); // 3 stack frames between here and user code - ACE_OS::strcpy (this->fp_, "s"); - len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - trc.c_str ()); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - } - break; - - case '*': - // * requires an argument from the "varags" but doesn't complete - // the current conversion specification (for example, %*s): - return false; - - // these require an argument from the "varags" list: - case 'a': - this->abort_ = ABRT_NEED_ARG; - this->copy_trunc ("Aborting...", 11); - return false; - case 'A': // ACE_timer_t is a typedef for double on all platforms - ACE_OS::strcpy (this->fp_, "f"); - return false; - - case 'b': - ACE_OS::strcpy (this->fp_, ACE_SSIZE_T_FORMAT_SPECIFIER + 1); // skip % - return false; - case 'B': - ACE_OS::strcpy (this->fp_, ACE_SIZE_T_FORMAT_SPECIFIER + 1); // skip % - return false; - - case 'C': case 'p': case 'S': - ACE_OS::strcpy (this->fp_, "s"); - // the remaining parts of case 'p' are handled in prepare_format - return false; - - case 'q': - ACE_OS::strcpy (this->fp_, ACE_INT64_FORMAT_SPECIFIER + 1); // skip % - return false; - case 'Q': - ACE_OS::strcpy (this->fp_, ACE_UINT64_FORMAT_SPECIFIER + 1); // skip % - return false; - - case 'r': - this->offset_ = ACE_Log_Msg::msg_off_; - if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT)) - this->copy_trunc ("{", 1); - ACE_Log_Msg::msg_off_ = this->bp_ - this->logger_->msg_; - return false; - - case 'R': - ACE_OS::strcpy (this->fp_, "d"); - return false; - - case 'w': case 'z': - ACE_OS::strcpy (this->fp_, "u"); - return false; - case 'W': - ACE_OS::strcpy (this->fp_, "ls"); - return false; - case 'Z': -#if (defined ACE_WIN32 && !defined ACE_USES_WCHAR) || defined HPUX - ACE_OS::strcpy (this->fp_, "S"); -#elif defined ACE_WIN32 - ACE_OS::strcpy (this->fp_, "s"); -#else - ACE_OS::strcpy (this->fp_, "ls"); -#endif - return false; - - case '@': - ACE_OS::strcpy (this->fp_, "p"); - return false; - case ':': - if (sizeof (time_t) == 8) - ACE_OS::strcpy (this->fp_, ACE_INT64_FORMAT_SPECIFIER + 1); // skip % - else - ACE_OS::strcpy (this->fp_, "d"); - return false; - - case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': // <- ints - case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': // <- doubles - case 'c': case 's': // <- char / const char* - *this->fp_++ = this->in_prog_; - *this->fp_ = 0; - return false; - - default: - // not actually a format specifier: copy verbatim to output - this->copy_trunc (format_start - 1 /* start at % */, n + 2); - this->in_prog_ = ' '; - break; - } - return true; -} - -void ACE_Log_Formatter::insert_pct_S (int sig) -{ - const int n = ACE_OS::snprintf (this->bp_, this->bspace_, - this->fmt_out_, ACE_OS::strsignal (sig)); - ACE_UPDATE_COUNT (this->bspace_, n); - this->bp_ += n; -} - -template -void ACE_Log_Formatter::insert_arg (ArgT arg, bool allow_star) -{ - if (!this->enabled_) return; - - this->prepare_format (); - - const int intArg = static_cast (arg); - switch (this->in_prog_) - { - case 'R': - this->logger_->op_status (intArg); - break; - case 'S': - this->insert_pct_S (intArg); - return; - case '*': - if (allow_star) - { - this->last_star_ = intArg; - this->fp_ += - ACE_OS::snprintf (this->fp_, - sizeof fmt_out_ - (this->fp_ - this->fmt_out_), - "%d", intArg); - return; - } - break; - } - - insert_arg_i (arg); -} - -template -void ACE_Log_Formatter::insert_arg (ArgT *arg) -{ - if (!this->enabled_) return; - - this->prepare_format (); - - insert_arg_i (arg); -} - -template -void ACE_Log_Formatter::insert_arg_i (ArgT arg) -{ - if (this->abort_ == ABRT_NEED_ARG) - { - // arg is ignored - this->abort_ = ABRT_AFTER_FORMAT; - } - else if (*this->fmt_out_) - { - const int n = ACE_OS::snprintf (this->bp_, this->bspace_, - this->fmt_out_, arg); - ACE_UPDATE_COUNT (this->bspace_, n); - this->bp_ += n; - } -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (int pct_adiRS) -{ - this->insert_arg (pct_adiRS, true); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (unsigned int pct_ouxX) -{ - this->insert_arg (pct_ouxX, true); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (double pct_AeEfFgG) -{ - this->insert_arg (pct_AeEfFgG); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (long double pct_AeEfFgG) -{ - this->insert_arg (pct_AeEfFgG); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (char pct_c) -{ - this->insert_arg (pct_c); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (const char *pct_Cps) -{ - this->insert_arg (pct_Cps ? pct_Cps : "(null)"); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (ACE_INT64 pct_q) -{ - this->insert_arg (pct_q); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (ACE_UINT64 pct_Q) -{ - this->insert_arg (pct_Q); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (void (*pct_r) ()) -{ - if (this->enabled_) - { - this->prepare_format (); - pct_r (); - } - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (ACE_WCHAR_T pct_wz) -{ - this->insert_arg (pct_wz); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (const ACE_WCHAR_T *pct_WZ) -{ - this->insert_arg (pct_WZ ? pct_WZ : (const ACE_WCHAR_T *) L"(null)"); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (const void *pct_at) -{ - this->insert_arg (pct_at); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (const ACE_Time_Value *pct_DT) -{ - if (!this->enabled_) return *this; - - this->prepare_format (); - - char day_and_time[27]; - const char *const time = - ACE::timestamp (*pct_DT, day_and_time, sizeof day_and_time, true); - const int len = - ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, - this->in_prog_ == 'T' ? time : day_and_time); - ACE_UPDATE_COUNT (this->bspace_, len); - this->bp_ += len; - - return *this; -} - -#if ACE_SIZEOF_LONG == 4 -ACE_Log_Formatter &ACE_Log_Formatter::operator, (long pct_Lmodifier) -{ - this->insert_arg (pct_Lmodifier, true); - return *this; -} - -ACE_Log_Formatter &ACE_Log_Formatter::operator, (unsigned long pct_Lmodifier) -{ - this->insert_arg (pct_Lmodifier, true); - return *this; -} -#endif - -bool ACE_Log_Formatter::to_record (ACE_Log_Record &record) -{ - if (!this->enabled_) return false; - - this->prepare_format (); - if (this->bspace_) *this->bp_ = 0; - - record.priority (this->priority_); - record.time_stamp (ACE_OS::gettimeofday ()); - record.pid (this->logger_->getpid ()); - record.msg_data (this->logger_->msg ()); - return true; -} - -ssize_t ACE_Log_Msg::log (const ACE_Log_Formatter &formatter) -{ - ACE_Log_Record record; - if (const_cast (formatter).to_record (record)) - { - const ssize_t result = this->log (record, formatter.abort ()); - if (formatter.abort ()) - { -#ifndef ACE_LACKS_STDERR - record.print (local_host_, 0, stderr); -#endif - ACE_OS::abort (); - } - errno = formatter.saved_errno (); - return result; - } - return 0; -} - -#endif /* ACE_LACKS_VA_FUNCTIONS */ - - #if !defined (ACE_WIN32) /** * @class ACE_Log_Msg_Sig_Guard @@ -2881,16 +2246,12 @@ ACE_Log_Msg::log (ACE_Log_Record &log_record, *ACE_Log_Msg_Manager::get_lock (), -1)); -#if !defined ACE_LACKS_STDERR || defined ACE_FACE_DEV if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::STDERR) && !suppress_stderr) // This is taken care of by our caller. log_record.print (ACE_Log_Msg::local_host_, flags, stderr); -#else - ACE_UNUSED_ARG (suppress_stderr); -#endif if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::CUSTOM) || ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG) || @@ -2986,16 +2347,15 @@ ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority, // i.e. we need 68 bytes of buffer per line. size_t hexdump_size = (end_ptr - wr_ptr -58)/68*16; - if (hexdump_size < size) - { - wr_ptr += ACE_OS::snprintf (wr_ptr, - end_ptr - wr_ptr, - ACE_TEXT (" (showing first ") - ACE_SIZE_T_FORMAT_SPECIFIER - ACE_TEXT (" bytes)"), - hexdump_size); - size = hexdump_size; - } + if (hexdump_size < size) { + wr_ptr += ACE_OS::snprintf (wr_ptr, + end_ptr - wr_ptr, + ACE_TEXT (" (showing first ") + ACE_SIZE_T_FORMAT_SPECIFIER + ACE_TEXT (" bytes)"), + hexdump_size); + size = hexdump_size; + } *wr_ptr++ = '\n'; ACE::format_hexdump(buffer, size, wr_ptr, end_ptr - wr_ptr); @@ -3129,22 +2489,13 @@ ACE_Log_Msg::msg_ostream (ACE_OSTREAM_TYPE *m, bool delete_ostream) // Same stream, allow user to change the delete_ostream "flag" if (delete_ostream && !this->ostream_refcount_) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_NEW_MALLOC (this->ostream_refcount_, static_cast(ACE_Allocator::instance()->malloc(sizeof(Atomic_ULong))), Atomic_ULong (1)); -#else ACE_NEW (this->ostream_refcount_, Atomic_ULong (1)); -#endif /* ACE_HAS_ALLOC_HOOKS */ } else if (!delete_ostream && this->ostream_refcount_) { if (--*this->ostream_refcount_ == 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - this->ostream_refcount_->~Atomic_ULong(); - ACE_Allocator::instance()->free(this->ostream_refcount_); -#else delete this->ostream_refcount_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } this->ostream_refcount_ = 0; } @@ -3157,11 +2508,7 @@ ACE_Log_Msg::msg_ostream (ACE_OSTREAM_TYPE *m, bool delete_ostream) if (delete_ostream) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_NEW_MALLOC (this->ostream_refcount_, static_cast(ACE_Allocator::instance()->malloc(sizeof(Atomic_ULong))), Atomic_ULong (1)); -#else ACE_NEW (this->ostream_refcount_, Atomic_ULong (1)); -#endif /* ACE_HAS_ALLOC_HOOKS */ } this->ostream_ = m; @@ -3172,17 +2519,15 @@ ACE_Log_Msg::local_host (const ACE_TCHAR *s) { if (s) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::local_host_); -#else ACE_OS::free ((void *) ACE_Log_Msg::local_host_); -#endif /* ACE_HAS_ALLOC_HOOKS */ + { + ACE_NO_HEAP_CHECK; - ACE_ALLOCATOR (ACE_Log_Msg::local_host_, ACE_OS::strdup (s)); + ACE_ALLOCATOR (ACE_Log_Msg::local_host_, ACE_OS::strdup (s)); + } } } -#ifndef ACE_LACKS_VA_FUNCTIONS int ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority, const char *, @@ -3201,8 +2546,6 @@ ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority, } #endif /* ACE_USES_WCHAR */ -#endif /* ACE_LACKS_VA_FUNCTIONS */ - // **************************************************************** void diff --git a/dep/acelite/ace/Log_Msg.h b/dep/acelite/ace/Log_Msg.h index 92c54cecb..0df963fcf 100644 --- a/dep/acelite/ace/Log_Msg.h +++ b/dep/acelite/ace/Log_Msg.h @@ -4,7 +4,9 @@ /** * @file Log_Msg.h * - * @author Douglas C. Schmidt + * $Id: Log_Msg.h 97662 2014-03-17 10:11:16Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -23,7 +25,6 @@ #include "ace/Log_Priority.h" #include "ace/os_include/os_limits.h" #include "ace/Synch_Traits.h" -#include "ace/Basic_Types.h" // The ACE_ASSERT macro used to be defined here, include ace/Assert.h // for backwards compatibility. @@ -72,63 +73,32 @@ } while (0) #endif #if !defined (ACE_ERROR_RETURN) -# ifdef ACE_LACKS_VA_FUNCTIONS -# define ACE_ERROR_RETURN(X, Y) \ +#define ACE_ERROR_RETURN(X, Y) \ do { \ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \ - ace___->log (X); \ + ace___->log X; \ return Y; \ } while (0) -# else /* ACE_LACKS_VA_FUNCTIONS */ -# define ACE_ERROR_RETURN(X, Y) \ - do { \ - int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \ - ace___->log X; \ - return Y; \ - } while (0) -# endif /* ACE_LACKS_VA_FUNCTIONS */ #endif #if !defined (ACE_ERROR) -# ifdef ACE_LACKS_VA_FUNCTIONS -# define ACE_ERROR(X) \ - do { \ - int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \ - ace___->log (X); \ - } while (0) -# else /* ACE_LACKS_VA_FUNCTIONS */ -# define ACE_ERROR(X) \ +#define ACE_ERROR(X) \ do { \ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \ ace___->log X; \ } while (0) -# endif /* ACE_LACKS_VA_FUNCTIONS */ #endif #if !defined (ACE_DEBUG) -# ifdef ACE_LACKS_VA_FUNCTIONS -# define ACE_DEBUG(X) \ - do { \ - int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ - ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ - ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ - ace___->log (X); \ - } while (0) -# else /* ACE_LACKS_VA_FUNCTIONS */ -# define ACE_DEBUG(X) \ +#define ACE_DEBUG(X) \ do { \ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ ace___->log X; \ } while (0) -# endif /* ACE_LACKS_VA_FUNCTIONS */ #endif #if !defined (ACE_ERROR_INIT) #define ACE_ERROR_INIT(VALUE, FLAGS) \ @@ -161,14 +131,6 @@ # undef THREAD #endif /* THREAD */ -#ifndef ACE_DEFAULT_LOG_FLAGS -# ifdef ACE_ANDROID -# define ACE_DEFAULT_LOG_FLAGS ACE_Log_Msg::STDERR | ACE_Log_Msg::SYSLOG -# else -# define ACE_DEFAULT_LOG_FLAGS ACE_Log_Msg::STDERR -# endif -#endif - ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Log_Msg_Callback; @@ -183,7 +145,6 @@ class ACE_Thread_Descriptor; class ACE_Log_Record; class ACE_Log_Category_TSS; template class ACE_Atomic_Op; -class ACE_Log_Formatter; /** * @class ACE_Log_Msg @@ -242,7 +203,7 @@ public: SYSLOG = 128, /// Write messages to the user provided backend CUSTOM = 256 - }; + }; // = Initialization and termination routines. @@ -292,7 +253,7 @@ public: * @a logger_key is 0, @a prog_name is used. */ int open (const ACE_TCHAR *prog_name, - u_long options_flags = ACE_DEFAULT_LOG_FLAGS, + u_long options_flags = ACE_Log_Msg::STDERR, const ACE_TCHAR *logger_key = 0); // = Set/get the options flags. @@ -469,14 +430,12 @@ public: /// Return true if the requested priority is enabled. int log_priority_enabled (ACE_Log_Priority log_priority); -#ifndef ACE_LACKS_VA_FUNCTIONS /// Return true if the requested priority is enabled. int log_priority_enabled (ACE_Log_Priority log_priority, const char *, ...); -#endif -#if defined (ACE_USES_WCHAR) && !defined ACE_LACKS_VA_FUNCTIONS +#if defined (ACE_USES_WCHAR) // We are not using ACE_TCHAR for this since ACE_HEX_DUMP // doesn't take in a ACE_TCHAR. log_hexdump takes in a char // string, so this must be able to take in a char string even @@ -517,7 +476,6 @@ public: int op_status, int errnum); -#ifndef ACE_LACKS_VA_FUNCTIONS /** * Format a message to the thread-safe ACE logging mechanism. Valid * options (prefixed by '%', as in printf format strings) include: @@ -575,13 +533,6 @@ public: ssize_t log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format, ...); #endif /* ACE_HAS_WCHAR */ -#else /* ACE_LACKS_VA_FUNCTIONS */ - friend class ACE_Log_Formatter; - - ssize_t log (const ACE_Log_Formatter &formatter); - -#endif /* ACE_LACKS_VA_FUNCTIONS */ - /** * An alternative logging mechanism that makes it possible to * integrate variable argument lists from other logging mechanisms @@ -767,153 +718,6 @@ private: ACE_Log_Msg (const ACE_Log_Msg &); }; - -#ifdef ACE_LACKS_VA_FUNCTIONS -class ACE_Time_Value; -/// Alternative to varargs for formatting log messages. -/// When this implementation is enabled, the logging macros (ACE_DEBUG, etc.) -/// are modified to change from logger->log(LM_FOO, "fmt_str", arg1, arg2) to -/// logger->log((LM_FOO, "fmt_str", arg1, arg2)). Due to the extra set of -/// parens, the various overloaded comma operators below take the place of the -/// varargs function. The first operator called is the non-member -/// operator,(ACE_Log_Priority, const char*) which returns an ACE_Log_Formatter -/// object. The subsequent comma operators (for the actual variable args) are -/// members of the ACE_Log_Formatter class. -class ACE_Export ACE_Log_Formatter -{ -public: - ACE_Log_Formatter (ACE_Log_Priority prio, const char *fmt); - - // Notes: - // - ACE_OS::snprintf() is assumed to work. The fallback to ACE_OS::sprintf() - /// is not implemented. - // - Other than special cases (listed below), the names of the parameters - // indicate which formatters they are used for (pct_c => %c). - // - size_t (%B), ssize_t (%b), and time_t (%:) will use one of the - // other overloads (int, INT64, UINT64) depending on the platform. - // - %*s (etc) uses the int or uint overloads for the size argument. - // - No support for ACE_USES_WCHAR has been attempted. - // - Not all platform-specific features from the varargs implementation have - // been ported over to this implementation. - - ACE_Log_Formatter &operator, (int pct_adiRS); - - ACE_Log_Formatter &operator, (unsigned int pct_ouxX); - - ACE_Log_Formatter &operator, (double pct_AeEfFgG); - - ACE_Log_Formatter &operator, (long double pct_AeEfFgG); - - ACE_Log_Formatter &operator, (char pct_c); - - ACE_Log_Formatter &operator, (const char *pct_Cps); - - ACE_Log_Formatter &operator, (ACE_INT64 pct_q); - - ACE_Log_Formatter &operator, (ACE_UINT64 pct_Q); - - ACE_Log_Formatter &operator, (void (*pct_r) ()); - - ACE_Log_Formatter &operator, (ACE_WCHAR_T pct_wz); - - ACE_Log_Formatter &operator, (const ACE_WCHAR_T *pct_WZ); - - ACE_Log_Formatter &operator, (const void *pct_at); - - ACE_Log_Formatter &operator, (const ACE_Time_Value *pct_DT); - -#if ACE_SIZEOF_LONG == 4 - ACE_Log_Formatter &operator, (long pct_Lmodifier); - - ACE_Log_Formatter &operator, (unsigned long pct_Lmodifier); -#endif - - bool abort () const { return this->abort_; } - - int saved_errno () const { return this->saved_errno_; } - - bool to_record (ACE_Log_Record &record); - - ACE_Log_Priority priority () const { return this->priority_; } - -private: - /// Parse the format_ string up to the point where an argument is needed. - /// Set up fmt_out_ as a format string that goes out to snprintf. - void prepare_format (); - - /// Helper function for prepare_format. Processes as much of one conversion - /// specification as possible. Returns true if prepare_format can continue - /// parsing, false if prepare_format needs to return to get more input. - bool process_conversion (); - - /// Copy up to 'limit' characters of 'str' to the resulting buffer (bp_). - /// Returns the number of characters copied. - int copy_trunc (const char *str, int limit); - - /// Insert one argument into the formatted buffer. - /// arg is not a pointer (pointers use the overload below). - /// If allow_star is true, the argument can be the length for a conversion - /// that uses the '*' for width or precision. - template - void insert_arg (ArgT arg, bool allow_star = false); - - /// Insert one pointer-typed argument into the formatted buffer. - /// These could be strings (so ArgT is const char or const wchar_t) or void*. - template - void insert_arg (ArgT *arg); - - /// Core functionality common to both insert_arg overloads. - template - void insert_arg_i (ArgT arg); - - /// Insert the %S (signal name) conversion specification into the buffer. - void insert_pct_S (int sig); - - /// Save errno at the start of the log formatting so it can be restored later. - const int saved_errno_; - - /// Priority of this message. - const ACE_Log_Priority priority_; - - /// Remaining format string (from user) that's left to process. - const char *format_; - - /// The ACE_Log_Msg object that this formatter works with. - ACE_Log_Msg *const logger_; - - /// Saved state of the %a (abort) processing. - enum { ABRT_NONE, ABRT_AFTER_FORMAT, ABRT_NEED_ARG } abort_; - - /// The current log priority is enabled on the logger object. - bool enabled_; - - /// Which specifier is currently being processed (' ' for none). - char in_prog_; - - /// The value last read in from the "varargs" for '*' in width or precision. - int last_star_; - - /// Buffer pointer into ACE_Log_Msg's resulting buffer. - char *bp_; - - /// Buffer space available for bp_ to advance. - size_t bspace_; - - /// Local buffer for outgoing (given to snprintf) format strings. - char fmt_out_[128]; - - /// Format pointer: current position in fmt_out_. - char *fp_; - - /// Saved value of ACE_Log_Msg::msg_off_ in case of reentrant logging (%r). - ptrdiff_t offset_; -}; - -ACE_Export -ACE_Log_Formatter operator, (ACE_Log_Priority prio, const char *fmt); - -#endif /* ACE_LACKS_VA_FUNCTIONS */ - ACE_END_VERSIONED_NAMESPACE_DECL #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) diff --git a/dep/acelite/ace/Log_Msg.inl b/dep/acelite/ace/Log_Msg.inl index 1062c15c6..2f73c897d 100644 --- a/dep/acelite/ace/Log_Msg.inl +++ b/dep/acelite/ace/Log_Msg.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Log_Msg.inl 97662 2014-03-17 10:11:16Z johnnyw $ + #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" diff --git a/dep/acelite/ace/Log_Msg_Backend.cpp b/dep/acelite/ace/Log_Msg_Backend.cpp index 95fd1a6a7..3ab6a3d70 100644 --- a/dep/acelite/ace/Log_Msg_Backend.cpp +++ b/dep/acelite/ace/Log_Msg_Backend.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Msg_Backend.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Log_Msg_Backend.h" diff --git a/dep/acelite/ace/Log_Msg_Backend.h b/dep/acelite/ace/Log_Msg_Backend.h index 87b42f69b..ba3dba1c9 100644 --- a/dep/acelite/ace/Log_Msg_Backend.h +++ b/dep/acelite/ace/Log_Msg_Backend.h @@ -4,7 +4,9 @@ /** * @file Log_Msg_Backend.h * - * @author Douglas C. Schmidt + * $Id: Log_Msg_Backend.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Log_Msg_Callback.cpp b/dep/acelite/ace/Log_Msg_Callback.cpp index 5586c7470..a32626596 100644 --- a/dep/acelite/ace/Log_Msg_Callback.cpp +++ b/dep/acelite/ace/Log_Msg_Callback.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Msg_Callback.cpp 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/Log_Msg_Callback.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Log_Msg_Callback.h b/dep/acelite/ace/Log_Msg_Callback.h index 0493a0769..c88f06529 100644 --- a/dep/acelite/ace/Log_Msg_Callback.h +++ b/dep/acelite/ace/Log_Msg_Callback.h @@ -4,7 +4,9 @@ /** * @file Log_Msg_Callback.h * - * @author Douglas C. Schmidt + * $Id: Log_Msg_Callback.h 97246 2013-08-07 07:10:20Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Log_Msg_IPC.cpp b/dep/acelite/ace/Log_Msg_IPC.cpp index 94b710a6b..4df1db722 100644 --- a/dep/acelite/ace/Log_Msg_IPC.cpp +++ b/dep/acelite/ace/Log_Msg_IPC.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Msg_IPC.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Log_Msg_IPC.h" #include "ace/Log_Record.h" #include "ace/CDR_Stream.h" @@ -16,8 +18,6 @@ ACE_Log_Msg_IPC::~ACE_Log_Msg_IPC (void) (void) this->close (); } -ACE_ALLOC_HOOK_DEFINE(ACE_Log_Msg_IPC) - int ACE_Log_Msg_IPC::open (const ACE_TCHAR *logger_key) { diff --git a/dep/acelite/ace/Log_Msg_IPC.h b/dep/acelite/ace/Log_Msg_IPC.h index 1dad164bd..958eae276 100644 --- a/dep/acelite/ace/Log_Msg_IPC.h +++ b/dep/acelite/ace/Log_Msg_IPC.h @@ -4,6 +4,8 @@ /** * @file Log_Msg_IPC.h * + * $Id: Log_Msg_IPC.h 84536 2009-02-20 09:28:48Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= @@ -69,8 +71,6 @@ public: virtual int close (void); virtual ssize_t log (ACE_Log_Record &log_record); - ACE_ALLOC_HOOK_DECLARE; - private: ACE_LOG_MSG_IPC_STREAM message_queue_; }; diff --git a/dep/acelite/ace/Log_Msg_NT_Event_Log.cpp b/dep/acelite/ace/Log_Msg_NT_Event_Log.cpp index f9d0d141d..192de5f27 100644 --- a/dep/acelite/ace/Log_Msg_NT_Event_Log.cpp +++ b/dep/acelite/ace/Log_Msg_NT_Event_Log.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Msg_NT_Event_Log.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/config-all.h" #if defined (ACE_HAS_LOG_MSG_NT_EVENT_LOG) diff --git a/dep/acelite/ace/Log_Msg_NT_Event_Log.h b/dep/acelite/ace/Log_Msg_NT_Event_Log.h index d234923a5..777f8e97f 100644 --- a/dep/acelite/ace/Log_Msg_NT_Event_Log.h +++ b/dep/acelite/ace/Log_Msg_NT_Event_Log.h @@ -4,6 +4,8 @@ /** * @file Log_Msg_NT_Event_Log.h * + * $Id: Log_Msg_NT_Event_Log.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Christopher Kohlhoff */ //============================================================================= diff --git a/dep/acelite/ace/Log_Msg_UNIX_Syslog.cpp b/dep/acelite/ace/Log_Msg_UNIX_Syslog.cpp index 0c14e0fbb..1ccd438b4 100644 --- a/dep/acelite/ace/Log_Msg_UNIX_Syslog.cpp +++ b/dep/acelite/ace/Log_Msg_UNIX_Syslog.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Msg_UNIX_Syslog.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/config-all.h" #if !defined (ACE_LACKS_UNIX_SYSLOG) @@ -41,20 +43,15 @@ ACE_Log_Msg_UNIX_Syslog::open (const ACE_TCHAR * logger_key) // options LOG_CONS and LOG_PID to be set. There really should be a // logging strategy option to control the syslog log options, // however, we'll take the easy way out for now. -#if defined (ACE_LACKS_OPENLOG) - ACE_UNUSED_ARG (logger_key); - ACE_NOTSUP_RETURN (-1); -#else -# if defined (ACE_USES_WCHAR) +#if defined (ACE_USES_WCHAR) openlog (ACE_TEXT_ALWAYS_CHAR (logger_key), LOG_CONS|LOG_PID, ACE_DEFAULT_SYSLOG_FACILITY); -# else +#else openlog (const_cast (logger_key), LOG_CONS|LOG_PID, ACE_DEFAULT_SYSLOG_FACILITY); -# endif /* ACE_USES_WCHAR */ -#endif /* ACE_LACKS_OPENLOG */ +#endif /* ACE_USES_WCHAR */ // Enable logging of all syslog priorities. If logging of all // priorities is not desired, use the ACE_Log_Msg::priority_mask() diff --git a/dep/acelite/ace/Log_Msg_UNIX_Syslog.h b/dep/acelite/ace/Log_Msg_UNIX_Syslog.h index c870d07e8..56d75029e 100644 --- a/dep/acelite/ace/Log_Msg_UNIX_Syslog.h +++ b/dep/acelite/ace/Log_Msg_UNIX_Syslog.h @@ -4,6 +4,8 @@ /** * @file Log_Msg_UNIX_Syslog.h * + * $Id: Log_Msg_UNIX_Syslog.h 90388 2010-06-02 15:27:59Z vzykov $ + * * @author Jerry D. De Master */ //============================================================================= diff --git a/dep/acelite/ace/Log_Priority.h b/dep/acelite/ace/Log_Priority.h index e077d2303..80a09800e 100644 --- a/dep/acelite/ace/Log_Priority.h +++ b/dep/acelite/ace/Log_Priority.h @@ -4,7 +4,9 @@ /** * @file Log_Priority.h * - * @author Douglas C. Schmidt + * $Id: Log_Priority.h 97262 2013-08-09 08:32:10Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Log_Record.cpp b/dep/acelite/ace/Log_Record.cpp index 68c4ef78a..fadd0f1e6 100644 --- a/dep/acelite/ace/Log_Record.cpp +++ b/dep/acelite/ace/Log_Record.cpp @@ -1,3 +1,5 @@ +// $Id: Log_Record.cpp 97058 2013-04-19 14:41:18Z huangh $ + #include "ace/Log_Record.h" #include "ace/Log_Msg.h" @@ -125,14 +127,10 @@ ACE_Log_Record::msg_data (const ACE_TCHAR *data) size_t const newlen = ACE_OS::strlen (data) + 1; // Will need room for '\0' if (newlen > this->msg_data_size_) { - this->msg_data_size_ = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->msg_data_); - ACE_ALLOCATOR_RETURN (this->msg_data_, static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * newlen)), -1); -#else + ACE_TCHAR *new_msg_data = 0; + ACE_NEW_RETURN (new_msg_data, ACE_TCHAR[newlen], -1); delete [] this->msg_data_; - ACE_NEW_RETURN (this->msg_data_, ACE_TCHAR[newlen], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ + this->msg_data_ = new_msg_data; this->msg_data_size_ = newlen; } ACE_OS::strcpy (this->msg_data_, data); @@ -153,11 +151,7 @@ ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp, category_(0) { // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN))); -#else ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (0 != this->msg_data_) { this->msg_data_size_ = MAXLOGMSGLEN; @@ -178,11 +172,7 @@ ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp, category_(0) { // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN))); -#else ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (0 != this->msg_data_) { this->msg_data_size_ = MAXLOGMSGLEN; @@ -214,11 +204,7 @@ ACE_Log_Record::ACE_Log_Record (void) category_(0) { // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN))); -#else ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (0 != this->msg_data_) { this->msg_data_size_ = MAXLOGMSGLEN; @@ -229,7 +215,7 @@ ACE_Log_Record::ACE_Log_Record (void) int ACE_Log_Record::format_msg (const ACE_TCHAR host_name[], u_long verbose_flag, - ACE_TCHAR *verbose_msg, size_t verbose_msg_size) + ACE_TCHAR *verbose_msg) { /* 012345678901234567890123456 */ /* yyyy-mm-dd hh:mm:ss.mmmmmm */ @@ -268,7 +254,7 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[], const ACE_TCHAR *lhost_name = ((host_name == 0) ? ACE_TEXT ("") : host_name); - ACE_OS::snprintf (verbose_msg, verbose_msg_size, + ACE_OS::sprintf (verbose_msg, verbose_fmt, timestamp, lhost_name, @@ -277,7 +263,7 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[], this->msg_data_); } else if (ACE_BIT_ENABLED (verbose_flag, ACE_Log_Msg::VERBOSE_LITE)) - ACE_OS::snprintf (verbose_msg, verbose_msg_size, + ACE_OS::sprintf (verbose_msg, verbose_lite_fmt, timestamp, ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)), @@ -303,14 +289,9 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[], if ( log_priority_enabled(this->category(), ACE_Log_Priority (this->type_)) ) { ACE_TCHAR *verbose_msg = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (verbose_msg, static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXVERBOSELOGMSGLEN)), -1); -#else ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ - int result = this->format_msg (host_name, verbose_flag, verbose_msg, - MAXVERBOSELOGMSGLEN); + int result = this->format_msg (host_name, verbose_flag, verbose_msg); if (result == 0) { @@ -335,11 +316,7 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[], } } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(verbose_msg); -#else delete [] verbose_msg; -#endif /* ACE_HAS_ALLOC_HOOKS */ return result; } @@ -384,12 +361,8 @@ operator>> (ACE_InputCDR &cdr, if ((cdr >> type) && (cdr >> pid) && (cdr >> sec) && (cdr >> usec) && (cdr >> buffer_len)) { ACE_TCHAR *log_msg; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (log_msg, static_cast (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (buffer_len + 1))), -1); -#else ACE_NEW_RETURN (log_msg, ACE_TCHAR[buffer_len + 1], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_Auto_Basic_Array_Ptr log_msg_p (log_msg); + auto_ptr log_msg_p (log_msg); log_record.type (type); log_record.pid (pid); log_record.time_stamp (ACE_Time_Value (ACE_Utils::truncate_cast (sec), @@ -418,8 +391,7 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[], ACE_TCHAR* verbose_msg = 0; ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1); - int const result = this->format_msg (host_name, verbose_flag, verbose_msg, - MAXVERBOSELOGMSGLEN); + int const result = this->format_msg (host_name, verbose_flag, verbose_msg); if (result == 0) { diff --git a/dep/acelite/ace/Log_Record.h b/dep/acelite/ace/Log_Record.h index 792384b9a..04338c07a 100644 --- a/dep/acelite/ace/Log_Record.h +++ b/dep/acelite/ace/Log_Record.h @@ -4,7 +4,9 @@ /** * @file Log_Record.h * - * @author Douglas C. Schmidt + * $Id: Log_Record.h 96984 2013-04-11 15:22:24Z huangh $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -74,7 +76,7 @@ public: /// FILE if the corresponding type is enabled. int print (const ACE_TCHAR host_name[], u_long verbose_flag, -#if !defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_STDERR) +#if !defined (ACE_HAS_WINCE) FILE *fp = stderr); #else FILE *fp); @@ -90,8 +92,7 @@ public: int format_msg (const ACE_TCHAR host_name[], u_long verbose_flag, - ACE_TCHAR *verbose_msg, - size_t verbose_msg_size); + ACE_TCHAR *verbose_msg); /** * Returns a character array with the string form of the diff --git a/dep/acelite/ace/Log_Record.inl b/dep/acelite/ace/Log_Record.inl index dfd7e75b5..d0371b661 100644 --- a/dep/acelite/ace/Log_Record.inl +++ b/dep/acelite/ace/Log_Record.inl @@ -1,24 +1,19 @@ // -*- C++ -*- +// +// $Id: Log_Record.inl 97017 2013-04-15 14:00:52Z mitza $ + #include "ace/Global_Macros.h" #include "ace/os_include/arpa/os_inet.h" #include "ace/Time_Value.h" #include "ace/OS_NS_string.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Log_Record::~ACE_Log_Record (void) { if (this->msg_data_) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->msg_data_); -#else delete [] this->msg_data_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_INLINE ACE_UINT32 diff --git a/dep/acelite/ace/Logging_Strategy.cpp b/dep/acelite/ace/Logging_Strategy.cpp index 78f5ac0ac..e2aca7bff 100644 --- a/dep/acelite/ace/Logging_Strategy.cpp +++ b/dep/acelite/ace/Logging_Strategy.cpp @@ -1,3 +1,5 @@ +// $Id: Logging_Strategy.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Logging_Strategy.h" #include "ace/Service_Config.h" #include "ace/ACE.h" @@ -173,11 +175,7 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[]) case 'k': // Ensure that the LOGGER flag is set ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->logger_key_); -#else delete [] this->logger_key_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->logger_key_ = ACE::strnew (get_opt.opt_arg ()); break; case 'm': @@ -186,11 +184,7 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[]) this->max_size_ <<= 10; // convert from KB to bytes. break; case 'n': -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->program_name_); -#else delete [] this->program_name_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->program_name_ = ACE::strnew (get_opt.opt_arg ()); break; case 'N': @@ -210,11 +204,7 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[]) case 's': // Ensure that the OSTREAM flag is set ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->filename_); -#else delete [] this->filename_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->filename_ = ACE::strnew (get_opt.opt_arg ()); break; case 't': @@ -253,13 +243,8 @@ ACE_Logging_Strategy::ACE_Logging_Strategy (void) #if defined (ACE_DEFAULT_LOGFILE) this->filename_ = ACE::strnew (ACE_DEFAULT_LOGFILE); #else /* ACE_DEFAULT_LOGFILE */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR (this->filename_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (MAXPATHLEN + 1)))); -#else ACE_NEW (this->filename_, ACE_TCHAR[MAXPATHLEN + 1]); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Get the temporary directory if (ACE::get_temp_dir @@ -282,30 +267,17 @@ ACE_Logging_Strategy::~ACE_Logging_Strategy (void) { // This is allocated in constructor, so it must be deallocated in // the destructor! -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->filename_); -#else delete [] this->filename_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } int ACE_Logging_Strategy::fini (void) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->filename_); -#else delete [] this->filename_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->filename_ = 0; // Avoid double deletions. -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->logger_key_); - ACE_Allocator::instance()->free(this->program_name_);; -#else delete [] this->logger_key_; delete [] this->program_name_; -#endif /* ACE_HAS_ALLOC_HOOKS */ if (this->reactor () && this->interval_ > 0 && this->max_size_ > 0) @@ -506,14 +478,14 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, for (int i = max_num ; i > 1 ;i--) { - ACE_OS::snprintf (backup, MAXPATHLEN + 1, - ACE_TEXT ("%s.%d"), - this->filename_, - i); - ACE_OS::snprintf (to_backup, MAXPATHLEN + 1, - ACE_TEXT ("%s.%d"), - this->filename_, - i - 1); + ACE_OS::sprintf (backup, + ACE_TEXT ("%s.%d"), + this->filename_, + i); + ACE_OS::sprintf (to_backup, + ACE_TEXT ("%s.%d"), + this->filename_, + i - 1); // Remove any existing old file; ignore error as // file may not exist. @@ -523,19 +495,19 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, // backup log file. ACE_OS::rename (to_backup, backup); } - ACE_OS::snprintf (backup, MAXPATHLEN + 1, - ACE_TEXT ("%s.1"), - this->filename_); + ACE_OS::sprintf (backup, + ACE_TEXT ("%s.1"), + this->filename_); } else { if (fixed_number_ && count_>max_file_number_) count_ = 1; // start over from 1 - ACE_OS::snprintf (backup, MAXPATHLEN + 1, - ACE_TEXT ("%s.%d"), - this->filename_, - count_); + ACE_OS::sprintf (backup, + ACE_TEXT ("%s.%d"), + this->filename_, + count_); } // Remove any existing old file; ignore error as file may @@ -614,6 +586,8 @@ ACE_Logging_Strategy::log_msg (ACE_Log_Msg *log_msg) this->log_msg_ = log_msg; } +ACE_END_VERSIONED_NAMESPACE_DECL + // The following is a "Factory" used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the // Logging_Strategy. @@ -627,8 +601,6 @@ ACE_STATIC_SVC_DEFINE (ACE_Logging_Strategy, ACE_FACTORY_DEFINE (ACE, ACE_Logging_Strategy) -ACE_END_VERSIONED_NAMESPACE_DECL - // _get_dll_unload_policy() prevents ACE from being unloaded and having its // framework components run down if/when the Logging Strategy is unloaded. extern "C" ACE_Export int diff --git a/dep/acelite/ace/Logging_Strategy.h b/dep/acelite/ace/Logging_Strategy.h index 140e3352a..69c277852 100644 --- a/dep/acelite/ace/Logging_Strategy.h +++ b/dep/acelite/ace/Logging_Strategy.h @@ -4,6 +4,8 @@ /** * @file Logging_Strategy.h * + * $Id: Logging_Strategy.h 96985 2013-04-11 15:50:32Z huangh $ + * * @author Prashant Jain * @author Orlando Ribeiro */ @@ -203,10 +205,10 @@ protected: ACE_Log_Msg *log_msg_; }; +ACE_END_VERSIONED_NAMESPACE_DECL + ACE_STATIC_SVC_DECLARE_EXPORT(ACE, ACE_Logging_Strategy) ACE_FACTORY_DECLARE (ACE, ACE_Logging_Strategy) -ACE_END_VERSIONED_NAMESPACE_DECL - #endif /* ACE_LOGGING_STRATEGY_H */ diff --git a/dep/acelite/ace/MEM_Acceptor.cpp b/dep/acelite/ace/MEM_Acceptor.cpp index a7353b6e3..c1a9113a4 100644 --- a/dep/acelite/ace/MEM_Acceptor.cpp +++ b/dep/acelite/ace/MEM_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: MEM_Acceptor.cpp 97308 2013-09-01 00:58:08Z mesnier_p $ + #include "ace/MEM_Acceptor.h" #include "ace/Lib_Find.h" @@ -39,11 +41,7 @@ ACE_MEM_Acceptor::ACE_MEM_Acceptor (void) ACE_MEM_Acceptor::~ACE_MEM_Acceptor (void) { ACE_TRACE ("ACE_MEM_Acceptor::~ACE_MEM_Acceptor"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->mmap_prefix_); -#else delete[] this->mmap_prefix_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } // General purpose routine for performing server ACE_SOCK creation. @@ -142,10 +140,10 @@ ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream, if (this->mmap_prefix_ != 0) { - ACE_OS::snprintf (buf, sizeof buf / sizeof buf[0], - ACE_TEXT ("%s_%d_"), - this->mmap_prefix_, - local_addr.get_port_number ()); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s_%d_"), + this->mmap_prefix_, + local_addr.get_port_number ()); } else { @@ -159,9 +157,9 @@ ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream, buf[0] = 0; } - ACE_OS::snprintf (name, 25, - ACE_TEXT ("MEM_Acceptor_%d_"), - local_addr.get_port_number ()); + ACE_OS::sprintf (name, + ACE_TEXT ("MEM_Acceptor_%d_"), + local_addr.get_port_number ()); ACE_OS::strcat (buf, name); } ACE_TCHAR unique [MAXPATHLEN]; diff --git a/dep/acelite/ace/MEM_Acceptor.h b/dep/acelite/ace/MEM_Acceptor.h index cb1e34157..94ff5138d 100644 --- a/dep/acelite/ace/MEM_Acceptor.h +++ b/dep/acelite/ace/MEM_Acceptor.h @@ -4,6 +4,8 @@ /** * @file MEM_Acceptor.h * + * $Id: MEM_Acceptor.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/MEM_Acceptor.inl b/dep/acelite/ace/MEM_Acceptor.inl index 77e7b9b37..4e63e1067 100644 --- a/dep/acelite/ace/MEM_Acceptor.inl +++ b/dep/acelite/ace/MEM_Acceptor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: MEM_Acceptor.inl 91688 2010-09-09 11:21:50Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/MEM_Addr.cpp b/dep/acelite/ace/MEM_Addr.cpp index 985a99be5..b7ca94dfd 100644 --- a/dep/acelite/ace/MEM_Addr.cpp +++ b/dep/acelite/ace/MEM_Addr.cpp @@ -1,3 +1,5 @@ +// $Id: MEM_Addr.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Defines the Internet domain address family address format. #include "ace/MEM_Addr.h" @@ -12,9 +14,6 @@ #include "ace/OS_NS_stdlib.h" #include "ace/OS_NS_unistd.h" #include "ace/os_include/os_netdb.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -118,7 +117,7 @@ ACE_MEM_Addr::get_addr (void) const // Set a pointer to the address. void -ACE_MEM_Addr::set_addr (const void *addr, int len) +ACE_MEM_Addr::set_addr (void *addr, int len) { ACE_TRACE ("ACE_MEM_Addr::set_addr"); diff --git a/dep/acelite/ace/MEM_Addr.h b/dep/acelite/ace/MEM_Addr.h index 09fff5c1a..3a3d09095 100644 --- a/dep/acelite/ace/MEM_Addr.h +++ b/dep/acelite/ace/MEM_Addr.h @@ -4,6 +4,8 @@ /** * @file MEM_Addr.h * + * $Id: MEM_Addr.h 97326 2013-09-11 07:52:09Z johnnyw $ + * * @author Nanbor Wang */ //========================================================================== @@ -76,7 +78,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the address. - virtual void set_addr (const void *, int len); + virtual void set_addr (void *, int len); /// Transform the external ACE_MEM_Addr address into string /// format. @@ -105,21 +107,7 @@ public: */ const char *get_host_name (void) const; - /** - * Return the "dotted decimal" external Internet address representation of - * the hostname storing it in the @a addr (which is assumed to be - * @a addr_size bytes long). This version is reentrant. - */ - const char *get_host_addr (char *addr, int addr_size) const; - - /** - * Return the "dotted decimal" external Internet address representation of - * the hostname. This version is non-reentrant since it returns a - * pointer to a static data area. You should therefore either - * (1) do a "deep copy" of the address returned by get_host_addr(), e.g., - * using strdup() or (2) use the "reentrant" version of - * get_host_addr() described above. - */ + /// Return the "dotted decimal" external address. const char *get_host_addr (void) const; /// Return the 4-byte external IP address, converting it into host byte diff --git a/dep/acelite/ace/MEM_Addr.inl b/dep/acelite/ace/MEM_Addr.inl index f849070ac..ef19536df 100644 --- a/dep/acelite/ace/MEM_Addr.inl +++ b/dep/acelite/ace/MEM_Addr.inl @@ -1,10 +1,14 @@ // -*- C++ -*- +// +// $Id: MEM_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Global_Macros.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL -/// Set the port number. +// Set the port number. + ACE_INLINE void ACE_MEM_Addr::set_port_number (u_short port_number, int encode) @@ -30,7 +34,8 @@ ACE_MEM_Addr::set (const ACE_TCHAR port_number[]) return this->string_to_addr (port_number); } -/// Return the port number. +// Return the port number. + ACE_INLINE u_short ACE_MEM_Addr::get_port_number (void) const { @@ -38,23 +43,17 @@ ACE_MEM_Addr::get_port_number (void) const return this->internal_.get_port_number (); } -/// Return the "dotted decimal" external address. +// Return the dotted Internet address. + ACE_INLINE const char * ACE_MEM_Addr::get_host_addr (void) const { ACE_TRACE ("ACE_MEM_Addr::get_host_addr"); - return this->external_.get_host_addr (); + return this->internal_.get_host_addr (); } -/// Return the "dotted decimal" external address. -ACE_INLINE const char * -ACE_MEM_Addr::get_host_addr (char *addr, int addr_size) const -{ - ACE_TRACE ("ACE_MEM_Addr::get_host_addr"); - return this->external_.get_host_addr (addr, addr_size); -} +// Return the 4-byte IP address, converting it into host byte order. -/// Return the 4-byte IP address, converting it into host byte order. ACE_INLINE ACE_UINT32 ACE_MEM_Addr::get_ip_address (void) const { @@ -74,7 +73,8 @@ ACE_MEM_Addr::get_remote_addr (void) const return this->external_; } -/// Compare two addresses for equality. +// Compare two addresses for equality. + ACE_INLINE bool ACE_MEM_Addr::operator == (const ACE_MEM_Addr &sap) const { @@ -92,7 +92,8 @@ ACE_MEM_Addr::operator == (const ACE_INET_Addr &sap) const return this->external_ == sap; } -/// Compare two addresses for inequality. +// Compare two addresses for inequality. + ACE_INLINE bool ACE_MEM_Addr::operator != (const ACE_MEM_Addr &sap) const { diff --git a/dep/acelite/ace/MEM_Connector.cpp b/dep/acelite/ace/MEM_Connector.cpp index 4df5ec488..613ba87c6 100644 --- a/dep/acelite/ace/MEM_Connector.cpp +++ b/dep/acelite/ace/MEM_Connector.cpp @@ -1,3 +1,5 @@ +// $Id: MEM_Connector.cpp 97326 2013-09-11 07:52:09Z johnnyw $ + #include "ace/MEM_Connector.h" #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) @@ -32,7 +34,7 @@ ACE_MEM_Connector::ACE_MEM_Connector (void) // Establish a connection. ACE_MEM_Connector::ACE_MEM_Connector (ACE_MEM_Stream &new_stream, const ACE_INET_Addr &remote_sap, - const ACE_Time_Value *timeout, + ACE_Time_Value *timeout, const ACE_Addr &local_sap, int reuse_addr, int flags, @@ -55,7 +57,7 @@ ACE_MEM_Connector::ACE_MEM_Connector (ACE_MEM_Stream &new_stream, int ACE_MEM_Connector::connect (ACE_MEM_Stream &new_stream, const ACE_INET_Addr &remote_sap, - const ACE_Time_Value *timeout, + ACE_Time_Value *timeout, const ACE_Addr &local_sap, int reuse_addr, int flags, diff --git a/dep/acelite/ace/MEM_Connector.h b/dep/acelite/ace/MEM_Connector.h index 2ce458c0c..7301ac8fb 100644 --- a/dep/acelite/ace/MEM_Connector.h +++ b/dep/acelite/ace/MEM_Connector.h @@ -4,6 +4,8 @@ /** * @file MEM_Connector.h * + * $Id: MEM_Connector.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Nanbor Wang */ //============================================================================= @@ -78,7 +80,7 @@ public: */ ACE_MEM_Connector (ACE_MEM_Stream &new_stream, const ACE_INET_Addr &remote_sap, - const ACE_Time_Value *timeout = 0, + ACE_Time_Value *timeout = 0, const ACE_Addr &local_sap = ACE_Addr::sap_any, int reuse_addr = 0, int flags = 0, @@ -127,7 +129,7 @@ public: */ int connect (ACE_MEM_Stream &new_stream, const ACE_INET_Addr &remote_sap, - const ACE_Time_Value *timeout = 0, + ACE_Time_Value *timeout = 0, const ACE_Addr &local_sap = ACE_Addr::sap_any, int reuse_addr = 0, int flags = 0, diff --git a/dep/acelite/ace/MEM_Connector.inl b/dep/acelite/ace/MEM_Connector.inl index ca7a601f1..e11132b5b 100644 --- a/dep/acelite/ace/MEM_Connector.inl +++ b/dep/acelite/ace/MEM_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: MEM_Connector.inl 91688 2010-09-09 11:21:50Z johnnyw $ + // Establish a connection. ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/MEM_IO.cpp b/dep/acelite/ace/MEM_IO.cpp index 04e49821d..1064f3e6c 100644 --- a/dep/acelite/ace/MEM_IO.cpp +++ b/dep/acelite/ace/MEM_IO.cpp @@ -1,4 +1,6 @@ // MEM_IO.cpp +// $Id: MEM_IO.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/MEM_IO.h" #include "ace/Handle_Set.h" @@ -251,15 +253,6 @@ ACE_MT_MEM_IO::init (ACE_HANDLE handle, return 0; } -int -ACE_MT_MEM_IO::fini () -{ - const int ret = ACE_MEM_SAP::fini (); - ACE_Process_Mutex::unlink (this->recv_channel_.lock_->name ()); - ACE_Process_Mutex::unlink (this->send_channel_.lock_->name ()); - return ret; -} - ssize_t ACE_MT_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf, int flags, diff --git a/dep/acelite/ace/MEM_IO.h b/dep/acelite/ace/MEM_IO.h index 385d6e995..8e3f79c0b 100644 --- a/dep/acelite/ace/MEM_IO.h +++ b/dep/acelite/ace/MEM_IO.h @@ -4,6 +4,8 @@ /** * @file MEM_IO.h * + * $Id: MEM_IO.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Nanbor Wang */ //============================================================================= @@ -116,8 +118,6 @@ public: const ACE_TCHAR *name, MALLOC_OPTIONS *options); - int fini (); - /** * Fetch location of next available data into . * As this operation read the address of the data off the socket diff --git a/dep/acelite/ace/MEM_IO.inl b/dep/acelite/ace/MEM_IO.inl index 0599660bc..5edc0128b 100644 --- a/dep/acelite/ace/MEM_IO.inl +++ b/dep/acelite/ace/MEM_IO.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: MEM_IO.inl 91813 2010-09-17 07:52:52Z johnnyw $ + #include "ace/OS_NS_string.h" #include "ace/Truncate.h" diff --git a/dep/acelite/ace/MEM_SAP.cpp b/dep/acelite/ace/MEM_SAP.cpp index 4386c0ca7..1d3312d36 100644 --- a/dep/acelite/ace/MEM_SAP.cpp +++ b/dep/acelite/ace/MEM_SAP.cpp @@ -1,3 +1,5 @@ +// $Id: MEM_SAP.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/MEM_SAP.h" #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) @@ -10,7 +12,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_MEM_SAP) +ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP) void ACE_MEM_SAP::dump (void) const @@ -82,9 +84,7 @@ ACE_MEM_SAP::close_shm_malloc (void) int retv = -1; if (this->shm_malloc_ != 0) - if (this->shm_malloc_->release (1) == 0) - ACE_Process_Mutex::unlink (this->shm_malloc_->memory_pool (). - mmap ().filename ()); + this->shm_malloc_->release (1); delete this->shm_malloc_; this->shm_malloc_ = 0; diff --git a/dep/acelite/ace/MEM_SAP.h b/dep/acelite/ace/MEM_SAP.h index ea5f1cd21..4ca6b7336 100644 --- a/dep/acelite/ace/MEM_SAP.h +++ b/dep/acelite/ace/MEM_SAP.h @@ -4,6 +4,8 @@ /** * @file MEM_SAP.h * + * $Id: MEM_SAP.h 92090 2010-09-29 14:10:45Z johnnyw $ + * * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/MEM_SAP.inl b/dep/acelite/ace/MEM_SAP.inl index 87c6f9133..a006fdc11 100644 --- a/dep/acelite/ace/MEM_SAP.inl +++ b/dep/acelite/ace/MEM_SAP.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: MEM_SAP.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/RW_Thread_Mutex.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/MEM_Stream.cpp b/dep/acelite/ace/MEM_Stream.cpp index 74690a6dd..32647ddf1 100644 --- a/dep/acelite/ace/MEM_Stream.cpp +++ b/dep/acelite/ace/MEM_Stream.cpp @@ -1,3 +1,5 @@ +// $Id: MEM_Stream.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/MEM_Stream.h" #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) diff --git a/dep/acelite/ace/MEM_Stream.h b/dep/acelite/ace/MEM_Stream.h index 8afbe13b2..6f0d36160 100644 --- a/dep/acelite/ace/MEM_Stream.h +++ b/dep/acelite/ace/MEM_Stream.h @@ -4,6 +4,8 @@ /** * @file MEM_Stream.h * + * $Id: MEM_Stream.h 94448 2011-09-08 08:20:29Z johnnyw $ + * * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/MEM_Stream.inl b/dep/acelite/ace/MEM_Stream.inl index d268c45a7..d7cff06cb 100644 --- a/dep/acelite/ace/MEM_Stream.inl +++ b/dep/acelite/ace/MEM_Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: MEM_Stream.inl 92069 2010-09-28 11:38:59Z johnnyw $ + #include "ace/MEM_Stream.h" #include "ace/OS_NS_sys_socket.h" diff --git a/dep/acelite/ace/MMAP_Memory_Pool.cpp b/dep/acelite/ace/MMAP_Memory_Pool.cpp index c0a02bac8..bae6f7cbc 100644 --- a/dep/acelite/ace/MMAP_Memory_Pool.cpp +++ b/dep/acelite/ace/MMAP_Memory_Pool.cpp @@ -1,3 +1,5 @@ +// $Id: MMAP_Memory_Pool.cpp 97921 2014-10-10 21:58:31Z shuston $ + // MMAP_Memory_Pool.cpp #include "ace/MMAP_Memory_Pool.h" #include "ace/OS_NS_sys_mman.h" diff --git a/dep/acelite/ace/MMAP_Memory_Pool.h b/dep/acelite/ace/MMAP_Memory_Pool.h index ed272d8ef..b11077d42 100644 --- a/dep/acelite/ace/MMAP_Memory_Pool.h +++ b/dep/acelite/ace/MMAP_Memory_Pool.h @@ -4,7 +4,9 @@ /** * @file MMAP_Memory_Pool.h * - * @author Dougls C. Schmidt + * $Id: MMAP_Memory_Pool.h 81589 2008-05-02 13:07:33Z johnnyw $ + * + * @author Dougls C. Schmidt * @author Prashant Jain */ //============================================================================= @@ -333,10 +335,6 @@ public: /// Overwrite the default sync behavior with no-op virtual int sync (void *addr, size_t len, int flags = MS_SYNC); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/MMAP_Memory_Pool.inl b/dep/acelite/ace/MMAP_Memory_Pool.inl index bc494c431..80df93223 100644 --- a/dep/acelite/ace/MMAP_Memory_Pool.inl +++ b/dep/acelite/ace/MMAP_Memory_Pool.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: MMAP_Memory_Pool.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Malloc.cpp b/dep/acelite/ace/Malloc.cpp index 0984ac100..a3fd3176e 100644 --- a/dep/acelite/ace/Malloc.cpp +++ b/dep/acelite/ace/Malloc.cpp @@ -1,3 +1,5 @@ +// $Id: Malloc.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Malloc.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Malloc.h b/dep/acelite/ace/Malloc.h index 3afe9b957..988c8b90e 100644 --- a/dep/acelite/ace/Malloc.h +++ b/dep/acelite/ace/Malloc.h @@ -4,6 +4,8 @@ /** * @file Malloc.h * + * $Id: Malloc.h 96985 2013-04-11 15:50:32Z huangh $ + * * @author Doug Schmidt and Irfan Pyarali */ //========================================================================== diff --git a/dep/acelite/ace/Malloc.inl b/dep/acelite/ace/Malloc.inl index 2eb2a3a23..caf48684f 100644 --- a/dep/acelite/ace/Malloc.inl +++ b/dep/acelite/ace/Malloc.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Malloc.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Malloc_Allocator.cpp b/dep/acelite/ace/Malloc_Allocator.cpp index 31834e3c8..06df196f8 100644 --- a/dep/acelite/ace/Malloc_Allocator.cpp +++ b/dep/acelite/ace/Malloc_Allocator.cpp @@ -1,3 +1,5 @@ +// $Id: Malloc_Allocator.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Malloc_Allocator.h" #include "ace/Object_Manager.h" @@ -109,6 +111,7 @@ void * ACE_New_Allocator::malloc (size_t nbytes) { char *ptr = 0; + if (nbytes > 0) ACE_NEW_RETURN (ptr, char[nbytes], 0); return (void *) ptr; @@ -135,11 +138,7 @@ ACE_New_Allocator::calloc (size_t n_elem, size_t elem_size, char initial_value) void ACE_New_Allocator::free (void *ptr) { -#ifdef ACE_FACE_SAFETY_BASE - ACE_UNUSED_ARG (ptr); -#else delete [] (char *) ptr; -#endif } int diff --git a/dep/acelite/ace/Malloc_Allocator.h b/dep/acelite/ace/Malloc_Allocator.h index 81710aad5..1757cd275 100644 --- a/dep/acelite/ace/Malloc_Allocator.h +++ b/dep/acelite/ace/Malloc_Allocator.h @@ -4,6 +4,8 @@ /** * @file Malloc_Allocator.h * + * $Id: Malloc_Allocator.h 97185 2013-05-30 18:51:35Z johnnyw $ + * * @author Based on code that formerly existed in another ACE file. */ //========================================================================== diff --git a/dep/acelite/ace/Malloc_Allocator.inl b/dep/acelite/ace/Malloc_Allocator.inl index bb1fcffc0..050d73538 100644 --- a/dep/acelite/ace/Malloc_Allocator.inl +++ b/dep/acelite/ace/Malloc_Allocator.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Malloc_Allocator.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Malloc_Base.h b/dep/acelite/ace/Malloc_Base.h index b26906992..35e466851 100644 --- a/dep/acelite/ace/Malloc_Base.h +++ b/dep/acelite/ace/Malloc_Base.h @@ -4,6 +4,8 @@ /** * @file Malloc_Base.h * + * $Id: Malloc_Base.h 92085 2010-09-29 12:23:13Z johnnyw $ + * * @author Doug Schmidt and Irfan Pyarali */ //============================================================================= @@ -22,8 +24,6 @@ #include "ace/os_include/sys/os_types.h" #include "ace/os_include/sys/os_mman.h" #include "ace/os_include/sys/os_types.h" -#include -#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -162,71 +162,6 @@ private: static int delete_allocator_; }; -/** - * @class ACE_Allocator_Std_Adapter - * - * @brief Model of std::allocator that forwards requests to -# ACE_Allocator::instance. To be used with STL containers. - */ - -template -class ACE_Export ACE_Allocator_Std_Adapter -{ -public: - typedef T value_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - template struct rebind { typedef ACE_Allocator_Std_Adapter other; }; - - ACE_Allocator_Std_Adapter() {} - - template - ACE_Allocator_Std_Adapter(const ACE_Allocator_Std_Adapter&) {} - - static T* allocate(std::size_t n) - { - void* raw_mem = ACE_Allocator::instance()->malloc(n * sizeof(T)); - if (!raw_mem) throw std::bad_alloc(); - return static_cast(raw_mem); - } - - static void deallocate(T* ptr, std::size_t) - { - ACE_Allocator::instance()->free(ptr); - } - - static void construct(T* ptr, const T& value) - { - new (static_cast(ptr)) T(value); - } - - static void destroy(T* ptr) - { - ptr->~T(); - } - - static size_type max_size() - { - return (std::numeric_limits::max)(); - } -}; - -template -bool operator==(const ACE_Allocator_Std_Adapter&, const ACE_Allocator_Std_Adapter&) -{ - return true; -} - -template -bool operator!=(const ACE_Allocator_Std_Adapter&, const ACE_Allocator_Std_Adapter&) -{ - return false; -} - ACE_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" diff --git a/dep/acelite/ace/Malloc_T.cpp b/dep/acelite/ace/Malloc_T.cpp index 69a6e4398..666e789b8 100644 --- a/dep/acelite/ace/Malloc_T.cpp +++ b/dep/acelite/ace/Malloc_T.cpp @@ -1,3 +1,5 @@ +// $Id: Malloc_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_MALLOC_T_CPP #define ACE_MALLOC_T_CPP @@ -35,13 +37,8 @@ ACE_Cached_Allocator::ACE_Cached_Allocator (size_t n_chunks) // previous versions of ACE size_t chunk_size = sizeof (T); chunk_size = ACE_MALLOC_ROUNDUP (chunk_size, ACE_MALLOC_ALIGN); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR (this->pool_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * n_chunks * chunk_size))); -#else ACE_NEW (this->pool_, char[n_chunks * chunk_size]); -#endif /* ACE_HAS_ALLOC_HOOKS */ for (size_t c = 0; c < n_chunks; @@ -50,22 +47,16 @@ ACE_Cached_Allocator::ACE_Cached_Allocator (size_t n_chunks) void* placement = this->pool_ + c * chunk_size; this->free_list_.add (new (placement) ACE_Cached_Mem_Pool_Node); } - // Put into free list using placement constructor, no real memory + // Put into free list using placement contructor, no real memory // allocation in the above . } template ACE_Cached_Allocator::~ACE_Cached_Allocator (void) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->pool_); -#else delete [] this->pool_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Cached_Allocator) - template void * ACE_Cached_Allocator::malloc (size_t nbytes) { @@ -128,7 +119,7 @@ ACE_Dynamic_Cached_Allocator::ACE_Dynamic_Cached_Allocator this->free_list_.add (new (placement) ACE_Cached_Mem_Pool_Node); } - // Put into free list using placement constructor, no real memory + // Put into free list using placement contructor, no real memory // allocation in the above . } @@ -181,7 +172,7 @@ ACE_Dynamic_Cached_Allocator::free (void * ptr) this->free_list_.add ((ACE_Cached_Mem_Pool_Node *) ptr); } -ACE_ALLOC_HOOK_DEFINE_Tmcc (ACE_Malloc_T) +ACE_ALLOC_HOOK_DEFINE (ACE_Malloc_T) template void * ACE_Allocator_Adapter::malloc (size_t nbytes) @@ -366,8 +357,6 @@ ACE_Allocator_Adapter::dump (void) const #endif /* ACE_HAS_DUMP */ } -ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Allocator_Adapter) - template void ACE_Malloc_T::dump (void) const { @@ -516,17 +505,17 @@ ACE_Malloc_T::ACE_Malloc_T (const ACE_TCHAR *p { ACE_TRACE ("ACE_Malloc_T::ACE_Malloc_T"); this->lock_ = ACE_Malloc_Lock_Adapter_T ()(pool_name); - if (this->lock_ != 0) - { - this->delete_lock_ = true; + if (this->lock_ == 0) + return; - this->bad_flag_ = this->open (); + this->delete_lock_ = true; - if (this->bad_flag_ == -1) - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Malloc_T::ACE_Malloc_T"))); - } + this->bad_flag_ = this->open (); + + if (this->bad_flag_ == -1) + ACELIB_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Malloc_T::ACE_Malloc_T"))); } template @@ -541,16 +530,16 @@ ACE_Malloc_T::ACE_Malloc_T (const ACE_TCHAR *p // Use pool_name for lock_name if lock_name not passed. const ACE_TCHAR *name = lock_name ? lock_name : pool_name; this->lock_ = ACE_Malloc_Lock_Adapter_T ()(name); - if (this->lock_ != 0) - { - this->delete_lock_ = true; + if (this->lock_ == 0) + return; - this->bad_flag_ = this->open (); - if (this->bad_flag_ == -1) - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Malloc_T::ACE_Malloc_T"))); - } + this->delete_lock_ = true; + + this->bad_flag_ = this->open (); + if (this->bad_flag_ == -1) + ACELIB_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Malloc_T::ACE_Malloc_T"))); } diff --git a/dep/acelite/ace/Malloc_T.h b/dep/acelite/ace/Malloc_T.h index 017de151e..3d170b722 100644 --- a/dep/acelite/ace/Malloc_T.h +++ b/dep/acelite/ace/Malloc_T.h @@ -4,7 +4,9 @@ /** * @file Malloc_T.h * - * @author Douglas C. Schmidt and + * $Id: Malloc_T.h 92085 2010-09-29 12:23:13Z johnnyw $ + * + * @author Douglas C. Schmidt and * Irfan Pyarali */ //========================================================================== @@ -51,8 +53,6 @@ public: /// Set the next ACE_Cached_Mem_Pool_Node. void set_next (ACE_Cached_Mem_Pool_Node *ptr); - ACE_ALLOC_HOOK_DECLARE; - private: /** * Since memory is not used when placed in a free list, @@ -121,8 +121,6 @@ public: /// Return the number of chunks available in the cache. size_t pool_depth (void); - ACE_ALLOC_HOOK_DECLARE; - private: /// Remember how we allocate the memory in the first place so /// we can clear things up later. @@ -348,8 +346,6 @@ public: /// Dump the state of the object. virtual void dump (void) const; - ACE_ALLOC_HOOK_DECLARE; - private: /// ALLOCATOR instance, which is owned by the adapter. ALLOCATOR allocator_; @@ -677,6 +673,7 @@ private: * specialization to create a version that matches the lock strategy's ctor * signature. See ACE_Process_Semaphore and ACE_Thread_Semaphore for * examples. + * */ /*****************************************************************************/ diff --git a/dep/acelite/ace/Malloc_T.inl b/dep/acelite/ace/Malloc_T.inl index 42321a18a..af4c491f7 100644 --- a/dep/acelite/ace/Malloc_T.inl +++ b/dep/acelite/ace/Malloc_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Malloc_T.inl 92069 2010-09-28 11:38:59Z johnnyw $ + #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -24,8 +27,6 @@ ACE_Cached_Mem_Pool_Node::set_next (ACE_Cached_Mem_Pool_Node *ptr) this->next_ = ptr; } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Cached_Mem_Pool_Node) - template ACE_INLINE size_t ACE_Cached_Allocator::pool_depth (void) { @@ -66,11 +67,7 @@ ACE_Malloc_T::release (int close) this->memory_pool_.release (0); if (retv == 0) - { - ace_mon.release (); - this->remove (); - } - + this->remove (); return retv; } return -1; diff --git a/dep/acelite/ace/Managed_Object.cpp b/dep/acelite/ace/Managed_Object.cpp index 3935cf96f..1e7e9eeb2 100644 --- a/dep/acelite/ace/Managed_Object.cpp +++ b/dep/acelite/ace/Managed_Object.cpp @@ -1,3 +1,5 @@ +// $Id: Managed_Object.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_MANAGED_OBJECT_CPP #define ACE_MANAGED_OBJECT_CPP @@ -11,10 +13,6 @@ #include "ace/Managed_Object.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Managed_Object.h b/dep/acelite/ace/Managed_Object.h index 48292bb55..d29dc1a54 100644 --- a/dep/acelite/ace/Managed_Object.h +++ b/dep/acelite/ace/Managed_Object.h @@ -4,6 +4,8 @@ /** * @file Managed_Object.h * + * $Id: Managed_Object.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author David L. Levine */ //============================================================================= diff --git a/dep/acelite/ace/Managed_Object.inl b/dep/acelite/ace/Managed_Object.inl index 4747e8faa..2e77a1c4e 100644 --- a/dep/acelite/ace/Managed_Object.inl +++ b/dep/acelite/ace/Managed_Object.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Managed_Object.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Manual_Event.cpp b/dep/acelite/ace/Manual_Event.cpp index d0504f84e..fc1c94a97 100644 --- a/dep/acelite/ace/Manual_Event.cpp +++ b/dep/acelite/ace/Manual_Event.cpp @@ -1,17 +1,13 @@ +// $Id: Manual_Event.cpp 96220 2012-11-06 10:03:41Z mcorino $ + #include "ace/Manual_Event.h" #if !defined (__ACE_INLINE__) #include "ace/Manual_Event.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Manual_Event_T) - template ACE_Manual_Event_T::ACE_Manual_Event_T ( int initial_state, diff --git a/dep/acelite/ace/Manual_Event.h b/dep/acelite/ace/Manual_Event.h index 5287eec3e..43aa5e493 100644 --- a/dep/acelite/ace/Manual_Event.h +++ b/dep/acelite/ace/Manual_Event.h @@ -4,9 +4,11 @@ /** * @file Manual_Event.h * + * $Id: Manual_Event.h 96220 2012-11-06 10:03:41Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Manual_Event.inl b/dep/acelite/ace/Manual_Event.inl index d72fdfc85..7a9cedd5c 100644 --- a/dep/acelite/ace/Manual_Event.inl +++ b/dep/acelite/ace/Manual_Event.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Manual_Event.inl 96220 2012-11-06 10:03:41Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Map_Manager.cpp b/dep/acelite/ace/Map_Manager.cpp index ecb34ab50..14abd0ad1 100644 --- a/dep/acelite/ace/Map_Manager.cpp +++ b/dep/acelite/ace/Map_Manager.cpp @@ -1,3 +1,5 @@ +// $Id: Map_Manager.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_MAP_MANAGER_CPP #define ACE_MAP_MANAGER_CPP @@ -15,13 +17,13 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Map_Entry) -ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Manager) -ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Const_Iterator_Base) -ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Iterator_Base) -ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Const_Iterator) -ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Iterator) -ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Reverse_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Map_Entry) +ACE_ALLOC_HOOK_DEFINE(ACE_Map_Manager) +ACE_ALLOC_HOOK_DEFINE(ACE_Map_Const_Iterator_Base) +ACE_ALLOC_HOOK_DEFINE(ACE_Map_Iterator_Base) +ACE_ALLOC_HOOK_DEFINE(ACE_Map_Const_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Map_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Map_Reverse_Iterator) template int ACE_Map_Manager::open (size_t size, diff --git a/dep/acelite/ace/Map_Manager.h b/dep/acelite/ace/Map_Manager.h index 987e3267c..fcdee28fb 100644 --- a/dep/acelite/ace/Map_Manager.h +++ b/dep/acelite/ace/Map_Manager.h @@ -4,7 +4,9 @@ /** * @file Map_Manager.h * - * @author Douglas C. Schmidt + * $Id: Map_Manager.h 97505 2014-01-06 15:38:30Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -451,7 +453,7 @@ class ACE_Map_Iterator_Base { public: // = Initialization method. - /// Constructor. If head != 0, the iterator constructed is positioned + /// Contructor. If head != 0, the iterator constructed is positioned /// at the head of the map, it is positioned at the end otherwise. ACE_Map_Iterator_Base (ACE_Map_Manager &mm); @@ -510,7 +512,7 @@ class ACE_Map_Const_Iterator_Base { public: // = Initialization method. - /// Constructor. If head != 0, the iterator constructed is positioned + /// Contructor. If head != 0, the iterator constructed is positioned /// at the head of the map, it is positioned at the end otherwise. ACE_Map_Const_Iterator_Base (const ACE_Map_Manager &mm); diff --git a/dep/acelite/ace/Map_Manager.inl b/dep/acelite/ace/Map_Manager.inl index 3c132b4f9..7c45d5d8c 100644 --- a/dep/acelite/ace/Map_Manager.inl +++ b/dep/acelite/ace/Map_Manager.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Map_Manager.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Guard_T.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/Map_T.cpp b/dep/acelite/ace/Map_T.cpp index f67f07ef8..ff22dfa74 100644 --- a/dep/acelite/ace/Map_T.cpp +++ b/dep/acelite/ace/Map_T.cpp @@ -1,3 +1,5 @@ +// $Id: Map_T.cpp 92097 2010-09-30 05:41:49Z msmit $ + #ifndef ACE_MAP_T_CPP #define ACE_MAP_T_CPP diff --git a/dep/acelite/ace/Map_T.h b/dep/acelite/ace/Map_T.h index 71af05dd9..5eeecc007 100644 --- a/dep/acelite/ace/Map_T.h +++ b/dep/acelite/ace/Map_T.h @@ -4,6 +4,8 @@ /** * @file Map_T.h * + * $Id: Map_T.h 93792 2011-04-07 11:48:50Z mcorino $ + * * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Map_T.inl b/dep/acelite/ace/Map_T.inl index 1e4ae9b81..a9a0eb796 100644 --- a/dep/acelite/ace/Map_T.inl +++ b/dep/acelite/ace/Map_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Map_T.inl 92097 2010-09-30 05:41:49Z msmit $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE int diff --git a/dep/acelite/ace/Mem_Map.cpp b/dep/acelite/ace/Mem_Map.cpp index e2e04c8df..fe9b81840 100644 --- a/dep/acelite/ace/Mem_Map.cpp +++ b/dep/acelite/ace/Mem_Map.cpp @@ -1,3 +1,5 @@ +// $Id: Mem_Map.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Defines the member functions for the memory mapping facility. #include "ace/Mem_Map.h" @@ -11,9 +13,6 @@ #include "ace/OS_NS_string.h" #include "ace/Log_Category.h" #include "ace/Truncate.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Mem_Map.h b/dep/acelite/ace/Mem_Map.h index 3f4ced26b..bda59bd18 100644 --- a/dep/acelite/ace/Mem_Map.h +++ b/dep/acelite/ace/Mem_Map.h @@ -4,7 +4,9 @@ /** * @file Mem_Map.h * - * @author Douglas C. Schmidt + * $Id: Mem_Map.h 91066 2010-07-12 11:05:04Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Mem_Map.inl b/dep/acelite/ace/Mem_Map.inl index 0d9994ce8..ac659d1c9 100644 --- a/dep/acelite/ace/Mem_Map.inl +++ b/dep/acelite/ace/Mem_Map.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Mem_Map.inl 96760 2013-02-05 21:11:03Z stanleyk $ + #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_sys_mman.h" #include "ace/OS_NS_sys_stat.h" diff --git a/dep/acelite/ace/Memory_Pool.h b/dep/acelite/ace/Memory_Pool.h index 88ef23517..a36e74334 100644 --- a/dep/acelite/ace/Memory_Pool.h +++ b/dep/acelite/ace/Memory_Pool.h @@ -4,7 +4,9 @@ /** * @file Memory_Pool.h * - * @author Dougls C. Schmidt + * $Id: Memory_Pool.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Dougls C. Schmidt * @author Prashant Jain */ //============================================================================= diff --git a/dep/acelite/ace/Message_Block.cpp b/dep/acelite/ace/Message_Block.cpp index fca5f105a..2f564ad67 100644 --- a/dep/acelite/ace/Message_Block.cpp +++ b/dep/acelite/ace/Message_Block.cpp @@ -1,3 +1,4 @@ +// $Id: Message_Block.cpp 96985 2013-04-11 15:50:32Z huangh $ #include "ace/Message_Block.h" #if !defined (__ACE_INLINE__) @@ -845,8 +846,9 @@ ACE_Data_Block::release (ACE_Lock *lock) // since otherwise we'd be trying to "release" through a deleted // pointer! if (result == 0) - ACE_DES_FREE_THIS (allocator->free, - ACE_Data_Block); + ACE_DES_FREE (this, + allocator->free, + ACE_Data_Block); return result; } @@ -949,8 +951,9 @@ ACE_Message_Block::release_i (ACE_Lock *lock) else { ACE_Allocator *allocator = this->message_block_allocator_; - ACE_DES_FREE_THIS (allocator->free, - ACE_Message_Block); + ACE_DES_FREE (this, + allocator->free, + ACE_Message_Block); } return result; diff --git a/dep/acelite/ace/Message_Block.h b/dep/acelite/ace/Message_Block.h index 5c9389eeb..058e7fe2d 100644 --- a/dep/acelite/ace/Message_Block.h +++ b/dep/acelite/ace/Message_Block.h @@ -4,7 +4,9 @@ /** * @file Message_Block.h * - * @author Douglas C. Schmidt + * $Id: Message_Block.h 97262 2013-08-09 08:32:10Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -715,7 +717,7 @@ public: */ char *mark (void) const; - // = Message size is the total amount of space allocated. + // = Message size is the total amount of space allotred. /// Get the total amount of allotted space in the message. The amount of /// allotted space may be less than allocated space. diff --git a/dep/acelite/ace/Message_Block.inl b/dep/acelite/ace/Message_Block.inl index 1bc636fbd..a4c00563c 100644 --- a/dep/acelite/ace/Message_Block.inl +++ b/dep/acelite/ace/Message_Block.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Message_Block.inl 84527 2009-02-19 14:01:42Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Data_Block * diff --git a/dep/acelite/ace/Message_Block_T.cpp b/dep/acelite/ace/Message_Block_T.cpp index e4161efed..bb38ca694 100644 --- a/dep/acelite/ace/Message_Block_T.cpp +++ b/dep/acelite/ace/Message_Block_T.cpp @@ -1,3 +1,5 @@ +// $Id: Message_Block_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_MESSAGE_BLOCK_T_CPP #define ACE_MESSAGE_BLOCK_T_CPP diff --git a/dep/acelite/ace/Message_Block_T.h b/dep/acelite/ace/Message_Block_T.h index 24d601681..b57a25bdc 100644 --- a/dep/acelite/ace/Message_Block_T.h +++ b/dep/acelite/ace/Message_Block_T.h @@ -4,7 +4,9 @@ /** * @file Message_Block_T.h * - * @author Douglas C. Schmidt + * $Id: Message_Block_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/Message_Block_T.inl b/dep/acelite/ace/Message_Block_T.inl index cdc1b7387..58c89c641 100644 --- a/dep/acelite/ace/Message_Block_T.inl +++ b/dep/acelite/ace/Message_Block_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Message_Block_T.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE diff --git a/dep/acelite/ace/Message_Queue.cpp b/dep/acelite/ace/Message_Queue.cpp index dc3595325..7b32a48b1 100644 --- a/dep/acelite/ace/Message_Queue.cpp +++ b/dep/acelite/ace/Message_Queue.cpp @@ -1,3 +1,5 @@ +// $Id: Message_Queue.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Message_Queue.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/Message_Queue.h b/dep/acelite/ace/Message_Queue.h index a88763997..a4448a24b 100644 --- a/dep/acelite/ace/Message_Queue.h +++ b/dep/acelite/ace/Message_Queue.h @@ -4,7 +4,9 @@ /** * @file Message_Queue.h * - * @author Douglas C. Schmidt + * $Id: Message_Queue.h 97201 2013-06-18 07:17:34Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -199,6 +201,9 @@ public: /// Dump the state of an object. virtual void dump (void) const = 0; + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + private: // = Disallow copying and assignment. ACE_Message_Queue_Base (const ACE_Message_Queue_Base &); diff --git a/dep/acelite/ace/Message_Queue.inl b/dep/acelite/ace/Message_Queue.inl index 31f420e4c..4dab25222 100644 --- a/dep/acelite/ace/Message_Queue.inl +++ b/dep/acelite/ace/Message_Queue.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Message_Queue.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Message_Queue_NT.cpp b/dep/acelite/ace/Message_Queue_NT.cpp index 8107c6c7c..870175a9f 100644 --- a/dep/acelite/ace/Message_Queue_NT.cpp +++ b/dep/acelite/ace/Message_Queue_NT.cpp @@ -1,3 +1,5 @@ +// $Id: Message_Queue_NT.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Message_Queue.h" #include "ace/Message_Queue_NT.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/Message_Queue_NT.h b/dep/acelite/ace/Message_Queue_NT.h index 5ac769e73..e959e57cf 100644 --- a/dep/acelite/ace/Message_Queue_NT.h +++ b/dep/acelite/ace/Message_Queue_NT.h @@ -4,7 +4,9 @@ /** * @file Message_Queue_NT.h * - * @author Douglas C. Schmidt + * $Id: Message_Queue_NT.h 82723 2008-09-16 09:35:44Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Message_Queue_NT.inl b/dep/acelite/ace/Message_Queue_NT.inl index 7c1b28515..4fc18fbbd 100644 --- a/dep/acelite/ace/Message_Queue_NT.inl +++ b/dep/acelite/ace/Message_Queue_NT.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Message_Queue_NT.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) # include "ace/Guard_T.h" #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ diff --git a/dep/acelite/ace/Message_Queue_T.cpp b/dep/acelite/ace/Message_Queue_T.cpp index c223563eb..0e4dd8e36 100644 --- a/dep/acelite/ace/Message_Queue_T.cpp +++ b/dep/acelite/ace/Message_Queue_T.cpp @@ -1,3 +1,5 @@ +// $Id: Message_Queue_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_MESSAGE_QUEUE_T_CPP #define ACE_MESSAGE_QUEUE_T_CPP @@ -28,10 +30,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Message_Queue) -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Dynamic_Message_Queue) -ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex) -ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex_N) +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue) +ACE_ALLOC_HOOK_DEFINE(ACE_Dynamic_Message_Queue) +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex) +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_N) template void ACE_Message_Queue_Ex::dump (void) const @@ -381,7 +383,7 @@ ACE_Message_Queue_Ex_Iterator::dum this->iter_.dump (); } -ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Iterator) template ACE_Message_Queue_Ex_Reverse_Iterator:: @@ -422,7 +424,7 @@ ACE_Message_Queue_Ex_Reverse_Iteratoriter_.dump (); } -ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex_Reverse_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Reverse_Iterator) template ACE_Message_Queue_Ex_N::ACE_Message_Queue_Ex_N @@ -530,7 +532,7 @@ ACE_Message_Queue_Ex_N::wrap_with_ return mb_head; } -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Message_Queue_Reverse_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Reverse_Iterator) template int ACE_Message_Queue_Ex::dequeue (ACE_MESSAGE_TYPE *&first_item, @@ -739,7 +741,7 @@ ACE_Message_Queue_Iterator::dump (void) const #endif /* ACE_HAS_DUMP */ } -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Message_Queue_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Iterator) template ACE_Message_Queue_Reverse_Iterator::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue &q) @@ -2715,7 +2717,7 @@ ACE_Dynamic_Message_Queue::refresh_pending_queue (co (int) current_status), -1); } - /* FALLTHROUGH */ + /* FALLTHRU */ } else { diff --git a/dep/acelite/ace/Message_Queue_T.h b/dep/acelite/ace/Message_Queue_T.h index b701abb3c..52024907a 100644 --- a/dep/acelite/ace/Message_Queue_T.h +++ b/dep/acelite/ace/Message_Queue_T.h @@ -4,7 +4,9 @@ /** * @file Message_Queue_T.h * - * @author Douglas C. Schmidt + * $Id: Message_Queue_T.h 96070 2012-08-17 09:07:16Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Message_Queue_Vx.cpp b/dep/acelite/ace/Message_Queue_Vx.cpp index 15e6d1403..51d6f292f 100644 --- a/dep/acelite/ace/Message_Queue_Vx.cpp +++ b/dep/acelite/ace/Message_Queue_Vx.cpp @@ -1,3 +1,5 @@ +// $Id: Message_Queue_Vx.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Message_Queue.h" #include "ace/Message_Queue_Vx.h" #include "ace/Log_Category.h" @@ -14,8 +16,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // class ACE_Message_Queue_Vx // //////////////////////////////// -ACE_ALLOC_HOOK_DEFINE (ACE_Message_Queue_Vx); - void ACE_Message_Queue_Vx::dump (void) const { @@ -342,6 +342,15 @@ ACE_Message_Queue_Vx::wait_not_empty_cond (ACE_Time_Value *) return 0; } +#if ! defined (ACE_NEEDS_FUNC_DEFINITIONS) +int +ACE_Message_Queue_Vx::peek_dequeue_head (ACE_Message_Block *&, + ACE_Time_Value *) +{ + ACE_NOTSUP_RETURN (-1); +} +#endif /* ! ACE_NEEDS_FUNC_DEFINITIONS */ + #endif /* ACE_VXWORKS */ ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Message_Queue_Vx.h b/dep/acelite/ace/Message_Queue_Vx.h index 30d1a3547..39dac1321 100644 --- a/dep/acelite/ace/Message_Queue_Vx.h +++ b/dep/acelite/ace/Message_Queue_Vx.h @@ -4,7 +4,9 @@ /** * @file Message_Queue_Vx.h * - * @author Douglas C. Schmidt + * $Id: Message_Queue_Vx.h 91743 2010-09-13 18:24:51Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -196,8 +198,9 @@ private: ACE_Message_Queue_Vx (const ACE_Message_Queue_Vx &); void operator= (const ACE_Message_Queue_Vx &); - virtual int peek_dequeue_head (ACE_Message_Block *&first_item, - ACE_Time_Value *tv = 0); + ACE_UNIMPLEMENTED_FUNC (virtual int peek_dequeue_head + (ACE_Message_Block *&first_item, + ACE_Time_Value *tv = 0)) private: /// Maximum number of messages that can be queued. diff --git a/dep/acelite/ace/Message_Queue_Vx.inl b/dep/acelite/ace/Message_Queue_Vx.inl index e54c62f6f..c509b1837 100644 --- a/dep/acelite/ace/Message_Queue_Vx.inl +++ b/dep/acelite/ace/Message_Queue_Vx.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Message_Queue_Vx.inl 96860 2013-02-25 16:55:51Z schmidt $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_VXWORKS) @@ -21,13 +24,6 @@ ACE_Message_Queue_Vx::msgq (void) ); } -ACE_INLINE int -ACE_Message_Queue_Vx::peek_dequeue_head (ACE_Message_Block *&, - ACE_Time_Value *) -{ - ACE_NOTSUP_RETURN (-1); -} - #endif /* ACE_VXWORKS */ ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Method_Request.cpp b/dep/acelite/ace/Method_Request.cpp index f48d395cb..f9927f777 100644 --- a/dep/acelite/ace/Method_Request.cpp +++ b/dep/acelite/ace/Method_Request.cpp @@ -1,3 +1,4 @@ +// $Id: Method_Request.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ #include "ace/Method_Request.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Method_Request.h b/dep/acelite/ace/Method_Request.h index 9684020c8..156f11247 100644 --- a/dep/acelite/ace/Method_Request.h +++ b/dep/acelite/ace/Method_Request.h @@ -4,8 +4,10 @@ /** * @file Method_Request.h * + * $Id: Method_Request.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Andres Kruse - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Metrics_Cache.h b/dep/acelite/ace/Metrics_Cache.h index 5bf44c47d..7e174d1e8 100644 --- a/dep/acelite/ace/Metrics_Cache.h +++ b/dep/acelite/ace/Metrics_Cache.h @@ -4,6 +4,8 @@ /** * @file Metrics_Cache.h * + * $Id: Metrics_Cache.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Chris Gill */ //============================================================================= diff --git a/dep/acelite/ace/Metrics_Cache_T.cpp b/dep/acelite/ace/Metrics_Cache_T.cpp index b17c85c13..a1bca24d7 100644 --- a/dep/acelite/ace/Metrics_Cache_T.cpp +++ b/dep/acelite/ace/Metrics_Cache_T.cpp @@ -1,3 +1,5 @@ +// $Id: Metrics_Cache_T.cpp 92090 2010-09-29 14:10:45Z johnnyw $ + #ifndef ACE_METRICS_CACHE_CPP #define ACE_METRICS_CACHE_CPP diff --git a/dep/acelite/ace/Metrics_Cache_T.h b/dep/acelite/ace/Metrics_Cache_T.h index 037ae3bee..05aac1a86 100644 --- a/dep/acelite/ace/Metrics_Cache_T.h +++ b/dep/acelite/ace/Metrics_Cache_T.h @@ -4,6 +4,8 @@ /** * @file Metrics_Cache_T.h * + * $Id: Metrics_Cache_T.h 95839 2012-06-07 10:13:33Z johnnyw $ + * * @author Chris Gill */ //============================================================================= diff --git a/dep/acelite/ace/Metrics_Cache_T.inl b/dep/acelite/ace/Metrics_Cache_T.inl index 5b2e1a771..d96df13f9 100644 --- a/dep/acelite/ace/Metrics_Cache_T.inl +++ b/dep/acelite/ace/Metrics_Cache_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Metrics_Cache_T.inl 92090 2010-09-29 14:10:45Z johnnyw $ + #ifndef ACE_METRICS_CACHE_T_INL #define ACE_METRICS_CACHE_T_INL diff --git a/dep/acelite/ace/Min_Max.h b/dep/acelite/ace/Min_Max.h index be7dc1815..373862973 100644 --- a/dep/acelite/ace/Min_Max.h +++ b/dep/acelite/ace/Min_Max.h @@ -4,8 +4,11 @@ /** * @file Min_Max.h * + * $Id: Min_Max.h 80826 2008-03-04 14:51:23Z wotte $ + * * Define an appropriate set of min()/max() functions using templates. * + * * @author Derek Dominish */ //============================================================================= diff --git a/dep/acelite/ace/Module.cpp b/dep/acelite/ace/Module.cpp index 176023860..e1907a5cd 100644 --- a/dep/acelite/ace/Module.cpp +++ b/dep/acelite/ace/Module.cpp @@ -1,3 +1,5 @@ +// $Id: Module.cpp 97548 2014-01-24 10:04:58Z johnnyw $ + #ifndef ACE_MODULE_CPP #define ACE_MODULE_CPP @@ -13,13 +15,9 @@ #include "ace/Module.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Module) +ACE_ALLOC_HOOK_DEFINE(ACE_Module) template void ACE_Module::dump (void) const diff --git a/dep/acelite/ace/Module.h b/dep/acelite/ace/Module.h index f44727d06..b015ec3e4 100644 --- a/dep/acelite/ace/Module.h +++ b/dep/acelite/ace/Module.h @@ -4,7 +4,9 @@ /** * @file Module.h * - * @author Douglas C. Schmidt + * $Id: Module.h 96061 2012-08-16 09:36:07Z mcorino $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Module.inl b/dep/acelite/ace/Module.inl index 43f9dba76..3081bed39 100644 --- a/dep/acelite/ace/Module.inl +++ b/dep/acelite/ace/Module.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Module.inl 96061 2012-08-16 09:36:07Z mcorino $ + #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Monitor_Admin.cpp b/dep/acelite/ace/Monitor_Admin.cpp index 78e82e75d..37693b516 100644 --- a/dep/acelite/ace/Monitor_Admin.cpp +++ b/dep/acelite/ace/Monitor_Admin.cpp @@ -1,3 +1,5 @@ +// $Id: Monitor_Admin.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Monitor_Admin.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) diff --git a/dep/acelite/ace/Monitor_Admin.h b/dep/acelite/ace/Monitor_Admin.h index c506c049e..739722f34 100644 --- a/dep/acelite/ace/Monitor_Admin.h +++ b/dep/acelite/ace/Monitor_Admin.h @@ -4,6 +4,8 @@ /** * @file Monitor_Admin.h * + * $Id: Monitor_Admin.h 85297 2009-05-07 01:40:41Z parsons $ + * * @author Jeff Parsons */ //============================================================================= diff --git a/dep/acelite/ace/Monitor_Admin_Manager.cpp b/dep/acelite/ace/Monitor_Admin_Manager.cpp index b4a363f1d..aed71e54a 100644 --- a/dep/acelite/ace/Monitor_Admin_Manager.cpp +++ b/dep/acelite/ace/Monitor_Admin_Manager.cpp @@ -1,3 +1,5 @@ +// $Id: Monitor_Admin_Manager.cpp 81691 2008-05-14 11:09:21Z johnnyw $ + #include "ace/Monitor_Admin_Manager.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) diff --git a/dep/acelite/ace/Monitor_Admin_Manager.h b/dep/acelite/ace/Monitor_Admin_Manager.h index 5b4f04c23..72977383f 100644 --- a/dep/acelite/ace/Monitor_Admin_Manager.h +++ b/dep/acelite/ace/Monitor_Admin_Manager.h @@ -4,6 +4,8 @@ /** * @file Monitor_Admin_Manager.h * + * $Id: Monitor_Admin_Manager.h 81691 2008-05-14 11:09:21Z johnnyw $ + * * @author Jeff Parsons */ //============================================================================= diff --git a/dep/acelite/ace/Monitor_Base.cpp b/dep/acelite/ace/Monitor_Base.cpp index c152ece18..e1c0a3f27 100644 --- a/dep/acelite/ace/Monitor_Base.cpp +++ b/dep/acelite/ace/Monitor_Base.cpp @@ -1,8 +1,9 @@ +// $Id: Monitor_Base.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Monitor_Base.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) -#include "ace/ACE.h" #include "ace/Monitor_Admin_Manager.h" #include "ace/Monitor_Control_Action.h" #include "ace/Monitor_Point_Registry.h" @@ -36,11 +37,7 @@ namespace ACE { for (size_t i = 0UL; i < this->data_.index_; ++i) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->data_.list_[i]); -#else delete [] this->data_.list_[i]; -#endif /* ACE_HAS_ALLOC_HOOKS */ } } } @@ -402,3 +399,4 @@ namespace ACE ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */ + diff --git a/dep/acelite/ace/Monitor_Base.h b/dep/acelite/ace/Monitor_Base.h index 769418e25..2557e6ea7 100644 --- a/dep/acelite/ace/Monitor_Base.h +++ b/dep/acelite/ace/Monitor_Base.h @@ -4,6 +4,8 @@ /** * @file Monitor_Base.h * + * $Id: Monitor_Base.h 82333 2008-07-16 01:01:32Z johnnyw $ + * * @author Jeff Parsons */ //============================================================================= diff --git a/dep/acelite/ace/Monitor_Base.inl b/dep/acelite/ace/Monitor_Base.inl index 53248c3db..71603dbbe 100644 --- a/dep/acelite/ace/Monitor_Base.inl +++ b/dep/acelite/ace/Monitor_Base.inl @@ -1,3 +1,5 @@ +// $Id: Monitor_Base.inl 82328 2008-07-15 17:20:17Z parsons $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE diff --git a/dep/acelite/ace/Monitor_Control_Action.cpp b/dep/acelite/ace/Monitor_Control_Action.cpp index 63416dde1..5ab52b369 100644 --- a/dep/acelite/ace/Monitor_Control_Action.cpp +++ b/dep/acelite/ace/Monitor_Control_Action.cpp @@ -1,3 +1,5 @@ +// $Id: Monitor_Control_Action.cpp 81691 2008-05-14 11:09:21Z johnnyw $ + #include "ace/Monitor_Control_Action.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) diff --git a/dep/acelite/ace/Monitor_Control_Action.h b/dep/acelite/ace/Monitor_Control_Action.h index f25e57bf3..7831aabd4 100644 --- a/dep/acelite/ace/Monitor_Control_Action.h +++ b/dep/acelite/ace/Monitor_Control_Action.h @@ -4,6 +4,8 @@ /** * @file Monitor_Control_Action.h * + * $Id: Monitor_Control_Action.h 81691 2008-05-14 11:09:21Z johnnyw $ + * * @author Jeff Parsons */ //============================================================================= diff --git a/dep/acelite/ace/Monitor_Control_Types.cpp b/dep/acelite/ace/Monitor_Control_Types.cpp index 786ca4c8a..f60d9117c 100644 --- a/dep/acelite/ace/Monitor_Control_Types.cpp +++ b/dep/acelite/ace/Monitor_Control_Types.cpp @@ -1,3 +1,5 @@ +// $Id: Monitor_Control_Types.cpp 84834 2009-03-16 12:28:51Z johnnyw $ + #include "ace/Monitor_Control_Types.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) diff --git a/dep/acelite/ace/Monitor_Control_Types.h b/dep/acelite/ace/Monitor_Control_Types.h index 0eaba0e5a..5e92e524f 100644 --- a/dep/acelite/ace/Monitor_Control_Types.h +++ b/dep/acelite/ace/Monitor_Control_Types.h @@ -4,6 +4,8 @@ /** * @file Monitor_Control_Types.h * + * $Id: Monitor_Control_Types.h 83306 2008-10-17 12:19:53Z johnnyw $ + * * @author Jeff Parsons */ //============================================================================= @@ -100,12 +102,7 @@ namespace ACE /** * @brief Holder for a monitor point's constraints. */ -#if defined (ACE_HAS_ALLOC_HOOKS) - typedef ACE_Array_Map, ACE_Allocator_Std_Adapter > > ConstraintList; -#else typedef ACE_Array_Map ConstraintList; -#endif /* ACE_HAS_ALLOC_HOOKS */ - }; } } diff --git a/dep/acelite/ace/Monitor_Point_Registry.cpp b/dep/acelite/ace/Monitor_Point_Registry.cpp index d6c558a24..3f33e834b 100644 --- a/dep/acelite/ace/Monitor_Point_Registry.cpp +++ b/dep/acelite/ace/Monitor_Point_Registry.cpp @@ -1,9 +1,10 @@ +// $Id: Monitor_Point_Registry.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Monitor_Point_Registry.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) #include "ace/Monitor_Base.h" -#include "ace/Guard_T.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Monitor_Point_Registry.h b/dep/acelite/ace/Monitor_Point_Registry.h index 42245249d..82dba6caf 100644 --- a/dep/acelite/ace/Monitor_Point_Registry.h +++ b/dep/acelite/ace/Monitor_Point_Registry.h @@ -4,6 +4,8 @@ /** * @file Monitor_Point_Registry.h * + * $Id: Monitor_Point_Registry.h 81691 2008-05-14 11:09:21Z johnnyw $ + * * @author Jeff Parsons */ //============================================================================= diff --git a/dep/acelite/ace/Monitor_Size.cpp b/dep/acelite/ace/Monitor_Size.cpp index 545a09690..f968f9b9b 100644 --- a/dep/acelite/ace/Monitor_Size.cpp +++ b/dep/acelite/ace/Monitor_Size.cpp @@ -1,3 +1,5 @@ +// $Id: Monitor_Size.cpp 82328 2008-07-15 17:20:17Z parsons $ + #include "ace/Monitor_Size.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) diff --git a/dep/acelite/ace/Monitor_Size.h b/dep/acelite/ace/Monitor_Size.h index aba459556..42ec31312 100644 --- a/dep/acelite/ace/Monitor_Size.h +++ b/dep/acelite/ace/Monitor_Size.h @@ -4,6 +4,8 @@ /** * @file Monitor_Size.h * + * $Id: Monitor_Size.h 81691 2008-05-14 11:09:21Z johnnyw $ + * * @author Jeff Parsons */ //============================================================================= diff --git a/dep/acelite/ace/Monotonic_Time_Policy.cpp b/dep/acelite/ace/Monotonic_Time_Policy.cpp index 7b66b7bb0..3965c1bee 100644 --- a/dep/acelite/ace/Monotonic_Time_Policy.cpp +++ b/dep/acelite/ace/Monotonic_Time_Policy.cpp @@ -1,3 +1,5 @@ +// $Id: Monotonic_Time_Policy.cpp 96061 2012-08-16 09:36:07Z mcorino $ + #include "ace/Monotonic_Time_Policy.h" #if !defined(__ACE_INLINE__) diff --git a/dep/acelite/ace/Monotonic_Time_Policy.h b/dep/acelite/ace/Monotonic_Time_Policy.h index 77e822e6a..a9615c98e 100644 --- a/dep/acelite/ace/Monotonic_Time_Policy.h +++ b/dep/acelite/ace/Monotonic_Time_Policy.h @@ -4,6 +4,8 @@ /** * @file Monotonic_Time_Policy.h * + * $Id: Monotonic_Time_Policy.h 96061 2012-08-16 09:36:07Z mcorino $ + * * @author Martin Corino */ #include /**/ "ace/pre.h" diff --git a/dep/acelite/ace/Monotonic_Time_Policy.inl b/dep/acelite/ace/Monotonic_Time_Policy.inl index bef06a049..e6f0b3df4 100644 --- a/dep/acelite/ace/Monotonic_Time_Policy.inl +++ b/dep/acelite/ace/Monotonic_Time_Policy.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Monotonic_Time_Policy.inl 96095 2012-08-23 06:36:25Z johnnyw $ + #include "ace/OS_NS_sys_time.h" #include "ace/High_Res_Timer.h" diff --git a/dep/acelite/ace/Msg_WFMO_Reactor.cpp b/dep/acelite/ace/Msg_WFMO_Reactor.cpp index 7852dcead..dafda96f3 100644 --- a/dep/acelite/ace/Msg_WFMO_Reactor.cpp +++ b/dep/acelite/ace/Msg_WFMO_Reactor.cpp @@ -1,3 +1,5 @@ +// $Id: Msg_WFMO_Reactor.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Msg_WFMO_Reactor.h" diff --git a/dep/acelite/ace/Msg_WFMO_Reactor.h b/dep/acelite/ace/Msg_WFMO_Reactor.h index 981cdf5be..3c1eadd5b 100644 --- a/dep/acelite/ace/Msg_WFMO_Reactor.h +++ b/dep/acelite/ace/Msg_WFMO_Reactor.h @@ -4,6 +4,8 @@ /** * @file Msg_WFMO_Reactor.h * + * $Id: Msg_WFMO_Reactor.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Beskrovny Evgeny * @author Irfan Pyarali */ diff --git a/dep/acelite/ace/Msg_WFMO_Reactor.inl b/dep/acelite/ace/Msg_WFMO_Reactor.inl index ee73e6118..f28bb4321 100644 --- a/dep/acelite/ace/Msg_WFMO_Reactor.inl +++ b/dep/acelite/ace/Msg_WFMO_Reactor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Msg_WFMO_Reactor.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_WIN32) && !defined (ACE_LACKS_MSG_WFMO) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Multihomed_INET_Addr.cpp b/dep/acelite/ace/Multihomed_INET_Addr.cpp index 1acc40c10..629351d37 100644 --- a/dep/acelite/ace/Multihomed_INET_Addr.cpp +++ b/dep/acelite/ace/Multihomed_INET_Addr.cpp @@ -1,3 +1,5 @@ +// $Id: Multihomed_INET_Addr.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Extends ACE_INET_Addr with support for multi-homed addresses. #include "ace/Multihomed_INET_Addr.h" @@ -243,40 +245,21 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs, size_t size) const { - if (size == 0) - return; - // Copy primary address(es) to the first slot(s) of the user-supplied array - ACE_INET_Addr me (*this); - size_t i = 0; - for (i = 0; i < size; ++i) - { - sockaddr_in *in4 = reinterpret_cast (me.get_addr ()); - if (in4->sin_family == AF_INET) - { - addrs[i] = *in4; - ++i; - } - if (!me.next ()) - break; - } + // Copy primary address to the first slot of the user-supplied array + if (size > 0) { + addrs[0] = *reinterpret_cast (this->get_addr ()); + } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - for (size_t j = 0; j < this->secondaries_.size (); ++j) - { - ACE_INET_Addr copy (this->secondaries_[j]); - for (; i < size; ++i) - { - sockaddr_in *in4 = reinterpret_cast (copy.get_addr ()); - if (in4->sin_family == AF_INET) - { - addrs[i] = *in4; - ++i; - } - if (!copy.next ()) - break; - } - } + + size_t top = size - 1 < this->secondaries_.size() ? + size - 1 : this->secondaries_.size(); + + for (size_t i = 0; i < top; ++i) { + addrs[i+1] = + *reinterpret_cast (this->secondaries_[i].get_addr()); + } } #if defined (ACE_HAS_IPV6) @@ -284,40 +267,22 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs, size_t size) const { - if (size == 0) - return; - // Copy primary address(es) to the first slot(s) of the user-supplied array - ACE_INET_Addr me (*this); - size_t i = 0; - for (i = 0; i < size; ++i) + // Copy primary address to the first slot of the user-supplied array + if (size > 0) { - sockaddr_in6 *in6 = reinterpret_cast (me.get_addr ()); - if (in6->sin6_family == AF_INET6) - { - addrs[i] = *in6; - ++i; - } - if (!me.next ()) - break; + addrs[0] = *reinterpret_cast (this->get_addr ()); } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - for (size_t j = 0; j < this->secondaries_.size (); ++j) + size_t top = + size - 1 < this->secondaries_.size() ? + size - 1 : this->secondaries_.size(); + + for (size_t i = 0; i < top; ++i) { - ACE_INET_Addr copy (this->secondaries_[j]); - for (; i < size; ++i) - { - sockaddr_in6 *in6 = - reinterpret_cast (copy.get_addr ()); - if (in6->sin6_family == AF_INET6) - { - addrs[i] = *in6; - ++i; - } - if (!copy.next ()) - break; - } + addrs[i+1] = + *reinterpret_cast (this->secondaries_[i].get_addr()); } } #endif /* ACE_HAS_IPV6 */ diff --git a/dep/acelite/ace/Multihomed_INET_Addr.h b/dep/acelite/ace/Multihomed_INET_Addr.h index fd5a1b226..6be07a910 100644 --- a/dep/acelite/ace/Multihomed_INET_Addr.h +++ b/dep/acelite/ace/Multihomed_INET_Addr.h @@ -4,6 +4,8 @@ /** * @file Multihomed_INET_Addr.h * + * $Id: Multihomed_INET_Addr.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * @author Edward R. Mulholland */ //============================================================================= @@ -180,9 +182,6 @@ public: void get_addresses(sockaddr_in6 *addrs, size_t size) const; #endif /* ACE_HAS_IPV6 */ - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: ACE_Array secondaries_; }; diff --git a/dep/acelite/ace/Multihomed_INET_Addr.inl b/dep/acelite/ace/Multihomed_INET_Addr.inl index 0dbad8375..61c856059 100644 --- a/dep/acelite/ace/Multihomed_INET_Addr.inl +++ b/dep/acelite/ace/Multihomed_INET_Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Multihomed_INET_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Accessor implementations diff --git a/dep/acelite/ace/Mutex.cpp b/dep/acelite/ace/Mutex.cpp index c5e982a5d..14d2661ef 100644 --- a/dep/acelite/ace/Mutex.cpp +++ b/dep/acelite/ace/Mutex.cpp @@ -1,3 +1,5 @@ +// $Id: Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Mutex.h" #if !defined (__ACE_INLINE__) @@ -7,13 +9,10 @@ #include "ace/Log_Category.h" #include "ace/OS_NS_string.h" #include "ace/os_include/sys/os_mman.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE (ACE_Mutex) +ACE_ALLOC_HOOK_DEFINE(ACE_Mutex) void ACE_Mutex::dump (void) const @@ -22,39 +21,28 @@ ACE_Mutex::dump (void) const // ACE_TRACE ("ACE_Mutex::dump"); ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); -# ifdef ACE_MUTEX_USE_PROCESS_LOCK +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("lockname_ = %s\n"), this->lockname_)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("process_lock_ = %x\n"), this->process_lock_)); -# endif /* ACE_MUTEX_USE_PROCESS_LOCK */ +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ } -int -ACE_Mutex::unlink (const ACE_TCHAR *name) -{ -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_SEMA - return ACE_OS::sema_unlink (ACE_TEXT_ALWAYS_CHAR (name)); -#else - ACE_UNUSED_ARG (name); - return 0; -#endif -} - ACE_Mutex::ACE_Mutex (int type, const ACE_TCHAR *name, ACE_mutexattr_t *arg, mode_t mode) : -#ifdef ACE_MUTEX_USE_PROCESS_LOCK +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) process_lock_ (0), lockname_ (0), -#endif /* ACE_MUTEX_USE_PROCESS_LOCK */ +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ removed_ (false) { // ACE_TRACE ("ACE_Mutex::ACE_Mutex"); // These platforms need process-wide mutex to be in shared memory. -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX +#if defined(ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS) if (type == USYNC_PROCESS) { // Let's see if the shared memory entity already exists. @@ -100,47 +88,29 @@ ACE_Mutex::ACE_Mutex (int type, const ACE_TCHAR *name, name, arg) != 0) { - ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Mutex::ACE_Mutex"))); + ACELIB_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Mutex::ACE_Mutex"))); + return; } - return; } - -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - ACE_UNUSED_ARG (mode); - if (type == USYNC_PROCESS) + else { - if (name) - this->lockname_ = ACE_OS::strdup (name); - else - { - const size_t un_len = (ACE_UNIQUE_NAME_LEN + 1) * sizeof (ACE_TCHAR); - ACE_TCHAR *const un = -# ifdef ACE_HAS_ALLOC_HOOKS - (ACE_TCHAR *) ACE_Allocator::instance ()->malloc (un_len); -# else - (ACE_TCHAR *) ACE_OS::malloc (un_len); -# endif /* ACE_HAS_ALLOC_HOOKS */ - un[0] = ACE_TEXT ('/'); - ACE_OS::unique_name (this, un + 1, ACE_UNIQUE_NAME_LEN); - this->lockname_ = un; - } - - this->process_lock_ = &this->process_sema_; - if (ACE_OS::sema_init (&this->process_sema_, 1 /*mutex unlocked*/, - USYNC_PROCESS, this->lockname_) != 0) - ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Mutex::ACE_Mutex"))); - ACE_OS::sema_avoid_unlink (&this->process_sema_, true); - return; - } + // local mutex init if USYNC_PROCESS flag is not enabled. #else - ACE_UNUSED_ARG (mode); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ + ACE_UNUSED_ARG (mode); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ - if (ACE_OS::mutex_init (&this->lock_, type, name, arg) != 0) - ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Mutex::ACE_Mutex"))); + if (ACE_OS::mutex_init (&this->lock_, + type, + name, + arg) != 0) + ACELIB_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Mutex::ACE_Mutex"))); +#if defined(ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS) + } +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ } ACE_Mutex::~ACE_Mutex (void) diff --git a/dep/acelite/ace/Mutex.h b/dep/acelite/ace/Mutex.h index 159f57da0..7183a2db3 100644 --- a/dep/acelite/ace/Mutex.h +++ b/dep/acelite/ace/Mutex.h @@ -4,7 +4,9 @@ /** * @file Mutex.h * - * @author Douglas C. Schmidt + * $Id: Mutex.h 91626 2010-09-07 10:59:20Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -23,15 +25,15 @@ #include "ace/OS_NS_unistd.h" #include "ace/os_include/os_fcntl.h" -#if !defined (ACE_DEFAULT_MUTEX_A) -# define ACE_DEFAULT_MUTEX_A "ACE_MUTEX" -#endif /* ACE_DEFAULT_MUTEX_A */ +# if !defined (ACE_DEFAULT_MUTEX_A) +# define ACE_DEFAULT_MUTEX_A "ACE_MUTEX" +# endif /* ACE_DEFAULT_MUTEX_A */ -#if defined (ACE_HAS_WCHAR) -# define ACE_DEFAULT_MUTEX_W ACE_TEXT_WIDE (ACE_DEFAULT_MUTEX_A) -#endif /* ACE_HAS_WCHAR */ +# if defined (ACE_HAS_WCHAR) +# define ACE_DEFAULT_MUTEX_W ACE_TEXT_WIDE(ACE_DEFAULT_MUTEX_A) +# endif /* ACE_HAS_WCHAR */ -#define ACE_DEFAULT_MUTEX ACE_TEXT (ACE_DEFAULT_MUTEX_A) +# define ACE_DEFAULT_MUTEX ACE_TEXT (ACE_DEFAULT_MUTEX_A) ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -144,10 +146,6 @@ public: const ACE_mutex_t &lock (void) const; ACE_mutex_t &lock (void); - /// If a file was created as the underlying storage for the mutex, - /// remove it from the filesystem (for process-shared mutexes). - static int unlink (const ACE_TCHAR *name); - /// Dump the state of an object. void dump (void) const; @@ -156,20 +154,9 @@ public: // = This should be protected but some C++ compilers complain... public: -#if defined ACE_HAS_PTHREADS && defined ACE_LACKS_MUTEXATTR_PSHARED -# define ACE_MUTEX_USE_PROCESS_LOCK -# define ACE_MUTEX_PROCESS_LOCK_IS_SEMA - ACE_sema_t process_sema_; - typedef ACE_sema_t Process_Lock; -#elif defined ACE_HAS_PTHREADS || defined ACE_HAS_STHREADS -# define ACE_MUTEX_USE_PROCESS_LOCK -# define ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - typedef ACE_mutex_t Process_Lock; -#endif - -#ifdef ACE_MUTEX_USE_PROCESS_LOCK +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) /// This lock resides in shared memory. - Process_Lock *process_lock_; + ACE_mutex_t *process_lock_; /** * Remember the name of the mutex if we created it so we can unlink @@ -177,7 +164,7 @@ public: * can destroy it). */ const ACE_TCHAR *lockname_; -#endif /* ACE_MUTEX_USE_PROCESS_LOCK */ +#endif /* ACE_HAS_PTHREADS */ /// Mutex type supported by the OS. ACE_mutex_t lock_; @@ -191,7 +178,7 @@ public: private: // Prevent assignment and initialization. - ACE_Mutex &operator= (const ACE_Mutex &); + void operator= (const ACE_Mutex &); ACE_Mutex (const ACE_Mutex &); }; diff --git a/dep/acelite/ace/Mutex.inl b/dep/acelite/ace/Mutex.inl index 428707097..5942808bd 100644 --- a/dep/acelite/ace/Mutex.inl +++ b/dep/acelite/ace/Mutex.inl @@ -1,24 +1,20 @@ // -*- C++ -*- +// +// $Id: Mutex.inl 91626 2010-09-07 10:59:20Z johnnyw $ + #include "ace/OS_NS_sys_mman.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_Mutex::acquire_read (void) { // ACE_TRACE ("ACE_Mutex::acquire_read"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_lock (this->process_lock_); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_wait (this->process_lock_); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_lock (this->process_lock_); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return ACE_OS::mutex_lock (&this->lock_); } @@ -26,13 +22,10 @@ ACE_INLINE int ACE_Mutex::acquire_write (void) { // ACE_TRACE ("ACE_Mutex::acquire_write"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_lock (this->process_lock_); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_wait (this->process_lock_); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_lock (this->process_lock_); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return ACE_OS::mutex_lock (&this->lock_); } @@ -40,13 +33,10 @@ ACE_INLINE int ACE_Mutex::tryacquire_read (void) { // ACE_TRACE ("ACE_Mutex::tryacquire_read"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_trylock (this->process_lock_); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_trywait (this->process_lock_); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_trylock (this->process_lock_); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return ACE_OS::mutex_trylock (&this->lock_); } @@ -54,10 +44,10 @@ ACE_INLINE const ACE_mutex_t & ACE_Mutex::lock (void) const { // ACE_TRACE ("ACE_Mutex::lock"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) if (this->process_lock_) return *this->process_lock_; -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return this->lock_; } @@ -65,10 +55,10 @@ ACE_INLINE ACE_mutex_t & ACE_Mutex::lock (void) { // ACE_TRACE ("ACE_Mutex::lock"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) if (this->process_lock_) return *this->process_lock_; -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return this->lock_; } @@ -76,13 +66,10 @@ ACE_INLINE int ACE_Mutex::tryacquire_write (void) { // ACE_TRACE ("ACE_Mutex::tryacquire_write"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_trylock (this->process_lock_); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_trywait (this->process_lock_); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_trylock (this->process_lock_); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return ACE_OS::mutex_trylock (&this->lock_); } @@ -97,13 +84,10 @@ ACE_INLINE int ACE_Mutex::acquire (void) { // ACE_TRACE ("ACE_Mutex::acquire"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_lock (this->process_lock_); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_wait (this->process_lock_); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_lock (this->process_lock_); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return ACE_OS::mutex_lock (&this->lock_); } @@ -111,26 +95,20 @@ ACE_INLINE int ACE_Mutex::acquire (ACE_Time_Value &tv) { // ACE_TRACE ("ACE_Mutex::acquire"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_lock (this->process_lock_, tv); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_wait (this->process_lock_, tv); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ + #if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_lock (this->process_lock_, tv); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS*/ return ACE_OS::mutex_lock (&this->lock_, tv); } ACE_INLINE int ACE_Mutex::acquire (ACE_Time_Value *tv) { -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_lock (this->process_lock_, tv); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_wait (this->process_lock_, tv); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ + #if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_lock (this->process_lock_, tv); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS*/ return ACE_OS::mutex_lock (&this->lock_, tv); } @@ -138,13 +116,10 @@ ACE_INLINE int ACE_Mutex::tryacquire (void) { // ACE_TRACE ("ACE_Mutex::tryacquire"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_trylock (this->process_lock_); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_trywait (this->process_lock_); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_trylock (this->process_lock_); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return ACE_OS::mutex_trylock (&this->lock_); } @@ -152,13 +127,10 @@ ACE_INLINE int ACE_Mutex::release (void) { // ACE_TRACE ("ACE_Mutex::release"); -#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX - if (this->process_lock_) - return ACE_OS::mutex_unlock (this->process_lock_); -#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - if (this->process_lock_) - return ACE_OS::sema_post (this->process_lock_); -#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ +#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS) + if (this->process_lock_) + return ACE_OS::mutex_unlock (this->process_lock_); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return ACE_OS::mutex_unlock (&this->lock_); } @@ -167,7 +139,7 @@ ACE_Mutex::remove (void) { // ACE_TRACE ("ACE_Mutex::remove"); int result = 0; -#ifdef ACE_MUTEX_USE_PROCESS_LOCK +#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS) // In the case of a interprocess mutex, the owner is the first // process that created the shared memory object. In this case, the // lockname_ pointer will be non-zero (points to allocated memory @@ -181,7 +153,6 @@ ACE_Mutex::remove (void) this->removed_ = true; // Only destroy the lock if we're the ones who initialized // it. -# ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX if (!this->lockname_) ACE_OS::munmap ((void *) this->process_lock_, sizeof (ACE_mutex_t)); @@ -191,28 +162,24 @@ ACE_Mutex::remove (void) ACE_OS::munmap ((void *) this->process_lock_, sizeof (ACE_mutex_t)); ACE_OS::shm_unlink (this->lockname_); + ACE_OS::free ( + static_cast ( + const_cast (this->lockname_))); } -# elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA - result = ACE_OS::sema_destroy (this->process_lock_); -# endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */ - -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (const_cast ( - this->lockname_)); -# else - ACE_OS::free (const_cast (this->lockname_)); -# endif /* ACE_HAS_ALLOC_HOOKS */ } - return result; } -#endif /* ACE_MUTEX_USE_PROCESS_LOCK */ - - if (this->removed_ == false) - { - this->removed_ = true; - result = ACE_OS::mutex_destroy (&this->lock_); - } - + else + { +#else /* !ACE_HAS_PTHREADS && !ACE_HAS_STHREADS */ + if (this->removed_ == false) + { + this->removed_ = true; + result = ACE_OS::mutex_destroy (&this->lock_); + } +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ +#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS) + } +#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */ return result; } diff --git a/dep/acelite/ace/NT_Service.cpp b/dep/acelite/ace/NT_Service.cpp index fd88af02b..e70550b40 100644 --- a/dep/acelite/ace/NT_Service.cpp +++ b/dep/acelite/ace/NT_Service.cpp @@ -1,3 +1,5 @@ +// $Id: NT_Service.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/config-all.h" #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES) @@ -202,10 +204,7 @@ ACE_NT_Service::insert (DWORD start_type, 0, SC_MANAGER_ALL_ACCESS); if (sc_mgr == 0) - { - ACE_OS::set_errno_to_last_error(); - return -1; - } + return -1; SC_HANDLE sh = ACE_TEXT_CreateService (sc_mgr, this->name (), diff --git a/dep/acelite/ace/NT_Service.h b/dep/acelite/ace/NT_Service.h index 236a6dc5d..f602021e4 100644 --- a/dep/acelite/ace/NT_Service.h +++ b/dep/acelite/ace/NT_Service.h @@ -4,6 +4,8 @@ /** * @file NT_Service.h * + * $Id: NT_Service.h 93117 2011-01-20 12:11:28Z mcorino $ + * * @author Steve Huston */ //========================================================================== @@ -290,7 +292,7 @@ public: int continue_svc (ACE_Time_Value *wait_time = 0, DWORD *svc_state = 0); /** - * Get the current state for the service. If @a wait_hint is not 0, + * Get the current state for the service. If is not 0, * it receives the service's reported wait hint. Note that this * function returns 0 on failure (not -1 as is usual in ACE). A * zero return would (probably) only be returned if there is either @@ -328,7 +330,7 @@ protected: SC_HANDLE svc_sc_handle (void); /** - * Waits for the service to reach @a desired_state or get + * Waits for the service to reach or get * (apparently) stuck before it reaches that state. Will wait at * most @a wait_time to get to the desired state. If @a wait_time is * 0, then the function keeps waiting until the desired state is diff --git a/dep/acelite/ace/NT_Service.inl b/dep/acelite/ace/NT_Service.inl index 9808ce8f7..80c2a7a37 100644 --- a/dep/acelite/ace/NT_Service.inl +++ b/dep/acelite/ace/NT_Service.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: NT_Service.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Name_Proxy.cpp b/dep/acelite/ace/Name_Proxy.cpp index fc99cb6aa..b2f459829 100644 --- a/dep/acelite/ace/Name_Proxy.cpp +++ b/dep/acelite/ace/Name_Proxy.cpp @@ -1,3 +1,5 @@ +// $Id: Name_Proxy.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Name_Proxy.h" #include "ace/Log_Category.h" #include "ace/os_include/arpa/os_inet.h" @@ -147,9 +149,9 @@ ACE_Name_Proxy::recv_reply (ACE_Name_Request &reply) switch (n) { case -1: + // FALLTHROUGH ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("****************** recv_reply returned -1\n"))); - // FALLTHROUGH default: ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"), diff --git a/dep/acelite/ace/Name_Proxy.h b/dep/acelite/ace/Name_Proxy.h index 05254a0a3..a60a118f4 100644 --- a/dep/acelite/ace/Name_Proxy.h +++ b/dep/acelite/ace/Name_Proxy.h @@ -4,9 +4,12 @@ /** * @file Name_Proxy.h * + * $Id: Name_Proxy.h 80826 2008-03-04 14:51:23Z wotte $ + * * Proxy for dealing with remote server process managing NET_LOCAL * Name_Bindings. * + * * @author Gerhard Lenzer * @author Douglas C. Schmidt * @author Prashant Jain diff --git a/dep/acelite/ace/Name_Request_Reply.cpp b/dep/acelite/ace/Name_Request_Reply.cpp index 72cc2a2a3..e67604093 100644 --- a/dep/acelite/ace/Name_Request_Reply.cpp +++ b/dep/acelite/ace/Name_Request_Reply.cpp @@ -1,3 +1,5 @@ +// $Id: Name_Request_Reply.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Name_Request_Reply.h" #include "ace/Basic_Types.h" #include "ace/CDR_Base.h" diff --git a/dep/acelite/ace/Name_Request_Reply.h b/dep/acelite/ace/Name_Request_Reply.h index 5c91d2389..e8509f10b 100644 --- a/dep/acelite/ace/Name_Request_Reply.h +++ b/dep/acelite/ace/Name_Request_Reply.h @@ -4,6 +4,8 @@ /** * @file Name_Request_Reply.h * + * $Id: Name_Request_Reply.h 84316 2009-02-03 19:46:05Z johnnyw $ + * * Define the format used to exchange messages between the * ACE_Name Server and its clients. * diff --git a/dep/acelite/ace/Name_Space.cpp b/dep/acelite/ace/Name_Space.cpp index 403f473bd..7e8f01dec 100644 --- a/dep/acelite/ace/Name_Space.cpp +++ b/dep/acelite/ace/Name_Space.cpp @@ -1,4 +1,6 @@ // Name_Space.cpp +// $Id: Name_Space.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Name_Space.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_stdlib.h" @@ -19,11 +21,7 @@ ACE_Name_Binding::ACE_Name_Binding (void) ACE_Name_Binding::~ACE_Name_Binding (void) { ACE_TRACE ("ACE_Name_Binding::~ACE_Name_Binding"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->type_); -#else ACE_OS::free ((void *) this->type_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_Name_Binding::ACE_Name_Binding (const ACE_NS_WString &name, @@ -51,11 +49,7 @@ ACE_Name_Binding::operator = (const ACE_Name_Binding &s) if (this != &s) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->type_); -#else ACE_OS::free ((void *) this->type_); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->name_ = s.name_; this->value_ = s.value_; this->type_ = ACE_OS::strdup (s.type_); diff --git a/dep/acelite/ace/Name_Space.h b/dep/acelite/ace/Name_Space.h index 9f0deb3a3..66396644a 100644 --- a/dep/acelite/ace/Name_Space.h +++ b/dep/acelite/ace/Name_Space.h @@ -4,6 +4,8 @@ /** * @file Name_Space.h * + * $Id: Name_Space.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Prashant Jain */ //========================================================================== @@ -75,7 +77,7 @@ typedef ACE_Unbounded_Set_Iterator ACE_PWSTRING_ITERATOR; * @class ACE_Name_Space * * @brief Abstract base class that provides an abstract interface to - * the database without exposing any implementation details. + * the database without exposing any implemenation details. * * Manages a Naming Service Name Space. Provides the basic * methods -- bind, unbind, rebind, find, and listnames. diff --git a/dep/acelite/ace/Naming_Context.cpp b/dep/acelite/ace/Naming_Context.cpp index 52f70b31d..fdc88a66e 100644 --- a/dep/acelite/ace/Naming_Context.cpp +++ b/dep/acelite/ace/Naming_Context.cpp @@ -1,3 +1,5 @@ +// $Id: Naming_Context.cpp 97308 2013-09-01 00:58:08Z mesnier_p $ + #include "ace/Get_Opt.h" #include "ace/Naming_Context.h" #include "ace/Remote_Name_Space.h" @@ -37,10 +39,10 @@ ACE_Naming_Context::info (ACE_TCHAR **strp, ACE_TCHAR buf[BUFSIZ]; - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%s\t#%s\n"), - ACE_TEXT ("ACE_Naming_Context"), - ACE_TEXT ("Proxy for making calls to a Name Server")); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t#%s\n"), + ACE_TEXT ("ACE_Naming_Context"), + ACE_TEXT ("Proxy for making calls to a Name Server")); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) return -1; @@ -140,8 +142,7 @@ ACE_Naming_Context::close (void) ACE_Naming_Context::ACE_Naming_Context (void) : name_options_ (0), name_space_ (0), - netnameserver_host_ (0), - netnameserver_port_ (0) + netnameserver_host_ (0) { ACE_TRACE ("ACE_Naming_Context::ACE_Naming_Context"); @@ -431,11 +432,7 @@ ACE_Name_Options::ACE_Name_Options (void) this->namespace_dir_ = ACE_OS::strdup (ACE_DEFAULT_NAMESPACE_DIR); #else /* ACE_DEFAULT_NAMESPACE_DIR */ size_t pathsize = (MAXPATHLEN + 1) * sizeof (ACE_TCHAR); -#if defined (ACE_HAS_ALLOC_HOOKS) - this->namespace_dir_ = static_cast (ACE_Allocator::instance()->malloc (pathsize)); -#else this->namespace_dir_ = static_cast (ACE_OS::malloc (pathsize)); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (ACE::get_temp_dir (this->namespace_dir_, MAXPATHLEN) == -1) { @@ -452,21 +449,12 @@ ACE_Name_Options::~ACE_Name_Options (void) { ACE_TRACE ("ACE_Name_Options::~ACE_Name_Options"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->nameserver_host_); - ACE_Allocator::instance()->free ((void *) this->namespace_dir_ ); - ACE_Allocator::instance()->free ((void *) this->process_name_ ); - ACE_Allocator::instance()->free ((void *) this->database_ ); -#else ACE_OS::free ((void *) this->nameserver_host_); ACE_OS::free ((void *) this->namespace_dir_ ); ACE_OS::free ((void *) this->process_name_ ); ACE_OS::free ((void *) this->database_ ); -#endif /* ACE_HAS_ALLOC_HOOKS */ } -ACE_ALLOC_HOOK_DEFINE(ACE_Name_Options) - void ACE_Name_Options::nameserver_port (int port) { @@ -485,11 +473,7 @@ void ACE_Name_Options::namespace_dir (const ACE_TCHAR *dir) { ACE_TRACE ("ACE_Name_Options::namespace_dir"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->namespace_dir_ ); -#else ACE_OS::free ((void *) this->namespace_dir_ ); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->namespace_dir_ = ACE_OS::strdup (dir); } @@ -498,11 +482,7 @@ ACE_Name_Options::process_name (const ACE_TCHAR *pname) { ACE_TRACE ("ACE_Name_Options::process_name"); const ACE_TCHAR *t = ACE::basename (pname, ACE_DIRECTORY_SEPARATOR_CHAR); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->process_name_ ); -#else ACE_OS::free ((void *) this->process_name_ ); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->process_name_ = ACE_OS::strdup (t); } @@ -510,11 +490,7 @@ void ACE_Name_Options::nameserver_host (const ACE_TCHAR *host) { ACE_TRACE ("ACE_Name_Options::nameserver_host"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->nameserver_host_ ); -#else - ACE_OS::free ((void *) this->nameserver_host_ ); -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_OS::free ((void *) this->nameserver_host_); this->nameserver_host_ = ACE_OS::strdup (host); } @@ -536,11 +512,7 @@ void ACE_Name_Options::database (const ACE_TCHAR *db) { ACE_TRACE ("ACE_Name_Options::database"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) this->database_); -#else ACE_OS::free ((void *) this->database_); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->database_ = ACE_OS::strdup (db); } @@ -646,7 +618,6 @@ ACE_Name_Options::parse_args (int argc, ACE_TCHAR *argv[]) this->verbosity_ = true; break; default: -#ifndef ACE_LACKS_STDERR ACE_OS::fprintf (stderr, "%s\n" "\t[-d] (enable debugging)\n" "\t[-h nameserver host]\n" @@ -658,12 +629,13 @@ ACE_Name_Options::parse_args (int argc, ACE_TCHAR *argv[]) "\t[-v] (verbose)\n" "\t[-r] (use Win32 Registry)\n", ACE_TEXT_ALWAYS_CHAR (argv[0])); -#endif /* NOTREACHED */ break; } } +ACE_END_VERSIONED_NAMESPACE_DECL + // The following Factory is used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the Name // Server client. @@ -677,5 +649,3 @@ ACE_STATIC_SVC_DEFINE (ACE_Naming_Context, ACE_Service_Type::DELETE_OBJ, 0) ACE_STATIC_SVC_REQUIRE (ACE_Naming_Context) - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Naming_Context.h b/dep/acelite/ace/Naming_Context.h index 9d3e3f959..861f771bc 100644 --- a/dep/acelite/ace/Naming_Context.h +++ b/dep/acelite/ace/Naming_Context.h @@ -4,8 +4,10 @@ /** * @file Naming_Context.h * + * $Id: Naming_Context.h 96261 2012-11-12 19:27:25Z johnnyw $ + * * @author Gerhard Lenzer - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Prashant Jain */ //========================================================================== @@ -339,8 +341,6 @@ public: /// Return verbose status bool verbose (void); - ACE_ALLOC_HOOK_DECLARE; - private: /// Extra debugging info bool debugging_; @@ -373,14 +373,14 @@ private: ACE_Naming_Context::Context_Scope_Type context_; }; -ACE_FACTORY_DECLARE (ACE, ACE_Naming_Context) -ACE_STATIC_SVC_DECLARE_EXPORT (ACE, ACE_Naming_Context) - ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) #include "ace/Naming_Context.inl" #endif /* __ACE_INLINE__ */ +ACE_FACTORY_DECLARE (ACE, ACE_Naming_Context) +ACE_STATIC_SVC_DECLARE_EXPORT (ACE, ACE_Naming_Context) + #include /**/ "ace/post.h" #endif /* ACE_NAMING_CONTEXT_H */ diff --git a/dep/acelite/ace/Naming_Context.inl b/dep/acelite/ace/Naming_Context.inl index 77d451e82..034442b93 100644 --- a/dep/acelite/ace/Naming_Context.inl +++ b/dep/acelite/ace/Naming_Context.inl @@ -1,3 +1,5 @@ +// $Id: Naming_Context.inl 84160 2009-01-14 14:13:58Z johnnyw $ + ACE_INLINE bool ACE_Name_Options::use_registry (void) const { diff --git a/dep/acelite/ace/Netlink_Addr.cpp b/dep/acelite/ace/Netlink_Addr.cpp index 198ee7293..888febb0a 100644 --- a/dep/acelite/ace/Netlink_Addr.cpp +++ b/dep/acelite/ace/Netlink_Addr.cpp @@ -1,7 +1,11 @@ +// $Id: Netlink_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $ + //============================================================================= /** * @file Netlink_Addr.cpp * + * $Id: Netlink_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $ + * * @author Robert Iakobashvilli * @author Raz Ben Yehuda */ @@ -11,10 +15,6 @@ #ifdef ACE_HAS_NETLINK -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/Netlink_Addr.inl" #endif /* __ACE_INLINE__ */ @@ -65,3 +65,4 @@ ACE_Netlink_Addr::get_gid (void) const ACE_END_VERSIONED_NAMESPACE_DECL #endif + diff --git a/dep/acelite/ace/Netlink_Addr.h b/dep/acelite/ace/Netlink_Addr.h index b9a1e0cc3..87f0653da 100644 --- a/dep/acelite/ace/Netlink_Addr.h +++ b/dep/acelite/ace/Netlink_Addr.h @@ -2,6 +2,8 @@ /** * @file Netlink_Addr.h * + * $Id: Netlink_Addr.h 95425 2012-01-09 11:09:43Z johnnyw $ + * * @author Robert Iakobashvilli * @author Raz Ben Yehuda */ @@ -81,7 +83,7 @@ public: /** * Set a pointer to the address */ - virtual void set_addr (const void *, int len= sizeof(sockaddr_nl) ); + virtual void set_addr (void *, int len= sizeof(sockaddr_nl) ); /// Declare the dynamic allocation hooks. ACE_ALLOC_HOOK_DECLARE; diff --git a/dep/acelite/ace/Netlink_Addr.inl b/dep/acelite/ace/Netlink_Addr.inl index 912f21cd8..4ec38fa4a 100644 --- a/dep/acelite/ace/Netlink_Addr.inl +++ b/dep/acelite/ace/Netlink_Addr.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Netlink_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + #ifdef ACE_HAS_NETLINK ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -39,8 +41,8 @@ ACE_INLINE int ACE_Netlink_Addr::get_addr_size (void) const } -ACE_INLINE void ACE_Netlink_Addr::set_addr (const void *addr, int len) { - ACE_OS::memcpy (&this->nl_, addr, len); +ACE_INLINE void ACE_Netlink_Addr::set_addr (void *addr, int len){ + ACE_OS::memcpy (&this->nl_,addr,len); } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Node.cpp b/dep/acelite/ace/Node.cpp index f1ca0de37..b1b36fd73 100644 --- a/dep/acelite/ace/Node.cpp +++ b/dep/acelite/ace/Node.cpp @@ -1,19 +1,17 @@ +// $Id: Node.cpp 81624 2008-05-06 17:14:57Z wotte $ + #ifndef ACE_NODE_CPP #define ACE_NODE_CPP #include "ace/Node.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Node) +ACE_ALLOC_HOOK_DEFINE(ACE_Node) template ACE_Node::~ACE_Node (void) diff --git a/dep/acelite/ace/Node.h b/dep/acelite/ace/Node.h index 57bf9de39..57433a70e 100644 --- a/dep/acelite/ace/Node.h +++ b/dep/acelite/ace/Node.h @@ -4,6 +4,8 @@ /** * @file Node.h * + * $Id: Node.h 81624 2008-05-06 17:14:57Z wotte $ + * * @author Doug Schmidt */ //============================================================================= @@ -52,8 +54,6 @@ public: /// This isn't necessary, but it keeps some compilers happy. ~ACE_Node (void); - ACE_ALLOC_HOOK_DECLARE; - private: // = Initialization methods ACE_Node (const T &i, ACE_Node *n); diff --git a/dep/acelite/ace/Notification_Queue.cpp b/dep/acelite/ace/Notification_Queue.cpp index 7a0af0aea..881909052 100644 --- a/dep/acelite/ace/Notification_Queue.cpp +++ b/dep/acelite/ace/Notification_Queue.cpp @@ -1,3 +1,5 @@ +// $Id: Notification_Queue.cpp 85236 2009-05-01 11:43:56Z johnnyw $ + #include "ace/Notification_Queue.h" #if !defined (__ACE_INLINE__) @@ -8,8 +10,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Notification_Queue_Node) - ACE_Notification_Queue:: ACE_Notification_Queue() : ACE_Copy_Disabled() diff --git a/dep/acelite/ace/Notification_Queue.h b/dep/acelite/ace/Notification_Queue.h index dc7801e16..d312e0cd2 100644 --- a/dep/acelite/ace/Notification_Queue.h +++ b/dep/acelite/ace/Notification_Queue.h @@ -1,6 +1,8 @@ /** * @file Notification_Queue.h * + * $Id: Notification_Queue.h 95425 2012-01-09 11:09:43Z johnnyw $ + * * @author Carlos O'Ryan */ @@ -57,8 +59,6 @@ public: */ void clear_mask(ACE_Reactor_Mask mask); - ACE_ALLOC_HOOK_DECLARE; - private: ACE_Notification_Buffer contents_; }; diff --git a/dep/acelite/ace/Notification_Queue.inl b/dep/acelite/ace/Notification_Queue.inl index 5d615dffb..999dd831e 100644 --- a/dep/acelite/ace/Notification_Queue.inl +++ b/dep/acelite/ace/Notification_Queue.inl @@ -1,3 +1,5 @@ +// $Id: Notification_Queue.inl 94385 2011-08-10 12:19:36Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Notification_Queue_Node:: diff --git a/dep/acelite/ace/Notification_Strategy.cpp b/dep/acelite/ace/Notification_Strategy.cpp index 854e9d962..e37f85ece 100644 --- a/dep/acelite/ace/Notification_Strategy.cpp +++ b/dep/acelite/ace/Notification_Strategy.cpp @@ -1,3 +1,5 @@ +// $Id: Notification_Strategy.cpp 91287 2010-08-05 10:30:49Z johnnyw $ + #include "ace/Notification_Strategy.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Notification_Strategy.h b/dep/acelite/ace/Notification_Strategy.h index f47824b76..ba4c558db 100644 --- a/dep/acelite/ace/Notification_Strategy.h +++ b/dep/acelite/ace/Notification_Strategy.h @@ -4,6 +4,8 @@ /** * @file Notification_Strategy.h * + * $Id: Notification_Strategy.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Notification_Strategy.inl b/dep/acelite/ace/Notification_Strategy.inl index f1c1598d0..e1a309bcb 100644 --- a/dep/acelite/ace/Notification_Strategy.inl +++ b/dep/acelite/ace/Notification_Strategy.inl @@ -1,5 +1,7 @@ // -*- C++ -*- // +//$Id: Notification_Strategy.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Event_Handler * diff --git a/dep/acelite/ace/Null_Barrier.h b/dep/acelite/ace/Null_Barrier.h index 50e4e2789..6ea89e7db 100644 --- a/dep/acelite/ace/Null_Barrier.h +++ b/dep/acelite/ace/Null_Barrier.h @@ -4,9 +4,11 @@ /** * @file Null_Barrier.h * + * $Id: Null_Barrier.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Null_Condition.h b/dep/acelite/ace/Null_Condition.h index a86e0c54b..9a1e47ec0 100644 --- a/dep/acelite/ace/Null_Condition.h +++ b/dep/acelite/ace/Null_Condition.h @@ -4,9 +4,11 @@ /** * @file Null_Condition.h * + * $Id: Null_Condition.h 96076 2012-08-18 19:26:00Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Null_Mutex.h b/dep/acelite/ace/Null_Mutex.h index 443ce1585..85d06688a 100644 --- a/dep/acelite/ace/Null_Mutex.h +++ b/dep/acelite/ace/Null_Mutex.h @@ -4,9 +4,11 @@ /** * @file Null_Mutex.h * + * $Id: Null_Mutex.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== @@ -23,6 +25,7 @@ #include "ace/Global_Macros.h" #include "ace/OS_Memory.h" + ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Time_Value; @@ -79,8 +82,6 @@ public: //ACE_ALLOC_HOOK_DECLARE; int lock_; // A dummy lock. - - ACE_ALLOC_HOOK_DECLARE; }; // FUZZ: disable check_for_ACE_Guard diff --git a/dep/acelite/ace/Null_Semaphore.h b/dep/acelite/ace/Null_Semaphore.h index 3e35bdff2..6d152e23a 100644 --- a/dep/acelite/ace/Null_Semaphore.h +++ b/dep/acelite/ace/Null_Semaphore.h @@ -4,9 +4,11 @@ /** * @file Null_Semaphore.h * + * $Id: Null_Semaphore.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Numeric_Limits.h b/dep/acelite/ace/Numeric_Limits.h index 187123f6a..c8ab7c2ff 100644 --- a/dep/acelite/ace/Numeric_Limits.h +++ b/dep/acelite/ace/Numeric_Limits.h @@ -4,6 +4,8 @@ /** * @file Numeric_Limits.h * + * $Id: Numeric_Limits.h 95761 2012-05-15 18:23:04Z johnnyw $ + * * Traits containing basic integer limits. Useful for template-based * code on platforms that lack @c std::numeric_limits<>. * diff --git a/dep/acelite/ace/OS.h b/dep/acelite/ace/OS.h index 7eb5105c3..f5baa84ed 100644 --- a/dep/acelite/ace/OS.h +++ b/dep/acelite/ace/OS.h @@ -4,7 +4,9 @@ /** * @file OS.h * - * @author Douglas C. Schmidt + * $Id: OS.h 97130 2013-05-13 17:36:26Z mesnier_p $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... */ diff --git a/dep/acelite/ace/OS_Errno.cpp b/dep/acelite/ace/OS_Errno.cpp index 065eb39e1..3fe4a0a0a 100644 --- a/dep/acelite/ace/OS_Errno.cpp +++ b/dep/acelite/ace/OS_Errno.cpp @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_Errno.cpp 91809 2010-09-17 07:20:41Z johnnyw $ + #include "ace/OS_Errno.h" // Inlining this class on debug builds with gcc on Solaris can cause diff --git a/dep/acelite/ace/OS_Errno.h b/dep/acelite/ace/OS_Errno.h index be1a5eee3..bda24ad0a 100644 --- a/dep/acelite/ace/OS_Errno.h +++ b/dep/acelite/ace/OS_Errno.h @@ -4,7 +4,9 @@ /** * @file OS_Errno.h * - * @author (Originally in OS.h)Doug Schmidt + * $Id: OS_Errno.h 83891 2008-11-28 11:01:50Z johnnyw $ + * + * @author (Originally in OS.h)Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/OS_Errno.inl b/dep/acelite/ace/OS_Errno.inl index 9fd2af39b..3fac7dfd4 100644 --- a/dep/acelite/ace/OS_Errno.inl +++ b/dep/acelite/ace/OS_Errno.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_Errno.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/OS_Log_Msg_Attributes.cpp b/dep/acelite/ace/OS_Log_Msg_Attributes.cpp index e5eea9fdd..bbf0cb048 100644 --- a/dep/acelite/ace/OS_Log_Msg_Attributes.cpp +++ b/dep/acelite/ace/OS_Log_Msg_Attributes.cpp @@ -1,3 +1,5 @@ +// $Id: OS_Log_Msg_Attributes.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/OS_Log_Msg_Attributes.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_Log_Msg_Attributes.h b/dep/acelite/ace/OS_Log_Msg_Attributes.h index 6ef922b1a..ee59c0830 100644 --- a/dep/acelite/ace/OS_Log_Msg_Attributes.h +++ b/dep/acelite/ace/OS_Log_Msg_Attributes.h @@ -4,6 +4,8 @@ /** * @file OS_Log_Msg_Attributes.h * + * $Id: OS_Log_Msg_Attributes.h 97874 2014-09-08 12:10:55Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/OS_Log_Msg_Attributes.inl b/dep/acelite/ace/OS_Log_Msg_Attributes.inl index 222609f53..df575b497 100644 --- a/dep/acelite/ace/OS_Log_Msg_Attributes.inl +++ b/dep/acelite/ace/OS_Log_Msg_Attributes.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_Log_Msg_Attributes.inl 84184 2009-01-19 10:18:31Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/OS_Memory.h b/dep/acelite/ace/OS_Memory.h index 5effb9269..cf1f91fa2 100644 --- a/dep/acelite/ace/OS_Memory.h +++ b/dep/acelite/ace/OS_Memory.h @@ -4,7 +4,9 @@ /** * @file OS_Memory.h * - * @author Doug Schmidt + * $Id: OS_Memory.h 91688 2010-09-09 11:21:50Z johnnyw $ + * + * @author Doug Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... */ diff --git a/dep/acelite/ace/OS_NS_Thread.cpp b/dep/acelite/ace/OS_NS_Thread.cpp index 8a0522717..358b43476 100644 --- a/dep/acelite/ace/OS_NS_Thread.cpp +++ b/dep/acelite/ace/OS_NS_Thread.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_Thread.cpp 97911 2014-10-07 21:58:25Z shuston $ + #include "ace/OS_NS_Thread.h" #if !defined (ACE_HAS_INLINED_OSCALLS) @@ -13,6 +15,7 @@ #include "ace/OS_NS_errno.h" #include "ace/OS_NS_ctype.h" #include "ace/Log_Category.h" // for ACE_ASSERT +// This is necessary to work around nasty problems with MVS C++. #include "ace/Auto_Ptr.h" #include "ace/Thread_Mutex.h" #include "ace/Condition_Thread_Mutex.h" @@ -32,7 +35,7 @@ ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME (void *args) # define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ CreateThread (0, STACKSIZE, (unsigned long (__stdcall *) (void *)) ENTRY_POINT, ARGS, (FLAGS) & (CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION), (unsigned long *) THR_ID) #elif defined(ACE_HAS_WTHREADS) - // Green Hills compiler gets confused when __stdcall is embedded in + // Green Hills compiler gets confused when __stdcall is imbedded in // parameter list, so we define the type ACE_WIN32THRFUNC_T and use it // instead. typedef unsigned (__stdcall *ACE_WIN32THRFUNC_T)(void*); @@ -45,25 +48,19 @@ ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME (void *args) ACE_BEGIN_VERSIONED_NAMESPACE_DECL void -ACE_Thread_ID::to_string (char *thr_string, size_t thr_string_len) const +ACE_Thread_ID::to_string (char *thr_string) const { #if defined (ACE_WIN32) - ACE_OS::snprintf (thr_string, thr_string_len, "%u", - static_cast (this->thread_id_)); + ACE_OS::sprintf (thr_string, "%u", + static_cast (this->thread_id_)); #else // Yes, this is an ugly C-style cast, but the correct C++ cast is // different depending on whether the t_id is an integral type or a // pointer type. FreeBSD uses a pointer type, but doesn't have a _np // function to get an integral type like other OSes, so use the // bigger hammer. - ACE_OS::snprintf (thr_string, thr_string_len, "%lu", -# ifdef ACE_THREAD_T_IS_A_STRUCT - *reinterpret_cast (& -# else - (unsigned long) ( -# endif // ACE_THREAD_T_IS_A_STRUCT - thread_handle_)); - + ACE_OS::sprintf (thr_string, "%lu", + (unsigned long) thread_handle_); #endif /* ACE_WIN32 */ } @@ -125,6 +122,7 @@ ACE_TSS_Emulation::tss_base (void* ts_storage[], u_int *ts_created) if (!key_created_) { + ACE_NO_HEAP_CHECK; if (ACE_OS::thr_keycreate_native (&native_tss_key_, &ACE_TSS_Emulation_cleanup) != 0) { @@ -159,16 +157,11 @@ ACE_TSS_Emulation::tss_base (void* ts_storage[], u_int *ts_created) // storage array. if (ts_storage == 0) { -#ifdef ACE_HAS_ALLOC_HOOKS - const size_t n = ACE_TSS_THREAD_KEYS_MAX * sizeof (void *); - ACE_Allocator *const alloc = ACE_Allocator::instance (); - ACE_ALLOCATOR_RETURN (ts_storage, - static_cast (alloc->malloc (n)), 0); -#else + ACE_NO_HEAP_CHECK; + ACE_NEW_RETURN (ts_storage, void*[ACE_TSS_THREAD_KEYS_MAX], 0); -#endif // Zero the entire TSS array. Do it manually instead of // using memset, for optimum speed. Though, memset may be @@ -355,14 +348,11 @@ ACE_TSS_Ref::operator== (const ACE_TSS_Ref &info) const { ACE_OS_TRACE ("ACE_TSS_Ref::operator=="); -#ifdef ACE_THREAD_T_IS_A_STRUCT - return 0 == ACE_OS::memcmp (&this->tid_, &info.tid_, sizeof tid_); -#else return this->tid_ == info.tid_; -#endif } // Check for inequality. +ACE_SPECIAL_INLINE bool ACE_TSS_Ref::operator != (const ACE_TSS_Ref &tss_ref) const { @@ -436,7 +426,7 @@ ACE_TSS_Keys::ACE_TSS_Keys (void) } } - +ACE_SPECIAL_INLINE void ACE_TSS_Keys::find (const u_int key, u_int &word, u_int &bit) { @@ -494,8 +484,6 @@ ACE_TSS_Keys::is_set (const ACE_thread_key_t key) const class ACE_TSS_Cleanup { public: - ACE_ALLOC_HOOK_DECLARE; - /// Register a newly-allocated key /// @param key the key to be monitored /// @param destructor the function to call to delete objects stored via this key @@ -565,8 +553,6 @@ private: ACE_thread_key_t in_use_; }; -ACE_ALLOC_HOOK_DEFINE (ACE_TSS_Cleanup); -ACE_ALLOC_HOOK_DEFINE (ACE_TSS_Keys); /*****************************************************************************/ /** @@ -595,7 +581,7 @@ public: USE, DESTROY }; - explicit TSS_Cleanup_Instance (Purpose purpose = USE); + TSS_Cleanup_Instance (Purpose purpose = USE); ~TSS_Cleanup_Instance(); bool valid(); @@ -1871,7 +1857,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m, if (result == 0 && lock_type != 0) { -# if defined (ACE_HAS_RECURSIVE_MUTEXES) && !defined (ACE_LACKS_PTHREAD_MUTEXATTR_SETTYPE) +# if defined (ACE_HAS_RECURSIVE_MUTEXES) (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes, lock_type), result); @@ -1879,7 +1865,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m, } if (result == 0) - { +{ # if defined (ACE_PTHREAD_MUTEX_T_INITIALIZE) /* VxWorks 6.x API reference states: * If the memory for the mutex variable object has been allocated @@ -1894,7 +1880,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m, result = 0; else result = -1; // ACE_ADAPT_RETVAL used it for intermediate status - } +} // Only do the deletions if the parameter wasn't // originally set. @@ -1978,14 +1964,9 @@ ACE_OS::mutex_destroy (ACE_mutex_t *m) ACE_OS_TRACE ("ACE_OS::mutex_destroy"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) -# if defined (ACE_LACKS_PTHREAD_MUTEX_DESTROY) - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -# else int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m), result), int, -1); -# endif /* ACE_LACKS_PTHREAD_MUTEX_DESTROY */ # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1); @@ -2398,82 +2379,111 @@ ACE_OS::mutex_lock_cleanup (void *mutex) // EVENTS BEGIN /*****************************************************************************/ -#ifndef ACE_WIN32 - -int ACE_event_t::lock (void) -{ -# if !ACE_EVENT_USE_MUTEX_PSHARED - if (this->eventdata_->type_ == USYNC_PROCESS) - return ACE_OS::sema_wait (&this->lock_); -# endif - return ACE_OS::mutex_lock (&this->eventdata_->lock_); -} - -int ACE_event_t::unlock (void) -{ -# if !ACE_EVENT_USE_MUTEX_PSHARED - if (this->eventdata_->type_ == USYNC_PROCESS) - return ACE_OS::sema_post (&this->lock_); -# endif - return ACE_OS::mutex_unlock (&this->eventdata_->lock_); -} - -int ACE_event_t::wake_one (void) -{ -# if !ACE_EVENT_USE_COND_PSHARED - if (this->eventdata_->type_ == USYNC_PROCESS) - { - if (ACE_OS::sema_post (&this->semaphore_) != 0) - return -1; - } - else -# endif - if (ACE_OS::cond_signal (&this->eventdata_->condition_) != 0) - return -1; - return 0; -} - -#endif /* ACE_WIN32 */ - int ACE_OS::event_destroy (ACE_event_t *event) { #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) - if (!event->eventdata_) + if (event->eventdata_) { - errno = EINVAL; - return -1; - } + // mutex_destroy()/cond_destroy() are called in a loop if the object + // is BUSY. This avoids conditions where we fail to destroy these + // objects because at time of destroy they were just being used in + // another thread possibly causing deadlocks later on if they keep + // being used after we're gone. - // mutex_destroy()/cond_destroy() are called in a loop if the object - // is BUSY. This avoids conditions where we fail to destroy these - // objects because at time of destroy they were just being used in - // another thread possibly causing deadlocks later on if they keep - // being used after we're gone. - - if (event->eventdata_->type_ == USYNC_PROCESS) - { - if (event->name_) + if (event->eventdata_->type_ == USYNC_PROCESS) { - int r1, r2; -# if ACE_EVENT_USE_MUTEX_PSHARED - // First destroy the mutex so locking after this will return - // errors. - while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1 - && errno == EBUSY) - ACE_OS::thr_yield (); + if (event->name_) + { + // Only destroy the event data if we're the ones who initialized + // it. + + int r1, r2; +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + // First destroy the mutex so locking after this will return + // errors. + while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1 + && errno == EBUSY) + { + ACE_OS::thr_yield (); + } # else - r1 = ACE_OS::sema_destroy (&event->lock_); + r1 = ACE_OS::sema_destroy(&event->lock_); # endif -# if ACE_EVENT_USE_COND_PSHARED - // Now fix event to manual reset, raise signal and broadcast - // until is's possible to destroy the condition. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + // Now fix event to manual reset, raise signal and broadcast + // until is's possible to destroy the condition. + event->eventdata_->manual_reset_ = 1; + while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1 + && errno == EBUSY) + { + event->eventdata_->is_signaled_ = 1; + if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) + return -1; + ACE_OS::thr_yield (); + } +# else + r2 = ACE_OS::sema_destroy(&event->semaphore_); +# endif + ACE_OS::munmap (event->eventdata_, + sizeof (ACE_eventdata_t)); + ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR(event->name_)); + ACE_OS::free (event->name_); + return r1 != 0 || r2 != 0 ? -1 : 0; + } + else + { + ACE_OS::munmap (event->eventdata_, + sizeof (ACE_eventdata_t)); +# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \ + (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \ + (defined (ACE_USES_FIFO_SEM) || \ + (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM))) + ACE_OS::sema_destroy(&event->lock_); +# endif +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + return 0; +# else + return ACE_OS::sema_destroy(&event->semaphore_); +# endif + } + } + else + { + int r1, r2; + // First destroy the mutex so locking after this will return errors. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + // first destroy the mutex so locking after this will return errors + while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1 + && errno == EBUSY) + { + ACE_OS::thr_yield (); + } +# else + r1 = ACE_OS::sema_destroy(&event->lock_); +# endif + +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + // Now fix event to manual reset, raise signal and broadcast until + // it's possible to destroy the condition. event->eventdata_->manual_reset_ = 1; - while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) - == -1 && errno == EBUSY) + while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1 + && errno == EBUSY) { event->eventdata_->is_signaled_ = 1; if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) @@ -2481,52 +2491,11 @@ ACE_OS::event_destroy (ACE_event_t *event) ACE_OS::thr_yield (); } # else - r2 = ACE_OS::sema_destroy (&event->semaphore_); + r2 = ACE_OS::sema_destroy(&event->semaphore_); # endif - ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t)); - ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (event->name_)); -# if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance ()->free (event->name_); -# else - ACE_OS::free (event->name_); -# endif /* ACE_HAS_ALLOC_HOOKS */ + delete event->eventdata_; return r1 != 0 || r2 != 0 ? -1 : 0; } - else // !name_ (not owned by this process) - { - ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t)); - -# if !ACE_EVENT_USE_MUTEX_PSHARED - ACE_OS::sema_destroy (&event->lock_); -# endif - -# if !ACE_EVENT_USE_COND_PSHARED - return ACE_OS::sema_destroy (&event->semaphore_); -# endif - } - } - else // USYNC_THREAD: - { - int r1, r2; - // First destroy the mutex so locking after this will return errors. - while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1 - && errno == EBUSY) - ACE_OS::thr_yield (); - - // Now fix event to manual reset, raise signal and broadcast until - // it's possible to destroy the condition. - event->eventdata_->manual_reset_ = 1; - while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1 - && errno == EBUSY) - { - event->eventdata_->is_signaled_ = 1; - if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) - return -1; - ACE_OS::thr_yield (); - } - - delete event->eventdata_; - return r1 != 0 || r2 != 0 ? -1 : 0; } return 0; @@ -2536,45 +2505,6 @@ ACE_OS::event_destroy (ACE_event_t *event) #endif /* ACE_WIN32 */ } -ACE_ALLOC_HOOK_DEFINE (ACE_eventdata_t) - -#ifndef ACE_WIN32 -namespace { - int eventdata_init (ACE_eventdata_t *evtdata, int type, int manual_reset, - int initial_state, ACE_condattr_t *attributes, - const char *name, void *arg, int init_condition = 1, - int init_mutex = 1) - { - evtdata->type_ = type; - evtdata->manual_reset_ = manual_reset; - evtdata->is_signaled_ = initial_state; - evtdata->auto_event_signaled_ = false; - evtdata->waiting_threads_ = 0; - evtdata->signal_count_ = 0; - - if (init_condition) - { - const int result = attributes ? - ACE_OS::cond_init (&evtdata->condition_, *attributes, name, arg) : - ACE_OS::cond_init (&evtdata->condition_, type, name, arg); - - if (result != 0) - return result; - } - - return init_mutex ? ACE_OS::mutex_init (&evtdata->lock_, type, name, - (ACE_mutexattr_t *) arg) : 0; - } - - template - void format_name (char (&str)[N], const char *name, const char (&suffix)[M]) - { - ACE_OS::strncpy (str, name, N - M); - ACE_OS::strcat (str, suffix); - } -} -#endif /* ACE_WIN32 */ - int ACE_OS::event_init (ACE_event_t *event, int type, @@ -2615,12 +2545,12 @@ ACE_OS::event_init (ACE_event_t *event, } #elif defined (ACE_HAS_THREADS) ACE_UNUSED_ARG (sa); - event->name_ = 0; event->eventdata_ = 0; + ACE_eventdata_t* evtdata; if (type == USYNC_PROCESS) { - const char *name_p = name; + const char *name_p = 0; # if defined (ACE_SHM_OPEN_REQUIRES_ONE_SLASH) char adj_name[MAXPATHLEN]; if (name[0] != '/') @@ -2629,9 +2559,14 @@ ACE_OS::event_init (ACE_event_t *event, ACE_OS::strsncpy (&adj_name[1], name, MAXPATHLEN-1); name_p = adj_name; } + else + { + name_p = name; + } +# else + name_p = name; # endif /* ACE_SHM_OPEN_REQUIRES_ONE_SLASH */ - - bool owner = false; + int owner = 0; // Let's see if the shared memory entity already exists. ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p), O_RDWR | O_CREAT | O_EXCL, @@ -2653,12 +2588,16 @@ ACE_OS::event_init (ACE_event_t *event, ACE_OS::close (fd); return -1; } - owner = true; + owner = 1; } - void *const mapped = ACE_OS::mmap (0, sizeof (ACE_eventdata_t), - PROT_RDWR, MAP_SHARED, fd); - ACE_eventdata_t *evtdata = reinterpret_cast (mapped); + evtdata = + (ACE_eventdata_t *) ACE_OS::mmap (0, + sizeof (ACE_eventdata_t), + PROT_RDWR, + MAP_SHARED, + fd, + 0); ACE_OS::close (fd); if (evtdata == MAP_FAILED) { @@ -2667,53 +2606,174 @@ ACE_OS::event_init (ACE_event_t *event, return -1; } - event->eventdata_ = evtdata; - if (owner) { event->name_ = ACE_OS::strdup (name_p); - if (event->name_ == 0 || - eventdata_init (event->eventdata_, USYNC_PROCESS, manual_reset, - initial_state, attributes, name, arg, - ACE_EVENT_USE_COND_PSHARED, - ACE_EVENT_USE_MUTEX_PSHARED) != 0) + if (event->name_ == 0) { - ACE_OS::munmap (evtdata, sizeof (ACE_eventdata_t)); ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p)); return -1; } - } + event->eventdata_ = evtdata; + event->eventdata_->type_ = type; + event->eventdata_->manual_reset_ = manual_reset; + event->eventdata_->is_signaled_ = initial_state; + event->eventdata_->auto_event_signaled_ = false; + event->eventdata_->waiting_threads_ = 0; + event->eventdata_->signal_count_ = 0; - int result = 0; -# if !ACE_EVENT_USE_COND_PSHARED - char sem_name[128] = {}; - format_name (sem_name, name, "._ACE_EVTSEM_"); - result = ACE_OS::sema_init (&event->semaphore_, 0, type, attributes, - sem_name, arg); +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + int result = attributes == 0 ? + ACE_OS::cond_init (&event->eventdata_->condition_, + type, + name, + arg) : + ACE_OS::cond_init (&event->eventdata_->condition_, + *attributes, + name, + arg); +# else + char sem_name[128]; + ACE_OS::strncpy (sem_name, + name, + sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_"))); + ACE_OS::strcat (sem_name, "._ACE_EVTSEM_"); + int result = ACE_OS::sema_init (&event->semaphore_, + 0, + type, + attributes, + sem_name, + arg); # endif - -# if !ACE_EVENT_USE_MUTEX_PSHARED - if (result == 0) + if (result == 0) +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + result = ACE_OS::mutex_init (&event->eventdata_->lock_, + type, + name, + (ACE_mutexattr_t *) arg); +# else + { + char lck_name[128]; + ACE_OS::strncpy + (lck_name, + name, + sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_"))); + ACE_OS::strcat (lck_name, "._ACE_EVTLCK_"); + result = ACE_OS::sema_init (&event->lock_, + 0, + type, + attributes, + lck_name, + arg); + if (result == 0) + result = ACE_OS::sema_post (&event->lock_); /* Initially unlock */ + } +# endif + return result; + } + else { - char lck_name[128] = {}; - format_name (lck_name, name, "._ACE_EVTLCK_"); - result = ACE_OS::sema_init (&event->lock_, owner, type, attributes, - lck_name, arg); + int result = 0; + + event->name_ = 0; + event->eventdata_ = evtdata; +# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \ + (defined (ACE_USES_FIFO_SEM) || \ + (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM))) + char sem_name[128]; + ACE_OS::strncpy (sem_name, + name, + sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_"))); + ACE_OS::strcat (sem_name, "._ACE_EVTSEM_"); + result = ACE_OS::sema_init(&event->semaphore_, + 0, + type, + attributes, + sem_name, + arg); +# endif + +# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \ + (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \ + (defined (ACE_USES_FIFO_SEM) || \ + (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (result == 0) + { + char lck_name[128]; + ACE_OS::strncpy + (lck_name, + name, + sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_"))); + ACE_OS::strcat (lck_name, "._ACE_EVTLCK_"); + result = ACE_OS::sema_init (&event->lock_, + 0, + type, + attributes, + lck_name, + arg); + } +# endif + return result; } -# endif - -# if !ACE_EVENT_USE_COND_PSHARED || !ACE_EVENT_USE_MUTEX_PSHARED - if (result != 0 && owner) - ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p)); -# endif - - return result; } else { - ACE_NEW_RETURN (event->eventdata_, ACE_eventdata_t, -1); - return eventdata_init (event->eventdata_, USYNC_THREAD, manual_reset, - initial_state, attributes, name, arg); + ACE_NEW_RETURN (evtdata, ACE_eventdata_t, -1); + event->name_ = 0; + event->eventdata_ = evtdata; + event->eventdata_->type_ = type; + event->eventdata_->manual_reset_ = manual_reset; + event->eventdata_->is_signaled_ = initial_state; + event->eventdata_->auto_event_signaled_ = false; + event->eventdata_->waiting_threads_ = 0; + event->eventdata_->signal_count_ = 0; + +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + int result = attributes == 0 ? + ACE_OS::cond_init (&event->eventdata_->condition_, + type, + name, + arg) : + ACE_OS::cond_init (&event->eventdata_->condition_, + *attributes, + name, + arg); +# else + int result = ACE_OS::sema_init (&event->semaphore_, + 0, + type, + attributes, + name, + arg); +# endif + if (result == 0) +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + result = ACE_OS::mutex_init (&event->eventdata_->lock_, + type, + name, + (ACE_mutexattr_t *) arg); +# else + result = ACE_OS::sema_init (&event->lock_, + 0, + type, + attributes, + name, + arg); + if (result == 0) + result = ACE_OS::sema_post(&event->lock_); /* initially unlock */ +# endif + + return result; } #else ACE_UNUSED_ARG (event); @@ -2734,66 +2794,89 @@ ACE_OS::event_pulse (ACE_event_t *event) #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) + int result = 0; int error = 0; - int result = event->lock (); - if (result != 0) - return result; - if (event->eventdata_->waiting_threads_ > 0) + // grab the lock first +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) +# else + if (ACE_OS::sema_wait (&event->lock_) == 0) +# endif + { + if (event->eventdata_->waiting_threads_ > 0) { + // Manual-reset event. if (event->eventdata_->manual_reset_ == 1) + { + // Wakeup all waiters. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) { - // Wakeup all waiters. -# if !ACE_EVENT_USE_COND_PSHARED - if (event->eventdata_->type_ == USYNC_PROCESS) - { - event->eventdata_->signal_count_ = - event->eventdata_->waiting_threads_; - for (unsigned long i = 0; - i < event->eventdata_->signal_count_; ++i) - if (ACE_OS::sema_post (&event->semaphore_) != 0) - { - event->eventdata_->signal_count_ = 0; - result = -1; - error = errno; - } - - if (result == 0) - while (event->eventdata_->signal_count_ != 0 && - event->eventdata_->waiting_threads_ != 0) - ACE_OS::thr_yield (); - } - else -#endif - if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) - { - result = -1; - error = errno; - } - else - event->eventdata_->signal_count_ = - event->eventdata_->waiting_threads_; + result = -1; + error = errno; } - else // Auto-reset event: wakeup one waiter. + if (result == 0) + event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_; +# else + event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_; + for (unsigned long i=0; ieventdata_->signal_count_ ;++i) + if (ACE_OS::sema_post(&event->semaphore_) != 0) + { + event->eventdata_->signal_count_ = 0; + result = -1; + error = errno; + } + + if (result == 0) + while(event->eventdata_->signal_count_!=0 && event->eventdata_->waiting_threads_!=0) + ACE_OS::thr_yield (); +# endif + } + // Auto-reset event: wakeup one waiter. + else + { +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0) +# else + if (ACE_OS::sema_post(&event->semaphore_) != 0) +# endif { - if (event->wake_one () != 0) - { - result = -1; - error = errno; - } - - event->eventdata_->auto_event_signaled_ = true; + result = -1; + error = errno; } + + event->eventdata_->auto_event_signaled_ = true; + } } - event->eventdata_->is_signaled_ = 0; - - if (event->unlock () != 0) - return -1; - - if (result == -1) - errno = error; + // Reset event. + event->eventdata_->is_signaled_ = 0; + // Now we can let go of the lock. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) + return -1; +# else + if (ACE_OS::sema_post (&event->lock_) != 0) + return -1; +# endif + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; + } + else + result = -1; return result; #else ACE_UNUSED_ARG (event); @@ -2807,13 +2890,37 @@ ACE_OS::event_reset (ACE_event_t *event) #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) - if (event->lock () != 0) - return -1; + int result = 0; - event->eventdata_->is_signaled_ = 0; - event->eventdata_->auto_event_signaled_ = false; + // Grab the lock first. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) +# else + if (ACE_OS::sema_wait (&event->lock_) == 0) +# endif + { + // Reset event. + event->eventdata_->is_signaled_ = 0; + event->eventdata_->auto_event_signaled_ = false; - return event->unlock (); + // Now we can let go of the lock. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) + return -1; +# else + if (ACE_OS::sema_post (&event->lock_) != 0) + return -1; +# endif + } + else + result = -1; + return result; #else ACE_UNUSED_ARG (event); ACE_NOTSUP_RETURN (-1); @@ -2826,53 +2933,83 @@ ACE_OS::event_signal (ACE_event_t *event) #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) + int result = 0; int error = 0; - int result = event->lock (); - if (result != 0) - return result; - - if (event->eventdata_->manual_reset_ == 1) + // grab the lock first +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) +# else + if (ACE_OS::sema_wait (&event->lock_) == 0) +# endif + { + // Manual-reset event. + if (event->eventdata_->manual_reset_ == 1) { // wakeup all -# if !ACE_EVENT_USE_COND_PSHARED - if (event->eventdata_->type_ == USYNC_PROCESS) - { - if (ACE_OS::sema_post (&event->semaphore_) != 0) - { - result = -1; - error = errno; - } - } - else -#endif - if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) - { - result = -1; - error = errno; - } +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) + { + result = -1; + error = errno; + } +# else + if (ACE_OS::sema_post(&event->semaphore_) != 0) + { + result = -1; + error = errno; + } +# endif if (result == 0) + // signal event event->eventdata_->is_signaled_ = 1; } - else // Auto-reset event + // Auto-reset event + else { if (event->eventdata_->waiting_threads_ == 0) + // No waiters: signal event. event->eventdata_->is_signaled_ = 1; - else if (event->wake_one () != 0) - { - result = -1; - error = errno; - } + // Waiters: wakeup one waiter. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + else if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0) +# else + else if (ACE_OS::sema_post(&event->semaphore_) != 0) +# endif + { + result = -1; + error = errno; + } event->eventdata_->auto_event_signaled_ = true; } - if (event->unlock () != 0) - return -1; + // Now we can let go of the lock. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) + return -1; +# else + if (ACE_OS::sema_post (&event->lock_) != 0) + return -1; +# endif - if (result == -1) - errno = error; + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; + } + else + result = -1; return result; #else @@ -2886,10 +3023,14 @@ ACE_OS::event_timedwait (ACE_event_t *event, ACE_Time_Value *timeout, int use_absolute_time) { + if (timeout == 0) + // Wait indefinitely. + return ACE_OS::event_wait (event); + #if defined (ACE_WIN32) DWORD result; - if (timeout && *timeout == ACE_Time_Value::zero) + if (*timeout == ACE_Time_Value::zero) // Do a "poll". result = ::WaitForSingleObject (*event, 0); else @@ -2901,11 +3042,7 @@ ACE_OS::event_timedwait (ACE_event_t *event, // parameter is given in absolute or relative value // depending on parameter . int msec_timeout = 0; - if (!timeout) - { - msec_timeout = INFINITE; - } - else if (use_absolute_time) + if (use_absolute_time) { // Time is given in absolute time, we should use // gettimeofday() to calculate relative time @@ -2937,112 +3074,142 @@ ACE_OS::event_timedwait (ACE_event_t *event, return -1; } #elif defined (ACE_HAS_THREADS) + int result = 0; int error = 0; - int result = event->lock (); - if (result != 0) - return result; - - if (event->eventdata_->is_signaled_ == 1) + // grab the lock first +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) +# else + if (ACE_OS::sema_wait (&event->lock_) == 0) +# endif { - if (event->eventdata_->manual_reset_ == 0) + if (event->eventdata_->is_signaled_ == 1) + // event is currently signaled { - // AUTO: reset state - event->eventdata_->is_signaled_ = 0; - event->eventdata_->auto_event_signaled_ = false; + if (event->eventdata_->manual_reset_ == 0) + { + // AUTO: reset state + event->eventdata_->is_signaled_ = 0; + event->eventdata_->auto_event_signaled_ = false; + } } - } - else // event is currently not signaled - { - ++event->eventdata_->waiting_threads_; - - ACE_Time_Value *absolute_timeout = timeout, converted_time; - - // cond_timedwait() expects absolute time, check flag - if (timeout && use_absolute_time == 0) + else + // event is currently not signaled { - converted_time = timeout->to_absolute_time (); - absolute_timeout = &converted_time; + event->eventdata_->waiting_threads_++; + + ACE_Time_Value absolute_timeout = *timeout; + + // cond_timewait() expects absolute time, check + // flag. + if (use_absolute_time == 0) + absolute_timeout = timeout->to_absolute_time (); + + while (event->eventdata_->is_signaled_ == 0 && + event->eventdata_->auto_event_signaled_ == false) + { +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::cond_timedwait (&event->eventdata_->condition_, + &event->eventdata_->lock_, + &absolute_timeout) != 0) + { + result = -1; + error = errno; + break; + } + + if (event->eventdata_->signal_count_ > 0) + { + event->eventdata_->signal_count_--; + break; + } +# else +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) +# else + if (ACE_OS::sema_post (&event->lock_) != 0) +# endif + { + event->eventdata_->waiting_threads_--; + return -1; + } + + if (ACE_OS::sema_wait(&event->semaphore_, absolute_timeout) !=0) + { + result = -1; + if (errno == ETIMEDOUT) // Semaphores time out with ETIMEDOUT (POSIX) + error = ETIME; + else + error = errno; + } + + bool signalled = false; + if (result == 0 && event->eventdata_->signal_count_ > 0) + { + event->eventdata_->signal_count_--; + signalled = true; + } + +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0) +# else + if (ACE_OS::sema_wait (&event->lock_) != 0) +# endif + { + event->eventdata_->waiting_threads_--; // yes, I know it's not save + return -1; + } + + if (result) + break; + + if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1) + if (ACE_OS::sema_post(&event->semaphore_) != 0) + { + result = -1; + error = errno; + break; + } + + if (signalled) + break; +# endif + } + + // Reset the auto_event_signaled_ to false now that we have + // woken up. + if (event->eventdata_->auto_event_signaled_ == true) + event->eventdata_->auto_event_signaled_ = false; + + event->eventdata_->waiting_threads_--; } - while (event->eventdata_->is_signaled_ == 0 && - !event->eventdata_->auto_event_signaled_) -# if !ACE_EVENT_USE_COND_PSHARED - if (event->eventdata_->type_ == USYNC_PROCESS) - { - if (event->unlock () != 0) - { - --event->eventdata_->waiting_threads_; - return -1; - } + // Now we can let go of the lock. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) + return -1; +# else + if (ACE_OS::sema_post (&event->lock_) != 0) + return -1; +# endif - if (ACE_OS::sema_wait (&event->semaphore_, absolute_timeout) != 0) - { - result = -1; - error = (errno == ETIMEDOUT) // Semaphores use ETIMEDOUT (POSIX) - ? ETIME : errno; - } - - bool signalled = false; - if (result == 0 && event->eventdata_->signal_count_ > 0) - { - --event->eventdata_->signal_count_; - signalled = true; - } - - if (event->lock () != 0) - { - --event->eventdata_->waiting_threads_; - return -1; - } - - if (result != 0) - break; - - if (event->eventdata_->manual_reset_ == 1 && - event->eventdata_->is_signaled_ == 1 && - ACE_OS::sema_post (&event->semaphore_) != 0) - { - result = -1; - error = errno; - break; - } - - if (signalled) - break; - } - else -#endif - { - if (ACE_OS::cond_timedwait (&event->eventdata_->condition_, - &event->eventdata_->lock_, - absolute_timeout) != 0) - { - result = -1; - error = errno; - break; - } - - if (event->eventdata_->signal_count_ > 0) - { - --event->eventdata_->signal_count_; - break; - } - } - - // Reset the auto_event_signaled_ to false now that we have woken up. - if (event->eventdata_->auto_event_signaled_) - event->eventdata_->auto_event_signaled_ = false; - - --event->eventdata_->waiting_threads_; + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; } - - if (event->unlock () != 0) - return -1; - - if (result == -1) - errno = error; - + else + result = -1; return result; #else ACE_UNUSED_ARG (event); @@ -3052,6 +3219,148 @@ ACE_OS::event_timedwait (ACE_event_t *event, #endif /* ACE_WIN32 */ } +int +ACE_OS::event_wait (ACE_event_t *event) +{ +#if defined (ACE_WIN32) + switch (::WaitForSingleObject (*event, INFINITE)) + { + case WAIT_OBJECT_0: + return 0; + default: + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + } +#elif defined (ACE_HAS_THREADS) + int result = 0; + int error = 0; + + // grab the lock first +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) +# else + if (ACE_OS::sema_wait (&event->lock_) == 0) +# endif + { + if (event->eventdata_->is_signaled_ == 1) + // Event is currently signaled. + { + if (event->eventdata_->manual_reset_ == 0) + // AUTO: reset state + event->eventdata_->is_signaled_ = 0; + } + else // event is currently not signaled + { + event->eventdata_->waiting_threads_++; + + while (event->eventdata_->is_signaled_ == 0 && + event->eventdata_->auto_event_signaled_ == false) + { +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::cond_wait (&event->eventdata_->condition_, + &event->eventdata_->lock_) != 0) + { + result = -1; + error = errno; + // Something went wrong... + break; + } + if (event->eventdata_->signal_count_ > 0) + { + event->eventdata_->signal_count_--; + break; + } +# else +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) +# else + if (ACE_OS::sema_post (&event->lock_) != 0) +# endif + { + event->eventdata_->waiting_threads_--; + return -1; + } + + if (ACE_OS::sema_wait (&event->semaphore_) !=0) + { + result = -1; + error = errno; + } + + bool signalled = false; + if (result == 0 && event->eventdata_->signal_count_ > 0) + { + event->eventdata_->signal_count_--; + signalled = true; + } + +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0) +# else + if (ACE_OS::sema_wait (&event->lock_) != 0) +# endif + { + event->eventdata_->waiting_threads_--; + return -1; + } + + if (result) + break; + + if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1) + if (ACE_OS::sema_post(&event->semaphore_) != 0) + { + result = -1; + error = errno; + break; + } + + if (signalled) + break; +# endif + } + + // Reset it since we have woken up. + if (event->eventdata_->auto_event_signaled_ == true) + event->eventdata_->auto_event_signaled_ = false; + + event->eventdata_->waiting_threads_--; + } + + // Now we can let go of the lock. +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ + (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) + return -1; +# else + if (ACE_OS::sema_post (&event->lock_) != 0) + return -1; +# endif + + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; + } + else + result = -1; + return result; +#else + ACE_UNUSED_ARG (event); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + /*****************************************************************************/ // EVENTS END /*****************************************************************************/ @@ -3127,7 +3436,8 @@ ACE_OS::lwp_setparams (const ACE_Sched_Params &sched_params) #endif /* ! ACE_HAS_STHREADS && ! sun */ } -#if !defined (ACE_HAS_THREADS) || defined (ACE_LACKS_RWLOCK_T) +#if !defined (ACE_HAS_THREADS) || (defined (ACE_LACKS_RWLOCK_T) && \ + !defined (ACE_HAS_PTHREADS_UNIX98_EXT)) int ACE_OS::rwlock_init (ACE_rwlock_t *rw, int type, @@ -3553,11 +3863,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, else thread_args = thread_adapter; -#if defined (ACE_HAS_CPP11) - std::unique_ptr auto_thread_args; -#else auto_ptr auto_thread_args; -#endif /* ACE_HAS_CPP11 */ if (thread_adapter == 0) ACE_auto_ptr_reset (auto_thread_args, @@ -4131,9 +4437,9 @@ ACE_OS::thr_create (ACE_THR_FUNC func, tid = ::taskSpawn (thr_name && *thr_name ? const_cast (*thr_name) : 0, priority, (int) flags, - stacksize, + (int) stacksize, thread_args->entry_point (), - (ACE_VX_USR_ARG_T) thread_args, + (int) thread_args, 0, 0, 0, 0, 0, 0, 0, 0, 0); # if 0 /* Don't support setting of stack, because it doesn't seem to work. */ } @@ -4167,7 +4473,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, } # endif /* 0 */ - if (tid == ACE_VX_TASK_ID_ERROR) + if (tid == ERROR) return -1; else { @@ -4204,7 +4510,7 @@ ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status) { ACE_OS_TRACE ("ACE_OS::thr_exit"); #if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_EXIT) +# if defined (ACE_HAS_PTHREADS) ::pthread_exit (status); # elif defined (ACE_HAS_STHREADS) ::thr_exit (status); @@ -4255,10 +4561,8 @@ ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status) # endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/ # elif defined (ACE_HAS_VXTHREADS) - ACE_UNUSED_ARG (status); - ::taskDelete (ACE_OS::thr_self ()); -# else - ACE_UNUSED_ARG (status); + ACE_thread_t tid = ACE_OS::thr_self (); + *((int *) status) = ::taskDelete (tid); # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (status); @@ -4578,15 +4882,10 @@ ACE_OS::thr_keyfree_native (ACE_OS_thread_key_t key) // unload of libACE, by a program not linked with libACE, // ACE_TSS_cleanup will be invoked again at the thread exit // after libACE has been actually been unmapped from memory. - (void) ACE_OS::thr_setspecific_native (key, 0); + (void) ACE_OS::thr_setspecific (key, 0); # endif /* ACE_HAS_BROKEN_THREAD_KEYFREE */ # if defined (ACE_HAS_PTHREADS) -# if defined (ACE_LACKS_PTHREAD_KEY_DELETE) - ACE_UNUSED_ARG (key); - ACE_NOTSUP_RETURN (-1); -# else return ::pthread_key_delete (key); -# endif /* ACE_LACKS_PTHREAD_KEY_DELETE */ # elif defined (ACE_HAS_THR_KEYDELETE) return ::thr_keydelete (key); # elif defined (ACE_HAS_STHREADS) @@ -4786,8 +5085,14 @@ ACE_OS::unique_name (const void *object, // uniqueness between other "live" objects in the same process. The // uniqueness of this name is therefore only valid for the life of // . - ACE_OS::snprintf (name, length, "%p%d", object, - static_cast (ACE_OS::getpid ())); + char temp_name[ACE_UNIQUE_NAME_LEN]; + ACE_OS::sprintf (temp_name, + "%p%d", + object, + static_cast (ACE_OS::getpid ())); + ACE_OS::strsncpy (name, + temp_name, + length); } #if defined (ACE_USES_WCHAR) @@ -4801,8 +5106,14 @@ ACE_OS::unique_name (const void *object, // uniqueness between other "live" objects in the same process. The // uniqueness of this name is therefore only valid for the life of // . - ACE_OS::snprintf (name, length, ACE_TEXT ("%p%d"), object, - static_cast (ACE_OS::getpid ())); + wchar_t temp_name[ACE_UNIQUE_NAME_LEN]; + ACE_OS::sprintf (temp_name, + ACE_TEXT ("%p%d"), + object, + static_cast (ACE_OS::getpid ())); + ACE_OS::strsncpy (name, + temp_name, + length); } #endif @@ -4813,8 +5124,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL # include /**/ /* for ::sysClkRateGet() */ # include "ace/Service_Config.h" -#if !defined (ACE_LACKS_VA_FUNCTIONS) - // This global function can be used from the VxWorks shell to pass // arguments to a C main () function. // @@ -4824,12 +5133,10 @@ ACE_END_VERSIONED_NAMESPACE_DECL int spa (FUNCPTR entry, ...) { - // The called entrypoint can get the function name plus the normal 10 - // optional arguments. - static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 1 + 10; + static const unsigned int ACE_MAX_ARGS = 10; static char *argv[ACE_MAX_ARGS] = { 0 }; va_list pvar; - ACE_VX_USR_ARG_T argc; + unsigned int argc; // Hardcode a program name because the real one isn't available // through the VxWorks shell. @@ -4843,7 +5150,7 @@ spa (FUNCPTR entry, ...) // number of arguments would have to be passed. va_start (pvar, entry); - for (argc = 1; argc < ACE_MAX_ARGS; ++argc) + for (argc = 1; argc <= ACE_MAX_ARGS; ++argc) { argv[argc] = va_arg (pvar, char *); @@ -4851,46 +5158,41 @@ spa (FUNCPTR entry, ...) break; } - if (argc >= ACE_MAX_ARGS && argv[ACE_MAX_ARGS - 1] != 0) + if (argc > ACE_MAX_ARGS && argv[argc-1] != 0) { - // Try to read another arg, and warn user if the limit was exceeded. - // - // Note that the VxWorks shell arguments change from int to long when - // using a 64bit compiler. Cast the argument up so that the format - // specifier remains correct for either build type. + // try to read another arg, and warn user if the limit was exceeded if (va_arg (pvar, char *) != 0) - ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %ld\n", - (long)ACE_MAX_ARGS); + ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %d\n", + ACE_MAX_ARGS); } else { // fill unused argv slots with 0 to get rid of leftovers // from previous invocations - for (ACE_VX_USR_ARG_T i = argc; i < ACE_MAX_ARGS; ++i) + for (unsigned int i = argc; i <= ACE_MAX_ARGS; ++i) argv[i] = 0; } // The hard-coded options are what ::sp () uses, except for the // larger stack size (instead of ::sp ()'s 20000). - ACE_VX_TASK_ID const ret = ::taskSpawn (argv[0], // task name - 100, // task priority - VX_FP_TASK, // task options - ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size - entry, // entry point - argc, // first argument to main () - (ACE_VX_USR_ARG_T) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0, 0); + int const ret = ::taskSpawn (argv[0], // task name + 100, // task priority + VX_FP_TASK, // task options + ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size + entry, // entry point + argc, // first argument to main () + (int) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0, 0); va_end (pvar); // ::taskSpawn () returns the taskID on success: return 0 instead if // successful - return ret > 0 ? 0 : -1; + return ret > 0 ? 0 : ret; } -#endif /* !ACE_LACKS_VA_FUNCTIONS */ // A helper function for the extended spa functions static void -add_to_argv (ACE_VX_USR_ARG_T& argc, char** argv, int max_args, char* string) +add_to_argv (int& argc, char** argv, int max_args, char* string) { char indouble = 0; size_t previous = 0; @@ -4956,8 +5258,6 @@ add_to_argv (ACE_VX_USR_ARG_T& argc, char** argv, int max_args, char* string) } } -#if !defined (ACE_LACKS_VA_FUNCTIONS) - // This global function can be used from the VxWorks shell to pass // arguments to a C main () function. // @@ -4968,10 +5268,10 @@ int spae (FUNCPTR entry, ...) { static int const WINDSH_ARGS = 10; - static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128; + static int const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast ("ace_main"), 0 }; va_list pvar; - ACE_VX_USR_ARG_T argc = 1; + int argc = 1; // Peel off arguments to spa () and put into argv. va_arg () isn't // necessarily supposed to return 0 when done, though since the @@ -4993,19 +5293,19 @@ spae (FUNCPTR entry, ...) // The hard-coded options are what ::sp () uses, except for the // larger stack size (instead of ::sp ()'s 20000). - ACE_VX_TASK_ID const ret = ::taskSpawn (argv[0], // task name - 100, // task priority - VX_FP_TASK, // task options - ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size - entry, // entry point - argc, // first argument to main () - (ACE_VX_USR_ARG_T) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0, 0); + int const ret = ::taskSpawn (argv[0], // task name + 100, // task priority + VX_FP_TASK, // task options + ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size + entry, // entry point + argc, // first argument to main () + (int) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0, 0); va_end (pvar); // ::taskSpawn () returns the taskID on success: return 0 instead if // successful - return ret > 0 ? 0 : -1; + return ret > 0 ? 0 : ret; } // This global function can be used from the VxWorks shell to pass @@ -5022,10 +5322,10 @@ int spaef (FUNCPTR entry, ...) { static int const WINDSH_ARGS = 10; - static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128; + static int const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast ("ace_main"), 0 }; va_list pvar; - ACE_VX_USR_ARG_T argc = 1; + int argc = 1; // Peel off arguments to spa () and put into argv. va_arg () isn't // necessarily supposed to return 0 when done, though since the @@ -5052,7 +5352,6 @@ spaef (FUNCPTR entry, ...) // Return the return value of the invoked ace_main routine. return ret; } -#endif /* !ACE_LACKS_VA_FUNCTIONS */ // This global function can be used from the VxWorks shell to pass // arguments to and run a main () function (i.e. ace_main). @@ -5073,11 +5372,11 @@ _vx_call_entry(FUNCPTR entry, int argc, char* argv[]) } int -vx_execae (FUNCPTR entry, char* arg, int prio, int opt, size_t stacksz, ...) +vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...) { - static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128; + static int const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast ("ace_main"), 0 }; - ACE_VX_USR_ARG_T argc = 1; + int argc = 1; // Peel off arguments to run_main () and put into argv. if (arg) @@ -5087,22 +5386,22 @@ vx_execae (FUNCPTR entry, char* arg, int prio, int opt, size_t stacksz, ...) // fill unused argv slots with 0 to get rid of leftovers // from previous invocations - for (ACE_VX_USR_ARG_T i = argc; i < ACE_MAX_ARGS; ++i) + for (int i = argc; i < ACE_MAX_ARGS; ++i) argv[i] = 0; // The hard-coded options are what ::sp () uses, except for the // larger stack size (instead of ::sp ()'s 20000). - ACE_VX_TASK_ID const ret = ::taskSpawn (argv[0], // task name - prio==0 ? 100 : prio, // task priority - opt==0 ? VX_FP_TASK : opt, // task options - stacksz==0 ? ACE_NEEDS_HUGE_THREAD_STACKSIZE : stacksz, // stack size - (FUNCPTR)_vx_call_entry, // entrypoint caller - (ACE_VX_USR_ARG_T)entry, // entry point - argc, // first argument to main () - (ACE_VX_USR_ARG_T) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0); + int const ret = ::taskSpawn (argv[0], // task name + prio==0 ? 100 : prio, // task priority + opt==0 ? VX_FP_TASK : opt, // task options + stacksz==0 ? ACE_NEEDS_HUGE_THREAD_STACKSIZE : stacksz, // stack size + (FUNCPTR)_vx_call_entry, // entrypoint caller + (int)entry, // entry point + argc, // first argument to main () + (int) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0); - if (ret == ACE_VX_TASK_ID_ERROR) + if (ret == ERROR) return 255; while( ret > 0 && ::taskIdVerify (ret) != ERROR ) diff --git a/dep/acelite/ace/OS_NS_Thread.h b/dep/acelite/ace/OS_NS_Thread.h index f932a701c..6103168c4 100644 --- a/dep/acelite/ace/OS_NS_Thread.h +++ b/dep/acelite/ace/OS_NS_Thread.h @@ -4,7 +4,9 @@ /** * @file OS_NS_Thread.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_Thread.h 97911 2014-10-07 21:58:25Z shuston $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -160,7 +162,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL # elif defined (ACE_VXWORKS) # include /**/ // for sysClkRateGet() -# include /**/ # if !defined (__RTP__) # include /**/ # include /**/ @@ -229,8 +230,8 @@ typedef struct char *name_; } ACE_sema_t; # endif /* !ACE_HAS_POSIX_SEM */ -typedef ACE_VX_TASK_ID ACE_thread_t; -typedef ACE_VX_TASK_ID ACE_hthread_t; +typedef int ACE_thread_t; +typedef int ACE_hthread_t; // Key type: the ACE TSS emulation requires the key type be unsigned, // for efficiency. (Current POSIX and Solaris TSS implementations also // use u_int, so the ACE TSS emulation is compatible with them.) @@ -400,7 +401,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # endif /* ACE_HAS_WTHREADS_CONDITION_VARIABLE || ACE_LACKS_COND_T */ -# if defined (ACE_LACKS_RWLOCK_T) +# if defined (ACE_LACKS_RWLOCK_T) && !defined (ACE_HAS_PTHREADS_UNIX98_EXT) ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -705,7 +706,7 @@ public: ACE_Thread_ID (const ACE_Thread_ID &id); /// Assignment operator - ACE_Thread_ID& operator= (const ACE_Thread_ID &id); + ACE_Thread_ID& operator= (const ACE_Thread_ID&id); /// Get the thread id. ACE_thread_t id (void) const; @@ -720,14 +721,7 @@ public: void handle (ACE_hthread_t); // Create a string representation of the thread id. - void to_string (char *thr_string, size_t thr_string_len) const; - - // Create a string representation of the thread id. - template - void to_string (char (&thr_string)[N]) const - { - this->to_string (thr_string, N); - } + void to_string (char *thr_string) const; /// Equality operator. bool operator== (const ACE_Thread_ID &) const; @@ -810,7 +804,7 @@ class ACE_TSS_Keys; class ACE_Export ACE_TSS_Emulation { public: - typedef void (*ACE_TSS_DESTRUCTOR)(void *value); + typedef void (*ACE_TSS_DESTRUCTOR)(void *value) /* throw () */; /// Maximum number of TSS keys allowed over the life of the program. enum { ACE_TSS_THREAD_KEYS_MAX = ACE_DEFAULT_THREAD_KEYS }; @@ -1006,8 +1000,6 @@ private: class ACE_TSS_Keys { public: - ACE_ALLOC_HOOK_DECLARE; - /// Default constructor, to initialize all bits to zero (unused). ACE_TSS_Keys (void); @@ -1264,7 +1256,7 @@ namespace ACE_OS { ACE_Time_Value *timeout, int use_absolute_time = 1); - ACE_NAMESPACE_INLINE_FUNCTION + extern ACE_Export int event_wait (ACE_event_t *event); //@} @@ -1498,12 +1490,6 @@ namespace ACE_OS { LPSECURITY_ATTRIBUTES sa = 0); # endif /* ACE_HAS_WCHAR */ - ACE_NAMESPACE_INLINE_FUNCTION - void sema_avoid_unlink (ACE_sema_t *s, bool avoid_unlink); - - ACE_NAMESPACE_INLINE_FUNCTION - int sema_unlink (const char *name); - ACE_NAMESPACE_INLINE_FUNCTION int sema_post (ACE_sema_t *s); @@ -1850,65 +1836,57 @@ namespace ACE_OS { #endif /* ACE_USES_WCHAR */ } /* namespace ACE_OS */ +ACE_END_VERSIONED_NAMESPACE_DECL + #if !defined (ACE_WIN32) -/// Implementation details of Event emulation on Unix, may be in shared memory -struct ACE_eventdata_t +extern "C" { - /// Protect critical section. - ACE_mutex_t lock_; - - /// Keeps track of waiters. - ACE_cond_t condition_; - - /// Object type. - int type_; - - /// Specifies if this is an auto- or manual-reset event. - int manual_reset_; - - /// "True" if signaled. - int is_signaled_; - - /// Special bool for auto_events alone - /** - * The semantics of auto events forces us to introduce this extra - * variable to ensure that the thread is not woken up - * spuriously. Please see event_timedwait () to see - * how this is used for auto_events. - * @todo This is a hack that needs revisiting after x.4 - */ - bool auto_event_signaled_; - - /// Number of waiting threads. - unsigned long waiting_threads_; - - /// Signal count - unsigned long signal_count_; - - ACE_ALLOC_HOOK_DECLARE; -}; - -# if !defined ACE_USES_FIFO_SEM \ - && !(defined ACE_HAS_POSIX_SEM && defined ACE_HAS_POSIX_SEM_TIMEOUT \ - && !defined ACE_LACKS_NAMED_POSIX_SEM) -# define ACE_EVENT_NO_FIFO_SEM + typedef struct + { +#if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && \ + (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + /// Protect critical section. + ACE_mutex_t lock_; + /// Keeps track of waiters. + ACE_cond_t condition_; +#else +# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ + (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) + /// Protect critical section. + ACE_mutex_t lock_; # endif +#endif -# if (defined ACE_HAS_PTHREADS && defined _POSIX_THREAD_PROCESS_SHARED \ - && !defined ACE_LACKS_MUTEXATTR_PSHARED) || defined ACE_EVENT_NO_FIFO_SEM -# define ACE_EVENT_USE_MUTEX_PSHARED 1 -# else -# define ACE_EVENT_USE_MUTEX_PSHARED 0 -# endif + /// Object type. + int type_; -# if (defined ACE_HAS_PTHREADS && defined _POSIX_THREAD_PROCESS_SHARED \ - && !defined ACE_LACKS_CONDATTR_PSHARED \ - && !defined ACE_LACKS_MUTEXATTR_PSHARED) || defined ACE_EVENT_NO_FIFO_SEM -# define ACE_EVENT_USE_COND_PSHARED 1 -# else -# define ACE_EVENT_USE_COND_PSHARED 0 -# endif + /// Specifies if this is an auto- or manual-reset event. + int manual_reset_; + + /// "True" if signaled. + int is_signaled_; + + /// Special bool for auto_events alone + /** + * The semantics of auto events forces us to introduce this extra + * variable to ensure that the thread is not woken up + * spuriously. Please see event_wait and event_timedwait () to see + * how this is used for auto_events. + * @todo This is a hack that needs revisiting after x.4 + */ + bool auto_event_signaled_; + + /// Number of waiting threads. + unsigned long waiting_threads_; + + /// Signal count + unsigned long signal_count_; + } ACE_eventdata_t; +} + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** * @class ACE_event_t @@ -1917,52 +1895,45 @@ struct ACE_eventdata_t */ class ACE_Export ACE_event_t { - friend int ACE_OS::event_init (ACE_event_t *, int, int, int, const char *, - void *, int); - friend int ACE_OS::event_init (ACE_event_t *, int, ACE_condattr_t *, int, - int, const char *, void *, int); - friend int ACE_OS::event_destroy (ACE_event_t *); - friend int ACE_OS::event_wait (ACE_event_t *); - friend int ACE_OS::event_timedwait (ACE_event_t *, ACE_Time_Value *, int); - friend int ACE_OS::event_signal (ACE_event_t *); - friend int ACE_OS::event_pulse (ACE_event_t *); - friend int ACE_OS::event_reset (ACE_event_t *); + friend int ACE_OS::event_init(ACE_event_t*, int, int, int, const char*, void*,int); + friend int ACE_OS::event_init(ACE_event_t*, int, ACE_condattr_t*, int, int, const char*, void*,int); + friend int ACE_OS::event_destroy(ACE_event_t*); + friend int ACE_OS::event_wait(ACE_event_t*); + friend int ACE_OS::event_timedwait(ACE_event_t*, ACE_Time_Value*, int); + friend int ACE_OS::event_signal(ACE_event_t*); + friend int ACE_OS::event_pulse(ACE_event_t*); + friend int ACE_OS::event_reset(ACE_event_t*); public: /// Constructor initializing all pointer fields to null ACE_event_t (void); -private: - /// Lock the internal mutex/semaphore - int lock (void); - - /// Unlock the internal mutex/semaphore - int unlock (void); - - /// Use the internal semaphore or condition variable to unblock one thread - int wake_one (void); +protected: /// Event name if process shared. - char *name_; + char* name_; /// Event data - ACE_eventdata_t *eventdata_; + ACE_eventdata_t* eventdata_; -# if !ACE_EVENT_USE_COND_PSHARED +#if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \ + (defined (ACE_USES_FIFO_SEM) || \ + (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM))) /// Keeps track of waiters. ACE_sema_t semaphore_; -# endif -# if !ACE_EVENT_USE_MUTEX_PSHARED - /// Protect critical section. +# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_MUTEXATTR_PSHARED)) && \ + (defined (ACE_USES_FIFO_SEM) || (defined (ACE_HAS_POSIX_SEM) && !defined (ACE_LACKS_NAMED_POSIX_SEM))) + /// Protect critical section. ACE_sema_t lock_; # endif +#endif }; -#endif /* ACE_WIN32 */ - ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_WIN32 */ + #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_Thread.inl b/dep/acelite/ace/OS_NS_Thread.inl index d4023d057..fad40fd24 100644 --- a/dep/acelite/ace/OS_NS_Thread.inl +++ b/dep/acelite/ace/OS_NS_Thread.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_Thread.inl 97911 2014-10-07 21:58:25Z shuston $ + #include "ace/OS_NS_macros.h" // for timespec_t, perhaps move it to os_time.h #include "ace/Time_Value.h" @@ -20,10 +23,6 @@ # include /**/ #endif /* ACE_HAS_PRIOCNTL */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL /*****************************************************************************/ @@ -485,12 +484,6 @@ ACE_OS::mutex_lock (ACE_mutex_t *m, return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout); } -ACE_INLINE int -ACE_OS::event_wait (ACE_event_t *event) -{ - return ACE_OS::event_timedwait (event, 0); -} - ACE_INLINE int ACE_OS::event_init (ACE_event_t *event, int manual_reset, @@ -760,10 +753,12 @@ ACE_OS::recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m) #if defined (ACE_HAS_RECURSIVE_MUTEXES) return ACE_OS::thread_mutex_destroy (m); #else - if (ACE_OS::cond_destroy (&m->lock_available_) == -1 - || ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1) + if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1) return -1; - return 0; + else if (ACE_OS::cond_destroy (&m->lock_available_) == -1) + return -1; + else + return 0; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); @@ -1037,7 +1032,7 @@ ACE_OS::rw_rdlock (ACE_rwlock_t *rw) { ACE_OS_TRACE ("ACE_OS::rw_rdlock"); #if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw), @@ -1088,7 +1083,7 @@ ACE_OS::rw_tryrdlock (ACE_rwlock_t *rw) { ACE_OS_TRACE ("ACE_OS::rw_tryrdlock"); #if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw), @@ -1131,7 +1126,7 @@ ACE_OS::rw_trywrlock (ACE_rwlock_t *rw) { ACE_OS_TRACE ("ACE_OS::rw_trywrlock"); #if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw), @@ -1180,7 +1175,9 @@ ACE_OS::rw_trywrlock_upgrade (ACE_rwlock_t *rw) { ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade"); #if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) && !defined (ACE_LACKS_RWLOCK_T) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + // This will probably result in -1, EDEADLK, at least on HP-UX, but let it + // go - it's a more descriptive error than ENOTSUP. int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw), result), @@ -1252,7 +1249,7 @@ ACE_OS::rw_unlock (ACE_rwlock_t *rw) { ACE_OS_TRACE ("ACE_OS::rw_unlock"); #if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw), @@ -1311,7 +1308,7 @@ ACE_OS::rw_wrlock (ACE_rwlock_t *rw) { ACE_OS_TRACE ("ACE_OS::rw_wrlock"); #if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw), @@ -1364,7 +1361,7 @@ ACE_OS::rwlock_destroy (ACE_rwlock_t *rw) { ACE_OS_TRACE ("ACE_OS::rwlock_destroy"); #if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw), @@ -1386,7 +1383,8 @@ ACE_OS::rwlock_destroy (ACE_rwlock_t *rw) #endif /* ACE_HAS_THREADS */ } -#if defined (ACE_HAS_THREADS) && !defined (ACE_LACKS_RWLOCK_T) +#if defined (ACE_HAS_THREADS) && (!defined (ACE_LACKS_RWLOCK_T) || \ + defined (ACE_HAS_PTHREADS_UNIX98_EXT)) ACE_INLINE int ACE_OS::rwlock_init (ACE_rwlock_t *rw, int type, @@ -1420,101 +1418,84 @@ ACE_OS::rwlock_init (ACE_rwlock_t *rw, ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_init (rw, type, arg), result), int, -1); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ } -#endif /* ACE_HAS_THREADS && !defined (ACE_LACKS_RWLOCK_T) */ +#endif /* ACE_HAS THREADS && !defined (ACE_LACKS_RWLOCK_T) */ ACE_INLINE int ACE_OS::sema_destroy (ACE_sema_t *s) { ACE_OS_TRACE ("ACE_OS::sema_destroy"); -#if defined (ACE_HAS_POSIX_SEM) - int result = 0; -# if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) +# if defined (ACE_HAS_POSIX_SEM) + int result; +# if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) ACE_OS::mutex_destroy (&s->lock_); ACE_OS::cond_destroy (&s->count_nonzero_); -# endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */ -# if defined (ACE_LACKS_NAMED_POSIX_SEM) +# endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */ +# if defined (ACE_LACKS_NAMED_POSIX_SEM) if (s->name_) { // Only destroy the semaphore if we're the ones who // initialized it. -# if !defined (ACE_LACKS_SEM_DESTROY) ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result); -# endif /* ACE_LACKS_SEM_DESTROY */ ACE_OS::shm_unlink (s->name_); delete s->name_; return result; } -# else +# else if (s->name_) { - if (!s->avoid_unlink_) - ACE_OS::sema_unlink (s->name_); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) s->name_); -#else + ACE_OSCALL (::sem_unlink (s->name_), int, -1, result); ACE_OS::free ((void *) s->name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1); } -# endif /* ACE_LACKS_NAMED_POSIX_SEM */ +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ else { -# if !defined (ACE_LACKS_UNNAMED_SEMAPHORE) && !defined (ACE_LACKS_SEM_DESTROY) ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result); -# endif /* !ACE_LACKS_UNNAMED_SEMAPHORE && !ACE_LACKS_SEM_DESTROY */ -# if defined (ACE_LACKS_NAMED_POSIX_SEM) +# if defined (ACE_LACKS_NAMED_POSIX_SEM) if (s->new_sema_) -# endif /* ACE_LACKS_NAMED_POSIX_SEM */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(s->sema_); -#else +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ delete s->sema_; -#endif /* ACE_HAS_ALLOC_HOOKS */ s->sema_ = 0; return result; } -#elif defined (ACE_USES_FIFO_SEM) +# elif defined (ACE_USES_FIFO_SEM) int r0 = 0; if (s->name_) { r0 = ACE_OS::unlink (s->name_); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ((void *) s->name_); -#else - ACE_OS::free ((void *) s->name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_OS::free (s->name_); s->name_ = 0; } int r1 = ACE_OS::close (s->fd_[0]); /* ignore error */ int r2 = ACE_OS::close (s->fd_[1]); /* ignore error */ return r0 != 0 || r1 != 0 || r2 != 0 ? -1 : 0; -#elif defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) +# elif defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), result), int, -1); -# elif defined (ACE_HAS_PTHREADS) +# elif defined (ACE_HAS_PTHREADS) int r1 = ACE_OS::mutex_destroy (&s->lock_); int r2 = ACE_OS::cond_destroy (&s->count_nonzero_); return r1 != 0 || r2 != 0 ? -1 : 0; -# elif defined (ACE_HAS_WTHREADS) -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) +# elif defined (ACE_HAS_WTHREADS) +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1); -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ // Free up underlying objects of the simulated semaphore. int const r1 = ACE_OS::thread_mutex_destroy (&s->lock_); int const r2 = ACE_OS::event_destroy (&s->count_nonzero_); return r1 != 0 || r2 != 0 ? -1 : 0; -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_VXWORKS) +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_VXWORKS) int result; ACE_OSCALL (::semDelete (s->sema_), int, -1, result); s->sema_ = 0; return result; -# endif /* ACE_HAS_STHREADS */ -#else +# endif /* ACE_HAS_STHREADS */ +# else ACE_UNUSED_ARG (s); ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_POSIX_SEM */ +# endif /* ACE_HAS_POSIX_SEM */ } // NOTE: The previous four function definitions must appear before @@ -1549,7 +1530,6 @@ ACE_OS::sema_init (ACE_sema_t *s, ACE_UNUSED_ARG (sa); s->name_ = 0; - s->avoid_unlink_ = false; # if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) ACE_UNUSED_ARG (arg); ACE_UNUSED_ARG (attributes); @@ -1559,7 +1539,7 @@ ACE_OS::sema_init (ACE_sema_t *s, if (ACE_OS::mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *) arg) == 0 && (attributes == 0 ? - ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) : + ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) : ACE_OS::cond_init (&s->count_nonzero_, *attributes, name, arg)) == 0 && ACE_OS::mutex_lock (&s->lock_) == 0) { @@ -1663,26 +1643,15 @@ ACE_OS::sema_init (ACE_sema_t *s, # endif /* ACE_LACKS_NAMED_POSIX_SEM */ else { -# if defined (ACE_LACKS_UNNAMED_SEMAPHORE) - ACE_NOTSUP_RETURN (-1); -# else -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (s->sema_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(sem_t))), - -1); -#else ACE_NEW_RETURN (s->sema_, sem_t, -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ - -# if defined (ACE_LACKS_NAMED_POSIX_SEM) +# if defined (ACE_LACKS_NAMED_POSIX_SEM) s->new_sema_ = true; -# endif /* ACE_LACKS_NAMED_POSIX_SEM */ +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ ACE_OSCALL_RETURN (::sem_init (s->sema_, type != USYNC_THREAD, count), int, -1); -# endif /* ACE_LACKS_UNNAMED_SEMAPHORE */ } #elif defined (ACE_USES_FIFO_SEM) @@ -1787,7 +1756,7 @@ ACE_OS::sema_init (ACE_sema_t *s, if (ACE_OS::mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *) arg) == 0 && (attributes == 0 ? - ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) : + ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) : ACE_OS::cond_init (&s->count_nonzero_, *attributes, name, arg)) == 0 && ACE_OS::mutex_lock (&s->lock_) == 0) { @@ -1974,28 +1943,6 @@ ACE_OS::sema_init (ACE_sema_t *s, } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE void -ACE_OS::sema_avoid_unlink (ACE_sema_t *s, bool avoid_unlink) -{ -#if defined (ACE_HAS_POSIX_SEM) - s->avoid_unlink_ = avoid_unlink; -#else - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (avoid_unlink); -#endif -} - -ACE_INLINE int -ACE_OS::sema_unlink (const char *name) -{ -#if defined (ACE_HAS_POSIX_SEM) && !defined (ACE_LACKS_SEM_UNLINK) - ACE_OSCALL_RETURN (::sem_unlink (name), int, -1); -#else - ACE_UNUSED_ARG (name); - ACE_NOTSUP_RETURN (-1); -#endif -} - ACE_INLINE int ACE_OS::sema_post (ACE_sema_t *s) { @@ -2989,15 +2936,9 @@ ACE_OS::thr_join (ACE_hthread_t thr_handle, ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result), int, -1); # elif defined (ACE_HAS_PTHREADS) -# if defined (ACE_LACKS_PTHREAD_JOIN) - ACE_UNUSED_ARG (thr_handle); - ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); -# else int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result), int, -1); -# endif /* ACE_LACKS_PTHREAD_JOIN */ # elif defined (ACE_HAS_WTHREADS) // Waiting on the calling thread will deadlock, so try to avoid that. The // direct access to the needed info (GetThreadId) was added at Vista. @@ -3053,17 +2994,10 @@ ACE_OS::thr_join (ACE_thread_t waiter_id, ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result), int, -1); # elif defined (ACE_HAS_PTHREADS) -# if defined (ACE_LACKS_PTHREAD_JOIN) - ACE_UNUSED_ARG (waiter_id); - ACE_UNUSED_ARG (thr_id); - ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); -# else ACE_UNUSED_ARG (thr_id); int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result), int, -1); -# endif /* ACE_LACKS_PTHREAD_JOIN */ # elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (waiter_id); ACE_UNUSED_ARG (thr_id); @@ -3163,24 +3097,31 @@ ACE_INLINE ssize_t ACE_OS::thr_id (char buffer[], size_t buffer_length) { #if defined (ACE_WIN32) +#if defined (ACE_HAS_SNPRINTF) return ACE_OS::snprintf (buffer, buffer_length, "%u", static_cast (ACE_OS::thr_self ())); -#else /* ACE_WIN32 */ +#else + ACE_UNUSED_ARG (buffer_length); + return ACE_OS::sprintf (buffer, + "%u", + static_cast (ACE_OS::thr_self ())); +#endif /* ACE_HAS_SNPRINTF */ +#else ACE_hthread_t t_id; ACE_OS::thr_self (t_id); -#if defined(ACE_HAS_OPAQUE_PTHREAD_T) - return ACE_OS::snprintf (buffer, - buffer_length, - "%s", - ""); -#else /* ACE_HAS_OPAQUE_PTHREAD_T */ +#if defined (ACE_HAS_SNPRINTF) return ACE_OS::snprintf (buffer, buffer_length, "%lu", (unsigned long) t_id); -#endif /* ACE_HAS_OPAQUE_PTHREAD_T */ +#else + ACE_UNUSED_ARG (buffer_length); + return ACE_OS::sprintf (buffer, + "%lu", + (unsigned long) t_id); +#endif /* ACE_HAS_SNPRINTF */ #endif /* WIN32 */ } @@ -3460,18 +3401,8 @@ ACE_OS::thr_sigsetmask (int how, # if !defined (ACE_LACKS_PTHREAD_SIGMASK) int result; //FUZZ: disable check_for_lack_ACE_OS -# if defined (ACE_HAS_NONCONST_PTHREAD_SIGMASK) - sigset_t *ncnsm = const_cast(nsm); - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, ncnsm, osm), - result), - int, - -1); -# else ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm), - result), - int, - -1); -# endif /* ACE_HAS_NONCONST__PTHREAD_SIGMASK */ + result), int, -1); //FUZZ: enable check_for_lack_ACE_OS # endif /* !ACE_LACKS_PTHREAD_SIGMASK */ @@ -3801,6 +3732,13 @@ ACE_OS::thread_mutex_unlock (ACE_thread_mutex_t *m) /*****************************************************************************/ +# if defined (ACE_IS_SPLITTING) +# define ACE_SPECIAL_INLINE +# else +# define ACE_SPECIAL_INLINE ACE_INLINE +//# define ACE_SPECIAL_INLINE inline +# endif + #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) ACE_INLINE diff --git a/dep/acelite/ace/OS_NS_arpa_inet.cpp b/dep/acelite/ace/OS_NS_arpa_inet.cpp index 0cc14c302..d585cc69e 100644 --- a/dep/acelite/ace/OS_NS_arpa_inet.cpp +++ b/dep/acelite/ace/OS_NS_arpa_inet.cpp @@ -1,14 +1,12 @@ // -*- C++ -*- +// $Id: OS_NS_arpa_inet.cpp 95534 2012-02-17 23:19:33Z mitza $ + #include "ace/OS_NS_arpa_inet.h" #if !defined (ACE_HAS_INLINED_OSCALLS) # include "ace/OS_NS_arpa_inet.inl" #endif /* ACE_HAS_INLINED_OSCALLS */ -#include "ace/Basic_Types.h" - -#include - ACE_BEGIN_VERSIONED_NAMESPACE_DECL int @@ -23,54 +21,6 @@ ACE_OS::inet_aton (const char *host_name, struct in_addr *addr) if (host_name == 0 || host_name[0] == '\0') host_name = " "; # endif /* ACE_WIN32 */ - -# if defined (ACE_LACKS_INET_ADDR) - if (!host_name) - return 0; - ACE_UINT32 ip = 0; - int part = 0; - for (const char *dot; *host_name; host_name = *dot ? dot + 1 : dot, ++part) - { - if (part > 3) - return 0; - dot = ACE_OS::strchr (host_name, '.'); - if (!dot) - dot = host_name + ACE_OS::strlen (host_name); - char *last; - const unsigned long n = std::strtoul (host_name, &last, 0); - if (last != dot) - return 0; - if (!*dot) - switch (part) - { - case 0: -# if ACE_SIZEOF_LONG > 4 - if (n > 0xffffffff) - return 0; -# endif - ip = static_cast (n); - continue; - case 1: - if (n > 0xffffff) - return 0; - ip <<= 24; - ip |= n; - continue; - case 2: - if (n > 0xffff) - return 0; - ip <<= 16; - ip |= n; - continue; - } - if (n > 0xff) - return 0; - ip <<= 8; - ip |= n; - } - addr->s_addr = ACE_HTONL (ip); - return 1; -# else unsigned long ip_addr = ACE_OS::inet_addr (host_name); if (ip_addr == INADDR_NONE @@ -84,8 +34,7 @@ ACE_OS::inet_aton (const char *host_name, struct in_addr *addr) addr->s_addr = ip_addr; // Network byte ordered return 1; } -# endif // ACE_LACKS_INET_ADDR -#elif defined (ACE_VXWORKS) +#elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x690) // inet_aton() returns OK (0) on success and ERROR (-1) on failure. // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026 ::errnoSet(0); diff --git a/dep/acelite/ace/OS_NS_arpa_inet.h b/dep/acelite/ace/OS_NS_arpa_inet.h index caf7eb6c4..fc8e660ac 100644 --- a/dep/acelite/ace/OS_NS_arpa_inet.h +++ b/dep/acelite/ace/OS_NS_arpa_inet.h @@ -4,7 +4,9 @@ /** * @file OS_NS_arpa_inet.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_arpa_inet.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_arpa_inet.inl b/dep/acelite/ace/OS_NS_arpa_inet.inl index 3860140cb..4a5c0443e 100644 --- a/dep/acelite/ace/OS_NS_arpa_inet.inl +++ b/dep/acelite/ace/OS_NS_arpa_inet.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_arpa_inet.inl 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_string.h" #include "ace/OS_NS_errno.h" #include "ace/OS_NS_stdio.h" @@ -36,29 +38,34 @@ ACE_OS::inet_ntop (int family, const void *addrptr, char *strptr, size_t len) { ACE_OS_TRACE ("ACE_OS::inet_ntop"); -#if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_NTOP -# if defined (ACE_HAS_NONCONST_INET_NTOP) - ACE_OSCALL_RETURN (::inet_ntop (family, const_cast (addrptr), strptr, len), const char *, 0); -# else +#if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0); -# endif #else + const u_char *p = reinterpret_cast (addrptr); if (family == AF_INET) { - const u_char *const p = reinterpret_cast (addrptr); - if (ACE_OS::snprintf (strptr, len, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]) - > static_cast (len)) + char temp[INET_ADDRSTRLEN]; + + // Stevens uses snprintf() in his implementation but snprintf() + // doesn't appear to be very portable. For now, hope that using + // sprintf() will not cause any string/memory overrun problems. + ACE_OS::sprintf (temp, + "%d.%d.%d.%d", + p[0], p[1], p[2], p[3]); + + if (ACE_OS::strlen (temp) >= len) { errno = ENOSPC; return 0; // Failure } + + ACE_OS::strcpy (strptr, temp); return strptr; } - errno = EAFNOSUPPORT; - return 0; -#endif + ACE_NOTSUP_RETURN(0); +#endif /* ACE_HAS_IPV6 */ } ACE_INLINE int @@ -66,21 +73,24 @@ ACE_OS::inet_pton (int family, const char *strptr, void *addrptr) { ACE_OS_TRACE ("ACE_OS::inet_pton"); -#if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_PTON +#if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1); #else - if (family == AF_INET) { - if (ACE_OS::inet_aton (strptr, static_cast (addrptr))) - return 1; // Success + struct in_addr in_val; + + if (ACE_OS::inet_aton (strptr, &in_val)) + { + ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr)); + return 1; // Success + } return 0; // Input is not a valid presentation format } - errno = EAFNOSUPPORT; - return 0; -#endif + ACE_NOTSUP_RETURN(-1); +#endif /* ACE_HAS_IPV6 */ } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_ctype.cpp b/dep/acelite/ace/OS_NS_ctype.cpp index c97a1f026..614d0ae36 100644 --- a/dep/acelite/ace/OS_NS_ctype.cpp +++ b/dep/acelite/ace/OS_NS_ctype.cpp @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_ctype.cpp 91683 2010-09-09 09:07:49Z johnnyw $ + #include "ace/OS_NS_ctype.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_ctype.h b/dep/acelite/ace/OS_NS_ctype.h index 702b9127a..f87a0c6cc 100644 --- a/dep/acelite/ace/OS_NS_ctype.h +++ b/dep/acelite/ace/OS_NS_ctype.h @@ -4,7 +4,9 @@ /** * @file OS_NS_ctype.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_ctype.h 83891 2008-11-28 11:01:50Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_ctype.inl b/dep/acelite/ace/OS_NS_ctype.inl index 8d53061a8..4d736488b 100644 --- a/dep/acelite/ace/OS_NS_ctype.inl +++ b/dep/acelite/ace/OS_NS_ctype.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_ctype.inl 85785 2009-06-24 18:20:42Z mitza $ + #if defined (ACE_LACKS_ISCTYPE) #include "ace/OS_NS_errno.h" #endif @@ -31,11 +34,7 @@ ACE_OS::ace_isascii (ACE_TCHAR c) #if defined (ACE_USES_WCHAR) # if defined (ACE_LACKS_ISWASCII) if (c < 256) -# if defined (ACE_LACKS_ISASCII) - return (static_cast(c) <= 0x7F); -# else - return isascii ((unsigned char) c); -# endif /* ACE_LACKS_ISASCII */ + return isascii (static_cast (c)); else return c; # else diff --git a/dep/acelite/ace/OS_NS_dirent.cpp b/dep/acelite/ace/OS_NS_dirent.cpp index 182667c72..a742b5a9e 100644 --- a/dep/acelite/ace/OS_NS_dirent.cpp +++ b/dep/acelite/ace/OS_NS_dirent.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_dirent.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/OS_NS_dirent.h" @@ -11,10 +13,6 @@ #include "ace/Log_Category.h" #include "ace/OS_NS_stdlib.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_LACKS_CLOSEDIR) @@ -193,25 +191,13 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname, if (nfiles == arena_size) { ACE_DIRENT **newv = 0; - int new_arena_size; if (arena_size == 0) - new_arena_size = 10; + arena_size = 10; else - new_arena_size = arena_size * 2; + arena_size *= 2; -#if defined (ACE_HAS_ALLOC_HOOKS) - newv = (ACE_DIRENT **) ACE_Allocator::instance()->malloc (new_arena_size * sizeof (ACE_DIRENT *)); - if (newv && vector) - { - ACE_OS::memcpy (newv, vector, arena_size * sizeof (ACE_DIRENT *)); - } -#else newv = (ACE_DIRENT **) ACE_OS::realloc (vector, - new_arena_size * sizeof (ACE_DIRENT *)); -#endif /* ACE_HAS_ALLOC_HOOKS */ - - arena_size = new_arena_size; - + arena_size * sizeof (ACE_DIRENT *)); if (newv == 0) { fail = 1; @@ -221,20 +207,12 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname, } #if defined (ACE_LACKS_STRUCT_DIR) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_Allocator::instance()->malloc (sizeof (ACE_DIRENT)); -#else ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (sizeof (ACE_DIRENT)); -#endif /* ACE_HAS_ALLOC_HOOKS */ #else size_t dsize = sizeof (ACE_DIRENT) + ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_Allocator::instance()->malloc (dsize); -#else ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (dsize); -#endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* ACE_LACKS_STRUCT_DIR */ if (newdp == 0) @@ -244,20 +222,13 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname, } #if defined (ACE_LACKS_STRUCT_DIR) -#if defined (ACE_HAS_ALLOC_HOOKS) - newdp->d_name = (ACE_TCHAR*) ACE_Allocator::instance()->malloc ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); -#else - newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); -#endif /* ACE_HAS_ALLOC_HOOKS */ + newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc ( + (ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); if (newdp->d_name == 0) { fail = 1; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (newdp); -#else ACE_OS::free (newdp); -#endif /* ACE_HAS_ALLOC_HOOKS */ break; } @@ -278,23 +249,11 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname, while (vector && nfiles-- > 0) { #if defined (ACE_LACKS_STRUCT_DIR) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (vector[nfiles]->d_name); -#else ACE_OS::free (vector[nfiles]->d_name); -#endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* ACE_LACKS_STRUCT_DIR */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (vector[nfiles]); -#else ACE_OS::free (vector[nfiles]); -#endif /* ACE_HAS_ALLOC_HOOKS */ } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (vector); -#else ACE_OS::free (vector); -#endif /* ACE_HAS_ALLOC_HOOKS */ return -1; } diff --git a/dep/acelite/ace/OS_NS_dirent.h b/dep/acelite/ace/OS_NS_dirent.h index 8a35cd9f9..caf72b16e 100644 --- a/dep/acelite/ace/OS_NS_dirent.h +++ b/dep/acelite/ace/OS_NS_dirent.h @@ -4,7 +4,9 @@ /** * @file OS_NS_dirent.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_dirent.h 85435 2009-05-25 18:52:50Z coryan $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -57,6 +59,7 @@ extern "C" { * as macros on some platforms. This way macro definitions will * be usable later as there is no way to save the macro definition * using the pre-processor. + * */ #if !defined (ACE_LACKS_REWINDDIR) diff --git a/dep/acelite/ace/OS_NS_dirent.inl b/dep/acelite/ace/OS_NS_dirent.inl index 6e31c21a1..2f73e091a 100644 --- a/dep/acelite/ace/OS_NS_dirent.inl +++ b/dep/acelite/ace/OS_NS_dirent.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_dirent.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_Memory.h" #if defined (ACE_LACKS_ALPHASORT) diff --git a/dep/acelite/ace/OS_NS_dlfcn.cpp b/dep/acelite/ace/OS_NS_dlfcn.cpp index e3d1c96ad..5ac764f25 100644 --- a/dep/acelite/ace/OS_NS_dlfcn.cpp +++ b/dep/acelite/ace/OS_NS_dlfcn.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_dlfcn.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/OS_NS_dlfcn.h" diff --git a/dep/acelite/ace/OS_NS_dlfcn.h b/dep/acelite/ace/OS_NS_dlfcn.h index b5babec2d..45cf625dc 100644 --- a/dep/acelite/ace/OS_NS_dlfcn.h +++ b/dep/acelite/ace/OS_NS_dlfcn.h @@ -4,7 +4,9 @@ /** * @file OS_NS_dlfcn.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_dlfcn.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_dlfcn.inl b/dep/acelite/ace/OS_NS_dlfcn.inl index 2147def7f..3df2c6f0a 100644 --- a/dep/acelite/ace/OS_NS_dlfcn.inl +++ b/dep/acelite/ace/OS_NS_dlfcn.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_dlfcn.inl 97911 2014-10-07 21:58:25Z shuston $ + #include "ace/OS_NS_macros.h" #include "ace/OS_NS_errno.h" #include "ace/OS_NS_fcntl.h" @@ -253,14 +256,6 @@ ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, // which resolves the most recently loaded symbols, which resolve // mostly what we want.. ACE_UNUSED_ARG (handle); -#if (ACE_VXWORKS < 0x690) - SYM_TYPE symtype; - char *value = 0; - STATUS status; - ACE_OSCALL (::symFindByName(sysSymTbl, symbolname, &value, &symtype), int, -1, status); - - return status == OK ? reinterpret_cast (value) : 0; -#else STATUS status; SYMBOL_DESC symbolDesc; /* symFind() descriptor */ @@ -271,7 +266,6 @@ ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, ACE_OSCALL (::symFind(sysSymTbl, &symbolDesc), int, -1, status); return status == OK ? reinterpret_cast (symbolDesc.value) : 0; -#endif /* (ACE_VXWORKS < 0x690) */ # else diff --git a/dep/acelite/ace/OS_NS_errno.cpp b/dep/acelite/ace/OS_NS_errno.cpp index f84975d40..8526c391d 100644 --- a/dep/acelite/ace/OS_NS_errno.cpp +++ b/dep/acelite/ace/OS_NS_errno.cpp @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_errno.cpp 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_errno.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_errno.h b/dep/acelite/ace/OS_NS_errno.h index 821bb7d09..36c3e94b2 100644 --- a/dep/acelite/ace/OS_NS_errno.h +++ b/dep/acelite/ace/OS_NS_errno.h @@ -4,7 +4,9 @@ /** * @file OS_NS_errno.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_errno.h 94454 2011-09-08 17:36:56Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_errno.inl b/dep/acelite/ace/OS_NS_errno.inl index cad5d4978..3a3ec6c54 100644 --- a/dep/acelite/ace/OS_NS_errno.inl +++ b/dep/acelite/ace/OS_NS_errno.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_errno.inl 94454 2011-09-08 17:36:56Z johnnyw $ + #include "ace/config-all.h" /* Need ACE_TRACE */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_fcntl.cpp b/dep/acelite/ace/OS_NS_fcntl.cpp index 547868765..41cf76fcb 100644 --- a/dep/acelite/ace/OS_NS_fcntl.cpp +++ b/dep/acelite/ace/OS_NS_fcntl.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_fcntl.cpp 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_fcntl.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_fcntl.h b/dep/acelite/ace/OS_NS_fcntl.h index 3fd7d0748..0fe86a5f1 100644 --- a/dep/acelite/ace/OS_NS_fcntl.h +++ b/dep/acelite/ace/OS_NS_fcntl.h @@ -4,7 +4,9 @@ /** * @file OS_NS_fcntl.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_fcntl.h 87487 2009-11-12 07:54:39Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_fcntl.inl b/dep/acelite/ace/OS_NS_fcntl.inl index afb95c684..ddace065e 100644 --- a/dep/acelite/ace/OS_NS_fcntl.inl +++ b/dep/acelite/ace/OS_NS_fcntl.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_fcntl.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_errno.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_macros.h b/dep/acelite/ace/OS_NS_macros.h index 10a6b9705..a949ce247 100644 --- a/dep/acelite/ace/OS_NS_macros.h +++ b/dep/acelite/ace/OS_NS_macros.h @@ -4,7 +4,9 @@ /** * @file OS_NS_macros.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_macros.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_math.cpp b/dep/acelite/ace/OS_NS_math.cpp index ffacea876..c2692a44b 100644 --- a/dep/acelite/ace/OS_NS_math.cpp +++ b/dep/acelite/ace/OS_NS_math.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_math.cpp 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_math.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_math.h b/dep/acelite/ace/OS_NS_math.h index 2072851f7..210554eed 100644 --- a/dep/acelite/ace/OS_NS_math.h +++ b/dep/acelite/ace/OS_NS_math.h @@ -4,7 +4,9 @@ /** * @file OS_NS_math.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_math.h 95724 2012-05-03 06:43:31Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -38,6 +40,7 @@ * as macros on some platforms. This way macro definitions will * be usable later as there is no way to save the macro definition * using the pre-processor. + * */ inline double ace_log2_helper (double x) { diff --git a/dep/acelite/ace/OS_NS_math.inl b/dep/acelite/ace/OS_NS_math.inl index 3c9753a29..76a50caa4 100644 --- a/dep/acelite/ace/OS_NS_math.inl +++ b/dep/acelite/ace/OS_NS_math.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_math.inl 93622 2011-03-22 15:45:57Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_OS { diff --git a/dep/acelite/ace/OS_NS_netdb.cpp b/dep/acelite/ace/OS_NS_netdb.cpp index ad9499355..680dc4dfe 100644 --- a/dep/acelite/ace/OS_NS_netdb.cpp +++ b/dep/acelite/ace/OS_NS_netdb.cpp @@ -1,47 +1,30 @@ // -*- C++ -*- +// $Id: OS_NS_netdb.cpp 97320 2013-09-05 07:53:58Z johnnyw $ + #include "ace/OS_NS_netdb.h" #if !defined (ACE_HAS_INLINED_OSCALLS) # include "ace/OS_NS_netdb.inl" #endif /* ACE_HAS_INLINED_OSCALLS */ -#if defined (ACE_WIN32) && defined (ACE_HAS_PHARLAP) -# include "ace/OS_NS_stdio.h" -#endif - #include "ace/os_include/net/os_if.h" -#include "ace/Global_Macros.h" -#include "ace/OS_NS_arpa_inet.h" -#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_unistd.h" +#if defined (ACE_WIN32) && defined (ACE_HAS_PHARLAP) +#include "ace/OS_NS_stdio.h" +#endif #include "ace/OS_NS_stropts.h" #include "ace/OS_NS_sys_socket.h" -#include "ace/OS_NS_unistd.h" #if defined (ACE_LINUX) && !defined (ACE_LACKS_NETWORKING) # include "ace/os_include/os_ifaddrs.h" #endif /* ACE_LINUX && !ACE_LACKS_NETWORKING */ -#ifdef ACE_LACKS_IOCTL -#include "ace/OS_NS_devctl.h" -#endif - -#ifdef ACE_VXWORKS -# include "ace/os_include/sys/os_sysctl.h" -# include -#endif - -#ifdef ACE_HAS_ALLOC_HOOKS -# include "ace/Malloc_Base.h" -#endif - // Include if_arp so that getmacaddr can use the // arp structure. #if defined (sun) # include /**/ #endif -#include - ACE_BEGIN_VERSIONED_NAMESPACE_DECL int @@ -112,7 +95,9 @@ ACE_OS::getmacaddress (struct macaddr_node_t *node) for (i = 0; i < 10; i++) { // Ethernet. - ACE_OS::snprintf (dev_name, 16, "ether%d", i); + ACE_OS::sprintf (dev_name, + "ether%d", + i); ip_dev = EtsTCPGetDeviceHandle (dev_name); if (ip_dev != 0) break; @@ -220,12 +205,7 @@ ACE_OS::getmacaddress (struct macaddr_node_t *node) if (handle == ACE_INVALID_HANDLE) return -1; -# ifdef ACE_LACKS_IOCTL - int info = 0; - if (ACE_OS::posix_devctl (handle, SIOCGIFHWADDR, &ifr, sizeof ifr, &info) < 0) -# else if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0) -# endif { ACE_OS::close (handle); return -1; @@ -367,193 +347,12 @@ ACE_OS::getmacaddress (struct macaddr_node_t *node) return 0; -#elif defined ACE_VXWORKS - - int name[] = {CTL_NET, AF_ROUTE, 0, 0, NET_RT_IFLIST, 0}; - static const size_t name_elts = sizeof name / sizeof name[0]; - - size_t result_sz = 0u; - if (sysctl (name, name_elts, 0, &result_sz, 0, 0u) != 0) - return -1; - -# ifdef ACE_HAS_ALLOC_HOOKS - char *const result = - static_cast (ACE_Allocator::instance ()->malloc (result_sz)); -# define ACE_NETDB_CLEANUP ACE_Allocator::instance ()->free (result) -# else - char *const result = static_cast (ACE_OS::malloc (result_sz)); -# define ACE_NETDB_CLEANUP ACE_OS::free (result) -# endif - - if (sysctl (name, name_elts, result, &result_sz, 0, 0u) != 0) - { - ACE_NETDB_CLEANUP; - return -1; - } - - for (size_t pos = 0, n; pos + sizeof (if_msghdr) < result_sz; pos += n) - { - if_msghdr *const hdr = reinterpret_cast (result + pos); - n = hdr->ifm_msglen; - sockaddr_dl *const addr = - reinterpret_cast (result + pos + sizeof (if_msghdr)); - - if (addr->sdl_alen >= sizeof node->node) - { - ACE_OS::memcpy (node->node, LLADDR (addr), sizeof node->node); - ACE_NETDB_CLEANUP; - return 0; - } - - while (pos + n < result_sz) - { - ifa_msghdr *const ifa = - reinterpret_cast (result + pos + n); - if (ifa->ifam_type != RTM_NEWADDR) - break; - n += ifa->ifam_msglen; - } - } - - ACE_NETDB_CLEANUP; -# undef ACE_NETDB_CLEANUP - return -1; - #else ACE_UNUSED_ARG (node); ACE_NOTSUP_RETURN (-1); #endif } -#ifdef ACE_LACKS_GETADDRINFO -int -ACE_OS::getaddrinfo_emulation (const char *name, addrinfo **result) -{ - hostent entry; - ACE_HOSTENT_DATA buffer; - int herr = 0; - const hostent *host = ACE_OS::gethostbyname_r (name, &entry, buffer, &herr); - - if (host == 0) - { - switch (herr) - { - case NO_DATA: - case HOST_NOT_FOUND: - return EAI_NONAME; - case TRY_AGAIN: - return EAI_AGAIN; - case NO_RECOVERY: - return EAI_FAIL; - case ENOTSUP: - if (ACE_OS::inet_aton (name, (in_addr *) &buffer[0]) != 0) - { - host = &entry; - entry.h_length = sizeof (in_addr); - entry.h_addr_list = (char **) (buffer + sizeof (in_addr)); - entry.h_addr_list[0] = buffer; - entry.h_addr_list[1] = 0; - break; - } - // fall-through - default: - errno = herr; - return EAI_SYSTEM; - } - } - - size_t n = 0; - for (char **addr = host->h_addr_list; *addr; ++addr, ++n) /*empty*/; - -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator *const al = ACE_Allocator::instance (); -# define ACE_ALLOC al-> -# else -# define ACE_ALLOC ACE_OS:: -# endif - - ACE_ALLOCATOR_RETURN (*result, - (addrinfo *) ACE_ALLOC calloc (n, sizeof (addrinfo)), - EAI_MEMORY); - - sockaddr_in *const addr_storage = - (sockaddr_in *) ACE_ALLOC calloc (n, sizeof (sockaddr_in)); - - if (!addr_storage) - { - ACE_ALLOC free (*result); - *result = 0; - return EAI_MEMORY; - } - - for (size_t i = 0; i < n; ++i) - { - (*result)[i].ai_family = AF_INET; - (*result)[i].ai_addrlen = sizeof (sockaddr_in); - (*result)[i].ai_addr = (sockaddr *) addr_storage + i; - (*result)[i].ai_addr->sa_family = AF_INET; - ACE_OS::memcpy (&addr_storage[i].sin_addr, host->h_addr_list[i], - (std::min) (size_t (host->h_length), sizeof (in_addr))); - if (i < n - 1) - (*result)[i].ai_next = (*result) + i + 1; - } - - return 0; -} - -void -ACE_OS::freeaddrinfo_emulation (addrinfo *result) -{ -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator *const al = ACE_Allocator::instance (); - al->free (result->ai_addr); - al->free (result); -# else - ACE_OS::free (result->ai_addr); - ACE_OS::free (result); -# endif -} -#endif /* ACE_LACKS_GETADDRINFO */ - -#ifdef ACE_LACKS_GETNAMEINFO -int -ACE_OS::getnameinfo_emulation (const sockaddr *saddr, ACE_SOCKET_LEN saddr_len, - char *host, ACE_SOCKET_LEN host_len) -{ - if (saddr_len != sizeof (sockaddr_in) || saddr->sa_family != AF_INET) - return EAI_FAMILY; // IPv6 support requries actual OS-provided getnameinfo - - const void *addr = &((const sockaddr_in *) saddr)->sin_addr; - int h_error; - hostent hentry; - ACE_HOSTENT_DATA buf; - hostent *const hp = - ACE_OS::gethostbyaddr_r (static_cast (addr), -# ifdef ACE_LACKS_IN_ADDR_T - 4, -# else - sizeof (in_addr_t), -# endif - AF_INET, &hentry, buf, &h_error); - - if (hp == 0 || hp->h_name == 0) - return EAI_NONAME; - - if (ACE_OS::strlen (hp->h_name) >= size_t (host_len)) - { - if (host_len > 0) - { - ACE_OS::memcpy (host, hp->h_name, host_len - 1); - host[host_len - 1] = '\0'; - } - return EAI_OVERFLOW; - } - - ACE_OS::strcpy (host, hp->h_name); - return 0; -} -#endif /* ACE_LACKS_GETNAMEINFO */ - ACE_END_VERSIONED_NAMESPACE_DECL # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) @@ -581,3 +380,4 @@ ACE_OS::netdb_release (void) ACE_END_VERSIONED_NAMESPACE_DECL # endif /* defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) */ + diff --git a/dep/acelite/ace/OS_NS_netdb.h b/dep/acelite/ace/OS_NS_netdb.h index 5885e1789..63f2bafc7 100644 --- a/dep/acelite/ace/OS_NS_netdb.h +++ b/dep/acelite/ace/OS_NS_netdb.h @@ -4,7 +4,9 @@ /** * @file OS_NS_netdb.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_netdb.h 93597 2011-03-21 12:54:52Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -24,7 +26,6 @@ # endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/os_include/os_netdb.h" -#include "ace/os_include/sys/os_socket.h" #include /**/ "ace/ACE_export.h" #if defined (ACE_EXPORT_MACRO) @@ -105,36 +106,6 @@ namespace ACE_OS struct servent *result, ACE_SERVENT_DATA buf); - ACE_NAMESPACE_INLINE_FUNCTION - int getaddrinfo (const char *name, const char *service, - const addrinfo *hints, addrinfo **result); - - ACE_NAMESPACE_INLINE_FUNCTION - void freeaddrinfo (addrinfo *result); - - ACE_NAMESPACE_INLINE_FUNCTION - const ACE_TCHAR *gai_strerror (int errcode); - - ACE_NAMESPACE_INLINE_FUNCTION - int getnameinfo (const sockaddr *addr, ACE_SOCKET_LEN addr_len, - char *host, ACE_SOCKET_LEN host_len, - char *service, ACE_SOCKET_LEN service_len, - unsigned int flags); - -#ifdef ACE_LACKS_GETADDRINFO - extern ACE_Export - int getaddrinfo_emulation (const char *name, addrinfo **result); - - extern ACE_Export - void freeaddrinfo_emulation (addrinfo *result); -#endif - -#ifdef ACE_LACKS_GETNAMEINFO - extern ACE_Export - int getnameinfo_emulation (const sockaddr *addr, ACE_SOCKET_LEN addr_len, - char *host, ACE_SOCKET_LEN host_len); -#endif - # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) extern ACE_Export int netdb_acquire (void); diff --git a/dep/acelite/ace/OS_NS_netdb.inl b/dep/acelite/ace/OS_NS_netdb.inl index 5f4e4c258..d3d2baaf2 100644 --- a/dep/acelite/ace/OS_NS_netdb.inl +++ b/dep/acelite/ace/OS_NS_netdb.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_netdb.inl 97130 2013-05-13 17:36:26Z mesnier_p $ + #include "ace/OS_NS_macros.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_errno.h" @@ -96,8 +99,7 @@ ACE_OS::gethostbyaddr_r (const char *addr, ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); - if (h_errnop) - *h_errnop = ENOTSUP; + ACE_UNUSED_ARG (h_errnop); ACE_NOTSUP_RETURN (0); # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) @@ -273,8 +275,7 @@ ACE_OS::gethostbyname_r (const char *name, ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); - if (h_errnop) - *h_errnop = ENOTSUP; + ACE_UNUSED_ARG (h_errnop); ACE_NOTSUP_RETURN (0); # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) @@ -735,79 +736,4 @@ ACE_OS::getservbyname_r (const char *svc, #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) */ } - -ACE_INLINE int -ACE_OS::getaddrinfo (const char *name, const char *service, - const addrinfo *hints, addrinfo **result) -{ - ACE_OS_TRACE ("ACE_OS::getaddrinfo"); -#ifdef ACE_LACKS_GETADDRINFO - ACE_UNUSED_ARG (service); - ACE_UNUSED_ARG (hints); - return ACE_OS::getaddrinfo_emulation (name, result); -#else - return ::getaddrinfo (name, service, hints, result); -#endif -} - -ACE_INLINE void -ACE_OS::freeaddrinfo (addrinfo *result) -{ - ACE_OS_TRACE ("ACE_OS::freeaddrinfo"); -#ifdef ACE_LACKS_GETADDRINFO - ACE_OS::freeaddrinfo_emulation (result); -#else - ::freeaddrinfo (result); -#endif -} - -ACE_INLINE const ACE_TCHAR * -ACE_OS::gai_strerror (int errcode) -{ - ACE_OS_TRACE ("ACE_OS::gai_strerror"); -#ifdef ACE_LACKS_GAI_STRERROR - switch (errcode) - { - case EAI_NONAME: - return ACE_TEXT ("Name does not resolve to an address"); - case EAI_AGAIN: - return ACE_TEXT ("Temporary failure, try again"); - case EAI_FAIL: - return ACE_TEXT ("Name resolution failed"); - case EAI_FAMILY: - return ACE_TEXT ("Address family not supported"); - case EAI_MEMORY: - return ACE_TEXT ("Out of memory"); - case EAI_SYSTEM: - return ACE_TEXT ("Other error, see errno"); - case EAI_OVERFLOW: - return ACE_TEXT ("Buffer provided by caller was too small"); - default: - return ACE_TEXT ("Unknown error"); - } -#elif defined ACE_WIN32 - return ACE_TEXT_gai_strerror (errcode); -#else - return ACE_TEXT_CHAR_TO_TCHAR (::gai_strerror (errcode)); -#endif -} - -ACE_INLINE int -ACE_OS::getnameinfo (const sockaddr *addr, ACE_SOCKET_LEN addr_len, - char *host, ACE_SOCKET_LEN host_len, - char *service, ACE_SOCKET_LEN service_len, - unsigned int flags) -{ - ACE_OS_TRACE ("ACE_OS::getnameinfo"); -#ifdef ACE_LACKS_GETNAMEINFO - ACE_UNUSED_ARG (service); - ACE_UNUSED_ARG (service_len); - ACE_UNUSED_ARG (flags); - return ACE_OS::getnameinfo_emulation (addr, addr_len, host, host_len); -#else - return ::getnameinfo (addr, addr_len, host, host_len, - service, service_len, flags); -#endif -} - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_poll.cpp b/dep/acelite/ace/OS_NS_poll.cpp index 8265665e9..954c59bc7 100644 --- a/dep/acelite/ace/OS_NS_poll.cpp +++ b/dep/acelite/ace/OS_NS_poll.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_poll.cpp 91626 2010-09-07 10:59:20Z johnnyw $ + #include "ace/OS_NS_poll.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_poll.h b/dep/acelite/ace/OS_NS_poll.h index f865f51bd..b18893b19 100644 --- a/dep/acelite/ace/OS_NS_poll.h +++ b/dep/acelite/ace/OS_NS_poll.h @@ -4,7 +4,9 @@ /** * @file OS_NS_poll.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_poll.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_poll.inl b/dep/acelite/ace/OS_NS_poll.inl index 511c71948..92ce0c41e 100644 --- a/dep/acelite/ace/OS_NS_poll.inl +++ b/dep/acelite/ace/OS_NS_poll.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_poll.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Time_Value.h" #include "ace/OS_NS_errno.h" diff --git a/dep/acelite/ace/OS_NS_pwd.cpp b/dep/acelite/ace/OS_NS_pwd.cpp index 6212d2c25..be191f62a 100644 --- a/dep/acelite/ace/OS_NS_pwd.cpp +++ b/dep/acelite/ace/OS_NS_pwd.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_pwd.cpp 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_pwd.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_pwd.h b/dep/acelite/ace/OS_NS_pwd.h index 4bdaf9001..ffbf7180b 100644 --- a/dep/acelite/ace/OS_NS_pwd.h +++ b/dep/acelite/ace/OS_NS_pwd.h @@ -4,7 +4,9 @@ /** * @file OS_NS_pwd.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_pwd.h 93597 2011-03-21 12:54:52Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_pwd.inl b/dep/acelite/ace/OS_NS_pwd.inl index 3d680bba9..396ea0af0 100644 --- a/dep/acelite/ace/OS_NS_pwd.inl +++ b/dep/acelite/ace/OS_NS_pwd.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_pwd.inl 93563 2011-03-16 14:33:48Z olli $ + #include "ace/OS_NS_errno.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -56,14 +59,6 @@ ACE_OS::getpwnam_r (const char *name, } *result = pwd; return 0; -#elif defined (ACE_HAS_STHREADS) - if (::getpwnam_r (name, pwd, buffer, bufsize) != 0) - { - *result = 0; - return -1; - } - *result = pwd; - return 0; #else return ::getpwnam_r (name, pwd, buffer, bufsize, result); #endif /* ACE_LACKS_PWD_FUNCTIONS */ diff --git a/dep/acelite/ace/OS_NS_regex.cpp b/dep/acelite/ace/OS_NS_regex.cpp index c6302c74c..141d50ab2 100644 --- a/dep/acelite/ace/OS_NS_regex.cpp +++ b/dep/acelite/ace/OS_NS_regex.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_regex.cpp 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_regex.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_regex.h b/dep/acelite/ace/OS_NS_regex.h index 8851abe49..eccdb69dd 100644 --- a/dep/acelite/ace/OS_NS_regex.h +++ b/dep/acelite/ace/OS_NS_regex.h @@ -4,7 +4,9 @@ /** * @file OS_NS_regex.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_regex.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_regex.inl b/dep/acelite/ace/OS_NS_regex.inl index e135051c7..0ffdcdfb2 100644 --- a/dep/acelite/ace/OS_NS_regex.inl +++ b/dep/acelite/ace/OS_NS_regex.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_regex.inl 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_errno.h" #include "ace/os_include/os_regex.h" diff --git a/dep/acelite/ace/OS_NS_signal.cpp b/dep/acelite/ace/OS_NS_signal.cpp index 49177a6d4..c7c3d85dc 100644 --- a/dep/acelite/ace/OS_NS_signal.cpp +++ b/dep/acelite/ace/OS_NS_signal.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_signal.cpp 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/OS_NS_signal.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_signal.h b/dep/acelite/ace/OS_NS_signal.h index 8cf09884e..07c3c516a 100644 --- a/dep/acelite/ace/OS_NS_signal.h +++ b/dep/acelite/ace/OS_NS_signal.h @@ -4,7 +4,9 @@ /** * @file OS_NS_signal.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_signal.h 97246 2013-08-07 07:10:20Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -41,6 +43,7 @@ * as macros on some platforms. This way macro definitions will * be usable later as there is no way to save the macro definition * using the pre-processor. + * */ #if !defined (ACE_LACKS_SIGSET) @@ -166,10 +169,6 @@ namespace ACE_OS { int kill (pid_t pid, int signum); -#ifdef pthread_sigmask -# define ACE_PTHREAD_SIGMASK_MACRO pthread_sigmask -# undef pthread_sigmask -#endif ACE_NAMESPACE_INLINE_FUNCTION int pthread_sigmask (int how, const sigset_t *nsp, diff --git a/dep/acelite/ace/OS_NS_signal.inl b/dep/acelite/ace/OS_NS_signal.inl index e125f430c..43046245f 100644 --- a/dep/acelite/ace/OS_NS_signal.inl +++ b/dep/acelite/ace/OS_NS_signal.inl @@ -1,7 +1,8 @@ // -*- C++ -*- +// $Id: OS_NS_signal.inl 93651 2011-03-28 08:49:11Z johnnyw $ + #include "ace/OS_NS_macros.h" #include "ace/OS_NS_errno.h" -#include "ace/os_include/os_pthread.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -16,14 +17,6 @@ kill (pid_t pid, int signum) ACE_UNUSED_ARG (pid); ACE_UNUSED_ARG (signum); ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_VXWORKS) - /* - * The VxWorks kill interface is not really POSIX - * since they use a task id in place of a pid type. - * This only becomes an issue when using the 64bit compiler - * as the TASK_ID is no longer defined as an int. - */ - ACE_OSCALL_RETURN (::kill ((ACE_VX_TASK_ID)pid, signum), int, -1); #else ACE_OSCALL_RETURN (::kill (pid, signum), int, -1); #endif /* ACE_LACKS_KILL */ @@ -34,21 +27,10 @@ pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp) { #if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_SIGMASK) int result; -# ifdef ACE_PTHREAD_SIGMASK_MACRO - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (ACE_PTHREAD_SIGMASK_MACRO (how, nsp, osp) - , result), int, -1); -# elif defined (ACE_HAS_NONCONST_PTHREAD_SIGMASK) - sigset_t *ncnsp = const_cast(nsp); - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, ncnsp, osp), - result), - int, - -1); -# else ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp), result), int, -1); -# endif /* ACE_HAS_NONCONST__PTHREAD_SIGMASK */ #else /* !ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */ ACE_UNUSED_ARG (how); ACE_UNUSED_ARG (nsp); @@ -199,8 +181,7 @@ signal (int signum, ACE_SignalHandler func) if (signum == 0) return 0; else -#if (defined ACE_WIN32 && !defined ACE_HAS_WINCE) || \ - (!defined ACE_LACKS_UNIX_SIGNALS && !defined ACE_LACKS_SIGNAL) +# if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) # if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS4_SIGNALS) return ::signal (signum, func); # else @@ -217,14 +198,14 @@ signal (int signum, ACE_SignalHandler func) ACE_INLINE int sigprocmask (int how, const sigset_t *nsp, sigset_t *osp) { -#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) || defined (ACE_LACKS_SIGPROCMASK) +#if defined (ACE_LACKS_SIGSET) ACE_UNUSED_ARG (how); ACE_UNUSED_ARG (nsp); ACE_UNUSED_ARG (osp); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1); -#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS || ACE_LACKS_SIGPROCMASK */ +#endif /* ACE_LACKS_SIGSET */ } ACE_INLINE int diff --git a/dep/acelite/ace/OS_NS_stdio.cpp b/dep/acelite/ace/OS_NS_stdio.cpp index dd537ae17..76ade88cc 100644 --- a/dep/acelite/ace/OS_NS_stdio.cpp +++ b/dep/acelite/ace/OS_NS_stdio.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_stdio.cpp 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_Thread.h" @@ -5,20 +7,6 @@ # include "ace/OS_NS_stdio.inl" #endif /* ACE_HAS_INLINED_OSCALLS */ -#if !defined (ACE_LACKS_STDINT_H) -# include -#endif - -#include "ace/Malloc_Base.h" - -#include -#include -#include - -#ifndef ACE_LACKS_WCHAR_H -# include -#endif - # if defined (ACE_WIN32) ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -253,43 +241,30 @@ ACE_OS::fopen (const wchar_t *filename, #endif /* ACE_WIN32 */ -#ifndef ACE_STDIO_USE_STDLIB_FOR_VARARGS // The following *printf functions aren't inline because // they use varargs. + int ACE_OS::fprintf (FILE *fp, const char *format, ...) { // ACE_OS_TRACE ("ACE_OS::fprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (fp); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vfprintf (fp, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } -#endif /* ACE_STDIO_USE_STDLIB_FOR_VARARGS */ #if defined (ACE_HAS_WCHAR) int ACE_OS::fprintf (FILE *fp, const wchar_t *format, ...) { // ACE_OS_TRACE ("ACE_OS::fprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (fp); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vfprintf (fp, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } #endif /* ACE_HAS_WCHAR */ @@ -297,17 +272,11 @@ int ACE_OS::asprintf (char **bufp, const char *format, ...) { // ACE_OS_TRACE ("ACE_OS::asprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (bufp); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vasprintf (bufp, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } #if defined (ACE_HAS_WCHAR) @@ -315,93 +284,59 @@ int ACE_OS::asprintf (wchar_t **bufp, const wchar_t *format, ...) { // ACE_OS_TRACE ("ACE_OS::asprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (bufp); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vasprintf (bufp, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } #endif /* ACE_HAS_WCHAR */ -#if !defined ACE_FACE_DEV || !defined ACE_STDIO_USE_STDLIB_FOR_VARARGS int ACE_OS::printf (const char *format, ...) { // ACE_OS_TRACE ("ACE_OS::printf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vprintf (format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } -#endif /* !ACE_FACE_DEV || !ACE_STDIO_USE_STDLIB_FOR_VARARGS */ #if defined (ACE_HAS_WCHAR) int ACE_OS::printf (const wchar_t *format, ...) { // ACE_OS_TRACE ("ACE_OS::printf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vprintf (format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } #endif /* ACE_HAS_WCHAR */ -#if !defined ACE_STDIO_USE_STDLIB_FOR_VARARGS || defined ACE_LACKS_SNPRINTF int ACE_OS::snprintf (char *buf, size_t maxlen, const char *format, ...) { // ACE_OS_TRACE ("ACE_OS::snprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (maxlen); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vsnprintf (buf, maxlen, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } -#endif /* ACE_STDIO_USE_STDLIB_FOR_VARARGS */ #if defined (ACE_HAS_WCHAR) int ACE_OS::snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format, ...) { // ACE_OS_TRACE ("ACE_OS::snprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (maxlen); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vsnprintf (buf, maxlen, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } #endif /* ACE_HAS_WCHAR */ @@ -409,17 +344,11 @@ int ACE_OS::sprintf (char *buf, const char *format, ...) { // ACE_OS_TRACE ("ACE_OS::sprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vsprintf (buf, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } #if defined (ACE_HAS_WCHAR) @@ -427,21 +356,15 @@ int ACE_OS::sprintf (wchar_t *buf, const wchar_t *format, ...) { // ACE_OS_TRACE ("ACE_OS::sprintf"); -#if defined (ACE_LACKS_VA_FUNCTIONS) - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#else va_list ap; va_start (ap, format); int const result = ACE_OS::vsprintf (buf, format, ap); va_end (ap); return result; -#endif /* ACE_LACKS_VA_FUNCTIONS */ } #endif /* ACE_HAS_WCHAR */ -#if !defined (ACE_HAS_VASPRINTF) && !defined (ACE_LACKS_VA_COPY) +#if !defined (ACE_HAS_VASPRINTF) int ACE_OS::vasprintf_emulation(char **bufp, const char *format, va_list argptr) { @@ -467,10 +390,10 @@ ACE_OS::vasprintf_emulation(char **bufp, const char *format, va_list argptr) return size; } -#endif +#endif /* !ACE_HAS_VASPRINTF */ -#if !defined (ACE_HAS_VASWPRINTF) && !defined (ACE_LACKS_VA_COPY) #if defined (ACE_HAS_WCHAR) +#if !defined (ACE_HAS_VASWPRINTF) int ACE_OS::vaswprintf_emulation(wchar_t **bufp, const wchar_t *format, va_list argptr) { @@ -497,1102 +420,7 @@ ACE_OS::vaswprintf_emulation(wchar_t **bufp, const wchar_t *format, va_list argp return size; } +#endif /* !ACE_HAS_VASWPRINTF */ #endif /* ACE_HAS_WCHAR */ -#endif /* !ACE_HAS_VASPRINTF */ - -#if defined (ACE_HAS_VSNPRINTF_EMULATION) - -#ifdef ACE_LACKS_WCHAR_H - typedef int wint_t; -#elif !defined ACE_LACKS_WCHAR_STD_NAMESPACE - using std::wint_t; -# ifndef ACE_LACKS_WCSRTOMBS - using std::wcsrtombs; -# endif -#endif - -namespace { // helpers for vsnprintf_emulation - enum Flag { SNPRINTF_NONE, SNPRINTF_GROUP, SNPRINTF_LEFT, - SNPRINTF_SIGN = 4, SNPRINTF_SPACE = 8, SNPRINTF_ALT = 0x10, - SNPRINTF_ZERO = 0x20, SNPRINTF_CHAR = 0x40, SNPRINTF_SHORT = 0x80, - SNPRINTF_LONG = 0x100, SNPRINTF_LONGLONG = 0x200, SNPRINTF_INTMAX = 0x400, - SNPRINTF_SIZET = 0x800, SNPRINTF_PTRDIFF = 0x1000, - SNPRINTF_LONGDOUBLE = 0x2000, SNPRINTF_UCASE = 0x4000, - SNPRINTF_UNSIGNED = 0x8000, SNPRINTF_NEGATIVE = 0x10000, - SNPRINTF_EXPONENT = 0x20000, SNPRINTF_FLEXPONENT = 0x40000, - SNPRINTF_HEXPONENT = 0x80000, - SNPRINTF_LARGE_INT = (SNPRINTF_LONG|SNPRINTF_LONGLONG|SNPRINTF_INTMAX| - SNPRINTF_SIZET|SNPRINTF_PTRDIFF) - }; - - struct Snprintf_Flags - { - Snprintf_Flags () - : val_ (SNPRINTF_NONE) - {} - - explicit Snprintf_Flags (const char *&fmt) - : val_ (SNPRINTF_NONE) - { - this->parse_flags (fmt); - if (this->has (SNPRINTF_LEFT)) - this->remove (SNPRINTF_ZERO); - if (this->has (SNPRINTF_SIGN)) - this->remove (SNPRINTF_SPACE); - } - - void parse_flags (const char *&fmt) - { - for (; true; ++fmt) - { - switch (*fmt) - { - // ' used as a flag is a POSIX extension to ISO std C - case '\'': this->add (SNPRINTF_GROUP); break; - case '-': this->add (SNPRINTF_LEFT); break; - case '+': this->add (SNPRINTF_SIGN); break; - case ' ': this->add (SNPRINTF_SPACE); break; - case '#': this->add (SNPRINTF_ALT); break; - case '0': this->add (SNPRINTF_ZERO); break; - default: return; - } - } - } - - void parse_length (const char *&fmt) - { - if (fmt[0] == 'h' && fmt[1] == 'h') - this->add (SNPRINTF_CHAR), fmt += 2; - else if (fmt[0] == 'h') - this->add (SNPRINTF_SHORT), ++fmt; - else if (fmt[0] == 'l' && fmt[1] == 'l') - this->add (SNPRINTF_LONGLONG), fmt += 2; - else if (fmt[0] == 'l') - this->add (SNPRINTF_LONG), ++fmt; - else if (fmt[0] == 'j') - this->add (SNPRINTF_INTMAX), ++fmt; - else if (fmt[0] == 'z') - this->add (SNPRINTF_SIZET), ++fmt; - else if (fmt[0] == 't') - this->add (SNPRINTF_PTRDIFF), ++fmt; - else if (fmt[0] == 'L') - this->add (SNPRINTF_LONGDOUBLE), ++fmt; - } - - void width (int &w) - { - if (w < 0) - { - this->add (SNPRINTF_LEFT); - w = -w; - } - } - - template - void value (T &v) - { - if (v < 0) - { - this->add (SNPRINTF_NEGATIVE); - v = -v; - } - } - - void conv_spec (char &c) - { - if (std::isupper (c)) - { - if (c == 'C' || c == 'S') // C,S specs are POSIX extensions - this->add (SNPRINTF_LONG); - else - this->add (SNPRINTF_UCASE); - c = std::tolower (c); - } - - switch (c) - { - case 'o': case 'u': case 'x': this->add (SNPRINTF_UNSIGNED); break; - case 'p': this->add (SNPRINTF_ALT); break; - case 'e': this->add (SNPRINTF_EXPONENT); break; - case 'g': this->add (SNPRINTF_FLEXPONENT); break; - case 'a': this->add (SNPRINTF_HEXPONENT); break; - default: break; - } - } - - void add (Flag f) { this->val_ |= f; } - void remove (Flag f) { this->val_ &= ~f; } - bool has (Flag f) const { return (this->val_ & f) == f; } - bool has_some (Flag f) const { return this->val_ & f; } - int val_; - }; - - struct Snprintf_Digit_Grouping - { - Snprintf_Digit_Grouping (Snprintf_Flags flags, const char *grouping, - char thousands) - : grouping_ (flags.has (SNPRINTF_GROUP) ? grouping : 0) - , separator_ (flags.has (SNPRINTF_GROUP) ? *grouping : CHAR_MAX) - , next_sep_ (this->separator_) - , thousands_ (thousands) - { - if (!this->separator_) - { - this->grouping_ = 0; - this->separator_ = this->next_sep_ = CHAR_MAX; - } - } - - int separators_needed (int digits) const - { - if (!this->grouping_) - return 0; - const char *grouping = this->grouping_; - int group = *grouping; - int separators = 0; - while (group > 0 && group < CHAR_MAX && digits > group) - { - digits -= group; - ++separators; - if (grouping[1]) - group = *++grouping; - } - return separators; - } - - bool next (char *&buf) - { - const bool separate = this->next_sep_ == 0; - if (separate) - { - *--buf = this->thousands_; - if (this->grouping_[1]) - this->separator_ = *++this->grouping_; - this->next_sep_ = this->separator_; - } - if (this->next_sep_ > 0 && this->next_sep_ < CHAR_MAX) - --this->next_sep_; - return separate; - } - - const char *grouping_; - int separator_, next_sep_; - const char thousands_; - }; - - struct Snprintf_Buffer - { - Snprintf_Buffer (char *buf, size_t max) - : buf_ (buf) - , avail_ (max - 1) // last byte is not available for writes, must be null - , written_ (0) - {} - - void out (const char *s, size_t n) - { - if (n == 0) - return; - const size_t m = n > this->avail_ ? this->avail_ : n; - ACE_OS::memcpy (this->buf_, s, m); - this->buf_ += m; - this->avail_ -= m; - this->written_ += n; - } - - void fill (char c, size_t n) - { - if (n == 0) - return; - const size_t m = n > this->avail_ ? this->avail_ : n; - ACE_OS::memset (this->buf_, c, m); - this->buf_ += m; - this->avail_ -= m; - this->written_ += n; - } - - void pad (const char *s, size_t n, Snprintf_Flags flags, int width) - { - const int used = static_cast (n); - if (!flags.has (SNPRINTF_LEFT) && width > used) - this->fill (' ', width - used); - this->out (s, n); - if (flags.has (SNPRINTF_LEFT) && width > used) - this->fill (' ', width - used); - } - - void conv_int (ACE_UINT64 val, Snprintf_Flags flags, - int width, int precision, int base = 10) - { - if (val == 0 && precision == 0) - { - if (flags.has (SNPRINTF_SPACE) && !flags.has (SNPRINTF_UNSIGNED)) - this->fill (' ', 1); - if (flags.has (SNPRINTF_ALT) && base == 8) - this->fill ('0', 1); - return; - } - - if (precision >= 0) - flags.remove (SNPRINTF_ZERO); - if (precision == -1) - precision = 1; - -#ifdef ACE_LACKS_LOCALECONV - static const char thousands_sep = 0; - static const char grouping[] = ""; -#else -# ifdef localeconv -# undef localeconv -# endif - const std::lconv *const conv = std::localeconv (); - const char thousands_sep = - conv && *conv->thousands_sep ? *conv->thousands_sep : ','; - const char *grouping = conv ? conv->grouping : ""; -#endif - - if (base != 10) - flags.remove (SNPRINTF_GROUP); - Snprintf_Digit_Grouping dg (flags, grouping, thousands_sep); - - char buf[100]; - char *it = buf + sizeof buf; - const char a = flags.has (SNPRINTF_UCASE) ? 'A' : 'a'; - int sep_chars = 0; - - for (ACE_UINT64 v = val; v; v /= base) - { - if (dg.next (it)) - ++sep_chars; - *--it = static_cast (v % base < 10 ? - '0' + v % base : a + v % base - 10); - } - - const int digits = static_cast (buf + sizeof buf - it - sep_chars); - - if (base == 8 && flags.has (SNPRINTF_ALT) && precision <= digits) - precision = digits + 1; - - if (flags.has (SNPRINTF_NEGATIVE)) - *--it = '-'; - else if (flags.has (SNPRINTF_SPACE) && !flags.has (SNPRINTF_UNSIGNED)) - *--it = ' '; - else if (flags.has (SNPRINTF_SIGN) && !flags.has (SNPRINTF_UNSIGNED)) - *--it = '+'; - - const bool has_sign = it < buf + sizeof buf - digits - sep_chars; - bool has_0x = false; - if (val != 0 && base == 16 && flags.has (SNPRINTF_ALT)) - { - *--it = flags.has (SNPRINTF_UCASE) ? 'X' : 'x'; - *--it = '0'; - has_0x = true; - } - - int padding = 0; - if (flags.has (SNPRINTF_ZERO) || precision > digits) - { - if (precision > digits) - padding = precision - digits; - - const int prefix = has_sign ? 1 : (has_0x ? 2 : 0); - if (flags.has (SNPRINTF_ZERO) && width > digits + sep_chars + prefix) - padding = width - digits - prefix - sep_chars; - - if (!flags.has (SNPRINTF_LEFT) && digits + padding + prefix < width) - { - this->fill (' ', width - digits - padding - prefix - sep_chars); - width = -1; - } - - this->out (it, prefix); - it += prefix; - this->fill ('0', padding); - padding += prefix; - } - - this->pad (it, buf + sizeof buf - it, flags, width - padding); - } - - void conv_float (long double val, Snprintf_Flags flags, - int width, int precision) - { - char buf[LDBL_MAX_10_EXP + 2]; - char *it = buf; - - // Find the sign bit manually, signbit() is only available with C99/C++11 - const void *const ptr = &val; - const char *const pval = static_cast (ptr); -#if ACE_BYTE_ORDER == ACE_LITTLE_ENDIAN -# if defined LDBL_MANT_DIG && LDBL_MANT_DIG == 64 -# define SIGN_OFFSET 9 -# else -# define SIGN_OFFSET (ACE_SIZEOF_LONG_DOUBLE - 1) -# endif -#else -# define SIGN_OFFSET 0 -#endif - if (pval[SIGN_OFFSET] & 0x80) - val = -val, *it++ = '-'; - else if (flags.has (SNPRINTF_SIGN)) - *it++ = '+'; - else if (flags.has (SNPRINTF_SPACE)) - *it++ = ' '; - const bool has_sign = it > buf; - - if (!(val >= -(std::numeric_limits::max)() - && val <= (std::numeric_limits::max)())) - { - if (val != val) - ACE_OS::strcpy (it, flags.has (SNPRINTF_UCASE) ? "NAN" : "nan"); - else - ACE_OS::strcpy (it, flags.has (SNPRINTF_UCASE) ? "INF" : "inf"); - this->conv_str (buf, flags, width, -1); - return; - } - -#ifdef ACE_LACKS_LOCALECONV - static const char radix = '.', thousands_sep = 0; - static const char grouping[] = ""; -#else - const std::lconv *const conv = std::localeconv (); - const char radix = conv ? *conv->decimal_point : '.'; - const char thousands_sep = - conv && *conv->thousands_sep ? *conv->thousands_sep : ','; - const char *grouping = conv ? conv->grouping : ""; -#endif - - const long double log = val > 0 ? std::log10 (val) : 0; - int dig_left = static_cast (1 + ((val >= 1) ? log : 0)); - -#if defined __HP_aCC && __HP_aCC < 40000 - int exp = static_cast (log); -#else - int exp = static_cast (std::floor (log)); -#endif - if (flags.has (SNPRINTF_FLEXPONENT)) - { - const int p = precision > 0 ? precision : (precision < 0 ? 6 : 1); - precision = p - 1; - if (exp < p && exp >= -4) - precision -= exp; - else - flags.add (SNPRINTF_EXPONENT); - } - - if (flags.has (SNPRINTF_EXPONENT)) - { - dig_left = 1; - val /= std::pow (10.L, exp); - } - - if (flags.has (SNPRINTF_HEXPONENT)) - { - *it++ = '0'; - *it++ = flags.has (SNPRINTF_UCASE) ? 'X' : 'x'; - long double mant = std::frexp (val, &exp); - if (mant != 0) - exp -= 4; - const char a = flags.has (SNPRINTF_UCASE) ? 'A' : 'a'; - *it++ = hex_digit (mant, a); - if (precision >= 0 || flags.has (SNPRINTF_ALT) || mant > 0) - *it++ = radix; - for (int i = 0; i < precision || precision == -1; ++i) - { - if ((precision == -1 && mant == 0) || it == buf + sizeof buf - 8) - break; - *it++ = hex_digit (mant, a); - } - flags.add (SNPRINTF_EXPONENT); - *it++ = flags.has (SNPRINTF_UCASE) ? 'P' : 'p'; - } - else - { -#if (defined __MINGW32__ && defined __x86_64__) \ - || (defined ACE_VXWORKS && !defined __RTP__) - // Avoid std::modf(long double, long double*) on MinGW-W64 64-bit: - // see https://sourceforge.net/p/mingw-w64/bugs/478 - double int_part; - double frac_part = std::modf (static_cast (val), &int_part); -#else - long double int_part; - long double frac_part = std::modf (val, &int_part); -#endif - - Snprintf_Digit_Grouping dg (flags, grouping, thousands_sep); - dig_left += dg.separators_needed (dig_left); - - for (char *dec = it + dig_left; dec > it; int_part /= 10) - { - dg.next (dec); - *--dec = '0' + static_cast (std::fmod (int_part, 10)); - } - - it += dig_left; - const char *const frac_start = it; - - if (precision == -1) - precision = 6; - if (precision > 0 || flags.has (SNPRINTF_ALT)) - *it++ = radix; - - for (int i = 0; i < precision && it < buf + sizeof buf; ++i) - { - frac_part *= 10; - const int digit = static_cast (frac_part); - *it++ = '0' + digit; - frac_part -= digit; - } - - if (flags.has (SNPRINTF_FLEXPONENT) && !flags.has (SNPRINTF_ALT)) - { - for (char *f = it - 1; f >= frac_start; --f) - { - if (*f == '0' || *f == radix) - { - --it; - } - else - { - break; - } - } - } - } - - if (flags.has (SNPRINTF_EXPONENT)) - { - if (!flags.has (SNPRINTF_HEXPONENT)) - *it++ = flags.has (SNPRINTF_UCASE) ? 'E' : 'e'; - Snprintf_Buffer sb (it, buf + sizeof buf - it); - Snprintf_Flags exp_flags; - exp_flags.add (SNPRINTF_SIGN); - exp_flags.value (exp); - const int exp_prec = flags.has (SNPRINTF_HEXPONENT) ? 1 : 2; - sb.conv_int (exp, exp_flags, -1, exp_prec); - it = sb.buf_; - } - - int used = static_cast (it - buf); - const char *const end = it; - it = buf; - if (flags.has (SNPRINTF_ZERO) && used < width) - { - if (has_sign) - this->fill (*it++, 1); - if (flags.has (SNPRINTF_HEXPONENT)) - this->out (it, 2), it += 2; - if (width > used) - this->fill ('0', width - used); - width = -1; - } - - this->pad (it, end - it, flags, width); - } - - static char hex_digit (long double &mant, char a) - { - mant *= 16; - int m = static_cast (mant); - mant -= m; - return m < 10 ? '0' + m : a + m - 10; - } - - void conv_char (unsigned char c, Snprintf_Flags flags, int width) - { - this->pad (reinterpret_cast (&c), 1, flags, width); - } - - void conv_str (const char *str, Snprintf_Flags flags, - int width, int precision) - { - const size_t len = ACE_OS::strlen (str), - n = (precision >= 0 && precision < int (len)) ? precision : len; - this->pad (str, n, flags, width); - } - - void conv_str (const wchar_t *str, Snprintf_Flags flags, - int width, int precision) - { -#ifdef ACE_LACKS_WCSRTOMBS - ACE_UNUSED_ARG (str); - this->conv_str ("(error: no wide string conversion)", - flags, width, precision); -#else - std::mbstate_t mbstate = std::mbstate_t (); - const size_t n = 1 + wcsrtombs (0, &str, 0, &mbstate); - char *buf = static_cast (ACE_Allocator::instance ()->malloc (n)); - if (buf) - { - wcsrtombs (buf, &str, n, &mbstate); - this->conv_str (buf, flags, width, precision); - } - ACE_Allocator::instance ()->free (buf); -#endif - } - - char *buf_; - size_t avail_, written_; - }; - -#ifdef EOVERFLOW -# define ACE_SNPRINTF_EOVERFLOW EOVERFLOW -#else -# define ACE_SNPRINTF_EOVERFLOW EINVAL -#endif - - int snprintf_read_int (const char *&fmt) - { - char *end = 0; - const unsigned long i = ACE_OS::strtoul (fmt, &end, 10); - fmt = end; - if (i > INT_MAX) - { - errno = ACE_SNPRINTF_EOVERFLOW; - return -1; - } - return static_cast (i); - } - - int snprintf_positional (const char *&fmt) - { - const char *f = fmt; - const int i = snprintf_read_int (f); - if (i > 0 && *f == '$') - { - fmt = f + 1; - return i; - } - return 0; - } - - struct Snprintf_Positional_Args - { - Snprintf_Positional_Args () - : pos_arg_ (this->pos_storage_) - , scanned_ (false) - {} - - ~Snprintf_Positional_Args () - { - if (this->pos_arg_ != this->pos_storage_) - ACE_Allocator::instance ()->free (this->pos_arg_); - } - - struct Positional_Arg - { - Positional_Arg () - : type_ (PA_UNUSED) - {} - - enum { - PA_UNUSED, - PA_INT, PA_LONG, PA_LONGLONG, PA_INTMAX, PA_PTRDIFF, PA_SSIZE, - PA_UINT, PA_ULONG, PA_ULONGLONG, PA_UINTMAX, PA_UPTRDIFF, PA_SIZE, - PA_WINT, PA_DOUBLE, PA_LONGDOUBLE, - PA_PCHAR, PA_PWCHAR, PA_PVOID, - PA_PINT, PA_PINTMAX, PA_PLONG, PA_PLONGLONG, PA_PPTRDIFF, PA_PSHORT, - PA_PSCHAR, PA_PSSIZE - } type_; - - union - { - int i; - ACE_UINT64 ui64; - ACE_INT64 i64; - long double f; - void *p; - }; - }; - - static void conv_storage_needed (const char *fmt, int &storage_needed) - { - while (const char *f = ACE_OS::strpbrk (fmt, "*%")) - { - if (!*f || *f == '%') - break; - const int p = snprintf_positional (++f); - if (p > storage_needed) - storage_needed = p; - fmt = f; - } - } - - void scan (int n, const char *fmt, va_list ap) - { - int storage_needed = n; - const char *f = fmt; - conv_storage_needed (f, storage_needed); - while (const char *const pct = ACE_OS::strchr (f, '%')) - if (pct[1] == '%') - f = pct + 2; - else - { - const int p = snprintf_positional (++f); - if (p > storage_needed) - storage_needed = p; - conv_storage_needed (f, storage_needed); - } - - if (size_t (storage_needed) > - sizeof this->pos_storage_ / sizeof (Positional_Arg)) - this->pos_arg_ = static_cast ( - ACE_Allocator::instance ()->calloc ( - sizeof (Positional_Arg) * storage_needed)); - - f = fmt; - while (true) - { - static const char digits[] = "0123456789"; - f += ACE_OS::strspn (f, "-+ #0'"); - if (*f == '*') - (*this)[snprintf_positional (++f)].type_ = Positional_Arg::PA_INT; - else - f += ACE_OS::strspn (f, digits); - - if (f[0] == '.' && f[1] == '*') - { - f += 2; - (*this)[snprintf_positional (f)].type_ = Positional_Arg::PA_INT; - } - else if (*f == '.') - { - ++f; - f += ACE_OS::strspn (f, digits); - } - - Snprintf_Flags flags; - flags.parse_length (f); - - switch (*f) - { - case 'd': case 'i': - if (flags.has (SNPRINTF_LONG)) - (*this)[n].type_ = Positional_Arg::PA_LONG; - else if (flags.has (SNPRINTF_LONGLONG)) - (*this)[n].type_ = Positional_Arg::PA_LONGLONG; - else if (flags.has (SNPRINTF_INTMAX)) - (*this)[n].type_ = Positional_Arg::PA_INTMAX; - else if (flags.has (SNPRINTF_SIZET)) - (*this)[n].type_ = Positional_Arg::PA_SSIZE; - else if (flags.has (SNPRINTF_PTRDIFF)) - (*this)[n].type_ = Positional_Arg::PA_PTRDIFF; - else - (*this)[n].type_ = Positional_Arg::PA_INT; - break; - case 'o': case 'u': case 'x': case 'X': - if (flags.has (SNPRINTF_LONG)) - (*this)[n].type_ = Positional_Arg::PA_ULONG; - else if (flags.has (SNPRINTF_LONGLONG)) - (*this)[n].type_ = Positional_Arg::PA_ULONGLONG; - else if (flags.has (SNPRINTF_INTMAX)) - (*this)[n].type_ = Positional_Arg::PA_UINTMAX; - else if (flags.has (SNPRINTF_SIZET)) - (*this)[n].type_ = Positional_Arg::PA_SIZE; - else if (flags.has (SNPRINTF_PTRDIFF)) - (*this)[n].type_ = Positional_Arg::PA_UPTRDIFF; - else - (*this)[n].type_ = Positional_Arg::PA_UINT; - break; - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': - (*this)[n].type_ = flags.has (SNPRINTF_LONGDOUBLE) ? - Positional_Arg::PA_LONGDOUBLE : Positional_Arg::PA_DOUBLE; - break; - case 'c': - (*this)[n].type_ = flags.has (SNPRINTF_LONG) ? - Positional_Arg::PA_WINT : Positional_Arg::PA_INT; - break; - case 'C': - (*this)[n].type_ = Positional_Arg::PA_WINT; - break; - case 's': - (*this)[n].type_ = flags.has (SNPRINTF_LONG) ? - Positional_Arg::PA_PWCHAR : Positional_Arg::PA_PCHAR; - break; - case 'S': - (*this)[n].type_ = Positional_Arg::PA_PWCHAR; - break; - case 'p': - (*this)[n].type_ = Positional_Arg::PA_PVOID; - break; - case 'n': - if (flags.has (SNPRINTF_LONG)) - (*this)[n].type_ = Positional_Arg::PA_PLONG; - else if (flags.has (SNPRINTF_LONGLONG)) - (*this)[n].type_ = Positional_Arg::PA_PLONGLONG; - else if (flags.has (SNPRINTF_INTMAX)) - (*this)[n].type_ = Positional_Arg::PA_PINTMAX; - else if (flags.has (SNPRINTF_SIZET)) - (*this)[n].type_ = Positional_Arg::PA_PSSIZE; - else if (flags.has (SNPRINTF_PTRDIFF)) - (*this)[n].type_ = Positional_Arg::PA_PPTRDIFF; - else if (flags.has (SNPRINTF_SHORT)) - (*this)[n].type_ = Positional_Arg::PA_PSHORT; - else if (flags.has (SNPRINTF_CHAR)) - (*this)[n].type_ = Positional_Arg::PA_PSCHAR; - else - (*this)[n].type_ = Positional_Arg::PA_PINT; - break; - default: - break; - } - - // Find the next conversion and set n to the positional arg number - do - f = ACE_OS::strchr (f + 1, '%'); - while (f && f[1] == '%' && ++f); - - if (!f) - break; - n = snprintf_positional (++f); - } - - for (int i = 1; i <= storage_needed; ++i) - switch ((*this)[i].type_) - { - case Positional_Arg::PA_INT: - (*this)[i].i = va_arg (ap, int); - break; - case Positional_Arg::PA_LONG: - (*this)[i].i64 = va_arg (ap, long); - break; - case Positional_Arg::PA_LONGLONG: - (*this)[i].i64 = va_arg (ap, long long); - break; -#ifndef ACE_LACKS_STDINT_H - case Positional_Arg::PA_INTMAX: - (*this)[i].i64 = va_arg (ap, intmax_t); - break; -#endif - case Positional_Arg::PA_PTRDIFF: - (*this)[i].i64 = va_arg (ap, ptrdiff_t); - break; - case Positional_Arg::PA_SSIZE: - (*this)[i].i64 = va_arg (ap, ssize_t); - break; - case Positional_Arg::PA_UINT: - (*this)[i].ui64 = va_arg (ap, unsigned int); - break; - case Positional_Arg::PA_ULONG: - (*this)[i].ui64 = va_arg (ap, unsigned long); - break; - case Positional_Arg::PA_ULONGLONG: - (*this)[i].ui64 = va_arg (ap, unsigned long long); - break; -#ifndef ACE_LACKS_STDINT_H - case Positional_Arg::PA_UINTMAX: - (*this)[i].ui64 = va_arg (ap, uintmax_t); - break; -#endif - case Positional_Arg::PA_UPTRDIFF: - (*this)[i].ui64 = static_cast (va_arg (ap, ptrdiff_t)); - break; - case Positional_Arg::PA_SIZE: - (*this)[i].ui64 = va_arg (ap, size_t); - break; -#ifdef __MINGW32__ -#define ACE_WINT_T_VA_ARG int -#else -#define ACE_WINT_T_VA_ARG wint_t -#endif - case Positional_Arg::PA_WINT: - (*this)[i].ui64 = va_arg (ap, ACE_WINT_T_VA_ARG); - break; - case Positional_Arg::PA_DOUBLE: - (*this)[i].f = va_arg (ap, double); - break; - case Positional_Arg::PA_LONGDOUBLE: - (*this)[i].f = va_arg (ap, long double); - break; - case Positional_Arg::PA_PCHAR: - (*this)[i].p = va_arg (ap, char *); - break; - case Positional_Arg::PA_PWCHAR: - (*this)[i].p = va_arg (ap, wchar_t *); - break; - case Positional_Arg::PA_PVOID: - (*this)[i].p = va_arg (ap, void *); - break; - case Positional_Arg::PA_PINT: - (*this)[i].p = va_arg (ap, int *); - break; -#ifndef ACE_LACKS_STDINT_H - case Positional_Arg::PA_PINTMAX: - (*this)[i].p = va_arg (ap, intmax_t *); - break; -#endif - case Positional_Arg::PA_PLONG: - (*this)[i].p = va_arg (ap, long *); - break; - case Positional_Arg::PA_PLONGLONG: - (*this)[i].p = va_arg (ap, long long *); - break; - case Positional_Arg::PA_PPTRDIFF: - (*this)[i].p = va_arg (ap, ptrdiff_t *); - break; - case Positional_Arg::PA_PSHORT: - (*this)[i].p = va_arg (ap, short *); - break; - case Positional_Arg::PA_PSCHAR: - (*this)[i].p = va_arg (ap, signed char *); - break; - case Positional_Arg::PA_PSSIZE: - (*this)[i].p = va_arg (ap, ssize_t *); - break; - default: - break; - } - this->scanned_ = true; - } - - Positional_Arg &operator[] (int idx) - { - return this->pos_arg_[idx - 1]; - } - - Positional_Arg pos_storage_[10], *pos_arg_; - bool scanned_; - - private: - Snprintf_Positional_Args (const Snprintf_Positional_Args&); - Snprintf_Positional_Args& operator= (const Snprintf_Positional_Args&); - }; -} - -int -ACE_OS::vsnprintf_emulation (char *buf, size_t max, const char *fmt, va_list ap) -{ - if (max > INT_MAX) - { - errno = ACE_SNPRINTF_EOVERFLOW; - return -1; - } - - Snprintf_Buffer sb (buf, max); - Snprintf_Positional_Args pos_arg; - - while (const char *const pct = ACE_OS::strchr (fmt, '%')) - { - // Output up to next % in format string - const bool escaped = pct[1] == '%'; - const size_t non_conv = pct - fmt + escaped; - sb.out (fmt, non_conv); - fmt += 1 + non_conv; - if (escaped) - continue; - - // Check if positional args are used (%1$d) - const int posn = snprintf_positional (fmt); - if (posn && !pos_arg.scanned_) - pos_arg.scan (posn, fmt, ap); // POSIX extension - - // Parse flags (+- #'0) - Snprintf_Flags flags (fmt); - - // Parse field width (integer, *, or *n$) - static const int WIDTH_PREC_UNSPEC = -1; - int width = WIDTH_PREC_UNSPEC; - if (*fmt == '*') - { - ++fmt; - const int width_p = snprintf_positional (fmt); - width = width_p ? pos_arg[width_p].i : va_arg (ap, int); - flags.width (width); - } - else if (*fmt >= '1' && *fmt <= '9') - { - width = snprintf_read_int (fmt); - if (width == -1) - return -1; - } - - // Parse precision (.integer, .*, or .*n$) - int precision = WIDTH_PREC_UNSPEC; - if (fmt[0] == '.' && fmt[1] == '*') - { - fmt += 2; - const int prec_p = snprintf_positional (fmt); - precision = prec_p ? pos_arg[prec_p].i : va_arg (ap, int); - if (precision < 0) - precision = WIDTH_PREC_UNSPEC; - } - else if (*fmt == '.') - { - precision = snprintf_read_int (++fmt); - if (precision == -1) - return -1; - } - - flags.parse_length (fmt); - - // would be nice to have a helper function for this, but va_list - // can't portably be passed to another function (even by pointer) -#ifdef ACE_LACKS_STDINT_H -# define GET_UNSIGNED_INTMAX -#else -# define GET_UNSIGNED_INTMAX \ - else if (flags.has (SNPRINTF_INTMAX)) \ - val = va_arg (ap, uintmax_t); -#endif -#define GET_UNSIGNED_VA \ - if (posn) \ - val = pos_arg[posn].ui64; \ - else if (flags.has (SNPRINTF_LONGLONG)) \ - val = va_arg (ap, unsigned long long); \ - else if (flags.has (SNPRINTF_LONG)) \ - val = va_arg (ap, unsigned long); \ - GET_UNSIGNED_INTMAX \ - else if (flags.has (SNPRINTF_SIZET)) \ - val = va_arg (ap, size_t); \ - else if (flags.has (SNPRINTF_PTRDIFF)) \ - val = static_cast (va_arg (ap, ptrdiff_t)); \ - else \ - val = va_arg (ap, unsigned int); \ - if (flags.has (SNPRINTF_SHORT)) \ - val = static_cast (val); \ - else if (flags.has (SNPRINTF_CHAR)) \ - val = static_cast (val) - -#define GET_ARG(MEMBER, TYPE) \ - (posn ? static_cast (pos_arg[posn].MEMBER) : va_arg (ap, TYPE)) - - ACE_UINT64 val; - ACE_INT64 sval; - long double fval; - wchar_t tmp_wstr[2] = {}; - - // Parse conversion specifier (diouxXfFeEgGaAcCsSpn) and convert arg - char spec = *fmt++; - flags.conv_spec (spec); - switch (spec) - { - case 'd': case 'i': - if (posn) - sval = flags.has_some (SNPRINTF_LARGE_INT) - ? pos_arg[posn].i64 : pos_arg[posn].i; - else if (flags.has (SNPRINTF_LONGLONG)) - sval = va_arg (ap, long long); - else if (flags.has (SNPRINTF_LONG)) - sval = va_arg (ap, long); -#ifndef ACE_LACKS_STDINT_H - else if (flags.has (SNPRINTF_INTMAX)) - sval = va_arg (ap, intmax_t); -#endif - else if (flags.has (SNPRINTF_SIZET)) - sval = va_arg (ap, ssize_t); - else if (flags.has (SNPRINTF_PTRDIFF)) - sval = va_arg (ap, ptrdiff_t); - else - sval = va_arg (ap, int); - - if (flags.has (SNPRINTF_SHORT)) - sval = static_cast (sval); - else if (flags.has (SNPRINTF_CHAR)) - sval = static_cast (sval); - - flags.value (sval); - sb.conv_int (sval, flags, width, precision); - break; - - case 'o': - GET_UNSIGNED_VA; - sb.conv_int (val, flags, width, precision, 8); - break; - - case 'u': - GET_UNSIGNED_VA; - sb.conv_int (val, flags, width, precision); - break; - - case 'x': - GET_UNSIGNED_VA; - sb.conv_int (val, flags, width, precision, 16); - break; - - case 'f': - fval = posn ? pos_arg[posn].f : - (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double) - : va_arg (ap, double)); - sb.conv_float (fval, flags, width, precision); - break; - - case 'e': - fval = posn ? pos_arg[posn].f : - (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double) - : va_arg (ap, double)); - sb.conv_float (fval, flags, width, precision); - break; - - case 'g': - fval = posn ? pos_arg[posn].f : - (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double) - : va_arg (ap, double)); - sb.conv_float (fval, flags, width, precision); - break; - - case 'a': - fval = posn ? pos_arg[posn].f : - (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double) - : va_arg (ap, double)); - sb.conv_float (fval, flags, width, precision); - break; - - case 'c': - if (flags.has (SNPRINTF_LONG)) - { - *tmp_wstr = static_cast ( - posn ? pos_arg[posn].ui64 : va_arg (ap, ACE_WINT_T_VA_ARG)); - sb.conv_str (tmp_wstr, flags, width, precision); - } - else - sb.conv_char (static_cast (GET_ARG (i, int)), - flags, width); - break; - - case 's': - if (flags.has (SNPRINTF_LONG)) - sb.conv_str (GET_ARG (p, const wchar_t *), flags, width, precision); - else - sb.conv_str (GET_ARG (p, const char *), flags, width, precision); - break; - - case 'p': - val = reinterpret_cast (GET_ARG (p, void *)); - sb.conv_int (val, flags, width, precision, 16); - break; - - case 'n': - if (flags.has (SNPRINTF_LONGLONG)) - *GET_ARG (p, long long *) = sb.written_; - else if (flags.has (SNPRINTF_LONG)) - *GET_ARG (p, long *) = static_cast (sb.written_); -#ifndef ACE_LACKS_STDINT_H - else if (flags.has (SNPRINTF_INTMAX)) - *GET_ARG (p, intmax_t *) = sb.written_; -#endif - else if (flags.has (SNPRINTF_SIZET)) - *GET_ARG (p, ssize_t *) = sb.written_; - else if (flags.has (SNPRINTF_PTRDIFF)) - *GET_ARG (p, ptrdiff_t *) = sb.written_; - else if (flags.has (SNPRINTF_SHORT)) - *GET_ARG (p, short *) = static_cast (sb.written_); - else if (flags.has (SNPRINTF_CHAR)) - *GET_ARG (p, signed char *) = - static_cast (sb.written_); - else - *GET_ARG (p, int *) = static_cast (sb.written_); - break; - - default: - break; - } - } - - // Output remaining part of format string - sb.out (fmt, ACE_OS::strlen (fmt)); - *sb.buf_ = 0; - return static_cast (sb.written_); -} -#endif // ACE_HAS_VSNPRINTF_EMULATION ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_stdio.h b/dep/acelite/ace/OS_NS_stdio.h index 8895c77b0..ba8faabdf 100644 --- a/dep/acelite/ace/OS_NS_stdio.h +++ b/dep/acelite/ace/OS_NS_stdio.h @@ -4,7 +4,9 @@ /** * @file OS_NS_stdio.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_stdio.h 97921 2014-10-10 21:58:31Z shuston $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -47,6 +49,7 @@ * as macros on some platforms. This way macro definitions will * be usable later as there is no way to save the macro definition * using the pre-processor. + * */ inline void ace_clearerr_helper (FILE *stream) { @@ -68,7 +71,6 @@ inline int ace_fgetc_helper (FILE *fp) #endif /* defined (fgetc) */ } -#if !defined (ACE_LACKS_FPUTC) inline int ace_fputc_helper (int ch, FILE *fp) { #if defined (fputc) @@ -78,9 +80,7 @@ inline int ace_fputc_helper (int ch, FILE *fp) return ACE_STD_NAMESPACE::fputc (ch, fp); #endif /* defined (fputc) */ } -#endif /* !ACE_LACKS_FPUTC */ -#if !defined (ACE_LACKS_GETC) inline int ace_getc_helper (FILE *fp) { #if defined (getc) @@ -90,25 +90,17 @@ inline int ace_getc_helper (FILE *fp) return ACE_STD_NAMESPACE::getc (fp); #endif /* defined (getc) */ } -#elif defined getc -# undef getc -#endif /* !ACE_LACKS_GETC */ inline int ace_putc_helper (int ch, FILE *fp) { #if defined (putc) return putc (ch, fp); #undef putc -#elif !defined (ACE_LACKS_PUTC) - return ACE_STD_NAMESPACE::putc (ch, fp); #else - ACE_UNUSED_ARG (ch); - ACE_UNUSED_ARG (fp); - return -1; + return ACE_STD_NAMESPACE::putc (ch, fp); #endif /* defined (putc) */ } -#if !defined (ACE_LACKS_UNGETC) inline int ace_ungetc_helper (int ch, FILE *fp) { #if defined (ungetc) @@ -118,7 +110,6 @@ inline int ace_ungetc_helper (int ch, FILE *fp) return ACE_STD_NAMESPACE::ungetc (ch, fp); #endif /* defined (ungetc) */ } -#endif /* !ACE_LACKS_UNGETC */ #if !defined ACE_FILENO_EQUIVALENT inline ACE_HANDLE ace_fileno_helper (FILE *fp) @@ -381,13 +372,9 @@ namespace ACE_OS { #endif /* ACE_WIN32 */ -#ifdef ACE_STDIO_USE_STDLIB_FOR_VARARGS - using ::fprintf; -#else extern ACE_Export int fprintf (FILE *fp, const char *format, ...) ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 3); -#endif # if defined (ACE_HAS_WCHAR) extern ACE_Export @@ -452,13 +439,9 @@ namespace ACE_OS { void perror (const wchar_t *s); #endif /* ACE_HAS_WCHAR */ -#if defined ACE_FACE_DEV && defined ACE_STDIO_USE_STDLIB_FOR_VARARGS - using ::printf; -#else extern ACE_Export int printf (const char *format, ...) ACE_GCC_FORMAT_ATTRIBUTE (printf, 1, 2); -#endif #if defined (ACE_HAS_WCHAR) extern ACE_Export @@ -488,13 +471,9 @@ namespace ACE_OS { ACE_NAMESPACE_INLINE_FUNCTION void rewind (FILE *fp); -#if defined ACE_STDIO_USE_STDLIB_FOR_VARARGS && !defined ACE_LACKS_SNPRINTF - using ::snprintf; -#else extern ACE_Export int snprintf (char *buf, size_t maxlen, const char *format, ...) ACE_GCC_FORMAT_ATTRIBUTE (printf, 3, 4); -#endif # if defined (ACE_HAS_WCHAR) extern ACE_Export @@ -542,7 +521,7 @@ namespace ACE_OS { int vsnprintf (char *buffer, size_t maxlen, const char *format, va_list argptr) ACE_GCC_FORMAT_ATTRIBUTE (printf, 3, 0); -#if defined (ACE_HAS_WCHAR) +# if defined (ACE_HAS_WCHAR) ACE_NAMESPACE_INLINE_FUNCTION int vasprintf (wchar_t **bufp, const wchar_t *format, va_list argptr); @@ -557,24 +536,19 @@ namespace ACE_OS { ACE_NAMESPACE_INLINE_FUNCTION int vsnprintf (wchar_t *buffer, size_t maxlen, const wchar_t *format, va_list argptr); -#endif /* ACE_HAS_WCHAR */ +# endif /* ACE_HAS_WCHAR */ -#if defined (ACE_HAS_VSNPRINTF_EMULATION) - extern ACE_Export - int vsnprintf_emulation (char *buf, size_t max, const char *fmt, va_list ap); -#endif - -#if !defined (ACE_HAS_VASPRINTF) && !defined (ACE_LACKS_VA_COPY) +#if !defined (ACE_HAS_VASPRINTF) extern ACE_Export int vasprintf_emulation (char **bufp, const char *format, va_list argptr); -#endif +#endif /* !ACE_HAS_VASPRINTF */ -#if !defined (ACE_HAS_VASWPRINTF) && !defined (ACE_LACKS_VA_COPY) #if defined (ACE_HAS_WCHAR) +#if !defined (ACE_HAS_VASWPRINTF) extern ACE_Export int vaswprintf_emulation (wchar_t **bufp, const wchar_t *format, va_list argptr); -#endif /* ACE_HAS_WCHAR */ #endif /* !ACE_HAS_VASWPRINTF */ +#endif /* ACE_HAS_WCHAR */ } /* namespace ACE_OS */ diff --git a/dep/acelite/ace/OS_NS_stdio.inl b/dep/acelite/ace/OS_NS_stdio.inl index 28da671ea..c766b0881 100644 --- a/dep/acelite/ace/OS_NS_stdio.inl +++ b/dep/acelite/ace/OS_NS_stdio.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_stdio.inl 97921 2014-10-10 21:58:31Z shuston $ + #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_stdlib.h" #include "ace/OS_NS_fcntl.h" @@ -13,10 +16,6 @@ # include #endif /* ACE_HAS_TRIO */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - /*****************************************************************************/ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -170,13 +169,8 @@ ACE_OS::flock_destroy (ACE_OS::ace_flock_t *lock, { if (unlink_file) ACE_OS::unlink (lock->lockname_); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free ( - static_cast (const_cast (lock->lockname_))); -#else ACE_OS::free ( static_cast (const_cast (lock->lockname_))); -#endif /* ACE_HAS_ALLOC_HOOKS */ } lock->lockname_ = 0; } @@ -381,10 +375,7 @@ ACE_OS::cuserid (char *user, size_t maxlen) return user; #elif defined (ACE_HAS_ALT_CUSERID) # if defined (ACE_LACKS_PWD_FUNCTIONS) - ACE_UNUSED_ARG (user); - ACE_UNUSED_ARG (maxlen); - ACE_NOTSUP_RETURN (0); - //# error Cannot use alternate cuserid() without POSIX password functions! +# error Cannot use alternate cuserid() without POSIX password functions! # endif /* ACE_LACKS_PWD_FUNCTIONS */ // POSIX.1 dropped the cuserid() function. @@ -555,52 +546,28 @@ ACE_OS::fflush (FILE *fp) } ACE_INLINE int -ACE_OS::fgetc (FILE *fp) +ACE_OS::fgetc (FILE* fp) { return ace_fgetc_helper (fp); } ACE_INLINE int -ACE_OS::getc (FILE *fp) +ACE_OS::getc (FILE* fp) { -#ifdef ACE_LACKS_GETC - ACE_UNUSED_ARG (fp); - ACE_NOTSUP_RETURN (-1); -#else return ace_getc_helper (fp); -#endif } ACE_INLINE int -ACE_OS::fgetpos (FILE *fp, fpos_t *pos) +ACE_OS::fgetpos (FILE* fp, fpos_t* pos) { -#ifdef ACE_LACKS_FGETPOS - ACE_UNUSED_ARG (fp); - ACE_UNUSED_ARG (pos); - ACE_NOTSUP_RETURN (-1); -#else ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1); -#endif } ACE_INLINE char * ACE_OS::fgets (char *buf, int size, FILE *fp) { ACE_OS_TRACE ("ACE_OS::fgets"); -#if defined (ACE_LACKS_FGETS) - char *iter = buf; - int c = EOF; - for (int i = 0; i < size - 1 && c != '\n'; ++i) - { - c = ACE_STD_NAMESPACE::fgetc (fp); - if (c != EOF) - *iter++ = static_cast (c); - } - *iter = '\0'; - return c == EOF ? 0 : buf; -#else ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0); -#endif /* ACE_LACKS_FGETS */ } #if defined (ACE_HAS_WCHAR) && !defined(ACE_LACKS_FGETWS) @@ -679,50 +646,26 @@ ACE_OS::fopen (const wchar_t *filename, const char *mode) ACE_INLINE int ACE_OS::ungetc (int c, FILE *fp) { -#ifdef ACE_LACKS_UNGETC - ACE_UNUSED_ARG (c); - ACE_UNUSED_ARG (fp); - ACE_NOTSUP_RETURN (-1); -#else return ace_ungetc_helper (c, fp); -#endif } ACE_INLINE int ACE_OS::fputc (int c, FILE *fp) { -#ifdef ACE_LACKS_FPUTC - ACE_UNUSED_ARG (c); - ACE_UNUSED_ARG (fp); - ACE_NOTSUP_RETURN (-1); -#else return ace_fputc_helper (c, fp); -#endif } ACE_INLINE int ACE_OS::putc (int c, FILE *fp) { -#ifdef ACE_LACKS_PUTC - ACE_UNUSED_ARG (c); - ACE_UNUSED_ARG (fp); - ACE_NOTSUP_RETURN (-1); -#else return ace_putc_helper (c, fp); -#endif } ACE_INLINE int ACE_OS::fputs (const char *s, FILE *stream) { ACE_OS_TRACE ("ACE_OS::fputs"); -#ifdef ACE_LACKS_FPUTS - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (stream); - ACE_NOTSUP_RETURN (-1); -#else ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1); -#endif } #if defined (ACE_HAS_WCHAR) && !defined(ACE_LACKS_FPUTWS) @@ -764,8 +707,8 @@ ACE_OS::freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream) ACE_INLINE int ACE_OS::fseek (FILE *fp, long offset, int whence) { -#if defined (ACE_WIN32) -# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END +# if defined (ACE_WIN32) +# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END //#error Windows NT is evil AND rude! switch (whence) { @@ -782,21 +725,15 @@ ACE_OS::fseek (FILE *fp, long offset, int whence) errno = EINVAL; return -1; // rather safe than sorry } -# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ -#endif /* ACE_WIN32 */ +# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ +# endif /* ACE_WIN32 */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1); } ACE_INLINE int ACE_OS::fsetpos (FILE* fp, fpos_t* pos) { -#if defined (ACE_LACKS_FSETPOS) - ACE_UNUSED_ARG (fp); - ACE_UNUSED_ARG (pos); - ACE_NOTSUP_RETURN (-1); -#else ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1); -#endif /* ACE_LACKS_FSETPOS */ } ACE_INLINE long @@ -845,12 +782,7 @@ ACE_INLINE int ACE_OS::puts (const char *s) { ACE_OS_TRACE ("ACE_OS::puts"); -#if defined (ACE_LACKS_PUTS) - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (-1); -#else ACE_OSCALL_RETURN (::puts (s), int, -1); -#endif /* ACE_LACKS_PUTS */ } #if defined (ACE_HAS_WCHAR) @@ -873,12 +805,7 @@ ACE_OS::rename (const char *old_name, const char *new_name, int flags) { -# if defined (ACE_LACKS_RENAME) - ACE_UNUSED_ARG (old_name); - ACE_UNUSED_ARG (new_name); - ACE_UNUSED_ARG (flags); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WINCE) +# if defined (ACE_HAS_WINCE) // Win CE is always wide-char. ACE_UNUSED_ARG (flags); if (0 == ::MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name), @@ -907,12 +834,7 @@ ACE_OS::rename (const wchar_t *old_name, const wchar_t *new_name, int flags) { -# if defined (ACE_LACKS_RENAME) - ACE_UNUSED_ARG (old_name); - ACE_UNUSED_ARG (new_name); - ACE_UNUSED_ARG (flags); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WINCE) +# if defined (ACE_HAS_WINCE) ACE_UNUSED_ARG (flags); if (::MoveFileW (old_name, new_name) == 0) ACE_FAIL_RETURN (-1); @@ -943,11 +865,7 @@ ACE_OS::rewind (FILE *fp) { #if !defined (ACE_HAS_WINCE) ACE_OS_TRACE ("ACE_OS::rewind"); -# if defined (ACE_LACKS_REWIND) - ACE_UNUSED_ARG (fp); -# else ::rewind (fp); -# endif /* ACE_LACKS_REWIND */ #else // This isn't perfect since it doesn't reset EOF, but it's probably // the closest we can get on WINCE. @@ -966,8 +884,6 @@ ACE_OS::tempnam (const char *dir, const char *pfx) ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_NONCONST_TEMPNAM) ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (const_cast (dir), const_cast (pfx)), char *, 0); -#elif defined (ACE_TEMPNAM_EQUIVALENT) - ACE_OSCALL_RETURN (ACE_TEMPNAM_EQUIVALENT (dir, pfx), char *, 0); #else /* ACE_LACKS_TEMPNAM */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (dir, pfx), char *, 0); #endif /* ACE_LACKS_TEMPNAM */ @@ -1016,11 +932,6 @@ ACE_OS::vasprintf (char **bufp, const char* format, va_list argptr) { #if defined (ACE_HAS_VASPRINTF) return ::vasprintf (bufp, format, argptr); -#elif defined (ACE_LACKS_VA_COPY) - ACE_UNUSED_ARG (bufp); - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (argptr); - ACE_NOTSUP_RETURN (-1); #else return ACE_OS::vasprintf_emulation (bufp, format, argptr); #endif /* ACE_HAS_VASPRINTF */ @@ -1032,11 +943,6 @@ ACE_OS::vasprintf (wchar_t **bufp, const wchar_t* format, va_list argptr) { #if defined (ACE_HAS_VASWPRINTF) return ::vaswprintf (bufp, format, argptr); -#elif defined (ACE_LACKS_VA_COPY) - ACE_UNUSED_ARG (bufp); - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (argptr); - ACE_NOTSUP_RETURN (-1); #else return ACE_OS::vaswprintf_emulation (bufp, format, argptr); #endif /* ACE_HAS_VASWPRINTF */ @@ -1046,13 +952,7 @@ ACE_OS::vasprintf (wchar_t **bufp, const wchar_t* format, va_list argptr) ACE_INLINE int ACE_OS::vprintf (const char *format, va_list argptr) { -#if defined (ACE_LACKS_VPRINTF) - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (argptr); - ACE_NOTSUP_RETURN (-1); -#else return ::vprintf (format, argptr); -#endif /* ACE_LACKS_VPRINTF */ } #if defined (ACE_HAS_WCHAR) @@ -1072,14 +972,7 @@ ACE_OS::vprintf (const wchar_t *format, va_list argptr) ACE_INLINE int ACE_OS::vfprintf (FILE *fp, const char *format, va_list argptr) { -#ifdef ACE_LACKS_VFPRINTF - ACE_UNUSED_ARG (fp); - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (argptr); - ACE_NOTSUP_RETURN (-1); -#else return ACE_STD_NAMESPACE::vfprintf (fp, format, argptr); -#endif } #if defined (ACE_HAS_WCHAR) @@ -1100,14 +993,7 @@ ACE_OS::vfprintf (FILE *fp, const wchar_t *format, va_list argptr) ACE_INLINE int ACE_OS::vsprintf (char *buffer, const char *format, va_list argptr) { -#ifdef ACE_LACKS_VSPRINTF - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (argptr); - ACE_NOTSUP_RETURN (-1); -#else return ::vsprintf (buffer, format, argptr); -#endif /* ACE_LACKS_VSPRINTF */ } #if defined (ACE_HAS_WCHAR) @@ -1183,8 +1069,6 @@ ACE_OS::vsnprintf (char *buffer, size_t maxlen, const char *format, va_list ap) return result; #elif defined (ACE_HAS_TRIO) return trio_vsnprintf (buffer, maxlen, format, ap); -#elif defined (ACE_HAS_VSNPRINTF_EMULATION) - return vsnprintf_emulation (buffer, maxlen, format, ap); #else ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (maxlen); diff --git a/dep/acelite/ace/OS_NS_stdlib.cpp b/dep/acelite/ace/OS_NS_stdlib.cpp index e73808e9a..2b19794b3 100644 --- a/dep/acelite/ace/OS_NS_stdlib.cpp +++ b/dep/acelite/ace/OS_NS_stdlib.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_stdlib.cpp 97921 2014-10-10 21:58:31Z shuston $ + #include "ace/OS_NS_stdlib.h" #include "ace/Default_Constants.h" @@ -26,10 +28,6 @@ # include "ace/Numeric_Limits.h" #endif /* ACE_LACKS_MKSTEMP */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0; @@ -61,21 +59,15 @@ ACE_OS::exit (int status) #if defined (ACE_WIN32) ::ExitProcess ((UINT) status); -#elif !defined ACE_LACKS_EXIT - ::exit (status); #else - ACE_UNUSED_ARG (status); + ::exit (status); #endif /* ACE_WIN32 */ } void ACE_OS::free (void *ptr) { -#if defined (ACE_LACKS_FREE) - ACE_UNUSED_ARG (ptr); -#else ACE_FREE_FUNC (ACE_MALLOC_T (ptr)); -#endif } // You may be asking yourself, why are we doing this? Well, in winbase.h, @@ -140,11 +132,7 @@ ACE_OS::strenvdup (const ACE_TCHAR *str) if (buf_len > ACE_DEFAULT_ARGV_BUFSIZ) { buf_p = -#if defined (ACE_HAS_ALLOC_HOOKS) - (ACE_TCHAR *) ACE_Allocator::instance()->malloc (buf_len * sizeof (ACE_TCHAR)); -#else (ACE_TCHAR *) ACE_OS::malloc (buf_len * sizeof (ACE_TCHAR)); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (buf_p == 0) { errno = ENOMEM; @@ -289,7 +277,7 @@ ACE_OS::malloc (size_t nbytes) return ACE_MALLOC_FUNC (nbytes); } -#if defined (ACE_LACKS_MKTEMP) && !defined (ACE_DISABLE_MKTEMP) +#if defined (ACE_LACKS_MKTEMP) && !defined (ACE_DISBALE_MKTEMP) ACE_TCHAR * ACE_OS::mktemp (ACE_TCHAR *s) { @@ -297,51 +285,52 @@ ACE_OS::mktemp (ACE_TCHAR *s) if (s == 0) // check for null template string failed! return 0; - - ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX")); - if (xxxxxx == 0) - // the template string doesn't contain "XXXXXX"! - return s; - - // Find an unused filename for this process. It is assumed - // that the user will open the file immediately after - // getting this filename back (so, yes, there is a race - // condition if multiple threads in a process use the same - // template). This appears to match the behavior of the - // SunOS 5.5 mktemp(). - bool found = false; - for (ACE_TCHAR letter = ACE_TEXT ('a'); - letter <= ACE_TEXT ('z'); - ++letter) + else { - ACE_stat sb; - ACE_OS::snprintf (xxxxxx, 7, - ACE_TEXT ("%05d%c"), - (int)ACE_OS::getpid () % 100000, - letter); - if (ACE_OS::stat (s, &sb) < 0) + ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX")); + + if (xxxxxx == 0) + // the template string doesn't contain "XXXXXX"! + return s; + else { - found = true; - break; + ACE_TCHAR unique_letter = ACE_TEXT ('a'); + ACE_stat sb; + + // Find an unused filename for this process. It is assumed + // that the user will open the file immediately after + // getting this filename back (so, yes, there is a race + // condition if multiple threads in a process use the same + // template). This appears to match the behavior of the + // SunOS 5.5 mktemp(). + ACE_OS::sprintf (xxxxxx, + ACE_TEXT ("%05d%c"), + ACE_OS::getpid (), + unique_letter); + while (ACE_OS::stat (s, &sb) >= 0) + { + if (++unique_letter <= ACE_TEXT ('z')) + ACE_OS::sprintf (xxxxxx, + ACE_TEXT ("%05d%c"), + ACE_OS::getpid (), + unique_letter); + else + { + // maximum of 26 unique files per template, per process + ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT ("")); + return s; + } + } } + return s; } - if (!found) - // maximum of 26 unique files per template, per process - xxxxxx[0] = ACE_TEXT ('\0'); - return s; } -#endif /* ACE_LACKS_MKTEMP && !ACE_DISABLE_MKTEMP */ +#endif /* ACE_LACKS_MKTEMP &7 !ACE_DISABLE_MKTEMP */ void * ACE_OS::realloc (void *ptr, size_t nbytes) { -#ifdef ACE_LACKS_REALLOC - ACE_UNUSED_ARG (ptr); - ACE_UNUSED_ARG (nbytes); - ACE_NOTSUP_RETURN (0); -#else return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes); -#endif } #if defined (ACE_LACKS_REALPATH) @@ -378,11 +367,7 @@ ACE_OS::realpath (const char *file_name, // To match glibc realpath() and Win32 _fullpath() behavior, // allocate room for the return value if resolved_name is // a null pointer. -#if defined (ACE_HAS_ALLOC_HOOKS) - rpath = static_cast(ACE_Allocator::instance()->malloc (PATH_MAX)); -#else rpath = static_cast(ACE_OS::malloc (PATH_MAX)); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (rpath == 0) { errno = ENOMEM; @@ -402,11 +387,7 @@ ACE_OS::realpath (const char *file_name, if (ACE_OS::getcwd (rpath, PATH_MAX) == 0) { if (resolved_name == 0) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (rpath); -#else ACE_OS::free (rpath); -#endif /* ACE_HAS_ALLOC_HOOKS */ return 0; } dest = ACE_OS::strchr (rpath, '\0'); @@ -439,11 +420,7 @@ ACE_OS::realpath (const char *file_name, { errno = ENAMETOOLONG; if (resolved_name == 0) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (rpath); -#else ACE_OS::free (rpath); -#endif /* ACE_HAS_ALLOC_HOOKS */ return 0; } } @@ -474,11 +451,7 @@ ACE_OS::realpath (const char *file_name, if (ACE_OS::lstat(rpath, &st) < 0) { if (resolved_name == 0) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (rpath); -#else - ACE_OS::free (rpath); -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_OS::free (rpath); return 0; } @@ -489,11 +462,7 @@ ACE_OS::realpath (const char *file_name, { errno = ELOOP; if (resolved_name == 0) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (rpath); -#else ACE_OS::free (rpath); -#endif /* ACE_HAS_ALLOC_HOOKS */ return 0; } @@ -507,11 +476,7 @@ ACE_OS::realpath (const char *file_name, { errno = ENAMETOOLONG; if (resolved_name == 0) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (rpath); -#else ACE_OS::free (rpath); -#endif /* ACE_HAS_ALLOC_HOOKS */ return 0; } @@ -545,11 +510,11 @@ ACE_OS::realpath (const char *file_name, long ACE_OS::strtol_emulation (const char *nptr, char **endptr, int base) { - const char *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const char *s = nptr; + ACE_REGISTER unsigned long acc; + ACE_REGISTER int c; + ACE_REGISTER unsigned long cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. @@ -627,11 +592,11 @@ ACE_OS::wcstol_emulation (const wchar_t *nptr, wchar_t **endptr, int base) { - const wchar_t *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const wchar_t *s = nptr; + ACE_REGISTER unsigned long acc; + ACE_REGISTER int c; + ACE_REGISTER unsigned long cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. @@ -693,13 +658,13 @@ ACE_OS::wcstol_emulation (const wchar_t *nptr, unsigned long ACE_OS::strtoul_emulation (const char *nptr, char **endptr, - int base) + ACE_REGISTER int base) { - const char *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const char *s = nptr; + ACE_REGISTER unsigned long acc; + ACE_REGISTER int c; + ACE_REGISTER unsigned long cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * See strtol for comments as to the logic used. @@ -765,11 +730,11 @@ ACE_OS::wcstoul_emulation (const wchar_t *nptr, wchar_t **endptr, int base) { - const wchar_t *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const wchar_t *s = nptr; + ACE_REGISTER unsigned long acc; + ACE_REGISTER int c; + ACE_REGISTER unsigned long cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * See strtol for comments as to the logic used. @@ -832,13 +797,13 @@ ACE_OS::wcstoul_emulation (const wchar_t *nptr, ACE_INT64 ACE_OS::strtoll_emulation (const char *nptr, char **endptr, - int base) + ACE_REGISTER int base) { - const char *s = nptr; - ACE_UINT64 acc; - int c; - ACE_UINT64 cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const char *s = nptr; + ACE_REGISTER ACE_UINT64 acc; + ACE_REGISTER int c; + ACE_REGISTER ACE_UINT64 cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. @@ -902,11 +867,11 @@ ACE_OS::wcstoll_emulation (const wchar_t *nptr, wchar_t **endptr, int base) { - const wchar_t *s = nptr; - ACE_UINT64 acc; - int c; - ACE_UINT64 cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const wchar_t *s = nptr; + ACE_REGISTER ACE_UINT64 acc; + ACE_REGISTER int c; + ACE_REGISTER ACE_UINT64 cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. @@ -969,13 +934,13 @@ ACE_OS::wcstoll_emulation (const wchar_t *nptr, ACE_UINT64 ACE_OS::strtoull_emulation (const char *nptr, char **endptr, - int base) + ACE_REGISTER int base) { - const char *s = nptr; - ACE_UINT64 acc; - int c; - ACE_UINT64 cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const char *s = nptr; + ACE_REGISTER ACE_UINT64 acc; + ACE_REGISTER int c; + ACE_REGISTER ACE_UINT64 cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * See strtol for comments as to the logic used. @@ -1041,11 +1006,11 @@ ACE_OS::wcstoull_emulation (const wchar_t *nptr, wchar_t **endptr, int base) { - const wchar_t *s = nptr; - ACE_UINT64 acc; - int c; - ACE_UINT64 cutoff; - int neg = 0, any, cutlim; + ACE_REGISTER const wchar_t *s = nptr; + ACE_REGISTER ACE_UINT64 acc; + ACE_REGISTER int c; + ACE_REGISTER ACE_UINT64 cutoff; + ACE_REGISTER int neg = 0, any, cutlim; /* * See strtol for comments as to the logic used. @@ -1138,10 +1103,7 @@ ACE_OS::mkstemp_emulation (ACE_TCHAR * s) // Add the process and thread ids to ensure uniqueness. msec += ACE_OS::getpid(); - -#ifndef ACE_THREAD_T_IS_A_STRUCT msec += (size_t) ACE_OS::thr_self(); -#endif // ACE_thread_t may be a char* (returned by ACE_OS::thr_self()) so // we need to use a C-style cast as a catch-all in order to use a diff --git a/dep/acelite/ace/OS_NS_stdlib.h b/dep/acelite/ace/OS_NS_stdlib.h index 16209b672..ac02a585f 100644 --- a/dep/acelite/ace/OS_NS_stdlib.h +++ b/dep/acelite/ace/OS_NS_stdlib.h @@ -4,7 +4,9 @@ /** * @file OS_NS_stdlib.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_stdlib.h 97921 2014-10-10 21:58:31Z shuston $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -46,6 +48,11 @@ extern "C" { } #endif /* ACE_WIN32 && _MSC_VER */ +// FreeBSD has atop macro (not related to ACE_OS::atop) +#if defined (atop) +# undef atop +#endif + /* * We inline and undef some functions that may be implemented * as macros on some platforms. This way macro definitions will @@ -77,18 +84,6 @@ inline ACE_INT64 ace_strtoull_helper (const char *s, char **ptr, int base) } #endif /* !ACE_LACKS_STRTOULL && !ACE_STRTOULL_EQUIVALENT */ -#if !defined (ACE_LACKS_RAND_R) -inline int ace_rand_r_helper (unsigned *seed) -{ -# if defined (rand_r) - return rand_r (seed); -# undef rand_r -# else - return ACE_STD_NAMESPACE::rand_r (seed); -# endif /* rand_r */ -} -#endif /* !ACE_LACKS_RAND_R */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_OS { diff --git a/dep/acelite/ace/OS_NS_stdlib.inl b/dep/acelite/ace/OS_NS_stdlib.inl index cb59874b3..f65a9675c 100644 --- a/dep/acelite/ace/OS_NS_stdlib.inl +++ b/dep/acelite/ace/OS_NS_stdlib.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_stdlib.inl 97921 2014-10-10 21:58:31Z shuston $ + #include "ace/config-all.h" /* Need ACE_TRACE */ #include "ace/Object_Manager_Base.h" #include "ace/OS_NS_string.h" @@ -25,13 +28,10 @@ ACE_OS::_exit (int status) ACE_OS_TRACE ("ACE_OS::_exit"); #if defined (ACE_VXWORKS) ::exit (status); -#elif defined (ACE_HAS_WINCE) - ::TerminateProcess (::GetCurrentProcess (), status); -#elif !defined (ACE_LACKS__EXIT) - ::_exit (status); +#elif !defined (ACE_HAS_WINCE) + ::_exit (status); #else - ACE_UNUSED_ARG (status); - + ::TerminateProcess (::GetCurrentProcess (), status); #endif /* ACE_VXWORKS */ } @@ -42,7 +42,7 @@ ACE_OS::abort (void) ACE_OS::_exit (128 + SIGABRT); #elif !defined (ACE_LACKS_ABORT) ::abort (); -#elif !defined (ACE_LACKS_EXIT) +#else exit (1); #endif /* !ACE_LACKS_ABORT */ } @@ -339,8 +339,6 @@ ACE_OS::putenv (const char *string) #elif defined (ACE_LACKS_PUTENV) ACE_UNUSED_ARG (string); ACE_NOTSUP_RETURN (0); -#elif defined (ACE_PUTENV_EQUIVALENT) - ACE_OSCALL_RETURN (ACE_PUTENV_EQUIVALENT (const_cast (string)), int, -1); #else /* ! ACE_HAS_WINCE */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::putenv (const_cast (string)), int, -1); #endif /* ACE_LACKS_PUTENV && ACE_HAS_SETENV */ @@ -409,11 +407,7 @@ ACE_INLINE int ACE_OS::rand (void) { ACE_OS_TRACE ("ACE_OS::rand"); -#if !defined (ACE_LACKS_RAND) ACE_OSCALL_RETURN (::rand (), int, -1); -#else - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_LACKS_RAND */ } ACE_INLINE int @@ -431,7 +425,7 @@ ACE_OS::rand_r (unsigned int *seed) *seed = (unsigned int)new_seed; return (int) (new_seed & RAND_MAX); #else - return ace_rand_r_helper (seed); + return ::rand_r (seed); # endif /* ACE_LACKS_RAND_R */ } @@ -481,11 +475,7 @@ ACE_INLINE void ACE_OS::srand (u_int seed) { ACE_OS_TRACE ("ACE_OS::srand"); -#ifdef ACE_LACKS_SRAND - ACE_UNUSED_ARG (seed); -#else ::srand (seed); -#endif } #if !defined (ACE_LACKS_STRTOD) diff --git a/dep/acelite/ace/OS_NS_string.cpp b/dep/acelite/ace/OS_NS_string.cpp index 091e8ece9..d63cd9f36 100644 --- a/dep/acelite/ace/OS_NS_string.cpp +++ b/dep/acelite/ace/OS_NS_string.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_string.cpp 97884 2014-09-08 18:00:53Z johnnyw $ + #include "ace/ACE.h" #include "ace/Global_Macros.h" #include "ace/OS_NS_string.h" @@ -8,10 +10,6 @@ # include "ace/OS_NS_string.inl" #endif /* ACE_HAS_INLINED_OSCALLS */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_LACKS_MEMCHR) @@ -36,12 +34,7 @@ ACE_OS::memchr_emulation (const void *s, int c, size_t len) char * ACE_OS::strdup_emulation (const char *s) { -#if defined (ACE_HAS_ALLOC_HOOKS) - char *t = (char *) ACE_Allocator::instance()->malloc (ACE_OS::strlen (s) + 1); -#else char *t = (char *) ACE_OS::malloc (ACE_OS::strlen (s) + 1); -#endif /* ACE_HAS_ALLOC_HOOKS */ - if (t == 0) return 0; @@ -69,8 +62,8 @@ ACE_OS::strdup_emulation (const wchar_t *s) char * ACE_OS::strecpy (char *s, const char *t) { - char *dscan = s; - const char *sscan = t; + ACE_REGISTER char *dscan = s; + ACE_REGISTER const char *sscan = t; while ((*dscan++ = *sscan++) != '\0') continue; @@ -82,8 +75,8 @@ ACE_OS::strecpy (char *s, const char *t) wchar_t * ACE_OS::strecpy (wchar_t *s, const wchar_t *t) { - wchar_t *dscan = s; - const wchar_t *sscan = t; + ACE_REGISTER wchar_t *dscan = s; + ACE_REGISTER const wchar_t *sscan = t; while ((*dscan++ = *sscan++) != ACE_TEXT_WIDE ('\0')) continue; @@ -134,7 +127,7 @@ ACE_OS::strerror (int errnum) if (errno == EINVAL || errmsg == 0 || errmsg[0] == 0) { - ACE_OS::snprintf (ret_errortext, 128, "Unknown error %d", errnum); + ACE_OS::sprintf (ret_errortext, "Unknown error %d", errnum); errmsg = ret_errortext; g = EINVAL; } @@ -153,6 +146,7 @@ ACE_OS::strerror_emulation (int) } #endif /* ACE_LACKS_STRERROR */ + char * ACE_OS::strsignal (int signum) { @@ -169,41 +163,25 @@ ACE_OS::strsignal (int signum) if (ret_val <= reinterpret_cast (0)) { - ACE_OS::snprintf (signal_text, 128, "Unknown signal: %d", signum); + ACE_OS::sprintf (signal_text, "Unknown signal: %d", signum); ret_val = signal_text; } return ret_val; #else if (signum < 0 || signum >= ACE_NSIG) { - ACE_OS::snprintf (signal_text, 128, "Unknown signal: %d", signum); + ACE_OS::sprintf (signal_text, "Unknown signal: %d", signum); return signal_text; } # if defined (ACE_SYS_SIGLIST) return ACE_SYS_SIGLIST[signum]; # else - ACE_OS::snprintf (signal_text, 128, "Signal: %d", signum); + ACE_OS::sprintf (signal_text, "Signal: %d", signum); return signal_text; # endif /* ACE_SYS_SIGLIST */ #endif /* ACE_HAS_STRSIGNAL */ } -char * -ACE_OS::strerror_r (int errnum, char *buf, size_t buflen) -{ -#ifdef ACE_HAS_STRERROR_R -# ifdef ACE_HAS_STRERROR_R_XSI - if (::strerror_r (errnum, buf, buflen) == 0) - return buf; - return const_cast ("Unknown Error"); -# else - return ::strerror_r (errnum, buf, buflen); -# endif -#else - return ACE_OS::strncpy (buf, strerror (errnum), buflen); -#endif -} - const char * ACE_OS::strnchr (const char *s, int c, size_t len) { @@ -342,9 +320,9 @@ ACE_OS::strrchr_emulation (const char *s, int c) char * ACE_OS::strsncpy (char *dst, const char *src, size_t maxlen) { - char *rdst = dst; - const char *rsrc = src; - size_t rmaxlen = maxlen; + ACE_REGISTER char *rdst = dst; + ACE_REGISTER const char *rsrc = src; + ACE_REGISTER size_t rmaxlen = maxlen; if (rmaxlen > 0) { @@ -368,9 +346,9 @@ ACE_OS::strsncpy (char *dst, const char *src, size_t maxlen) ACE_WCHAR_T * ACE_OS::strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen) { - ACE_WCHAR_T *rdst = dst; - const ACE_WCHAR_T *rsrc = src; - size_t rmaxlen = maxlen; + ACE_REGISTER ACE_WCHAR_T *rdst = dst; + ACE_REGISTER const ACE_WCHAR_T *rsrc = src; + ACE_REGISTER size_t rmaxlen = maxlen; if (rmaxlen > 0) { diff --git a/dep/acelite/ace/OS_NS_string.h b/dep/acelite/ace/OS_NS_string.h index 23da89534..d881d7f73 100644 --- a/dep/acelite/ace/OS_NS_string.h +++ b/dep/acelite/ace/OS_NS_string.h @@ -4,7 +4,9 @@ /** * @file OS_NS_string.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_string.h 93549 2011-03-15 19:50:24Z olli $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -201,9 +203,6 @@ namespace ACE_OS { extern ACE_Export char *strsignal (int signum); - extern ACE_Export - char *strerror_r (int errnum, char *buf, size_t buflen); - /// Finds the length of a string (char version). ACE_NAMESPACE_INLINE_FUNCTION size_t strlen (const char *s); diff --git a/dep/acelite/ace/OS_NS_string.inl b/dep/acelite/ace/OS_NS_string.inl index 2c828cfcf..e12a6d225 100644 --- a/dep/acelite/ace/OS_NS_string.inl +++ b/dep/acelite/ace/OS_NS_string.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_string.inl 93549 2011-03-15 19:50:24Z olli $ + // OS_NS_wchar.h is only needed to get the emulation methods. // Perhaps they should be moved. dhinton #include "ace/OS_NS_wchar.h" @@ -502,13 +505,7 @@ ACE_OS::strstr (wchar_t *s, const wchar_t *t) ACE_INLINE char * ACE_OS::strtok (char *s, const char *tokens) { -#if !defined (ACE_LACKS_STRTOK) return ::strtok (s, tokens); -#else - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (tokens); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_LACKS_STRTOK */ } #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK) diff --git a/dep/acelite/ace/OS_NS_strings.cpp b/dep/acelite/ace/OS_NS_strings.cpp index d09d152fd..3727ff389 100644 --- a/dep/acelite/ace/OS_NS_strings.cpp +++ b/dep/acelite/ace/OS_NS_strings.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_strings.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/OS_NS_strings.h" diff --git a/dep/acelite/ace/OS_NS_strings.h b/dep/acelite/ace/OS_NS_strings.h index 37d2befa5..9a9775230 100644 --- a/dep/acelite/ace/OS_NS_strings.h +++ b/dep/acelite/ace/OS_NS_strings.h @@ -4,7 +4,9 @@ /** * @file OS_NS_strings.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_strings.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_strings.inl b/dep/acelite/ace/OS_NS_strings.inl index 780eff09d..cb6f21e65 100644 --- a/dep/acelite/ace/OS_NS_strings.inl +++ b/dep/acelite/ace/OS_NS_strings.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_strings.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_HAS_WCHAR) # include "ace/OS_NS_wchar.h" #endif /* ACE_HAS_WCHAR */ diff --git a/dep/acelite/ace/OS_NS_stropts.cpp b/dep/acelite/ace/OS_NS_stropts.cpp index 64b527fcc..4a81a1f5b 100644 --- a/dep/acelite/ace/OS_NS_stropts.cpp +++ b/dep/acelite/ace/OS_NS_stropts.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_stropts.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/OS_NS_stropts.h" diff --git a/dep/acelite/ace/OS_NS_stropts.h b/dep/acelite/ace/OS_NS_stropts.h index e281289ae..5b96b617c 100644 --- a/dep/acelite/ace/OS_NS_stropts.h +++ b/dep/acelite/ace/OS_NS_stropts.h @@ -4,7 +4,9 @@ /** * @file OS_NS_stropts.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_stropts.h 85110 2009-04-20 09:18:43Z msmit $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_stropts.inl b/dep/acelite/ace/OS_NS_stropts.inl index 919ac531c..04200747c 100644 --- a/dep/acelite/ace/OS_NS_stropts.inl +++ b/dep/acelite/ace/OS_NS_stropts.inl @@ -1,15 +1,13 @@ // -*- C++ -*- +// +// $Id: OS_NS_stropts.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/os_include/os_errno.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_macros.h" #include "ace/OS_Memory.h" #include "ace/OS_QoS.h" -#include "ace/Global_Macros.h" - -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -112,12 +110,8 @@ ACE_OS::ioctl (ACE_HANDLE handle, void *val) { ACE_OS_TRACE ("ACE_OS::ioctl"); -#if defined (ACE_LACKS_IOCTL) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (cmd); - ACE_UNUSED_ARG (val); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_WIN32) + +#if defined (ACE_WIN32) ACE_SOCKET sock = (ACE_SOCKET) handle; ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast (val)), int, -1); #elif defined (ACE_HAS_IOCTL_INT_3_PARAM) @@ -174,20 +168,11 @@ ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl, { // This is the hard case. char *buf; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (buf, static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * (ctl->len + data->len))), -1); -#else ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::memcpy (buf, ctl->buf, ctl->len); ACE_OS::memcpy (buf + ctl->len, data->buf, data->len); result = ACE_OS::write (handle, buf, ctl->len + data->len); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(buf); -#else delete [] buf; -#endif /* ACE_HAS_ALLOC_HOOKS */ - return static_cast (result); } #endif /* ACE_HAS_STREAM_PIPES */ diff --git a/dep/acelite/ace/OS_NS_sys_mman.cpp b/dep/acelite/ace/OS_NS_sys_mman.cpp index c42b4a880..8f80280e9 100644 --- a/dep/acelite/ace/OS_NS_sys_mman.cpp +++ b/dep/acelite/ace/OS_NS_sys_mman.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_mman.cpp 92837 2010-12-08 17:31:02Z johnnyw $ + #include "ace/OS_NS_sys_mman.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_mman.h b/dep/acelite/ace/OS_NS_sys_mman.h index 3d976aeaa..c4dd05e83 100644 --- a/dep/acelite/ace/OS_NS_sys_mman.h +++ b/dep/acelite/ace/OS_NS_sys_mman.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_mman.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_mman.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_mman.inl b/dep/acelite/ace/OS_NS_sys_mman.inl index cd2931a8e..da823032f 100644 --- a/dep/acelite/ace/OS_NS_sys_mman.inl +++ b/dep/acelite/ace/OS_NS_sys_mman.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_mman.inl 97286 2013-08-12 18:11:28Z johnnyw $ + #include "ace/OS_NS_fcntl.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_stdio.h" @@ -8,7 +11,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_HAS_VOIDPTR_MMAP) -// Needed for some odd OS's +// Needed for some odd OS's (e.g., SGI). typedef void *ACE_MMAP_TYPE; #else typedef char *ACE_MMAP_TYPE; @@ -229,7 +232,7 @@ ACE_OS::munmap (void *addr, size_t len) ACE_UNUSED_ARG (len); ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1); -#elif !defined (ACE_LACKS_MMAP) && !defined (ACE_LACKS_MUNMAP) +#elif !defined (ACE_LACKS_MMAP) ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1); #else ACE_UNUSED_ARG (addr); @@ -279,7 +282,7 @@ ACE_OS::shm_unlink (const ACE_TCHAR *path) { ACE_OS_TRACE ("ACE_OS::shm_unlink"); #if defined (ACE_HAS_SHM_OPEN) -# if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670) +#if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670) // With VxWorks the file should just start with / and no other // slashes, so replace all other / by _ ACE_TCHAR buf [MAXPATHLEN + 1]; @@ -294,13 +297,8 @@ ACE_OS::shm_unlink (const ACE_TCHAR *path) } } path = buf; -# endif -# if defined (ACE_LACKS_SHM_UNLINK) - ACE_UNUSED_ARG (path); - ACE_NOTSUP_RETURN (-1); -# else +#endif ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1); -# endif /* ACE_LACKS_SHM_UNLINK */ #else /* ! ACE_HAS_SHM_OPEN */ // Just use ::unlink. return ACE_OS::unlink (path); diff --git a/dep/acelite/ace/OS_NS_sys_msg.cpp b/dep/acelite/ace/OS_NS_sys_msg.cpp index fc3068089..789c32a47 100644 --- a/dep/acelite/ace/OS_NS_sys_msg.cpp +++ b/dep/acelite/ace/OS_NS_sys_msg.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_msg.cpp 92837 2010-12-08 17:31:02Z johnnyw $ + #include "ace/OS_NS_sys_msg.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_msg.h b/dep/acelite/ace/OS_NS_sys_msg.h index 2af245d9a..24b4f5057 100644 --- a/dep/acelite/ace/OS_NS_sys_msg.h +++ b/dep/acelite/ace/OS_NS_sys_msg.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_msg.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_msg.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_msg.inl b/dep/acelite/ace/OS_NS_sys_msg.inl index 92b7a646e..5fe12c84a 100644 --- a/dep/acelite/ace/OS_NS_sys_msg.inl +++ b/dep/acelite/ace/OS_NS_sys_msg.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_msg.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_errno.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_sys_resource.cpp b/dep/acelite/ace/OS_NS_sys_resource.cpp index f6798a035..eea2c7d05 100644 --- a/dep/acelite/ace/OS_NS_sys_resource.cpp +++ b/dep/acelite/ace/OS_NS_sys_resource.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_resource.cpp 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_sys_resource.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_resource.h b/dep/acelite/ace/OS_NS_sys_resource.h index 90d85c56f..009cb1356 100644 --- a/dep/acelite/ace/OS_NS_sys_resource.h +++ b/dep/acelite/ace/OS_NS_sys_resource.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_resource.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_resource.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_resource.inl b/dep/acelite/ace/OS_NS_sys_resource.inl index e49119d3e..f1f49da91 100644 --- a/dep/acelite/ace/OS_NS_sys_resource.inl +++ b/dep/acelite/ace/OS_NS_sys_resource.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_resource.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_errno.h" #include "ace/OS_NS_macros.h" diff --git a/dep/acelite/ace/OS_NS_sys_select.cpp b/dep/acelite/ace/OS_NS_sys_select.cpp index 0fb85c079..c644bc829 100644 --- a/dep/acelite/ace/OS_NS_sys_select.cpp +++ b/dep/acelite/ace/OS_NS_sys_select.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_select.cpp 91626 2010-09-07 10:59:20Z johnnyw $ + #include "ace/OS_NS_sys_select.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_select.h b/dep/acelite/ace/OS_NS_sys_select.h index 363c64b8f..94e7d84ab 100644 --- a/dep/acelite/ace/OS_NS_sys_select.h +++ b/dep/acelite/ace/OS_NS_sys_select.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_select.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_select.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_select.inl b/dep/acelite/ace/OS_NS_sys_select.inl index 396ffe729..ef1d4bed7 100644 --- a/dep/acelite/ace/OS_NS_sys_select.inl +++ b/dep/acelite/ace/OS_NS_sys_select.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_select.inl 95761 2012-05-15 18:23:04Z johnnyw $ + #include "ace/OS_NS_errno.h" #include "ace/OS_NS_macros.h" #include "ace/Time_Value.h" diff --git a/dep/acelite/ace/OS_NS_sys_sendfile.cpp b/dep/acelite/ace/OS_NS_sys_sendfile.cpp index a47fce717..3bb74becc 100644 --- a/dep/acelite/ace/OS_NS_sys_sendfile.cpp +++ b/dep/acelite/ace/OS_NS_sys_sendfile.cpp @@ -1,27 +1,25 @@ +// $Id: OS_NS_sys_sendfile.cpp 84216 2009-01-22 18:34:40Z johnnyw $ + #include "ace/OS_NS_sys_sendfile.h" #include "ace/OS_NS_sys_mman.h" #if defined (ACE_WIN32) || defined (HPUX) # include "ace/OS_NS_sys_socket.h" +#else +# include "ace/OS_NS_unistd.h" #endif /* ACE_WIN32 || HPUX */ -#include "ace/OS_NS_unistd.h" - #ifndef ACE_HAS_INLINED_OSCALLS # include "ace/OS_NS_sys_sendfile.inl" #endif /* ACE_HAS_INLINED_OSCALLS */ -#include "ace/Malloc_Base.h" -#include "ace/OS_Memory.h" -#include "ace/os_include/os_errno.h" - ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined ACE_HAS_SENDFILE && ACE_HAS_SENDFILE == 0 ssize_t ACE_OS::sendfile_emulation (ACE_HANDLE out_fd, ACE_HANDLE in_fd, - off_t *offset, + off_t * offset, size_t count) { // @@ Is it possible to inline a call to ::TransmitFile() on @@ -30,24 +28,10 @@ ACE_OS::sendfile_emulation (ACE_HANDLE out_fd, // @@ We may want set up a signal lease (or oplock) if supported by // the platform so that we don't get a bus error if the mmap()ed // file is truncated. - void *buf = ACE_OS::mmap (0, count, PROT_READ, MAP_SHARED, in_fd, *offset); - const bool use_read = buf == MAP_FAILED && errno == ENODEV; - ACE_OFF_T prev_pos; + void * const buf = + ACE_OS::mmap (0, count, PROT_READ, MAP_SHARED, in_fd, *offset); - if (use_read) - { -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (buf, - ACE_Allocator::instance ()->malloc (count), -1); -# else - ACE_NEW_RETURN (buf, char[count], -1); -# endif - prev_pos = ACE_OS::lseek (in_fd, 0, SEEK_CUR); - if (ACE_OS::lseek (in_fd, *offset, SEEK_SET) == -1 - || ACE_OS::read (in_fd, buf, count) == -1) - return -1; - } - else if (buf == MAP_FAILED) + if (buf == MAP_FAILED) return -1; #if defined (ACE_WIN32) || defined (HPUX) @@ -57,17 +41,7 @@ ACE_OS::sendfile_emulation (ACE_HANDLE out_fd, ssize_t const r = ACE_OS::write (out_fd, buf, count); #endif /* ACE_WIN32 */ - if (use_read) - { - ACE_OS::lseek (in_fd, prev_pos, SEEK_SET); -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (buf); -# else - delete[] static_cast (buf); -# endif - } - else - (void) ACE_OS::munmap (buf, count); + (void) ACE_OS::munmap (buf, count); if (r > 0) *offset += static_cast (r); diff --git a/dep/acelite/ace/OS_NS_sys_sendfile.h b/dep/acelite/ace/OS_NS_sys_sendfile.h index 5b7f5da81..b39f2a1ec 100644 --- a/dep/acelite/ace/OS_NS_sys_sendfile.h +++ b/dep/acelite/ace/OS_NS_sys_sendfile.h @@ -4,6 +4,8 @@ /** * @file OS_NS_sys_sendfile.h * + * $Id: OS_NS_sys_sendfile.h 84216 2009-01-22 18:34:40Z johnnyw $ + * * @author Ossama Othman */ //============================================================================= diff --git a/dep/acelite/ace/OS_NS_sys_sendfile.inl b/dep/acelite/ace/OS_NS_sys_sendfile.inl index 3be63e7d9..9ea878c43 100644 --- a/dep/acelite/ace/OS_NS_sys_sendfile.inl +++ b/dep/acelite/ace/OS_NS_sys_sendfile.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_sendfile.inl 84216 2009-01-22 18:34:40Z johnnyw $ + #if defined ACE_HAS_SENDFILE && ACE_HAS_SENDFILE == 1 # include #endif /* ACE_HAS_SENDFILE==1 */ diff --git a/dep/acelite/ace/OS_NS_sys_shm.cpp b/dep/acelite/ace/OS_NS_sys_shm.cpp index eebf798e4..eba6ee239 100644 --- a/dep/acelite/ace/OS_NS_sys_shm.cpp +++ b/dep/acelite/ace/OS_NS_sys_shm.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_shm.cpp 96519 2012-12-17 10:00:00Z johnnyw $ + #include "ace/OS_NS_sys_shm.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_shm.h b/dep/acelite/ace/OS_NS_sys_shm.h index d7597ca9f..5edb85117 100644 --- a/dep/acelite/ace/OS_NS_sys_shm.h +++ b/dep/acelite/ace/OS_NS_sys_shm.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_shm.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_shm.h 93359 2011-02-11 11:33:12Z mcorino $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_shm.inl b/dep/acelite/ace/OS_NS_sys_shm.inl index 02c3b9221..013d20843 100644 --- a/dep/acelite/ace/OS_NS_sys_shm.inl +++ b/dep/acelite/ace/OS_NS_sys_shm.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_shm.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_errno.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_sys_socket.cpp b/dep/acelite/ace/OS_NS_sys_socket.cpp index dec4e2333..eb0159cba 100644 --- a/dep/acelite/ace/OS_NS_sys_socket.cpp +++ b/dep/acelite/ace/OS_NS_sys_socket.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_socket.cpp 96519 2012-12-17 10:00:00Z johnnyw $ + #include "ace/OS_NS_sys_socket.h" #if !defined (ACE_HAS_INLINED_OSCALLS) @@ -108,7 +110,7 @@ ACE_OS::socket_init (int version_high, int version_low) { ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d"); ACE_TCHAR buf[80]; // @@ Eliminate magic number. - ACE_OS::snprintf (buf, 80, fmt, ACE_TEXT ("WSAStartup %d"), error); + ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSAStartup"), error); ::MessageBox (0, buf, ACE_TEXT ("WSAStartup failed!"), MB_OK); } # else @@ -139,7 +141,7 @@ ACE_OS::socket_fini (void) # if defined (ACE_HAS_WINCE) ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d"); ACE_TCHAR buf[80]; // @@ Eliminate magic number. - ACE_OS::snprintf (buf, 80, fmt, ACE_TEXT ("WSACleanup %d"), error); + ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSACleanup"), error); ::MessageBox (0, buf , ACE_TEXT ("WSACleanup failed!"), MB_OK); # else ACE_OS::fprintf (stderr, @@ -217,12 +219,13 @@ ACE_OS::sendv_partial_i (ACE_HANDLE handle, } return (ssize_t) bytes_sent; -#else +# else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buffers); ACE_UNUSED_ARG (n); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_WINSOCK2 */ + + return -1; +# endif /* ACE_HAS_WINSOCK2 */ } ssize_t @@ -262,13 +265,14 @@ ACE_OS::send_partial_i (ACE_HANDLE handle, } return result; -#else +# else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (flags); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_LACKS_SEND && ACE_WIN32 */ + + return -1; +# endif /* ACE_LACKS_SEND && ACE_WIN32 */ } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_sys_socket.h b/dep/acelite/ace/OS_NS_sys_socket.h index 1f972a9f2..860de8dfb 100644 --- a/dep/acelite/ace/OS_NS_sys_socket.h +++ b/dep/acelite/ace/OS_NS_sys_socket.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_socket.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_socket.h 95533 2012-02-14 22:59:17Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -58,20 +60,6 @@ #define ACE_SHUTDOWN_BOTH 2 #endif /* SD_BOTH */ -#if defined (IP_RECVDSTADDR) -#define ACE_RECVPKTINFO IP_RECVDSTADDR -#elif defined (IP_PKTINFO) -#define ACE_RECVPKTINFO IP_PKTINFO -#endif - -#if defined (ACE_HAS_IPV6) -#if defined (IPV6_PKTINFO) -#define ACE_RECVPKTINFO6 IPV6_PKTINFO -#elif defined (IPV6_RECVPKTINFO) -#define ACE_RECVPKTINFO6 IPV6_RECVPKTINFO -#endif -#endif - ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Accept_QoS_Params; diff --git a/dep/acelite/ace/OS_NS_sys_socket.inl b/dep/acelite/ace/OS_NS_sys_socket.inl index 3055da018..ce200bb37 100644 --- a/dep/acelite/ace/OS_NS_sys_socket.inl +++ b/dep/acelite/ace/OS_NS_sys_socket.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_sys_socket.inl 97938 2014-10-27 07:56:26Z johnnyw $ + #include "ace/OS_NS_errno.h" #include "ace/OS_NS_macros.h" #include "ace/OS_NS_sys_uio.h" @@ -972,48 +974,29 @@ ACE_INLINE unsigned int ACE_OS::if_nametoindex (const char *ifname) { ACE_OS_TRACE ("ACE_OS::if_nametoindex"); -#if defined (ACE_LACKS_IF_NAME_INDEX) - ACE_UNUSED_ARG (ifname); - ACE_NOTSUP_RETURN (0); -#else ACE_OSCALL_RETURN (::if_nametoindex (ifname), int, 0); -#endif /* ACE_LACKS_IF_NAME_INDEX */ } ACE_INLINE char * ACE_OS::if_indextoname (unsigned int ifindex, char *ifname) { ACE_OS_TRACE ("ACE_OS::if_indextoname"); -#if defined (ACE_LACKS_IF_NAME_INDEX) - ACE_UNUSED_ARG (ifindex); - ACE_UNUSED_ARG (ifname); - ACE_NOTSUP_RETURN (0); -#else ACE_OSCALL_RETURN (::if_indextoname (ifindex, ifname), char *, 0); -#endif /* ACE_LACKS_IF_NAME_INDEX */ } ACE_INLINE struct if_nameindex * ACE_OS::if_nameindex (void) { ACE_OS_TRACE ("ACE_OS::if_nameindex"); -#if defined (ACE_LACKS_IF_NAME_INDEX) - ACE_NOTSUP_RETURN (0); -#else ACE_OSCALL_RETURN (::if_nameindex (), struct if_nameindex *, 0); -#endif /* ACE_LACKS_IF_NAME_INDEX */ } ACE_INLINE void ACE_OS::if_freenameindex (struct if_nameindex *ptr) { ACE_OS_TRACE ("ACE_OS::if_freenameindex"); -#if defined (ACE_LACKS_IF_NAME_INDEX) - ACE_UNUSED_ARG (ptr); -#else if (ptr != 0) ::if_freenameindex (ptr); -#endif /* ACE_LACKS_IF_NAME_INDEX */ } #endif /* ACE_LINUX && ACE_HAS_IPV6 */ diff --git a/dep/acelite/ace/OS_NS_sys_stat.cpp b/dep/acelite/ace/OS_NS_sys_stat.cpp index fd6accb3f..ed372a046 100644 --- a/dep/acelite/ace/OS_NS_sys_stat.cpp +++ b/dep/acelite/ace/OS_NS_sys_stat.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_stat.cpp 96519 2012-12-17 10:00:00Z johnnyw $ + #include "ace/OS_NS_sys_stat.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_stat.h b/dep/acelite/ace/OS_NS_sys_stat.h index cf6e99f36..36e11a9eb 100644 --- a/dep/acelite/ace/OS_NS_sys_stat.h +++ b/dep/acelite/ace/OS_NS_sys_stat.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_stat.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_stat.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -57,10 +59,6 @@ typedef struct _stati64 ACE_stat; # define ACE_STAT_FUNC_NAME ::_stati64 # define ACE_WSTAT_FUNC_NAME ::_wstati64 # endif /* _MSC_VER >= 1400 */ -# elif defined (__MINGW32__) -typedef struct _stati64 ACE_stat; -# define ACE_STAT_FUNC_NAME ::_stati64 -# define ACE_WSTAT_FUNC_NAME ::_wstati64 # else typedef struct stat ACE_stat; # define ACE_STAT_FUNC_NAME ::stat diff --git a/dep/acelite/ace/OS_NS_sys_stat.inl b/dep/acelite/ace/OS_NS_sys_stat.inl index 93e321dd1..c868a0ed2 100644 --- a/dep/acelite/ace/OS_NS_sys_stat.inl +++ b/dep/acelite/ace/OS_NS_sys_stat.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_stat.inl 96943 2013-03-30 09:42:31Z mcorino $ + #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_fcntl.h" #include "ace/OS_NS_errno.h" @@ -148,11 +151,7 @@ namespace ACE_OS int, -1); #elif defined (ACE_MKDIR_LACKS_MODE) ACE_UNUSED_ARG (mode); -# if defined (ACE_MKDIR_EQUIVALENT) - ACE_OSCALL_RETURN (ACE_MKDIR_EQUIVALENT (path), int, -1); -# else ACE_OSCALL_RETURN (::mkdir (path), int, -1); -# endif #else ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1); #endif @@ -200,7 +199,6 @@ namespace ACE_OS #elif defined (ACE_HAS_WINCE) ACE_TEXT_WIN32_FIND_DATA fdata; - int rc = 0; HANDLE fhandle; fhandle = ::FindFirstFile (ACE_TEXT_CHAR_TO_TCHAR (file), &fdata); @@ -212,7 +210,7 @@ namespace ACE_OS else if (fdata.nFileSizeHigh != 0) { errno = EINVAL; - rc = -1; + return -1; } else { @@ -222,9 +220,7 @@ namespace ACE_OS stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); } - - ::FindClose (fhandle); - return rc; + return 0; #elif defined (ACE_HAS_X86_STAT_MACROS) // Solaris for intel uses an macro for stat(), this macro is a // wrapper for _xstat(). @@ -242,7 +238,6 @@ namespace ACE_OS #if defined (ACE_HAS_WINCE) WIN32_FIND_DATAW fdata; - int rc = 0; HANDLE fhandle; fhandle = ::FindFirstFileW (file, &fdata); @@ -254,7 +249,7 @@ namespace ACE_OS else if (fdata.nFileSizeHigh != 0) { errno = EINVAL; - rc = -1; + return -1; } else { @@ -264,9 +259,7 @@ namespace ACE_OS stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); } - - ::FindClose (fhandle); - return rc; + return 0; #elif defined (__BORLANDC__) \ || defined (_MSC_VER) \ || (defined (__MINGW32__) && !defined (__MINGW64_VERSION_MAJOR)) diff --git a/dep/acelite/ace/OS_NS_sys_time.cpp b/dep/acelite/ace/OS_NS_sys_time.cpp index f2f8a37ec..39a585882 100644 --- a/dep/acelite/ace/OS_NS_sys_time.cpp +++ b/dep/acelite/ace/OS_NS_sys_time.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_time.cpp 95719 2012-05-01 12:54:01Z johnnyw $ + #include "ace/OS_NS_sys_time.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_time.h b/dep/acelite/ace/OS_NS_sys_time.h index 02d633314..c3df9319d 100644 --- a/dep/acelite/ace/OS_NS_sys_time.h +++ b/dep/acelite/ace/OS_NS_sys_time.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_time.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_time.h 87823 2009-11-30 12:38:34Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -37,9 +39,6 @@ namespace ACE_OS { ACE_NAMESPACE_INLINE_FUNCTION ACE_Time_Value gettimeofday (void); - - ACE_NAMESPACE_INLINE_FUNCTION - ACE_Time_Value gettimeofday_ (void); } /* namespace ACE_OS */ ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_sys_time.inl b/dep/acelite/ace/OS_NS_sys_time.inl index acaf2f9f4..fd747166a 100644 --- a/dep/acelite/ace/OS_NS_sys_time.inl +++ b/dep/acelite/ace/OS_NS_sys_time.inl @@ -1,8 +1,11 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_time.inl 89266 2010-02-26 18:30:42Z johnnyw $ + #include "ace/os_include/sys/os_time.h" #include "ace/os_include/os_errno.h" -#if defined (ACE_VXWORKS) || defined (ACE_HAS_CLOCK_GETTIME_REALTIME) || defined (ACE_LACKS_GETTIMEOFDAY) +#if defined (ACE_VXWORKS) || defined (ACE_HAS_CLOCK_GETTIME_REALTIME) # include "ace/OS_NS_time.h" #endif /* ACE_VXWORKS || ACE_HAS_CLOCK_REALTIME */ @@ -18,14 +21,12 @@ ACE_OS::gettimeofday (void) int result = 0; #endif // !defined (ACE_WIN32) -#if defined (ACE_LACKS_GETTIMEOFDAY) && defined (ACE_HAS_CLOCK_GETTIME) - timespec ts; - if (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts) == -1) - { - return ACE_Time_Value (-1); - } +#if defined (ACE_HAS_CLOCK_GETTIME_REALTIME) + struct timespec ts; - return ACE_Time_Value (ts); + ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result); + tv.tv_sec = ts.tv_sec; + tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec #elif defined (ACE_WIN32) && defined (ACE_LACKS_GETSYSTEMTIMEASFILETIME) SYSTEMTIME tsys; @@ -60,11 +61,7 @@ ACE_OS::gettimeofday (void) tv.tv_sec = ts.tv_sec; tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec # else -# if defined (ACE_LACKS_GETTIMEOFDAY) - ACE_NOTSUP_RETURN (ACE_Time_Value ((time_t)-1)); -# else ACE_OSCALL (::gettimeofday (&tv), int, -1, result); -# endif /* ACE_LACKS_GETTIMEOFDAY */ # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */ #endif /* 0 */ #if !defined (ACE_WIN32) @@ -75,10 +72,4 @@ ACE_OS::gettimeofday (void) #endif // !defined (ACE_WIN32) } -ACE_INLINE ACE_Time_Value -ACE_OS::gettimeofday_ (void) -{ - return ACE_OS::gettimeofday (); -} - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_sys_uio.cpp b/dep/acelite/ace/OS_NS_sys_uio.cpp index eeccc55a5..ef8ae318f 100644 --- a/dep/acelite/ace/OS_NS_sys_uio.cpp +++ b/dep/acelite/ace/OS_NS_sys_uio.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_uio.cpp 96519 2012-12-17 10:00:00Z johnnyw $ + #include "ace/OS_NS_sys_uio.h" #if !defined (ACE_HAS_INLINED_OSCALLS) @@ -8,14 +10,9 @@ #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" -#ifdef ACE_HAS_ALLOC_HOOKS -# include "ace/Global_Macros.h" -# include "ace/Malloc_Base.h" -#endif - ACE_BEGIN_VERSIONED_NAMESPACE_DECL -#if defined (ACE_LACKS_READV) +# if defined (ACE_LACKS_READV) // "Fake" readv for operating systems without it. Note that this is // thread-safe. @@ -41,15 +38,13 @@ ACE_OS::readv_emulation (ACE_HANDLE handle, length += iov[i].iov_len; char *buf; -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (buf, - (char *) ACE_Allocator::instance ()->malloc (length), - -1); -# else +# if defined (ACE_HAS_ALLOCA) + buf = (char *) alloca (length); +# else ACE_NEW_RETURN (buf, char[length], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ +# endif /* !defined (ACE_HAS_ALLOCA) */ length = ACE_OS::read (handle, buf, length); @@ -72,16 +67,14 @@ ACE_OS::readv_emulation (ACE_HANDLE handle, } } -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (buf); -# else +# if !defined (ACE_HAS_ALLOCA) delete [] buf; -# endif /* ACE_HAS_ALLOC_HOOKS */ +# endif /* !defined (ACE_HAS_ALLOCA) */ return length; } -#endif /* ACE_LACKS_READV */ +# endif /* ACE_LACKS_READV */ -#if defined (ACE_LACKS_WRITEV) +# if defined (ACE_LACKS_WRITEV) // "Fake" writev for operating systems without it. Note that this is // thread-safe. @@ -91,38 +84,44 @@ ACE_OS::writev_emulation (ACE_HANDLE handle, const iovec *iov, int n) { ACE_OS_TRACE ("ACE_OS::writev_emulation"); - // 'handle' may be a datagram socket (or similar) so this operation - // must not be divided into multiple smaller writes. + // To avoid having to allocate a temporary buffer to which all of + // the data will be copied and then written, this implementation + // performs incremental writes. - if (n == 1) - return ACE_OS::write (handle, iov[0].iov_base, iov[0].iov_len); + ssize_t bytes_sent = 0; - ssize_t length = 0; for (int i = 0; i < n; ++i) - length += iov[i].iov_len; + { + ssize_t const result = + ACE_OS::write (handle, iov[i].iov_base, iov[i].iov_len); - char *buf; -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (buf, - (char *) ACE_Allocator::instance ()->malloc (length), - -1); -# else - ACE_NEW_RETURN (buf, char[length], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ + if (result == -1) + { + // There is a subtle difference in behaviour depending on + // whether or not any data was sent. If no data was sent, + // then always return -1. Otherwise return bytes_sent. + // This gives the caller an opportunity to keep track of + // bytes that have already been sent. + if (bytes_sent > 0) + break; + else + return -1; + } + else + { + bytes_sent += result; - char *iter = buf; - for (int i = 0; i < n; iter += iov[i++].iov_len) - ACE_OS::memcpy (iter, iov[i].iov_base, iov[i].iov_len); + // Do not continue on to the next loop iteration if the + // amount of data sent was less than the amount data given. + // This avoids a subtle problem where "holes" in the data + // stream would occur if partial sends of a given buffer in + // the iovec array occured. + if (static_cast (result) < iov[i].iov_len) + break; + } + } - const ssize_t result = ACE_OS::write (handle, buf, length); - -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (buf); -# else - delete[] buf; -# endif /* ACE_HAS_ALLOC_HOOKS */ - - return result; + return bytes_sent; } # endif /* ACE_LACKS_WRITEV */ diff --git a/dep/acelite/ace/OS_NS_sys_uio.h b/dep/acelite/ace/OS_NS_sys_uio.h index e03894b30..d08df3d1c 100644 --- a/dep/acelite/ace/OS_NS_sys_uio.h +++ b/dep/acelite/ace/OS_NS_sys_uio.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_uio.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_uio.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_uio.inl b/dep/acelite/ace/OS_NS_sys_uio.inl index d31e7034e..c704e07ea 100644 --- a/dep/acelite/ace/OS_NS_sys_uio.inl +++ b/dep/acelite/ace/OS_NS_sys_uio.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_uio.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/os_include/os_errno.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_NS_sys_utsname.cpp b/dep/acelite/ace/OS_NS_sys_utsname.cpp index fd561ebac..f9efec38d 100644 --- a/dep/acelite/ace/OS_NS_sys_utsname.cpp +++ b/dep/acelite/ace/OS_NS_sys_utsname.cpp @@ -1,10 +1,11 @@ +// $Id: OS_NS_sys_utsname.cpp 93543 2011-03-14 08:25:46Z johnnyw $ + #include "ace/OS_NS_sys_utsname.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_errno.h" -#if defined (ACE_VXWORKS) && defined (ACE_LACKS_UNAME) && !defined (__RTP__) +#if defined (ACE_VXWORKS) && defined (ACE_LACKS_UNAME) // for sysBspRev(), sysModel() # include /**/ // for kernelVersion() @@ -23,22 +24,9 @@ ACE_OS::uname (ACE_utsname *name) size_t maxnamelen = sizeof name->nodename; ACE_OS::strcpy (name->sysname, "Win32"); -# if defined (ACE_HAS_WIN32_GETVERSION) - /* Since MS found it necessary to deprecate these. */ -# pragma warning(push) -# pragma warning(disable:4996) -# if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-declarations" -# endif /* __clang__ */ ACE_TEXT_OSVERSIONINFO vinfo; vinfo.dwOSVersionInfoSize = sizeof(ACE_TEXT_OSVERSIONINFO); ACE_TEXT_GetVersionEx (&vinfo); -# if defined(__clang__) -# pragma clang diagnostic pop -# endif /* __clang__ */ -# pragma warning(pop) -# endif SYSTEM_INFO sinfo; # if defined (ACE_HAS_PHARLAP) @@ -59,7 +47,6 @@ ACE_OS::uname (ACE_utsname *name) const char* unknown = "???"; -# if defined (ACE_HAS_WIN32_GETVERSION) if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT # if defined (VER_PLATFORM_WIN32_CE) @@ -73,14 +60,14 @@ ACE_OS::uname (ACE_utsname *name) os = "Windows NT %d.%d"; else os = "Windows CE %d.%d"; - ACE_OS::snprintf (name->release, maxnamelen, - os, - (int) vinfo.dwMajorVersion, - (int) vinfo.dwMinorVersion); - ACE_OS::snprintf (name->version, maxnamelen, - "Build %d %s", - (int) vinfo.dwBuildNumber, - ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion)); + ACE_OS::sprintf (name->release, + os, + (int) vinfo.dwMajorVersion, + (int) vinfo.dwMinorVersion); + ACE_OS::sprintf (name->version, + "Build %d %s", + (int) vinfo.dwBuildNumber, + ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion)); // We have to make sure that the size of (processor + subtype) // is not greater than the size of name->machine. So we give @@ -91,7 +78,7 @@ ACE_OS::uname (ACE_utsname *name) char processor[bufsize] = "Unknown"; char subtype[bufsize] = "Unknown"; - WORD arch = sinfo.wProcessorArchitecture; + WORD arch = sinfo.wProcessorArchitecture; switch (arch) { @@ -108,7 +95,7 @@ ACE_OS::uname (ACE_utsname *name) else if (sinfo.wProcessorLevel == 7) // I'm guessing here ACE_OS::strcpy (subtype, "Pentium II"); else - ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel); + ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; case PROCESSOR_ARCHITECTURE_MIPS: ACE_OS::strcpy (processor, "MIPS"); @@ -117,11 +104,11 @@ ACE_OS::uname (ACE_utsname *name) else if (sinfo.wProcessorLevel == 4) ACE_OS::strcpy (subtype, "R4000"); else - ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel); + ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; case PROCESSOR_ARCHITECTURE_ALPHA: ACE_OS::strcpy (processor, "Alpha"); - ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel); + ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; case PROCESSOR_ARCHITECTURE_PPC: ACE_OS::strcpy (processor, "PPC"); @@ -141,25 +128,29 @@ ACE_OS::uname (ACE_utsname *name) # if defined PROCESSOR_ARCHITECTURE_IA64 case PROCESSOR_ARCHITECTURE_IA64: ACE_OS::strcpy (processor, "Itanium"); - ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel); + ACE_OS::sprintf (subtype, "%d", + sinfo.wProcessorLevel); break; # endif # if defined PROCESSOR_ARCHITECTURE_AMD64 case PROCESSOR_ARCHITECTURE_AMD64: ACE_OS::strcpy (processor, "x64"); - ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel); + ACE_OS::sprintf (subtype, "%d", + sinfo.wProcessorLevel); break; # endif # if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: ACE_OS::strcpy (processor, "WOW64"); - ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel); + ACE_OS::sprintf (subtype, "%d", + sinfo.wProcessorLevel); break; # endif # if defined PROCESSOR_ARCHITECTURE_ARM case PROCESSOR_ARCHITECTURE_ARM: ACE_OS::strcpy (processor, "ARM"); - ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel); + ACE_OS::sprintf (subtype, "%d", + sinfo.wProcessorLevel); break; # endif case PROCESSOR_ARCHITECTURE_UNKNOWN: @@ -169,7 +160,9 @@ ACE_OS::uname (ACE_utsname *name) ACE_OS::strcpy (processor, "Unknown"); break; } - ACE_OS::snprintf (name->machine, maxnamelen, "%s %s", processor, subtype); + ACE_OS::sprintf (name->machine, + "%s %s", + processor, subtype); } else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { @@ -194,8 +187,7 @@ ACE_OS::uname (ACE_utsname *name) ACE_OS::strcpy (name->release, unknown); } - ACE_OS::snprintf (name->version, maxnamelen, "%d", - LOWORD (vinfo.dwBuildNumber)); + ACE_OS::sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber)); if (sinfo.dwProcessorType == PROCESSOR_INTEL_386) ACE_OS::strcpy (name->machine, "Intel 80386"); else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486) @@ -206,7 +198,6 @@ ACE_OS::uname (ACE_utsname *name) ACE_OS::strcpy (name->machine, unknown); } else -# endif /* !ACE_HAS_WIN32_GETVERSION */ { // We don't know what this is! @@ -221,7 +212,7 @@ ACE_OS::uname (ACE_utsname *name) return ACE_OS::hostname (name->nodename, maxnamelen); # endif /* ACE_LACKS_HOSTNAME */ -#elif defined (ACE_VXWORKS) && !defined (__RTP__) +#elif defined (ACE_VXWORKS) size_t const maxnamelen = sizeof name->nodename; ACE_OS::strcpy (name->sysname, "VxWorks"); ACE_OS::strcpy (name->release, kernelVersion()); @@ -240,9 +231,6 @@ ACE_OS::uname (ACE_utsname *name) strcpy(name->version,"4.0.9"); strcpy(name->machine,"a standard name"); return status; -#else - ACE_UNUSED_ARG (name); - ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ } diff --git a/dep/acelite/ace/OS_NS_sys_utsname.h b/dep/acelite/ace/OS_NS_sys_utsname.h index 2851122ec..978fecf9e 100644 --- a/dep/acelite/ace/OS_NS_sys_utsname.h +++ b/dep/acelite/ace/OS_NS_sys_utsname.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_utsname.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_utsname.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_wait.cpp b/dep/acelite/ace/OS_NS_sys_wait.cpp index 16f8cc26e..fbb2608b3 100644 --- a/dep/acelite/ace/OS_NS_sys_wait.cpp +++ b/dep/acelite/ace/OS_NS_sys_wait.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_sys_wait.cpp 92712 2010-11-25 12:22:13Z johnnyw $ + #include "ace/OS_NS_sys_wait.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_sys_wait.h b/dep/acelite/ace/OS_NS_sys_wait.h index 58a7d0118..8cdf6efa4 100644 --- a/dep/acelite/ace/OS_NS_sys_wait.h +++ b/dep/acelite/ace/OS_NS_sys_wait.h @@ -4,7 +4,9 @@ /** * @file OS_NS_sys_wait.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_sys_wait.h 83735 2008-11-14 09:41:52Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_sys_wait.inl b/dep/acelite/ace/OS_NS_sys_wait.inl index 1d687a870..7ae954e0e 100644 --- a/dep/acelite/ace/OS_NS_sys_wait.inl +++ b/dep/acelite/ace/OS_NS_sys_wait.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_sys_wait.inl 95761 2012-05-15 18:23:04Z johnnyw $ + #include "ace/OS_NS_errno.h" #include "ace/Global_Macros.h" @@ -10,7 +13,7 @@ ACE_OS::wait (int *status) ACE_OS_TRACE ("ACE_OS::wait"); #if defined (ACE_LACKS_WAIT) ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); + ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (::wait (status), pid_t, -1); #endif /* ACE_LACKS_WAIT */ @@ -29,7 +32,7 @@ ACE_OS::waitpid (pid_t pid, ACE_UNUSED_ARG (wait_options); ACE_UNUSED_ARG (handle); - ACE_NOTSUP_RETURN (-1); + ACE_NOTSUP_RETURN (0); #elif defined (ACE_WIN32) int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG) ? 0 /* don't hang */ diff --git a/dep/acelite/ace/OS_NS_time.cpp b/dep/acelite/ace/OS_NS_time.cpp index 2ab3c7ebe..836e25767 100644 --- a/dep/acelite/ace/OS_NS_time.cpp +++ b/dep/acelite/ace/OS_NS_time.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_time.cpp 93561 2011-03-16 14:02:24Z olli $ + #include "ace/OS_NS_time.h" #if !defined (ACE_HAS_INLINED_OSCALLS) @@ -73,14 +75,14 @@ ACE_OS::ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen) SYSTEMTIME systime; FileTimeToLocalFileTime (&file_time, &localtime); FileTimeToSystemTime (&localtime, &systime); - ACE_OS::snprintf (buf, buflen, ACE_OS_CTIME_R_FMTSTR, - ACE_OS_day_of_week_name[systime.wDayOfWeek], - ACE_OS_month_name[systime.wMonth - 1], - systime.wDay, - systime.wHour, - systime.wMinute, - systime.wSecond, - systime.wYear); + ACE_OS::sprintf (buf, ACE_OS_CTIME_R_FMTSTR, + ACE_OS_day_of_week_name[systime.wDayOfWeek], + ACE_OS_month_name[systime.wMonth - 1], + systime.wDay, + systime.wHour, + systime.wMinute, + systime.wSecond, + systime.wYear); return buf; } # endif /* ACE_HAS_WINCE */ @@ -287,7 +289,7 @@ ACE_OS::localtime_r (const time_t *t, struct tm *res) return res; } #else - return ace_localtime_r_helper (t, res); + ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0); #endif /* ACE_HAS_TR24731_2005_CRT */ } diff --git a/dep/acelite/ace/OS_NS_time.h b/dep/acelite/ace/OS_NS_time.h index 2a5f074b0..078dd9a69 100644 --- a/dep/acelite/ace/OS_NS_time.h +++ b/dep/acelite/ace/OS_NS_time.h @@ -4,7 +4,9 @@ /** * @file OS_NS_time.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_time.h 95763 2012-05-16 06:43:51Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -90,47 +92,6 @@ inline long ace_timezone() #endif } -/* - * We inline and undef some functions that may be implemented - * as macros on some platforms. This way macro definitions will - * be usable later as there is no way to save the macro definition - * using the pre-processor. - */ -#if !defined (ACE_LACKS_ASCTIME_R) -inline char *ace_asctime_r_helper (const struct tm *t, char *buf) -{ -# if defined (asctime_r) - return asctime_r (t, buf); -# undef asctime_r -# else - return ACE_STD_NAMESPACE::asctime_r (t, buf); -# endif /* asctime_r */ -} -#endif /* !ACE_LACKS_ASCTIME_R */ - -#if !defined (ACE_LACKS_GMTIME_R) -inline struct tm *ace_gmtime_r_helper (const time_t *clock, struct tm *res) -{ -# if defined (gmtime_r) - return gmtime_r (clock, res); -# undef gmtime_r -# else - return ACE_STD_NAMESPACE::gmtime_r (clock, res); -# endif /* gmtime_r */ -} -#endif /* !ACE_LACKS_GMTIME_R */ - -#if !defined (ACE_LACKS_LOCALTIME_R) -inline struct tm *ace_localtime_r_helper (const time_t *clock, struct tm *res) -{ -# if defined (localtime_r) - return localtime_r (clock, res); -# undef localtime_r -# else - return ACE_STD_NAMESPACE::localtime_r (clock, res); -# endif /* localtime_r */ -} -#endif /* !ACE_LACKS_LOCALTIME_R */ #if !defined (ACE_LACKS_DIFFTIME) # if defined (_WIN32_WCE) && ((_WIN32_WCE >= 0x600) && (_WIN32_WCE <= 0x700)) && !defined (_USE_32BIT_TIME_T) \ diff --git a/dep/acelite/ace/OS_NS_time.inl b/dep/acelite/ace/OS_NS_time.inl index bc81f93a8..1c2673f16 100644 --- a/dep/acelite/ace/OS_NS_time.inl +++ b/dep/acelite/ace/OS_NS_time.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_time.inl 97769 2014-06-05 06:37:53Z johnnyw $ + #include "ace/OS_NS_string.h" #include "ace/OS_NS_errno.h" #include "ace/Time_Value.h" @@ -26,7 +29,7 @@ ACE_OS::asctime_r (const struct tm *t, char *buf, int buflen) #if defined (ACE_HAS_REENTRANT_FUNCTIONS) # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) char *result = 0; - ace_asctime_r_helper (t, buf); + ACE_OSCALL (::asctime_r (t, buf), char *, 0, result); ACE_OS::strsncpy (buf, result, buflen); return buf; # else @@ -36,16 +39,16 @@ ACE_OS::asctime_r (const struct tm *t, char *buf, int buflen) ACE_OSCALL_RETURN (::asctime_r (t, buf, buflen), char *, 0); # endif /* ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R */ # endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ +#elif defined (ACE_LACKS_ASCTIME_R) + ACE_UNUSED_ARG (t); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (buflen); + ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_TR24731_2005_CRT) char *result = buf; ACE_SECURECRTCALL (asctime_s (buf, static_cast (buflen), t), \ char*, 0, result); return result; -#elif defined (ACE_LACKS_ASCTIME) - ACE_UNUSED_ARG (t); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (buflen); - ACE_NOTSUP_RETURN (0); #else char *result = 0; ACE_OSCALL (ACE_STD_NAMESPACE::asctime (t), char *, 0, result); @@ -90,10 +93,7 @@ ACE_INLINE ACE_TCHAR * ACE_OS::ctime (const time_t *t) { ACE_OS_TRACE ("ACE_OS::ctime"); -#if defined (ACE_LACKS_CTIME) - ACE_UNUSED_ARG (t); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_HAS_WINCE) +#if defined (ACE_HAS_WINCE) static ACE_TCHAR buf [ctime_buf_size]; return ACE_OS::ctime_r (t, buf, @@ -275,23 +275,21 @@ ACE_OS::gethrtime (const ACE_HRTimer_Op op) ACE_UNUSED_ARG (op); // Use .obj/gethrtime.o, which was compiled with g++. return ACE_GETHRTIME_NAME (); -#elif (defined (__GNUG__) || defined (__INTEL_COMPILER)) && \ - !defined (ACE_VXWORKS) && defined (ACE_HAS_PENTIUM) && \ - !defined (ACE_LACKS_PENTIUM_RDTSC) +#elif (defined (__GNUG__) || defined (__INTEL_COMPILER)) && !defined(ACE_VXWORKS) && defined (ACE_HAS_PENTIUM) ACE_UNUSED_ARG (op); ACE_hrtime_t now; -# if defined (__amd64__) || defined (__x86_64__) +#if defined (__amd64__) || defined (__x86_64__) // Read the high res tick counter into 32 bit int variables "eax" and // "edx", and then combine them into 64 bit int "now" ACE_UINT32 eax, edx; asm volatile ("rdtsc" : "=a" (eax), "=d" (edx) : : "memory"); now = (((ACE_UINT64) eax) | (((ACE_UINT64) edx) << 32)); -# else +#else // Read the high-res tick counter directly into memory variable "now". // The A constraint signifies a 64-bit int. asm volatile ("rdtsc" : "=A" (now) : : "memory"); -# endif +#endif return now; #elif defined (ACE_LINUX) && defined (ACE_HAS_ALPHA_TIMER) @@ -375,12 +373,12 @@ ACE_OS::gmtime_r (const time_t *t, struct tm *res) { ACE_OS_TRACE ("ACE_OS::gmtime_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) - return ace_gmtime_r_helper (t, res); -#elif defined (ACE_HAS_TR24731_2005_CRT) + ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0); +#elif defined (ACE_HAS_TR24731_2005_CRT) && !defined (ACE_WIN32_VC14) struct tm *tm_p = res; ACE_SECURECRTCALL (gmtime_s (res, t), struct tm *, 0, tm_p); return tm_p; -#elif defined (ACE_LACKS_GMTIME) +#elif defined (ACE_LACKS_GMTIME_R) ACE_UNUSED_ARG (t); ACE_UNUSED_ARG (res); ACE_NOTSUP_RETURN (0); diff --git a/dep/acelite/ace/OS_NS_unistd.cpp b/dep/acelite/ace/OS_NS_unistd.cpp index 1bf7a4cdc..d028b0bb1 100644 --- a/dep/acelite/ace/OS_NS_unistd.cpp +++ b/dep/acelite/ace/OS_NS_unistd.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_unistd.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/OS_NS_unistd.h" #if !defined (ACE_HAS_INLINED_OSCALLS) @@ -71,11 +73,7 @@ ACE_OS::argv_to_string (int argc, { if (argv_p == argv) { -#if defined (ACE_HAS_ALLOC_HOOKS) - argv_p = (ACE_TCHAR **) ACE_Allocator::instance()->malloc (argc * sizeof (ACE_TCHAR *)); -#else argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *)); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (argv_p == 0) { errno = ENOMEM; @@ -86,11 +84,7 @@ ACE_OS::argv_to_string (int argc, argv_p[i] = ACE_OS::strenvdup (argv[i]); if (argv_p[i] == 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (argv_p); -#else ACE_OS::free (argv_p); -#endif /* ACE_HAS_ALLOC_HOOKS */ errno = ENOMEM; return 0; } @@ -107,11 +101,7 @@ ACE_OS::argv_to_string (int argc, { if (argv_p == argv) { -#if defined (ACE_HAS_ALLOC_HOOKS) - argv_p = (ACE_TCHAR **) ACE_Allocator::instance()->malloc (argc * sizeof (ACE_TCHAR *)); -#else argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *)); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (argv_p == 0) { errno = ENOMEM; @@ -128,20 +118,11 @@ ACE_OS::argv_to_string (int argc, ++quotes; } argv_p[i] = -#if defined (ACE_HAS_ALLOC_HOOKS) - (ACE_TCHAR *) ACE_Allocator::instance()->malloc ((ACE_OS::strlen (temp) + quotes + 3) - * sizeof (ACE_TCHAR)); -#else (ACE_TCHAR *) ACE_OS::malloc ((ACE_OS::strlen (temp) + quotes + 3) * sizeof (ACE_TCHAR)); -#endif /* ACE_HAS_ALLOC_HOOKS */ if (argv_p[i] == 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (argv_p); -#else ACE_OS::free (argv_p); -#endif /* ACE_HAS_ALLOC_HOOKS */ errno = ENOMEM; return 0; } @@ -166,11 +147,7 @@ ACE_OS::argv_to_string (int argc, *end = ACE_TEXT ('\0'); if (temp != argv[i]) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (temp); -#else ACE_OS::free (temp); -#endif /* ACE_HAS_ALLOC_HOOKS */ } buf_len += ACE_OS::strlen (argv_p[i]); @@ -181,15 +158,9 @@ ACE_OS::argv_to_string (int argc, // Step through all argv params and copy each one into buf; separate // each param with white space. -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (buf, - static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (buf_len + 1))), - 0); -#else ACE_NEW_RETURN (buf, ACE_TCHAR[buf_len + 1], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Initial null charater to make it a null string. buf[0] = ACE_TEXT ('\0'); @@ -199,11 +170,7 @@ ACE_OS::argv_to_string (int argc, { end = ACE_OS::strecpy (end, argv_p[i]); if (argv_p[i] != argv[i]) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (argv_p[i]); -#else ACE_OS::free (argv_p[i]); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Replace the null char that strecpy put there with white // space. @@ -213,11 +180,7 @@ ACE_OS::argv_to_string (int argc, *end = ACE_TEXT ('\0'); if (argv_p != argv) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (argv_p); -#else ACE_OS::free (argv_p); -#endif /* ACE_HAS_ALLOC_HOOKS */ // The number of arguments. return argc; @@ -388,7 +351,7 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[]) ACE_OS::exit (errno); } # endif /* ACE_HAS_WCHAR */ - return result; + default: // Server process. The fork succeeded. return result; @@ -644,7 +607,7 @@ ACE_OS::pread (ACE_HANDLE handle, return bytes_read; -# endif /* ACE_HAS_P_READ_WRITE */ +# endif /* ACE_HAD_P_READ_WRITE */ } ssize_t @@ -847,26 +810,14 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf, // Make sure that the buffer we're copying into is always large // enough. if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN(argp, - static_cast(ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR) * (cp - buf + 1))), - -1); -#else ACE_NEW_RETURN (argp, ACE_TCHAR[cp - buf + 1], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Make a new argv vector of argc + 1 elements. -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN(argv, - static_cast(ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR*) * (argc + 1))), - -1); -#else ACE_NEW_RETURN (argv, ACE_TCHAR *[argc + 1], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_TCHAR *ptr = buf; @@ -906,11 +857,7 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf, if (argv[i] == 0) { if (argp != arg) -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(argp); -#else delete [] argp; -#endif /* ACE_HAS_ALLOC_HOOKS */ errno = ENOMEM; return -1; } @@ -924,11 +871,7 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf, { if (argp != arg) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(argp); -#else delete [] argp; -#endif /* ACE_HAS_ALLOC_HOOKS */ } errno = ENOMEM; @@ -939,11 +882,7 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf, if (argp != arg) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(argp); -#else delete [] argp; -#endif /* ACE_HAS_ALLOC_HOOKS */ } argv[argc] = 0; diff --git a/dep/acelite/ace/OS_NS_unistd.h b/dep/acelite/ace/OS_NS_unistd.h index 460d767d9..298e12417 100644 --- a/dep/acelite/ace/OS_NS_unistd.h +++ b/dep/acelite/ace/OS_NS_unistd.h @@ -4,7 +4,9 @@ /** * @file OS_NS_unistd.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_unistd.h 92712 2010-11-25 12:22:13Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_unistd.inl b/dep/acelite/ace/OS_NS_unistd.inl index 9019916ac..64f929938 100644 --- a/dep/acelite/ace/OS_NS_unistd.inl +++ b/dep/acelite/ace/OS_NS_unistd.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_unistd.inl 97304 2013-08-29 21:14:43Z shuston $ + #include "ace/OS_NS_sys_utsname.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_errno.h" @@ -54,11 +57,7 @@ ACE_OS::access (const char *path, int amode) # endif /* ACE_HAS_ACCESS_EMULATION */ #elif defined(ACE_WIN32) // Windows doesn't support checking X_OK(6) -# if defined (ACE_ACCESS_EQUIVALENT) - ACE_OSCALL_RETURN (ACE_ACCESS_EQUIVALENT (path, amode & 6), int, -1); -# else - ACE_OSCALL_RETURN (::access (path, amode & 6), int, -1); -# endif + ACE_OSCALL_RETURN (::access (path, amode & 6), int, -1); #else ACE_OSCALL_RETURN (::access (path, amode), int, -1); #endif /* ACE_LACKS_ACCESS */ @@ -128,8 +127,6 @@ ACE_OS::chdir (const char *path) ACE_NOTSUP_RETURN (-1); #elif defined (ACE_HAS_NONCONST_CHDIR) ACE_OSCALL_RETURN (::chdir (const_cast (path)), int, -1); -#elif defined (ACE_CHDIR_EQUIVALENT) - ACE_OSCALL_RETURN (ACE_CHDIR_EQUIVALENT (path), int, -1); #else ACE_OSCALL_RETURN (::chdir (path), int, -1); #endif /* ACE_HAS_NONCONST_CHDIR */ @@ -157,8 +154,6 @@ ACE_OS::rmdir (const char *path) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectory (ACE_TEXT_CHAR_TO_TCHAR(path)), ace_result_), int, -1); -#elif defined (ACE_RMDIR_EQUIVALENT) - ACE_OSCALL_RETURN (ACE_RMDIR_EQUIVALENT (path), int, -1); #else ACE_OSCALL_RETURN (::rmdir (path), int, -1); #endif /* ACE_WIN32 */ @@ -331,7 +326,7 @@ ACE_OS::execvp (const char *file, char *const argv[]) { ACE_OS_TRACE ("ACE_OS::execvp"); -#if defined (ACE_LACKS_EXEC) || defined (ACE_LACKS_EXECVP) +#if defined (ACE_LACKS_EXEC) ACE_UNUSED_ARG (file); ACE_UNUSED_ARG (argv); @@ -411,11 +406,7 @@ ACE_OS::getcwd (char *buf, size_t size) ACE_UNUSED_ARG (size); ACE_NOTSUP_RETURN (0); #elif defined (ACE_WIN32) -# if defined (ACE_GETCWD_EQUIVALENT) - return ACE_GETCWD_EQUIVALENT (buf, static_cast (size)); -# else return ::getcwd (buf, static_cast (size)); -# endif #else ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0); #endif /* ACE_LACKS_GETCWD */ @@ -931,7 +922,10 @@ ACE_INLINE int ACE_OS::sleep (u_int seconds) { ACE_OS_TRACE ("ACE_OS::sleep"); -#if defined (ACE_HAS_CLOCK_GETTIME) +#if defined (ACE_WIN32) + ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS); + return 0; +#elif defined (ACE_HAS_CLOCK_GETTIME) struct timespec rqtp; // Initializer doesn't work with Green Hills 1.8.7 rqtp.tv_sec = seconds; @@ -939,12 +933,6 @@ ACE_OS::sleep (u_int seconds) //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1); //FUZZ: enable check_for_lack_ACE_OS -#elif defined (ACE_LACKS_SLEEP) - ACE_UNUSED_ARG (seconds); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_WIN32) - ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS); - return 0; #else ACE_OSCALL_RETURN (::sleep (seconds), int, -1); #endif /* ACE_WIN32 */ @@ -1023,11 +1011,7 @@ ACE_OS::swab (const void *src, char *to = static_cast (dest); # if defined (ACE_HAS_INT_SWAB) int ilength = ACE_Utils::truncate_cast (length); -# if defined (ACE_SWAB_EQUIVALENT) - ACE_SWAB_EQUIVALENT (from, to, ilength); -# else ::swab (from, to, ilength); -# endif # else ::swab (from, to, length); # endif /* ACE_HAS_INT_SWAB */ @@ -1129,7 +1113,7 @@ ACE_OS::ualarm (useconds_t usecs, useconds_t interval) #if defined (ACE_HAS_UALARM) return ::ualarm (usecs, interval); -#elif !defined (ACE_LACKS_UNIX_SIGNALS) && !defined (ACE_LACKS_ALARM) +#elif !defined (ACE_LACKS_UNIX_SIGNALS) ACE_UNUSED_ARG (interval); # if defined (ACE_VXWORKS) && ACE_VXWORKS >= 0x690 && defined (_WRS_CONFIG_LP64) return ::alarm (static_cast (usecs * ACE_ONE_SECOND_IN_USECS)); @@ -1154,7 +1138,7 @@ ACE_OS::ualarm (const ACE_Time_Value &tv, useconds_t interval = (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec (); return ::ualarm (usecs, interval); -#elif !defined (ACE_LACKS_UNIX_SIGNALS) && !defined (ACE_LACKS_ALARM) +#elif !defined (ACE_LACKS_UNIX_SIGNALS) ACE_UNUSED_ARG (tv_interval); # if defined (ACE_VXWORKS) && ACE_VXWORKS >= 0x690 && defined (_WRS_CONFIG_LP64) return ::alarm (static_cast (tv.sec ())); @@ -1181,8 +1165,6 @@ ACE_OS::unlink (const char *path) # elif defined (ACE_LACKS_UNLINK) ACE_UNUSED_ARG (path); ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_UNLINK_EQUIVALENT) - ACE_OSCALL_RETURN (ACE_UNLINK_EQUIVALENT (path), int, -1); # else ACE_OSCALL_RETURN (::unlink (path), int, -1); # endif /* ACE_HAS_NONCONST_UNLINK */ diff --git a/dep/acelite/ace/OS_NS_wchar.cpp b/dep/acelite/ace/OS_NS_wchar.cpp index aa914be24..9592a3854 100644 --- a/dep/acelite/ace/OS_NS_wchar.cpp +++ b/dep/acelite/ace/OS_NS_wchar.cpp @@ -1,3 +1,5 @@ +// $Id: OS_NS_wchar.cpp 92712 2010-11-25 12:22:13Z johnnyw $ + #include "ace/OS_NS_wchar.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_wchar.h b/dep/acelite/ace/OS_NS_wchar.h index 5b42e80b2..dc7ddb579 100644 --- a/dep/acelite/ace/OS_NS_wchar.h +++ b/dep/acelite/ace/OS_NS_wchar.h @@ -4,7 +4,9 @@ /** * @file OS_NS_wchar.h * - * @author Douglas C. Schmidt + * $Id: OS_NS_wchar.h 91995 2010-09-24 12:45:24Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/OS_NS_wchar.inl b/dep/acelite/ace/OS_NS_wchar.inl index 0b11e61e3..a11a0fb23 100644 --- a/dep/acelite/ace/OS_NS_wchar.inl +++ b/dep/acelite/ace/OS_NS_wchar.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_NS_wchar.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_HAS_WCHAR) diff --git a/dep/acelite/ace/OS_NS_wctype.cpp b/dep/acelite/ace/OS_NS_wctype.cpp index 8c74fdea2..b5bb362dc 100644 --- a/dep/acelite/ace/OS_NS_wctype.cpp +++ b/dep/acelite/ace/OS_NS_wctype.cpp @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_wctype.cpp 91781 2010-09-15 12:49:15Z johnnyw $ + #include "ace/OS_NS_wctype.h" #if !defined (ACE_HAS_INLINED_OSCALLS) diff --git a/dep/acelite/ace/OS_NS_wctype.h b/dep/acelite/ace/OS_NS_wctype.h index f20f20434..47fbfd580 100644 --- a/dep/acelite/ace/OS_NS_wctype.h +++ b/dep/acelite/ace/OS_NS_wctype.h @@ -4,6 +4,8 @@ /** * @file OS_NS_wctype.h * + * $Id: OS_NS_wctype.h 83891 2008-11-28 11:01:50Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/OS_NS_wctype.inl b/dep/acelite/ace/OS_NS_wctype.inl index 9bb54585d..79ce0812a 100644 --- a/dep/acelite/ace/OS_NS_wctype.inl +++ b/dep/acelite/ace/OS_NS_wctype.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: OS_NS_wctype.inl 91781 2010-09-15 12:49:15Z johnnyw $ + #if defined (ACE_LACKS_ISWCTYPE) #include "ace/OS_NS_errno.h" #endif diff --git a/dep/acelite/ace/OS_QoS.cpp b/dep/acelite/ace/OS_QoS.cpp index 47bce4a88..4913dd51f 100644 --- a/dep/acelite/ace/OS_QoS.cpp +++ b/dep/acelite/ace/OS_QoS.cpp @@ -2,7 +2,7 @@ ///** // * @file OS_QoS.cpp // * -// * +// * $Id: OS_QoS.cpp 86508 2009-08-14 13:32:40Z johnnyw $ // * // * @brief Contains OS specific data structures for QoS networking. // * diff --git a/dep/acelite/ace/OS_QoS.h b/dep/acelite/ace/OS_QoS.h index 3173eadba..74d46afce 100644 --- a/dep/acelite/ace/OS_QoS.h +++ b/dep/acelite/ace/OS_QoS.h @@ -4,6 +4,8 @@ /** * @file OS_QoS.h * + * $Id: OS_QoS.h 80826 2008-03-04 14:51:23Z wotte $ + * * @brief Contains OS specific data structures for QoS networking. * * @author Craig Rodrigues diff --git a/dep/acelite/ace/OS_TLI.cpp b/dep/acelite/ace/OS_TLI.cpp index 1ae8e540e..368378121 100644 --- a/dep/acelite/ace/OS_TLI.cpp +++ b/dep/acelite/ace/OS_TLI.cpp @@ -1,3 +1,5 @@ +// $Id: OS_TLI.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/OS_TLI.h" diff --git a/dep/acelite/ace/OS_TLI.h b/dep/acelite/ace/OS_TLI.h index c1b0e40ec..efc43ae4b 100644 --- a/dep/acelite/ace/OS_TLI.h +++ b/dep/acelite/ace/OS_TLI.h @@ -4,7 +4,9 @@ /** * @file OS_TLI.h * - * @author Doug Schmidt + * $Id: OS_TLI.h 91688 2010-09-09 11:21:50Z johnnyw $ + * + * @author Doug Schmidt */ //============================================================================= @@ -154,6 +156,7 @@ typedef struct t_bind ACE_TBIND; * @namespace ACE_OS * * @brief This class is a wrapper for the XTI/TLI operations + * */ namespace ACE_OS { diff --git a/dep/acelite/ace/OS_TLI.inl b/dep/acelite/ace/OS_TLI.inl index 7104344ca..bbca38b2c 100644 --- a/dep/acelite/ace/OS_TLI.inl +++ b/dep/acelite/ace/OS_TLI.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: OS_TLI.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_errno.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/OS_Thread_Adapter.cpp b/dep/acelite/ace/OS_Thread_Adapter.cpp index 355408b45..17713e6f6 100644 --- a/dep/acelite/ace/OS_Thread_Adapter.cpp +++ b/dep/acelite/ace/OS_Thread_Adapter.cpp @@ -1,3 +1,5 @@ +// $Id: OS_Thread_Adapter.cpp 92682 2010-11-23 23:41:19Z shuston $ + #include "ace/OS_Thread_Adapter.h" #include "ace/Thread_Hook.h" @@ -5,10 +7,6 @@ #include "ace/Global_Macros.h" #include "ace/OS_NS_Thread.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_OS_Thread_Adapter::ACE_OS_Thread_Adapter ( @@ -36,8 +34,6 @@ ACE_OS_Thread_Adapter::~ACE_OS_Thread_Adapter (void) { } -ACE_ALLOC_HOOK_DEFINE(ACE_OS_Thread_Adapter) - ACE_THR_FUNC_RETURN ACE_OS_Thread_Adapter::invoke (void) { diff --git a/dep/acelite/ace/OS_Thread_Adapter.h b/dep/acelite/ace/OS_Thread_Adapter.h index dc994327d..401a3df9c 100644 --- a/dep/acelite/ace/OS_Thread_Adapter.h +++ b/dep/acelite/ace/OS_Thread_Adapter.h @@ -4,6 +4,8 @@ /** * @file OS_Thread_Adapter.h * + * $Id: OS_Thread_Adapter.h 92682 2010-11-23 23:41:19Z shuston $ + * * @author Carlos O'Ryan */ //============================================================================= @@ -58,8 +60,6 @@ public: */ virtual ACE_THR_FUNC_RETURN invoke (void); - ACE_ALLOC_HOOK_DECLARE; - protected: /// Ensure that this object is allocated on the heap. diff --git a/dep/acelite/ace/OS_main.cpp b/dep/acelite/ace/OS_main.cpp index 74b917da9..6bff13af4 100644 --- a/dep/acelite/ace/OS_main.cpp +++ b/dep/acelite/ace/OS_main.cpp @@ -1,3 +1,5 @@ +// $Id: OS_main.cpp 97431 2013-11-19 14:28:52Z johnnyw $ + #include "ace/OS_main.h" #if !defined (ACE_DOESNT_DEFINE_MAIN) diff --git a/dep/acelite/ace/OS_main.h b/dep/acelite/ace/OS_main.h index b1ffac914..b916280ea 100644 --- a/dep/acelite/ace/OS_main.h +++ b/dep/acelite/ace/OS_main.h @@ -4,7 +4,9 @@ /** * @file OS_main.h * - * @author Douglas C. Schmidt + * $Id: OS_main.h 85579 2009-06-08 18:46:54Z mitza $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * diff --git a/dep/acelite/ace/Obchunk.cpp b/dep/acelite/ace/Obchunk.cpp index e9493a347..137c548d7 100644 --- a/dep/acelite/ace/Obchunk.cpp +++ b/dep/acelite/ace/Obchunk.cpp @@ -1,7 +1,6 @@ +// $Id: Obchunk.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Obchunk.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/Obchunk.inl" diff --git a/dep/acelite/ace/Obchunk.h b/dep/acelite/ace/Obchunk.h index 3a2fddc26..07b3abae8 100644 --- a/dep/acelite/ace/Obchunk.h +++ b/dep/acelite/ace/Obchunk.h @@ -4,6 +4,8 @@ /** * @file Obchunk.h * + * $Id: Obchunk.h 96230 2012-11-06 22:18:13Z schmidt $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Obchunk.inl b/dep/acelite/ace/Obchunk.inl index b27a8abef..b2c716849 100644 --- a/dep/acelite/ace/Obchunk.inl +++ b/dep/acelite/ace/Obchunk.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Obchunk.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Object_Manager.cpp b/dep/acelite/ace/Object_Manager.cpp index ed83f68aa..012df81ff 100644 --- a/dep/acelite/ace/Object_Manager.cpp +++ b/dep/acelite/ace/Object_Manager.cpp @@ -1,11 +1,13 @@ +// $Id: Object_Manager.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Object_Manager.h" #if !defined (ACE_LACKS_ACE_TOKEN) # include "ace/Token_Manager.h" #endif /* ! ACE_LACKS_ACE_TOKEN */ #include "ace/Thread_Manager.h" #if !defined (ACE_LACKS_ACE_SVCCONF) -# include "ace/Service_Manager.h" -# include "ace/Service_Config.h" +# include "ace/Service_Manager.h" +# include "ace/Service_Config.h" #endif /* ! ACE_LACKS_ACE_SVCCONF */ #include "ace/Signal.h" #include "ace/Log_Category.h" @@ -29,8 +31,7 @@ #include "ace/Mutex.h" #include "ace/RW_Thread_Mutex.h" #if defined (ACE_DISABLE_WIN32_ERROR_WINDOWS) && !defined (ACE_HAS_WINCE) -# include "ace/OS_NS_stdlib.h" -# include /**/ + #include "ace/OS_NS_stdlib.h" #endif // ACE_DISABLE_WIN32_ERROR_WINDOWS #if ! defined (ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS) @@ -120,8 +121,6 @@ public: ACE_Object_Manager_Preallocations (void); ~ACE_Object_Manager_Preallocations (void); - ACE_ALLOC_HOOK_DECLARE; - private: ACE_Static_Svc_Descriptor ace_svc_desc_ACE_Service_Manager; }; @@ -150,8 +149,6 @@ ACE_Object_Manager_Preallocations::~ACE_Object_Manager_Preallocations (void) { } -ACE_ALLOC_HOOK_DEFINE(ACE_Object_Manager_Preallocations) - #endif /* ! ACE_LACKS_ACE_SVCCONF */ int @@ -168,7 +165,7 @@ ACE_Object_Manager::shutting_down (void) #if defined (ACE_DISABLE_WIN32_ERROR_WINDOWS) // Instead of popping up a window for exceptions, just print something out -LONG WINAPI ACE_UnhandledExceptionFilter (PEXCEPTION_POINTERS pExceptionInfo) +LONG _stdcall ACE_UnhandledExceptionFilter (PEXCEPTION_POINTERS pExceptionInfo) { DWORD dwExceptionCode = pExceptionInfo->ExceptionRecord->ExceptionCode; @@ -417,8 +414,6 @@ ACE_Object_Manager::~ACE_Object_Manager (void) fini (); } -ACE_ALLOC_HOOK_DEFINE(ACE_Object_Manager) - ACE_Object_Manager * ACE_Object_Manager::instance (void) { @@ -894,10 +889,13 @@ static ACE_Object_Manager_Manager ACE_Object_Manager_Manager_instance; #if defined (ACE_HAS_THREADS) +// hack to get around errors while compiling using split-cpp +#if !defined (ACE_IS_SPLITTING) // This is global so that it doesn't have to be declared in the header // file. That would cause nasty circular include problems. typedef ACE_Cleanup_Adapter ACE_Static_Object_Lock_Type; static ACE_Static_Object_Lock_Type *ACE_Static_Object_Lock_lock = 0; +#endif /* ! ACE_IS_SPLITTING */ // ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK isn't (currently) used by ACE. // But, applications may find it useful for avoiding recursive calls diff --git a/dep/acelite/ace/Object_Manager.h b/dep/acelite/ace/Object_Manager.h index f3651742e..5e177ee6b 100644 --- a/dep/acelite/ace/Object_Manager.h +++ b/dep/acelite/ace/Object_Manager.h @@ -4,6 +4,8 @@ /** * @file Object_Manager.h * + * $Id: Object_Manager.h 91066 2010-07-12 11:05:04Z johnnyw $ + * * @author David L. Levine * @author Matthias Kerkhoff * @author Per Andersson @@ -197,8 +199,6 @@ class ACE_Export ACE_Object_Manager : public ACE_Object_Manager_Base { public: - ACE_ALLOC_HOOK_DECLARE; - /** * Explicitly initialize (construct the singleton instance of) the * ACE_Object_Manager. Returns 0 on success, -1 on failure, and 1 diff --git a/dep/acelite/ace/Object_Manager.inl b/dep/acelite/ace/Object_Manager.inl index a65098a6f..30dca17ac 100644 --- a/dep/acelite/ace/Object_Manager.inl +++ b/dep/acelite/ace/Object_Manager.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Object_Manager.inl 84163 2009-01-15 07:57:27Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Object_Manager_Base.cpp b/dep/acelite/ace/Object_Manager_Base.cpp index 9e17e8210..e62b05676 100644 --- a/dep/acelite/ace/Object_Manager_Base.cpp +++ b/dep/acelite/ace/Object_Manager_Base.cpp @@ -1,3 +1,5 @@ +// $Id: Object_Manager_Base.cpp 92580 2010-11-15 09:48:02Z johnnyw $ + #include "ace/Object_Manager_Base.h" #include "ace/OS_Memory.h" #include "ace/OS_NS_Thread.h" @@ -5,10 +7,6 @@ #include "ace/OS_NS_signal.h" #include "ace/OS_NS_stdio.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) @@ -25,17 +23,6 @@ int ACE_SEH_Default_Exception_Handler (void *) } #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# define ACE_OS_PREALLOCATE_OBJECT(TYPE, ID)\ - {\ - TYPE *obj_p = 0;\ - ACE_ALLOCATOR_RETURN (obj_p, static_cast(ACE_Allocator::instance()->malloc(sizeof(TYPE))), -1); \ - preallocated_object[ID] = (void *) obj_p;\ - } -# define ACE_OS_DELETE_PREALLOCATED_OBJECT(TYPE, ID)\ - ACE_Allocator::instance()->free (preallocated_object[ID]); \ - preallocated_object[ID] = 0; -#else # define ACE_OS_PREALLOCATE_OBJECT(TYPE, ID)\ {\ TYPE *obj_p = 0;\ @@ -45,7 +32,6 @@ int ACE_SEH_Default_Exception_Handler (void *) # define ACE_OS_DELETE_PREALLOCATED_OBJECT(TYPE, ID)\ delete (TYPE *) preallocated_object[ID];\ preallocated_object[ID] = 0; -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_Object_Manager_Base::ACE_Object_Manager_Base (void) : object_manager_state_ (OBJ_MAN_UNINITIALIZED) @@ -121,8 +107,6 @@ ACE_OS_Object_Manager::~ACE_OS_Object_Manager (void) fini (); } -ACE_ALLOC_HOOK_DEFINE(ACE_OS_Object_Manager) - sigset_t * ACE_OS_Object_Manager::default_mask (void) { @@ -267,32 +251,17 @@ ACE_OS_Object_Manager::init (void) ACE_OS::set_exit_hook (&ACE_OS_Object_Manager_Internal_Exit_Hook); } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (default_mask_, static_cast(ACE_Allocator::instance()->malloc(sizeof(sigset_t))), -1); -#else ACE_NEW_RETURN (default_mask_, sigset_t, -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::sigfillset (default_mask_); // Finally, indicate that the ACE_OS_Object_Manager instance has // been initialized. object_manager_state_ = OBJ_MAN_INITIALIZED; -# if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_GETVERSION) -/* Since MS found it necessary to deprecate these. */ -# pragma warning(push) -# pragma warning(disable:4996) -# if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-declarations" -# endif /* __clang__ */ +# if defined (ACE_WIN32) ACE_OS::win32_versioninfo_.dwOSVersionInfoSize = sizeof (ACE_TEXT_OSVERSIONINFO); ACE_TEXT_GetVersionEx (&ACE_OS::win32_versioninfo_); -# if defined(__clang__) -# pragma clang diagnostic pop -# endif /* __clang__ */ -# pragma warning(pop) # endif /* ACE_WIN32 */ return 0; } else { @@ -346,9 +315,6 @@ ACE_OS_Object_Manager::fini (void) if (ACE_OS::thread_mutex_destroy // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. (reinterpret_cast (ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0) -# ifdef ACE_LACKS_PTHREAD_MUTEX_DESTROY - if (errno != ENOTSUP) -# endif ACE_OS_Object_Manager::print_error_message ( __LINE__, ACE_TEXT ("ACE_OS_MONITOR_LOCK")); # endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ @@ -358,9 +324,6 @@ ACE_OS_Object_Manager::fini (void) if (ACE_OS::recursive_mutex_destroy // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. (reinterpret_cast (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0) -# ifdef ACE_LACKS_PTHREAD_MUTEX_DESTROY - if (errno != ENOTSUP) -# endif ACE_OS_Object_Manager::print_error_message ( __LINE__, ACE_TEXT ("ACE_TSS_CLEANUP_LOCK")); # endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ @@ -370,9 +333,6 @@ ACE_OS_Object_Manager::fini (void) if (ACE_OS::thread_mutex_destroy // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. (reinterpret_cast (ACE_OS_Object_Manager::preallocated_object [ACE_LOG_MSG_INSTANCE_LOCK])) != 0) -# ifdef ACE_LACKS_PTHREAD_MUTEX_DESTROY - if (errno != ENOTSUP) -# endif ACE_OS_Object_Manager::print_error_message ( __LINE__, ACE_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK ")); # endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ @@ -407,11 +367,7 @@ ACE_OS_Object_Manager::fini (void) #endif /* ! ACE_HAS_STATIC_PREALLOCATION */ } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(default_mask_); -#else delete default_mask_; -#endif /* ACE_HAS_ALLOC_HOOKS */ default_mask_ = 0; // Indicate that this ACE_OS_Object_Manager instance has been shut down. @@ -445,17 +401,10 @@ ACE_OS_Object_Manager::print_error_message (unsigned int line_number, { // To avoid duplication of these const strings in OS.o. #if !defined (ACE_HAS_WINCE) -# ifndef ACE_LACKS_STDERR fprintf (stderr, "ace/Object_Manager_Base.cpp, line %u: %s ", line_number, ACE_TEXT_ALWAYS_CHAR (message)); -# else - ACE_UNUSED_ARG (line_number); - ACE_UNUSED_ARG (message); -# endif -# if !defined (ACE_LACKS_PERROR) perror ("failed"); -# endif /* ACE_LACKS_PERROR */ #else // @@ Need to use the following information. ACE_UNUSED_ARG (line_number); diff --git a/dep/acelite/ace/Object_Manager_Base.h b/dep/acelite/ace/Object_Manager_Base.h index dca3054c8..a613f3c63 100644 --- a/dep/acelite/ace/Object_Manager_Base.h +++ b/dep/acelite/ace/Object_Manager_Base.h @@ -4,7 +4,9 @@ /** * @file Object_Manager_Base.h * - * @author Douglas C. Schmidt + * $Id: Object_Manager_Base.h 97262 2013-08-09 08:32:10Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -127,8 +129,6 @@ class ACE_Log_Msg; class ACE_Export ACE_OS_Object_Manager : public ACE_Object_Manager_Base { public: - ACE_ALLOC_HOOK_DECLARE; - /// Explicitly initialize. virtual int init (void); diff --git a/dep/acelite/ace/Obstack.cpp b/dep/acelite/ace/Obstack.cpp index 110a5cc8d..fefb5cf96 100644 --- a/dep/acelite/ace/Obstack.cpp +++ b/dep/acelite/ace/Obstack.cpp @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Obstack.cpp 97400 2013-10-31 10:44:50Z mhengstmengel $ + #include "ace/Obstack.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Obstack.h b/dep/acelite/ace/Obstack.h index 7e0feacab..b7b75e735 100644 --- a/dep/acelite/ace/Obstack.h +++ b/dep/acelite/ace/Obstack.h @@ -3,7 +3,9 @@ /** * @file Obstack.h * - * @author Douglas C. Schmidt + * $Id: Obstack.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Obstack_T.cpp b/dep/acelite/ace/Obstack_T.cpp index 659f643e9..5dc36ac9e 100644 --- a/dep/acelite/ace/Obstack_T.cpp +++ b/dep/acelite/ace/Obstack_T.cpp @@ -1,3 +1,5 @@ +// $Id: Obstack_T.cpp 97400 2013-10-31 10:44:50Z mhengstmengel $ + #ifndef ACE_OBSTACK_T_CPP #define ACE_OBSTACK_T_CPP @@ -15,7 +17,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Obstack_T) +ACE_ALLOC_HOOK_DEFINE(ACE_Obstack_T) template void ACE_Obstack_T::dump (void) const diff --git a/dep/acelite/ace/Obstack_T.h b/dep/acelite/ace/Obstack_T.h index 613fd6137..f83817edc 100644 --- a/dep/acelite/ace/Obstack_T.h +++ b/dep/acelite/ace/Obstack_T.h @@ -4,7 +4,9 @@ /** * @file Obstack_T.h * - * @author Doug Schmidt + * $Id: Obstack_T.h 96230 2012-11-06 22:18:13Z schmidt $ + * + * @author Doug Schmidt * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/Obstack_T.inl b/dep/acelite/ace/Obstack_T.inl index fb9d09d43..4d93048b3 100644 --- a/dep/acelite/ace/Obstack_T.inl +++ b/dep/acelite/ace/Obstack_T.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Obstack_T.inl 91688 2010-09-09 11:21:50Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE size_t diff --git a/dep/acelite/ace/PI_Malloc.cpp b/dep/acelite/ace/PI_Malloc.cpp index b1e94335e..8c19fa75d 100644 --- a/dep/acelite/ace/PI_Malloc.cpp +++ b/dep/acelite/ace/PI_Malloc.cpp @@ -1,3 +1,5 @@ +// $Id: PI_Malloc.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_PI_MALLOC_CPP #define ACE_PI_MALLOC_CPP diff --git a/dep/acelite/ace/PI_Malloc.h b/dep/acelite/ace/PI_Malloc.h index a76d95f36..679b71b98 100644 --- a/dep/acelite/ace/PI_Malloc.h +++ b/dep/acelite/ace/PI_Malloc.h @@ -4,6 +4,8 @@ /** * @file PI_Malloc.h * + * $Id: PI_Malloc.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Priyanka Gontla * @author Based on code that existed in other ACE files. */ diff --git a/dep/acelite/ace/PI_Malloc.inl b/dep/acelite/ace/PI_Malloc.inl index 98cdca3ae..0828ebb83 100644 --- a/dep/acelite/ace/PI_Malloc.inl +++ b/dep/acelite/ace/PI_Malloc.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: PI_Malloc.inl 80826 2008-03-04 14:51:23Z wotte $ + #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/POSIX_Asynch_IO.cpp b/dep/acelite/ace/POSIX_Asynch_IO.cpp index 2b29515b9..d24f93f9a 100644 --- a/dep/acelite/ace/POSIX_Asynch_IO.cpp +++ b/dep/acelite/ace/POSIX_Asynch_IO.cpp @@ -1,3 +1,5 @@ +// $Id: POSIX_Asynch_IO.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/POSIX_Asynch_IO.h" #if defined (ACE_HAS_AIO_CALLS) diff --git a/dep/acelite/ace/POSIX_Asynch_IO.h b/dep/acelite/ace/POSIX_Asynch_IO.h index 2fde60e79..ba1803037 100644 --- a/dep/acelite/ace/POSIX_Asynch_IO.h +++ b/dep/acelite/ace/POSIX_Asynch_IO.h @@ -4,6 +4,8 @@ /** * @file POSIX_Asynch_IO.h * + * $Id: POSIX_Asynch_IO.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * The implementation classes for POSIX implementation of Asynch * Operations are defined here in this file. * @@ -181,7 +183,7 @@ public: ACE_POSIX_Proactor * posix_proactor (void) const; protected: - /// Constructor. + /// Contructor. ACE_POSIX_Asynch_Operation (ACE_POSIX_Proactor *posix_proactor); /// Destructor. @@ -277,6 +279,7 @@ protected: * * This class implements for all POSIX * based implementation of Proactor. + * */ class ACE_Export ACE_POSIX_Asynch_Read_Stream : public virtual ACE_Asynch_Read_Stream_Impl, public ACE_POSIX_Asynch_Operation @@ -304,6 +307,7 @@ public: * @brief This class provides concrete implementation for * on POSIX platforms. * + * * This class has all the information necessary for the * @c handler to uniquiely identify the completion of the * asynchronous write. @@ -538,6 +542,7 @@ protected: * for POSIX platforms where the * completion strategy for Proactor is based on AIOCB (AIO * Control Blocks). + * */ class ACE_Export ACE_POSIX_Asynch_Write_File : public virtual ACE_Asynch_Write_File_Impl, public ACE_POSIX_Asynch_Write_Stream @@ -582,6 +587,7 @@ private: * @brief This is that class which will be passed back to the * handler when the asynchronous accept completes. * + * * This class has all the information necessary for the * handler to uniquiely identify the completion of the * asynchronous accept. @@ -795,6 +801,7 @@ protected: /** * @class ACE_POSIX_Asynch_Connect + * */ class ACE_Export ACE_POSIX_Asynch_Connect : public virtual ACE_Asynch_Connect_Impl, @@ -1037,6 +1044,7 @@ public: * will be passed back to the when the asynchronous * reads completes through the * callback. + * */ class ACE_Export ACE_POSIX_Asynch_Read_Dgram : public virtual ACE_Asynch_Read_Dgram_Impl, public ACE_POSIX_Asynch_Operation diff --git a/dep/acelite/ace/POSIX_CB_Proactor.cpp b/dep/acelite/ace/POSIX_CB_Proactor.cpp index 9be836cc8..dcc1cd674 100644 --- a/dep/acelite/ace/POSIX_CB_Proactor.cpp +++ b/dep/acelite/ace/POSIX_CB_Proactor.cpp @@ -1,3 +1,5 @@ +// $Id: POSIX_CB_Proactor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/POSIX_CB_Proactor.h" #if defined (ACE_HAS_AIO_CALLS) && !defined (ACE_HAS_BROKEN_SIGEVENT_STRUCT) diff --git a/dep/acelite/ace/POSIX_CB_Proactor.h b/dep/acelite/ace/POSIX_CB_Proactor.h index e38360f5f..fc76f82e2 100644 --- a/dep/acelite/ace/POSIX_CB_Proactor.h +++ b/dep/acelite/ace/POSIX_CB_Proactor.h @@ -4,6 +4,8 @@ /** * @file POSIX_CB_Proactor.h * + * $Id: POSIX_CB_Proactor.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Alexander Libman */ //============================================================================= diff --git a/dep/acelite/ace/POSIX_Proactor.cpp b/dep/acelite/ace/POSIX_Proactor.cpp index e3414396b..fb5ba08f0 100644 --- a/dep/acelite/ace/POSIX_Proactor.cpp +++ b/dep/acelite/ace/POSIX_Proactor.cpp @@ -1,3 +1,5 @@ +// $Id: POSIX_Proactor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/POSIX_Proactor.h" #if defined (ACE_HAS_AIO_CALLS) @@ -920,12 +922,6 @@ int ACE_POSIX_AIOCB_Proactor::delete_result_aiocb_list (void) void ACE_POSIX_AIOCB_Proactor::check_max_aio_num () { -#if !defined (ACE_ANDROID) - // Android API 23 introduced a define _POSIX_AIO_MAX 1 which gets used by _SC_AIO_MAX. - // Previously, without the define, the value returned was -1, which got ignored. - // Officially, the Android OS does not support AIO so if ACE_HAS_AIO_CALLS is defined - // then a 3rd party library must be in use and this check is invalid. - long max_os_aio_num = ACE_OS::sysconf (_SC_AIO_MAX); // Define max limit AIO's for concrete OS @@ -935,7 +931,6 @@ void ACE_POSIX_AIOCB_Proactor::check_max_aio_num () if (max_os_aio_num > 0 && aiocb_list_max_size_ > (unsigned long) max_os_aio_num) aiocb_list_max_size_ = max_os_aio_num; -#endif #if defined (HPUX) || defined (__FreeBSD__) // Although HPUX 11.00 allows to start 2048 AIO's for all process in @@ -974,6 +969,40 @@ void ACE_POSIX_AIOCB_Proactor::check_max_aio_num () ACELIB_DEBUG ((LM_DEBUG, "(%P | %t) ACE_POSIX_AIOCB_Proactor::Max Number of AIOs=%d\n", aiocb_list_max_size_)); + +#if defined(__sgi) + + ACELIB_DEBUG((LM_DEBUG, + ACE_TEXT( "SGI IRIX specific: aio_init!\n"))); + +//typedef struct aioinit { +// int aio_threads; /* The number of aio threads to start (5) */ +// int aio_locks; /* Initial number of preallocated locks (3) */ +// int aio_num; /* estimated total simultanious aiobc structs (1000) */ +// int aio_usedba; /* Try to use DBA for raw I/O in lio_listio (0) */ +// int aio_debug; /* turn on debugging (0) */ +// int aio_numusers; /* max number of user sprocs making aio_* calls (5) */ +// int aio_reserved[3]; +//} aioinit_t; + + aioinit_t aioinit; + + aioinit.aio_threads = 10; /* The number of aio threads to start (5) */ + aioinit.aio_locks = 20; /* Initial number of preallocated locks (3) */ + /* estimated total simultaneous aiobc structs (1000) */ + aioinit.aio_num = aiocb_list_max_size_; + aioinit.aio_usedba = 0; /* Try to use DBA for raw IO in lio_listio (0) */ + aioinit.aio_debug = 0; /* turn on debugging (0) */ + aioinit.aio_numusers = 100; /* max number of user sprocs making aio_* calls (5) */ + aioinit.aio_reserved[0] = 0; + aioinit.aio_reserved[1] = 0; + aioinit.aio_reserved[2] = 0; + + aio_sgi_init (&aioinit); + +#endif + + return; } void @@ -992,6 +1021,7 @@ ACE_POSIX_AIOCB_Proactor::delete_notify_manager (void) { // We are responsible for delete as all pointers set to 0 after // delete, it is save to delete twice + delete aiocb_notify_pipe_manager_; aiocb_notify_pipe_manager_ = 0; } diff --git a/dep/acelite/ace/POSIX_Proactor.h b/dep/acelite/ace/POSIX_Proactor.h index 46ebef1fa..991a27515 100644 --- a/dep/acelite/ace/POSIX_Proactor.h +++ b/dep/acelite/ace/POSIX_Proactor.h @@ -4,6 +4,8 @@ /** * @file POSIX_Proactor.h * + * $Id: POSIX_Proactor.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Irfan Pyarali * @author Tim Harrison * @author Alexander Babu Arulanthu diff --git a/dep/acelite/ace/POSIX_Proactor.inl b/dep/acelite/ace/POSIX_Proactor.inl index c6edd4a5c..da52de69a 100644 --- a/dep/acelite/ace/POSIX_Proactor.inl +++ b/dep/acelite/ace/POSIX_Proactor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: POSIX_Proactor.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Pagefile_Memory_Pool.cpp b/dep/acelite/ace/Pagefile_Memory_Pool.cpp index ba803872c..907dc23c7 100644 --- a/dep/acelite/ace/Pagefile_Memory_Pool.cpp +++ b/dep/acelite/ace/Pagefile_Memory_Pool.cpp @@ -1,3 +1,5 @@ +// $Id: Pagefile_Memory_Pool.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Pagefile_Memory_Pool.cpp #include "ace/Pagefile_Memory_Pool.h" diff --git a/dep/acelite/ace/Pagefile_Memory_Pool.h b/dep/acelite/ace/Pagefile_Memory_Pool.h index 9c5f20337..28fdfe59a 100644 --- a/dep/acelite/ace/Pagefile_Memory_Pool.h +++ b/dep/acelite/ace/Pagefile_Memory_Pool.h @@ -4,7 +4,9 @@ /** * @file Pagefile_Memory_Pool.h * - * @author Dougls C. Schmidt + * $Id: Pagefile_Memory_Pool.h 85318 2009-05-11 18:17:14Z johnnyw $ + * + * @author Dougls C. Schmidt * @author Prashant Jain */ //============================================================================= diff --git a/dep/acelite/ace/Pagefile_Memory_Pool.inl b/dep/acelite/ace/Pagefile_Memory_Pool.inl index 30003e0b1..fc499ec17 100644 --- a/dep/acelite/ace/Pagefile_Memory_Pool.inl +++ b/dep/acelite/ace/Pagefile_Memory_Pool.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Pagefile_Memory_Pool.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Pair_T.cpp b/dep/acelite/ace/Pair_T.cpp index 0bf170b38..35e5803e6 100644 --- a/dep/acelite/ace/Pair_T.cpp +++ b/dep/acelite/ace/Pair_T.cpp @@ -1,3 +1,5 @@ +// $Id: Pair_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_PAIR_T_CPP #define ACE_PAIR_T_CPP diff --git a/dep/acelite/ace/Pair_T.h b/dep/acelite/ace/Pair_T.h index 329778178..604fcba71 100644 --- a/dep/acelite/ace/Pair_T.h +++ b/dep/acelite/ace/Pair_T.h @@ -4,6 +4,8 @@ /** * @file Pair_T.h * + * $Id: Pair_T.h 92097 2010-09-30 05:41:49Z msmit $ + * * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Pair_T.inl b/dep/acelite/ace/Pair_T.inl index a8f620350..cb362e1a3 100644 --- a/dep/acelite/ace/Pair_T.inl +++ b/dep/acelite/ace/Pair_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Pair_T.inl 92097 2010-09-30 05:41:49Z msmit $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE diff --git a/dep/acelite/ace/Parse_Node.cpp b/dep/acelite/ace/Parse_Node.cpp index c362f0763..19b55951d 100644 --- a/dep/acelite/ace/Parse_Node.cpp +++ b/dep/acelite/ace/Parse_Node.cpp @@ -1,3 +1,4 @@ +// $Id: Parse_Node.cpp 96985 2013-04-11 15:50:32Z huangh $ #include "ace/Parse_Node.h" #if (ACE_USES_CLASSIC_SVC_CONF == 1) @@ -47,20 +48,14 @@ ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno) // reverse order from the way they should be pushed onto the stream. // So traverse mods_ and and reverse the list, then iterate over it to push // the modules in the stream in the correct order. -#if defined (ACE_HAS_ALLOC_HOOKS) - typedef std::list > list_t; -#else - typedef std::list list_t; -#endif /* ACE_HAS_ALLOC_HOOKS */ - list_t mod_list; + std::list mod_list; const ACE_Static_Node *module; for (module = dynamic_cast (this->mods_); module != 0; module = dynamic_cast (module->link())) mod_list.push_front (module); - list_t::const_iterator iter; + std::list::const_iterator iter; for (iter = mod_list.begin (); iter != mod_list.end (); ++iter) { module = *iter; @@ -198,11 +193,7 @@ ACE_Parse_Node::print (void) const ACE_Parse_Node::~ACE_Parse_Node (void) { ACE_TRACE ("ACE_Parse_Node::~ACE_Parse_Node"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (this->name_)); -#else delete[] const_cast (this->name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ delete this->next_; } @@ -419,11 +410,7 @@ ACE_Static_Node::apply (ACE_Service_Gestalt *config, int &yyerrno) ACE_Static_Node::~ACE_Static_Node (void) { ACE_TRACE ("ACE_Static_Node::~ACE_Static_Node"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->parameters_); -#else delete[] this->parameters_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } @@ -577,11 +564,7 @@ ACE_Object_Node::symbol (ACE_Service_Gestalt *, ACE_Object_Node::~ACE_Object_Node (void) { ACE_TRACE ("ACE_Object_Node::~ACE_Object_Node"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (this->object_name_)); -#else delete[] const_cast (this->object_name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_ALLOC_HOOK_DEFINE (ACE_Function_Node) @@ -731,13 +714,8 @@ ACE_Function_Node::symbol (ACE_Service_Gestalt *, ACE_Function_Node::~ACE_Function_Node (void) { ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (function_name_)); - ACE_Allocator::instance()->free(const_cast (pathname_)); -#else delete[] const_cast (function_name_); delete[] const_cast (pathname_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_ALLOC_HOOK_DEFINE (ACE_Dummy_Node) @@ -867,11 +845,7 @@ ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config, ACE_Static_Function_Node::~ACE_Static_Function_Node (void) { ACE_TRACE ("ACE_Static_Function_Node::~ACE_Static_Function_Node"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (function_name_)); -#else delete[] const_cast (this->function_name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory) diff --git a/dep/acelite/ace/Parse_Node.h b/dep/acelite/ace/Parse_Node.h index 346252291..034deef31 100644 --- a/dep/acelite/ace/Parse_Node.h +++ b/dep/acelite/ace/Parse_Node.h @@ -4,6 +4,8 @@ /** * @file Parse_Node.h * + * $Id: Parse_Node.h 81239 2008-04-04 22:28:48Z iliyan $ + * * @author Doug Schmidt */ //============================================================================= @@ -22,7 +24,6 @@ #if (ACE_USES_CLASSIC_SVC_CONF == 1) -#include "ace/Auto_Ptr.h" #include "ace/DLL.h" #include "ace/SString.h" #include "ace/Svc_Conf.h" diff --git a/dep/acelite/ace/Ping_Socket.cpp b/dep/acelite/ace/Ping_Socket.cpp index 3779ca252..cbc64ff58 100644 --- a/dep/acelite/ace/Ping_Socket.cpp +++ b/dep/acelite/ace/Ping_Socket.cpp @@ -1,3 +1,5 @@ +// $Id: Ping_Socket.cpp 97355 2013-09-27 22:16:09Z shuston $ + #include "ace/Ping_Socket.h" #if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1) @@ -7,10 +9,7 @@ #include "ace/OS_NS_string.h" #include "ace/OS_NS_sys_time.h" #include "ace/OS_NS_sys_socket.h" -#include "ace/OS_NS_unistd.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ +# include "ace/OS_NS_unistd.h" #if !defined (__ACE_INLINE__) # include "ace/Ping_Socket.inl" @@ -39,7 +38,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL #else /* #if ! defined (ACE_WIN32) */ /* - * This was a surprise to me... This stuff is not defined anywhere under MSVC. + * This was a surpise to me... This stuff is not defined anywhere under MSVC. * These values have only been checked for NT4 and Win2K. They were taken from * the MSDN ping.c program and modified. */ @@ -117,7 +116,7 @@ ACE_Ping_Socket::ACE_Ping_Socket (ACE_Addr const & local, } // trying to increase the size of socket receive buffer - some - // protection from multiple responses e.g., when falling to the + // protection from multiple responces e.g., when falling to the // multi-cast address int size = 64 * 1024; ACE_SOCK::set_option (SOL_SOCKET, diff --git a/dep/acelite/ace/Ping_Socket.h b/dep/acelite/ace/Ping_Socket.h index 4497b9e8e..b063681dd 100644 --- a/dep/acelite/ace/Ping_Socket.h +++ b/dep/acelite/ace/Ping_Socket.h @@ -4,6 +4,8 @@ /** * @file Ping_Socket.h * + * $Id: Ping_Socket.h 93597 2011-03-21 12:54:52Z johnnyw $ + * * @author Robert S. Iakobashvili * @author Gonzalo A. Diethelm */ diff --git a/dep/acelite/ace/Ping_Socket.inl b/dep/acelite/ace/Ping_Socket.inl index b6fcf0be1..bce261d91 100644 --- a/dep/acelite/ace/Ping_Socket.inl +++ b/dep/acelite/ace/Ping_Socket.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Ping_Socket.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE char * diff --git a/dep/acelite/ace/Pipe.cpp b/dep/acelite/ace/Pipe.cpp index 7384dcc63..98b4ff95a 100644 --- a/dep/acelite/ace/Pipe.cpp +++ b/dep/acelite/ace/Pipe.cpp @@ -1,23 +1,17 @@ +// $Id: Pipe.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Pipe.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Connector.h" #include "ace/Log_Category.h" -#include "ace/OS_NS_stdio.h" #include "ace/OS_NS_sys_socket.h" #include "ace/OS_Memory.h" #include "ace/Truncate.h" -#include "ace/Malloc_Base.h" #if defined (ACE_HAS_STREAM_PIPES) || defined (__QNX__) # include "ace/OS_NS_unistd.h" #endif // ACE_HAS_STREAM_PIPES || __QNX__ -#if defined (ACE_LACKS_LISTEN) && defined (ACE_LACKS_SOCKETPAIR) \ - && !defined (ACE_HAS_STREAM_PIPES) -# include "ace/OS_NS_time.h" -# include "ace/os_include/sys/os_un.h" -#endif - #include "ace/os_include/netinet/os_tcp.h" #if !defined (__ACE_INLINE__) @@ -45,41 +39,7 @@ ACE_Pipe::open (int buffer_size) { ACE_TRACE ("ACE_Pipe::open"); -#if defined (ACE_LACKS_LISTEN) && defined (ACE_LACKS_SOCKETPAIR) \ - && !defined (ACE_HAS_STREAM_PIPES) - ACE_UNUSED_ARG (buffer_size); - - if ((this->handles_[0] = ACE_OS::socket (AF_LOCAL, SOCK_DGRAM, 0)) == -1) - { - return -1; - } - - sockaddr_un addr = { -#if defined(ACE_VXWORKS) || defined(__APPLE__) - sizeof (sockaddr_un), -#endif - AF_LOCAL, {}}; - unsigned seed = static_cast (ACE_OS::time ()); - ACE_OS::snprintf (addr.sun_path, sizeof addr.sun_path, "/tmp/ACE-Pipe-%d-%p", - ACE_OS::rand_r (&seed), this); - - if (ACE_OS::bind (this->handles_[0], (sockaddr*) &addr, sizeof addr) == -1) - { - this->close (); - return -1; - } - - if ((this->handles_[1] = ACE_OS::socket (AF_LOCAL, SOCK_DGRAM, 0)) == -1 || - ACE_OS::connect (this->handles_[1], (sockaddr*) &addr, sizeof addr) == -1) - { - ACE_OS::unlink (addr.sun_path); - this->close (); - return -1; - } - - ACE_OS::unlink (addr.sun_path); - -#elif defined (ACE_LACKS_SOCKETPAIR) +#if defined (ACE_LACKS_SOCKETPAIR) ACE_INET_Addr my_addr; ACE_SOCK_Acceptor acceptor; ACE_SOCK_Connector connector; @@ -170,7 +130,7 @@ ACE_Pipe::open (int buffer_size) ACE_TEXT ("pipe")), -1); -# if !defined(__QNX__) +#if !defined(__QNX__) int arg = RMSGN; // Enable "msg no discard" mode, which ensures that record @@ -187,7 +147,7 @@ ACE_Pipe::open (int buffer_size) ACE_TEXT ("%p\n"), ACE_TEXT ("ioctl")), -1); } -# endif /* __QNX__ */ +#endif /* __QNX__ */ #else /* ! ACE_LACKS_SOCKETPAIR && ! ACE_HAS_STREAM_PIPES */ if (ACE_OS::socketpair (AF_UNIX, @@ -314,7 +274,7 @@ int ACE_Pipe::close_write (void) // the ints (basically, an varargs version of writev). The count N is // the *total* number of trailing arguments, *not* a couple of the // number of tuple pairs! -#if !defined (ACE_LACKS_VA_FUNCTIONS) + ssize_t ACE_Pipe::send (size_t n, ...) const { @@ -325,16 +285,9 @@ ACE_Pipe::send (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -356,11 +309,7 @@ ACE_Pipe::send (size_t n, ...) const #endif /* ACE_WIN32 */ #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; @@ -382,16 +331,9 @@ ACE_Pipe::recv (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -413,15 +355,10 @@ ACE_Pipe::recv (size_t n, ...) const #endif /* ACE_WIN32 */ #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; } -#endif /* !ACE_LACKS_VA_FUNCTIONS */ ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Pipe.h b/dep/acelite/ace/Pipe.h index 6a58e934f..b305456eb 100644 --- a/dep/acelite/ace/Pipe.h +++ b/dep/acelite/ace/Pipe.h @@ -4,7 +4,9 @@ /** * @file Pipe.h * - * @author Douglas C. Schmidt + * $Id: Pipe.h 92010 2010-09-24 14:54:19Z shuston $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -110,7 +112,6 @@ public: /// Recv iovecs via <::readv>. ssize_t recv (iovec iov[], int n) const; -#if !defined (ACE_LACKS_VA_FUNCTIONS) /** * Send N char *ptrs and int lengths. Note that the char *'s * precede the ints (basically, an varargs version of writev). The @@ -127,7 +128,6 @@ public: * number of tuple pairs! */ ssize_t recv (size_t n, ...) const; -#endif /* !ACE_LACKS_VA_FUNCTIONS */ /// Send @a n bytes via Win32 WriteFile using overlapped I/O. ssize_t send (const void *buf, diff --git a/dep/acelite/ace/Pipe.inl b/dep/acelite/ace/Pipe.inl index 85900d2d6..3199bbf03 100644 --- a/dep/acelite/ace/Pipe.inl +++ b/dep/acelite/ace/Pipe.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Pipe.inl 92010 2010-09-24 14:54:19Z shuston $ + #include "ace/Global_Macros.h" #include "ace/ACE.h" diff --git a/dep/acelite/ace/Priority_Reactor.cpp b/dep/acelite/ace/Priority_Reactor.cpp index 1a6f5ec31..4564cadd1 100644 --- a/dep/acelite/ace/Priority_Reactor.cpp +++ b/dep/acelite/ace/Priority_Reactor.cpp @@ -1,3 +1,5 @@ +// $Id: Priority_Reactor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Priority_Reactor.h" #include "ace/Malloc_T.h" @@ -29,13 +31,8 @@ ACE_Priority_Reactor::init_bucket (void) TUPLE_ALLOCATOR (ACE_Select_Reactor::DEFAULT_SIZE)); // The event handlers are assigned to a new As the Event -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR (this->bucket_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(QUEUE *) * (npriorities)))); -#else ACE_NEW (this->bucket_, QUEUE *[npriorities]); -#endif /* ACE_HAS_ALLOC_HOOKS */ // This loops "ensures" exception safety. for (int i = 0; i < npriorities; ++i) @@ -72,11 +69,7 @@ ACE_Priority_Reactor::~ACE_Priority_Reactor (void) for (int i = 0; i < npriorities; ++i) delete this->bucket_[i]; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->bucket_); -#else delete[] this->bucket_; -#endif /* ACE_HAS_ALLOC_HOOKS */ delete tuple_allocator_; } diff --git a/dep/acelite/ace/Priority_Reactor.h b/dep/acelite/ace/Priority_Reactor.h index 177a8cf7a..2f29c4c07 100644 --- a/dep/acelite/ace/Priority_Reactor.h +++ b/dep/acelite/ace/Priority_Reactor.h @@ -4,6 +4,8 @@ /** * @file Priority_Reactor.h * + * $Id: Priority_Reactor.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/Proactor.cpp b/dep/acelite/ace/Proactor.cpp index 420379b35..d793a937a 100644 --- a/dep/acelite/ace/Proactor.cpp +++ b/dep/acelite/ace/Proactor.cpp @@ -1,3 +1,5 @@ +// $Id: Proactor.cpp 97262 2013-08-09 08:32:10Z johnnyw $ + #include /**/ "ace/config-lite.h" #include "ace/Proactor.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) @@ -58,7 +60,7 @@ class ACE_Proactor_Timer_Handler : public ACE_Task { public: /// Constructor. - explicit ACE_Proactor_Timer_Handler (ACE_Proactor &proactor); + ACE_Proactor_Timer_Handler (ACE_Proactor &proactor); /// Destructor. virtual ~ACE_Proactor_Timer_Handler (void); @@ -243,11 +245,7 @@ ACE_Proactor_Handle_Timeout_Upcall::timeout (ACE_Proactor_Timer_Queue &, ACE_TEXT ("create_asynch_timer failed")), -1); -#if defined (ACE_HAS_CPP11) - std::unique_ptr safe_asynch_timer (asynch_timer); -#else auto_ptr safe_asynch_timer (asynch_timer); -#endif /* ACE_HAS_CPP11 */ // Post a completion. if (-1 == safe_asynch_timer->post_completion diff --git a/dep/acelite/ace/Proactor.h b/dep/acelite/ace/Proactor.h index 31c4aa2e2..4288aef6b 100644 --- a/dep/acelite/ace/Proactor.h +++ b/dep/acelite/ace/Proactor.h @@ -4,6 +4,8 @@ /** * @file Proactor.h * + * $Id: Proactor.h 95332 2011-12-15 11:09:41Z mcorino $ + * * @author Irfan Pyarali * @author Tim Harrison * @author Alexander Babu Arulanthu @@ -122,7 +124,7 @@ protected: * @brief A manager for asynchronous event demultiplexing. * * See the Proactor pattern description at - * http://www.dre.vanderbilt.edu/~schmidt/PDF/proactor.pdf for more + * http://www.cs.wustl.edu/~schmidt/proactor.ps.gz for more * details. */ class ACE_Export ACE_Proactor diff --git a/dep/acelite/ace/Proactor.inl b/dep/acelite/ace/Proactor.inl index c5027092b..a62e7936e 100644 --- a/dep/acelite/ace/Proactor.inl +++ b/dep/acelite/ace/Proactor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Proactor.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/Proactor_Impl.cpp b/dep/acelite/ace/Proactor_Impl.cpp index 9cf5f4795..4b7772c04 100644 --- a/dep/acelite/ace/Proactor_Impl.cpp +++ b/dep/acelite/ace/Proactor_Impl.cpp @@ -1,3 +1,5 @@ +// $Id: Proactor_Impl.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ + #include "ace/Proactor_Impl.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) diff --git a/dep/acelite/ace/Proactor_Impl.h b/dep/acelite/ace/Proactor_Impl.h index f8851eaca..9668206b2 100644 --- a/dep/acelite/ace/Proactor_Impl.h +++ b/dep/acelite/ace/Proactor_Impl.h @@ -4,6 +4,8 @@ /** * @file Proactor_Impl.h * + * $Id: Proactor_Impl.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Alexander Babu Arulanthu * @author Alexander Libman */ @@ -34,7 +36,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * classes. * * See the Proactor pattern description at - * http://www.dre.vanderbilt.edu/~schmidt/PDF/proactor.pdf for more + * http://www.cs.wustl.edu/~schmidt/proactor.ps.gz for more * details. */ class ACE_Export ACE_Proactor_Impl : public ACE_Event_Handler diff --git a/dep/acelite/ace/Process.cpp b/dep/acelite/ace/Process.cpp index 6cf5433c0..e97564ab9 100644 --- a/dep/acelite/ace/Process.cpp +++ b/dep/acelite/ace/Process.cpp @@ -1,3 +1,5 @@ +// $Id: Process.cpp 97924 2014-10-11 21:15:17Z shuston $ + #include "ace/Process.h" #if !defined (__ACE_INLINE__) @@ -175,34 +177,17 @@ ACE_Process::spawn (ACE_Process_Options &options) } # endif - BOOL fork_result; - if (options.get_user_token () == ACE_INVALID_HANDLE) - { - fork_result = ACE_TEXT_CreateProcess (0, - options.command_line_buf (), - options.get_process_attributes (), - options.get_thread_attributes (), - options.handle_inheritance (), - flags, - env_buf, // environment variables - options.working_directory (), - options.startup_info (), - &this->process_info_); - } - else - { - fork_result = ACE_TEXT_CreateProcessAsUser (options.get_user_token (), - 0, - options.command_line_buf (), - options.get_process_attributes (), - options.get_thread_attributes (), - options.handle_inheritance (), - flags, - env_buf, // environment variables - options.working_directory (), - options.startup_info (), - &this->process_info_); - } + BOOL fork_result = + ACE_TEXT_CreateProcess (0, + options.command_line_buf (), + options.get_process_attributes (), + options.get_thread_attributes (), + options.handle_inheritance (), + flags, + env_buf, // environment variables + options.working_directory (), + options.startup_info (), + &this->process_info_); # if defined (ACE_HAS_WCHAR) && !defined (ACE_USES_WCHAR) if (options.use_unicode_environment ()) @@ -350,7 +335,7 @@ ACE_Process::spawn (ACE_Process_Options &options) # if defined (ACE_USES_WCHAR) if (procenv) - delete [] procenv; + delete procenv; # endif /* ACE_USES_WCHAR */ // restore STD file descriptors (if necessary) @@ -536,11 +521,7 @@ ACE_Process::spawn (ACE_Process_Options &options) // Now the forked process has both inherited variables and // the user's supplied variables. -# ifdef ACE_LACKS_EXECVP - result = ACE_OS::execv (procname, procargv); -# else result = ACE_OS::execvp (procname, procargv); -# endif } else { @@ -828,8 +809,6 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment, environment_inherited_ (0), process_attributes_ (0), thread_attributes_ (0), - user_token_ (ACE_INVALID_HANDLE), - close_user_token_ (false), #else /* ACE_WIN32 */ stdin_ (ACE_INVALID_HANDLE), stdout_ (ACE_INVALID_HANDLE), @@ -857,13 +836,8 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment, process_group_ (ACE_INVALID_PID), use_unicode_environment_ (false) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR (command_line_buf_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * command_line_buf_len))); -#else ACE_NEW (command_line_buf_, ACE_TCHAR[command_line_buf_len]); -#endif /* ACE_HAS_ALLOC_HOOKS */ command_line_buf_[0] = '\0'; process_name_[0] = '\0'; @@ -875,20 +849,10 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment, #if !defined (ACE_HAS_WINCE) working_directory_[0] = '\0'; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR (environment_buf_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * env_buf_len))); -#else ACE_NEW (environment_buf_, ACE_TCHAR[env_buf_len]); -#endif /* ACE_HAS_ALLOC_HOOKS */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR (environment_argv_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR*) * max_env_args))); -#else ACE_NEW (environment_argv_, ACE_TCHAR *[max_env_args]); -#endif /* ACE_HAS_ALLOC_HOOKS */ environment_buf_[0] = '\0'; environment_argv_[0] = 0; #if defined (ACE_WIN32) @@ -898,13 +862,8 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment, this->startup_info_.cb = sizeof this->startup_info_; #endif /* ACE_WIN32 */ #endif /* !ACE_HAS_WINCE */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR (command_line_argv_, - static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR*) * max_cmdline_args))); -#else ACE_NEW (command_line_argv_, ACE_TCHAR *[max_cmdline_args]); -#endif /* ACE_HAS_ALLOC_HOOKS */ } #if !defined (ACE_HAS_WINCE) @@ -998,19 +957,31 @@ ACE_Process_Options::setenv (ACE_TCHAR *envp[]) return 0; } -#ifndef ACE_LACKS_VA_FUNCTIONS int ACE_Process_Options::setenv (const ACE_TCHAR *format, ...) { ACE_TCHAR stack_buf[DEFAULT_COMMAND_LINE_BUF_LEN]; + int status; // Start varargs. va_list argp; va_start (argp, format); // Add the rest of the varargs. - int status = ACE_OS::vsnprintf (stack_buf, DEFAULT_COMMAND_LINE_BUF_LEN, - format, argp); + // At the time of this writing, only one platform does not support + // vsnprintf (LynxOS). Should we get to the point where no platform + // sets ACE_LACKS_VSNPRINTF, this condition can be removed. +#if defined (ACE_LACKS_VSNPRINTF) + status = ACE_OS::vsprintf (stack_buf, + format, + argp); +#else + status = ACE_OS::vsnprintf (stack_buf, + DEFAULT_COMMAND_LINE_BUF_LEN, + format, + argp); +#endif /* ACE_LACKS_VSNPRINTF */ + // End varargs. va_end (argp); @@ -1048,8 +1019,10 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name, # endif // Add in the variable name. - ACE_OS::snprintf (safe_newformat.get (), buflen, fmt, - variable_name, format); + ACE_OS::sprintf (safe_newformat.get (), + fmt, + variable_name, + format); // Add the rest of the varargs. size_t tmp_buflen = buflen; @@ -1120,7 +1093,6 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name, return 0; } -#endif // ACE_LACKS_VA_FUNCTIONS int ACE_Process_Options::setenv_i (ACE_TCHAR *assignment, @@ -1171,47 +1143,32 @@ ACE_Process_Options::set_handles (ACE_HANDLE std_in, if (std_err == ACE_INVALID_HANDLE) std_err = ACE_STDERR; - // STD handles may have value 0 (not ACE_INVALID_HANDLE) if there is no such - // handle in the process. This was observed to occur for stdin in console - // processes that were launched from services. In this case we need to make - // sure not to return -1 from setting std_in so that we can process std_out - // and std_err. + if (!::DuplicateHandle (::GetCurrentProcess (), + std_in, + ::GetCurrentProcess (), + &this->startup_info_.hStdInput, + 0, + TRUE, + DUPLICATE_SAME_ACCESS)) + return -1; - if (std_in) - { - if (!::DuplicateHandle (::GetCurrentProcess (), - std_in, - ::GetCurrentProcess (), - &this->startup_info_.hStdInput, - 0, - TRUE, - DUPLICATE_SAME_ACCESS)) - return -1; - } + if (!::DuplicateHandle (::GetCurrentProcess (), + std_out, + ::GetCurrentProcess (), + &this->startup_info_.hStdOutput, + 0, + TRUE, + DUPLICATE_SAME_ACCESS)) + return -1; - if (std_out) - { - if (!::DuplicateHandle (::GetCurrentProcess (), - std_out, - ::GetCurrentProcess (), - &this->startup_info_.hStdOutput, - 0, - TRUE, - DUPLICATE_SAME_ACCESS)) - return -1; - } - - if (std_err) - { - if (!::DuplicateHandle (::GetCurrentProcess (), - std_err, - ::GetCurrentProcess (), - &this->startup_info_.hStdError, - 0, - TRUE, - DUPLICATE_SAME_ACCESS)) - return -1; - } + if (!::DuplicateHandle (::GetCurrentProcess (), + std_err, + ::GetCurrentProcess (), + &this->startup_info_.hStdError, + 0, + TRUE, + DUPLICATE_SAME_ACCESS)) + return -1; #else /* ACE_WIN32 */ this->stdin_ = ACE_OS::dup (std_in); this->stdout_ = ACE_OS::dup (std_out); @@ -1246,32 +1203,12 @@ ACE_Process_Options::~ACE_Process_Options (void) { #if !defined (ACE_HAS_WINCE) release_handles(); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(environment_buf_); - ACE_Allocator::instance()->free(environment_argv_); -#else delete [] environment_buf_; delete [] environment_argv_; -#endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !ACE_HAS_WINCE */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(command_line_buf_); -#else delete [] command_line_buf_; -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE::strdelete (command_line_copy_); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(command_line_argv_); -#else delete [] command_line_argv_; -#endif /* ACE_HAS_ALLOC_HOOKS */ - -#if defined (ACE_WIN32) - if (user_token_ != ACE_INVALID_HANDLE && close_user_token_) - { - ::CloseHandle(user_token_); - } -#endif /* ACE_WIN32 */ } int @@ -1311,7 +1248,6 @@ ACE_Process_Options::command_line (const ACE_TCHAR *const argv[]) return 0; // Success. } -#ifndef ACE_LACKS_VA_FUNCTIONS int ACE_Process_Options::command_line (const ACE_TCHAR *format, ...) { @@ -1325,10 +1261,19 @@ ACE_Process_Options::command_line (const ACE_TCHAR *format, ...) return -1; } +#if !defined (ACE_LACKS_VSNPRINTF) || defined (ACE_HAS_TRIO) + // vsnprintf the format and args into command_line_buf__. ACE_OS::vsnprintf (command_line_buf_, command_line_buf_len_, format, argp); +#else + // sprintf the format and args into command_line_buf__. + ACE_OS::vsprintf (command_line_buf_, + format, + argp); +#endif + // Useless macro. va_end (argp); @@ -1354,7 +1299,9 @@ ACE_Process_Options::command_line (const ACE_ANTI_TCHAR *format, ...) va_start (argp, format); // sprintf the format and args into command_line_buf_. - ACE_OS::vsnprintf (anti_clb, this->command_line_buf_len_, format, argp); + ACE_OS::vsprintf (anti_clb, + format, + argp); // Useless macro. va_end (argp); @@ -1368,7 +1315,6 @@ ACE_Process_Options::command_line (const ACE_ANTI_TCHAR *format, ...) return 0; } #endif /* ACE_HAS_WCHAR && !ACE_HAS_WINCE */ -#endif // ACE_LACKS_VA_FUNCTIONS ACE_TCHAR * ACE_Process_Options::env_buf (void) @@ -1421,12 +1367,42 @@ ACE_Process_Options::command_line_argv (void) int ACE_Process_Options::pass_handle (ACE_HANDLE h) { -#if defined (ACE_HAS_WINCE) +# if defined (ACE_WIN32) +# if defined (ACE_HAS_WINCE) ACE_NOTSUP_RETURN (-1); -#else +# else + + // This is oriented towards socket handles... may need some adjustment + // for non-sockets. + // This is all based on an MSDN article: + // http://support.microsoft.com/support/kb/articles/Q150/5/23.asp + // If on Win95/98, the handle needs to be duplicated for the to-be-spawned + // process. On WinNT, they get inherited by the child process automatically. + // If the handle is duplicated, remember the duplicate so it can be + // closed later. Can't be closed now, or the child won't get it. + ACE_TEXT_OSVERSIONINFO osvi; + ZeroMemory (&osvi, sizeof (osvi)); + osvi.dwOSVersionInfoSize = sizeof (ACE_TEXT_OSVERSIONINFO); + // If this is Win95/98 or we can't tell, duplicate the handle. + if (!ACE_TEXT_GetVersionEx (&osvi) || osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) + { + HANDLE dup_handle; + if (!DuplicateHandle (GetCurrentProcess (), + static_cast (h), + GetCurrentProcess (), + &dup_handle, + 0, + TRUE, // Inheritable + DUPLICATE_SAME_ACCESS)) + return -1; + dup_handles_.set_bit (static_cast (dup_handle)); + } +# endif /* ACE_HAS_WINCE */ +#endif /* ACE_WIN32 */ + this->handles_passed_.set_bit (h); + return 0; -#endif /* ACE_HAS_WINCE */ } // Get a copy of the handles the ACE_Process_Options duplicated @@ -1457,26 +1433,10 @@ ACE_Managed_Process::~ACE_Managed_Process (void) { } -ACE_ALLOC_HOOK_DEFINE(ACE_Managed_Process) - void ACE_Managed_Process::unmanage (void) { delete this; } -#if defined (ACE_WIN32) -void -ACE_Process_Options::set_user_token (HANDLE token, bool close_token) -{ - if (user_token_ != ACE_INVALID_HANDLE && close_user_token_) - { - ::CloseHandle(user_token_); - } - - user_token_ = token; - close_user_token_ = close_token; -} -#endif /* ACE_WIN32 */ - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Process.h b/dep/acelite/ace/Process.h index 327573513..c66ecc6f6 100644 --- a/dep/acelite/ace/Process.h +++ b/dep/acelite/ace/Process.h @@ -4,6 +4,8 @@ /** * @file Process.h * + * $Id: Process.h 97553 2014-01-30 17:01:44Z shuston $ + * * @author Tim Harrison */ //============================================================================= @@ -114,7 +116,6 @@ public: /// Release the standard handles previously set with set_handles; void release_handles (void); -#ifndef ACE_LACKS_VA_FUNCTIONS /// @param format must be of the form "VARIABLE=VALUE". There can not be /// any spaces between VARIABLE and the equal sign. int setenv (const ACE_TCHAR *format, @@ -131,7 +132,6 @@ public: int setenv (const ACE_TCHAR *variable_name, const ACE_TCHAR *format, ...); -#endif // ACE_LACKS_VA_FUNCTIONS /// Same as above with argv format. @a envp must be null terminated. int setenv (ACE_TCHAR *envp[]); @@ -145,7 +145,6 @@ public: void working_directory (const wchar_t *wd); #endif /* ACE_HAS_WCHAR */ -#ifndef ACE_LACKS_VA_FUNCTIONS /** * Set the command-line arguments. @a format can use any printf * formats. The first token in @a format should be the path to the @@ -161,7 +160,6 @@ public: /// Anti-TChar version of command_line () int command_line (const ACE_ANTI_TCHAR *format, ...); #endif /* ACE_HAS_WCHAR && !ACE_HAS_WINCE */ -#endif // ACE_LACKS_VA_FUNCTIONS /// Same as above in argv format. @a argv must be null terminated. int command_line (const ACE_TCHAR * const argv[]); @@ -313,14 +311,6 @@ public: /// CreateProcess. LPSECURITY_ATTRIBUTES set_thread_attributes (void); - /// Get user token. Return ACE_INVALID_HANDLE if it has not been set. - HANDLE get_user_token (void) const; - - /// Set user token for creating process as user. - /// @param token the user token is passed to \c ::CreateProcessAsUser. - /// @param close_token whether to close the user token when destructing. - void set_user_token (HANDLE token, bool close_token = false); - #else /* All things not WIN32 */ /// argv-style array of environment settings. @@ -392,11 +382,6 @@ protected: /// Data for thread_attributes_. SECURITY_ATTRIBUTES security_buf2_; - /// User token for \a CreateProcessAsUser - HANDLE user_token_; - - /// Keeps track of whether we need to close user token. - bool close_user_token_; #else /* !ACE_WIN32 */ ACE_HANDLE stdin_; ACE_HANDLE stdout_; @@ -679,8 +664,6 @@ public: /// Cleanup by deleting @c this. virtual void unmanage (void); - ACE_ALLOC_HOOK_DECLARE; - protected: /// Make sure that we're allocated dynamically! diff --git a/dep/acelite/ace/Process.inl b/dep/acelite/ace/Process.inl index 66241f436..bb0722d2c 100644 --- a/dep/acelite/ace/Process.inl +++ b/dep/acelite/ace/Process.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Process.inl 97660 2014-03-17 09:49:33Z johnnyw $ + #include "ace/ACE.h" #include "ace/OS_NS_sys_wait.h" #include "ace/OS_NS_signal.h" @@ -219,11 +222,6 @@ ACE_Process_Options::set_thread_attributes (void) #endif /* !ACE_HAS_WINCE */ } -ACE_INLINE HANDLE ACE_Process_Options::get_user_token (void) const -{ - return user_token_; -} - #else /* !defined (ACE_WIN32) */ ACE_INLINE ACE_HANDLE diff --git a/dep/acelite/ace/Process_Manager.cpp b/dep/acelite/ace/Process_Manager.cpp index f50b5584c..b08ac9367 100644 --- a/dep/acelite/ace/Process_Manager.cpp +++ b/dep/acelite/ace/Process_Manager.cpp @@ -1,3 +1,5 @@ +// $Id: Process_Manager.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Process_Manager.cpp #include "ace/Process_Manager.h" @@ -61,8 +63,6 @@ ACE_Process_Manager::Process_Descriptor::~Process_Descriptor (void) { } -ACE_ALLOC_HOOK_DEFINE(ACE_Process_Manager::Process_Descriptor) - void ACE_Process_Manager::Process_Descriptor::dump (void) const { diff --git a/dep/acelite/ace/Process_Manager.h b/dep/acelite/ace/Process_Manager.h index dbfd2b068..2a72c0204 100644 --- a/dep/acelite/ace/Process_Manager.h +++ b/dep/acelite/ace/Process_Manager.h @@ -4,7 +4,9 @@ /** * @file Process_Manager.h * - * @author Douglas C. Schmidt + * $Id: Process_Manager.h 97551 2014-01-29 20:54:06Z shuston $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -243,15 +245,6 @@ public: * @retval 0 on success; -1 on failure. */ int wait (const ACE_Time_Value &timeout = ACE_Time_Value::max_time); -#if defined (ACE_HAS_CPP11) - /// @sa wait - template< class Rep, class Period > - int wait (const std::chrono::duration& timeout) - { - ACE_Time_Value const tv (timeout); - return this->wait (tv); - } -#endif /** * Wait up to @a timeout for a single specified process to terminate. @@ -269,17 +262,6 @@ public: pid_t wait (pid_t pid, const ACE_Time_Value &timeout, ACE_exitcode *status = 0); -#if defined (ACE_HAS_CPP11) - /// @sa wait - template< class Rep, class Period > - pid_t wait (pid_t pid, - const std::chrono::duration& timeout, - ACE_exitcode *status = 0) - { - ACE_Time_Value const tv (timeout); - return this->wait (pid, tv, status); - } -#endif /** * Wait indefinitely for a single, specified process to terminate. @@ -419,8 +401,6 @@ private: /// Dump the state of an object. void dump (void) const; - - ACE_ALLOC_HOOK_DECLARE; }; /// Resize the pool of Process_Descriptors. diff --git a/dep/acelite/ace/Process_Manager.inl b/dep/acelite/ace/Process_Manager.inl index 33d2c034b..be8b53cab 100644 --- a/dep/acelite/ace/Process_Manager.inl +++ b/dep/acelite/ace/Process_Manager.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Process_Manager.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE size_t diff --git a/dep/acelite/ace/Process_Mutex.cpp b/dep/acelite/ace/Process_Mutex.cpp index 3a1372679..ac5b2a157 100644 --- a/dep/acelite/ace/Process_Mutex.cpp +++ b/dep/acelite/ace/Process_Mutex.cpp @@ -1,3 +1,5 @@ +// $Id: Process_Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Process_Mutex.h" #include "ace/Log_Category.h" #include "ace/ACE.h" @@ -36,17 +38,6 @@ ACE_Process_Mutex::unique_name (void) return this->name_; } -int -ACE_Process_Mutex::unlink (const ACE_TCHAR *name) -{ -#if defined (_ACE_USE_SV_SEM) - ACE_UNUSED_ARG (name); - return 0; -#else - return ACE_Mutex::unlink (name); -#endif -} - ACE_Process_Mutex::ACE_Process_Mutex (const char *name, void *arg, mode_t mode) #if defined (_ACE_USE_SV_SEM) : lock_ (name ? name : ACE_TEXT_ALWAYS_CHAR (this->unique_name ()), diff --git a/dep/acelite/ace/Process_Mutex.h b/dep/acelite/ace/Process_Mutex.h index 3b713c526..476676e6c 100644 --- a/dep/acelite/ace/Process_Mutex.h +++ b/dep/acelite/ace/Process_Mutex.h @@ -4,10 +4,12 @@ /** * @file Process_Mutex.h * + * $Id: Process_Mutex.h 87179 2009-10-20 16:27:01Z shuston $ + * * A wrapper for mutexes that can be used across processes on the * same host machine, as well as within a process, of course. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= @@ -198,13 +200,6 @@ public: const ACE_mutex_t &lock (void) const; #endif /* !_ACE_USE_SV_SEM */ - /// Get the name used for the lock, or null if no name is used. - const ACE_TCHAR *name () const; - - /// If a file was created as the underlying storage for the mutex, - /// remove it from the filesystem. - static int unlink (const ACE_TCHAR *name); - /// Dump the state of an object. void dump (void) const; diff --git a/dep/acelite/ace/Process_Mutex.inl b/dep/acelite/ace/Process_Mutex.inl index 040bfc5cd..00c84e6a5 100644 --- a/dep/acelite/ace/Process_Mutex.inl +++ b/dep/acelite/ace/Process_Mutex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Process_Mutex.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if !defined (_ACE_USE_SV_SEM) @@ -112,14 +115,4 @@ ACE_Process_Mutex::tryacquire_write_upgrade (void) return 0; } -ACE_INLINE const ACE_TCHAR * -ACE_Process_Mutex::name () const -{ -#if defined _ACE_USE_SV_SEM || !defined ACE_MUTEX_USE_PROCESS_LOCK - return 0; -#else - return this->lock_.lockname_; -#endif -} - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Process_Semaphore.cpp b/dep/acelite/ace/Process_Semaphore.cpp index bb3f94e4e..9bed1fc17 100644 --- a/dep/acelite/ace/Process_Semaphore.cpp +++ b/dep/acelite/ace/Process_Semaphore.cpp @@ -1,9 +1,8 @@ +// $Id: Process_Semaphore.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Process_Semaphore.h" #include "ace/Log_Category.h" #include "ace/OS_Memory.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/Process_Semaphore.inl" @@ -15,8 +14,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Process_Semaphore) - void ACE_Process_Semaphore::dump (void) const { diff --git a/dep/acelite/ace/Process_Semaphore.h b/dep/acelite/ace/Process_Semaphore.h index 3f3fb1c5f..fddaf8aec 100644 --- a/dep/acelite/ace/Process_Semaphore.h +++ b/dep/acelite/ace/Process_Semaphore.h @@ -4,10 +4,12 @@ /** * @file Process_Semaphore.h * + * $Id: Process_Semaphore.h 93359 2011-02-11 11:33:12Z mcorino $ + * * Wrapper for Dijkstra style general semaphores that work * across processes. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Process_Semaphore.inl b/dep/acelite/ace/Process_Semaphore.inl index d19eb2286..0874b2d51 100644 --- a/dep/acelite/ace/Process_Semaphore.inl +++ b/dep/acelite/ace/Process_Semaphore.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Process_Semaphore.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) diff --git a/dep/acelite/ace/Profile_Timer.cpp b/dep/acelite/ace/Profile_Timer.cpp index 0e80384ea..8bf7a1a1d 100644 --- a/dep/acelite/ace/Profile_Timer.cpp +++ b/dep/acelite/ace/Profile_Timer.cpp @@ -1,3 +1,5 @@ +// $Id: Profile_Timer.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Profile_Timer.h" #if !defined (__ACE_INLINE__) @@ -17,9 +19,6 @@ #if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32) #include "ace/OS_NS_stdio.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -46,7 +45,7 @@ ACE_Profile_Timer::ACE_Profile_Timer (void) # if defined (ACE_HAS_PRUSAGE_T) ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_); char buf[20]; - ACE_OS::sprintf (buf, 20, "/proc/%d", static_cast (ACE_OS::getpid ())); + ACE_OS::sprintf (buf, "/proc/%d", static_cast (ACE_OS::getpid ())); this->proc_handle_ = ACE_OS::open (buf, O_RDONLY, 0); if (this->proc_handle_ == -1) diff --git a/dep/acelite/ace/Profile_Timer.h b/dep/acelite/ace/Profile_Timer.h index ee0a592dc..e21c39796 100644 --- a/dep/acelite/ace/Profile_Timer.h +++ b/dep/acelite/ace/Profile_Timer.h @@ -4,7 +4,9 @@ /** * @file Profile_Timer.h * - * @author Douglas C. Schmidt + * $Id: Profile_Timer.h 93359 2011-02-11 11:33:12Z mcorino $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Profile_Timer.inl b/dep/acelite/ace/Profile_Timer.inl index 3b52d4195..9990585ce 100644 --- a/dep/acelite/ace/Profile_Timer.inl +++ b/dep/acelite/ace/Profile_Timer.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Profile_Timer.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_sys_time.h" #include "ace/OS_NS_sys_resource.h" #include "ace/Global_Macros.h" diff --git a/dep/acelite/ace/RB_Tree.cpp b/dep/acelite/ace/RB_Tree.cpp index 0c8c2a713..a762e9095 100644 --- a/dep/acelite/ace/RB_Tree.cpp +++ b/dep/acelite/ace/RB_Tree.cpp @@ -1,3 +1,5 @@ +// $Id: RB_Tree.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_RB_TREE_CPP #define ACE_RB_TREE_CPP @@ -17,11 +19,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree) -ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree_Iterator_Base) -ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree_Iterator) -ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree_Reverse_Iterator) - // Constructor. template @@ -1099,6 +1096,8 @@ ACE_RB_Tree::remove_i (ACE_RB_Tree_Node< return 0; } +ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator_Base) + // Constructor. template @@ -1177,6 +1176,8 @@ ACE_RB_Tree_Iterator_Base::dump_i (void) } +ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator) + // Constructor. template @@ -1210,6 +1211,7 @@ ACE_RB_Tree_Iterator::~ACE_RB_Tree_Itera ACE_TRACE ("ACE_RB_Tree_Iterator::~ACE_RB_Tree_Iterator"); } +ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Reverse_Iterator) // Constructor. diff --git a/dep/acelite/ace/RB_Tree.h b/dep/acelite/ace/RB_Tree.h index b28afa6ee..86948e36c 100644 --- a/dep/acelite/ace/RB_Tree.h +++ b/dep/acelite/ace/RB_Tree.h @@ -4,6 +4,8 @@ /** * @file RB_Tree.h * + * $Id: RB_Tree.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Chris Gill */ //============================================================================= @@ -124,7 +126,7 @@ public: * inlining is disabled and on platforms where * @c ACE_TEMPLATES_REQUIRE_SOURCE is defined. In those * platform/configuration combinations, multiple definitions - * of this method occurred. Placing the definition inline in + * of this method occured. Placing the definition inline in * the header avoids such errors. */ ACE_Allocator * allocator (void) const { return this->allocator_; } @@ -438,9 +440,6 @@ public: /// Destroys all nodes and sets the root pointer null. void clear (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Reinitialize constructor. /** diff --git a/dep/acelite/ace/RB_Tree.inl b/dep/acelite/ace/RB_Tree.inl index dcebea5e7..1b4b366f5 100644 --- a/dep/acelite/ace/RB_Tree.inl +++ b/dep/acelite/ace/RB_Tree.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: RB_Tree.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Guard_T.h" #include "ace/Malloc_Base.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/README b/dep/acelite/ace/README index 68ed0bfaf..3fb701566 100644 --- a/dep/acelite/ace/README +++ b/dep/acelite/ace/README @@ -1,3 +1,5 @@ +// $Id: README 97921 2014-10-10 21:58:31Z shuston $ + ACE Portability Macros ---------------------- @@ -953,7 +955,6 @@ ACE_LACKS_QSORT Compiler/platform lacks the ACE_LACKS_READLINK Platform lacks the readlink() function. ACE_LACKS_READV Platform doesn't define readv, so use our own -ACE_LACKS_RENAME Platform lacks rename(). ACE_LACKS_RLIMIT Platform/compiler lacks {get,set}rlimit() function (e.g., VxWorks, Chorus, and diff --git a/dep/acelite/ace/RW_Mutex.cpp b/dep/acelite/ace/RW_Mutex.cpp index 3711ca5ce..37124eda3 100644 --- a/dep/acelite/ace/RW_Mutex.cpp +++ b/dep/acelite/ace/RW_Mutex.cpp @@ -1,9 +1,11 @@ /** * @file RW_Mutex.cpp * + * $Id: RW_Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/RW_Mutex.h" diff --git a/dep/acelite/ace/RW_Mutex.h b/dep/acelite/ace/RW_Mutex.h index 46f7458ed..99ba4c0d3 100644 --- a/dep/acelite/ace/RW_Mutex.h +++ b/dep/acelite/ace/RW_Mutex.h @@ -4,9 +4,11 @@ /** * @file RW_Mutex.h * + * $Id: RW_Mutex.h 93359 2011-02-11 11:33:12Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/RW_Mutex.inl b/dep/acelite/ace/RW_Mutex.inl index 3939b8c23..3ff9826c5 100644 --- a/dep/acelite/ace/RW_Mutex.inl +++ b/dep/acelite/ace/RW_Mutex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: RW_Mutex.inl 83934 2008-12-01 13:47:06Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const ACE_rwlock_t & diff --git a/dep/acelite/ace/RW_Process_Mutex.cpp b/dep/acelite/ace/RW_Process_Mutex.cpp index eda9c8a81..6c5ffc30a 100644 --- a/dep/acelite/ace/RW_Process_Mutex.cpp +++ b/dep/acelite/ace/RW_Process_Mutex.cpp @@ -1,3 +1,5 @@ +// $Id: RW_Process_Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/RW_Process_Mutex.h" #include "ace/Log_Category.h" #include "ace/ACE.h" diff --git a/dep/acelite/ace/RW_Process_Mutex.h b/dep/acelite/ace/RW_Process_Mutex.h index f07a56735..3953c2b4d 100644 --- a/dep/acelite/ace/RW_Process_Mutex.h +++ b/dep/acelite/ace/RW_Process_Mutex.h @@ -4,7 +4,9 @@ /** * @file RW_Process_Mutex.h * - * @author Douglas C. Schmidt + * $Id: RW_Process_Mutex.h 87487 2009-11-12 07:54:39Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/RW_Process_Mutex.inl b/dep/acelite/ace/RW_Process_Mutex.inl index 61326713a..42e92270a 100644 --- a/dep/acelite/ace/RW_Process_Mutex.inl +++ b/dep/acelite/ace/RW_Process_Mutex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: RW_Process_Mutex.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Explicitly destroy the mutex. diff --git a/dep/acelite/ace/RW_Thread_Mutex.cpp b/dep/acelite/ace/RW_Thread_Mutex.cpp index cffcc8d4e..7fce758d9 100644 --- a/dep/acelite/ace/RW_Thread_Mutex.cpp +++ b/dep/acelite/ace/RW_Thread_Mutex.cpp @@ -1,19 +1,17 @@ /** * @file RW_Thread_Mutex.cpp * + * $Id: RW_Thread_Mutex.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/RW_Thread_Mutex.h" #if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/RW_Thread_Mutex.inl" #endif /* __ACE_INLINE__ */ diff --git a/dep/acelite/ace/RW_Thread_Mutex.h b/dep/acelite/ace/RW_Thread_Mutex.h index d54997e7b..490282966 100644 --- a/dep/acelite/ace/RW_Thread_Mutex.h +++ b/dep/acelite/ace/RW_Thread_Mutex.h @@ -4,9 +4,11 @@ /** * @file RW_Thread_Mutex.h * + * $Id: RW_Thread_Mutex.h 80826 2008-03-04 14:51:23Z wotte $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/RW_Thread_Mutex.inl b/dep/acelite/ace/RW_Thread_Mutex.inl index a69c8b597..9e41cd9d9 100644 --- a/dep/acelite/ace/RW_Thread_Mutex.inl +++ b/dep/acelite/ace/RW_Thread_Mutex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: RW_Thread_Mutex.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/Reactor.cpp b/dep/acelite/ace/Reactor.cpp index b23e3effe..20a76e2d2 100644 --- a/dep/acelite/ace/Reactor.cpp +++ b/dep/acelite/ace/Reactor.cpp @@ -1,3 +1,5 @@ +// $Id: Reactor.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ + #include "ace/Reactor.h" #if !defined (ACE_LACKS_ACE_SVCCONF) diff --git a/dep/acelite/ace/Reactor.h b/dep/acelite/ace/Reactor.h index d44a51909..653c989aa 100644 --- a/dep/acelite/ace/Reactor.h +++ b/dep/acelite/ace/Reactor.h @@ -4,8 +4,10 @@ /** * @file Reactor.h * + * $Id: Reactor.h 97894 2014-09-16 18:11:56Z johnnyw $ + * * @author Irfan Pyarali - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //============================================================================= @@ -341,6 +343,7 @@ public: ACE_Reactor_Mask mask); #if defined (ACE_WIN32) + /** * Register handler for OS events. * @@ -359,6 +362,7 @@ public: */ int register_handler (ACE_Event_Handler *event_handler, ACE_HANDLE event_handle = ACE_INVALID_HANDLE); + #endif /* ACE_WIN32 */ /** @@ -576,19 +580,7 @@ public: const ACE_Time_Value &delay, const ACE_Time_Value &interval = ACE_Time_Value::zero); -#if defined (ACE_HAS_CPP11) - template> - long schedule_timer (ACE_Event_Handler *event_handler, - const void *arg, - const std::chrono::duration& delay, - const std::chrono::duration& interval = - std::chrono::duration::zero ()) - { - ACE_Time_Value const tv_delay (delay); - ACE_Time_Value const tv_interval (interval); - return this->schedule_timer (event_handler, arg, tv_delay, tv_interval); - } -#endif + /** * Reset recurring timer interval. * @@ -602,15 +594,6 @@ public: */ virtual int reset_timer_interval (long timer_id, const ACE_Time_Value &interval); -#if defined (ACE_HAS_CPP11) - template - int reset_timer_interval (long timer_id, - const std::chrono::duration& interval) - { - ACE_Time_Value const tv_interval (interval); - return this->reset_timer_interval (timer_id, tv_interval); - } -#endif /** * Cancel timer. diff --git a/dep/acelite/ace/Reactor.inl b/dep/acelite/ace/Reactor.inl index 5d2bc60cf..36a89dbf6 100644 --- a/dep/acelite/ace/Reactor.inl +++ b/dep/acelite/ace/Reactor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Reactor.inl 82723 2008-09-16 09:35:44Z johnnyw $ + #include "ace/Reactor_Impl.h" /* diff --git a/dep/acelite/ace/Reactor_Impl.cpp b/dep/acelite/ace/Reactor_Impl.cpp index dd496854a..7503e257f 100644 --- a/dep/acelite/ace/Reactor_Impl.cpp +++ b/dep/acelite/ace/Reactor_Impl.cpp @@ -1,9 +1,9 @@ +// $Id: Reactor_Impl.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Reactor_Impl.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE (ACE_Reactor_Impl) - ACE_Reactor_Impl::~ACE_Reactor_Impl (void) { } diff --git a/dep/acelite/ace/Reactor_Impl.h b/dep/acelite/ace/Reactor_Impl.h index a0ea308a4..863c0b4ee 100644 --- a/dep/acelite/ace/Reactor_Impl.h +++ b/dep/acelite/ace/Reactor_Impl.h @@ -4,6 +4,8 @@ /** * @file Reactor_Impl.h * + * $Id: Reactor_Impl.h 84316 2009-02-03 19:46:05Z johnnyw $ + * * @author Irfan Pyarali */ //============================================================================= @@ -52,12 +54,12 @@ public: virtual int close (void) = 0; /** - * Called by a thread when it wants to unblock the Reactor_Impl. - * This wakeups the Reactor_Impl if currently blocked. Pass over - * both the Event_Handler *and* the @a mask to allow the caller to - * dictate which Event_Handler method the Reactor_Impl will + * Called by a thread when it wants to unblock the . + * This wakeups the if currently blocked. Pass over + * both the *and* the @a mask to allow the caller to + * dictate which method the will * invoke. The ACE_Time_Value indicates how long to blocking - * trying to notify the Reactor_Impl. If @a timeout == 0, the + * trying to notify the . If @a timeout == 0, the * caller will block until action is possible, else will wait until * the relative time specified in *@a timeout elapses). */ @@ -66,29 +68,29 @@ public: ACE_Time_Value *timeout = 0) = 0; /// Handles pending threads (if any) that are waiting to unblock the - /// Reactor_Impl. + /// . virtual int dispatch_notifications (int &number_of_active_handles, ACE_Handle_Set &rd_mask) = 0; /// Returns the ACE_HANDLE of the notify pipe on which the reactor /// is listening for notifications so that other threads can unblock - /// the Reactor_Impl + /// the virtual ACE_HANDLE notify_handle (void) = 0; /// Verify whether the buffer has dispatchable info or not. virtual int is_dispatchable (ACE_Notification_Buffer &buffer)= 0; - /// Handle one of the notify call on the handle. This could be - /// because of a thread trying to unblock the Reactor_Impl + /// Handle one of the notify call on the . This could be + /// because of a thread trying to unblock the virtual int dispatch_notify (ACE_Notification_Buffer &buffer) = 0; /// Read one of the notify call on the @a handle into the /// @a buffer. This could be because of a thread trying to unblock - /// the Reactor_Impl + /// the virtual int read_notify_pipe (ACE_HANDLE handle, ACE_Notification_Buffer &buffer) = 0; /** - * Set the maximum number of times that the @c handle_input method + * Set the maximum number of times that the method * will iterate and dispatch the ACE_Event_Handlers that are * passed in via the notify queue before breaking out of the event * loop. By default, this is set to -1, which means "iterate until @@ -99,7 +101,7 @@ public: virtual void max_notify_iterations (int) = 0; /** - * Get the maximum number of times that the @c handle_input method + * Get the maximum number of times that the method * will iterate and dispatch the ACE_Event_Handlers that are * passed in via the notify queue before breaking out of its event * loop. @@ -181,8 +183,8 @@ public: * dispatched, 0 if the @a max_wait_time elapsed without dispatching * any handlers, or -1 if an error occurs. * - * The only difference between alertable_handle_events() and - * handle_events() is that in the alertable case, the eventloop will + * The only difference between and + * is that in the alertable case, the eventloop will * return when the system queues an I/O completion routine or an * Asynchronous Procedure Call. */ @@ -194,8 +196,8 @@ public: * @a max_wait_time value is a reference and can therefore never be * NULL. * - * The only difference between alertable_handle_events() and - * handle_events() is that in the alertable case, the eventloop will + * The only difference between and + * is that in the alertable case, the eventloop will * return when the system queues an I/O completion routine or an * Asynchronous Procedure Call. */ @@ -206,8 +208,8 @@ public: /** * Return the status of Reactor. If this function returns 0, the reactor is - * actively handling events. If it returns non-zero, handling_events() and - * handle_alertable_events() return -1 immediately. + * actively handling events. If it returns non-zero, and + * return -1 immediately. */ virtual int deactivated (void) = 0; @@ -221,12 +223,12 @@ public: // = Register and remove Handlers. /// Register @a event_handler with @a mask. The I/O handle will always - /// come from get_handle() on the @a event_handler. + /// come from on the @a event_handler. virtual int register_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) = 0; /// Register @a event_handler with @a mask. The I/O handle is provided - /// through the @a io_handle parameter. + /// through the parameter. virtual int register_handler (ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) = 0; @@ -242,8 +244,8 @@ public: /** * Register an @a event_handler that will be notified when - * event_handle is signaled. Since no event mask is passed - * through this interface, it is assumed that the @a event_handler + * is signaled. Since no event mask is passed + * through this interface, it is assumed that the * being passed in is an event handle and not an I/O handle. */ virtual int register_handler (ACE_Event_Handler *event_handler, @@ -253,7 +255,7 @@ public: /** * Register an @a event_handler that will be notified when - * event_handle is signaled. @a mask specifies the network events + * is signaled. @a mask specifies the network events * that the @a event_handler is interested in. */ virtual int register_handler (ACE_HANDLE event_handle, @@ -261,7 +263,7 @@ public: ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) = 0; - /// Register @a event_handler with all the @a handles in the Handle_Set. + /// Register @a event_handler with all the @a handles in the . virtual int register_handler (const ACE_Handle_Set &handles, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) = 0; @@ -285,8 +287,8 @@ public: /** * Removes @a event_handler. Note that the I/O handle will be - * obtained using get_handle() method of @a event_handler . If - * @a mask == ACE_Event_Handler::DONT_CALL then the handle_close() + * obtained using method of @a event_handler . If + * @a mask == ACE_Event_Handler::DONT_CALL then the * method of the @a event_handler is not invoked. */ virtual int remove_handler (ACE_Event_Handler *event_handler, @@ -294,7 +296,7 @@ public: /** * Removes @a handle. If @a mask == ACE_Event_Handler::DONT_CALL - * then the handle_close() method of the associated event_handler + * then the method of the associated * is not invoked. */ virtual int remove_handler (ACE_HANDLE handle, @@ -302,8 +304,8 @@ public: /** * Removes all handles in @a handle_set. If @a mask == - * ACE_Event_Handler::DONT_CALL then the handle_close() method of - * the associated event_handlers is not invoked. + * ACE_Event_Handler::DONT_CALL then the method of + * the associated s is not invoked. */ virtual int remove_handler (const ACE_Handle_Set &handle_set, ACE_Reactor_Mask mask) = 0; @@ -319,13 +321,13 @@ public: ACE_Sig_Action *old_disp = 0, int sigkey = -1) = 0; - /// Calls remove_handler() for every signal in @a sigset. + /// Calls for every signal in @a sigset. virtual int remove_handler (const ACE_Sig_Set &sigset) = 0; // = Suspend and resume Handlers. - /// Suspend @a event_handler temporarily. Uses - /// ACE_Event_Handler::get_handle() to get the handle. + /// Suspend @a event_handler temporarily. Use + /// to get the handle. virtual int suspend_handler (ACE_Event_Handler *event_handler) = 0; /// Suspend @a handle temporarily. @@ -337,7 +339,7 @@ public: /// Suspend all temporarily. virtual int suspend_handlers (void) = 0; - /// Resume @a event_handler. Uses ACE_Event_Handler::get_handle() to + /// Resume @a event_handler. Use to /// get the handle. virtual int resume_handler (ACE_Event_Handler *event_handler) = 0; @@ -347,7 +349,7 @@ public: /// Resume all @a handles in handle set. virtual int resume_handler (const ACE_Handle_Set &handles) = 0; - /// Resume all handles. + /// Resume all . virtual int resume_handlers (void) = 0; /// Does the reactor allow the application to resume the handle on @@ -388,7 +390,7 @@ public: /** * Resets the interval of the timer represented by @a timer_id to * @a interval, which is specified in relative time to the current - * gettimeofday(). If @a interval is equal to + * . If @a interval is equal to * ACE_Time_Value::zero, the timer will become a non-rescheduling * timer. Returns 0 if successful, -1 if not. */ @@ -449,7 +451,7 @@ public: * Set the maximum number of times that ACE_Reactor_Impl will * iterate and dispatch the ACE_Event_Handlers that are passed in * via the notify queue before breaking out of its - * ACE_Message_Queue::dequeue() loop. By default, this is set to + * loop. By default, this is set to * -1, which means "iterate until the queue is empty." Setting this * to a value like "1 or 2" will increase "fairness" (and thus * prevent starvation) at the expense of slightly higher dispatching @@ -461,7 +463,7 @@ public: * Get the maximum number of times that the ACE_Reactor_Impl will * iterate and dispatch the ACE_Event_Handlers that are passed in * via the notify queue before breaking out of its - * ACE_Message_Queue::dequeue() loop. + * loop. */ virtual int max_notify_iterations (void) = 0; diff --git a/dep/acelite/ace/Reactor_Notification_Strategy.cpp b/dep/acelite/ace/Reactor_Notification_Strategy.cpp index 534236beb..fdad27b65 100644 --- a/dep/acelite/ace/Reactor_Notification_Strategy.cpp +++ b/dep/acelite/ace/Reactor_Notification_Strategy.cpp @@ -1,3 +1,5 @@ +// $Id: Reactor_Notification_Strategy.cpp 91287 2010-08-05 10:30:49Z johnnyw $ + #include "ace/Reactor_Notification_Strategy.h" #include "ace/Reactor.h" diff --git a/dep/acelite/ace/Reactor_Notification_Strategy.h b/dep/acelite/ace/Reactor_Notification_Strategy.h index 93f58051d..1cfb83c77 100644 --- a/dep/acelite/ace/Reactor_Notification_Strategy.h +++ b/dep/acelite/ace/Reactor_Notification_Strategy.h @@ -4,6 +4,8 @@ /** * @file Reactor_Notification_Strategy.h * + * $Id: Reactor_Notification_Strategy.h 92345 2010-10-24 12:39:33Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Reactor_Notification_Strategy.inl b/dep/acelite/ace/Reactor_Notification_Strategy.inl index 92a472cee..69a260d0f 100644 --- a/dep/acelite/ace/Reactor_Notification_Strategy.inl +++ b/dep/acelite/ace/Reactor_Notification_Strategy.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Reactor_Notification_Strategy.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Reactor * diff --git a/dep/acelite/ace/Reactor_Timer_Interface.cpp b/dep/acelite/ace/Reactor_Timer_Interface.cpp index 7eb096977..8bd7be7e3 100644 --- a/dep/acelite/ace/Reactor_Timer_Interface.cpp +++ b/dep/acelite/ace/Reactor_Timer_Interface.cpp @@ -1,3 +1,5 @@ +// $Id: Reactor_Timer_Interface.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Reactor_Timer_Interface.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Reactor_Timer_Interface.h b/dep/acelite/ace/Reactor_Timer_Interface.h index 3000d93b1..02e4e6281 100644 --- a/dep/acelite/ace/Reactor_Timer_Interface.h +++ b/dep/acelite/ace/Reactor_Timer_Interface.h @@ -4,6 +4,8 @@ /** * @file Reactor_Timer_Interface.h * + * $Id: Reactor_Timer_Interface.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Irfan Pyarali */ //============================================================================= @@ -31,6 +33,7 @@ class ACE_Event_Handler; class ACE_Export ACE_Reactor_Timer_Interface { public: + virtual ~ACE_Reactor_Timer_Interface (void); virtual long schedule_timer (ACE_Event_Handler *event_handler, @@ -38,30 +41,8 @@ public: const ACE_Time_Value &delay, const ACE_Time_Value &interval = ACE_Time_Value::zero) = 0; -#if defined (ACE_HAS_CPP11) - template> - long schedule_timer (ACE_Event_Handler *event_handler, - const void *arg, - const std::chrono::duration& delay, - const std::chrono::duration& interval = std::chrono::duration::zero ()) - { - ACE_Time_Value const tv_delay (delay); - ACE_Time_Value const tv_interval (interval); - return this->schedule_timer (event_handler, arg, tv_delay, tv_interval); - } -#endif - virtual int reset_timer_interval (long timer_id, const ACE_Time_Value &interval) = 0; -#if defined (ACE_HAS_CPP11) - template - int reset_timer_interval (long timer_id, - const std::chrono::duration& interval) - { - ACE_Time_Value const tv_interval (interval); - return this->reset_timer_interval (timer_id, tv_interval); - } -#endif virtual int cancel_timer (long timer_id, const void **arg = 0, diff --git a/dep/acelite/ace/Reactor_Token_T.cpp b/dep/acelite/ace/Reactor_Token_T.cpp index f4399c903..d083fc67f 100644 --- a/dep/acelite/ace/Reactor_Token_T.cpp +++ b/dep/acelite/ace/Reactor_Token_T.cpp @@ -1,10 +1,10 @@ +// $Id: Reactor_Token_T.cpp 97645 2014-03-07 12:01:21Z johnnyw $ + #include "ace/Log_Category.h" #include "ace/Reactor_Token_T.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Reactor_Token_T) - template void ACE_Reactor_Token_T::dump (void) const { diff --git a/dep/acelite/ace/Reactor_Token_T.h b/dep/acelite/ace/Reactor_Token_T.h index 521fdc845..7442040b9 100644 --- a/dep/acelite/ace/Reactor_Token_T.h +++ b/dep/acelite/ace/Reactor_Token_T.h @@ -4,6 +4,8 @@ /** * @file Reactor_Token_T.h * + * $Id: Reactor_Token_T.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Steve Huston */ //============================================================================= diff --git a/dep/acelite/ace/Read_Buffer.cpp b/dep/acelite/ace/Read_Buffer.cpp index 14ac5ded6..46dbefc63 100644 --- a/dep/acelite/ace/Read_Buffer.cpp +++ b/dep/acelite/ace/Read_Buffer.cpp @@ -1,3 +1,5 @@ +// $Id: Read_Buffer.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Read_Buffer.h" #include "ace/config-all.h" diff --git a/dep/acelite/ace/Read_Buffer.h b/dep/acelite/ace/Read_Buffer.h index 1d7dfde2a..967ec4dde 100644 --- a/dep/acelite/ace/Read_Buffer.h +++ b/dep/acelite/ace/Read_Buffer.h @@ -4,7 +4,9 @@ /** * @file Read_Buffer.h * - * @author Douglas C. Schmidt + * $Id: Read_Buffer.h 92345 2010-10-24 12:39:33Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Seth Widoff */ //========================================================================== diff --git a/dep/acelite/ace/Read_Buffer.inl b/dep/acelite/ace/Read_Buffer.inl index cadd00774..4d104bd2a 100644 --- a/dep/acelite/ace/Read_Buffer.inl +++ b/dep/acelite/ace/Read_Buffer.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Read_Buffer.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Accessor to the number of bytes in the buffer. diff --git a/dep/acelite/ace/Recursive_Thread_Mutex.cpp b/dep/acelite/ace/Recursive_Thread_Mutex.cpp index 7d379ab20..3fe0f9c5c 100644 --- a/dep/acelite/ace/Recursive_Thread_Mutex.cpp +++ b/dep/acelite/ace/Recursive_Thread_Mutex.cpp @@ -1,9 +1,11 @@ /** * @file Recursive_Thread_Mutex.cpp * + * $Id: Recursive_Thread_Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/Recursive_Thread_Mutex.h" @@ -15,9 +17,6 @@ #endif /* __ACE_INLINE__ */ #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Recursive_Thread_Mutex.h b/dep/acelite/ace/Recursive_Thread_Mutex.h index 8c4c867ff..240d9ce60 100644 --- a/dep/acelite/ace/Recursive_Thread_Mutex.h +++ b/dep/acelite/ace/Recursive_Thread_Mutex.h @@ -4,9 +4,11 @@ /** * @file Recursive_Thread_Mutex.h * + * $Id: Recursive_Thread_Mutex.h 93359 2011-02-11 11:33:12Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt and + * @author Douglas C. Schmidt and * Abdullah Sowayan */ //========================================================================== diff --git a/dep/acelite/ace/Recursive_Thread_Mutex.inl b/dep/acelite/ace/Recursive_Thread_Mutex.inl index 739e77569..57e8a8a66 100644 --- a/dep/acelite/ace/Recursive_Thread_Mutex.inl +++ b/dep/acelite/ace/Recursive_Thread_Mutex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Recursive_Thread_Mutex.inl 89121 2010-02-22 14:48:31Z schmidt $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_recursive_thread_mutex_t & diff --git a/dep/acelite/ace/Recyclable.cpp b/dep/acelite/ace/Recyclable.cpp index d42aea8a4..9af11bb85 100644 --- a/dep/acelite/ace/Recyclable.cpp +++ b/dep/acelite/ace/Recyclable.cpp @@ -1,3 +1,4 @@ +//$Id: Recyclable.cpp 91286 2010-08-05 09:04:31Z johnnyw $ #include "ace/Recyclable.h" diff --git a/dep/acelite/ace/Recyclable.h b/dep/acelite/ace/Recyclable.h index 47d06052f..36c75586d 100644 --- a/dep/acelite/ace/Recyclable.h +++ b/dep/acelite/ace/Recyclable.h @@ -4,6 +4,8 @@ /** * @file Recyclable.h * + * $Id: Recyclable.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Recyclable.inl b/dep/acelite/ace/Recyclable.inl index 7a7e3fda2..c07d89a85 100644 --- a/dep/acelite/ace/Recyclable.inl +++ b/dep/acelite/ace/Recyclable.inl @@ -1,5 +1,7 @@ // -*- C++ -*- // +//$Id: Recyclable.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Recyclable_State diff --git a/dep/acelite/ace/Refcountable_T.cpp b/dep/acelite/ace/Refcountable_T.cpp index 5ffada80a..755c61150 100644 --- a/dep/acelite/ace/Refcountable_T.cpp +++ b/dep/acelite/ace/Refcountable_T.cpp @@ -1,3 +1,5 @@ +// $Id: Refcountable_T.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ + #ifndef ACE_REFCOUNTABLE_T_CPP #define ACE_REFCOUNTABLE_T_CPP diff --git a/dep/acelite/ace/Refcountable_T.h b/dep/acelite/ace/Refcountable_T.h index b4916bf98..a8b0ec5f2 100644 --- a/dep/acelite/ace/Refcountable_T.h +++ b/dep/acelite/ace/Refcountable_T.h @@ -4,6 +4,8 @@ /** * @file Refcountable_T.h * + * $Id: Refcountable_T.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Doug Schmidt * @author Johnny Willemsen */ diff --git a/dep/acelite/ace/Refcountable_T.inl b/dep/acelite/ace/Refcountable_T.inl index 7a901476d..b66e3f9e2 100644 --- a/dep/acelite/ace/Refcountable_T.inl +++ b/dep/acelite/ace/Refcountable_T.inl @@ -1,5 +1,7 @@ // -*- C++ -*- // +//$Id: Refcountable_T.inl 81407 2008-04-24 05:59:30Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Refcounted_Auto_Ptr.cpp b/dep/acelite/ace/Refcounted_Auto_Ptr.cpp index d97c128b9..c43bcc7b9 100644 --- a/dep/acelite/ace/Refcounted_Auto_Ptr.cpp +++ b/dep/acelite/ace/Refcounted_Auto_Ptr.cpp @@ -1,3 +1,5 @@ +// $Id: Refcounted_Auto_Ptr.cpp 81179 2008-03-31 19:00:29Z iliyan $ + #ifndef ACE_REFCOUNTED_AUTO_PTR_CPP #define ACE_REFCOUNTED_AUTO_PTR_CPP @@ -5,9 +7,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Refcounted_Auto_Ptr) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Refcounted_Auto_Ptr_Rep) - template ACE_Refcounted_Auto_Ptr::~ACE_Refcounted_Auto_Ptr (void) { diff --git a/dep/acelite/ace/Refcounted_Auto_Ptr.h b/dep/acelite/ace/Refcounted_Auto_Ptr.h index b5670cc05..b766d7306 100644 --- a/dep/acelite/ace/Refcounted_Auto_Ptr.h +++ b/dep/acelite/ace/Refcounted_Auto_Ptr.h @@ -4,6 +4,8 @@ /** * @file Refcounted_Auto_Ptr.h * + * $Id: Refcounted_Auto_Ptr.h 81179 2008-03-31 19:00:29Z iliyan $ + * * @author John Tucker */ //============================================================================= diff --git a/dep/acelite/ace/Refcounted_Auto_Ptr.inl b/dep/acelite/ace/Refcounted_Auto_Ptr.inl index f495076b1..cf55bfdf4 100644 --- a/dep/acelite/ace/Refcounted_Auto_Ptr.inl +++ b/dep/acelite/ace/Refcounted_Auto_Ptr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Refcounted_Auto_Ptr.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Guard_T.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/Registry.cpp b/dep/acelite/ace/Registry.cpp index 017ae1a5d..a62a5632b 100644 --- a/dep/acelite/ace/Registry.cpp +++ b/dep/acelite/ace/Registry.cpp @@ -1,3 +1,5 @@ +// $Id: Registry.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Registry.h" #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) diff --git a/dep/acelite/ace/Registry.h b/dep/acelite/ace/Registry.h index afdf775b6..8b7f6a1ed 100644 --- a/dep/acelite/ace/Registry.h +++ b/dep/acelite/ace/Registry.h @@ -4,6 +4,8 @@ /** * @file Registry.h * + * $Id: Registry.h 85110 2009-04-20 09:18:43Z msmit $ + * * @author Irfan Pyarali (irfan@cs.wustl.edu) */ //============================================================================= diff --git a/dep/acelite/ace/Registry_Name_Space.cpp b/dep/acelite/ace/Registry_Name_Space.cpp index c803b5a2e..e109b2526 100644 --- a/dep/acelite/ace/Registry_Name_Space.cpp +++ b/dep/acelite/ace/Registry_Name_Space.cpp @@ -1,3 +1,5 @@ +// $Id: Registry_Name_Space.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Registry_Name_Space.h" diff --git a/dep/acelite/ace/Registry_Name_Space.h b/dep/acelite/ace/Registry_Name_Space.h index 5c830112d..289e61039 100644 --- a/dep/acelite/ace/Registry_Name_Space.h +++ b/dep/acelite/ace/Registry_Name_Space.h @@ -4,6 +4,8 @@ /** * @file Registry_Name_Space.h * + * $Id: Registry_Name_Space.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Irfan Pyarali (irfan@cs.wustl.edu) */ //============================================================================= diff --git a/dep/acelite/ace/Remote_Name_Space.cpp b/dep/acelite/ace/Remote_Name_Space.cpp index c40d190ef..b8c6190af 100644 --- a/dep/acelite/ace/Remote_Name_Space.cpp +++ b/dep/acelite/ace/Remote_Name_Space.cpp @@ -1,3 +1,4 @@ +// $Id: Remote_Name_Space.cpp 96985 2013-04-11 15:50:32Z huangh $ #include "ace/Remote_Name_Space.h" #include "ace/Auto_Ptr.h" #include "ace/Log_Category.h" @@ -108,15 +109,9 @@ ACE_Remote_Name_Space::resolve (const ACE_NS_WString &name, ACE_NS_WString temp (reply.value (), reply.value_len () / sizeof (ACE_WCHAR_T)); value = temp; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (type, - static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * (reply.type_len () + 1))), - -1); -#else ACE_NEW_RETURN (type, char[reply.type_len () + 1], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::strcpy (type, reply.type ()); return 0; } @@ -367,8 +362,6 @@ ACE_Remote_Name_Space::~ACE_Remote_Name_Space (void) ACE_TRACE ("ACE_Remote_Name_Space::~ACE_Remote_Name_Space"); } -ACE_ALLOC_HOOK_DEFINE(ACE_Remote_Name_Space) - void ACE_Remote_Name_Space::dump (void) const { diff --git a/dep/acelite/ace/Remote_Name_Space.h b/dep/acelite/ace/Remote_Name_Space.h index 8643b2069..73c9272f0 100644 --- a/dep/acelite/ace/Remote_Name_Space.h +++ b/dep/acelite/ace/Remote_Name_Space.h @@ -4,6 +4,8 @@ /** * @file Remote_Name_Space.h * + * $Id: Remote_Name_Space.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Prashant Jain */ //========================================================================== @@ -133,8 +135,6 @@ public: /// Dump the state of the object. virtual void dump (void) const; - ACE_ALLOC_HOOK_DECLARE; - private: /// Interface to Name server process for NET_LOCAL namespace. ACE_Name_Proxy ns_proxy_; diff --git a/dep/acelite/ace/Remote_Tokens.cpp b/dep/acelite/ace/Remote_Tokens.cpp index 2e1d24617..3915dde7a 100644 --- a/dep/acelite/ace/Remote_Tokens.cpp +++ b/dep/acelite/ace/Remote_Tokens.cpp @@ -1,3 +1,5 @@ +// $Id: Remote_Tokens.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Remote_Tokens.h" #if defined (ACE_HAS_TOKENS_LIBRARY) diff --git a/dep/acelite/ace/Remote_Tokens.h b/dep/acelite/ace/Remote_Tokens.h index 582e63ee4..3d09f7f2f 100644 --- a/dep/acelite/ace/Remote_Tokens.h +++ b/dep/acelite/ace/Remote_Tokens.h @@ -4,7 +4,9 @@ /** * @file Remote_Tokens.h * - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) + * $Id: Remote_Tokens.h 93359 2011-02-11 11:33:12Z mcorino $ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) * @author Tim Harrison (harrison@cs.wustl.edu) */ //============================================================================= diff --git a/dep/acelite/ace/Remote_Tokens.inl b/dep/acelite/ace/Remote_Tokens.inl index 84f8e3691..3d811c008 100644 --- a/dep/acelite/ace/Remote_Tokens.inl +++ b/dep/acelite/ace/Remote_Tokens.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Remote_Tokens.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_HAS_TOKENS_LIBRARY) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Reverse_Lock_T.cpp b/dep/acelite/ace/Reverse_Lock_T.cpp index e55e1f472..b8f6255db 100644 --- a/dep/acelite/ace/Reverse_Lock_T.cpp +++ b/dep/acelite/ace/Reverse_Lock_T.cpp @@ -1,3 +1,5 @@ +// $Id: Reverse_Lock_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_REVERSE_LOCK_T_CPP #define ACE_REVERSE_LOCK_T_CPP diff --git a/dep/acelite/ace/Reverse_Lock_T.h b/dep/acelite/ace/Reverse_Lock_T.h index f582c3f49..48b6bbed0 100644 --- a/dep/acelite/ace/Reverse_Lock_T.h +++ b/dep/acelite/ace/Reverse_Lock_T.h @@ -4,9 +4,11 @@ /** * @file Reverse_Lock_T.h * + * $Id: Reverse_Lock_T.h 84481 2009-02-17 10:58:31Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Reverse_Lock_T.inl b/dep/acelite/ace/Reverse_Lock_T.inl index 21d4d9705..27e3a9a50 100644 --- a/dep/acelite/ace/Reverse_Lock_T.inl +++ b/dep/acelite/ace/Reverse_Lock_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Reverse_Lock_T.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/config-all.h" #include "ace/OS_NS_errno.h" diff --git a/dep/acelite/ace/Rtems_init.c b/dep/acelite/ace/Rtems_init.c index 389169d7a..3aad4d5a0 100644 --- a/dep/acelite/ace/Rtems_init.c +++ b/dep/acelite/ace/Rtems_init.c @@ -1,3 +1,6 @@ +/* + * $Id: Rtems_init.c 80826 2008-03-04 14:51:23Z wotte $ + */ #if defined (ACE_HAS_RTEMS) diff --git a/dep/acelite/ace/SOCK.cpp b/dep/acelite/ace/SOCK.cpp index 6127d625d..57bcb550e 100644 --- a/dep/acelite/ace/SOCK.cpp +++ b/dep/acelite/ace/SOCK.cpp @@ -1,8 +1,7 @@ +// $Id: SOCK.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SOCK.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SOCK.inl" diff --git a/dep/acelite/ace/SOCK.h b/dep/acelite/ace/SOCK.h index 8fa3942c4..124a4ea4a 100644 --- a/dep/acelite/ace/SOCK.h +++ b/dep/acelite/ace/SOCK.h @@ -4,7 +4,9 @@ /** * @file SOCK.h * - * @author Douglas C. Schmidt + * $Id: SOCK.h 91626 2010-09-07 10:59:20Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/SOCK.inl b/dep/acelite/ace/SOCK.inl index 74875bd41..957ad5ac5 100644 --- a/dep/acelite/ace/SOCK.inl +++ b/dep/acelite/ace/SOCK.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_sys_socket.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SOCK_Acceptor.cpp b/dep/acelite/ace/SOCK_Acceptor.cpp index 47057df08..891013bab 100644 --- a/dep/acelite/ace/SOCK_Acceptor.cpp +++ b/dep/acelite/ace/SOCK_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_Acceptor.cpp 97459 2013-12-12 00:22:03Z mesnier_p $ + #include "ace/SOCK_Acceptor.h" #include "ace/Log_Category.h" @@ -5,9 +7,6 @@ #include "ace/OS_NS_string.h" #include "ace/OS_NS_sys_socket.h" #include "ace/os_include/os_fcntl.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SOCK_Acceptor.inl" @@ -221,15 +220,12 @@ ACE_SOCK_Acceptor::dump (void) const int ACE_SOCK_Acceptor::shared_open (const ACE_Addr &local_sap, int protocol_family, - int backlog, - int ipv6_only) + int backlog) { ACE_TRACE ("ACE_SOCK_Acceptor::shared_open"); int error = 0; -#if !defined (ACE_HAS_IPV6) - ACE_UNUSED_ARG (ipv6_only); -#else /* defined (ACE_HAS_IPV6) */ +#if defined (ACE_HAS_IPV6) if (protocol_family == PF_INET6) { sockaddr_in6 local_inet6_addr; @@ -246,31 +242,29 @@ ACE_SOCK_Acceptor::shared_open (const ACE_Addr &local_sap, else local_inet6_addr = *reinterpret_cast (local_sap.get_addr ()); - /* - * Handle IPv6-only requests. On Windows, v6-only is the default - * unless it is turned off. On Linux, v4/v6 dual is the default - * unless v6-only is turned on. - * This must be done before attempting to bind the address. - * On Windows older than Vista this will fail. - */ - int setting = !!ipv6_only; - if (-1 == ACE_OS::setsockopt (this->get_handle (), - IPPROTO_IPV6, - IPV6_V6ONLY, - (char *)&setting, - sizeof (setting))) +# if defined (ACE_WIN32) + // on windows vista and later, Winsock can support dual stack sockets + // but this must be explicitly set prior to the bind. Since this + // behavior is the default on *nix platforms, it should be benigh to + // just do it here. On older platforms the setsockopt will fail, but + // that should be OK. + int zero = 0; + ACE_OS::setsockopt (this->get_handle (), + IPPROTO_IPV6, + IPV6_V6ONLY, + (char *)&zero, + sizeof (zero)); +# endif /* ACE_WIN32 */ + // We probably don't need a bind_port written here. + // There are currently no supported OS's that define + // ACE_LACKS_WILDCARD_BIND. + if (ACE_OS::bind (this->get_handle (), + reinterpret_cast (&local_inet6_addr), + sizeof local_inet6_addr) == -1) error = 1; - else - // We probably don't need a bind_port written here. - // There are currently no supported OS's that define - // ACE_LACKS_WILDCARD_BIND. - if (ACE_OS::bind (this->get_handle (), - reinterpret_cast (&local_inet6_addr), - sizeof local_inet6_addr) == -1) - error = 1; } else -#endif /* ACE_HAS_IPV6 */ +#endif if (protocol_family == PF_INET) { sockaddr_in local_inet_addr; @@ -320,8 +314,7 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap, int reuse_addr, int protocol_family, int backlog, - int protocol, - int ipv6_only) + int protocol) { ACE_TRACE ("ACE_SOCK_Acceptor::open"); @@ -339,8 +332,7 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap, else return this->shared_open (local_sap, protocol_family, - backlog, - ipv6_only); + backlog); } ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap, @@ -350,8 +342,7 @@ ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap, int reuse_addr, int protocol_family, int backlog, - int protocol, - int ipv6_only) + int protocol) { ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor"); if (this->open (local_sap, @@ -361,8 +352,7 @@ ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap, reuse_addr, protocol_family, backlog, - protocol, - ipv6_only) == -1) + protocol) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SOCK_Acceptor"))); @@ -375,8 +365,7 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap, int reuse_addr, int protocol_family, int backlog, - int protocol, - int ipv6_only) + int protocol) { ACE_TRACE ("ACE_SOCK_Acceptor::open"); @@ -399,8 +388,7 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap, else return this->shared_open (local_sap, protocol_family, - backlog, - ipv6_only); + backlog); } // General purpose routine for performing server ACE_SOCK creation. @@ -409,16 +397,14 @@ ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap, int reuse_addr, int protocol_family, int backlog, - int protocol, - int ipv6_only) + int protocol) { ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor"); if (this->open (local_sap, reuse_addr, protocol_family, backlog, - protocol, - ipv6_only) == -1) + protocol) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SOCK_Acceptor"))); diff --git a/dep/acelite/ace/SOCK_Acceptor.h b/dep/acelite/ace/SOCK_Acceptor.h index 577b654b2..79d3adefe 100644 --- a/dep/acelite/ace/SOCK_Acceptor.h +++ b/dep/acelite/ace/SOCK_Acceptor.h @@ -4,7 +4,9 @@ /** * @file SOCK_Acceptor.h * - * @author Douglas C. Schmidt + * $Id: SOCK_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -46,16 +48,12 @@ public: * @a local_sap is the address that we're going to listen for * connections on. If @a reuse_addr is 1 then we'll use the * @c SO_REUSEADDR to reuse this address. - * @a ipv6_only is used when opening a IPv6 acceptor. If non-zero, - * the socket will only accept connections from IPv6 peers. If zero - * the socket will accept both IPv4 and v6 if it is able to. */ ACE_SOCK_Acceptor (const ACE_Addr &local_sap, int reuse_addr = 0, int protocol_family = PF_UNSPEC, int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0, - int ipv6_only = 0); + int protocol = 0); /// Initialize a passive-mode QoS-enabled acceptor socket. Returns 0 /// on success and -1 on failure. @@ -66,26 +64,20 @@ public: int reuse_addr, int protocol_family = PF_UNSPEC, int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0, - int ipv6_only = 0); + int protocol = 0); /** * Initialize a passive-mode BSD-style acceptor socket (no QoS). * @a local_sap is the address that we're going to listen for * connections on. If @a reuse_addr is 1 then we'll use the - * @c SO_REUSEADDR to reuse this address. - * @a ipv6_only is used when opening a IPv6 acceptor. If non-zero, - * the socket will only accept connections from IPv6 peers. If zero - * the socket will accept both IPv4 and v6 if it is able to. - * @retval Returns 0 on success and + * @c SO_REUSEADDR to reuse this address. Returns 0 on success and * -1 on failure. */ int open (const ACE_Addr &local_sap, int reuse_addr = 0, int protocol_family = PF_UNSPEC, int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0, - int ipv6_only = 0); + int protocol = 0); /// Initialize a passive-mode QoS-enabled acceptor socket. Returns 0 /// on success and -1 on failure. @@ -96,8 +88,7 @@ public: int reuse_addr, int protocol_family = PF_UNSPEC, int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0, - int ipv6_only = 0); + int protocol = 0); /// Close the socket. Returns 0 on success and -1 on failure. int close (void); @@ -170,8 +161,7 @@ protected: */ int shared_open (const ACE_Addr &local_sap, int protocol_family, - int backlog, - int ipv6_only); + int backlog); private: /// Do not allow this function to percolate up to this interface... diff --git a/dep/acelite/ace/SOCK_Acceptor.inl b/dep/acelite/ace/SOCK_Acceptor.inl index bf6822a3e..fec79aeec 100644 --- a/dep/acelite/ace/SOCK_Acceptor.inl +++ b/dep/acelite/ace/SOCK_Acceptor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_Acceptor.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/SOCK_CODgram.cpp b/dep/acelite/ace/SOCK_CODgram.cpp index 3921375ac..09e5506f4 100644 --- a/dep/acelite/ace/SOCK_CODgram.cpp +++ b/dep/acelite/ace/SOCK_CODgram.cpp @@ -1,9 +1,8 @@ +// $Id: SOCK_CODgram.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SOCK_CODgram.h" #include "ace/Log_Category.h" #include "ace/OS_NS_sys_socket.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SOCK_CODgram.inl" diff --git a/dep/acelite/ace/SOCK_CODgram.h b/dep/acelite/ace/SOCK_CODgram.h index b22eb6075..0788f8710 100644 --- a/dep/acelite/ace/SOCK_CODgram.h +++ b/dep/acelite/ace/SOCK_CODgram.h @@ -4,6 +4,8 @@ /** * @file SOCK_CODgram.h * + * $Id: SOCK_CODgram.h 81509 2008-04-28 22:00:49Z shuston $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/SOCK_CODgram.inl b/dep/acelite/ace/SOCK_CODgram.inl index 28f4faf93..a05228b36 100644 --- a/dep/acelite/ace/SOCK_CODgram.inl +++ b/dep/acelite/ace/SOCK_CODgram.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_CODgram.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/SOCK_Connector.cpp b/dep/acelite/ace/SOCK_Connector.cpp index e84767064..ef846cab3 100644 --- a/dep/acelite/ace/SOCK_Connector.cpp +++ b/dep/acelite/ace/SOCK_Connector.cpp @@ -1,12 +1,11 @@ +// $Id: SOCK_Connector.cpp 97699 2014-04-08 20:08:26Z mesnier_p $ + #include "ace/SOCK_Connector.h" #include "ace/INET_Addr.h" #include "ace/Log_Category.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_sys_socket.h" #include "ace/os_include/os_fcntl.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (ACE_HAS_WINCE) #include "ace/OS_QoS.h" @@ -196,19 +195,6 @@ ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream, local_sap) == -1) return -1; -#if defined(ACE_WIN32) && defined(ACE_HAS_IPV6) - // On windows, the IPv4-mapped IPv6 address format can only be used on a dual-stack socket. - const ACE_INET_Addr& remote_address = static_cast(remote_sap); - if (remote_address.is_ipv4_mapped_ipv6()) { - int zero = 0; - ACE_OS::setsockopt(new_stream.get_handle(), - IPPROTO_IPV6, - IPV6_V6ONLY, - (char *)&zero, - sizeof(zero)); - } -#endif - int result = ACE_OS::connect (new_stream.get_handle (), reinterpret_cast (remote_sap.get_addr ()), remote_sap.get_size ()); @@ -244,19 +230,6 @@ ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream, local_sap) == -1) return -1; -#if defined(ACE_WIN32) && defined(ACE_HAS_IPV6) - // On windows, the IPv4-mapped IPv6 address format can only be used on a dual-stack socket. - const ACE_INET_Addr& remote_address = static_cast(remote_sap); - if (remote_address.is_ipv4_mapped_ipv6()) { - int zero = 0; - ACE_OS::setsockopt(new_stream.get_handle(), - IPPROTO_IPV6, - IPV6_V6ONLY, - (char *)&zero, - sizeof(zero)); - } -#endif - int result = ACE_OS::connect (new_stream.get_handle (), reinterpret_cast (remote_sap.get_addr ()), remote_sap.get_size (), diff --git a/dep/acelite/ace/SOCK_Connector.h b/dep/acelite/ace/SOCK_Connector.h index e84410257..28e048e10 100644 --- a/dep/acelite/ace/SOCK_Connector.h +++ b/dep/acelite/ace/SOCK_Connector.h @@ -4,7 +4,9 @@ /** * @file SOCK_Connector.h * - * @author Doug Schmidt + * $Id: SOCK_Connector.h 91626 2010-09-07 10:59:20Z johnnyw $ + * + * @author Doug Schmidt */ //============================================================================= @@ -259,7 +261,7 @@ public: * to the peer. * @param remote_sap If non-0, it points to the @c ACE_INET_Addr object * that will contain the address of the connected peer. - * @param timeout Same values and return value possibilities as for + * @param timeout Same values and return value possibilites as for * connect(). @see connect(). */ int complete (ACE_SOCK_Stream &new_stream, diff --git a/dep/acelite/ace/SOCK_Connector.inl b/dep/acelite/ace/SOCK_Connector.inl index ff1c70311..a805ba0b1 100644 --- a/dep/acelite/ace/SOCK_Connector.inl +++ b/dep/acelite/ace/SOCK_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_Connector.inl 82723 2008-09-16 09:35:44Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // This constructor is used by a client when it wants to connect to diff --git a/dep/acelite/ace/SOCK_Dgram.cpp b/dep/acelite/ace/SOCK_Dgram.cpp index 3c5d47399..8eaadb35b 100644 --- a/dep/acelite/ace/SOCK_Dgram.cpp +++ b/dep/acelite/ace/SOCK_Dgram.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_Dgram.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SOCK_Dgram.h" #include "ace/Log_Category.h" @@ -8,9 +10,6 @@ #include "ace/OS_NS_ctype.h" #include "ace/os_include/net/os_if.h" #include "ace/Truncate.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) # include "ace/SOCK_Dgram.inl" @@ -66,16 +65,9 @@ ACE_SOCK_Dgram::recv (iovec *io_vec, return -1; else if (inlen > 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (io_vec->iov_base, - static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * inlen)), - -1); -#else ACE_NEW_RETURN (io_vec->iov_base, char[inlen], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ - ssize_t rcv_len = ACE_OS::recvfrom (this->get_handle (), (char *) io_vec->iov_base, inlen, @@ -84,11 +76,7 @@ ACE_SOCK_Dgram::recv (iovec *io_vec, &addr_len); if (rcv_len < 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(io_vec->iov_base); -#else delete [] (char *)io_vec->iov_base; -#endif /* ACE_HAS_ALLOC_HOOKS */ io_vec->iov_base = 0; } else @@ -116,26 +104,10 @@ ACE_SOCK_Dgram::recv (iovec *io_vec, int ACE_SOCK_Dgram::shared_open (const ACE_Addr &local, - int protocol_family, - int ipv6_only) + int protocol_family) { ACE_TRACE ("ACE_SOCK_Dgram::shared_open"); bool error = false; -#if defined (ACE_HAS_IPV6) - int setting = !!ipv6_only; - if (protocol_family == PF_INET6 && - -1 == ACE_OS::setsockopt (this->get_handle (), - IPPROTO_IPV6, - IPV6_V6ONLY, - (char *)&setting, - sizeof (setting))) - { - this->close(); - return -1; - } -#else - ACE_UNUSED_ARG (ipv6_only); -#endif /* defined (ACE_HAS_IPV6) */ if (local == ACE_Addr::sap_any) { @@ -169,8 +141,7 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, - int reuse_addr, - int ipv6_only) + int reuse_addr) { if (ACE_SOCK::open (SOCK_DGRAM, protocol_family, @@ -181,8 +152,7 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local, reuse_addr) == -1) return -1; else if (this->shared_open (local, - protocol_family, - ipv6_only) == -1) + protocol_family) == -1) return -1; else return 0; @@ -194,8 +164,7 @@ int ACE_SOCK_Dgram::open (const ACE_Addr &local, int protocol_family, int protocol, - int reuse_addr, - int ipv6_only) + int reuse_addr) { ACE_TRACE ("ACE_SOCK_Dgram::open"); @@ -217,8 +186,7 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local, return -1; else return this->shared_open (local, - protocol_family, - ipv6_only); + protocol_family); } // Here's the general-purpose constructor used by a connectionless @@ -227,16 +195,14 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local, ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local, int protocol_family, int protocol, - int reuse_addr, - int ipv6_only) + int reuse_addr) { ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram"); if (this->open (local, protocol_family, protocol, - reuse_addr, - ipv6_only) == -1) + reuse_addr) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SOCK_Dgram"))); @@ -248,8 +214,7 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, - int reuse_addr, - int ipv6_only) + int reuse_addr) { ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram"); if (this->open (local, @@ -258,8 +223,7 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local, protocolinfo, g, flags, - reuse_addr, - ipv6_only) == -1) + reuse_addr) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SOCK_Dgram"))); @@ -291,7 +255,7 @@ ACE_SOCK_Dgram::send (const iovec iov[], send_msg.msg_control = 0; send_msg.msg_controllen = 0; send_msg.msg_flags = 0; -#elif !defined ACE_LACKS_SENDMSG +#else send_msg.msg_accrights = 0; send_msg.msg_accrightslen = 0; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ @@ -308,28 +272,11 @@ ssize_t ACE_SOCK_Dgram::recv (iovec iov[], int n, ACE_Addr &addr, - int flags, - ACE_INET_Addr *to_addr) const + int flags) const { ACE_TRACE ("ACE_SOCK_Dgram::recv"); msghdr recv_msg; -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - union control_buffer { - cmsghdr control_msg_header; -#if defined (IP_RECVDSTADDR) - u_char padding[CMSG_SPACE(sizeof (struct in_addr))]; -#elif defined (IP_PKTINFO) - u_char padding[CMSG_SPACE(sizeof (struct in_pktinfo))]; -#endif -#if defined (ACE_HAS_IPV6) - u_char padding6[CMSG_SPACE(sizeof (struct in6_pktinfo))]; -#endif - } cbuf; -#else - ACE_UNUSED_ARG (to_addr); -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - recv_msg.msg_iov = (iovec *) iov; recv_msg.msg_iovlen = n; #if defined (ACE_HAS_SOCKADDR_MSG_NAME) @@ -340,9 +287,9 @@ ACE_SOCK_Dgram::recv (iovec iov[], recv_msg.msg_namelen = addr.get_size (); #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - recv_msg.msg_control = to_addr ? &cbuf : 0; - recv_msg.msg_controllen = to_addr ? sizeof (cbuf) : 0; -#elif !defined ACE_LACKS_SENDMSG + recv_msg.msg_control = 0 ; + recv_msg.msg_controllen = 0 ; +#else recv_msg.msg_accrights = 0; recv_msg.msg_accrightslen = 0; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ @@ -352,49 +299,6 @@ ACE_SOCK_Dgram::recv (iovec iov[], flags); addr.set_size (recv_msg.msg_namelen); addr.set_type (((sockaddr_in *) addr.get_addr())->sin_family); - -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) - if (to_addr) { - this->get_local_addr (*to_addr); - if (to_addr->get_type() == AF_INET) { -#if defined (IP_RECVDSTADDR) || defined (IP_PKTINFO) - for (cmsghdr *ptr = CMSG_FIRSTHDR (&recv_msg); ptr != 0; ptr = CMSG_NXTHDR (&recv_msg, ptr)) { -#if defined (IP_RECVDSTADDR) - if (ptr->cmsg_level == IPPROTO_IP && - ptr->cmsg_type == IP_RECVDSTADDR) { - to_addr->set_address ((const char *)(CMSG_DATA (ptr)), - sizeof (struct in_addr), - 0); - break; - } -#else - if (ptr->cmsg_level == IPPROTO_IP && - ptr->cmsg_type == IP_PKTINFO) { - to_addr->set_address ((const char *)&(((struct in_pktinfo *)(CMSG_DATA (ptr)))->ipi_addr), - sizeof (struct in_addr), - 0); - break; - } -#endif - } -#endif - } -#if defined (ACE_HAS_IPV6) && defined (IPV6_PKTINFO) - else if (to_addr->get_type() == AF_INET6) { - for (cmsghdr *ptr = CMSG_FIRSTHDR (&recv_msg); ptr != 0; ptr = CMSG_NXTHDR (&recv_msg, ptr)) { - if (ptr->cmsg_level == IPPROTO_IPV6 && ptr->cmsg_type == IPV6_PKTINFO) { - to_addr->set_address ((const char *)&(((struct in6_pktinfo *)(CMSG_DATA (ptr)))->ipi6_addr), - sizeof (struct in6_addr), - 0); - - break; - } - } - } -#endif - } -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ - return status; } @@ -430,14 +334,9 @@ ACE_SOCK_Dgram::send (const iovec iov[], #if defined (ACE_HAS_ALLOCA) buf = alloca (length); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (buf, (buf *) - ACE_Allocator::instance ()->malloc (length), -1); -# else ACE_NEW_RETURN (buf, char[length], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ char *ptr = buf; @@ -450,11 +349,7 @@ ACE_SOCK_Dgram::send (const iovec iov[], ssize_t result = ACE_SOCK_Dgram::send (buf, length, addr, flags); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (buf); -# else delete [] buf; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ return result; } @@ -488,14 +383,9 @@ ACE_SOCK_Dgram::recv (iovec iov[], #if defined (ACE_HAS_ALLOCA) buf = alloca (length); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (buf, (buf *) - ACE_Allocator::instance ()->malloc (length), -1); -# else ACE_NEW_RETURN (buf, char[length], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ length = ACE_SOCK_Dgram::recv (buf, length, addr, flags); @@ -520,11 +410,7 @@ ACE_SOCK_Dgram::recv (iovec iov[], } #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (buf); -# else delete [] buf; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ return length; } diff --git a/dep/acelite/ace/SOCK_Dgram.h b/dep/acelite/ace/SOCK_Dgram.h index ff5679975..3a8eba63d 100644 --- a/dep/acelite/ace/SOCK_Dgram.h +++ b/dep/acelite/ace/SOCK_Dgram.h @@ -4,7 +4,9 @@ /** * @file SOCK_Dgram.h * - * @author Douglas C. Schmidt + * $Id: SOCK_Dgram.h 92580 2010-11-15 09:48:02Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -15,9 +17,6 @@ #include "ace/SOCK.h" #include "ace/INET_Addr.h" -// Included so users have access to ACE_RECVPKTINFO and ACE_RECVPKTINFO6 . -#include "ace/OS_NS_sys_socket.h" - #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ @@ -46,8 +45,7 @@ public: ACE_SOCK_Dgram (const ACE_Addr &local, int protocol_family = ACE_PROTOCOL_FAMILY_INET, int protocol = 0, - int reuse_addr = 0, - int ipv6_only = 0); + int reuse_addr = 0); /** * This is a QoS-enabed method for initiating a socket dgram that @@ -60,16 +58,14 @@ public: ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g = 0, u_long flags = 0, - int reuse_addr = 0, - int ipv6_only = 0); + int reuse_addr = 0); /// This is a BSD-style method (i.e., no QoS) for initiating a socket /// dgram that will accept datagrams at the address. int open (const ACE_Addr &local, int protocol_family = ACE_PROTOCOL_FAMILY_INET, int protocol = 0, - int reuse_addr = 0, - int ipv6_only = 0); + int reuse_addr = 0); /** * This is a QoS-enabed method for initiating a socket dgram that @@ -82,8 +78,7 @@ public: ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g = 0, u_long flags = 0, - int reuse_addr = 0, - int ipv6_only = 0); + int reuse_addr = 0); /// Default dtor. ~ACE_SOCK_Dgram (void); @@ -123,16 +118,11 @@ public: int flags = 0) const; /// Recv an of size @a n to the datagram socket (uses - /// ). The IP destination address will be placed in @a - /// *to_addr if it is not null and set_option has been called with - /// 1) level IPPROTO_IP, option ACE_RECVPKTINFO, and value 1 for - /// IPV4 addresses or 2) IPPROTO_IPV6, option ACE_RECVPKTINFO6, and - /// value 1 for IPV6 addresses. + /// ). ssize_t recv (iovec iov[], int n, ACE_Addr &addr, - int flags = 0, - ACE_INET_Addr *to_addr = 0) const; + int flags = 0) const; /** * Wait up to @a timeout amount of time to receive a datagram into @@ -216,9 +206,7 @@ public: protected: /// Open is shared by this and by . - int shared_open (const ACE_Addr &local, - int protocol_family, - int ipv6_only = 0); + int shared_open (const ACE_Addr &local, int protocol_family); /// Create a multicast addr/if pair, in format useful for system calls. /// If mreq param is NULL, just verify the passed addr/interface specs. diff --git a/dep/acelite/ace/SOCK_Dgram.inl b/dep/acelite/ace/SOCK_Dgram.inl index b2a116c31..7bffb19ba 100644 --- a/dep/acelite/ace/SOCK_Dgram.inl +++ b/dep/acelite/ace/SOCK_Dgram.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_Dgram.inl 80826 2008-03-04 14:51:23Z wotte $ + // SOCK_Dgram.i #include "ace/OS_NS_sys_socket.h" diff --git a/dep/acelite/ace/SOCK_Dgram_Bcast.cpp b/dep/acelite/ace/SOCK_Dgram_Bcast.cpp index f4cc86f7a..33e4a8b30 100644 --- a/dep/acelite/ace/SOCK_Dgram_Bcast.cpp +++ b/dep/acelite/ace/SOCK_Dgram_Bcast.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_Dgram_Bcast.cpp 97798 2014-07-03 10:57:43Z johnnyw $ + #include "ace/SOCK_Dgram_Bcast.h" #include "ace/Log_Category.h" @@ -6,9 +8,6 @@ #include "ace/os_include/net/os_if.h" #include "ace/OS_NS_netdb.h" #include "ace/OS_Memory.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SOCK_Dgram_Bcast.inl" @@ -28,8 +27,6 @@ ACE_Bcast_Node::ACE_Bcast_Node (ACE_INET_Addr &addr, ACE_TRACE ("ACE_Bcast_Node::ACE_Bcast_Node"); } -ACE_ALLOC_HOOK_DEFINE(ACE_Bcast_Node) - void ACE_SOCK_Dgram_Bcast::dump (void) const { @@ -155,11 +152,7 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ACE_TCHAR *host_name) return -1; else ACE_OS::memcpy ((char *) &host_addr.sin_addr.s_addr, -# ifdef ACE_HOSTENT_H_ADDR - (char *) hp->ACE_HOSTENT_H_ADDR, -# else (char *) hp->h_addr, -# endif hp->h_length); } diff --git a/dep/acelite/ace/SOCK_Dgram_Bcast.h b/dep/acelite/ace/SOCK_Dgram_Bcast.h index fb2f38520..2156a669c 100644 --- a/dep/acelite/ace/SOCK_Dgram_Bcast.h +++ b/dep/acelite/ace/SOCK_Dgram_Bcast.h @@ -4,6 +4,8 @@ /** * @file SOCK_Dgram_Bcast.h * + * $Id: SOCK_Dgram_Bcast.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //============================================================================= @@ -44,8 +46,6 @@ public: /// Pointer to the next interface in the chain. ACE_Bcast_Node *next_; - - ACE_ALLOC_HOOK_DECLARE; }; /** diff --git a/dep/acelite/ace/SOCK_Dgram_Bcast.inl b/dep/acelite/ace/SOCK_Dgram_Bcast.inl index 429afa82e..165972488 100644 --- a/dep/acelite/ace/SOCK_Dgram_Bcast.inl +++ b/dep/acelite/ace/SOCK_Dgram_Bcast.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_Dgram_Bcast.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_sys_socket.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SOCK_Dgram_Mcast.cpp b/dep/acelite/ace/SOCK_Dgram_Mcast.cpp index cfaab1fcb..985722d88 100644 --- a/dep/acelite/ace/SOCK_Dgram_Mcast.cpp +++ b/dep/acelite/ace/SOCK_Dgram_Mcast.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_Dgram_Mcast.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SOCK_Dgram_Mcast.h" #include "ace/OS_Memory.h" @@ -5,9 +7,6 @@ #include "ace/OS_NS_errno.h" #include "ace/os_include/net/os_if.h" #include "ace/os_include/arpa/os_inet.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if defined (ACE_LINUX) && defined (ACE_HAS_IPV6) #include "ace/OS_NS_sys_socket.h" @@ -148,11 +147,7 @@ ACE_SOCK_Dgram_Mcast::~ACE_SOCK_Dgram_Mcast (void) ACE_TRACE ("ACE_SOCK_Dgram_Mcast::~ACE_SOCK_Dgram_Mcast"); // Free memory and optionally unsubscribe from currently subscribed group(s). -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->send_net_if_); -#else delete [] this->send_net_if_; -#endif /* ACE_HAS_ALLOC_HOOKS */ this->clear_subs_list (); } @@ -248,11 +243,8 @@ ACE_SOCK_Dgram_Mcast::open_i (const ACE_INET_Addr &mcast_addr, { if (this->set_nic (net_if, mcast_addr.get_type ())) return -1; -#if defined (ACE_HAS_ALLOC_HOOKS) - this->send_net_if_ = static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (ACE_OS::strlen (net_if) + 1))); -#else + this->send_net_if_ = new ACE_TCHAR[ACE_OS::strlen (net_if) + 1]; -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::strcpy (this->send_net_if_, net_if); } diff --git a/dep/acelite/ace/SOCK_Dgram_Mcast.h b/dep/acelite/ace/SOCK_Dgram_Mcast.h index 50592e4ed..a2e7def0f 100644 --- a/dep/acelite/ace/SOCK_Dgram_Mcast.h +++ b/dep/acelite/ace/SOCK_Dgram_Mcast.h @@ -4,9 +4,11 @@ /** * @file SOCK_Dgram_Mcast.h * + * $Id: SOCK_Dgram_Mcast.h 96014 2012-08-08 15:30:01Z sma $ + * * @author Irfan Pyrali * @author Tim Harrison - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Bill Fulton * @author Don Hinton */ diff --git a/dep/acelite/ace/SOCK_Dgram_Mcast.inl b/dep/acelite/ace/SOCK_Dgram_Mcast.inl index d79200126..d5f1ecbd1 100644 --- a/dep/acelite/ace/SOCK_Dgram_Mcast.inl +++ b/dep/acelite/ace/SOCK_Dgram_Mcast.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_Dgram_Mcast.inl 96014 2012-08-08 15:30:01Z sma $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/SOCK_IO.cpp b/dep/acelite/ace/SOCK_IO.cpp index e2b68a645..10af6460b 100644 --- a/dep/acelite/ace/SOCK_IO.cpp +++ b/dep/acelite/ace/SOCK_IO.cpp @@ -1,13 +1,11 @@ +// $Id: SOCK_IO.cpp 91622 2010-09-06 08:26:30Z sma $ + #include "ace/SOCK_IO.h" #include "ace/OS_NS_sys_socket.h" #include "ace/OS_Memory.h" #include "ace/Truncate.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/SOCK_IO.inl" #endif /* __ACE_INLINE__ */ @@ -51,16 +49,9 @@ ACE_SOCK_IO::recvv (iovec *io_vec, return -1; else if (inlen > 0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (io_vec->iov_base, - static_cast(ACE_Allocator::instance()->malloc(sizeof(char) * inlen)), - -1); -#else ACE_NEW_RETURN (io_vec->iov_base, char[inlen], -1); -#endif /* ACE_HAS_ALLOC_HOOKS */ - // It's ok to blindly cast this value since 'inlen' is an int and, thus, // we can't get more than that back. Besides, if the recv() fails, we // don't want that value cast to unsigned and returned. @@ -84,7 +75,7 @@ ACE_SOCK_IO::recvv (iovec *io_vec, // the ints (basically, an varargs version of writev). The count N is // the *total* number of trailing arguments, *not* a couple of the // number of tuple pairs! -#ifndef ACE_LACKS_VA_FUNCTIONS + ssize_t ACE_SOCK_IO::send (size_t n, ...) const { @@ -96,16 +87,9 @@ ACE_SOCK_IO::send (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -120,11 +104,7 @@ ACE_SOCK_IO::send (size_t n, ...) const iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; @@ -147,16 +127,9 @@ ACE_SOCK_IO::recv (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -171,15 +144,10 @@ ACE_SOCK_IO::recv (size_t n, ...) const iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; } -#endif // ACE_LACKS_VA_FUNCTIONS ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SOCK_IO.h b/dep/acelite/ace/SOCK_IO.h index 538bec97c..391f77cb8 100644 --- a/dep/acelite/ace/SOCK_IO.h +++ b/dep/acelite/ace/SOCK_IO.h @@ -4,7 +4,9 @@ /** * @file SOCK_IO.h * - * @author Douglas C. Schmidt + * $Id: SOCK_IO.h 97075 2013-04-24 15:01:48Z schmidt $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -82,11 +84,9 @@ public: ssize_t recvv (iovec *io_vec, const ACE_Time_Value *timeout = 0) const; -#ifndef ACE_LACKS_VA_FUNCTIONS /// Recv @a n varargs messages to the connected socket. ssize_t recv (size_t n, ...) const; -#endif /// Recv @a n bytes via Win32 @c ReadFile using overlapped I/O. ssize_t recv (void *buf, @@ -109,11 +109,9 @@ public: int n, const ACE_Time_Value *timeout = 0) const; -#ifndef ACE_LACKS_VA_FUNCTIONS /// Send @a n varargs messages to the connected socket. ssize_t send (size_t n, ...) const; -#endif /// Send @a n bytes via Win32 using overlapped I/O. ssize_t send (const void *buf, diff --git a/dep/acelite/ace/SOCK_IO.inl b/dep/acelite/ace/SOCK_IO.inl index eec644cd7..55716921d 100644 --- a/dep/acelite/ace/SOCK_IO.inl +++ b/dep/acelite/ace/SOCK_IO.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_IO.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_unistd.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SOCK_Netlink.cpp b/dep/acelite/ace/SOCK_Netlink.cpp index c1c1ce4d5..a2c40583f 100644 --- a/dep/acelite/ace/SOCK_Netlink.cpp +++ b/dep/acelite/ace/SOCK_Netlink.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_Netlink.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include /* */ "ace/SOCK_Netlink.h" #ifdef ACE_HAS_NETLINK @@ -8,9 +10,6 @@ #include "ace/OS_NS_unistd.h" #include "ace/SOCK_Netlink.h" #include "ace/OS_NS_sys_socket.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SOCK_Netlink.inl" diff --git a/dep/acelite/ace/SOCK_Netlink.h b/dep/acelite/ace/SOCK_Netlink.h index 993a5d4f5..c3be22155 100644 --- a/dep/acelite/ace/SOCK_Netlink.h +++ b/dep/acelite/ace/SOCK_Netlink.h @@ -1,7 +1,10 @@ +// $Id: SOCK_Netlink.h 80826 2008-03-04 14:51:23Z wotte $ //============================================================================= /** * @file SOCK_Netlink.h * + * $Id: SOCK_Netlink.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Robert Iakobashvilli * @author Raz Ben Yehuda */ @@ -36,6 +39,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * and user to kernel. * This code was created so one could use ACE reactor * as a gateway to a linux kernel. + * */ class ACE_Export ACE_SOCK_Netlink : public ACE_SOCK { public: diff --git a/dep/acelite/ace/SOCK_Netlink.inl b/dep/acelite/ace/SOCK_Netlink.inl index 58ad283aa..0a0504ce1 100644 --- a/dep/acelite/ace/SOCK_Netlink.inl +++ b/dep/acelite/ace/SOCK_Netlink.inl @@ -1,3 +1,5 @@ +// $Id: SOCK_Netlink.inl 80826 2008-03-04 14:51:23Z wotte $ + #ifdef ACE_HAS_NETLINK ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SOCK_SEQPACK_Acceptor.cpp b/dep/acelite/ace/SOCK_SEQPACK_Acceptor.cpp index fc1bc669b..34ea5dd8e 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Acceptor.cpp +++ b/dep/acelite/ace/SOCK_SEQPACK_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_SEQPACK_Acceptor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SOCK_SEQPACK_Acceptor.h" #include "ace/Auto_Ptr.h" @@ -333,13 +335,8 @@ ACE_SOCK_SEQPACK_Acceptor::shared_open (const ACE_Multihomed_INET_Addr &local_sa // representations of the primary and secondary // addresses. sockaddr_in* local_inet_addrs = 0; -#if defined(ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (local_inet_addrs, - static_cast(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * num_addresses))); -#else ACE_NEW_NORETURN (local_inet_addrs, sockaddr_in[num_addresses]); -#endif if (!local_inet_addrs) error = 1; @@ -403,11 +400,7 @@ ACE_SOCK_SEQPACK_Acceptor::shared_open (const ACE_Multihomed_INET_Addr &local_sa #endif /* ACE_HAS_LKSCTP */ } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(local_inet_addrs); -#else delete [] local_inet_addrs; -#endif /* ACE_HAS_ALLOC_HOOKS */ } } else if (ACE_OS::bind (this->get_handle (), diff --git a/dep/acelite/ace/SOCK_SEQPACK_Acceptor.h b/dep/acelite/ace/SOCK_SEQPACK_Acceptor.h index d6e1e65f3..d5c701081 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Acceptor.h +++ b/dep/acelite/ace/SOCK_SEQPACK_Acceptor.h @@ -4,10 +4,12 @@ /** * @file SOCK_SEQPACK_Acceptor.h * + * $Id: SOCK_SEQPACK_Acceptor.h 84325 2009-02-04 22:46:30Z shuston $ * @author Patrick J. Lardieri * @author Gaurav Naik, Lockheed Martin ATL * @author based on SOCK_STREAM_Acceptor - * by Douglas C. Schmidt + * by Douglas C. Schmidt + * */ //============================================================================= diff --git a/dep/acelite/ace/SOCK_SEQPACK_Acceptor.inl b/dep/acelite/ace/SOCK_SEQPACK_Acceptor.inl index 82577e266..00bfe399d 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Acceptor.inl +++ b/dep/acelite/ace/SOCK_SEQPACK_Acceptor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_SEQPACK_Acceptor.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/SOCK_SEQPACK_Association.cpp b/dep/acelite/ace/SOCK_SEQPACK_Association.cpp index 8c3f2a001..a382a2f3e 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Association.cpp +++ b/dep/acelite/ace/SOCK_SEQPACK_Association.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_SEQPACK_Association.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SOCK_SEQPACK_Association.h" #include "ace/Auto_Ptr.h" @@ -162,11 +164,7 @@ ACE_SOCK_SEQPACK_Association::get_local_addrs (ACE_INET_Addr *addrs, size_t &siz // an ACE_Auto_Array_Ptr.) { sockaddr_in *addr_structs_bootstrap = 0; -#if defined(ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (addr_structs_bootstrap, static_cast(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * size)), -1); -#else ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1); -#endif addr_structs.reset(addr_structs_bootstrap); } @@ -305,11 +303,7 @@ ACE_SOCK_SEQPACK_Association::get_remote_addrs (ACE_INET_Addr *addrs, size_t &si // an ACE_Auto_Array_Ptr.) { sockaddr_in *addr_structs_bootstrap = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (addr_structs_bootstrap, static_cast(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * (size))), -1); -#else ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1); -#endif addr_structs.reset(addr_structs_bootstrap); } diff --git a/dep/acelite/ace/SOCK_SEQPACK_Association.h b/dep/acelite/ace/SOCK_SEQPACK_Association.h index c1eb5be44..6189d1a99 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Association.h +++ b/dep/acelite/ace/SOCK_SEQPACK_Association.h @@ -5,10 +5,13 @@ * * @file SOCK_SEQPACK_Association.h * + * $Id: SOCK_SEQPACK_Association.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Patrick J. Lardieri * @author Gaurav Naik, Lockheed Martin ATL * @author based on SOCK_Stream - * by Douglas C. Schmidt + * by Douglas C. Schmidt + * */ //============================================================================= diff --git a/dep/acelite/ace/SOCK_SEQPACK_Association.inl b/dep/acelite/ace/SOCK_SEQPACK_Association.inl index 98e59c6f4..2aed02d02 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Association.inl +++ b/dep/acelite/ace/SOCK_SEQPACK_Association.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_SEQPACK_Association.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/SOCK_SEQPACK_Association.h" #include "ace/OS_NS_sys_socket.h" diff --git a/dep/acelite/ace/SOCK_SEQPACK_Connector.cpp b/dep/acelite/ace/SOCK_SEQPACK_Connector.cpp index 92787f9a5..5b14925d1 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Connector.cpp +++ b/dep/acelite/ace/SOCK_SEQPACK_Connector.cpp @@ -1,3 +1,5 @@ +// $Id: SOCK_SEQPACK_Connector.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SOCK_SEQPACK_Connector.h" #include "ace/INET_Addr.h" @@ -133,11 +135,7 @@ ACE_SOCK_SEQPACK_Connector::shared_connect_start (ACE_SOCK_SEQPACK_Association & // representations of the primary and secondary // addresses. sockaddr_in* local_inet_addrs = 0; -#if defined(ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (local_inet_addrs, static_cast(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * (num_addresses)))); -#else ACE_NEW_NORETURN (local_inet_addrs, sockaddr_in[num_addresses]); -#endif if (!local_inet_addrs) return -1; @@ -219,11 +217,7 @@ ACE_SOCK_SEQPACK_Connector::shared_connect_start (ACE_SOCK_SEQPACK_Association & } #endif /* ACE_HAS_LKSCTP */ -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(local_inet_addrs); -#else delete [] local_inet_addrs; -#endif /* ACE_HAS_ALLOC_HOOKS */ } // Enable non-blocking, if required. diff --git a/dep/acelite/ace/SOCK_SEQPACK_Connector.h b/dep/acelite/ace/SOCK_SEQPACK_Connector.h index d14500836..67bc75776 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Connector.h +++ b/dep/acelite/ace/SOCK_SEQPACK_Connector.h @@ -4,10 +4,13 @@ /** * @file SOCK_SEQPACK_Connector.h * + * $Id: SOCK_SEQPACK_Connector.h 84816 2009-03-13 08:16:32Z johnnyw $ + * * @author Patrick J. Lardieri * @author Gaurav Naik, Lockheed Martin ATL * @author based on SOCK_STREAM_Connector * by Douglas C. Schmidt + * */ //============================================================================= @@ -264,7 +267,7 @@ public: * to the peer. * @param remote_sap If non-0, it points to the @c ACE_INET_Addr object * that will contain the address of the connected peer. - * @param timeout Same values and return value possibilities as for + * @param timeout Same values and return value possibilites as for * connect(). @see connect(). */ int complete (ACE_SOCK_SEQPACK_Association &new_association, diff --git a/dep/acelite/ace/SOCK_SEQPACK_Connector.inl b/dep/acelite/ace/SOCK_SEQPACK_Connector.inl index 1b04fe274..332b6ce30 100644 --- a/dep/acelite/ace/SOCK_SEQPACK_Connector.inl +++ b/dep/acelite/ace/SOCK_SEQPACK_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_SEQPACK_Connector.inl 82723 2008-09-16 09:35:44Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // This constructor is used by a client when it wants to connect to diff --git a/dep/acelite/ace/SOCK_Stream.cpp b/dep/acelite/ace/SOCK_Stream.cpp index c25a9b429..54148be89 100644 --- a/dep/acelite/ace/SOCK_Stream.cpp +++ b/dep/acelite/ace/SOCK_Stream.cpp @@ -1,12 +1,12 @@ +// $Id: SOCK_Stream.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/SOCK_Stream.h" #if !defined (__ACE_INLINE__) #include "ace/SOCK_Stream.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SOCK_Stream.h b/dep/acelite/ace/SOCK_Stream.h index ae0c6969c..97dc8f708 100644 --- a/dep/acelite/ace/SOCK_Stream.h +++ b/dep/acelite/ace/SOCK_Stream.h @@ -4,7 +4,9 @@ /** * @file SOCK_Stream.h * - * @author Douglas C. Schmidt + * $Id: SOCK_Stream.h 92956 2010-12-29 16:12:31Z shuston $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/SOCK_Stream.inl b/dep/acelite/ace/SOCK_Stream.inl index fe25fdde3..cbe6cd3d9 100644 --- a/dep/acelite/ace/SOCK_Stream.inl +++ b/dep/acelite/ace/SOCK_Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SOCK_Stream.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/SOCK_Stream.h" #include "ace/OS_NS_sys_socket.h" diff --git a/dep/acelite/ace/SPIPE.cpp b/dep/acelite/ace/SPIPE.cpp index a57a8a0ae..00f2224a8 100644 --- a/dep/acelite/ace/SPIPE.cpp +++ b/dep/acelite/ace/SPIPE.cpp @@ -1,11 +1,9 @@ +// $Id: SPIPE.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/SPIPE.h" #include "ace/OS_NS_unistd.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/SPIPE.inl" #endif /* __ACE_INLINE__ */ diff --git a/dep/acelite/ace/SPIPE.h b/dep/acelite/ace/SPIPE.h index 0ae586ec3..6654b82a6 100644 --- a/dep/acelite/ace/SPIPE.h +++ b/dep/acelite/ace/SPIPE.h @@ -4,6 +4,8 @@ /** * @file SPIPE.h * + * $Id: SPIPE.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/SPIPE.inl b/dep/acelite/ace/SPIPE.inl index 5303fbdea..6e4c7ed47 100644 --- a/dep/acelite/ace/SPIPE.inl +++ b/dep/acelite/ace/SPIPE.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SPIPE.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/SPIPE_Acceptor.cpp b/dep/acelite/ace/SPIPE_Acceptor.cpp index 84420da62..6a9148a98 100644 --- a/dep/acelite/ace/SPIPE_Acceptor.cpp +++ b/dep/acelite/ace/SPIPE_Acceptor.cpp @@ -1,10 +1,9 @@ +// $Id: SPIPE_Acceptor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SPIPE_Acceptor.h" #include "ace/Log_Category.h" #include "ace/OS_NS_sys_stat.h" #include "ace/OS_NS_sys_time.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if defined (ACE_HAS_STREAM_PIPES) # include "ace/OS_NS_unistd.h" diff --git a/dep/acelite/ace/SPIPE_Acceptor.h b/dep/acelite/ace/SPIPE_Acceptor.h index fd3b065e6..a804670d0 100644 --- a/dep/acelite/ace/SPIPE_Acceptor.h +++ b/dep/acelite/ace/SPIPE_Acceptor.h @@ -4,7 +4,9 @@ /** * @file SPIPE_Acceptor.h * - * @author Douglas C. Schmidt + * $Id: SPIPE_Acceptor.h 94007 2011-04-27 09:01:45Z johnnyw $ + * + * @author Douglas C. Schmidt * @author Prashant Jain */ //============================================================================= @@ -41,6 +43,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @warning Works on non-Windows platforms only when @c ACE_HAS_STREAM_PIPES * is defined. + * */ class ACE_Export ACE_SPIPE_Acceptor : public ACE_SPIPE { diff --git a/dep/acelite/ace/SPIPE_Addr.cpp b/dep/acelite/ace/SPIPE_Addr.cpp index ef34d66dc..256b5473c 100644 --- a/dep/acelite/ace/SPIPE_Addr.cpp +++ b/dep/acelite/ace/SPIPE_Addr.cpp @@ -1,3 +1,5 @@ +// $Id: SPIPE_Addr.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/SPIPE_Addr.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" @@ -22,12 +24,14 @@ ACE_SPIPE_Addr::dump (void) const // Set a pointer to the address. void -ACE_SPIPE_Addr::set_addr (const void *addr, int len) +ACE_SPIPE_Addr::set_addr (void *addr, int len) { ACE_TRACE ("ACE_SPIPE_Addr::set_addr"); this->ACE_Addr::base_set (AF_SPIPE, len); - ACE_OS::memcpy (&this->SPIPE_addr_, addr, len); + ACE_OS::memcpy ((void *) &this->SPIPE_addr_, + (void *) addr, + len); } // Return the address. diff --git a/dep/acelite/ace/SPIPE_Addr.h b/dep/acelite/ace/SPIPE_Addr.h index 11d2e6a9c..100d93b96 100644 --- a/dep/acelite/ace/SPIPE_Addr.h +++ b/dep/acelite/ace/SPIPE_Addr.h @@ -4,7 +4,9 @@ /** * @file SPIPE_Addr.h * - * @author Douglas C. Schmidt + * $Id: SPIPE_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -55,7 +57,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the underlying network address. - virtual void set_addr (const void *addr, int len); + virtual void set_addr (void *addr, int len); /// Transform the current address into string format. virtual int addr_to_string (ACE_TCHAR *addr, size_t) const; diff --git a/dep/acelite/ace/SPIPE_Addr.inl b/dep/acelite/ace/SPIPE_Addr.inl index b92aed809..a20e0e86f 100644 --- a/dep/acelite/ace/SPIPE_Addr.inl +++ b/dep/acelite/ace/SPIPE_Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SPIPE_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/SString.h" diff --git a/dep/acelite/ace/SPIPE_Connector.cpp b/dep/acelite/ace/SPIPE_Connector.cpp index 3b29e4fcb..af0ee6094 100644 --- a/dep/acelite/ace/SPIPE_Connector.cpp +++ b/dep/acelite/ace/SPIPE_Connector.cpp @@ -1,12 +1,11 @@ +// $Id: SPIPE_Connector.cpp 97308 2013-09-01 00:58:08Z mesnier_p $ + #include "ace/SPIPE_Connector.h" #include "ace/Handle_Ops.h" #include "ace/Log_Category.h" #include "ace/OS_NS_sys_time.h" #include "ace/OS_NS_fcntl.h" #include "ace/OS_NS_unistd.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SPIPE_Connector.inl" diff --git a/dep/acelite/ace/SPIPE_Connector.h b/dep/acelite/ace/SPIPE_Connector.h index 681221d74..89b9199d5 100644 --- a/dep/acelite/ace/SPIPE_Connector.h +++ b/dep/acelite/ace/SPIPE_Connector.h @@ -4,7 +4,9 @@ /** * @file SPIPE_Connector.h * - * @author Doug Schmidt + * $Id: SPIPE_Connector.h 82723 2008-09-16 09:35:44Z johnnyw $ + * + * @author Doug Schmidt * @author Prashant Jain */ //============================================================================= diff --git a/dep/acelite/ace/SPIPE_Connector.inl b/dep/acelite/ace/SPIPE_Connector.inl index e31bf17a2..46fdcbd42 100644 --- a/dep/acelite/ace/SPIPE_Connector.inl +++ b/dep/acelite/ace/SPIPE_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SPIPE_Connector.inl 82723 2008-09-16 09:35:44Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE bool diff --git a/dep/acelite/ace/SPIPE_Stream.cpp b/dep/acelite/ace/SPIPE_Stream.cpp index c9374c19b..67bc34e4b 100644 --- a/dep/acelite/ace/SPIPE_Stream.cpp +++ b/dep/acelite/ace/SPIPE_Stream.cpp @@ -1,3 +1,5 @@ +// $Id: SPIPE_Stream.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/SPIPE_Stream.h" #include "ace/OS_Memory.h" @@ -5,9 +7,6 @@ #include "ace/SPIPE_Stream.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -34,7 +33,6 @@ ACE_SPIPE_Stream::ACE_SPIPE_Stream (void) // the *total* number of trailing arguments, *not* a couple of the // number of tuple pairs! -#ifndef ACE_LACKS_VA_FUNCTIONS ssize_t ACE_SPIPE_Stream::send (size_t n, ...) const { @@ -45,16 +43,9 @@ ACE_SPIPE_Stream::send (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -67,11 +58,7 @@ ACE_SPIPE_Stream::send (size_t n, ...) const ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; @@ -93,16 +80,9 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_ALLOCATOR_RETURN (iovp, (iovec *) - ACE_Allocator::instance ()->malloc (total_tuples * - sizeof (iovec)), - -1); -# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -115,15 +95,10 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) -# ifdef ACE_HAS_ALLOC_HOOKS - ACE_Allocator::instance ()->free (iovp); -# else delete [] iovp; -# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; } -#endif // ACE_LACKS_VA_FUNCTIONS ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SPIPE_Stream.h b/dep/acelite/ace/SPIPE_Stream.h index af3476b8a..573573161 100644 --- a/dep/acelite/ace/SPIPE_Stream.h +++ b/dep/acelite/ace/SPIPE_Stream.h @@ -4,7 +4,9 @@ /** * @file SPIPE_Stream.h * - * @author Douglas C. Schmidt + * $Id: SPIPE_Stream.h 84480 2009-02-16 18:58:16Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -110,7 +112,6 @@ public: /// Recv iovecs via the OS "scatter-read" operation. ssize_t recv (iovec iov[], int len) const; -#ifndef ACE_LACKS_VA_FUNCTIONS /** * Send N char *ptrs and int lengths. Note that the char *'s * precede the ints (basically, an varargs version of writev). The @@ -127,7 +128,6 @@ public: * number of tuple pairs! */ ssize_t recv (size_t len, ...) const; -#endif /// Send @a len bytes via Win32 using overlapped I/O. ssize_t send (const void *buf, size_t len, ACE_OVERLAPPED *overlapped) const; diff --git a/dep/acelite/ace/SPIPE_Stream.inl b/dep/acelite/ace/SPIPE_Stream.inl index 08b9071b2..0aa532690 100644 --- a/dep/acelite/ace/SPIPE_Stream.inl +++ b/dep/acelite/ace/SPIPE_Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SPIPE_Stream.inl 93061 2011-01-12 21:06:07Z wotte $ + #include "ace/OS_NS_sys_uio.h" #include "ace/OS_NS_errno.h" #include "ace/OS_NS_unistd.h" diff --git a/dep/acelite/ace/SString.cpp b/dep/acelite/ace/SString.cpp index 1d678159c..db66850fd 100644 --- a/dep/acelite/ace/SString.cpp +++ b/dep/acelite/ace/SString.cpp @@ -1,6 +1,9 @@ +// $Id: SString.cpp 92580 2010-11-15 09:48:02Z johnnyw $ + #include "ace/Malloc_T.h" #include "ace/OS_Memory.h" #include "ace/SString.h" +#include "ace/Auto_Ptr.h" #include "ace/OS_NS_string.h" #include "ace/Numeric_Limits.h" @@ -62,15 +65,9 @@ ACE_NS_WString::char_rep (void) const { char *t = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (t, - static_cast(ACE_Allocator::instance()->malloc (sizeof (char) * (this->len_ + 1))), - 0); -#else ACE_NEW_RETURN (t, char[this->len_ + 1], 0); -#endif for (size_type i = 0; i < this->len_; ++i) // Note that this cast may lose data if wide chars are @@ -92,15 +89,9 @@ ACE_NS_WString::ushort_rep (void) const { ACE_UINT16 *t = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (t, - static_cast (ACE_Allocator::instance()->malloc(sizeof(ACE_UINT16) * (this->len_ + 1))), - 0); -#else ACE_NEW_RETURN (t, ACE_UINT16[this->len_ + 1], 0); -#endif for (size_type i = 0; i < this->len_; ++i) // Note that this cast may lose data if wide chars are diff --git a/dep/acelite/ace/SString.h b/dep/acelite/ace/SString.h index a9cb4f0ef..3c5f9957b 100644 --- a/dep/acelite/ace/SString.h +++ b/dep/acelite/ace/SString.h @@ -4,7 +4,9 @@ /** * @file SString.h * - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) + * $Id: SString.h 92580 2010-11-15 09:48:02Z johnnyw $ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) */ //============================================================================= @@ -156,11 +158,11 @@ public: /// Default destructor. ~ACE_SString (void); - /// Return the slot'th character in the string (doesn't perform + /// Return the character in the string (doesn't perform /// bounds checking). char operator [] (size_type slot) const; - /// Return the slot'th character by reference in the string + /// Return the character by reference in the string /// (doesn't perform bounds checking). char &operator [] (size_type slot); @@ -204,7 +206,7 @@ public: /// location that matches (will be >= pos), else npos. size_type find (const ACE_SString &str, size_type pos = 0) const; - /// Find @a s starting at pos. Returns the slot of the first + /// Find starting at pos. Returns the slot of the first /// location that matches (will be >= pos), else npos. size_type find (const char *s, size_type pos = 0) const; diff --git a/dep/acelite/ace/SString.inl b/dep/acelite/ace/SString.inl index c5685c090..2e4957e23 100644 --- a/dep/acelite/ace/SString.inl +++ b/dep/acelite/ace/SString.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SString.inl 80826 2008-03-04 14:51:23Z wotte $ + // Include ACE.h only if it hasn't already been included, e.g., if // ACE_TEMPLATES_REQUIRE_SOURCE, ACE.h won't have been pulled in by // String_Base.cpp. @@ -246,11 +249,7 @@ ACE_Auto_String_Free::ACE_Auto_String_Free (ACE_Auto_String_Free& rhs) ACE_INLINE void ACE_Auto_String_Free::reset (char* p) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (this->p_); -#else ACE_OS::free (this->p_); -#endif /* ACE_HAS_ALLOC_HOOKS */ this->p_ = p; } diff --git a/dep/acelite/ace/SStringfwd.h b/dep/acelite/ace/SStringfwd.h index 95aa9591c..50f30f69c 100644 --- a/dep/acelite/ace/SStringfwd.h +++ b/dep/acelite/ace/SStringfwd.h @@ -4,9 +4,11 @@ /** * @file SStringfwd.h * + * $Id: SStringfwd.h 88793 2010-02-01 17:50:34Z cleeland $ + * * Forward declarations and typedefs of ACE string types. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Nanbor Wang * @author Ossama Othman */ diff --git a/dep/acelite/ace/SUN_Proactor.cpp b/dep/acelite/ace/SUN_Proactor.cpp index d9b3ba7b0..ca4f928eb 100644 --- a/dep/acelite/ace/SUN_Proactor.cpp +++ b/dep/acelite/ace/SUN_Proactor.cpp @@ -1,3 +1,5 @@ +// $Id: SUN_Proactor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SUN_Proactor.h" #if defined (ACE_HAS_AIO_CALLS) && defined (sun) diff --git a/dep/acelite/ace/SUN_Proactor.h b/dep/acelite/ace/SUN_Proactor.h index 2d68fccf3..496616279 100644 --- a/dep/acelite/ace/SUN_Proactor.h +++ b/dep/acelite/ace/SUN_Proactor.h @@ -4,6 +4,8 @@ /** * @file SUN_Proactor.h * + * $Id: SUN_Proactor.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Alexander Libman */ //============================================================================= diff --git a/dep/acelite/ace/SV_Message.cpp b/dep/acelite/ace/SV_Message.cpp index 0e22199f2..4757c03d6 100644 --- a/dep/acelite/ace/SV_Message.cpp +++ b/dep/acelite/ace/SV_Message.cpp @@ -1,9 +1,7 @@ // SV_Message.cpp -#include "ace/SV_Message.h" +// $Id: SV_Message.cpp 91286 2010-08-05 09:04:31Z johnnyw $ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ +#include "ace/SV_Message.h" #if !defined (__ACE_INLINE__) #include "ace/SV_Message.inl" diff --git a/dep/acelite/ace/SV_Message.h b/dep/acelite/ace/SV_Message.h index 3ad09a1cc..395d35834 100644 --- a/dep/acelite/ace/SV_Message.h +++ b/dep/acelite/ace/SV_Message.h @@ -4,6 +4,8 @@ /** * @file SV_Message.h * + * $Id: SV_Message.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/SV_Message.inl b/dep/acelite/ace/SV_Message.inl index ef4265ba6..4f43c170a 100644 --- a/dep/acelite/ace/SV_Message.inl +++ b/dep/acelite/ace/SV_Message.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SV_Message.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Global_Macros.h" #include "ace/config-all.h" diff --git a/dep/acelite/ace/SV_Message_Queue.cpp b/dep/acelite/ace/SV_Message_Queue.cpp index a57be50fb..15410170e 100644 --- a/dep/acelite/ace/SV_Message_Queue.cpp +++ b/dep/acelite/ace/SV_Message_Queue.cpp @@ -1,8 +1,7 @@ +// $Id: SV_Message_Queue.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SV_Message_Queue.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SV_Message_Queue.inl" diff --git a/dep/acelite/ace/SV_Message_Queue.h b/dep/acelite/ace/SV_Message_Queue.h index 96e64944a..3698ca90d 100644 --- a/dep/acelite/ace/SV_Message_Queue.h +++ b/dep/acelite/ace/SV_Message_Queue.h @@ -4,7 +4,9 @@ /** * @file SV_Message_Queue.h * - * @author Douglas C. Schmidt + * $Id: SV_Message_Queue.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //=========================================================================== diff --git a/dep/acelite/ace/SV_Message_Queue.inl b/dep/acelite/ace/SV_Message_Queue.inl index f1355d51c..507fed9f5 100644 --- a/dep/acelite/ace/SV_Message_Queue.inl +++ b/dep/acelite/ace/SV_Message_Queue.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SV_Message_Queue.inl 96483 2012-12-09 14:38:45Z johnnyw $ + #include "ace/Global_Macros.h" #include "ace/OS_NS_sys_msg.h" diff --git a/dep/acelite/ace/SV_Semaphore_Complex.cpp b/dep/acelite/ace/SV_Semaphore_Complex.cpp index aa1a590bb..6127a3a42 100644 --- a/dep/acelite/ace/SV_Semaphore_Complex.cpp +++ b/dep/acelite/ace/SV_Semaphore_Complex.cpp @@ -1,9 +1,8 @@ +// $Id: SV_Semaphore_Complex.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SV_Semaphore_Complex.h" #include "ace/Log_Category.h" #include "ace/OS_NS_Thread.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SV_Semaphore_Complex.inl" @@ -69,10 +68,8 @@ ACE_SV_Semaphore_Complex::open (key_t k, mode_t perms) { ACE_TRACE ("ACE_SV_Semaphore_Complex::open"); -#ifdef ACE_HAS_SYSV_IPC if (k == IPC_PRIVATE) return -1; -#endif this->key_ = k; @@ -121,11 +118,7 @@ ACE_SV_Semaphore_Complex::open (key_t k, int semval = ACE_SV_Semaphore_Simple::control (GETVAL, 0, 1); if (semval == -1) -#ifdef ACE_HAS_SYSV_IPC return this->init (); -#else - return -1; -#endif else if (semval == 0) { // We should initialize by doing a SETALL, but that would @@ -157,11 +150,7 @@ ACE_SV_Semaphore_Complex::open (key_t k, // Decrement the process counter. We don't need a lock to do this. if (ACE_OS::semop (this->internal_id_, &ACE_SV_Semaphore_Complex::op_open_[0], 1) < 0) -#ifdef ACE_HAS_SYSV_IPC return this->init (); -#else - return -1; -#endif return 0; } } @@ -190,10 +179,8 @@ ACE_SV_Semaphore_Complex::close (void) ACE_TRACE ("ACE_SV_Semaphore_Complex::close"); int semval; -#ifdef ACE_HAS_SYSV_IPC if (this->key_ == (key_t) - 1 || this->internal_id_ == -1) return -1; -#endif // The following semop() first gets a lock on the ACE_SV_Semaphore, // then increments [1] - the process number. @@ -218,9 +205,7 @@ ACE_SV_Semaphore_Complex::close (void) { int result = ACE_OS::semop (this->internal_id_, &ACE_SV_Semaphore_Complex::op_unlock_[0], 1); -#ifdef ACE_HAS_SYSV_IPC this->init (); -#endif return result; } } @@ -244,14 +229,12 @@ ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex (const char *name, { ACE_TRACE ("ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex"); - key_t key = ACE_DEFAULT_SEM_KEY; + key_t key; -#ifdef ACE_HAS_SYSV_IPC - if (name != 0) + if (name == 0) + key = ACE_DEFAULT_SEM_KEY; + else key = this->name_2_key (name); -#else - ACE_UNUSED_ARG (name); -#endif if (this->open (key, flags, initial_value, nsems, perms) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SV_Semaphore_Complex"))); @@ -267,9 +250,7 @@ ACE_SV_Semaphore_Complex::~ACE_SV_Semaphore_Complex (void) ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex (void) { ACE_TRACE ("ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex"); -#ifdef ACE_HAS_SYSV_IPC this->init (); -#endif } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/SV_Semaphore_Complex.h b/dep/acelite/ace/SV_Semaphore_Complex.h index d8e3bc55f..01d613e38 100644 --- a/dep/acelite/ace/SV_Semaphore_Complex.h +++ b/dep/acelite/ace/SV_Semaphore_Complex.h @@ -4,7 +4,9 @@ /** * @file SV_Semaphore_Complex.h * - * @author Douglas C. Schmidt + * $Id: SV_Semaphore_Complex.h 97314 2013-09-03 13:11:59Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/SV_Semaphore_Complex.inl b/dep/acelite/ace/SV_Semaphore_Complex.inl index 184bd2d64..a1b6659fe 100644 --- a/dep/acelite/ace/SV_Semaphore_Complex.inl +++ b/dep/acelite/ace/SV_Semaphore_Complex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SV_Semaphore_Complex.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/SV_Semaphore_Simple.cpp b/dep/acelite/ace/SV_Semaphore_Simple.cpp index 593065ec6..f16ad96fa 100644 --- a/dep/acelite/ace/SV_Semaphore_Simple.cpp +++ b/dep/acelite/ace/SV_Semaphore_Simple.cpp @@ -1,10 +1,9 @@ +// $Id: SV_Semaphore_Simple.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SV_Semaphore_Simple.h" #include "ace/Log_Category.h" #include "ace/ACE.h" #include "ace/os_include/sys/os_sem.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SV_Semaphore_Simple.inl" @@ -42,7 +41,6 @@ ACE_SV_Semaphore_Simple::control (int cmd, } } -#ifdef ACE_HAS_SYSV_IPC int ACE_SV_Semaphore_Simple::init (key_t k, int i) { @@ -51,7 +49,6 @@ ACE_SV_Semaphore_Simple::init (key_t k, int i) this->internal_id_ = i; return 0; } -#endif // General ACE_SV_Semaphore operation. Increment or decrement by a // specific amount (positive or negative; amount can`t be zero). @@ -86,10 +83,8 @@ ACE_SV_Semaphore_Simple::open (key_t k, ACE_TRACE ("ACE_SV_Semaphore_Simple::open"); union semun ivalue; -#ifdef ACE_HAS_SYSV_IPC if (k == IPC_PRIVATE || k == static_cast (ACE_INVALID_SEM_KEY)) return -1; -#endif ivalue.val = initial_value; this->key_ = k; @@ -135,12 +130,7 @@ ACE_SV_Semaphore_Simple::name_2_key (const char *name) if (name == 0) { errno = EINVAL; -#ifdef ACE_HAS_SYSV_IPC return static_cast (ACE_INVALID_SEM_KEY); -#else - key_t ret = ACE_DEFAULT_SEM_KEY; - return ret; -#endif } // Basically "hash" the values in the . This won't @@ -151,14 +141,7 @@ ACE_SV_Semaphore_Simple::name_2_key (const char *name) # pragma warning(push) # pragma warning(disable : 4312) #endif /* defined (ACE_WIN32) && defined (_MSC_VER) */ - -#ifdef ACE_HAS_SYSV_IPC - return (key_t) ACE::crc32 (name); -#else - key_t ret = ACE_DEFAULT_SEM_KEY; - return ret; -#endif - + return (key_t)(intptr_t)ACE::crc32 (name); #if defined (ACE_WIN32) && defined (_MSC_VER) # pragma warning(pop) #endif /* defined (ACE_WIN32) && defined (_MSC_VER) */ @@ -176,14 +159,12 @@ ACE_SV_Semaphore_Simple::open (const char *name, { ACE_TRACE ("ACE_SV_Semaphore_Simple::open"); - key_t key = ACE_DEFAULT_SEM_KEY; + key_t key; -#ifdef ACE_HAS_SYSV_IPC - if (name != 0) + if (name == 0) + key = ACE_DEFAULT_SEM_KEY; + else key = this->name_2_key (name); -#else - ACE_UNUSED_ARG (name); -#endif return this->open (key, flags, initial_value, n, perms); } @@ -234,9 +215,7 @@ ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (void) : sem_number_ (0) { ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple"); -#ifdef ACE_HAS_SYSV_IPC this->init (); -#endif } // Remove all SV_Semaphores associated with a particular key. This @@ -250,9 +229,7 @@ ACE_SV_Semaphore_Simple::remove (void) const { ACE_TRACE ("ACE_SV_Semaphore_Simple::remove"); int const result = this->control (IPC_RMID); -#ifdef ACE_HAS_SYSV_IPC ((ACE_SV_Semaphore_Simple *) this)->init (); -#endif return result; } diff --git a/dep/acelite/ace/SV_Semaphore_Simple.h b/dep/acelite/ace/SV_Semaphore_Simple.h index 0c4f47fe1..799df8fae 100644 --- a/dep/acelite/ace/SV_Semaphore_Simple.h +++ b/dep/acelite/ace/SV_Semaphore_Simple.h @@ -4,7 +4,9 @@ /** * @file SV_Semaphore_Simple.h * - * @author Douglas C. Schmidt + * $Id: SV_Semaphore_Simple.h 97314 2013-09-03 13:11:59Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -170,7 +172,6 @@ protected: /// Number of semaphores we're creating. int sem_number_; -#ifdef ACE_HAS_SYSV_IPC /** * Convert name to key This function is used internally to create * keys for the semaphores. A valid name contains letters and @@ -182,8 +183,6 @@ protected: */ int init (key_t k = static_cast (ACE_INVALID_SEM_KEY), int i = -1); -#endif - key_t name_2_key (const char *name); }; diff --git a/dep/acelite/ace/SV_Semaphore_Simple.inl b/dep/acelite/ace/SV_Semaphore_Simple.inl index b8d0b7037..777e85fbf 100644 --- a/dep/acelite/ace/SV_Semaphore_Simple.inl +++ b/dep/acelite/ace/SV_Semaphore_Simple.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SV_Semaphore_Simple.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Global_Macros.h" #include "ace/OS_NS_Thread.h" @@ -40,11 +43,7 @@ ACE_INLINE int ACE_SV_Semaphore_Simple::close (void) { ACE_TRACE ("ACE_SV_Semaphore_Simple::close"); -#ifdef ACE_HAS_SYSV_IPC return this->init (); -#else - ACE_NOTSUP_RETURN (-1); -#endif } // General ACE_SV_Semaphore operation on an array of SV_Semaphores. diff --git a/dep/acelite/ace/SV_Shared_Memory.cpp b/dep/acelite/ace/SV_Shared_Memory.cpp index ef65d4976..6674d9a64 100644 --- a/dep/acelite/ace/SV_Shared_Memory.cpp +++ b/dep/acelite/ace/SV_Shared_Memory.cpp @@ -1,8 +1,7 @@ +// $Id: SV_Shared_Memory.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/SV_Shared_Memory.h" #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/SV_Shared_Memory.inl" diff --git a/dep/acelite/ace/SV_Shared_Memory.h b/dep/acelite/ace/SV_Shared_Memory.h index 78387e1c9..fb34f286b 100644 --- a/dep/acelite/ace/SV_Shared_Memory.h +++ b/dep/acelite/ace/SV_Shared_Memory.h @@ -4,7 +4,9 @@ /** * @file SV_Shared_Memory.h * - * @author Douglas C. Schmidt + * $Id: SV_Shared_Memory.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/SV_Shared_Memory.inl b/dep/acelite/ace/SV_Shared_Memory.inl index 19235c3ff..e6a61948d 100644 --- a/dep/acelite/ace/SV_Shared_Memory.inl +++ b/dep/acelite/ace/SV_Shared_Memory.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: SV_Shared_Memory.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_sys_shm.h" #include "ace/Global_Macros.h" #include "ace/OS_NS_errno.h" diff --git a/dep/acelite/ace/Sample_History.cpp b/dep/acelite/ace/Sample_History.cpp index 7cebff07e..d0acac482 100644 --- a/dep/acelite/ace/Sample_History.cpp +++ b/dep/acelite/ace/Sample_History.cpp @@ -1,3 +1,5 @@ +// $Id: Sample_History.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Sample_History.h" #if !defined (__ACE_INLINE__) @@ -8,30 +10,18 @@ #include "ace/Log_Category.h" #include "ace/OS_Memory.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Sample_History::ACE_Sample_History (size_t max_samples) : max_samples_ (max_samples) , sample_count_ (0) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR(this->samples_, static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_UINT64) * this->max_samples_))); -#else ACE_NEW(this->samples_, ACE_UINT64[this->max_samples_]); -#endif /* ACE_HAS_ALLOC_HOOKS */ } ACE_Sample_History::~ACE_Sample_History (void) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(this->samples_); -#else delete[] this->samples_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } void diff --git a/dep/acelite/ace/Sample_History.h b/dep/acelite/ace/Sample_History.h index 9a6bcb193..c31c56923 100644 --- a/dep/acelite/ace/Sample_History.h +++ b/dep/acelite/ace/Sample_History.h @@ -4,6 +4,8 @@ /** * @file Sample_History.h * + * $Id: Sample_History.h 95747 2012-05-13 17:14:12Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/Sample_History.inl b/dep/acelite/ace/Sample_History.inl index 305c861ff..8d7d7c9b5 100644 --- a/dep/acelite/ace/Sample_History.inl +++ b/dep/acelite/ace/Sample_History.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Sample_History.inl 95747 2012-05-13 17:14:12Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/Sbrk_Memory_Pool.cpp b/dep/acelite/ace/Sbrk_Memory_Pool.cpp index 45dd167ac..d0653b175 100644 --- a/dep/acelite/ace/Sbrk_Memory_Pool.cpp +++ b/dep/acelite/ace/Sbrk_Memory_Pool.cpp @@ -1,7 +1,9 @@ +// $Id: Sbrk_Memory_Pool.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/OS_NS_unistd.h" #include "ace/Sbrk_Memory_Pool.h" #include "ace/Log_Category.h" -#include "ace/Malloc_Base.h" + #if !defined (ACE_LACKS_SBRK) diff --git a/dep/acelite/ace/Sbrk_Memory_Pool.h b/dep/acelite/ace/Sbrk_Memory_Pool.h index ea435b11d..501994860 100644 --- a/dep/acelite/ace/Sbrk_Memory_Pool.h +++ b/dep/acelite/ace/Sbrk_Memory_Pool.h @@ -4,7 +4,9 @@ /** * @file Sbrk_Memory_Pool.h * - * @author Dougls C. Schmidt + * $Id: Sbrk_Memory_Pool.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Dougls C. Schmidt * @author Prashant Jain */ //============================================================================= diff --git a/dep/acelite/ace/Sched_Params.cpp b/dep/acelite/ace/Sched_Params.cpp index f9eb92d7c..8aee95bfc 100644 --- a/dep/acelite/ace/Sched_Params.cpp +++ b/dep/acelite/ace/Sched_Params.cpp @@ -3,6 +3,8 @@ /** * @file Sched_Params.cpp * + * $Id: Sched_Params.cpp 95761 2012-05-15 18:23:04Z johnnyw $ + * * @author David Levine */ //============================================================================= diff --git a/dep/acelite/ace/Sched_Params.h b/dep/acelite/ace/Sched_Params.h index c355fefc8..6bde2ddeb 100644 --- a/dep/acelite/ace/Sched_Params.h +++ b/dep/acelite/ace/Sched_Params.h @@ -4,6 +4,8 @@ /** * @file Sched_Params.h * + * $Id: Sched_Params.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author David Levine * @author Carlos O'Ryan */ diff --git a/dep/acelite/ace/Sched_Params.inl b/dep/acelite/ace/Sched_Params.inl index 5392611ac..73803ac17 100644 --- a/dep/acelite/ace/Sched_Params.inl +++ b/dep/acelite/ace/Sched_Params.inl @@ -4,6 +4,8 @@ /** * @file Sched_Params.inl * + * $Id: Sched_Params.inl 80826 2008-03-04 14:51:23Z wotte $ + * * @author David Levine */ //============================================================================= diff --git a/dep/acelite/ace/Select_Reactor.h b/dep/acelite/ace/Select_Reactor.h index 312b17c78..2dd96f349 100644 --- a/dep/acelite/ace/Select_Reactor.h +++ b/dep/acelite/ace/Select_Reactor.h @@ -4,7 +4,9 @@ /** * @file Select_Reactor.h * - * @author Douglas C. Schmidt + * $Id: Select_Reactor.h 91626 2010-09-07 10:59:20Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Select_Reactor_Base.cpp b/dep/acelite/ace/Select_Reactor_Base.cpp index f5d5252de..15f2f95e5 100644 --- a/dep/acelite/ace/Select_Reactor_Base.cpp +++ b/dep/acelite/ace/Select_Reactor_Base.cpp @@ -1,3 +1,5 @@ +// $Id: Select_Reactor_Base.cpp 97798 2014-07-03 10:57:43Z johnnyw $ + #include "ace/Select_Reactor_Base.h" #include "ace/Reactor.h" #include "ace/Thread.h" @@ -18,10 +20,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Notify) -ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Handler_Repository) -ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Handler_Repository_Iterator) - template inline ACE_Event_Handler * ACE_SELECT_REACTOR_EVENT_HANDLER (iterator i) @@ -529,6 +527,8 @@ ACE_Select_Reactor_Handler_Repository::dump (void) const #endif /* ACE_HAS_DUMP */ } +ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Handler_Repository_Iterator) + ACE_Select_Reactor_Notify::ACE_Select_Reactor_Notify (void) : select_reactor_ (0) , max_notify_iterations_ (-1) @@ -610,16 +610,9 @@ ACE_Select_Reactor_Notify::open (ACE_Reactor_Impl *r, if (this->notification_pipe_.open () == -1) return -1; -#if defined (F_SETFD) && !defined (ACE_LACKS_FCNTL) - if (ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1) == -1) - { - return -1; - } - - if (ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1) == -1) - { - return -1; - } +#if defined (F_SETFD) + ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1); + ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1); #endif /* F_SETFD */ #if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) @@ -627,13 +620,6 @@ ACE_Select_Reactor_Notify::open (ACE_Reactor_Impl *r, { return -1; } - -# if defined (ACE_LACKS_LISTEN) && defined (ACE_LACKS_SOCKETPAIR) \ - && !defined (ACE_HAS_STREAM_PIPES) - if (ACE::set_flags (this->notification_pipe_.write_handle (), - ACE_NONBLOCK) == -1) - return -1; -# endif #endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ // There seems to be a Win32 bug with this... Set this into diff --git a/dep/acelite/ace/Select_Reactor_Base.h b/dep/acelite/ace/Select_Reactor_Base.h index 54f3f45f2..851fea0d6 100644 --- a/dep/acelite/ace/Select_Reactor_Base.h +++ b/dep/acelite/ace/Select_Reactor_Base.h @@ -4,7 +4,9 @@ /** * @file Select_Reactor_Base.h * - * @author Douglas C. Schmidt + * $Id: Select_Reactor_Base.h 93792 2011-04-07 11:48:50Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Select_Reactor_Base.inl b/dep/acelite/ace/Select_Reactor_Base.inl index 3993e9ff7..d91492b37 100644 --- a/dep/acelite/ace/Select_Reactor_Base.inl +++ b/dep/acelite/ace/Select_Reactor_Base.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Select_Reactor_Base.inl 81138 2008-03-28 09:18:15Z johnnyw $ + #include "ace/Reactor.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Select_Reactor_T.cpp b/dep/acelite/ace/Select_Reactor_T.cpp index fbe182efe..d1e4d4ac1 100644 --- a/dep/acelite/ace/Select_Reactor_T.cpp +++ b/dep/acelite/ace/Select_Reactor_T.cpp @@ -1,3 +1,5 @@ +// $Id: Select_Reactor_T.cpp 97894 2014-09-16 18:11:56Z johnnyw $ + #ifndef ACE_SELECT_REACTOR_T_CPP #define ACE_SELECT_REACTOR_T_CPP @@ -32,7 +34,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Select_Reactor_T) +ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_T) template int ACE_Select_Reactor_T::any_ready @@ -1364,7 +1366,7 @@ ACE_Select_Reactor_T::dispatch (dispatch_set, active_handle_count, other_handlers_dispatched) == -1) - // State has changed or a serious failure has occurred, so exit + // State has changed or a serious failure has occured, so exit // loop. break; diff --git a/dep/acelite/ace/Select_Reactor_T.h b/dep/acelite/ace/Select_Reactor_T.h index 76bbbeebd..a9737c1e8 100644 --- a/dep/acelite/ace/Select_Reactor_T.h +++ b/dep/acelite/ace/Select_Reactor_T.h @@ -4,7 +4,9 @@ /** * @file Select_Reactor_T.h * - * @author Douglas C. Schmidt + * $Id: Select_Reactor_T.h 93359 2011-02-11 11:33:12Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -220,6 +222,7 @@ public: ACE_Reactor_Mask mask); #if defined (ACE_WIN32) + // Originally this interface was available for all platforms, but // because ACE_HANDLE is an int on non-Win32 platforms, compilers // are not able to tell the difference between @@ -230,6 +233,7 @@ public: /// Not implemented. virtual int register_handler (ACE_Event_Handler *event_handler, ACE_HANDLE event_handle = ACE_INVALID_HANDLE); + #endif /* ACE_WIN32 */ /// Not implemented. @@ -430,9 +434,9 @@ public: /** * Set the maximum number of times that the - * ACE_Select_Reactor_Notify::handle_input() method will iterate and + * method will iterate and * dispatch the ACE_Event_Handlers that are passed in via the - * notify pipe before breaking out of its recv loop. By default, + * notify pipe before breaking out of its loop. By default, * this is set to -1, which means "iterate until the pipe is empty." * Setting this to a value like "1 or 2" will increase "fairness" * (and thus prevent starvation) at the expense of slightly higher @@ -442,9 +446,9 @@ public: /** * Get the maximum number of times that the - * ACE_Select_Reactor_Notify::handle_input() method will iterate and + * method will iterate and * dispatch the ACE_Event_Handlers that are passed in via the - * notify pipe before breaking out of its recv loop. + * notify pipe before breaking out of its loop. */ virtual int max_notify_iterations (void); diff --git a/dep/acelite/ace/Select_Reactor_T.inl b/dep/acelite/ace/Select_Reactor_T.inl index 7200933a4..54542427f 100644 --- a/dep/acelite/ace/Select_Reactor_T.inl +++ b/dep/acelite/ace/Select_Reactor_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Select_Reactor_T.inl 96017 2012-08-08 22:18:09Z mitza $ + #include "ace/Reactor.h" #include "ace/Signal.h" #include "ace/Sig_Handler.h" @@ -70,6 +73,7 @@ ACE_Select_Reactor_T::register_handler (int signum, } #if defined (ACE_WIN32) + template ACE_INLINE int ACE_Select_Reactor_T::register_handler (ACE_Event_Handler *, @@ -78,6 +82,7 @@ ACE_Select_Reactor_T::register_handler (ACE_Event_Hand // Don't have an implementation for this yet... ACE_NOTSUP_RETURN (-1); } + #endif /* ACE_WIN32 */ template diff --git a/dep/acelite/ace/Semaphore.cpp b/dep/acelite/ace/Semaphore.cpp index dcbac24fc..dc533ee0b 100644 --- a/dep/acelite/ace/Semaphore.cpp +++ b/dep/acelite/ace/Semaphore.cpp @@ -1,3 +1,5 @@ +// $Id: Semaphore.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Semaphore.h" #if !defined (__ACE_INLINE__) @@ -6,9 +8,6 @@ #include "ace/Log_Category.h" #include "ace/ACE.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Semaphore.h b/dep/acelite/ace/Semaphore.h index a94afc3fc..7c4936abf 100644 --- a/dep/acelite/ace/Semaphore.h +++ b/dep/acelite/ace/Semaphore.h @@ -4,9 +4,11 @@ /** * @file Semaphore.h * + * $Id: Semaphore.h 81014 2008-03-19 11:41:31Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Semaphore.inl b/dep/acelite/ace/Semaphore.inl index 8de0beef3..e0162dc24 100644 --- a/dep/acelite/ace/Semaphore.inl +++ b/dep/acelite/ace/Semaphore.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Semaphore.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const ACE_sema_t & diff --git a/dep/acelite/ace/Service_Config.cpp b/dep/acelite/ace/Service_Config.cpp index 193e54ab8..cc2cd7c55 100644 --- a/dep/acelite/ace/Service_Config.cpp +++ b/dep/acelite/ace/Service_Config.cpp @@ -1,3 +1,5 @@ +// $Id: Service_Config.cpp 97326 2013-09-11 07:52:09Z johnnyw $ + #include "ace/Service_Config.h" #if !defined (__ACE_INLINE__) @@ -22,9 +24,6 @@ #include "ace/Log_Category.h" #include "ace/ACE.h" -#ifdef ACE_HAS_TSS_EMULATION -#include "ace/Object_Manager.h" -#endif ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -109,7 +108,7 @@ ACE_Service_Config_Guard::ACE_Service_Config_Guard (ACE_Service_Gestalt * psg) if (ACE::debug ()) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) - SCG:") - ACE_TEXT (" - config=%@ repo=%@ superseded by repo=%@\n"), + ACE_TEXT (" - config=%@ repo=%@ superceded by repo=%@\n"), this, this->saved_.get (), this->saved_->repo_, @@ -539,12 +538,11 @@ ACE_Service_Config::reconfigure (void) { #if !defined (ACE_NLOGGING) time_t t = ACE_OS::time (0); - +#endif /* ! ACE_NLOGGING */ if (ACE::debug ()) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("beginning reconfiguration at %s"), ACE_OS::ctime (&t))); -#endif /* ! ACE_NLOGGING */ } if (ACE_Service_Config::process_directives () == -1) ACELIB_ERROR ((LM_ERROR, diff --git a/dep/acelite/ace/Service_Config.h b/dep/acelite/ace/Service_Config.h index 3076a3bb5..f4969144a 100644 --- a/dep/acelite/ace/Service_Config.h +++ b/dep/acelite/ace/Service_Config.h @@ -4,7 +4,9 @@ /** * @file Service_Config.h * - * @author Douglas C. Schmidt + * $Id: Service_Config.h 96605 2013-01-02 19:33:30Z tgirard $ + * + * @author Douglas C. Schmidt */ //==================================================================== @@ -252,19 +254,19 @@ public: * The ACE_Service_Config uses the Monostate pattern. Therefore, * you can only have one of these instantiated per-process. It * represents the process-wide collection of services, which is - * typically shared among all other configurable entities. The only + * typicaly shared among all other configurable entities. The only * ACE_Service_Config instance is registered with and owned by the * ACE_Object_Manager. * * By contrast, the ACE_Service_Gestalt represents the collection - * of services, pertaining to a configurable entity. Typically, a + * of services, pertaining to a configurable entity. Typicaly, a * "configurable entity" is an instance, which owns an instance of - * ACE_Service_Gestalt in order to ensure full control over the + * ACE_Service_Gestalt in order to ensure full controll over the * services it needs. * * Another facet of ACE_Service_Config is that for a given thread, * it provides access to its current, process-global - * ACE_Service_Gestalt instance through its current() method. + * ACE_Service_Gestalt instance through its curent() method. * * @note The signal_handler_ static member is allocated by the * ACE_Object_Manager. The ACE_Service_Config constructor @@ -716,7 +718,7 @@ private: * @brief A guard class, designed to be instantiated on the stack. * * Instantiating it with a specific configuration ensures any references to - * ACE_Service_Config::instance(), even when occurring in static constructors, + * ACE_Service_Config::instance(), even when occuring in static constructors, * will allways access the designated configuration instance. * This comes very handy when a dynamic service also registers any static * services of its own and their static factories. diff --git a/dep/acelite/ace/Service_Config.inl b/dep/acelite/ace/Service_Config.inl index 5cffe4344..78e11bcfe 100644 --- a/dep/acelite/ace/Service_Config.inl +++ b/dep/acelite/ace/Service_Config.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Service_Config.inl 91813 2010-09-17 07:52:52Z johnnyw $ + #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Service_Gestalt.cpp b/dep/acelite/ace/Service_Gestalt.cpp index 6bc653bf2..496533e76 100644 --- a/dep/acelite/ace/Service_Gestalt.cpp +++ b/dep/acelite/ace/Service_Gestalt.cpp @@ -1,3 +1,5 @@ +// $Id: Service_Gestalt.cpp 97798 2014-07-03 10:57:43Z johnnyw $ + #include "ace/Svc_Conf.h" #include "ace/Get_Opt.h" #include "ace/ARGV.h" @@ -132,25 +134,15 @@ Processed_Static_Svc (const ACE_Static_Svc_Descriptor *assd) :name_(0), assd_(assd) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_NORETURN (name_, static_cast(ACE_Allocator::instance()->malloc (sizeof(ACE_TCHAR) * (ACE_OS::strlen(assd->name_)+1)))); -#else ACE_NEW_NORETURN (name_, ACE_TCHAR[ACE_OS::strlen(assd->name_)+1]); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::strcpy(name_,assd->name_); } ACE_Service_Gestalt::Processed_Static_Svc::~Processed_Static_Svc (void) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(name_); -#else delete [] name_; -#endif /* ACE_HAS_ALLOC_HOOKS */ } -ACE_ALLOC_HOOK_DEFINE(ACE_Service_Gestalt::Processed_Static_Svc) - void ACE_Service_Gestalt::intrusive_add_ref (ACE_Service_Gestalt* g) { @@ -358,7 +350,7 @@ ACE_Service_Gestalt::add_processed_static_svc /// associates a service object with the Gestalt and makes the /// resource (a Service Object) local to the repository. This is but /// the first step in using such SO. The next is the - /// "initialization" step. It is typically done through a "static" + /// "initialization" step. It is typicaly done through a "static" /// service configuration directive. /// /// In contrast a "dynamic" directive, when processed through the @@ -789,6 +781,10 @@ ACE_Service_Gestalt::process_directives_i (ACE_Svc_Conf_Param *param) : param->source.directive)); #endif + // AC 970827 Skip the heap check because yacc allocates a buffer + // here which will be reported as a memory leak for some reason. + ACE_NO_HEAP_CHECK + // Were we called in the context of the current instance? ACE_ASSERT (this == param->config); diff --git a/dep/acelite/ace/Service_Gestalt.h b/dep/acelite/ace/Service_Gestalt.h index aae3b3981..1f2522a36 100644 --- a/dep/acelite/ace/Service_Gestalt.h +++ b/dep/acelite/ace/Service_Gestalt.h @@ -4,6 +4,8 @@ /** * @file Service_Gestalt.h * + * $Id: Service_Gestalt.h 91626 2010-09-07 10:59:20Z johnnyw $ + * * @author Iliyan Jeliazkov */ //==================================================================== @@ -20,6 +22,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Auto_Ptr.h" #include "ace/SString.h" #include "ace/Unbounded_Queue.h" #include "ace/Unbounded_Set.h" @@ -62,6 +65,7 @@ class ACE_Svc_Conf_Param; * may or may not be bounded by the lifetime of the gestalt, that owns * it. This feature is important for the derived classes and the * Service Config in particular. + * */ class ACE_Export ACE_Service_Gestalt : private ACE_Copy_Disabled { @@ -321,7 +325,6 @@ public: ~Processed_Static_Svc (void); ACE_TCHAR * name_; const ACE_Static_Svc_Descriptor *assd_; - ACE_ALLOC_HOOK_DECLARE; }; /// Get the current ACE_Service_Repository held by this object. diff --git a/dep/acelite/ace/Service_Gestalt.inl b/dep/acelite/ace/Service_Gestalt.inl index ec46b2706..436037b71 100644 --- a/dep/acelite/ace/Service_Gestalt.inl +++ b/dep/acelite/ace/Service_Gestalt.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Service_Gestalt.inl 91158 2010-07-21 15:54:12Z mesnier_p $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Service_Manager.cpp b/dep/acelite/ace/Service_Manager.cpp index 547648ea5..ba5a6ce99 100644 --- a/dep/acelite/ace/Service_Manager.cpp +++ b/dep/acelite/ace/Service_Manager.cpp @@ -1,3 +1,5 @@ +// $Id: Service_Manager.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Service_Manager.h" #include "ace/Get_Opt.h" @@ -78,11 +80,11 @@ ACE_Service_Manager::info (ACE_TCHAR **strp, size_t length) const return -1; } - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%d/%s %s"), - sa.get_port_number (), - ACE_TEXT ("tcp"), - ACE_TEXT ("# lists all services in the daemon\n")); + ACE_OS::sprintf (buf, + ACE_TEXT ("%d/%s %s"), + sa.get_port_number (), + ACE_TEXT ("tcp"), + ACE_TEXT ("# lists all services in the daemon\n")); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) { diff --git a/dep/acelite/ace/Service_Manager.h b/dep/acelite/ace/Service_Manager.h index 132853855..13ce60405 100644 --- a/dep/acelite/ace/Service_Manager.h +++ b/dep/acelite/ace/Service_Manager.h @@ -4,7 +4,9 @@ /** * @file Service_Manager.h * - * @author Douglas C. Schmidt + * $Id: Service_Manager.h 81388 2008-04-23 14:02:05Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -57,9 +59,6 @@ public: /// Destructor. virtual ~ACE_Service_Manager (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: // = Perform the various meta-services. @@ -83,6 +82,9 @@ protected: /// Dump the state of an object. void dump (void) const; + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + protected: int open (const ACE_INET_Addr &sia); diff --git a/dep/acelite/ace/Service_Object.cpp b/dep/acelite/ace/Service_Object.cpp index a16b9af04..b182e86c2 100644 --- a/dep/acelite/ace/Service_Object.cpp +++ b/dep/acelite/ace/Service_Object.cpp @@ -1,9 +1,8 @@ +// $Id: Service_Object.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/config-all.h" #include "ace/Service_Object.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/Service_Object.inl" @@ -30,11 +29,11 @@ ACE_Service_Type::dump (void) const ACE_TRACE ("ACE_Service_Type::dump"); #endif /* ACE_HAS_DUMP */ + // Using printf, since the log facility may not have been // initialized yet. Using a "//" prefix, in case the executable // happens to be a code generator and the output gets embedded in // the generated C++ code. -#ifndef ACE_LACKS_STDERR ACE_OS::fprintf(stderr, "// [ST] dump, this=%p, name=%s, type=%p, so=%p, active=%d\n", static_cast (this), @@ -42,7 +41,7 @@ ACE_Service_Type::dump (void) const static_cast (this->type_), (this->type_ != 0) ? this->type_->object () : 0, this->active_); -#endif + } ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n, @@ -78,11 +77,7 @@ ACE_Service_Type::~ACE_Service_Type (void) ACE_TRACE ("ACE_Service_Type::~ACE_Service_Type"); this->fini (); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (this->name_)); -#else delete [] const_cast (this->name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } int @@ -168,12 +163,7 @@ ACE_Service_Type::name (const ACE_TCHAR *n) { ACE_TRACE ("ACE_Service_Type::name"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (this->name_)); -#else delete [] const_cast (this->name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ - this->name_ = ACE::strnew (n); } diff --git a/dep/acelite/ace/Service_Object.h b/dep/acelite/ace/Service_Object.h index 37803f5f5..2f24ccbd4 100644 --- a/dep/acelite/ace/Service_Object.h +++ b/dep/acelite/ace/Service_Object.h @@ -4,7 +4,9 @@ /** * @file Service_Object.h * - * @author Douglas C. Schmidt + * $Id: Service_Object.h 84170 2009-01-15 13:31:50Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -56,9 +58,6 @@ public: /// Re-enable a previously suspended service. virtual int resume (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; }; // Forward decl. diff --git a/dep/acelite/ace/Service_Object.inl b/dep/acelite/ace/Service_Object.inl index e5c5099f0..6283f3e99 100644 --- a/dep/acelite/ace/Service_Object.inl +++ b/dep/acelite/ace/Service_Object.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Service_Object.inl 81388 2008-04-23 14:02:05Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Service_Object_Ptr::ACE_Service_Object_Ptr (ACE_Service_Object *so) diff --git a/dep/acelite/ace/Service_Repository.cpp b/dep/acelite/ace/Service_Repository.cpp index 6c5fb03df..022b14352 100644 --- a/dep/acelite/ace/Service_Repository.cpp +++ b/dep/acelite/ace/Service_Repository.cpp @@ -1,3 +1,5 @@ +// $Id: Service_Repository.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Service_Repository.h" #if !defined (__ACE_INLINE__) @@ -114,7 +116,7 @@ int ACE_Service_Repository::fini (void) { ACE_TRACE ("ACE_Service_Repository::fini"); - ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); int retval = 0; // Do not be tempted to use the prefix decrement operator. Use @@ -209,7 +211,7 @@ int ACE_Service_Repository::close (void) { ACE_TRACE ("ACE_Service_Repository::close"); - ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); #ifndef ACE_NLOGGING if(ACE::debug ()) @@ -384,7 +386,7 @@ ACE_Service_Repository::find (const ACE_TCHAR name[], bool ignore_suspended) const { ACE_TRACE ("ACE_Service_Repository::find"); - ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); size_t ignore_location = 0; return this->find_i (name, ignore_location, srp, ignore_suspended); } @@ -406,8 +408,10 @@ ACE_Service_Repository::insert (const ACE_Service_Type *sr) // storage { // @TODO: Do we need a recursive mutex here? - ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, - ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, + this->lock_, + -1)); return_value = find_i (sr->name (), i, &s, false); @@ -461,7 +465,7 @@ ACE_Service_Repository::resume (const ACE_TCHAR name[], const ACE_Service_Type **srp) { ACE_TRACE ("ACE_Service_Repository::resume"); - ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); size_t i = 0; if (-1 == this->find_i (name, i, srp, 0)) @@ -477,7 +481,7 @@ ACE_Service_Repository::suspend (const ACE_TCHAR name[], const ACE_Service_Type **srp) { ACE_TRACE ("ACE_Service_Repository::suspend"); - ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); size_t i = 0; if (-1 == this->find_i (name, i, srp, 0)) return -1; @@ -495,7 +499,7 @@ ACE_Service_Repository::remove (const ACE_TCHAR name[], ACE_Service_Type **ps) ACE_TRACE ("ACE_Service_Repository::remove"); ACE_Service_Type *s = 0; { - ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); // Not found!? if (this->remove_i (name, &s) == -1) diff --git a/dep/acelite/ace/Service_Repository.h b/dep/acelite/ace/Service_Repository.h index 8b3af28c1..9d03b1133 100644 --- a/dep/acelite/ace/Service_Repository.h +++ b/dep/acelite/ace/Service_Repository.h @@ -4,7 +4,9 @@ /** * @file Service_Repository.h * - * @author Douglas C. Schmidt + * $Id: Service_Repository.h 91016 2010-07-06 11:29:50Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -20,10 +22,8 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Default_Constants.h" -#include "ace/Synch_Traits.h" -#include "ace/Array_Map.h" -#include "ace/Malloc_Base.h" #include "ace/Recursive_Thread_Mutex.h" +#include "ace/Array_Map.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -132,9 +132,6 @@ public: /// Dump the state of an object. void dump (void) const; - /// Returns a reference to the lock used by the ACE_Service_Repository - ACE_SYNCH_RECURSIVE_MUTEX &lock (void) const; - /// Declare the dynamic allocation hooks. ACE_ALLOC_HOOK_DECLARE; @@ -190,11 +187,7 @@ protected: const ACE_DLL &adll); /// The typedef of the array used to store the services. -#if defined (ACE_HAS_ALLOC_HOOKS) - typedef ACE_Array_Map, ACE_Allocator_Std_Adapter > > array_type; -#else - typedef ACE_Array_Map array_type; -#endif /* ACE_HAS_ALLOC_HOOKS */ + typedef ACE_Array_Map array_type; /// Contains all the configured services. array_type service_array_; @@ -205,8 +198,10 @@ protected: /// Must delete the @c svc_rep_ if true. static bool delete_svc_rep_; - /// Synchronization variable for the ACE_Service_Repository. - mutable ACE_SYNCH_RECURSIVE_MUTEX lock_; +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Synchronization variable for the MT_SAFE Repository + mutable ACE_Recursive_Thread_Mutex lock_; +#endif /* ACE_MT_SAFE */ }; /** diff --git a/dep/acelite/ace/Service_Repository.inl b/dep/acelite/ace/Service_Repository.inl index 9cbd38821..1645f3803 100644 --- a/dep/acelite/ace/Service_Repository.inl +++ b/dep/acelite/ace/Service_Repository.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Service_Repository.inl 84170 2009-01-15 13:31:50Z johnnyw $ + // Returns a count of the number of currently valid entries (counting // both resumed and suspended entries). @@ -19,12 +22,6 @@ ACE_Service_Repository::current_size (void) const return this->service_array_.size (); } -ACE_INLINE ACE_SYNCH_RECURSIVE_MUTEX& -ACE_Service_Repository::lock (void) const -{ - return this->lock_; -} - ACE_INLINE int ACE_Service_Repository_Iterator::done (void) const { diff --git a/dep/acelite/ace/Service_Types.cpp b/dep/acelite/ace/Service_Types.cpp index 1d835685e..b743536b3 100644 --- a/dep/acelite/ace/Service_Types.cpp +++ b/dep/acelite/ace/Service_Types.cpp @@ -1,3 +1,5 @@ +// $Id: Service_Types.cpp 95676 2012-04-03 16:32:27Z schmidt $ + #include "ace/Service_Types.h" #if !defined (__ACE_INLINE__) @@ -46,11 +48,7 @@ ACE_Service_Type_Impl::~ACE_Service_Type_Impl (void) // It's ok to call this, even though we may have already deleted it // in the fini() method since it would then be NULL. -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (this->name_)); -#else delete [] const_cast (this->name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ } int @@ -58,11 +56,7 @@ ACE_Service_Type_Impl::fini (void) const { ACE_TRACE ("ACE_Service_Type_Impl::fini"); -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free(const_cast (this->name_)); -#else delete [] const_cast (this->name_); -#endif /* ACE_HAS_ALLOC_HOOKS */ (const_cast (this))->name_ = 0; if (ACE_BIT_ENABLED (this->flags_, @@ -267,10 +261,10 @@ ACE_Module_Type::info (ACE_TCHAR **str, size_t len) const ACE_TRACE ("ACE_Module_Type::info"); ACE_TCHAR buf[BUFSIZ]; - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%s\t %s"), - this->name (), - ACE_TEXT ("# ACE_Module\n")); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s"), + this->name (), + ACE_TEXT ("# ACE_Module\n")); if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0) return -1; @@ -357,10 +351,10 @@ ACE_Stream_Type::info (ACE_TCHAR **str, size_t len) const ACE_TRACE ("ACE_Stream_Type::info"); ACE_TCHAR buf[BUFSIZ]; - ACE_OS::snprintf (buf, BUFSIZ, - ACE_TEXT ("%s\t %s"), - this->name (), - ACE_TEXT ("# STREAM\n")); + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s"), + this->name (), + ACE_TEXT ("# STREAM\n")); if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0) return -1; diff --git a/dep/acelite/ace/Service_Types.h b/dep/acelite/ace/Service_Types.h index 922abee6a..70a7ac4f5 100644 --- a/dep/acelite/ace/Service_Types.h +++ b/dep/acelite/ace/Service_Types.h @@ -4,7 +4,9 @@ /** * @file Service_Types.h * - * @author Douglas C. Schmidt + * $Id: Service_Types.h 89925 2010-04-19 12:49:11Z cbeaulac $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Service_Types.inl b/dep/acelite/ace/Service_Types.inl index cb13c1c4e..4586ac612 100644 --- a/dep/acelite/ace/Service_Types.inl +++ b/dep/acelite/ace/Service_Types.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Service_Types.inl 89925 2010-04-19 12:49:11Z cbeaulac $ + #include "ace/ACE.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Shared_Memory.cpp b/dep/acelite/ace/Shared_Memory.cpp index 7b2cba500..97ad06939 100644 --- a/dep/acelite/ace/Shared_Memory.cpp +++ b/dep/acelite/ace/Shared_Memory.cpp @@ -1,3 +1,5 @@ +// $Id: Shared_Memory.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Shared_Memory.h" diff --git a/dep/acelite/ace/Shared_Memory.h b/dep/acelite/ace/Shared_Memory.h index be6970e31..6dbd17ff4 100644 --- a/dep/acelite/ace/Shared_Memory.h +++ b/dep/acelite/ace/Shared_Memory.h @@ -4,6 +4,8 @@ /** * @file Shared_Memory.h * + * $Id: Shared_Memory.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Shared_Memory_MM.cpp b/dep/acelite/ace/Shared_Memory_MM.cpp index c465fe0b1..be3f5d6dc 100644 --- a/dep/acelite/ace/Shared_Memory_MM.cpp +++ b/dep/acelite/ace/Shared_Memory_MM.cpp @@ -1,8 +1,6 @@ -#include "ace/Shared_Memory_MM.h" +// $Id: Shared_Memory_MM.cpp 91286 2010-08-05 09:04:31Z johnnyw $ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ +#include "ace/Shared_Memory_MM.h" #if !defined (__ACE_INLINE__) #include "ace/Shared_Memory_MM.inl" diff --git a/dep/acelite/ace/Shared_Memory_MM.h b/dep/acelite/ace/Shared_Memory_MM.h index d3e54464b..e02b21249 100644 --- a/dep/acelite/ace/Shared_Memory_MM.h +++ b/dep/acelite/ace/Shared_Memory_MM.h @@ -4,7 +4,9 @@ /** * @file Shared_Memory_MM.h * - * @author Douglas C. Schmidt + * $Id: Shared_Memory_MM.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Shared_Memory_MM.inl b/dep/acelite/ace/Shared_Memory_MM.inl index 75762c199..6e1f4b766 100644 --- a/dep/acelite/ace/Shared_Memory_MM.inl +++ b/dep/acelite/ace/Shared_Memory_MM.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Shared_Memory_MM.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Return the name of file that is mapped (if any). diff --git a/dep/acelite/ace/Shared_Memory_Pool.cpp b/dep/acelite/ace/Shared_Memory_Pool.cpp index 845f595ad..df93cb166 100644 --- a/dep/acelite/ace/Shared_Memory_Pool.cpp +++ b/dep/acelite/ace/Shared_Memory_Pool.cpp @@ -1,3 +1,5 @@ +// $Id: Shared_Memory_Pool.cpp 97185 2013-05-30 18:51:35Z johnnyw $ + // Shared_Memory_Pool.cpp #include "ace/Shared_Memory_Pool.h" #include "ace/OS_NS_sys_shm.h" @@ -38,11 +40,6 @@ int ACE_Shared_Memory_Pool::in_use (ACE_OFF_T &offset, size_t &counter) { -#ifndef ACE_HAS_SYSV_IPC - ACE_UNUSED_ARG (offset); - ACE_UNUSED_ARG (counter); - ACE_NOTSUP_RETURN (-1); -#else offset = 0; SHM_TABLE *st = reinterpret_cast (this->base_addr_); shmid_ds buf; @@ -59,8 +56,8 @@ ACE_Shared_Memory_Pool::in_use (ACE_OFF_T &offset, offset += buf.shm_segsz; // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) segment size = %d, offset = %d\n"), buf.shm_segsz, offset)); } + return 0; -#endif } int @@ -68,12 +65,6 @@ ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr, ACE_OFF_T &offset, size_t &counter) { -#ifndef ACE_HAS_SYSV_IPC - ACE_UNUSED_ARG (searchPtr); - ACE_UNUSED_ARG (offset); - ACE_UNUSED_ARG (counter); - ACE_NOTSUP_RETURN (-1); -#else offset = 0; SHM_TABLE *st = reinterpret_cast (this->base_addr_); shmid_ds buf; @@ -103,7 +94,6 @@ ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr, } return 0; -#endif } int @@ -123,7 +113,7 @@ ACE_Shared_Memory_Pool::commit_backing_store_name (size_t rounded_bytes, "exceeded max number of segments = %d, base = %u, offset = %u\n", counter, this->base_addr_, - static_cast(offset)), + offset), -1); else { @@ -244,22 +234,16 @@ ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool ( this->segment_size_ = options->segment_size_; } -#ifndef ACE_HAS_SYSV_IPC - ACE_UNUSED_ARG (backing_store_name); -#else if (backing_store_name) { // Convert the string into a number that is used as the segment // key. - int segment_key = 0; -#if !defined (ACE_LACKS_SSCANF) + int segment_key; int result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (backing_store_name), "%d", &segment_key); -#else - int result = 0; -#endif /* ACE_LACKS_SSCANF */ + if (result == 0 || result == EOF) // The conversion to a number failed so hash with crc32 // ACE::crc32 is also used in . @@ -275,7 +259,6 @@ ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool ( } else this->base_shm_key_ = ACE_DEFAULT_SHM_KEY; -#endif // ACE_HAS_SYSV_IPC if (this->signal_handler_.register_handler (SIGSEGV, this) == -1) ACELIB_ERROR ((LM_ERROR, @@ -384,9 +367,7 @@ ACE_Shared_Memory_Pool::init_acquire (size_t nbytes, counter < this->max_segments_; counter++) { -#ifdef ACE_HAS_SYSV_IPC st[counter].key_ = this->base_shm_key_ + counter; -#endif st[counter].shmid_ = 0; st[counter].used_ = 0; } diff --git a/dep/acelite/ace/Shared_Memory_Pool.h b/dep/acelite/ace/Shared_Memory_Pool.h index d8872f18b..dbf5dac91 100644 --- a/dep/acelite/ace/Shared_Memory_Pool.h +++ b/dep/acelite/ace/Shared_Memory_Pool.h @@ -4,7 +4,9 @@ /** * @file Shared_Memory_Pool.h * - * @author Dougls C. Schmidt + * $Id: Shared_Memory_Pool.h 97185 2013-05-30 18:51:35Z johnnyw $ + * + * @author Dougls C. Schmidt * @author Prashant Jain */ //============================================================================= diff --git a/dep/acelite/ace/Shared_Memory_SV.cpp b/dep/acelite/ace/Shared_Memory_SV.cpp index 1a7e10b40..56f11a421 100644 --- a/dep/acelite/ace/Shared_Memory_SV.cpp +++ b/dep/acelite/ace/Shared_Memory_SV.cpp @@ -1,12 +1,11 @@ +// $Id: Shared_Memory_SV.cpp 91368 2010-08-16 13:03:34Z mhengstmengel $ + #include "ace/Shared_Memory_SV.h" #if !defined (__ACE_INLINE__) #include "ace/Shared_Memory_SV.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Shared_Memory_SV.h b/dep/acelite/ace/Shared_Memory_SV.h index f6109d507..7ae62a332 100644 --- a/dep/acelite/ace/Shared_Memory_SV.h +++ b/dep/acelite/ace/Shared_Memory_SV.h @@ -4,7 +4,9 @@ /** * @file Shared_Memory_SV.h * - * @author Douglas C. Schmidt + * $Id: Shared_Memory_SV.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Shared_Memory_SV.inl b/dep/acelite/ace/Shared_Memory_SV.inl index ae7fbc6e2..1a586701c 100644 --- a/dep/acelite/ace/Shared_Memory_SV.inl +++ b/dep/acelite/ace/Shared_Memory_SV.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Shared_Memory_SV.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/Global_Macros.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Shared_Object.cpp b/dep/acelite/ace/Shared_Object.cpp index 117b32d47..242a2e7c2 100644 --- a/dep/acelite/ace/Shared_Object.cpp +++ b/dep/acelite/ace/Shared_Object.cpp @@ -1,3 +1,5 @@ +// $Id: Shared_Object.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Shared_Object.h" #include "ace/Global_Macros.h" #include "ace/config-all.h" diff --git a/dep/acelite/ace/Shared_Object.h b/dep/acelite/ace/Shared_Object.h index 6497f292e..fedf051ba 100644 --- a/dep/acelite/ace/Shared_Object.h +++ b/dep/acelite/ace/Shared_Object.h @@ -4,7 +4,9 @@ /** * @file Shared_Object.h * - * @author Douglas C. Schmidt + * $Id: Shared_Object.h 81348 2008-04-14 09:00:32Z johnnyw $ + * + * @author Douglas C. Schmidt */ //========================================================================== @@ -46,6 +48,7 @@ public: /// Returns information on a service object. virtual int info (ACE_TCHAR **info_string, size_t length = 0) const; + }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Shared_Object.inl b/dep/acelite/ace/Shared_Object.inl index 358a3fb7a..4f5f00206 100644 --- a/dep/acelite/ace/Shared_Object.inl +++ b/dep/acelite/ace/Shared_Object.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Shared_Object.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Sig_Adapter.cpp b/dep/acelite/ace/Sig_Adapter.cpp index 18a5cc9b9..3861dbaa1 100644 --- a/dep/acelite/ace/Sig_Adapter.cpp +++ b/dep/acelite/ace/Sig_Adapter.cpp @@ -1,3 +1,5 @@ +// $Id: Sig_Adapter.cpp 96257 2012-11-12 13:35:09Z johnnyw $ + #include "ace/Sig_Adapter.h" ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Action &sa, int sigkey) @@ -34,8 +36,6 @@ ACE_Sig_Adapter::~ACE_Sig_Adapter () { } -ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Adapter) - int ACE_Sig_Adapter::sigkey (void) { diff --git a/dep/acelite/ace/Sig_Adapter.h b/dep/acelite/ace/Sig_Adapter.h index bb0f791a0..cbd6b3998 100644 --- a/dep/acelite/ace/Sig_Adapter.h +++ b/dep/acelite/ace/Sig_Adapter.h @@ -4,7 +4,9 @@ /** * @file Sig_Adapter.h * - * @author Douglas C. Schmidt + * $Id: Sig_Adapter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -45,8 +47,6 @@ public: /// Called by the to dispatch the signal handler. virtual int handle_signal (int, siginfo_t *, ucontext_t *); - ACE_ALLOC_HOOK_DECLARE; - private: /// Key for this signal handler (used to remove it). int sigkey_; diff --git a/dep/acelite/ace/Sig_Handler.cpp b/dep/acelite/ace/Sig_Handler.cpp index 577a1e430..da84cbd14 100644 --- a/dep/acelite/ace/Sig_Handler.cpp +++ b/dep/acelite/ace/Sig_Handler.cpp @@ -1,3 +1,5 @@ +// $Id: Sig_Handler.cpp 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/Sig_Handler.h" #include "ace/Sig_Adapter.h" #include "ace/Signal.h" @@ -10,6 +12,8 @@ #include "ace/Sig_Handler.inl" #endif /* __ACE_INLINE__ */ + + #if defined (ACE_HAS_SIG_C_FUNC) extern "C" void diff --git a/dep/acelite/ace/Sig_Handler.h b/dep/acelite/ace/Sig_Handler.h index e71b153fb..214efa73f 100644 --- a/dep/acelite/ace/Sig_Handler.h +++ b/dep/acelite/ace/Sig_Handler.h @@ -4,7 +4,9 @@ /** * @file Sig_Handler.h * - * @author Douglas C. Schmidt + * $Id: Sig_Handler.h 97246 2013-08-07 07:10:20Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Sig_Handler.inl b/dep/acelite/ace/Sig_Handler.inl index a2ad69de7..a7f9c73ab 100644 --- a/dep/acelite/ace/Sig_Handler.inl +++ b/dep/acelite/ace/Sig_Handler.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Sig_Handler.inl 96181 2012-10-08 13:30:13Z shuston $ + ACE_INLINE ACE_Sig_Handler::ACE_Sig_Handler (void) { diff --git a/dep/acelite/ace/Signal.cpp b/dep/acelite/ace/Signal.cpp index b04b80042..6bdae8409 100644 --- a/dep/acelite/ace/Signal.cpp +++ b/dep/acelite/ace/Signal.cpp @@ -1,10 +1,8 @@ +// $Id: Signal.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Signal.h" // #include "ace/Log_Category.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/Signal.inl" #endif /* __ACE_INLINE__ */ diff --git a/dep/acelite/ace/Signal.h b/dep/acelite/ace/Signal.h index 3c39e92f7..4a95c98ba 100644 --- a/dep/acelite/ace/Signal.h +++ b/dep/acelite/ace/Signal.h @@ -4,7 +4,9 @@ /** * @file Signal.h * - * @author Douglas C. Schmidt + * $Id: Signal.h 97262 2013-08-09 08:32:10Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Signal.inl b/dep/acelite/ace/Signal.inl index ff2f52403..088d580aa 100644 --- a/dep/acelite/ace/Signal.inl +++ b/dep/acelite/ace/Signal.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Signal.inl 92069 2010-09-28 11:38:59Z johnnyw $ + #include "ace/OS_NS_signal.h" #include "ace/config-all.h" #include "ace/Trace.h" diff --git a/dep/acelite/ace/Singleton.cpp b/dep/acelite/ace/Singleton.cpp index 52ca2b53d..d84ab928f 100644 --- a/dep/acelite/ace/Singleton.cpp +++ b/dep/acelite/ace/Singleton.cpp @@ -1,3 +1,5 @@ +// $Id: Singleton.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_SINGLETON_CPP #define ACE_SINGLETON_CPP @@ -19,13 +21,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Singleton) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unmanaged_Singleton) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_TSS_Singleton) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unmanaged_TSS_Singleton) -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_DLL_Singleton_T) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_DLL_Singleton_Adapter_T) - template void ACE_Singleton::dump (void) { @@ -83,12 +78,7 @@ ACE_Singleton::instance (void) // Obtain a lock from the ACE_Object_Manager. The pointer // is static, so we only obtain one per ACE_Singleton // instantiation. -#if defined(ACE_FACE_SAFETY_BASE) - static ACE_LOCK the_lock; - static ACE_LOCK *lock = &the_lock; -#else /* ACE_FACE_SAFETY_BASE */ static ACE_LOCK *lock = 0; -#endif /* ACE_FACE_SAFETY_BASE */ if (ACE_Object_Manager::get_singleton_lock (lock) != 0) // Failed to acquire the lock! return 0; @@ -101,11 +91,8 @@ ACE_Singleton::instance (void) ACE_NEW_RETURN (singleton, (ACE_Singleton), 0); // Register for destruction with ACE_Object_Manager. -#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE == 0) ACE_Object_Manager::at_exit (singleton, 0, typeid (TYPE).name ()); -#else - ACE_Object_Manager::at_exit (singleton, &lock, - typeid (TYPE).name ()); +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) } #endif /* ACE_MT_SAFE */ } @@ -115,21 +102,11 @@ ACE_Singleton::instance (void) } template void -ACE_Singleton::cleanup (void *param) +ACE_Singleton::cleanup (void *) { ACE_Object_Manager::remove_at_exit (this); delete this; ACE_Singleton::instance_i () = 0; - -#if !defined ACE_MT_SAFE || ACE_MT_SAFE == 0 || defined ACE_FACE_SAFETY_BASE - ACE_UNUSED_ARG (param); -#else - if (param) - { - ACE_LOCK **lock = static_cast (param); - *lock = 0; - } -#endif } template void @@ -213,12 +190,7 @@ ACE_Unmanaged_Singleton::instance (void) // Obtain a lock from the ACE_Object_Manager. The pointer // is static, so we only obtain one per // ACE_Unmanaged_Singleton instantiation. -#if defined(ACE_FACE_SAFETY_BASE) - static ACE_LOCK the_lock; - static ACE_LOCK *lock = &the_lock; -#else /* ACE_FACE_SAFETY_BASE */ static ACE_LOCK *lock = 0; -#endif /* ACE_FACE_SAFETY_BASE */ if (ACE_Object_Manager::get_singleton_lock (lock) != 0) // Failed to acquire the lock! return 0; @@ -306,12 +278,7 @@ ACE_TSS_Singleton::instance (void) // Obtain a lock from the ACE_Object_Manager. The pointer // is static, so we only obtain one per ACE_Singleton instantiation. -#if defined(ACE_FACE_SAFETY_BASE) - static ACE_LOCK the_lock; - static ACE_LOCK *lock = &the_lock; -#else /* ACE_FACE_SAFETY_BASE */ static ACE_LOCK *lock = 0; -#endif /* ACE_FACE_SAFETY_BASE */ if (ACE_Object_Manager::get_singleton_lock (lock) != 0) // Failed to acquire the lock! return 0; @@ -402,12 +369,7 @@ ACE_Unmanaged_TSS_Singleton::instance (void) // Obtain a lock from the ACE_Object_Manager. The pointer // is static, so we only obtain one per // ACE_Unmanaged_Singleton instantiation. -#if defined(ACE_FACE_SAFETY_BASE) - static ACE_LOCK the_lock; - static ACE_LOCK *lock = &the_lock; -#else /* ACE_FACE_SAFETY_BASE */ static ACE_LOCK *lock = 0; -#endif /* ACE_FACE_SAFETY_BASE */ if (ACE_Object_Manager::get_singleton_lock (lock) != 0) // Failed to acquire the lock! return 0; @@ -514,12 +476,7 @@ ACE_DLL_Singleton_T::instance (void) // Obtain a lock from the ACE_Object_Manager. The pointer // is static, so we only obtain one per // ACE_Unmanaged_Singleton instantiation. -#if defined(ACE_FACE_SAFETY_BASE) - static ACE_LOCK the_lock; - static ACE_LOCK *lock = &the_lock; -#else /* ACE_FACE_SAFETY_BASE */ static ACE_LOCK *lock = 0; -#endif /* ACE_FACE_SAFETY_BASE */ if (ACE_Object_Manager::get_singleton_lock (lock) != 0) // Failed to acquire the lock! return 0; diff --git a/dep/acelite/ace/Singleton.h b/dep/acelite/ace/Singleton.h index d0cd95f4a..308ddc3c2 100644 --- a/dep/acelite/ace/Singleton.h +++ b/dep/acelite/ace/Singleton.h @@ -4,10 +4,12 @@ /** * @file Singleton.h * + * $Id: Singleton.h 84273 2009-01-30 12:55:25Z johnnyw $ + * * @brief * * @author Tim Harrison - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt * @author Chris Lahey * @author Rich Christy * @author David Levine @@ -90,9 +92,6 @@ public: /// Dump the state of the object. static void dump (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Default constructor. ACE_Singleton (void); @@ -139,9 +138,6 @@ public: /// Dump the state of the object. static void dump (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Default constructor. ACE_Unmanaged_Singleton (void); @@ -187,9 +183,6 @@ public: /// Dump the state of the object. static void dump (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Default constructor. ACE_TSS_Singleton (void); @@ -235,9 +228,6 @@ public: /// Dump the state of the object. static void dump (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Default constructor. ACE_Unmanaged_TSS_Singleton (void); @@ -296,9 +286,6 @@ public: const ACE_TCHAR *name (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Default constructor. ACE_DLL_Singleton_T (void); @@ -323,9 +310,6 @@ class ACE_DLL_Singleton_Adapter_T : public TYPE { public: const ACE_TCHAR *dll_name (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Singleton.inl b/dep/acelite/ace/Singleton.inl index 912271ba2..107a8b78c 100644 --- a/dep/acelite/ace/Singleton.inl +++ b/dep/acelite/ace/Singleton.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Singleton.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Default constructors. diff --git a/dep/acelite/ace/Sock_Connect.cpp b/dep/acelite/ace/Sock_Connect.cpp index 43606fa2f..de7215f37 100644 --- a/dep/acelite/ace/Sock_Connect.cpp +++ b/dep/acelite/ace/Sock_Connect.cpp @@ -1,3 +1,5 @@ +// $Id: Sock_Connect.cpp 97798 2014-07-03 10:57:43Z johnnyw $ + #include "ace/Sock_Connect.h" #include "ace/INET_Addr.h" #include "ace/Log_Category.h" @@ -213,11 +215,7 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr, return -1; else ACE_OS::memcpy ((char *) &ip_addr.sin_addr.s_addr, -# ifdef ACE_HOSTENT_H_ADDR - (char *) hp->ACE_HOSTENT_H_ADDR, -# else (char *) hp->h_addr, -# endif hp->h_length); } else @@ -340,28 +338,6 @@ ACE::get_fqdn (ACE_INET_Addr const & addr, char hostname[], size_t len) { -#ifndef ACE_LACKS_GETNAMEINFO - - const socklen_t addr_size = -# ifdef ACE_HAS_IPV6 - (addr.get_type () == PF_INET6) ? sizeof (sockaddr_in6) : -# endif - sizeof (sockaddr_in); - - if (ACE_OS::getnameinfo ((const sockaddr *) addr.get_addr (), - addr_size, hostname, - static_cast (len), - 0, 0, NI_NAMEREQD) != 0) - return -1; - - if (ACE::debug ()) - ACELIB_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) - ACE::get_fqdn, ") - ACE_TEXT ("canonical host name is %C\n"), - hostname)); - - return 0; -#else // below, ACE_LACKS_GETNAMEINFO int h_error; // Not the same as errno! hostent hentry; ACE_HOSTENT_DATA buf; @@ -375,7 +351,7 @@ ACE::get_fqdn (ACE_INET_Addr const & addr, ip_addr_size = sizeof sock_addr->sin_addr; ip_addr = (char*) &sock_addr->sin_addr; } -# ifdef ACE_HAS_IPV6 +#ifdef ACE_HAS_IPV6 else { sockaddr_in6 * sock_addr = @@ -384,7 +360,7 @@ ACE::get_fqdn (ACE_INET_Addr const & addr, ip_addr_size = sizeof sock_addr->sin6_addr; ip_addr = (char*) &sock_addr->sin6_addr; } -# endif /* ACE_HAS_IPV6 */ +#endif /* ACE_HAS_IPV6 */ // get the host entry for the address in question hostent * const hp = ACE_OS::gethostbyaddr_r (ip_addr, @@ -460,7 +436,6 @@ ACE::get_fqdn (ACE_INET_Addr const & addr, } return 0; -#endif /* ACE_LACKS_GETNAMEINFO */ } #if defined (ACE_WIN32) @@ -1247,7 +1222,7 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs) #endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) */ } -# if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_FSCANF) +# if defined (ACE_HAS_IPV6) // Retrieve IPv6 local interfaces by scanning /proc/net/if_inet6 if // it exists. If we cannot open it then ignore possible IPv6 // interfaces, we did our best;-) @@ -1273,12 +1248,12 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs) // resolve the resulting text using getaddrinfo(). const char* ip_fmt = "%s:%s:%s:%s:%s:%s:%s:%s%%%d"; - ACE_OS::snprintf (s_ipaddr, 64, ip_fmt, - addr_p[0], addr_p[1], addr_p[2], addr_p[3], - addr_p[4], addr_p[5], addr_p[6], addr_p[7], - scopeid); + ACE_OS::sprintf (s_ipaddr, + ip_fmt, + addr_p[0], addr_p[1], addr_p[2], addr_p[3], + addr_p[4], addr_p[5], addr_p[6], addr_p[7], scopeid); - error = ACE_OS::getaddrinfo (s_ipaddr, 0, &hints, &res0); + error = getaddrinfo (s_ipaddr, 0, &hints, &res0); if (error) continue; @@ -1288,12 +1263,12 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs) addrs[count].set(reinterpret_cast (res0->ai_addr), res0->ai_addrlen); ++count; } - ACE_OS::freeaddrinfo (res0); + freeaddrinfo (res0); } ACE_OS::fclose (fp); } -# endif /* ACE_HAS_IPV6 && !ACE_LACKS_FSCANF */ +# endif /* ACE_HAS_IPV6 */ return 0; #else @@ -1345,13 +1320,7 @@ return 0; struct ifconf ifcfg; size_t ifreq_size = num_ifs * sizeof (struct ifreq); - struct ifreq *p_ifs; - -#if defined (ACE_HAS_ALLOC_HOOKS) - p_ifs = (struct IFREQ *)ACE_Allocator::instance()->malloc (ifreq_size); -#else - p_ifs = (struct ifreq *) ACE_OS::malloc (ifreq_size); -#endif /* ACE_HAS_ALLOC_HOOKS */ + struct ifreq *p_ifs = (struct ifreq *) ACE_OS::malloc (ifreq_size); if (!p_ifs) { @@ -1369,12 +1338,7 @@ return 0; SIOCGIFCONF_CMD, (caddr_t) &ifcfg) == -1) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (ifcfg.ifc_req); -#else ACE_OS::free (ifcfg.ifc_req); -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE::count_interfaces:") @@ -1397,9 +1361,9 @@ return 0; break; ++if_count; -# if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) +#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) ++p_ifs; -# else +#else if (p_ifs->ifr_addr.sa_len <= sizeof (struct sockaddr)) { ++p_ifs; @@ -1409,14 +1373,10 @@ return 0; p_ifs = (struct ifreq *) (p_ifs->ifr_addr.sa_len + (caddr_t) &p_ifs->ifr_addr); } -# endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) */ +#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__)*/ } -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance()->free (ifcfg.ifc_req); -#else - ACE_OS::free (ifcfg.ifc_req); -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_OS::free (ifcfg.ifc_req); # if defined (ACE_HAS_IPV6) FILE* fp = 0; @@ -1430,7 +1390,7 @@ return 0; } ACE_OS::fclose (fp); } -# endif /* ACE_HAS_IPV6 && !ACE_LACKS_FSCANF */ +# endif /* ACE_HAS_IPV6 */ how_many = if_count; return 0; @@ -1475,7 +1435,7 @@ ip_check (int &ipvn_enabled, int pf) #if defined (ACE_WIN32) // as of the release of Windows 2008, even hosts that have IPv6 interfaces disabled // will still permit the creation of a PF_INET6 socket, thus rendering the socket - // creation test inconsistent. The recommended solution is to get the list of + // creation test inconsistent. The reccommended solution is to get the list of // endpoint addresses and see if any match the desired family. ACE_INET_Addr *if_addrs = 0; size_t if_cnt = 0; diff --git a/dep/acelite/ace/Sock_Connect.h b/dep/acelite/ace/Sock_Connect.h index 540111474..d6a72c718 100644 --- a/dep/acelite/ace/Sock_Connect.h +++ b/dep/acelite/ace/Sock_Connect.h @@ -4,6 +4,8 @@ /** * @file Sock_Connect.h * + * $Id: Sock_Connect.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Priyanka Gontla * @author Based on code that existed formerly in ACE.h. */ diff --git a/dep/acelite/ace/Stack_Trace.cpp b/dep/acelite/ace/Stack_Trace.cpp index cd6f154ad..353be8106 100644 --- a/dep/acelite/ace/Stack_Trace.cpp +++ b/dep/acelite/ace/Stack_Trace.cpp @@ -2,6 +2,8 @@ /** * @file Stack_Trace.cpp * + * $Id: Stack_Trace.cpp 96017 2012-08-08 22:18:09Z mitza $ + * * @brief Encapsulate string representation of stack trace. * * Some platform-specific areas of this code have been adapted from @@ -20,6 +22,7 @@ * * If you add support for a new platform, please add a bullet to the * above list with durable references to the origins of your code. + * */ //============================================================================= @@ -28,8 +31,6 @@ #include "ace/OS_NS_string.h" #include "ace/OS_NS_stdio.h" -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /* This is ugly, simply because it's very platform-specific. */ @@ -57,16 +58,7 @@ determine_starting_frame (ssize_t initial_frame, ssize_t offset) return ACE_MAX( initial_frame + offset, static_cast(0)); } -#if defined(ACE_FACE_SAFETY_BASE) && !defined(ACE_FACE_DEV) -void -ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, size_t num_frames) -{ - ACE_UNUSED_ARG (starting_frame_offset); - ACE_UNUSED_ARG (num_frames); - ACE_OS::strcpy (&this->buf_[0], UNABLE_TO_GET_TRACE); -} - -#elif (defined(__GLIBC__) || defined(ACE_HAS_EXECINFO_H)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +#if (defined(__GLIBC__) || defined(ACE_HAS_EXECINFO_H)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) // This is the code for glibc # include @@ -134,9 +126,9 @@ static ACE_Stack_Trace_stackstate* ACE_Stack_Trace_stateptr = 0; static void ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller, - INSTR *func, - int nargs, - ACE_VX_USR_ARG_T *args) + unsigned int func, + unsigned int nargs, + unsigned int *args) { if (ACE_Stack_Trace_stateptr == 0) return; @@ -154,21 +146,20 @@ ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller, // These are references so that the structure gets updated // in the code below. char*& buf = stackstate->buf; - size_t& len = stackstate->buflen; + unsigned int& len = stackstate->buflen; // At some point try using symFindByValue() to lookup func (and caller?) // to print out symbols rather than simply addresses. // VxWorks can pass -1 for "nargs" if there was an error - if (nargs == -1) - nargs = 0; + if (nargs == static_cast (-1)) nargs = 0; - len += ACE_OS::sprintf (&buf[len], "%p: %p (", caller, func); - for (int i = 0; i < nargs; ++i) + len += ACE_OS::sprintf (&buf[len], "%#10x: %#10x (", (int)caller, func); + for (unsigned int i = 0; i < nargs; ++i) { if (i != 0) len += ACE_OS::sprintf (&buf[len], ", "); - len += ACE_OS::sprintf(&buf[len], "0x" ACE_VX_ARG_FORMAT, args[i]); + len += ACE_OS::sprintf(&buf [len], "%#x", args [i]); } len += ACE_OS::sprintf(&buf[len], ")\n"); @@ -192,7 +183,7 @@ ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, REG_SET regs; - taskRegsGet (taskIdSelf(), ®s); + taskRegsGet ((int)taskIdSelf(), ®s); // Maybe we should take a lock here to guard stateptr? ACE_Stack_Trace_stateptr = &state; trcStack (®s, (FUNCPTR)ACE_Stack_Trace_Add_Frame_To_Buf, taskIdSelf ()); @@ -264,6 +255,17 @@ ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, const char *fnName = "(no symbols)"; static const int N_ARGS = 12; +#if (ACE_VXWORKS < 0x690) +# define ACE_VX_USR_ARG_T int +# define ACE_VX_ARG_FORMAT "%x" +#else +# define ACE_VX_USR_ARG_T _Vx_usr_arg_t +# ifdef _WRS_CONFIG_LP64 +# define ACE_VX_ARG_FORMAT "%lx" +# else +# define ACE_VX_ARG_FORMAT "%x" +# endif +#endif ACE_VX_USR_ARG_T buf[N_ARGS]; ACE_VX_USR_ARG_T *pArgs = 0; int numArgs = @@ -735,4 +737,3 @@ ACE_Stack_Trace::generate_trace (ssize_t, size_t) } #endif -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Stack_Trace.h b/dep/acelite/ace/Stack_Trace.h index 14cdcc012..bfef0ab64 100644 --- a/dep/acelite/ace/Stack_Trace.h +++ b/dep/acelite/ace/Stack_Trace.h @@ -3,6 +3,8 @@ /** * @file Stack_Trace.h * + * $Id: Stack_Trace.h 97426 2013-11-12 09:59:19Z johnnyw $ + * * @author Chris Cleeland (cleeland.ociweb.com) */ //============================================================================= @@ -23,8 +25,6 @@ # define ACE_STACK_TRACE_SYMBUFSIZ 4096 # endif -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - /** * @class ACE_Stack_Trace * @@ -102,8 +102,6 @@ private: void generate_trace (ssize_t starting_frame_offset, size_t num_frames); }; -ACE_END_VERSIONED_NAMESPACE_DECL - #include /**/ "ace/post.h" #endif /* ACE_STACK_TRACE_H */ diff --git a/dep/acelite/ace/Static_Object_Lock.h b/dep/acelite/ace/Static_Object_Lock.h index fc167062f..ad780258e 100644 --- a/dep/acelite/ace/Static_Object_Lock.h +++ b/dep/acelite/ace/Static_Object_Lock.h @@ -4,6 +4,8 @@ /** * @file Static_Object_Lock.h * + * $Id: Static_Object_Lock.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author David L. Levine * @author Matthias Kerkhoff * @author Per Andersson @@ -51,5 +53,26 @@ ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_HAS_THREADS */ +// hack to get around errors while compiling using split-cpp +#if defined (ACE_HAS_THREADS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_IS_SPLITTING) +typedef ACE_Cleanup_Adapter ACE_Static_Object_Lock_Type; + +# if defined (__GNUC__) +// With g++, suppress the warning that this is unused. +static ACE_Static_Object_Lock_Type *ACE_Static_Object_Lock_lock __attribute__ ((unused)) = 0; +# else +static ACE_Static_Object_Lock_Type *ACE_Static_Object_Lock_lock = 0; +# endif /* __GNUC__ */ + +# endif /* ACE_IS_SPLITTING */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ + #include /**/ "ace/post.h" #endif /* ACE_STATIC_OBJECT_LOCK_H */ diff --git a/dep/acelite/ace/Stats.cpp b/dep/acelite/ace/Stats.cpp index b47c4857f..04bba5e86 100644 --- a/dep/acelite/ace/Stats.cpp +++ b/dep/acelite/ace/Stats.cpp @@ -1,3 +1,5 @@ +// $Id: Stats.cpp 95761 2012-05-15 18:23:04Z johnnyw $ + #include "ace/Stats.h" #if !defined (__ACE_INLINE__) @@ -217,13 +219,13 @@ ACE_Stats::print_summary (const u_int precision, // Build a format string, in case the C library doesn't support %*u. ACE_TCHAR format[32]; if (tmp_precision == 0) - ACE_OS::snprintf (format, 32, ACE_TEXT ("%%%d"), tmp_precision); + ACE_OS::sprintf (format, ACE_TEXT ("%%%d"), tmp_precision); else - ACE_OS::snprintf (format, 32, ACE_TEXT ("%%d.%%0%du"), tmp_precision); + ACE_OS::sprintf (format, ACE_TEXT ("%%d.%%0%du"), tmp_precision); ACE_Stats_Value u (tmp_precision); ((ACE_Stats *) this)->mean (u, scale_factor); - ACE_OS::snprintf (mean_string, 128, format, u.whole (), u.fractional ()); + ACE_OS::sprintf (mean_string, format, u.whole (), u.fractional ()); ACE_Stats_Value sd (tmp_precision); if (((ACE_Stats *) this)->std_dev (sd, scale_factor)) @@ -235,8 +237,7 @@ ACE_Stats::print_summary (const u_int precision, { success = 1; } - ACE_OS::snprintf (std_dev_string, 128, format, sd.whole (), - sd.fractional ()); + ACE_OS::sprintf (std_dev_string, format, sd.whole (), sd.fractional ()); ACE_Stats_Value minimum (tmp_precision), maximum (tmp_precision); if (min_ != 0) @@ -249,10 +250,10 @@ ACE_Stats::print_summary (const u_int precision, const ACE_UINT64 m (max_); quotient (m, scale_factor, maximum); } - ACE_OS::snprintf (min_string, 128, format, - minimum.whole (), minimum.fractional ()); - ACE_OS::snprintf (max_string, 128, format, - maximum.whole (), maximum.fractional ()); + ACE_OS::sprintf (min_string, format, + minimum.whole (), minimum.fractional ()); + ACE_OS::sprintf (max_string, format, + maximum.whole (), maximum.fractional ()); } if (success == 1) diff --git a/dep/acelite/ace/Stats.h b/dep/acelite/ace/Stats.h index e3f16fdd5..f529a90d3 100644 --- a/dep/acelite/ace/Stats.h +++ b/dep/acelite/ace/Stats.h @@ -4,6 +4,8 @@ /** * @file Stats.h * + * $Id: Stats.h 96985 2013-04-11 15:50:32Z huangh $ + * * @author David L. Levine */ //========================================================================== @@ -165,13 +167,7 @@ public: */ int print_summary (const u_int precision, const ACE_UINT32 scale_factor = 1, - FILE * -#ifdef ACE_LACKS_STDOUT - = 0 -#else - = stdout -#endif - ) const; + FILE * = stdout) const; /// Initialize internal state. void reset (void); diff --git a/dep/acelite/ace/Stats.inl b/dep/acelite/ace/Stats.inl index 2e54c1228..a27b0d6ba 100644 --- a/dep/acelite/ace/Stats.inl +++ b/dep/acelite/ace/Stats.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Stats.inl 96985 2013-04-11 15:50:32Z huangh $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Strategies_T.cpp b/dep/acelite/ace/Strategies_T.cpp index 761ca762d..e205ca359 100644 --- a/dep/acelite/ace/Strategies_T.cpp +++ b/dep/acelite/ace/Strategies_T.cpp @@ -1,3 +1,5 @@ +// $Id: Strategies_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_STRATEGIES_T_CPP #define ACE_STRATEGIES_T_CPP @@ -1489,15 +1491,16 @@ ACE_NOOP_Concurrency_Strategy::activate_svc_handler (SVC_HANDLER *, return 0; } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Creation_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Singleton_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_DLL_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Concurrency_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Reactive_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Thread_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Process_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Accept_Strategy) -ACE_ALLOC_HOOK_DEFINE_Tco(ACE_Connect_Strategy) + +ACE_ALLOC_HOOK_DEFINE(ACE_Creation_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Singleton_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Concurrency_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Connect_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Process_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Accept_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy) ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Strategies_T.h b/dep/acelite/ace/Strategies_T.h index 238822bce..67906f4a7 100644 --- a/dep/acelite/ace/Strategies_T.h +++ b/dep/acelite/ace/Strategies_T.h @@ -4,7 +4,9 @@ /** * @file Strategies_T.h * - * @author Douglas C. Schmidt + * $Id: Strategies_T.h 97110 2013-05-10 08:03:33Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Strategies_T.inl b/dep/acelite/ace/Strategies_T.inl index ef16da284..22fa2c763 100644 --- a/dep/acelite/ace/Strategies_T.inl +++ b/dep/acelite/ace/Strategies_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Strategies_T.inl 96985 2013-04-11 15:50:32Z huangh $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE diff --git a/dep/acelite/ace/Stream.cpp b/dep/acelite/ace/Stream.cpp index 47315c401..d74aca51f 100644 --- a/dep/acelite/ace/Stream.cpp +++ b/dep/acelite/ace/Stream.cpp @@ -1,4 +1,6 @@ // Stream.cpp +// $Id: Stream.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_STREAM_CPP #define ACE_STREAM_CPP @@ -19,7 +21,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream) +ACE_ALLOC_HOOK_DEFINE(ACE_Stream) // Give some idea of what the heck is going on in a stream! diff --git a/dep/acelite/ace/Stream.h b/dep/acelite/ace/Stream.h index d8381dde9..a9dc401f0 100644 --- a/dep/acelite/ace/Stream.h +++ b/dep/acelite/ace/Stream.h @@ -4,7 +4,9 @@ /** * @file Stream.h * - * @author Douglas C. Schmidt + * $Id: Stream.h 96070 2012-08-17 09:07:16Z mcorino $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Stream.inl b/dep/acelite/ace/Stream.inl index ac9754924..b1bd92a60 100644 --- a/dep/acelite/ace/Stream.inl +++ b/dep/acelite/ace/Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Stream.inl 96061 2012-08-16 09:36:07Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE ACE_Module * diff --git a/dep/acelite/ace/Stream_Modules.cpp b/dep/acelite/ace/Stream_Modules.cpp index 4533d1b37..a071aa19f 100644 --- a/dep/acelite/ace/Stream_Modules.cpp +++ b/dep/acelite/ace/Stream_Modules.cpp @@ -1,3 +1,5 @@ +// $Id: Stream_Modules.cpp 96061 2012-08-16 09:36:07Z mcorino $ + #ifndef ACE_STREAM_MODULES_CPP #define ACE_STREAM_MODULES_CPP @@ -11,7 +13,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream_Head) +ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Head) template ACE_Stream_Head::ACE_Stream_Head (void) @@ -151,7 +153,7 @@ ACE_Stream_Head::fini (void) return 0; } -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream_Tail) +ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Tail) template ACE_Stream_Tail::ACE_Stream_Tail (void) @@ -295,7 +297,7 @@ ACE_Stream_Tail::fini (void) return 0; } -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Thru_Task) +ACE_ALLOC_HOOK_DEFINE(ACE_Thru_Task) template ACE_Thru_Task::ACE_Thru_Task (void) diff --git a/dep/acelite/ace/Stream_Modules.h b/dep/acelite/ace/Stream_Modules.h index 1760e3b89..008bdecd5 100644 --- a/dep/acelite/ace/Stream_Modules.h +++ b/dep/acelite/ace/Stream_Modules.h @@ -4,7 +4,9 @@ /** * @file Stream_Modules.h * - * @author Douglas C. Schmidt + * $Id: Stream_Modules.h 96061 2012-08-16 09:36:07Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/String_Base.cpp b/dep/acelite/ace/String_Base.cpp index b12d8c4ca..2373c5782 100644 --- a/dep/acelite/ace/String_Base.cpp +++ b/dep/acelite/ace/String_Base.cpp @@ -1,9 +1,12 @@ +// $Id: String_Base.cpp 93238 2011-02-01 14:30:38Z shuston $ + #ifndef ACE_STRING_BASE_CPP #define ACE_STRING_BASE_CPP #include "ace/ACE.h" #include "ace/Malloc_Base.h" #include "ace/String_Base.h" +#include "ace/Auto_Ptr.h" #include "ace/OS_NS_string.h" #include // For std::swap<> @@ -14,7 +17,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_String_Base) +ACE_ALLOC_HOOK_DEFINE(ACE_String_Base) template ACE_CHAR_T ACE_String_Base::NULL_String_ = 0; @@ -370,11 +373,7 @@ ACE_String_Base::rep (void) const ACE_TRACE ("ACE_String_Base::rep"); ACE_CHAR_T *new_string; -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (new_string, static_cast(ACE_Allocator::instance()->malloc(sizeof(ACE_CHAR_T) * (this->len_ + 1))), 0); -#else ACE_NEW_RETURN (new_string, ACE_CHAR_T[this->len_ + 1], 0); -#endif ACE_OS::strsncpy (new_string, this->rep_, this->len_+1); return new_string; diff --git a/dep/acelite/ace/String_Base.h b/dep/acelite/ace/String_Base.h index 8005c34b7..b02d78672 100644 --- a/dep/acelite/ace/String_Base.h +++ b/dep/acelite/ace/String_Base.h @@ -4,7 +4,9 @@ /** * @file String_Base.h * - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) + * $Id: String_Base.h 95709 2012-04-24 01:19:24Z schmidt $ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/String_Base.inl b/dep/acelite/ace/String_Base.inl index 9e397d2d1..2ccecd35e 100644 --- a/dep/acelite/ace/String_Base.inl +++ b/dep/acelite/ace/String_Base.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: String_Base.inl 88793 2010-02-01 17:50:34Z cleeland $ + #include "ace/Malloc_Base.h" #include "ace/Min_Max.h" #include "ace/OS_NS_string.h" diff --git a/dep/acelite/ace/String_Base_Const.cpp b/dep/acelite/ace/String_Base_Const.cpp index 12169d66a..e3f0f18f4 100644 --- a/dep/acelite/ace/String_Base_Const.cpp +++ b/dep/acelite/ace/String_Base_Const.cpp @@ -1,3 +1,5 @@ +// $Id: String_Base_Const.cpp 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/String_Base_Const.h" #include "ace/Numeric_Limits.h" diff --git a/dep/acelite/ace/String_Base_Const.h b/dep/acelite/ace/String_Base_Const.h index 3fce9f408..cad0c0b60 100644 --- a/dep/acelite/ace/String_Base_Const.h +++ b/dep/acelite/ace/String_Base_Const.h @@ -4,6 +4,8 @@ /** * @file String_Base_Const.h * + * $Id: String_Base_Const.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/Svc_Conf.h b/dep/acelite/ace/Svc_Conf.h index 7c47a5e5a..4a03e40ae 100644 --- a/dep/acelite/ace/Svc_Conf.h +++ b/dep/acelite/ace/Svc_Conf.h @@ -4,6 +4,8 @@ /** * @file Svc_Conf.h * + * $Id: Svc_Conf.h 81332 2008-04-10 22:47:04Z iliyan $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Svc_Conf.y b/dep/acelite/ace/Svc_Conf.y index 039cbab5e..ec3ed5c06 100644 --- a/dep/acelite/ace/Svc_Conf.y +++ b/dep/acelite/ace/Svc_Conf.y @@ -1,4 +1,6 @@ %{ +// $Id: Svc_Conf.y 94034 2011-05-09 19:11:03Z johnnyw $ + #include "ace/Svc_Conf.h" #if (ACE_USES_CLASSIC_SVC_CONF == 1) diff --git a/dep/acelite/ace/Svc_Conf_Lexer.cpp b/dep/acelite/ace/Svc_Conf_Lexer.cpp index 08d2f65d7..95b2a2625 100644 --- a/dep/acelite/ace/Svc_Conf_Lexer.cpp +++ b/dep/acelite/ace/Svc_Conf_Lexer.cpp @@ -1,3 +1,4 @@ +// $Id: Svc_Conf_Lexer.cpp 92178 2010-10-08 07:44:20Z olli $ #include "ace/Svc_Conf_Lexer.h" #if (ACE_USES_CLASSIC_SVC_CONF == 1) @@ -84,8 +85,6 @@ struct ace_yy_buffer_state #endif /* ACE_USES_WCHAR */ } - ACE_ALLOC_HOOK_DECLARE; - // Input related char input_[ACE_YY_CONVERSION_SPACE]; size_t index_; @@ -104,8 +103,6 @@ struct ace_yy_buffer_state #endif /* ACE_USES_WCHAR */ }; -ACE_ALLOC_HOOK_DEFINE(ace_yy_buffer_state) - // ****************************************************************** // Global functions // ****************************************************************** @@ -246,9 +243,7 @@ ACE_Svc_Conf_Lexer::input (ACE_Svc_Conf_Param* param, } else { -#ifndef ACE_LACKS_STDERR ACE_OS::fprintf (stderr, "ERROR: input in scanner failed\n"); -#endif ACE_OS::exit (2); } } diff --git a/dep/acelite/ace/Svc_Conf_Lexer.h b/dep/acelite/ace/Svc_Conf_Lexer.h index ad2528ba4..fbd15e1a6 100644 --- a/dep/acelite/ace/Svc_Conf_Lexer.h +++ b/dep/acelite/ace/Svc_Conf_Lexer.h @@ -4,6 +4,8 @@ /** * @file Svc_Conf_Lexer.h * + * $Id: Svc_Conf_Lexer.h 81312 2008-04-09 21:01:34Z iliyan $ + * * This class is a hand-coded replacement for the lexer generated from * Svc_Conf.l that correctly supports Unicode. * diff --git a/dep/acelite/ace/Svc_Conf_Param.h b/dep/acelite/ace/Svc_Conf_Param.h index 4b03076bb..764c615d6 100644 --- a/dep/acelite/ace/Svc_Conf_Param.h +++ b/dep/acelite/ace/Svc_Conf_Param.h @@ -4,6 +4,8 @@ /** * @file Svc_Conf_Param.h * + * $Id: Svc_Conf_Param.h 81312 2008-04-09 21:01:34Z iliyan $ + * * @author Iliyan Jeliazkov * @author Based on code originally found in Svc_Conf.h by Doug Schmidt and Ossama Othman. @@ -45,7 +47,7 @@ extern void ace_yy_delete_buffer (ace_yy_buffer_state *buffer); * This class retains the state for a given parse/scan. It primarily * makes it possible to hold the static object lock in the scanner * for as short a period of time as possible. The resulting finer - * grained locking prevents deadlocks from occurring when scanning a + * grained locking prevents deadlocks from occuring when scanning a * `svc.conf' file and activating an ACE_Task, for example, as a * result of processing the directives in that file. */ diff --git a/dep/acelite/ace/Svc_Conf_Token_Table.h b/dep/acelite/ace/Svc_Conf_Token_Table.h index 78df46db9..f139d027e 100644 --- a/dep/acelite/ace/Svc_Conf_Token_Table.h +++ b/dep/acelite/ace/Svc_Conf_Token_Table.h @@ -2,6 +2,8 @@ /* Skeleton interface for Bison's Yacc-like parsers in C + $Id: Svc_Conf_Token_Table.h 82145 2008-06-24 11:03:50Z sma $ + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. diff --git a/dep/acelite/ace/Svc_Conf_Tokens.h b/dep/acelite/ace/Svc_Conf_Tokens.h index a3e6a129d..26a8ddad0 100644 --- a/dep/acelite/ace/Svc_Conf_Tokens.h +++ b/dep/acelite/ace/Svc_Conf_Tokens.h @@ -3,6 +3,8 @@ /** * @file Svc_Conf_Tokens.h * + * $Id: Svc_Conf_Tokens.h 81335 2008-04-11 01:53:36Z iliyan $ + * * @author Iliyan Jeliazkov */ //==================================================================== diff --git a/dep/acelite/ace/Svc_Conf_y.cpp b/dep/acelite/ace/Svc_Conf_y.cpp index 333682808..125e148ae 100644 --- a/dep/acelite/ace/Svc_Conf_y.cpp +++ b/dep/acelite/ace/Svc_Conf_y.cpp @@ -1,3 +1,4 @@ +// $Id: Svc_Conf_y.cpp 96985 2013-04-11 15:50:32Z huangh $ /* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C @@ -104,6 +105,8 @@ /* Copy the first part of user declarations. */ +// $Id: Svc_Conf_y.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Svc_Conf.h" #if (ACE_USES_CLASSIC_SVC_CONF == 1) @@ -1901,7 +1904,7 @@ ace_yyreturn: ace_yystos[*ace_yyssp], ace_yyvsp); YYPOPSTACK (1); } -#if defined ace_yyoverflow && !defined ACE_LACKS_FREE +#ifndef ace_yyoverflow if (ace_yyss != ace_yyssa) YYSTACK_FREE (ace_yyss); #endif diff --git a/dep/acelite/ace/Svc_Handler.cpp b/dep/acelite/ace/Svc_Handler.cpp index 1774e0188..76fb03170 100644 --- a/dep/acelite/ace/Svc_Handler.cpp +++ b/dep/acelite/ace/Svc_Handler.cpp @@ -1,3 +1,5 @@ +// $Id: Svc_Handler.cpp 97075 2013-04-24 15:01:48Z schmidt $ + #ifndef ACE_SVC_HANDLER_CPP #define ACE_SVC_HANDLER_CPP diff --git a/dep/acelite/ace/Svc_Handler.h b/dep/acelite/ace/Svc_Handler.h index 6e44ad2ae..3b42ea848 100644 --- a/dep/acelite/ace/Svc_Handler.h +++ b/dep/acelite/ace/Svc_Handler.h @@ -4,7 +4,9 @@ /** * @file Svc_Handler.h * - * @author Douglas Schmidt + * $Id: Svc_Handler.h 97084 2013-04-26 20:42:28Z schmidt $ + * + * @author Douglas Schmidt * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Synch.h b/dep/acelite/ace/Synch.h index 112f36460..133209373 100644 --- a/dep/acelite/ace/Synch.h +++ b/dep/acelite/ace/Synch.h @@ -4,9 +4,11 @@ /** * @file Synch.h * + * $Id: Synch.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * Wrapper Facades for various synchronization mechanisms. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Synch_Options.cpp b/dep/acelite/ace/Synch_Options.cpp index 9ef9448b3..dd204ce26 100644 --- a/dep/acelite/ace/Synch_Options.cpp +++ b/dep/acelite/ace/Synch_Options.cpp @@ -1,12 +1,10 @@ +// $Id: Synch_Options.cpp 91287 2010-08-05 10:30:49Z johnnyw $ + #include "ace/Synch_Options.h" #include "ace/Global_Macros.h" #include "ace/config-all.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_ALLOC_HOOK_DEFINE (ACE_Synch_Options) diff --git a/dep/acelite/ace/Synch_Options.h b/dep/acelite/ace/Synch_Options.h index 171f1e24c..2466f0fc5 100644 --- a/dep/acelite/ace/Synch_Options.h +++ b/dep/acelite/ace/Synch_Options.h @@ -4,7 +4,9 @@ /** * @file Synch_Options.h * - * @author Douglas C. Schmidt + * $Id: Synch_Options.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Synch_Traits.h b/dep/acelite/ace/Synch_Traits.h index 3a4c52dd1..a841039a2 100644 --- a/dep/acelite/ace/Synch_Traits.h +++ b/dep/acelite/ace/Synch_Traits.h @@ -4,9 +4,11 @@ /** * @file Synch_Traits.h * + * $Id: Synch_Traits.h 96073 2012-08-17 13:39:55Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/System_Time.cpp b/dep/acelite/ace/System_Time.cpp index e7c347104..0780eaa08 100644 --- a/dep/acelite/ace/System_Time.cpp +++ b/dep/acelite/ace/System_Time.cpp @@ -1,3 +1,5 @@ +// $Id: System_Time.cpp 97308 2013-09-01 00:58:08Z mesnier_p $ + #include "ace/System_Time.h" #include "ace/MMAP_Memory_Pool.h" #include "ace/Malloc_T.h" diff --git a/dep/acelite/ace/System_Time.h b/dep/acelite/ace/System_Time.h index dca30ec97..bd5150d23 100644 --- a/dep/acelite/ace/System_Time.h +++ b/dep/acelite/ace/System_Time.h @@ -4,6 +4,8 @@ /** * @file System_Time.h * + * $Id: System_Time.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Prashant Jain * @author Tim H. Harrison * @author Douglas C. Schmidt diff --git a/dep/acelite/ace/TLI.cpp b/dep/acelite/ace/TLI.cpp index 2c101d827..3db3ec29b 100644 --- a/dep/acelite/ace/TLI.cpp +++ b/dep/acelite/ace/TLI.cpp @@ -1,3 +1,5 @@ +// $Id: TLI.cpp 96985 2013-04-11 15:50:32Z huangh $ + // Defines the member functions for the base class of the ACE_TLI // abstraction. @@ -49,6 +51,7 @@ ACE_TLI::ACE_TLI (void) { delete [] this->so_opt_req.opt.buf; this->so_opt_req.opt.buf = 0; + return; } #endif /* ACE_HAS_SVR4_TLI */ } diff --git a/dep/acelite/ace/TLI.h b/dep/acelite/ace/TLI.h index 6a4403479..10ba78ad9 100644 --- a/dep/acelite/ace/TLI.h +++ b/dep/acelite/ace/TLI.h @@ -4,6 +4,8 @@ /** * @file TLI.h * + * $Id: TLI.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/TLI.inl b/dep/acelite/ace/TLI.inl index 2e339c6ea..1d7e196b1 100644 --- a/dep/acelite/ace/TLI.inl +++ b/dep/acelite/ace/TLI.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: TLI.inl 93359 2011-02-11 11:33:12Z mcorino $ + #include "ace/TLI.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/TLI_Acceptor.cpp b/dep/acelite/ace/TLI_Acceptor.cpp index 4b833578f..bbb6fe8f8 100644 --- a/dep/acelite/ace/TLI_Acceptor.cpp +++ b/dep/acelite/ace/TLI_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: TLI_Acceptor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/TLI_Acceptor.h" #include "ace/Log_Category.h" #include "ace/ACE.h" diff --git a/dep/acelite/ace/TLI_Acceptor.h b/dep/acelite/ace/TLI_Acceptor.h index 47e122530..e277067ee 100644 --- a/dep/acelite/ace/TLI_Acceptor.h +++ b/dep/acelite/ace/TLI_Acceptor.h @@ -4,6 +4,8 @@ /** * @file TLI_Acceptor.h * + * $Id: TLI_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/TLI_Connector.cpp b/dep/acelite/ace/TLI_Connector.cpp index 42682e4dc..1acb7ee29 100644 --- a/dep/acelite/ace/TLI_Connector.cpp +++ b/dep/acelite/ace/TLI_Connector.cpp @@ -1,3 +1,5 @@ +// $Id: TLI_Connector.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/TLI_Connector.h" diff --git a/dep/acelite/ace/TLI_Connector.h b/dep/acelite/ace/TLI_Connector.h index b90fb2a0a..c5f5a1d7c 100644 --- a/dep/acelite/ace/TLI_Connector.h +++ b/dep/acelite/ace/TLI_Connector.h @@ -4,6 +4,8 @@ /** * @file TLI_Connector.h * + * $Id: TLI_Connector.h 96985 2013-04-11 15:50:32Z huangh $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/TLI_Connector.inl b/dep/acelite/ace/TLI_Connector.inl index eac9d9a58..328409686 100644 --- a/dep/acelite/ace/TLI_Connector.inl +++ b/dep/acelite/ace/TLI_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: TLI_Connector.inl 96985 2013-04-11 15:50:32Z huangh $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/TLI_Stream.cpp b/dep/acelite/ace/TLI_Stream.cpp index 3f20739a4..d12fcbe6c 100644 --- a/dep/acelite/ace/TLI_Stream.cpp +++ b/dep/acelite/ace/TLI_Stream.cpp @@ -1,3 +1,5 @@ +// $Id: TLI_Stream.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + /* Defines the member functions for the base class of the ACE_TLI_Stream abstraction. */ diff --git a/dep/acelite/ace/TLI_Stream.h b/dep/acelite/ace/TLI_Stream.h index acbc4c3d7..a37505bbe 100644 --- a/dep/acelite/ace/TLI_Stream.h +++ b/dep/acelite/ace/TLI_Stream.h @@ -4,6 +4,8 @@ /** * @file TLI_Stream.h * + * $Id: TLI_Stream.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/TLI_Stream.inl b/dep/acelite/ace/TLI_Stream.inl index 8f5608f0a..1ef1a173e 100644 --- a/dep/acelite/ace/TLI_Stream.inl +++ b/dep/acelite/ace/TLI_Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: TLI_Stream.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/TLI_Stream.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/TP_Reactor.cpp b/dep/acelite/ace/TP_Reactor.cpp index 41942a60b..0108f69b8 100644 --- a/dep/acelite/ace/TP_Reactor.cpp +++ b/dep/acelite/ace/TP_Reactor.cpp @@ -1,3 +1,5 @@ +// $Id: TP_Reactor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/TP_Reactor.h" #include "ace/Thread.h" #include "ace/Timer_Queue.h" @@ -315,7 +317,7 @@ int ACE_TP_Reactor::handle_notify_events (int & /*event_count*/, ACE_TP_Token_Guard &guard) { - // Get the handle on which notify calls could have occurred + // Get the handle on which notify calls could have occured ACE_HANDLE notify_handle = this->get_notify_handle (); int result = 0; diff --git a/dep/acelite/ace/TP_Reactor.h b/dep/acelite/ace/TP_Reactor.h index 15384c0eb..965b6dfcc 100644 --- a/dep/acelite/ace/TP_Reactor.h +++ b/dep/acelite/ace/TP_Reactor.h @@ -4,6 +4,8 @@ /** * @file TP_Reactor.h * + * $Id: TP_Reactor.h 94454 2011-09-08 17:36:56Z johnnyw $ + * * The ACE_TP_Reactor (aka, Thread Pool Reactor) uses the * Leader/Followers pattern to demultiplex events among a pool of * threads. When using a thread pool reactor, an application diff --git a/dep/acelite/ace/TP_Reactor.inl b/dep/acelite/ace/TP_Reactor.inl index f793fd23c..2b14a8c9b 100644 --- a/dep/acelite/ace/TP_Reactor.inl +++ b/dep/acelite/ace/TP_Reactor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: TP_Reactor.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL /************************************************************************/ diff --git a/dep/acelite/ace/TSS_Adapter.cpp b/dep/acelite/ace/TSS_Adapter.cpp index ee1f55fdc..e51ca3035 100644 --- a/dep/acelite/ace/TSS_Adapter.cpp +++ b/dep/acelite/ace/TSS_Adapter.cpp @@ -1,17 +1,15 @@ /** * @file TSS_Adapter.cpp * + * $Id: TSS_Adapter.cpp 93792 2011-04-07 11:48:50Z mcorino $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/TSS_Adapter.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_TSS_Adapter::ACE_TSS_Adapter (void *object, ACE_THR_DEST f) @@ -20,8 +18,6 @@ ACE_TSS_Adapter::ACE_TSS_Adapter (void *object, ACE_THR_DEST f) { } -ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Adapter); - void ACE_TSS_Adapter::cleanup (void) { diff --git a/dep/acelite/ace/TSS_Adapter.h b/dep/acelite/ace/TSS_Adapter.h index 376f51792..b80642236 100644 --- a/dep/acelite/ace/TSS_Adapter.h +++ b/dep/acelite/ace/TSS_Adapter.h @@ -4,9 +4,11 @@ /** * @file TSS_Adapter.h * + * $Id: TSS_Adapter.h 93792 2011-04-07 11:48:50Z mcorino $ + * * Originally in Synch.h * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== @@ -43,8 +45,6 @@ public: /// Perform the cleanup operation. void cleanup (void); - ACE_ALLOC_HOOK_DECLARE; - //private: /// The real TS object. diff --git a/dep/acelite/ace/TSS_T.cpp b/dep/acelite/ace/TSS_T.cpp index bee8257b0..cb6a2e03c 100644 --- a/dep/acelite/ace/TSS_T.cpp +++ b/dep/acelite/ace/TSS_T.cpp @@ -1,3 +1,5 @@ +// $Id: TSS_T.cpp 97130 2013-05-13 17:36:26Z mesnier_p $ + #ifndef ACE_TSS_T_CPP #define ACE_TSS_T_CPP @@ -15,9 +17,6 @@ #include "ace/Log_Category.h" #include "ace/Guard_T.h" #include "ace/OS_NS_stdio.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if defined (ACE_HAS_THR_C_DEST) # include "ace/TSS_Adapter.h" @@ -25,7 +24,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_TSS) +ACE_ALLOC_HOOK_DEFINE(ACE_TSS) #if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) # if defined (ACE_HAS_THR_C_DEST) @@ -46,13 +45,7 @@ ACE_TSS::~ACE_TSS (void) # else TYPE *ts_obj = this->ts_value (); this->ts_value (0); -# if !defined ACE_HAS_LYNXOS_178 || defined ACE_HAS_TSS_EMULATION - // A bug in LynxOS-178 causes pthread_setspecific (called from ts_value(0) - // above) to call the cleanup function, so we need to avoid calling it here. ACE_TSS::cleanup (ts_obj); -# else - ACE_UNUSED_ARG (ts_obj); -# endif # endif /* ACE_HAS_THR_C_DEST */ ACE_OS::thr_key_detach (this->key_); @@ -161,7 +154,7 @@ ACE_TSS::ACE_TSS (TYPE *ts_obj) ACE_TEXT ("ACE_Thread::keycreate() failed!"), ACE_TEXT ("ACE_TSS::ACE_TSS"), MB_OK); -#elif !defined (ACE_LACKS_VA_FUNCTIONS) +#else ACE_OS::fprintf (stderr, "ACE_Thread::keycreate() failed!"); #endif /* ACE_HAS_WINCE */ @@ -339,7 +332,7 @@ ACE_TSS::ts_object (TYPE *new_ts_obj) return ts_obj; } -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_TSS_Guard) +ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Guard) template void ACE_TSS_Guard::dump (void) const diff --git a/dep/acelite/ace/TSS_T.h b/dep/acelite/ace/TSS_T.h index d3097d544..7c877545b 100644 --- a/dep/acelite/ace/TSS_T.h +++ b/dep/acelite/ace/TSS_T.h @@ -4,9 +4,11 @@ /** * @file TSS_T.h * + * $Id: TSS_T.h 91703 2010-09-10 11:05:38Z msmit $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== @@ -22,7 +24,7 @@ // This should probably go somewhere else, but it's only used here and // in Thread_Manager. -// Note there is no ACE_TSS_SET because one would typically do +// Note there is no ACE_TSS_SET because one would typicaly do // 'ACE_TSS_GET()->xyz_ = value', so the macro would have been too // complicated. # if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) @@ -72,6 +74,7 @@ class ACE_TSS_Adapter; * instances of this type are dynamicaly allocated. On the stack it is * typically allocated inside the ACE_Thread::svc() method which * limits its lifetime appropriately. + * */ template class ACE_TSS : private ACE_Copy_Disabled @@ -168,8 +171,8 @@ public: /// Dump the state of an object. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. protected: /// Actually implements the code that retrieves the object from diff --git a/dep/acelite/ace/TSS_T.inl b/dep/acelite/ace/TSS_T.inl index 7e68976c8..947e6bd95 100644 --- a/dep/acelite/ace/TSS_T.inl +++ b/dep/acelite/ace/TSS_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: TSS_T.inl 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Thread.h" #include "ace/Log_Category.h" diff --git a/dep/acelite/ace/TTY_IO.cpp b/dep/acelite/ace/TTY_IO.cpp index 53c56badd..a64519abf 100644 --- a/dep/acelite/ace/TTY_IO.cpp +++ b/dep/acelite/ace/TTY_IO.cpp @@ -1,3 +1,5 @@ +// $Id: TTY_IO.cpp 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/TTY_IO.h" #include "ace/OS_NS_errno.h" #include "ace/OS_NS_string.h" @@ -242,24 +244,16 @@ int ACE_TTY_IO::control (Control_Mode cmd, Serial_Params *arg) const { devpar.c_cflag |= PARENB; devpar.c_cflag |= PARODD; - devpar.c_iflag &= ~IGNPAR; - devpar.c_iflag |= INPCK | PARMRK; } else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_EVEN) == 0) { devpar.c_cflag |= PARENB; devpar.c_cflag &= ~PARODD; - devpar.c_iflag &= ~IGNPAR; - devpar.c_iflag |= INPCK | PARMRK; } else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_NONE) == 0) - { - devpar.c_cflag &= ~PARENB; - } + devpar.c_cflag &= ~PARENB; else - { - return -1; - } + return -1; } else { @@ -299,6 +293,7 @@ int ACE_TTY_IO::control (Control_Mode cmd, Serial_Params *arg) const devpar.c_cflag |= CLOCAL; #endif /* CLOCAL */ + devpar.c_iflag = IGNPAR | INPCK; if (arg->databits < 8) devpar.c_iflag |= ISTRIP; diff --git a/dep/acelite/ace/TTY_IO.h b/dep/acelite/ace/TTY_IO.h index 860184d7d..3245ce516 100644 --- a/dep/acelite/ace/TTY_IO.h +++ b/dep/acelite/ace/TTY_IO.h @@ -4,7 +4,9 @@ /** * @file TTY_IO.h * - * @author Douglas C. Schmidt + * $Id: TTY_IO.h 97246 2013-08-07 07:10:20Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Task.cpp b/dep/acelite/ace/Task.cpp index 17acc652f..1d159ad84 100644 --- a/dep/acelite/ace/Task.cpp +++ b/dep/acelite/ace/Task.cpp @@ -1,3 +1,5 @@ +// $Id: Task.cpp 95761 2012-05-15 18:23:04Z johnnyw $ + #include "ace/Task.h" #include "ace/Module.h" @@ -5,7 +7,6 @@ #include "ace/Task.inl" #endif /* __ACE_INLINE__ */ -#include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -14,13 +15,8 @@ ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man) thr_mgr_ (thr_man), flags_ (0), grp_id_ (-1) -#if !(defined (ACE_TANDEM_T1248_PTHREADS) || defined (ACE_THREAD_T_IS_A_STRUCT)) ,last_thread_id_ (0) -#endif /* ! ACE_TANDEM_T1248_PTHREADS || ACE_THREAD_T_IS_A_STRUCT */ { -#if defined (ACE_TANDEM_T1248_PTHREADS) || defined (ACE_THREAD_T_IS_A_STRUCT) - ACE_OS::memset( &this->last_thread_id_, '\0', sizeof( this->last_thread_id_ )); -#endif /* ACE_TANDEM_T1248_PTHREADS || ACE_THREAD_T_IS_A_STRUCT */ } ACE_Task_Base::~ACE_Task_Base (void) @@ -131,14 +127,10 @@ ACE_Task_Base::activate (long flags, return 1; // Already active. else { - if ((this->thr_count_ > 0 || grp_id == -1) && - this->grp_id_ != -1) + if (this->thr_count_ > 0 && this->grp_id_ != -1) // If we're joining an existing group of threads then make - // sure to (re)use its group id. + // sure to use its group id. grp_id = this->grp_id_; - else if (grp_id != -1) - // make sure to reset the cached grp_id - this->grp_id_ = -1; this->thr_count_ += n_threads; } @@ -192,11 +184,11 @@ ACE_Task_Base::activate (long flags, if (this->grp_id_ == -1) this->grp_id_ = grp_spawned; -#if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_THREAD_T_IS_A_STRUCT) +#if defined(ACE_TANDEM_T1248_PTHREADS) ACE_OS::memcpy( &this->last_thread_id_, '\0', sizeof(this->last_thread_id_)); #else this->last_thread_id_ = 0; // Reset to prevent inadvertant match on ID -#endif /* ACE_TANDEM_T1248_PTHREADS || ACE_THREAD_T_IS_A_STRUCT */ +#endif /* defined (ACE_TANDEM_T1248_PTHREADS) */ return 0; @@ -264,10 +256,9 @@ ACE_Task_Base::svc_run (void *args) t->thr_mgr ()->at_exit (t, ACE_Task_Base::cleanup, 0); #endif /* ACE_HAS_SIG_C_FUNC */ - ACE_THR_FUNC_RETURN status; // Call the Task's svc() hook method. int const svc_status = t->svc (); - + ACE_THR_FUNC_RETURN status; #if defined (ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN) // Reinterpret case between integral types is not mentioned in the C++ spec status = static_cast (svc_status); diff --git a/dep/acelite/ace/Task.h b/dep/acelite/ace/Task.h index 87e658b8f..d6c0a68ee 100644 --- a/dep/acelite/ace/Task.h +++ b/dep/acelite/ace/Task.h @@ -4,7 +4,9 @@ /** * @file Task.h * - * @author Douglas C. Schmidt + * $Id: Task.h 91688 2010-09-09 11:21:50Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -279,7 +281,7 @@ protected: #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) /// Protect the state of a Task during concurrent operations, but /// only if we're configured as MT safe... - mutable ACE_Thread_Mutex lock_; + ACE_Thread_Mutex lock_; #endif /* ACE_MT_SAFE */ /// Holds the thread ID of the last thread to exit svc() in this object. diff --git a/dep/acelite/ace/Task.inl b/dep/acelite/ace/Task.inl index 2d585d13b..9f70371e5 100644 --- a/dep/acelite/ace/Task.inl +++ b/dep/acelite/ace/Task.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Task.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Get the current group id. @@ -6,6 +9,7 @@ ACE_INLINE int ACE_Task_Base::grp_id (void) const { ACE_TRACE ("ACE_Task_Base::grp_id"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, const_cast (this->lock_), -1)); return this->grp_id_; } @@ -57,7 +61,7 @@ ACE_INLINE size_t ACE_Task_Base::thr_count (void) const { ACE_TRACE ("ACE_Task_Base::thr_count"); - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, const_cast (this->lock_), 0)); return this->thr_count_; } diff --git a/dep/acelite/ace/Task_Ex_T.cpp b/dep/acelite/ace/Task_Ex_T.cpp index 801c433ab..a90ef95a7 100644 --- a/dep/acelite/ace/Task_Ex_T.cpp +++ b/dep/acelite/ace/Task_Ex_T.cpp @@ -1,3 +1,5 @@ +// $Id: Task_Ex_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_TASK_EX_T_CPP #define ACE_TASK_EX_T_CPP @@ -14,14 +16,9 @@ #include "ace/Task_Ex_T.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tycc (ACE_Task_Ex) - template void ACE_Task_Ex::dump (void) const { diff --git a/dep/acelite/ace/Task_Ex_T.h b/dep/acelite/ace/Task_Ex_T.h index 1f883dce7..04eadb794 100644 --- a/dep/acelite/ace/Task_Ex_T.h +++ b/dep/acelite/ace/Task_Ex_T.h @@ -4,6 +4,8 @@ /** * @file Task_Ex_T.h * + * $Id: Task_Ex_T.h 96061 2012-08-16 09:36:07Z mcorino $ + * * @author Kobi Cohen-Arazi */ //============================================================================= diff --git a/dep/acelite/ace/Task_Ex_T.inl b/dep/acelite/ace/Task_Ex_T.inl index a51323056..543e107ef 100644 --- a/dep/acelite/ace/Task_Ex_T.inl +++ b/dep/acelite/ace/Task_Ex_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Task_Ex_T.inl 96061 2012-08-16 09:36:07Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE void diff --git a/dep/acelite/ace/Task_T.cpp b/dep/acelite/ace/Task_T.cpp index b28dd2cce..78bc59704 100644 --- a/dep/acelite/ace/Task_T.cpp +++ b/dep/acelite/ace/Task_T.cpp @@ -1,3 +1,5 @@ +// $Id: Task_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_TASK_T_CPP #define ACE_TASK_T_CPP @@ -16,8 +18,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Task) - template void ACE_Task::dump (void) const { diff --git a/dep/acelite/ace/Task_T.h b/dep/acelite/ace/Task_T.h index 696117558..9b0cd9e2c 100644 --- a/dep/acelite/ace/Task_T.h +++ b/dep/acelite/ace/Task_T.h @@ -4,7 +4,9 @@ /** * @file Task_T.h * - * @author Douglas C. Schmidt + * $Id: Task_T.h 96061 2012-08-16 09:36:07Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Task_T.inl b/dep/acelite/ace/Task_T.inl index 99de01add..34ad25b0c 100644 --- a/dep/acelite/ace/Task_T.inl +++ b/dep/acelite/ace/Task_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Task_T.inl 96066 2012-08-16 12:45:46Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE void @@ -34,10 +37,10 @@ ACE_Task::ungetq (ACE_Message_Block *mb, ACE_Time_Va } template ACE_INLINE int -ACE_Task::flush (u_long f) +ACE_Task::flush (u_long flag) { ACE_TRACE ("ACE_Task::flush"); - if (ACE_BIT_ENABLED (f, ACE_Task_Flags::ACE_FLUSHALL)) + if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) return this->msg_queue_ != 0 && this->msg_queue_->close (); else return -1; // Note, need to be more careful about what we free... diff --git a/dep/acelite/ace/Test_and_Set.cpp b/dep/acelite/ace/Test_and_Set.cpp index 4ba0dd61d..15fbfe084 100644 --- a/dep/acelite/ace/Test_and_Set.cpp +++ b/dep/acelite/ace/Test_and_Set.cpp @@ -1,3 +1,5 @@ +// $Id: Test_and_Set.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_TEST_AND_SET_CPP #define ACE_TEST_AND_SET_CPP diff --git a/dep/acelite/ace/Test_and_Set.h b/dep/acelite/ace/Test_and_Set.h index 6ec541a69..b1e558f6d 100644 --- a/dep/acelite/ace/Test_and_Set.h +++ b/dep/acelite/ace/Test_and_Set.h @@ -3,6 +3,8 @@ //============================================================================= /** * @file Test_and_Set.h + * + * $Id: Test_and_Set.h 96230 2012-11-06 22:18:13Z schmidt $ */ //============================================================================= diff --git a/dep/acelite/ace/Thread.cpp b/dep/acelite/ace/Thread.cpp index c8ff2e3bf..952a51b6e 100644 --- a/dep/acelite/ace/Thread.cpp +++ b/dep/acelite/ace/Thread.cpp @@ -1,3 +1,5 @@ +// $Id: Thread.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/Thread.h" #if !defined (__ACE_INLINE__) diff --git a/dep/acelite/ace/Thread.h b/dep/acelite/ace/Thread.h index 6290de52e..d654ffea5 100644 --- a/dep/acelite/ace/Thread.h +++ b/dep/acelite/ace/Thread.h @@ -4,7 +4,9 @@ /** * @file Thread.h * - * @author Douglas Schmidt + * $Id: Thread.h 92060 2010-09-27 18:08:48Z johnnyw $ + * + * @author Douglas Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Thread.inl b/dep/acelite/ace/Thread.inl index 33f7fcf0b..5e08bd34d 100644 --- a/dep/acelite/ace/Thread.inl +++ b/dep/acelite/ace/Thread.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Thread.inl 95376 2011-12-20 15:39:02Z shuston $ + #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Thread_Adapter.cpp b/dep/acelite/ace/Thread_Adapter.cpp index 905eefddc..0afb322e7 100644 --- a/dep/acelite/ace/Thread_Adapter.cpp +++ b/dep/acelite/ace/Thread_Adapter.cpp @@ -1,3 +1,5 @@ +// $Id: Thread_Adapter.cpp 92682 2010-11-23 23:41:19Z shuston $ + #include "ace/Thread_Adapter.h" #include "ace/Thread_Manager.h" #include "ace/Thread_Exit.h" @@ -42,8 +44,6 @@ ACE_Thread_Adapter::~ACE_Thread_Adapter (void) { } -ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Adapter); - ACE_THR_FUNC_RETURN ACE_Thread_Adapter::invoke (void) { diff --git a/dep/acelite/ace/Thread_Adapter.h b/dep/acelite/ace/Thread_Adapter.h index 660f120e6..6880e2cb2 100644 --- a/dep/acelite/ace/Thread_Adapter.h +++ b/dep/acelite/ace/Thread_Adapter.h @@ -4,6 +4,8 @@ /** * @file Thread_Adapter.h * + * $Id: Thread_Adapter.h 92682 2010-11-23 23:41:19Z shuston $ + * * @author Carlos O'Ryan */ //============================================================================= @@ -67,8 +69,6 @@ public: /// Accessor for the optional ACE_Thread_Manager. ACE_Thread_Manager *thr_mgr (void); - ACE_ALLOC_HOOK_DECLARE; - protected: /// Ensure that this object must be allocated on the heap. ~ACE_Thread_Adapter (void); diff --git a/dep/acelite/ace/Thread_Adapter.inl b/dep/acelite/ace/Thread_Adapter.inl index 06751eecd..6def13be5 100644 --- a/dep/acelite/ace/Thread_Adapter.inl +++ b/dep/acelite/ace/Thread_Adapter.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Thread_Adapter.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Thread_Manager * diff --git a/dep/acelite/ace/Thread_Control.cpp b/dep/acelite/ace/Thread_Control.cpp index c00234e5f..4046c07ee 100644 --- a/dep/acelite/ace/Thread_Control.cpp +++ b/dep/acelite/ace/Thread_Control.cpp @@ -1,3 +1,5 @@ +// $Id: Thread_Control.cpp 94054 2011-05-11 18:28:20Z johnnyw $ + #include "ace/Thread_Control.h" #include "ace/Thread_Manager.h" diff --git a/dep/acelite/ace/Thread_Control.h b/dep/acelite/ace/Thread_Control.h index a392d83a5..392eb7a62 100644 --- a/dep/acelite/ace/Thread_Control.h +++ b/dep/acelite/ace/Thread_Control.h @@ -4,6 +4,8 @@ /** * @file Thread_Control.h * + * $Id: Thread_Control.h 94054 2011-05-11 18:28:20Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/Thread_Control.inl b/dep/acelite/ace/Thread_Control.inl index 20d03fe78..0f8e0c9ec 100644 --- a/dep/acelite/ace/Thread_Control.inl +++ b/dep/acelite/ace/Thread_Control.inl @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: Thread_Control.inl 91730 2010-09-13 09:31:11Z johnnyw $ + #include "ace/OS_NS_macros.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Thread_Exit.cpp b/dep/acelite/ace/Thread_Exit.cpp index 0d35cdba2..8f6484093 100644 --- a/dep/acelite/ace/Thread_Exit.cpp +++ b/dep/acelite/ace/Thread_Exit.cpp @@ -1,3 +1,5 @@ +// $Id: Thread_Exit.cpp 92580 2010-11-15 09:48:02Z johnnyw $ + #include "ace/Thread_Exit.h" #include "ace/Managed_Object.h" #include "ace/Thread_Manager.h" @@ -90,8 +92,6 @@ ACE_Thread_Exit::~ACE_Thread_Exit (void) ACE_OS_TRACE ("ACE_Thread_Exit::~ACE_Thread_Exit"); } -ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Exit) - ACE_Thread_Exit_Maybe::ACE_Thread_Exit_Maybe (int flag) : instance_ (0) { diff --git a/dep/acelite/ace/Thread_Exit.h b/dep/acelite/ace/Thread_Exit.h index a6ac6516c..5b614e2e8 100644 --- a/dep/acelite/ace/Thread_Exit.h +++ b/dep/acelite/ace/Thread_Exit.h @@ -4,6 +4,8 @@ /** * @file Thread_Exit.h * + * $Id: Thread_Exit.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Carlos O'Ryan */ //============================================================================= @@ -57,8 +59,6 @@ public: /// singleton. static void cleanup (void *instance); - ACE_ALLOC_HOOK_DECLARE; - private: /// Automatically add/remove the thread from the /// ACE_Thread_Manager. diff --git a/dep/acelite/ace/Thread_Hook.cpp b/dep/acelite/ace/Thread_Hook.cpp index f1b07e392..549e51e39 100644 --- a/dep/acelite/ace/Thread_Hook.cpp +++ b/dep/acelite/ace/Thread_Hook.cpp @@ -1,3 +1,5 @@ +// $Id: Thread_Hook.cpp 97246 2013-08-07 07:10:20Z johnnyw $ + #include "ace/Thread_Hook.h" #include "ace/Object_Manager_Base.h" diff --git a/dep/acelite/ace/Thread_Hook.h b/dep/acelite/ace/Thread_Hook.h index dcb6d396e..ff0f03a4d 100644 --- a/dep/acelite/ace/Thread_Hook.h +++ b/dep/acelite/ace/Thread_Hook.h @@ -4,6 +4,8 @@ /** * @file Thread_Hook.h * + * $Id: Thread_Hook.h 97246 2013-08-07 07:10:20Z johnnyw $ + * * @author Carlos O'Ryan */ //============================================================================= diff --git a/dep/acelite/ace/Thread_Manager.cpp b/dep/acelite/ace/Thread_Manager.cpp index 172e4a43a..d5cd969c4 100644 --- a/dep/acelite/ace/Thread_Manager.cpp +++ b/dep/acelite/ace/Thread_Manager.cpp @@ -1,3 +1,5 @@ +// $Id: Thread_Manager.cpp 97769 2014-06-05 06:37:53Z johnnyw $ + #include "ace/TSS_T.h" #include "ace/Thread_Manager.h" #include "ace/Dynamic.h" @@ -25,8 +27,6 @@ ACE_At_Thread_Exit_Func::~ACE_At_Thread_Exit_Func (void) this->do_apply (); } -ACE_ALLOC_HOOK_DEFINE(ACE_At_Thread_Exit_Func) - void ACE_At_Thread_Exit_Func::apply (void) { @@ -370,9 +370,6 @@ ACE_Thread_Manager::ACE_Thread_Manager (size_t prealloc, #endif /* ACE_HAS_THREADS */ , thread_desc_freelist_ (ACE_FREE_LIST_WITH_POOL, prealloc, lwm, hwm, inc) -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - , join_cond_ (this->lock_) -#endif { ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager"); } @@ -389,9 +386,6 @@ ACE_Thread_Manager::ACE_Thread_Manager (const ACE_Condition_Attributes &attribut #endif /* ACE_HAS_THREADS */ , thread_desc_freelist_ (ACE_FREE_LIST_WITH_POOL, prealloc, lwm, hwm, inc) -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - , join_cond_ (this->lock_) -#endif { #if !defined (ACE_HAS_THREADS) ACE_UNUSED_ARG (attributes); @@ -588,11 +582,7 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, // Create a new thread running . *Must* be called with the // held... // Get a "new" Thread Descriptor from the freelist. -#if defined (ACE_HAS_CPP11) - std::unique_ptr new_thr_desc (this->thread_desc_freelist_.remove ()); -#else auto_ptr new_thr_desc (this->thread_desc_freelist_.remove ()); -#endif /* ACE_HAS_CPP11 */ // Reset thread descriptor status new_thr_desc->reset (this); @@ -619,11 +609,7 @@ ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, flags), -1); # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ -#if defined ACE_HAS_CPP11 - std::unique_ptr auto_thread_args (static_cast (thread_args)); -#else auto_ptr auto_thread_args (static_cast (thread_args)); -#endif ACE_TRACE ("ACE_Thread_Manager::spawn_i"); ACE_hthread_t thr_handle; @@ -1009,40 +995,6 @@ int ACE_Thread_Manager::join_thr (ACE_Thread_Descriptor *td, int) { ACE_TRACE ("ACE_Thread_Manager::join_thr"); - -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); - - if (ACE_BIT_DISABLED (td->flags_, THR_DETACHED | THR_DAEMON) - || ACE_BIT_ENABLED (td->flags_, THR_JOINABLE)) - { - if (td->terminated_) - return 0; - ACE_SET_BITS (td->thr_state_, ACE_THR_JOINING); - } - else - { - errno = EINVAL; - return -1; - } - - const ACE_thread_t waiting_id = td->thr_id_; - - while (true) - { - if (this->join_cond_.wait () == -1) - return -1; - - bool found = false; - for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); - !iter.done () && !found; iter.advance ()) - if (ACE_OS::thr_equal (iter.next ()->thr_id_, waiting_id)) - found = true; - if (!found) - break; - } - -#else int const result = ACE_Thread::join (td->thr_handle_); if (result != 0) { @@ -1053,7 +1005,6 @@ ACE_Thread_Manager::join_thr (ACE_Thread_Descriptor *td, int) errno = result; return -1; } -#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN return 0; } @@ -1497,12 +1448,10 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status) if (ACE_OS::thr_equal (biter.next ()->thr_id_, tid)) { ACE_Thread_Descriptor_Base *tdbl = biter.advance_and_remove (false); -#ifndef ACE_LACKS_PTHREAD_JOIN if (ACE_Thread::join (tdbl->thr_handle_, status) == -1) { return -1; } -#endif delete tdbl; // return immediately if we've found the thread we want to join. @@ -1511,8 +1460,9 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status) } #endif /* !ACE_HAS_VXTHREADS */ - typedef ACE_Double_Linked_List_Iterator iter_t; - for (iter_t iter (this->thr_list_); !iter.done (); iter.advance ()) + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) { // If threads are created as THR_DETACHED or THR_DAEMON, we // can't help much. @@ -1522,7 +1472,7 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status) { tdb = *iter.next (); ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING); - found = true; + found = 1; break; } } @@ -1530,31 +1480,10 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status) if (!found) return -1; // Didn't find the thread we want or the thread is not joinable. - -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - ACE_UNUSED_ARG (status); // not currently supported without pthread_join - - while (found) - { - if (this->join_cond_.wait () == -1) - return -1; - - found = false; - for (iter_t iter (this->thr_list_); !iter.done () && !found; iter.advance ()) - if (ACE_OS::thr_equal (iter.next ()->thr_id_, tid) && - (ACE_BIT_DISABLED (iter.next ()->flags_, THR_DETACHED | THR_DAEMON) - || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE))) - found = true; - } - -#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN - } -#ifndef ACE_LACKS_PTHREAD_JOIN if (ACE_Thread::join (tdb.thr_handle_, status) == -1) return -1; -#endif return 0; } @@ -1586,8 +1515,9 @@ ACE_Thread_Manager::wait_grp (int grp_id) -1); #endif /* !ACE_HAS_VXTHREADS */ - typedef ACE_Double_Linked_List_Iterator iter_t; - for (iter_t iter (this->thr_list_); !iter.done (); iter.advance ()) + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) { // If threads are created as THR_DETACHED or THR_DAEMON, we // can't help much. @@ -1615,28 +1545,6 @@ ACE_Thread_Manager::wait_grp (int grp_id) } } #endif /* !ACE_HAS_VXTHREADS */ - -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - - while (copy_count) - { - if (this->join_cond_.wait () == -1) - { - delete[] copy_table; - return -1; - } - - copy_count = 0; - for (iter_t iter (this->thr_list_); !iter.done () && !copy_count; iter.advance ()) - if (iter.next ()->grp_id_ == grp_id && - ACE_BIT_ENABLED (iter.next ()->thr_state_, ACE_THR_JOINING) && - (ACE_BIT_DISABLED (iter.next ()->flags_, - THR_DETACHED | THR_DAEMON) - || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE))) - ++copy_count; - } - -#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN } // Now actually join() with all the threads in this group. @@ -1696,10 +1604,6 @@ ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, bool do_thread_exit) // @@ We call Thread_Descriptor terminate this realize the cleanup // process itself. td->terminate(); - -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - this->join_cond_.broadcast (); -#endif } } @@ -1798,12 +1702,11 @@ ACE_Thread_Manager::wait (const ACE_Time_Value *timeout, while ((item = term_thr_list_copy.delete_head ()) != 0) { -#ifndef ACE_LACKS_PTHREAD_JOIN if (ACE_BIT_DISABLED (item->flags_, THR_DETACHED | THR_DAEMON) || ACE_BIT_ENABLED (item->flags_, THR_JOINABLE)) // Detached handles shouldn't reached here. (void) ACE_Thread::join (item->thr_handle_); -#endif + delete item; } @@ -1876,8 +1779,9 @@ ACE_Thread_Manager::wait_task (ACE_Task_Base *task) -1); #endif /* !ACE_HAS_VXTHREADS */ - typedef ACE_Double_Linked_List_Iterator iter_t; - for (iter_t iter (this->thr_list_); !iter.done (); iter.advance ()) + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) { // If threads are created as THR_DETACHED or THR_DAEMON, we // can't wait on them here. @@ -1887,14 +1791,6 @@ ACE_Thread_Manager::wait_task (ACE_Task_Base *task) || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE))) { -# ifdef ACE_LACKS_PTHREAD_JOIN - if (ACE_OS::thr_equal (iter.next ()->thr_id_, ACE_OS::thr_self ())) - { - errno = EDEADLK; - delete[] copy_table; - return -1; - } -# endif ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING); copy_table[copy_count++] = *iter.next (); @@ -1910,35 +1806,11 @@ ACE_Thread_Manager::wait_task (ACE_Task_Base *task) if (titer.next ()->task_ == task) { ACE_Thread_Descriptor_Base *tdb = titer.advance_and_remove (false); -# ifndef ACE_LACKS_PTHREAD_JOIN copy_table[copy_count++] = *tdb; -# endif delete tdb; } } #endif /* !ACE_HAS_VXTHREADS */ - -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - - while (copy_count) - { - if (this->join_cond_.wait () == -1) - { - delete[] copy_table; - return -1; - } - - copy_count = 0; - for (iter_t iter (this->thr_list_); !iter.done () && !copy_count; iter.advance ()) - if (iter.next ()->task_ == task && - ACE_BIT_ENABLED (iter.next ()->thr_state_, ACE_THR_JOINING) && - (ACE_BIT_DISABLED (iter.next ()->flags_, - THR_DETACHED | THR_DAEMON) - || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE))) - ++copy_count; - } - -#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN } // Now to do the actual work @@ -2374,6 +2246,4 @@ ACE_Thread_Manager::get_grp (ACE_Task_Base *task, int &grp_id) return 0; } -ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Descriptor_Base); - ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Thread_Manager.h b/dep/acelite/ace/Thread_Manager.h index 4945ef547..b1465ebb2 100644 --- a/dep/acelite/ace/Thread_Manager.h +++ b/dep/acelite/ace/Thread_Manager.h @@ -4,7 +4,9 @@ /** * @file Thread_Manager.h * - * @author Douglas C. Schmidt + * $Id: Thread_Manager.h 96985 2013-04-11 15:50:32Z huangh $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -137,8 +139,6 @@ public: virtual ~ACE_At_Thread_Exit_Func (void); - ACE_ALLOC_HOOK_DECLARE; - protected: /// The object to be cleanup void *object_; @@ -194,8 +194,6 @@ public: /// ACE_Task_Base associated with this thread.; ACE_Task_Base *task (void) const; - ACE_ALLOC_HOOK_DECLARE; - protected: /// Reset this base thread descriptor. void reset (void); @@ -226,7 +224,7 @@ protected: * @class ACE_Thread_Descriptor * * @brief Information for controlling threads that run under the control - * of the Thread_Manager. + * of the . */ class ACE_Export ACE_Thread_Descriptor : public ACE_Thread_Descriptor_Base { @@ -275,7 +273,7 @@ public: * "cleanup_hook" function; the first parameter is the object (or * array) to be destroyed. Returns 0 on success, non-zero on * failure: -1 if virtual memory is exhausted or 1 if the object (or - * array) had already been registered. + * arrayt) had already been registered. */ int at_exit (void *object, ACE_CLEANUP_FUNC cleanup_hook, @@ -304,13 +302,6 @@ public: void set_next (ACE_Thread_Descriptor *td); ACE_Thread_Descriptor *get_next (void) const; -protected: - /// Run the AT_Thread_Exit hooks. - void do_at_exit (void); - - /// Terminate realize the cleanup process to thread termination - void terminate (void); - private: /// Reset this thread descriptor. void reset (ACE_Thread_Manager *tm); @@ -324,7 +315,12 @@ private: void at_push (ACE_At_Thread_Exit* cleanup, bool is_owner = false); -private: + /// Run the AT_Thread_Exit hooks. + void do_at_exit (void); + + /// Terminate realize the cleanup process to thread termination + void terminate (void); + /// Thread_Descriptor is the ownership of ACE_Log_Msg if log_msg_!=0 /// This can occur because ACE_TSS_cleanup was executed before terminate. ACE_Log_Msg *log_msg_; @@ -342,7 +338,7 @@ private: #endif /// Pointer to an ACE_Thread_Manager or NULL if there's no - /// ACE_Thread_Manager + /// ACE_Thread_Manager> ACE_Thread_Manager* tm_; /// Registration lock to prevent premature removal of thread descriptor. @@ -389,7 +385,7 @@ class ACE_Export ACE_Thread_Manager public: friend class ACE_Thread_Control; - // Allow ACE_Thread_Exit to register the global TSS instance object. + // Allow ACE_THread_Exit to register the global TSS instance object. friend class ACE_Thread_Exit; friend class ACE_Thread_Descriptor; @@ -905,7 +901,7 @@ public: int kill_task (ACE_Task_Base *task, int signum); /** - * Cancel all threads in an ACE_Task. If @a async_cancel is non-0, + * Cancel all threads in an ACE_Task. If is non-0, * then asynchronously cancel these threads if the OS platform * supports cancellation. Otherwise, perform a "cooperative" * cancellation. @@ -1037,7 +1033,7 @@ public: int get_grp (ACE_Task_Base *task, int &grp_id); /// Return a count of the current number of threads active in the - /// Thread_Manager. + /// . size_t count_threads (void) const; /// Get the state of the thread. Returns false if the thread is not @@ -1071,7 +1067,7 @@ public: * second parameter to the "cleanup_hook" function; the first * parameter is the object (or array) to be destroyed. * "cleanup_hook", for example, may delete the object (or array). - * If @a cleanup_hook == 0, the @a object will _NOT_ get cleanup at + * If == 0, the will _NOT_ get cleanup at * thread exit. You can use this to cancel the previously added * at_exit. */ @@ -1123,12 +1119,12 @@ protected: /// Run the registered hooks when the thread exits. void run_thread_exit_hooks (int i); - /// Locate the index of the table slot occupied by @a t_id. Returns - /// -1 if @a t_id is not in the table doesn't contain @a t_id. + /// Locate the index of the table slot occupied by . Returns + /// -1 if is not in the table doesn't contain . ACE_Thread_Descriptor *find_thread (ACE_thread_t t_id); - /// Locate the index of the table slot occupied by @a h_id. Returns - /// -1 if @a h_id is not in the table doesn't contain @a h_id. + /// Locate the index of the table slot occupied by . Returns + /// -1 if is not in the table doesn't contain . ACE_Thread_Descriptor *find_hthread (ACE_hthread_t h_id); /** @@ -1207,7 +1203,7 @@ protected: int cancel_thr (ACE_Thread_Descriptor *td, int async_cancel = 0); - /// Register a thread as terminated and put it into the terminated_thr_list_. + /// Register a thread as terminated and put it into the . int register_as_terminated (ACE_Thread_Descriptor *td); /// Setting the static ACE_TSS_TYPE (ACE_Thread_Exit) *thr_exit_ pointer. @@ -1238,7 +1234,7 @@ protected: // = ACE_Thread_Mutex and condition variable for synchronizing termination. #if defined (ACE_HAS_THREADS) - /// Serialize access to the zero_cond_. + /// Serialize access to the . ACE_Thread_Mutex lock_; /// Keep track of when there are no more threads. @@ -1247,10 +1243,6 @@ protected: ACE_Locked_Free_List thread_desc_freelist_; -#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN) - ACE_Condition_Thread_Mutex join_cond_; -#endif - private: #if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) /// Pointer to a process-wide ACE_Thread_Manager. diff --git a/dep/acelite/ace/Thread_Manager.inl b/dep/acelite/ace/Thread_Manager.inl index e3ddda3a8..4b9afe979 100644 --- a/dep/acelite/ace/Thread_Manager.inl +++ b/dep/acelite/ace/Thread_Manager.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Thread_Manager.inl 85341 2009-05-14 11:07:37Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Thread_Mutex.cpp b/dep/acelite/ace/Thread_Mutex.cpp index b51505f7b..482b45fca 100644 --- a/dep/acelite/ace/Thread_Mutex.cpp +++ b/dep/acelite/ace/Thread_Mutex.cpp @@ -1,9 +1,11 @@ /** * @file Thread_Mutex.cpp * + * $Id: Thread_Mutex.cpp 96985 2013-04-11 15:50:32Z huangh $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/Thread_Mutex.h" diff --git a/dep/acelite/ace/Thread_Mutex.h b/dep/acelite/ace/Thread_Mutex.h index 9270aa68a..71fff2db1 100644 --- a/dep/acelite/ace/Thread_Mutex.h +++ b/dep/acelite/ace/Thread_Mutex.h @@ -4,9 +4,11 @@ /** * @file Thread_Mutex.h * + * $Id: Thread_Mutex.h 96061 2012-08-16 09:36:07Z mcorino $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Thread_Mutex.inl b/dep/acelite/ace/Thread_Mutex.inl index e3d271932..dfd2d1600 100644 --- a/dep/acelite/ace/Thread_Mutex.inl +++ b/dep/acelite/ace/Thread_Mutex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Thread_Mutex.inl 91813 2010-09-17 07:52:52Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const ACE_thread_mutex_t & diff --git a/dep/acelite/ace/Thread_Semaphore.cpp b/dep/acelite/ace/Thread_Semaphore.cpp index 1fa0bf178..0affc662b 100644 --- a/dep/acelite/ace/Thread_Semaphore.cpp +++ b/dep/acelite/ace/Thread_Semaphore.cpp @@ -1,19 +1,17 @@ /** * @file Thread_Semaphore.cpp * + * $Id: Thread_Semaphore.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + * * Originally in Synch.cpp * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ #include "ace/Thread_Semaphore.h" #if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/Thread_Semaphore.inl" #endif /* __ACE_INLINE__ */ @@ -25,8 +23,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Semaphore) - void ACE_Thread_Semaphore::dump (void) const { diff --git a/dep/acelite/ace/Thread_Semaphore.h b/dep/acelite/ace/Thread_Semaphore.h index c59e25ba9..c9843a919 100644 --- a/dep/acelite/ace/Thread_Semaphore.h +++ b/dep/acelite/ace/Thread_Semaphore.h @@ -4,9 +4,11 @@ /** * @file Thread_Semaphore.h * + * $Id: Thread_Semaphore.h 95807 2012-06-01 12:44:19Z johnnyw $ + * * Moved from Synch.h. * - * @author Douglas C. Schmidt + * @author Douglas C. Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Thread_Semaphore.inl b/dep/acelite/ace/Thread_Semaphore.inl index 9a2a0affe..b64ec3c08 100644 --- a/dep/acelite/ace/Thread_Semaphore.inl +++ b/dep/acelite/ace/Thread_Semaphore.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Thread_Semaphore.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/Throughput_Stats.cpp b/dep/acelite/ace/Throughput_Stats.cpp index 6ecc4c8aa..d86121a47 100644 --- a/dep/acelite/ace/Throughput_Stats.cpp +++ b/dep/acelite/ace/Throughput_Stats.cpp @@ -1,3 +1,5 @@ +// $Id: Throughput_Stats.cpp 97628 2014-02-24 11:29:43Z johnnyw $ + #include "ace/Throughput_Stats.h" #include "ace/OS_NS_stdio.h" diff --git a/dep/acelite/ace/Throughput_Stats.h b/dep/acelite/ace/Throughput_Stats.h index f3d1744c5..0911e8d4b 100644 --- a/dep/acelite/ace/Throughput_Stats.h +++ b/dep/acelite/ace/Throughput_Stats.h @@ -4,6 +4,8 @@ /** * @file Throughput_Stats.h * + * $Id: Throughput_Stats.h 95743 2012-05-13 12:29:28Z johnnyw $ + * * @author David L. Levine */ //========================================================================== diff --git a/dep/acelite/ace/Time_Policy.cpp b/dep/acelite/ace/Time_Policy.cpp index 4d2e6880b..c44daa7fe 100644 --- a/dep/acelite/ace/Time_Policy.cpp +++ b/dep/acelite/ace/Time_Policy.cpp @@ -1,3 +1,5 @@ +// $Id: Time_Policy.cpp 96061 2012-08-16 09:36:07Z mcorino $ + #include "ace/Time_Policy.h" #if !defined(__ACE_INLINE__) diff --git a/dep/acelite/ace/Time_Policy.h b/dep/acelite/ace/Time_Policy.h index 01bef1364..a94dd9591 100644 --- a/dep/acelite/ace/Time_Policy.h +++ b/dep/acelite/ace/Time_Policy.h @@ -4,6 +4,8 @@ /** * @file Time_Policy.h * + * $Id: Time_Policy.h 96061 2012-08-16 09:36:07Z mcorino $ + * * @author Carlos O'Ryan * @author Martin Corino */ @@ -42,6 +44,7 @@ public: * @class ACE_HR_Time_Policy * * @brief Implement a time policy based on the ACE Highres timer. + * */ class ACE_Export ACE_HR_Time_Policy { @@ -130,6 +133,7 @@ private: * * @brief Abstract base class for dynamically loaded and/or shared * time policies. + * */ class ACE_Export ACE_Dynamic_Time_Policy_Base { diff --git a/dep/acelite/ace/Time_Policy.inl b/dep/acelite/ace/Time_Policy.inl index 59650b8e1..b59a0f675 100644 --- a/dep/acelite/ace/Time_Policy.inl +++ b/dep/acelite/ace/Time_Policy.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Time_Policy.inl 96061 2012-08-16 09:36:07Z mcorino $ + #include "ace/OS_NS_sys_time.h" #include "ace/High_Res_Timer.h" diff --git a/dep/acelite/ace/Time_Policy_T.cpp b/dep/acelite/ace/Time_Policy_T.cpp index 4ca20433e..6845131aa 100644 --- a/dep/acelite/ace/Time_Policy_T.cpp +++ b/dep/acelite/ace/Time_Policy_T.cpp @@ -1,3 +1,5 @@ +// $Id: Time_Policy_T.cpp 96061 2012-08-16 09:36:07Z mcorino $ + #ifndef ACE_TIME_POLICY_T_CPP #define ACE_TIME_POLICY_T_CPP diff --git a/dep/acelite/ace/Time_Policy_T.h b/dep/acelite/ace/Time_Policy_T.h index 85d0dde6a..bde0c5c45 100644 --- a/dep/acelite/ace/Time_Policy_T.h +++ b/dep/acelite/ace/Time_Policy_T.h @@ -4,6 +4,8 @@ /** * @file Time_Policy_T.h * + * $Id: Time_Policy_T.h 96061 2012-08-16 09:36:07Z mcorino $ + * * @author Martin Corino */ //============================================================================= @@ -28,6 +30,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @brief Template class implementing a dynamic time policy based on * another time policy + * */ template class ACE_Time_Policy_T : public ACE_Dynamic_Time_Policy_Base diff --git a/dep/acelite/ace/Time_Policy_T.inl b/dep/acelite/ace/Time_Policy_T.inl index 25a5ea079..23a07813a 100644 --- a/dep/acelite/ace/Time_Policy_T.inl +++ b/dep/acelite/ace/Time_Policy_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Time_Policy_T.inl 96066 2012-08-16 12:45:46Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Time_Value.cpp b/dep/acelite/ace/Time_Value.cpp index 77c151e13..32b9b80dd 100644 --- a/dep/acelite/ace/Time_Value.cpp +++ b/dep/acelite/ace/Time_Value.cpp @@ -1,8 +1,6 @@ -#include "ace/Time_Value.h" +// $Id: Time_Value.cpp 97886 2014-09-09 06:43:37Z johnnyw $ -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ +#include "ace/Time_Value.h" #if !defined (__ACE_INLINE__) #include "ace/Time_Value.inl" @@ -18,8 +16,6 @@ # include #endif /* ACE_HAS_CPP98_IOSTREAMS */ -#include - #ifdef ACE_HAS_CPP11 # include #endif /* ACE_HAS_CPP11 */ @@ -176,30 +172,52 @@ ACE_Time_Value::dump (void) const void ACE_Time_Value::normalize (bool saturate) { - // ACE_OS_TRACE ("ACE_Time_Value::normalize"); - if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS || - this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS) - { - time_t const sec = std::abs(this->tv_.tv_usec) / ACE_ONE_SECOND_IN_USECS * (this->tv_.tv_usec > 0 ? 1 : -1); - suseconds_t const usec = static_cast (this->tv_.tv_usec - sec * ACE_ONE_SECOND_IN_USECS); + // // ACE_OS_TRACE ("ACE_Time_Value::normalize"); + // From Hans Rohnert... - if (saturate && this->tv_.tv_sec > 0 && sec > 0 && - ACE_Numeric_Limits::max() - this->tv_.tv_sec < sec) - { - this->tv_.tv_sec = ACE_Numeric_Limits::max(); - this->tv_.tv_usec = ACE_ONE_SECOND_IN_USECS - 1; - } - else if (saturate && this->tv_.tv_sec < 0 && sec < 0 && - ACE_Numeric_Limits::min() - this->tv_.tv_sec > sec) - { - this->tv_.tv_sec = ACE_Numeric_Limits::min(); - this->tv_.tv_usec = -ACE_ONE_SECOND_IN_USECS + 1; - } + if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS) + { + /*! \todo This loop needs some optimization. + */ + if (!saturate) // keep the conditionnal expression outside the while loop to minimize performance cost + do + { + ++this->tv_.tv_sec; + this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; + } + while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS); else - { - this->tv_.tv_sec += sec; - this->tv_.tv_usec = usec; - } + do + if (this->tv_.tv_sec < ACE_Numeric_Limits::max()) + { + ++this->tv_.tv_sec; + this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; + } + else + this->tv_.tv_usec = ACE_ONE_SECOND_IN_USECS - 1; + while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS); + } + else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS) + { + /*! \todo This loop needs some optimization. + */ + if (!saturate) + do + { + --this->tv_.tv_sec; + this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; + } + while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS); + else + do + if (this->tv_.tv_sec > ACE_Numeric_Limits::min()) + { + --this->tv_.tv_sec; + this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; + } + else + this->tv_.tv_usec = -ACE_ONE_SECOND_IN_USECS + 1; + while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS); } if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0) @@ -317,7 +335,7 @@ ACE_Time_Value::operator *= (double d) #ifdef ACE_HAS_CPP98_IOSTREAMS ostream &operator<<(ostream &o, const ACE_Time_Value &v) { - char const oldFiller = o.fill (); + char oldFiller = o.fill (); o.fill ('0'); const timeval *tv = v; if (tv->tv_sec) @@ -325,9 +343,9 @@ ostream &operator<<(ostream &o, const ACE_Time_Value &v) o << tv->tv_sec; if (tv->tv_usec) #ifdef ACE_HAS_CPP11 - o << '.' << std::setw (6) << std::labs (tv->tv_usec); + o << '.' << std::setw (6) << std::abs (tv->tv_usec); #else - o << '.' << std::setw (6) << ACE_STD_NAMESPACE::labs (tv->tv_usec); + o << '.' << std::setw (6) << ACE_STD_NAMESPACE::abs (tv->tv_usec); #endif } else if (tv->tv_usec < 0) diff --git a/dep/acelite/ace/Time_Value.h b/dep/acelite/ace/Time_Value.h index 7b67867ee..522b1e0b0 100644 --- a/dep/acelite/ace/Time_Value.h +++ b/dep/acelite/ace/Time_Value.h @@ -4,7 +4,9 @@ /** * @file Time_Value.h * - * @author Douglas C. Schmidt + * $Id: Time_Value.h 96061 2012-08-16 09:36:07Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -21,11 +23,6 @@ # include "ace/os_include/os_time.h" -#if defined (ACE_HAS_CPP11) -# include -# include "ace/Truncate.h" -#endif /* ACE_HAS_CPP11 */ - // Define some helpful constants. // Not type-safe, and signed. For backward compatibility. #define ACE_ONE_SECOND_IN_MSECS 1000L @@ -83,21 +80,9 @@ public: /// Construct the ACE_Time_Value object from a timespec_t. explicit ACE_Time_Value (const timespec_t &t); -#if defined (ACE_HAS_CPP11) - /// Construct the ACE_Time_Value object from a chrono duration. - template< class Rep, class Period > - explicit ACE_Time_Value (const std::chrono::duration& duration) - { - this->set (duration); - } -#endif /* ACE_HAS_CPP11 */ - /// Destructor virtual ~ACE_Time_Value (); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - # if defined (ACE_WIN32) /// Construct the ACE_Time_Value object from a Win32 FILETIME explicit ACE_Time_Value (const FILETIME &ft); @@ -117,25 +102,10 @@ public: void set (const timespec_t &t); # if defined (ACE_WIN32) - /// Initializes the ACE_Time_Value object from a Win32 FILETIME. + /// Initializes the ACE_Time_Value object from a Win32 FILETIME. void set (const FILETIME &ft); # endif /* ACE_WIN32 */ -#if defined (ACE_HAS_CPP11) - /// Initializes the ACE_Time_Value object from a std::duration. - template< class Rep, class Period > - void set (const std::chrono::duration& duration) - { - std::chrono::seconds const s { - std::chrono::duration_cast (duration)}; - - std::chrono::microseconds const usec { - std::chrono::duration_cast( - duration % std::chrono::seconds (1))}; - this->set (s.count (), ACE_Utils::truncate_cast(usec.count ())); - } -#endif /* ACE_HAS_CPP11 */ - /// Converts from ACE_Time_Value format into milliseconds format. /** * @return Sum of second field (in milliseconds) and microsecond field @@ -264,10 +234,10 @@ public: /// Add @a tv to this. ACE_Time_Value &operator += (time_t tv); - /// Assign @a tv to this + /// Assign @ tv to this ACE_Time_Value &operator = (const ACE_Time_Value &tv); - /// Assign @a tv to this + /// Assign @ tv to this ACE_Time_Value &operator = (time_t tv); /// Subtract @a tv to this. @@ -276,39 +246,6 @@ public: /// Subtract @a tv to this. ACE_Time_Value &operator -= (time_t tv); -#if defined (ACE_HAS_CPP11) - /// Add @a std::duration to this. - template< class Rep, class Period > - ACE_Time_Value &operator += (const std::chrono::duration& duration) - { - const ACE_Time_Value tv (duration); - this->sec (this->sec () + tv.sec ()); - this->usec (this->usec () + tv.usec ()); - this->normalize (); - return *this; - } - - /// Assign @a std::duration to this - template< class Rep, class Period > - ACE_Time_Value &operator = (const std::chrono::duration& duration) - { - this->set (duration); - return *this; - } - - /// Subtract @a std::duration to this. - template< class Rep, class Period > - ACE_Time_Value &operator -= (const std::chrono::duration& duration) - { - const ACE_Time_Value tv (duration); - this->sec (this->sec () - tv.sec ()); - this->usec (this->usec () - tv.usec ()); - this->normalize (); - return *this; - } -#endif /* ACE_HAS_CPP11 */ - - /** \brief Multiply the time value by the @a d factor. \note The result of the operator is valid for results from range @@ -475,66 +412,6 @@ extern ACE_Export ostream &operator<<( ostream &o, const ACE_Time_Value &v ); ACE_END_VERSIONED_NAMESPACE_DECL -#if defined (ACE_HAS_CPP11) - -// Additional chrono operators. - -namespace std -{ - namespace chrono - { - /** - * @name Streaming ACE_Time_Value to chrono - * - * Streaming an ACE_Time_Value into one of the chrono types (nanoseconds, - * microseconds, milliseconds, seconds, minutes, or hours). - * - */ - //@{ - ACE_Export nanoseconds& operator <<(nanoseconds &ns, ACE_Time_Value const &tv); - ACE_Export microseconds& operator <<(microseconds &us, ACE_Time_Value const &tv); - ACE_Export milliseconds& operator <<(milliseconds &ms, ACE_Time_Value const &tv); - ACE_Export seconds& operator <<(seconds &s, ACE_Time_Value const &tv); - ACE_Export minutes& operator <<(minutes &m, ACE_Time_Value const &tv); - ACE_Export hours& operator <<(hours &h, ACE_Time_Value const &tv); - //@} - - /** - * @name Adding ACE_Time_Value to chrono - * - * Adding an ACE_Time_Value to one of the chrono types (nanoseconds, - * microseconds, milliseconds, seconds, minutes, or hours). - * - */ - //@{ - ACE_Export nanoseconds& operator +=(nanoseconds &ns, ACE_Time_Value const &tv); - ACE_Export microseconds& operator +=(microseconds &us, ACE_Time_Value const &tv); - ACE_Export milliseconds& operator +=(milliseconds &ms, ACE_Time_Value const &tv); - ACE_Export seconds& operator +=(seconds &s, ACE_Time_Value const &tv); - ACE_Export minutes& operator +=(minutes &m, ACE_Time_Value const &tv); - ACE_Export hours& operator +=(hours &h, ACE_Time_Value const &tv); - //@} - - /** - * @name Substracting ACE_Time_Value from chrono - * - * Substracting an ACE_Time_Value from one of the chrono types (nanoseconds, - * microseconds, milliseconds, seconds, minutes, or hours). - * - */ - //@{ - ACE_Export nanoseconds& operator -=(nanoseconds &ns, ACE_Time_Value const &tv); - ACE_Export microseconds& operator -=(microseconds &us, ACE_Time_Value const &tv); - ACE_Export milliseconds& operator -=(milliseconds &ms, ACE_Time_Value const &tv); - ACE_Export seconds& operator -=(seconds &s, ACE_Time_Value const &tv); - ACE_Export minutes& operator -=(minutes &m, ACE_Time_Value const &tv); - ACE_Export hours& operator -=(hours &h, ACE_Time_Value const &tv); - //@} - } -} - -#endif /* ACE_HAS_CPP11 */ - #if defined (__ACE_INLINE__) #include "ace/Time_Value.inl" #endif /* __ACE_INLINE__ */ diff --git a/dep/acelite/ace/Time_Value.inl b/dep/acelite/ace/Time_Value.inl index 98459b477..c0a16c1b5 100644 --- a/dep/acelite/ace/Time_Value.inl +++ b/dep/acelite/ace/Time_Value.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Time_Value.inl 95761 2012-05-15 18:23:04Z johnnyw $ + #include "ace/Truncate.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -70,22 +73,10 @@ ACE_INLINE void ACE_Time_Value::set (double d) { // ACE_OS_TRACE ("ACE_Time_Value::set"); - if (d < ACE_Numeric_Limits::min()) - { - this->tv_.tv_sec = ACE_Numeric_Limits::min(); - this->tv_.tv_usec = -ACE_ONE_SECOND_IN_USECS + 1; - } - else if (d > ACE_Numeric_Limits::max()) - { - this->tv_.tv_sec = ACE_Numeric_Limits::max(); - this->tv_.tv_usec = ACE_ONE_SECOND_IN_USECS - 1; - } - else - { - time_t l = (time_t) d; - this->tv_.tv_sec = l; - this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + (d < 0 ? -0.5 : 0.5)); - } + time_t l = (time_t) d; + this->tv_.tv_sec = l; + this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + .5); + this->normalize (); } /// Initializes a timespec_t. Note that this approach loses precision @@ -405,161 +396,3 @@ operator - (const ACE_Time_Value &tv1, } ACE_END_VERSIONED_NAMESPACE_DECL - -#if defined (ACE_HAS_CPP11) - -// Additional chrono streaming operators. - -namespace std -{ - namespace chrono - { - ACE_INLINE nanoseconds& - operator <<(nanoseconds &ns, ACE_Time_Value const &tv) - { - ns = duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return ns; - } - - ACE_INLINE microseconds& - operator <<(microseconds &us, ACE_Time_Value const &tv) - { - us= duration_cast(seconds{tv.sec ()}) + - microseconds{tv.usec()}; - return us; - } - - ACE_INLINE milliseconds& - operator <<(milliseconds &ms, ACE_Time_Value const &tv) - { - ms = duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return ms; - } - - ACE_INLINE seconds& - operator <<(seconds &s, ACE_Time_Value const &tv) - { - s = seconds{tv.sec ()} + - duration_cast(microseconds{tv.usec()}); - return s; - } - - ACE_INLINE minutes& - operator <<(minutes &m, ACE_Time_Value const &tv) - { - m = duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return m; - } - - ACE_INLINE hours& - operator <<(hours &h, ACE_Time_Value const &tv) - { - h = duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return h; - } - - - ACE_INLINE nanoseconds& - operator +=(nanoseconds &ns, ACE_Time_Value const &tv) - { - ns += duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return ns; - } - - ACE_INLINE microseconds& - operator +=(microseconds &us, ACE_Time_Value const &tv) - { - us += duration_cast(seconds{tv.sec ()}) + - microseconds{tv.usec()}; - return us; - } - - ACE_INLINE milliseconds& - operator +=(milliseconds &ms, ACE_Time_Value const &tv) - { - ms += duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return ms; - } - - ACE_INLINE seconds& - operator +=(seconds &s, ACE_Time_Value const &tv) - { - s += seconds{tv.sec ()} + - duration_cast(microseconds{tv.usec()}); - return s; - } - - ACE_INLINE minutes& - operator +=(minutes &m, ACE_Time_Value const &tv) - { - m += duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return m; - } - - ACE_INLINE hours& - operator +=(hours &h, ACE_Time_Value const &tv) - { - h += duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return h; - } - - - ACE_INLINE nanoseconds& - operator -=(nanoseconds &ns, ACE_Time_Value const &tv) - { - ns -= duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return ns; - } - - ACE_INLINE microseconds& - operator -=(microseconds &us, ACE_Time_Value const &tv) - { - us -= duration_cast(seconds{tv.sec ()}) + - microseconds{tv.usec()}; - return us; - } - - ACE_INLINE milliseconds& - operator -=(milliseconds &ms, ACE_Time_Value const &tv) - { - ms -= duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return ms; - } - - ACE_INLINE seconds& - operator -=(seconds &s, ACE_Time_Value const &tv) - { - s -= seconds{tv.sec ()} + - duration_cast(microseconds{tv.usec()}); - return s; - } - - ACE_INLINE minutes& - operator -=(minutes &m, ACE_Time_Value const &tv) - { - m -= duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return m; - } - - ACE_INLINE hours& - operator -=(hours &h, ACE_Time_Value const &tv) - { - h -= duration_cast(seconds{tv.sec ()}) + - duration_cast(microseconds{tv.usec()}); - return h; - } - } -} - -#endif /* ACE_HAS_CPP11 */ diff --git a/dep/acelite/ace/Time_Value_T.cpp b/dep/acelite/ace/Time_Value_T.cpp index 79689d904..e7fdec987 100644 --- a/dep/acelite/ace/Time_Value_T.cpp +++ b/dep/acelite/ace/Time_Value_T.cpp @@ -1,3 +1,5 @@ +// $Id: Time_Value_T.cpp 96061 2012-08-16 09:36:07Z mcorino $ + #ifndef ACE_TIME_VALUE_T_CPP #define ACE_TIME_VALUE_T_CPP diff --git a/dep/acelite/ace/Time_Value_T.h b/dep/acelite/ace/Time_Value_T.h index 4348dccf1..615d5820a 100644 --- a/dep/acelite/ace/Time_Value_T.h +++ b/dep/acelite/ace/Time_Value_T.h @@ -4,6 +4,8 @@ /** * @file Time_Value_T.h * + * $Id: Time_Value_T.h 96061 2012-08-16 09:36:07Z mcorino $ + * * @author Martin Corino */ //============================================================================= diff --git a/dep/acelite/ace/Time_Value_T.inl b/dep/acelite/ace/Time_Value_T.inl index 934bebf22..e74f16b91 100644 --- a/dep/acelite/ace/Time_Value_T.inl +++ b/dep/acelite/ace/Time_Value_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Time_Value_T.inl 96061 2012-08-16 09:36:07Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template diff --git a/dep/acelite/ace/Timeprobe.cpp b/dep/acelite/ace/Timeprobe.cpp index d1895827f..69a2d0080 100644 --- a/dep/acelite/ace/Timeprobe.cpp +++ b/dep/acelite/ace/Timeprobe.cpp @@ -1,3 +1,5 @@ +// $Id: Timeprobe.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/config-all.h" diff --git a/dep/acelite/ace/Timeprobe.h b/dep/acelite/ace/Timeprobe.h index 872e274ee..1ede92b39 100644 --- a/dep/acelite/ace/Timeprobe.h +++ b/dep/acelite/ace/Timeprobe.h @@ -4,6 +4,8 @@ /** * @file Timeprobe.h * + * $Id: Timeprobe.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Irfan Pyarali * * If users want to use time probes, the ACE_COMPILE_TIMEPROBES diff --git a/dep/acelite/ace/Timeprobe.inl b/dep/acelite/ace/Timeprobe.inl index 216f43724..aa7a92406 100644 --- a/dep/acelite/ace/Timeprobe.inl +++ b/dep/acelite/ace/Timeprobe.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Timeprobe.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE bool diff --git a/dep/acelite/ace/Timeprobe_T.cpp b/dep/acelite/ace/Timeprobe_T.cpp index a88eb00bb..235abb2e5 100644 --- a/dep/acelite/ace/Timeprobe_T.cpp +++ b/dep/acelite/ace/Timeprobe_T.cpp @@ -1,3 +1,5 @@ +// $Id: Timeprobe_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_TIMEPROBE_T_CPP #define ACE_TIMEPROBE_T_CPP diff --git a/dep/acelite/ace/Timeprobe_T.h b/dep/acelite/ace/Timeprobe_T.h index 0512060af..54e5ff4c1 100644 --- a/dep/acelite/ace/Timeprobe_T.h +++ b/dep/acelite/ace/Timeprobe_T.h @@ -4,6 +4,8 @@ /** * @file Timeprobe_T.h * + * $Id: Timeprobe_T.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Timer_Hash.h b/dep/acelite/ace/Timer_Hash.h index 500bb28bd..3d786a1a2 100644 --- a/dep/acelite/ace/Timer_Hash.h +++ b/dep/acelite/ace/Timer_Hash.h @@ -4,6 +4,8 @@ /** * @file Timer_Hash.h * + * $Id: Timer_Hash.h 95335 2011-12-15 13:13:17Z msmit $ + * * @author Darrell Brunsch */ //============================================================================= diff --git a/dep/acelite/ace/Timer_Hash_T.cpp b/dep/acelite/ace/Timer_Hash_T.cpp index c3c2e0503..2c10eda44 100644 --- a/dep/acelite/ace/Timer_Hash_T.cpp +++ b/dep/acelite/ace/Timer_Hash_T.cpp @@ -1,3 +1,5 @@ +// $Id: Timer_Hash_T.cpp 97646 2014-03-07 12:35:48Z johnnyw $ + #ifndef ACE_TIMER_HASH_T_CPP #define ACE_TIMER_HASH_T_CPP diff --git a/dep/acelite/ace/Timer_Hash_T.h b/dep/acelite/ace/Timer_Hash_T.h index 2e7975c31..123b973b7 100644 --- a/dep/acelite/ace/Timer_Hash_T.h +++ b/dep/acelite/ace/Timer_Hash_T.h @@ -4,6 +4,8 @@ /** * @file Timer_Hash_T.h * + * $Id: Timer_Hash_T.h 97645 2014-03-07 12:01:21Z johnnyw $ + * * @author Darrell Brunsch */ //============================================================================= diff --git a/dep/acelite/ace/Timer_Heap.h b/dep/acelite/ace/Timer_Heap.h index ccdf8c605..742aed8ff 100644 --- a/dep/acelite/ace/Timer_Heap.h +++ b/dep/acelite/ace/Timer_Heap.h @@ -4,7 +4,9 @@ /** * @file Timer_Heap.h * - * @author Douglas C. Schmidt + * $Id: Timer_Heap.h 95335 2011-12-15 13:13:17Z msmit $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Timer_Heap_T.cpp b/dep/acelite/ace/Timer_Heap_T.cpp index fa2704ed8..4bd6b6824 100644 --- a/dep/acelite/ace/Timer_Heap_T.cpp +++ b/dep/acelite/ace/Timer_Heap_T.cpp @@ -1,3 +1,5 @@ +// $Id: Timer_Heap_T.cpp 97645 2014-03-07 12:01:21Z johnnyw $ + #ifndef ACE_TIMER_HEAP_T_CPP #define ACE_TIMER_HEAP_T_CPP @@ -22,9 +24,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tccct(ACE_Timer_Heap_Iterator_T) -ACE_ALLOC_HOOK_DEFINE_Tccct(ACE_Timer_Heap_T) - // Define some simple inlined functions to clarify the code. inline size_t ACE_HEAP_PARENT (size_t X) @@ -124,13 +123,8 @@ ACE_Timer_Heap_T::ACE_Timer_Heap_T ( } // Create the heap array. -#if defined (ACE_HAS_ALLOC_HOOKS) - this->heap_ = reinterpret_cast **> - (ACE_Allocator::instance ()->malloc (sizeof (ACE_Timer_Node_T *) * size)); -#else - ACE_NEW (this->heap_, - ACE_Timer_Node_T *[size]); -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_NEW (this->heap_, + ACE_Timer_Node_T *[size]); // Create the parallel ACE_NEW (this->timer_ids_, @@ -194,22 +188,12 @@ ACE_Timer_Heap_T::ACE_Timer_Heap_T ( this->max_size_ = static_cast (ACE_Numeric_Limits::max ()); // Create the heap array. -#if defined (ACE_HAS_ALLOC_HOOKS) - this->heap_ = reinterpret_cast **> - (ACE_Allocator::instance ()->malloc (sizeof (ACE_Timer_Node_T *) * this->max_size_)); -#else ACE_NEW (this->heap_, ACE_Timer_Node_T *[this->max_size_]); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Create the parallel array. -#if defined (ACE_HAS_ALLOC_HOOKS) - this->timer_ids_ = reinterpret_cast - (ACE_Allocator::instance ()->malloc (sizeof (ssize_t) * this->max_size_)); -#else - ACE_NEW (this->timer_ids_, - ssize_t[this->max_size_]); -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_NEW (this->timer_ids_, + ssize_t[this->max_size_]); // Initialize the "freelist," which uses negative values to // distinguish freelist elements from "pointers" into the @@ -230,19 +214,8 @@ ACE_Timer_Heap_T::~ACE_Timer_Heap_T (void) this->close (); -#if defined (ACE_HAS_ALLOC_HOOKS) - if (this->heap_) - (ACE_Allocator::instance ()->free (this->heap_)); -#else delete [] this->heap_; -#endif /* ACE_HAS_ALLOC_HOOKS */ - -#if defined (ACE_HAS_ALLOC_HOOKS) - if (this->timer_ids_) - (ACE_Allocator::instance ()->free (this->timer_ids_)); -#else delete [] this->timer_ids_; -#endif /* ACE_HAS_ALLOC_HOOKS */ // clean up any preallocated timer nodes if (preallocated_nodes_ != 0) @@ -570,48 +543,27 @@ ACE_Timer_Heap_T::grow_heap (void) // First grow the heap itself. ACE_Timer_Node_T **new_heap = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - new_heap = reinterpret_cast **> - (ACE_Allocator::instance ()->malloc (sizeof (ACE_Timer_Node_T *) * new_size)); -#else - ACE_NEW (new_heap, - ACE_Timer_Node_T *[new_size]); -#endif /* ACE_HAS_ALLOC_HOOKS */ + ACE_NEW (new_heap, + ACE_Timer_Node_T *[new_size]); ACE_OS::memcpy (new_heap, this->heap_, this->max_size_ * sizeof *new_heap); - -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_Allocator::instance ()->free (this->heap_); -#else delete [] this->heap_; -#endif /* ACE_HAS_ALLOC_HOOKS */ - this->heap_ = new_heap; // Grow the array of timer ids. ssize_t *new_timer_ids = 0; -#if defined (ACE_HAS_ALLOC_HOOKS) - new_timer_ids = reinterpret_cast - (ACE_Allocator::instance ()->malloc (sizeof (ssize_t) * new_size)); -#else ACE_NEW (new_timer_ids, ssize_t[new_size]); -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::memcpy (new_timer_ids, this->timer_ids_, this->max_size_ * sizeof (ssize_t)); -#if defined (ACE_HAS_ALLOC_HOOKS) - if (this->timer_ids_) - (ACE_Allocator::instance ()->free (this->timer_ids_)); -#else - delete [] this->timer_ids_; -#endif /* ACE_HAS_ALLOC_HOOKS */ + delete [] timer_ids_; this->timer_ids_ = new_timer_ids; // And add the new elements to the end of the "freelist". diff --git a/dep/acelite/ace/Timer_Heap_T.h b/dep/acelite/ace/Timer_Heap_T.h index ba09c9969..147d633fd 100644 --- a/dep/acelite/ace/Timer_Heap_T.h +++ b/dep/acelite/ace/Timer_Heap_T.h @@ -4,7 +4,9 @@ /** * @file Timer_Heap_T.h * - * @author Douglas C. Schmidt + * $Id: Timer_Heap_T.h 95368 2011-12-19 13:38:49Z mcorino $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -59,9 +61,6 @@ public: /// Returns the node at the current position in the sequence virtual ACE_Timer_Node_T *item (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /// Pointer to the ACE_Timer_Heap that we are iterating over. Heap & timer_heap_; @@ -190,9 +189,6 @@ public: /// Reads the earliest node from the queue and returns it. virtual ACE_Timer_Node_T *get_first (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - protected: /** diff --git a/dep/acelite/ace/Timer_List.h b/dep/acelite/ace/Timer_List.h index d274f11a3..5dff92a56 100644 --- a/dep/acelite/ace/Timer_List.h +++ b/dep/acelite/ace/Timer_List.h @@ -4,6 +4,8 @@ /** * @file Timer_List.h * + * $Id: Timer_List.h 95335 2011-12-15 13:13:17Z msmit $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Timer_List_T.cpp b/dep/acelite/ace/Timer_List_T.cpp index aa6c795c1..1aee3d2a7 100644 --- a/dep/acelite/ace/Timer_List_T.cpp +++ b/dep/acelite/ace/Timer_List_T.cpp @@ -1,3 +1,5 @@ +// $Id: Timer_List_T.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_TIMER_LIST_T_C #define ACE_TIMER_LIST_T_C diff --git a/dep/acelite/ace/Timer_List_T.h b/dep/acelite/ace/Timer_List_T.h index efd8f57bb..8b7c783f4 100644 --- a/dep/acelite/ace/Timer_List_T.h +++ b/dep/acelite/ace/Timer_List_T.h @@ -4,7 +4,9 @@ /** * @file Timer_List_T.h * - * @author Douglas C. Schmidt + * $Id: Timer_List_T.h 97645 2014-03-07 12:01:21Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Timer_Queue.h b/dep/acelite/ace/Timer_Queue.h index c48e6e37b..13ec4fc82 100644 --- a/dep/acelite/ace/Timer_Queue.h +++ b/dep/acelite/ace/Timer_Queue.h @@ -4,7 +4,9 @@ /** * @file Timer_Queue.h * - * @author Douglas C. Schmidt + * $Id: Timer_Queue.h 95332 2011-12-15 11:09:41Z mcorino $ + * + * @author Douglas C. Schmidt * @author Irfan Pyarali */ //============================================================================= diff --git a/dep/acelite/ace/Timer_Queue_Adapters.cpp b/dep/acelite/ace/Timer_Queue_Adapters.cpp index 7f12d8258..5753cfc6c 100644 --- a/dep/acelite/ace/Timer_Queue_Adapters.cpp +++ b/dep/acelite/ace/Timer_Queue_Adapters.cpp @@ -1,3 +1,5 @@ +// $Id: Timer_Queue_Adapters.cpp 97493 2013-12-31 07:45:27Z johnnyw $ + #ifndef ACE_TIMER_QUEUE_ADAPTERS_CPP #define ACE_TIMER_QUEUE_ADAPTERS_CPP @@ -159,7 +161,7 @@ ACE_Thread_Timer_Queue_Adapter::ACE_Thread_Timer_Queue_Adapter (ACE_Th : ACE_Task_Base (tm), timer_queue_(timer_queue), delete_timer_queue_(false), - condition_ (mutex_, cond_attr_), + condition_ (mutex_), active_ (true), // Assume that we start in active mode. thr_id_ (ACE_OS::NULL_thread) { diff --git a/dep/acelite/ace/Timer_Queue_Adapters.h b/dep/acelite/ace/Timer_Queue_Adapters.h index 0ba8dc2f0..d55617171 100644 --- a/dep/acelite/ace/Timer_Queue_Adapters.h +++ b/dep/acelite/ace/Timer_Queue_Adapters.h @@ -4,7 +4,9 @@ /** * @file Timer_Queue_Adapters.h * - * @author Douglas C. Schmidt and + * $Id: Timer_Queue_Adapters.h 89482 2010-03-15 07:58:50Z johnnyw $ + * + * @author Douglas C. Schmidt and * Carlos O'Ryan */ //============================================================================= @@ -115,6 +117,7 @@ private: * @note This is a case where template parameters will be useful, but * (IMHO) the effort and portability problems discourage their * use. + * */ template class ACE_Thread_Timer_Queue_Adapter : public ACE_Task_Base @@ -225,12 +228,6 @@ private: /// . ACE_SYNCH_RECURSIVE_MUTEX mutex_; - /// Attributes to initialize condition with. - /* We only need this because some crappy compilers can't - properly handle initializing the conditions with - temporary objects. */ - ACE_Condition_Attributes_T cond_attr_; - /** * The dispatching thread sleeps on this condition while waiting to * dispatch the next timer; it is used to wake it up if there is a diff --git a/dep/acelite/ace/Timer_Queue_Adapters.inl b/dep/acelite/ace/Timer_Queue_Adapters.inl index ad5129f73..c6a769030 100644 --- a/dep/acelite/ace/Timer_Queue_Adapters.inl +++ b/dep/acelite/ace/Timer_Queue_Adapters.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Timer_Queue_Adapters.inl 95368 2011-12-19 13:38:49Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE TQ * diff --git a/dep/acelite/ace/Timer_Queue_Iterator.cpp b/dep/acelite/ace/Timer_Queue_Iterator.cpp index 2d16088b8..e5a89d023 100644 --- a/dep/acelite/ace/Timer_Queue_Iterator.cpp +++ b/dep/acelite/ace/Timer_Queue_Iterator.cpp @@ -1,10 +1,9 @@ +//$Id: Timer_Queue_Iterator.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_TIMER_QUEUE_ITERATOR_CPP #define ACE_TIMER_QUEUE_ITERATOR_CPP #include "ace/config-all.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -16,8 +15,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Timer_Node_T) - template void ACE_Timer_Node_T::dump (void) const { diff --git a/dep/acelite/ace/Timer_Queue_Iterator.h b/dep/acelite/ace/Timer_Queue_Iterator.h index 6fa376c25..8f1a2ea30 100644 --- a/dep/acelite/ace/Timer_Queue_Iterator.h +++ b/dep/acelite/ace/Timer_Queue_Iterator.h @@ -1,3 +1,5 @@ +//$Id: Timer_Queue_Iterator.h 96333 2012-11-23 08:08:31Z johnnyw $ + #ifndef ACE_TIMER_QUEUE_ITERATOR_H #define ACE_TIMER_QUEUE_ITERATOR_H @@ -17,6 +19,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * @class ACE_Timer_Node_Dispatch_Info_T * * @brief Maintains generated dispatch information for Timer nodes. + * */ template class ACE_Timer_Node_Dispatch_Info_T @@ -121,9 +124,6 @@ public: /// Dump the state of an TYPE. void dump (void) const; - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - private: /// Type of object stored in the Queue TYPE type_; diff --git a/dep/acelite/ace/Timer_Queue_Iterator.inl b/dep/acelite/ace/Timer_Queue_Iterator.inl index 556987e08..90fa4687b 100644 --- a/dep/acelite/ace/Timer_Queue_Iterator.inl +++ b/dep/acelite/ace/Timer_Queue_Iterator.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Timer_Queue_Iterator.inl 95332 2011-12-15 11:09:41Z mcorino $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE void diff --git a/dep/acelite/ace/Timer_Queue_T.cpp b/dep/acelite/ace/Timer_Queue_T.cpp index e5a5fbf1f..ba48fc05f 100644 --- a/dep/acelite/ace/Timer_Queue_T.cpp +++ b/dep/acelite/ace/Timer_Queue_T.cpp @@ -1,3 +1,5 @@ +// $Id: Timer_Queue_T.cpp 97644 2014-03-07 11:59:51Z johnnyw $ + #ifndef ACE_TIMER_QUEUE_T_CPP #define ACE_TIMER_QUEUE_T_CPP @@ -411,9 +413,11 @@ ACE_Timer_Queue_T::dispatch_info_i (const if (this->is_empty ()) return 0; + ACE_Timer_Node_T *expired = 0; + if (this->earliest_time () <= cur_time) { - ACE_Timer_Node_T *expired = this->remove_first (); + expired = this->remove_first (); // Get the dispatch info expired->get_dispatch_info (info); diff --git a/dep/acelite/ace/Timer_Queue_T.h b/dep/acelite/ace/Timer_Queue_T.h index 41f87dbe5..47652d25e 100644 --- a/dep/acelite/ace/Timer_Queue_T.h +++ b/dep/acelite/ace/Timer_Queue_T.h @@ -4,7 +4,9 @@ /** * @file Timer_Queue_T.h * - * @author Doug Schmidt + * $Id: Timer_Queue_T.h 97644 2014-03-07 11:59:51Z johnnyw $ + * + * @author Doug Schmidt * @author Irfan Pyarali and * @author Darrell Brunsch */ @@ -73,9 +75,6 @@ class ACE_Timer_Queue_T : public ACE_Timer_Queue_Upcall_Base { public: - /// Type of time policy - typedef TIME_POLICY time_policy_t; - // = Initialization and termination methods. /** * Default constructor. @a upcall_functor is the instance of the @@ -188,6 +187,7 @@ public: const void *upcall_act); protected: + /// Schedule a timer. virtual long schedule_i (const TYPE &type, const void *act, @@ -225,6 +225,7 @@ protected: bool const delete_free_list_; private: + /// Returned by . ACE_Time_Value timeout_; diff --git a/dep/acelite/ace/Timer_Queue_T.inl b/dep/acelite/ace/Timer_Queue_T.inl index 64f2bf14c..5ea413da7 100644 --- a/dep/acelite/ace/Timer_Queue_T.inl +++ b/dep/acelite/ace/Timer_Queue_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Timer_Queue_T.inl 97644 2014-03-07 11:59:51Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE FUNCTOR & diff --git a/dep/acelite/ace/Timer_Queuefwd.h b/dep/acelite/ace/Timer_Queuefwd.h index 26aee6eb6..46f0612cc 100644 --- a/dep/acelite/ace/Timer_Queuefwd.h +++ b/dep/acelite/ace/Timer_Queuefwd.h @@ -4,6 +4,8 @@ /** * @file Timer_Queuefwd.h * + * $Id: Timer_Queuefwd.h 95332 2011-12-15 11:09:41Z mcorino $ + * * Forward declarations and typedefs of ACE_Timer_Queue class. * * @author Ossama Othman diff --git a/dep/acelite/ace/Timer_Wheel.h b/dep/acelite/ace/Timer_Wheel.h index b21eb9c51..12b8bff0d 100644 --- a/dep/acelite/ace/Timer_Wheel.h +++ b/dep/acelite/ace/Timer_Wheel.h @@ -4,6 +4,8 @@ /** * @file Timer_Wheel.h * + * $Id: Timer_Wheel.h 95335 2011-12-15 13:13:17Z msmit $ + * * @author Darrell Brunsch (brunsch@cs.wustl.edu) */ //============================================================================= diff --git a/dep/acelite/ace/Timer_Wheel_T.cpp b/dep/acelite/ace/Timer_Wheel_T.cpp index 5c5534618..08537902f 100644 --- a/dep/acelite/ace/Timer_Wheel_T.cpp +++ b/dep/acelite/ace/Timer_Wheel_T.cpp @@ -1,3 +1,5 @@ +// $Id: Timer_Wheel_T.cpp 97817 2014-07-28 17:27:29Z johnnyw $ + #ifndef ACE_TIMER_WHEEL_T_CPP #define ACE_TIMER_WHEEL_T_CPP @@ -311,17 +313,24 @@ ACE_Timer_Wheel_T::generate_timer_id (u_in if (root == root->get_next ()) root->set_act(0); + // We use this field to keep track of the next counter value that + // may be in use. Of course it may have expired, so we just use + // this field so that we know when we don't have to check for duplicates +#if defined (ACE_WIN64) + // The cast below is legit... we know that long is shorter than a + // pointer, but are only using it as a 'long' storage area. +# pragma warning(push) +# pragma warning(disable : 4311) +#endif /* ACE_WIN64 */ + long next_cnt = ACE_Utils::truncate_cast ((intptr_t)root->get_act ()); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ + // This field is used as a counter instead of a timer_id. long cnt = root->get_timer_id (); - if (cnt < max_cnt) - { - root->set_timer_id (cnt + 1); - return (cnt << this->spoke_bits_) | spoke; - } - - // Count has overflowed its range. - if (root == root->get_next ()) + if (cnt >= max_cnt && root == root->get_next ()) { // Special case when we overflow on an empty spoke. We can just // wrap the count around without searching for duplicates. We only @@ -330,20 +339,50 @@ ACE_Timer_Wheel_T::generate_timer_id (u_in root->set_timer_id (1); return spoke; } - - // Overflowed count, and the spoke is not empty. Search for an unused - // id value. - //ACELIB_ERROR((LM_ERROR, "Timer id overflow. We have to search now.\n")); - for (cnt = 0; cnt < max_cnt - 1; ++cnt) + else if (cnt >= max_cnt) + { // overflow + cnt = 0; // try again starting at zero + } + else if (next_cnt == 0 || cnt < next_cnt) + { + root->set_timer_id (cnt + 1); + return (cnt << this->spoke_bits_) | spoke; + } + + //ACELIB_ERROR((LM_ERROR, "Timer id overflow. We have to search now.\n")); + + // We've run out of consecutive id numbers so now we have to search + // for a unique id. + // We'll try increasing numbers until we find one that is not in use, + // and we'll record the next highest number so that we can avoid this + // search as often as possible. + for (; cnt < max_cnt - 1; ++cnt) { - // Look for an unused id. Yes, every new id on this spoke will result in a - // scan until all the spoke's timers get canceled/expired then the spoke will - // start over like new. So, when an empty spot is found, don't reset the - // root node's timer_id - it stays at max until the spoke clears out and - // starts over. long id = (cnt << this->spoke_bits_) | spoke; - if (0 == this->find_spoke_node (spoke, id)) - return id; + ACE_Timer_Node_T* n = this->find_spoke_node (spoke, id); + if (n == 0) + { + root->set_timer_id (cnt + 1); + // Now we need to find the next highest cnt in use + next_cnt = 0; + for (; n != root; n = n->get_next ()) + { + long tmp = n->get_timer_id () >> this->spoke_bits_; + if (tmp > cnt && (tmp < next_cnt || next_cnt == 0)) + next_cnt = tmp; + } +#if defined (ACE_WIN64) + // The cast below is legit... we know we're storing a long in + // a pointer, but are only using it as a 'long' storage area. +# pragma warning(push) +# pragma warning(disable : 4312) +#endif /* ACE_WIN64 */ + root->set_act (reinterpret_cast (next_cnt)); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ + return id; + } } return -1; // We did our best, but the spoke is full. @@ -384,10 +423,6 @@ ACE_Timer_Wheel_T::schedule_i (const TYPE& n->set (type, act, future_time, interval, 0, 0, id); this->schedule_i (n, spoke, future_time); } - else - { - this->free_node (n); - } return id; } diff --git a/dep/acelite/ace/Timer_Wheel_T.h b/dep/acelite/ace/Timer_Wheel_T.h index be21c31c0..e451deca9 100644 --- a/dep/acelite/ace/Timer_Wheel_T.h +++ b/dep/acelite/ace/Timer_Wheel_T.h @@ -4,6 +4,8 @@ /** * @file Timer_Wheel_T.h * + * $Id: Timer_Wheel_T.h 95368 2011-12-19 13:38:49Z mcorino $ + * * @author Darrell Brunsch */ //============================================================================= @@ -169,6 +171,7 @@ public: virtual ACE_Timer_Node_T* get_first (void); protected: + /// Schedules a timer. virtual long schedule_i (const TYPE& type, const void* act, @@ -199,6 +202,8 @@ private: u_int spoke_count_; /// Number of timer_id bits used for the spoke int spoke_bits_; + /// Maximum number of timers per spoke + u_int max_per_spoke_; /// Resolution (in microsoconds) of the timing wheel. int res_bits_; /// Index of the list with the earliest time diff --git a/dep/acelite/ace/Token.cpp b/dep/acelite/ace/Token.cpp index 86acaf07d..cc9a24a44 100644 --- a/dep/acelite/ace/Token.cpp +++ b/dep/acelite/ace/Token.cpp @@ -1,3 +1,5 @@ +// $Id: Token.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Token.h" #if !defined (__ACE_INLINE__) @@ -294,7 +296,7 @@ ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), ACELIB_DEBUG ((LM_DEBUG, "(%t) ACE_Token::shared_acquire (UNBLOCKED)\n")); #endif /* ACE_TOKEN_DEBUGGING */ - // If timeout occurred + // If timeout occured if (timed_out) { // This thread was still selected to own the token. @@ -440,7 +442,7 @@ ACE_Token::renew (int requeue_position, ACELIB_DEBUG ((LM_DEBUG, "(%t) ACE_Token::renew (UNBLOCKED)\n")); #endif /* ACE_TOKEN_DEBUGGING */ - // If timeout occurred + // If timeout occured if (timed_out) { // This thread was still selected to own the token. diff --git a/dep/acelite/ace/Token.h b/dep/acelite/ace/Token.h index ba00a7ee2..7857c44df 100644 --- a/dep/acelite/ace/Token.h +++ b/dep/acelite/ace/Token.h @@ -4,10 +4,12 @@ /** * @file Token.h * + * $Id: Token.h 85367 2009-05-18 10:11:54Z johnnyw $ + * * @author Original author * @author Karl-Heinz Dorn (kdorn@erlh.siemens.de) * @author Ported to ACE by - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) */ //============================================================================= diff --git a/dep/acelite/ace/Token.inl b/dep/acelite/ace/Token.inl index 5d42c427b..f09a0e6f3 100644 --- a/dep/acelite/ace/Token.inl +++ b/dep/acelite/ace/Token.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Token.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/config-macros.h" #if defined (ACE_HAS_THREADS) diff --git a/dep/acelite/ace/Token_Collection.cpp b/dep/acelite/ace/Token_Collection.cpp index c15d7cf9c..cbd20588a 100644 --- a/dep/acelite/ace/Token_Collection.cpp +++ b/dep/acelite/ace/Token_Collection.cpp @@ -1,3 +1,4 @@ +// $Id: Token_Collection.cpp 96985 2013-04-11 15:50:32Z huangh $ #include "ace/Token_Collection.h" #if defined (ACE_HAS_TOKENS_LIBRARY) diff --git a/dep/acelite/ace/Token_Collection.h b/dep/acelite/ace/Token_Collection.h index c4b55ce44..3db64182a 100644 --- a/dep/acelite/ace/Token_Collection.h +++ b/dep/acelite/ace/Token_Collection.h @@ -4,6 +4,8 @@ /** * @file Token_Collection.h * + * $Id: Token_Collection.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * The ACE_Token class offers methods for acquiring, renewing, * and releasing a synchronization token on a per-token basis. The * ACE_Token_Collection offers an interface for performing @@ -12,7 +14,8 @@ * * The atomic group operations are not yet implemented. * - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) * @author Tim Harrison (harrison@cs.wustl.edu) */ //============================================================================= @@ -53,6 +56,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * @bug Although ACE_Token_Collection inherits from ACE_Token_Proxy, it * can not be including in a collection. This is because * returns zero for now. + * */ class ACE_Export ACE_Token_Collection : public ACE_Token_Proxy { diff --git a/dep/acelite/ace/Token_Collection.inl b/dep/acelite/ace/Token_Collection.inl index 1104b1f60..73f1e95d7 100644 --- a/dep/acelite/ace/Token_Collection.inl +++ b/dep/acelite/ace/Token_Collection.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Token_Collection.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_HAS_TOKENS_LIBRARY) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Token_Invariants.cpp b/dep/acelite/ace/Token_Invariants.cpp index 4d664c02b..dc4196bf0 100644 --- a/dep/acelite/ace/Token_Invariants.cpp +++ b/dep/acelite/ace/Token_Invariants.cpp @@ -1,3 +1,5 @@ +// $Id: Token_Invariants.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Token_Invariants.h" #if defined (ACE_HAS_TOKENS_LIBRARY) diff --git a/dep/acelite/ace/Token_Invariants.h b/dep/acelite/ace/Token_Invariants.h index 6fc5a0028..3e620b036 100644 --- a/dep/acelite/ace/Token_Invariants.h +++ b/dep/acelite/ace/Token_Invariants.h @@ -4,11 +4,15 @@ /** * @file Token_Invariants.h * + * $Id: Token_Invariants.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Tim Harrison (harrison@cs.wustl.edu) * * Allows applications to test that invariants are always * satisfied. Can test mutexes and readers/writer locks. Does * not test recursive acquisition. + * + * */ //============================================================================= diff --git a/dep/acelite/ace/Token_Manager.cpp b/dep/acelite/ace/Token_Manager.cpp index 0c983f9ff..72f4ed983 100644 --- a/dep/acelite/ace/Token_Manager.cpp +++ b/dep/acelite/ace/Token_Manager.cpp @@ -1,3 +1,5 @@ +// $Id: Token_Manager.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Token_Manager.h" #if defined (ACE_HAS_TOKENS_LIBRARY) diff --git a/dep/acelite/ace/Token_Manager.h b/dep/acelite/ace/Token_Manager.h index 3f0427799..eb86a4dd9 100644 --- a/dep/acelite/ace/Token_Manager.h +++ b/dep/acelite/ace/Token_Manager.h @@ -4,6 +4,8 @@ /** * @file Token_Manager.h * + * $Id: Token_Manager.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Tim Harrison (harrison@cs.wustl.edu) */ //============================================================================= diff --git a/dep/acelite/ace/Token_Manager.inl b/dep/acelite/ace/Token_Manager.inl index 0bbbfc67d..a44778c89 100644 --- a/dep/acelite/ace/Token_Manager.inl +++ b/dep/acelite/ace/Token_Manager.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Token_Manager.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_HAS_TOKENS_LIBRARY) ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Token_Request_Reply.cpp b/dep/acelite/ace/Token_Request_Reply.cpp index 3df3541ef..ffe4c41e8 100644 --- a/dep/acelite/ace/Token_Request_Reply.cpp +++ b/dep/acelite/ace/Token_Request_Reply.cpp @@ -1,3 +1,5 @@ +// $Id: Token_Request_Reply.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Token_Request_Reply.h" #if defined (ACE_HAS_TOKENS_LIBRARY) diff --git a/dep/acelite/ace/Token_Request_Reply.h b/dep/acelite/ace/Token_Request_Reply.h index dd1a03bcd..01a7cfd3e 100644 --- a/dep/acelite/ace/Token_Request_Reply.h +++ b/dep/acelite/ace/Token_Request_Reply.h @@ -4,10 +4,13 @@ /** * @file Token_Request_Reply.h * + * $Id: Token_Request_Reply.h 80826 2008-03-04 14:51:23Z wotte $ + * * Define the format used to exchange messages between the * ACE_Token Server and its clients. * - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) * @author Tim Harrison (harrison@cs.wustl.edu) */ //============================================================================= diff --git a/dep/acelite/ace/Token_Request_Reply.inl b/dep/acelite/ace/Token_Request_Reply.inl index df58781c5..4291bfa60 100644 --- a/dep/acelite/ace/Token_Request_Reply.inl +++ b/dep/acelite/ace/Token_Request_Reply.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Token_Request_Reply.inl 80826 2008-03-04 14:51:23Z wotte $ + #if defined (ACE_HAS_TOKENS_LIBRARY) #include "ace/Truncate.h" diff --git a/dep/acelite/ace/Tokenizer_T.cpp b/dep/acelite/ace/Tokenizer_T.cpp index 5be90545e..ccf737679 100644 --- a/dep/acelite/ace/Tokenizer_T.cpp +++ b/dep/acelite/ace/Tokenizer_T.cpp @@ -1,9 +1,12 @@ +// $Id: Tokenizer_T.cpp 91813 2010-09-17 07:52:52Z johnnyw $ + #ifndef ACE_TOKENIZER_T_CPP #define ACE_TOKENIZER_T_CPP #include "ace/ACE.h" #include "ace/Malloc_Base.h" #include "ace/String_Base.h" +#include "ace/Auto_Ptr.h" #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Tokenizer_T.h b/dep/acelite/ace/Tokenizer_T.h index 686004873..b13f5bb5a 100644 --- a/dep/acelite/ace/Tokenizer_T.h +++ b/dep/acelite/ace/Tokenizer_T.h @@ -4,7 +4,9 @@ /** * @file Tokenizer_T.h * - * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) + * $Id: Tokenizer_T.h 88793 2010-02-01 17:50:34Z cleeland $ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) * @author Nanbor Wang */ //============================================================================= diff --git a/dep/acelite/ace/Trace.cpp b/dep/acelite/ace/Trace.cpp index 9259a8a19..beaa4f1b6 100644 --- a/dep/acelite/ace/Trace.cpp +++ b/dep/acelite/ace/Trace.cpp @@ -1,3 +1,5 @@ +// $Id: Trace.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/Trace.h" // Turn off tracing for the duration of this file. @@ -8,9 +10,6 @@ #include "ace/Log_Category.h" #include "ace/Object_Manager_Base.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Trace.h b/dep/acelite/ace/Trace.h index d29acb23d..3fbc9ce0b 100644 --- a/dep/acelite/ace/Trace.h +++ b/dep/acelite/ace/Trace.h @@ -4,7 +4,9 @@ /** * @file Trace.h * - * @author Douglas C. Schmidt + * $Id: Trace.h 87823 2009-11-30 12:38:34Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -46,9 +48,6 @@ public: /// as the function is exited. ~ACE_Trace (void); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - // = Control the tracing level. /// Determine if tracing is enabled or not static bool is_tracing(void); diff --git a/dep/acelite/ace/Truncate.h b/dep/acelite/ace/Truncate.h index fd9fed20f..8ff051415 100644 --- a/dep/acelite/ace/Truncate.h +++ b/dep/acelite/ace/Truncate.h @@ -4,6 +4,8 @@ /** * @file Truncate.h * + * $Id: Truncate.h 95761 2012-05-15 18:23:04Z johnnyw $ + * * @author Steve Huston * @author Ossama Othman * @author Russell Mora @@ -32,28 +34,28 @@ namespace ACE_Utils template struct Sign_Check; // Specialize the unsigned signed cases. - template<> struct Sign_Check { static bool const is_signed = false; }; - template<> struct Sign_Check { static bool const is_signed = false; }; - template<> struct Sign_Check { static bool const is_signed = false; }; - template<> struct Sign_Check { static bool const is_signed = false; }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; # ifdef __GNUC__ // Silence g++ "-pedantic" warnings regarding use of "long long" // type. __extension__ # endif /* __GNUC__ */ - template<> struct Sign_Check { static bool const is_signed = false; }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; // Specialize the signed cases. - template<> struct Sign_Check { static bool const is_signed = true; }; - template<> struct Sign_Check { static bool const is_signed = true; }; - template<> struct Sign_Check { static bool const is_signed = true; }; - template<> struct Sign_Check { static bool const is_signed = true; }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; # ifdef __GNUC__ // Silence g++ "-pedantic" warnings regarding use of "long long" // type. __extension__ # endif /* __GNUC__ */ - template<> struct Sign_Check { static bool const is_signed = true; }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; // ----------------------------------------------------- @@ -271,8 +273,9 @@ namespace ACE_Utils template struct Fast_Comparator { - static bool const USE_LEFT = - ((sizeof (LEFT) > sizeof (RIGHT) + ACE_STATIC_CONSTANT ( + bool, + USE_LEFT = ((sizeof (LEFT) > sizeof (RIGHT) && (Sign_Check::is_signed == 1 || Sign_Check::is_signed == 0)) @@ -288,14 +291,15 @@ namespace ACE_Utils && ((Sign_Check::is_signed == 1 && Sign_Check::is_signed == 1) || (Sign_Check::is_signed == 0 - && Sign_Check::is_signed == 0)))); + && Sign_Check::is_signed == 0))))); - static bool const USE_RIGHT = - (sizeof (RIGHT) > sizeof (LEFT) + ACE_STATIC_CONSTANT ( + bool, + USE_RIGHT = (sizeof (RIGHT) > sizeof (LEFT) && (Sign_Check::is_signed == 1 - || Sign_Check::is_signed == 0)); + || Sign_Check::is_signed == 0))); - static bool const USABLE = (USE_LEFT || USE_RIGHT); + ACE_STATIC_CONSTANT (bool, USABLE = (USE_LEFT || USE_RIGHT)); typedef typename ACE::If_Then_Else< USE_LEFT, @@ -368,11 +372,12 @@ namespace ACE_Utils template struct Truncator { - static bool const + ACE_STATIC_CONSTANT ( + bool, // max FROM always greater than max TO MAX_FROM_GT_MAX_TO = (sizeof(FROM) > sizeof (TO) || (sizeof(FROM) == sizeof (TO) - && Sign_Check::is_signed == 0)); + && Sign_Check::is_signed == 0))); typedef typename ACE::If_Then_Else< MAX_FROM_GT_MAX_TO, diff --git a/dep/acelite/ace/Typed_SV_Message.cpp b/dep/acelite/ace/Typed_SV_Message.cpp index 842d70ac2..6be3d4c68 100644 --- a/dep/acelite/ace/Typed_SV_Message.cpp +++ b/dep/acelite/ace/Typed_SV_Message.cpp @@ -1,3 +1,5 @@ +// $Id: Typed_SV_Message.cpp 80826 2008-03-04 14:51:23Z wotte $ + #ifndef ACE_TYPED_SV_MESSAGE_CPP #define ACE_TYPED_SV_MESSAGE_CPP diff --git a/dep/acelite/ace/Typed_SV_Message.h b/dep/acelite/ace/Typed_SV_Message.h index 50ef362fb..b43258e01 100644 --- a/dep/acelite/ace/Typed_SV_Message.h +++ b/dep/acelite/ace/Typed_SV_Message.h @@ -4,6 +4,8 @@ /** * @file Typed_SV_Message.h * + * $Id: Typed_SV_Message.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //========================================================================== diff --git a/dep/acelite/ace/Typed_SV_Message.inl b/dep/acelite/ace/Typed_SV_Message.inl index 2e3c12939..6d8ea7023 100644 --- a/dep/acelite/ace/Typed_SV_Message.inl +++ b/dep/acelite/ace/Typed_SV_Message.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Typed_SV_Message.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/config-all.h" #include "ace/Global_Macros.h" diff --git a/dep/acelite/ace/Typed_SV_Message_Queue.cpp b/dep/acelite/ace/Typed_SV_Message_Queue.cpp index 3fe864f14..88cd1b848 100644 --- a/dep/acelite/ace/Typed_SV_Message_Queue.cpp +++ b/dep/acelite/ace/Typed_SV_Message_Queue.cpp @@ -1,3 +1,5 @@ +// $Id: Typed_SV_Message_Queue.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_TYPED_SV_MESSAGE_QUEUE_CPP #define ACE_TYPED_SV_MESSAGE_QUEUE_CPP diff --git a/dep/acelite/ace/Typed_SV_Message_Queue.h b/dep/acelite/ace/Typed_SV_Message_Queue.h index b3015a04b..12c0e5092 100644 --- a/dep/acelite/ace/Typed_SV_Message_Queue.h +++ b/dep/acelite/ace/Typed_SV_Message_Queue.h @@ -4,7 +4,9 @@ /** * @file Typed_SV_Message_Queue.h * - * @author Douglas C. Schmidt + * $Id: Typed_SV_Message_Queue.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Typed_SV_Message_Queue.inl b/dep/acelite/ace/Typed_SV_Message_Queue.inl index 915bd3717..90539936e 100644 --- a/dep/acelite/ace/Typed_SV_Message_Queue.inl +++ b/dep/acelite/ace/Typed_SV_Message_Queue.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Typed_SV_Message_Queue.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/SV_Message_Queue.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/UNIX_Addr.cpp b/dep/acelite/ace/UNIX_Addr.cpp index 460c58fc4..fa889d84e 100644 --- a/dep/acelite/ace/UNIX_Addr.cpp +++ b/dep/acelite/ace/UNIX_Addr.cpp @@ -1,13 +1,11 @@ +// $Id: UNIX_Addr.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/UNIX_Addr.h" #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) -#if defined (ACE_HAS_ALLOC_HOOKS) -# include "ace/Malloc_Base.h" -#endif /* ACE_HAS_ALLOC_HOOKS */ - #if !defined (__ACE_INLINE__) #include "ace/UNIX_Addr.inl" #endif /* __ACE_INLINE__ */ @@ -18,12 +16,14 @@ ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr) // Set a pointer to the address. void -ACE_UNIX_Addr::set_addr (const void *addr, int len) +ACE_UNIX_Addr::set_addr (void *addr, int len) { ACE_TRACE ("ACE_UNIX_Addr::set_addr"); this->ACE_Addr::base_set (AF_UNIX, len); - ACE_OS::memcpy (&this->unix_addr_, addr, len); + ACE_OS::memcpy ((void *) &this->unix_addr_, + (void *) addr, + len); } // Return a pointer to the underlying address. @@ -41,10 +41,6 @@ ACE_UNIX_Addr::string_to_addr (const char addr[]) { ACE_OS::strsncpy (this->unix_addr_.sun_path, addr, sizeof this->unix_addr_.sun_path); - - this->set_size (sizeof this->unix_addr_ - - sizeof (this->unix_addr_.sun_path) + - ACE_OS::strlen (this->unix_addr_.sun_path)); return 0; } @@ -75,8 +71,7 @@ ACE_UNIX_Addr::dump (void) const // Do nothing constructor. ACE_UNIX_Addr::ACE_UNIX_Addr (void) - : ACE_Addr (AF_UNIX, - sizeof this->unix_addr_ - sizeof (this->unix_addr_.sun_path)) + : ACE_Addr (AF_UNIX, sizeof this->unix_addr_) { (void) ACE_OS::memset ((void *) &this->unix_addr_, 0, diff --git a/dep/acelite/ace/UNIX_Addr.h b/dep/acelite/ace/UNIX_Addr.h index 02749abf0..e60465528 100644 --- a/dep/acelite/ace/UNIX_Addr.h +++ b/dep/acelite/ace/UNIX_Addr.h @@ -4,6 +4,8 @@ /** * @file UNIX_Addr.h * + * $Id: UNIX_Addr.h 96985 2013-04-11 15:50:32Z huangh $ + * * @author Doug Schmidt */ //============================================================================= @@ -63,7 +65,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the underlying network address. - virtual void set_addr (const void *addr, int len); + virtual void set_addr (void *addr, int len); /// Transform the current address into string format. virtual int addr_to_string (ACE_TCHAR addr[], size_t) const; diff --git a/dep/acelite/ace/UNIX_Addr.inl b/dep/acelite/ace/UNIX_Addr.inl index f19ef68a5..5e801b56f 100644 --- a/dep/acelite/ace/UNIX_Addr.inl +++ b/dep/acelite/ace/UNIX_Addr.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: UNIX_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/OS_NS_string.h" diff --git a/dep/acelite/ace/UPIPE_Acceptor.cpp b/dep/acelite/ace/UPIPE_Acceptor.cpp index 708c5037f..6d6366cd0 100644 --- a/dep/acelite/ace/UPIPE_Acceptor.cpp +++ b/dep/acelite/ace/UPIPE_Acceptor.cpp @@ -1,3 +1,5 @@ +// $Id: UPIPE_Acceptor.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/UPIPE_Acceptor.h" diff --git a/dep/acelite/ace/UPIPE_Acceptor.h b/dep/acelite/ace/UPIPE_Acceptor.h index 432fac53f..e4925a045 100644 --- a/dep/acelite/ace/UPIPE_Acceptor.h +++ b/dep/acelite/ace/UPIPE_Acceptor.h @@ -4,6 +4,8 @@ /** * @file UPIPE_Acceptor.h * + * $Id: UPIPE_Acceptor.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Gerhard Lenzer * @author Douglas C. Schmidt */ diff --git a/dep/acelite/ace/UPIPE_Acceptor.inl b/dep/acelite/ace/UPIPE_Acceptor.inl index 37af88b4a..9432ad7bb 100644 --- a/dep/acelite/ace/UPIPE_Acceptor.inl +++ b/dep/acelite/ace/UPIPE_Acceptor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: UPIPE_Acceptor.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int diff --git a/dep/acelite/ace/UPIPE_Addr.h b/dep/acelite/ace/UPIPE_Addr.h index eb331b0b1..aaf33b683 100644 --- a/dep/acelite/ace/UPIPE_Addr.h +++ b/dep/acelite/ace/UPIPE_Addr.h @@ -4,6 +4,8 @@ /** * @file UPIPE_Addr.h * + * $Id: UPIPE_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Doug Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/UPIPE_Connector.cpp b/dep/acelite/ace/UPIPE_Connector.cpp index 144c1502a..07fc462a0 100644 --- a/dep/acelite/ace/UPIPE_Connector.cpp +++ b/dep/acelite/ace/UPIPE_Connector.cpp @@ -1,3 +1,5 @@ +// $Id: UPIPE_Connector.cpp 96985 2013-04-11 15:50:32Z huangh $ + #include "ace/UPIPE_Connector.h" diff --git a/dep/acelite/ace/UPIPE_Connector.h b/dep/acelite/ace/UPIPE_Connector.h index fff02dc59..b2ad1787a 100644 --- a/dep/acelite/ace/UPIPE_Connector.h +++ b/dep/acelite/ace/UPIPE_Connector.h @@ -4,6 +4,8 @@ /** * @file UPIPE_Connector.h * + * $Id: UPIPE_Connector.h 82723 2008-09-16 09:35:44Z johnnyw $ + * * @author Gerhard Lenzer and Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/UPIPE_Connector.inl b/dep/acelite/ace/UPIPE_Connector.inl index cbb55a486..b44ac6e6f 100644 --- a/dep/acelite/ace/UPIPE_Connector.inl +++ b/dep/acelite/ace/UPIPE_Connector.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: UPIPE_Connector.inl 96985 2013-04-11 15:50:32Z huangh $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Creates a Local ACE_UPIPE. diff --git a/dep/acelite/ace/UPIPE_Stream.cpp b/dep/acelite/ace/UPIPE_Stream.cpp index 46d470ce7..03c063add 100644 --- a/dep/acelite/ace/UPIPE_Stream.cpp +++ b/dep/acelite/ace/UPIPE_Stream.cpp @@ -1,3 +1,5 @@ +// $Id: UPIPE_Stream.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/UPIPE_Stream.h" diff --git a/dep/acelite/ace/UPIPE_Stream.h b/dep/acelite/ace/UPIPE_Stream.h index 491c8799c..b10aef115 100644 --- a/dep/acelite/ace/UPIPE_Stream.h +++ b/dep/acelite/ace/UPIPE_Stream.h @@ -4,6 +4,8 @@ /** * @file UPIPE_Stream.h * + * $Id: UPIPE_Stream.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Gerhard Lenzer * @author Douglas C. Schmidt */ diff --git a/dep/acelite/ace/UPIPE_Stream.inl b/dep/acelite/ace/UPIPE_Stream.inl index acc4a4ed7..7a0d73c31 100644 --- a/dep/acelite/ace/UPIPE_Stream.inl +++ b/dep/acelite/ace/UPIPE_Stream.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: UPIPE_Stream.inl 80826 2008-03-04 14:51:23Z wotte $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_HANDLE diff --git a/dep/acelite/ace/UTF16_Encoding_Converter.cpp b/dep/acelite/ace/UTF16_Encoding_Converter.cpp index 941ab11b2..da883734c 100644 --- a/dep/acelite/ace/UTF16_Encoding_Converter.cpp +++ b/dep/acelite/ace/UTF16_Encoding_Converter.cpp @@ -1,3 +1,5 @@ +// $Id: UTF16_Encoding_Converter.cpp 83735 2008-11-14 09:41:52Z johnnyw $ + // ====================================================================== // // The actual conversion methods are covered by the copyright information diff --git a/dep/acelite/ace/UTF16_Encoding_Converter.h b/dep/acelite/ace/UTF16_Encoding_Converter.h index 0097b7bb8..9bdcb21a0 100644 --- a/dep/acelite/ace/UTF16_Encoding_Converter.h +++ b/dep/acelite/ace/UTF16_Encoding_Converter.h @@ -4,6 +4,8 @@ /** * @file UTF16_Encoding_Converter.h * + * $Id: UTF16_Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * * This class contains declarations for methods that convert between * UTF-16 (both BE and LE) and UTF-8 * diff --git a/dep/acelite/ace/UTF16_Encoding_Converter.inl b/dep/acelite/ace/UTF16_Encoding_Converter.inl index d241c5ec8..e52927578 100644 --- a/dep/acelite/ace/UTF16_Encoding_Converter.inl +++ b/dep/acelite/ace/UTF16_Encoding_Converter.inl @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: UTF16_Encoding_Converter.inl 80826 2008-03-04 14:51:23Z wotte $ + // ====================================================================== // // The actual conversion methods are covered by the copyright information diff --git a/dep/acelite/ace/UTF32_Encoding_Converter.cpp b/dep/acelite/ace/UTF32_Encoding_Converter.cpp index 22bd9fac0..459bf2530 100644 --- a/dep/acelite/ace/UTF32_Encoding_Converter.cpp +++ b/dep/acelite/ace/UTF32_Encoding_Converter.cpp @@ -1,3 +1,5 @@ +// $Id: UTF32_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + // ====================================================================== // // The actual conversion methods are covered by the copyright information diff --git a/dep/acelite/ace/UTF32_Encoding_Converter.h b/dep/acelite/ace/UTF32_Encoding_Converter.h index ab7b9d14e..214edeeee 100644 --- a/dep/acelite/ace/UTF32_Encoding_Converter.h +++ b/dep/acelite/ace/UTF32_Encoding_Converter.h @@ -4,6 +4,8 @@ /** * @file UTF32_Encoding_Converter.h * + * $Id: UTF32_Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * * This class contains declarations for methods that convert between * UTF-32 (both BE and LE) and UTF-8 * diff --git a/dep/acelite/ace/UTF8_Encoding_Converter.cpp b/dep/acelite/ace/UTF8_Encoding_Converter.cpp index a618ba403..cd6c409d0 100644 --- a/dep/acelite/ace/UTF8_Encoding_Converter.cpp +++ b/dep/acelite/ace/UTF8_Encoding_Converter.cpp @@ -1,3 +1,5 @@ +// $Id: UTF8_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/UTF8_Encoding_Converter.h" #if defined (ACE_USES_WCHAR) diff --git a/dep/acelite/ace/UTF8_Encoding_Converter.h b/dep/acelite/ace/UTF8_Encoding_Converter.h index 3cca2f41d..2cb6ed4e4 100644 --- a/dep/acelite/ace/UTF8_Encoding_Converter.h +++ b/dep/acelite/ace/UTF8_Encoding_Converter.h @@ -4,6 +4,8 @@ /** * @file UTF8_Encoding_Converter.h * + * $Id: UTF8_Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * * This class contains declarations for methods that convert between * UTF-8 and the native ACE_TCHAR representation. * diff --git a/dep/acelite/ace/UUID.cpp b/dep/acelite/ace/UUID.cpp index dbac895fb..a08a0e7f3 100644 --- a/dep/acelite/ace/UUID.cpp +++ b/dep/acelite/ace/UUID.cpp @@ -1,3 +1,5 @@ +//$Id: UUID.cpp 97383 2013-10-23 08:44:20Z mhengstmengel $ + #include "ace/UUID.h" #include "ace/Guard_T.h" @@ -20,15 +22,11 @@ namespace ACE_Utils // NIL version of the UUID const UUID UUID::NIL_UUID; -#ifndef ACE_LACKS_SSCANF UUID::UUID (const ACE_CString& uuid_string) { this->init (); this->from_string_i (uuid_string); } -#endif /* ACE_LACKS_SSCANF */ - - ACE_ALLOC_HOOK_DEFINE(UUID); const UUID & UUID::operator = (const UUID & rhs) @@ -69,65 +67,52 @@ namespace ACE_Utils if (36 == UUID_STRING_LENGTH) { -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (buf, - static_cast (ACE_Allocator::instance()->malloc(sizeof (char) * (UUID_STRING_LENGTH + 1))), - 0); -#else ACE_NEW_RETURN (buf, char[UUID_STRING_LENGTH + 1], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Let the auto array pointer manage the buffer. auto_clean.reset (buf); - ACE_OS::snprintf (buf, UUID_STRING_LENGTH + 1, - "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", - this->uuid_.time_low_, - this->uuid_.time_mid_, - this->uuid_.time_hi_and_version_, - this->uuid_.clock_seq_hi_and_reserved_, - this->uuid_.clock_seq_low_, - this->uuid_.node_.node_ID ()[0], - this->uuid_.node_.node_ID ()[1], - this->uuid_.node_.node_ID ()[2], - this->uuid_.node_.node_ID ()[3], - this->uuid_.node_.node_ID ()[4], - this->uuid_.node_.node_ID ()[5]); + ACE_OS::sprintf (buf, + "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", + this->uuid_.time_low_, + this->uuid_.time_mid_, + this->uuid_.time_hi_and_version_, + this->uuid_.clock_seq_hi_and_reserved_, + this->uuid_.clock_seq_low_, + (this->uuid_.node_.node_ID ()) [0], + (this->uuid_.node_.node_ID ()) [1], + (this->uuid_.node_.node_ID ()) [2], + (this->uuid_.node_.node_ID ()) [3], + (this->uuid_.node_.node_ID ()) [4], + (this->uuid_.node_.node_ID ()) [5]); } else { UUID_STRING_LENGTH += 2; //for '-' - -#if defined (ACE_HAS_ALLOC_HOOKS) - ACE_ALLOCATOR_RETURN (buf, - static_cast (ACE_Allocator::instance()->malloc(sizeof (char) * (UUID_STRING_LENGTH + 1))), - 0); -#else ACE_NEW_RETURN (buf, char[UUID_STRING_LENGTH + 1], 0); -#endif /* ACE_HAS_ALLOC_HOOKS */ // Let the auto array pointer manage the buffer. auto_clean.reset (buf); - ACE_OS::snprintf (buf, UUID_STRING_LENGTH + 1, - "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s", - this->uuid_.time_low_, - this->uuid_.time_mid_, - this->uuid_.time_hi_and_version_, - this->uuid_.clock_seq_hi_and_reserved_, - this->uuid_.clock_seq_low_, - this->uuid_.node_.node_ID ()[0], - this->uuid_.node_.node_ID ()[1], - this->uuid_.node_.node_ID ()[2], - this->uuid_.node_.node_ID ()[3], - this->uuid_.node_.node_ID ()[4], - this->uuid_.node_.node_ID ()[5], - thr_id_.c_str (), - pid_.c_str ()); + ACE_OS::sprintf (buf, + "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s", + this->uuid_.time_low_, + this->uuid_.time_mid_, + this->uuid_.time_hi_and_version_, + this->uuid_.clock_seq_hi_and_reserved_, + this->uuid_.clock_seq_low_, + (this->uuid_.node_.node_ID ()) [0], + (this->uuid_.node_.node_ID ()) [1], + (this->uuid_.node_.node_ID ()) [2], + (this->uuid_.node_.node_ID ()) [3], + (this->uuid_.node_.node_ID ()) [4], + (this->uuid_.node_.node_ID ()) [5], + thr_id_.c_str (), + pid_.c_str ()); } // Save the string. @@ -141,7 +126,6 @@ namespace ACE_Utils return this->as_string_.get (); } -#ifndef ACE_LACKS_SSCANF void UUID::from_string_i (const ACE_CString& uuid_string) { @@ -178,22 +162,9 @@ namespace ACE_Utils const int nScanned = #if defined (ACE_HAS_TR24731_2005_CRT) sscanf_s ( - uuid_string.c_str (), - "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", - &time_low, - &time_mid, - &time_hi_and_version, - &clock_seq_hi_and_reserved, - &clock_seq_low, - &node[0], - &node[1], - &node[2], - &node[3], - &node[4], - &node[5] - ); #else ::sscanf ( +#endif /* ACE_HAS_TR24731_2005_CRT */ uuid_string.c_str (), "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", &time_low, @@ -208,7 +179,6 @@ namespace ACE_Utils &node[4], &node[5] ); -#endif /* ACE_HAS_TR24731_2005_CRT */ if (nScanned != 11) { @@ -317,7 +287,6 @@ namespace ACE_Utils this->pid_ = thr_pid_str.substr (pos+1, thr_pid_str.length ()-pos-1); } } -#endif // ACE_LACKS_SSCANF UUID_Generator::UUID_Generator (void) : time_last_ (0), @@ -406,11 +375,12 @@ namespace ACE_Utils { ACE_Thread_ID thread_id; char buf [BUFSIZ]; - thread_id.to_string (buf, BUFSIZ); + thread_id.to_string (buf); uuid.thr_id (buf); - ACE_OS::snprintf (buf, BUFSIZ, "%d", - static_cast (ACE_OS::getpid ())); + ACE_OS::sprintf (buf, + "%d", + static_cast (ACE_OS::getpid ())); uuid.pid (buf); } } diff --git a/dep/acelite/ace/UUID.h b/dep/acelite/ace/UUID.h index 5ed3877da..ae43c145d 100644 --- a/dep/acelite/ace/UUID.h +++ b/dep/acelite/ace/UUID.h @@ -4,6 +4,8 @@ /** * @file UUID.h * + * $Id: UUID.h 88604 2010-01-18 18:01:19Z hillj $ + * * @author Andrew T. Finnel * @author Yamuna Krishnmaurthy */ @@ -88,10 +90,8 @@ namespace ACE_Utils /// Constructor UUID (void); -#ifndef ACE_LACKS_SSCANF /// Constructs a UUID from a string representation. UUID (const ACE_CString& uuidString); -#endif UUID (const UUID &right); @@ -127,10 +127,8 @@ namespace ACE_Utils /// Returns a string representation of the UUID const ACE_CString* to_string (void) const; -#ifndef ACE_LACKS_SSCANF /// Set the value using a string void from_string (const ACE_CString& uuid_string); -#endif /// NIL UUID static const UUID NIL_UUID; @@ -145,8 +143,6 @@ namespace ACE_Utils /// Assign an existing UUID to this UUID. const UUID & operator = (const UUID & rhs); - ACE_ALLOC_HOOK_DECLARE; - private: /// Initialize the UUID void init (void); @@ -156,9 +152,7 @@ namespace ACE_Utils * * @param[in] uuid_string String version of UUID. */ -#ifndef ACE_LACKS_SSCANF void from_string_i (const ACE_CString& uuid_string); -#endif /// Data Members for Class Attributes struct data @@ -267,7 +261,7 @@ namespace ACE_Utils bool destroy_lock_; - /// Initialization state of the generator. + /// Initalization state of the generator. bool is_init_; }; @@ -285,3 +279,4 @@ ACE_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" #endif // ACE_UUID_H + diff --git a/dep/acelite/ace/UUID.inl b/dep/acelite/ace/UUID.inl index cf3a3c150..568adfa00 100644 --- a/dep/acelite/ace/UUID.inl +++ b/dep/acelite/ace/UUID.inl @@ -1,5 +1,7 @@ // -*- C++ -*- // +//$Id: UUID.inl 85331 2009-05-14 00:04:12Z hillj $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_Utils @@ -153,13 +155,11 @@ namespace ACE_Utils this->pid_ = pid; } -#ifndef ACE_LACKS_SSCANF ACE_INLINE void UUID::from_string (const ACE_CString& uuidString) { this->from_string_i (uuidString); } -#endif ACE_INLINE bool UUID::operator == (const UUID &right) const diff --git a/dep/acelite/ace/Unbounded_Queue.cpp b/dep/acelite/ace/Unbounded_Queue.cpp index 02f96eeab..317458469 100644 --- a/dep/acelite/ace/Unbounded_Queue.cpp +++ b/dep/acelite/ace/Unbounded_Queue.cpp @@ -1,3 +1,5 @@ +// $Id: Unbounded_Queue.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_UNBOUNDED_QUEUE_CPP #define ACE_UNBOUNDED_QUEUE_CPP @@ -17,7 +19,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Unbounded_Queue) +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Queue) template ACE_Unbounded_Queue::ACE_Unbounded_Queue (ACE_Allocator *alloc) diff --git a/dep/acelite/ace/Unbounded_Queue.h b/dep/acelite/ace/Unbounded_Queue.h index 1a660ad2a..65be7aaae 100644 --- a/dep/acelite/ace/Unbounded_Queue.h +++ b/dep/acelite/ace/Unbounded_Queue.h @@ -4,7 +4,9 @@ /** * @file Unbounded_Queue.h * - * @author Douglas C. Schmidt + * $Id: Unbounded_Queue.h 84316 2009-02-03 19:46:05Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -142,6 +144,7 @@ private: * -# Default constructor * -# Copy constructor * -# operator= + * */ template class ACE_Unbounded_Queue diff --git a/dep/acelite/ace/Unbounded_Queue.inl b/dep/acelite/ace/Unbounded_Queue.inl index b3e76ad99..81e3ded3e 100644 --- a/dep/acelite/ace/Unbounded_Queue.inl +++ b/dep/acelite/ace/Unbounded_Queue.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Unbounded_Queue.inl 84316 2009-02-03 19:46:05Z johnnyw $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE size_t diff --git a/dep/acelite/ace/Unbounded_Set.cpp b/dep/acelite/ace/Unbounded_Set.cpp index 4450f21f0..a452eb339 100644 --- a/dep/acelite/ace/Unbounded_Set.cpp +++ b/dep/acelite/ace/Unbounded_Set.cpp @@ -1,3 +1,5 @@ +// $Id: Unbounded_Set.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_UNBOUNDED_SET_CPP #define ACE_UNBOUNDED_SET_CPP diff --git a/dep/acelite/ace/Unbounded_Set.h b/dep/acelite/ace/Unbounded_Set.h index 24be412d7..165560951 100644 --- a/dep/acelite/ace/Unbounded_Set.h +++ b/dep/acelite/ace/Unbounded_Set.h @@ -4,7 +4,9 @@ /** * @file Unbounded_Set.h * - * @author Douglas C. Schmidt + * $Id: Unbounded_Set.h 91743 2010-09-13 18:24:51Z johnnyw $ + * + * @author Douglas C. Schmidt */ //============================================================================= diff --git a/dep/acelite/ace/Unbounded_Set.inl b/dep/acelite/ace/Unbounded_Set.inl index d1372f243..c83629496 100644 --- a/dep/acelite/ace/Unbounded_Set.inl +++ b/dep/acelite/ace/Unbounded_Set.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Unbounded_Set.inl 91813 2010-09-17 07:52:52Z johnnyw $ + #include "ace/Global_Macros.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Unbounded_Set_Ex.cpp b/dep/acelite/ace/Unbounded_Set_Ex.cpp index d6460cef1..81fd7e48c 100644 --- a/dep/acelite/ace/Unbounded_Set_Ex.cpp +++ b/dep/acelite/ace/Unbounded_Set_Ex.cpp @@ -1,3 +1,5 @@ +// $Id: Unbounded_Set_Ex.cpp 96985 2013-04-11 15:50:32Z huangh $ + #ifndef ACE_UNBOUNDED_SET_EX_CPP #define ACE_UNBOUNDED_SET_EX_CPP @@ -15,7 +17,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unbounded_Set_Ex) +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex) template size_t ACE_Unbounded_Set_Ex::size (void) const @@ -226,7 +228,7 @@ ACE_Unbounded_Set_Ex::remove (const T &item) { // ACE_TRACE ("ACE_Unbounded_Set_Ex::remove"); - // Insert the item to be found into the dummy node. + // Insert the item to be founded into the dummy node. this->head_->item_ = item; NODE *curr = this->head_; @@ -234,11 +236,6 @@ ACE_Unbounded_Set_Ex::remove (const T &item) while (!(this->comp_ (curr->next_->item_, item))) curr = curr->next_; - // reset the dummy node. This ensures reference counted items are - // completely released. Without this, a reference can linger as - // the dummy long after it was removed from the list. - this->head_->item_ = T(); - if (curr->next_ == this->head_) return -1; // Item was not found. else @@ -283,7 +280,7 @@ ACE_Unbounded_Set_Ex::end (void) const return const_iterator (*this, 1); } -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unbounded_Set_Ex_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Iterator) template void ACE_Unbounded_Set_Ex_Iterator::dump (void) const @@ -390,7 +387,7 @@ ACE_Unbounded_Set_Ex_Iterator::operator!= (const ACE_Unbounded_Set_Ex_Iter return (this->set_ != rhs.set_ || this->current_ != rhs.current_); } -ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unbounded_Set_Ex_Const_Iterator) +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Const_Iterator) template void ACE_Unbounded_Set_Ex_Const_Iterator::dump (void) const diff --git a/dep/acelite/ace/Unbounded_Set_Ex.h b/dep/acelite/ace/Unbounded_Set_Ex.h index b984adeda..3d290a6ac 100644 --- a/dep/acelite/ace/Unbounded_Set_Ex.h +++ b/dep/acelite/ace/Unbounded_Set_Ex.h @@ -4,7 +4,9 @@ /** * @file Unbounded_Set_Ex.h * - * @author Douglas C. Schmidt + * $Id: Unbounded_Set_Ex.h 88978 2010-02-13 16:03:31Z hillj $ + * + * @author Douglas C. Schmidt */ //============================================================================= @@ -207,6 +209,7 @@ private: * -# Copy constructor * -# operator= * -# operator== const + * */ template class ACE_Unbounded_Set_Ex diff --git a/dep/acelite/ace/Unbounded_Set_Ex.inl b/dep/acelite/ace/Unbounded_Set_Ex.inl index bbb8772d6..356a1f58f 100644 --- a/dep/acelite/ace/Unbounded_Set_Ex.inl +++ b/dep/acelite/ace/Unbounded_Set_Ex.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Unbounded_Set_Ex.inl 81624 2008-05-06 17:14:57Z wotte $ + #include "ace/Global_Macros.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/dep/acelite/ace/Value_Ptr.h b/dep/acelite/ace/Value_Ptr.h index 8d22e5e2b..c7acc1251 100644 --- a/dep/acelite/ace/Value_Ptr.h +++ b/dep/acelite/ace/Value_Ptr.h @@ -4,6 +4,8 @@ /** * @file Value_Ptr.h * + * $Id: Value_Ptr.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * Value_Ptr implementation based on code in Herb Sutter's book "More * Exceptional C++". * diff --git a/dep/acelite/ace/Vector_T.cpp b/dep/acelite/ace/Vector_T.cpp index 3cbec049a..f46466534 100644 --- a/dep/acelite/ace/Vector_T.cpp +++ b/dep/acelite/ace/Vector_T.cpp @@ -1,3 +1,5 @@ +// $Id: Vector_T.cpp 92069 2010-09-28 11:38:59Z johnnyw $ + #ifndef ACE_VECTOR_T_CPP #define ACE_VECTOR_T_CPP @@ -13,7 +15,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Vector) +ACE_ALLOC_HOOK_DEFINE(ACE_Vector) template void ACE_Vector::resize (const size_t new_size, @@ -66,7 +68,6 @@ ACE_Vector::operator== (const ACE_Vector &s) c } // **************************************************************** -ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Vector_Iterator) template int ACE_Vector_Iterator::next (T *&item) diff --git a/dep/acelite/ace/Vector_T.h b/dep/acelite/ace/Vector_T.h index a5be43470..8037bd6e2 100644 --- a/dep/acelite/ace/Vector_T.h +++ b/dep/acelite/ace/Vector_T.h @@ -4,6 +4,8 @@ /** * @file Vector_T.h * + * $Id: Vector_T.h 92069 2010-09-28 11:38:59Z johnnyw $ + * * @author Craig L. Ching * @author Gonzalo Diethelm */ @@ -90,9 +92,6 @@ public: */ ~ACE_Vector (); - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - /** * Returns the current vector capacity, that is, the currently * allocated buffer size. @@ -188,16 +187,6 @@ public: void swap (ACE_Vector &rhs); - /* - * Implement our own end functions because Array_Base's end functions use the - * current capacity, not the Vector's actual element count! - */ - /// C++ Standard End Iterator - ///{ - typename ACE_Array_Base::iterator end (); - typename ACE_Array_Base::const_iterator end () const; - ///} - protected: /** diff --git a/dep/acelite/ace/Vector_T.inl b/dep/acelite/ace/Vector_T.inl index 103bb93be..4b773109a 100644 --- a/dep/acelite/ace/Vector_T.inl +++ b/dep/acelite/ace/Vector_T.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: Vector_T.inl 81478 2008-04-28 13:22:26Z schmidt $ + #include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -45,18 +48,6 @@ void ACE_Vector::pop_back (void) } } -template ACE_INLINE -typename ACE_Array_Base::iterator ACE_Vector::end () -{ - return ACE_Array_Base::array_ + length_; -} - -template ACE_INLINE -typename ACE_Array_Base::const_iterator ACE_Vector::end () const -{ - return ACE_Array_Base::array_ + length_; -} - // Compare this vector with for inequality. template ACE_INLINE bool diff --git a/dep/acelite/ace/Version.h b/dep/acelite/ace/Version.h index d2854c550..98c7edd50 100644 --- a/dep/acelite/ace/Version.h +++ b/dep/acelite/ace/Version.h @@ -1,12 +1,9 @@ // -*- C++ -*- -// This is file was automatically generated by $ACE_ROOT/bin/make_release.py +// $Id: Version.h 97979 2014-11-14 07:38:51Z johnnyw $ +// This is file was automatically generated by \$ACE_ROOT/bin/make_release.py #define ACE_MAJOR_VERSION 6 -#define ACE_MINOR_VERSION 5 -#define ACE_MICRO_VERSION 5 -#define ACE_BETA_VERSION 5 -#define ACE_VERSION "6.5.5" -#define ACE_VERSION_CODE 394501 -#define ACE_MAKE_VERSION_CODE(a,b,c) (((a) << 16) + ((b) << 8) + (c)) - +#define ACE_MINOR_VERSION 3 +#define ACE_BETA_VERSION 0 +#define ACE_VERSION "6.3.0" diff --git a/dep/acelite/ace/Versioned_Namespace.h b/dep/acelite/ace/Versioned_Namespace.h index cd1e68ba7..211584134 100644 --- a/dep/acelite/ace/Versioned_Namespace.h +++ b/dep/acelite/ace/Versioned_Namespace.h @@ -4,6 +4,8 @@ /** * @file Versioned_Namespace.h * + * $Id: Versioned_Namespace.h 92286 2010-10-20 18:22:07Z johnnyw $ + * * Versioned namespace support. * * Useful for preventing conflicts when using a third party library. @@ -29,9 +31,9 @@ // concatenated. Force the preprocessor to expand them during the // argument prescan by calling a macro that itself calls another that // performs the actual concatenation. -# define ACE_MAKE_VERSIONED_NAMESPACE_NAME_IMPL(MAJOR,MINOR,MICRO) ACE_ ## MAJOR ## _ ## MINOR ## _ ## MICRO -# define ACE_MAKE_VERSIONED_NAMESPACE_NAME(MAJOR,MINOR,MICRO) ACE_MAKE_VERSIONED_NAMESPACE_NAME_IMPL(MAJOR,MINOR,MICRO) -# define ACE_VERSIONED_NAMESPACE_NAME ACE_MAKE_VERSIONED_NAMESPACE_NAME(ACE_MAJOR_VERSION,ACE_MINOR_VERSION,ACE_MICRO_VERSION) +# define ACE_MAKE_VERSIONED_NAMESPACE_NAME_IMPL(MAJOR,MINOR,BETA) ACE_ ## MAJOR ## _ ## MINOR ## _ ## BETA +# define ACE_MAKE_VERSIONED_NAMESPACE_NAME(MAJOR,MINOR,BETA) ACE_MAKE_VERSIONED_NAMESPACE_NAME_IMPL(MAJOR,MINOR,BETA) +# define ACE_VERSIONED_NAMESPACE_NAME ACE_MAKE_VERSIONED_NAMESPACE_NAME(ACE_MAJOR_VERSION,ACE_MINOR_VERSION,ACE_BETA_VERSION) # endif /* !ACE_VERSIONED_NAMESPACE_NAME */ # define ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_VERSIONED_NAMESPACE_NAME { diff --git a/dep/acelite/ace/WFMO_Reactor.cpp b/dep/acelite/ace/WFMO_Reactor.cpp index 5f901b141..db245afb0 100644 --- a/dep/acelite/ace/WFMO_Reactor.cpp +++ b/dep/acelite/ace/WFMO_Reactor.cpp @@ -1,3 +1,5 @@ +// $Id: WFMO_Reactor.cpp 97798 2014-07-03 10:57:43Z johnnyw $ + #include "ace/WFMO_Reactor.h" #if defined (ACE_WIN32) @@ -1384,11 +1386,7 @@ ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, long new_network_events = 0; bool delete_event = false; -#if defined (ACE_HAS_CPP11) - std::unique_ptr event; -#else auto_ptr event; -#endif /* ACE_HAS_CPP11 */ // Look up the repository to see if the is already // there. @@ -1405,15 +1403,10 @@ ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, // need to create one if (event_handle == ACE_INVALID_HANDLE) { -#if defined (ACE_HAS_CPP11) - std::unique_ptr tmp (new ACE_Auto_Event); - event = std::move(tmp); -#else // Note: don't change this since some C++ compilers have // s that don't work properly... auto_ptr tmp (new ACE_Auto_Event); event = tmp; -#endif /* ACE_HAS_CPP11 */ event_handle = event->handle (); delete_event = true; } diff --git a/dep/acelite/ace/WFMO_Reactor.h b/dep/acelite/ace/WFMO_Reactor.h index 664685eac..f56b27416 100644 --- a/dep/acelite/ace/WFMO_Reactor.h +++ b/dep/acelite/ace/WFMO_Reactor.h @@ -4,9 +4,11 @@ /** * @file WFMO_Reactor.h * + * $Id: WFMO_Reactor.h 97645 2014-03-07 12:01:21Z johnnyw $ + * * @author Irfan Pyarali * @author Tim Harrison - * @author Doug Schmidt + * @author Doug Schmidt */ //============================================================================= @@ -71,10 +73,11 @@ int WSAEnumNetworkEvents (SOCKET s, #endif /* !defined ACE_HAS_WINSOCK2 */ +class ACE_WFMO_Reactor_Test; // Must be out of versioned namespace. + ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Forward decl. -class ACE_WFMO_Reactor_Test; class ACE_WFMO_Reactor; class ACE_Handle_Set; @@ -112,7 +115,7 @@ public: * Event_Handler entry. The reason the event is not in this * structure is because we need to pass an event array into * WaitForMultipleObjects and therefore keeping the events - * separate makes sense. + * seperate makes sense. */ class Common_Info { @@ -545,10 +548,10 @@ public: /** * Set the maximum number of times that the - * ACE_WFMO_Reactor_Notify::handle_input() method will iterate and + * method will iterate and * dispatch the ACE_Event_Handlers that are passed in via the * notify queue before breaking out of its - * ACE_Message_Queue::dequeue() loop. By default, this is set to + * loop. By default, this is set to * -1, which means "iterate until the queue is empty." Setting this * to a value like "1 or 2" will increase "fairness" (and thus * prevent starvation) at the expense of slightly higher dispatching @@ -561,7 +564,7 @@ public: * ACE_WFMO_Reactor_Notify::handle_input() method will iterate and * dispatch the ACE_Event_Handlers that are passed in via the * notify queue before breaking out of its - * ACE_Message_Queue::dequeue() loop. + * loop. */ int max_notify_iterations (void); diff --git a/dep/acelite/ace/WFMO_Reactor.inl b/dep/acelite/ace/WFMO_Reactor.inl index 19c7da594..ef8c6dc10 100644 --- a/dep/acelite/ace/WFMO_Reactor.inl +++ b/dep/acelite/ace/WFMO_Reactor.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: WFMO_Reactor.inl 97894 2014-09-16 18:11:56Z johnnyw $ + #include "ace/Handle_Set.h" #include "ace/Reactor.h" #include "ace/Thread.h" diff --git a/dep/acelite/ace/WIN32_Asynch_IO.cpp b/dep/acelite/ace/WIN32_Asynch_IO.cpp index d914ccfc4..a27d47aed 100644 --- a/dep/acelite/ace/WIN32_Asynch_IO.cpp +++ b/dep/acelite/ace/WIN32_Asynch_IO.cpp @@ -1,3 +1,5 @@ +// $Id: WIN32_Asynch_IO.cpp 97957 2014-11-04 17:45:11Z johnnyw $ + #include "ace/WIN32_Asynch_IO.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) && \ diff --git a/dep/acelite/ace/WIN32_Asynch_IO.h b/dep/acelite/ace/WIN32_Asynch_IO.h index 41ceffac0..dee891c65 100644 --- a/dep/acelite/ace/WIN32_Asynch_IO.h +++ b/dep/acelite/ace/WIN32_Asynch_IO.h @@ -4,12 +4,16 @@ /** * @file WIN32_Asynch_IO.h * + * $Id: WIN32_Asynch_IO.h 97946 2014-10-31 14:07:41Z mcorino $ + * + * * These classes only works on Win32 platforms. * * The implementation of ACE_Asynch_Transmit_File, * ACE_Asynch_Accept, and ACE_Asynch_Connect are only supported if * ACE_HAS_WINSOCK2 is defined or you are on WinNT 4.0 or higher. * + * * @author Irfan Pyarali * @author Tim Harrison * @author Alexander Babu Arulanthu @@ -147,6 +151,7 @@ protected: * * @brief This class abstracts out the common things needed for * implementing Asynch_Operation for WIN32 platform. + * */ class ACE_Export ACE_WIN32_Asynch_Operation : public virtual ACE_Asynch_Operation_Impl { @@ -483,6 +488,7 @@ protected: * @brief This class is a factory for starting off asynchronous writes * on a stream. * + * * Once open() is called, multiple asynchronous s can * started using this class. A ACE_Asynch_Write_Stream::Result * will be passed back to the @a handler when the asynchronous @@ -1337,6 +1343,7 @@ private: /** * @class ACE_WIN32_Asynch_Transmit_File_Result * + * * @brief This class implements ACE_Asynch_Transmit_File::Result for * WIN32 platforms. * @@ -1666,6 +1673,7 @@ protected: * will be passed back to the @a handler when the asynchronous * reads completes through the * callback. + * */ class ACE_Export ACE_WIN32_Asynch_Read_Dgram : public virtual ACE_Asynch_Read_Dgram_Impl, public ACE_WIN32_Asynch_Operation @@ -1844,6 +1852,7 @@ protected: * @brief This class is a factory for starting off asynchronous writes * on a UDP socket. * + * * Once is called, multiple asynchronous s can * started using this class. A ACE_Asynch_Write_Stream::Result * will be passed back to the @a handler when the asynchronous diff --git a/dep/acelite/ace/WIN32_Proactor.cpp b/dep/acelite/ace/WIN32_Proactor.cpp index 25bf4f31b..c26c59a08 100644 --- a/dep/acelite/ace/WIN32_Proactor.cpp +++ b/dep/acelite/ace/WIN32_Proactor.cpp @@ -1,3 +1,5 @@ +// $Id: WIN32_Proactor.cpp 96985 2013-04-11 15:50:32Z huangh $ + // #include "ace/WIN32_Proactor.h" diff --git a/dep/acelite/ace/WIN32_Proactor.h b/dep/acelite/ace/WIN32_Proactor.h index e370ee08d..4fb686d7a 100644 --- a/dep/acelite/ace/WIN32_Proactor.h +++ b/dep/acelite/ace/WIN32_Proactor.h @@ -4,6 +4,8 @@ /** * @file WIN32_Proactor.h * + * $Id: WIN32_Proactor.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Irfan Pyarali (irfan@cs.wustl.edu) * @author Tim Harrison (harrison@cs.wustl.edu) * @author Alexander Babu Arulanthu @@ -44,7 +46,7 @@ class ACE_WIN32_Proactor_Timer_Handler; * @brief A manager for asynchronous event demultiplexing on Win32. * * See the Proactor pattern description at - * http://www.dre.vanderbilt.edu/~schmidt/PDF/proactor.pdf for more + * http://www.cs.wustl.edu/~schmidt/PDF/proactor.pdf for more * details. */ class ACE_Export ACE_WIN32_Proactor : public ACE_Proactor_Impl diff --git a/dep/acelite/ace/XML_Svc_Conf.cpp b/dep/acelite/ace/XML_Svc_Conf.cpp index a3b082473..23dddad84 100644 --- a/dep/acelite/ace/XML_Svc_Conf.cpp +++ b/dep/acelite/ace/XML_Svc_Conf.cpp @@ -1,3 +1,5 @@ +// $Id: XML_Svc_Conf.cpp 80826 2008-03-04 14:51:23Z wotte $ + #include "ace/XML_Svc_Conf.h" #if (ACE_USES_CLASSIC_SVC_CONF == 0) diff --git a/dep/acelite/ace/XML_Svc_Conf.h b/dep/acelite/ace/XML_Svc_Conf.h index a45fa662a..883151e05 100644 --- a/dep/acelite/ace/XML_Svc_Conf.h +++ b/dep/acelite/ace/XML_Svc_Conf.h @@ -4,6 +4,8 @@ /** * @file XML_Svc_Conf.h * + * $Id: XML_Svc_Conf.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Nanbor Wang */ //============================================================================= @@ -38,6 +40,8 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * This DLL should include an operation as follow: * * extern "C" ACE_XML_Svc_Conf_Parser * _ACEXML_create_XML_Svc_Conf_Object (void); + * + * */ class ACE_Export ACE_XML_Svc_Conf diff --git a/dep/acelite/ace/XTI_ATM_Mcast.cpp b/dep/acelite/ace/XTI_ATM_Mcast.cpp index 44da82975..e01c55eab 100644 --- a/dep/acelite/ace/XTI_ATM_Mcast.cpp +++ b/dep/acelite/ace/XTI_ATM_Mcast.cpp @@ -1,3 +1,5 @@ +// $Id: XTI_ATM_Mcast.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/XTI_ATM_Mcast.h" diff --git a/dep/acelite/ace/XTI_ATM_Mcast.h b/dep/acelite/ace/XTI_ATM_Mcast.h index 56ce53446..bfdfa92c9 100644 --- a/dep/acelite/ace/XTI_ATM_Mcast.h +++ b/dep/acelite/ace/XTI_ATM_Mcast.h @@ -4,6 +4,8 @@ /** * @file XTI_ATM_Mcast.h * + * $Id: XTI_ATM_Mcast.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Joe Hoffert */ //============================================================================= diff --git a/dep/acelite/ace/XTI_ATM_Mcast.inl b/dep/acelite/ace/XTI_ATM_Mcast.inl index c8dddef66..de408a6a1 100644 --- a/dep/acelite/ace/XTI_ATM_Mcast.inl +++ b/dep/acelite/ace/XTI_ATM_Mcast.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: XTI_ATM_Mcast.inl 96985 2013-04-11 15:50:32Z huangh $ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE diff --git a/dep/acelite/ace/ace_wchar.cpp b/dep/acelite/ace/ace_wchar.cpp index 515efd1a3..f969c7885 100644 --- a/dep/acelite/ace/ace_wchar.cpp +++ b/dep/acelite/ace/ace_wchar.cpp @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ace_wchar.cpp 91286 2010-08-05 09:04:31Z johnnyw $ + #include "ace/config-macros.h" #include "ace/ace_wchar.h" diff --git a/dep/acelite/ace/ace_wchar.h b/dep/acelite/ace/ace_wchar.h index 7afc67332..ff884231b 100644 --- a/dep/acelite/ace/ace_wchar.h +++ b/dep/acelite/ace/ace_wchar.h @@ -4,6 +4,8 @@ /** * @file ace_wchar.h * + * $Id: ace_wchar.h 93597 2011-03-21 12:54:52Z johnnyw $ + * * @author Darrell Brunsch */ //============================================================================= @@ -228,7 +230,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL #define ACE_TEXT_CreateFileMapping ::CreateFileMappingW #define ACE_TEXT_CreateMutex ::CreateMutexW #define ACE_TEXT_CreateProcess ::CreateProcessW -#define ACE_TEXT_CreateProcessAsUser ::CreateProcessAsUserW #define ACE_TEXT_CreateSemaphore ::CreateSemaphoreW #define ACE_TEXT_CreateService ::CreateServiceW #define ACE_TEXT_ExpandEnvironmentStrings ::ExpandEnvironmentStringsW @@ -274,7 +275,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL #define ACE_TEXT_PdhExpandCounterPath ::PdhExpandCounterPathW #define ACE_TEXT_PdhOpenQuery ::PdhOpenQueryW #define ACE_TEXT_PdhAddCounter ::PdhAddCounterW -#define ACE_TEXT_gai_strerror ::gai_strerrorW #else /* ACE_USES_WCHAR */ #define ACE_LPSTR LPSTR @@ -289,7 +289,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL #define ACE_TEXT_CreateFileMapping ::CreateFileMappingA #define ACE_TEXT_CreateMutex ::CreateMutexA #define ACE_TEXT_CreateProcess ::CreateProcessA -#define ACE_TEXT_CreateProcessAsUser ::CreateProcessAsUserA #define ACE_TEXT_CreateSemaphore ::CreateSemaphoreA #define ACE_TEXT_CreateService ::CreateServiceA #define ACE_TEXT_ExpandEnvironmentStrings ::ExpandEnvironmentStringsA @@ -335,7 +334,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL #define ACE_TEXT_PdhExpandCounterPath ::PdhExpandCounterPathA #define ACE_TEXT_PdhOpenQuery ::PdhOpenQueryA #define ACE_TEXT_PdhAddCounter ::PdhAddCounterA -#define ACE_TEXT_gai_strerror ::gai_strerrorA #endif /* ACE_USES_WCHAR */ #endif /* ACE_WIN32 */ diff --git a/dep/acelite/ace/ace_wchar.inl b/dep/acelite/ace/ace_wchar.inl index 438d6672d..744b44f5e 100644 --- a/dep/acelite/ace/ace_wchar.inl +++ b/dep/acelite/ace/ace_wchar.inl @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: ace_wchar.inl 80826 2008-03-04 14:51:23Z wotte $ + // These are always inlined // FUZZ: disable check_for_inline @@ -44,7 +47,7 @@ ACE_Wide_To_Ascii::convert (const wchar_t *wstr) while ((*wtemp) != 0) // Hopefully the string is null terminated! ++wtemp; - size_t const len = wtemp - wstr + 1; + int const len = wtemp - wstr + 1; # else /* ACE_WIN32 */ size_t const len = ::wcslen (wstr) + 1; # endif /* ACE_WIN32 */ diff --git a/dep/acelite/ace/checked_iterator.h b/dep/acelite/ace/checked_iterator.h index 473ca5c9d..08940e62b 100644 --- a/dep/acelite/ace/checked_iterator.h +++ b/dep/acelite/ace/checked_iterator.h @@ -23,6 +23,8 @@ * not supported, the pointer passed to the function is returned * instead. * + * $Id: checked_iterator.h 88263 2009-12-20 07:58:09Z johnnyw $ + * * @internal The functions and types in this header are meant for * internal use. They may change at any point between * releases. diff --git a/dep/acelite/ace/config-WinCE.h b/dep/acelite/ace/config-WinCE.h index e9414226f..121f46555 100644 --- a/dep/acelite/ace/config-WinCE.h +++ b/dep/acelite/ace/config-WinCE.h @@ -1,3 +1,5 @@ +// $Id: config-WinCE.h 93622 2011-03-22 15:45:57Z johnnyw $ + // Note: For WinCE build, simply use: #include "ace/config-win32.h" // It is same as config.h for Windows NT/2k so that you can // share same files and directories for both WinCE and NT/2k diff --git a/dep/acelite/ace/config-aix-5.x.h b/dep/acelite/ace/config-aix-5.x.h index 5969745ee..edff471a0 100644 --- a/dep/acelite/ace/config-aix-5.x.h +++ b/dep/acelite/ace/config-aix-5.x.h @@ -1,3 +1,4 @@ +// $Id: config-aix-5.x.h 93530 2011-03-11 12:12:40Z olli $ // // Config file for AIX 5.1 and higher. @@ -192,8 +193,6 @@ #define ACE_HAS_REENTRANT_FUNCTIONS -#define ACE_HAS_SIOCGIFCONF - // Compiler/platform defines the sig_atomic_t typedef #define ACE_HAS_SIG_ATOMIC_T #define ACE_HAS_SIGINFO_T @@ -321,16 +320,5 @@ #define ACE_LACKS_ISCTYPE #define ACE_HAS_STRSIGNAL #define ACE_NEEDS_STRSIGNAL_RANGE_CHECK -#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN - - -#if defined (ACE_AIX_VERS) && (ACE_AIX_VERS < 503) -# define ACE_LACKS_UNSETENV -# define ACE_LACKS_LOG2 -# define ACE_LACKS_PTHREAD_ATTR_SETSTACK -#endif /* ACE_AIX_VERS < 503 */ - -#define ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII "%ld" -#define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%lu" #endif /* ACE_CONFIG_AIX_5_X_H */ diff --git a/dep/acelite/ace/config-aix-7.h b/dep/acelite/ace/config-aix-7.h index 3864490ce..29ae08023 100644 --- a/dep/acelite/ace/config-aix-7.h +++ b/dep/acelite/ace/config-aix-7.h @@ -4,6 +4,8 @@ /** * @file config-aix-7.h * + * $Id: config-aix-7.h 93556 2011-03-16 12:12:04Z shuston $ + * * This is the config file for AIX 7 and higher. * * @author Steve Huston diff --git a/dep/acelite/ace/config-all.h b/dep/acelite/ace/config-all.h index 06d8eeb2b..5c0bf0934 100644 --- a/dep/acelite/ace/config-all.h +++ b/dep/acelite/ace/config-all.h @@ -4,7 +4,9 @@ /** * @file config-all.h * - * @author (Originally in OS.h)Doug Schmidt + * $Id: config-all.h 97262 2013-08-09 08:32:10Z johnnyw $ + * + * @author (Originally in OS.h)Doug Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... */ diff --git a/dep/acelite/ace/config-android.h b/dep/acelite/ace/config-android.h index 4cb908207..3608b826d 100644 --- a/dep/acelite/ace/config-android.h +++ b/dep/acelite/ace/config-android.h @@ -1,15 +1,13 @@ // -*- C++ -*- -// Config Header file for Android NDK +// $Id: config-android.h 97439 2013-11-27 08:11:17Z msmit $ + +// The following configuration file is designed to work for Android +// platforms using GNU C++. #ifndef ACE_CONFIG_ANDROID_H #define ACE_CONFIG_ANDROID_H #include /**/ "ace/pre.h" -// NOTE: We must be careful from now on to distinguish between the API level -// and NDK version. -// There is a large number of combinations of these two that can lead to -// problems. - // Location of the __ANDROID_API__ define // #include $NDK_ROOT/sysroot/usr/include/android/api-level.h #include "android/api-level.h" @@ -19,96 +17,6 @@ #endif #define ACE_ANDROID -#define ACE_PLATFORM_CONFIG config-android.h - -/* - * Android NDK Revision Macros - * - * Revsions Scheme Work Like This: - * Revision | __NDK_MAJOR__ | __NDK_MINOR__ - * r16 | 16 | 0 - * r16b | 16 | 1 - * r16c | 16 | 2 - * - * After r16, NDK version macros are defined in android/ndk-version.h Before - * that they must be defined in platform_macros.GNU before the include of - * platform_android.GNU. - */ -#define ACE_ANDROID_NDK_AT_LEAST(MAJ, MIN) \ - (__NDK_MAJOR__ > (MAJ) || (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ >= (MIN))) - -#define ACE_ANDROID_NDK_EXACTLY(MAJ, MIN) \ - (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ == (MIN)) - -#define ACE_ANDROID_NDK_LESS_THAN(MAJ, MIN) \ - (__NDK_MAJOR__ < (MAJ) || (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ < (MIN))) - -#ifdef ACE_ANDROID_NDK_HAS_NDK_VERSION_H -# include "android/ndk-version.h" -#else -# ifndef __NDK_MAJOR__ -# error ndk-version.h is missing, __NDK_MAJOR__ for Android NDK must be defined! -# endif -# ifndef __NDK_MINOR__ -# error ndk-version.h is missing, __NDK_MINOR__ for Android NDK must be defined! -# endif -#endif - -// ucontext.h and clock_settime() were added in r10c -#if ACE_ANDROID_NDK_AT_LEAST(10, 2) -# define ACE_HAS_UCONTEXT_T -# define ACE_HAS_CLOCK_SETTIME -#else -# define ACE_LACKS_UCONTEXT_H -#endif - -// NDK has these by r12b -#if ACE_ANDROID_NDK_LESS_THAN(12, 1) -# define ACE_LACKS_GETHOSTENT -# define ACE_LACKS_LOCALECONV -# define ACE_LACKS_WCHAR_STD_NAMESPACE -// Used in tests/Sequence_Unit_Tests/string_sequence_tester.hpp -# define TAO_LACKS_WCHAR_CXX_STDLIB -#endif - -#if ACE_ANDROID_NDK_LESS_THAN(12, 1) || __ANDROID_API__ < 18 -# define ACE_LACKS_LOG2 -#endif - -#if ACE_ANDROID_NDK_LESS_THAN(12, 1) || __ANDROID_API__ < 21 -# define ACE_LACKS_SEARCH_H -# define ACE_LACKS_SYS_SEM_H -# define ACE_LACKS_SEMBUF_T -# define ACE_LACKS_SYS_MSG_H -# define ACE_LACKS_SYS_SHM_H -# define ACE_LACKS_SYSV_SHMEM -#else -# define ACE_HAS_SEMUN -#endif - -// NDK has telldir() and seekdir() by 15c -#if ACE_ANDROID_NDK_LESS_THAN(15, 2) || __ANDROID_API__ < 23 -# define ACE_LACKS_TELLDIR -# define ACE_LACKS_SEEKDIR -#endif - -// fd_mask was added in r17c -#if ACE_ANDROID_NDK_LESS_THAN(17, 2) -# define ACE_LACKS_FD_MASK -#endif - -#if __ANDROID_API__ < 21 -# define ACE_LACKS_RAND_R -# define ACE_LACKS_WCSTOLL -# define ACE_LACKS_WCSTOULL -# define ACE_LACKS_CONDATTR_SETCLOCK -#endif - -// These were available before r18, but in r18 they are restricted to API >= 28 ¯\_(ツ)_/¯ -#if __ANDROID_API__ < 28 -# define ACE_LACKS_SETHOSTENT -# define ACE_LACKS_ENDHOSTENT -#endif #define ACE_HAS_SSIZE_T @@ -132,18 +40,35 @@ #define ACE_USES_ULONG_FOR_STAT_TIME #define ACE_LACKS_NEW_H +#define ACE_LACKS_SEARCH_H #define ACE_LACKS_SIGINFO_H #define ACE_LACKS_STROPTS_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYS_SHM_H #define ACE_LACKS_SYS_SYSCTL_H +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_CUSERID +#define ACE_LACKS_FD_MASK +#define ACE_LACKS_GETHOSTENT #define ACE_LACKS_GETLOADAVG #define ACE_LACKS_ISCTYPE +#define ACE_LACKS_LOG2 #define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS #define ACE_LACKS_PWD_FUNCTIONS +#define ACE_LACKS_PTHREAD_CANCEL +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_SETINHERITSCHED #define ACE_LACKS_STRRECVFD -#define ACE_LACKS_PTHREAD_CANCEL // posix_limits.h explicitly says this -#define ACE_LACKS_SETINHERITSCHED // posix_limits.h explicitly says this #define ACE_LACKS_SWAB +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_WCSTOLL +#define ACE_LACKS_WCSTOULL + +#define ACE_LACKS_RAND_R // Android seems to have 64 keys of which Android itself use 5 #define ACE_DEFAULT_THREAD_KEYS 59 @@ -157,9 +82,13 @@ # define ACE_MT_SAFE 1 #endif +#define ACE_PLATFORM_CONFIG config-android.h + // Needed to differentiate between libc 5 and libc 6 (aka glibc). #include +#define ACE_HAS_PTHREADS_UNIX98_EXT + #include "ace/config-posix.h" // @todo JW, test if this works @@ -191,15 +120,12 @@ #define ACE_HAS_P_READ_WRITE // Use ACE's alternate cuserid() implementation since the use of the // system cuserid() is discouraged. -#define ACE_LACKS_CUSERID #define ACE_HAS_ALT_CUSERID #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) # define ACE_HAS_ISASTREAM_PROTOTYPE # define ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE # define ACE_HAS_CPU_SET_T -#elif ACE_ANDROID_NDK_AT_LEAST(15, 0) || __ANDROID_API__ >= 21 -# define ACE_HAS_CPU_SET_T #endif /* __GLIBC__ > 2 || __GLIBC__ === 2 && __GLIBC_MINOR__ >= 3) */ // Then the compiler specific parts @@ -209,6 +135,13 @@ // this must appear before its #include. # define ACE_HAS_STRING_CLASS # include "ace/config-g++-common.h" + +# define ACE_HAS_CUSTOM_EXPORT_MACROS +# define ACE_Proper_Export_Flag +# define ACE_IMPORT_SINGLETON_DECLARATION(T) __extension__ extern template class T +# define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) __extension__ extern template class SINGLETON_TYPE; +# define ACE_HAS_EXPLICIT_TEMPLATE_CLASS_INSTANTIATION + #elif defined (__GNUC__) /** * GNU C compiler. @@ -397,7 +330,27 @@ #define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R #define ACE_HAS_REENTRANT_FUNCTIONS -#define ACE_HAS_TIMEZONE + +#if __ANDROID_API__ >= 9 +# define ACE_HAS_TIMEZONE +#endif + +#if __ANDROID_API__ < 14 +# define ACE_LACKS_STD_WSTRING +# define ACE_LACKS_GETIPNODEBYADDR +# define ACE_LACKS_GETIPNODEBYNAME +#endif + +#if __ANDROID_API__ == 3 +# error Unsupported Android release 3 +#elif __ANDROID_API__ == 8 +# define ACE_LACKS_REGEX_H 1 +# define ACE_LACKS_CONDATTR 1 +#elif __ANDROID_API__ == 9 +#elif __ANDROID_API__ == 14 +#else +# error Unsupported Android release +#endif #if !defined ACE_DEFAULT_TEMP_DIR # define ACE_DEFAULT_TEMP_DIR "/data/tmp" @@ -447,10 +400,6 @@ # undef _B #endif -// Disable newer features, result in runtime failures on Android -#define ACE_LACKS_GETADDRINFO -#define ACE_LACKS_GETNAMEINFO - #include /**/ "ace/post.h" #endif /* ACE_CONFIG_ANDROID_H */ diff --git a/dep/acelite/ace/config-cygwin32.h b/dep/acelite/ace/config-cygwin32.h index 892707740..4fc154371 100644 --- a/dep/acelite/ace/config-cygwin32.h +++ b/dep/acelite/ace/config-cygwin32.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-cygwin32.h 93530 2011-03-11 12:12:40Z olli $ + // The following configuration file is designed to work for CygWin // platforms using GNU C++. diff --git a/dep/acelite/ace/config-freebsd.h b/dep/acelite/ace/config-freebsd.h index d7a6c9f1d..92c156de8 100644 --- a/dep/acelite/ace/config-freebsd.h +++ b/dep/acelite/ace/config-freebsd.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-freebsd.h 95430 2012-01-11 20:45:28Z mcorino $ + // The following configuration file is designed to work for FreeBSD #ifndef ACE_CONFIG_H @@ -12,11 +14,6 @@ // Make sure we source in the OS version. #include -// Make sure system defined macro (not related to ACE_OS::atop) -// is not defined during ACE compilation -#include -#undef atop - #include "ace/config-posix.h" #include "ace/config-g++-common.h" @@ -104,6 +101,12 @@ # define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 #endif /* ACE_LACKS_PERFECT_MULTICAST_FILTERING */ +#if defined (__ia64) || defined (__x86_64__) +# define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%lu" +# define ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII "%ld" +# define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%lu" +#endif /* __ia64 */ + // // Version specific settings // @@ -185,15 +188,6 @@ enum schedparam_policy { # define ACE_HAS_VOID_UNSETENV #endif -#if defined (__ia64) || defined(__alpha) || defined (__x86_64__) || defined(__powerpc64__) || (defined(__mips__) && defined(__LP64__)) || defined (__aarch64__) -// On 64 bit platforms, the "long" type is 64-bits. Override the -// default 32-bit platform-specific format specifiers appropriately. -//# define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%lu" -//# define ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII "%ld" -# define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%lu" -#endif /* __ia64 */ - - #include /**/ "ace/post.h" #endif /* ACE_CONFIG_H */ diff --git a/dep/acelite/ace/config-g++-common.h b/dep/acelite/ace/config-g++-common.h index 95f5e4c63..c8a0f9405 100644 --- a/dep/acelite/ace/config-g++-common.h +++ b/dep/acelite/ace/config-g++-common.h @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: config-g++-common.h 97874 2014-09-08 12:10:55Z johnnyw $ + // This configuration file is designed to be included by another, // specific configuration file. It provides config information common // to all g++ platforms, including egcs. @@ -31,16 +34,13 @@ # define ACE_HAS_NEW_NOTHROW #endif /* __GNUC__ >= 3.3 */ -#if (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || defined __clang__ +#if (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) # if __cplusplus > 199711L # define ACE_HAS_CPP11 # endif # if __cplusplus > 201103L # define ACE_HAS_CPP14 # endif -# if __cplusplus > 201402L -# define ACE_HAS_CPP17 -# endif #endif #if (defined (i386) || defined (__i386__)) && !defined (ACE_SIZEOF_LONG_DOUBLE) @@ -135,9 +135,8 @@ # endif # if defined (ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS) && ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS == 1 -# define ACE_EXPORT_SINGLETON_DECLARATION(T) __extension__ extern template class ACE_Proper_Export_Flag T -# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) __extension__ extern template class ACE_Proper_Export_Flag SINGLETON_TYPE ; -# define ACE_HAS_EXPLICIT_TEMPLATE_CLASS_INSTANTIATION +# define ACE_EXPORT_SINGLETON_DECLARATION(T) template class ACE_Proper_Export_Flag T +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class ACE_Proper_Export_Flag SINGLETON_TYPE ; # else /* ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS */ # define ACE_EXPORT_SINGLETON_DECLARATION(T) \ _Pragma ("GCC visibility push(default)") \ diff --git a/dep/acelite/ace/config-hpux-11.00.h b/dep/acelite/ace/config-hpux-11.00.h index 995bfd987..bb69bac1a 100644 --- a/dep/acelite/ace/config-hpux-11.00.h +++ b/dep/acelite/ace/config-hpux-11.00.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-hpux-11.00.h 97326 2013-09-11 07:52:09Z johnnyw $ + // The following configuration file is designed to work for HP // platforms running HP-UX 11.00 using aC++ or gcc (2.95 and up). @@ -104,6 +106,7 @@ #endif /* ACE_HAS_AIO_CALLS */ //////////////////////////////////////////////////////////////////////////// +// // General OS information - see README for more details on what they mean // /////////////////////////////////////////////////////////////////////////// @@ -346,6 +349,7 @@ #define ACE_LACKS_STRUCT_LIFNUM ////////////////////////////////////////////////////////////////////////// +// // STREAMS information // ////////////////////////////////////////////////////////////////////////// @@ -366,6 +370,7 @@ // #define ACE_HAS_STREAM_PIPES ///////////////////////////////////////////////////////////////////////// +// // TLI/XTI information // //////////////////////////////////////////////////////////////////////// @@ -382,6 +387,7 @@ #define ACE_HAS_SYS_XTI_H 1 ///////////////////////////////////////////////////////////////////////// +// // Threads information. // // Use of threads is controlled by the 'threads' argument to make. See diff --git a/dep/acelite/ace/config-icc-common.h b/dep/acelite/ace/config-icc-common.h index 4bf081721..2b860d3ea 100644 --- a/dep/acelite/ace/config-icc-common.h +++ b/dep/acelite/ace/config-icc-common.h @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: config-icc-common.h 97642 2014-03-05 14:43:41Z johnnyw $ + #ifndef ACE_LINUX_ICC_COMMON_H #define ACE_LINUX_ICC_COMMON_H #include /**/ "ace/pre.h" diff --git a/dep/acelite/ace/config-integritySCA.h b/dep/acelite/ace/config-integritySCA.h index 98679878c..19362257a 100644 --- a/dep/acelite/ace/config-integritySCA.h +++ b/dep/acelite/ace/config-integritySCA.h @@ -7,6 +7,8 @@ * This config.h file is for version 4.0.x of the * Integrity RTOS with SCA from Green Hills Software * http://www.ghs.com/products/rtos/integrity.html + * + * $Id: config-integritySCA.h 92181 2010-10-08 07:52:54Z olli $ */ #define ghs diff --git a/dep/acelite/ace/config-kfreebsd.h b/dep/acelite/ace/config-kfreebsd.h index 164b06a06..427d9bc45 100644 --- a/dep/acelite/ace/config-kfreebsd.h +++ b/dep/acelite/ace/config-kfreebsd.h @@ -1,13 +1,10 @@ +// $Id: config-kfreebsd.h 97326 2013-09-11 07:52:09Z johnnyw $ + #ifndef ACE_CONFIG_KFREEBSD_H -#define ACE_CONFIG_KFREEBSD_H - -// Make sure system defined macro (not related to ACE_OS::atop) -// is not defined during ACE compilation -#include -#undef atop - +#define ACE_CONFIG_KFREEBSDH #include "ace/config-g++-common.h" + /* Uses ctime_r & asctime_r with only two parameters vs. three. */ #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R 1 @@ -239,6 +236,9 @@ /* Compiler requires extern "C" functions for signals. */ #define ACE_HAS_SIG_C_FUNC 1 +/* Define to 1 if platform has snprintf(). */ +#define ACE_HAS_SNPRINTF 1 + /* Define to 1 if `sin6_len' is a member of `sockaddr_in6'. */ #define ACE_HAS_SOCKADDR_IN6_SIN6_LEN 1 @@ -545,7 +545,7 @@ #define LT_OBJDIR ".libs/" /* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "ace-bugs@list.isis.vanderbilt.edu" +#define PACKAGE_BUGREPORT "ace-bugs@cs.wustl.edu" /* Define to the full name of this package. */ #define PACKAGE_NAME "ACE" @@ -612,6 +612,7 @@ /* Enable ACE inlining */ #define __ACE_INLINE__ 1 -#endif /* ACE_CONFIG_KFREEBSD_H */ + +#endif /* ACE_CONFIG_KFREEBSDH */ diff --git a/dep/acelite/ace/config-linux.h b/dep/acelite/ace/config-linux.h index e248aea30..05f34fac1 100644 --- a/dep/acelite/ace/config-linux.h +++ b/dep/acelite/ace/config-linux.h @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: config-linux.h 97326 2013-09-11 07:52:09Z johnnyw $ + // The following configuration file is designed to work for Linux // platforms using GNU C++. @@ -115,7 +118,6 @@ # define ACE_LACKS_SIGINFO_H # define ACE_HAS_UCONTEXT_T # define ACE_HAS_SIGTIMEDWAIT -# define ACE_HAS_STRERROR_R #else /* ! __GLIBC__ */ // Fixes a problem with some non-glibc versions of Linux... @@ -146,6 +148,9 @@ // this must appear before its #include. # define ACE_HAS_STRING_CLASS # include "ace/config-g++-common.h" +# ifdef __clang__ +# undef ACE_HAS_GCC_ATOMIC_BUILTINS +# endif #elif defined (__SUNCC_PRO) || defined (__SUNPRO_CC) # include "ace/config-suncc-common.h" #elif defined (__PGI) @@ -304,7 +309,7 @@ # define ACE_HAS_STRBUF_T #endif -#if defined (__ia64) || defined(__alpha) || defined (__x86_64__) || defined(__powerpc64__) || (defined(__mips__) && defined(__LP64__)) || defined (__aarch64__) +#if defined (__ia64) || defined(__alpha) || defined (__x86_64__) || defined(__powerpc64__) // On 64 bit platforms, the "long" type is 64-bits. Override the // default 32-bit platform-specific format specifiers appropriately. # define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%lu" @@ -394,12 +399,12 @@ #define ACE_HAS_SVR4_DYNAMIC_LINKING #define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE #define ACE_HAS_RECURSIVE_MUTEXES #define ACE_HAS_THREAD_SPECIFIC_STORAGE #define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R #define ACE_HAS_REENTRANT_FUNCTIONS -#define ACE_HAS_MNTENT // To support UCLIBC #if defined (__UCLIBC__) diff --git a/dep/acelite/ace/config-lite.h b/dep/acelite/ace/config-lite.h index 55d11f9a4..889eca80a 100644 --- a/dep/acelite/ace/config-lite.h +++ b/dep/acelite/ace/config-lite.h @@ -4,7 +4,9 @@ /** * @file config-lite.h * - * @author (Originally in OS.h)Doug Schmidt + * $Id: config-lite.h 97976 2014-11-13 11:36:14Z shuston $ + * + * @author (Originally in OS.h)Doug Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -114,7 +116,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL // Once all C++ compilers support the standard reverse_iterator // adapters, we can drop this generator macro or at least drop the // MSVC++ or Sun Studio preprocessor conditional blocks. -#if defined (__SUNPRO_CC) && __SUNPRO_CC <= 0x5140 \ +#if defined (__SUNPRO_CC) && __SUNPRO_CC <= 0x5130 \ && !defined (_STLPORT_VERSION) // If we're not using the stlport4 C++ library (which has standard // iterators), we need to ensure this is included in order to test @@ -129,7 +131,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL typedef std::reverse_iterator reverse_iterator; \ typedef std::reverse_iterator const_reverse_iterator; -#elif defined (__SUNPRO_CC) && __SUNPRO_CC <= 0x5140 \ +#elif defined (__SUNPRO_CC) && __SUNPRO_CC <= 0x5130 \ && defined (_RWSTD_NO_CLASS_PARTIAL_SPEC) # define ACE_DECLARE_STL_REVERSE_ITERATORS \ typedef std::reverse_iterator - #define ACE_HAS_MAC_OSX #define ACE_HAS_NET_IF_DL_H @@ -25,12 +25,18 @@ # endif // GCC 3.3 #endif // ACE_SIZEOF_LONG_DOUBLE +#define ACE_UINT64_TYPE unsigned long long + #if defined (__GNUG__) # include "ace/config-g++-common.h" #endif /* __GNUG__ */ #define ACE_ISCTYPE_EQUIVALENT __isctype +#ifndef ACE_HAS_NONCONST_FD_ISSET +#define ACE_HAS_NONCONST_FD_ISSET +#endif + #define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR #define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%lu" @@ -49,7 +55,6 @@ #define ACE_HAS_GPERF #define ACE_HAS_POSIX_SEM -#define ACE_HAS_SIOCGIFCONF #define ACE_HAS_SUNOS4_GETTIMEOFDAY @@ -204,11 +209,10 @@ #endif #define ACE_LACKS_CONDATTR_SETCLOCK -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101200 #define ACE_LACKS_CLOCKID_T #define ACE_LACKS_CLOCK_MONOTONIC #define ACE_LACKS_CLOCK_REALTIME -#endif + // dlcompat package (not part of base Darwin) is needed for dlopen(). // You may download directly from sourceforge and install or use fink // Fink installer puts libraries in /sw/lib and headers in /sw/include @@ -226,8 +230,6 @@ // gperf seems to need this //#define ACE_HAS_NONSTATIC_OBJECT_MANAGER -#define ACE_IOCTL_TYPE_ARG2 unsigned long - #if defined(__APPLE_CC__) && (__APPLE_CC__ < 1173) #error "Compiler must be upgraded, see http://developer.apple.com" #endif /* __APPLE_CC__ */ diff --git a/dep/acelite/ace/config-macosx-lion.h b/dep/acelite/ace/config-macosx-lion.h index 055e08377..894cae45c 100644 --- a/dep/acelite/ace/config-macosx-lion.h +++ b/dep/acelite/ace/config-macosx-lion.h @@ -1,9 +1,14 @@ +// $Id: config-macosx-lion.h 97667 2014-03-17 12:38:46Z johnnyw $ #ifndef ACE_CONFIG_MACOSX_LION_H #define ACE_CONFIG_MACOSX_LION_H #include "ace/config-macosx-leopard.h" #ifdef __clang__ +# ifdef ACE_HAS_GCC_ATOMIC_BUILTINS +# undef ACE_HAS_GCC_ATOMIC_BUILTINS +# endif + # define ACE_ANY_OPS_USE_NAMESPACE #endif /* __clang__ */ diff --git a/dep/acelite/ace/config-macosx-mavericks.h b/dep/acelite/ace/config-macosx-mavericks.h index 630a9722c..06b1ff16c 100644 --- a/dep/acelite/ace/config-macosx-mavericks.h +++ b/dep/acelite/ace/config-macosx-mavericks.h @@ -1,3 +1,4 @@ +// $Id: config-macosx-mavericks.h 97579 2014-02-11 09:40:17Z johnnyw $ #ifndef ACE_CONFIG_MACOSX_MAVERICKS_H #define ACE_CONFIG_MACOSX_MAVERICKS_H diff --git a/dep/acelite/ace/config-macosx-mountainlion.h b/dep/acelite/ace/config-macosx-mountainlion.h index 3445f3f1b..c27bf0c05 100644 --- a/dep/acelite/ace/config-macosx-mountainlion.h +++ b/dep/acelite/ace/config-macosx-mountainlion.h @@ -1,3 +1,4 @@ +// $Id: config-macosx-mountainlion.h 97579 2014-02-11 09:40:17Z johnnyw $ #ifndef ACE_CONFIG_MACOSX_MOUNTAINLION_H #define ACE_CONFIG_MACOSX_MOUNTAINLION_H diff --git a/dep/acelite/ace/config-macosx-panther.h b/dep/acelite/ace/config-macosx-panther.h index 63237459a..4b131f986 100644 --- a/dep/acelite/ace/config-macosx-panther.h +++ b/dep/acelite/ace/config-macosx-panther.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-macosx-panther.h 87167 2009-10-19 19:33:53Z olli $ + // This configuration file is designed to work with the MacOS X operating system. #ifndef ACE_CONFIG_MACOSX_H diff --git a/dep/acelite/ace/config-macosx-snowleopard.h b/dep/acelite/ace/config-macosx-snowleopard.h index 553056a9a..49d83a67d 100644 --- a/dep/acelite/ace/config-macosx-snowleopard.h +++ b/dep/acelite/ace/config-macosx-snowleopard.h @@ -1,10 +1,16 @@ +// $Id: config-macosx-snowleopard.h 96711 2013-01-28 07:59:03Z johnnyw $ #ifndef ACE_CONFIG_MACOSX_SNOWLEOPARD_H #define ACE_CONFIG_MACOSX_SNOWLEOPARD_H #include "ace/config-macosx-leopard.h" #ifdef __clang__ +#ifdef ACE_HAS_GCC_ATOMIC_BUILTINS +#undef ACE_HAS_GCC_ATOMIC_BUILTINS +#endif + #define ACE_ANY_OPS_USE_NAMESPACE + #endif #define ACE_LACKS_UCONTEXT_H diff --git a/dep/acelite/ace/config-macosx-tiger.h b/dep/acelite/ace/config-macosx-tiger.h index 1e39c8283..944c1651f 100644 --- a/dep/acelite/ace/config-macosx-tiger.h +++ b/dep/acelite/ace/config-macosx-tiger.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-macosx-tiger.h 91693 2010-09-09 12:57:54Z johnnyw $ + // This configuration file is designed to work with the MacOS X operating system. #ifndef ACE_CONFIG_MACOSX_TIGER_H diff --git a/dep/acelite/ace/config-macosx-yosemite.h b/dep/acelite/ace/config-macosx-yosemite.h index bb2a48530..1a0c11d80 100644 --- a/dep/acelite/ace/config-macosx-yosemite.h +++ b/dep/acelite/ace/config-macosx-yosemite.h @@ -1,6 +1,11 @@ +// $Id: config-macosx-yosemite.h 97777 2014-06-06 06:43:29Z johnnyw $ #ifndef ACE_CONFIG_MACOSX_YOSEMITE_H #define ACE_CONFIG_MACOSX_YOSEMITE_H #include "ace/config-macosx-mavericks.h" +#undef ACE_LACKS_CLOCKID_T +#undef ACE_LACKS_CLOCK_MONOTONIC +#undef ACE_LACKS_CLOCK_REALTIME + #endif // ACE_CONFIG_MACOSX_YOSEMITE_H diff --git a/dep/acelite/ace/config-macosx.h b/dep/acelite/ace/config-macosx.h index 13a853a93..8eb499117 100644 --- a/dep/acelite/ace/config-macosx.h +++ b/dep/acelite/ace/config-macosx.h @@ -1,33 +1,180 @@ -#ifndef ACE_CONFIG_MACOSX_ALL_H -#define ACE_CONFIG_MACOSX_ALL_H -#include +/* -*- C++ -*- */ +// $Id: config-macosx.h 97326 2013-09-11 07:52:09Z johnnyw $ -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 -#include "config-macosx-mojave.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 -#include "config-macosx-highsierra.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 -#include "config-macosx-sierra.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 -#include "config-macosx-elcapitan.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 -#include "config-macosx-yosemite.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100900 -#include "config-macosx-mavericks.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100800 -#include "config-macosx-mountainlion.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100700 -#include "config-macosx-lion.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100600 -#include "config-macosx-snowleopard.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100500 -#include "config-macosx-leopard.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100400 -#include "config-macosx-tiger.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100300 -#include "config-macosx-panther.h" -#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 100200 -#include "config-macosx-jaguar.h" +// This configuration file is designed to work with the MacOS X operating system, version 10.2 (Jaguar). + +#ifndef ACE_CONFIG_MACOSX_H +#define ACE_CONFIG_MACOSX_H + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +#define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%lu" + +#if defined (ACE_HAS_PENTIUM) +# undef ACE_HAS_PENTIUM +#endif /* ACE_HAS_PENTIUM */ + +#if !defined (_THREAD_SAFE) +#define _THREAD_SAFE +#endif /* _THREAD_SAFE */ + +#define ACE_HAS_GPERF +#define ACE_HAS_POSIX_SEM + +//#define ACE_HAS_SVR4_TLI + +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_WCHAR_H + +#define ACE_SYS_SELECT_NEEDS_UNISTD_H + +// +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform supports SVR4 signal typedef +#define ACE_HAS_SVR4_SIGNAL_T + +//Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +//Platform supports sigsuspend() +#define ACE_HAS_SIGSUSPEND + +//#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#define ACE_LACKS_GETPGID +#define ACE_LACKS_RWLOCK_T + +#define ACE_HAS_SIOCGIFCONF + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +#define ACE_HAS_SYSCTL + +#define ACE_NEEDS_SCHED_H + +#define ACE_LACKS_MALLOC_H + +#define ACE_HAS_ALT_CUSERID + +// Platform supports POSIX timers via struct timespec. +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_UALARM + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +#define ACE_LACKS_STRRECVFD + +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Explicit dynamic linking permits "lazy" symbol resolution +//#define ACE_HAS_RTLD_LAZY_V + +// platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// platform supports IP multicast +#define ACE_HAS_IP_MULTICAST +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Defines the page size of the system. +#define ACE_HAS_GETPAGESIZE + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Platform/compiler supports timezone * as second parameter to gettimeofday(). +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_MSQ_PROTOS +#define ACE_HAS_MSG +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_MSGSND + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 #endif -#endif // ACE_CONFIG_MACOSX_ALL_H +#if ACE_MT_SAFE == 1 +// Yes, we do have threads. +# define ACE_HAS_THREADS +// And they're even POSIX pthreads +# define ACE_HAS_PTHREADS +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_LACKS_THREAD_PROCESS_SCOPING +#endif /* ACE_MT_SAFE == 1 */ + +#define ACE_HAS_DIRENT +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SEARCH_H + +#define ACE_LACKS_SETSCHED +//#define ACE_HAS_RECURSIVE_MUTEXES + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#define ACE_HAS_SEMUN +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_GETIFADDRS +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_UNNAMED_SEMAPHORE + +// dlcompat package (not part of base Darwin) is needed for dlopen(). +// You may download directly from sourceforge and install or use fink +// Fink installer puts libraries in /sw/lib and headers in /sw/include +// In order to install dlcompat do the following: +// - download fink from http://fink.sf.net +// - type: +// fink install dlcompat +// as of Dec 2002, if you use fink you will need to uncomment the next line +//#define ACE_NEEDS_DL_UNDERSCORE +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_LD_SEARCH_PATH ACE_TEXT ("DYLD_LIBRARY_PATH") +#define ACE_DLL_SUFFIX ACE_TEXT (".dylib") +#define ACE_LACKS_DLCLOSE + +// gperf seems to need this +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER + +#if defined(__APPLE_CC__) && (__APPLE_CC__ < 1173) +#error "Compiler must be upgraded, see http://developer.apple.com" +#endif /* __APPLE_CC__ */ + +#endif /* ACE_CONFIG_MACOSX_H */ diff --git a/dep/acelite/ace/config-macros.h b/dep/acelite/ace/config-macros.h index cbeae4690..a4542047e 100644 --- a/dep/acelite/ace/config-macros.h +++ b/dep/acelite/ace/config-macros.h @@ -4,7 +4,9 @@ /** * @file config-macros.h * - * @author (Originally in OS.h)Doug Schmidt + * $Id: config-macros.h 97400 2013-10-31 10:44:50Z mhengstmengel $ + * + * @author (Originally in OS.h)Doug Schmidt * @author Jesper S. M|ller * @author and a cast of thousands... * @@ -19,16 +21,41 @@ #ifndef ACE_CONFIG_MACROS_H #define ACE_CONFIG_MACROS_H -#include "ace/config.h" -#include "ace/config-face-safety.h" +#define ACE_HAS_IPV6 1 +#define ACE_USES_IPV4_IPV6_MIGRATION 1 + +#if defined(_WIN32) +# include "ace/config-win32.h" +#elif defined(__linux) || defined(__linux__) +# include "ace/config-linux.h" +#elif defined(__FreeBSD__) +# include "ace/config-freebsd.h" +#elif defined(__APPLE__) +# include +# if defined(MAC_OS_X_VERSION_10_10) +# include "ace/config-macosx-yosemite.h" +# elif defined(MAC_OS_X_VERSION_10_9) +# include "ace/config-macosx-mavericks.h" +# elif defined(MAC_OS_X_VERSION_10_8) +# include "ace/config-macosx-mountainlion.h" +# elif defined(MAC_OS_X_VERSION_10_7) +# include "ace/config-macosx-lion.h" +# elif defined(MAC_OS_X_VERSION_10_6) +# include "ace/config-macosx-snowleopard.h" +# elif defined(MAC_OS_X_VERSION_10_5) +# include "ace/config-macosx-leopard.h" +# elif defined(MAC_OS_X_VERSION_10_4) +# include "ace/config-macosx-tiger.h" +# elif defined(MAC_OS_X_VERSION_10_3) +# include "ace/config-macosx-panther.h" +# else +# include "ace/config-macosx.h" +#endif +#endif #include "ace/Version.h" #include "ace/Versioned_Namespace.h" -#if defined (ACE_HAS_ALLOC_HOOKS) -# include -#endif - #if !defined (ACE_HAS_EXCEPTIONS) #define ACE_HAS_EXCEPTIONS #endif /* !ACE_HAS_EXCEPTIONS */ @@ -114,21 +141,12 @@ # endif # endif /* ACE_HAS_DYNAMIC_LINKING */ -# if defined (ACE_HAS_DYNAMIC_LINKING) && ACE_HAS_DYNAMIC_LINKING == 0 && \ - defined (ACE_HAS_SVR4_DYNAMIC_LINKING) -# undef ACE_HAS_SVR4_DYNAMIC_LINKING -# endif /* ACE_HAS_DYNAMIC_LINKING == 0 */ - # if defined (ACE_USES_FIFO_SEM) # if defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_MKFIFO) || defined (ACE_LACKS_FCNTL) # undef ACE_USES_FIFO_SEM # endif # endif /* ACE_USES_FIFO_SEM */ -# ifndef ACE_LACKS_POSIX_DEVCTL -# define ACE_LACKS_POSIX_DEVCTL -# endif - // ========================================================================= // INLINE macros // @@ -271,7 +289,7 @@ # endif /* ghs || __GNUC__ || ..... */ #endif /* !ACE_UNUSED_ARG */ -#if defined (_MSC_VER) || defined (ghs) || defined (__DECCXX) || defined(__BORLANDC__) || defined (ACE_RM544) || defined (__USLC__) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) || (defined (__HP_aCC) && (__HP_aCC < 39000 || __HP_aCC >= 60500)) +#if defined (_MSC_VER) || defined (ghs) || defined (__DECCXX) || defined(__BORLANDC__) || defined (ACE_RM544) || defined (__USLC__) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) || (defined (__HP_aCC) && (__HP_aCC < 40000 || __HP_aCC >= 60500)) # define ACE_NOTREACHED(a) #else /* ghs || ..... */ # define ACE_NOTREACHED(a) a @@ -284,175 +302,18 @@ // ============================================================================ # if defined (ACE_HAS_ALLOC_HOOKS) -# define ACE_ALLOC_HOOK_DECLARE \ +# define ACE_ALLOC_HOOK_DECLARE \ void *operator new (size_t bytes); \ - void *operator new (size_t bytes, void *ptr); \ - void *operator new (size_t bytes, const std::nothrow_t &) throw (); \ - void operator delete (void *ptr); \ - void operator delete (void *ptr, const std::nothrow_t &); \ - void *operator new[] (size_t size); \ - void operator delete[] (void *ptr); \ - void *operator new[] (size_t size, const std::nothrow_t &) throw (); \ - void operator delete[] (void *ptr, const std::nothrow_t &) - -# define ACE_GENERIC_ALLOCS(MAKE_PREFIX, CLASS) \ - MAKE_PREFIX (void *, CLASS)::operator new (size_t bytes) \ - { \ - void *const ptr = ACE_Allocator::instance ()->malloc (bytes); \ - if (ptr == 0) \ - throw std::bad_alloc (); \ - return ptr; \ - } \ - MAKE_PREFIX (void *, CLASS)::operator new (size_t, void *ptr) { return ptr; }\ - MAKE_PREFIX (void *, CLASS)::operator new (size_t bytes, \ - const std::nothrow_t &) throw () \ - { return ACE_Allocator::instance ()->malloc (bytes); } \ - MAKE_PREFIX (void, CLASS)::operator delete (void *ptr) \ - { if (ptr) ACE_Allocator::instance ()->free (ptr); } \ - MAKE_PREFIX (void, CLASS)::operator delete (void *ptr, \ - const std::nothrow_t &) \ - { if (ptr) ACE_Allocator::instance ()->free (ptr); } \ - MAKE_PREFIX (void *, CLASS)::operator new[] (size_t size) \ - { \ - void *const ptr = ACE_Allocator::instance ()->malloc (size); \ - if (ptr == 0) \ - throw std::bad_alloc (); \ - return ptr; \ - } \ - MAKE_PREFIX (void, CLASS)::operator delete[] (void *ptr) \ - { if (ptr) ACE_Allocator::instance ()->free (ptr); } \ - MAKE_PREFIX (void *, CLASS)::operator new[] (size_t size, \ - const std::nothrow_t &) throw ()\ - { return ACE_Allocator::instance ()->malloc (size); } \ - MAKE_PREFIX (void, CLASS)::operator delete[] (void *ptr, \ - const std::nothrow_t &) \ - { if (ptr) ACE_Allocator::instance ()->free (ptr); } - -# define ACE_ALLOC_HOOK_HELPER(RET, CLASS) RET CLASS -# define ACE_ALLOC_HOOK_DEFINE(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tt(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tt(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tt, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tc(RET, CLASS) template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Ty(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Ty(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Ty, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tyc(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tyc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tyc, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tycc(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tycc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tycc, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tcy(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tcy(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcy, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tcyc(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tcyc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcyc, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tca(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tca(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tca, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tco(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tco(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tco, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tcoccc(RET, CLASS) \ - template RET \ - CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tcoccc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcoccc, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tcc(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tcc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcc, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tccc(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tccc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tccc, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tccct(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tccct(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tccct, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tc4(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tc4(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc4, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tc5(RET, CLASS) \ - template RET \ - CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tc5(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc5, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tc6(RET, CLASS) \ - template RET \ - CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tc6(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc6, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tc7(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tc7(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc7, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tcs(RET, CLASS) \ - template RET CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tcs(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcs, CLASS) - -# define ACE_ALLOC_HOOK_HELPER_Tmcc(RET, CLASS) \ - template RET \ - CLASS -# define ACE_ALLOC_HOOK_DEFINE_Tmcc(CLASS) \ - ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tmcc, CLASS) + void operator delete (void *ptr); + // Note that these are just place holders for now. Some day they + // may be be replaced by . +# define ACE_ALLOC_HOOK_DEFINE(CLASS) \ + void *CLASS::operator new (size_t bytes) { return ::new char[bytes]; } \ + void CLASS::operator delete (void *ptr) { delete [] ((char *) ptr); } # else -# define ACE_ALLOC_HOOK_DECLARE struct Ace_ {} /* Just need a dummy... */ -# define ACE_ALLOC_HOOK_DEFINE(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tt(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tc(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tcc(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tccc(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tccct(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tc4(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tc5(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tc6(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tc7(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Ty(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tyc(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tycc(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tcy(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tcyc(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tca(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tco(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tcoccc(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tcs(CLASS) -# define ACE_ALLOC_HOOK_DEFINE_Tmcc(CLASS) +# define ACE_ALLOC_HOOK_DECLARE struct __Ace {} /* Just need a dummy... */ +# define ACE_ALLOC_HOOK_DEFINE(CLASS) # endif /* ACE_HAS_ALLOC_HOOKS */ // ============================================================================ @@ -693,11 +554,4 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ # define ACE_HAS_REACTOR_NOTIFICATION_QUEUE #endif -// If config.h declared a lack of process-shared mutexes but was silent about -// process-shared condition variables, ACE must not attempt to use a -// process-shared condition variable (which always requires a mutex too). -#if defined ACE_LACKS_MUTEXATTR_PSHARED && !defined ACE_LACKS_CONDATTR_PSHARED -# define ACE_LACKS_CONDATTR_PSHARED -#endif - #endif /* ACE_CONFIG_MACROS_H */ diff --git a/dep/acelite/ace/config-netbsd.h b/dep/acelite/ace/config-netbsd.h index 406df338c..5d10c725f 100644 --- a/dep/acelite/ace/config-netbsd.h +++ b/dep/acelite/ace/config-netbsd.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-netbsd.h 97326 2013-09-11 07:52:09Z johnnyw $ + #ifndef ACE_CONFIG_H #define ACE_CONFIG_H diff --git a/dep/acelite/ace/config-openbsd.h b/dep/acelite/ace/config-openbsd.h index e928905ad..a4039d556 100644 --- a/dep/acelite/ace/config-openbsd.h +++ b/dep/acelite/ace/config-openbsd.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-openbsd.h 93613 2011-03-22 09:27:38Z olli $ + // The following configuration file is designed to work for OpenBSD #ifndef ACE_CONFIG_H @@ -41,16 +43,21 @@ #define ACE_HAS_MSG #define ACE_HAS_NANOSLEEP #define ACE_HAS_NEW_NO_H +#define ACE_HAS_NONCONST_MSGSND #define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONCONST_SWAB #define ACE_HAS_POLL #define ACE_HAS_POSIX_NONBLOCK #define ACE_HAS_POSIX_TIME #define ACE_HAS_PTHREADS_UNIX98_EXT +#define ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP #define ACE_HAS_PTHREAD_GETCONCURRENCY #define ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP #define ACE_HAS_PTHREAD_NP_H +#define ACE_HAS_PTHREAD_RESUME_NP #define ACE_HAS_PTHREAD_SETCONCURRENCY #define ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE +#define ACE_HAS_PTHREAD_SUSPEND_NP #define ACE_HAS_P_READ_WRITE #define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS #define ACE_HAS_REENTRANT_FUNCTIONS @@ -90,19 +97,22 @@ #define ACE_HAS_XPG4_MULTIBYTE_CHAR #define ACE_HAS_SYS_SIGINFO_H -#define ACE_LACKS_CONDATTR_PSHARED #define ACE_LACKS_GETIPNODEBYADDR #define ACE_LACKS_GETIPNODEBYNAME #define ACE_LACKS_ISCTYPE -#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_ISWASCII #define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING #define ACE_LACKS_SETSCHED #define ACE_LACKS_STROPTS_H #define ACE_LACKS_STRRECVFD #define ACE_LACKS_TIMESPEC_T #define ACE_LACKS_UCONTEXT_H +#define ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS #define ACE_PAGE_SIZE 4096 +#define ACE_SCANDIR_CMP_USES_CONST_VOIDPTR +#define ACE_SCANDIR_SEL_LACKS_CONST // OpenBSD 3.6 #if (OpenBSD < 200411) @@ -116,7 +126,7 @@ // Lacks perfect filtering, must bind group address. #if !defined ACE_LACKS_PERFECT_MULTICAST_FILTERING -# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING #endif /* ACE_LACKS_PERFECT_MULTICAST_FILTERING */ // OpenBSD's dlsym call segfaults when passed an invalid handle. diff --git a/dep/acelite/ace/config-openvms.h b/dep/acelite/ace/config-openvms.h index 28d8c01c6..91762386f 100644 --- a/dep/acelite/ace/config-openvms.h +++ b/dep/acelite/ace/config-openvms.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-openvms.h 94294 2011-07-01 09:32:25Z johnnyw $ + // The following configuration file is designed to work for OpenVMS 7.3-2 #ifndef ACE_CONFIG_H diff --git a/dep/acelite/ace/config-pharlap.h b/dep/acelite/ace/config-pharlap.h index dbc933bc5..dad0e91a9 100644 --- a/dep/acelite/ace/config-pharlap.h +++ b/dep/acelite/ace/config-pharlap.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-pharlap.h 84373 2009-02-10 18:21:50Z johnnyw $ + // This configuration file is for use with the PharLap Realtime ETS Kernel. // It has been tested with PharLap TNT Embedded ToolSuite version 9.1. diff --git a/dep/acelite/ace/config-posix-nonetworking.h b/dep/acelite/ace/config-posix-nonetworking.h index 23e33eccc..7edc31d0d 100644 --- a/dep/acelite/ace/config-posix-nonetworking.h +++ b/dep/acelite/ace/config-posix-nonetworking.h @@ -1,4 +1,6 @@ /* -*- C -*- */ +// $Id: config-posix-nonetworking.h 80826 2008-03-04 14:51:23Z wotte $ + /* The following configuration file is designed to work for RTEMS platforms using GNU C. */ diff --git a/dep/acelite/ace/config-posix.h b/dep/acelite/ace/config-posix.h index 781b7a8da..09b4e0671 100644 --- a/dep/acelite/ace/config-posix.h +++ b/dep/acelite/ace/config-posix.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-posix.h 82517 2008-08-05 19:36:26Z shuston $ + #ifndef ACE_CONFIG_POSIX_H #define ACE_CONFIG_POSIX_H diff --git a/dep/acelite/ace/config-qnx.h b/dep/acelite/ace/config-qnx.h index bedcdd26e..07e90a5b2 100644 --- a/dep/acelite/ace/config-qnx.h +++ b/dep/acelite/ace/config-qnx.h @@ -1,4 +1,5 @@ // -*- C++ -*- +// $Id: config-qnx.h 97326 2013-09-11 07:52:09Z johnnyw $ // The following configuration file is designed to work for QNX RTP // GNU C++ and the POSIX (pthread) threads package. You can get QNX // RTP at http://get.qnx.com. diff --git a/dep/acelite/ace/config-rtems.h b/dep/acelite/ace/config-rtems.h index 5943d8237..f65893cc5 100644 --- a/dep/acelite/ace/config-rtems.h +++ b/dep/acelite/ace/config-rtems.h @@ -1,4 +1,6 @@ /* -*- C -*- */ +// $Id: config-rtems.h 93571 2011-03-17 07:37:11Z olli $ + /* The following configuration file is designed to work for RTEMS platforms using GNU C. */ diff --git a/dep/acelite/ace/config-suncc-common.h b/dep/acelite/ace/config-suncc-common.h index ff4d38c42..8033a4f5a 100644 --- a/dep/acelite/ace/config-suncc-common.h +++ b/dep/acelite/ace/config-suncc-common.h @@ -1,4 +1,7 @@ // -*- C++ -*- +// +// $Id: config-suncc-common.h 91685 2010-09-09 09:35:14Z johnnyw $ + #ifndef ACE_SUNCC_COMMON_H #define ACE_SUNCC_COMMON_H #include /**/ "ace/pre.h" @@ -48,10 +51,5 @@ #define ACE_TEMPLATES_REQUIRE_SOURCE -// Solaris Studio 12.4 implements symbol lookup correctly. -#if defined (__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130) -#define ACE_ANY_OPS_USE_NAMESPACE -#endif - #include /**/ "ace/post.h" #endif /* ACE_SUNCC_COMMON_H */ diff --git a/dep/acelite/ace/config-sunos5.10.h b/dep/acelite/ace/config-sunos5.10.h index 99b12cbc6..1ba1e19a1 100644 --- a/dep/acelite/ace/config-sunos5.10.h +++ b/dep/acelite/ace/config-sunos5.10.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.10.h 95428 2012-01-11 15:42:20Z sma $ + // The following configuration file is designed to work for SunOS 5.10 // (Solaris 10) platforms using the SunC++ 5.x (Sun Studio 8-10), or g++ // compilers. @@ -20,9 +22,6 @@ # undef ACE_LACKS_ALPHASORT #endif -#undef ACE_LACKS_GETADDRINFO -#undef ACE_LACKS_GETNAMEINFO - // Solaris 10 offers a useable log2() unlike previous Solaris versions. #if defined (ACE_LACKS_LOG2) # undef ACE_LACKS_LOG2 @@ -59,9 +58,4 @@ #define ACE_HAS_SOLARIS_ATOMIC_LIB -// Solaris Studio 12.4 implements symbol lookup correctly. -#if defined (__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130) -#define ACE_ANY_OPS_USE_NAMESPACE -#endif - #endif /* ACE_CONFIG_H */ diff --git a/dep/acelite/ace/config-sunos5.11.h b/dep/acelite/ace/config-sunos5.11.h index 07f8b679f..bbfd91c82 100644 --- a/dep/acelite/ace/config-sunos5.11.h +++ b/dep/acelite/ace/config-sunos5.11.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.11.h 80826 2008-03-04 14:51:23Z wotte $ + // The following configuration file is designed to work for SunOS 5.11 // (Solaris 11) platforms using the SunC++ 5.x (Sun Studio 10-12), or g++ // compilers. diff --git a/dep/acelite/ace/config-sunos5.4-g++.h b/dep/acelite/ace/config-sunos5.4-g++.h index c17ae74ee..55fc6579c 100644 --- a/dep/acelite/ace/config-sunos5.4-g++.h +++ b/dep/acelite/ace/config-sunos5.4-g++.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.4-g++.h 93573 2011-03-17 07:53:03Z olli $ + // The following configuration file is designed to work for SunOS 5.4 // platforms using the GNU g++ compiler. diff --git a/dep/acelite/ace/config-sunos5.4-sunc++-4.x.h b/dep/acelite/ace/config-sunos5.4-sunc++-4.x.h index 231876110..4c7a3a639 100644 --- a/dep/acelite/ace/config-sunos5.4-sunc++-4.x.h +++ b/dep/acelite/ace/config-sunos5.4-sunc++-4.x.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.4-sunc++-4.x.h 93573 2011-03-17 07:53:03Z olli $ + // The following configuration file is designed to work for SunOS 5.4 // platforms using the SunC++ 4.0.x compiler. diff --git a/dep/acelite/ace/config-sunos5.5.h b/dep/acelite/ace/config-sunos5.5.h index d6313d754..30e48da6d 100644 --- a/dep/acelite/ace/config-sunos5.5.h +++ b/dep/acelite/ace/config-sunos5.5.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.5.h 94454 2011-09-08 17:36:56Z johnnyw $ + // This configuration file is designed to work for SunOS 5.5 platforms // using the following compilers: // * Sun C++ 4.2 and later (including 5.x), patched as noted below diff --git a/dep/acelite/ace/config-sunos5.6.h b/dep/acelite/ace/config-sunos5.6.h index a6e2f0c36..e7f935c75 100644 --- a/dep/acelite/ace/config-sunos5.6.h +++ b/dep/acelite/ace/config-sunos5.6.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.6.h 93117 2011-01-20 12:11:28Z mcorino $ + // The following configuration file is designed to work for SunOS 5.6 // platforms using the SunC++ 4.x or g++ compilers. diff --git a/dep/acelite/ace/config-sunos5.7.h b/dep/acelite/ace/config-sunos5.7.h index d21859e5d..7c472ec16 100644 --- a/dep/acelite/ace/config-sunos5.7.h +++ b/dep/acelite/ace/config-sunos5.7.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.7.h 97175 2013-05-29 06:59:19Z johnnyw $ + // The following configuration file is designed to work for SunOS 5.7 // (Solaris 7) platforms using the SunC++ 4.x, 5.x, or g++ compilers. diff --git a/dep/acelite/ace/config-sunos5.8.h b/dep/acelite/ace/config-sunos5.8.h index b78ee27a1..eb83e9149 100644 --- a/dep/acelite/ace/config-sunos5.8.h +++ b/dep/acelite/ace/config-sunos5.8.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.8.h 80826 2008-03-04 14:51:23Z wotte $ + // The following configuration file is designed to work for SunOS 5.8 // (Solaris 8) platforms using the SunC++ 4.x, 5.x, 6.x, or g++ compilers. diff --git a/dep/acelite/ace/config-sunos5.9.h b/dep/acelite/ace/config-sunos5.9.h index 53cb350fb..b8d09447e 100644 --- a/dep/acelite/ace/config-sunos5.9.h +++ b/dep/acelite/ace/config-sunos5.9.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-sunos5.9.h 84213 2009-01-22 15:45:13Z johnnyw $ + // The following configuration file is designed to work for SunOS 5.9 // (Solaris 9) platforms using the SunC++ 5.x (Forte 6 and 7), or g++ // compilers. @@ -11,8 +13,6 @@ #include "ace/config-sunos5.8.h" #define ACE_HAS_SENDFILE 1 -#define ACE_LACKS_GETADDRINFO -#define ACE_LACKS_GETNAMEINFO #define ACE_LACKS_THR_CONCURRENCY_FUNCS #endif /* ACE_CONFIG_H */ diff --git a/dep/acelite/ace/config-vxworks.h b/dep/acelite/ace/config-vxworks.h index e9b35930a..79e51ebd3 100644 --- a/dep/acelite/ace/config-vxworks.h +++ b/dep/acelite/ace/config-vxworks.h @@ -1,4 +1,6 @@ //* -*- C++ -*- */ +// $Id: config-vxworks.h 95534 2012-02-17 23:19:33Z mitza $ + // The following configuration file is designed to work for VxWorks // Based on ACE_VXWORKS it will select the correct config file @@ -34,8 +36,6 @@ # elif (_WRS_VXWORKS_MINOR == 9) # define ACE_VXWORKS 0x690 # endif -# elif (_WRS_VXWORKS_MAJOR == 7) -# define ACE_VXWORKS 0x700 # endif # endif #endif /* ! ACE_VXWORKS */ @@ -52,29 +52,8 @@ # include "ace/config-vxworks6.8.h" #elif (ACE_VXWORKS == 0x690) # include "ace/config-vxworks6.9.h" -#elif (ACE_VXWORKS == 0x700) -# include "ace/config-vxworks7.0.h" #else -# error Unknown or unsupported VxWorks version -#endif - -// Adapt to system argument changes added at VxWorks 6.9 and 64-bit. -// It would be nicer to typedef the data types, but without including the -// applicable VxWorks headers here, that doesn't work. -#if (ACE_VXWORKS < 0x690) -# define ACE_VX_USR_ARG_T int -# define ACE_VX_TASK_ID int -# define ACE_VX_ARG_FORMAT "%x" -# define ACE_VX_TASK_ID_ERROR ERROR -#else -# define ACE_VX_USR_ARG_T _Vx_usr_arg_t -# define ACE_VX_TASK_ID TASK_ID -# ifdef _WRS_CONFIG_LP64 -# define ACE_VX_ARG_FORMAT "%lx" -# else -# define ACE_VX_ARG_FORMAT "%x" -# endif -# define ACE_VX_TASK_ID_ERROR TASK_ID_ERROR +#error Unknown or unsupported VxWorks version #endif #include /**/ "ace/post.h" diff --git a/dep/acelite/ace/config-vxworks6.4.h b/dep/acelite/ace/config-vxworks6.4.h index 260c559a5..4b6a56d4a 100644 --- a/dep/acelite/ace/config-vxworks6.4.h +++ b/dep/acelite/ace/config-vxworks6.4.h @@ -1,4 +1,6 @@ //* -*- C++ -*- */ +// $Id: config-vxworks6.4.h 97326 2013-09-11 07:52:09Z johnnyw $ + // The following configuration file is designed to work for VxWorks // 6.4 platforms using one of these compilers: // 1) The GNU g++ compiler that is shipped with VxWorks 6.4 @@ -16,14 +18,6 @@ # define ACE_VXWORKS 0x640 #endif /* ! ACE_VXWORKS */ -#ifndef ACE_LACKS_RAND_R -# define ACE_LACKS_RAND_R 1 -#endif - -#ifndef __RTP__ -# define ACE_LACKS_STD_WSTRING -#endif - #if !defined (__RTP__) // Fix for wrong typedef of time_t in kernel mode #ifndef _TIME_T @@ -88,7 +82,6 @@ // OS-specific configuration #define ACE_HAS_4_4BSD_SENDMSG_RECVMSG #define ACE_HAS_3_PARAM_READDIR_R -#define ACE_HAS_NET_IF_DL_H #define ACE_HAS_NONCONST_GETBY #define ACE_HAS_NONCONST_INET_ADDR #define ACE_HAS_NONCONST_SWAB @@ -270,7 +263,6 @@ #define ACE_LACKS_WCSNCPY #define ACE_LACKS_WCSPBRK #define ACE_LACKS_WCSRCHR - #define ACE_LACKS_WCSRTOMBS #define ACE_LACKS_WCSSPN #define ACE_LACKS_WCSSTR #define ACE_LACKS_WCSTOK diff --git a/dep/acelite/ace/config-vxworks6.5.h b/dep/acelite/ace/config-vxworks6.5.h index 6af5b3954..19273e6ca 100644 --- a/dep/acelite/ace/config-vxworks6.5.h +++ b/dep/acelite/ace/config-vxworks6.5.h @@ -1,4 +1,6 @@ //* -*- C++ -*- */ +// $Id: config-vxworks6.5.h 80826 2008-03-04 14:51:23Z wotte $ + // The following configuration file is designed to work for VxWorks // 6.5 platforms using one of these compilers: // 1) The GNU g++ compiler that is shipped with VxWorks 6.5 diff --git a/dep/acelite/ace/config-vxworks6.6.h b/dep/acelite/ace/config-vxworks6.6.h index c2373e20c..eebce4432 100644 --- a/dep/acelite/ace/config-vxworks6.6.h +++ b/dep/acelite/ace/config-vxworks6.6.h @@ -1,4 +1,6 @@ //* -*- C++ -*- */ +// $Id: config-vxworks6.6.h 85143 2009-04-22 09:15:08Z johnnyw $ + // The following configuration file is designed to work for VxWorks // 6.6 platforms using one of these compilers: // 1) The GNU g++ compiler that is shipped with VxWorks 6.6 diff --git a/dep/acelite/ace/config-vxworks6.7.h b/dep/acelite/ace/config-vxworks6.7.h index dd2778795..eab429a2e 100644 --- a/dep/acelite/ace/config-vxworks6.7.h +++ b/dep/acelite/ace/config-vxworks6.7.h @@ -1,4 +1,6 @@ //* -*- C++ -*- */ +// $Id: config-vxworks6.7.h 84971 2009-03-25 13:03:44Z johnnyw $ + // The following configuration file is designed to work for VxWorks // 6.7 platforms using one of these compilers: // 1) The GNU g++ compiler that is shipped with VxWorks 6.7 diff --git a/dep/acelite/ace/config-vxworks6.8.h b/dep/acelite/ace/config-vxworks6.8.h index 56d805d08..14e072df6 100644 --- a/dep/acelite/ace/config-vxworks6.8.h +++ b/dep/acelite/ace/config-vxworks6.8.h @@ -1,4 +1,6 @@ //* -*- C++ -*- */ +// $Id: config-vxworks6.8.h 96050 2012-08-14 22:22:54Z mitza $ + // The following configuration file is designed to work for VxWorks // 6.8 platforms using one of these compilers: // 1) The GNU g++ compiler that is shipped with VxWorks 6.8 @@ -14,6 +16,13 @@ #include "ace/config-vxworks6.7.h" +#ifndef ACE_LACKS_RAND_R +# define ACE_LACKS_RAND_R 1 +#endif + +#ifndef __RTP__ +# define ACE_LACKS_STD_WSTRING +#endif #include /**/ "ace/post.h" #endif /* ACE_CONFIG_VXWORKS_6_8_H */ diff --git a/dep/acelite/ace/config-vxworks6.9.h b/dep/acelite/ace/config-vxworks6.9.h index d792e5179..9a15936a6 100644 --- a/dep/acelite/ace/config-vxworks6.9.h +++ b/dep/acelite/ace/config-vxworks6.9.h @@ -1,4 +1,6 @@ //* -*- C++ -*- */ +// $Id: config-vxworks6.9.h 97911 2014-10-07 21:58:25Z shuston $ + // The following configuration file is designed to work for VxWorks // 6.9 platforms using one of these compilers: // 1) The GNU g++ compiler that is shipped with VxWorks 6.9 diff --git a/dep/acelite/ace/config-win32-borland.h b/dep/acelite/ace/config-win32-borland.h index 47fd0dbf0..ef64bc3c7 100644 --- a/dep/acelite/ace/config-win32-borland.h +++ b/dep/acelite/ace/config-win32-borland.h @@ -1,4 +1,6 @@ //-*- C++ -*- +//$Id: config-win32-borland.h 97641 2014-02-28 09:24:49Z johnnyw $ + // The following configuration file contains defines for Borland compilers. #ifndef ACE_CONFIG_WIN32_BORLAND_H @@ -35,11 +37,11 @@ # define ACE_CC_PREPROCESSOR_ARGS "-q -Sl -o%s" #endif -#if !defined (WIN32) -# if defined (__WIN32__) || defined (_WIN32) +// Automatically define WIN32 macro if the compiler tells us it is our +// target platform. +# if defined (__WIN32__) && !defined (WIN32) # define WIN32 1 # endif -#endif // When building a VCL application, the main VCL header file should be // included before anything else. You can define ACE_HAS_VCL=1 in your @@ -48,7 +50,7 @@ # include /**/ # endif -#if defined (_WIN64) +#if defined (__clang__) # define ACE_HAS_BCC64 #else # define ACE_HAS_BCC32 @@ -95,7 +97,6 @@ #define ACE_LACKS_SYS_SEM_H #define ACE_LACKS_SYS_IOCTL_H #define ACE_LACKS_STROPTS_H -#define ACE_LACKS_WCSRTOMBS #undef ACE_LACKS_STRUCT_DIR #undef ACE_LACKS_CLOSEDIR @@ -115,6 +116,7 @@ # define ACE_HAS_TIME_T_LONG_MISMATCH #endif +#define ACE_EXPORT_NESTED_CLASSES 1 #define ACE_HAS_CPLUSPLUS_HEADERS 1 #define ACE_HAS_NONCONST_SELECT_TIMEVAL #define ACE_HAS_SIG_ATOMIC_T @@ -126,10 +128,8 @@ #define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 #define ACE_HAS_NEW_NOTHROW #define ACE_TEMPLATES_REQUIRE_SOURCE 1 -#if defined (ACE_HAS_BCC32) -# define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%Lu" -# define ACE_INT64_FORMAT_SPECIFIER_ASCII "%Ld" -#endif +#define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%Lu" +#define ACE_INT64_FORMAT_SPECIFIER_ASCII "%Ld" #define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 #define ACE_USES_STD_NAMESPACE_FOR_ABS 1 #define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) STATUS) @@ -145,19 +145,17 @@ # endif /* !__MT__ */ #endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ -#if (__BORLANDC__ <= 0x730) +#if (__BORLANDC__ <= 0x680) # define ACE_LACKS_ISWCTYPE # define ACE_LACKS_ISCTYPE #endif -#if (__BORLANDC__ >= 0x640) && (__BORLANDC__ <= 0x730) +#if (__BORLANDC__ >= 0x650) && (__BORLANDC__ <= 0x680) # define ACE_LACKS_STRTOK_R #endif -#if (__BORLANDC__ <= 0x730) +#if (__BORLANDC__ <= 0x680) # define ACE_LACKS_LOCALTIME_R -# define ACE_LACKS_GMTIME_R -# define ACE_LACKS_ASCTIME_R #endif #define ACE_WCSDUP_EQUIVALENT ::_wcsdup @@ -168,31 +166,16 @@ #define ACE_HAS_ITOA 1 #if defined (ACE_HAS_BCC64) -# if (__BORLANDC__ <= 0x730) +# if (__BORLANDC__ < 0x680) # define ACE_LACKS_SWAB # endif #endif #if defined (ACE_HAS_BCC32) -// The bcc32 compiler can't handle assembly in inline methods or -// templates (E2211). When we build for pentium optimized and we are inlining -// then we disable inline assembly -# if defined (ACE_HAS_PENTIUM) && defined(__ACE_INLINE__) && !defined(__clang__) -# define ACE_LACKS_INLINE_ASSEMBLY -# endif # define ACE_SIZEOF_LONG_DOUBLE 10 # define ACE_NEEDS_DL_UNDERSCORE #endif -#ifdef __clang__ -# define ACE_ANY_OPS_USE_NAMESPACE -# define ACE_HAS_BUILTIN_BSWAP16 -# define ACE_HAS_BUILTIN_BSWAP32 -# define ACE_HAS_BUILTIN_BSWAP64 -# define ACE_LACKS_INLINE_ASSEMBLY -#endif /* __clang__ */ - - #include /**/ "ace/post.h" #endif /* ACE_CONFIG_WIN32_BORLAND_H */ diff --git a/dep/acelite/ace/config-win32-cegcc.h b/dep/acelite/ace/config-win32-cegcc.h index f1480b2a5..4f115d69a 100644 --- a/dep/acelite/ace/config-win32-cegcc.h +++ b/dep/acelite/ace/config-win32-cegcc.h @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: config-win32-cegcc.h 92102 2010-09-30 08:14:15Z johnnyw $ + // // The following configuration file is designed to work for win32 // platforms using gcc/g++ with mingw32 (http://www.mingw.org). diff --git a/dep/acelite/ace/config-win32-common.h b/dep/acelite/ace/config-win32-common.h index 56567eead..f74577b7d 100644 --- a/dep/acelite/ace/config-win32-common.h +++ b/dep/acelite/ace/config-win32-common.h @@ -1,4 +1,6 @@ /* -*- C++ -*- */ +// $Id: config-win32-common.h 97940 2014-10-27 18:11:13Z johnnyw $ + #ifndef ACE_CONFIG_WIN32_COMMON_H #define ACE_CONFIG_WIN32_COMMON_H @@ -143,7 +145,7 @@ #define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllexport) SINGLETON_TYPE; #define ACE_IMPORT_SINGLETON_DECLARATION(T) extern template class T #define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) extern template class SINGLETON_TYPE ; -#endif /* !ACE_HAS_CUSTOM_EXPORT_MACROS || ACE_HAS_CUSTOM_EXPORT_MACROS==0 */ +#endif /* !__BORLANDC__ */ // Define ACE_HAS_WINSOCK2 to 0 in your config.h file if you do *not* // want to compile with WinSock 2.0. @@ -154,7 +156,7 @@ // By default, we use non-static object manager on Win32. That is, // the object manager is allocated in main's stack memory. If this // does not suit your need, i.e., if your programs depend on the use -// of static object manager, you need to disable the behavior by adding +// of static object manager, you neet to disable the behavior by adding // // #undef ACE_HAS_NONSTATIC_OBJECT_MANAGER // @@ -167,7 +169,7 @@ // either: // // 1. Using static object manager (as described above), however, using -// the non-static object manager is preferred, therefore, +// the non-static object manager is prefered, therefore, // 2. Instantiate the non-static object manager yourself by either 1) // call ACE::init () at the beginning and ACE::fini () at the end, // _or_ 2) instantiate the ACE_Object_Manager in your CWinApp @@ -235,15 +237,10 @@ #define ACE_HAS_DIRENT #define ACE_HAS_MSG -#define ACE_HAS_NONCONST_INET_NTOP #define ACE_HAS_RECURSIVE_MUTEXES #define ACE_HAS_SOCKADDR_MSG_NAME #define ACE_HAS_THREAD_SAFE_ACCEPT -/* MS is phasing out the GetVersion API so let's prepare */ -/* For now all releases still provide it. */ -#define ACE_HAS_WIN32_GETVERSION - /* LACKS dir-related facilities */ #define ACE_LACKS_READDIR_R #define ACE_LACKS_REWINDDIR @@ -280,10 +277,6 @@ #define ACE_LACKS_GETIPNODEBYNAME_IPV6 #define ACE_LACKS_KILL #define ACE_LACKS_INET_ATON -#if _WIN32_WINNT < 0x0600 -# define ACE_LACKS_INET_NTOP -# define ACE_LACKS_INET_PTON -#endif #define ACE_LACKS_MADVISE #define ACE_LACKS_MKFIFO #define ACE_LACKS_MODE_MASKS @@ -663,7 +656,7 @@ #if (WINVER>=0x0600) // Windows Server 2008 definitions go here -// Windows Vista definitions go here +// Windows Vista defintions go here # if ! defined(ACE_DEFAULT_THREAD_KEYS) # define ACE_DEFAULT_THREAD_KEYS 1088 # endif // ! defined(ACE_DEFAULT_THREAD_KEYS) diff --git a/dep/acelite/ace/config-win32-dmc.h b/dep/acelite/ace/config-win32-dmc.h index 1a31077a5..77c4795b3 100644 --- a/dep/acelite/ace/config-win32-dmc.h +++ b/dep/acelite/ace/config-win32-dmc.h @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: config-win32-dmc.h 92102 2010-09-30 08:14:15Z johnnyw $ + // The following configuration file contains defines for Digital Mars compilers. #ifndef ACE_CONFIG_WIN32_DMC_H @@ -42,6 +44,7 @@ #define ACE_WCSDUP_EQUIVALENT ::_wcsdup // This section above was extracted from config-win32-msvc +#define ACE_EXPORT_NESTED_CLASSES 1 #define ACE_HAS_CPLUSPLUS_HEADERS 1 #define ACE_HAS_NONCONST_SELECT_TIMEVAL 1 #define ACE_HAS_SIG_ATOMIC_T 1 diff --git a/dep/acelite/ace/config-win32-interix.h b/dep/acelite/ace/config-win32-interix.h index 2f603d55e..a1a8faeff 100644 --- a/dep/acelite/ace/config-win32-interix.h +++ b/dep/acelite/ace/config-win32-interix.h @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: config-win32-interix.h 93550 2011-03-15 21:26:56Z olli $ + // The following configuration file is designed to work for Interix // platforms using GNU g++ (Interix == Microsoft's Services for Unix) diff --git a/dep/acelite/ace/config-win32-mingw.h b/dep/acelite/ace/config-win32-mingw.h index 63a783869..5d1ca07b1 100644 --- a/dep/acelite/ace/config-win32-mingw.h +++ b/dep/acelite/ace/config-win32-mingw.h @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: config-win32-mingw.h 96943 2013-03-30 09:42:31Z mcorino $ + // // The following configuration file is designed to work for win32 // platforms using gcc/g++ with mingw32 (http://www.mingw.org). @@ -87,8 +89,6 @@ #define ACE_LACKS_PDHMSG_H #define ACE_LACKS_STRTOK_R #define ACE_LACKS_LOCALTIME_R -#define ACE_LACKS_GMTIME_R -#define ACE_LACKS_ASCTIME_R #define ACE_HAS_NONCONST_WCSDUP #define ACE_HAS_WINSOCK2_GQOS #define ACE_ISCTYPE_EQUIVALENT ::_isctype diff --git a/dep/acelite/ace/config-win32-mingw64.h b/dep/acelite/ace/config-win32-mingw64.h index b801b10a7..504e70ddc 100644 --- a/dep/acelite/ace/config-win32-mingw64.h +++ b/dep/acelite/ace/config-win32-mingw64.h @@ -1,4 +1,6 @@ // -*- C++ -*- +// $Id: config-win32-mingw64.h 97440 2013-11-27 12:16:41Z mcorino $ + // // The following configuration file is designed to work for win32 and win64 // platforms using gcc/g++ with mingw64 (http://http://mingw-w64.sourceforge.net/). @@ -122,13 +124,9 @@ #define ACE_LACKS_PDHMSG_H #define ACE_LACKS_STRTOK_R #define ACE_LACKS_LOCALTIME_R -#define ACE_LACKS_GMTIME_R -#define ACE_LACKS_ASCTIME_R #define ACE_HAS_NONCONST_WCSDUP #define ACE_ISCTYPE_EQUIVALENT ::_isctype -#define ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE - #define ACE_INT64_FORMAT_SPECIFIER_ASCII "%I64d" #define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%I64u" diff --git a/dep/acelite/ace/config-win32-msvc-10.h b/dep/acelite/ace/config-win32-msvc-10.h index 62dcdae8d..01e9585f2 100644 --- a/dep/acelite/ace/config-win32-msvc-10.h +++ b/dep/acelite/ace/config-win32-msvc-10.h @@ -3,6 +3,8 @@ /** * @file config-win32-msvc-10.h * + * $Id: config-win32-msvc-10.h 97431 2013-11-19 14:28:52Z johnnyw $ + * * @brief Microsoft Visual C++ 10.0 configuration file. * * This file is the ACE configuration file for Microsoft Visual C++ version 10. diff --git a/dep/acelite/ace/config-win32-msvc-11.h b/dep/acelite/ace/config-win32-msvc-11.h index 8078ffa60..3142f579b 100644 --- a/dep/acelite/ace/config-win32-msvc-11.h +++ b/dep/acelite/ace/config-win32-msvc-11.h @@ -3,6 +3,8 @@ /** * @file config-win32-msvc-11.h * + * $Id: config-win32-msvc-11.h 97766 2014-06-04 10:08:40Z johnnyw $ + * * @brief Microsoft Visual C++ 11.0 configuration file. * * This file is the ACE configuration file for Microsoft Visual C++ version 11. diff --git a/dep/acelite/ace/config-win32-msvc-12.h b/dep/acelite/ace/config-win32-msvc-12.h index 0b59cd446..6e41ebc5a 100644 --- a/dep/acelite/ace/config-win32-msvc-12.h +++ b/dep/acelite/ace/config-win32-msvc-12.h @@ -3,6 +3,8 @@ /** * @file config-win32-msvc-12.h * + * $Id: config-win32-msvc-12.h 97766 2014-06-04 10:08:40Z johnnyw $ + * * @brief Microsoft Visual C++ 12.0 configuration file. * * This file is the ACE configuration file for Microsoft Visual C++ version 12. diff --git a/dep/acelite/ace/config-win32-msvc-14.h b/dep/acelite/ace/config-win32-msvc-14.h index e674c9703..85f0acfd2 100644 --- a/dep/acelite/ace/config-win32-msvc-14.h +++ b/dep/acelite/ace/config-win32-msvc-14.h @@ -3,9 +3,11 @@ /** * @file config-win32-msvc-14.h * + * $Id: config-win32-msvc-14.h 97798 2014-07-03 10:57:43Z johnnyw $ + * * @brief Microsoft Visual C++ 14.0 configuration file. * - * This file is the ACE configuration file for Microsoft Visual C++ version 2015. + * This file is the ACE configuration file for Microsoft Visual C++ version 14. * * @note Do not include this file directly, include config-win32.h instead. */ @@ -29,28 +31,11 @@ #define ACE_HAS_POSIX_TIME 1 #define ACE_LACKS_TIMESPEC_T 1 -// According to MS the Visual Studio 2015 C-runtime has a +// According to MS the Visual Studio 2014 C-runtime has a // C99 compliant vsnprintf/vsnwprintf, this is a change compared to // previous versions #define ACE_HAS_C99_VSNPRINTF #define ACE_HAS_C99_VSNWPRINTF -// Visual Studio 2015 has 3 parameter wcstok -#define ACE_HAS_3_PARAM_WCSTOK - -// Visual Studio 2015 has adequate C++11 support -#define ACE_HAS_CPP11 - -#define ACE_PUTENV_EQUIVALENT ::_putenv -#define ACE_TEMPNAM_EQUIVALENT ::_tempnam -#define ACE_STRDUP_EQUIVALENT ::_strdup -#define ACE_MKDIR_EQUIVALENT ::_mkdir -#define ACE_ACCESS_EQUIVALENT ::_access -#define ACE_CHDIR_EQUIVALENT ::_chdir -#define ACE_RMDIR_EQUIVALENT ::_rmdir -#define ACE_GETCWD_EQUIVALENT ::_getcwd -#define ACE_SWAB_EQUIVALENT ::_swab -#define ACE_UNLINK_EQUIVALENT ::_unlink - #include /**/ "ace/post.h" #endif /* ACE_CONFIG_WIN32_MSVC_14_H */ diff --git a/dep/acelite/ace/config-win32-msvc-7.h b/dep/acelite/ace/config-win32-msvc-7.h index 9db4d3920..93ced167c 100644 --- a/dep/acelite/ace/config-win32-msvc-7.h +++ b/dep/acelite/ace/config-win32-msvc-7.h @@ -3,6 +3,8 @@ /** * @file config-win32-msvc-7.h * + * $Id: config-win32-msvc-7.h 93562 2011-03-16 14:13:52Z olli $ + * * @brief Microsoft Visual C++ 7.0 configuration file. * * This file is the ACE configuration file for Microsoft Visual C++ version 7. @@ -47,6 +49,7 @@ #define ACE_LACKS_STRPTIME #define ACE_LACKS_STRTOK_R +#define ACE_LACKS_LOCALTIME_R #define ACE_HAS_SIG_ATOMIC_T #define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES diff --git a/dep/acelite/ace/config-win32-msvc-8.h b/dep/acelite/ace/config-win32-msvc-8.h index c2dfcfddd..fa6c63a1f 100644 --- a/dep/acelite/ace/config-win32-msvc-8.h +++ b/dep/acelite/ace/config-win32-msvc-8.h @@ -3,6 +3,8 @@ /** * @file config-win32-msvc-8.h * + * $Id: config-win32-msvc-8.h 95719 2012-05-01 12:54:01Z johnnyw $ + * * @brief Microsoft Visual C++ 8.0 configuration file. * * This file is the ACE configuration file for Microsoft Visual C++ version 8. diff --git a/dep/acelite/ace/config-win32-msvc-9.h b/dep/acelite/ace/config-win32-msvc-9.h index 19865aa34..3992d0d39 100644 --- a/dep/acelite/ace/config-win32-msvc-9.h +++ b/dep/acelite/ace/config-win32-msvc-9.h @@ -3,6 +3,8 @@ /** * @file config-win32-msvc-9.h * + * $Id: config-win32-msvc-9.h 97431 2013-11-19 14:28:52Z johnnyw $ + * * @brief Microsoft Visual C++ 9.0 configuration file. * * This file is the ACE configuration file for Microsoft Visual C++ version 9. diff --git a/dep/acelite/ace/config-win32-msvc.h b/dep/acelite/ace/config-win32-msvc.h index 5736e5691..86a7e62c0 100644 --- a/dep/acelite/ace/config-win32-msvc.h +++ b/dep/acelite/ace/config-win32-msvc.h @@ -2,6 +2,8 @@ /** * @file config-win32-msvc.h * + * $Id: config-win32-msvc.h 97766 2014-06-04 10:08:40Z johnnyw $ + * * @brief Microsoft Visual C++ configuration file. * * This file is the ACE configuration file for Microsoft Visual C++ @@ -38,11 +40,7 @@ #endif /* _WIN32_WCE */ //FUZZ: disable check_for_msc_ver -#if (_MSC_VER >= 1920) -# include "ace/config-win32-msvc-142.h" -#elif (_MSC_VER >= 1910) -# include "ace/config-win32-msvc-141.h" -#elif (_MSC_VER >= 1900) +#if (_MSC_VER >= 1900) # include "ace/config-win32-msvc-14.h" #elif (_MSC_VER >= 1800) # include "ace/config-win32-msvc-12.h" @@ -103,9 +101,7 @@ #define ACE_LACKS_NETDB_H #define ACE_LACKS_NET_IF_H #define ACE_LACKS_NETINET_IN_H -#if !defined (ACE_WIN32_VC14) -# define ACE_LACKS_STDINT_H -#endif +#define ACE_LACKS_STDINT_H #define ACE_LACKS_STROPTS_H #define ACE_LACKS_SYS_IOCTL_H #define ACE_LACKS_SYS_IPC_H @@ -129,10 +125,6 @@ #define ACE_LACKS_TERMIOS_H #define ACE_LACKS_REGEX_H -#define ACE_LACKS_LOCALTIME_R -#define ACE_LACKS_GMTIME_R -#define ACE_LACKS_ASCTIME_R - #define ACE_INT64_FORMAT_SPECIFIER_ASCII "%I64d" #define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%I64u" diff --git a/dep/acelite/ace/config-win32.h b/dep/acelite/ace/config-win32.h index 3217c2b78..f2b2d2d96 100644 --- a/dep/acelite/ace/config-win32.h +++ b/dep/acelite/ace/config-win32.h @@ -3,6 +3,8 @@ /** * @file config-win32.h * + * $Id: config-win32.h 97246 2013-08-07 07:10:20Z johnnyw $ + * * @brief Microsoft Windows configuration file. * * This file is the ACE configuration file for all of Microsoft Windows diff --git a/dep/acelite/ace/config-windows.h b/dep/acelite/ace/config-windows.h index b36f01d24..28e59c9a3 100644 --- a/dep/acelite/ace/config-windows.h +++ b/dep/acelite/ace/config-windows.h @@ -1,3 +1,5 @@ /* -*- C++ -*- */ +// $Id: config-windows.h 94353 2011-07-30 13:13:13Z johnnyw $ + // This is all we need to do to build ACE on a Windows platform (32bit or 64bit) #include "config-win32.h" diff --git a/dep/acelite/ace/iosfwd.h b/dep/acelite/ace/iosfwd.h index fb38cf083..b9576ebae 100644 --- a/dep/acelite/ace/iosfwd.h +++ b/dep/acelite/ace/iosfwd.h @@ -4,6 +4,8 @@ /** * @file iosfwd.h * + * $Id: iosfwd.h 89098 2010-02-21 21:51:41Z schmidt $ + * * @author Irfan Pyarali * * This file contains the portability ugliness for the Standard C++ diff --git a/dep/acelite/ace/os_include/arpa/os_inet.h b/dep/acelite/ace/os_include/arpa/os_inet.h index db079938b..d3212781a 100644 --- a/dep/acelite/ace/os_include/arpa/os_inet.h +++ b/dep/acelite/ace/os_include/arpa/os_inet.h @@ -6,6 +6,8 @@ * * definitions for internet operations * + * $Id: os_inet.h 97259 2013-08-09 08:14:31Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/net/os_if.h b/dep/acelite/ace/os_include/net/os_if.h index e3cb68423..d672292a6 100644 --- a/dep/acelite/ace/os_include/net/os_if.h +++ b/dep/acelite/ace/os_include/net/os_if.h @@ -6,6 +6,8 @@ * * sockets local interfaces * + * $Id: os_if.h 91688 2010-09-09 11:21:50Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -24,9 +26,6 @@ #if !defined (ACE_LACKS_NET_IF_H) # include /**/ -# if defined (m_flags) -# undef m_flags -# endif /* m_flags */ # if defined (ACE_HAS_NET_IF_DL_H) # include /**/ # endif /* ACE_HAS_NET_IF_DL_H */ diff --git a/dep/acelite/ace/os_include/netinet/os_in.h b/dep/acelite/ace/os_include/netinet/os_in.h index 4c82df461..61e00accd 100644 --- a/dep/acelite/ace/os_include/netinet/os_in.h +++ b/dep/acelite/ace/os_include/netinet/os_in.h @@ -7,6 +7,8 @@ * * Internet address family * + * $Id: os_in.h 97259 2013-08-09 08:14:31Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -93,7 +95,7 @@ extern "C" }; # endif /* ACE_LACKS_IP_MREQ */ -#if !defined (ACE_HAS_IPPORT_RESERVED) && !defined (IPPORT_RESERVED) +#if !defined (IPPORT_RESERVED) # define IPPORT_RESERVED 1024 #endif /* !IPPORT_RESERVED */ diff --git a/dep/acelite/ace/os_include/netinet/os_tcp.h b/dep/acelite/ace/os_include/netinet/os_tcp.h index 6c672144d..69a6be6e8 100644 --- a/dep/acelite/ace/os_include/netinet/os_tcp.h +++ b/dep/acelite/ace/os_include/netinet/os_tcp.h @@ -6,6 +6,8 @@ * * definitions for the Internet Transmission Control Protocol (TCP) * + * $Id: os_tcp.h 97259 2013-08-09 08:14:31Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_aio.h b/dep/acelite/ace/os_include/os_aio.h index 0d2ffe080..4ec9fe9d1 100644 --- a/dep/acelite/ace/os_include/os_aio.h +++ b/dep/acelite/ace/os_include/os_aio.h @@ -6,6 +6,8 @@ * * asynchronous input and output (REALTIME) * + * $Id: os_aio.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_assert.h b/dep/acelite/ace/os_include/os_assert.h index f69a172d5..8bbd1fa22 100644 --- a/dep/acelite/ace/os_include/os_assert.h +++ b/dep/acelite/ace/os_include/os_assert.h @@ -6,6 +6,8 @@ * * verify program assertion * + * $Id: os_assert.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_byteswap.h b/dep/acelite/ace/os_include/os_byteswap.h index 4e0af7af1..cc95110aa 100644 --- a/dep/acelite/ace/os_include/os_byteswap.h +++ b/dep/acelite/ace/os_include/os_byteswap.h @@ -6,6 +6,8 @@ * * Byteswap methods * + * $Id: os_byteswap.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/os_complex.h b/dep/acelite/ace/os_include/os_complex.h index 2cd6cf761..db0aa3b48 100644 --- a/dep/acelite/ace/os_include/os_complex.h +++ b/dep/acelite/ace/os_include/os_complex.h @@ -6,6 +6,8 @@ * * complex arithmetic * + * $Id: os_complex.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_cpio.h b/dep/acelite/ace/os_include/os_cpio.h index 1766fcb27..273e73429 100644 --- a/dep/acelite/ace/os_include/os_cpio.h +++ b/dep/acelite/ace/os_include/os_cpio.h @@ -6,6 +6,8 @@ * * cpio archive values * + * $Id: os_cpio.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_ctype.h b/dep/acelite/ace/os_include/os_ctype.h index c82a1a3e4..4b5b65120 100644 --- a/dep/acelite/ace/os_include/os_ctype.h +++ b/dep/acelite/ace/os_include/os_ctype.h @@ -6,6 +6,8 @@ * * character types * + * $Id: os_ctype.h 83520 2008-11-03 08:54:08Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_dirent.h b/dep/acelite/ace/os_include/os_dirent.h index b5ce357e8..a51317a46 100644 --- a/dep/acelite/ace/os_include/os_dirent.h +++ b/dep/acelite/ace/os_include/os_dirent.h @@ -6,6 +6,8 @@ * * format of directory entries * + * $Id: os_dirent.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_dlfcn.h b/dep/acelite/ace/os_include/os_dlfcn.h index 5bba90e82..c65d78f19 100644 --- a/dep/acelite/ace/os_include/os_dlfcn.h +++ b/dep/acelite/ace/os_include/os_dlfcn.h @@ -6,6 +6,8 @@ * * dynamic linking * + * $Id: os_dlfcn.h 94379 2011-08-09 17:18:49Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_errno.h b/dep/acelite/ace/os_include/os_errno.h index c083e7407..bc49e03cd 100644 --- a/dep/acelite/ace/os_include/os_errno.h +++ b/dep/acelite/ace/os_include/os_errno.h @@ -6,6 +6,8 @@ * * system error numbers * + * $Id: os_errno.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -448,10 +450,6 @@ extern int t_errno; # define ECANCELED 125 #endif /* ECANCELED */ -#ifndef ESHUTDOWN -#define ESHUTDOWN ECANCELED -#endif - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/dep/acelite/ace/os_include/os_fcntl.h b/dep/acelite/ace/os_include/os_fcntl.h index 97cb355f7..bc3796a6b 100644 --- a/dep/acelite/ace/os_include/os_fcntl.h +++ b/dep/acelite/ace/os_include/os_fcntl.h @@ -6,6 +6,8 @@ * * file control options * + * $Id: os_fcntl.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_fenv.h b/dep/acelite/ace/os_include/os_fenv.h index e22f8e498..f5ee57482 100644 --- a/dep/acelite/ace/os_include/os_fenv.h +++ b/dep/acelite/ace/os_include/os_fenv.h @@ -6,6 +6,8 @@ * * floating-point environment * + * $Id: os_fenv.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_float.h b/dep/acelite/ace/os_include/os_float.h index f6539c59b..1cc45b675 100644 --- a/dep/acelite/ace/os_include/os_float.h +++ b/dep/acelite/ace/os_include/os_float.h @@ -6,6 +6,8 @@ * * floating types * + * $Id: os_float.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_fmtmsg.h b/dep/acelite/ace/os_include/os_fmtmsg.h index 0a6f7ae17..aa37b391c 100644 --- a/dep/acelite/ace/os_include/os_fmtmsg.h +++ b/dep/acelite/ace/os_include/os_fmtmsg.h @@ -6,6 +6,8 @@ * * message display structures * + * $Id: os_fmtmsg.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_fnmatch.h b/dep/acelite/ace/os_include/os_fnmatch.h index 932e826bd..d83fd12cc 100644 --- a/dep/acelite/ace/os_include/os_fnmatch.h +++ b/dep/acelite/ace/os_include/os_fnmatch.h @@ -6,6 +6,8 @@ * * filename-matching types * + * $Id: os_fnmatch.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_ftw.h b/dep/acelite/ace/os_include/os_ftw.h index c7d63a25e..df8a9ca59 100644 --- a/dep/acelite/ace/os_include/os_ftw.h +++ b/dep/acelite/ace/os_include/os_ftw.h @@ -6,6 +6,8 @@ * * file tree traversal * + * $Id: os_ftw.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_glob.h b/dep/acelite/ace/os_include/os_glob.h index e1dd8078e..9d1db790d 100644 --- a/dep/acelite/ace/os_include/os_glob.h +++ b/dep/acelite/ace/os_include/os_glob.h @@ -6,6 +6,8 @@ * * pathname pattern-matching types * + * $Id: os_glob.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_grp.h b/dep/acelite/ace/os_include/os_grp.h index 07d9ee1b6..b776e960f 100644 --- a/dep/acelite/ace/os_include/os_grp.h +++ b/dep/acelite/ace/os_include/os_grp.h @@ -6,6 +6,8 @@ * * group structure * + * $Id: os_grp.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_iconv.h b/dep/acelite/ace/os_include/os_iconv.h index 39f237e79..bf245e9a7 100644 --- a/dep/acelite/ace/os_include/os_iconv.h +++ b/dep/acelite/ace/os_include/os_iconv.h @@ -6,6 +6,8 @@ * * codeset conversion facility * + * $Id: os_iconv.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_ifaddrs.h b/dep/acelite/ace/os_include/os_ifaddrs.h index eacca0e06..80cc773eb 100644 --- a/dep/acelite/ace/os_include/os_ifaddrs.h +++ b/dep/acelite/ace/os_include/os_ifaddrs.h @@ -6,6 +6,8 @@ * * os_ifaddrs.h include * + * $Id: os_ifaddrs.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/os_intrin.h b/dep/acelite/ace/os_include/os_intrin.h index 9f31f1c09..37b669500 100644 --- a/dep/acelite/ace/os_include/os_intrin.h +++ b/dep/acelite/ace/os_include/os_intrin.h @@ -6,6 +6,8 @@ * * Intrinsic methods * + * $Id: os_intrin.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/os_inttypes.h b/dep/acelite/ace/os_include/os_inttypes.h index eca7c256e..570cbe5c5 100644 --- a/dep/acelite/ace/os_include/os_inttypes.h +++ b/dep/acelite/ace/os_include/os_inttypes.h @@ -6,6 +6,8 @@ * * fixed size integer types * + * $Id: os_inttypes.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_iso646.h b/dep/acelite/ace/os_include/os_iso646.h index 0ca2b7062..998b7e98e 100644 --- a/dep/acelite/ace/os_include/os_iso646.h +++ b/dep/acelite/ace/os_include/os_iso646.h @@ -6,6 +6,8 @@ * * alternative spellings * + * $Id: os_iso646.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_kstat.h b/dep/acelite/ace/os_include/os_kstat.h index 957b608bd..e311ccf56 100644 --- a/dep/acelite/ace/os_include/os_kstat.h +++ b/dep/acelite/ace/os_include/os_kstat.h @@ -4,6 +4,8 @@ /** * @file os_kstat.h * + * $Id: os_kstat.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/os_langinfo.h b/dep/acelite/ace/os_include/os_langinfo.h index 8af517369..e7274e844 100644 --- a/dep/acelite/ace/os_include/os_langinfo.h +++ b/dep/acelite/ace/os_include/os_langinfo.h @@ -6,6 +6,8 @@ * * language information constants * + * $Id: os_langinfo.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_libgen.h b/dep/acelite/ace/os_include/os_libgen.h index 97d5a8e03..db0027b24 100644 --- a/dep/acelite/ace/os_include/os_libgen.h +++ b/dep/acelite/ace/os_include/os_libgen.h @@ -6,6 +6,8 @@ * * definitions for pattern matching functions * + * $Id: os_libgen.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_limits.h b/dep/acelite/ace/os_include/os_limits.h index acb52890e..7fe6fa251 100644 --- a/dep/acelite/ace/os_include/os_limits.h +++ b/dep/acelite/ace/os_include/os_limits.h @@ -6,6 +6,8 @@ * * implementation-defined constants * + * $Id: os_limits.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_local.h b/dep/acelite/ace/os_include/os_local.h index 308527e89..2900be95b 100644 --- a/dep/acelite/ace/os_include/os_local.h +++ b/dep/acelite/ace/os_include/os_local.h @@ -6,6 +6,8 @@ * * category macros * + * $Id: os_local.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_math.h b/dep/acelite/ace/os_include/os_math.h index 7695cf8eb..ee2dc69f2 100644 --- a/dep/acelite/ace/os_include/os_math.h +++ b/dep/acelite/ace/os_include/os_math.h @@ -6,6 +6,8 @@ * * mathematical declarations * + * $Id: os_math.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_monetary.h b/dep/acelite/ace/os_include/os_monetary.h index fc99b4910..4fc2815ba 100644 --- a/dep/acelite/ace/os_include/os_monetary.h +++ b/dep/acelite/ace/os_include/os_monetary.h @@ -6,6 +6,8 @@ * * monetary types * + * $Id: os_monetary.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_mqueue.h b/dep/acelite/ace/os_include/os_mqueue.h index a834f7f4c..9577d9eb2 100644 --- a/dep/acelite/ace/os_include/os_mqueue.h +++ b/dep/acelite/ace/os_include/os_mqueue.h @@ -6,6 +6,8 @@ * * message queues (REALTIME) * + * $Id: os_mqueue.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_ndbm.h b/dep/acelite/ace/os_include/os_ndbm.h index e8a28ae91..7d934ec1f 100644 --- a/dep/acelite/ace/os_include/os_ndbm.h +++ b/dep/acelite/ace/os_include/os_ndbm.h @@ -6,6 +6,8 @@ * * definitions for ndbm database operations * + * $Id: os_ndbm.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_netdb.h b/dep/acelite/ace/os_include/os_netdb.h index 320e8f191..14a8e5d7f 100644 --- a/dep/acelite/ace/os_include/os_netdb.h +++ b/dep/acelite/ace/os_include/os_netdb.h @@ -6,6 +6,8 @@ * * definitions for network database operations * + * $Id: os_netdb.h 93359 2011-02-11 11:33:12Z mcorino $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -24,7 +26,6 @@ #include "ace/os_include/netinet/os_in.h" #include "ace/os_include/os_limits.h" -#include "ace/os_include/sys/os_socket.h" // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus @@ -64,55 +65,6 @@ struct servent { }; #endif /* ACE_LACKS_SERVENT */ -#ifdef ACE_LACKS_ADDRINFO - struct addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - ACE_SOCKET_LEN ai_addrlen; - sockaddr *ai_addr; - char *ai_canonname; - addrinfo *ai_next; - }; -#endif - -#ifndef AI_V4MAPPED -# define AI_V4MAPPED 0x8 -#endif - -#ifndef AI_ADDRCONFIG -# define AI_ADDRCONFIG 0x20 -#endif - -#ifndef EAI_NONAME -# define EAI_NONAME -2 /* Error result from getaddrinfo(): no addr for name */ -#endif - -#ifndef EAI_AGAIN -# define EAI_AGAIN -3 /* Error result from getaddrinfo(): try again later */ -#endif - -#ifndef EAI_FAIL -# define EAI_FAIL -4 /* Error result from getaddrinfo(): non-recoverable */ -#endif - -#ifndef EAI_FAMILY -# define EAI_FAMILY -6 /* Error result from getaddrinfo(): family not supp. */ -#endif - -#ifndef EAI_MEMORY -# define EAI_MEMORY -10 /* Error result from getaddrinfo(): out of memory */ -#endif - -#ifndef EAI_SYSTEM -# define EAI_SYSTEM -11 /* Error result from getaddrinfo(): see errno */ -#endif - -#ifndef EAI_OVERFLOW -# define EAI_OVERFLOW -12 /* Error result from getaddrinfo(): buffer overflow */ -#endif - #if defined (ACE_HAS_STRUCT_NETDB_DATA) typedef char ACE_HOSTENT_DATA[sizeof(struct hostent_data)]; typedef char ACE_SERVENT_DATA[sizeof(struct servent_data)]; diff --git a/dep/acelite/ace/os_include/os_nl_types.h b/dep/acelite/ace/os_include/os_nl_types.h index 604437138..bb199a107 100644 --- a/dep/acelite/ace/os_include/os_nl_types.h +++ b/dep/acelite/ace/os_include/os_nl_types.h @@ -6,6 +6,8 @@ * * data types * + * $Id: os_nl_types.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_pdh.h b/dep/acelite/ace/os_include/os_pdh.h index 96c77a99f..6eed83408 100644 --- a/dep/acelite/ace/os_include/os_pdh.h +++ b/dep/acelite/ace/os_include/os_pdh.h @@ -6,6 +6,8 @@ * * definitions for the windows pdh API * + * $Id: os_pdh.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/os_pdhmsg.h b/dep/acelite/ace/os_include/os_pdhmsg.h index 3ea606fa9..467f3c3bf 100644 --- a/dep/acelite/ace/os_include/os_pdhmsg.h +++ b/dep/acelite/ace/os_include/os_pdhmsg.h @@ -6,6 +6,8 @@ * * definitions for the windows pdh API * + * $Id: os_pdhmsg.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/os_poll.h b/dep/acelite/ace/os_include/os_poll.h index b1aad483e..9f491f79a 100644 --- a/dep/acelite/ace/os_include/os_poll.h +++ b/dep/acelite/ace/os_include/os_poll.h @@ -6,6 +6,8 @@ * * definitions for the poll() function * + * $Id: os_poll.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_pthread.h b/dep/acelite/ace/os_include/os_pthread.h index 6b2582b21..aef6fca29 100644 --- a/dep/acelite/ace/os_include/os_pthread.h +++ b/dep/acelite/ace/os_include/os_pthread.h @@ -6,6 +6,8 @@ * * threads * + * $Id: os_pthread.h 95761 2012-05-15 18:23:04Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -35,7 +37,6 @@ #endif /* ACE_HAS_PRIOCNTL */ #include "ace/os_include/sys/os_types.h" -#include "ace/os_include/os_stdint.h" // This needs to go here *first* to avoid problems with AIX. # if defined (ACE_HAS_PTHREADS) @@ -44,8 +45,11 @@ # undef ACE_DONT_INCLUDE_ACE_SIGNAL_H # endif /* ACE_HAS_PTHREADS */ + #if !defined (ACE_LACKS_PTHREAD_H) + extern "C" { # include /**/ + } #endif /* !ACE_LACKS_PTHREAD_H */ #if defined (ACE_HAS_PTHREAD_NP_H) @@ -337,7 +341,7 @@ public: # endif /* !ACE_HAS_POSIX_SEM */ # endif /* !ACE_HAS_STHREADS */ -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) && !defined (ACE_LACKS_RWLOCK_T) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) typedef pthread_rwlock_t ACE_rwlock_t; # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ diff --git a/dep/acelite/ace/os_include/os_pwd.h b/dep/acelite/ace/os_include/os_pwd.h index 7b98964fe..74817c45b 100644 --- a/dep/acelite/ace/os_include/os_pwd.h +++ b/dep/acelite/ace/os_include/os_pwd.h @@ -6,6 +6,8 @@ * * password structure * + * $Id: os_pwd.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_regex.h b/dep/acelite/ace/os_include/os_regex.h index 61f549245..338ac9d40 100644 --- a/dep/acelite/ace/os_include/os_regex.h +++ b/dep/acelite/ace/os_include/os_regex.h @@ -6,6 +6,8 @@ * * regular expression matching types * + * $Id: os_regex.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_sched.h b/dep/acelite/ace/os_include/os_sched.h index 7880bd3f1..f06541b8c 100644 --- a/dep/acelite/ace/os_include/os_sched.h +++ b/dep/acelite/ace/os_include/os_sched.h @@ -6,6 +6,8 @@ * * execution scheduling (REALTIME) * + * $Id: os_sched.h 85102 2009-04-17 14:04:36Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -37,7 +39,7 @@ extern "C" #if !defined (__cpu_set_t_defined) || !defined (ACE_HAS_CPU_SET_T) #if defined (ACE_HAS_CPUSET_T) typedef cpuset_t cpu_set_t; -#elif !defined (ACE_HAS_CPU_SET_T) +#else # define ACE_CPU_SETSIZE 1024 typedef struct { diff --git a/dep/acelite/ace/os_include/os_search.h b/dep/acelite/ace/os_include/os_search.h index 673b4d2fb..dc846aae8 100644 --- a/dep/acelite/ace/os_include/os_search.h +++ b/dep/acelite/ace/os_include/os_search.h @@ -6,6 +6,8 @@ * * search tables * + * $Id: os_search.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_semaphore.h b/dep/acelite/ace/os_include/os_semaphore.h index 98e5f2109..7fad7dafb 100644 --- a/dep/acelite/ace/os_include/os_semaphore.h +++ b/dep/acelite/ace/os_include/os_semaphore.h @@ -6,6 +6,8 @@ * * semaphores (REALTIME) * + * $Id: os_semaphore.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -50,11 +52,6 @@ extern "C" /// POSIX semaphore, else its an unnamed POSIX semaphore). char *name_; - /// Do not unlink the named semaphore. This lets the logical entity - /// of the semaphore outlive any one process that opens it. The semaphore - /// must be manually unlinked with ACE_OS::sema_unlink(). - bool avoid_unlink_; - # if defined (ACE_LACKS_NAMED_POSIX_SEM) /// this->sema_ doesn't always get created dynamically if a platform /// doesn't support named posix semaphores. We use this flag to diff --git a/dep/acelite/ace/os_include/os_setjmp.h b/dep/acelite/ace/os_include/os_setjmp.h index 7639aeb2c..2d347e678 100644 --- a/dep/acelite/ace/os_include/os_setjmp.h +++ b/dep/acelite/ace/os_include/os_setjmp.h @@ -6,6 +6,8 @@ * * stack environment declarations * + * $Id: os_setjmp.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_signal.h b/dep/acelite/ace/os_include/os_signal.h index f9d3d1f38..46e390289 100644 --- a/dep/acelite/ace/os_include/os_signal.h +++ b/dep/acelite/ace/os_include/os_signal.h @@ -6,6 +6,8 @@ * * signals * + * $Id: os_signal.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_spawn.h b/dep/acelite/ace/os_include/os_spawn.h index af6896837..64f84db20 100644 --- a/dep/acelite/ace/os_include/os_spawn.h +++ b/dep/acelite/ace/os_include/os_spawn.h @@ -6,6 +6,8 @@ * * spawn (ADVANCED REALTIME) * + * $Id: os_spawn.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_stdarg.h b/dep/acelite/ace/os_include/os_stdarg.h index c93ffb035..19dfc60cd 100644 --- a/dep/acelite/ace/os_include/os_stdarg.h +++ b/dep/acelite/ace/os_include/os_stdarg.h @@ -6,6 +6,8 @@ * * handle variable argument list * + * $Id: os_stdarg.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_stdbool.h b/dep/acelite/ace/os_include/os_stdbool.h index b4c1c141c..4fb257a6d 100644 --- a/dep/acelite/ace/os_include/os_stdbool.h +++ b/dep/acelite/ace/os_include/os_stdbool.h @@ -6,6 +6,8 @@ * * boolean type and values * + * $Id: os_stdbool.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_stddef.h b/dep/acelite/ace/os_include/os_stddef.h index 625a8a44f..6ea31640f 100644 --- a/dep/acelite/ace/os_include/os_stddef.h +++ b/dep/acelite/ace/os_include/os_stddef.h @@ -6,6 +6,8 @@ * * standard type definitions * + * $Id: os_stddef.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_stdint.h b/dep/acelite/ace/os_include/os_stdint.h index d2150b1db..53114e9ae 100644 --- a/dep/acelite/ace/os_include/os_stdint.h +++ b/dep/acelite/ace/os_include/os_stdint.h @@ -6,6 +6,8 @@ * * integer types * + * $Id: os_stdint.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -34,8 +36,7 @@ extern "C" // BSD style types #if defined (ACE_LACKS_SYS_TYPES_H) \ - || (defined (__GLIBC__) && !defined (_BSD_SOURCE)) \ - || defined (ACE_LACKS_BSD_TYPES) + || (defined (__GLIBC__) && !defined (_BSD_SOURCE)) typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; diff --git a/dep/acelite/ace/os_include/os_stdio.h b/dep/acelite/ace/os_include/os_stdio.h index c5a9bac41..fcaaa69f0 100644 --- a/dep/acelite/ace/os_include/os_stdio.h +++ b/dep/acelite/ace/os_include/os_stdio.h @@ -6,6 +6,8 @@ * * standard buffered input/output * + * $Id: os_stdio.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_stdlib.h b/dep/acelite/ace/os_include/os_stdlib.h index fbeec6809..293212871 100644 --- a/dep/acelite/ace/os_include/os_stdlib.h +++ b/dep/acelite/ace/os_include/os_stdlib.h @@ -6,6 +6,8 @@ * * standard library definitions * + * $Id: os_stdlib.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -23,7 +25,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/os_include/os_stddef.h" -#include "ace/os_include/os_stdint.h" #include "ace/os_include/sys/os_wait.h" #if defined (ACE_HAS_ALLOCA_H) diff --git a/dep/acelite/ace/os_include/os_string.h b/dep/acelite/ace/os_include/os_string.h index 3b6d34356..a74d7119f 100644 --- a/dep/acelite/ace/os_include/os_string.h +++ b/dep/acelite/ace/os_include/os_string.h @@ -6,6 +6,8 @@ * * string operations * + * $Id: os_string.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_strings.h b/dep/acelite/ace/os_include/os_strings.h index 3120adab2..ba258b08c 100644 --- a/dep/acelite/ace/os_include/os_strings.h +++ b/dep/acelite/ace/os_include/os_strings.h @@ -6,6 +6,8 @@ * * string operations * + * $Id: os_strings.h 80826 2008-03-04 14:51:23Z wotte $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_stropts.h b/dep/acelite/ace/os_include/os_stropts.h index 4ed4c4b44..3e347eff0 100644 --- a/dep/acelite/ace/os_include/os_stropts.h +++ b/dep/acelite/ace/os_include/os_stropts.h @@ -6,6 +6,8 @@ * * STREAMS interface (STREAMS) * + * $Id: os_stropts.h 97874 2014-09-08 12:10:55Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -87,18 +89,6 @@ extern "C" # define SIOCGIFADDR 0 # endif /* SIOCGIFADDR */ -# if !defined (SIOCGIFCONF) -# define SIOCGIFCONF 0 -# endif /* SIOCGIFCONF */ - -# if !defined (SIOCGIFFLAGS) -# define SIOCGIFFLAGS 0 -# endif /* SIOCGIFFLAGS */ - -# if !defined (SIOCGIFHWADDR) -# define SIOCGIFHWADDR 0 -# endif /* SIOCGIFHWADDR */ - # if !defined (ACE_HAS_STRBUF_T) struct strbuf { diff --git a/dep/acelite/ace/os_include/os_syslog.h b/dep/acelite/ace/os_include/os_syslog.h index 98e4ad935..c0bc75200 100644 --- a/dep/acelite/ace/os_include/os_syslog.h +++ b/dep/acelite/ace/os_include/os_syslog.h @@ -6,6 +6,8 @@ * * definitions for system error logging * + * $Id: os_syslog.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_tar.h b/dep/acelite/ace/os_include/os_tar.h index f24b9de38..47054e9b4 100644 --- a/dep/acelite/ace/os_include/os_tar.h +++ b/dep/acelite/ace/os_include/os_tar.h @@ -6,6 +6,8 @@ * * extended tar definitions * + * $Id: os_tar.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_termios.h b/dep/acelite/ace/os_include/os_termios.h index 59392d902..61e6988b4 100644 --- a/dep/acelite/ace/os_include/os_termios.h +++ b/dep/acelite/ace/os_include/os_termios.h @@ -6,6 +6,8 @@ * * define values for termios * + * $Id: os_termios.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_tgmath.h b/dep/acelite/ace/os_include/os_tgmath.h index 512ce9fa1..5f8c61392 100644 --- a/dep/acelite/ace/os_include/os_tgmath.h +++ b/dep/acelite/ace/os_include/os_tgmath.h @@ -6,6 +6,8 @@ * * type-generic macros * + * $Id: os_tgmath.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_time.h b/dep/acelite/ace/os_include/os_time.h index b6d613b7a..033ea26c5 100644 --- a/dep/acelite/ace/os_include/os_time.h +++ b/dep/acelite/ace/os_include/os_time.h @@ -6,6 +6,8 @@ * * time types * + * $Id: os_time.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_trace.h b/dep/acelite/ace/os_include/os_trace.h index 8668140e1..14a1ee1f4 100644 --- a/dep/acelite/ace/os_include/os_trace.h +++ b/dep/acelite/ace/os_include/os_trace.h @@ -6,6 +6,8 @@ * * tracing * + * $Id: os_trace.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_typeinfo.h b/dep/acelite/ace/os_include/os_typeinfo.h index 7f33a689b..c74b703da 100644 --- a/dep/acelite/ace/os_include/os_typeinfo.h +++ b/dep/acelite/ace/os_include/os_typeinfo.h @@ -6,6 +6,8 @@ * * definitions for the typeinfo file * + * $Id: os_typeinfo.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/os_ucontext.h b/dep/acelite/ace/os_include/os_ucontext.h index 086880336..4ba4430f2 100644 --- a/dep/acelite/ace/os_include/os_ucontext.h +++ b/dep/acelite/ace/os_include/os_ucontext.h @@ -6,6 +6,8 @@ * * user context * + * $Id: os_ucontext.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_ulimit.h b/dep/acelite/ace/os_include/os_ulimit.h index 5033bf6f1..e7256e19f 100644 --- a/dep/acelite/ace/os_include/os_ulimit.h +++ b/dep/acelite/ace/os_include/os_ulimit.h @@ -6,6 +6,8 @@ * * ulimit commands * + * $Id: os_ulimit.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_unistd.h b/dep/acelite/ace/os_include/os_unistd.h index 942a40c43..6c10ebf1e 100644 --- a/dep/acelite/ace/os_include/os_unistd.h +++ b/dep/acelite/ace/os_include/os_unistd.h @@ -6,6 +6,8 @@ * * standard symbolic constants and types * + * $Id: os_unistd.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_utime.h b/dep/acelite/ace/os_include/os_utime.h index 4d7e76279..4aa411998 100644 --- a/dep/acelite/ace/os_include/os_utime.h +++ b/dep/acelite/ace/os_include/os_utime.h @@ -6,6 +6,8 @@ * * access and modification times structure * + * $Id: os_utime.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_utmpx.h b/dep/acelite/ace/os_include/os_utmpx.h index 5c44e5e61..dd97c07dd 100644 --- a/dep/acelite/ace/os_include/os_utmpx.h +++ b/dep/acelite/ace/os_include/os_utmpx.h @@ -6,6 +6,8 @@ * * user accounting database definitions * + * $Id: os_utmpx.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_wchar.h b/dep/acelite/ace/os_include/os_wchar.h index 62280ad22..d215ab79e 100644 --- a/dep/acelite/ace/os_include/os_wchar.h +++ b/dep/acelite/ace/os_include/os_wchar.h @@ -6,6 +6,8 @@ * * wide-character handling * + * $Id: os_wchar.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_wctype.h b/dep/acelite/ace/os_include/os_wctype.h index 0a7140e79..c397ce8aa 100644 --- a/dep/acelite/ace/os_include/os_wctype.h +++ b/dep/acelite/ace/os_include/os_wctype.h @@ -6,6 +6,8 @@ * * wide-character classification and mapping utilities * + * $Id: os_wctype.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/os_wordexp.h b/dep/acelite/ace/os_include/os_wordexp.h index e4a2bd3c7..a82cbe1a4 100644 --- a/dep/acelite/ace/os_include/os_wordexp.h +++ b/dep/acelite/ace/os_include/os_wordexp.h @@ -6,6 +6,8 @@ * * word-expansion types * + * $Id: os_wordexp.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_ipc.h b/dep/acelite/ace/os_include/sys/os_ipc.h index ae9053a38..883f5d148 100644 --- a/dep/acelite/ace/os_include/sys/os_ipc.h +++ b/dep/acelite/ace/os_include/sys/os_ipc.h @@ -6,6 +6,8 @@ * * XSI interprocess communication access structure * + * $Id: os_ipc.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_loadavg.h b/dep/acelite/ace/os_include/sys/os_loadavg.h index 6437d7d92..7a675aac7 100644 --- a/dep/acelite/ace/os_include/sys/os_loadavg.h +++ b/dep/acelite/ace/os_include/sys/os_loadavg.h @@ -6,6 +6,8 @@ * * loadavg functions * + * $Id: os_loadavg.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/sys/os_mman.h b/dep/acelite/ace/os_include/sys/os_mman.h index 2f98bf4b7..f91f5b4a1 100644 --- a/dep/acelite/ace/os_include/sys/os_mman.h +++ b/dep/acelite/ace/os_include/sys/os_mman.h @@ -6,6 +6,8 @@ * * memory management declarations * + * $Id: os_mman.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_msg.h b/dep/acelite/ace/os_include/sys/os_msg.h index 83166e37b..c1b2c9a01 100644 --- a/dep/acelite/ace/os_include/sys/os_msg.h +++ b/dep/acelite/ace/os_include/sys/os_msg.h @@ -6,6 +6,8 @@ * * XSI message queue structures * + * $Id: os_msg.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_pstat.h b/dep/acelite/ace/os_include/sys/os_pstat.h index 377e83b2e..8b3da508e 100644 --- a/dep/acelite/ace/os_include/sys/os_pstat.h +++ b/dep/acelite/ace/os_include/sys/os_pstat.h @@ -6,6 +6,8 @@ * * pstat functions * + * $Id: os_pstat.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/sys/os_resource.h b/dep/acelite/ace/os_include/sys/os_resource.h index 437e2d6e4..ca44c88e1 100644 --- a/dep/acelite/ace/os_include/sys/os_resource.h +++ b/dep/acelite/ace/os_include/sys/os_resource.h @@ -6,6 +6,8 @@ * * definitions for XSI resource operations * + * $Id: os_resource.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_select.h b/dep/acelite/ace/os_include/sys/os_select.h index c9888613f..8cfced1f6 100644 --- a/dep/acelite/ace/os_include/sys/os_select.h +++ b/dep/acelite/ace/os_include/sys/os_select.h @@ -6,6 +6,8 @@ * * select types * + * $Id: os_select.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_sem.h b/dep/acelite/ace/os_include/sys/os_sem.h index 7efec988f..f11b8cab2 100644 --- a/dep/acelite/ace/os_include/sys/os_sem.h +++ b/dep/acelite/ace/os_include/sys/os_sem.h @@ -6,6 +6,8 @@ * * XSI semaphore facility * + * $Id: os_sem.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -23,7 +25,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/os_include/sys/os_ipc.h" -#include "ace/os_include/os_stdint.h" #if !defined (ACE_LACKS_SYS_SEM_H) # include /**/ diff --git a/dep/acelite/ace/os_include/sys/os_shm.h b/dep/acelite/ace/os_include/sys/os_shm.h index c74edab18..cb592fca6 100644 --- a/dep/acelite/ace/os_include/sys/os_shm.h +++ b/dep/acelite/ace/os_include/sys/os_shm.h @@ -6,6 +6,8 @@ * * XSI shared memory facility * + * $Id: os_shm.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_socket.h b/dep/acelite/ace/os_include/sys/os_socket.h index 19b0eadb7..a8bf06b94 100644 --- a/dep/acelite/ace/os_include/sys/os_socket.h +++ b/dep/acelite/ace/os_include/sys/os_socket.h @@ -6,6 +6,8 @@ * * main sockets header * + * $Id: os_socket.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_stat.h b/dep/acelite/ace/os_include/sys/os_stat.h index d179d5f95..77d246fff 100644 --- a/dep/acelite/ace/os_include/sys/os_stat.h +++ b/dep/acelite/ace/os_include/sys/os_stat.h @@ -6,6 +6,8 @@ * * data returned by the stat() function * + * $Id: os_stat.h 97491 2013-12-30 11:17:48Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_statvfs.h b/dep/acelite/ace/os_include/sys/os_statvfs.h index 7f274437a..fd9326450 100644 --- a/dep/acelite/ace/os_include/sys/os_statvfs.h +++ b/dep/acelite/ace/os_include/sys/os_statvfs.h @@ -6,6 +6,8 @@ * * VFS File System information structure * + * $Id: os_statvfs.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_sysctl.h b/dep/acelite/ace/os_include/sys/os_sysctl.h index 79c716ffc..a9b51c640 100644 --- a/dep/acelite/ace/os_include/sys/os_sysctl.h +++ b/dep/acelite/ace/os_include/sys/os_sysctl.h @@ -6,6 +6,8 @@ * * declarations for sysctl * + * $Id: os_sysctl.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/sys/os_sysinfo.h b/dep/acelite/ace/os_include/sys/os_sysinfo.h index 95b595ff2..fef29fd81 100644 --- a/dep/acelite/ace/os_include/sys/os_sysinfo.h +++ b/dep/acelite/ace/os_include/sys/os_sysinfo.h @@ -4,6 +4,8 @@ /** * @file os_sysinfo.h * + * $Id: os_sysinfo.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Johnny Willemsen */ //============================================================================= diff --git a/dep/acelite/ace/os_include/sys/os_time.h b/dep/acelite/ace/os_include/sys/os_time.h index ec981cdc1..f2141d048 100644 --- a/dep/acelite/ace/os_include/sys/os_time.h +++ b/dep/acelite/ace/os_include/sys/os_time.h @@ -6,6 +6,8 @@ * * time types * + * $Id: os_time.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_timeb.h b/dep/acelite/ace/os_include/sys/os_timeb.h index 59177fc74..47dc36932 100644 --- a/dep/acelite/ace/os_include/sys/os_timeb.h +++ b/dep/acelite/ace/os_include/sys/os_timeb.h @@ -6,6 +6,8 @@ * * additional definitions for date and time * + * $Id: os_timeb.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_times.h b/dep/acelite/ace/os_include/sys/os_times.h index 3e2313ba0..77ce9fa08 100644 --- a/dep/acelite/ace/os_include/sys/os_times.h +++ b/dep/acelite/ace/os_include/sys/os_times.h @@ -6,6 +6,8 @@ * * file access and modification times structure * + * $Id: os_times.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_types.h b/dep/acelite/ace/os_include/sys/os_types.h index 60a425b92..4fa5fac4a 100644 --- a/dep/acelite/ace/os_include/sys/os_types.h +++ b/dep/acelite/ace/os_include/sys/os_types.h @@ -6,6 +6,8 @@ * * data types * + * $Id: os_types.h 97939 2014-10-27 12:30:12Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ @@ -74,7 +76,7 @@ typedef double ACE_timer_t; typedef offset_t ACE_LOFF_T; #elif defined (WIN32) typedef __int64 ACE_LOFF_T; -#elif (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x700)) || \ +#elif (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x690)) || \ defined (ACE_LYNXOS_MAJOR) || \ (defined (ACE_OPENVMS) && !defined (_LARGEFILE)) || \ defined (__TANDEM) diff --git a/dep/acelite/ace/os_include/sys/os_uio.h b/dep/acelite/ace/os_include/sys/os_uio.h index 39343824b..a771ad1c9 100644 --- a/dep/acelite/ace/os_include/sys/os_uio.h +++ b/dep/acelite/ace/os_include/sys/os_uio.h @@ -6,6 +6,8 @@ * * definitions for vector I/O operations * + * $Id: os_uio.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_un.h b/dep/acelite/ace/os_include/sys/os_un.h index 4459c009e..dad04646a 100644 --- a/dep/acelite/ace/os_include/sys/os_un.h +++ b/dep/acelite/ace/os_include/sys/os_un.h @@ -6,6 +6,8 @@ * * definitions for UNIX domain sockets * + * $Id: os_un.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_utsname.h b/dep/acelite/ace/os_include/sys/os_utsname.h index d0201507d..95e3f7c7a 100644 --- a/dep/acelite/ace/os_include/sys/os_utsname.h +++ b/dep/acelite/ace/os_include/sys/os_utsname.h @@ -6,6 +6,8 @@ * * system name structure * + * $Id: os_utsname.h 97827 2014-08-02 17:34:32Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/os_include/sys/os_wait.h b/dep/acelite/ace/os_include/sys/os_wait.h index eef8b801e..be5347ef0 100644 --- a/dep/acelite/ace/os_include/sys/os_wait.h +++ b/dep/acelite/ace/os_include/sys/os_wait.h @@ -6,6 +6,8 @@ * * declarations for waiting * + * $Id: os_wait.h 97262 2013-08-09 08:32:10Z johnnyw $ + * * @author Don Hinton * @author This code was originally in various places including ace/OS.h. */ diff --git a/dep/acelite/ace/post.h b/dep/acelite/ace/post.h index bea9b56ef..e78627744 100644 --- a/dep/acelite/ace/post.h +++ b/dep/acelite/ace/post.h @@ -4,6 +4,8 @@ /** * @file post.h * + * $Id: post.h 97602 2014-02-19 20:24:30Z johnnyw $ + * * @author Christopher Kohlhoff * * This file restores the original alignment rules. @@ -15,7 +17,7 @@ # pragma pack (pop) #elif defined (__BORLANDC__) # pragma option pop -# if (__BORLANDC__ >= 0x660) && (__BORLANDC__ <= 0x730) +# if (__BORLANDC__ >= 0x660) && (__BORLANDC__ <= 0x680) # pragma option pop # endif # pragma nopushoptwarn diff --git a/dep/acelite/ace/pre.h b/dep/acelite/ace/pre.h index ccb8c553b..dc4aef9ac 100644 --- a/dep/acelite/ace/pre.h +++ b/dep/acelite/ace/pre.h @@ -4,6 +4,8 @@ /** * @file pre.h * + * $Id: pre.h 97602 2014-02-19 20:24:30Z johnnyw $ + * * @author Christopher Kohlhoff * * This file saves the original alignment rules and changes the alignment @@ -17,7 +19,7 @@ # pragma pack (push, 8) #elif defined (__BORLANDC__) # pragma option push -a8 -b -Ve- -Vx- -w-rvl -w-rch -w-ccc -w-obs -w-aus -w-pia -w-inl -w-sig -# if (__BORLANDC__ >= 0x660) && (__BORLANDC__ <= 0x730) +# if (__BORLANDC__ >= 0x660) && (__BORLANDC__ <= 0x680) // False warning: Function defined with different linkage, reported to // Embarcadero as QC 117740 # pragma option push -w-8127 diff --git a/dep/acelite/ace/streams.h b/dep/acelite/ace/streams.h index 8a6577eeb..396a67c71 100644 --- a/dep/acelite/ace/streams.h +++ b/dep/acelite/ace/streams.h @@ -4,6 +4,8 @@ /** * @file streams.h * + * $Id: streams.h 82445 2008-07-28 13:40:01Z johnnyw $ + * * @author Irfan Pyarali * * This file contains the portability ugliness for the Standard C++ @@ -11,6 +13,8 @@ * will need to be updated. * * This files deals with the streams includes. + * + * */ //============================================================================= diff --git a/dep/acelite/ace/svc_export.h b/dep/acelite/ace/svc_export.h index f0e8e1db2..18cf3a24c 100644 --- a/dep/acelite/ace/svc_export.h +++ b/dep/acelite/ace/svc_export.h @@ -1,4 +1,5 @@ // -*- C++ -*- +// $Id: svc_export.h 84495 2009-02-17 17:44:31Z johnnyw $ // Definition for Win32 Export directives. // This file was generated by generate_export_file.pl diff --git a/dep/bzip2/CMakeLists.txt b/dep/bzip2/CMakeLists.txt index e9a429411..d7da81449 100644 --- a/dep/bzip2/CMakeLists.txt +++ b/dep/bzip2/CMakeLists.txt @@ -1,24 +1,3 @@ -project(bzip2 VERSION 1.0.6) +file(GLOB sources_bzip2 ./*.c) -add_library(bzip2 - blocksort.c - bzlib.c - compress.c - crctable.c - decompress.c - huffman.c - randtable.c - bzlib.h - bzlib_private.h -) - -add_library(BZip2::BZip2 ALIAS bzip2) - -target_include_directories(bzip2 - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}) - -target_compile_definitions(bzip2 - PUBLIC - BZ_STRICT_ANSI -) +add_library(bzip2 ${sources_bzip2}) diff --git a/dep/bzip2/blocksort.c b/dep/bzip2/blocksort.c index d0d662cd4..bd2dec157 100644 --- a/dep/bzip2/blocksort.c +++ b/dep/bzip2/blocksort.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/bzlib.c b/dep/bzip2/bzlib.c index bd358a793..245c3b8a0 100644 --- a/dep/bzip2/bzlib.c +++ b/dep/bzip2/bzlib.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -1375,7 +1375,8 @@ const char * BZ_API(BZ2_bzlibVersion)(void) #if defined(_WIN32) || defined(OS2) || defined(MSDOS) # include # include -# define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY) +# define SET_BINARY_MODE(file) _setmode(_fileno(file),O_BINARY) +# define fdopen(fd, mode) _fdopen((fd), (mode)) #else # define SET_BINARY_MODE(file) #endif diff --git a/dep/bzip2/bzlib.h b/dep/bzip2/bzlib.h index 8277123da..c5b75d6d8 100644 --- a/dep/bzip2/bzlib.h +++ b/dep/bzip2/bzlib.h @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/bzlib_private.h b/dep/bzip2/bzlib_private.h index 5d0217f46..23427879b 100644 --- a/dep/bzip2/bzlib_private.h +++ b/dep/bzip2/bzlib_private.h @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -36,7 +36,7 @@ /*-- General stuff. --*/ -#define BZ_VERSION "1.0.6, 6-Sept-2010" +#define BZ_VERSION "1.0.5, 10-Dec-2007" typedef char Char; typedef unsigned char Bool; diff --git a/dep/bzip2/compress.c b/dep/bzip2/compress.c index caf769601..8c80a0797 100644 --- a/dep/bzip2/compress.c +++ b/dep/bzip2/compress.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/crctable.c b/dep/bzip2/crctable.c index 1fea7e946..215687b2c 100644 --- a/dep/bzip2/crctable.c +++ b/dep/bzip2/crctable.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/decompress.c b/dep/bzip2/decompress.c index 311f5668f..bba5e0fa3 100644 --- a/dep/bzip2/decompress.c +++ b/dep/bzip2/decompress.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -381,13 +381,6 @@ Int32 BZ2_decompress ( DState* s ) es = -1; N = 1; do { - /* Check that N doesn't get too big, so that es doesn't - go negative. The maximum value that can be - RUNA/RUNB encoded is equal to the block size (post - the initial RLE), viz, 900k, so bounding N at 2 - million should guard against overflow without - rejecting any legitimate inputs. */ - if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR); if (nextSym == BZ_RUNA) es = es + (0+1) * N; else if (nextSym == BZ_RUNB) es = es + (1+1) * N; N = N * 2; @@ -492,28 +485,15 @@ Int32 BZ2_decompress ( DState* s ) RETURN(BZ_DATA_ERROR); /*-- Set up cftab to facilitate generation of T^(-1) --*/ - /* Check: unzftab entries in range. */ - for (i = 0; i <= 255; i++) { - if (s->unzftab[i] < 0 || s->unzftab[i] > nblock) - RETURN(BZ_DATA_ERROR); - } - /* Actually generate cftab. */ s->cftab[0] = 0; for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; - /* Check: cftab entries in range. */ for (i = 0; i <= 256; i++) { if (s->cftab[i] < 0 || s->cftab[i] > nblock) { /* s->cftab[i] can legitimately be == nblock */ RETURN(BZ_DATA_ERROR); } } - /* Check: cftab entries non-descending. */ - for (i = 1; i <= 256; i++) { - if (s->cftab[i-1] > s->cftab[i]) { - RETURN(BZ_DATA_ERROR); - } - } s->state_out_len = 0; s->state_out_ch = 0; diff --git a/dep/bzip2/huffman.c b/dep/bzip2/huffman.c index 2283fdbc5..87e79e38a 100644 --- a/dep/bzip2/huffman.c +++ b/dep/bzip2/huffman.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/bzip2/randtable.c b/dep/bzip2/randtable.c index 6d6245990..068b76367 100644 --- a/dep/bzip2/randtable.c +++ b/dep/bzip2/randtable.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward + bzip2/libbzip2 version 1.0.5 of 10 December 2007 + Copyright (C) 1996-2007 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/dep/g3dlite/CMakeLists.txt b/dep/g3dlite/CMakeLists.txt index 9628cf222..e4b090f4e 100644 --- a/dep/g3dlite/CMakeLists.txt +++ b/dep/g3dlite/CMakeLists.txt @@ -14,7 +14,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -add_library(g3dlite STATIC +set(LIBRARY_NAME g3dlite) + +set(LIBRARY_SRCS G3D/AABox.cpp G3D/Any.cpp G3D/BinaryFormat.cpp @@ -59,11 +61,17 @@ add_library(g3dlite STATIC G3D/uint128.cpp ) -target_link_libraries(g3dlite - PRIVATE - ZLIB::ZLIB +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_SOURCE_DIR}/dep/zlib" ) -target_include_directories(g3dlite - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +add_library(${LIBRARY_NAME} STATIC + ${LIBRARY_SRCS} ) + +if(WIN32) + target_link_libraries(${LIBRARY_NAME} + zlib + ) +endif() diff --git a/dep/g3dlite/G3D/AtomicInt32.h b/dep/g3dlite/G3D/AtomicInt32.h index bfcb881de..2d63f9983 100644 --- a/dep/g3dlite/G3D/AtomicInt32.h +++ b/dep/g3dlite/G3D/AtomicInt32.h @@ -73,9 +73,7 @@ public: # if defined(G3D_WIN32) return InterlockedExchangeAdd(&m_value, x); -# elif defined(__arm__) - return __sync_fetch_and_add(&m_value, 1); # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) int32 old; @@ -116,12 +114,8 @@ public: # if defined(G3D_WIN32) // Note: returns the newly decremented value return InterlockedDecrement(&m_value); -# elif defined(__arm__) - - return __sync_sub_and_fetch(&m_value, 1); - # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) - unsigned char nz; + unsigned char nz; asm volatile ("lock; decl %1;\n\t" "setnz %%al" @@ -148,8 +142,6 @@ public: int32 compareAndSet(const int32 comperand, const int32 exchange) { # if defined(G3D_WIN32) return InterlockedCompareExchange(&m_value, exchange, comperand); -# elif defined(__arm__) - return __sync_val_compare_and_swap(&m_value, comperand, exchange); # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) || defined(G3D_OSX) // Based on Apache Portable Runtime // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx diff --git a/dep/g3dlite/G3D/BinaryInput.cpp b/dep/g3dlite/G3D/BinaryInput.cpp index f1613dc19..d7de47d1d 100644 --- a/dep/g3dlite/G3D/BinaryInput.cpp +++ b/dep/g3dlite/G3D/BinaryInput.cpp @@ -38,7 +38,7 @@ #include "G3D/fileutils.h" #include "G3D/Log.h" #include "G3D/FileSystem.h" -#include "zlib.h" +#include #if _HAVE_ZIP /* G3DFIX: Use ZIP-library only if defined */ #include "zip.h" #endif /* G3DFIX: Use ZIP-library only if defined */ diff --git a/dep/g3dlite/G3D/CollisionDetection.cpp b/dep/g3dlite/G3D/CollisionDetection.cpp index 3824717d5..198602fa7 100644 --- a/dep/g3dlite/G3D/CollisionDetection.cpp +++ b/dep/g3dlite/G3D/CollisionDetection.cpp @@ -885,7 +885,7 @@ float CollisionDetection::collisionTimeForMovingPointFixedPlane( } } -bool CollisionDetection::rayAABox( +bool __fastcall CollisionDetection::rayAABox( const Ray& ray, const Vector3& invDir, const AABox& box, diff --git a/dep/g3dlite/G3D/CollisionDetection.h b/dep/g3dlite/G3D/CollisionDetection.h index 3c1289b9e..cda438a73 100644 --- a/dep/g3dlite/G3D/CollisionDetection.h +++ b/dep/g3dlite/G3D/CollisionDetection.h @@ -653,7 +653,7 @@ public: @return True if the ray hits the box */ - static bool rayAABox( + static bool __fastcall rayAABox( const Ray& ray, const Vector3& invDir, const AABox& box, diff --git a/dep/g3dlite/G3D/Intersect.cpp b/dep/g3dlite/G3D/Intersect.cpp index b1dd30574..f2f7580da 100644 --- a/dep/g3dlite/G3D/Intersect.cpp +++ b/dep/g3dlite/G3D/Intersect.cpp @@ -25,7 +25,7 @@ namespace G3D { #pragma float_control( precise, off ) #endif -bool Intersect::rayAABox(const Ray& ray, const AABox& box) { +bool __fastcall Intersect::rayAABox(const Ray& ray, const AABox& box) { switch (ray.classification) { case Ray::MMM: @@ -331,7 +331,7 @@ bool Intersect::rayAABox(const Ray& ray, const AABox& box) { } -bool Intersect::rayAABox(const Ray& ray, const AABox& box, float& time) { +bool __fastcall Intersect::rayAABox(const Ray& ray, const AABox& box, float& time) { switch (ray.classification) { case Ray::MMM: diff --git a/dep/g3dlite/G3D/Intersect.h b/dep/g3dlite/G3D/Intersect.h index dff771b03..cc841d650 100644 --- a/dep/g3dlite/G3D/Intersect.h +++ b/dep/g3dlite/G3D/Intersect.h @@ -34,7 +34,7 @@ public: Computer Graphics Lab, TU Braunschweig, Germany and University of Koblenz-Landau, Germany */ - static bool rayAABox(const Ray& ray, const AABox& box); + static bool __fastcall rayAABox(const Ray& ray, const AABox& box); /** \brief Returns true if the intersection of the ray and the solid box is non-empty. @@ -47,7 +47,7 @@ public: Computer Graphics Lab, TU Braunschweig, Germany and University of Koblenz-Landau, Germany */ - static bool rayAABox(const Ray& ray, const AABox& box, float& time); + static bool __fastcall rayAABox(const Ray& ray, const AABox& box, float& time); }; } diff --git a/dep/g3dlite/G3D/System.cpp b/dep/g3dlite/G3D/System.cpp index 5f160b7fa..d6877da82 100644 --- a/dep/g3dlite/G3D/System.cpp +++ b/dep/g3dlite/G3D/System.cpp @@ -531,11 +531,7 @@ static bool checkForCPUID() { // add cases for incompatible architectures if they are added // e.g., if we ever support __powerpc__ being defined again -#if defined(__arm__) - return false; -#else - return true; -#endif + return true; } @@ -1740,15 +1736,6 @@ void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, ui edx = 0; } -#elif defined(G3D_LINUX) && defined(__arm__) -// non-x86 CPU; no CPUID, at least in userspace -void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, uint32& edx) { - eax = 0; - ebx = 0; - ecx = 0; - edx = 0; -} - #else // See http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well diff --git a/dep/g3dlite/G3D/Vector3.h b/dep/g3dlite/G3D/Vector3.h index 3fd911864..e7a5e696b 100644 --- a/dep/g3dlite/G3D/Vector3.h +++ b/dep/g3dlite/G3D/Vector3.h @@ -103,7 +103,7 @@ public: // WARNING. These member functions rely on // (1) Vector3 not having virtual functions // (2) the data packed in a 3*sizeof(float) memory block - const float& operator[] (int i) const; + const float& __fastcall operator[] (int i) const; float& operator[] (int i); enum Axis {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, DETECT_AXIS=-1}; @@ -115,7 +115,7 @@ public: Axis primaryAxis() const; // assignment and comparison - Vector3& operator= (const Vector3& rkVector); + Vector3& __fastcall operator= (const Vector3& rkVector); bool operator== (const Vector3& rkVector) const; bool operator!= (const Vector3& rkVector) const; size_t hashCode() const; @@ -132,25 +132,25 @@ public: bool isUnit() const; // arithmetic operations - Vector3 operator+ (const Vector3& v) const; - Vector3 operator- (const Vector3& v) const; - Vector3 operator* (float s) const; - inline Vector3 operator/ (float s) const { + Vector3 __fastcall operator+ (const Vector3& v) const; + Vector3 __fastcall operator- (const Vector3& v) const; + Vector3 __fastcall operator* (float s) const; + inline Vector3 __fastcall operator/ (float s) const { return *this * (1.0f / s); } - Vector3 operator* (const Vector3& v) const; - Vector3 operator/ (const Vector3& v) const; - Vector3 operator- () const; + Vector3 __fastcall operator* (const Vector3& v) const; + Vector3 __fastcall operator/ (const Vector3& v) const; + Vector3 __fastcall operator- () const; // arithmetic updates - Vector3& operator+= (const Vector3& v); - Vector3& operator-= (const Vector3& v); - Vector3& operator*= (float s); - inline Vector3& operator/= (float s) { + Vector3& __fastcall operator+= (const Vector3& v); + Vector3& __fastcall operator-= (const Vector3& v); + Vector3& __fastcall operator*= (float s); + inline Vector3& __fastcall operator/= (float s) { return (*this *= (1.0f / s)); } - Vector3& operator*= (const Vector3& v); - Vector3& operator/= (const Vector3& v); + Vector3& __fastcall operator*= (const Vector3& v); + Vector3& __fastcall operator/= (const Vector3& v); /** Same as magnitude */ float length() const; @@ -266,14 +266,14 @@ public: float squaredMagnitude () const; - float dot(const Vector3& rkVector) const; + float __fastcall dot(const Vector3& rkVector) const; float unitize(float tolerance = 1e-06); /** Cross product. Note that two cross products in a row can be computed more cheaply: v1 x (v2 x v3) = (v1 dot v3) v2 - (v1 dot v2) v3. */ - Vector3 cross(const Vector3& rkVector) const; + Vector3 __fastcall cross(const Vector3& rkVector) const; Vector3 unitCross(const Vector3& rkVector) const; /** @@ -286,8 +286,8 @@ public: */ class Matrix3 cross() const; - Vector3 min(const Vector3 &v) const; - Vector3 max(const Vector3 &v) const; + Vector3 __fastcall min(const Vector3 &v) const; + Vector3 __fastcall max(const Vector3 &v) const; /** Smallest element */ inline float min() const { diff --git a/dep/g3dlite/G3D/g3dmath.h b/dep/g3dlite/G3D/g3dmath.h index 47614765c..4d5a9b7b6 100644 --- a/dep/g3dlite/G3D/g3dmath.h +++ b/dep/g3dlite/G3D/g3dmath.h @@ -61,7 +61,7 @@ namespace G3D { #ifdef _MSC_VER -inline double drand48() { +inline double __fastcall drand48() { return ::rand() / double(RAND_MAX); } diff --git a/dep/g3dlite/G3D/platform.h b/dep/g3dlite/G3D/platform.h index 16cfaabfe..ae3d2949f 100644 --- a/dep/g3dlite/G3D/platform.h +++ b/dep/g3dlite/G3D/platform.h @@ -44,6 +44,14 @@ #define G3D_WINSOCK_MAJOR_VERSION 2 #define G3D_WINSOCK_MINOR_VERSION 0 +#ifndef _MSC_VER +/// Fast call is a register-based optimized calling convention supported only by Visual C++ +#ifdef __FreeBSD__ +#undef __fastcall +#endif +#define __fastcall +#endif + #ifdef _MSC_VER #define G3D_WIN32 #elif defined(__FreeBSD__) || defined(__OpenBSD__) @@ -265,9 +273,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {\ # ifndef __stdcall # define __stdcall # endif -# elif defined(__arm__) - // CDECL does not apply to arm. -# define __cdecl # endif // calling conventions /** @def G3D_CHECK_PRINTF_METHOD_ARGS() diff --git a/dep/g3dlite_Notes.txt b/dep/g3dlite_Notes.txt new file mode 100644 index 000000000..be74591ff --- /dev/null +++ b/dep/g3dlite_Notes.txt @@ -0,0 +1,3 @@ +The default files for G3DLITE were ammended in commit: + +https://github.com/mangos/mangosDeps/commit/e135e5971c9588258174c37ce544991374a17562 \ No newline at end of file diff --git a/dep/gsoap/CMakeLists.txt b/dep/gsoap/CMakeLists.txt index 59e2059c4..d8ccc2bfd 100644 --- a/dep/gsoap/CMakeLists.txt +++ b/dep/gsoap/CMakeLists.txt @@ -14,15 +14,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -add_library(gsoap STATIC - soapC.cpp - soapServer.cpp - stdsoap2.cpp - soapH.h - soapStub.h - stdsoap2.h +set(LIBRARY_NAME gsoap) + +file(GLOB_RECURSE GSOAP_LIBRARY_SRCS *.cpp *.h) + +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}" + # Used to get access to config.h + "${CMAKE_BINARY_DIR}" ) -target_include_directories(gsoap - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} -) +add_library(${LIBRARY_NAME} STATIC ${GSOAP_LIBRARY_SRCS}) diff --git a/dep/libmpq/.gitignore b/dep/libmpq/.gitignore index ee7b95b83..b038a7024 100644 --- a/dep/libmpq/.gitignore +++ b/dep/libmpq/.gitignore @@ -1,13 +1,20 @@ -# -# NOTE! Don't add files that are generated in specific -# subdirectories here. Add them in the ".gitignore" file -# in that subdirectory instead. -# -# NOTE! Please use 'git-ls-files -i --exclude-standard' -# command after changing this file, to see if there are -# any tracked files which get ignored after the change. -# -# MaNGOS generated files at Windows build -# - bin +Makefile +Makefile.in +aclocal.m4 +config.guess +config.h +config.h.in +config.status +config.sub +configure +install-sh +libmpq-config +libmpq.pc +libmpq/.libs/ +libmpq/libmpq.la +libtool +ltmain.sh +missing +py-compile +stamp-h1 diff --git a/dep/libmpq/CMakeLists.txt b/dep/libmpq/CMakeLists.txt index 34264fb9d..1bfd853ce 100644 --- a/dep/libmpq/CMakeLists.txt +++ b/dep/libmpq/CMakeLists.txt @@ -1,7 +1,7 @@ # MaNGOS is a full featured server for World of Warcraft, supporting # the following clients: 1.12.x, 2.4.3, 3.2.5a, 4.2.3 and 5.4.8 # -# Copyright (C) 2005-2020 MaNGOS +# Copyright (C) 2005-2019 MaNGOS project # # ***** BEGIN GPL LICENSE BLOCK ***** # @@ -24,59 +24,59 @@ # World of Warcraft, and all World of Warcraft or Warcraft art, images, # and lore are copyrighted by Blizzard Entertainment, Inc. -#project(libmpq VERSION 0.4.2) +file(GLOB sources_mpq libmpq/*.c libmpq/*.h) +set(mpq_STAT_SRCS + ${sources_mpq} +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/dep/zlib + ${CMAKE_SOURCE_DIR}/dep/bzip2 +) + +if( WIN32 ) + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/win + ) +endif() + +#Configure libmpq, without using it's ./configure etc. include(CheckIncludeFiles) include(CheckFunctionExists) -check_include_files(dlfcn.h HAVE_DLFCN_H) -check_include_files(inttypes.h HAVE_INTTYPES_H) -check_include_files(memory.h HAVE_MEMORY_H) -check_include_files(stdint.h HAVE_STDINT_H) -check_include_files(stdlib.h HAVE_STDLIB_H) -check_include_files(strings.h HAVE_STRINGS_H) -check_include_files(string.h HAVE_STRING_H) -check_include_files(sys/stat.h HAVE_SYS_STAT_H) -check_include_files(sys/types.h HAVE_SYS_TYPES_H) -check_include_files(unistd.h HAVE_UNISTD_H) -check_function_exists(fseeko HAVE_FSEEKO) - -set(STDC_HEADERS 1) +#check_include_files(dlfcn.h HAVE_DLFCN_H) +#check_function_exists(fseeko HAVE_FSEEKO) +#check_include_files(inttypes.h HAVE_INTTYPES_H) set(HAVE_LIBBZ2 1) set(HAVE_LIBZ 1) +#check_include_files(memory.h HAVE_MEMORY_H) +#check_include_files(stdint.h HAVE_STDINT_H) +#check_include_files(stdlib.h HAVE_STDLIB_H) +#check_include_files(strings.h HAVE_STRINGS_H) +#check_include_files(string.h HAVE_STRING_H) +#check_include_files(sys/stat.h HAVE_SYS_STAT_H) +#check_include_files(sys/types.h HAVE_SYS_TYPES_H) +#check_include_files(unistd.h HAVE_UNISTD_H) + +#Taken from https://github.com/jonathanslenders/fluidsynth/blob/master/cmake_admin/CheckSTDC.cmake +#check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" StandardHeadersExist) +if (StandardHeadersExist) + set(STDC_HEADERS 1) +else() + set(STDC_HEADERS 0) +endif() set(LIBMPQ_PACKAGE_VERSION "0.4.2") set(LIBMPQ_PACKAGE_NAME "libmpq") -configure_file(libmpq/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h) -add_library(libmpq STATIC - libmpq/common.c - libmpq/common.h - libmpq/crypt_buf.h - libmpq/explode.c - libmpq/explode.h - libmpq/extract.c - libmpq/extract.h - libmpq/huffman.c - libmpq/huffman.h - libmpq/mpq-internal.h - libmpq/mpq.c - libmpq/mpq.h - libmpq/platform.h - libmpq/wave.c - libmpq/wave.h - ${CMAKE_CURRENT_BINARY_DIR}/config.h -) +#Add the library +add_library(libmpq STATIC ${mpq_STAT_SRCS}) -target_include_directories(libmpq - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) +include_directories( ${ZLIB_INCLUDE_DIRS} ) +target_link_libraries(libmpq ${ZLIB_LIBRARIES} bzip2) -target_link_libraries(libmpq - PRIVATE - ZLIB::ZLIB - BZip2::BZip2 -) +set_target_properties(libmpq PROPERTIES LINKER_LANGUAGE CXX) diff --git a/dep/libmpq/INSTALL b/dep/libmpq/INSTALL new file mode 100644 index 000000000..b42a17ac4 --- /dev/null +++ b/dep/libmpq/INSTALL @@ -0,0 +1,182 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. diff --git a/dep/libmpq/autogen.sh b/dep/libmpq/autogen.sh old mode 100755 new mode 100644 diff --git a/dep/libmpq/bindings/python/mpq-info b/dep/libmpq/bindings/python/mpq-info old mode 100755 new mode 100644 diff --git a/dep/libmpq/win/config.h b/dep/libmpq/config.h.cmake similarity index 68% rename from dep/libmpq/win/config.h rename to dep/libmpq/config.h.cmake index 683349462..b039f4181 100644 --- a/dep/libmpq/win/config.h +++ b/dep/libmpq/config.h.cmake @@ -2,74 +2,79 @@ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 +#cmakedefine HAVE_DLFCN_H 1 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ -#define HAVE_FSEEKO 1 +#cmakedefine HAVE_FSEEKO 1 /* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 +#cmakedefine HAVE_INTTYPES_H 1 /* Define to 1 if you have the `bz2' library (-lbz2). */ -#define HAVE_LIBBZ2 1 +#cmakedefine HAVE_LIBBZ2 1 /* Define to 1 if you have the `z' library (-lz). */ -#define HAVE_LIBZ 1 +#cmakedefine HAVE_LIBZ 1 /* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 +#cmakedefine HAVE_MEMORY_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 +#cmakedefine HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 +#cmakedefine HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 +#cmakedefine HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 +#cmakedefine HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 +#cmakedefine HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 +#cmakedefine HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 0 +#cmakedefine HAVE_UNISTD_H 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ -#define PACKAGE "libmpq" +#define PACKAGE "@LIBMPQ_PACKAGE_NAME@" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "mbroemme@plusserver.de" /* Define to the full name of this package. */ -#define PACKAGE_NAME "libmpq" +#define PACKAGE_NAME "@LIBMPQ_PACKAGE_NAME@" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libmpq 0.4.2" +#define PACKAGE_STRING "@LIBMPQ_PACKAGE_NAME@ @LIBMPQ_PACKAGE_VERSION@" /* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "libmpq" +#define PACKAGE_TARNAME "@LIBMPQ_PACKAGE_NAME@" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.4.2" +#define PACKAGE_VERSION "@LIBMPQ_PACKAGE_VERSION@" /* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 +#cmakedefine STDC_HEADERS 1 /* Version number of package */ -#define VERSION "0.4.2" +#define VERSION "@LIBMPQ_PACKAGE_VERSION@" + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ diff --git a/dep/libmpq/debian/rules b/dep/libmpq/debian/rules old mode 100755 new mode 100644 index 5d11fe010..1e101be5f --- a/dep/libmpq/debian/rules +++ b/dep/libmpq/debian/rules @@ -41,7 +41,7 @@ endif ifneq "$(wildcard /usr/share/misc/config.guess)" "" cp -f /usr/share/misc/config.guess config.guess endif - ./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" + ./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS) -ggdb" LDFLAGS="-Wl,-z,defs" build: build-stamp diff --git a/dep/libmpq/doc/man3/Makefile.am b/dep/libmpq/doc/man3/Makefile.am index 80bff4e74..cad3d865d 100644 --- a/dep/libmpq/doc/man3/Makefile.am +++ b/dep/libmpq/doc/man3/Makefile.am @@ -27,4 +27,5 @@ man_MANS = \ libmpq__file_packed_size.3 \ libmpq__file_read.3 \ libmpq__file_unpacked_size.3 \ + libmpq__strerror.3 \ libmpq__version.3 diff --git a/dep/libmpq/doc/man3/libmpq.3 b/dep/libmpq/doc/man3/libmpq.3 index 349451f87..768dab0a7 100644 --- a/dep/libmpq/doc/man3/libmpq.3 +++ b/dep/libmpq/doc/man3/libmpq.3 @@ -29,6 +29,8 @@ libmpq \- cross-platform C library for manipulating mpq archives. .sp .BI "const char *libmpq__version();" .sp +.BI "const char *libmpq__strerror(int32_t returncode);" +.sp .BI "int32_t libmpq__archive_open(" .BI " mpq_archive_s **" "mpq_archive", .BI " const char *" "mpq_filename", @@ -172,6 +174,7 @@ libmpq \- cross-platform C library for manipulating mpq archives. The \fIlibmpq\fP library supports decrypting, decompressing, exploding and various manipulations of the MoPaQ archive files. It uses \fIzlib(3)\fP and \fIbzip2(1)\fP compression library. At this moment \fIlibmpq\fP is not able to create MoPaQ archives, this limitation will be removed in a future version. .SH SEE ALSO .BR libmpq__version (3), +.BR libmpq__strerror (3), .BR libmpq__archive_open (3), .BR libmpq__archive_close (3), .BR libmpq__archive_packed_size (3), diff --git a/dep/libmpq/doc/man3/libmpq__strerror.3 b/dep/libmpq/doc/man3/libmpq__strerror.3 new file mode 100644 index 000000000..246f422ee --- /dev/null +++ b/dep/libmpq/doc/man3/libmpq__strerror.3 @@ -0,0 +1,45 @@ +.\" Copyright (c) 2010 Georg Lukas +.\" +.\" This is free documentation; you can redistribute it and/or +.\" modify it under the terms of the GNU General Public License as +.\" published by the Free Software Foundation; either version 2 of +.\" the License, or (at your option) any later version. +.\" +.\" The GNU General Public License's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" This manual is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public +.\" License along with this manual; if not, write to the Free +.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, +.\" USA. +.TH libmpq 3 2010-07-18 "The MoPaQ archive library" +.SH NAME +libmpq__strerror \- return string describing libmpq error number +.SH SYNOPSIS +.nf +.B +#include +.sp +.BI "const char *libmpq__strerror(int32_t returncode);" +.fi +.SH DESCRIPTION +.PP +Call \fBlibmpq__strerror\fP() to get a string message for the return code of one of the other libmpq functions. +.SH RETURN VALUE +The function returns a string pointer to non-writable memory or NULL if \fBreturncode\fP is not a return code of a libmpq function. +.SH SEE ALSO +.BR libmpq (3), strerror (3) +.SH AUTHOR +Check documentation. +.TP +libmpq is (c) 2003-2008 +.B Maik Broemme +.PP +The above e-mail address can be used to send bug reports, feedbacks or library enhancements. diff --git a/dep/libmpq/libmpq/common.c b/dep/libmpq/libmpq/common.c index 346afe018..879bd902b 100644 --- a/dep/libmpq/libmpq/common.c +++ b/dep/libmpq/libmpq/common.c @@ -20,7 +20,6 @@ /* generic includes. */ #include -#include #include #include #include @@ -101,7 +100,7 @@ int32_t libmpq__decrypt_block(uint32_t *in_buf, uint32_t in_size, uint32_t seed) } /* function to detect decryption key. */ -int32_t libmpq__decrypt_key(uint8_t *in_buf, uint32_t in_size, uint32_t block_size) { +int32_t libmpq__decrypt_key(uint8_t *in_buf, uint32_t in_size, uint32_t block_size, uint32_t *key) { /* some common variables. */ uint32_t saveseed1; @@ -149,7 +148,8 @@ int32_t libmpq__decrypt_key(uint8_t *in_buf, uint32_t in_size, uint32_t block_si if ((ch - ch2) <= block_size) { /* file seed found, so return it. */ - return saveseed1; + *key = saveseed1; + return LIBMPQ_SUCCESS; } } diff --git a/dep/libmpq/libmpq/common.h b/dep/libmpq/libmpq/common.h index 12d6008de..bd13f9613 100644 --- a/dep/libmpq/libmpq/common.h +++ b/dep/libmpq/libmpq/common.h @@ -23,38 +23,39 @@ /* function to return the hash to a given string. */ uint32_t libmpq__hash_string( - const char *key, - uint32_t offset + const char *key, + uint32_t offset ); /* function to encrypt a block. */ int32_t libmpq__encrypt_block( - uint32_t *in_buf, - uint32_t in_size, - uint32_t seed + uint32_t *in_buf, + uint32_t in_size, + uint32_t seed ); /* function to decrypt a block. */ int32_t libmpq__decrypt_block( - uint32_t *in_buf, - uint32_t in_size, - uint32_t seed + uint32_t *in_buf, + uint32_t in_size, + uint32_t seed ); /* function to detect decryption key. */ int32_t libmpq__decrypt_key( - uint8_t *in_buf, - uint32_t in_size, - uint32_t block_size + uint8_t *in_buf, + uint32_t in_size, + uint32_t block_size, + uint32_t *key ); /* function to decompress or explode block from archive. */ int32_t libmpq__decompress_block( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size, - uint32_t compression_type + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size, + uint32_t compression_type ); -#endif /* _COMMON_H */ +#endif /* _COMMON_H */ diff --git a/dep/libmpq/libmpq/crypt_buf.h b/dep/libmpq/libmpq/crypt_buf.h index 34184b017..1f7b4d8ca 100644 --- a/dep/libmpq/libmpq/crypt_buf.h +++ b/dep/libmpq/libmpq/crypt_buf.h @@ -1,217 +1,217 @@ /* DO NOT CHANGE! this file is auto-generated by crypt_buf_gen.c */ static const uint32_t crypt_buf[0x500] = { - 0x55c636e2, 0x02be0170, 0x584b71d4, 0x2984f00e, 0xb682c809, 0x91cf876b, - 0x775a9c24, 0x597d5ca5, 0x5a1afeb2, 0xd3e9ce0d, 0x32cdcdf8, 0xb18201cd, - 0x3cce05ce, 0xa55d13be, 0xbb0afe71, 0x9376ab33, 0x848f645e, 0x87e45a45, - 0x45b86017, 0x5e656ca8, 0x1b851a95, 0x2542dbd7, 0xab4df9e4, 0x5976ae9b, - 0x6c317e7d, 0xcddd2f94, 0x3c3c13e5, 0x335b1371, 0x31a592ca, 0x51e4fc4c, - 0xf7db5b2f, 0x8abdbe41, 0x8beaa674, 0x20d6b319, 0xde6c9a9d, 0xc5ac84e5, - 0x445a5feb, 0x94958cb0, 0x1e7d3847, 0xf35d29b0, 0xca5cceda, 0xb732c8b5, - 0xfdcc41dd, 0x0edcec16, 0x9d01feae, 0x1165d38e, 0x9ee193c8, 0xbf33b13c, - 0x61bc0dfc, 0xef3e7be9, 0xf8d4d4c5, 0xc79b7694, 0x5a255943, 0x0b3dd20a, - 0x9d1ab5a3, 0xcfa8ba57, 0x5e6d7069, 0xcb89b731, 0x3dc0d15b, 0x0d4d7e7e, - 0x97e37f2b, 0xfefc2bb1, 0xf95b16b5, 0x27a55b93, 0x45f22729, 0x4c986630, - 0x7c666862, 0x5fa40847, 0xa3f16205, 0x791b7764, 0x386b36d6, 0x6e6c3fef, - 0xc75855db, 0x4abc7dc7, 0x4a328f9b, 0xcef20c0f, 0x60b88f07, 0xf7bb4b8f, - 0x830b5192, 0x94f711ec, 0x20250752, 0x399d21a3, 0xe5c0840d, 0xe76cffa5, - 0x624fab29, 0x5df133e6, 0x83e0b9b8, 0xc5796bfb, 0x4a7ab2d0, 0xba59a821, - 0x03a81e4c, 0xcd3adfdb, 0x32b26b8c, 0x8e35c533, 0x9e6300e9, 0x8cf92ac5, - 0x880d18eb, 0x131a53b3, 0x2ed2dc64, 0xb23257c1, 0xa06450c1, 0x1b92cb8e, - 0x72ed730e, 0x19a685f0, 0x82836483, 0x42d94e8a, 0xee9bd6f6, 0x556d0b6a, - 0xba65589a, 0xde24cce4, 0x53329f6c, 0xc754fe8b, 0x503d2dc7, 0x10027ba4, - 0xd3b60a8b, 0x68e68d83, 0x0a9128a9, 0x595fa35f, 0x0b03b5be, 0x150a45c4, - 0xb1629cce, 0xe5f7497b, 0x8a7098a4, 0xb8233e69, 0x8ea0f978, 0x5b579970, - 0xeab14318, 0x4b28b263, 0xb6766cef, 0x06782877, 0x155c6dd0, 0xc711333c, - 0xf819cedf, 0x00eb1d68, 0xd6fffa6e, 0x439e5962, 0xd765d6db, 0xcb0bcee9, - 0x6d3c5647, 0x965466f3, 0x0ca983c9, 0x74ecc1ce, 0xfc0563b6, 0x42b08fee, - 0xc5b38853, 0xfe502ceb, 0x7b432faf, 0xc309e610, 0x2c3997d8, 0x43774654, - 0x15bd9d2c, 0xed6a420d, 0xc7ff520c, 0xb8a97fd1, 0x5e4d60cc, 0xb9738d11, - 0xda2181ff, 0x73ac2597, 0x3a8eec8d, 0xac85e779, 0xf3f975d6, 0xb9fe7b91, - 0x0f155d1e, 0x2860b6dd, 0x835977cb, 0xb0607436, 0x9cab7f6b, 0x8ab91186, - 0xc12b51e9, 0x20084e8b, 0x44ba8ead, 0xa542b130, 0x82bcd5c4, 0xcc747f4e, - 0x0f1909d8, 0xda242e1c, 0x6f7d1aa0, 0xd2626486, 0x88d0781e, 0xab695ccd, - 0xfa569145, 0xb4feb55c, 0xbe47e896, 0xe70a7a88, 0xd56185a2, 0xacf4c871, - 0x09282332, 0x1ddeeaa8, 0x590c7adb, 0xf4a97667, 0xbfd85705, 0x0ea77ccc, - 0xa9f85364, 0x83195869, 0x8bfb041a, 0xdb842f5c, 0xd6f0f315, 0xa7756ea7, - 0x0a51b439, 0xa9edf8a3, 0xd9084e2f, 0x827407f8, 0xd4ac8284, 0x09739d0d, - 0xb3bb6cfc, 0xd539c77d, 0x6bbc9ac0, 0x35c641aa, 0x934c96b0, 0xd17af317, - 0x29c6baef, 0xb275cdac, 0xd72662de, 0x9f5c2544, 0xc1a98f75, 0xd98e8f9a, - 0x47bd5c86, 0x70c610a6, 0xb5482ed4, 0x23b9c68c, 0x3c1bae66, 0x69556e7f, - 0xd902f5e0, 0x653d195b, 0xde6541fb, 0x07bcc6ac, 0xc6ee7788, 0x801534d4, - 0x2c1f35c0, 0xd9de614d, 0xbdccac85, 0xb4d4a0da, 0x242d549b, 0x9d964796, - 0xb9ceb982, 0x59fa99a9, 0xd8986cc1, 0x9e90c1a1, 0x01bbd82f, 0xd7f1c5fd, - 0xdd847eba, 0x883d305d, 0x25f13152, 0x4a92694d, 0x77f1e601, 0x8024e6e7, - 0x02a5f53d, 0x9c3ef4d9, 0xaf403ccc, 0xe2ad03c0, 0x46edf6ec, 0x6f9bd3e6, - 0xcc24ad7a, 0x47afab12, 0x82298df7, 0x708c9eec, 0x76f8c1b1, 0xb39459d2, - 0x3f1e26d9, 0xe1811be7, 0x56ed1c4d, 0xc9d18af8, 0xe828060e, 0x91cada2e, - 0x5ccbf9b7, 0xf1a552d4, 0x3c9d4343, 0xe1008785, 0x2adfeebf, 0xf90240a0, - 0x3d08cce7, 0x426e6fb0, 0x573c984f, 0x13a843ae, 0x406b7439, 0x636085d9, - 0x5000ba9a, 0xad4a47ab, 0xaf001d8d, 0x419907ae, 0x185c8f96, 0xe5e9ed4d, - 0x61764133, 0xd3703d97, 0xac98f0c6, 0xdbc3a37c, 0x85f010c4, 0x90491e32, - 0xf12e18bf, 0xc88c96e1, 0xd3fbd6d9, 0xe3c28b08, 0xd5bf08cc, 0xb1e78859, - 0x2546ddcf, 0xb030b200, 0xaafd2811, 0x55b22d21, 0xd38bf567, 0x469c7a2b, - 0x5ad05792, 0xa1a5981e, 0x7dfb8384, 0x34d1ca0a, 0x7eb0dbe0, 0xd61ce0f6, - 0x398068b7, 0xe6406d1f, 0x95ae6b47, 0xe4281230, 0xb0843061, 0xa70a3a68, - 0xe340f625, 0x72dcbffd, 0x8eb8afcd, 0x18b6661f, 0x17ef5a5c, 0x000c5b22, - 0x6ba13836, 0x6165e383, 0x74481c5b, 0xe56f0711, 0xa26f5024, 0x5ff22e60, - 0x31a5e829, 0xa1094bf0, 0xc680ec6c, 0x8cf327d7, 0xebf1348a, 0x6a227d2f, - 0x74065184, 0x8df65112, 0x2bbd05ee, 0xe4d00ed6, 0x2980ee1a, 0x6ae1da73, - 0xe84614da, 0x6c9906ab, 0xcf8e02db, 0xd3723e97, 0x92f66caf, 0xac8491c7, - 0xaec65696, 0xb98997cf, 0xfa16c762, 0x6d73c65f, 0x205d22a6, 0x4dd3aaa5, - 0x2deb6bc0, 0x9f37686c, 0x71a5282b, 0x376bb9e0, 0x7fff2a1b, 0xde67982f, - 0x9cbf33ce, 0x2e6dab37, 0x6e3424b9, 0x0ee143bc, 0x832a60d9, 0xbb6329e1, - 0x13f6befd, 0x5965fb84, 0xf60b233c, 0x3d695183, 0x433224a1, 0xb5d9cae5, - 0x82459bab, 0x9f21b311, 0xaf6c5247, 0xb447b13a, 0x7b2676c3, 0xc38979cd, - 0x8526ae25, 0xc550ad5b, 0x685099a7, 0x65e9c2bd, 0xe5c6dc36, 0xe10b37a9, - 0x88016878, 0xce81d4e4, 0x24d6fc80, 0x4106152d, 0x6d4f5f90, 0xc4dc74be, - 0xdb48676c, 0x6cb569b7, 0xf3bf598f, 0x042b08d9, 0x02ccb2de, 0xb1056f65, - 0x47994af4, 0xfa141ba4, 0x9376ab2e, 0x07a76737, 0x75e7e6fc, 0x449d80a1, - 0x03b7259d, 0xf6df358a, 0x5a75d5b9, 0x47286923, 0x3b1a30ef, 0xeebe3d6a, - 0x9db1aa00, 0x007a90d9, 0x24667071, 0x019c73cf, 0x69039bcd, 0x95900744, - 0x6518b1eb, 0x6905f202, 0xee3951b2, 0xe141fca9, 0x797fa832, 0x5a95e55b, - 0xd6263b15, 0x5b61f394, 0x897acb1c, 0x005f83a9, 0x22420f71, 0xf495176e, - 0x7e138f3d, 0x1392e384, 0x373bf7aa, 0x8e512816, 0xa960b3ca, 0x0474d74c, - 0xffacd6d7, 0x2ef5ed9e, 0x60992aaa, 0x7e690e99, 0x23c0749d, 0xd8e29105, - 0x555d5909, 0x15631bfe, 0xa69c5a1c, 0x501017ca, 0x99438048, 0x38733ac7, - 0xe682e2c8, 0xd4655fd6, 0x956e4c04, 0x347df643, 0x2f4b177b, 0x93ed3aa4, - 0xa77e1dd5, 0x7ae55702, 0xd2a52fd9, 0xef8ba18c, 0xb7d3c1ee, 0x8078ba8d, - 0xab5aaadb, 0x752be08f, 0x068b31c1, 0x078aae3c, 0xaa5a8343, 0x123d9268, - 0x2ceaee43, 0x8ebdb239, 0x650251f3, 0x04883648, 0x8c62e12e, 0x12b32167, - 0xe5112e9a, 0x10002548, 0x3e7a818d, 0x077e5327, 0xf140cc21, 0x6ce7d75d, - 0x9b99f9a5, 0x3215741c, 0xb6aadbae, 0x738768dc, 0x82a3742f, 0x76517020, - 0xdd872ad8, 0x9d0902b2, 0x7d1a6b04, 0x49381592, 0x63a652a5, 0x0c15e626, - 0xe22f70d6, 0x01e84385, 0xb29de134, 0x20c5000e, 0xe961f443, 0x2d31662e, - 0x3ce6bc28, 0x34f9dd94, 0xfa45de53, 0x497588bd, 0x9468215b, 0x0777fa5c, - 0x6f7114c0, 0xe0e82694, 0xe4371986, 0x57112de2, 0xe0cac289, 0xf2a3cee0, - 0x6a41e1b9, 0xbfcea77d, 0xf927fd52, 0x69747d98, 0xbea76cdb, 0x8dd39557, - 0x04db5ece, 0x2a0885c8, 0x3be4e8ee, 0x21d785dc, 0x09de7c0e, 0x3258ea33, - 0x51922982, 0xee8dd024, 0x3df6965d, 0x30c1237b, 0xf7f6686a, 0x9faca186, - 0x7c400076, 0x85acef8a, 0xf4b6d220, 0xddc3481c, 0x439eaec4, 0x717bbe63, - 0x8259faa7, 0xd682bd68, 0x932a8610, 0x38bf0a7f, 0x6212e2c7, 0x88ee3168, - 0xb3c27047, 0x6133cb1e, 0x15295506, 0x5ae66246, 0x1d208ddd, 0xa91d3dba, - 0xc315968d, 0x6aa2664b, 0x716d0cca, 0x891f4956, 0x80866bff, 0xbd56c847, - 0x9093425a, 0x28dd9e87, 0x84ef3e08, 0x690a49d6, 0x6a7eff82, 0xabcfe400, - 0x3d3be5ca, 0x381b650c, 0x4b7c8622, 0x3e0246f3, 0xa3561654, 0x9488865c, - 0x3aef1bf2, 0x5e5d68a2, 0xd32f1ddc, 0x51972bf0, 0x177a213b, 0x469375c2, - 0x37640bd0, 0xfc3324c8, 0x07091a09, 0x2d63d3fb, 0x2153f023, 0x48223875, - 0x61a55826, 0x8c136538, 0x49f71d98, 0x84c7d51e, 0x85551a73, 0x13d604c5, - 0xd701a626, 0x87b844ca, 0x741eb29d, 0x2a2c977c, 0xc797ca03, 0x6c4085d7, - 0x2dacf79b, 0x734fa2eb, 0xcc290557, 0xfa1e75e4, 0x06b29a27, 0xbece2a7a, - 0x70a4554b, 0xc935942e, 0xa764bbc1, 0x1fe391d6, 0x7807f0c2, 0x40606ed9, - 0xe5153086, 0xe91d7dd2, 0xed5d3ba9, 0xaa14b64a, 0x83b24dd9, 0xec1ff5cd, - 0xba33ead3, 0xe4ef735c, 0xbc062438, 0xd8bfd523, 0x473d1e04, 0x2007f8a7, - 0xb02903ed, 0x86ea8ada, 0x95ab69cf, 0xfd1f9809, 0x9cb3d8bb, 0x51f45958, - 0x9cdd4276, 0xc245865e, 0x8f0c836b, 0x4ee7dc07, 0xf6368d9d, 0xef2c1dc1, - 0xee56b54b, 0xbd62ce2f, 0xf4916aad, 0xc81cb594, 0x41729f49, 0x24bef0a4, - 0xdef487a9, 0x222e05b8, 0x8d3bf5c6, 0x11b55009, 0xad09d2b3, 0x19db9fd1, - 0xd7427085, 0x33dbfc8b, 0x526b9378, 0x790e1bc8, 0xb2998a00, 0xa5641703, - 0x0676d249, 0x6b9185cc, 0x30e4348f, 0x82c52f65, 0x57c7dc24, 0x489c1ecd, - 0x9fcab02a, 0x56d61117, 0xfe869cac, 0x55fc5140, 0x7fbbb382, 0x9e5afc79, - 0x10047c99, 0xfc9f5984, 0x56587e2d, 0xb98193f0, 0x98fe5e8e, 0x29b15b6b, - 0x9561f055, 0xbb0caa25, 0x1e4ecc15, 0x23f5393b, 0x0845b458, 0xceff67ca, - 0xb099900c, 0x00b1564f, 0x39eef3d1, 0xfcc1bf84, 0xac8893b5, 0x6484bf0e, - 0x91c02ab3, 0x8c0c0c70, 0x686fa8c6, 0xe171bed6, 0xdfae37df, 0xd5a1a4e7, - 0xe3eb49a1, 0x5e6014e0, 0x205b21ac, 0xfd58b3da, 0x2e7c07cd, 0xef2cc85a, - 0xd7587b46, 0xf417847d, 0x8a30cec1, 0x70984f6c, 0xf0b63388, 0xc220c98d, - 0xede62936, 0x92c0a7b3, 0x1ef371e8, 0x2005f7af, 0x91a47265, 0xb0cf5504, - 0xd500aba8, 0xcb5c4bd3, 0x9b3bcbc3, 0xcf6644b5, 0xce9488ef, 0x003fc96e, - 0xaa42222f, 0x4844f3d0, 0x4db89d77, 0x08681aae, 0x662f3a28, 0x761552db, - 0x1df7a17a, 0x93feed9a, 0xcc496a4f, 0xa217cfcd, 0x3ba3c930, 0x268f7e77, - 0x0797b4a1, 0x8bebfc51, 0x068930c4, 0x16c874e2, 0xc242da24, 0xfb229f76, - 0xa0795b02, 0x689fc036, 0x17a73732, 0xd21aec00, 0xac00a692, 0x5b217f18, - 0xae421624, 0x2bc05cc0, 0x48c1db7a, 0x4f4e63b4, 0x1667f04e, 0x34020f94, - 0x972b2555, 0x9a07355b, 0x01665970, 0x7db60c6f, 0x3ad7103b, 0x5c3d09c0, - 0xeea3dada, 0x88c21c10, 0x102436d7, 0x6a3b3400, 0xeb523c4c, 0xfb97d896, - 0x964cb86b, 0xdd878038, 0x0529da4d, 0x0b1468a5, 0x18739ac8, 0xf7f26668, - 0xf64f4471, 0x5c14f5c3, 0x44a081fb, 0x39ac7e37, 0x8a17c26b, 0x868f5e67, - 0x3931978d, 0x6edf7817, 0x4951cc67, 0x943407f3, 0xcc5e748f, 0x2b7ee729, - 0xcbb320f0, 0x11fec8e7, 0xfccfc658, 0x03454354, 0x373aa1ec, 0x1d58fe9a, - 0x064710ae, 0xa88aa0ba, 0xd183a23e, 0x40d150a3, 0xf531b8d1, 0xa7d99f85, - 0x11838cd5, 0xb19e64b3, 0x3d67a5e9, 0xb02c5ac6, 0x99b9b9e8, 0x4c202b7a, - 0x15f261d3, 0xa84c2d0d, 0x50f185a6, 0x33ba41d5, 0x39791013, 0x4baff44e, - 0xeeeeaa1c, 0xe0488314, 0x559ccd2b, 0xa104f445, 0x636f37c4, 0x264d5e3b, - 0x75c17f35, 0x75424131, 0xbb115739, 0x74fe755a, 0x7d3a7aa6, 0x2d8be784, - 0x83ed154a, 0xfc2673d8, 0x44dd4a7f, 0x79056cc8, 0x82cc8831, 0x9d3c1b7c, - 0xe9453bfa, 0x24315694, 0x661f3253, 0x75549f5c, 0xbb2b63ed, 0x67e00d96, - 0xf48966c7, 0x0d7bea56, 0xc25f92ef, 0xa947a79d, 0xde4adf6f, 0xac0f0342, - 0xd3eb246b, 0xa4aa118e, 0x3c3e6a46, 0x457f4441, 0xa50a406f, 0x6c508d9f, - 0xe9ac18e7, 0x1ecdb4ba, 0x39ac7e3a, 0x7fb304fa, 0x6f38f8e8, 0x4aecea6d, - 0x61035e73, 0x81708907, 0xebc07205, 0x90fd7614, 0xb52d217f, 0x6c4de195, - 0x1dd49084, 0x64ee482c, 0x94c7a521, 0x540c09d8, 0x75df8dd5, 0x414131f7, - 0x3698fd76, 0xf784db4f, 0xf8c97a03, 0x048f39b9, 0x3bf4f0bd, 0x8cb50992, - 0x9b58d9ee, 0xe5ab79cc, 0x9a5f6052, 0xbd9591b0, 0xfad2232b, 0x5a632254, - 0x0286e618, 0x8ad3c8f7, 0xe4060176, 0x754c4617, 0x5c10490b, 0x6f7d6fff, - 0x2187b42a, 0x5775095b, 0x02f4c663, 0x5a5dca06, 0xfe4ad4c7, 0x53e19f7d, - 0x59ff46b5, 0xbcc42ba5, 0xfd2f4a97, 0xbed6d905, 0x95629b6b, 0x21a1c0db, - 0xaa10b45d, 0xe6ef6d58, 0x2892cf4d, 0x9fed6c10, 0x1e386bf7, 0x9be0c6e8, - 0x2b2f15ef, 0x19f5ac7b, 0x7aff0e72, 0x31da576f, 0x30252cb4, 0x577960ac, - 0x166e9e5a, 0xa9374a61, 0x71369c96, 0x7ff826ae, 0xe8175326, 0xcabbfd33, - 0x0191190e, 0x699d3c3e, 0x36b40b22, 0xb3950513, 0x9b889bfa, 0xa52a5007, - 0xac290fed, 0x3b4e4a4f, 0xb753d8d6, 0x3c531f22, 0x582f6427, 0xa9cd93a9, - 0x546e39ae, 0x242faad2, 0xd2e0f747, 0x09f6325d, 0x59d48719, 0xad7eb66e, - 0xd5512878, 0x56debf9d, 0x5107e5a5, 0xf1c00aa4, 0x814ccca8, 0x600d90f0, - 0x9be97619, 0x915fa5f2, 0x2b5628dd, 0xa33d5f5a, 0x595df7c1, 0x6966215d, - 0x50ec8337, 0xf1d21372, 0x0ee2eefb, 0xad9e70b7, 0xab0d2fe4, 0xcf277b5d, - 0x62585a2c, 0x835a7844, 0x74b1fa6b, 0x49baffd5, 0x2ea9c864, 0x129311a8, - 0xbdfa1867, 0x83ca5997, 0x9d1db719, 0x84bb79e6, 0x9e3f99f2, 0x313f6101, - 0x1b99245b, 0xd15d8fb2, 0xcef90f81, 0x2945268d, 0xdbbcf573, 0xb1021886, - 0x9ee7ec1d, 0x1cf824f7, 0x7eaa2e32, 0x69c0a2b5, 0x7494419c, 0xe253d7d3, - 0x48da3d12, 0x45b8b571, 0xdb4d147a, 0xd82d8dde, 0x265d10a2, 0xb0a6eb9a, - 0x7e1c93a6, 0x36fe2f46, 0xdcad6b00, 0x05439191, 0xb0ce5484, 0x61d1c309, - 0x8da62a03, 0x06d0fe2f, 0xbac6dd3c, 0xca2006f3, 0x8321b1af, 0x0411a6f3, - 0xe8918eac, 0x21a2c152, 0x91c0d54f, 0x6aaa14fa, 0xdd22a440, 0x88cb2075, - 0x7a4eb813, 0x67afa071, 0xd8d98c9c, 0x31f10d47, 0x6ff1a8a8, 0x2faaf0a1, - 0x48a221bb, 0x3be6948b, 0xaa79e79b, 0x0ea7278c, 0x7a3857ef, 0x49b7fe55, - 0xd51cb931, 0x041c018d, 0x00b90501, 0x45ea7881, 0x8fc1dbcf, 0xb80b32a9, - 0xabacd2e9, 0x677bdc40, 0xecace542, 0x6d6514eb, 0x31c09ff7, 0x5e6c1abd, - 0x1c391d0f, 0x0e9d77f1, 0x7119392d, 0x6be9b0ba, 0x6194fa77, 0x45e62148, - 0x42234af2, 0xc3239d66, 0x939cbdbc, 0x56200d9c, 0x6b275208, 0x001a61f3, - 0xccc2a546, 0x4b722be0, 0xee25f2b7, 0x6d86cf9e, 0xaa6be0cd, 0x4dcda7b6, - 0x78d4aa13, 0x36ea7ad9, 0x3f29d700, 0xdeea2d84, 0x6a6af5bd, 0x18afb81c, - 0xd8e4e73c, 0x8aa708ba, 0x658b94d9, 0xa676478c, 0xcfa10c22, 0x25593c74, - 0x8d962235, 0x5f980270, 0x3df6ebc0, 0x8e7d92fa, 0xc3ee55e1, 0xd5f72447, - 0x02b0fa95, 0x52b0b520, 0x70d2c11f, 0x3a6fdd6c, 0x193aa698, 0x5496f7d5, - 0x4208931b, 0x7a4106ec, 0x83e86840, 0xf49b6f8c, 0xba3d9a51, 0x55f54ddd, - 0x2de51372, 0x9afb571b, 0x3ab35406, 0xad64ff1f, 0xc77764fe, 0x7f864466, - 0x416d9cd4, 0xa2489278, 0xe30b86e4, 0x0b5231b6, 0xba67aed6, 0xe5ab2467, - 0x60028b90, 0x1d9e20c6, 0x2a7c692a, 0x6b691cdb, 0x9e51f817, 0x9b763dec, - 0x3d29323f, 0xcfe12b68, 0x754b459b, 0xa2238047, 0xd9c55514, 0x6bdcffc1, - 0x693e6340, 0x82383fe7, 0x1916ea5f, 0xec7bcd59, 0x72de165a, 0xe79a1617, - 0x8ec86234, 0xa8f0d284, 0x20c90226, 0x7bf98884, 0x28a58331, 0x3ec3fa6e, - 0x4ce0895b, 0xc353b4d0, 0x33ef064f, 0x21e5e210, 0xc8bb589d, 0xe85dcab2, - 0xac65829f, 0xa7bf92d0, 0x05a6174d, 0x25a50c2e, 0xe5c78777, 0x3d75021f, - 0x4baa9c98, 0x23bdc884, 0x9653bbd7, 0xbadce7f5, 0xc283a484, 0xc040df2e, - 0x9370a841, 0x2f316022, 0x36eed231, 0xac2cbc0c, 0x13c0a49b, 0xcdd12997, - 0x07fe91b2, 0xcd7eabcd, 0x2c01271d, 0x18432df8, 0x599c6bc7, 0x75e93d5a, - 0xb67a6ee2, 0x8e738e16, 0xff9073fd, 0xaf77026a, 0xf86ea2fc, 0x91509ea3, - 0x33a78dc6, 0x4f79234a, 0x3a7535bc, 0x3539fcb1, 0x3103ee52, 0x4f6f1e69, - 0x6bb3ebbc, 0x4cb77555, 0x8dd1e999, 0x2ade439d, 0x11521fae, 0xb94d2545, - 0x8dde9abd, 0x1909393f, 0xb792a23d, 0x749c455b, 0xb5b60f2c, 0x380459ce, - 0x0dad5820, 0xb130845b, 0x291cbd52, 0xde9a5bb7, 0x51def961, 0x515b6408, - 0xca6e823e, 0x382e6e74, 0xeebe3d71, 0x4c8f0c6a, 0xe676dcea, 0x14e1dc7c, - 0x6f7fc634, 0xcf85a943, 0xd39ea96e, 0x136e7c93, 0x7164b304, 0xf32f1333, - 0x35c34034, 0xde39d721, 0x91a87439, 0xc410111f, 0x29f17aac, 0x1316a6ff, - 0x12f194ee, 0x420b9499, 0xf72db0dc, 0x690b9f93, 0x17d14bb2, 0x8f931ab8, - 0x217500bc, 0x875413f8, 0x98b2e43d, 0xc51f9571, 0x54cebdca, 0x0719cc79, - 0xf3c7080d, 0xe4286771, 0xa3eab3cd, 0x4a6b00e0, 0x11cf0759, 0x7e897379, - 0x5b32876c, 0x5e8cd4f6, 0x0cedfa64, 0x919ac2c7, 0xb214f3b3, 0x0e89c38c, - 0xf0c43a39, 0xeae10522, 0x835bce06, 0x9eec43c2, 0xea26a9d6, 0x69531821, - 0x6725b24a, 0xda81b0e2, 0xd5b4ae33, 0x080f99fb, 0x15a83daf, 0x29dfc720, - 0x91e1900f, 0x28163d58, 0x83d107a2, 0x4eac149a, 0x9f71da18, 0x61d5c4fa, - 0xe3ab2a5f, 0xc7b0d63f, 0xb3cc752a, 0x61ebcfb6, 0x26ffb52a, 0xed789e3f, - 0xaa3bc958, 0x455a8788, 0xc9c082a9, 0x0a1bef0e, 0xc29a5a7e, 0x150d4735, - 0x943809e0, 0x69215510, 0xef0b0da9, 0x3b4e9fb3, 0xd8b5d04c, 0xc7a023a8, - 0xb0d50288, 0x64821375, 0xc260e8cf, 0x8496bd2c, 0xff4f5435, 0x0fb5560c, - 0x7cd74a52, 0x93589c80, 0x88975c47, 0x83bda89d, 0x8bcc4296, 0x01b82c21, - 0xfd821dbf, 0x26520b47, 0x04983e19, 0xd3e1ca27, 0x782c580f, 0x326ff573, - 0xc157bcc7, 0x4f5e6b84, 0x44ebfbfb, 0xda26d9d8, 0x6cd9d08e, 0x1719f1d8, - 0x715c0487, 0x2c2d3c92, 0x53faaba9, 0xbc836146, 0x510c92d6, 0xe089f82a, - 0x4680171f, 0x369f00de, 0x70ec2331, 0x0e253d55, 0xdafb9717, 0xe5dd922d, - 0x95915d21, 0xa0202f96, 0xa161cc47, 0xeacfa6f1, 0xed5e9189, 0xdab87684, - 0xa4b76d4a, 0xfa704897, 0x631f10ba, 0xd39da8f9, 0x5db4c0e4, 0x16fde42a, - 0x2dff7580, 0xb56fec7e, 0xc3ffb370, 0x8e6f36bc, 0x6097d459, 0x514d5d36, - 0xa5a737e2, 0x3977b9b3, 0xfd31a0ca, 0x903368db, 0xe8370d61, 0x98109520, - 0xade23cac, 0x99f82e04, 0x41de7ea3, 0x84a1c295, 0x09191be0, 0x30930d02, - 0x1c9fa44a, 0xc406b6d7, 0xeedca152, 0x6149809c, 0xb0099ef4, 0xc5f653a5, - 0x4c10790d, 0x7303286c + 0x55c636e2, 0x02be0170, 0x584b71d4, 0x2984f00e, 0xb682c809, 0x91cf876b, + 0x775a9c24, 0x597d5ca5, 0x5a1afeb2, 0xd3e9ce0d, 0x32cdcdf8, 0xb18201cd, + 0x3cce05ce, 0xa55d13be, 0xbb0afe71, 0x9376ab33, 0x848f645e, 0x87e45a45, + 0x45b86017, 0x5e656ca8, 0x1b851a95, 0x2542dbd7, 0xab4df9e4, 0x5976ae9b, + 0x6c317e7d, 0xcddd2f94, 0x3c3c13e5, 0x335b1371, 0x31a592ca, 0x51e4fc4c, + 0xf7db5b2f, 0x8abdbe41, 0x8beaa674, 0x20d6b319, 0xde6c9a9d, 0xc5ac84e5, + 0x445a5feb, 0x94958cb0, 0x1e7d3847, 0xf35d29b0, 0xca5cceda, 0xb732c8b5, + 0xfdcc41dd, 0x0edcec16, 0x9d01feae, 0x1165d38e, 0x9ee193c8, 0xbf33b13c, + 0x61bc0dfc, 0xef3e7be9, 0xf8d4d4c5, 0xc79b7694, 0x5a255943, 0x0b3dd20a, + 0x9d1ab5a3, 0xcfa8ba57, 0x5e6d7069, 0xcb89b731, 0x3dc0d15b, 0x0d4d7e7e, + 0x97e37f2b, 0xfefc2bb1, 0xf95b16b5, 0x27a55b93, 0x45f22729, 0x4c986630, + 0x7c666862, 0x5fa40847, 0xa3f16205, 0x791b7764, 0x386b36d6, 0x6e6c3fef, + 0xc75855db, 0x4abc7dc7, 0x4a328f9b, 0xcef20c0f, 0x60b88f07, 0xf7bb4b8f, + 0x830b5192, 0x94f711ec, 0x20250752, 0x399d21a3, 0xe5c0840d, 0xe76cffa5, + 0x624fab29, 0x5df133e6, 0x83e0b9b8, 0xc5796bfb, 0x4a7ab2d0, 0xba59a821, + 0x03a81e4c, 0xcd3adfdb, 0x32b26b8c, 0x8e35c533, 0x9e6300e9, 0x8cf92ac5, + 0x880d18eb, 0x131a53b3, 0x2ed2dc64, 0xb23257c1, 0xa06450c1, 0x1b92cb8e, + 0x72ed730e, 0x19a685f0, 0x82836483, 0x42d94e8a, 0xee9bd6f6, 0x556d0b6a, + 0xba65589a, 0xde24cce4, 0x53329f6c, 0xc754fe8b, 0x503d2dc7, 0x10027ba4, + 0xd3b60a8b, 0x68e68d83, 0x0a9128a9, 0x595fa35f, 0x0b03b5be, 0x150a45c4, + 0xb1629cce, 0xe5f7497b, 0x8a7098a4, 0xb8233e69, 0x8ea0f978, 0x5b579970, + 0xeab14318, 0x4b28b263, 0xb6766cef, 0x06782877, 0x155c6dd0, 0xc711333c, + 0xf819cedf, 0x00eb1d68, 0xd6fffa6e, 0x439e5962, 0xd765d6db, 0xcb0bcee9, + 0x6d3c5647, 0x965466f3, 0x0ca983c9, 0x74ecc1ce, 0xfc0563b6, 0x42b08fee, + 0xc5b38853, 0xfe502ceb, 0x7b432faf, 0xc309e610, 0x2c3997d8, 0x43774654, + 0x15bd9d2c, 0xed6a420d, 0xc7ff520c, 0xb8a97fd1, 0x5e4d60cc, 0xb9738d11, + 0xda2181ff, 0x73ac2597, 0x3a8eec8d, 0xac85e779, 0xf3f975d6, 0xb9fe7b91, + 0x0f155d1e, 0x2860b6dd, 0x835977cb, 0xb0607436, 0x9cab7f6b, 0x8ab91186, + 0xc12b51e9, 0x20084e8b, 0x44ba8ead, 0xa542b130, 0x82bcd5c4, 0xcc747f4e, + 0x0f1909d8, 0xda242e1c, 0x6f7d1aa0, 0xd2626486, 0x88d0781e, 0xab695ccd, + 0xfa569145, 0xb4feb55c, 0xbe47e896, 0xe70a7a88, 0xd56185a2, 0xacf4c871, + 0x09282332, 0x1ddeeaa8, 0x590c7adb, 0xf4a97667, 0xbfd85705, 0x0ea77ccc, + 0xa9f85364, 0x83195869, 0x8bfb041a, 0xdb842f5c, 0xd6f0f315, 0xa7756ea7, + 0x0a51b439, 0xa9edf8a3, 0xd9084e2f, 0x827407f8, 0xd4ac8284, 0x09739d0d, + 0xb3bb6cfc, 0xd539c77d, 0x6bbc9ac0, 0x35c641aa, 0x934c96b0, 0xd17af317, + 0x29c6baef, 0xb275cdac, 0xd72662de, 0x9f5c2544, 0xc1a98f75, 0xd98e8f9a, + 0x47bd5c86, 0x70c610a6, 0xb5482ed4, 0x23b9c68c, 0x3c1bae66, 0x69556e7f, + 0xd902f5e0, 0x653d195b, 0xde6541fb, 0x07bcc6ac, 0xc6ee7788, 0x801534d4, + 0x2c1f35c0, 0xd9de614d, 0xbdccac85, 0xb4d4a0da, 0x242d549b, 0x9d964796, + 0xb9ceb982, 0x59fa99a9, 0xd8986cc1, 0x9e90c1a1, 0x01bbd82f, 0xd7f1c5fd, + 0xdd847eba, 0x883d305d, 0x25f13152, 0x4a92694d, 0x77f1e601, 0x8024e6e7, + 0x02a5f53d, 0x9c3ef4d9, 0xaf403ccc, 0xe2ad03c0, 0x46edf6ec, 0x6f9bd3e6, + 0xcc24ad7a, 0x47afab12, 0x82298df7, 0x708c9eec, 0x76f8c1b1, 0xb39459d2, + 0x3f1e26d9, 0xe1811be7, 0x56ed1c4d, 0xc9d18af8, 0xe828060e, 0x91cada2e, + 0x5ccbf9b7, 0xf1a552d4, 0x3c9d4343, 0xe1008785, 0x2adfeebf, 0xf90240a0, + 0x3d08cce7, 0x426e6fb0, 0x573c984f, 0x13a843ae, 0x406b7439, 0x636085d9, + 0x5000ba9a, 0xad4a47ab, 0xaf001d8d, 0x419907ae, 0x185c8f96, 0xe5e9ed4d, + 0x61764133, 0xd3703d97, 0xac98f0c6, 0xdbc3a37c, 0x85f010c4, 0x90491e32, + 0xf12e18bf, 0xc88c96e1, 0xd3fbd6d9, 0xe3c28b08, 0xd5bf08cc, 0xb1e78859, + 0x2546ddcf, 0xb030b200, 0xaafd2811, 0x55b22d21, 0xd38bf567, 0x469c7a2b, + 0x5ad05792, 0xa1a5981e, 0x7dfb8384, 0x34d1ca0a, 0x7eb0dbe0, 0xd61ce0f6, + 0x398068b7, 0xe6406d1f, 0x95ae6b47, 0xe4281230, 0xb0843061, 0xa70a3a68, + 0xe340f625, 0x72dcbffd, 0x8eb8afcd, 0x18b6661f, 0x17ef5a5c, 0x000c5b22, + 0x6ba13836, 0x6165e383, 0x74481c5b, 0xe56f0711, 0xa26f5024, 0x5ff22e60, + 0x31a5e829, 0xa1094bf0, 0xc680ec6c, 0x8cf327d7, 0xebf1348a, 0x6a227d2f, + 0x74065184, 0x8df65112, 0x2bbd05ee, 0xe4d00ed6, 0x2980ee1a, 0x6ae1da73, + 0xe84614da, 0x6c9906ab, 0xcf8e02db, 0xd3723e97, 0x92f66caf, 0xac8491c7, + 0xaec65696, 0xb98997cf, 0xfa16c762, 0x6d73c65f, 0x205d22a6, 0x4dd3aaa5, + 0x2deb6bc0, 0x9f37686c, 0x71a5282b, 0x376bb9e0, 0x7fff2a1b, 0xde67982f, + 0x9cbf33ce, 0x2e6dab37, 0x6e3424b9, 0x0ee143bc, 0x832a60d9, 0xbb6329e1, + 0x13f6befd, 0x5965fb84, 0xf60b233c, 0x3d695183, 0x433224a1, 0xb5d9cae5, + 0x82459bab, 0x9f21b311, 0xaf6c5247, 0xb447b13a, 0x7b2676c3, 0xc38979cd, + 0x8526ae25, 0xc550ad5b, 0x685099a7, 0x65e9c2bd, 0xe5c6dc36, 0xe10b37a9, + 0x88016878, 0xce81d4e4, 0x24d6fc80, 0x4106152d, 0x6d4f5f90, 0xc4dc74be, + 0xdb48676c, 0x6cb569b7, 0xf3bf598f, 0x042b08d9, 0x02ccb2de, 0xb1056f65, + 0x47994af4, 0xfa141ba4, 0x9376ab2e, 0x07a76737, 0x75e7e6fc, 0x449d80a1, + 0x03b7259d, 0xf6df358a, 0x5a75d5b9, 0x47286923, 0x3b1a30ef, 0xeebe3d6a, + 0x9db1aa00, 0x007a90d9, 0x24667071, 0x019c73cf, 0x69039bcd, 0x95900744, + 0x6518b1eb, 0x6905f202, 0xee3951b2, 0xe141fca9, 0x797fa832, 0x5a95e55b, + 0xd6263b15, 0x5b61f394, 0x897acb1c, 0x005f83a9, 0x22420f71, 0xf495176e, + 0x7e138f3d, 0x1392e384, 0x373bf7aa, 0x8e512816, 0xa960b3ca, 0x0474d74c, + 0xffacd6d7, 0x2ef5ed9e, 0x60992aaa, 0x7e690e99, 0x23c0749d, 0xd8e29105, + 0x555d5909, 0x15631bfe, 0xa69c5a1c, 0x501017ca, 0x99438048, 0x38733ac7, + 0xe682e2c8, 0xd4655fd6, 0x956e4c04, 0x347df643, 0x2f4b177b, 0x93ed3aa4, + 0xa77e1dd5, 0x7ae55702, 0xd2a52fd9, 0xef8ba18c, 0xb7d3c1ee, 0x8078ba8d, + 0xab5aaadb, 0x752be08f, 0x068b31c1, 0x078aae3c, 0xaa5a8343, 0x123d9268, + 0x2ceaee43, 0x8ebdb239, 0x650251f3, 0x04883648, 0x8c62e12e, 0x12b32167, + 0xe5112e9a, 0x10002548, 0x3e7a818d, 0x077e5327, 0xf140cc21, 0x6ce7d75d, + 0x9b99f9a5, 0x3215741c, 0xb6aadbae, 0x738768dc, 0x82a3742f, 0x76517020, + 0xdd872ad8, 0x9d0902b2, 0x7d1a6b04, 0x49381592, 0x63a652a5, 0x0c15e626, + 0xe22f70d6, 0x01e84385, 0xb29de134, 0x20c5000e, 0xe961f443, 0x2d31662e, + 0x3ce6bc28, 0x34f9dd94, 0xfa45de53, 0x497588bd, 0x9468215b, 0x0777fa5c, + 0x6f7114c0, 0xe0e82694, 0xe4371986, 0x57112de2, 0xe0cac289, 0xf2a3cee0, + 0x6a41e1b9, 0xbfcea77d, 0xf927fd52, 0x69747d98, 0xbea76cdb, 0x8dd39557, + 0x04db5ece, 0x2a0885c8, 0x3be4e8ee, 0x21d785dc, 0x09de7c0e, 0x3258ea33, + 0x51922982, 0xee8dd024, 0x3df6965d, 0x30c1237b, 0xf7f6686a, 0x9faca186, + 0x7c400076, 0x85acef8a, 0xf4b6d220, 0xddc3481c, 0x439eaec4, 0x717bbe63, + 0x8259faa7, 0xd682bd68, 0x932a8610, 0x38bf0a7f, 0x6212e2c7, 0x88ee3168, + 0xb3c27047, 0x6133cb1e, 0x15295506, 0x5ae66246, 0x1d208ddd, 0xa91d3dba, + 0xc315968d, 0x6aa2664b, 0x716d0cca, 0x891f4956, 0x80866bff, 0xbd56c847, + 0x9093425a, 0x28dd9e87, 0x84ef3e08, 0x690a49d6, 0x6a7eff82, 0xabcfe400, + 0x3d3be5ca, 0x381b650c, 0x4b7c8622, 0x3e0246f3, 0xa3561654, 0x9488865c, + 0x3aef1bf2, 0x5e5d68a2, 0xd32f1ddc, 0x51972bf0, 0x177a213b, 0x469375c2, + 0x37640bd0, 0xfc3324c8, 0x07091a09, 0x2d63d3fb, 0x2153f023, 0x48223875, + 0x61a55826, 0x8c136538, 0x49f71d98, 0x84c7d51e, 0x85551a73, 0x13d604c5, + 0xd701a626, 0x87b844ca, 0x741eb29d, 0x2a2c977c, 0xc797ca03, 0x6c4085d7, + 0x2dacf79b, 0x734fa2eb, 0xcc290557, 0xfa1e75e4, 0x06b29a27, 0xbece2a7a, + 0x70a4554b, 0xc935942e, 0xa764bbc1, 0x1fe391d6, 0x7807f0c2, 0x40606ed9, + 0xe5153086, 0xe91d7dd2, 0xed5d3ba9, 0xaa14b64a, 0x83b24dd9, 0xec1ff5cd, + 0xba33ead3, 0xe4ef735c, 0xbc062438, 0xd8bfd523, 0x473d1e04, 0x2007f8a7, + 0xb02903ed, 0x86ea8ada, 0x95ab69cf, 0xfd1f9809, 0x9cb3d8bb, 0x51f45958, + 0x9cdd4276, 0xc245865e, 0x8f0c836b, 0x4ee7dc07, 0xf6368d9d, 0xef2c1dc1, + 0xee56b54b, 0xbd62ce2f, 0xf4916aad, 0xc81cb594, 0x41729f49, 0x24bef0a4, + 0xdef487a9, 0x222e05b8, 0x8d3bf5c6, 0x11b55009, 0xad09d2b3, 0x19db9fd1, + 0xd7427085, 0x33dbfc8b, 0x526b9378, 0x790e1bc8, 0xb2998a00, 0xa5641703, + 0x0676d249, 0x6b9185cc, 0x30e4348f, 0x82c52f65, 0x57c7dc24, 0x489c1ecd, + 0x9fcab02a, 0x56d61117, 0xfe869cac, 0x55fc5140, 0x7fbbb382, 0x9e5afc79, + 0x10047c99, 0xfc9f5984, 0x56587e2d, 0xb98193f0, 0x98fe5e8e, 0x29b15b6b, + 0x9561f055, 0xbb0caa25, 0x1e4ecc15, 0x23f5393b, 0x0845b458, 0xceff67ca, + 0xb099900c, 0x00b1564f, 0x39eef3d1, 0xfcc1bf84, 0xac8893b5, 0x6484bf0e, + 0x91c02ab3, 0x8c0c0c70, 0x686fa8c6, 0xe171bed6, 0xdfae37df, 0xd5a1a4e7, + 0xe3eb49a1, 0x5e6014e0, 0x205b21ac, 0xfd58b3da, 0x2e7c07cd, 0xef2cc85a, + 0xd7587b46, 0xf417847d, 0x8a30cec1, 0x70984f6c, 0xf0b63388, 0xc220c98d, + 0xede62936, 0x92c0a7b3, 0x1ef371e8, 0x2005f7af, 0x91a47265, 0xb0cf5504, + 0xd500aba8, 0xcb5c4bd3, 0x9b3bcbc3, 0xcf6644b5, 0xce9488ef, 0x003fc96e, + 0xaa42222f, 0x4844f3d0, 0x4db89d77, 0x08681aae, 0x662f3a28, 0x761552db, + 0x1df7a17a, 0x93feed9a, 0xcc496a4f, 0xa217cfcd, 0x3ba3c930, 0x268f7e77, + 0x0797b4a1, 0x8bebfc51, 0x068930c4, 0x16c874e2, 0xc242da24, 0xfb229f76, + 0xa0795b02, 0x689fc036, 0x17a73732, 0xd21aec00, 0xac00a692, 0x5b217f18, + 0xae421624, 0x2bc05cc0, 0x48c1db7a, 0x4f4e63b4, 0x1667f04e, 0x34020f94, + 0x972b2555, 0x9a07355b, 0x01665970, 0x7db60c6f, 0x3ad7103b, 0x5c3d09c0, + 0xeea3dada, 0x88c21c10, 0x102436d7, 0x6a3b3400, 0xeb523c4c, 0xfb97d896, + 0x964cb86b, 0xdd878038, 0x0529da4d, 0x0b1468a5, 0x18739ac8, 0xf7f26668, + 0xf64f4471, 0x5c14f5c3, 0x44a081fb, 0x39ac7e37, 0x8a17c26b, 0x868f5e67, + 0x3931978d, 0x6edf7817, 0x4951cc67, 0x943407f3, 0xcc5e748f, 0x2b7ee729, + 0xcbb320f0, 0x11fec8e7, 0xfccfc658, 0x03454354, 0x373aa1ec, 0x1d58fe9a, + 0x064710ae, 0xa88aa0ba, 0xd183a23e, 0x40d150a3, 0xf531b8d1, 0xa7d99f85, + 0x11838cd5, 0xb19e64b3, 0x3d67a5e9, 0xb02c5ac6, 0x99b9b9e8, 0x4c202b7a, + 0x15f261d3, 0xa84c2d0d, 0x50f185a6, 0x33ba41d5, 0x39791013, 0x4baff44e, + 0xeeeeaa1c, 0xe0488314, 0x559ccd2b, 0xa104f445, 0x636f37c4, 0x264d5e3b, + 0x75c17f35, 0x75424131, 0xbb115739, 0x74fe755a, 0x7d3a7aa6, 0x2d8be784, + 0x83ed154a, 0xfc2673d8, 0x44dd4a7f, 0x79056cc8, 0x82cc8831, 0x9d3c1b7c, + 0xe9453bfa, 0x24315694, 0x661f3253, 0x75549f5c, 0xbb2b63ed, 0x67e00d96, + 0xf48966c7, 0x0d7bea56, 0xc25f92ef, 0xa947a79d, 0xde4adf6f, 0xac0f0342, + 0xd3eb246b, 0xa4aa118e, 0x3c3e6a46, 0x457f4441, 0xa50a406f, 0x6c508d9f, + 0xe9ac18e7, 0x1ecdb4ba, 0x39ac7e3a, 0x7fb304fa, 0x6f38f8e8, 0x4aecea6d, + 0x61035e73, 0x81708907, 0xebc07205, 0x90fd7614, 0xb52d217f, 0x6c4de195, + 0x1dd49084, 0x64ee482c, 0x94c7a521, 0x540c09d8, 0x75df8dd5, 0x414131f7, + 0x3698fd76, 0xf784db4f, 0xf8c97a03, 0x048f39b9, 0x3bf4f0bd, 0x8cb50992, + 0x9b58d9ee, 0xe5ab79cc, 0x9a5f6052, 0xbd9591b0, 0xfad2232b, 0x5a632254, + 0x0286e618, 0x8ad3c8f7, 0xe4060176, 0x754c4617, 0x5c10490b, 0x6f7d6fff, + 0x2187b42a, 0x5775095b, 0x02f4c663, 0x5a5dca06, 0xfe4ad4c7, 0x53e19f7d, + 0x59ff46b5, 0xbcc42ba5, 0xfd2f4a97, 0xbed6d905, 0x95629b6b, 0x21a1c0db, + 0xaa10b45d, 0xe6ef6d58, 0x2892cf4d, 0x9fed6c10, 0x1e386bf7, 0x9be0c6e8, + 0x2b2f15ef, 0x19f5ac7b, 0x7aff0e72, 0x31da576f, 0x30252cb4, 0x577960ac, + 0x166e9e5a, 0xa9374a61, 0x71369c96, 0x7ff826ae, 0xe8175326, 0xcabbfd33, + 0x0191190e, 0x699d3c3e, 0x36b40b22, 0xb3950513, 0x9b889bfa, 0xa52a5007, + 0xac290fed, 0x3b4e4a4f, 0xb753d8d6, 0x3c531f22, 0x582f6427, 0xa9cd93a9, + 0x546e39ae, 0x242faad2, 0xd2e0f747, 0x09f6325d, 0x59d48719, 0xad7eb66e, + 0xd5512878, 0x56debf9d, 0x5107e5a5, 0xf1c00aa4, 0x814ccca8, 0x600d90f0, + 0x9be97619, 0x915fa5f2, 0x2b5628dd, 0xa33d5f5a, 0x595df7c1, 0x6966215d, + 0x50ec8337, 0xf1d21372, 0x0ee2eefb, 0xad9e70b7, 0xab0d2fe4, 0xcf277b5d, + 0x62585a2c, 0x835a7844, 0x74b1fa6b, 0x49baffd5, 0x2ea9c864, 0x129311a8, + 0xbdfa1867, 0x83ca5997, 0x9d1db719, 0x84bb79e6, 0x9e3f99f2, 0x313f6101, + 0x1b99245b, 0xd15d8fb2, 0xcef90f81, 0x2945268d, 0xdbbcf573, 0xb1021886, + 0x9ee7ec1d, 0x1cf824f7, 0x7eaa2e32, 0x69c0a2b5, 0x7494419c, 0xe253d7d3, + 0x48da3d12, 0x45b8b571, 0xdb4d147a, 0xd82d8dde, 0x265d10a2, 0xb0a6eb9a, + 0x7e1c93a6, 0x36fe2f46, 0xdcad6b00, 0x05439191, 0xb0ce5484, 0x61d1c309, + 0x8da62a03, 0x06d0fe2f, 0xbac6dd3c, 0xca2006f3, 0x8321b1af, 0x0411a6f3, + 0xe8918eac, 0x21a2c152, 0x91c0d54f, 0x6aaa14fa, 0xdd22a440, 0x88cb2075, + 0x7a4eb813, 0x67afa071, 0xd8d98c9c, 0x31f10d47, 0x6ff1a8a8, 0x2faaf0a1, + 0x48a221bb, 0x3be6948b, 0xaa79e79b, 0x0ea7278c, 0x7a3857ef, 0x49b7fe55, + 0xd51cb931, 0x041c018d, 0x00b90501, 0x45ea7881, 0x8fc1dbcf, 0xb80b32a9, + 0xabacd2e9, 0x677bdc40, 0xecace542, 0x6d6514eb, 0x31c09ff7, 0x5e6c1abd, + 0x1c391d0f, 0x0e9d77f1, 0x7119392d, 0x6be9b0ba, 0x6194fa77, 0x45e62148, + 0x42234af2, 0xc3239d66, 0x939cbdbc, 0x56200d9c, 0x6b275208, 0x001a61f3, + 0xccc2a546, 0x4b722be0, 0xee25f2b7, 0x6d86cf9e, 0xaa6be0cd, 0x4dcda7b6, + 0x78d4aa13, 0x36ea7ad9, 0x3f29d700, 0xdeea2d84, 0x6a6af5bd, 0x18afb81c, + 0xd8e4e73c, 0x8aa708ba, 0x658b94d9, 0xa676478c, 0xcfa10c22, 0x25593c74, + 0x8d962235, 0x5f980270, 0x3df6ebc0, 0x8e7d92fa, 0xc3ee55e1, 0xd5f72447, + 0x02b0fa95, 0x52b0b520, 0x70d2c11f, 0x3a6fdd6c, 0x193aa698, 0x5496f7d5, + 0x4208931b, 0x7a4106ec, 0x83e86840, 0xf49b6f8c, 0xba3d9a51, 0x55f54ddd, + 0x2de51372, 0x9afb571b, 0x3ab35406, 0xad64ff1f, 0xc77764fe, 0x7f864466, + 0x416d9cd4, 0xa2489278, 0xe30b86e4, 0x0b5231b6, 0xba67aed6, 0xe5ab2467, + 0x60028b90, 0x1d9e20c6, 0x2a7c692a, 0x6b691cdb, 0x9e51f817, 0x9b763dec, + 0x3d29323f, 0xcfe12b68, 0x754b459b, 0xa2238047, 0xd9c55514, 0x6bdcffc1, + 0x693e6340, 0x82383fe7, 0x1916ea5f, 0xec7bcd59, 0x72de165a, 0xe79a1617, + 0x8ec86234, 0xa8f0d284, 0x20c90226, 0x7bf98884, 0x28a58331, 0x3ec3fa6e, + 0x4ce0895b, 0xc353b4d0, 0x33ef064f, 0x21e5e210, 0xc8bb589d, 0xe85dcab2, + 0xac65829f, 0xa7bf92d0, 0x05a6174d, 0x25a50c2e, 0xe5c78777, 0x3d75021f, + 0x4baa9c98, 0x23bdc884, 0x9653bbd7, 0xbadce7f5, 0xc283a484, 0xc040df2e, + 0x9370a841, 0x2f316022, 0x36eed231, 0xac2cbc0c, 0x13c0a49b, 0xcdd12997, + 0x07fe91b2, 0xcd7eabcd, 0x2c01271d, 0x18432df8, 0x599c6bc7, 0x75e93d5a, + 0xb67a6ee2, 0x8e738e16, 0xff9073fd, 0xaf77026a, 0xf86ea2fc, 0x91509ea3, + 0x33a78dc6, 0x4f79234a, 0x3a7535bc, 0x3539fcb1, 0x3103ee52, 0x4f6f1e69, + 0x6bb3ebbc, 0x4cb77555, 0x8dd1e999, 0x2ade439d, 0x11521fae, 0xb94d2545, + 0x8dde9abd, 0x1909393f, 0xb792a23d, 0x749c455b, 0xb5b60f2c, 0x380459ce, + 0x0dad5820, 0xb130845b, 0x291cbd52, 0xde9a5bb7, 0x51def961, 0x515b6408, + 0xca6e823e, 0x382e6e74, 0xeebe3d71, 0x4c8f0c6a, 0xe676dcea, 0x14e1dc7c, + 0x6f7fc634, 0xcf85a943, 0xd39ea96e, 0x136e7c93, 0x7164b304, 0xf32f1333, + 0x35c34034, 0xde39d721, 0x91a87439, 0xc410111f, 0x29f17aac, 0x1316a6ff, + 0x12f194ee, 0x420b9499, 0xf72db0dc, 0x690b9f93, 0x17d14bb2, 0x8f931ab8, + 0x217500bc, 0x875413f8, 0x98b2e43d, 0xc51f9571, 0x54cebdca, 0x0719cc79, + 0xf3c7080d, 0xe4286771, 0xa3eab3cd, 0x4a6b00e0, 0x11cf0759, 0x7e897379, + 0x5b32876c, 0x5e8cd4f6, 0x0cedfa64, 0x919ac2c7, 0xb214f3b3, 0x0e89c38c, + 0xf0c43a39, 0xeae10522, 0x835bce06, 0x9eec43c2, 0xea26a9d6, 0x69531821, + 0x6725b24a, 0xda81b0e2, 0xd5b4ae33, 0x080f99fb, 0x15a83daf, 0x29dfc720, + 0x91e1900f, 0x28163d58, 0x83d107a2, 0x4eac149a, 0x9f71da18, 0x61d5c4fa, + 0xe3ab2a5f, 0xc7b0d63f, 0xb3cc752a, 0x61ebcfb6, 0x26ffb52a, 0xed789e3f, + 0xaa3bc958, 0x455a8788, 0xc9c082a9, 0x0a1bef0e, 0xc29a5a7e, 0x150d4735, + 0x943809e0, 0x69215510, 0xef0b0da9, 0x3b4e9fb3, 0xd8b5d04c, 0xc7a023a8, + 0xb0d50288, 0x64821375, 0xc260e8cf, 0x8496bd2c, 0xff4f5435, 0x0fb5560c, + 0x7cd74a52, 0x93589c80, 0x88975c47, 0x83bda89d, 0x8bcc4296, 0x01b82c21, + 0xfd821dbf, 0x26520b47, 0x04983e19, 0xd3e1ca27, 0x782c580f, 0x326ff573, + 0xc157bcc7, 0x4f5e6b84, 0x44ebfbfb, 0xda26d9d8, 0x6cd9d08e, 0x1719f1d8, + 0x715c0487, 0x2c2d3c92, 0x53faaba9, 0xbc836146, 0x510c92d6, 0xe089f82a, + 0x4680171f, 0x369f00de, 0x70ec2331, 0x0e253d55, 0xdafb9717, 0xe5dd922d, + 0x95915d21, 0xa0202f96, 0xa161cc47, 0xeacfa6f1, 0xed5e9189, 0xdab87684, + 0xa4b76d4a, 0xfa704897, 0x631f10ba, 0xd39da8f9, 0x5db4c0e4, 0x16fde42a, + 0x2dff7580, 0xb56fec7e, 0xc3ffb370, 0x8e6f36bc, 0x6097d459, 0x514d5d36, + 0xa5a737e2, 0x3977b9b3, 0xfd31a0ca, 0x903368db, 0xe8370d61, 0x98109520, + 0xade23cac, 0x99f82e04, 0x41de7ea3, 0x84a1c295, 0x09191be0, 0x30930d02, + 0x1c9fa44a, 0xc406b6d7, 0xeedca152, 0x6149809c, 0xb0099ef4, 0xc5f653a5, + 0x4c10790d, 0x7303286c }; diff --git a/dep/libmpq/libmpq/explode.h b/dep/libmpq/libmpq/explode.h index 1d14dfc0e..007ee88f1 100644 --- a/dep/libmpq/libmpq/explode.h +++ b/dep/libmpq/libmpq/explode.h @@ -28,60 +28,87 @@ #define _EXPLODE_H /* define compression constants and return values. */ -#define LIBMPQ_PKZIP_CMP_BINARY 0 /* binary compression. */ -#define LIBMPQ_PKZIP_CMP_ASCII 1 /* ascii compression. */ -#define LIBMPQ_PKZIP_CMP_NO_ERROR 0 -#define LIBMPQ_PKZIP_CMP_INV_DICTSIZE 1 -#define LIBMPQ_PKZIP_CMP_INV_MODE 2 -#define LIBMPQ_PKZIP_CMP_BAD_DATA 3 -#define LIBMPQ_PKZIP_CMP_ABORT 4 +#define LIBMPQ_PKZIP_CMP_BINARY 0 /* binary compression. */ +#define LIBMPQ_PKZIP_CMP_ASCII 1 /* ascii compression. */ +#define LIBMPQ_PKZIP_CMP_NO_ERROR 0 +#define LIBMPQ_PKZIP_CMP_INV_DICTSIZE 1 +#define LIBMPQ_PKZIP_CMP_INV_MODE 2 +#define LIBMPQ_PKZIP_CMP_BAD_DATA 3 +#define LIBMPQ_PKZIP_CMP_ABORT 4 + +/* define true and false, because not all systems have them. */ +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +#ifdef _MSC_VER +#pragma pack(push,1) +#define PACK_STRUCT +#else +//#error "pack_begin.h may not be included twice!" +/* we assume GNU here */ +#define PACK_STRUCT __attribute__((packed)) +#endif -#include "pack_begin.h" /* compression structure. */ -typedef struct { - uint32_t offs0000; /* 0000 - start. */ - uint32_t cmp_type; /* 0004 - compression type (binary or ascii). */ - uint32_t out_pos; /* 0008 - position in output buffer. */ - uint32_t dsize_bits; /* 000C - dict size (4, 5, 6 for 0x400, 0x800, 0x1000). */ - uint32_t dsize_mask; /* 0010 - dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000). */ - uint32_t bit_buf; /* 0014 - 16-bit buffer for processing input data. */ - uint32_t extra_bits; /* 0018 - number of extra (above 8) bits in bit buffer. */ - uint32_t in_pos; /* 001C - position in in_buf. */ - uint32_t in_bytes; /* 0020 - number of bytes in input buffer. */ - void *param; /* 0024 - custom parameter. */ - uint32_t (*read_buf)(char *buf, uint32_t *size, void *param); /* 0028 offset.*/ - void (*write_buf)(char *buf, uint32_t *size, void *param); /* 002C offset. */ - uint8_t out_buf[0x2000]; /* 0030 - output circle buffer, starting position is 0x1000. */ - uint8_t offs_2030[0x204]; /* 2030 - whats that? */ - uint8_t in_buf[0x800]; /* 2234 - buffer for data to be decompressed. */ - uint8_t pos1[0x100]; /* 2A34 - positions in buffers. */ - uint8_t pos2[0x100]; /* 2B34 - positions in buffers. */ - uint8_t offs_2c34[0x100]; /* 2C34 - buffer. */ - uint8_t offs_2d34[0x100]; /* 2D34 - buffer. */ - uint8_t offs_2e34[0x80]; /* 2EB4 - buffer. */ - uint8_t offs_2eb4[0x100]; /* 2EB4 - buffer. */ - uint8_t bits_asc[0x100]; /* 2FB4 - buffer. */ - uint8_t dist_bits[0x40]; /* 30B4 - numbers of bytes to skip copied block length. */ - uint8_t slen_bits[0x10]; /* 30F4 - numbers of bits for skip copied block length. */ - uint8_t clen_bits[0x10]; /* 3104 - number of valid bits for copied block. */ - uint16_t len_base[0x10]; /* 3114 - buffer. */ +typedef struct +{ + uint32_t offs0000; /* 0000 - start. */ + uint32_t cmp_type; /* 0004 - compression type (binary or ascii). */ + uint32_t out_pos; /* 0008 - position in output buffer. */ + uint32_t dsize_bits; /* 000C - dict size (4, 5, 6 for 0x400, 0x800, 0x1000). */ + uint32_t dsize_mask; /* 0010 - dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000). */ + uint32_t bit_buf; /* 0014 - 16-bit buffer for processing input data. */ + uint32_t extra_bits; /* 0018 - number of extra (above 8) bits in bit buffer. */ + uint32_t in_pos; /* 001C - position in in_buf. */ + uint32_t in_bytes; /* 0020 - number of bytes in input buffer. */ + void *param; /* 0024 - custom parameter. */ + uint32_t (*read_buf)(char *buf, uint32_t *size, void *param); /* 0028 offset.*/ + void (*write_buf)(char *buf, uint32_t *size, void *param); /* 002C offset. */ + uint8_t out_buf[0x2000]; /* 0030 - output circle buffer, starting position is 0x1000. */ + uint8_t offs_2030[0x204]; /* 2030 - whats that? */ + uint8_t in_buf[0x800]; /* 2234 - buffer for data to be decompressed. */ + uint8_t pos1[0x100]; /* 2A34 - positions in buffers. */ + uint8_t pos2[0x100]; /* 2B34 - positions in buffers. */ + uint8_t offs_2c34[0x100]; /* 2C34 - buffer. */ + uint8_t offs_2d34[0x100]; /* 2D34 - buffer. */ + uint8_t offs_2e34[0x80]; /* 2EB4 - buffer. */ + uint8_t offs_2eb4[0x100]; /* 2EB4 - buffer. */ + uint8_t bits_asc[0x100]; /* 2FB4 - buffer. */ + uint8_t dist_bits[0x40]; /* 30B4 - numbers of bytes to skip copied block length. */ + uint8_t slen_bits[0x10]; /* 30F4 - numbers of bits for skip copied block length. */ + uint8_t clen_bits[0x10]; /* 3104 - number of valid bits for copied block. */ + uint16_t len_base[0x10]; /* 3114 - buffer. */ } PACK_STRUCT pkzip_cmp_s; -#include "pack_end.h" + +#ifdef _PACK_BEGIN +#undef _PACK_BEGIN +#endif + +#ifdef _MSC_VER +#pragma pack(pop) +#endif + +#undef PACK_STRUCT /* data structure. */ -typedef struct { - uint8_t *in_buf; /* pointer to input data buffer. */ - uint32_t in_pos; /* current offset in input data buffer. */ - int32_t in_bytes; /* number of bytes in the input buffer. */ - uint8_t *out_buf; /* pointer to output data buffer. */ - uint32_t out_pos; /* position in the output buffer. */ - int32_t max_out; /* maximum number of bytes in the output buffer. */ +typedef struct +{ + uint8_t *in_buf; /* pointer to input data buffer. */ + uint32_t in_pos; /* current offset in input data buffer. */ + int32_t in_bytes; /* number of bytes in the input buffer. */ + uint8_t *out_buf; /* pointer to output data buffer. */ + uint32_t out_pos; /* position in the output buffer. */ + int32_t max_out; /* maximum number of bytes in the output buffer. */ } pkzip_data_s; /* decompress the stream using pkzip compression. */ uint32_t libmpq__do_decompress_pkzip( - uint8_t *work_buf, - void *param + uint8_t *work_buf, + void *param ); -#endif /* _EXPLODE_H */ +#endif /* _EXPLODE_H */ diff --git a/dep/libmpq/libmpq/extract.h b/dep/libmpq/libmpq/extract.h index d6ea794f1..695bc7c70 100644 --- a/dep/libmpq/libmpq/extract.h +++ b/dep/libmpq/libmpq/extract.h @@ -16,18 +16,18 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ + */ #ifndef _EXTRACT_H #define _EXTRACT_H /* define compression types for multilpe compressions. */ -#define LIBMPQ_COMPRESSION_HUFFMAN 0x01 /* huffman compression. (used on wave files only and introduced in starcraft) */ -#define LIBMPQ_COMPRESSION_ZLIB 0x02 /* zlib compression. (introduced in warcraft 3) */ -#define LIBMPQ_COMPRESSION_PKZIP 0x08 /* pkware dcl compression. (first used compression algorithm) */ -#define LIBMPQ_COMPRESSION_BZIP2 0x10 /* bzip compression. (introduced in warcraft 3 - the frozen throne) */ -#define LIBMPQ_COMPRESSION_WAVE_MONO 0x40 /* adpcm 4:1 compression. (introduced in starcraft) */ -#define LIBMPQ_COMPRESSION_WAVE_STEREO 0x80 /* adpcm 4:1 compression. (introduced in starcraft) */ +#define LIBMPQ_COMPRESSION_HUFFMAN 0x01 /* huffman compression. (used on wave files only and introduced in starcraft) */ +#define LIBMPQ_COMPRESSION_ZLIB 0x02 /* zlib compression. (introduced in warcraft 3) */ +#define LIBMPQ_COMPRESSION_PKZIP 0x08 /* pkware dcl compression. (first used compression algorithm) */ +#define LIBMPQ_COMPRESSION_BZIP2 0x10 /* bzip compression. (introduced in warcraft 3 - the frozen throne) */ +#define LIBMPQ_COMPRESSION_WAVE_MONO 0x40 /* adpcm 4:1 compression. (introduced in starcraft) */ +#define LIBMPQ_COMPRESSION_WAVE_STEREO 0x80 /* adpcm 4:1 compression. (introduced in starcraft) */ /* * table for decompression functions, return value for all functions @@ -36,10 +36,11 @@ * LIBMPQ_ERROR_MALLOC * LIBMPQ_ERROR_DECOMPRESS */ -typedef int32_t (*DECOMPRESS)(uint8_t *, uint32_t, uint8_t *, uint32_t); -typedef struct { - uint32_t mask; /* decompression bit. */ - DECOMPRESS decompress; /* decompression function. */ +typedef int32_t (*DECOMPRESS)(uint8_t *, uint32_t, uint8_t *, uint32_t); +typedef struct +{ + uint32_t mask; /* decompression bit. */ + DECOMPRESS decompress; /* decompression function. */ } decompress_table_s; /* @@ -49,58 +50,58 @@ typedef struct { * 1500F5F0 */ extern int32_t libmpq__decompress_huffman( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size ); /* decompression using zlib. */ extern int32_t libmpq__decompress_zlib( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size ); /* decompression using pkzip. */ extern int32_t libmpq__decompress_pkzip( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size ); /* decompression using bzip2. */ extern int32_t libmpq__decompress_bzip2( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size ); /* decompression using wave. (1 channel) */ extern int32_t libmpq__decompress_wave_mono( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size ); /* decompression using wave. (2 channels) */ extern int32_t libmpq__decompress_wave_stereo( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size ); /* decompression using multiple of the above algorithm. */ extern int32_t libmpq__decompress_multi( - uint8_t *in_buf, - uint32_t in_size, - uint8_t *out_buf, - uint32_t out_size + uint8_t *in_buf, + uint32_t in_size, + uint8_t *out_buf, + uint32_t out_size ); -#endif /* _EXTRACT_H */ +#endif /* _EXTRACT_H */ diff --git a/dep/libmpq/libmpq/huffman.h b/dep/libmpq/libmpq/huffman.h index 6f691088f..55da55950 100644 --- a/dep/libmpq/libmpq/huffman.h +++ b/dep/libmpq/libmpq/huffman.h @@ -28,124 +28,129 @@ #define _HUFFMAN_H /* define huffman compression and decompression values. */ -#define LIBMPQ_HUFF_DECOMPRESS 0 /* we want to decompress using huffman trees. */ +#define LIBMPQ_HUFF_DECOMPRESS 0 /* we want to decompress using huffman trees. */ /* define pointer conversions. */ -#define PTR_NOT(ptr) (struct huffman_tree_item_s *)(~(unsigned long)(ptr)) -#define PTR_PTR(ptr) ((struct huffman_tree_item_s *)(ptr)) -#define PTR_INT(ptr) (long)(ptr) +#define PTR_NOT(ptr) (struct huffman_tree_item_s *)(~(unsigned long)(ptr)) +#define PTR_PTR(ptr) ((struct huffman_tree_item_s *)(ptr)) +#define PTR_INT(ptr) (long)(ptr) /* define item handling. */ -#define INSERT_ITEM 1 /* insert item into huffman tree. */ -#define SWITCH_ITEMS 2 /* switch items isnide huffman tree. */ +#define INSERT_ITEM 1 /* insert item into huffman tree. */ +#define SWITCH_ITEMS 2 /* switch items isnide huffman tree. */ /* input stream for huffman decompression. */ -struct huffman_input_stream_s { - uint8_t *in_buf; /* 00 - input data. */ - uint32_t bit_buf; /* 04 - input bit buffer. */ - uint32_t bits; /* 08 - number of bits remaining in byte. */ +struct huffman_input_stream_s +{ + uint8_t *in_buf; /* 00 - input data. */ + uint32_t bit_buf; /* 04 - input bit buffer. */ + uint32_t bits; /* 08 - number of bits remaining in byte. */ }; /* huffman tree item. */ -struct huffman_tree_item_s { - struct huffman_tree_item_s *next; /* 00 - pointer to next huffman tree item. */ - struct huffman_tree_item_s *prev; /* 04 - pointer to prev huffman tree item (< 0 if none). */ - uint32_t dcmp_byte; /* 08 - index of this item in item pointer array, decompressed byte value. */ - uint32_t byte_value; /* 0C - some byte value. */ - struct huffman_tree_item_s *parent; /* 10 - pointer to parent huffman tree item (NULL if none). */ - struct huffman_tree_item_s *child; /* 14 - pointer to child huffman tree item. */ +struct huffman_tree_item_s +{ + struct huffman_tree_item_s *next; /* 00 - pointer to next huffman tree item. */ + struct huffman_tree_item_s *prev; /* 04 - pointer to prev huffman tree item (< 0 if none). */ + uint32_t dcmp_byte; /* 08 - index of this item in item pointer array, decompressed byte value. */ + uint32_t byte_value; /* 0C - some byte value. */ + struct huffman_tree_item_s *parent; /* 10 - pointer to parent huffman tree item (NULL if none). */ + struct huffman_tree_item_s *child; /* 14 - pointer to child huffman tree item. */ }; /* structure used for quick decompression. */ -struct huffman_decompress_s { - uint32_t offs00; /* 00 - 1 if resolved. */ - uint32_t bits; /* 04 - bit count. */ - union { - uint32_t dcmp_byte; /* 08 - byte value for decompress (if bitCount <= 7). */ - struct huffman_tree_item_s *p_item; /* 08 - huffman tree item (if number of bits is greater than 7). */ - }; +struct huffman_decompress_s +{ + uint32_t offs00; /* 00 - 1 if resolved. */ + uint32_t bits; /* 04 - bit count. */ + union + { + uint32_t dcmp_byte; /* 08 - byte value for decompress (if bitCount <= 7). */ + struct huffman_tree_item_s *p_item; /* 08 - huffman tree item (if number of bits is greater than 7). */ + }; }; /* structure for huffman tree. */ -struct huffman_tree_s { - uint32_t cmp0; /* 0000 - 1 if compression type 0. */ - uint32_t offs0004; /* 0004 - some flag. */ - struct huffman_tree_item_s items0008[0x203]; /* 0008 - huffman tree items. */ - struct huffman_tree_item_s *item3050; /* 3050 - always NULL? */ - struct huffman_tree_item_s *item3054; /* 3054 - pointer to huffman tree item. */ - struct huffman_tree_item_s *item3058; /* 3058 - pointer to huffman tree item (< 0 if invalid). */ - struct huffman_tree_item_s *item305C; /* 305C - usually NULL. */ - struct huffman_tree_item_s *first; /* 3060 - pointer to top (first) huffman tree item. */ - struct huffman_tree_item_s *last; /* 3064 - pointer to bottom (last) huffman tree item (< 0 if invalid). */ - uint32_t items; /* 3068 - number of used huffman tree items. */ - struct huffman_tree_item_s *items306C[0x102]; /* 306C - huffman tree item pointer array. */ - struct huffman_decompress_s qd3474[0x80]; /* 3474 - array for quick decompression. */ - uint8_t table_1502A630[]; /* some table to make struct size flexible. */ +struct huffman_tree_s +{ + uint32_t cmp0; /* 0000 - 1 if compression type 0. */ + uint32_t offs0004; /* 0004 - some flag. */ + struct huffman_tree_item_s items0008[0x203]; /* 0008 - huffman tree items. */ + struct huffman_tree_item_s *item3050; /* 3050 - always NULL? */ + struct huffman_tree_item_s *item3054; /* 3054 - pointer to huffman tree item. */ + struct huffman_tree_item_s *item3058; /* 3058 - pointer to huffman tree item (< 0 if invalid). */ + struct huffman_tree_item_s *item305C; /* 305C - usually NULL. */ + struct huffman_tree_item_s *first; /* 3060 - pointer to top (first) huffman tree item. */ + struct huffman_tree_item_s *last; /* 3064 - pointer to bottom (last) huffman tree item (< 0 if invalid). */ + uint32_t items; /* 3068 - number of used huffman tree items. */ + struct huffman_tree_item_s *items306C[0x102]; /* 306C - huffman tree item pointer array. */ + struct huffman_decompress_s qd3474[0x80]; /* 3474 - array for quick decompression. */ + uint8_t table_1502A630[]; /* some table to make struct size flexible. */ }; /* insert a new item into huffman tree. */ void libmpq__huffman_insert_item( - struct huffman_tree_item_s **p_item, - struct huffman_tree_item_s *item, - uint32_t where, - struct huffman_tree_item_s *item2 + struct huffman_tree_item_s **p_item, + struct huffman_tree_item_s *item, + uint32_t where, + struct huffman_tree_item_s *item2 ); /* remove item from huffman tree. */ void libmpq__huffman_remove_item( - struct huffman_tree_item_s *hi + struct huffman_tree_item_s *hi ); /* get previous item from huffman tree. */ struct huffman_tree_item_s *libmpq__huffman_previous_item( - struct huffman_tree_item_s *hi, - long value + struct huffman_tree_item_s *hi, + long value ); /* get one bit from stream. */ uint32_t libmpq__huffman_get_1bit( - struct huffman_input_stream_s *is + struct huffman_input_stream_s *is ); /* get seven bit from stream. */ uint32_t libmpq__huffman_get_7bit( - struct huffman_input_stream_s *is + struct huffman_input_stream_s *is ); /* get eight bit from stream. */ uint32_t libmpq__huffman_get_8bit( - struct huffman_input_stream_s *is + struct huffman_input_stream_s *is ); /* call 1500E740. */ struct huffman_tree_item_s *libmpq__huffman_call_1500E740( - struct huffman_tree_s *ht + struct huffman_tree_s *ht ); /* call 1500E820- */ void libmpq__huffman_call_1500E820( - struct huffman_tree_s *ht, - struct huffman_tree_item_s *p_item + struct huffman_tree_s *ht, + struct huffman_tree_item_s *p_item ); /* initialize the huffman tree. */ void libmpq__huffman_tree_init( - struct huffman_tree_s *ht, - uint32_t cmp + struct huffman_tree_s *ht, + uint32_t cmp ); /* build the huffman tree. */ void libmpq__huffman_tree_build( - struct huffman_tree_s *ht, - uint32_t cmp_type + struct huffman_tree_s *ht, + uint32_t cmp_type ); /* decompress the stream using huffman compression. */ int32_t libmpq__do_decompress_huffman( - struct huffman_tree_s *ht, - struct huffman_input_stream_s *is, - uint8_t *out_buf, - uint32_t out_length + struct huffman_tree_s *ht, + struct huffman_input_stream_s *is, + uint8_t *out_buf, + uint32_t out_length ); -#endif /* _HUFFMAN_H */ +#endif /* _HUFFMAN_H */ diff --git a/dep/libmpq/libmpq/mpq-internal.h b/dep/libmpq/libmpq/mpq-internal.h index bfa9d25c9..8a5683101 100644 --- a/dep/libmpq/libmpq/mpq-internal.h +++ b/dep/libmpq/libmpq/mpq-internal.h @@ -27,32 +27,32 @@ #include /* define return value if nothing failed. */ -#define LIBMPQ_SUCCESS 0 /* return value for all functions which success. */ +#define LIBMPQ_SUCCESS 0 /* return value for all functions which success. */ /* define generic mpq archive information. */ -#define LIBMPQ_HEADER 0x1A51504D /* mpq archive header ('MPQ\x1A') */ +#define LIBMPQ_HEADER 0x1A51504D /* mpq archive header ('MPQ\x1A') */ /* define the known archive versions. */ -#define LIBMPQ_ARCHIVE_VERSION_ONE 0 /* version one used until world of warcraft. */ -#define LIBMPQ_ARCHIVE_VERSION_TWO 1 /* version two used from world of warcraft - the burning crusade. */ +#define LIBMPQ_ARCHIVE_VERSION_ONE 0 /* version one used until world of warcraft. */ +#define LIBMPQ_ARCHIVE_VERSION_TWO 1 /* version two used from world of warcraft - the burning crusade. */ /* define values used by blizzard as flags. */ -#define LIBMPQ_FLAG_EXISTS 0x80000000 /* set if file exists, reset when the file was deleted. */ -#define LIBMPQ_FLAG_ENCRYPTED 0x00010000 /* indicates whether file is encrypted. */ -#define LIBMPQ_FLAG_COMPRESSED 0x0000FF00 /* file is compressed. */ -#define LIBMPQ_FLAG_COMPRESS_PKZIP 0x00000100 /* compression made by pkware data compression library. */ -#define LIBMPQ_FLAG_COMPRESS_MULTI 0x00000200 /* multiple compressions. */ -#define LIBMPQ_FLAG_COMPRESS_NONE 0x00000300 /* no compression (no blizzard flag used by myself). */ -#define LIBMPQ_FLAG_SINGLE 0x01000000 /* file is stored in one single sector, first seen in world of warcraft. */ -#define LIBMPQ_FLAG_EXTRA 0x04000000 /* compressed block offset table has one extra entry. */ +#define LIBMPQ_FLAG_EXISTS 0x80000000 /* set if file exists, reset when the file was deleted. */ +#define LIBMPQ_FLAG_ENCRYPTED 0x00010000 /* indicates whether file is encrypted. */ +#define LIBMPQ_FLAG_COMPRESSED 0x0000FF00 /* file is compressed. */ +#define LIBMPQ_FLAG_COMPRESS_PKZIP 0x00000100 /* compression made by pkware data compression library. */ +#define LIBMPQ_FLAG_COMPRESS_MULTI 0x00000200 /* multiple compressions. */ +#define LIBMPQ_FLAG_COMPRESS_NONE 0x00000300 /* no compression (no blizzard flag used by myself). */ +#define LIBMPQ_FLAG_SINGLE 0x01000000 /* file is stored in one single sector, first seen in world of warcraft. */ +#define LIBMPQ_FLAG_EXTRA 0x04000000 /* compressed block offset table has one extra entry. */ /* define generic hash values. */ -#define LIBMPQ_HASH_FREE 0xFFFFFFFF /* hash table entry is empty and has always been empty. */ +#define LIBMPQ_HASH_FREE 0xFFFFFFFF /* hash table entry is empty and has always been empty. */ /* define special files. */ -#define LIBMPQ_LISTFILE_NAME "(listfile)" /* internal listfile. */ -#define LIBMPQ_SIGNATURE_NAME "(signature)" /* internal signature file. */ -#define LIBMPQ_ATTRIBUTES_NAME "(attributes)" /* internal attributes file. */ +#define LIBMPQ_LISTFILE_NAME "(listfile)" /* internal listfile. */ +#define LIBMPQ_SIGNATURE_NAME "(signature)" /* internal signature file. */ +#define LIBMPQ_ATTRIBUTES_NAME "(attributes)" /* internal attributes file. */ /* define true and false, because not all systems have them. */ #ifndef FALSE @@ -62,84 +62,109 @@ #define TRUE 1 #endif -#include "pack_begin.h" +#ifdef _MSC_VER +#pragma pack(push,1) +#define PACK_STRUCT +#else +//#error "pack_begin.h may not be included twice!" +/* we assume GNU here */ +#define PACK_STRUCT __attribute__((packed)) +#endif + /* mpq archive header. */ -typedef struct { - uint32_t mpq_magic; /* the 0x1A51504D ('MPQ\x1A') signature. */ - uint32_t header_size; /* mpq archive header size. */ - uint32_t archive_size; /* size of mpq archive. */ - uint16_t version; /* 0000 for starcraft and broodwar. */ - uint16_t block_size; /* size of file block is (512 * 2 ^ block size). */ - uint32_t hash_table_offset; /* file position of mpq_hash. */ - uint32_t block_table_offset; /* file position of mpq_block, each entry has 16 bytes. */ - uint32_t hash_table_count; /* number of entries in hash table. */ - uint32_t block_table_count; /* number of entries in the block table. */ +typedef struct +{ + uint32_t mpq_magic; /* the 0x1A51504D ('MPQ\x1A') signature. */ + uint32_t header_size; /* mpq archive header size. */ + uint32_t archive_size; /* size of mpq archive. */ + uint16_t version; /* 0000 for starcraft and broodwar. */ + uint16_t block_size; /* size of file block is (512 * 2 ^ block size). */ + uint32_t hash_table_offset; /* file position of mpq_hash. */ + uint32_t block_table_offset; /* file position of mpq_block, each entry has 16 bytes. */ + uint32_t hash_table_count; /* number of entries in hash table. */ + uint32_t block_table_count; /* number of entries in the block table. */ } PACK_STRUCT mpq_header_s; /* mpq extended archive header, used since world of warcraft - the burning crusade. */ -typedef struct { - uint64_t extended_offset; /* offset to the beginning of the extended block table, relative to the beginning of the archive. */ - uint16_t hash_table_offset_high; /* upper 16 bits of the hash table offset for large archives. */ - uint16_t block_table_offset_high;/* upper 16 bits of the block table offset for large archives.*/ +typedef struct +{ + uint64_t extended_offset; /* offset to the beginning of the extended block table, relative to the beginning of the archive. */ + uint16_t hash_table_offset_high; /* upper 16 bits of the hash table offset for large archives. */ + uint16_t block_table_offset_high; /* upper 16 bits of the block table offset for large archives.*/ } PACK_STRUCT mpq_header_ex_s; /* hash entry, all files in the archive are searched by their hashes. */ -typedef struct { - uint32_t hash_a; /* the first two uint32_ts are the encrypted file. */ - uint32_t hash_b; /* the first two uint32_ts are the encrypted file. */ - uint16_t locale; /* locale information. */ - uint16_t platform; /* platform information and zero is default. */ - uint32_t block_table_index; /* index to file description block. */ +typedef struct +{ + uint32_t hash_a; /* the first two uint32_ts are the encrypted file. */ + uint32_t hash_b; /* the first two uint32_ts are the encrypted file. */ + uint16_t locale; /* locale information. */ + uint16_t platform; /* platform information and zero is default. */ + uint32_t block_table_index; /* index to file description block. */ } PACK_STRUCT mpq_hash_s; /* file description block contains informations about the file. */ -typedef struct { - uint32_t offset; /* block file starting position in the archive. */ - uint32_t packed_size; /* packed file size. */ - uint32_t unpacked_size; /* unpacked file size. */ - uint32_t flags; /* flags. */ +typedef struct +{ + uint32_t offset; /* block file starting position in the archive. */ + uint32_t packed_size; /* packed file size. */ + uint32_t unpacked_size; /* unpacked file size. */ + uint32_t flags; /* flags. */ } PACK_STRUCT mpq_block_s; /* extended file description block contains information about the offset beyond 2^32 (4GB). */ -typedef struct { - uint16_t offset_high; /* upper 16 bit of the file offset in archive. */ +typedef struct +{ + uint16_t offset_high; /* upper 16 bit of the file offset in archive. */ } PACK_STRUCT mpq_block_ex_s; /* file structure used since diablo 1.00 (0x38 bytes). */ -typedef struct { - uint32_t seed; /* seed used for file decrypt. */ - uint32_t *packed_offset; /* position of each file block (only for packed files). */ - uint32_t open_count; /* number of times it has been opened - used for freeing */ +typedef struct +{ + uint32_t seed; /* seed used for file decrypt. */ + uint32_t *packed_offset; /* position of each file block (only for packed files). */ + uint32_t open_count; /* number of times it has been opened - used for freeing */ } PACK_STRUCT mpq_file_s; /* map structure for valid blocks and hashes (first seen in warcraft 3 archives). */ -typedef struct { - uint32_t block_table_indices; /* real mapping for file number to block entry. */ - uint32_t block_table_diff; /* block table difference between valid blocks and invalid blocks before. */ +typedef struct +{ + uint32_t block_table_indices; /* real mapping for file number to block entry. */ + uint32_t block_table_diff; /* block table difference between valid blocks and invalid blocks before. */ } PACK_STRUCT mpq_map_s; -#include "pack_end.h" + +#ifdef _PACK_BEGIN +#undef _PACK_BEGIN +#endif + +#ifdef _MSC_VER +#pragma pack(pop) +#endif + +#undef PACK_STRUCT /* archive structure used since diablo 1.00 by blizzard. */ -struct mpq_archive { +struct mpq_archive +{ - /* generic file information. */ - FILE *fp; /* file handle. */ + /* generic file information. */ + FILE *fp; /* file handle. */ - /* generic size information. */ - uint32_t block_size; /* size of the mpq block. */ - off_t archive_offset; /* absolute start position of archive. */ + /* generic size information. */ + uint32_t block_size; /* size of the mpq block. */ + off_t archive_offset; /* absolute start position of archive. */ - /* archive related buffers and tables. */ - mpq_header_s mpq_header; /* mpq file header. */ - mpq_header_ex_s mpq_header_ex; /* mpq extended file header. */ - mpq_hash_s *mpq_hash; /* hash table. */ - mpq_block_s *mpq_block; /* block table. */ - mpq_block_ex_s *mpq_block_ex; /* extended block table. */ - mpq_file_s **mpq_file; /* pointer to the file pointers which are opened. */ + /* archive related buffers and tables. */ + mpq_header_s mpq_header; /* mpq file header. */ + mpq_header_ex_s mpq_header_ex; /* mpq extended file header. */ + mpq_hash_s *mpq_hash; /* hash table. */ + mpq_block_s *mpq_block; /* block table. */ + mpq_block_ex_s *mpq_block_ex; /* extended block table. */ + mpq_file_s **mpq_file; /* pointer to the file pointers which are opened. */ - /* non archive structure related members. */ - mpq_map_s *mpq_map; /* map table between valid blocks and hashes. */ - uint32_t files; /* number of files in archive, which could be extracted. */ + /* non archive structure related members. */ + mpq_map_s *mpq_map; /* map table between valid blocks and hashes. */ + uint32_t files; /* number of files in archive, which could be extracted. */ }; -#endif /* _MPQ_INTERNAL_H */ +#endif /* _MPQ_INTERNAL_H */ diff --git a/dep/libmpq/libmpq/mpq.c b/dep/libmpq/libmpq/mpq.c index 606346b7b..dcc7824a4 100644 --- a/dep/libmpq/libmpq/mpq.c +++ b/dep/libmpq/libmpq/mpq.c @@ -40,990 +40,972 @@ /* this function returns the library version information. */ const char *libmpq__version(void) { - /* return version information. */ - return VERSION; + /* return version information. */ + return VERSION; +} + +static const char *__libmpq_error_strings[] = { + "success", + "open error on file", + "close error on file", + "lseek error on file", + "read error on file", + "write error on file", + "memory allocation error", + "format errror", + "init() wasn't called", + "buffer size is to small", + "file or block does not exist in archive", + "we don't know the decryption seed", + "error on unpacking file" + }; + +/* this function returns a string message for a return code. */ +const char *libmpq__strerror(int32_t returncode) { + /* check for array bounds */ + if (-returncode < 0 || -returncode > sizeof(__libmpq_error_strings)/sizeof(char*)) + return NULL; + + /* return appropriate string */ + return __libmpq_error_strings[-returncode]; } /* this function read a file and verify if it is a valid mpq archive, then it read and decrypt the hash table. */ int32_t libmpq__archive_open(mpq_archive_s **mpq_archive, const char *mpq_filename, libmpq__off_t archive_offset) { - /* some common variables. */ - uint32_t rb = 0; - uint32_t i = 0; - uint32_t count = 0; - int32_t result = 0; - uint32_t header_search = FALSE; + /* some common variables. */ + uint32_t rb = 0; + uint32_t i = 0; + uint32_t count = 0; + int32_t result = 0; + uint32_t header_search = FALSE; + size_t rc = 0; - if (archive_offset == -1) { - archive_offset = 0; - header_search = TRUE; - } + if (archive_offset == -1) { + archive_offset = 0; + header_search = TRUE; + } - if ((*mpq_archive = calloc(1, sizeof(mpq_archive_s))) == NULL) { + if ((*mpq_archive = calloc(1, sizeof(mpq_archive_s))) == NULL) { - /* archive struct could not be allocated */ - return LIBMPQ_ERROR_MALLOC; - } + /* archive struct could not be allocated */ + return LIBMPQ_ERROR_MALLOC; + } - /* check if file exists and is readable */ - if (((*mpq_archive)->fp = fopen(mpq_filename, "rb")) == NULL) { + /* check if file exists and is readable */ + if (((*mpq_archive)->fp = fopen(mpq_filename, "rb")) == NULL) { - /* file could not be opened. */ - result = LIBMPQ_ERROR_OPEN; - goto error; - } + /* file could not be opened. */ + result = LIBMPQ_ERROR_OPEN; + goto error; + } - /* assign some default values. */ - (*mpq_archive)->mpq_header.mpq_magic = 0; - (*mpq_archive)->files = 0; + /* assign some default values. */ + (*mpq_archive)->mpq_header.mpq_magic = 0; + (*mpq_archive)->files = 0; - /* loop through file and search for mpq signature. */ - while (TRUE) { + /* loop through file and search for mpq signature. */ + while (TRUE) { - /* reset header values. */ - (*mpq_archive)->mpq_header.mpq_magic = 0; + /* reset header values. */ + (*mpq_archive)->mpq_header.mpq_magic = 0; - /* seek in file. */ - if (fseeko((*mpq_archive)->fp, archive_offset, SEEK_SET) < 0) { + /* seek in file. */ + if (fseeko((*mpq_archive)->fp, archive_offset, SEEK_SET) < 0) { - /* seek in file failed. */ - result = LIBMPQ_ERROR_SEEK; - goto error; - } + /* seek in file failed. */ + result = LIBMPQ_ERROR_SEEK; + goto error; + } - /* read header from file. */ - if ((rb = fread(&(*mpq_archive)->mpq_header, 1, sizeof(mpq_header_s), (*mpq_archive)->fp)) != sizeof(mpq_header_s)) { + /* read header from file. */ + if ((rb = fread(&(*mpq_archive)->mpq_header, 1, sizeof(mpq_header_s), (*mpq_archive)->fp)) != sizeof(mpq_header_s)) { - /* no valid mpq archive. */ - result = LIBMPQ_ERROR_FORMAT; - goto error; - } + /* no valid mpq archive. */ + result = LIBMPQ_ERROR_FORMAT; + goto error; + } - /* check if we found a valid mpq header. */ - if ((*mpq_archive)->mpq_header.mpq_magic == LIBMPQ_HEADER) { + /* check if we found a valid mpq header. */ + if ((*mpq_archive)->mpq_header.mpq_magic == LIBMPQ_HEADER) { - /* check if we process old mpq archive version. */ - if ((*mpq_archive)->mpq_header.version == LIBMPQ_ARCHIVE_VERSION_ONE) { + /* check if we process old mpq archive version. */ + if ((*mpq_archive)->mpq_header.version == LIBMPQ_ARCHIVE_VERSION_ONE) { - /* check if the archive is protected. */ - if ((*mpq_archive)->mpq_header.header_size != sizeof(mpq_header_s)) { + /* check if the archive is protected. */ + if ((*mpq_archive)->mpq_header.header_size != sizeof(mpq_header_s)) { - /* correct header size. */ - (*mpq_archive)->mpq_header.header_size = sizeof(mpq_header_s); - } - } + /* correct header size. */ + (*mpq_archive)->mpq_header.header_size = sizeof(mpq_header_s); + } + } - /* check if we process new mpq archive version. */ - if ((*mpq_archive)->mpq_header.version == LIBMPQ_ARCHIVE_VERSION_TWO) { + /* check if we process new mpq archive version. */ + if ((*mpq_archive)->mpq_header.version == LIBMPQ_ARCHIVE_VERSION_TWO) { - /* check if the archive is protected. */ - if ((*mpq_archive)->mpq_header.header_size != sizeof(mpq_header_s) + sizeof(mpq_header_ex_s)) { + /* check if the archive is protected. */ + if ((*mpq_archive)->mpq_header.header_size != sizeof(mpq_header_s) + sizeof(mpq_header_ex_s)) { - /* correct header size. */ - (*mpq_archive)->mpq_header.header_size = sizeof(mpq_header_s) + sizeof(mpq_header_ex_s); - } - } + /* correct header size. */ + (*mpq_archive)->mpq_header.header_size = sizeof(mpq_header_s) + sizeof(mpq_header_ex_s); + } + } - /* break the loop, because header was found. */ - break; - } + /* break the loop, because header was found. */ + break; + } - /* move to the next possible offset. */ - if (!header_search) { + /* move to the next possible offset. */ + if (!header_search) { - /* no valid mpq archive. */ - result = LIBMPQ_ERROR_FORMAT; - goto error; - } - archive_offset += 512; - } + /* no valid mpq archive. */ + result = LIBMPQ_ERROR_FORMAT; + goto error; + } + archive_offset += 512; + } - /* store block size for later use. */ - (*mpq_archive)->block_size = 512 << (*mpq_archive)->mpq_header.block_size; + /* store block size for later use. */ + (*mpq_archive)->block_size = 512 << (*mpq_archive)->mpq_header.block_size; - /* store archive offset and size for later use. */ - (*mpq_archive)->archive_offset = archive_offset; + /* store archive offset and size for later use. */ + (*mpq_archive)->archive_offset = (off_t)archive_offset; - /* check if we process new mpq archive version. */ - if ((*mpq_archive)->mpq_header.version == LIBMPQ_ARCHIVE_VERSION_TWO) { + /* check if we process new mpq archive version. */ + if ((*mpq_archive)->mpq_header.version == LIBMPQ_ARCHIVE_VERSION_TWO) { - /* seek in file. */ - if (fseeko((*mpq_archive)->fp, sizeof(mpq_header_s) + archive_offset, SEEK_SET) < 0) { + /* seek in file. */ + if (fseeko((*mpq_archive)->fp, sizeof(mpq_header_s) + archive_offset, SEEK_SET) < 0) { - /* seek in file failed. */ - result = LIBMPQ_ERROR_SEEK; - goto error; - } + /* seek in file failed. */ + result = LIBMPQ_ERROR_SEEK; + goto error; + } - /* read header from file. */ - if ((rb = fread(&(*mpq_archive)->mpq_header_ex, 1, sizeof(mpq_header_ex_s), (*mpq_archive)->fp)) != sizeof(mpq_header_ex_s)) { + /* read header from file. */ + if ((rb = fread(&(*mpq_archive)->mpq_header_ex, 1, sizeof(mpq_header_ex_s), (*mpq_archive)->fp)) != sizeof(mpq_header_ex_s)) { - /* no valid mpq archive. */ - result = LIBMPQ_ERROR_FORMAT; - goto error; - } - } + /* no valid mpq archive. */ + result = LIBMPQ_ERROR_FORMAT; + goto error; + } + } - /* allocate memory for the block table, hash table, file and block table to file mapping. */ - if (((*mpq_archive)->mpq_block = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_block_s))) == NULL || - ((*mpq_archive)->mpq_block_ex = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_block_ex_s))) == NULL || - ((*mpq_archive)->mpq_hash = calloc((*mpq_archive)->mpq_header.hash_table_count, sizeof(mpq_hash_s))) == NULL || - ((*mpq_archive)->mpq_file = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_file_s))) == NULL || - ((*mpq_archive)->mpq_map = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_map_s))) == NULL) { + /* allocate memory for the block table, hash table, file and block table to file mapping. */ + if (((*mpq_archive)->mpq_block = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_block_s))) == NULL || + ((*mpq_archive)->mpq_block_ex = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_block_ex_s))) == NULL || + ((*mpq_archive)->mpq_hash = calloc((*mpq_archive)->mpq_header.hash_table_count, sizeof(mpq_hash_s))) == NULL || + ((*mpq_archive)->mpq_file = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_file_s))) == NULL || + ((*mpq_archive)->mpq_map = calloc((*mpq_archive)->mpq_header.block_table_count, sizeof(mpq_map_s))) == NULL) { - /* memory allocation problem. */ - result = LIBMPQ_ERROR_MALLOC; - goto error; - } + /* memory allocation problem. */ + result = LIBMPQ_ERROR_MALLOC; + goto error; + } - /* seek in file. */ - if (fseeko((*mpq_archive)->fp, (*mpq_archive)->mpq_header.hash_table_offset + (((long long)((*mpq_archive)->mpq_header_ex.hash_table_offset_high)) << 32) + (*mpq_archive)->archive_offset, SEEK_SET) < 0) { + /* seek in file. */ + if (fseeko((*mpq_archive)->fp, (*mpq_archive)->mpq_header.hash_table_offset + (((long long)((*mpq_archive)->mpq_header_ex.hash_table_offset_high)) << 32) + (*mpq_archive)->archive_offset, SEEK_SET) < 0) { - /* seek in file failed. */ - result = LIBMPQ_ERROR_SEEK; - goto error; - } + /* seek in file failed. */ + result = LIBMPQ_ERROR_SEEK; + goto error; + } - /* read the hash table into the buffer. */ - if ((rb = fread((*mpq_archive)->mpq_hash, 1, (*mpq_archive)->mpq_header.hash_table_count * sizeof(mpq_hash_s), (*mpq_archive)->fp)) < 0) { + /* read the hash table into the buffer. */ + rc = (*mpq_archive)->mpq_header.hash_table_count * sizeof(mpq_hash_s); + rb = fread((*mpq_archive)->mpq_hash, 1, rc, (*mpq_archive)->fp); + if (rb < rc) { - /* something on read failed. */ - result = LIBMPQ_ERROR_READ; - goto error; - } + /* something on read failed. */ + result = LIBMPQ_ERROR_READ; + goto error; + } - /* decrypt the hashtable. */ - libmpq__decrypt_block((uint32_t *)((*mpq_archive)->mpq_hash), (*mpq_archive)->mpq_header.hash_table_count * sizeof(mpq_hash_s), libmpq__hash_string("(hash table)", 0x300)); + /* decrypt the hashtable. */ + libmpq__decrypt_block((uint32_t *)((*mpq_archive)->mpq_hash), (*mpq_archive)->mpq_header.hash_table_count * sizeof(mpq_hash_s), libmpq__hash_string("(hash table)", 0x300)); - /* seek in file. */ - if (fseeko((*mpq_archive)->fp, (*mpq_archive)->mpq_header.block_table_offset + (((long long)((*mpq_archive)->mpq_header_ex.block_table_offset_high)) << 32) + (*mpq_archive)->archive_offset, SEEK_SET) < 0) { + /* seek in file. */ + if (fseeko((*mpq_archive)->fp, (*mpq_archive)->mpq_header.block_table_offset + (((long long)((*mpq_archive)->mpq_header_ex.block_table_offset_high)) << 32) + (*mpq_archive)->archive_offset, SEEK_SET) < 0) { - /* seek in file failed. */ - result = LIBMPQ_ERROR_SEEK; - goto error; - } + /* seek in file failed. */ + result = LIBMPQ_ERROR_SEEK; + goto error; + } - /* read the block table into the buffer. */ - if ((rb = fread((*mpq_archive)->mpq_block, 1, (*mpq_archive)->mpq_header.block_table_count * sizeof(mpq_block_s), (*mpq_archive)->fp)) < 0) { + /* read the block table into the buffer. */ + rc = (*mpq_archive)->mpq_header.block_table_count * sizeof(mpq_block_s); + rb = fread((*mpq_archive)->mpq_block, 1, rc, (*mpq_archive)->fp); + if (rb < rc) { - /* something on read failed. */ - result = LIBMPQ_ERROR_READ; - goto error; - } + /* something on read failed. */ + result = LIBMPQ_ERROR_READ; + goto error; + } - /* decrypt block table. */ - libmpq__decrypt_block((uint32_t *)((*mpq_archive)->mpq_block), (*mpq_archive)->mpq_header.block_table_count * sizeof(mpq_block_s), libmpq__hash_string("(block table)", 0x300)); + /* decrypt block table. */ + libmpq__decrypt_block((uint32_t *)((*mpq_archive)->mpq_block), (*mpq_archive)->mpq_header.block_table_count * sizeof(mpq_block_s), libmpq__hash_string("(block table)", 0x300)); - /* check if extended block table is present, regardless of version 2 it is only present in archives > 4GB. */ - if ((*mpq_archive)->mpq_header_ex.extended_offset > 0) { + /* check if extended block table is present, regardless of version 2 it is only present in archives > 4GB. */ + if ((*mpq_archive)->mpq_header_ex.extended_offset > 0) { - /* seek in file. */ - if (fseeko((*mpq_archive)->fp, (*mpq_archive)->mpq_header_ex.extended_offset + archive_offset, SEEK_SET) < 0) { + /* seek in file. */ + if (fseeko((*mpq_archive)->fp, (*mpq_archive)->mpq_header_ex.extended_offset + archive_offset, SEEK_SET) < 0) { - /* seek in file failed. */ - result = LIBMPQ_ERROR_SEEK; - goto error; - } + /* seek in file failed. */ + result = LIBMPQ_ERROR_SEEK; + goto error; + } - /* read header from file. */ - if ((rb = fread((*mpq_archive)->mpq_block_ex, 1, (*mpq_archive)->mpq_header.block_table_count * sizeof(mpq_block_ex_s), (*mpq_archive)->fp)) < 0) { + /* read header from file. */ + rc = (*mpq_archive)->mpq_header.block_table_count * sizeof(mpq_block_ex_s); + rb = fread((*mpq_archive)->mpq_block_ex, 1, rc, (*mpq_archive)->fp); + if (rb < rc) { - /* no valid mpq archive. */ - result = LIBMPQ_ERROR_FORMAT; - goto error; - } - } + /* no valid mpq archive. */ + result = LIBMPQ_ERROR_FORMAT; + goto error; + } + } - /* loop through all files in mpq archive and check if they are valid. */ - for (i = 0; i < (*mpq_archive)->mpq_header.block_table_count; i++) { + /* loop through all files in mpq archive and check if they are valid. */ + for (i = 0; i < (*mpq_archive)->mpq_header.block_table_count; i++) { - /* save block difference between valid and invalid blocks. */ - (*mpq_archive)->mpq_map[i].block_table_diff = i - count; + /* save block difference between valid and invalid blocks. */ + (*mpq_archive)->mpq_map[i].block_table_diff = i - count; - /* check if file exists, sizes and offsets are correct. */ - if (((*mpq_archive)->mpq_block[i].flags & LIBMPQ_FLAG_EXISTS) == 0) { + /* check if file exists, sizes and offsets are correct. */ + if (((*mpq_archive)->mpq_block[i].flags & LIBMPQ_FLAG_EXISTS) == 0) { - /* file does not exist, so nothing to do with that block. */ - continue; - } + /* file does not exist, so nothing to do with that block. */ + continue; + } - /* create final indices tables. */ - (*mpq_archive)->mpq_map[count].block_table_indices = i; + /* create final indices tables. */ + (*mpq_archive)->mpq_map[count].block_table_indices = i; - /* increase file counter. */ - count++; - } + /* increase file counter. */ + count++; + } - /* save the number of files. */ - (*mpq_archive)->files = count; + /* save the number of files. */ + (*mpq_archive)->files = count; - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; error: - if ((*mpq_archive)->fp) - fclose((*mpq_archive)->fp); + if ((*mpq_archive)->fp) + fclose((*mpq_archive)->fp); - free((*mpq_archive)->mpq_map); - free((*mpq_archive)->mpq_file); - free((*mpq_archive)->mpq_hash); - free((*mpq_archive)->mpq_block); - free((*mpq_archive)->mpq_block_ex); - free(*mpq_archive); + free((*mpq_archive)->mpq_map); + free((*mpq_archive)->mpq_file); + free((*mpq_archive)->mpq_hash); + free((*mpq_archive)->mpq_block); + free((*mpq_archive)->mpq_block_ex); + free(*mpq_archive); - *mpq_archive = NULL; + *mpq_archive = NULL; - return result; + return result; } /* this function close the file descriptor, free the decryption buffer and the file list. */ int32_t libmpq__archive_close(mpq_archive_s *mpq_archive) { - /* try to close the file */ - if ((fclose(mpq_archive->fp)) < 0) { + /* try to close the file */ + if ((fclose(mpq_archive->fp)) < 0) { - /* don't free anything here, so the caller can try calling us - * again. - */ - return LIBMPQ_ERROR_CLOSE; - } + /* don't free anything here, so the caller can try calling us + * again. + */ + return LIBMPQ_ERROR_CLOSE; + } - /* free header, tables and list. */ - free(mpq_archive->mpq_map); - free(mpq_archive->mpq_file); - free(mpq_archive->mpq_hash); - free(mpq_archive->mpq_block); - free(mpq_archive->mpq_block_ex); - free(mpq_archive); + /* free header, tables and list. */ + free(mpq_archive->mpq_map); + free(mpq_archive->mpq_file); + free(mpq_archive->mpq_hash); + free(mpq_archive->mpq_block); + free(mpq_archive->mpq_block_ex); + free(mpq_archive); - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the packed size of all files in the archive. */ int32_t libmpq__archive_packed_size(mpq_archive_s *mpq_archive, libmpq__off_t *packed_size) { - /* some common variables. */ - uint32_t i; + /* some common variables. */ + uint32_t i; - /* loop through all files in archive and count packed size. */ - for (i = 0; i < mpq_archive->files; i++) { - *packed_size += mpq_archive->mpq_block[mpq_archive->mpq_map[i].block_table_indices].packed_size; - } + /* loop through all files in archive and count packed size. */ + for (i = 0; i < mpq_archive->files; i++) { + *packed_size += mpq_archive->mpq_block[mpq_archive->mpq_map[i].block_table_indices].packed_size; + } - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the unpacked size of all files in the archive. */ int32_t libmpq__archive_unpacked_size(mpq_archive_s *mpq_archive, libmpq__off_t *unpacked_size) { - /* some common variables. */ - uint32_t i; + /* some common variables. */ + uint32_t i; - /* loop through all files in archive and count unpacked size. */ - for (i = 0; i < mpq_archive->files; i++) { - *unpacked_size += mpq_archive->mpq_block[mpq_archive->mpq_map[i].block_table_indices].unpacked_size; - } + /* loop through all files in archive and count unpacked size. */ + for (i = 0; i < mpq_archive->files; i++) { + *unpacked_size += mpq_archive->mpq_block[mpq_archive->mpq_map[i].block_table_indices].unpacked_size; + } - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the archive offset (beginning of archive in file). */ int32_t libmpq__archive_offset(mpq_archive_s *mpq_archive, libmpq__off_t *offset) { - /* return archive offset. */ - *offset = mpq_archive->archive_offset; + /* return archive offset. */ + *offset = mpq_archive->archive_offset; - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the archive offset. */ int32_t libmpq__archive_version(mpq_archive_s *mpq_archive, uint32_t *version) { - /* return archive version. */ - *version = mpq_archive->mpq_header.version + 1; + /* return archive version. */ + *version = mpq_archive->mpq_header.version + 1; - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the number of valid files in archive. */ int32_t libmpq__archive_files(mpq_archive_s *mpq_archive, uint32_t *files) { - /* return archive version. */ - *files = mpq_archive->files; + /* return archive version. */ + *files = mpq_archive->files; - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } +#define CHECK_FILE_NUM(file_number, mpq_archive) \ + if (file_number < 0 || file_number > mpq_archive->files - 1) { \ + return LIBMPQ_ERROR_EXIST; \ + } + +#define CHECK_BLOCK_NUM(block_number, mpq_archive) \ + if (block_number < 0 || block_number >= ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0 ? 1 : (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size)) { \ + return LIBMPQ_ERROR_EXIST; \ + } + /* this function return the packed size of the given files in the archive. */ int32_t libmpq__file_packed_size(mpq_archive_s *mpq_archive, uint32_t file_number, libmpq__off_t *packed_size) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* get the packed size of file. */ + *packed_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].packed_size; - /* get the packed size of file. */ - *packed_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].packed_size; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the unpacked size of the given file in the archive. */ int32_t libmpq__file_unpacked_size(mpq_archive_s *mpq_archive, uint32_t file_number, libmpq__off_t *unpacked_size) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* get the unpacked size of file. */ + *unpacked_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size; - /* get the unpacked size of file. */ - *unpacked_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the file offset (beginning of file in archive). */ int32_t libmpq__file_offset(mpq_archive_s *mpq_archive, uint32_t file_number, libmpq__off_t *offset) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* return file offset relative to archive start. */ + *offset = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].offset + (((long long)mpq_archive->mpq_block_ex[mpq_archive->mpq_map[file_number].block_table_indices].offset_high) << 32); - /* return file offset relative to archive start. */ - *offset = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].offset + (((long long)mpq_archive->mpq_block_ex[mpq_archive->mpq_map[file_number].block_table_indices].offset_high) << 32); - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the number of blocks for the given file in the archive. */ int32_t libmpq__file_blocks(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *blocks) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* return the number of blocks for the given file. */ + *blocks = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0 ? 1 : (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size; - /* return the number of blocks for the given file. */ - *blocks = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0 ? 1 : (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return if the file is encrypted or not. */ int32_t libmpq__file_encrypted(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *encrypted) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* return the encryption status of file. */ + *encrypted = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_ENCRYPTED) != 0 ? TRUE : FALSE; - /* return the encryption status of file. */ - *encrypted = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_ENCRYPTED) != 0 ? TRUE : FALSE; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return if the file is compressed or not. */ int32_t libmpq__file_compressed(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *compressed) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* return the compression status of file. */ + *compressed = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_COMPRESS_MULTI) != 0 ? TRUE : FALSE; - /* return the compression status of file. */ - *compressed = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_COMPRESS_MULTI) != 0 ? TRUE : FALSE; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return if the file is imploded or not. */ int32_t libmpq__file_imploded(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t *imploded) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* return the implosion status of file. */ + *imploded = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_COMPRESS_PKZIP) != 0 ? TRUE : FALSE; - /* return the implosion status of file. */ - *imploded = (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_COMPRESS_PKZIP) != 0 ? TRUE : FALSE; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return filenumber by the given name. */ int32_t libmpq__file_number(mpq_archive_s *mpq_archive, const char *filename, uint32_t *number) { - /* some common variables. */ - uint32_t i, hash1, hash2, hash3, ht_count; + /* some common variables. */ + uint32_t i, hash1, hash2, hash3, ht_count; - /* if the list of file names doesn't include this one, we'll have - * to figure out the file number the "hard" way. - */ - ht_count = mpq_archive->mpq_header.hash_table_count; + /* if the list of file names doesn't include this one, we'll have + * to figure out the file number the "hard" way. + */ + ht_count = mpq_archive->mpq_header.hash_table_count; - hash1 = libmpq__hash_string (filename, 0x0) & (ht_count - 1); - hash2 = libmpq__hash_string (filename, 0x100); - hash3 = libmpq__hash_string (filename, 0x200); + hash1 = libmpq__hash_string (filename, 0x0) & (ht_count - 1); + hash2 = libmpq__hash_string (filename, 0x100); + hash3 = libmpq__hash_string (filename, 0x200); - /* loop through all files in mpq archive. - * hash1 gives us a clue about the starting position of this - * search. - */ - for (i = hash1; mpq_archive->mpq_hash[i].block_table_index != LIBMPQ_HASH_FREE; i = (i + 1) & (ht_count - 1)) { + /* loop through all files in mpq archive. + * hash1 gives us a clue about the starting position of this + * search. + */ + for (i = hash1; mpq_archive->mpq_hash[i].block_table_index != LIBMPQ_HASH_FREE; i = (i + 1) & (ht_count - 1)) { - /* if the other two hashes match, we found our file number. */ - if (mpq_archive->mpq_hash[i].hash_a == hash2 && - mpq_archive->mpq_hash[i].hash_b == hash3) { + /* if the other two hashes match, we found our file number. */ + if (mpq_archive->mpq_hash[i].hash_a == hash2 && + mpq_archive->mpq_hash[i].hash_b == hash3) { - /* return the file number. */ - *number = mpq_archive->mpq_hash[i].block_table_index - mpq_archive->mpq_map[mpq_archive->mpq_hash[i].block_table_index].block_table_diff; + /* return the file number. */ + *number = mpq_archive->mpq_hash[i].block_table_index - mpq_archive->mpq_map[mpq_archive->mpq_hash[i].block_table_index].block_table_diff; - /* we found our file, return zero. */ - return LIBMPQ_SUCCESS; - } + /* we found our file, return zero. */ + return LIBMPQ_SUCCESS; + } - /* check if we have cycled through the whole hash table */ - if (((i + 1) & (ht_count - 1)) == hash1) { - break; - } - } + /* check if we have cycled through the whole hash table */ + if (((i + 1) & (ht_count - 1)) == hash1) { + break; + } + } - /* if no matching entry found, so return error. */ - return LIBMPQ_ERROR_EXIST; + /* if no matching entry found, so return error. */ + return LIBMPQ_ERROR_EXIST; } /* this function read the given file from archive into a buffer. */ int32_t libmpq__file_read(mpq_archive_s *mpq_archive, uint32_t file_number, uint8_t *out_buf, libmpq__off_t out_size, libmpq__off_t *transferred) { - /* some common variables. */ - uint32_t i; - uint32_t blocks = 0; - int32_t result = 0; - libmpq__off_t file_offset = 0; - libmpq__off_t unpacked_size = 0; - libmpq__off_t transferred_block = 0; - libmpq__off_t transferred_total = 0; + /* some common variables. */ + uint32_t i; + uint32_t blocks = 0; + int32_t result = 0; + libmpq__off_t file_offset = 0; + libmpq__off_t unpacked_size = 0; + libmpq__off_t transferred_block = 0; + libmpq__off_t transferred_total = 0; - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* get target size of block. */ + libmpq__file_unpacked_size(mpq_archive, file_number, &unpacked_size); - /* get target size of block. */ - libmpq__file_unpacked_size(mpq_archive, file_number, &unpacked_size); + /* check if target buffer is to small. */ + if (unpacked_size > out_size) { - /* check if target buffer is to small. */ - if (unpacked_size > out_size) { + /* output buffer size is to small or block size is unknown. */ + return LIBMPQ_ERROR_SIZE; + } - /* output buffer size is to small or block size is unknown. */ - return LIBMPQ_ERROR_SIZE; - } + /* fetch file offset. */ + libmpq__file_offset(mpq_archive, file_number, &file_offset); - /* fetch file offset. */ - libmpq__file_offset(mpq_archive, file_number, &file_offset); + /* get block count for file. */ + libmpq__file_blocks(mpq_archive, file_number, &blocks); - /* get block count for file. */ - libmpq__file_blocks(mpq_archive, file_number, &blocks); + /* open the packed block offset table. */ + if ((result = libmpq__block_open_offset(mpq_archive, file_number)) < 0) { - /* open the packed block offset table. */ - if ((result = libmpq__block_open_offset(mpq_archive, file_number)) < 0) { + /* something on opening packed block offset table failed. */ + return result; + } - /* something on opening packed block offset table failed. */ - return result; - } + /* loop through all blocks. */ + for (i = 0; i < blocks; i++) { - /* loop through all blocks. */ - for (i = 0; i < blocks; i++) { + /* cleanup size variable. */ + unpacked_size = 0; - /* cleanup size variable. */ - unpacked_size = 0; + /* get unpacked block size. */ + libmpq__block_unpacked_size(mpq_archive, file_number, i, &unpacked_size); - /* get unpacked block size. */ - libmpq__block_unpacked_size(mpq_archive, file_number, i, &unpacked_size); + /* read block. */ + if ((result = libmpq__block_read(mpq_archive, file_number, i, out_buf + transferred_total, unpacked_size, &transferred_block)) < 0) { - /* read block. */ - if ((result = libmpq__block_read(mpq_archive, file_number, i, out_buf + transferred_total, unpacked_size, &transferred_block)) < 0) { + /* close the packed block offset table. */ + libmpq__block_close_offset(mpq_archive, file_number); - /* close the packed block offset table. */ - libmpq__block_close_offset(mpq_archive, file_number); + /* something on reading block failed. */ + return result; + } - /* something on reading block failed. */ - return result; - } + transferred_total += transferred_block; - transferred_total += transferred_block; + } - } + /* close the packed block offset table. */ + libmpq__block_close_offset(mpq_archive, file_number); - /* close the packed block offset table. */ - libmpq__block_close_offset(mpq_archive, file_number); + /* check for null pointer. */ + if (transferred != NULL) { - /* check for null pointer. */ - if (transferred != NULL) { + /* store transferred bytes. */ + *transferred = transferred_total; + } - /* store transferred bytes. */ - *transferred = transferred_total; - } - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function open a file in the given archive and caches the block offset information. */ int32_t libmpq__block_open_offset(mpq_archive_s *mpq_archive, uint32_t file_number) { - /* some common variables. */ - uint32_t i; - uint32_t packed_size; - int32_t rb = 0; - int32_t result = 0; + /* some common variables. */ + uint32_t i; + uint32_t packed_size; + int32_t rb = 0; + int32_t result = 0; - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + if (mpq_archive->mpq_file[file_number]) { - if (mpq_archive->mpq_file[file_number]) { + /* file already opened, so increment counter */ + mpq_archive->mpq_file[file_number]->open_count++; + return LIBMPQ_SUCCESS; + } - /* file already opened, so increment counter */ - mpq_archive->mpq_file[file_number]->open_count++; - return LIBMPQ_SUCCESS; - } + /* check if file is not stored in a single sector. */ + if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { - /* check if file is not stored in a single sector. */ - if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { + /* get packed size based on block size and block count. */ + packed_size = sizeof(uint32_t) * (((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size) + 1); + } else { - /* get packed size based on block size and block count. */ - packed_size = sizeof(uint32_t) * (((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size) + 1); - } else { + /* file is stored in single sector and we need only two entries for the packed block offset table. */ + packed_size = sizeof(uint32_t) * 2; + } - /* file is stored in single sector and we need only two entries for the packed block offset table. */ - packed_size = sizeof(uint32_t) * 2; - } + /* check if data has one extra entry. */ + if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_EXTRA) != 0) { - /* check if data has one extra entry. */ - if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_EXTRA) != 0) { + /* add one uint32_t. */ + packed_size += sizeof(uint32_t); + } - /* add one uint32_t. */ - packed_size += sizeof(uint32_t); - } + /* allocate memory for the file. */ + if ((mpq_archive->mpq_file[file_number] = calloc(1, sizeof(mpq_file_s))) == NULL) { - /* allocate memory for the file. */ - if ((mpq_archive->mpq_file[file_number] = calloc(1, sizeof(mpq_file_s))) == NULL) { + /* memory allocation problem. */ + result = LIBMPQ_ERROR_MALLOC; + goto error; + } - /* memory allocation problem. */ - result = LIBMPQ_ERROR_MALLOC; - goto error; - } + /* allocate memory for the packed block offset table. */ + if ((mpq_archive->mpq_file[file_number]->packed_offset = calloc(1, packed_size)) == NULL) { - /* allocate memory for the packed block offset table. */ - if ((mpq_archive->mpq_file[file_number]->packed_offset = calloc(1, packed_size)) == NULL) { + /* memory allocation problem. */ + result = LIBMPQ_ERROR_MALLOC; + goto error; + } - /* memory allocation problem. */ - result = LIBMPQ_ERROR_MALLOC; - goto error; - } + /* initialize counter to one opening */ + mpq_archive->mpq_file[file_number]->open_count = 1; - /* initialize counter to one opening */ - mpq_archive->mpq_file[file_number]->open_count = 1; + /* check if we need to load the packed block offset table, we will maintain this table for unpacked files too. */ + if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_COMPRESSED) != 0 && + (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { - /* check if we need to load the packed block offset table, we will maintain this table for unpacked files too. */ - if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_COMPRESSED) != 0 && - (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { + /* seek to block position. */ + if (fseeko(mpq_archive->fp, mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].offset + (((long long)mpq_archive->mpq_block_ex[mpq_archive->mpq_map[file_number].block_table_indices].offset_high) << 32) + mpq_archive->archive_offset, SEEK_SET) < 0) { - /* seek to block position. */ - if (fseeko(mpq_archive->fp, mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].offset + (((long long)mpq_archive->mpq_block_ex[mpq_archive->mpq_map[file_number].block_table_indices].offset_high) << 32) + mpq_archive->archive_offset, SEEK_SET) < 0) { + /* seek in file failed. */ + result = LIBMPQ_ERROR_SEEK; + goto error; + } - /* seek in file failed. */ - result = LIBMPQ_ERROR_SEEK; - goto error; - } + /* read block positions from begin of file. */ + if ((rb = fread(mpq_archive->mpq_file[file_number]->packed_offset, 1, packed_size, mpq_archive->fp)) < 0) { - /* read block positions from begin of file. */ - if ((rb = fread(mpq_archive->mpq_file[file_number]->packed_offset, 1, packed_size, mpq_archive->fp)) < 0) { + /* something on read from archive failed. */ + result = LIBMPQ_ERROR_READ; + goto error; + } - /* something on read from archive failed. */ - result = LIBMPQ_ERROR_READ; - goto error; - } + /* check if the archive is protected some way, sometimes the file appears not to be encrypted, but it is. + * a special case are files with an additional sector but LIBMPQ_FLAG_CRC not set. we don't want to handle + * them as encrypted. */ + if (mpq_archive->mpq_file[file_number]->packed_offset[0] != rb && + mpq_archive->mpq_file[file_number]->packed_offset[0] != rb + 4) { - /* check if the archive is protected some way, sometimes the file appears not to be encrypted, but it is. */ - if (mpq_archive->mpq_file[file_number]->packed_offset[0] != rb) { + /* file is encrypted. */ + mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags |= LIBMPQ_FLAG_ENCRYPTED; + } - /* file is encrypted. */ - mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags |= LIBMPQ_FLAG_ENCRYPTED; - } + /* check if packed offset block is encrypted, we have to decrypt it. */ + if (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_ENCRYPTED) { - /* check if packed offset block is encrypted, we have to decrypt it. */ - if (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_ENCRYPTED) { + /* check if we don't know the file seed, try to find it. */ + if (libmpq__decrypt_key((uint8_t *)mpq_archive->mpq_file[file_number]->packed_offset, packed_size, mpq_archive->block_size, &mpq_archive->mpq_file[file_number]->seed) < 0) { - /* check if we don't know the file seed, try to find it. */ - if ((mpq_archive->mpq_file[file_number]->seed = libmpq__decrypt_key((uint8_t *)mpq_archive->mpq_file[file_number]->packed_offset, packed_size, mpq_archive->block_size)) < 0) { + /* sorry without seed, we cannot extract file. */ + result = LIBMPQ_ERROR_DECRYPT; + goto error; + } - /* sorry without seed, we cannot extract file. */ - result = LIBMPQ_ERROR_DECRYPT; - goto error; - } + /* decrypt block in input buffer. */ + if (libmpq__decrypt_block(mpq_archive->mpq_file[file_number]->packed_offset, packed_size, mpq_archive->mpq_file[file_number]->seed - 1) < 0 ) { - /* decrypt block in input buffer. */ - if (libmpq__decrypt_block(mpq_archive->mpq_file[file_number]->packed_offset, packed_size, mpq_archive->mpq_file[file_number]->seed - 1) < 0 ) { + /* something on decrypt failed. */ + result = LIBMPQ_ERROR_DECRYPT; + goto error; + } - /* something on decrypt failed. */ - result = LIBMPQ_ERROR_DECRYPT; - goto error; - } + /* check if the block positions are correctly decrypted. */ + if (mpq_archive->mpq_file[file_number]->packed_offset[0] != packed_size) { - /* check if the block positions are correctly decrypted. */ - if (mpq_archive->mpq_file[file_number]->packed_offset[0] != packed_size) { + /* sorry without seed, we cannot extract file. */ + result = LIBMPQ_ERROR_DECRYPT; + goto error; + } + } + } else { - /* sorry without seed, we cannot extract file. */ - result = LIBMPQ_ERROR_DECRYPT; - goto error; - } - } - } else { + /* check if file is not stored in a single sector. */ + if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { - /* check if file is not stored in a single sector. */ - if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { + /* loop through all blocks and create packed block offset table based on block size. */ + for (i = 0; i < ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size + 1); i++) { - /* loop through all blocks and create packed block offset table based on block size. */ - for (i = 0; i < ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size + 1); i++) { + /* check if we process the last block. */ + if (i == ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size)) { - /* check if we process the last block. */ - if (i == ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size)) { + /* store size of last block. */ + mpq_archive->mpq_file[file_number]->packed_offset[i] = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size; + } else { - /* store size of last block. */ - mpq_archive->mpq_file[file_number]->packed_offset[i] = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size; - } else { + /* store default block size. */ + mpq_archive->mpq_file[file_number]->packed_offset[i] = i * mpq_archive->block_size; + } + } + } else { - /* store default block size. */ - mpq_archive->mpq_file[file_number]->packed_offset[i] = i * mpq_archive->block_size; - } - } - } else { + /* store offsets. */ + mpq_archive->mpq_file[file_number]->packed_offset[0] = 0; + mpq_archive->mpq_file[file_number]->packed_offset[1] = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].packed_size; + } + } - /* store offsets. */ - mpq_archive->mpq_file[file_number]->packed_offset[0] = 0; - mpq_archive->mpq_file[file_number]->packed_offset[1] = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].packed_size; - } - } - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; error: - /* free packed block offset table and file pointer. */ - free(mpq_archive->mpq_file[file_number]->packed_offset); - free(mpq_archive->mpq_file[file_number]); + /* free packed block offset table and file pointer. */ + free(mpq_archive->mpq_file[file_number]->packed_offset); + free(mpq_archive->mpq_file[file_number]); - /* return error constant. */ - return result; + /* return error constant. */ + return result; } /* this function free the file pointer to the opened file in archive. */ int32_t libmpq__block_close_offset(mpq_archive_s *mpq_archive, uint32_t file_number) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + if (mpq_archive->mpq_file[file_number] == NULL) { - if (mpq_archive->mpq_file[file_number] == NULL) { + /* packed block offset table is not opened. */ + return LIBMPQ_ERROR_OPEN; + } - /* packed block offset table is not opened. */ - return LIBMPQ_ERROR_OPEN; - } + mpq_archive->mpq_file[file_number]->open_count--; - mpq_archive->mpq_file[file_number]->open_count--; + if (mpq_archive->mpq_file[file_number]->open_count != 0) { - if (mpq_archive->mpq_file[file_number]->open_count != 0) { + /* still in use */ + return LIBMPQ_SUCCESS; + } - /* still in use */ - return LIBMPQ_SUCCESS; - } + /* free packed block offset table and file pointer. */ + free(mpq_archive->mpq_file[file_number]->packed_offset); + free(mpq_archive->mpq_file[file_number]); - /* free packed block offset table and file pointer. */ - free(mpq_archive->mpq_file[file_number]->packed_offset); - free(mpq_archive->mpq_file[file_number]); + /* mark it as unopened - libmpq__block_open_offset checks for this to decide whether to increment the counter */ + mpq_archive->mpq_file[file_number] = NULL; - /* mark it as unopened - libmpq__block_open_offset checks for this to decide whether to increment the counter */ - mpq_archive->mpq_file[file_number] = NULL; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the unpacked size of the given file and block in the archive. */ int32_t libmpq__block_unpacked_size(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t block_number, libmpq__off_t *unpacked_size) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* check if given block number is not out of range. */ + CHECK_BLOCK_NUM(block_number, mpq_archive) - /* check if given block number is not out of range. */ - if (block_number < 0 || block_number >= ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0 ? 1 : (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size)) { + /* check if packed block offset table is opened. */ + if (mpq_archive->mpq_file[file_number] == NULL || + mpq_archive->mpq_file[file_number]->packed_offset == NULL) { - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* packed block offset table is not opened. */ + return LIBMPQ_ERROR_OPEN; + } - /* check if packed block offset table is opened. */ - if (mpq_archive->mpq_file[file_number] == NULL || - mpq_archive->mpq_file[file_number]->packed_offset == NULL) { + /* check if block is stored as single sector. */ + if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0) { - /* packed block offset table is not opened. */ - return LIBMPQ_ERROR_OPEN; - } + /* return the unpacked size of the block in the mpq archive. */ + *unpacked_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size; + } - /* check if block is stored as single sector. */ - if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0) { + /* check if block is not stored as single sector. */ + if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { - /* return the unpacked size of the block in the mpq archive. */ - *unpacked_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size; - } + /* check if we not process the last block. */ + if (block_number < ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size) - 1) { - /* check if block is not stored as single sector. */ - if ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) == 0) { + /* return the block size as unpacked size. */ + *unpacked_size = mpq_archive->block_size; + } else { - /* check if we not process the last block. */ - if (block_number < ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size) - 1) { + /* return the unpacked size of the last block in the mpq archive. */ + *unpacked_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size - mpq_archive->block_size * block_number; + } + } - /* return the block size as unpacked size. */ - *unpacked_size = mpq_archive->block_size; - } else { - - /* return the unpacked size of the last block in the mpq archive. */ - *unpacked_size = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size - mpq_archive->block_size * block_number; - } - } - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function return the decryption seed for the given file and block. */ int32_t libmpq__block_seed(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t block_number, uint32_t *seed) { - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* check if given block number is not out of range. */ + CHECK_BLOCK_NUM(block_number, mpq_archive) - /* check if given block number is not out of range. */ - if (block_number < 0 || block_number >= ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0 ? 1 : (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size)) { + /* check if packed block offset table is opened. */ + if (mpq_archive->mpq_file[file_number] == NULL || + mpq_archive->mpq_file[file_number]->packed_offset == NULL) { - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* packed block offset table is not opened. */ + return LIBMPQ_ERROR_OPEN; + } - /* check if packed block offset table is opened. */ - if (mpq_archive->mpq_file[file_number] == NULL || - mpq_archive->mpq_file[file_number]->packed_offset == NULL) { + /* return the decryption key. */ + *seed = mpq_archive->mpq_file[file_number]->seed + block_number; - /* packed block offset table is not opened. */ - return LIBMPQ_ERROR_OPEN; - } - - /* return the decryption key. */ - *seed = mpq_archive->mpq_file[file_number]->seed + block_number; - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } /* this function read the given block from archive into a buffer. */ int32_t libmpq__block_read(mpq_archive_s *mpq_archive, uint32_t file_number, uint32_t block_number, uint8_t *out_buf, libmpq__off_t out_size, libmpq__off_t *transferred) { - /* some common variables. */ - uint8_t *in_buf; - uint32_t seed = 0; - uint32_t encrypted = 0; - uint32_t compressed = 0; - uint32_t imploded = 0; - int32_t tb = 0; - libmpq__off_t block_offset = 0; - off_t in_size = 0; - libmpq__off_t unpacked_size = 0; + /* some common variables. */ + uint8_t *in_buf; + uint32_t seed = 0; + uint32_t encrypted = 0; + uint32_t compressed = 0; + uint32_t imploded = 0; + int32_t tb = 0; + libmpq__off_t block_offset = 0; + size_t in_size = 0; + libmpq__off_t unpacked_size = 0; - /* check if given file number is not out of range. */ - if (file_number < 0 || file_number > mpq_archive->files - 1) { + /* check if given file number is not out of range. */ + CHECK_FILE_NUM(file_number, mpq_archive) - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* check if given block number is not out of range. */ + CHECK_BLOCK_NUM(block_number, mpq_archive) - /* check if given block number is not out of range. */ - if (block_number < 0 || block_number >= ((mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].flags & LIBMPQ_FLAG_SINGLE) != 0 ? 1 : (mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].unpacked_size + mpq_archive->block_size - 1) / mpq_archive->block_size)) { + /* check if packed block offset table is opened. */ + if (mpq_archive->mpq_file[file_number] == NULL || + mpq_archive->mpq_file[file_number]->packed_offset == NULL) { - /* file number is out of range. */ - return LIBMPQ_ERROR_EXIST; - } + /* packed block offset table is not opened. */ + return LIBMPQ_ERROR_OPEN; + } - /* check if packed block offset table is opened. */ - if (mpq_archive->mpq_file[file_number] == NULL || - mpq_archive->mpq_file[file_number]->packed_offset == NULL) { + /* get target size of block. */ + libmpq__block_unpacked_size(mpq_archive, file_number, block_number, &unpacked_size); - /* packed block offset table is not opened. */ - return LIBMPQ_ERROR_OPEN; - } + /* check if target buffer is to small. */ + if (unpacked_size > out_size) { - /* get target size of block. */ - libmpq__block_unpacked_size(mpq_archive, file_number, block_number, &unpacked_size); + /* output buffer size is to small or block size is unknown. */ + return LIBMPQ_ERROR_SIZE; + } - /* check if target buffer is to small. */ - if (unpacked_size > out_size) { + /* fetch some required values like input buffer size and block offset. */ + block_offset = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].offset + (((long long)mpq_archive->mpq_block_ex[mpq_archive->mpq_map[file_number].block_table_indices].offset_high) << 32) + mpq_archive->mpq_file[file_number]->packed_offset[block_number]; + in_size = mpq_archive->mpq_file[file_number]->packed_offset[block_number + 1] - mpq_archive->mpq_file[file_number]->packed_offset[block_number]; - /* output buffer size is to small or block size is unknown. */ - return LIBMPQ_ERROR_SIZE; - } + /* seek in file. */ + if (fseeko(mpq_archive->fp, block_offset + mpq_archive->archive_offset, SEEK_SET) < 0) { - /* fetch some required values like input buffer size and block offset. */ - block_offset = mpq_archive->mpq_block[mpq_archive->mpq_map[file_number].block_table_indices].offset + (((long long)mpq_archive->mpq_block_ex[mpq_archive->mpq_map[file_number].block_table_indices].offset_high) << 32) + mpq_archive->mpq_file[file_number]->packed_offset[block_number]; - in_size = mpq_archive->mpq_file[file_number]->packed_offset[block_number + 1] - mpq_archive->mpq_file[file_number]->packed_offset[block_number]; + /* something with seek in file failed. */ + return LIBMPQ_ERROR_SEEK; + } - /* seek in file. */ - if (fseeko(mpq_archive->fp, block_offset + mpq_archive->archive_offset, SEEK_SET) < 0) { + /* allocate memory for the read buffer. */ + if ((in_buf = calloc(1, in_size)) == NULL) { - /* something with seek in file failed. */ - return LIBMPQ_ERROR_SEEK; - } + /* memory allocation problem. */ + return LIBMPQ_ERROR_MALLOC; + } - /* allocate memory for the read buffer. */ - if ((in_buf = calloc(1, in_size)) == NULL) { + /* read block from file. */ + if (fread(in_buf, 1, in_size, mpq_archive->fp) < in_size) { - /* memory allocation problem. */ - return LIBMPQ_ERROR_MALLOC; - } + /* free buffers. */ + free(in_buf); - /* read block from file. */ - if (fread(in_buf, 1, in_size, mpq_archive->fp) < 0) { + /* something on reading block failed. */ + return LIBMPQ_ERROR_READ; + } - /* free buffers. */ - free(in_buf); + /* get encryption status. */ + libmpq__file_encrypted(mpq_archive, file_number, &encrypted); - /* something on reading block failed. */ - return LIBMPQ_ERROR_READ; - } + /* check if file is encrypted. */ + if (encrypted == 1) { - /* get encryption status. */ - libmpq__file_encrypted(mpq_archive, file_number, &encrypted); + /* get decryption key. */ + libmpq__block_seed(mpq_archive, file_number, block_number, &seed); - /* check if file is encrypted. */ - if (encrypted == 1) { + /* decrypt block. */ + if (libmpq__decrypt_block((uint32_t *)in_buf, in_size, seed) < 0) { - /* get decryption key. */ - libmpq__block_seed(mpq_archive, file_number, block_number, &seed); + /* free buffers. */ + free(in_buf); - /* decrypt block. */ - if (libmpq__decrypt_block((uint32_t *)in_buf, in_size, seed) < 0) { + /* something on decrypting block failed. */ + return LIBMPQ_ERROR_DECRYPT; + } + } - /* free buffers. */ - free(in_buf); + /* get compression status. */ + libmpq__file_compressed(mpq_archive, file_number, &compressed); - /* something on decrypting block failed. */ - return LIBMPQ_ERROR_DECRYPT; - } - } + /* check if file is compressed. */ + if (compressed == 1) { - /* get compression status. */ - libmpq__file_compressed(mpq_archive, file_number, &compressed); + /* decompress block. */ + if ((tb = libmpq__decompress_block(in_buf, in_size, out_buf, (uint32_t)out_size, LIBMPQ_FLAG_COMPRESS_MULTI)) < 0) { - /* check if file is compressed. */ - if (compressed == 1) { + /* free temporary buffer. */ + free(in_buf); - /* decompress block. */ - if ((tb = libmpq__decompress_block(in_buf, in_size, out_buf, out_size, LIBMPQ_FLAG_COMPRESS_MULTI)) < 0) { + /* something on decompressing block failed. */ + return LIBMPQ_ERROR_UNPACK; + } + } - /* free temporary buffer. */ - free(in_buf); + /* get implosion status. */ + libmpq__file_imploded(mpq_archive, file_number, &imploded); - /* something on decompressing block failed. */ - return LIBMPQ_ERROR_UNPACK; - } - } + /* check if file is imploded. */ + if (imploded == 1) { - /* get implosion status. */ - libmpq__file_imploded(mpq_archive, file_number, &imploded); + /* explode block. */ + if ((tb = libmpq__decompress_block(in_buf, in_size, out_buf, (uint32_t)out_size, LIBMPQ_FLAG_COMPRESS_PKZIP)) < 0) { - /* check if file is imploded. */ - if (imploded == 1) { + /* free temporary buffer. */ + free(in_buf); - /* explode block. */ - if ((tb = libmpq__decompress_block(in_buf, in_size, out_buf, out_size, LIBMPQ_FLAG_COMPRESS_PKZIP)) < 0) { + /* something on decompressing block failed. */ + return LIBMPQ_ERROR_UNPACK; + } + } - /* free temporary buffer. */ - free(in_buf); + /* check if file is neither compressed nor imploded. */ + if (compressed == 0 && imploded == 0) { - /* something on decompressing block failed. */ - return LIBMPQ_ERROR_UNPACK; - } - } + /* copy block. */ + if ((tb = libmpq__decompress_block(in_buf, in_size, out_buf, (uint32_t)out_size, LIBMPQ_FLAG_COMPRESS_NONE)) < 0) { - /* check if file is neither compressed nor imploded. */ - if (compressed == 0 && imploded == 0) { + /* free temporary buffer. */ + free(in_buf); - /* copy block. */ - if ((tb = libmpq__decompress_block(in_buf, in_size, out_buf, out_size, LIBMPQ_FLAG_COMPRESS_NONE)) < 0) { + /* something on decompressing block failed. */ + return LIBMPQ_ERROR_UNPACK; + } + } - /* free temporary buffer. */ - free(in_buf); + /* free read buffer. */ + free(in_buf); - /* something on decompressing block failed. */ - return LIBMPQ_ERROR_UNPACK; - } - } + /* check for null pointer. */ + if (transferred != NULL) { - /* free read buffer. */ - free(in_buf); + /* store transferred bytes. */ + *transferred = tb; + } - /* check for null pointer. */ - if (transferred != NULL) { - - /* store transferred bytes. */ - *transferred = tb; - } - - /* if no error was found, return zero. */ - return LIBMPQ_SUCCESS; + /* if no error was found, return zero. */ + return LIBMPQ_SUCCESS; } diff --git a/dep/libmpq/libmpq/mpq.h b/dep/libmpq/libmpq/mpq.h index 3d53e0647..91ba22a58 100644 --- a/dep/libmpq/libmpq/mpq.h +++ b/dep/libmpq/libmpq/mpq.h @@ -43,18 +43,18 @@ extern "C" { #endif /* define errors. */ -#define LIBMPQ_ERROR_OPEN -1 /* open error on file. */ -#define LIBMPQ_ERROR_CLOSE -2 /* close error on file. */ -#define LIBMPQ_ERROR_SEEK -3 /* lseek error on file. */ -#define LIBMPQ_ERROR_READ -4 /* read error on file. */ -#define LIBMPQ_ERROR_WRITE -5 /* write error on file. */ -#define LIBMPQ_ERROR_MALLOC -6 /* memory allocation error. */ -#define LIBMPQ_ERROR_FORMAT -7 /* format errror. */ -#define LIBMPQ_ERROR_NOT_INITIALIZED -8 /* libmpq__init() wasn't called. */ -#define LIBMPQ_ERROR_SIZE -9 /* buffer size is to small. */ -#define LIBMPQ_ERROR_EXIST -10 /* file or block does not exist in archive. */ -#define LIBMPQ_ERROR_DECRYPT -11 /* we don't know the decryption seed. */ -#define LIBMPQ_ERROR_UNPACK -12 /* error on unpacking file. */ +#define LIBMPQ_ERROR_OPEN -1 /* open error on file. */ +#define LIBMPQ_ERROR_CLOSE -2 /* close error on file. */ +#define LIBMPQ_ERROR_SEEK -3 /* lseek error on file. */ +#define LIBMPQ_ERROR_READ -4 /* read error on file. */ +#define LIBMPQ_ERROR_WRITE -5 /* write error on file. */ +#define LIBMPQ_ERROR_MALLOC -6 /* memory allocation error. */ +#define LIBMPQ_ERROR_FORMAT -7 /* format errror. */ +#define LIBMPQ_ERROR_NOT_INITIALIZED -8 /* libmpq__init() wasn't called. */ +#define LIBMPQ_ERROR_SIZE -9 /* buffer size is to small. */ +#define LIBMPQ_ERROR_EXIST -10 /* file or block does not exist in archive. */ +#define LIBMPQ_ERROR_DECRYPT -11 /* we don't know the decryption seed. */ +#define LIBMPQ_ERROR_UNPACK -12 /* error on unpacking file. */ /* internal data structure. */ typedef struct mpq_archive mpq_archive_s; @@ -65,6 +65,9 @@ typedef int64_t libmpq__off_t; /* generic information about library. */ extern LIBMPQ_API const char *libmpq__version(void); +/* string error message for a libmpq return code. */ +extern LIBMPQ_API const char *libmpq__strerror(int32_t returncode); + /* generic mpq archive information. */ extern LIBMPQ_API int32_t libmpq__archive_open(mpq_archive_s **mpq_archive, const char *mpq_filename, libmpq__off_t archive_offset); extern LIBMPQ_API int32_t libmpq__archive_close(mpq_archive_s *mpq_archive); @@ -95,4 +98,4 @@ extern LIBMPQ_API int32_t libmpq__block_read(mpq_archive_s *mpq_archive, uint32_ } #endif -#endif /* _MPQ_H */ +#endif /* _MPQ_H */ diff --git a/dep/libmpq/libmpq/pack_begin.h b/dep/libmpq/libmpq/pack_begin.h deleted file mode 100644 index eb4a6ddeb..000000000 --- a/dep/libmpq/libmpq/pack_begin.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * pack_begin.h -- header file for struct packing used by libmpq. - * - * Copyright (c) 2010 Georg Lukas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PACK_BEGIN -#define _PACK_BEGIN -#else -#error "pack_begin.h may not be included twice!" -#endif - -#ifdef _MSC_VER - #pragma pack(push,1) - #define PACK_STRUCT -#else - /* we assume GNU here */ - #define PACK_STRUCT __attribute__((packed)) -#endif - diff --git a/dep/libmpq/libmpq/pack_end.h b/dep/libmpq/libmpq/pack_end.h deleted file mode 100644 index a8a35113b..000000000 --- a/dep/libmpq/libmpq/pack_end.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * pack_end.h -- header file for struct packing used by libmpq. - * - * Copyright (c) 2010 Georg Lukas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef _PACK_BEGIN -#undef _PACK_BEGIN -#else -#error "pack_begin.h must be includede before pack_end.h" -#endif - -#ifdef _MSC_VER - #pragma pack(pop) -#endif - -#undef PACK_STRUCT diff --git a/dep/libmpq/libmpq/platform.h b/dep/libmpq/libmpq/platform.h index 68fdfdc5d..18dd808e2 100644 --- a/dep/libmpq/libmpq/platform.h +++ b/dep/libmpq/libmpq/platform.h @@ -22,7 +22,7 @@ #define _PLATFORM_H #ifdef _MSC_VER - #define fseeko _fseeki64 + #define fseeko _fseeki64 #endif -#endif /* _PLATFORM_H */ +#endif /* _PLATFORM_H */ diff --git a/dep/libmpq/libmpq/wave.c b/dep/libmpq/libmpq/wave.c index 4f2b73ba2..628593fce 100644 --- a/dep/libmpq/libmpq/wave.c +++ b/dep/libmpq/libmpq/wave.c @@ -64,7 +64,7 @@ int32_t libmpq__do_decompress_wave(uint8_t *out_buf, int32_t out_length, uint8_t uint32_t index; int32_t nr_array1[2]; int32_t nr_array2[2]; - uint32_t count = 0; + int32_t count = 0; /* end on input buffer. */ uint8_t *in_end = in_buf + in_length; diff --git a/dep/libmpq/libmpq/wave.h b/dep/libmpq/libmpq/wave.h index 1b9491bd7..7e45254b7 100644 --- a/dep/libmpq/libmpq/wave.h +++ b/dep/libmpq/libmpq/wave.h @@ -22,24 +22,25 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ + */ #ifndef _WAVE_H #define _WAVE_H /* buffer. */ -typedef union { - uint16_t *pw; - uint8_t *pb; +typedef union +{ + uint16_t *pw; + uint8_t *pb; } byte_and_int16_t; /* decompress a wave file, mono or stereo, 1500F230 offset. */ int32_t libmpq__do_decompress_wave( - uint8_t *out_buf, - int32_t out_length, - uint8_t *in_buf, - int32_t in_length, - int32_t channels + uint8_t *out_buf, + int32_t out_length, + uint8_t *in_buf, + int32_t in_length, + int32_t channels ); -#endif /* _WAVE_H */ +#endif /* _WAVE_H */ diff --git a/dep/libmpq/win/.gitignore b/dep/libmpq/win/.gitignore new file mode 100644 index 000000000..6fd3935c7 --- /dev/null +++ b/dep/libmpq/win/.gitignore @@ -0,0 +1,5 @@ + +*.sdf +*.suo +bin +ipch \ No newline at end of file diff --git a/dep/libmpq/win/VC100/.gitignore b/dep/libmpq/win/VC100/.gitignore new file mode 100644 index 000000000..4fb7be5e4 --- /dev/null +++ b/dep/libmpq/win/VC100/.gitignore @@ -0,0 +1,2 @@ + +*.user \ No newline at end of file diff --git a/dep/libmpq/win/VC100/libmpq.vcxproj b/dep/libmpq/win/VC100/libmpq.vcxproj index e68a67ccd..d20ec144f 100644 --- a/dep/libmpq/win/VC100/libmpq.vcxproj +++ b/dep/libmpq/win/VC100/libmpq.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + libmpq @@ -21,32 +29,51 @@ Unicode true + + StaticLibrary + Unicode + true + StaticLibrary Unicode + + StaticLibrary + Unicode + + + + + + + <_ProjectFileVersion>10.0.30319.1 ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ Disabled ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) - WIN32;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -61,7 +88,45 @@ ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + Disabled + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + MaxSpeed + true + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + StreamingSIMDExtensions + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + MaxSpeed true @@ -112,4 +177,4 @@ - \ No newline at end of file + diff --git a/dep/libmpq/win/VC110/.gitignore b/dep/libmpq/win/VC110/.gitignore new file mode 100644 index 000000000..4fb7be5e4 --- /dev/null +++ b/dep/libmpq/win/VC110/.gitignore @@ -0,0 +1,2 @@ + +*.user \ No newline at end of file diff --git a/dep/libmpq/win/VC110/libmpq.vcxproj b/dep/libmpq/win/VC110/libmpq.vcxproj new file mode 100644 index 000000000..b06cfab42 --- /dev/null +++ b/dep/libmpq/win/VC110/libmpq.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + libmpq + {03AB0F44-628E-4855-99A0-C98A1EB52C50} + libmpq + + + + StaticLibrary + Unicode + true + v110 + + + StaticLibrary + Unicode + true + v110 + + + StaticLibrary + Unicode + v110 + + + StaticLibrary + Unicode + v110 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + + + + Disabled + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Level3 + EditAndContinue + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + Disabled + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + MaxSpeed + true + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + StreamingSIMDExtensions + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + MaxSpeed + true + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;%(PreprocessorDefinitions) + MultiThreadedDLL + true + StreamingSIMDExtensions + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + {b96f612a-c91d-43b3-a4c3-d4294817ec6c} + false + + + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + false + + + + + + \ No newline at end of file diff --git a/dep/libmpq/win/VC120/.gitignore b/dep/libmpq/win/VC120/.gitignore new file mode 100644 index 000000000..4fb7be5e4 --- /dev/null +++ b/dep/libmpq/win/VC120/.gitignore @@ -0,0 +1,2 @@ + +*.user \ No newline at end of file diff --git a/dep/libmpq/win/VC120/libmpq.vcxproj b/dep/libmpq/win/VC120/libmpq.vcxproj new file mode 100644 index 000000000..6318216c4 --- /dev/null +++ b/dep/libmpq/win/VC120/libmpq.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + libmpq + {03AB0F44-628E-4855-99A0-C98A1EB52C50} + libmpq + + + + StaticLibrary + Unicode + true + v120 + + + StaticLibrary + Unicode + true + v120 + + + StaticLibrary + Unicode + v120 + + + StaticLibrary + Unicode + v120 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + ..\bin\$(ProjectName)__$(Platform)_$(Configuration)\ + + + + Disabled + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Level3 + EditAndContinue + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + Disabled + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + MaxSpeed + true + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + StreamingSIMDExtensions + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + MaxSpeed + true + ..\; ..\..\..\..\dep\include\zlib; ..\..\..\..\dep\include\bzip2;%(AdditionalIncludeDirectories) + WIN32;%(PreprocessorDefinitions) + MultiThreadedDLL + true + StreamingSIMDExtensions + Level3 + ProgramDatabase + CompileAsC + + + true + + + ..\dep\lib\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + {b96f612a-c91d-43b3-a4c3-d4294817ec6c} + false + + + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} + false + + + + + + \ No newline at end of file diff --git a/dep/libmpq/win/VC90/libmpq.vcproj b/dep/libmpq/win/VC90/libmpq.vcproj deleted file mode 100644 index ac2dcc556..000000000 --- a/dep/libmpq/win/VC90/libmpq.vcproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dep/libmpq/win/libmpq_VC90.sln b/dep/libmpq/win/libmpq_VC110.sln similarity index 74% rename from dep/libmpq/win/libmpq_VC90.sln rename to dep/libmpq/win/libmpq_VC110.sln index 7c4a8e47a..8f7080dec 100644 --- a/dep/libmpq/win/libmpq_VC90.sln +++ b/dep/libmpq/win/libmpq_VC110.sln @@ -1,14 +1,10 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpq", "VC90\libmpq.vcproj", "{03AB0F44-628E-4855-99A0-C98A1EB52C50}" - ProjectSection(ProjectDependencies) = postProject - {B96F612A-C91D-43B3-A4C3-D4294817EC6C} = {B96F612A-C91D-43B3-A4C3-D4294817EC6C} - {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} - EndProjectSection +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpq", "VC110\libmpq.vcxproj", "{03AB0F44-628E-4855-99A0-C98A1EB52C50}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\win\VC90\zlib.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\win\VC110\zlib.vcxproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\..\..\win\VC90\bzip2.vcproj", "{B96F612A-C91D-43B3-A4C3-D4294817EC6C}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\..\..\win\VC110\bzip2.vcxproj", "{B96F612A-C91D-43B3-A4C3-D4294817EC6C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/dep/libmpq/win/libmpq_VC120.sln b/dep/libmpq/win/libmpq_VC120.sln new file mode 100644 index 000000000..549220186 --- /dev/null +++ b/dep/libmpq/win/libmpq_VC120.sln @@ -0,0 +1,47 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpq", "VC120\libmpq.vcxproj", "{03AB0F44-628E-4855-99A0-C98A1EB52C50}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\win\VC120\zlib.vcxproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\..\..\win\VC120\bzip2.vcxproj", "{B96F612A-C91D-43B3-A4C3-D4294817EC6C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|Win32.ActiveCfg = Debug|Win32 + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|Win32.Build.0 = Debug|Win32 + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|x64.ActiveCfg = Debug|x64 + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Debug|x64.Build.0 = Debug|x64 + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|Win32.ActiveCfg = Release|Win32 + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|Win32.Build.0 = Release|Win32 + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|x64.ActiveCfg = Release|x64 + {03AB0F44-628E-4855-99A0-C98A1EB52C50}.Release|x64.Build.0 = Release|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|x64.ActiveCfg = Debug|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|x64.Build.0 = Debug|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|x64.ActiveCfg = Release|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|x64.Build.0 = Release|x64 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|Win32.ActiveCfg = Debug|Win32 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|Win32.Build.0 = Debug|Win32 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|x64.ActiveCfg = Debug|x64 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|x64.Build.0 = Debug|x64 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|Win32.ActiveCfg = Release|Win32 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|Win32.Build.0 = Release|Win32 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|x64.ActiveCfg = Release|x64 + {B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/loadlib/CMakeLists.txt b/dep/loadlib/CMakeLists.txt index 8dc30ea97..f053e68ac 100644 --- a/dep/loadlib/CMakeLists.txt +++ b/dep/loadlib/CMakeLists.txt @@ -15,23 +15,19 @@ if(USE_STORMLIB) - add_library(loadlib - sl/loadlib.cpp - sl/adt.cpp - sl/wdt.cpp - sl/mpq.cpp) - - target_include_directories(loadlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/sl) - - target_link_libraries(loadlib PUBLIC stormlib) + include_directories( + ${CMAKE_SOURCE_DIR}/dep/StormLib/src + ${CMAKE_CURRENT_SOURCE_DIR}/sl + ) + add_library(loadlib sl/loadlib.cpp sl/adt.cpp sl/wdt.cpp sl/mpq.cpp) + target_link_libraries(loadlib storm) else() - add_library(loadlib - ml/loadlib.cpp - ml/adt.cpp - ml/wdt.cpp - ml/mpq.cpp) - - target_include_directories(loadlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/ml) - - target_link_libraries(loadlib PUBLIC libmpq) + include_directories( + ${CMAKE_SOURCE_DIR}/dep/libmpq + ${CMAKE_CURRENT_SOURCE_DIR}/ml + ) + add_library(loadlib ml/loadlib.cpp ml/adt.cpp ml/wdt.cpp ml/mpq.cpp) endif() + +# link loadlib with zlib +target_link_libraries(loadlib zlib) diff --git a/dep/loadlib/ml/adt.cpp b/dep/loadlib/ml/adt.cpp index 7db6c34ea..281b6bf50 100644 --- a/dep/loadlib/ml/adt.cpp +++ b/dep/loadlib/ml/adt.cpp @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/loadlib/ml/adt.h b/dep/loadlib/ml/adt.h index 7a1684d84..609579a95 100644 --- a/dep/loadlib/ml/adt.h +++ b/dep/loadlib/ml/adt.h @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/loadlib/ml/loadlib.cpp b/dep/loadlib/ml/loadlib.cpp index a5fe295eb..f33e88d98 100644 --- a/dep/loadlib/ml/loadlib.cpp +++ b/dep/loadlib/ml/loadlib.cpp @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/loadlib/ml/loadlib.h b/dep/loadlib/ml/loadlib.h index 73d9c3a9a..9a91199a6 100644 --- a/dep/loadlib/ml/loadlib.h +++ b/dep/loadlib/ml/loadlib.h @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/loadlib/ml/mpq.cpp b/dep/loadlib/ml/mpq.cpp index e259f2c16..d54772b71 100644 --- a/dep/loadlib/ml/mpq.cpp +++ b/dep/loadlib/ml/mpq.cpp @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/loadlib/ml/mpq.h b/dep/loadlib/ml/mpq.h index 39d5f0afd..25a9a9a35 100644 --- a/dep/loadlib/ml/mpq.h +++ b/dep/loadlib/ml/mpq.h @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/loadlib/ml/wdt.cpp b/dep/loadlib/ml/wdt.cpp index 310714665..37c2b8b6a 100644 --- a/dep/loadlib/ml/wdt.cpp +++ b/dep/loadlib/ml/wdt.cpp @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/loadlib/ml/wdt.h b/dep/loadlib/ml/wdt.h index 926393f27..42efb3f58 100644 --- a/dep/loadlib/ml/wdt.h +++ b/dep/loadlib/ml/wdt.h @@ -2,7 +2,7 @@ * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * - * Copyright (C) 2005-2020 MaNGOS + * Copyright (C) 2005-2019 MaNGOS project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/dep/lualib/CMakeLists.txt b/dep/lualib/CMakeLists.txt index 5e3d8f498..c2015002e 100644 --- a/dep/lualib/CMakeLists.txt +++ b/dep/lualib/CMakeLists.txt @@ -4,67 +4,16 @@ # Please see the included DOCS/LICENSE.md for more information # -project(lualib VERSION 5.2.3) +file(GLOB sources *.c) +list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/lua.c) +list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/luac.c) -add_library(lualib STATIC - lapi.c - lauxlib.c - lbaselib.c - lbitlib.c - lcode.c - lcorolib.c - lctype.c - ldblib.c - ldebug.c - ldo.c - ldump.c - lfunc.c - lgc.c - linit.c - liolib.c - llex.c - lmathlib.c - lmem.c - loadlib.c - lobject.c - lopcodes.c - loslib.c - lparser.c - lstate.c - lstring.c - lstrlib.c - ltable.c - ltablib.c - ltm.c - lundump.c - lvm.c - lzio.c - lapi.h - lauxlib.h - lcode.h - lctype.h - ldebug.h - ldo.h - lfunc.h - lgc.h - llex.h - llimits.h - lmem.h - lobject.h - lopcodes.h - lparser.h - lstate.h - lstring.h - ltable.h - ltm.h - lua.h - luaconf.h - lualib.h - lundump.h - lvm.h - lzio.h +set(lua_STAT_SRCS + ${sources} ) -target_include_directories(lualib - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} ) + +add_library(lualib STATIC ${lua_STAT_SRCS}) diff --git a/dep/mersennetwister/MersenneTwister.h b/dep/mersennetwister/MersenneTwister.h new file mode 100644 index 000000000..dfe3f5be1 --- /dev/null +++ b/dep/mersennetwister/MersenneTwister.h @@ -0,0 +1,414 @@ +// MersenneTwister.h +// Mersenne Twister random number generator -- a C++ class MTRand +// Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus +// Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com + +// The Mersenne Twister is an algorithm for generating random numbers. It +// was designed with consideration of the flaws in various other generators. +// The period, 2^19937-1, and the order of equidistribution, 623 dimensions, +// are far greater. The generator is also fast; it avoids multiplication and +// division, and it benefits from caches and pipelines. For more information +// see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html + +// Reference +// M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally +// Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on +// Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30. + +// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, +// Copyright (C) 2000 - 2003, Richard J. Wagner +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The names of its contributors may not be used to endorse or promote +// products derived from this software without specific prior written +// permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// The original code included the following notice: +// +// When you use this, send an email to: matumoto@math.keio.ac.jp +// with an appropriate reference to your work. +// +// It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu +// when you write. + +#ifndef MERSENNETWISTER_H +#define MERSENNETWISTER_H + +// Not thread safe (unless auto-initialization is avoided and each thread has +// its own MTRand object) + +#include"Platform/Define.h" + +#include +#include +#include + +class MTRand { +// Data +public: + typedef ::uint32 uint32; + enum { N = 624 }; // length of state vector + enum { SAVE = N + 1 }; // length of array for save() + +protected: + enum { M = 397 }; // period parameter + + uint32 state[N]; // internal state + uint32 *pNext; // next value to get from state + int left; // number of values left before reload needed + + +//Methods +public: + MTRand( const uint32& oneSeed ); // initialize with a simple uint32 + MTRand( uint32 *const bigSeed, uint32 const seedLength = N ); // or an array + MTRand(); // auto-initialize with /dev/urandom or time() and clock() + MTRand(const MTRand&); // prevent copy constructor + MTRand& operator=(const MTRand&); // no-op operator= + + // Do NOT use for CRYPTOGRAPHY without securely hashing several returned + // values together, otherwise the generator state can be learned after + // reading 624 consecutive values. + + // Access to 32-bit random numbers + double rand(); // real number in [0,1] + double rand( const double& n ); // real number in [0,n] + double randExc(); // real number in [0,1) + double randExc( const double& n ); // real number in [0,n) + double randDblExc(); // real number in (0,1) + double randDblExc( const double& n ); // real number in (0,n) + uint32 randInt(); // integer in [0,2^32-1] + uint32 randInt( const uint32& n ); // integer in [0,n] for n < 2^32 + double operator()() { return rand(); } // same as rand() + + // Access to 53-bit random numbers (capacity of IEEE double precision) + double rand53(); // real number in [0,1) + + // Access to nonuniform random number distributions + double randNorm( const double& mean = 0.0, const double& variance = 0.0 ); + + // Re-seeding functions with same behavior as initializers + void seed( const uint32 oneSeed ); + void seed( uint32 *const bigSeed, const uint32 seedLength = N ); + void seed(); + + // Saving and loading generator state + void save( uint32* saveArray ) const; // to array of size SAVE + void load( uint32 *const loadArray ); // from such array + /* Mangos not use streams for random values output + friend std::ostream& operator<<( std::ostream& os, const MTRand& mtrand ); + friend std::istream& operator>>( std::istream& is, MTRand& mtrand ); + */ +protected: + void initialize( const uint32 oneSeed ); + void reload(); + uint32 hiBit( const uint32& u ) const { return u & 0x80000000UL; } + uint32 loBit( const uint32& u ) const { return u & 0x00000001UL; } + uint32 loBits( const uint32& u ) const { return u & 0x7fffffffUL; } + uint32 mixBits( const uint32& u, const uint32& v ) const + { return hiBit(u) | loBits(v); } + uint32 twist( const uint32& m, const uint32& s0, const uint32& s1 ) const + { return m ^ (mixBits(s0,s1)>>1) ^ uint32(-(int32)(loBit(s1) & 0x9908b0dfUL)); } + static uint32 hash( time_t t, clock_t c ); +}; + +inline MTRand::MTRand(const MTRand&) + { seed(); } + +inline MTRand& MTRand::operator=(const MTRand&) + { return *this; } + +inline MTRand::MTRand( const uint32& oneSeed ) + { seed(oneSeed); } + +inline MTRand::MTRand( uint32 *const bigSeed, const uint32 seedLength ) + { seed(bigSeed,seedLength); } + +inline MTRand::MTRand() + { seed(); } + +inline double MTRand::rand() + { return double(randInt()) * (1.0/4294967295.0); } + +inline double MTRand::rand( const double& n ) + { return rand() * n; } + +inline double MTRand::randExc() + { return double(randInt()) * (1.0/4294967296.0); } + +inline double MTRand::randExc( const double& n ) + { return randExc() * n; } + +inline double MTRand::randDblExc() + { return ( double(randInt()) + 0.5 ) * (1.0/4294967296.0); } + +inline double MTRand::randDblExc( const double& n ) + { return randDblExc() * n; } + +inline double MTRand::rand53() +{ + uint32 a = randInt() >> 5, b = randInt() >> 6; + return ( a * 67108864.0 + b ) * (1.0/9007199254740992.0); // by Isaku Wada +} + +inline double MTRand::randNorm( const double& mean, const double& variance ) +{ + // Return a real number from a normal (Gaussian) distribution with given + // mean and variance by Box-Muller method + double r = sqrt( -2.0 * log( 1.0-randDblExc()) ) * variance; + double phi = 2.0 * 3.14159265358979323846264338328 * randExc(); + return mean + r * cos(phi); +} + +inline MTRand::uint32 MTRand::randInt() +{ + // Pull a 32-bit integer from the generator state + // Every other access function simply transforms the numbers extracted here + + if( left == 0 ) reload(); + --left; + + register uint32 s1; + s1 = *pNext++; + s1 ^= (s1 >> 11); + s1 ^= (s1 << 7) & 0x9d2c5680UL; + s1 ^= (s1 << 15) & 0xefc60000UL; + return ( s1 ^ (s1 >> 18) ); +} + +inline MTRand::uint32 MTRand::randInt( const uint32& n ) +{ + // Find which bits are used in n + // Optimized by Magnus Jonsson (magnus@smartelectronix.com) + uint32 used = n; + used |= used >> 1; + used |= used >> 2; + used |= used >> 4; + used |= used >> 8; + used |= used >> 16; + + // Draw numbers until one is found in [0,n] + uint32 i; + do + i = randInt() & used; // toss unused bits to shorten search + while( i > n ); + return i; +} + + +inline void MTRand::seed( const uint32 oneSeed ) +{ + // Seed the generator with a simple uint32 + initialize(oneSeed); + reload(); +} + + +inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength ) +{ + // Seed the generator with an array of uint32's + // There are 2^19937-1 possible initial states. This function allows + // all of those to be accessed by providing at least 19937 bits (with a + // default seed length of N = 624 uint32's). Any bits above the lower 32 + // in each element are discarded. + // Just call seed() if you want to get array from /dev/urandom + initialize(19650218UL); + register int i = 1; + register uint32 j = 0; + register int k = ( N > int(seedLength) ? N : int(seedLength) ); + for( ; k; --k ) + { + state[i] = + state[i] ^ ( (state[i-1] ^ (state[i-1] >> 30)) * 1664525UL ); + state[i] += ( bigSeed[j] & 0xffffffffUL ) + j; + state[i] &= 0xffffffffUL; + ++i; ++j; + if( i >= N ) { state[0] = state[N-1]; i = 1; } + if( j >= seedLength ) j = 0; + } + for( k = N - 1; k; --k ) + { + state[i] = + state[i] ^ ( (state[i-1] ^ (state[i-1] >> 30)) * 1566083941UL ); + state[i] -= i; + state[i] &= 0xffffffffUL; + ++i; + if( i >= N ) { state[0] = state[N-1]; i = 1; } + } + state[0] = 0x80000000UL; // MSB is 1, assuring non-zero initial array + reload(); +} + + +inline void MTRand::seed() +{ + // Seed the generator with hash of time() and clock() values + seed( hash( time(NULL), clock() ) ); +} + + +inline void MTRand::initialize( const uint32 seed ) +{ + // Initialize generator state with seed + // See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier. + // In previous versions, most significant bits (MSBs) of the seed affect + // only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. + register uint32 *s = state; + register uint32 *r = state; + register int i = 1; + *s++ = seed & 0xffffffffUL; + for( ; i < N; ++i ) + { + *s++ = ( 1812433253UL * ( *r ^ (*r >> 30) ) + i ) & 0xffffffffUL; + r++; + } +} + + +inline void MTRand::reload() +{ + // Generate N new values in state + // Made clearer and faster by Matthew Bellew (matthew.bellew@home.com) + register uint32 *p = state; + register int i; + for( i = N - M; i--; ++p ) + *p = twist( p[M], p[0], p[1] ); + for( i = M; --i; ++p ) + *p = twist( p[M-N], p[0], p[1] ); + *p = twist( p[M-N], p[0], state[0] ); + + left = N, pNext = state; +} + + +inline MTRand::uint32 MTRand::hash( time_t t, clock_t c ) +{ + // Get a uint32 from t and c + // Better than uint32(x) in case x is floating point in [0,1] + // Based on code by Lawrence Kirby (fred@genesis.demon.co.uk) + + static uint32 differ = 0; // guarantee time-based seeds will change + + uint32 h1 = 0; + unsigned char *p = (unsigned char *) &t; + for( size_t i = 0; i < sizeof(t); ++i ) + { + h1 *= UCHAR_MAX + 2U; + h1 += p[i]; + } + uint32 h2 = 0; + p = (unsigned char *) &c; + for( size_t j = 0; j < sizeof(c); ++j ) + { + h2 *= UCHAR_MAX + 2U; + h2 += p[j]; + } + return ( h1 + differ++ ) ^ h2; +} + + +inline void MTRand::save( uint32* saveArray ) const +{ + register uint32 *sa = saveArray; + register const uint32 *s = state; + register int i = N; + for( ; i--; *sa++ = *s++ ) {} + *sa = left; +} + + +inline void MTRand::load( uint32 *const loadArray ) +{ + register uint32 *s = state; + register uint32 *la = loadArray; + register int i = N; + for( ; i--; *s++ = *la++ ) {} + left = *la; + pNext = &state[N-left]; +} + +/* Mangos not use streams for random values output +inline std::ostream& operator<<( std::ostream& os, const MTRand& mtrand ) +{ + register const MTRand::uint32 *s = mtrand.state; + register int i = mtrand.N; + for( ; i--; os << *s++ << "\t" ) {} + return os << mtrand.left; +} + + +inline std::istream& operator>>( std::istream& is, MTRand& mtrand ) +{ + register MTRand::uint32 *s = mtrand.state; + register int i = mtrand.N; + for( ; i--; is >> *s++ ) {} + is >> mtrand.left; + mtrand.pNext = &mtrand.state[mtrand.N-mtrand.left]; + return is; +} +*/ + +#endif // MERSENNETWISTER_H + +// Change log: +// +// v0.1 - First release on 15 May 2000 +// - Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus +// - Translated from C to C++ +// - Made completely ANSI compliant +// - Designed convenient interface for initialization, seeding, and +// obtaining numbers in default or user-defined ranges +// - Added automatic seeding from /dev/urandom or time() and clock() +// - Provided functions for saving and loading generator state +// +// v0.2 - Fixed bug which reloaded generator one step too late +// +// v0.3 - Switched to clearer, faster reload() code from Matthew Bellew +// +// v0.4 - Removed trailing newline in saved generator format to be consistent +// with output format of built-in types +// +// v0.5 - Improved portability by replacing static const int's with enum's and +// clarifying return values in seed(); suggested by Eric Heimburg +// - Removed MAXINT constant; use 0xffffffffUL instead +// +// v0.6 - Eliminated seed overflow when uint32 is larger than 32 bits +// - Changed integer [0,n] generator to give better uniformity +// +// v0.7 - Fixed operator precedence ambiguity in reload() +// - Added access for real numbers in (0,1) and (0,n) +// +// v0.8 - Included time.h header to properly support time_t and clock_t +// +// v1.0 - Revised seeding to match 26 Jan 2002 update of Nishimura and Matsumoto +// - Allowed for seeding with arrays of any length +// - Added access for real numbers in [0,1) with 53-bit resolution +// - Added access for real numbers from normal (Gaussian) distributions +// - Increased overall speed by optimizing twist() +// - Doubled speed of integer [0,n] generation +// - Fixed out-of-range number generation on 64-bit machines +// - Improved portability by substituting literal constants for long enum's +// - Changed license from GNU LGPL to BSD diff --git a/dep/recastnavigation/.gitignore b/dep/recastnavigation/.gitignore new file mode 100644 index 000000000..fe4cf932a --- /dev/null +++ b/dep/recastnavigation/.gitignore @@ -0,0 +1,43 @@ +## Compiled source # +*.com +*.class +*.dll +*.exe +*.ilk +*.o +*.pdb +*.so + +## Linux exes have no extension +RecastDemo/Bin/RecastDemo + +# Build directory +RecastDemo/Build + +# Ignore some meshes based on name +RecastDemo/Bin/Meshes/_* + +## Logs and databases # +*.log +*.sql +*.sqlite + +## OS generated files # +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +*.swp +*.swo + +## xcode specific +*xcuserdata* + +## SDL contrib +RecastDemo/Contrib/SDL/* + +## Generated doc files +Docs/html diff --git a/dep/recastnavigation/DebugUtils/CMakeLists.txt b/dep/recastnavigation/DebugUtils/CMakeLists.txt new file mode 100644 index 000000000..5e9ab2ce9 --- /dev/null +++ b/dep/recastnavigation/DebugUtils/CMakeLists.txt @@ -0,0 +1,46 @@ +# MaNGOS is a full featured server for World of Warcraft, supporting +# the following clients: 1.12.x, 2.4.3, 3.2.5a, 4.2.3 and 5.4.8 +# +# Copyright (C) 2005-2019 MaNGOS project +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ***** END GPL LICENSE BLOCK ***** +# +# World of Warcraft, and all World of Warcraft or Warcraft art, images, +# and lore are copyrighted by Blizzard Entertainment, Inc. + +include(MacroMangosSourceGroup) + +#----------------------------------------------------------------------------- +# Define the DebugUtils library +file(GLOB sources Source/*.cpp) +file(GLOB headers Include/*.h) + +set(DebugUtils_LIB_SRCS ${sources} ${headers}) + +mangos_source_group(${DebugUtils_LIB_SRCS}) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/Include + ${CMAKE_CURRENT_SOURCE_DIR}/../Detour/Include/ + ${CMAKE_CURRENT_SOURCE_DIR}/../Recast/Include/ +) + +#----------------------------------------------------------------------------- +# Build the DebugUtils library +add_library(DebugUtils STATIC ${DebugUtils_LIB_SRCS}) diff --git a/dep/recastnavigation/Detour/Include/DetourMath.h b/dep/recastnavigation/Detour/Include/DetourMath.h index 54af8af09..744c562e5 100644 --- a/dep/recastnavigation/Detour/Include/DetourMath.h +++ b/dep/recastnavigation/Detour/Include/DetourMath.h @@ -1,24 +1,21 @@ +#ifndef DETOURMATH_H +#define DETOURMATH_H + /** @defgroup detour Detour Members in this module are wrappers around the standard math library + */ -#ifndef DETOURMATH_H -#define DETOURMATH_H - #include -// This include is required because libstdc++ has problems with isfinite -// if cmath is included before math.h. -#include -inline float dtMathFabsf(float x) { return fabsf(x); } -inline float dtMathSqrtf(float x) { return sqrtf(x); } -inline float dtMathFloorf(float x) { return floorf(x); } -inline float dtMathCeilf(float x) { return ceilf(x); } -inline float dtMathCosf(float x) { return cosf(x); } -inline float dtMathSinf(float x) { return sinf(x); } -inline float dtMathAtan2f(float y, float x) { return atan2f(y, x); } -inline bool dtMathIsfinite(float x) { return std::isfinite(x); } +#define dtMathFabs(x) fabs(x) +#define dtMathSqrtf(x) sqrtf(x) +#define dtMathFloorf(x) floorf(x) +#define dtMathCeilf(x) ceilf(x) +#define dtMathCosf(x) cosf(x) +#define dtMathSinf(x) sinf(x) +#define dtMathAtan2f(y, x) atan2f(y, x) #endif diff --git a/dep/recastnavigation/Detour/Include/DetourStatus.h b/dep/recastnavigation/Detour/Include/DetourStatus.h index 8e1bb44b9..5fda18955 100644 --- a/dep/recastnavigation/Detour/Include/DetourStatus.h +++ b/dep/recastnavigation/Detour/Include/DetourStatus.h @@ -22,44 +22,43 @@ typedef unsigned int dtStatus; // High level status. -static const unsigned int DT_FAILURE = 1u << 31; // Operation failed. -static const unsigned int DT_SUCCESS = 1u << 30; // Operation succeed. -static const unsigned int DT_IN_PROGRESS = 1u << 29; // Operation still in progress. +static const unsigned int DT_FAILURE = 1u << 31; // Operation failed. +static const unsigned int DT_SUCCESS = 1u << 30; // Operation succeed. +static const unsigned int DT_IN_PROGRESS = 1u << 29; // Operation still in progress. // Detail information for status. static const unsigned int DT_STATUS_DETAIL_MASK = 0x0ffffff; -static const unsigned int DT_WRONG_MAGIC = 1 << 0; // Input data is not recognized. -static const unsigned int DT_WRONG_VERSION = 1 << 1; // Input data is in wrong version. -static const unsigned int DT_OUT_OF_MEMORY = 1 << 2; // Operation ran out of memory. -static const unsigned int DT_INVALID_PARAM = 1 << 3; // An input parameter was invalid. -static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results. -static const unsigned int DT_OUT_OF_NODES = 1 << 5; // Query ran out of nodes during search. -static const unsigned int DT_PARTIAL_RESULT = 1 << 6; // Query did not reach the end location, returning best guess. -static const unsigned int DT_ALREADY_OCCUPIED = 1 << 7; // A tile has already been assigned to the given x,y coordinate +static const unsigned int DT_WRONG_MAGIC = 1 << 0; // Input data is not recognized. +static const unsigned int DT_WRONG_VERSION = 1 << 1; // Input data is in wrong version. +static const unsigned int DT_OUT_OF_MEMORY = 1 << 2; // Operation ran out of memory. +static const unsigned int DT_INVALID_PARAM = 1 << 3; // An input parameter was invalid. +static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results. +static const unsigned int DT_OUT_OF_NODES = 1 << 5; // Query ran out of nodes during search. +static const unsigned int DT_PARTIAL_RESULT = 1 << 6; // Query did not reach the end location, returning best guess. // Returns true of status is success. inline bool dtStatusSucceed(dtStatus status) { - return (status & DT_SUCCESS) != 0; + return (status & DT_SUCCESS) != 0; } // Returns true of status is failure. inline bool dtStatusFailed(dtStatus status) { - return (status & DT_FAILURE) != 0; + return (status & DT_FAILURE) != 0; } // Returns true of status is in progress. inline bool dtStatusInProgress(dtStatus status) { - return (status & DT_IN_PROGRESS) != 0; + return (status & DT_IN_PROGRESS) != 0; } // Returns true if specific detail is set. inline bool dtStatusDetail(dtStatus status, unsigned int detail) { - return (status & detail) != 0; + return (status & detail) != 0; } #endif // DETOURSTATUS_H diff --git a/dep/recastnavigation/Detour/win/Detour_VC110.sln b/dep/recastnavigation/Detour/win/Detour_VC110.sln new file mode 100644 index 000000000..90ca77391 --- /dev/null +++ b/dep/recastnavigation/Detour/win/Detour_VC110.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Detour", "VC110\Detour.vcxproj", "{72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|Win32.ActiveCfg = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|Win32.Build.0 = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|x64.ActiveCfg = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|x64.Build.0 = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|Win32.ActiveCfg = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|Win32.Build.0 = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|x64.ActiveCfg = Release|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/recastnavigation/Detour/win/Detour_VC120.sln b/dep/recastnavigation/Detour/win/Detour_VC120.sln new file mode 100644 index 000000000..30342e5c8 --- /dev/null +++ b/dep/recastnavigation/Detour/win/Detour_VC120.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Detour", "VC120\Detour.vcxproj", "{72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|Win32.ActiveCfg = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|Win32.Build.0 = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|x64.ActiveCfg = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|x64.Build.0 = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|Win32.ActiveCfg = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|Win32.Build.0 = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|x64.ActiveCfg = Release|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dep/recastnavigation/Detour/win/VC110/.gitignore b/dep/recastnavigation/Detour/win/VC110/.gitignore new file mode 100644 index 000000000..d82e4915b --- /dev/null +++ b/dep/recastnavigation/Detour/win/VC110/.gitignore @@ -0,0 +1,6 @@ + +*__Win32_Release +*__Win32_Debug +*__x64_Release +*__x64_Debug +*.user \ No newline at end of file diff --git a/dep/recastnavigation/Detour/win/VC110/Detour.vcxproj b/dep/recastnavigation/Detour/win/VC110/Detour.vcxproj new file mode 100644 index 000000000..e9f5bc86c --- /dev/null +++ b/dep/recastnavigation/Detour/win/VC110/Detour.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6} + Detour + + + + StaticLibrary + true + MultiByte + v110 + + + StaticLibrary + true + MultiByte + v110 + + + StaticLibrary + false + false + MultiByte + v110 + + + StaticLibrary + false + false + MultiByte + v110 + + + + + + + + + + + + + + + + + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + + Level3 + Disabled + ..\..\include + WIN32;DEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + + + true + + + + + Level3 + Disabled + ..\..\include + WIN32;DEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + + + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + ..\..\include + WIN32;NDEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + Speed + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + ..\..\include + WIN32;NDEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + Speed + + + true + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dep/recastnavigation/Detour/win/VC110/Detour.vcxproj.filters b/dep/recastnavigation/Detour/win/VC110/Detour.vcxproj.filters new file mode 100644 index 000000000..6f8f523d6 --- /dev/null +++ b/dep/recastnavigation/Detour/win/VC110/Detour.vcxproj.filters @@ -0,0 +1,60 @@ + + + + + {93bb99d1-034f-421d-abf2-856b22079565} + + + {661147bd-4839-4f24-8697-6ce5cb9b61a2} + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/dep/recastnavigation/Detour/win/VC120/.gitignore b/dep/recastnavigation/Detour/win/VC120/.gitignore new file mode 100644 index 000000000..d82e4915b --- /dev/null +++ b/dep/recastnavigation/Detour/win/VC120/.gitignore @@ -0,0 +1,6 @@ + +*__Win32_Release +*__Win32_Debug +*__x64_Release +*__x64_Debug +*.user \ No newline at end of file diff --git a/dep/recastnavigation/Detour/win/VC120/Detour.vcxproj b/dep/recastnavigation/Detour/win/VC120/Detour.vcxproj new file mode 100644 index 000000000..010862135 --- /dev/null +++ b/dep/recastnavigation/Detour/win/VC120/Detour.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6} + Detour + + + + StaticLibrary + true + MultiByte + v120 + + + StaticLibrary + true + MultiByte + v120 + + + StaticLibrary + false + false + MultiByte + v120 + + + StaticLibrary + false + false + MultiByte + v120 + + + + + + + + + + + + + + + + + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + + Level3 + Disabled + ..\..\include + WIN32;DEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + + + true + + + + + Level3 + Disabled + ..\..\include + WIN32;DEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + + + true + MachineX64 + + + + + Level3 + MaxSpeed + true + true + ..\..\include + WIN32;NDEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + Speed + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + ..\..\include + WIN32;NDEBUG;_MBCS;DT_POLYREF64;%(PreprocessorDefinitions) + Speed + + + true + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dep/recastnavigation/Detour/win/VC120/Detour.vcxproj.filters b/dep/recastnavigation/Detour/win/VC120/Detour.vcxproj.filters new file mode 100644 index 000000000..6f8f523d6 --- /dev/null +++ b/dep/recastnavigation/Detour/win/VC120/Detour.vcxproj.filters @@ -0,0 +1,60 @@ + + + + + {93bb99d1-034f-421d-abf2-856b22079565} + + + {661147bd-4839-4f24-8697-6ce5cb9b61a2} + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/dep/recastnavigation/DetourCrowd/Include/DetourCrowd.h b/dep/recastnavigation/DetourCrowd/Include/DetourCrowd.h new file mode 100644 index 000000000..0a77904f8 --- /dev/null +++ b/dep/recastnavigation/DetourCrowd/Include/DetourCrowd.h @@ -0,0 +1,450 @@ +// +// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. +// + +#ifndef DETOURCROWD_H +#define DETOURCROWD_H + +#include "DetourNavMeshQuery.h" +#include "DetourObstacleAvoidance.h" +#include "DetourLocalBoundary.h" +#include "DetourPathCorridor.h" +#include "DetourProximityGrid.h" +#include "DetourPathQueue.h" + +/// The maximum number of neighbors that a crowd agent can take into account +/// for steering decisions. +/// @ingroup crowd +static const int DT_CROWDAGENT_MAX_NEIGHBOURS = 6; + +/// The maximum number of corners a crowd agent will look ahead in the path. +/// This value is used for sizing the crowd agent corner buffers. +/// Due to the behavior of the crowd manager, the actual number of useful +/// corners will be one less than this number. +/// @ingroup crowd +static const int DT_CROWDAGENT_MAX_CORNERS = 4; + +/// The maximum number of crowd avoidance configurations supported by the +/// crowd manager. +/// @ingroup crowd +/// @see dtObstacleAvoidanceParams, dtCrowd::setObstacleAvoidanceParams(), dtCrowd::getObstacleAvoidanceParams(), +/// dtCrowdAgentParams::obstacleAvoidanceType +static const int DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS = 8; + +/// The maximum number of query filter types supported by the crowd manager. +/// @ingroup crowd +/// @see dtQueryFilter, dtCrowd::getFilter() dtCrowd::getEditableFilter(), +/// dtCrowdAgentParams::queryFilterType +static const int DT_CROWD_MAX_QUERY_FILTER_TYPE = 16; + +/// Provides neighbor data for agents managed by the crowd. +/// @ingroup crowd +/// @see dtCrowdAgent::neis, dtCrowd +struct dtCrowdNeighbour +{ + int idx; ///< The index of the neighbor in the crowd. + float dist; ///< The distance between the current agent and the neighbor. +}; + +/// The type of navigation mesh polygon the agent is currently traversing. +/// @ingroup crowd +enum CrowdAgentState +{ + DT_CROWDAGENT_STATE_INVALID, ///< The agent is not in a valid state. + DT_CROWDAGENT_STATE_WALKING, ///< The agent is traversing a normal navigation mesh polygon. + DT_CROWDAGENT_STATE_OFFMESH, ///< The agent is traversing an off-mesh connection. +}; + +/// Configuration parameters for a crowd agent. +/// @ingroup crowd +struct dtCrowdAgentParams +{ + float radius; ///< Agent radius. [Limit: >= 0] + float height; ///< Agent height. [Limit: > 0] + float maxAcceleration; ///< Maximum allowed acceleration. [Limit: >= 0] + float maxSpeed; ///< Maximum allowed speed. [Limit: >= 0] + + /// Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0] + float collisionQueryRange; + + float pathOptimizationRange; ///< The path visibility optimization range. [Limit: > 0] + + /// How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0] + float separationWeight; + + /// Flags that impact steering behavior. (See: #UpdateFlags) + unsigned char updateFlags; + + /// The index of the avoidance configuration to use for the agent. + /// [Limits: 0 <= value <= #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS] + unsigned char obstacleAvoidanceType; + + /// The index of the query filter used by this agent. + unsigned char queryFilterType; + + /// User defined data attached to the agent. + void* userData; +}; + +enum MoveRequestState +{ + DT_CROWDAGENT_TARGET_NONE = 0, + DT_CROWDAGENT_TARGET_FAILED, + DT_CROWDAGENT_TARGET_VALID, + DT_CROWDAGENT_TARGET_REQUESTING, + DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE, + DT_CROWDAGENT_TARGET_WAITING_FOR_PATH, + DT_CROWDAGENT_TARGET_VELOCITY, +}; + +/// Represents an agent managed by a #dtCrowd object. +/// @ingroup crowd +struct dtCrowdAgent +{ + /// True if the agent is active, false if the agent is in an unused slot in the agent pool. + bool active; + + /// The type of mesh polygon the agent is traversing. (See: #CrowdAgentState) + unsigned char state; + + /// True if the agent has valid path (targetState == DT_CROWDAGENT_TARGET_VALID) and the path does not lead to the requested position, else false. + bool partial; + + /// The path corridor the agent is using. + dtPathCorridor corridor; + + /// The local boundary data for the agent. + dtLocalBoundary boundary; + + /// Time since the agent's path corridor was optimized. + float topologyOptTime; + + /// The known neighbors of the agent. + dtCrowdNeighbour neis[DT_CROWDAGENT_MAX_NEIGHBOURS]; + + /// The number of neighbors. + int nneis; + + /// The desired speed. + float desiredSpeed; + + float npos[3]; ///< The current agent position. [(x, y, z)] + float disp[3]; + float dvel[3]; ///< The desired velocity of the agent. [(x, y, z)] + float nvel[3]; + float vel[3]; ///< The actual velocity of the agent. [(x, y, z)] + + /// The agent's configuration parameters. + dtCrowdAgentParams params; + + /// The local path corridor corners for the agent. (Staight path.) [(x, y, z) * #ncorners] + float cornerVerts[DT_CROWDAGENT_MAX_CORNERS*3]; + + /// The local path corridor corner flags. (See: #dtStraightPathFlags) [(flags) * #ncorners] + unsigned char cornerFlags[DT_CROWDAGENT_MAX_CORNERS]; + + /// The reference id of the polygon being entered at the corner. [(polyRef) * #ncorners] + dtPolyRef cornerPolys[DT_CROWDAGENT_MAX_CORNERS]; + + /// The number of corners. + int ncorners; + + unsigned char targetState; ///< State of the movement request. + dtPolyRef targetRef; ///< Target polyref of the movement request. + float targetPos[3]; ///< Target position of the movement request (or velocity in case of DT_CROWDAGENT_TARGET_VELOCITY). + dtPathQueueRef targetPathqRef; ///< Path finder ref. + bool targetReplan; ///< Flag indicating that the current path is being replanned. + float targetReplanTime; ///