| OLD | NEW |
| 1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
| 2 #include <functional> | 2 #include <functional> |
| 3 #include <vector> | 3 #include <vector> |
| 4 #include <Windows.h> | 4 #include <Windows.h> |
| 5 | 5 |
| 6 #include "../shared/AutoHandle.h" | 6 #include "../shared/AutoHandle.h" |
| 7 #include "../shared/Communication.h" | 7 #include "../shared/Communication.h" |
| 8 #include "../shared/Dictionary.h" | 8 #include "../shared/Dictionary.h" |
| 9 #include "../shared/Utils.h" | 9 #include "../shared/Utils.h" |
| 10 #include "../shared/Version.h" | 10 #include "../shared/Version.h" |
| 11 #include "../shared/CriticalSection.h" | 11 #include "../shared/CriticalSection.h" |
| 12 #include "Debug.h" | 12 #include "Debug.h" |
| 13 #include "Updater.h" | 13 #include "Updater.h" |
| 14 | 14 |
| 15 namespace | 15 namespace |
| 16 { | 16 { |
| 17 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; | 17 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; |
| 18 std::auto_ptr<Updater> updater; | 18 std::auto_ptr<Updater> updater; |
| 19 int activeConnections = 0; | 19 int activeConnections = 0; |
| 20 CriticalSection activeConnectionsLock; | 20 CriticalSection activeConnectionsLock; |
| 21 | 21 |
| 22 void WriteStrings(Communication::OutputBuffer& response, | 22 void WriteStrings(Communication::OutputBuffer& response, |
| 23 const std::vector<std::string>& strings) | 23 const std::vector<std::string>& strings) |
| 24 { | 24 { |
| 25 int32_t count = strings.size(); | 25 int32_t count = static_cast<int32_t>(strings.size()); |
| 26 response << count; | 26 response << count; |
| 27 for (int32_t i = 0; i < count; i++) | 27 for (int32_t i = 0; i < count; i++) |
| 28 response << strings[i]; | 28 response << strings[i]; |
| 29 } | 29 } |
| 30 | 30 |
| 31 void WriteSubscriptions(Communication::OutputBuffer& response, | 31 void WriteSubscriptions(Communication::OutputBuffer& response, |
| 32 const std::vector<AdblockPlus::SubscriptionPtr>& subscriptions) | 32 const std::vector<AdblockPlus::SubscriptionPtr>& subscriptions) |
| 33 { | 33 { |
| 34 int32_t count = subscriptions.size(); | 34 int32_t count = static_cast<int32_t>(subscriptions.size()); |
| 35 response << count; | 35 response << count; |
| 36 for (int32_t i = 0; i < count; i++) | 36 for (int32_t i = 0; i < count; i++) |
| 37 { | 37 { |
| 38 AdblockPlus::SubscriptionPtr subscription = subscriptions[i]; | 38 AdblockPlus::SubscriptionPtr subscription = subscriptions[i]; |
| 39 response << subscription->GetProperty("url")->AsString() | 39 response << subscription->GetProperty("url")->AsString() |
| 40 << subscription->GetProperty("title")->AsString() | 40 << subscription->GetProperty("title")->AsString() |
| 41 << subscription->GetProperty("specialization")->AsString() | 41 << subscription->GetProperty("specialization")->AsString() |
| 42 << subscription->IsListed(); | 42 << subscription->IsListed(); |
| 43 } | 43 } |
| 44 } | 44 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 for (size_t i = 0, count = filters.size(); i < count; i++) | 129 for (size_t i = 0, count = filters.size(); i < count; i++) |
| 130 { | 130 { |
| 131 AdblockPlus::FilterPtr filter = filters[i]; | 131 AdblockPlus::FilterPtr filter = filters[i]; |
| 132 if (filter->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION) | 132 if (filter->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION) |
| 133 { | 133 { |
| 134 std::string text = filter->GetProperty("text")->AsString(); | 134 std::string text = filter->GetProperty("text")->AsString(); |
| 135 | 135 |
| 136 //@@||example.com^$document | 136 //@@||example.com^$document |
| 137 const char prefix[] = "@@||"; | 137 const char prefix[] = "@@||"; |
| 138 const char suffix[] = "^$document"; | 138 const char suffix[] = "^$document"; |
| 139 const int prefixLen = strlen(prefix); | 139 const size_t prefixLen = strlen(prefix); |
| 140 const int suffixLen = strlen(suffix); | 140 const size_t suffixLen = strlen(suffix); |
| 141 if (!text.compare(0, prefixLen, prefix) && | 141 if (!text.compare(0, prefixLen, prefix) && |
| 142 !text.compare(text.size() - suffixLen, suffixLen, suffix)) | 142 !text.compare(text.size() - suffixLen, suffixLen, suffix)) |
| 143 { | 143 { |
| 144 domains.push_back(text.substr(prefixLen, text.size() - prefixLen -
suffixLen)); | 144 domains.push_back(text.substr(prefixLen, text.size() - prefixLen -
suffixLen)); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 WriteStrings(response, domains); | 149 WriteStrings(response, domains); |
| 150 break; | 150 break; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 401 } |
| 402 catch (std::runtime_error e) | 402 catch (std::runtime_error e) |
| 403 { | 403 { |
| 404 DebugException(e); | 404 DebugException(e); |
| 405 return 1; | 405 return 1; |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 | 408 |
| 409 return 0; | 409 return 0; |
| 410 } | 410 } |
| OLD | NEW |