-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
405 additions
and
174 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
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 |
---|---|---|
|
@@ -81,3 +81,4 @@ CMakeLists.txt.user* | |
# Deploy | ||
/deployment | ||
/neko*.sh | ||
/qtsdk/ |
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,88 @@ | ||
#include "base64.h" | ||
|
||
namespace Qt515Base64 { | ||
namespace { | ||
struct fromBase64_helper_result { | ||
qsizetype decodedLength; | ||
Base64DecodingStatus status; | ||
}; | ||
|
||
fromBase64_helper_result fromBase64_helper(const char *input, qsizetype inputSize, | ||
char *output /* may alias input */, | ||
Base64Options options) { | ||
fromBase64_helper_result result{0, Base64DecodingStatus::Ok}; | ||
|
||
unsigned int buf = 0; | ||
int nbits = 0; | ||
|
||
qsizetype offset = 0; | ||
for (qsizetype i = 0; i < inputSize; ++i) { | ||
int ch = input[i]; | ||
int d; | ||
|
||
if (ch >= 'A' && ch <= 'Z') { | ||
d = ch - 'A'; | ||
} else if (ch >= 'a' && ch <= 'z') { | ||
d = ch - 'a' + 26; | ||
} else if (ch >= '0' && ch <= '9') { | ||
d = ch - '0' + 52; | ||
} else if (ch == '+' && (options & Base64UrlEncoding) == 0) { | ||
d = 62; | ||
} else if (ch == '-' && (options & Base64UrlEncoding) != 0) { | ||
d = 62; | ||
} else if (ch == '/' && (options & Base64UrlEncoding) == 0) { | ||
d = 63; | ||
} else if (ch == '_' && (options & Base64UrlEncoding) != 0) { | ||
d = 63; | ||
} else { | ||
if (options & AbortOnBase64DecodingErrors) { | ||
if (ch == '=') { | ||
// can have 1 or 2 '=' signs, in both cases padding base64Size to | ||
// a multiple of 4. Any other case is illegal. | ||
if ((inputSize % 4) != 0) { | ||
result.status = Base64DecodingStatus::IllegalInputLength; | ||
return result; | ||
} else if ((i == inputSize - 1) || | ||
(i == inputSize - 2 && input[++i] == '=')) { | ||
d = -1; // ... and exit the loop, normally | ||
} else { | ||
result.status = Base64DecodingStatus::IllegalPadding; | ||
return result; | ||
} | ||
} else { | ||
result.status = Base64DecodingStatus::IllegalCharacter; | ||
return result; | ||
} | ||
} else { | ||
d = -1; | ||
} | ||
} | ||
|
||
if (d != -1) { | ||
buf = (buf << 6) | d; | ||
nbits += 6; | ||
if (nbits >= 8) { | ||
nbits -= 8; | ||
Q_ASSERT(offset < i); | ||
output[offset++] = buf >> nbits; | ||
buf &= (1 << nbits) - 1; | ||
} | ||
} | ||
} | ||
|
||
result.decodedLength = offset; | ||
return result; | ||
} | ||
} // namespace | ||
|
||
FromBase64Result QByteArray_fromBase64Encoding(const QByteArray &base64, Base64Options options) { | ||
const auto base64Size = base64.size(); | ||
QByteArray result((base64Size * 3) / 4, Qt::Uninitialized); | ||
const auto base64result = fromBase64_helper(base64.data(), | ||
base64Size, | ||
const_cast<char *>(result.constData()), | ||
options); | ||
result.truncate(int(base64result.decodedLength)); | ||
return {std::move(result), base64result.status}; | ||
} | ||
} // namespace Qt515Base64 |
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,47 @@ | ||
#include <QByteArray> | ||
|
||
namespace Qt515Base64 { | ||
enum Base64Option { | ||
Base64Encoding = 0, | ||
Base64UrlEncoding = 1, | ||
|
||
KeepTrailingEquals = 0, | ||
OmitTrailingEquals = 2, | ||
|
||
IgnoreBase64DecodingErrors = 0, | ||
AbortOnBase64DecodingErrors = 4, | ||
}; | ||
Q_DECLARE_FLAGS(Base64Options, Base64Option) | ||
Q_DECLARE_OPERATORS_FOR_FLAGS(Base64Options) | ||
|
||
enum class Base64DecodingStatus { | ||
Ok, | ||
IllegalInputLength, | ||
IllegalCharacter, | ||
IllegalPadding, | ||
}; | ||
|
||
class FromBase64Result { | ||
public: | ||
QByteArray decoded; | ||
Base64DecodingStatus decodingStatus; | ||
|
||
void swap(FromBase64Result &other) noexcept { | ||
qSwap(decoded, other.decoded); | ||
qSwap(decodingStatus, other.decodingStatus); | ||
} | ||
|
||
explicit operator bool() const noexcept { return decodingStatus == Base64DecodingStatus::Ok; } | ||
|
||
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(Q_QDOC) | ||
QByteArray &operator*() &noexcept { return decoded; } | ||
const QByteArray &operator*() const &noexcept { return decoded; } | ||
QByteArray &&operator*() &&noexcept { return std::move(decoded); } | ||
#else | ||
QByteArray &operator*() noexcept { return decoded; } | ||
const QByteArray &operator*() const noexcept { return decoded; } | ||
#endif | ||
}; | ||
|
||
FromBase64Result QByteArray_fromBase64Encoding(const QByteArray &base64, Base64Options options); | ||
} // namespace Qt515Base64 |
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,30 @@ | ||
## Linux 运行 | ||
|
||
**使用 Linux 系统相信您已具备基本的排错能力, | ||
本项目不提供特定发行版/架构的支持,预编译文件不能满足您的需求时,请自行编译/适配。** | ||
|
||
已知部分 Linux 发行版无法使用、非 x86_64 暂无适配,可以尝试自行编译。 | ||
|
||
目前 Release 便携包解压后,有两种使用方法: | ||
|
||
1. System: 若要使用系统的 Qt5 运行库,请执行 `./nekoray` | ||
2. Bundle: 若要使用预编译的 Qt 运行库,请执行 `./launcher` | ||
|
||
### Bundle | ||
|
||
要求:已安装主流的发行版和 xcb 桌面环境。 | ||
|
||
运行: `./launcher` 或 部分系统可双击打开 | ||
|
||
launcher 参数 | ||
|
||
* `./launcher -- -appdata` ( `--` 后的参数传递给主程序 ) | ||
* `-debug` Debug mode | ||
|
||
Ubuntu 22.04: `sudo apt install libxcb-xinerama0` | ||
|
||
### System | ||
|
||
要求:已安装主流的发行版和 xcb 桌面环境,已安装 Qt5.12 ~ Qt5.15 环境。 | ||
|
||
运行: `./nekoray` 或 部分系统可双击打开。如果无法运行,建议使用 Bundle 版。 |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
#pragma once | ||
|
||
#include <QJsonObject> | ||
#include <QJsonArray> | ||
|
||
#include "main/NekoRay.hpp" | ||
|
||
namespace NekoRay::fmt { | ||
|
Oops, something went wrong.