tree checksum vpatch file split hunks

all signers: mod6

antecedents: bitcoin-asciilifeform.3-turdmeister-alert-snip bitcoin-asciilifeform.1 rm_rf_upnp genesis bitcoin-asciilifeform.2-https_snipsnip

press order:

genesismod6
bitcoin-asciilifeform.1mod6
rm_rf_upnpmod6
bitcoin-asciilifeform.3-turdmeister-alert-snipmod6
bitcoin-asciilifeform.2-https_snipsnipmod6
bitcoin-asciilifeform.4-goodbye-win32mod6

patch:

- B860454AF0CEA61DA456CCCD4FE4B7152D0E4DF57F974259E7B1153AB0B1954BA526CEF89CFB85676CDD3E7D212C09576437E431EC9D71409D5C37C839FD4837
+ D064C6C28BA9016A427FE89F42E8C46CAF45755B9289A4B485DC05D35CCD02541181DA072F2C0ADA36290D23208F5F9B600417E653AC24A57020CE0F620C2C42
bitcoin/src/bitcoinrpc.cpp
(2422 . 11)(2422 . 6)
5 #ifdef TEST
6 int main(int argc, char *argv[])
7 {
8 #ifdef _MSC_VER
9 // Turn off microsoft heap dump noise
10 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
11 _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
12 #endif
13 setbuf(stdin, NULL);
14 setbuf(stdout, NULL);
15 setbuf(stderr, NULL);
- 7C19985746214E45BF75C9044C5F13230195376E74B6C013659CFBE89390FD575E7BB1935F82F0D42F01B93F58EE980AF16BD99101E4241EABD585B6FEC09B0F
+ 9AD9A4BD21D57594A27623378AE8969F00504822DA8D2EF89821F0790494D80726C3B39DED57DAE9ED17AD257F0C1A38CB7D69F513D0D403F34CCB914757605C
bitcoin/src/crypter.cpp
(7 . 9)(7 . 6)
20 #include <vector>
21 #include <string>
22 #include "headers.h"
23 #ifdef WIN32
24 #include <windows.h>
25 #endif
26
27 #include "crypter.h"
28 #include "main.h"
- D6224A6FE15BD7712174FD0D420D8B289204712D5CBDE94AEF0CC6EF96EC2FE60AABE4CD71360D32A2464E87C6BFAFF59D0464FDE880302BB8180DEA4371CE57
+ 0E9401061876B3C91016108AB88A45AA8DC5F57F1B6E0487A62E540A78C52D11062DE7C2D23E4A6545DD19992375199A243D099DB730C58DD11F9F27D707872B
bitcoin/src/db.cpp
(768 . 11)(768 . 9)
33 bool fIsEncrypted = false;
34
35 // Modify defaults
36 #ifndef WIN32
37 // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program
38 fMinimizeToTray = false;
39 fMinimizeOnClose = false;
40 #endif
41
42 //// todo: shouldn't we catch exceptions and try to recover and continue?
43 CRITICAL_BLOCK(pwallet->cs_wallet)
- DF1306462A92466A6661E4E98B4091FE0DE3FF53C781A8DC5FD6C575F052CA4ADC47E5E1A37B6904CCFEB107BF7899335DD5BBB4428E647DA6ACFFFD2E0CA6C6
+ AAE9B590747C266D9BACDC30A73F2D3ED9C7A5CC4FF42798D4F7DF3E7A28AF0BC8D70C4402FCC36779E77DDD3F4BCC41C1EEF08336207999EFBAC352817C1972
bitcoin/src/headers.h
(3 . 22)(3 . 6)
48 // Distributed under the MIT/X11 software license, see the accompanying
49 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
50
51 #ifdef _MSC_VER
52 #pragma warning(disable:4786)
53 #pragma warning(disable:4804)
54 #pragma warning(disable:4805)
55 #pragma warning(disable:4717)
56 #endif
57 #ifdef _WIN32_WINNT
58 #undef _WIN32_WINNT
59 #endif
60 #define _WIN32_WINNT 0x0500
61 #ifdef _WIN32_IE
62 #undef _WIN32_IE
63 #endif
64 #define _WIN32_IE 0x0400
65 #define WIN32_LEAN_AND_MEAN 1
66
67 // Include boost/foreach here as it defines __STDC_LIMIT_MACROS on some systems.
68 #include <boost/foreach.hpp>
69 #ifndef __STDC_LIMIT_MACROS
(55 . 16)(39 . 6)
71 #include <deque>
72 #include <map>
73
74 #ifdef WIN32
75 #include <windows.h>
76 #include <winsock2.h>
77 #include <mswsock.h>
78 #include <shlobj.h>
79 #include <shlwapi.h>
80 #include <io.h>
81 #include <process.h>
82 #include <malloc.h>
83 #else
84 #include <sys/time.h>
85 #include <sys/resource.h>
86 #include <sys/socket.h>
(77 . 7)(51 . 7)
88 #include <ifaddrs.h>
89 #include <fcntl.h>
90 #include <signal.h>
91 #endif
92
93 #ifdef BSD
94 #include <netinet/in.h>
95 #endif
- 352283739438E0D213F66B3D94A728ECF280ACE2280615A2C700E5D94BF32BBD3518F512FAB55F7071FF5E8F02EC988CC1BE71EC15597AF3C3933D7CB833EFC4
+ 5580D0FA04B103FDDFF3B029385134345CE8F1968688E4D69FC4BD0EF13F87BE7A380476829FB761B82AD0069D003948B5FCFF7470941AB8298DF82E93C9B80A
bitcoin/src/init.cpp
(25 . 10)(25 . 6)
100
101 void ExitTimeout(void* parg)
102 {
103 #ifdef WIN32
104 Sleep(5000);
105 ExitProcess(0);
106 #endif
107 }
108
109 void Shutdown(void* parg)
(113 . 19)(109 . 8)
111
112 bool AppInit2(int argc, char* argv[])
113 {
114 #ifdef _MSC_VER
115 // Turn off microsoft heap dump noise
116 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
117 _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
118 #endif
119 #if _MSC_VER >= 1400
120 // Disable confusing "helpful" text message on abort, ctrl-c
121 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
122 #endif
123 #ifndef WIN32
124 umask(077);
125 #endif
126 #ifndef WIN32
127
128 // Clean shutdown on SIGTERM
129 struct sigaction sa;
130 sa.sa_handler = HandleSIGTERM;
(134 . 7)(119 . 6)
132 sigaction(SIGTERM, &sa, NULL);
133 sigaction(SIGINT, &sa, NULL);
134 sigaction(SIGHUP, &sa, NULL);
135 #endif
136
137 //
138 // Parameters
(189 . 16)(173 . 11)
140 " -maxreceivebuffer=<n>\t " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)\n") +
141 " -maxsendbuffer=<n>\t " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 10000)\n") +
142 " -paytxfee=<amt> \t " + _("Fee per kB to add to transactions you send\n") +
143 #if !defined(WIN32)
144 " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +
145 #endif
146 " -testnet \t\t " + _("Use the test network\n") +
147 " -debug \t\t " + _("Output extra debugging information\n") +
148 " -logtimestamps \t " + _("Prepend debug output with timestamp\n") +
149 " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") +
150 #ifdef WIN32
151 " -printtodebugger \t " + _("Send trace/debug info to debugger\n") +
152 #endif
153 " -rpcuser=<user> \t " + _("Username for JSON-RPC connections\n") +
154 " -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections\n") +
155 " -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port> (default: 8332)\n") +
(218 . 12)(197 . 7)
157
158 fTestNet = GetBoolArg("-testnet");
159 fDebug = GetBoolArg("-debug");
160
161 #if !defined(WIN32)
162 fDaemon = GetBoolArg("-daemon");
163 #else
164 fDaemon = false;
165 #endif
166
167 if (fDaemon)
168 fServer = true;
(246 . 7)(220 . 6)
170 exit(ret);
171 }
172
173 #if !defined(WIN32)
174 if (fDaemon)
175 {
176 // Daemonize
(266 . 7)(239 . 6)
178 if (sid < 0)
179 fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
180 }
181 #endif
182
183 if (!fDebug && !pszSetDataDir[0])
184 ShrinkDebugFile();
- 265F35217E2A79155AA98DC832A62F1A24879F70AA594237811392D5F14EC182DE78CABACCF7F9D0AF07504FF4E37F39EA4C4C6DAC7D6D1B8890258AB40C2D33
+ 66AF7BED57921718A5E073DB591E4DC838622DF4AF4E5662A0B2F46F20EE60C98FEC6D967BDB71A4C1CF82E3DC9F2F6E0AEDDAEF9C7246B7797E6B4DB5F1080D
bitcoin/src/main.h
(923 . 11)(923 . 7)
189 fflush(fileout);
190 if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0)
191 {
192 #ifdef WIN32
193 _commit(_fileno(fileout));
194 #else
195 fsync(fileno(fileout));
196 #endif
197 }
198
199 return true;
- 83D546A9C99D9A33CF806B19617DFB36DBE2D51912B3D8B14AA2DF4EF64B9F281820D99F2C9CB822C21BAF8392389AA1FD543478037AEB734300651F0C9D5392
+
bitcoin/src/makefile.linux-mingw
(1 . 95)(0 . 0)
204 # Copyright (c) 2009-2010 Satoshi Nakamoto
205 # Distributed under the MIT/X11 software license, see the accompanying
206 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
207
208 DEPSDIR:=/usr/i586-mingw32msvc
209
210 INCLUDEPATHS= \
211 -I"$(DEPSDIR)/boost_1_47_0" \
212 -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
213 -I"$(DEPSDIR)/openssl-1.0.0e/include" \
214 -I"$(DEPSDIR)"
215
216 LIBPATHS= \
217 -L"$(DEPSDIR)/boost_1_47_0/stage/lib" \
218 -L"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
219 -L"$(DEPSDIR)/openssl-1.0.0e"
220
221 LIBS= \
222 -l boost_system-mt-s \
223 -l boost_filesystem-mt-s \
224 -l boost_program_options-mt-s \
225 -l boost_thread_win32-mt-s \
226 -l db_cxx \
227 -l ssl \
228 -l crypto
229
230 DEFS=-D_MT -DWIN32 -D_WINDOWS -DNOPCH -DBOOST_THREAD_USE_LIB
231 DEBUGFLAGS=-g
232 CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
233 HEADERS = \
234 base58.h \
235 bignum.h \
236 checkpoints.h \
237 crypter.h \
238 db.h \
239 headers.h \
240 init.h \
241 irc.h \
242 key.h \
243 keystore.h \
244 main.h \
245 net.h \
246 noui.h \
247 protocol.h \
248 bitcoinrpc.h \
249 script.h \
250 serialize.h \
251 strlcpy.h \
252 uint256.h \
253 util.h \
254 wallet.h
255
256
257
258 LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi
259
260 OBJS= \
261 obj/checkpoints.o \
262 obj/crypter.o \
263 obj/db.o \
264 obj/init.o \
265 obj/irc.o \
266 obj/keystore.o \
267 obj/main.o \
268 obj/net.o \
269 obj/protocol.o \
270 obj/bitcoinrpc.o \
271 obj/script.o \
272 obj/util.o \
273 obj/wallet.o
274
275 all: bitcoind.exe
276
277 obj/nogui/%.o: %.cpp $(HEADERS)
278 i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
279
280 bitcoind.exe: $(OBJS:obj/%=obj/nogui/%)
281 i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
282
283
284 obj/test/%.o: obj/test/%.cpp $(HEADERS)
285 i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
286
287 test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
288 i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s
289
290
291 clean:
292 -rm -f obj/*.o
293 -rm -f obj/nogui/*.o
294 -rm -f obj/test/*.o
295 -rm -f test/*.o
296 -rm -f headers.h.gch
297 -rm -f bitcoind.exe
298 -rm -f test_bitcoin.exe
- A1B78A422161C6F5F3CA51A585D8C3F68E9490AF3F1BA48B7772CBE4D5A9711619707984376F9A51487AEC676F437FBF6DF38309D535DACCB966873F9608E9F1
+ 397FA4CAF80112EF2A0EF2905AB0AF4DF49E437B926E5DDE97167D888423A21E5B34F42361296BC065D31F49A8BDA21AEDFC6365684BC9CADD873598803B912C
bitcoin/src/net.cpp
(10 . 10)(10 . 6)
303 #include "init.h"
304 #include "strlcpy.h"
305
306 #ifdef WIN32
307 #include <string.h>
308 #endif
309
310
311 using namespace std;
312 using namespace boost;
(94 . 13)(90 . 9)
314 bool fProxy = (fUseProxy && addrConnect.IsRoutable());
315 struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr());
316
317 #ifdef WIN32
318 u_long fNonblock = 1;
319 if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
320 #else
321 int fFlags = fcntl(hSocket, F_GETFL, 0);
322 if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == -1)
323 #endif
324
325 {
326 closesocket(hSocket);
327 return false;
(133 . 11)(125 . 7)
329 return false;
330 }
331 socklen_t nRetSize = sizeof(nRet);
332 #ifdef WIN32
333 if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR)
334 #else
335 if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
336 #endif
337 {
338 printf("getsockopt() for connection failed: %i\n",WSAGetLastError());
339 closesocket(hSocket);
(150 . 11)(138 . 7)
341 return false;
342 }
343 }
344 #ifdef WIN32
345 else if (WSAGetLastError() != WSAEISCONN)
346 #else
347 else
348 #endif
349 {
350 printf("connect() failed: %i\n",WSAGetLastError());
351 closesocket(hSocket);
(167 . 13)(151 . 8)
353 CNode::ConnectNode immediately turns the socket back to non-blocking
354 but we'll turn it back to blocking just in case
355 */
356 #ifdef WIN32
357 fNonblock = 0;
358 if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
359 #else
360 fFlags = fcntl(hSocket, F_GETFL, 0);
361 if (fcntl(hSocket, F_SETFL, fFlags & !O_NONBLOCK) == SOCKET_ERROR)
362 #endif
363 {
364 closesocket(hSocket);
365 return false;
(670 . 14)(649 . 8)
367 printf("connected %s\n", addrConnect.ToString().c_str());
368
369 // Set to nonblocking
370 #ifdef WIN32
371 u_long nOne = 1;
372 if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR)
373 printf("ConnectSocket() : ioctlsocket nonblocking setting failed, error %d\n", WSAGetLastError());
374 #else
375 if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
376 printf("ConnectSocket() : fcntl nonblocking setting failed, error %d\n", errno);
377 #endif
378
379 // Add node
380 CNode* pnode = new CNode(hSocket, addrConnect, false);
(1564 . 18)(1537 . 6)
382 int nOne = 1;
383 addrLocalHost.port = htons(GetListenPort());
384
385 #ifdef WIN32
386 // Initialize Windows Sockets
387 WSADATA wsadata;
388 int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
389 if (ret != NO_ERROR)
390 {
391 strError = strprintf("Error: TCP/IP socket library failed to start (WSAStartup returned error %d)", ret);
392 printf("%s\n", strError.c_str());
393 return false;
394 }
395 #endif
396
397 // Create socket for listening for incoming connections
398 hListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
399 if (hListenSocket == INVALID_SOCKET)
(1590 . 18)(1551 . 11)
401 setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
402 #endif
403
404 #ifndef WIN32
405 // Allow binding if the port is still in TIME_WAIT state after
406 // the program was closed and restarted. Not an issue on windows.
407 setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
408 #endif
409
410 #ifdef WIN32
411 // Set to nonblocking, incoming connections will also inherit this
412 if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR)
413 #else
414 if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
415 #endif
416 {
417 strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError());
418 printf("%s\n", strError.c_str());
(1643 . 21)(1597 . 6)
420 if (pnodeLocalHost == NULL)
421 pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", 0, false, nLocalServices));
422
423 #ifdef WIN32
424 // Get local host ip
425 char pszHostName[1000] = "";
426 if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
427 {
428 vector<CAddress> vaddr;
429 if (Lookup(pszHostName, vaddr, nLocalServices, -1, true))
430 BOOST_FOREACH (const CAddress &addr, vaddr)
431 if (addr.GetByte(3) != 127)
432 {
433 addrLocalHost = addr;
434 break;
435 }
436 }
437 #else
438 // Get local host ip
439 struct ifaddrs* myaddrs;
440 if (getifaddrs(&myaddrs) == 0)
(1692 . 7)(1631 . 7)
442 }
443 freeifaddrs(myaddrs);
444 }
445 #endif
446
447 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
448
449 if (fUseProxy || mapArgs.count("-connect") || fNoListen)
(1778 . 10)(1717 . 6)
451 if (closesocket(hListenSocket) == SOCKET_ERROR)
452 printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
453
454 #ifdef WIN32
455 // Shutdown Windows Sockets
456 WSACleanup();
457 #endif
458 }
459 }
460 instance_of_cnetcleanup;
- 82905169CADF6FB364C8C5073F4B80450A9A995219840FFB1E46F756F35BB9649677C75044D55A017B92C27E32CE5DAC52CDA187A18C3B544756882FF6A57B50
+ 0B8486F417CA786ACCC0335C0381A2FD80393E842F79A9926C556F81D6B09E41615DE890477DADAD86816F672A07B1DF2A495D0B95C85A3BF2FD8A8AA67B2863
bitcoin/src/net.h
(10 . 10)(10 . 6)
465 #include <boost/foreach.hpp>
466 #include <openssl/rand.h>
467
468 #ifndef WIN32
469 #include <arpa/inet.h>
470 #endif
471
472 #include "protocol.h"
473
474 class CAddrDB;
- E76EC1350E05C0FEF1798A50903586ACE4737FAA6DB134094A88A23A96E2A54D8E135A840B822EF136D336B035B3B03B7DED83A99267C892663B15D11AD00720
+ E5274FE2FF8AA6840CE5BE2E7797766DC4A70A19C2E08954BBFD9CFFF4AD9E27614606079A4CE7FC5AE150DFAF2906BEE118B543D889710DA78475BD12F24C56
bitcoin/src/protocol.cpp
(5 . 10)(5 . 8)
479
480 #include "protocol.h"
481 #include "util.h"
482 #include <arpa/inet.h>
483
484 #ifndef WIN32
485 # include <arpa/inet.h>
486 #endif
487
488 // Prototypes from net.h, but that header (currently) stinks, can't #include it without breaking things
489 bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
(165 . 11)(163 . 7)
491 ss.reserve(18);
492 ss << FLATDATA(pchReserved) << ip << port;
493
494 #if defined(_MSC_VER) && _MSC_VER < 1300
495 return std::vector<unsigned char>((unsigned char*)&ss.begin()[0], (unsigned char*)&ss.end()[0]);
496 #else
497 return std::vector<unsigned char>(ss.begin(), ss.end());
498 #endif
499 }
500
501 struct sockaddr_in CAddress::GetSockAddr() const
- 6D3CD409EEE6A9F7689A3CBBC8AF5207E314B39F4B16F8C82F350FFB1AFD42B8025EFFA2C1D2E6F5F511B2C0FDD87BF008206AE6809490E0DD8D06E9B3430EA4
+ 5368AB26F0F4D5E439F4C51E7C4081F20C4373B3B6EE9EE92B28335B03A5354E33DF645293B11171F483D06B76326528B4B594D59F103FC2F256B6C6E89525D4
bitcoin/src/script.h
(384 . 9)(384 . 7)
506 CScript() { }
507 CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }
508 CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { }
509 #ifndef _MSC_VER
510 CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { }
511 #endif
512
513 CScript& operator+=(const CScript& b)
514 {
- 0C9BC8280A5657728CB63DA6F822999A40C0791D9C81DAAA779181A5A1B241B1130A088B280A0A74777D27DB144978D15E43BA21BCCE68CE4D202767BD19E297
+ FA08E3A8029453DCA3E5DD6CA382EF541294CE5A7F914975B376F87C4EAE2DA55B8CA6CEA65343BA93E55F39956C4448E96B794CE39B799D65FD100E555262E7
bitcoin/src/serialize.h
(19 . 27)(19 . 9)
519 #include <boost/tuple/tuple_comparison.hpp>
520 #include <boost/tuple/tuple_io.hpp>
521
522 #if defined(_MSC_VER) || defined(__BORLANDC__)
523 typedef __int64 int64;
524 typedef unsigned __int64 uint64;
525 #else
526 typedef long long int64;
527 typedef unsigned long long uint64;
528 #endif
529 #if defined(_MSC_VER) && _MSC_VER < 1300
530 #define for if (false) ; else for
531 #endif
532
533 #ifdef WIN32
534 #include <windows.h>
535 // This is used to attempt to keep keying material out of swap
536 // Note that VirtualLock does not provide this as a guarantee on Windows,
537 // but, in practice, memory that has been VirtualLock'd almost never gets written to
538 // the pagefile except in rare circumstances where memory is extremely low.
539 #include <windows.h>
540 #define mlock(p, n) VirtualLock((p), (n));
541 #define munlock(p, n) VirtualUnlock((p), (n));
542 #else
543 #include <sys/mman.h>
544 #include <limits.h>
545 /* This comes from limits.h if it's not defined there set a sane default */
(53 . 7)(35 . 6)
547 #define munlock(a,b) \
548 munlock(((void *)(((size_t)(a)) & (~((PAGESIZE)-1)))),\
549 (((((size_t)(a)) + (b) - 1) | ((PAGESIZE) - 1)) + 1) - (((size_t)(a)) & (~((PAGESIZE) - 1))))
550 #endif
551
552 class CScript;
553 class CDataStream;
(902 . 12)(883 . 10)
555 Init(nTypeIn, nVersionIn);
556 }
557
558 #if !defined(_MSC_VER) || _MSC_VER >= 1300
559 CDataStream(const char* pbegin, const char* pend, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(pbegin, pend)
560 {
561 Init(nTypeIn, nVersionIn);
562 }
563 #endif
564
565 CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())
566 {
(993 . 7)(972 . 6)
568 vch.insert(it, first, last);
569 }
570
571 #if !defined(_MSC_VER) || _MSC_VER >= 1300
572 void insert(iterator it, const char* first, const char* last)
573 {
574 if (it == vch.begin() + nReadPos && last - first <= nReadPos)
(1005 . 7)(983 . 6)
576 else
577 vch.insert(it, first, last);
578 }
579 #endif
580
581 iterator erase(iterator it)
582 {
- 821F3AF7A2CE7BB860659E1B5833DA377C539C5E6207FFB48C042673DADA79B37002E6BD336E54C940CEE120BDB132B62966D30732E4AFEFDD46261EFF889BF8
+ E422BDFD1396BF3BE89E700E002A3E232C962582CA358ABCA81A1E689AA991F077AB81C929D5ECE265ACB834B41482551012381F63F17F0A972FE7B496CAEE04
bitcoin/src/uint256.h
(11 . 17)(11 . 8)
587 #include <string>
588 #include <vector>
589
590 #if defined(_MSC_VER) || defined(__BORLANDC__)
591 typedef __int64 int64;
592 typedef unsigned __int64 uint64;
593 #else
594 typedef long long int64;
595 typedef unsigned long long uint64;
596 #endif
597 #if defined(_MSC_VER) && _MSC_VER < 1300
598 #define for if (false) ; else for
599 #endif
600
601
602 inline int Testuint256AdHoc(std::vector<std::string> vArg);
603
- C7F92359243328F815311AD714EFD61CF038A265AAB7F69160CAF9ADD62F0A061807C1B9DA4474660C7BCB05800BA0E5265CF92E3934EADA359B7B70B42C8786
+ 73BCE315476B665825604C1CFCB777A779DE476B774B92656F4C52A49DD6B0740132F73E2348599FECFD6702A1F1629B1F5237A11F3D98B516721C350C358B16
bitcoin/src/util.cpp
(64 . 11)(64 . 6)
608 ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex();
609 CRYPTO_set_locking_callback(locking_callback);
610
611 #ifdef WIN32
612 // Seed random number generator with screen scrape and other hardware sources
613 RAND_screen();
614 #endif
615
616 // Seed random number generator with performance counter
617 RandAddSeed();
618 }
(108 . 21)(103 . 6)
620 return;
621 nLastPerfmon = GetTime();
622
623 #ifdef WIN32
624 // Don't need this on Linux, OpenSSL automatically uses /dev/urandom
625 // Seed with the entire set of perfmon data
626 unsigned char pdata[250000];
627 memset(pdata, 0, sizeof(pdata));
628 unsigned long nSize = sizeof(pdata);
629 long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);
630 RegCloseKey(HKEY_PERFORMANCE_DATA);
631 if (ret == ERROR_SUCCESS)
632 {
633 RAND_add(pdata, nSize, nSize/100.0);
634 memset(pdata, 0, nSize);
635 printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat("%x %H:%M", GetTime()).c_str(), nSize);
636 }
637 #endif
638 }
639
640 uint64 GetRand(uint64 nMax)
(198 . 48)(178 . 6)
642 }
643 }
644
645 #ifdef WIN32
646 if (fPrintToDebugger)
647 {
648 static CCriticalSection cs_OutputDebugStringF;
649
650 // accumulate a line at a time
651 CRITICAL_BLOCK(cs_OutputDebugStringF)
652 {
653 static char pszBuffer[50000];
654 static char* pend;
655 if (pend == NULL)
656 pend = pszBuffer;
657 va_list arg_ptr;
658 va_start(arg_ptr, pszFormat);
659 int limit = END(pszBuffer) - pend - 2;
660 int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr);
661 va_end(arg_ptr);
662 if (ret < 0 || ret >= limit)
663 {
664 pend = END(pszBuffer) - 2;
665 *pend++ = '\n';
666 }
667 else
668 pend += ret;
669 *pend = '\0';
670 char* p1 = pszBuffer;
671 char* p2;
672 while (p2 = strchr(p1, '\n'))
673 {
674 p2++;
675 char c = *p2;
676 *p2 = '\0';
677 OutputDebugStringA(p1);
678 *p2 = c;
679 p1 = p2;
680 }
681 if (p1 != pszBuffer)
682 memmove(pszBuffer, p1, pend - p1 + 1);
683 pend -= (p1 - pszBuffer);
684 }
685 }
686 #endif
687 return ret;
688 }
689
(457 . 11)(395 . 6)
691 pszValue = strchr(psz, '=');
692 *pszValue++ = '\0';
693 }
694 #ifdef WIN32
695 _strlwr(psz);
696 if (psz[0] == '/')
697 psz[0] = '-';
698 #endif
699 if (psz[0] != '-')
700 break;
701 mapArgs[psz] = pszValue;
(665 . 13)(598 . 7)
703
704 void FormatException(char* pszMessage, std::exception* pex, const char* pszThread)
705 {
706 #ifdef WIN32
707 char pszModule[MAX_PATH];
708 pszModule[0] = '\0';
709 GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
710 #else
711 const char* pszModule = "bitcoin";
712 #endif
713 if (pex)
714 snprintf(pszMessage, 1000,
715 "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread);
(717 . 67)(644 . 10)
717 strMiscWarning = pszMessage;
718 }
719
720
721
722
723
724
725
726
727 #ifdef WIN32
728 typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
729
730 string MyGetSpecialFolderPath(int nFolder, bool fCreate)
731 {
732 char pszPath[MAX_PATH+100] = "";
733
734 // SHGetSpecialFolderPath isn't always available on old Windows versions
735 HMODULE hShell32 = LoadLibraryA("shell32.dll");
736 if (hShell32)
737 {
738 PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =
739 (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");
740 bool fSuccess = false;
741 if (pSHGetSpecialFolderPath)
742 fSuccess =
743 (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);
744 FreeModule(hShell32);
745 if (fSuccess)
746 return pszPath;
747 }
748
749 // Backup option
750 std::string strPath;
751 {
752 const char *pszEnv;
753 if (nFolder == CSIDL_STARTUP)
754 {
755 pszEnv = getenv("USERPROFILE");
756 if (pszEnv)
757 strPath = pszEnv;
758 strPath += "\\Start Menu\\Programs\\Startup";
759 }
760 else if (nFolder == CSIDL_APPDATA)
761 {
762 pszEnv = getenv("APPDATA");
763 if (pszEnv)
764 strPath = pszEnv;
765 }
766 }
767
768 return strPath;
769 }
770 #endif
771
772 string GetDefaultDataDir()
773 {
774 // Windows: C:\Documents and Settings\username\Application Data\Bitcoin
775 // Mac: ~/Library/Application Support/Bitcoin
776 // Unix: ~/.bitcoin
777 #ifdef WIN32
778 // Windows
779 return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin";
780 #else
781 char* pszHome = getenv("HOME");
782 if (pszHome == NULL || strlen(pszHome) == 0)
783 pszHome = (char*)"/";
(793 . 7)(663 . 6)
785 // Unix
786 return strHome + ".bitcoin";
787 #endif
788 #endif
789 }
790
791 void GetDataDir(char* pszDir)
- A39EA68039E96132373815ADA8BCEBD6611278868E86CA8C302DB31CDD9CF1CDBD73961B062FCE4CAC43F99FFF9F901F07E549D4023569325908C716509856F6
+ 53346031ED18521834BDCF32E7E733544EC7A5155F8FC505706EBA497CBD76101FCA2EF8AA7BBABEE77F349B33ECD615DEDBE9A03488012435075907B0D46059
bitcoin/src/util.h
(7 . 11)(7 . 10)
796
797 #include "uint256.h"
798
799 #ifndef WIN32
800
801 #include <sys/types.h>
802 #include <sys/time.h>
803 #include <sys/resource.h>
804 #endif
805 #include <map>
806 #include <vector>
807 #include <string>
(25 . 19)(24 . 10)
809 #include <openssl/ripemd.h>
810
811
812 #if defined(_MSC_VER) || defined(__BORLANDC__)
813 typedef __int64 int64;
814 typedef unsigned __int64 uint64;
815 #else
816 typedef long long int64;
817 typedef unsigned long long uint64;
818 #endif
819 #if defined(_MSC_VER) && _MSC_VER < 1300
820 #define for if (false) ; else for
821 #endif
822 #ifndef _MSC_VER
823
824 #define __forceinline inline
825 #endif
826
827 #define loop for (;;)
828 #define BEGIN(a) ((char*)&(a))
(53 . 16)(43 . 10)
830 #define snprintf my_snprintf
831
832 #ifndef PRI64d
833 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MSVCRT__)
834 #define PRI64d "I64d"
835 #define PRI64u "I64u"
836 #define PRI64x "I64x"
837 #else
838 #define PRI64d "lld"
839 #define PRI64u "llu"
840 #define PRI64x "llx"
841 #endif
842 #endif
843
844 // This is needed because the foreach macro can't get over the comma in pair<t1, t2>
845 #define PAIRTYPE(t1, t2) std::pair<t1, t2>
(81 . 21)(65 . 6)
847 return u.ptr;
848 }
849
850 #ifdef WIN32
851 #define MSG_NOSIGNAL 0
852 #define MSG_DONTWAIT 0
853 #ifndef UINT64_MAX
854 #define UINT64_MAX _UI64_MAX
855 #define INT64_MAX _I64_MAX
856 #define INT64_MIN _I64_MIN
857 #endif
858 #ifndef S_IRUSR
859 #define S_IRUSR 0400
860 #define S_IWUSR 0200
861 #endif
862 #define unlink _unlink
863 typedef int socklen_t;
864 #else
865 #define WSAGetLastError() errno
866 #define WSAEINVAL EINVAL
867 #define WSAEALREADY EALREADY
(119 . 17)(88 . 13)
869 So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/
870 boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n));
871 }
872 #endif
873
874
875 inline int myclosesocket(SOCKET& hSocket)
876 {
877 if (hSocket == INVALID_SOCKET)
878 return WSAENOTSOCK;
879 #ifdef WIN32
880 int ret = closesocket(hSocket);
881 #else
882 int ret = close(hSocket);
883 #endif
884 hSocket = INVALID_SOCKET;
885 return ret;
886 }
(140 . 14)(105 . 6)
888 }
889
890
891
892
893
894
895
896
897
898
899 extern std::map<std::string, std::string> mapArgs;
900 extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
901 extern bool fDebug;
(193 . 9)(150 . 6)
903 std::string GetPidFile();
904 void CreatePidFile(std::string pidFile, pid_t pid);
905 void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
906 #ifdef WIN32
907 std::string MyGetSpecialFolderPath(int nFolder, bool fCreate);
908 #endif
909 std::string GetDefaultDataDir();
910 std::string GetDataDir();
911 void ShrinkDebugFile();
(323 . 20)(277 . 12)
913
914 inline int64 atoi64(const char* psz)
915 {
916 #ifdef _MSC_VER
917 return _atoi64(psz);
918 #else
919 return strtoll(psz, NULL, 10);
920 #endif
921 }
922
923 inline int64 atoi64(const std::string& str)
924 {
925 #ifdef _MSC_VER
926 return _atoi64(str.c_str());
927 #else
928 return strtoll(str.c_str(), NULL, 10);
929 #endif
930 }
931
932 inline int atoi(const std::string& str)
(411 . 13)(357 . 9)
934 inline int64 GetPerformanceCounter()
935 {
936 int64 nCounter = 0;
937 #ifdef WIN32
938 QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
939 #else
940 timeval t;
941 gettimeofday(&t, NULL);
942 nCounter = t.tv_sec * 1000000 + t.tv_usec;
943 #endif
944 return nCounter;
945 }
946
(445 . 11)(387 . 7)
948
949 inline bool IsSwitchChar(char c)
950 {
951 #ifdef WIN32
952 return c == '-' || c == '/';
953 #else
954 return c == '-';
955 #endif
956 }
957
958 inline std::string GetArg(const std::string& strArg, const std::string& strDefault)
(505 . 11)(443 . 6)
960
961 inline void heapchk()
962 {
963 #ifdef WIN32
964 /// for debugging
965 //if (_heapchk() != _HEAPOK)
966 // DebugBreak();
967 #endif
968 }
969
970 // Randomize the stack to help protect against buffer overrun exploits
(664 . 38)(597 . 6)
972
973 // Note: It turns out we might have been able to use boost::thread
974 // by using TerminateThread(boost::thread.native_handle(), 0);
975 #ifdef WIN32
976 typedef HANDLE pthread_t;
977
978 inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
979 {
980 DWORD nUnused = 0;
981 HANDLE hthread =
982 CreateThread(
983 NULL, // default security
984 0, // inherit stack size from parent
985 (LPTHREAD_START_ROUTINE)pfn, // function pointer
986 parg, // argument
987 0, // creation option, start immediately
988 &nUnused); // thread identifier
989 if (hthread == NULL)
990 {
991 printf("Error: CreateThread() returned %d\n", GetLastError());
992 return (pthread_t)0;
993 }
994 if (!fWantHandle)
995 {
996 CloseHandle(hthread);
997 return (pthread_t)-1;
998 }
999 return hthread;
1000 }
1001
1002 inline void SetThreadPriority(int nPriority)
1003 {
1004 SetThreadPriority(GetCurrentThread(), nPriority);
1005 }
1006 #else
1007 inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
1008 {
1009 pthread_t hthread = 0;
(738 . 29)(639 . 11)
1011 {
1012 pthread_exit((void*)nExitCode);
1013 }
1014 #endif
1015
1016
1017
1018
1019
1020 inline bool AffinityBugWorkaround(void(*pfn)(void*))
1021 {
1022 #ifdef WIN32
1023 // Sometimes after a few hours affinity gets stuck on one processor
1024 DWORD_PTR dwProcessAffinityMask = -1;
1025 DWORD_PTR dwSystemAffinityMask = -1;
1026 GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask);
1027 DWORD dwPrev1 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
1028 DWORD dwPrev2 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
1029 if (dwPrev2 != dwProcessAffinityMask)
1030 {
1031 printf("AffinityBugWorkaround() : SetThreadAffinityMask=%d, ProcessAffinityMask=%d, restarting thread\n", dwPrev2, dwProcessAffinityMask);
1032 if (!CreateThread(pfn, NULL))
1033 printf("Error: CreateThread() failed\n");
1034 return true;
1035 }
1036 #endif
1037 return false;
1038 }
1039