transactd 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/BUILD_UNIX-JA +174 -0
- data/BUILD_WIN-JA +256 -0
- data/CMakeLists.txt +96 -0
- data/COPYING +339 -0
- data/README +406 -0
- data/README-JA +424 -0
- data/bin/common/tdclc_32_1_0.dll +0 -0
- data/bin/common/tdclc_64_1_0.dll +0 -0
- data/build/common/check_for_link_iconv.cmake +73 -0
- data/build/common/copyifgreater.cmd +30 -0
- data/build/common/copyifgreater.js +290 -0
- data/build/common/get_boost_libs.cmake +106 -0
- data/build/common/get_ruby_path.cmake +115 -0
- data/build/common/options.cmake +127 -0
- data/build/common/smart_install.cmake +263 -0
- data/build/common/system.cmake +122 -0
- data/build/common/transactd.rc.in +52 -0
- data/build/common/transactd_cl_common.cmake +101 -0
- data/build/common/transactd_cl_output.cmake +93 -0
- data/build/common/transactd_common.cmake +237 -0
- data/build/common/transactd_required.cmake +28 -0
- data/build/swig/ruby/generate.cmake.in +35 -0
- data/build/swig/ruby/generate.cmd.in +19 -0
- data/build/swig/ruby/ruby.swg +101 -0
- data/build/swig/tdcl.i +188 -0
- data/build/tdclc/BUILDNUMBER.txt +1 -0
- data/build/tdclc/CMakeLists.txt +170 -0
- data/build/tdclc/tdclc_32.cbproj +181 -0
- data/build/tdclc/tdclc_64.cbproj +205 -0
- data/build/tdclcpp/BUILDNUMBER.txt +1 -0
- data/build/tdclcpp/CMakeLists.txt +142 -0
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
- data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
- data/build/tdclrb/BUILDNUMBER.txt +1 -0
- data/build/tdclrb/CMakeLists.txt +258 -0
- data/build/tdclrb/GEM_VERSION +3 -0
- data/build/tdclrb/bldgem/extconf.rb +123 -0
- data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
- data/build/tdclrb/gem/Makefile.win32-VS +65 -0
- data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
- data/build/tdclrb/gem/detect.rb +31 -0
- data/build/tdclrb/gem/helper.rb +113 -0
- data/build/tdclrb/gem/transactd.rb +22 -0
- data/build/tdclrb/gem_output.cmake +44 -0
- data/source/bzs/db/IBlobBuffer.h +51 -0
- data/source/bzs/db/blobBuffer.h +177 -0
- data/source/bzs/db/blobStructs.h +85 -0
- data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
- data/source/bzs/db/engine/mysql/bookmark.h +195 -0
- data/source/bzs/db/engine/mysql/database.cpp +1882 -0
- data/source/bzs/db/engine/mysql/database.h +465 -0
- data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
- data/source/bzs/db/engine/mysql/dbManager.h +143 -0
- data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
- data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
- data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
- data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
- data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
- data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
- data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
- data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
- data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
- data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
- data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
- data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
- data/source/bzs/db/protocol/tdap/client/client.h +292 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
- data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
- data/source/bzs/db/protocol/tdap/client/database.h +118 -0
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
- data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
- data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
- data/source/bzs/db/protocol/tdap/client/request.h +198 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
- data/source/bzs/db/protocol/tdap/client/table.h +221 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
- data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
- data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
- data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
- data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
- data/source/bzs/db/transactd/appBuilderImple.h +55 -0
- data/source/bzs/db/transactd/appModule.cpp +183 -0
- data/source/bzs/db/transactd/appModule.h +80 -0
- data/source/bzs/db/transactd/connManager.cpp +201 -0
- data/source/bzs/db/transactd/connManager.h +60 -0
- data/source/bzs/db/transactd/connectionRecord.h +69 -0
- data/source/bzs/db/transactd/transactd.cpp +325 -0
- data/source/bzs/env/compiler.h +135 -0
- data/source/bzs/env/crosscompile.cpp +130 -0
- data/source/bzs/env/crosscompile.h +150 -0
- data/source/bzs/env/fileopen.h +36 -0
- data/source/bzs/env/mbcswchrLinux.cpp +40 -0
- data/source/bzs/env/mbcswchrLinux.h +88 -0
- data/source/bzs/env/tstring.h +183 -0
- data/source/bzs/example/changeSchema.cpp +117 -0
- data/source/bzs/example/changeSchema_c.cpp +78 -0
- data/source/bzs/example/connection_pool_c.cpp +171 -0
- data/source/bzs/example/createDatabase.cpp +305 -0
- data/source/bzs/example/createDatabase_c.cpp +202 -0
- data/source/bzs/example/deleteRecords.cpp +87 -0
- data/source/bzs/example/deleteRecords_c.cpp +57 -0
- data/source/bzs/example/dropDatabase.cpp +59 -0
- data/source/bzs/example/dropDatabase_c.cpp +34 -0
- data/source/bzs/example/insertRecords.cpp +212 -0
- data/source/bzs/example/insertRecords_c.cpp +153 -0
- data/source/bzs/example/readRecords.cpp +141 -0
- data/source/bzs/example/readRecords_c.cpp +107 -0
- data/source/bzs/example/updateRecords.cpp +99 -0
- data/source/bzs/example/updateRecords_c.cpp +71 -0
- data/source/bzs/example/update_with_transaction.cpp +104 -0
- data/source/bzs/example/update_with_transaction_c.cpp +80 -0
- data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
- data/source/bzs/netsvc/client/tcpClient.h +489 -0
- data/source/bzs/netsvc/server/IAppModule.h +94 -0
- data/source/bzs/netsvc/server/iserver.h +65 -0
- data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
- data/source/bzs/netsvc/server/serverCpt.h +88 -0
- data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
- data/source/bzs/netsvc/server/serverPipe.h +96 -0
- data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
- data/source/bzs/netsvc/server/serverTpool.h +84 -0
- data/source/bzs/rtl/benchmark.cpp +96 -0
- data/source/bzs/rtl/benchmark.h +65 -0
- data/source/bzs/rtl/datetime.cpp +375 -0
- data/source/bzs/rtl/datetime.h +53 -0
- data/source/bzs/rtl/debuglog.cpp +106 -0
- data/source/bzs/rtl/debuglog.h +97 -0
- data/source/bzs/rtl/exception.h +116 -0
- data/source/bzs/rtl/stl_uty.cpp +35 -0
- data/source/bzs/rtl/stl_uty.h +29 -0
- data/source/bzs/rtl/stringBuffers.cpp +101 -0
- data/source/bzs/rtl/stringBuffers.h +58 -0
- data/source/bzs/rtl/strtrim.cpp +135 -0
- data/source/bzs/rtl/strtrim.h +46 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
- data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
- data/source/bzs/test/tdclrb/prepare.rb +226 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
- data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
- data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
- data/source/global/tdclatl/Database.cpp +503 -0
- data/source/global/tdclatl/Database.h +139 -0
- data/source/global/tdclatl/DbDef.cpp +242 -0
- data/source/global/tdclatl/DbDef.h +79 -0
- data/source/global/tdclatl/Field.cpp +92 -0
- data/source/global/tdclatl/Field.h +59 -0
- data/source/global/tdclatl/FieldDef.cpp +238 -0
- data/source/global/tdclatl/FieldDef.h +87 -0
- data/source/global/tdclatl/Flags.cpp +111 -0
- data/source/global/tdclatl/Flags.h +55 -0
- data/source/global/tdclatl/KeyDef.cpp +51 -0
- data/source/global/tdclatl/KeyDef.h +55 -0
- data/source/global/tdclatl/KeySegment.cpp +55 -0
- data/source/global/tdclatl/Table.cpp +600 -0
- data/source/global/tdclatl/Table.h +144 -0
- data/source/global/tdclatl/TableDef.cpp +291 -0
- data/source/global/tdclatl/TableDef.h +86 -0
- data/source/global/tdclatl/TdVersion.cpp +74 -0
- data/source/global/tdclatl/TdVersion.h +54 -0
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
- data/source/global/tdclatl/dllmain.cpp +30 -0
- data/source/global/tdclatl/dllmain.h +27 -0
- data/source/global/tdclatl/keySegment.h +57 -0
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/stdafx.cpp +2 -0
- data/source/global/tdclatl/stdafx.h +25 -0
- data/source/global/tdclatl/targetver.h +4 -0
- data/source/global/tdclatl/tdclatl.cpp +68 -0
- data/source/global/tdclatl/tdclatl.def +10 -0
- data/source/global/tdclatl/tdclatl.idl +1035 -0
- data/source/linux/charsetConvert.h +112 -0
- data/source/linux/linuxTypes.h +33 -0
- data/source/linux/tchar.h +428 -0
- data/transactd.gemspec +97 -0
- metadata +267 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
#ifndef benchmarkH
|
2
|
+
#define benchmarkH
|
3
|
+
/*=================================================================
|
4
|
+
Copyright (C) 2013 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
=================================================================*/
|
21
|
+
#include <boost/function.hpp>
|
22
|
+
#include <boost/version.hpp>
|
23
|
+
|
24
|
+
//#define BOOST_HIGH_RESOL_TIMER_ENABLE
|
25
|
+
|
26
|
+
#if BOOST_VERSION > 104801
|
27
|
+
|
28
|
+
#ifdef BOOST_HIGH_RESOL_TIMER_ENABLE
|
29
|
+
#include <boost/chrono/system_clocks.hpp>
|
30
|
+
#include <boost/chrono.hpp>
|
31
|
+
typedef boost::chrono::high_resolution_clock boost_timer;
|
32
|
+
#else
|
33
|
+
#define BOOST_CPUTIMER_ENABLE
|
34
|
+
#include <boost/timer/timer.hpp>
|
35
|
+
typedef boost::timer::cpu_timer boost_timer;
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#else
|
39
|
+
#include <boost/timer.hpp>
|
40
|
+
typedef boost::timer boost_timer;
|
41
|
+
|
42
|
+
#endif
|
43
|
+
|
44
|
+
namespace bzs
|
45
|
+
{
|
46
|
+
namespace rtl
|
47
|
+
{
|
48
|
+
// single thread only
|
49
|
+
class benchmark
|
50
|
+
{
|
51
|
+
static boost_timer t;
|
52
|
+
#ifdef BOOST_HIGH_RESOL_TIMER_ENABLE
|
53
|
+
static boost_timer::time_point m_start;
|
54
|
+
#endif
|
55
|
+
public:
|
56
|
+
static bool report(boost::function<bool()> func, const char* name);
|
57
|
+
static void report2(boost::function<void()> func, const char* name);
|
58
|
+
static void start();
|
59
|
+
static void showTimeSec(bool result, const char* name);
|
60
|
+
|
61
|
+
};
|
62
|
+
|
63
|
+
}//namespace rtl
|
64
|
+
}//namespace bzs
|
65
|
+
#endif
|
@@ -0,0 +1,375 @@
|
|
1
|
+
/*=================================================================
|
2
|
+
Copyright (C) 2000 2013 BizStation Corp All rights reserved.
|
3
|
+
|
4
|
+
This program is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU General Public License
|
6
|
+
as published by the Free Software Foundation; either version 2
|
7
|
+
of the License, or (at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
17
|
+
02111-1307, USA.
|
18
|
+
=================================================================*/
|
19
|
+
#include <bzs/env/tstring.h>
|
20
|
+
#pragma hdrstop
|
21
|
+
|
22
|
+
#include "datetime.h"
|
23
|
+
#include <string.h>
|
24
|
+
#include <stdio.h>
|
25
|
+
#include <stdlib.h>
|
26
|
+
#include <time.h>
|
27
|
+
#include <bzs/env/crosscompile.h>
|
28
|
+
#ifdef LINUX
|
29
|
+
#include <wchar.h>
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#pragma package(smart_init) // BCB package
|
33
|
+
#pragma warning(disable:4996) // VC++ unsafe function
|
34
|
+
|
35
|
+
//Ansi & Unicode
|
36
|
+
#if (defined(_WIN32) && _MSC_VER)
|
37
|
+
extern DWORD g_tlsiID_SC3;
|
38
|
+
#else
|
39
|
+
__THREAD _TCHAR __THREAD_BCB g_date[30];
|
40
|
+
#endif
|
41
|
+
|
42
|
+
inline _TCHAR* databuf()
|
43
|
+
{
|
44
|
+
#if (defined(_WIN32) && _MSC_VER)
|
45
|
+
return (_TCHAR*)TlsGetValue(g_tlsiID_SC3);
|
46
|
+
#else
|
47
|
+
return g_date;
|
48
|
+
#endif
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
namespace bzs
|
53
|
+
{
|
54
|
+
namespace rtl
|
55
|
+
{
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
int GetDate(const _TCHAR* NowDate)
|
60
|
+
{
|
61
|
+
int ret;
|
62
|
+
ret = _ttol(NowDate+8);
|
63
|
+
return ret;
|
64
|
+
}
|
65
|
+
|
66
|
+
int GetYear(const _TCHAR* NowDate, bool PrevMonth)
|
67
|
+
{
|
68
|
+
int ret;
|
69
|
+
ret = _ttol(NowDate);
|
70
|
+
if ((PrevMonth) && (GetMonth(NowDate, false) == 1))
|
71
|
+
ret--;
|
72
|
+
return ret;
|
73
|
+
}
|
74
|
+
|
75
|
+
int GetMonth(const _TCHAR* NowDate, bool PrevMonth)
|
76
|
+
{
|
77
|
+
int ret;
|
78
|
+
ret = _ttol(NowDate+5);
|
79
|
+
if (PrevMonth)
|
80
|
+
ret--;
|
81
|
+
if (ret == 0)
|
82
|
+
ret = 12;
|
83
|
+
|
84
|
+
return ret;
|
85
|
+
}
|
86
|
+
|
87
|
+
bool IsUrudosi(int Year)
|
88
|
+
{
|
89
|
+
if ((Year % 4) == 0)
|
90
|
+
{
|
91
|
+
if ((Year % 400) == 0)
|
92
|
+
return true;
|
93
|
+
else if ((Year % 100) == 0)
|
94
|
+
return false;
|
95
|
+
else
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
|
101
|
+
bool GetDatefromYearSerialDays(int year, int Days, _TCHAR* date, bool nextYearRight)
|
102
|
+
{
|
103
|
+
//The date of the day counted from the beginning of the year is returned.
|
104
|
+
//if orver the year then return false.
|
105
|
+
|
106
|
+
int mm;
|
107
|
+
int dd = Days;
|
108
|
+
for (mm=1; mm < 14;mm++)
|
109
|
+
{
|
110
|
+
switch (mm)
|
111
|
+
{
|
112
|
+
case 2:
|
113
|
+
if(IsUrudosi(year))
|
114
|
+
Days-=29;
|
115
|
+
else
|
116
|
+
Days-=28;
|
117
|
+
break;
|
118
|
+
case 4:
|
119
|
+
case 6:
|
120
|
+
case 9:
|
121
|
+
case 11:
|
122
|
+
Days-=30;break;
|
123
|
+
default:
|
124
|
+
Days-=31;
|
125
|
+
}
|
126
|
+
if (Days <= 0)
|
127
|
+
break;
|
128
|
+
dd=Days;
|
129
|
+
}
|
130
|
+
bool ret= true;
|
131
|
+
if ((dd>31)|| (mm==13))
|
132
|
+
{
|
133
|
+
if (nextYearRight)
|
134
|
+
{
|
135
|
+
year += 1;
|
136
|
+
mm = 1;
|
137
|
+
}else
|
138
|
+
{//for old program
|
139
|
+
dd = 31;
|
140
|
+
mm--;
|
141
|
+
}
|
142
|
+
ret= false;
|
143
|
+
}
|
144
|
+
_stprintf(date,_T("%04d/%02d/%02d"), year,mm,dd);
|
145
|
+
return ret;
|
146
|
+
}
|
147
|
+
|
148
|
+
//---------------------------------------------------------------------------
|
149
|
+
int JDate2NumOLD(const _TCHAR* date)
|
150
|
+
{//1900/01/01 = 2415021
|
151
|
+
int yy = GetYear(date,false);
|
152
|
+
int mm = GetMonth(date,false);
|
153
|
+
int dd = GetDate(date);
|
154
|
+
int i;
|
155
|
+
|
156
|
+
//The number of leap years
|
157
|
+
int n = 2415020;
|
158
|
+
for (i=1900; i < yy; i+= 4)
|
159
|
+
{
|
160
|
+
if(IsUrudosi(i))
|
161
|
+
n+=1;
|
162
|
+
}
|
163
|
+
n+= (yy - 1900 ) * 365;
|
164
|
+
for (i=1; i < mm ;i++)
|
165
|
+
{
|
166
|
+
switch(i)
|
167
|
+
{
|
168
|
+
case 2:
|
169
|
+
if(IsUrudosi(yy))
|
170
|
+
n+=29;
|
171
|
+
else
|
172
|
+
n+=28;
|
173
|
+
break;
|
174
|
+
case 4:
|
175
|
+
case 6:
|
176
|
+
case 9:
|
177
|
+
case 11:
|
178
|
+
n+=30;
|
179
|
+
break;
|
180
|
+
default:
|
181
|
+
n+=31;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
n+=dd;
|
185
|
+
return n;
|
186
|
+
}
|
187
|
+
#ifdef _WIN32
|
188
|
+
//---------------------------------------------------------------------------
|
189
|
+
int JDate2Num(const _NTCHAR* date)
|
190
|
+
{
|
191
|
+
#ifdef _UNICODE
|
192
|
+
wchar_t buf[20];
|
193
|
+
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, date, -1, buf, 20);
|
194
|
+
#else
|
195
|
+
char buf[20];
|
196
|
+
wtoa(buf, date, 20);
|
197
|
+
#endif
|
198
|
+
return JDate2Num(buf);
|
199
|
+
}
|
200
|
+
#endif
|
201
|
+
//---------------------------------------------------------------------------
|
202
|
+
int JDate2Num(const _TCHAR* date)
|
203
|
+
{//1980/01/01 = 2444240
|
204
|
+
int yy = GetYear(date,false);
|
205
|
+
if (yy < 1980)
|
206
|
+
return JDate2NumOLD(date);
|
207
|
+
|
208
|
+
int mm = GetMonth(date,false);
|
209
|
+
int dd = GetDate(date);
|
210
|
+
int i;
|
211
|
+
|
212
|
+
|
213
|
+
//The number of leap years
|
214
|
+
int n = 2444239;
|
215
|
+
for (i=1980; i < yy; i+= 4)
|
216
|
+
{
|
217
|
+
if(IsUrudosi(i))
|
218
|
+
n+=1;
|
219
|
+
}
|
220
|
+
n+= (yy - 1980 ) * 365;
|
221
|
+
for (i=1; i < mm ;i++)
|
222
|
+
{
|
223
|
+
switch(i)
|
224
|
+
{
|
225
|
+
case 2:
|
226
|
+
if(IsUrudosi(yy))
|
227
|
+
n+=29;
|
228
|
+
else
|
229
|
+
n+=28;
|
230
|
+
break;
|
231
|
+
case 4:
|
232
|
+
case 6:
|
233
|
+
case 9:
|
234
|
+
case 11:
|
235
|
+
n+=30;
|
236
|
+
break;
|
237
|
+
default:
|
238
|
+
n+=31;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
n+=dd;
|
242
|
+
return n;
|
243
|
+
}
|
244
|
+
//---------------------------------------------------------------------------
|
245
|
+
_TCHAR* JNum2DateOLD(int n)
|
246
|
+
{//1900/01/01 = 2415021
|
247
|
+
bool uru = false;
|
248
|
+
if (n < 2415021)
|
249
|
+
return NULL;
|
250
|
+
|
251
|
+
int yy = 1900;
|
252
|
+
n -= 2415020;
|
253
|
+
while (1)
|
254
|
+
{
|
255
|
+
if(uru)
|
256
|
+
{
|
257
|
+
if (n <= 366)
|
258
|
+
break;
|
259
|
+
}
|
260
|
+
else
|
261
|
+
{
|
262
|
+
if (n <= 365)
|
263
|
+
break;
|
264
|
+
}
|
265
|
+
if(uru)
|
266
|
+
n -= 366;
|
267
|
+
else
|
268
|
+
n -= 365;
|
269
|
+
yy++;
|
270
|
+
uru = IsUrudosi(yy);
|
271
|
+
}
|
272
|
+
GetDatefromYearSerialDays(yy, n, databuf());
|
273
|
+
return databuf();
|
274
|
+
}
|
275
|
+
|
276
|
+
//---------------------------------------------------------------------------
|
277
|
+
const _TCHAR* JNum2Date(int n)
|
278
|
+
{//1980/01/01 = 2444240
|
279
|
+
bool uru = true;
|
280
|
+
if (n < 2444240)
|
281
|
+
return JNum2DateOLD(n);
|
282
|
+
|
283
|
+
int yy = 1980;
|
284
|
+
n -= 2444239;
|
285
|
+
while (1)
|
286
|
+
{
|
287
|
+
if(uru)
|
288
|
+
{
|
289
|
+
if (n <= 366)
|
290
|
+
break;
|
291
|
+
}
|
292
|
+
else
|
293
|
+
{
|
294
|
+
if (n <= 365)
|
295
|
+
break;
|
296
|
+
}
|
297
|
+
if(uru)
|
298
|
+
n -= 366;
|
299
|
+
else
|
300
|
+
n -= 365;
|
301
|
+
yy++;
|
302
|
+
uru = IsUrudosi(yy);
|
303
|
+
}
|
304
|
+
GetDatefromYearSerialDays(yy, n, databuf());
|
305
|
+
return databuf();
|
306
|
+
}
|
307
|
+
|
308
|
+
//---------------------------------------------------------------------------
|
309
|
+
long StrToLongDate(_TCHAR* strdat)
|
310
|
+
{ //Conver string date to long. ex : 20011231
|
311
|
+
_TCHAR buf[9];
|
312
|
+
_tcsncpy(buf, strdat, 4);
|
313
|
+
_tcsncpy(buf + 4,strdat + 5, 2);
|
314
|
+
_tcsncpy(buf + 6,strdat + 8, 2);
|
315
|
+
buf[8] = 0x00;
|
316
|
+
return _ttol(buf);
|
317
|
+
}
|
318
|
+
//---------------------------------------------------------------------------
|
319
|
+
_TCHAR* LongToStrDate(long ldat , _TCHAR* strdat)
|
320
|
+
{ //Conver long date to string date�B
|
321
|
+
//No check long date is valid.
|
322
|
+
_TCHAR buf[11];
|
323
|
+
if (ldat == 0)
|
324
|
+
_tcscpy(strdat,_T("0000/00/00"));
|
325
|
+
else
|
326
|
+
{
|
327
|
+
_stprintf_s(buf, 11, _T("%08ld"),ldat);
|
328
|
+
|
329
|
+
_tcsncpy(strdat, buf, 4);
|
330
|
+
strdat[4] = '/';
|
331
|
+
_tcsncpy(strdat + 5, buf + 4, 2);
|
332
|
+
strdat[7] = '/';
|
333
|
+
_tcsncpy(strdat + 8, buf + 6, 2);
|
334
|
+
strdat[10] = 0x00;
|
335
|
+
}
|
336
|
+
return strdat;
|
337
|
+
}
|
338
|
+
//---------------------------------------------------------------------------
|
339
|
+
_TCHAR* LongToStrTime(long ltime , _TCHAR* strdat)
|
340
|
+
{ //Conver long time to string time�B
|
341
|
+
//No check long time is valid.
|
342
|
+
_TCHAR buf[9];
|
343
|
+
_stprintf_s(buf, 9, _T("%ld"),ltime);
|
344
|
+
_tcsncpy(strdat,buf,2);
|
345
|
+
strdat[2] = ':';
|
346
|
+
_tcsncpy(strdat + 3, buf + 2, 2);
|
347
|
+
strdat[5] = ':';
|
348
|
+
_tcsncpy(strdat + 6, buf + 4, 2);
|
349
|
+
strdat[8] = 0x00;
|
350
|
+
return strdat;
|
351
|
+
}
|
352
|
+
//---------------------------------------------------------------------------
|
353
|
+
const char* dateTimeStr(char* buf, unsigned int bufsize)
|
354
|
+
{
|
355
|
+
struct tm* date;
|
356
|
+
time_t now;
|
357
|
+
time(&now);
|
358
|
+
#ifdef __MINGW32__
|
359
|
+
date = localtime(&now);
|
360
|
+
#else
|
361
|
+
struct tm tmp;
|
362
|
+
date = &tmp;
|
363
|
+
localtime_x(date, &now);
|
364
|
+
#endif
|
365
|
+
sprintf_s(buf, bufsize, "%04d/%02d/%02d %02d:%02d:%02d"
|
366
|
+
,date->tm_year + 1900, date->tm_mon + 1,date->tm_mday
|
367
|
+
,date->tm_hour, date->tm_min, date->tm_sec);
|
368
|
+
return buf;
|
369
|
+
}
|
370
|
+
|
371
|
+
|
372
|
+
}//namespace rtl
|
373
|
+
}//namespace bzs
|
374
|
+
|
375
|
+
#pragma warning(default:4996)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#ifndef BZS_RT_DATETIME_H
|
2
|
+
#define BZS_RT_DATETIME_H
|
3
|
+
/*=================================================================
|
4
|
+
Copyright (C) 2000 2013 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
=================================================================*/
|
21
|
+
|
22
|
+
#include <bzs/env/compiler.h>
|
23
|
+
#include <bzs/env/tstring.h>
|
24
|
+
|
25
|
+
namespace bzs
|
26
|
+
{
|
27
|
+
namespace rtl
|
28
|
+
{
|
29
|
+
//---------------------------------------------------------------------------
|
30
|
+
PACKAGE int GetYear(const _TCHAR* NowDate, bool PrevMonth);
|
31
|
+
PACKAGE int GetMonth(const _TCHAR* NowDate, bool PrevMonth);
|
32
|
+
PACKAGE int GetDate(const _TCHAR* NowDate);
|
33
|
+
PACKAGE bool IsUrudosi(int Year);
|
34
|
+
PACKAGE bool GetDatefromYearSerialDays(int year, int Days, _TCHAR* date
|
35
|
+
, bool nextYearRight=false);
|
36
|
+
|
37
|
+
PACKAGE int JDate2Num(const _TCHAR* date);
|
38
|
+
|
39
|
+
#ifdef _WIN32
|
40
|
+
PACKAGE int JDate2Num(const _NTCHAR* date);
|
41
|
+
#endif
|
42
|
+
|
43
|
+
PACKAGE const _TCHAR* JNum2Date(int ldate);
|
44
|
+
|
45
|
+
PACKAGE long StrToLongDate(_TCHAR* pStrDate);
|
46
|
+
PACKAGE _TCHAR* LongToStrDate(long , _TCHAR* );
|
47
|
+
PACKAGE _TCHAR* LongToStrTime(long , _TCHAR* );
|
48
|
+
PACKAGE const char* dateTimeStr(char* buf, unsigned int bufsize);
|
49
|
+
|
50
|
+
}//namespace rtl
|
51
|
+
}//namespace bzs
|
52
|
+
|
53
|
+
#endif//BZS_RT_DATETIME_H
|
@@ -0,0 +1,106 @@
|
|
1
|
+
/*=================================================================
|
2
|
+
Copyright (C) 2012 2013 BizStation Corp All rights reserved.
|
3
|
+
|
4
|
+
This program is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU General Public License
|
6
|
+
as published by the Free Software Foundation; either version 2
|
7
|
+
of the License, or (at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
17
|
+
02111-1307, USA.
|
18
|
+
=================================================================*/
|
19
|
+
|
20
|
+
#include "debuglog.h"
|
21
|
+
#include <bzs/env/fileopen.h>
|
22
|
+
#include <algorithm>
|
23
|
+
#include <time.h>
|
24
|
+
|
25
|
+
namespace bzs
|
26
|
+
{
|
27
|
+
namespace rtl
|
28
|
+
{
|
29
|
+
|
30
|
+
#ifdef DEBUG_PROFILE
|
31
|
+
boost::timer::cpu_timer g_t;
|
32
|
+
#endif
|
33
|
+
|
34
|
+
static char datebuf[30];
|
35
|
+
|
36
|
+
debuglog* debuglog::m_ptr=NULL;
|
37
|
+
boost::mutex debuglog::m_mutex;
|
38
|
+
char debuglog::logfilename[MAX_PATH];
|
39
|
+
|
40
|
+
const char* dateTimeStr(char* buf, unsigned int bufsize)
|
41
|
+
{
|
42
|
+
struct tm* date;
|
43
|
+
time_t now;
|
44
|
+
time(&now);
|
45
|
+
struct tm tmp;
|
46
|
+
date = &tmp;
|
47
|
+
localtime_x(date, &now);
|
48
|
+
sprintf_s(buf, bufsize, "%04d/%02d/%02d %02d:%02d:%02d"
|
49
|
+
,date->tm_year + 1900, date->tm_mon + 1,date->tm_mday
|
50
|
+
,date->tm_hour, date->tm_min, date->tm_sec);
|
51
|
+
return buf;
|
52
|
+
}
|
53
|
+
|
54
|
+
const char* debuglog::dateTime()
|
55
|
+
{
|
56
|
+
return dateTimeStr(datebuf, 30);
|
57
|
+
}
|
58
|
+
|
59
|
+
void debuglog::write(const char* msg)
|
60
|
+
{
|
61
|
+
boost::mutex::scoped_lock lck(m_mutex);
|
62
|
+
FILE* fp = fileOpen(logfilename, "a+");
|
63
|
+
if (fp)
|
64
|
+
{
|
65
|
+
fputs(dateTime(), fp);
|
66
|
+
fputs(" ", fp);
|
67
|
+
fputs(msg, fp);
|
68
|
+
fclose(fp);
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
void debuglog::dump(FILE* fp, const char* p, int size, int limit)
|
74
|
+
{
|
75
|
+
size = std::min<int>(size, limit);
|
76
|
+
for (int i=0;i<size;i+=16)
|
77
|
+
{
|
78
|
+
|
79
|
+
for (int j=0;j<16;j++)
|
80
|
+
fprintf(fp, "%02X ", *((unsigned char*)(p+i+j)));
|
81
|
+
fprintf(fp, " ");
|
82
|
+
for (int j=0;j<16;j++)
|
83
|
+
fprintf(fp, "%c", *((unsigned char*)(p+i+j)));
|
84
|
+
fprintf(fp, "\n");
|
85
|
+
|
86
|
+
}
|
87
|
+
fprintf(fp, "\n");
|
88
|
+
}
|
89
|
+
|
90
|
+
void debuglog::writeDump(const char* msg, const char* ptr, int size)
|
91
|
+
{
|
92
|
+
boost::mutex::scoped_lock lck(m_mutex);
|
93
|
+
FILE* fp = fileOpen(logfilename, "a+");
|
94
|
+
if (fp)
|
95
|
+
{
|
96
|
+
fputs(msg, fp);
|
97
|
+
fputs("\n", fp);
|
98
|
+
dump(fp, ptr, size, INT_MAX);
|
99
|
+
|
100
|
+
fclose(fp);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
}//namespace rtl
|
105
|
+
}//namespace bzs
|
106
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#ifndef BZS_RL_DEBUGLOG_H
|
2
|
+
#define BZS_RL_DEBUGLOG_H
|
3
|
+
/*=================================================================
|
4
|
+
Copyright (C) 2012 2013 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
=================================================================*/
|
21
|
+
#include <boost/noncopyable.hpp>
|
22
|
+
#include <boost/thread/mutex.hpp>
|
23
|
+
#include <stdio.h>
|
24
|
+
#include <bzs/env/crosscompile.h>
|
25
|
+
#include <time.h>
|
26
|
+
#include <boost/timer/timer.hpp>
|
27
|
+
#ifdef _WIN32
|
28
|
+
#include <windows.h>
|
29
|
+
|
30
|
+
#endif
|
31
|
+
|
32
|
+
namespace bzs
|
33
|
+
{
|
34
|
+
namespace rtl
|
35
|
+
{
|
36
|
+
|
37
|
+
class debuglog : private boost::noncopyable
|
38
|
+
{
|
39
|
+
static debuglog* m_ptr;
|
40
|
+
protected:
|
41
|
+
static boost::mutex m_mutex;
|
42
|
+
static char logfilename[MAX_PATH];
|
43
|
+
|
44
|
+
public:
|
45
|
+
virtual ~debuglog(){};
|
46
|
+
virtual void stop()=0;
|
47
|
+
void write(const char* msg);
|
48
|
+
void writeDump(const char* msg, const char* ptr, int size);
|
49
|
+
static void regist(debuglog* ptr){m_ptr = ptr;};
|
50
|
+
static debuglog* get(){return m_ptr;}
|
51
|
+
static void dump(FILE* fp, const char* p, int size, int limit);
|
52
|
+
static void init();
|
53
|
+
static const char* dateTime();
|
54
|
+
|
55
|
+
};
|
56
|
+
|
57
|
+
#ifdef DEBUG_LOG
|
58
|
+
#define DEBUG_WRITELOG(MSG) debuglog::get()->write(MSG);
|
59
|
+
|
60
|
+
#else //DEBUG_LOG
|
61
|
+
#define DEBUG_WRITELOG(MSG)
|
62
|
+
#endif //DEBUG_LOG
|
63
|
+
|
64
|
+
#if defined(DEBUG_PROFILE) || defined(DEBUG_LOG)
|
65
|
+
#define DEBUG_PROFILE_INIT() bzs::rtl::debuglog::get()->init();
|
66
|
+
#define DEBUG_PROFILE_DEINIT() bzs::rtl::debuglog::get()->stop();
|
67
|
+
#else
|
68
|
+
#define DEBUG_PROFILE_INIT()
|
69
|
+
#define DEBUG_PROFILE_DEINIT()
|
70
|
+
#endif
|
71
|
+
|
72
|
+
#ifdef DEBUG_PROFILE
|
73
|
+
extern boost::timer::cpu_timer g_t;
|
74
|
+
|
75
|
+
#define DEBUG_PROFILE_START(V) if (V) bzs::rtl::g_t.start();
|
76
|
+
|
77
|
+
#define DEBUG_PROFILE_END(V, NAME) if (V) {bzs::rtl::g_t.stop(); \
|
78
|
+
char buf[256]; \
|
79
|
+
sprintf(buf, "%-20s %s\r\n",NAME, bzs::rtl::g_t.format().c_str()); \
|
80
|
+
bzs::rtl::debuglog::get()->write(buf);};
|
81
|
+
|
82
|
+
#define DEBUG_PROFILE_END_OP(V, IV) if (V){bzs::rtl::g_t.stop(); \
|
83
|
+
char buf[256]; \
|
84
|
+
sprintf(buf, "op = %-15ld %s\r\n", IV, bzs::rtl::g_t.format().c_str()); \
|
85
|
+
bzs::rtl::debuglog::get()->write(buf);};
|
86
|
+
|
87
|
+
#else //DEBUG_PROFILE
|
88
|
+
|
89
|
+
#define DEBUG_PROFILE_START(V)
|
90
|
+
#define DEBUG_PROFILE_END(V, NAME)
|
91
|
+
#define DEBUG_PROFILE_END_OP(V, IV)
|
92
|
+
|
93
|
+
#endif //DEBUG_PROFILE
|
94
|
+
|
95
|
+
}//namespace rtl
|
96
|
+
}//namespace bzs
|
97
|
+
#endif //BZS_RL_DEBUGLOG_H
|