summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/SASL/DIGESTMD5Properties.cpp
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/SASL/DIGESTMD5Properties.cpp')
-rw-r--r--Swiften/SASL/DIGESTMD5Properties.cpp188
1 files changed, 94 insertions, 94 deletions
diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp
index 157261a..baf0197 100644
--- a/Swiften/SASL/DIGESTMD5Properties.cpp
+++ b/Swiften/SASL/DIGESTMD5Properties.cpp
@@ -11,121 +11,121 @@
namespace Swift {
namespace {
- bool insideQuotes(const ByteArray& v) {
- if (v.empty()) {
- return false;
- }
- else if (v.size() == 1) {
- return v[0] == '"';
- }
- else if (v[0] == '"') {
- return v[v.size() - 1] != '"';
- }
- else {
- return false;
- }
- }
+ bool insideQuotes(const ByteArray& v) {
+ if (v.empty()) {
+ return false;
+ }
+ else if (v.size() == 1) {
+ return v[0] == '"';
+ }
+ else if (v[0] == '"') {
+ return v[v.size() - 1] != '"';
+ }
+ else {
+ return false;
+ }
+ }
- ByteArray stripQuotes(const ByteArray& v) {
- const char* data = reinterpret_cast<const char*>(vecptr(v));
- size_t size = v.size();
- if (v[0] == '"') {
- data++;
- size--;
- }
- if (v[v.size() - 1] == '"') {
- size--;
- }
- return createByteArray(data, size);
- }
+ ByteArray stripQuotes(const ByteArray& v) {
+ const char* data = reinterpret_cast<const char*>(vecptr(v));
+ size_t size = v.size();
+ if (v[0] == '"') {
+ data++;
+ size--;
+ }
+ if (v[v.size() - 1] == '"') {
+ size--;
+ }
+ return createByteArray(data, size);
+ }
}
DIGESTMD5Properties::DIGESTMD5Properties() {
}
DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) {
- DIGESTMD5Properties result;
- bool inKey = true;
- ByteArray currentKey;
- ByteArray currentValue;
- for (size_t i = 0; i < data.size(); ++i) {
- char c = static_cast<char>(data[i]);
- if (inKey) {
- if (c == '=') {
- inKey = false;
- }
- else {
- currentKey.push_back(static_cast<unsigned char>(c));
- }
- }
- else {
- if (c == ',' && !insideQuotes(currentValue)) {
- std::string key = byteArrayToString(currentKey);
- if (isQuoted(key)) {
- result.setValue(key, byteArrayToString(stripQuotes(currentValue)));
- }
- else {
- result.setValue(key, byteArrayToString(currentValue));
- }
- inKey = true;
- currentKey = ByteArray();
- currentValue = ByteArray();
- }
- else {
- currentValue.push_back(static_cast<unsigned char>(c));
- }
- }
- }
+ DIGESTMD5Properties result;
+ bool inKey = true;
+ ByteArray currentKey;
+ ByteArray currentValue;
+ for (size_t i = 0; i < data.size(); ++i) {
+ char c = static_cast<char>(data[i]);
+ if (inKey) {
+ if (c == '=') {
+ inKey = false;
+ }
+ else {
+ currentKey.push_back(static_cast<unsigned char>(c));
+ }
+ }
+ else {
+ if (c == ',' && !insideQuotes(currentValue)) {
+ std::string key = byteArrayToString(currentKey);
+ if (isQuoted(key)) {
+ result.setValue(key, byteArrayToString(stripQuotes(currentValue)));
+ }
+ else {
+ result.setValue(key, byteArrayToString(currentValue));
+ }
+ inKey = true;
+ currentKey = ByteArray();
+ currentValue = ByteArray();
+ }
+ else {
+ currentValue.push_back(static_cast<unsigned char>(c));
+ }
+ }
+ }
- if (!currentKey.empty()) {
- std::string key = byteArrayToString(currentKey);
- if (isQuoted(key)) {
- result.setValue(key, byteArrayToString(stripQuotes(currentValue)));
- }
- else {
- result.setValue(key, byteArrayToString(currentValue));
- }
- }
+ if (!currentKey.empty()) {
+ std::string key = byteArrayToString(currentKey);
+ if (isQuoted(key)) {
+ result.setValue(key, byteArrayToString(stripQuotes(currentValue)));
+ }
+ else {
+ result.setValue(key, byteArrayToString(currentValue));
+ }
+ }
- return result;
+ return result;
}
ByteArray DIGESTMD5Properties::serialize() const {
- ByteArray result;
- for(DIGESTMD5PropertiesMap::const_iterator i = properties.begin(); i != properties.end(); ++i) {
- if (i != properties.begin()) {
- result.push_back(',');
- }
- append(result, createByteArray(i->first));
- result.push_back('=');
- if (isQuoted(i->first)) {
- append(result, createByteArray("\""));
- append(result, i->second);
- append(result, createByteArray("\""));
- }
- else {
- append(result, i->second);
- }
- }
- return result;
+ ByteArray result;
+ for(DIGESTMD5PropertiesMap::const_iterator i = properties.begin(); i != properties.end(); ++i) {
+ if (i != properties.begin()) {
+ result.push_back(',');
+ }
+ append(result, createByteArray(i->first));
+ result.push_back('=');
+ if (isQuoted(i->first)) {
+ append(result, createByteArray("\""));
+ append(result, i->second);
+ append(result, createByteArray("\""));
+ }
+ else {
+ append(result, i->second);
+ }
+ }
+ return result;
}
boost::optional<std::string> DIGESTMD5Properties::getValue(const std::string& key) const {
- DIGESTMD5PropertiesMap::const_iterator i = properties.find(key);
- if (i != properties.end()) {
- return byteArrayToString(i->second);
- }
- else {
- return boost::optional<std::string>();
- }
+ DIGESTMD5PropertiesMap::const_iterator i = properties.find(key);
+ if (i != properties.end()) {
+ return byteArrayToString(i->second);
+ }
+ else {
+ return boost::optional<std::string>();
+ }
}
void DIGESTMD5Properties::setValue(const std::string& key, const std::string& value) {
- properties.insert(DIGESTMD5PropertiesMap::value_type(key, createByteArray(value)));
+ properties.insert(DIGESTMD5PropertiesMap::value_type(key, createByteArray(value)));
}
bool DIGESTMD5Properties::isQuoted(const std::string& p) {
- return p == "authzid" || p == "cnonce" || p == "digest-uri" || p == "nonce" || p == "realm" || p == "username";
+ return p == "authzid" || p == "cnonce" || p == "digest-uri" || p == "nonce" || p == "realm" || p == "username";
}
}