-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Dependency management and new C++ Server code
- Loading branch information
1 parent
cf24428
commit 88d6419
Showing
421 changed files
with
73,487 additions
and
50,239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[submodule "submodules/cppcodec"] | ||
path = submodules/cppcodec | ||
url = https://github.com/tplgy/cppcodec.git | ||
[submodule "submodules/crossguid"] | ||
path = submodules/crossguid | ||
url = https://github.com/graeme-hill/crossguid.git | ||
[submodule "submodules/libzip"] | ||
path = submodules/libzip | ||
url = https://github.com/nih-at/libzip.git | ||
[submodule "submodules/lodepng"] | ||
path = submodules/lodepng | ||
url = https://github.com/lvandeve/lodepng.git | ||
[submodule "submodules/PicoSHA2"] | ||
path = submodules/PicoSHA2 | ||
url = https://github.com/okdshin/PicoSHA2.git | ||
[submodule "submodules/pugixml"] | ||
path = submodules/pugixml | ||
url = https://github.com/zeux/pugixml.git | ||
[submodule "submodules/rapidjson"] | ||
path = submodules/rapidjson | ||
url = https://github.com/Tencent/rapidjson.git | ||
[submodule "submodules/sqlite"] | ||
path = submodules/sqlite | ||
url = https://github.com/sqlite/sqlite.git | ||
[submodule "submodules/zlib"] | ||
path = submodules/zlib | ||
url = https://github.com/madler/zlib.git | ||
[submodule "submodules/AutomaticComponentToolkit"] | ||
path = submodules/AutomaticComponentToolkit | ||
url = https://github.com/Autodesk/AutomaticComponentToolkit.git | ||
[submodule "submodules/lib3mf"] | ||
path = submodules/lib3mf | ||
url = https://github.com/3MFConsortium/lib3mf.git | ||
[submodule "submodules/uWebSockets"] | ||
path = submodules/uWebSockets | ||
url = https://github.com/uNetworking/uWebSockets.git | ||
[submodule "submodules/curl"] | ||
path = submodules/curl | ||
url = https://github.com/curl/curl.git | ||
[submodule "submodules/libuv"] | ||
path = submodules/libuv | ||
url = https://github.com/libuv/libuv.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/*++ | ||
Copyright (C) 2020 Autodesk Inc. | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* 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. | ||
* Neither the name of the Autodesk Inc. nor the | ||
names of its contributors may 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 AUTODESK INC. 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. | ||
*/ | ||
|
||
|
||
#include <string> | ||
|
||
#include "crossguid/guid.hpp" | ||
#include "PicoSHA2/picosha2.h" | ||
#include "common_utils.hpp" | ||
|
||
#define LIBMC_MAXRANDOMSTRINGITERATIONS 1024 | ||
|
||
namespace AMCCommon { | ||
|
||
|
||
#ifdef _WASM | ||
xg::Guid xg::newGuid() | ||
{ | ||
std::array<unsigned char, 16> bytes; | ||
for (int index = 0; index < 16; index++) { | ||
bytes[index] = rand() % 256; | ||
} | ||
return xg::Guid{ std::move(bytes) }; | ||
|
||
} | ||
#endif //_WASM | ||
|
||
std::string CUtils::createUUID() | ||
{ | ||
auto guid = xg::newGuid(); | ||
return normalizeUUIDString(guid.str()); | ||
} | ||
|
||
|
||
|
||
std::string CUtils::calculateRandomSHA256String(const uint32_t nIterations) | ||
{ | ||
if ((nIterations == 0) || (nIterations > LIBMC_MAXRANDOMSTRINGITERATIONS)) | ||
throw std::runtime_error("invalid random string iterations"); | ||
|
||
std::string sRandomString; | ||
|
||
uint32_t nCount = nIterations + (((uint32_t)rand()) % nIterations); | ||
for (uint32_t nIndex = 0; nIndex < nCount; nIndex++) | ||
sRandomString += createUUID(); | ||
|
||
return calculateSHA256FromString(sRandomString); | ||
} | ||
|
||
|
||
// Returns a UUID, such that sBasePath/sPrefixUUID.extension does not exist. | ||
// Tries out maximum nMaxIterations different random uuids. | ||
std::string CUtils::findTemporaryFileName(const std::string& sBasePath, const std::string& sPrefix, const std::string& sExtension, const uint32_t nMaxIterations) | ||
{ | ||
if (sBasePath.empty()) | ||
throw std::runtime_error("empty temporary file base path"); | ||
|
||
std::string sBasePathWithDelimiter = sBasePath; | ||
std::string sExtensionWithPoint; | ||
|
||
if (!sExtension.empty()) { | ||
if (sExtension.at(0) != '.') { | ||
sExtensionWithPoint = "." + sExtension; | ||
} | ||
else { | ||
sExtensionWithPoint = sExtension; | ||
} | ||
|
||
} | ||
|
||
char lastChar = sBasePathWithDelimiter.at(sBasePathWithDelimiter.length() - 1); | ||
if ((lastChar != '/') && (lastChar != '\\')) | ||
sBasePathWithDelimiter += "/"; | ||
|
||
for (uint32_t nIndex = 0; nIndex < nMaxIterations; nIndex++) { | ||
std::string sUUID = createUUID(); | ||
std::string sFullPath = sBasePathWithDelimiter + sPrefix + sUUID + sExtensionWithPoint; | ||
|
||
if (!fileOrPathExistsOnDisk(sFullPath)) | ||
return sFullPath; | ||
|
||
} | ||
|
||
throw std::runtime_error("could not create temporary file path"); | ||
|
||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.