├── .gitattributes
├── .gitignore
├── CDIR.sln
├── CDIR
├── CDIR.cpp
├── CDIR.h
├── CDIR.rc
├── CDIR.vcxproj
├── CDIR.vcxproj.filters
├── ConfigParser.cpp
├── ConfigParser.h
├── ReadMe.txt
├── WriteWrapper.cpp
├── WriteWrapper.h
├── cdir.ini
├── collector.ico
├── globals.h
├── libressl-2.5.5-windows
│ ├── include
│ │ ├── openssl
│ │ │ ├── aes.h
│ │ │ ├── asn1.h
│ │ │ ├── asn1_mac.h
│ │ │ ├── asn1t.h
│ │ │ ├── bio.h
│ │ │ ├── blowfish.h
│ │ │ ├── bn.h
│ │ │ ├── buffer.h
│ │ │ ├── camellia.h
│ │ │ ├── cast.h
│ │ │ ├── chacha.h
│ │ │ ├── cmac.h
│ │ │ ├── comp.h
│ │ │ ├── conf.h
│ │ │ ├── conf_api.h
│ │ │ ├── crypto.h
│ │ │ ├── curve25519.h
│ │ │ ├── des.h
│ │ │ ├── dh.h
│ │ │ ├── dsa.h
│ │ │ ├── dso.h
│ │ │ ├── dtls1.h
│ │ │ ├── ec.h
│ │ │ ├── ecdh.h
│ │ │ ├── ecdsa.h
│ │ │ ├── engine.h
│ │ │ ├── err.h
│ │ │ ├── evp.h
│ │ │ ├── gost.h
│ │ │ ├── hmac.h
│ │ │ ├── idea.h
│ │ │ ├── lhash.h
│ │ │ ├── md4.h
│ │ │ ├── md5.h
│ │ │ ├── modes.h
│ │ │ ├── obj_mac.h
│ │ │ ├── objects.h
│ │ │ ├── ocsp.h
│ │ │ ├── opensslconf.h
│ │ │ ├── opensslfeatures.h
│ │ │ ├── opensslv.h
│ │ │ ├── ossl_typ.h
│ │ │ ├── pem.h
│ │ │ ├── pem2.h
│ │ │ ├── pkcs12.h
│ │ │ ├── pkcs7.h
│ │ │ ├── poly1305.h
│ │ │ ├── rand.h
│ │ │ ├── rc2.h
│ │ │ ├── rc4.h
│ │ │ ├── ripemd.h
│ │ │ ├── rsa.h
│ │ │ ├── safestack.h
│ │ │ ├── sha.h
│ │ │ ├── srtp.h
│ │ │ ├── ssl.h
│ │ │ ├── ssl2.h
│ │ │ ├── ssl23.h
│ │ │ ├── ssl3.h
│ │ │ ├── stack.h
│ │ │ ├── tls1.h
│ │ │ ├── ts.h
│ │ │ ├── txt_db.h
│ │ │ ├── ui.h
│ │ │ ├── ui_compat.h
│ │ │ ├── whrlpool.h
│ │ │ ├── x509.h
│ │ │ ├── x509_vfy.h
│ │ │ └── x509v3.h
│ │ └── tls.h
│ ├── x64
│ │ ├── libcrypto-41.dll
│ │ ├── libcrypto-41.exp
│ │ ├── libcrypto-41.lib
│ │ ├── libssl-43.dll
│ │ ├── libssl-43.exp
│ │ ├── libssl-43.lib
│ │ ├── libtls-15.dll
│ │ ├── libtls-15.exp
│ │ ├── libtls-15.lib
│ │ ├── ocspcheck.exe
│ │ └── openssl.exe
│ └── x86
│ │ ├── libcrypto-41.dll
│ │ ├── libcrypto-41.exp
│ │ ├── libcrypto-41.lib
│ │ ├── libssl-43.dll
│ │ ├── libssl-43.exp
│ │ ├── libssl-43.lib
│ │ ├── libtls-15.dll
│ │ ├── libtls-15.exp
│ │ ├── libtls-15.lib
│ │ ├── ocspcheck.exe
│ │ └── openssl.exe
├── resource.h
├── stdafx.cpp
├── stdafx.h
├── targetver.h
├── util.cpp
├── util.h
├── winpmem_x64.exe
└── winpmem_x86.exe
├── LICENSE.txt
├── NTFSParserDLL
├── NTFS.h
├── NTFSParserDLL.cpp
├── NTFSParserDLL.vcxproj
├── NTFSParserDLL.vcxproj.filters
├── NTFS_Attribute.h
├── NTFS_Common.h
├── NTFS_DataType.h
├── NTFS_FileRecord.h
├── ReadMe.txt
├── dllmain.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── README.md
└── README_en.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | CDIR/x64/
19 | CDIR/x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | # DNX
42 | project.lock.json
43 | artifacts/
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | *.pch
52 | *.pdb
53 | *.pgc
54 | *.pgd
55 | *.rsp
56 | *.sbr
57 | *.tlb
58 | *.tli
59 | *.tlh
60 | *.tmp
61 | *.tmp_proj
62 | *.log
63 | *.vspscc
64 | *.vssscc
65 | .builds
66 | *.pidb
67 | *.svclog
68 | *.scc
69 |
70 | # Chutzpah Test files
71 | _Chutzpah*
72 |
73 | # Visual C++ cache files
74 | ipch/
75 | *.aps
76 | *.ncb
77 | *.opensdf
78 | *.sdf
79 | *.cachefile
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 | *.vspx
85 |
86 | # TFS 2012 Local Workspace
87 | $tf/
88 |
89 | # Guidance Automation Toolkit
90 | *.gpState
91 |
92 | # ReSharper is a .NET coding add-in
93 | _ReSharper*/
94 | *.[Rr]e[Ss]harper
95 | *.DotSettings.user
96 |
97 | # JustCode is a .NET coding add-in
98 | .JustCode
99 |
100 | # TeamCity is a build add-in
101 | _TeamCity*
102 |
103 | # DotCover is a Code Coverage Tool
104 | *.dotCover
105 |
106 | # NCrunch
107 | _NCrunch_*
108 | .*crunch*.local.xml
109 |
110 | # MightyMoose
111 | *.mm.*
112 | AutoTest.Net/
113 |
114 | # Web workbench (sass)
115 | .sass-cache/
116 |
117 | # Installshield output folder
118 | [Ee]xpress/
119 |
120 | # DocProject is a documentation generator add-in
121 | DocProject/buildhelp/
122 | DocProject/Help/*.HxT
123 | DocProject/Help/*.HxC
124 | DocProject/Help/*.hhc
125 | DocProject/Help/*.hhk
126 | DocProject/Help/*.hhp
127 | DocProject/Help/Html2
128 | DocProject/Help/html
129 |
130 | # Click-Once directory
131 | publish/
132 |
133 | # Publish Web Output
134 | *.[Pp]ublish.xml
135 | *.azurePubxml
136 | ## TODO: Comment the next line if you want to checkin your
137 | ## web deploy settings but do note that will include unencrypted
138 | ## passwords
139 | #*.pubxml
140 |
141 | *.publishproj
142 |
143 | # NuGet Packages
144 | *.nupkg
145 | # The packages folder can be ignored because of Package Restore
146 | **/packages/*
147 | # except build/, which is used as an MSBuild target.
148 | !**/packages/build/
149 | # Uncomment if necessary however generally it will be regenerated when needed
150 | #!**/packages/repositories.config
151 |
152 | # Windows Azure Build Output
153 | csx/
154 | *.build.csdef
155 |
156 | # Windows Store app package directory
157 | AppPackages/
158 |
159 | # Visual Studio cache files
160 | # files ending in .cache can be ignored
161 | *.[Cc]ache
162 | # but keep track of directories ending in .cache
163 | !*.[Cc]ache/
164 |
165 | # Others
166 | ClientBin/
167 | [Ss]tyle[Cc]op.*
168 | ~$*
169 | *~
170 | *.dbmdl
171 | *.dbproj.schemaview
172 | *.pfx
173 | *.publishsettings
174 | node_modules/
175 | orleans.codegen.cs
176 |
177 | # RIA/Silverlight projects
178 | Generated_Code/
179 |
180 | # Backup & report files from converting an old project file
181 | # to a newer Visual Studio version. Backup files are not needed,
182 | # because we have git ;-)
183 | _UpgradeReport_Files/
184 | Backup*/
185 | UpgradeLog*.XML
186 | UpgradeLog*.htm
187 |
188 | # SQL Server files
189 | *.mdf
190 | *.ldf
191 |
192 | # Business Intelligence projects
193 | *.rdl.data
194 | *.bim.layout
195 | *.bim_*.settings
196 |
197 | # Microsoft Fakes
198 | FakesAssemblies/
199 |
200 | # Node.js Tools for Visual Studio
201 | .ntvs_analysis.dat
202 |
203 | # Visual Studio 6 build log
204 | *.plg
205 |
206 | # Visual Studio 6 workspace options file
207 | *.opt
208 |
209 | # LightSwitch generated files
210 | GeneratedArtifacts/
211 | _Pvt_Extensions/
212 | ModelManifest.xml
213 | /CDIR.VC.db
214 | /CDIR.VC.VC.opendb
215 |
--------------------------------------------------------------------------------
/CDIR.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdir-collector", "CDIR\CDIR.vcxproj", "{06718832-98E4-4A84-82C3-9F5678C326E5}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0} = {5E42B778-F231-4797-B7FD-7D5BCA9738D0}
9 | EndProjectSection
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NTFSParserDLL", "NTFSParserDLL\NTFSParserDLL.vcxproj", "{5E42B778-F231-4797-B7FD-7D5BCA9738D0}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|x64 = Debug|x64
16 | Debug|x86 = Debug|x86
17 | Release|x64 = Release|x64
18 | Release|x86 = Release|x86
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Debug|x64.ActiveCfg = Debug|x64
22 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Debug|x64.Build.0 = Debug|x64
23 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Debug|x86.ActiveCfg = Debug|Win32
24 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Debug|x86.Build.0 = Debug|Win32
25 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Debug|x86.Deploy.0 = Debug|Win32
26 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Release|x64.ActiveCfg = Release|x64
27 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Release|x64.Build.0 = Release|x64
28 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Release|x86.ActiveCfg = Release|Win32
29 | {06718832-98E4-4A84-82C3-9F5678C326E5}.Release|x86.Build.0 = Release|Win32
30 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Debug|x64.ActiveCfg = Debug|x64
31 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Debug|x64.Build.0 = Debug|x64
32 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Debug|x86.ActiveCfg = Debug|Win32
33 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Debug|x86.Build.0 = Debug|Win32
34 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Release|x64.ActiveCfg = Release|x64
35 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Release|x64.Build.0 = Release|x64
36 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Release|x86.ActiveCfg = Release|Win32
37 | {5E42B778-F231-4797-B7FD-7D5BCA9738D0}.Release|x86.Build.0 = Release|Win32
38 | EndGlobalSection
39 | GlobalSection(SolutionProperties) = preSolution
40 | HideSolutionNode = FALSE
41 | EndGlobalSection
42 | EndGlobal
43 |
--------------------------------------------------------------------------------
/CDIR/CDIR.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "..\NTFSParserDLL\NTFS.h"
4 | #include "..\NTFSParserDLL\NTFS_DataType.h"
5 |
6 | struct FileInfo_t
7 | {
8 | CNTFSVolume* volume;
9 | CFileRecord* fileRecord;
10 | CIndexEntry* indexEntry;
11 | CAttrBase* data;
12 | };
--------------------------------------------------------------------------------
/CDIR/CDIR.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 |
5 | #include "resource.h"
6 |
7 | #define APSTUDIO_READONLY_SYMBOLS
8 | /////////////////////////////////////////////////////////////////////////////
9 | //
10 | // Generated from the TEXTINCLUDE 2 resource.
11 | //
12 | #include "winres.h"
13 |
14 | /////////////////////////////////////////////////////////////////////////////
15 | #undef APSTUDIO_READONLY_SYMBOLS
16 |
17 | /////////////////////////////////////////////////////////////////////////////
18 | // 日本語 (日本) resources
19 |
20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
21 | LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
22 |
23 | #ifdef APSTUDIO_INVOKED
24 | /////////////////////////////////////////////////////////////////////////////
25 | //
26 | // TEXTINCLUDE
27 | //
28 |
29 | 1 TEXTINCLUDE
30 | BEGIN
31 | "resource.h\0"
32 | END
33 |
34 | 2 TEXTINCLUDE
35 | BEGIN
36 | "#include ""winres.h""\r\n"
37 | "\0"
38 | END
39 |
40 | 3 TEXTINCLUDE
41 | BEGIN
42 | "\r\n"
43 | "\0"
44 | END
45 |
46 | #endif // APSTUDIO_INVOKED
47 |
48 |
49 | /////////////////////////////////////////////////////////////////////////////
50 | //
51 | // Icon
52 | //
53 |
54 | // Icon with lowest ID value placed first to ensure application icon
55 | // remains consistent on all systems.
56 | IDI_ICON1 ICON "collector.ico"
57 |
58 |
59 | /////////////////////////////////////////////////////////////////////////////
60 | //
61 | // Version
62 | //
63 |
64 | VS_VERSION_INFO VERSIONINFO
65 | FILEVERSION 1,3,7,0
66 | PRODUCTVERSION 1,3,7,0
67 | FILEFLAGSMASK 0x3fL
68 | #ifdef _DEBUG
69 | FILEFLAGS 0x1L
70 | #else
71 | FILEFLAGS 0x0L
72 | #endif
73 | FILEOS 0x40004L
74 | FILETYPE 0x1L
75 | FILESUBTYPE 0x0L
76 | BEGIN
77 | BLOCK "StringFileInfo"
78 | BEGIN
79 | BLOCK "041104b0"
80 | BEGIN
81 | VALUE "CompanyName", "Cyber Defense Institute, Inc."
82 | VALUE "FileDescription", "Data Collection Tool for Incident Response"
83 | VALUE "FileVersion", "1.3.7.0"
84 | VALUE "InternalName", "cdir-collector.exe"
85 | VALUE "LegalCopyright", "Copyright (C) 2024 Cyber Defense Institute"
86 | VALUE "OriginalFilename", "cdir-collector.exe"
87 | VALUE "ProductName", "CDIR Collector"
88 | VALUE "ProductVersion", "1.3.7.0"
89 | END
90 | END
91 | BLOCK "VarFileInfo"
92 | BEGIN
93 | VALUE "Translation", 0x411, 1200
94 | END
95 | END
96 |
97 | #endif // 日本語 (日本) resources
98 | /////////////////////////////////////////////////////////////////////////////
99 |
100 |
101 |
102 | #ifndef APSTUDIO_INVOKED
103 | /////////////////////////////////////////////////////////////////////////////
104 | //
105 | // Generated from the TEXTINCLUDE 3 resource.
106 | //
107 |
108 |
109 | /////////////////////////////////////////////////////////////////////////////
110 | #endif // not APSTUDIO_INVOKED
111 |
112 |
--------------------------------------------------------------------------------
/CDIR/CDIR.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ヘッダー ファイル
23 |
24 |
25 | ヘッダー ファイル
26 |
27 |
28 | ヘッダー ファイル
29 |
30 |
31 | ヘッダー ファイル
32 |
33 |
34 | ヘッダー ファイル
35 |
36 |
37 | ヘッダー ファイル
38 |
39 |
40 | ヘッダー ファイル
41 |
42 |
43 | ヘッダー ファイル
44 |
45 |
46 |
47 |
48 | ソース ファイル
49 |
50 |
51 | ソース ファイル
52 |
53 |
54 | ソース ファイル
55 |
56 |
57 | ソース ファイル
58 |
59 |
60 | ソース ファイル
61 |
62 |
63 |
64 |
65 | リソース ファイル
66 |
67 |
68 |
69 |
70 | リソース ファイル
71 |
72 |
73 | リソース ファイル
74 |
75 |
76 |
77 |
78 | リソース ファイル
79 |
80 |
81 |
--------------------------------------------------------------------------------
/CDIR/ConfigParser.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "ConfigParser.h"
3 | #include "util.h"
4 |
5 | #include
6 | #include
7 |
8 |
9 | ConfigParser::ConfigParser(string path)
10 | {
11 | ifstream file(path);
12 | string l;
13 | if (file.is_open()) {
14 | opened = true;
15 | while (getline(file, l)) {
16 | size_t idx;
17 | // check if comment
18 | for (idx = 0; idx < l.size() && isspace(l[idx]); idx++);
19 | if (l[idx] == '#' || l[idx] == ';') continue;
20 |
21 | if ((idx = l.find_first_of('=')) != string::npos) {
22 | string key = l.substr(0, idx);
23 | string val = l.substr(idx+1);
24 |
25 | // trim key string
26 | key = trim(key);
27 |
28 | if (CONFIGLIST.find(key) != CONFIGLIST.end()) {
29 | Value value;
30 | value.type = CONFIGLIST[key];
31 | switch (CONFIGLIST[key]) {
32 | case TYPE_BOOL:
33 | value.ptr = new bool;
34 | val = trim(val);
35 | *((bool*)value.ptr) = [=]() {
36 | if (_stricmp("true", val.c_str()) == 0) {
37 | return true;
38 | }
39 | if (_stricmp("false", val.c_str()) == 0) {
40 | return false;
41 | }
42 | if (strcmp("1", val.c_str()) == 0) {
43 | return true;
44 | }
45 | if (strcmp("0", val.c_str()) == 0) {
46 | return false;
47 | }
48 | cerr << msg("パースエラー",
49 | "parse error.") << endl;
50 | cerr << key + " " + "(1:ON 2:OFF 0:EXIT)" << endl << "> ";
51 | int input; cin >> input;
52 | if (!input) __exit(EXIT_SUCCESS);
53 |
54 | return (input == 1) ? true : false;
55 | }();
56 |
57 | break;
58 | case TYPE_INT:
59 | value.ptr = new int;
60 | val = trim(val);
61 | *((int*)value.ptr) = atoi(val.c_str());
62 | break;
63 | case TYPE_STRING:
64 | value.ptr = new string;
65 | for (idx = 0; idx < val.size() && isspace(val[idx]); idx++);
66 | *((string*)value.ptr) = val.substr(idx);
67 | break;
68 | }
69 | m[key] = value;
70 | }
71 | }
72 | }
73 | //for (auto &it : CONFIGLIST) {
74 | // cout << it.first << endl;
75 | //}
76 | }
77 | else {
78 | opened = false;
79 | }
80 | }
81 |
82 |
83 | ConfigParser::~ConfigParser()
84 | {
85 | }
86 |
87 | bool ConfigParser::isOpened() {
88 | return opened;
89 | }
90 |
91 |
92 | bool ConfigParser::isSet(string key) {
93 | return m.find(key) != m.end();
94 | }
95 |
96 |
97 | Value ConfigParser::getValue(string key) {
98 | if (m.find(key) != m.end()) {
99 | return m[key];
100 | }
101 | else {
102 | cerr << key << msg("は定義されていません", " is undefined") << endl;
103 | cerr << key + " " + "(1:ON 2:OFF 0:EXIT)" << endl << "> ";
104 | int input; cin >> input;
105 | if (!input) __exit(EXIT_SUCCESS);
106 | Value val;
107 | val.type = TYPE_BOOL;
108 | val.ptr = new bool;
109 | CASTVAL(bool,val) = (input == 1) ? true : false;
110 | return val;
111 | }
112 | }
113 |
114 | string ConfigParser::trim(string &str) {
115 | size_t beg, end;
116 | for (beg = 0; beg < str.size() && isspace(str[beg]); beg++);
117 | for (end = beg; end < str.size() && !isspace(str[end]); end++);
118 | str = str.substr(beg, end - beg);
119 | return str;
120 | }
--------------------------------------------------------------------------------
/CDIR/ConfigParser.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include