Refactor: GetRandHash() method for util
[novacoin.git] / src / util.h
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2012 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_UTIL_H
6 #define BITCOIN_UTIL_H
7
8 #include "uint256.h"
9
10 #ifndef WIN32
11 #include <sys/types.h>
12 #include <sys/time.h>
13 #include <sys/resource.h>
14 #else
15 typedef int pid_t; /* define for windows compatiblity */
16 #endif
17 #include <map>
18 #include <vector>
19 #include <string>
20
21 #include <boost/thread.hpp>
22 #include <boost/filesystem.hpp>
23 #include <boost/filesystem/path.hpp>
24 #include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
25 #include <boost/interprocess/sync/scoped_lock.hpp>
26 #include <boost/interprocess/sync/interprocess_semaphore.hpp>
27 #include <boost/interprocess/sync/lock_options.hpp>
28 #include <boost/date_time/gregorian/gregorian_types.hpp>
29 #include <boost/date_time/posix_time/posix_time_types.hpp>
30
31 #include <openssl/sha.h>
32 #include <openssl/ripemd.h>
33
34 #include "netbase.h" // for AddTimeData
35
36 typedef long long  int64;
37 typedef unsigned long long  uint64;
38
39 static const int64 COIN = 100000000;
40 static const int64 CENT = 1000000;
41
42 #define loop                for (;;)
43 #define BEGIN(a)            ((char*)&(a))
44 #define END(a)              ((char*)&((&(a))[1]))
45 #define UBEGIN(a)           ((unsigned char*)&(a))
46 #define UEND(a)             ((unsigned char*)&((&(a))[1]))
47 #define ARRAYLEN(array)     (sizeof(array)/sizeof((array)[0]))
48 #define printf              OutputDebugStringF
49
50 #ifdef snprintf
51 #undef snprintf
52 #endif
53 #define snprintf my_snprintf
54
55 #ifndef PRI64d
56 #if defined(_MSC_VER) || defined(__MSVCRT__)
57 #define PRI64d  "I64d"
58 #define PRI64u  "I64u"
59 #define PRI64x  "I64x"
60 #else
61 #define PRI64d  "lld"
62 #define PRI64u  "llu"
63 #define PRI64x  "llx"
64 #endif
65 #endif
66
67 // This is needed because the foreach macro can't get over the comma in pair<t1, t2>
68 #define PAIRTYPE(t1, t2)    std::pair<t1, t2>
69
70 // Align by increasing pointer, must have extra space at end of buffer
71 template <size_t nBytes, typename T>
72 T* alignup(T* p)
73 {
74     union
75     {
76         T* ptr;
77         size_t n;
78     } u;
79     u.ptr = p;
80     u.n = (u.n + (nBytes-1)) & ~(nBytes-1);
81     return u.ptr;
82 }
83
84 #ifdef WIN32
85 #define MSG_NOSIGNAL        0
86 #define MSG_DONTWAIT        0
87
88 #ifndef S_IRUSR
89 #define S_IRUSR             0400
90 #define S_IWUSR             0200
91 #endif
92 #define unlink              _unlink
93 #else
94 #define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
95 #define strlwr(psz)         to_lower(psz)
96 #define _strlwr(psz)        to_lower(psz)
97 #define MAX_PATH            1024
98 inline void Sleep(int64 n)
99 {
100     /*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly.
101       So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/
102     boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n));
103 }
104 #endif
105
106
107
108
109
110
111
112
113
114 extern std::map<std::string, std::string> mapArgs;
115 extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
116 extern bool fDebug;
117 extern bool fPrintToConsole;
118 extern bool fPrintToDebugger;
119 extern bool fRequestShutdown;
120 extern bool fShutdown;
121 extern bool fDaemon;
122 extern bool fServer;
123 extern bool fCommandLine;
124 extern std::string strMiscWarning;
125 extern bool fTestNet;
126 extern bool fNoListen;
127 extern bool fLogTimestamps;
128
129 void RandAddSeed();
130 void RandAddSeedPerfmon();
131 int OutputDebugStringF(const char* pszFormat, ...);
132 int my_snprintf(char* buffer, size_t limit, const char* format, ...);
133
134 /* It is not allowed to use va_start with a pass-by-reference argument.
135    (C++ standard, 18.7, paragraph 3). Use a dummy argument to work around this, and use a
136    macro to keep similar semantics.
137 */
138 std::string real_strprintf(const std::string &format, int dummy, ...);
139 #define strprintf(format, ...) real_strprintf(format, 0, __VA_ARGS__)
140
141 bool error(const char *format, ...);
142 void LogException(std::exception* pex, const char* pszThread);
143 void PrintException(std::exception* pex, const char* pszThread);
144 void PrintExceptionContinue(std::exception* pex, const char* pszThread);
145 void ParseString(const std::string& str, char c, std::vector<std::string>& v);
146 std::string FormatMoney(int64 n, bool fPlus=false);
147 bool ParseMoney(const std::string& str, int64& nRet);
148 bool ParseMoney(const char* pszIn, int64& nRet);
149 std::vector<unsigned char> ParseHex(const char* psz);
150 std::vector<unsigned char> ParseHex(const std::string& str);
151 bool IsHex(const std::string& str);
152 std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid = NULL);
153 std::string DecodeBase64(const std::string& str);
154 std::string EncodeBase64(const unsigned char* pch, size_t len);
155 std::string EncodeBase64(const std::string& str);
156 void ParseParameters(int argc, const char*const argv[]);
157 bool WildcardMatch(const char* psz, const char* mask);
158 bool WildcardMatch(const std::string& str, const std::string& mask);
159 int GetFilesize(FILE* file);
160 boost::filesystem::path GetDefaultDataDir();
161 const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
162 boost::filesystem::path GetConfigFile();
163 boost::filesystem::path GetPidFile();
164 void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
165 void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
166 bool GetStartOnSystemStartup();
167 bool SetStartOnSystemStartup(bool fAutoStart);
168 void ShrinkDebugFile();
169 int GetRandInt(int nMax);
170 uint64 GetRand(uint64 nMax);
171 uint256 GetRandHash();
172 int64 GetTime();
173 void SetMockTime(int64 nMockTimeIn);
174 int64 GetAdjustedTime();
175 std::string FormatFullVersion();
176 std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
177 void AddTimeData(const CNetAddr& ip, int64 nTime);
178
179
180
181
182
183
184
185
186
187
188
189 /** Wrapped boost mutex: supports recursive locking, but no waiting  */
190 typedef boost::interprocess::interprocess_recursive_mutex CCriticalSection;
191
192 /** Wrapped boost mutex: supports waiting but not recursive locking */
193 typedef boost::interprocess::interprocess_mutex CWaitableCriticalSection;
194
195 #ifdef DEBUG_LOCKORDER
196 void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false);
197 void LeaveCritical();
198 #else
199 void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {}
200 void static inline LeaveCritical() {}
201 #endif
202
203 /** Wrapper around boost::interprocess::scoped_lock */
204 template<typename Mutex>
205 class CMutexLock
206 {
207 private:
208     boost::interprocess::scoped_lock<Mutex> lock;
209 public:
210
211     void Enter(const char* pszName, const char* pszFile, int nLine)
212     {
213         if (!lock.owns())
214         {
215             EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()));
216 #ifdef DEBUG_LOCKCONTENTION
217             if (!lock.try_lock())
218             {
219                 printf("LOCKCONTENTION: %s\n", pszName);
220                 printf("Locker: %s:%d\n", pszFile, nLine);
221             }
222 #endif
223             lock.lock();
224         }
225     }
226
227     void Leave()
228     {
229         if (lock.owns())
230         {
231             lock.unlock();
232             LeaveCritical();
233         }
234     }
235
236     bool TryEnter(const char* pszName, const char* pszFile, int nLine)
237     {
238         if (!lock.owns())
239         {
240             EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()), true);
241             lock.try_lock();
242             if (!lock.owns())
243                 LeaveCritical();
244         }
245         return lock.owns();
246     }
247
248     CMutexLock(Mutex& mutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) : lock(mutexIn, boost::interprocess::defer_lock)
249     {
250         if (fTry)
251             TryEnter(pszName, pszFile, nLine);
252         else
253             Enter(pszName, pszFile, nLine);
254     }
255
256     ~CMutexLock()
257     {
258         if (lock.owns())
259             LeaveCritical();
260     }
261
262     operator bool()
263     {
264         return lock.owns();
265     }
266
267     boost::interprocess::scoped_lock<Mutex> &GetLock()
268     {
269         return lock;
270     }
271 };
272
273 typedef CMutexLock<CCriticalSection> CCriticalBlock;
274
275 #define LOCK(cs) CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__)
276 #define LOCK2(cs1,cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__),criticalblock2(cs2, #cs2, __FILE__, __LINE__)
277 #define TRY_LOCK(cs,name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true)
278
279 #define ENTER_CRITICAL_SECTION(cs) \
280     { \
281         EnterCritical(#cs, __FILE__, __LINE__, (void*)(&cs)); \
282         (cs).lock(); \
283     }
284
285 #define LEAVE_CRITICAL_SECTION(cs) \
286     { \
287         (cs).unlock(); \
288         LeaveCritical(); \
289     }
290
291 #ifdef MAC_OSX
292 // boost::interprocess::interprocess_semaphore seems to spinlock on OSX; prefer polling instead
293 class CSemaphore
294 {
295 private:
296     CCriticalSection cs;
297     int val;
298
299 public:
300     CSemaphore(int init) : val(init) {}
301
302     void wait() {
303         do {
304             {
305                 LOCK(cs);
306                 if (val>0) {
307                     val--;
308                     return;
309                 }
310             }
311             Sleep(100);
312         } while(1);
313     }
314
315     bool try_wait() {
316         LOCK(cs);
317         if (val>0) {
318             val--;
319             return true;
320         }
321         return false;
322     }
323
324     void post() {
325         LOCK(cs);
326         val++;
327     }
328 };
329 #else
330 typedef boost::interprocess::interprocess_semaphore CSemaphore;
331 #endif
332
333 inline std::string i64tostr(int64 n)
334 {
335     return strprintf("%"PRI64d, n);
336 }
337
338 inline std::string itostr(int n)
339 {
340     return strprintf("%d", n);
341 }
342
343 inline int64 atoi64(const char* psz)
344 {
345 #ifdef _MSC_VER
346     return _atoi64(psz);
347 #else
348     return strtoll(psz, NULL, 10);
349 #endif
350 }
351
352 inline int64 atoi64(const std::string& str)
353 {
354 #ifdef _MSC_VER
355     return _atoi64(str.c_str());
356 #else
357     return strtoll(str.c_str(), NULL, 10);
358 #endif
359 }
360
361 inline int atoi(const std::string& str)
362 {
363     return atoi(str.c_str());
364 }
365
366 inline int roundint(double d)
367 {
368     return (int)(d > 0 ? d + 0.5 : d - 0.5);
369 }
370
371 inline int64 roundint64(double d)
372 {
373     return (int64)(d > 0 ? d + 0.5 : d - 0.5);
374 }
375
376 inline int64 abs64(int64 n)
377 {
378     return (n >= 0 ? n : -n);
379 }
380
381 template<typename T>
382 std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
383 {
384     std::vector<char> rv;
385     static char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
386                                '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
387     rv.reserve((itend-itbegin)*3);
388     for(T it = itbegin; it < itend; ++it)
389     {
390         unsigned char val = (unsigned char)(*it);
391         if(fSpaces && it != itbegin)
392             rv.push_back(' ');
393         rv.push_back(hexmap[val>>4]);
394         rv.push_back(hexmap[val&15]);
395     }
396
397     return std::string(rv.begin(), rv.end());
398 }
399
400 inline std::string HexStr(const std::vector<unsigned char>& vch, bool fSpaces=false)
401 {
402     return HexStr(vch.begin(), vch.end(), fSpaces);
403 }
404
405 template<typename T>
406 void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSpaces=true)
407 {
408     printf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());
409 }
410
411 inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszFormat="%s", bool fSpaces=true)
412 {
413     printf(pszFormat, HexStr(vch, fSpaces).c_str());
414 }
415
416 inline int64 GetPerformanceCounter()
417 {
418     int64 nCounter = 0;
419 #ifdef WIN32
420     QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
421 #else
422     timeval t;
423     gettimeofday(&t, NULL);
424     nCounter = t.tv_sec * 1000000 + t.tv_usec;
425 #endif
426     return nCounter;
427 }
428
429 inline int64 GetTimeMillis()
430 {
431     return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -
432             boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
433 }
434
435 inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime)
436 {
437     time_t n = nTime;
438     struct tm* ptmTime = gmtime(&n);
439     char pszTime[200];
440     strftime(pszTime, sizeof(pszTime), pszFormat, ptmTime);
441     return pszTime;
442 }
443
444 template<typename T>
445 void skipspaces(T& it)
446 {
447     while (isspace(*it))
448         ++it;
449 }
450
451 inline bool IsSwitchChar(char c)
452 {
453 #ifdef WIN32
454     return c == '-' || c == '/';
455 #else
456     return c == '-';
457 #endif
458 }
459
460 /**
461  * Return string argument or default value
462  *
463  * @param strArg Argument to get (e.g. "-foo")
464  * @param default (e.g. "1")
465  * @return command-line argument or default value
466  */
467 std::string GetArg(const std::string& strArg, const std::string& strDefault);
468
469 /**
470  * Return integer argument or default value
471  *
472  * @param strArg Argument to get (e.g. "-foo")
473  * @param default (e.g. 1)
474  * @return command-line argument (0 if invalid number) or default value
475  */
476 int64 GetArg(const std::string& strArg, int64 nDefault);
477
478 /**
479  * Return boolean argument or default value
480  *
481  * @param strArg Argument to get (e.g. "-foo")
482  * @param default (true or false)
483  * @return command-line argument or default value
484  */
485 bool GetBoolArg(const std::string& strArg, bool fDefault=false);
486
487 /**
488  * Set an argument if it doesn't already have a value
489  *
490  * @param strArg Argument to set (e.g. "-foo")
491  * @param strValue Value (e.g. "1")
492  * @return true if argument gets set, false if it already had a value
493  */
494 bool SoftSetArg(const std::string& strArg, const std::string& strValue);
495
496 /**
497  * Set a boolean argument if it doesn't already have a value
498  *
499  * @param strArg Argument to set (e.g. "-foo")
500  * @param fValue Value (e.g. false)
501  * @return true if argument gets set, false if it already had a value
502  */
503 bool SoftSetBoolArg(const std::string& strArg, bool fValue);
504
505
506
507
508
509
510
511
512
513 // Randomize the stack to help protect against buffer overrun exploits
514 #define IMPLEMENT_RANDOMIZE_STACK(ThreadFn)     \
515     {                                           \
516         static char nLoops;                     \
517         if (nLoops <= 0)                        \
518             nLoops = GetRand(20) + 1;           \
519         if (nLoops-- > 1)                       \
520         {                                       \
521             ThreadFn;                           \
522             return;                             \
523         }                                       \
524     }
525
526
527 template<typename T1>
528 inline uint256 Hash(const T1 pbegin, const T1 pend)
529 {
530     static unsigned char pblank[1];
531     uint256 hash1;
532     SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);
533     uint256 hash2;
534     SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
535     return hash2;
536 }
537
538 template<typename T1, typename T2>
539 inline uint256 Hash(const T1 p1begin, const T1 p1end,
540                     const T2 p2begin, const T2 p2end)
541 {
542     static unsigned char pblank[1];
543     uint256 hash1;
544     SHA256_CTX ctx;
545     SHA256_Init(&ctx);
546     SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
547     SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
548     SHA256_Final((unsigned char*)&hash1, &ctx);
549     uint256 hash2;
550     SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
551     return hash2;
552 }
553
554 template<typename T1, typename T2, typename T3>
555 inline uint256 Hash(const T1 p1begin, const T1 p1end,
556                     const T2 p2begin, const T2 p2end,
557                     const T3 p3begin, const T3 p3end)
558 {
559     static unsigned char pblank[1];
560     uint256 hash1;
561     SHA256_CTX ctx;
562     SHA256_Init(&ctx);
563     SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
564     SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
565     SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0]));
566     SHA256_Final((unsigned char*)&hash1, &ctx);
567     uint256 hash2;
568     SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
569     return hash2;
570 }
571
572 template<typename T>
573 uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
574 {
575     // Most of the time is spent allocating and deallocating CDataStream's
576     // buffer.  If this ever needs to be optimized further, make a CStaticStream
577     // class with its buffer on the stack.
578     CDataStream ss(nType, nVersion);
579     ss.reserve(10000);
580     ss << obj;
581     return Hash(ss.begin(), ss.end());
582 }
583
584 inline uint160 Hash160(const std::vector<unsigned char>& vch)
585 {
586     uint256 hash1;
587     SHA256(&vch[0], vch.size(), (unsigned char*)&hash1);
588     uint160 hash2;
589     RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
590     return hash2;
591 }
592
593
594 /** Median filter over a stream of values. 
595  * Returns the median of the last N numbers
596  */
597 template <typename T> class CMedianFilter
598 {
599 private:
600     std::vector<T> vValues;
601     std::vector<T> vSorted;
602     unsigned int nSize;
603 public:
604     CMedianFilter(unsigned int size, T initial_value):
605         nSize(size)
606     {
607         vValues.reserve(size);
608         vValues.push_back(initial_value);
609         vSorted = vValues;
610     }
611     
612     void input(T value)
613     {
614         if(vValues.size() == nSize)
615         {
616             vValues.erase(vValues.begin());
617         }
618         vValues.push_back(value);
619
620         vSorted.resize(vValues.size());
621         std::copy(vValues.begin(), vValues.end(), vSorted.begin());
622         std::sort(vSorted.begin(), vSorted.end());
623     }
624
625     T median() const
626     {
627         int size = vSorted.size();
628         assert(size>0);
629         if(size & 1) // Odd number of elements
630         {
631             return vSorted[size/2];
632         }
633         else // Even number of elements
634         {
635             return (vSorted[size/2-1] + vSorted[size/2]) / 2;
636         }
637     }
638
639     int size() const
640     {
641         return vValues.size();
642     }
643
644     std::vector<T> sorted () const
645     {
646         return vSorted;
647     }
648 };
649
650
651
652
653
654
655
656
657
658
659 // Note: It turns out we might have been able to use boost::thread
660 // by using TerminateThread(boost::thread.native_handle(), 0);
661 #ifdef WIN32
662 typedef HANDLE pthread_t;
663
664 inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
665 {
666     DWORD nUnused = 0;
667     HANDLE hthread =
668         CreateThread(
669             NULL,                        // default security
670             0,                           // inherit stack size from parent
671             (LPTHREAD_START_ROUTINE)pfn, // function pointer
672             parg,                        // argument
673             0,                           // creation option, start immediately
674             &nUnused);                   // thread identifier
675     if (hthread == NULL)
676     {
677         printf("Error: CreateThread() returned %d\n", GetLastError());
678         return (pthread_t)0;
679     }
680     if (!fWantHandle)
681     {
682         CloseHandle(hthread);
683         return (pthread_t)-1;
684     }
685     return hthread;
686 }
687
688 inline void SetThreadPriority(int nPriority)
689 {
690     SetThreadPriority(GetCurrentThread(), nPriority);
691 }
692 #else
693 inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
694 {
695     pthread_t hthread = 0;
696     int ret = pthread_create(&hthread, NULL, (void*(*)(void*))pfn, parg);
697     if (ret != 0)
698     {
699         printf("Error: pthread_create() returned %d\n", ret);
700         return (pthread_t)0;
701     }
702     if (!fWantHandle)
703     {
704         pthread_detach(hthread);
705         return (pthread_t)-1;
706     }
707     return hthread;
708 }
709
710 #define THREAD_PRIORITY_LOWEST          PRIO_MAX
711 #define THREAD_PRIORITY_BELOW_NORMAL    2
712 #define THREAD_PRIORITY_NORMAL          0
713 #define THREAD_PRIORITY_ABOVE_NORMAL    0
714
715 inline void SetThreadPriority(int nPriority)
716 {
717     // It's unclear if it's even possible to change thread priorities on Linux,
718     // but we really and truly need it for the generation threads.
719 #ifdef PRIO_THREAD
720     setpriority(PRIO_THREAD, 0, nPriority);
721 #else
722     setpriority(PRIO_PROCESS, 0, nPriority);
723 #endif
724 }
725
726 inline void ExitThread(size_t nExitCode)
727 {
728     pthread_exit((void*)nExitCode);
729 }
730 #endif
731
732
733
734
735
736 inline uint32_t ByteReverse(uint32_t value)
737 {
738     value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
739     return (value<<16) | (value>>16);
740 }
741
742 #endif
743