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/Utils.h" | 9 #include "../shared/Utils.h" |
9 #include "../shared/Version.h" | 10 #include "../shared/Version.h" |
10 #include "Debug.h" | 11 #include "Debug.h" |
11 #include "Updater.h" | 12 #include "Updater.h" |
12 | 13 |
13 namespace | 14 namespace |
14 { | 15 { |
15 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; | 16 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; |
16 | 17 |
17 void WriteStrings(Communication::OutputBuffer& response, | 18 void WriteStrings(Communication::OutputBuffer& response, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 { | 192 { |
192 // TODO: Attempt to create the pipe first, and exit immediately if this | 193 // TODO: Attempt to create the pipe first, and exit immediately if this |
193 // fails. Since multiple instances of the engine could be running, | 194 // fails. Since multiple instances of the engine could be running, |
194 // this may need named mutices to avoid race conditions. | 195 // this may need named mutices to avoid race conditions. |
195 // Note that as soon as the pipe is created first, we can reduce the | 196 // Note that as soon as the pipe is created first, we can reduce the |
196 // client timeout after CreateProcess(), but should increase the one | 197 // client timeout after CreateProcess(), but should increase the one |
197 // in WaitNamedPipe(). | 198 // in WaitNamedPipe(). |
198 | 199 |
199 int argc; | 200 int argc; |
200 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); | 201 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
201 std::wstring locale(argc >= 1 ? argv[0] : L""); | 202 std::wstring locale(argc >= 2 ? argv[1] : L""); |
202 LocalFree(argv); | 203 LocalFree(argv); |
203 | 204 |
| 205 Dictionary::Create(locale); |
204 filterEngine = CreateFilterEngine(locale); | 206 filterEngine = CreateFilterEngine(locale); |
205 | 207 |
206 for (;;) | 208 for (;;) |
207 { | 209 { |
208 try | 210 try |
209 { | 211 { |
210 Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeNam
e, | 212 Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeNam
e, |
211 Communication::Pipe::MODE_CREATE); | 213 Communication::Pipe::MODE_CREATE); |
212 | 214 |
213 // TODO: Count established connections, kill the engine when none are left | 215 // TODO: Count established connections, kill the engine when none are left |
214 AutoHandle thread(CreateThread(0, 0, ClientThread, static_cast<LPVOID>(pip
e), 0, 0)); | 216 AutoHandle thread(CreateThread(0, 0, ClientThread, static_cast<LPVOID>(pip
e), 0, 0)); |
215 if (!thread) | 217 if (!thread) |
216 { | 218 { |
217 delete pipe; | 219 delete pipe; |
218 DebugLastError("CreateThread failed"); | 220 DebugLastError("CreateThread failed"); |
219 return 1; | 221 return 1; |
220 } | 222 } |
221 } | 223 } |
222 catch (std::runtime_error e) | 224 catch (std::runtime_error e) |
223 { | 225 { |
224 DebugException(e); | 226 DebugException(e); |
225 return 1; | 227 return 1; |
226 } | 228 } |
227 } | 229 } |
228 | 230 |
229 return 0; | 231 return 0; |
230 } | 232 } |
OLD | NEW |