chore: format code
This commit is contained in:
parent
8d2041e946
commit
b76daa2927
130
.clang-format
Normal file
130
.clang-format
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
---
|
||||||
|
AccessModifierOffset: 0
|
||||||
|
AlignAfterOpenBracket: BlockIndent
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments: None
|
||||||
|
AlignConsecutiveMacros: None
|
||||||
|
AlignConsecutiveBitFields: None
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignEscapedNewlines: DontAlign
|
||||||
|
AlignOperands: DontAlign
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
AttributeMacros: []
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BitFieldColonSpacing: After
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: false
|
||||||
|
SplitEmptyRecord: false
|
||||||
|
SplitEmptyNamespace: false
|
||||||
|
BreakAfterJavaFieldAnnotations: true
|
||||||
|
#BreakArrays: false
|
||||||
|
BreakBeforeBinaryOperators: All
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeConceptDeclarations: true
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
BreakInheritanceList: AfterColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 90
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
DeriveLineEnding: false
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false # wtf
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: Always
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: false
|
||||||
|
ForEachMacros: ["BOOST_FOREACH"]
|
||||||
|
IfMacros: []
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: Indent
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
#IndentRequiresClause: false
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
#InsertBraces: false
|
||||||
|
InsertTrailingCommas: Wrapped
|
||||||
|
JavaImportGroups: ["java"]
|
||||||
|
JavaScriptQuotes: Double
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
LambdaBodyIndentation: OuterScope
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: All
|
||||||
|
PackConstructorInitializers: NextLine
|
||||||
|
PointerAlignment: Left
|
||||||
|
QualifierAlignment: Left
|
||||||
|
ReferenceAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
#RemoveSemicolon: true
|
||||||
|
#RequiresClausePosition: OwnLine
|
||||||
|
#RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Always
|
||||||
|
SortIncludes: CaseInsensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceAroundPointerQualifiers: After
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: false
|
||||||
|
SpaceBeforeInheritanceColon: false
|
||||||
|
SpaceBeforeParens: ControlStatementsExceptControlMacros
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 0
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: c++20
|
||||||
|
StatementAttributeLikeMacros: []
|
||||||
|
StatementMacros: []
|
||||||
|
TabWidth: 4
|
||||||
|
TypenameMacros: []
|
||||||
|
UseCRLF: false # wtf
|
||||||
|
UseTab: Never
|
||||||
|
WhitespaceSensitiveMacros: ["BOOST_PP_STRINGSIZE"]
|
10
src/ansi.hpp
10
src/ansi.hpp
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace ansi {
|
namespace ansi {
|
||||||
const char *reset = "\033[0m";
|
inline const char* reset = "\033[0m";
|
||||||
|
|
||||||
const char *cyan = "\033[0;36m";
|
inline const char* cyan = "\033[0;36m";
|
||||||
const char *green = "\033[0;32m";
|
inline const char* green = "\033[0;32m";
|
||||||
const char *yellow = "\033[0;33m";
|
inline const char* yellow = "\033[0;33m";
|
||||||
} // namespace ansi
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "data.hpp"
|
#include "data.hpp"
|
||||||
#include "resourceloc.hpp"
|
#include "resourceloc.hpp"
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -17,8 +18,15 @@ void sendMsg(int msqid, data::RequestMapMsg *msg) {
|
||||||
|
|
||||||
std::string recvMsg(int msqid) {
|
std::string recvMsg(int msqid) {
|
||||||
data::ResponseMapMsg msg;
|
data::ResponseMapMsg msg;
|
||||||
if (msgrcv(msqid, &msg, sizeof(data::ResponseMapMsg) - sizeof(long),
|
|
||||||
data::clientbound_msg, 0) < 0) {
|
if (msgrcv(
|
||||||
|
msqid,
|
||||||
|
&msg,
|
||||||
|
sizeof(data::ResponseMapMsg) - sizeof(long),
|
||||||
|
data::clientbound_msg,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
< 0) {
|
||||||
throw std::runtime_error(std::string("receive error ") + strerror(errno));
|
throw std::runtime_error(std::string("receive error ") + strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,4 +58,4 @@ void resolveResourceLoc(key_t key) {
|
||||||
|
|
||||||
std::cout << resourceloc::resolve(inp) << std::endl;
|
std::cout << resourceloc::resolve(inp) << std::endl;
|
||||||
}
|
}
|
||||||
} // namespace client
|
}
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
namespace client {
|
namespace client {
|
||||||
void map(key_t key);
|
void map(key_t key);
|
||||||
void resolveResourceLoc(key_t key);
|
void resolveResourceLoc(key_t key);
|
||||||
} // namespace client
|
}
|
||||||
|
|
22
src/csv.cpp
22
src/csv.cpp
|
@ -1,10 +1,15 @@
|
||||||
#include "csv.hpp"
|
#include "csv.hpp"
|
||||||
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace csv {
|
namespace csv {
|
||||||
enum class CSVState { UnquotedField, QuotedField, QuotedQuote };
|
enum class CSVState {
|
||||||
|
UnquotedField,
|
||||||
|
QuotedField,
|
||||||
|
QuotedQuote
|
||||||
|
};
|
||||||
|
|
||||||
// this function has been made in collaboration with
|
// this function has been made in collaboration with
|
||||||
// StackOverflow https://stackoverflow.com/a/30338543
|
// StackOverflow https://stackoverflow.com/a/30338543
|
||||||
|
@ -12,6 +17,7 @@ void readCSVRow(const std::string &row, std::vector<std::string> &fields) {
|
||||||
fields.push_back("");
|
fields.push_back("");
|
||||||
CSVState state = CSVState::UnquotedField;
|
CSVState state = CSVState::UnquotedField;
|
||||||
size_t i = 0; // index of the current field
|
size_t i = 0; // index of the current field
|
||||||
|
|
||||||
for (char c : row) {
|
for (char c : row) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case CSVState::UnquotedField:
|
case CSVState::UnquotedField:
|
||||||
|
@ -20,24 +26,31 @@ void readCSVRow(const std::string &row, std::vector<std::string> &fields) {
|
||||||
fields.push_back("");
|
fields.push_back("");
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
state = CSVState::QuotedField;
|
state = CSVState::QuotedField;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fields[i].push_back(c);
|
fields[i].push_back(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSVState::QuotedField:
|
case CSVState::QuotedField:
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '"':
|
case '"':
|
||||||
state = CSVState::QuotedQuote;
|
state = CSVState::QuotedQuote;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fields[i].push_back(c);
|
fields[i].push_back(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSVState::QuotedQuote:
|
case CSVState::QuotedQuote:
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case ',': // , after closing quote
|
case ',': // , after closing quote
|
||||||
|
@ -45,20 +58,25 @@ void readCSVRow(const std::string &row, std::vector<std::string> &fields) {
|
||||||
i++;
|
i++;
|
||||||
state = CSVState::UnquotedField;
|
state = CSVState::UnquotedField;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '"': // "" -> "
|
case '"': // "" -> "
|
||||||
fields[i].push_back('"');
|
fields[i].push_back('"');
|
||||||
state = CSVState::QuotedField;
|
state = CSVState::QuotedField;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // end of quote
|
default: // end of quote
|
||||||
state = CSVState::UnquotedField;
|
state = CSVState::UnquotedField;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsvReader::operator>>(std::vector<std::string>& line) {
|
bool CsvReader::operator>>(std::vector<std::string>& line) {
|
||||||
line.clear();
|
line.clear();
|
||||||
|
|
||||||
if (!m_stream) {
|
if (!m_stream) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -70,4 +88,4 @@ bool CsvReader::operator>>(std::vector<std::string> &line) {
|
||||||
|
|
||||||
return !!m_stream;
|
return !!m_stream;
|
||||||
}
|
}
|
||||||
} // namespace csv
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace csv {
|
namespace csv {
|
||||||
class CsvReader {
|
class CsvReader {
|
||||||
private:
|
private:
|
||||||
|
@ -13,4 +14,4 @@ public:
|
||||||
|
|
||||||
bool operator>>(std::vector<std::string>& line);
|
bool operator>>(std::vector<std::string>& line);
|
||||||
};
|
};
|
||||||
} // namespace csv
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "data.hpp"
|
#include "data.hpp"
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -14,4 +15,4 @@ key_t getIpcKeyFromExeName(char *argv0) {
|
||||||
|
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
} // namespace data
|
}
|
||||||
|
|
|
@ -21,4 +21,4 @@ struct ResponseMapMsg {
|
||||||
unsigned int datalen;
|
unsigned int datalen;
|
||||||
char data[128];
|
char data[128];
|
||||||
};
|
};
|
||||||
} // namespace data
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "client.hpp"
|
#include "client.hpp"
|
||||||
#include "data.hpp"
|
#include "data.hpp"
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "mappings.hpp"
|
#include "mappings.hpp"
|
||||||
|
|
||||||
#include "ansi.hpp"
|
#include "ansi.hpp"
|
||||||
#include "csv.hpp"
|
#include "csv.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
|
@ -24,29 +26,35 @@ Mappings Mappings::load() {
|
||||||
|
|
||||||
// load mappings
|
// load mappings
|
||||||
fs::directory_iterator end_itr;
|
fs::directory_iterator end_itr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (fs::directory_iterator itr("mappings"); itr != end_itr; ++itr) {
|
for (fs::directory_iterator itr("mappings"); itr != end_itr; ++itr) {
|
||||||
if (fs::is_directory(itr->status()) ||
|
if (fs::is_directory(itr->status())
|
||||||
!boost::algorithm::ends_with(itr->path().string(), ".csv"))
|
|| !boost::algorithm::ends_with(itr->path().string(), ".csv"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
csv::CsvReader csv(itr->path().string());
|
csv::CsvReader csv(itr->path().string());
|
||||||
|
|
||||||
std::vector<std::string> l;
|
std::vector<std::string> l;
|
||||||
|
|
||||||
while (csv >> l) {
|
while (csv >> l) {
|
||||||
if (l.size() < 2) {
|
if (l.size() < 2) {
|
||||||
BOOST_LOG_TRIVIAL(warning) << "found invalid mapping";
|
BOOST_LOG_TRIVIAL(warning) << "found invalid mapping";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mappings[l[0]] = {l[0], l[1],
|
|
||||||
l.size() >= 4 ? std::optional(l[3]) : std::nullopt};
|
mappings[l[0]] = {
|
||||||
|
l[0], l[1], l.size() >= 4 ? std::optional(l[3]) : std::nullopt
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (boost::filesystem::filesystem_error& e) {
|
} catch (boost::filesystem::filesystem_error& e) {
|
||||||
if (e.code() == boost::system::errc::no_such_file_or_directory) {
|
if (e.code() == boost::system::errc::no_such_file_or_directory) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
std::string("The mappings directory is missing!\n") + e.what());
|
std::string("The mappings directory is missing!\n") + e.what()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +62,7 @@ Mappings Mappings::load() {
|
||||||
csv::CsvReader csv("renames.csv");
|
csv::CsvReader csv("renames.csv");
|
||||||
|
|
||||||
std::vector<std::string> l;
|
std::vector<std::string> l;
|
||||||
|
|
||||||
while (csv >> l) {
|
while (csv >> l) {
|
||||||
if (l.size() < 2) {
|
if (l.size() < 2) {
|
||||||
BOOST_LOG_TRIVIAL(warning) << "found invalid rename";
|
BOOST_LOG_TRIVIAL(warning) << "found invalid rename";
|
||||||
|
@ -75,6 +84,7 @@ void showMapInfo(Mapping mapping, std::optional<std::string> rename) {
|
||||||
auto doc = mapping.doc.has_value()
|
auto doc = mapping.doc.has_value()
|
||||||
? std::string(ansi::yellow) + "\n\n\t" + *mapping.doc + "\n"
|
? std::string(ansi::yellow) + "\n\n\t" + *mapping.doc + "\n"
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
if (rename.has_value()) {
|
if (rename.has_value()) {
|
||||||
BOOST_LOG_TRIVIAL(info)
|
BOOST_LOG_TRIVIAL(info)
|
||||||
<< "\nFound mapping:\n"
|
<< "\nFound mapping:\n"
|
||||||
|
@ -83,11 +93,10 @@ void showMapInfo(Mapping mapping, std::optional<std::string> rename) {
|
||||||
<< ansi::cyan << "\n\tRenamed \t" << ansi::green << *rename << doc
|
<< ansi::cyan << "\n\tRenamed \t" << ansi::green << *rename << doc
|
||||||
<< ansi::reset;
|
<< ansi::reset;
|
||||||
} else {
|
} else {
|
||||||
BOOST_LOG_TRIVIAL(info)
|
BOOST_LOG_TRIVIAL(info) << "\nFound mapping:\n"
|
||||||
<< "\nFound mapping:\n"
|
<< ansi::cyan << "\n\tOriginal\t" << ansi::green
|
||||||
<< ansi::cyan << "\n\tOriginal\t" << ansi::green << mapping.orig
|
<< mapping.orig << ansi::cyan << "\n\tRemapped\t"
|
||||||
<< ansi::cyan << "\n\tRemapped\t" << ansi::green << mapping.name << doc
|
<< ansi::green << mapping.name << doc << ansi::reset;
|
||||||
<< ansi::reset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,4 +118,4 @@ std::string Mappings::map(std::string inp) {
|
||||||
showMapInfo(mapped, std::nullopt);
|
showMapInfo(mapped, std::nullopt);
|
||||||
return mapped.name;
|
return mapped.name;
|
||||||
}
|
}
|
||||||
} // namespace mappings
|
}
|
||||||
|
|
|
@ -15,13 +15,14 @@ class Mappings {
|
||||||
std::map<std::string, std::string> m_renames;
|
std::map<std::string, std::string> m_renames;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Mappings(std::map<std::string, Mapping> mappings,
|
Mappings(
|
||||||
std::map<std::string, std::string> renames) {
|
std::map<std::string, Mapping> mappings,
|
||||||
this->m_mappings = mappings;
|
std::map<std::string, std::string> renames
|
||||||
this->m_renames = renames;
|
):
|
||||||
}
|
m_mappings(mappings), m_renames(renames) {}
|
||||||
|
|
||||||
~Mappings() = default;
|
~Mappings() = default;
|
||||||
static Mappings load();
|
static Mappings load();
|
||||||
std::string map(std::string inp);
|
std::string map(std::string inp);
|
||||||
};
|
};
|
||||||
} // namespace mappings
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "resourceloc.hpp"
|
#include "resourceloc.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
@ -21,14 +22,18 @@ std::string resolve(std::string inp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path_component;
|
std::string path_component;
|
||||||
|
|
||||||
for (unsigned int i = 3; i < components.size(); i++) {
|
for (unsigned int i = 3; i < components.size(); i++) {
|
||||||
path_component += components[i];
|
path_component += components[i];
|
||||||
|
|
||||||
if (i != components.size() - 1) {
|
if (i != components.size() - 1) {
|
||||||
path_component += "/";
|
path_component += "/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::str(boost::format("new ResourceLocation(\"%1%\", \"%2%\")") %
|
return boost::str(
|
||||||
components[2] % path_component);
|
boost::format("new ResourceLocation(\"%1%\", \"%2%\")") % components[2]
|
||||||
|
% path_component
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // namespace resourceloc
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace resourceloc {
|
namespace resourceloc {
|
||||||
std::string resolve(std::string inp);
|
std::string resolve(std::string inp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
#include "data.hpp"
|
#include "data.hpp"
|
||||||
#include "mappings.hpp"
|
#include "mappings.hpp"
|
||||||
#include "resourceloc.hpp"
|
#include "resourceloc.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -36,9 +38,16 @@ void run(key_t key) {
|
||||||
auto mappings = mappings::Mappings::load();
|
auto mappings = mappings::Mappings::load();
|
||||||
|
|
||||||
data::RequestMapMsg msg;
|
data::RequestMapMsg msg;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (msgrcv(msqid, &msg, sizeof(data::RequestMapMsg) - sizeof(long),
|
if (msgrcv(
|
||||||
data::serverbound_msg, 0) < 0) {
|
msqid,
|
||||||
|
&msg,
|
||||||
|
sizeof(data::RequestMapMsg) - sizeof(long),
|
||||||
|
data::serverbound_msg,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
< 0) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "receive error " << strerror(errno);
|
BOOST_LOG_TRIVIAL(error) << "receive error " << strerror(errno);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -48,4 +57,4 @@ void run(key_t key) {
|
||||||
sendToClient(msqid, mappings.map(s));
|
sendToClient(msqid, mappings.map(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace server
|
}
|
||||||
|
|
Loading…
Reference in a new issue